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);
85 #if CH_DBG_ENABLE_CHECKS
88 #if CH_DBG_ENABLE_ASSERTS
89 chSysHalt(
"MsgQueue_INVALID_PTR");
101 if (chMBPostAhead(&que->
mb, mpl.
msg_ptr_len, timout) != MSG_OK) {
123 memcpy(dst, msg, msgLen);
141 MsgPtrLen mpl = {.ptrOfst = 0, .len = 0};
145 status = chMBFetch(&que->
mb, (msg_t *) &mpl.
msg_ptr_len, timout);
146 }
while (status == MSG_RESET);
148 if (status != MSG_OK) {
159 static const char *
_strerror[] = {
"MsgQueue_MAILBOX_FULL",
160 "MsgQueue_MAILBOX_FAIL",
161 "MsgQueue_MAILBOX_TIMEOUT",
162 "MsgQueue_MAILBOX_NOT_EMPTY",
164 "MsgQueue_INVALID_PTR",
165 "MsgQueue_INVALID_ERRNO"
172 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)