|
经验证,EXIT4可唤醒MCU。
///// 定义
#define DOWN_BUTTON_PORT GPIOD
#define DOWN_BUTTON_PIN GPIO_Pin_4
///// 中断服务程序
void EXTI4_IRQHandler(void) interrupt 12
{
/* Joystick DOWN button is pressed */
PressedButton = BUTTON_DOWN;
/* Cleat Interrupt pending bit */
EXTI_ClearITPendingBit(EXTI_IT_Pin4);
}
////// 主程
while (1)
{
halt();
switch (PressedButton)
{
case BUTTON_KEY:
{
/* LD5 is green */
STM_EVAL_LEDToggle(LED5);
LCD_PrintString(LCD_LINE2, DISABLE, DISABLE, "Button: KEY ");
PressedButton = NO_BUTTON;
break;
}
case BUTTON_RIGHT:
{
/* Toggle LD1 */
STM_EVAL_LEDToggle(LED1);
LCD_PrintString(LCD_LINE2, DISABLE, DISABLE, "Button: RIGHT");
PressedButton = NO_BUTTON;
break;
}
case BUTTON_LEFT:
{
/* Toggle LD2 */
STM_EVAL_LEDToggle(LED2);
LCD_PrintString(LCD_LINE2, DISABLE, DISABLE, "Button: LEFT ");
PressedButton = NO_BUTTON;
break;
}
case BUTTON_UP:
{
/* Toggle LD3*/
STM_EVAL_LEDToggle(LED3);
LCD_PrintString(LCD_LINE2, DISABLE, DISABLE, "Button: UP ");
PressedButton = NO_BUTTON;
break;
}
case BUTTON_DOWN:
{
/* Toggle LD4*/
STM_EVAL_LEDToggle(LED4);
LCD_PrintString(LCD_LINE2, DISABLE, DISABLE, "Button: DOWN ");
PressedButton = NO_BUTTON;
break;
}
case BUTTON_SEL:
{
/* LD5 toggle green/red */
STM_EVAL_LEDToggle(LED5);
LCD_PrintString(LCD_LINE2, DISABLE, DISABLE, "Button: SEL ");
PressedButton = NO_BUTTON;
break;
}
default:
{
break;
}
} |
|