24 for (
size_t i = 0; i < length; i++)
35 if (((fifo->
head + 1) == fifo->
size) && (fifo->
tail == 0))
44 *((uint8_t *) fifo->
buffer + fifo->
head) = *(uint8_t *) buffer;
46 buffer = (uint8_t *) buffer + 1;
69 for (
size_t i = 0; i < length; i++)
73 *(uint8_t *) buffer = *((uint8_t *) fifo->
buffer + fifo->
tail);
75 buffer = (uint8_t *) buffer + 1;
103 for (
size_t i = 0; i < length; i++)
111 if (((fifo->
head + 1) == fifo->
size) && (fifo->
tail == 0))
117 *((uint8_t *) fifo->
buffer + fifo->
head) = *(uint8_t *) buffer;
119 buffer = (uint8_t *) buffer + 1;
135 for (
size_t i = 0; i < length; i++)
139 *(uint8_t *) buffer = *((uint8_t *) fifo->
buffer + fifo->
tail);
141 buffer = (uint8_t *) buffer + 1;
165 bool result = fifo->
tail == fifo->
head;
size_t twr_fifo_irq_read(twr_fifo_t *fifo, void *buffer, size_t length)
Read data from FIFO from interrupt.
void twr_fifo_purge(twr_fifo_t *fifo)
Purge FIFO buffer.
size_t twr_fifo_write(twr_fifo_t *fifo, const void *buffer, size_t length)
Write data to FIFO.
bool twr_fifo_is_empty(twr_fifo_t *fifo)
Is empty.
size_t twr_fifo_irq_write(twr_fifo_t *fifo, const void *buffer, size_t length)
Write data to FIFO from interrupt.
size_t twr_fifo_read(twr_fifo_t *fifo, void *buffer, size_t length)
Read data from FIFO.
void twr_fifo_init(twr_fifo_t *fifo, void *buffer, size_t size)
Initialize FIFO buffer.
void twr_irq_disable(void)
Disable interrupt requests globally (call can be nested)
void twr_irq_enable(void)
Enable interrupt requests globally (call can be nested)
Structure of FIFO instance.
void * buffer
Pointer to buffer where FIFO holds data.
size_t head
Position of FIFO's head.
size_t tail
Position of FIFO's tail.
size_t size
Size of buffer where FIFO holds data.