|
本例程使用的庫是:STM32F10x_StdPeriph_Lib_V3.3.0
例程已經(jīng)經(jīng)過驗(yàn)證,其中\(zhòng)Project\XX示例\MDK-ARM\目錄下包含MDK(keil)集成開發(fā)軟件的工程文件,打開其中的“Project.uvproj”即可。
已經(jīng)成功在MDK4.12軟件版本下編譯測(cè)試。
例程默認(rèn)調(diào)試工具為Jlink V8,使用Jlink V8調(diào)試過程請(qǐng)參考視頻:
單片機(jī)源程序如下:
- #include "stm32f10x_rcc.h"
- #include "stm32f10x_gpio.h"
- #include "stm32f10x_flash.h"
- #include "stm32f10x.h"
- #include "ili9320.h"
- #include "sdx.h"
- #include "znfat.h"
- #include "pic.h"
- #include <key.h>
- #include <control.h>
-
- struct znFAT_Init_Args Init_Args; //初始化參數(shù)集合
- struct FileInfo fileinfo; //文件信息集合
- unsigned char buf[21];
- int main()
- {
- unsigned int res=0,len=0;
- u16 c2len;
- u8 c2[] = "TFT LCD 320X240";
- u8 fixed=0;
- u16 charColor;
- u16 bkColor;
-
- c2len = sizeof(c2)-1;
-
-
- GPIO_KEY_Config();
- SD_IO_Init();
-
- ili9320_Initializtion();
- charColor = Yellow;
- bkColor = Red;
-
- znFAT_Device_Init(); //存儲(chǔ)設(shè)備初始化
-
- znFAT_Select_Device(0,&Init_Args); //選擇設(shè)備
-
- res=znFAT_Init(); //文件系統(tǒng)初始化
-
- if(!res) //文件系統(tǒng)初始化成功
- {
- ili9320_Clear(Grey);
- ili9320_PutStr_16x24_Center(200, c2, c2len,charColor, bkColor);
- Delay_ARMJISHU(4000000);
- }
- else //文件系統(tǒng)初始化失敗
- {
- ili9320_Clear(Green);
- ili9320_PutStr_16x24_Center(200, c2, c2len,charColor, bkColor);
- Delay_ARMJISHU(4000000);
- }
- //==================================================================
-
- res=znFAT_Open_File(&fileinfo,"/mcu.txt",0,1); //打開文件
- if(!res) //打開文件成功
- {
-
- len=znFAT_ReadData(&fileinfo,9,20,buf); //從文件偏移量9位置開始讀取20個(gè)字節(jié)
-
- buf[20]=0;
- ili9320_PutStr_16x24_Center(44, buf, len,charColor, bkColor);
-
- znFAT_Close_File(&fileinfo); //關(guān)閉文件
- }
- else
- {
- ili9320_Clear(Yellow);
- Delay_ARMJISHU(4000000);
- }
- znFAT_Flush_FS(); //刷新文件系統(tǒng)
- ili9320_DrawPicture(0,0,319,239,(u16 *)(pic + BmpHeadSize));
- Fixed_GUI_Rectangle(1,Black); //畫文件夾邊框
- Fixed_GUI_Rectangle(2,Black);
- Fixed_GUI_Rectangle(3,Black);
- Fixed_GUI_Rectangle(fixed,White); //畫選中文件夾邊框
- while(1)
- {
- switch(ReadKeyDown())
- {
- case 1 :
- break;
- case 2 :
- Open_X_File(fixed);
- break;
- case 3 :
- Fixed_GUI_Rectangle(fixed,Black);
- if(fixed==0)
- fixed=3;
- else
- fixed--;
- Fixed_GUI_Rectangle(fixed,White);
- break;
- ……………………
- …………限于本文篇幅 余下代碼請(qǐng)從51黑下載附件…………
復(fù)制代碼 下載(此代碼年代久遠(yuǎn),采用的老版本的庫和老版本Keil編寫的):
電子相冊(cè)代碼.7z
(1.25 MB, 下載次數(shù): 35)
2022-11-22 03:31 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
|
|