Mailbox

Mailbox service provides synchronized communication between tasks using a fixed-size FIFO queue. It supports blocking and timeout operations for both sending and receiving data.

Mailbox Management

mailbox_status_t mailbox_create(mailbox_t *mailbox, uint16_t queue_size, uint32_t element_size)

Create a mailbox.

Parameters:
  • mailbox – [in] pointer to the mailbox object (MUST-BE not NULL)

  • queue_size – [in] size of the mailbox queue

  • element_size – [in] size of each element in the mailbox

Returns:

  • MAILBOX_OK: mailbox create success

  • MAILBOX_NG: mailbox create fail

mailbox_status_t mailbox_delete(mailbox_t *mailbox)

Delete a mailbox.

Parameters:

mailbox – [in] pointer to the mailbox object (MUST-BE not NULL)

Returns:

  • MAILBOX_OK: mailbox delete success

  • MAILBOX_NG: mailbox delete fail

Mailbox Operations

mailbox_status_t mailbox_send(mailbox_t *mailbox, void *element, uint32_t timeout_ms)

Send a message to the mailbox.

Parameters:
  • mailbox – [in] pointer to the mailbox object (MUST-BE not NULL)

  • element – [in] pointer to the element to send (MUST-BE not NULL)

  • timeout_ms – [in] timeout in milliseconds for sending (MAILBOX_NULL for no wait, TASK_DELAY_INFINITE for wait indefinitely)

Returns:

  • MAILBOX_OK: mailbox send success

  • MAILBOX_NG: mailbox send fail

mailbox_status_t mailbox_receive(mailbox_t *mailbox, void *element, uint32_t timeout_ms)

Receive a message from the mailbox.

Parameters:
  • mailbox – [in] pointer to the mailbox object (MUST-BE not NULL)

  • element – [in] pointer to the element to receive (MUST-BE not NULL)

  • timeout_ms – [in] timeout in milliseconds for receiving (MAILBOX_NULL for no wait, TASK_DELAY_INFINITE for wait indefinitely)

Returns:

  • MAILBOX_OK: mailbox receive success

  • MAILBOX_NG: mailbox receive fail

Kernel Service

void mailbox_tick(uint32_t tick)

Mailbox tick (Polling)

This function will be called periodically by the kernel to manage mailbox timeouts and unblock tasks waiting on mailboxes

Note

This function will be called by the kernel

Parameters:

tick – [in] tick count to decrement (unit: milliseconds)

Returns:

none