rbuf_pool.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*******************************************************************************
  2. * @file rbuf_pool.h
  3. * @author MEMS Application Team
  4. * @version V1.0
  5. * @date 2020-10-15
  6. * @brief ring buffer for interaction RAM
  7. *******************************************************************************/
  8. #ifndef _RBUF_POOL_H
  9. #define _RBUF_POOL_H
  10. /******************************************************************************/
  11. //includes
  12. /******************************************************************************/
  13. #include <rbuf/rbuf_core.h>
  14. /******************************************************************************/
  15. //constants
  16. /******************************************************************************/
  17. #define RBUF_POOL_DBG (1)
  18. /******************************************************************************/
  19. //typedef
  20. /******************************************************************************/
  21. // Pool Node
  22. typedef struct rbuf_node_s {
  23. unsigned short blk_size;
  24. unsigned short blk_list;
  25. unsigned short next;
  26. unsigned short flag;
  27. } rbuf_node_t;
  28. // Pool Header
  29. typedef struct rbuf_pool_s {
  30. unsigned short buf_off;
  31. unsigned short buf_size;
  32. rbuf_node_t root;
  33. } rbuf_pool_t;
  34. /******************************************************************************/
  35. //variables
  36. /******************************************************************************/
  37. /******************************************************************************/
  38. //functions
  39. /******************************************************************************/
  40. rbuf_pool_t *rbuf_pool_init(char *buf, unsigned int size);
  41. rbuf_t *rbuf_pool_alloc(rbuf_pool_t *pool, unsigned int size, unsigned int mode);
  42. int rbuf_pool_free(rbuf_t *buf);
  43. #if RBUF_POOL_DBG
  44. void rbuf_pool_dump(rbuf_pool_t *pool);
  45. #else
  46. #define rbuf_pool_dump(x)
  47. #endif
  48. #endif /* _RBUF_POOL_H */