ringbuf.h 546 B

12345678910111213141516171819
  1. #ifndef _RING_BUF_H_
  2. #define _RING_BUF_H_
  3. #include <os_type.h>
  4. #include <stdlib.h>
  5. #include "mqtt/typedef.h"
  6. typedef struct {
  7. U8* p_o; /**< Original pointer */
  8. U8* volatile p_r; /**< Read pointer */
  9. U8* volatile p_w; /**< Write pointer */
  10. volatile I32 fill_cnt; /**< Number of filled slots */
  11. I32 size; /**< Buffer size */
  12. } RINGBUF;
  13. I16 ICACHE_FLASH_ATTR RINGBUF_Init(RINGBUF *r, U8* buf, I32 size);
  14. I16 ICACHE_FLASH_ATTR RINGBUF_Put(RINGBUF *r, U8 c);
  15. I16 ICACHE_FLASH_ATTR RINGBUF_Get(RINGBUF *r, U8* c);
  16. #endif