Control, send, receive, or wait for mail.
More...
|
#define | osFeature_MailQ 1 |
| Mail Queues: 1=available, 0=not available.
|
|
#define | osMailQDef(name, queue_sz, type) |
| Create a Mail Queue Definition.
|
|
#define | osMailQ(name) &os_mailQ_def_##name |
| Access a Mail Queue Definition.
|
|
The Mail Queue Management function group allows to control, send, receive, or wait for mail. A mail is a memory block that is send to a thread or interrupt service routine.
CMSIS-RTOS Mail Queue
#define osFeature_MailQ 1 |
A CMSIS-RTOS implementation may support mail queues. When the value osFeature_MailQ is 1 mail queues are supported. When the value osFeature_MailQ is 0 no mail queues are supported.
#define osMailQ |
( |
|
name | ) |
&os_mailQ_def_##name |
Access to the mail queue definition for the function osMailCreate.
- Parameters
-
- Note
- CAN BE CHANGED: The parameter to osMailQ shall be consistent but the macro body is implementation specific in every CMSIS-RTOS.
#define osMailQDef |
( |
|
name, |
|
|
|
queue_sz, |
|
|
|
type |
|
) |
| |
Define the attributes of a mail queue that can by the function osMailCreate using osMailQ.
- Parameters
-
name | name of the queue |
queue_sz | maximum number of messages in queue |
type | data type of a single message element |
- Note
- CAN BE CHANGED: The parameter to osMailQDef shall be consistent but the macro body is implementation specific in every CMSIS-RTOS.
void * osMailAlloc |
( |
osMailQId |
queue_id, |
|
|
uint32_t |
millisec |
|
) |
| |
- Parameters
-
[in] | queue_id | mail queue ID obtained with osMailCreate. |
[in] | millisec | timeout value or 0 in case of no time-out |
- Returns
- pointer to memory block that can be filled with mail or NULL in case of error.
- Note
- MUST REMAIN UNCHANGED: osMailAlloc shall be consistent in every CMSIS-RTOS.
Allocate a memory block from the mail queue that is filled with the mail information. When no memory block slot is available, the tread is put into the state WAITING for the time specified with millisec. When millisec is set to osWaitForever the function will wait for an infinite time until a mail queue slot becomes available.
A NULL pointer is returned when no memory slot can be obtained or queue specifies an illegal parameter.
- Note
- The parameter millisec must be 0 for using this function in an ISR.
void * osMailCAlloc |
( |
osMailQId |
queue_id, |
|
|
uint32_t |
millisec |
|
) |
| |
- Parameters
-
[in] | queue_id | mail queue ID obtained with osMailCreate. |
[in] | millisec | timeout value or 0 in case of no time-out |
- Returns
- pointer to memory block that can be filled with mail or NULL in case of error.
- Note
- MUST REMAIN UNCHANGED: osMailCAlloc shall be consistent in every CMSIS-RTOS.
Allocate a memory block from the mail queue that is filled with the mail information. The memory block returned is cleared. When no memory block is available, the tread is put into the state WAITING for the time specified with millisec. When millisec is set to osWaitForever the function will wait for an infinite time until a mail queue slot becomes available.
A NULL pointer is returned when no memory block can be obtained or queue specifies an illegal parameter.
- Note
- The parameter millisec must be 0 for using this function in an ISR.
- Parameters
-
- Returns
- mail queue ID for reference by other functions or NULL in case of error.
- Note
- MUST REMAIN UNCHANGED: osMailCreate shall be consistent in every CMSIS-RTOS.
Initialize and create a mail queue.
Example:
typedef struct {
float voltage;
float current;
int counter;
} T_MEAS;
void send_thread (void const *argument);
void recv_thread (void const *argument);
void send_thread (void const *argument) {
T_MEAS *mptr;
mptr->voltage = 223.72;
mptr->current = 17.54;
mptr->counter = 120786;
mptr->voltage = 227.23;
mptr->current = 12.41;
mptr->counter = 170823;
}
void recv_thread (void const *argument) {
T_MEAS *rptr;
for (;;) {
printf ("\nVoltage: %.2f V\n", rptr->voltage);
printf ("Current: %.2f A\n", rptr->current);
printf ("Number of cycles: %d\n", rptr->counter);
}
}
}
void StartApplication (void) {
:
}
- Parameters
-
[in] | queue_id | mail queue ID obtained with osMailCreate. |
[in] | mail | pointer to the memory block that was obtained with osMailGet. |
- Returns
- status code that indicates the execution status of the function.
- Note
- MUST REMAIN UNCHANGED: osMailFree shall be consistent in every CMSIS-RTOS.
Free the memory block specified by mail and return it to the mail queue.
Status and Error Codes
- osOK: the mail block is released.
- osErrorValue: mail block does not belong to the mail queue pool.
- osErrorParameter: the value to the parameter queue_id is incorrect.
- Parameters
-
[in] | queue_id | mail queue ID obtained with osMailCreate. |
[in] | millisec | timeout value or 0 in case of no time-out |
- Returns
- event that contains mail information or error code.
- Note
- MUST REMAIN UNCHANGED: osMailGet shall be consistent in every CMSIS-RTOS.
Suspend the execution of the current RUNNING thread until a mail arrives. When a mail is already in the queue, the function returns instantly with the mail information. When millisec is 0, the function returns instantly with status osOK. Otherwise the thread is put into the state WAITING. When millisec is set to osWaitForever the function will wait for an infinite time until a mail arrives.
- Note
- The parameter millisec must be 0 for using this function in an ISR.
Status and Error Codes
- osOK: no mail is available in the queue and no timeout was specified
- osEventTimeout: no mail has arrived during the given timeout period.
- osEventMail: mail received, value.p contains the pointer to mail content.
- osErrorParameter: a parameter is invalid or outside of a permitted range.
- Parameters
-
- Returns
- status code that indicates the execution status of the function.
- Note
- MUST REMAIN UNCHANGED: osMailPut shall be consistent in every CMSIS-RTOS.
Put the memory block specified with mail into the mail queue specified by queue.
Status and Error Codes
- osOK: the message is put into the queue.
- osErrorValue: mail was previously not allocated as memory slot.
- osErrorParameter: a parameter is invalid or outside of a permitted range.