30 #define MSGQ_HEAP HEAP_CCM
43 msg_t *mb_buf,
const cnt_t mb_size)
45 chMBObjectInit(&que->
mb, mb_buf, mb_size);
46 memset(mb_buf, 0, mb_size *
sizeof(msg_t));
53 const bool queue_full = chMBGetFreeCountI(&que->
mb) <= 0;
62 bool queue_empty = (chMBGetUsedCountI(&que->
mb) <= 0);
83 #if CH_DBG_ENABLE_CHECKS
86 #if CH_DBG_ENABLE_ASSERTS
87 chSysHalt(
"MsgQueue_INVALID_PTR");
99 if (chMBPostAhead(&que->
mb, mpl.
msg_ptr_len, timout) != MSG_OK) {
121 memcpy(dst, msg, msgLen);
139 MsgPtrLen mpl = {.ptrOfst = 0, .len = 0};
142 if (status != MSG_OK) {
153 static const char *
_strerror[] = {
"MsgQueue_MAILBOX_FULL",
154 "MsgQueue_MAILBOX_FAIL",
155 "MsgQueue_MAILBOX_TIMEOUT",
156 "MsgQueue_MAILBOX_NOT_EMPTY",
158 "MsgQueue_INVALID_PTR",
159 "MsgQueue_INVALID_ERRNO"
166 indice = (indice < arrayLen) ? indice : arrayLen - 1;
int32_t msgqueue_pop_timeout(MsgQueue *que, void **msgPtr, const systime_t timout)
receive message specifying timeout
const char * msgqueue_strerror(const MsgQueueStatus _errno)
debug api
void * tlsf_get_heap_addr(const tlsf_memory_heap_t *heap)
void msgqueue_init(MsgQueue *que, tlsf_memory_heap_t *heap, msg_t *mb_buf, const cnt_t mb_size)
initialise MsgQueue
int32_t msgqueue_copy_send(MsgQueue *que, const void *msg, const uint16_t msgLen, const MsgQueueUrgency urgency)
send a buffer NOT previously allocated
void tlsf_free_r(tlsf_memory_heap_t *heap, void *ptr)
int32_t msgqueue_copy_send_timeout(MsgQueue *que, const void *msg, const uint16_t msgLen, const MsgQueueUrgency urgency, const systime_t timout)
send a buffer NOT previously allocated
Dynamic memory allocation based on TLSF library.
bool msgqueue_is_full(MsgQueue *que)
test if queue is full
tlsf_memory_heap_t * heap
static const char * _strerror[]
int32_t msgqueue_send_timeout(MsgQueue *que, void *msg, const uint16_t msgLen, const MsgQueueUrgency urgency, const systime_t timout)
send a buffer previously allocated by msgqueue_malloc_before_send
bool msgqueue_is_empty(MsgQueue *que)
test if queue is empty
int32_t msgqueue_pop(MsgQueue *que, void **msgPtr)
wait then receive message
int32_t msgqueue_send(MsgQueue *que, void *msg, const uint16_t msgLen, const MsgQueueUrgency urgency)
send a buffer previously allocated by msgqueue_malloc_before_send
uint8_t msg[10]
Buffer used for general comunication over SPI (out buffer)
void * tlsf_malloc_r(tlsf_memory_heap_t *heap, size_t bytes)