int32_t test1(void)
{
pointer test_buf = NULL;
if(MQX_OK != _mem_verify(BSP_EXTERNAL_MRAM_RAM_BASE,
(pointer)((uint_32)BSP_EXTERNAL_MRAM_RAM_BASE + BSP_EXTERNAL_MRAM_RAM_SIZE))){
printf("The external sram failed to be verified.\n");
return -1;
}else{
printf("The external sram verified.\n");
}
if(MQX_OK != _mem_extend(BSP_EXTERNAL_MRAM_RAM_BASE, (_mem_size)BSP_EXTERNAL_MRAM_RAM_SIZE)){
printf("Failed to extend the external SRAM.\n");
r;
}else{
printf("Added the external sram to default mem pool.\n");
}
if(NULL == (test_buf = _mem_alloc(EXTERNAL_SRAM_TEST_BUF_SZ))){
printf("Failed to alloc buffer in the default pool after it being extended.\n");
return -1;
}else{
printf("Buffer allocated its address is 0x%08x\n", (uint_32)test_buf);
}
/* Access the buf here */
_task_block(); //block here to easy the checking of the memory pool
_mem_free(test_buf);
return 0;
}
int32_t test2(void)
{
pointer test_buf = NULL;
if(MQX_OK != _mem_verify(BSP_EXTERNAL_MRAM_RAM_BASE,
(pointer)((uint_32)BSP_EXTERNAL_MRAM_RAM_BASE + BSP_EXTERNAL_MRAM_RAM_SIZE))){
printf("The external sram failed to be verified.\n");
return -1;
}else{
printf("The external sram verified.\n");
}
_mem_pool_id ext_sram_pool = NULL;
ext_sram_pool = _mem_create_pool(BSP_EXTERNAL_MRAM_RAM_BASE, (_mem_size)BSP_EXTERNAL_MRAM_RAM_SIZE);
printf("Created a mem pool on the external sram, and the pool id is 0x%08x.\n", ext_sram_pool);
if(NULL == (test_buf = _mem_alloc_from(ext_sram_pool, EXTERNAL_SRAM_TEST_BUF_SZ))){
printf("Failed to alloc buffer from the new memory pool.\n");
return -1;
}else{
printf("Buffer allocated and its address is 0x%08x\n", (uint_32)test_buf);
}
/* Access the buf here */
_task_block(); //block here to easy the checking of the memory pool
_mem_free(test_buf);
return 0;
}