#include <osal.h>
static int mem_access_task_entry()
{
uint32_t i = 0;
size_t mem_size;
uint8_t *mem_ptr = NULL;
while (1)
{
mem_size = 1 << i++;
mem_ptr = osal_malloc(mem_size);
if (mem_ptr != NULL)
{
printf("access %d bytes memory success!\r\n", mem_size);
osal_free(mem_ptr);
mem_ptr = NULL;
printf("free memory success!\r\n");
}
else
{
printf("access %d bytes memory failed!\r\n", mem_size);
return 0;
}
}
}
int standard_app_demo_main()
{
osal_task_create("mem_access_task", mem_access_task_entry, NULL, 0x400, NULL, 11);
return 0;
}
mk文件
#example for osal_mem_demo
ifeq ($(CONFIG_USER_DEMO), "osal_mem_demo")
user_demo_src = ${wildcard $(TOP_DIR)/targets/STM32L431_BearPi/Demos/osal_mem_demo/*.c}
user_demo_defs = -D CONFIG_OSAL_MEM_ENABLE=1
endif
|