SONG ZHAO

MQX GPIO interrupt

Discussion created by SONG ZHAO on Jun 8, 2010
Latest reply on Jan 18, 2012 by Murat Gunal

Hi

 

I want to assign an interrupt handler to a button but this handler cannot be invoked when I pressed the button.

The following are the main code and can someone take a look and give some advice? I use MCF52235evb

 

//define the pin list button1

FILE_PTR btn_file;

 

 #define BTN1
    static const GPIO_PIN_STRUCT btn1[] = {
       BSP_BUTTON1 | GPIO_PIN_IRQ,
       GPIO_LIST_END
    };

 

//open file

btn_file = fopen("gpio:read", (char_ptr) &btn1)

 

//enable interrupt, I am not sure if it's necessary

ioctl(btn_file, GPIO_IOCTL_ENABLE_IRQ, NULL)

 

//register callback function

ioctl(btn_file, GPIO_IOCTL_SET_IRQ_FUNCTION, (char_ptr)&btn1_callback)

 

I really cannot find out what's wrong with this code.

 

Thanks a lot!!!!!!

Outcomes