...
Files
os.h/os_mem.c
Prototype
Code Block |
---|
void *OSMemGet (OS_MEM *p_mem,
OS_ERR *p_err) |
Arguments
p_mem
is a pointer to the desired memory partition control block.
...
If OS_CFG_ARG_CHK_EN
is set to 1
in DEF_ENABLED
in os_cfg.h
: if p_mem
is a NULL
pointer.
...
If the memory partition does not contain additional memory blocks to allocate.
OS_ERR_OBJ_TYPE
If OS_CFG_OBJ_TYPE_CHK_EN
is set to DEF_ENABLED
in os_cfg.h
: if the user did not pass a pointer to a memory partition.
Returned Value
OSMemGet()
returns a pointer to the allocated memory block if one is available. If a memory block is not available from the memory partition, OSMemGet()
returns a NULL
pointer. It is up to the application to “cast” the pointer to the proper data type since OSMemGet()
returns a void *
.
...
OS_CFG_MEM_EN
must be enabled in os_cfg.h
. Refer to uCµC-OS-III Configuration Manual,
Callers
Application and ISRs.
Notes/Warnings
- Memory partitions must be created before they are used.
- This is a non-blocking call and this function can be called from an ISR.
...
Example Usage
Code Block | ||
---|---|---|
| ||
OS_MEM CommMem;
void Task (void *p_arg)
{
OS_ERR err;
CPU_INT32U *p_msg;
(void)&p_arg;
while (DEF_ON) {
p_msg = (CPU_INT32U *)OSMemGet(&CommMem,
&err);
/* Check "err" */
:
:
}
} |