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");
97 if (chMBPostTimeout(&que->
mb, mpl.
msg_ptr_len, timout) != MSG_OK) {
101 if (chMBPostAheadTimeout(&que->
mb, mpl.
msg_ptr_len, timout) != MSG_OK) {
123 memcpy(dst,
msg, msgLen);
141 MsgPtrLen mpl = {.ptrOfst = 0, .len = 0};
146 }
while (
status == MSG_RESET);
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;
uint8_t msg[10]
Buffer used for general comunication over SPI (out buffer)
bool msgqueue_is_empty(MsgQueue *que)
test if queue is empty
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
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
int32_t msgqueue_pop(MsgQueue *que, void **msgPtr)
wait then receive message
bool msgqueue_is_full(MsgQueue *que)
test if queue is full
void msgqueue_init(MsgQueue *que, tlsf_memory_heap_t *heap, msg_t *mb_buf, const cnt_t mb_size)
initialise MsgQueue
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
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
static const char * _strerror[]
int32_t msgqueue_copy_send(MsgQueue *que, const void *msg, const uint16_t msgLen, const MsgQueueUrgency urgency)
send a buffer NOT previously allocated
tlsf_memory_heap_t * heap
@ MsgQueue_MAILBOX_TIMEOUT
Dynamic memory allocation based on TLSF library.
void * tlsf_get_heap_addr(const tlsf_memory_heap_t *heap)
void tlsf_free_r(tlsf_memory_heap_t *heap, void *ptr)
void * tlsf_malloc_r(tlsf_memory_heap_t *heap, size_t bytes)
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
int int32_t
Typedef defining 32 bit int type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.