本帖最后由 xyz549040622 于 2023-4-27 10:03 编辑
#include "ti_msp_dl_config.h"
extern volatile uint32_t interruptVectors[];
int main(void)
{
SYSCFG_DL_init();
/*
* Turn OFF LED if SW is open, ON if SW is closed.
* LED starts OFF by default.
*/
NVIC_EnableIRQ(GPIO_SWITCHES_INT_IRQN);//使能IO中断
while (1) {
__WFI();
}
}
void GROUP1_IRQHandler(void)
{
switch (DL_Interrupt_getPendingGroup(DL_INTERRUPT_GROUP_1)) {//选择获取中断标志位进行判断
case GPIO_SWITCHES_INT_IIDX://检测到对应的中断标志位
/* If SW is high, turn the LED off */
if (DL_GPIO_readPins(//读取输入脚的状态,并进行对应的LED脚状态翻转
GPIO_SWITCHES_PORT, GPIO_SWITCHES_USER_SWITCH_1_PIN)) {
DL_GPIO_setPins(GPIO_LEDS_PORT, GPIO_LEDS_USER_LED_1_PIN);
}
/* Otherwise, turn the LED on */
else {
DL_GPIO_clearPins(GPIO_LEDS_PORT, GPIO_LEDS_USER_LED_1_PIN);
}
break;
}
}
|