A simple fifo for data
fifo.h@0:3c704483eb79, 2014-05-21 (annotated)
- Committer:
- gert_lauritsen
- Date:
- Wed May 21 18:30:45 2014 +0000
- Revision:
- 0:3c704483eb79
Just a simple Fifo
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gert_lauritsen | 0:3c704483eb79 | 1 | #ifndef FIFO_H_ |
gert_lauritsen | 0:3c704483eb79 | 2 | #define FIFO_H_ |
gert_lauritsen | 0:3c704483eb79 | 3 | |
gert_lauritsen | 0:3c704483eb79 | 4 | #include "LPC17xx.h" |
gert_lauritsen | 0:3c704483eb79 | 5 | |
gert_lauritsen | 0:3c704483eb79 | 6 | #define FIFO_SIZE 256 |
gert_lauritsen | 0:3c704483eb79 | 7 | #define FIFO_TYPE uint8_t |
gert_lauritsen | 0:3c704483eb79 | 8 | |
gert_lauritsen | 0:3c704483eb79 | 9 | class fifo |
gert_lauritsen | 0:3c704483eb79 | 10 | { |
gert_lauritsen | 0:3c704483eb79 | 11 | FIFO_TYPE buffer[FIFO_SIZE]; |
gert_lauritsen | 0:3c704483eb79 | 12 | uint32_t head, tail; |
gert_lauritsen | 0:3c704483eb79 | 13 | |
gert_lauritsen | 0:3c704483eb79 | 14 | public: |
gert_lauritsen | 0:3c704483eb79 | 15 | fifo(); |
gert_lauritsen | 0:3c704483eb79 | 16 | uint8_t put(FIFO_TYPE data);// returns 0 on success |
gert_lauritsen | 0:3c704483eb79 | 17 | uint8_t get(FIFO_TYPE* data); |
gert_lauritsen | 0:3c704483eb79 | 18 | uint32_t available(); |
gert_lauritsen | 0:3c704483eb79 | 19 | uint32_t free(); |
gert_lauritsen | 0:3c704483eb79 | 20 | }; |
gert_lauritsen | 0:3c704483eb79 | 21 | |
gert_lauritsen | 0:3c704483eb79 | 22 | |
gert_lauritsen | 0:3c704483eb79 | 23 | #endif /* FIFO_H_ */ |