有智林板的可以把所有文件考到一个目录下边,工程非常简单只包括三个文件
main.C//主文件
TFT018.c//显示有关文件
STM32F10XR.LIB//这个文件在MDK目录下边很好找
智林开发板板载上,下,左,右,方向键,若直接按,就是OK,本程序只是设置好上拉电阻输入就行,
运行时可即时显示用户的按键,本例有HEX可直接下载到芯片里边
QQ群:77219145
以下是主程序:
int main(void)
{
#ifdef DEBUG
debug();
#endif
/* System Clocks Configuration */
RCC_Configuration();
/* NVIC Configuration */
NVIC_Configuration();
/* GPIO Configuration */
GPIO_Configuration();
/* Time base configuration */
TIM_TimeBaseStructure.TIM_Period = 0x5000;
TIM_TimeBaseStructure.TIM_Prescaler = 0x00;
TIM_TimeBaseStructure.TIM_ClockDivision = 0x0;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
/* Output Compare Toggle Mode configuration: Channel1 */
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCInitStructure.TIM_Pulse =CCR3_Val ;
TIM_OC3Init(TIM2, &TIM_OCInitStructure);
/* TIM enable counter */
TIM_Cmd(TIM2, ENABLE);
LCD_Init();
LCD_Clear_Screen(Blue);
while(1)
{
for(;;) {
Font = 0;
LCD_PutString(30,0,"STM32F 开发板",Cyan,Blue);
LCD_PutString(30,16,"GPIO 输入演示",Red,Yellow);
Font = 1;
LCD_PutString(38,32,"Version 1.0",Green,Blue);
Font = 0;
LCD_PutString(10,94,"智林测控技术研究所",Yellow,Blue);
LCD_PutString(36,111,"www.the0.net",Magenta,Blue);
if (((GPIOB->IDR & JOYSTICK) == JOYSTICK )) { // Check if JOYSTICK key is pressed
GPIOB->ODR &= ~LED; // switch off LED
}
else { // JOYSTICK key is pressed
GPIOB->ODR |= LED; // switch on LED
}
if (((GPIOB->IDR & UP) == 0 )) // Check if UP is pressed
LCD_PutString(48,40,"上",Yellow,Red);
else
LCD_PutString(48,40,"上",Red,Yellow);
if (((GPIOB->IDR & DOWN) == 0 )) // Check if DOWN is pressed
LCD_PutString(48,76,"下",Yellow,Red);
else
LCD_PutString(48,76,"下",Red,Yellow);
if (((GPIOB->IDR & LEFT) == 0 )) // Check if LEFT is pressed
LCD_PutString(30,58,"左",Yellow,Red);
else
LCD_PutString(30,58,"左",Red,Yellow);
if (((GPIOB->IDR & RIGHT) == 0 )) // Check if RIGHT is pressed
LCD_PutString(66,58,"右",Yellow,Red);
else
LCD_PutString(66,58,"右",Red,Yellow);
if (((GPIOB->IDR & OK) == 0 )) // Check if OK is pressed
LCD_PutString(48,58,"OK",Yellow,Red);
else
LCD_PutString(48,58,"OK",Red,Yellow);
if (((GPIOC->IDR & BP2) == 0 )) // Check if BP2 is not pressed
LCD_PutString(100,40,"BP2",Yellow,Red);
else
LCD_PutString(100,40,"BP2",Red,Yellow);
if (((GPIOA->IDR & BP3) == 0 )) // Check if BP3 is not pressed
LCD_PutString(100,76,"BP3",Yellow,Red);
else
LCD_PutString(100,76,"BP3",Red,Yellow);
}
}
}
https://static.assets-stash.eet-china.com/album/old-resources/2009/5/2/22b661b7-6a98-4b35-b2ca-cccbfc7868f0.rar
文章评论(0条评论)
登录后参与讨论