📄 main.c
字号:
#include "main.h"
#define RxBufferSize 0xFF
#define TxBufferSize 512
u8 RxBuffer[RxBufferSize];
u8 TxBuffer[TxBufferSize];
vu8 RxCounter = 0x00;
int main(void)
{
u8 i;
u8 myStr[8];
#ifdef DEBUG
debug();
#endif
/**********************************************
* 系统初始化
***********************************************/
//配置系统时钟
RCC_Configuration();
//配置 NVIC 和 Vector Table
NVIC_Configuration();
UART1_GPIO_Configuration();
UART1_Configuration();
OS_CPU_SysTickInit();
//延迟用于调试
Delay_Ms(1000);
/**********************************************
* 获取芯片 DeviceID
***********************************************/
USART_SendBuffer(USART1,"\r\n///**********************************************\r\n",MaxBufLen);
USART_SendBuffer(USART1,"///* 获取芯片 DeviceID \r\n",MaxBufLen);
USART_SendBuffer(USART1,"///**********************************************\r\n",MaxBufLen);
USART_SendBuffer(USART1,"DeviceID=",MaxBufLen);
u8 myID[12];
GetUniqueDeviceID(myID);
for (i=0;i<12;i++)
{
Int8ToStr_Hex(myID[i],myStr);
USART_SendBuffer(USART1,myStr,2);
USART_SendByte(USART1,' ');
}
USART_SendBuffer(USART1,"\r\n \r\n",MaxBufLen);
/**********************************************
* 测试TFT屏幕
***********************************************/
USART_SendBuffer(USART1,"\r\n///**********************************************\r\n",MaxBufLen);
USART_SendBuffer(USART1,"///* 测试TFT屏幕 \r\n",MaxBufLen);
USART_SendBuffer(USART1,"///**********************************************\r\n",MaxBufLen);
///LCD initialization
USART_SendBuffer(USART1,"--------Begin to initialize LCD!\r\n" , MaxBufLen);
tftInit();
/// LCD initialization
USART_SendBuffer(USART1,"--------Begin to Test LCD!\r\n" , MaxBufLen);
tftTest();
USART_SendBuffer(USART1,"--------LCD test is Over!\r\n" , MaxBufLen);
USART_SendBuffer(USART1,"\r\n \r\n",MaxBufLen);
/**********************************************
* SD_MMC初始化
***********************************************/
USART_SendBuffer(USART1,"\r\n///**********************************************\r\n",MaxBufLen);
USART_SendBuffer(USART1,"/// SD_MMC初始化 \r\n",MaxBufLen);
USART_SendBuffer(USART1,"///**********************************************\r\n",MaxBufLen);
if( !SD_MMC_SPI_Init() )
{
USART_SendBuffer(USART1,"----------SD_MMC card init error!\r\n" ,MaxBufLen);
}
else
{
memset(TxBuffer,0,512);
USART_SendBuffer(USART1,"----------SD_MMC card init ok!\r\n" ,MaxBufLen);
/**********************************************
* 测试 FAT16文件系统
***********************************************/
#if 0
USART_SendBuffer(USART1,"\r\n///**********************************************\r\n",MaxBufLen);
USART_SendBuffer(USART1,"/// 测试 FAT16文件系统 \r\n",MaxBufLen);
USART_SendBuffer(USART1,"///**********************************************\r\n",MaxBufLen);
FAT16_Test();
Delay_Ms(1000);
#endif
while(1)
{
/**********************************************
* 测试 汉字库
***********************************************/
#if 1
USART_SendBuffer(USART1,"\r\n///**********************************************\r\n",MaxBufLen);
USART_SendBuffer(USART1,"/// 测试 汉字库 \r\n",MaxBufLen);
USART_SendBuffer(USART1,"///**********************************************\r\n",MaxBufLen);
Font_Test();
Delay_Ms(3000);
#endif
/**********************************************
* 显示图片
***********************************************/
#if 1
OpenDir("/IMG/BMP");
USART_SendBuffer(USART1,"\r\n///**********************************************\r\n",MaxBufLen);
USART_SendBuffer(USART1,"/// 显示图片 ''A.BMP'' \r\n",MaxBufLen);
USART_SendBuffer(USART1,"///**********************************************\r\n",MaxBufLen);
ShowBMP24(-1,-1,"A.BMP",True);
Delay_Ms(3000);
USART_SendBuffer(USART1,"\r\n///**********************************************\r\n",MaxBufLen);
USART_SendBuffer(USART1,"/// 显示图片 ''B.BMP'' \r\n",MaxBufLen);
USART_SendBuffer(USART1,"///**********************************************\r\n",MaxBufLen);
ShowBMP24(-1,-1,"B.BMP",True);
Delay_Ms(3000);
USART_SendBuffer(USART1,"\r\n///**********************************************\r\n",MaxBufLen);
USART_SendBuffer(USART1,"/// 显示图片 ''C.BMP'' \r\n",MaxBufLen);
USART_SendBuffer(USART1,"///**********************************************\r\n",MaxBufLen);
ShowBMP24(50,50,"C.BMP",False);
Delay_Ms(3000);
USART_SendBuffer(USART1,"\r\n///**********************************************\r\n",MaxBufLen);
USART_SendBuffer(USART1,"/// 显示图片 ''D.BMP'' \r\n",MaxBufLen);
USART_SendBuffer(USART1,"///**********************************************\r\n",MaxBufLen);
ShowBMP24(-1,-1,"D.BMP",False);
Delay_Ms(3000);
}
#endif
}
/**********************************************
* 进入主循环
***********************************************/
while (1);
}
#ifdef DEBUG
/*******************************************************************************
* Function Name : assert_failed
* Description : Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* Input : - file: pointer to the source file name
* - line: assert_param error line source number
* Output : None
* Return : None
*******************************************************************************/
void assert_failed(u8* file, u32 line)
{
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* Infinite loop */
while (1)
{
}
}
#endif
/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -