Debian Codegraph @

contrib/ports/unix/port/include/netif/fifo.h

raw
1 #ifndef FIFO_H
2 #define FIFO_H
3
4 #include "lwip/sys.h"
5
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9
10 /** How many bytes in fifo */
11 #define FIFOSIZE 2048
12
13 /** fifo data structure, this one is passed to all fifo functions */
14 typedef struct fifo_t {
15 u8_t data[FIFOSIZE+10]; /* data segment, +10 is a hack probably not needed.. FIXME! */
16 int dataslot; /* index to next char to be read */
17 int emptyslot; /* index to next empty slot */
18 int len; /* len probably not needed, may be calculated from dataslot and emptyslot in conjunction with FIFOSIZE */
19
20 sys_sem_t sem; /* semaphore protecting simultaneous data manipulation */
21 sys_sem_t getSem; /* sepaphore used to signal new data if getWaiting is set */
22 u8_t getWaiting; /* flag used to indicate that fifoget is waiting for data. fifoput is supposed to clear */
23 /* this flag prior to signaling the getSem semaphore */
24 } fifo_t;
25
26
27 /**
28 * Get a character from fifo
29 * Blocking call.
30 * @param fifo pointer to fifo data structure
31 * @return character read from fifo
32 */
33 u8_t fifoGet(fifo_t * fifo);
34
35 /**
36 * Get a character from fifo
37 * Non blocking call.
38 * @param fifo pointer to fifo data structure
39 * @return character read from fifo, or < zero if non was available
40 */
41 s16_t fifoGetNonBlock(fifo_t * fifo);
42
43 /**
44 * fifoput is called by the signalhandler when new data has arrived (or some other event is indicated)
45 * fifoput reads directly from the serialport and is thus highly dependent on unix arch at this moment
46 * @param fifo pointer to fifo data structure
47 * @param fd unix file descriptor
48 */
49 void fifoPut(fifo_t * fifo, int fd);
50
51 /**
52 * fifoinit initiate fifo
53 * @param fifo pointer to fifo data structure, allocated by the user
54 */
55 void fifoInit(fifo_t * fifo);
56
57 #ifdef __cplusplus
58 }
59 #endif
60
61 #endif
62