目录
4. PINT_PinInterruptConfig配置PINT外设引脚中断
1.前言
此例子为SDK example,如下图
2.设置按键ISP为外部中断
3. 初始化外部中断---PINT
kINPUTMUX_GpioPort0Pin5ToPintsel对于的pin PIO0_5
/*!
* @brief Call back for PINT Pin interrupt 0-7.
* 不能有延迟,可以在此回调中翻转gpio等操作
*/
void pint_intr_callback(pint_pin_int_t pintr, uint32_t pmatch_status)
{
PRINTF("\f\r\nPINT Pin Interrupt %d event detected.", pintr);
}
/*!
* @brief Main function
*/
int main(void)
{
/* Board pin, clock, debug console init */
/* set BOD VBAT level to 1.65V */
POWER_SetBodVbatLevel(kPOWER_BodVbatLevel1650mv, kPOWER_BodHystLevel50mv, false);
/* attach 12 MHz clock to FLEXCOMM0 (debug console) */
CLOCK_AttachClk(kFRO12M_to_FLEXCOMM0);
BOARD_InitBootPins();
BOARD_InitBootClocks();
BOARD_InitDebugConsole();
//外部中断部分
/* Connect trigger sources to PINT */
INPUTMUX_Init(INPUTMUX); //初始化INPUTMUX,启用INPUTMUX时钟
INPUTMUX_AttachSignal(INPUTMUX, kPINT_PinInt0, kINPUTMUX_GpioPort0Pin5ToPintsel); //PIO0_5
/* Turnoff clock to inputmux to save power. Clock is only needed to make changes */
INPUTMUX_Deinit(INPUTMUX);
/* Initialize PINT */
PINT_Init(PINT);
/* Setup Pin Interrupt 0 for rising edge */
PINT_PinInterruptConfig(PINT, kPINT_PinInt0, kPINT_PinIntEnableRiseEdge, pint_intr_callback); //配置PINT外设引脚中断
/* Enable callbacks for PINT0 by Index */
PINT_EnableCallbackByIndex(PINT, kPINT_PinInt0);
PRINTF("\r\nPINT Pin Interrupt events are configured\r\n");
PRINTF("\r\nPress corresponding switches to generate events\r\n");
while (1)
{
__WFI();
}
}
4. PINT_PinInterruptConfig配置PINT外设引脚中断
其中第三个参数kPINT_PinIntEnableRiseEdge(在上升边产生引脚中断),总共有三种模式上升沿 下降沿 和双边沿,其他模式如下图
/*! @brief PINT Pin Interrupt enable type */
typedef enum _pint_pin_enable
{
kPINT_PinIntEnableNone = 0U, /*!< Do not generate Pin Interrupt */ //不产生引脚中断
kPINT_PinIntEnableRiseEdge = PINT_PIN_RISE_EDGE, /*!< Generate Pin Interrupt on rising edge */ //在上升边产生引脚中断
kPINT_PinIntEnableFallEdge = PINT_PIN_FALL_EDGE, /*!< Generate Pin Interrupt on falling edge */ //在下降边缘产生引脚中断
kPINT_PinIntEnableBothEdges = PINT_PIN_BOTH_EDGE, /*!< Generate Pin Interrupt on both edges */ //在两边产生引脚中断
kPINT_PinIntEnableLowLevel = PINT_PIN_LOW_LEVEL, /*!< Generate Pin Interrupt on low level */ //在低电平上产生引脚中断
kPINT_PinIntEnableHighLevel = PINT_PIN_HIGH_LEVEL /*!< Generate Pin Interrupt on high level */ //在高层上产生引脚中断
} pint_pin_enable_t;
5.具体代码如下链接
LPC55S69通过上升沿触发ISP按键实现按一下亮蓝灯,按一下灭蓝灯
https://download.youkuaiyun.com/download/m0_50136807/87454169