#endif //防止多次编译
#include "stm32f10x.h"
#include "LCD1602.h"
#define PE00 (uint32_t *)0x40230180
//时钟配置函数 8MHz*9=72MHz
void RCC_Configuration()
{
RCC_DeInit();
RCC_HSEConfig(RCC_HSE_ON);//使能HSE
if(RCC_WaitForHSEStartUp()==SUCCESS)
{
RCC_HCLKConfig(RCC_SYSCLK_Div1); //HCLK=SYSCLK
RCC_PCLK2Config(RCC_HCLK_Div1);
RCC_PCLK1Config(RCC_HCLK_Div2);
RCC_PLLConfig(RCC_PLLSource_HSE_Div1,RCC_PLLMul_9);
RCC_PLLCmd(ENABLE);
while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY)==RESET);
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
while(RCC_GetSYSCLKSource()!=0x08);
}
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC|\
RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE,ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1,ENABLE);
}
//延时n us
void delay_nus(unsigned long n)
{
unsigned long j;
while(n--)
{ j=8;
while(j--);
}
}
//延时n ms
void delay_nms(unsigned long n)
{
while(n--)
delay_nus(1100);
}
//GPIO配置函数
void GPIO_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;
GPIO_Init(GPIOD, &GPIO_InitStructure); //PD口OD输出
GPIO_InitStructure.GPIO_Pin = (GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD; //PE.0~2 OD输出
GPIO_Init(GPIOE, &GPIO_InitStructure);
}
///////////////////////////////////////////
int main()
{
//uint32_t i=0;
char str[]={"happy!"};
RCC_Configuration();
GPIO_Configuration();
LCD_Init();
LCD_Setpos_DispString(1,3,str);
LCD_DispFreq(123456);
LCD_FlickerChar(2,3);
LCD_FlickerScreen();
LCD_FlickerScreen();
LCD_FlickerScreen();
delay_nms(2000);
LCD_CloseFlicker();
while(1)
{
};
}