Rev 244 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 244 | Rev 380 | ||
---|---|---|---|
1 | #ifndef _FIFO_H_ |
1 | #ifndef _FIFO_H_ |
2 | #define _FIFO_H_ |
2 | #define _FIFO_H_ |
3 | 3 | ||
4 | #include <stdio.h> |
4 | #include <stdio.h> |
5 | #include "91x_lib.h" |
5 | #include "91x_lib.h" |
6 | #define NO_ITLine 0xFFFF |
6 | #define NO_ITLine 0xFFFF |
7 | 7 | ||
8 | // the fifo object |
8 | // the fifo object |
9 | typedef struct |
9 | typedef struct |
10 | { |
10 | { |
11 | u8 *buffer; // pointer to start of the ringbuffer |
11 | u8 *buffer; // pointer to start of the ringbuffer |
12 | u16 count; // number of bytes in FIFO |
12 | u16 count; // number of bytes in FIFO |
13 | u16 size; // buffer size |
13 | u16 size; // buffer size |
14 | u8 *pread; // read pointer |
14 | u8 *pread; // read pointer |
15 | u8 *pwrite; // write pointer |
15 | u8 *pwrite; // write pointer |
16 | u16 putvicsource; // IRQ source to block, during put |
16 | u16 putvicsource; // IRQ source to block, during put |
17 | u16 getvicsource; // IRQ source to block, during get |
17 | u16 getvicsource; // IRQ source to block, during get |
18 | } fifo_t; |
18 | } fifo_t; |
- | 19 | ||
19 | 20 | extern fifo_t UART1_rx_fifo; |
|
20 | /* |
21 | /* |
21 | The initialization of the FIFO sets the read/write pointers etc.. |
22 | The initialization of the FIFO sets the read/write pointers etc.. |
22 | The FIFO uses the buffer 'buf' which byte length must 'size'. |
23 | The FIFO uses the buffer 'buf' which byte length must 'size'. |
23 | Returns 1 on success ans 0 in case of an error. |
24 | Returns 1 on success ans 0 in case of an error. |
24 | */ |
25 | */ |
25 | u8 fifo_init (fifo_t* f, u8* buffer, const u16 size, u16 putvicsource, u16 getvicsource); |
26 | u8 fifo_init (fifo_t* f, u8* buffer, const u16 size, u16 putvicsource, u16 getvicsource); |
26 | 27 | ||
27 | /* |
28 | /* |
28 | Puts a byte into the FIFO. Returns 1 on success and 0 in case of FIFO overflow. |
29 | Puts a byte into the FIFO. Returns 1 on success and 0 in case of FIFO overflow. |
29 | */ |
30 | */ |
30 | u8 fifo_put (fifo_t* f, const u8 data); |
31 | u8 fifo_put (fifo_t* f, const u8 data); |
31 | 32 | ||
32 | /* |
33 | /* |
33 | Get the next byte from the FIFO. Returns 0 if the FIFO is empty. |
34 | Get the next byte from the FIFO. Returns 0 if the FIFO is empty. |
34 | */ |
35 | */ |
35 | u8 fifo_get (fifo_t* f, u8* pdata); |
36 | u8 fifo_get (fifo_t* f, u8* pdata); |
36 | 37 | ||
37 | /* |
38 | /* |
38 | Get the next byte out of the FIFO. If the FIFO is empty the function blocks |
39 | Get the next byte out of the FIFO. If the FIFO is empty the function blocks |
39 | until the next byte is put into the FIFO. |
40 | until the next byte is put into the FIFO. |
40 | */ |
41 | */ |
41 | u8 fifo_get_wait (fifo_t* f, u8* pdata); |
42 | u8 fifo_get_wait (fifo_t* f, u8* pdata); |
42 | 43 | ||
43 | /* |
44 | /* |
44 | Purges the FIFO so that it is empty afterwards |
45 | Purges the FIFO so that it is empty afterwards |
45 | */ |
46 | */ |
46 | void fifo_purge (fifo_t* f); |
47 | void fifo_purge (fifo_t* f); |
47 | 48 | ||
48 | #endif /* _FIFO_H_ */ |
49 | #endif /* _FIFO_H_ */ |
49 | 50 |