fifo.h 807 B

123456789101112131415161718192021222324252627282930313233343536
  1. #ifndef FIFO_H_
  2. #define FIFO_H_
  3. #include "stdint.h"
  4. #include "sys.h"
  5. #define COMMAND_NUM 10
  6. #define NAME_WIDTH 48
  7. #define COMMAND_WIDTH 96
  8. #define FIFO_OK 1
  9. #define FIFO_ERROR -1
  10. struct fifo_data{
  11. u16 length;
  12. u8* buf;
  13. };
  14. typedef struct FIFO {
  15. char name_buffer[COMMAND_NUM][NAME_WIDTH];
  16. char command_buffer[COMMAND_NUM][COMMAND_WIDTH];
  17. struct fifo_data* data[COMMAND_NUM];
  18. unsigned int head;
  19. unsigned int tail;
  20. unsigned int size;
  21. }FIFO;
  22. int FIFO_isEmpty (struct FIFO *Fifo);
  23. void FIFO_Init (struct FIFO *Fifo);
  24. void FIFO_Empty (struct FIFO *Fifo);
  25. int FIFO_Put (struct FIFO *Fifo, char* name, char* command);
  26. int FIFO_Get (struct FIFO *Fifo, char* name, char* command);
  27. void fifo_put_data(struct FIFO *Fifo, struct fifo_data* data);
  28. struct fifo_data* fifo_get_data(struct FIFO *Fifo);
  29. #endif