This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RTOS/AM5728: Sample code of sending interrupt by using GPIO pin

Guru 10235 points
Part Number: AM5728

Tool/software: TI-RTOS

Hello, TI Experts,

 

Our customer sent us a question about GPIO interrupt with PROCESSOR-SDK-RTOS-AM57X.

They would like to know how to send interrupt to external device by using GPIO pin.

 

Question:

  Are there any sample code of sending interrupt by using GPIO pin?

We would appreciate if you tell us the recommended way of sending interrupt by using GPIO pin.

Best regards,

  • Hi Matusan,

    For generating GPIO interrupt output, you just need to toggle the GPIO output pin. You can refer to the LED toggle example:

    software-dl.ti.com/.../index_device_drv.html

    processor_sdk_rtos_am57xx_5_02_00_10/demos/jailhouse-inmate/baremetal/led/led_test.c

    pdk_am57xx_1_0_13/packages/ti/drv/gpio/test/led_blink/src/main_led_blink.c
    pdk_am57xx_1_0_13/packages/ti/board/diag/led/src/led_test.c

    You can also check how reset signal is generated on GPIO pin output:

    pdk_am57xx_1_0_13/packages/ti/drv/mmcsd/test/src/main_emmc.c
    pdk_am57xx_1_0_13/packages/ti/drv/mcasp/example/evmAM437x/src/audio_evmInit.c
    pdk_am57xx_1_0_13/packages/ti/drv/spi/test/src/main_mcspi_test.c

    Regards,
    Pavel
  • Hi,

     

    Thank you very much for your kindness.

    I really appreciate your help.

     

    Our customer sent us additional question like below;

    They also want to know how to send interrupt from external device to A15_0 by using GPIO pin.

     

    Question:

    Are there any sample code of sending interrupt from external device to A15_0 by using GPIO pin?

     

    We would appreciate if you tell us the recommended way of sending interrupt from external device to A15_0 by using GPIO pin.

     

    Best regards,

  • Matusan,

    Each gpio pin can be configured to generate interrupts based on event type GPIO_CFG_IN_INT_XXX configuration. To generate interrupt, gpio pin has to be configured as input pin.

    For example, you can refer to the same GPIO_LedBlink (Simple example demonstrating LED Toggling):

    pdk_am57xx_1_0_13/packages/ti/drv/gpio/test/led_blink/src/am572x/GPIO_idkAM572x_board.c

    /* Input pin with interrupt enabled */
    GPIO_DEVICE_CONFIG(GPIO_GRN_LED_PORT_NUM_1P2, GPIO_GRN_LED_PIN_NUM_1P2) |
    GPIO_CFG_IN_INT_RISING | GPIO_CFG_INPUT,

    /* Input pin with interrupt enabled */
    GPIO_DEVICE_CONFIG(GPIO_GRN_LED_PORT_NUM_1P3, GPIO_GRN_LED_PIN_NUM_1P3) |
    GPIO_CFG_IN_INT_RISING | GPIO_CFG_INPUT,

    You can also check below example:

    processor_sdk_rtos_am57xx_5_02_00_10/demos/rtos_template_app/am572x/evmAM572X/A15/template_app/GPIO_evmAM572x_board.c

    /* Input pin with interrupt enabled : AM57X_IDK_GRN_LED */
    GPIO_DEVICE_CONFIG(GPIO_USER0_LED_PORT_NUM, GPIO_USER0_LED_PIN_NUM) |
    GPIO_CFG_IN_INT_RISING | GPIO_CFG_INPUT,


    Regards,
    Pavel
  • Hi,

     

    Thank you very much for your kindness.

    I really appreciate your help.

     

    They sent us additional questions.

    They found interruption related description such as "Hwi_create" like below;

    http://software-dl.ti.com/dsps/dsps_public_sw/sdo_sb/targetcontent/sysbios/6_33_03_33/exports/bios_6_33_03_33/docs/cdoc/ti/sysbios/hal/Hwi.html

    Hwi_create(Int intNum, Hwi_FuncPtr hwiFxn, const Hwi_Params *params, Error_Block *eb)

     

    Question:

       - Do we have to use "Hwi_create" to send interrupt from GPIO to A15_0?

       - Could you tell us what does the "intNum" mean?

         - Is it ”IRQ_CROSSBAR Instance Number" in Table Table 17-2. MPU_INTC Default Interrupt Mapping in the below TRM?

           http://www.ti.com/lit/ug/spruhz6k/spruhz6k.pdf      

     

    We would appreciate if you tell us how to use "Hwi_create" including sample code.

     

    Best regards,

     

     

  • Matusan,

    I can not find "Hwi_create" usage in the GPIO interrupt input examples:

    pdk_am57xx_1_0_13/packages/ti/drv/gpio/test/led_blink
    processor_sdk_rtos_am57xx_5_02_00_10/demos/rtos_template_app/am572x/evmAM572X/A15/

    I can find only reference to BIOS HWI library:

    pdk_am57xx_1_0_13/packages/ti/drv/gpio/test/led_blink/am572x/armv7/bios/gpio_arm_idkAM572x.cfg
    processor_sdk_rtos_am57xx_5_02_00_10/demos/rtos_template_app/am572x/evmAM572X/A15/template_app/main.cfg

    Thus I do not think you should directly use "Hwi_create" in your own GPIO test code. Please check also if below pointers will be in help:

    e2e.ti.com/.../654256
    e2e.ti.com/.../728877
    e2e.ti.com/.../507749

    processors.wiki.ti.com/.../Configuring_Interrupts_on_Keystone_Devices
    processors.wiki.ti.com/.../Processor_SDK_RTOS:_TI_RTOS_Tips_And_Tricks

    Regards,
    Pavel
  • Hi,

    Thank you very much for your kindness.
    I really appreciate your help.
    I will send the answer to the customer.

    Best regards,