函数:
参数:
返回值:
主函数代码:
#include "ti_msp_dl_config.h"extern volatile uint32_t interruptVectors[];int main(void)
{SYSCFG_DL_init(); //把所有的LED灯和按键初始化了一遍/** Turn OFF LED if SW is open, ON if SW is closed.* LED starts OFF by default.*/NVIC_EnableIRQ(GPIO_SWITCHES_INT_IRQN); //先允许外部中断while (1) {__WFI(); }
}void GROUP1_IRQHandler(void)
{switch (DL_Interrupt_getPendingGroup(DL_INTERRUPT_GROUP_1)) //判断是GROUP1中哪个中断挂起{case GPIO_SWITCHES_INT_IIDX: //是按键的中断/* If SW is high, turn the LED off */if (DL_GPIO_readPins(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;}
}
宏定义代码:
#ifndef ti_msp_dl_config_h
#define ti_msp_dl_config_h#define CONFIG_MSPM0G350X#if defined(__ti_version__) || defined(__TI_COMPILER_VERSION__)
#define SYSCONFIG_WEAK __attribute__((weak))
#elif defined(__IAR_SYSTEMS_ICC__)
#define SYSCONFIG_WEAK __weak
#elif defined(__GNUC__)
#define SYSCONFIG_WEAK __attribute__((weak))
#endif#include <ti/devices/msp/msp.h>
#include <ti/driverlib/driverlib.h>
#include <ti/driverlib/m0p/dl_core.h>#ifdef __cplusplus
extern "C" {
#endif/** ======== SYSCFG_DL_init ========* Perform all required MSP DL initialization** This function should be called once at a point before any use of* MSP DL.*//* clang-format off */#define POWER_STARTUP_DELAY (16)#define CPUCLK_FREQ 32000000/* Port definition for Pin Group GPIO_LEDS */
#define GPIO_LEDS_PORT (GPIOA)/* Defines for USER_LED_1: GPIOA.0 with pinCMx 1 on package pin 33 */
#define GPIO_LEDS_USER_LED_1_PIN (DL_GPIO_PIN_0)
#define GPIO_LEDS_USER_LED_1_IOMUX (IOMUX_PINCM1)
/* Port definition for Pin Group GPIO_SWITCHES */
#define GPIO_SWITCHES_PORT (GPIOB)/* Defines for USER_SWITCH_1: GPIOB.21 with pinCMx 49 on package pin 20 */
// pins affected by this interrupt request:["USER_SWITCH_1"]
#define GPIO_SWITCHES_INT_IRQN (GPIOB_INT_IRQn)
#define GPIO_SWITCHES_INT_IIDX (DL_INTERRUPT_GROUP1_IIDX_GPIOB)
#define GPIO_SWITCHES_USER_SWITCH_1_IIDX (DL_GPIO_IIDX_DIO21)
#define GPIO_SWITCHES_USER_SWITCH_1_PIN (DL_GPIO_PIN_21)
#define GPIO_SWITCHES_USER_SWITCH_1_IOMUX (IOMUX_PINCM49)/* clang-format on */void SYSCFG_DL_init(void);
void SYSCFG_DL_initPower(void);
void SYSCFG_DL_GPIO_init(void);
void SYSCFG_DL_SYSCTL_init(void);#ifdef __cplusplus
}
#endif#endif /* ti_msp_dl_config_h */
主函数中有这个函数:
DL_Interrupt_getPendingGroup(DL_INTERRUPT_GROUP_1);
这是用来判断是那个中断挂起的,具体的介绍,参数,返回值在开头三个图片中。