Hello,
I 'm trying to detect a external interruption. For do this thing, I have selected the GPIO 24 and i use this code
#define NUM_GPIO_IN 1
#define READ_SIZE 8
u8 DataBuffer[READ_SIZE];
extern u32 spi_handler;
/* HANDSHAKE BUS CONFIG. FOR CONTROL THE COMUNICATION PMC->WMP*/
adl_ioDefs_t Gpio_In_Config[NUM_GPIO_IN] = {
(ADL_IO_GPIO | 24 |ADL_IO_DIR_IN) };
s32 HandleGPIO,HandleGPIO_O;
s32 MyGpioEventHandle;
s32 ReadValue;
/*GPIO event handler*/
void MyGpioEventHandler ( s32 GpioHandle, adl_ioEvent_e Event, u32 Size, void *Param )
{
switch ( Event )
{
/*the subscribed input states has changed*/
case ADL_IO_EVENT_INPUT_CHANGED :
//I read the value of the GPIO 24 for know if I have a zero or a one
ReadValue = adl_ioReadSingle (HandleGPIO,Gpio_In_Config);
TRACE((1,"ReadValue = %d",ReadValue));
TRACE((1,"change"));
break;
}
}
void InitGPIO ( void )
{
// TODO Insert your task initialization code here
//Subscribe to the event
MyGpioEventHandle = adl_ioEventSubscribe (MyGpioEventHandler);
//I see if I have any error in the ioEventSubscription
TRACE (( 1, "handler returns %d", MyGpioEventHandle ));
if (MyGpioEventHandle>='0')
{
TRACE (( 7, "BIEN" ));
}
switch(MyGpioEventHandle)
{
case ADL_RET_ERR_PARAM:
TRACE (( 1, "if a parameter has an incorrect value" ));
break;
case ADL_RET_ERR_NO_MORE_HANDLES:
TRACE (( 1, "no more GPIO handles are available" ));
break;
case ADL_RET_ERR_SERVICE_LOCKED:
TRACE (( 1, "the function was called from a low level Interrupt handler" ));
break;
}
//subscribe to the input GPIO
HandleGPIO=adl_ioSubscribe(NUM_GPIO_IN,Gpio_In_Config,ADL_TMR_TYPE_TICK,1,MyGpioEventHandle);
//I see if I have any error in the ioSubscription
TRACE (( 1, "handler returns %d", HandleGPIO ));
switch(HandleGPIO)
{
case ADL_RET_ERR_PARAM:
TRACE (( 1, "if a parameter has an incorrect value" ));
break;
case ADL_RET_ERR_DONE:
TRACE (( 1, "refers to the field 3.10.2.6 adl_ioError_e" ));
break;
case ADL_RET_ERR_NO_MORE_TIMERS:
TRACE (( 1, "there is no timer available to start" ));
break;
case ADL_RET_ERR_NO_MORE_HANDLES:
TRACE (( 1, "no more GPIO handles are available" ));
break;
case ADL_RET_ERR_SERVICE_LOCKED:
TRACE (( 1, "the function was called from a low level Interrupt handler" ));
break;
}
/*
HandleGPIO_O=adl_ioSubscribe(NUM_GPIO_OUT,Gpio_Out_Config,0,0,0);
TRACE (( 1, "handler_O returns %d", HandleGPIO_O ));
switch(HandleGPIO_O)
{
case ADL_RET_ERR_PARAM:
TRACE (( 1, "if a parameter has an incorrect value" ));
break;
case ADL_RET_ERR_DONE:
TRACE (( 1, "refers to the field 3.10.2.6 adl_ioError_e" ));
break;
case ADL_RET_ERR_NO_MORE_TIMERS:
TRACE (( 1, "there is no timer available to start" ));
break;
case ADL_RET_ERR_NO_MORE_HANDLES:
TRACE (( 1, "no more GPIO handles are available" ));
break;
case ADL_RET_ERR_SERVICE_LOCKED:
TRACE (( 1, "the function was called from a low level Interrupt handler" ));
break;
}
*/
ReadValue = adl_ioReadSingle (HandleGPIO,Gpio_In_Config );
TRACE((1,"ReadValue = %d",ReadValue));
}
Is this code correct? I tried this code changing the GPIO and it detects that the GPIO is changing, but if I use the GPIO that I want, it doesn’t work. It’s possible that the problem could be that my port has value “1” only 0,128 ms? Do I have another option to receive the interruption?
Thank you,
Andrés