fifo.h 611 B

1234567891011121314151617181920212223242526
  1. #ifndef _FIFO_H_
  2. #define _FIFO_H_
  3. #include "../User/gd32f10x_it.h"
  4. #define MAXSIZE 8
  5. typedef struct _fifo_data_{
  6. uint8_t da[256];
  7. uint8_t len;
  8. }__attribute__((packed))fifoDa;
  9. typedef struct _fifo_{
  10. fifoDa memory[8];
  11. uint8_t front;
  12. uint8_t rear;
  13. bool flag;
  14. }__attribute__((packed)) FIFO_T;
  15. extern FIFO_T g_rxfifo;
  16. extern FIFO_T g_txfifo;
  17. extern void init_fifo(FIFO_T *fifo);
  18. extern bool fifo_is_full(FIFO_T *fifo);
  19. extern bool fifo_is_empty(FIFO_T *fifo);
  20. extern uint8_t fifo_write(FIFO_T *fifo,uint8_t *data,uint8_t len);
  21. extern uint8_t fifo_read(FIFO_T *fifo,uint8_t *data);
  22. #endif