[PLATFORM_SDK]How add gpio interrupt into Platform SDK

cancel
Showing results for 
Search instead for 
Did you mean: 

[PLATFORM_SDK]How add gpio interrupt into Platform SDK

617 Views
tongchunyang
Contributor III

Hello Everyone

Now I want to add a gpio interrupt test code into Platform SDK.

And all is run well (Coding/Compiling/Start Runing), but when run time with doing GPIO interrupt there is no response.

Detail:

1, source code in ../sdk/drivers/gpio/test/gpio_interrupt_test.c

#include "sdk.h"

#include "gpio/gpio.h"

#include "core/interrupt.h"

#include <stdio.h>

#define GPIO5_ICR1    ((uint32_t *)(0x20ac00c))

#define GPIO5_IMR    ((uint32_t *)(0x20ac014))

#define GPIO5_PIN10    (10)

//globals used for gpio_irq_test

unsigned int gpio_irq_served;

void gpio_interrupt_handler(void)

{

    printf("GPIO5 has been interrupted\n");

    gpio_irq_served = TRUE;

}

int gpio_irq_test(void)

{

    printf("Start GPIO5 IRQ test:\n");

    gpio5_iomux_config();

    gpio_set_direction(GPIO_PORT5, GPIO5_PIN10, GPIO_GDIR_INPUT);

    *(GPIO5_ICR1) = (uint32_t)0xc00;    // GPIO5 ICR1 falling edge for IO5

    *(GPIO5_IMR)  = (uint32_t)0x20;     // GPIO5 IMR enabling mask for IO5

    /* register the IRQ sub-routine */

    register_interrupt_routine(IMX_INT_GPIO5_INT15_0, gpio_interrupt_handler);

    /* enable the IRQ */

    enable_interrupt(IMX_INT_GPIO5_INT15_0, CPU_0, 0);

    while (gpio_irq_served == FALSE);

    return TEST_PASSED;

}

]\

2, Calling of the function defined above hase been added into all_test.c whitch placed into ../apps/sdk_unit_test/src/

3, Also I have just added the test printf into the source file of interrupt.c, whitch stored at ../sdk/core/src

//! @brief Handles IRQ exceptions. __attribute__ ((interrupt("IRQ"))) void IRQ_HDLR(void) {     // vectNum = RESERVED[31:13] | CPUID[12:10] | INTERRUPT_ID[9:0]     // send ack and get ID source     uint32_t vectNum = gic_read_irq_ack();     printf("[IRQ_HDLR]start, vectNum = 0x%x\n", vectNum);

4, When compiled finished, I just run the test and got the result like below:

result.png

Just like described above, I found that in the Platform_SDK, the interrupt function named IRQ_HDLR[intterrupt.c] could not be executed at all

Could anyone please tell me how to enable interrupt execution about Platform SDK?

Labels (1)
0 Kudos
2 Replies

170 Views
igorpadykov
NXP TechSupport
NXP TechSupport

Hi Tong

please look at attached code it may help

you (based on SDK).

Best regards

chip

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

-----------------------------------------------------------------------------------------------------------------------

170 Views
tongchunyang
Contributor III

Hi c

0 Kudos