rkfifo.h 802 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. int error;
  19. }rkfifo_t;
  20. int rkfifo_init(rkfifo_t *fifo, void *buffer, uint32_t size, uint32_t esize);
  21. unsigned int rkfifo_in(rkfifo_t *fifo, const void *buf, unsigned int len);
  22. unsigned int rkfifo_out_peek(rkfifo_t *fifo, void *buf, unsigned int len);
  23. unsigned int rkfifo_out(rkfifo_t *fifo, void *buf, unsigned int len);
  24. #ifdef __cplusplus
  25. }
  26. #endif /* __cplusplus */
  27. #endif