bs_bcu_app/bsp/bsp_queue.h

54 lines
1.2 KiB
C

#ifndef _BSP_QUEUE_H_
#define _BSP_QUEUE_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "kit_macro.h"
#define QUEUE_STATIC_INIT(_name, _len, _cell_len) \
uint8_t buf_##_name[_len * _cell_len]; \
QueueItem _name = \
{ \
(_len), \
(_cell_len), \
0, \
0, \
buf_##_name, \
}
#define QUEUE_STATIC_INIT_CCM(_name, _len, _cell_len) \
uint8_t buf_##_name[_len * _cell_len] __attribute__((section (".CCM_RAM"))); \
QueueItem _name __attribute__((section (".CCM_RAM"))) = \
{ \
(_len), \
(_cell_len), \
0, \
0, \
buf_##_name, \
}
typedef struct
{
uint16_t max_cnt;
uint16_t cell_len;
uint16_t pop_index;
uint16_t push_index;
uint8_t *buf;
}QueueItem;
bool bsp_queue_is_full(QueueItem* item);
bool bsp_queue_is_empty(QueueItem* item);
KitResult bsp_queue_pop_pointer(QueueItem* item, void **prt);
KitResult bsp_queue_push_pointer(QueueItem* item, void **prt);
KitResult bsp_queue_pop_instance(QueueItem* item, uint8_t *ins);
KitResult bsp_queue_push_instance(QueueItem* item, uint8_t *ins);
#ifdef __cplusplus
}
#endif
#endif