I 'm try to send a sms when SW300 is pressed. I read in the document that SW300 pressed is detected by COL0 (PIN 59) and
ROW0 (PIN 68). So I decided to use 1 GPO at 59 and 1 GPI at 68. But when I subscribe it using adl_ioSubscribe, the value return is -11 and it didn’t word. I don’t know why. Can anybody explain me please.
Here is my code:
#include "adl_global.h"
#define GPIO_OUTPUT_PIN 59 //COL0
#define GPIO_INPUT_PIN 68 //ROW0
//SMS service handle
static s8 SmsAutoHandle;
// GPIO service handle
static s32 GPIOHandle_OUT;
static s32 GPIOHandle_IN;
s32 ReadValue;
adl_ioDefs_t GpioConfig_OUT = ADL_IO_GPIO | GPIO_OUTPUT_PIN | ADL_IO_DIR_OUT;
adl_ioDefs_t GpioConfig_IN = ADL_IO_GPIO | GPIO_INPUT_PIN | ADL_IO_DIR_IN;
const u16 wm_apmCustomStackSize = 1024*3;
s32 GpioEventHandle;
static void SmsCtrlHandler ( u8 Event, u16 Nb )
{
/* Does nothing */
switch(Event)
{
case ADL_SMS_EVENT_SENDING_OK:
adl_atSendResponse(ADL_AT_RSP,"SMS Sent Successfully");
TRACE((1,"Inside ADL_SMS_EVENT_SENDING_OK EVENT"));
break;
case ADL_SMS_EVENT_SENDING_ERROR:
adl_atSendResponse(ADL_AT_RSP,"Error sending sms");
TRACE (( 1, "Error sending sms, try again" ));
break;
case ADL_SMS_EVENT_SENDING_MR:
TRACE (( 1, "SMS Sent Successfully" ));
TRACE((1,"Inside ADL_SMS_EVENT_SENDING_MR EVENT"));
break;
default:
adl_atSendResponse(ADL_AT_UNS,"Inside default");
break;
}
}
static bool SmsHandler ( ascii *SmsTel, ascii *SmsTimeOrLength,
ascii *SmsText )
{
//Do nothing
return 0;
}
void GpioEventHandler ( s32 GpioHandle, adl_ioEvent_e Event, u32 Size, void * Param )
{
s32 ReadValue_IN;
s32 ReadValue_OUT;
TRACE (( 1, "In GpioEventHandler" ));
// Check event
switch ( Event )
{
case ADL_IO_EVENT_INPUT_CHANGED :
ReadValue_IN = adl_ioReadSingle (GPIOHandle_IN, &GpioConfig_IN);
TRACE (( 1, "Read Value of ROW0" ));
if (ReadValue_IN == 1)
{
TRACE (( 1, "If ROW0 is HIGH, send sms to my cell phone" ));
//adl_ioWriteSingle ( GPIOHandle_OUT, &GpioConfig_OUT, TRUE );
//ReadValue = adl_ioReadSingle (GPIOHandle_IN, &GpioConfig_IN);
adl_smsSend(SmsAutoHandle, "0935020991", "Button 0 is pressed", ADL_SMS_MODE_TEXT);
}
break;
//adl_ioWriteSingle ( GPIOHandle_OUT, &GpioConfig_OUT, FALSE );
}
}
void adl_main ( adl_InitType_e InitType )
{
s32 ReadValue_IN, ReadValue_OUT;
//SMS Subscribe
TRACE (( 1, "In Main Application" ));
SmsAutoHandle = adl_smsSubscribe((adl_smsHdlr_f)SmsHandler,
(adl_smsCtrlHdlr_f)SmsCtrlHandler, ADL_SMS_MODE_TEXT);
TRACE (( 1, "SMS is subscribed" ));
TRACE (( 1, "SmsAutoHandle value is %d", SmsAutoHandle ));
//GPIO Subscribe
GpioEventHandle = adl_ioEventSubscribe (GpioEventHandler);
TRACE (( 1, "GPIO Event is subscribed" ));
TRACE (( 1, "GpioEventHandle value is %d", GpioEventHandle ));
GPIOHandle_OUT = adl_ioSubscribe ( 1, &GpioConfig_OUT, 0, 0, 0 );
GPIOHandle_IN = adl_ioSubscribe ( 1, &GpioConfig_IN, ADL_TMR_TYPE_100MS, 1, GpioEventHandle );
TRACE (( 1, "GPIOHandle_OUT value is %d", GPIOHandle_OUT ));
TRACE (( 1, "GPIOHandle_IN value is %d", GPIOHandle_IN ));
//adl_ioWriteSingle ( GPIOHandle_OUT, &GpioConfig_OUT, TRUE );
//TRACE (( 1, "SET COL0 HIGH" ));
ReadValue_IN = adl_ioReadSingle (GPIOHandle_IN, &GpioConfig_IN); //Read ROW0
ReadValue_OUT = adl_ioReadSingle (GPIOHandle_OUT, &GpioConfig_OUT); //Read COL0
TRACE (( 1, "ROW0 value is %d", ReadValue_IN ));
TRACE (( 1, "COL0 value is %d", ReadValue_OUT ));
}