例程主函数
const u8 TEXT_Buffer[19]={"FLASH SPI TEST OK!"};
#define SIZE (19-1)
int main(void)
{
uint8_t buff[SIZE], showChar[SIZE + 1], j, keyValue, ledState = 0;
uint32_t i;
/* 初始化 */
TFT_Init();
KEY_Config();
FLASH_Init();
LED_Config();
/* 显示初始化 */
TFT_ClearScreen(BLACK);
while(FLASH_ReadID() != EN25Q64)
{
GUI_Show12Char(75, 0, "FLASH Init ERROR!", RED, BLACK);
}
TFT_ClearScreen(BLACK);
GUI_Show12Char(75, 0, "FLASH Init OK! ", RED, BLACK);
GUI_Show12Char(0, 32, "KEY_UP: write KEY_DOWN:read", RED,
BLACK);
while(1)
{
keyValue = KEY_Scan();
/* 根据按键做出反应 */
switch(keyValue)
{
case(KEY_UP): //按上键将"FLASH SPI test OK!"从 FLASH 地
址 0 开始写入
FLASH_WriteData((u8*)TEXT_Buffer, 0, SIZE);
GUI_Show12Char(0, 48, "wirte OK! ", RED,
BLACK);
break;
case(KEY_DOWN): //按下键将从 FLASH 地址 0 开始读取 18
位数,将读取到的显示
FLASH_ReadData(buff, 0, SIZE);
for(j=0; j<SIZE; j++)
{
showChar[j] = buff[j];
}
GUI_Show12Char(0, 48, showChar, RED, BLACK);
break;
default:
break;
}
/* LED 灯闪烁 */
i++;
if(i > 0x5FFFF)
{
i = 0;
if(ledState == 0xFE)
{
ledState = 0xFF;
}
else
{
ledState = 0xFE;
}
LED_SetState(ledState);
}
}
} |