📄 main.c
字号:
/******************** (C) COPYRIGHT 2008 FUDANTIANXIN********************
* File Name : main.c
* Author : 上海复旦天欣科教仪器有限公司 周春明 ZCM
* Version : V1.0
* Date : 11/5/2008
* Description : FD-STM32-B实验箱:移植uCGUI
********************************************************************************
* 接口:
* 使用STM32的FSMC的BANK1的第四部分,即外部地址为0X6C000000。
*******************************************************************************/
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "GUI.H"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
static volatile ErrorStatus HSEStartUpStatus = SUCCESS;
static vu32 TimingDelay = 0;
vu32 TimeDisplay = 0;
u32 TimeNumber=0;
extern void MainTask(void) ;
/* Private function prototypes -----------------------------------------------*/
void RCC_Configuration(void);
void GPIO_Configuration(void);
void NVIC_Configuration(void);
extern void PS2Demo(void);
/* Private functions ---------------------------------------------------------*/
/****************************************************************************
* 名 称:main
* 功 能:编写main函数
* 入口参数:无
* 出口参数:无
* 说 明:
****************************************************************************/
void main(void)
{
#ifdef DEBUG
debug();
#endif
STM32_LCD_Demo(); //STM32实验箱整机操作实验测试
/* Infinite loop */
while(1)
{
}
}
/****************************************************************************
* 名 称:STM32_LCD_Demo
* 功 能:LCD程序
* 入口参数:无
* 出口参数:无
* 说 明:
****************************************************************************/
void STM32_LCD_Demo(void)
{
/* 配置RCC,NVIC,GPIO,RTC,IntExtOnOffConfig ,SysTick-----------------------------*/
RCC_Configuration();
// NVIC_Configuration();
GPIO_Configuration();
IntExtOnOffConfig(ENABLE);
SysTick_Config();
/*------------------- Drivers Initialization -------------------------------*/
//GUI_Delay(10);
GUI_Init();
GUI_SetBkColor(GUI_RED);
GUI_Clear();
NVIC_Configuration();
PS2Demo();
}
/****************************************************************************
* 名 称:SysTick_Config
* 功 能:配置SysTick_Config
* 入口参数:无
* 出口参数:无
* 说 明:
****************************************************************************/
void SysTick_Config(void)
{
SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK); //配置SysTick的源时钟
SysTick_SetReload(9000); /* 当HCLK==72MHz时,SysTick每1ms中断一次 */
SysTick_ITConfig(ENABLE); //使能SysTick中断
SysTick_CounterCmd(SysTick_Counter_Disable);
SysTick_CounterCmd(SysTick_Counter_Clear);//计算器清零
SysTick_CounterCmd(SysTick_Counter_Enable);//开始计数
}
/*******************************************************************************
* 名 称:IntExtOnOffConfig
* 功 能:开关外部中断line3,7,15,对应DownKey,SelKey,UpKey
* 入口参数:无
* 出口参数:无
* 说 明:
****************************************************************************/
void IntExtOnOffConfig(FunctionalState NewState)
{
EXTI_InitTypeDef EXTI_InitStructure;
/* Initializes the EXTI_InitStructure */
EXTI_StructInit(&EXTI_InitStructure);
}
/****************************************************************************
* 名 称:RCC_Configuration
* 功 能:配置RCC
* 入口参数:无
* 出口参数:无
* 说 明:
****************************************************************************/
void RCC_Configuration(void)
{
/* RCC system reset(for debug purpose) */
RCC_DeInit();
/* Enable HSE */
RCC_HSEConfig(RCC_HSE_ON);
/* Wait till HSE is ready */
HSEStartUpStatus = RCC_WaitForHSEStartUp();
if (HSEStartUpStatus == SUCCESS)
{
/* Enable Prefetch Buffer */
FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
/* Flash 2 wait state */
FLASH_SetLatency(FLASH_Latency_2);
/* HCLK = SYSCLK /2*/
RCC_HCLKConfig(RCC_SYSCLK_Div2);
/* PCLK2 = HCLK */
RCC_PCLK2Config(RCC_HCLK_Div1);
/* PCLK1 = HCLK/2 */
RCC_PCLK1Config(RCC_HCLK_Div2);
/* PLLCLK = 8MHz * 9 = 72 MHz */
RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);
/* Enable PLL */
RCC_PLLCmd(ENABLE);
/* Wait till PLL is ready */
while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
{}
/* Select PLL as system clock source */
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
/* Wait till PLL is used as system clock source */
while (RCC_GetSYSCLKSource() != 0x08)
{}
}
/* Enable GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG and AFIO clocks */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |RCC_APB2Periph_GPIOC
| RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE | RCC_APB2Periph_GPIOF | RCC_APB2Periph_GPIOG
| RCC_APB2Periph_AFIO | RCC_APB2Periph_ADC1, ENABLE);
}
/****************************************************************************
* 名 称:NVIC_Configuration
* 功 能:配置NVIC
* 入口参数:无
* 出口参数:无
* 说 明:
****************************************************************************/
void NVIC_Configuration(void)
{
NVIC_InitTypeDef NVIC_InitStructure;
#ifdef VECT_TAB_RAM
/* Set the Vector Table base location at 0x20000000 */
NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0);
#else /* VECT_TAB_FLASH */
/* Set the Vector Table base location at 0x08000000 */
NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);
#endif
/* Configure one bit for preemption priority */
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
/* Configure the SysTick handler priority */
NVIC_SystemHandlerPriorityConfig(SystemHandler_SysTick, 0, 0);
/* Enable the EXTI15_10 Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQChannel;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
/****************************************************************************
* 名 称:GPIO_Configuration
* 功 能:配置GPIO
* 入口参数:无
* 出口参数:无
* 说 明:
****************************************************************************/
void GPIO_Configuration(void)
{
}
/****************************************************************************
* 名 称:IncreaseTimeNumber
* 功 能:被SysTick中断调用,每次中断加1,即增加1ms,为uCGUI提供时间基准
* 入口参数:无
* 出口参数:无
* 说 明:
****************************************************************************/
void IncreaseTimeNumber(void)
{
TimeNumber++;
}
#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 + -