• MSPM0G3507——GPIO例程讲解1——input_capture


    函数: 

     参数:

    返回值: 

    主函数代码:

    1. #include "ti_msp_dl_config.h"
    2. extern volatile uint32_t interruptVectors[];
    3. int main(void)
    4. {
    5. SYSCFG_DL_init(); //把所有的LED灯和按键初始化了一遍
    6. /*
    7. * Turn OFF LED if SW is open, ON if SW is closed.
    8. * LED starts OFF by default.
    9. */
    10. NVIC_EnableIRQ(GPIO_SWITCHES_INT_IRQN); //先允许外部中断
    11. while (1) {
    12. __WFI();
    13. }
    14. }
    15. void GROUP1_IRQHandler(void)
    16. {
    17. switch (DL_Interrupt_getPendingGroup(DL_INTERRUPT_GROUP_1)) //判断是GROUP1中哪个中断挂起
    18. {
    19. case GPIO_SWITCHES_INT_IIDX: //是按键的中断
    20. /* If SW is high, turn the LED off */
    21. if (DL_GPIO_readPins(GPIO_SWITCHES_PORT, GPIO_SWITCHES_USER_SWITCH_1_PIN))
    22. {
    23. DL_GPIO_setPins(GPIO_LEDS_PORT, GPIO_LEDS_USER_LED_1_PIN);
    24. }
    25. /* Otherwise, turn the LED on */
    26. else
    27. {
    28. DL_GPIO_clearPins(GPIO_LEDS_PORT, GPIO_LEDS_USER_LED_1_PIN);
    29. }
    30. break;
    31. }
    32. }

     宏定义代码:

    1. #ifndef ti_msp_dl_config_h
    2. #define ti_msp_dl_config_h
    3. #define CONFIG_MSPM0G350X
    4. #if defined(__ti_version__) || defined(__TI_COMPILER_VERSION__)
    5. #define SYSCONFIG_WEAK __attribute__((weak))
    6. #elif defined(__IAR_SYSTEMS_ICC__)
    7. #define SYSCONFIG_WEAK __weak
    8. #elif defined(__GNUC__)
    9. #define SYSCONFIG_WEAK __attribute__((weak))
    10. #endif
    11. #include <ti/devices/msp/msp.h>
    12. #include <ti/driverlib/driverlib.h>
    13. #include <ti/driverlib/m0p/dl_core.h>
    14. #ifdef __cplusplus
    15. extern "C" {
    16. #endif
    17. /*
    18. * ======== SYSCFG_DL_init ========
    19. * Perform all required MSP DL initialization
    20. *
    21. * This function should be called once at a point before any use of
    22. * MSP DL.
    23. */
    24. /* clang-format off */
    25. #define POWER_STARTUP_DELAY (16)
    26. #define CPUCLK_FREQ 32000000
    27. /* Port definition for Pin Group GPIO_LEDS */
    28. #define GPIO_LEDS_PORT (GPIOA)
    29. /* Defines for USER_LED_1: GPIOA.0 with pinCMx 1 on package pin 33 */
    30. #define GPIO_LEDS_USER_LED_1_PIN (DL_GPIO_PIN_0)
    31. #define GPIO_LEDS_USER_LED_1_IOMUX (IOMUX_PINCM1)
    32. /* Port definition for Pin Group GPIO_SWITCHES */
    33. #define GPIO_SWITCHES_PORT (GPIOB)
    34. /* Defines for USER_SWITCH_1: GPIOB.21 with pinCMx 49 on package pin 20 */
    35. // pins affected by this interrupt request:["USER_SWITCH_1"]
    36. #define GPIO_SWITCHES_INT_IRQN (GPIOB_INT_IRQn)
    37. #define GPIO_SWITCHES_INT_IIDX (DL_INTERRUPT_GROUP1_IIDX_GPIOB)
    38. #define GPIO_SWITCHES_USER_SWITCH_1_IIDX (DL_GPIO_IIDX_DIO21)
    39. #define GPIO_SWITCHES_USER_SWITCH_1_PIN (DL_GPIO_PIN_21)
    40. #define GPIO_SWITCHES_USER_SWITCH_1_IOMUX (IOMUX_PINCM49)
    41. /* clang-format on */
    42. void SYSCFG_DL_init(void);
    43. void SYSCFG_DL_initPower(void);
    44. void SYSCFG_DL_GPIO_init(void);
    45. void SYSCFG_DL_SYSCTL_init(void);
    46. #ifdef __cplusplus
    47. }
    48. #endif
    49. #endif /* ti_msp_dl_config_h */

    主函数中有这个函数:

    DL_Interrupt_getPendingGroup(DL_INTERRUPT_GROUP_1);

    这是用来判断是那个中断挂起的,具体的介绍,参数,返回值在开头三个图片中。

  • 相关阅读:
    记一次内网靶机实战
    原生HTML Select下拉多选 + vue
    【数据结构】Golang 实现单链表
    PostgreSQL进阶
    如何学习一门技术
    若依 | 点击顶部 tag 标签不自动刷新
    Qt之submodule编译
    PTE-RA总结
    50道Redis面试题,来看看你会多少?
    基于Java的国内外重大新闻展示平台的设计与实现
  • 原文地址:https://blog.csdn.net/2302_80529671/article/details/139888641