How would I implement that? In the attached example, the array 'buffer' is defined in the structure with the constant FIFO_SIZE...which would need to vary somehow depending on TX_BUFFER_SIZE or RX_BUFFER_SIZE.
There could be up to 8 FIFO's used...
Thanks much!
Code: Select all
program StructTest
'receive and transmit buffers have different sizes:
const TX_BUFFER_SIZE = 32
const RX_BUFFER_SIZE = 128
'Buffer structure is the same in both RX and TX:
Structure FIFO_s
dim head as word ' index of oldest data in buffer (tail)
dim tail as word ' index of newest data in buffer (head)
dim num_elements as word ' number of bytes/words currently in buffer
dim not_empty_flag as byte volatile ' this flag is automatically set and cleared by the software buffer
dim full_flag as byte volatile ' this flag is automatically set and cleared by the software buffer
dim ovf_flag as byte volatile ' this flag is not automatically cleared by the software buffer
'Dimension buffer with TX or RX buffer size constant:
dim buffer as byte[FIFO_SIZE] ' FIFO buffer
end structure
'Define the buffers here:
Dim RX_Buffer as FIFO_s
Dim TX_Buffer as FIFO_s
main:
'Assign values to test structure:
RX_Buffer.num_elements = 16
TX_Buffer.head = 3
while(1)
wend
end.