Modified the PIC port MS/TP RS-485 handling to use an interrupt safe FIFO library (untested).

This commit is contained in:
skarg
2008-11-28 13:37:42 +00:00
parent 858adac724
commit 63f3f77552
5 changed files with 90 additions and 98 deletions
+39
View File
@@ -65,6 +65,19 @@ static bool FIFO_Full (
return (b ? (FIFO_Count(b) == b->buffer_len) : true);
}
/****************************************************************************
* DESCRIPTION: Tests to see if space is available
* RETURN: true if the number of bytes is available
* ALGORITHM: none
* NOTES: none
*****************************************************************************/
static bool FIFO_Available (
FIFO_BUFFER const *b,
unsigned count)
{
return (b ? (count < (b->buffer_len - FIFO_Count(b))) : false);
}
/****************************************************************************
* DESCRIPTION: Returns the empty/full status of the ring buffer
* RETURN: true if the ring buffer is empty, false if it is not.
@@ -135,6 +148,32 @@ bool FIFO_Put(
return status;
}
/****************************************************************************
* DESCRIPTION: Adds one or more elements of data to the FIFO
* RETURN: true if space available and added, false if not added
* ALGORITHM: none
* NOTES: none
*****************************************************************************/
bool FIFO_Add(
FIFO_BUFFER * b,
uint8_t *data_bytes,
unsigned count)
{
bool status = false; /* return value */
/* limit the ring to prevent overwriting */
if (FIFO_Available (b, count)) {
while (count) {
b->buffer[b->head % b->buffer_len] = data_byte;
b->head++;
count--;
}
status = true;
}
return status;
}
/****************************************************************************
* DESCRIPTION: Configures the ring buffer
* RETURN: none