/* 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);
}
}
}