fifo.h 675 B

1234567891011121314151617181920212223242526272829
  1. /*
  2. * fifo.h
  3. *
  4. * Created on: Jan 17, 2022
  5. * Author: radioman
  6. */
  7. #ifndef INC_FIFO_H_
  8. #define INC_FIFO_H_
  9. #include <stdint.h>
  10. typedef enum { FIFO_EMPTY, FIFO_READY, FIFO_FULL } FIFO_StateTypeDef;
  11. typedef struct {
  12. uint32_t head;
  13. uint32_t tail;
  14. uint32_t size;
  15. FIFO_StateTypeDef state;
  16. uint8_t *data;
  17. } FIFO_HandleTypeDef;
  18. void fifo_init(FIFO_HandleTypeDef *fifo, uint8_t *buffer, uint32_t size);
  19. FIFO_StateTypeDef fifo_state(FIFO_HandleTypeDef *fifo);
  20. int fifo_read(FIFO_HandleTypeDef *fifo, uint8_t *buf, uint32_t len);
  21. int fifo_write(FIFO_HandleTypeDef *fifo, uint8_t *data, uint32_t len);
  22. int fifo_size(FIFO_HandleTypeDef *fifo);
  23. #endif /* INC_FIFO_H_ */