Firmware SDK
twr_fifo.h
1 #ifndef _TWR_FIFO_H
2 #define _TWR_FIFO_H
3 
4 #include <twr_common.h>
5 
9 
11 
12 typedef struct
13 {
15  void *buffer;
16 
18  size_t size;
19 
21  size_t head;
22 
24  size_t tail;
25 
26 } twr_fifo_t;
27 
32 
33 void twr_fifo_init(twr_fifo_t *fifo, void *buffer, size_t size);
34 
37 
38 void twr_fifo_purge(twr_fifo_t *fifo);
39 
45 
46 size_t twr_fifo_write(twr_fifo_t *fifo, const void *buffer, size_t length);
47 
53 
54 size_t twr_fifo_read(twr_fifo_t *fifo, void *buffer, size_t length);
55 
61 
62 size_t twr_fifo_irq_write(twr_fifo_t *fifo, const void *buffer, size_t length);
63 
69 
70 size_t twr_fifo_irq_read(twr_fifo_t *fifo, void *buffer, size_t length);
71 
76 
77 bool twr_fifo_is_empty(twr_fifo_t *fifo);
78 
80 
81 #endif // _TWR_FIFO_H
size_t twr_fifo_irq_read(twr_fifo_t *fifo, void *buffer, size_t length)
Read data from FIFO from interrupt.
Definition: twr_fifo.c:133
void twr_fifo_purge(twr_fifo_t *fifo)
Purge FIFO buffer.
Definition: twr_fifo.c:12
size_t twr_fifo_write(twr_fifo_t *fifo, const void *buffer, size_t length)
Write data to FIFO.
Definition: twr_fifo.c:18
bool twr_fifo_is_empty(twr_fifo_t *fifo)
Is empty.
Definition: twr_fifo.c:161
size_t twr_fifo_irq_write(twr_fifo_t *fifo, const void *buffer, size_t length)
Write data to FIFO from interrupt.
Definition: twr_fifo.c:101
size_t twr_fifo_read(twr_fifo_t *fifo, void *buffer, size_t length)
Read data from FIFO.
Definition: twr_fifo.c:63
void twr_fifo_init(twr_fifo_t *fifo, void *buffer, size_t size)
Initialize FIFO buffer.
Definition: twr_fifo.c:4
Structure of FIFO instance.
Definition: twr_fifo.h:13
void * buffer
Pointer to buffer where FIFO holds data.
Definition: twr_fifo.h:15
size_t head
Position of FIFO's head.
Definition: twr_fifo.h:21
size_t tail
Position of FIFO's tail.
Definition: twr_fifo.h:24
size_t size
Size of buffer where FIFO holds data.
Definition: twr_fifo.h:18