\rv32m1_vega\driver_examples\gpio\input_interrupt 仿照这么这个例子改为其他按键,例如SW3,一直不行?

Home 论坛 开发和更新问题 \rv32m1_vega\driver_examples\gpio\input_interrupt 仿照这么这个例子改为其他按键,例如SW3,一直不行?

正在查看 5 帖子:1-5 (共 5 个帖子)
  • 作者
    帖子
  • #1936
    hyq666hyq666
    参与者

    \rv32m1_vega\driver_examples\gpio\input_interrupt 仿照这么这个例子改为其他按键,例如SW3,一直不行,什么原因?

    #1937
    hyq666hyq666
    参与者

    void BOARD_InitPins(void) {
    CLOCK_EnableClock(kCLOCK_PortA);
    CLOCK_EnableClock(kCLOCK_PortC); /* Clock Gate Control: 0x01u */
    CLOCK_EnableClock(kCLOCK_PortE); /* Clock Gate Control: 0x01u */

    const port_pin_config_t porte12_pinL12_config = {
    kPORT_PullDisable, /* Internal pull-up/down resistor is disabled */
    kPORT_FastSlewRate, /* Fast slew rate is configured */
    kPORT_PassiveFilterDisable, /* Passive filter is disabled */
    kPORT_OpenDrainDisable, /* Open drain is disabled */
    kPORT_LowDriveStrength, /* Low drive strength is configured */
    kPORT_MuxAsGpio, /* Pin is configured as PTE12 */
    kPORT_UnlockRegister /* Pin Control Register fields [15:0] are not locked */

    };
    PORT_SetPinConfig(PORTE, PIN12_IDX, &porte12_pinL12_config); /* PORTE12 (pin L12) is configured as PTE12 */
    PORT_SetPinMux(PORTA, PIN24_IDX, kPORT_MuxAsGpio); /* PORTA24 (pin D6) is configured as PTA24 */
    PORT_SetPinMux(PORTC, PIN7_IDX, kPORT_MuxAlt3); /* PORTC7 (pin N2) is configured as LPUART0_RX */
    PORT_SetPinMux(PORTC, PIN8_IDX, kPORT_MuxAlt3); /* PORTC8 (pin P3) is configured as LPUART0_TX */
    }

     

     

    #define BOARD_SW5_GPIO GPIOE
    #define BOARD_SW5_PORT PORTE
    #define BOARD_SW5_GPIO_PIN 12U
    #define BOARD_SW5_IRQ PORTE_IRQn
    #define BOARD_SW5_IRQ_HANDLER PORTE_IRQHandler
    #define BOARD_SW5_NAME “SW5”

    /* Board led color mapping */
    #define BOARD_LED_RED_GPIO GPIOA
    #define BOARD_LED_RED_GPIO_PIN 24U

    /*! @brief The TPM channel used for board */
    #define BOARD_TPM_CHANNEL 0U

    #1938
    hyq666hyq666
    参与者

    只能使用例子中SW2吗?

    #1939
    hyq666hyq666
    参与者

    // LSU error
    jal x0, LSU_Handler 程序跳到这里不走了是什么错误????

    #1940
    HowardHoward
    参与者
    • GPIOE是 Rapid/Fast GPIO,还需要打开Rapid/Fast GPIO 的clock,所以在BOARD_InitPins()中要enable rgpio clock

    void BOARD_InitPins(void) {
    CLOCK_EnableClock(kCLOCK_PortA); /* Clock Gate Control: 0x01u */
    CLOCK_EnableClock(kCLOCK_PortC); /* Clock Gate Control: 0x01u */
    CLOCK_EnableClock(kCLOCK_PortE); /* Clock Gate Control: 0x01u */
    CLOCK_EnableClock(kCLOCK_Rgpio1);

    ……

    }

    • 由于RISC-V中断只支持32个外部硬件中断信号,所以更多的中断信号是通过INTMUX模块来复用的。所以要初始化INTMUX这个模块。所以要在程序中添加INTMUX 驱动,即加入rv32m1_sdk_riscv\devices\RV32M1\drivers\fsl_intmux.c文件,然后在gpio_input_interrupt.c文件中 #include “fsl_intmux.h”,并且在初始化GPIOE中断加入红色代码行

    /* Init input switch GPIO. */

    INTMUX_Init(INTMUX0);
    INTMUX_EnableInterrupt(INTMUX0, 0, PORTE_IRQn);

    PORT_SetPinInterruptConfig(BOARD_SW3_PORT, BOARD_SW3_GPIO_PIN, kPORT_InterruptFallingEdge);
    EnableIRQ(BOARD_SW3_IRQ);
    GPIO_PinInit(BOARD_SW3_GPIO, BOARD_SW3_GPIO_PIN, &sw_config);

    • 其它修改对照SW2做对应修改

     

正在查看 5 帖子:1-5 (共 5 个帖子)
  • 抱歉,回复话题必需登录。