内存管理例程主函数
int main(void)
{
uint32_t i;
uint8_t ledState, keyValue, addr = 0;
uint8_t *p[64];
/* 初始化 */
TFT_Init();
FLASH_Init();
USART1_Config(9600);
SRAM_Config();
KEY_Config();
LED_Config();
MEMORY_Init();
GUI_DisplayInit();
while(1)
{
/* 通过按键进行相应的操作 */
keyValue = KEY_Scan();
if(keyValue)
{
switch(keyValue)
{
case(KEY_UP):
p[addr] = malloc(32 * 100); //一次开辟 100 个内存块
if(addr<64)
{
addr++;
}
break;
case(KEY_DOWN):
if(addr > 0)
{
addr--;
}
free(p[addr]);
break;
}
GUI_DisplayData();
}
/* LED 灯闪烁 */
i++;
if(i>0x5FFFF)
{
i = 0;
if(ledState == 0xFE)
{
ledState = 0xFF;
}
else
{
ledState = 0xFE;
}
LED_SetState(ledState);
}
}
} |