rkfifo.h 787 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #ifndef __RKFIFO_H_
  2. #define __RKFIFO_H_
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif /* __cplusplus */
  6. #include <stdint.h>
  7. /* 返回值宏定义 */
  8. #define RKFIFO_ENOMEM 12 /* Out of Memory */
  9. #define RKFIFO_EINVAL 22 /* Invalid argument */
  10. #define RKFIFO_ENOSPC 28 /* No space left on device */
  11. typedef struct rkfifo
  12. {
  13. uint32_t in;
  14. uint32_t out;
  15. uint32_t mask;
  16. uint32_t esize;
  17. void* data;
  18. }rkfifo_t;
  19. int rkfifo_init(rkfifo_t *fifo, void *buffer, uint32_t size, uint32_t esize);
  20. unsigned int rkfifo_in(rkfifo_t *fifo, const void *buf, unsigned int len);
  21. unsigned int rkfifo_out_peek(rkfifo_t *fifo, void *buf, unsigned int len);
  22. unsigned int rkfifo_out(rkfifo_t *fifo, void *buf, unsigned int len);
  23. #ifdef __cplusplus
  24. }
  25. #endif /* __cplusplus */
  26. #endif