Multiple GPIO configurations

Hi Everyone,

In the following code, i’m having trouble to Subscribe multiple gpio’s. :unamused:

Please do verify the code and comment.

/**************************************************************************/
/
GPIO PIN constants /
/
**************************************************************************/

#define GPS_EN_PIN (ADL_IO_GPIO | 2)
#define SDB_232_PIN (ADL_IO_GPIO | 4)
#define EN1_232_PIN (ADL_IO_GPIO | 5)
#define RS485_EN_PIN (ADL_IO_GPIO | 6)
#define RS485_RX_EN_PIN (ADL_IO_GPIO | 7)
#define EN2_232_PIN (ADL_IO_GPIO | 9)
#define RS485_TX_EN_PIN (ADL_IO_GPIO | 8 )

/**************************************************************************/
/
GPIO Declaration /
/
**************************************************************************/

adl_ioDefs_t GPS_EN_GpioConfig[1] = { GPS_EN_PIN | ADL_IO_DIR_OUT};
adl_ioDefs_t SDB_232_GpioConfig[1] = { SDB_232_PIN | ADL_IO_DIR_OUT};
adl_ioDefs_t EN1_232_GpioConfig[1] = { EN1_232_PIN | ADL_IO_DIR_OUT };
adl_ioDefs_t RS_485_EN_GpioConfig[1] = { RS485_EN_PIN | ADL_IO_DIR_OUT };
adl_ioDefs_t EN_485_RX_GpioConfig[1] = { RS485_RX_EN_PIN | ADL_IO_DIR_OUT };
adl_ioDefs_t EN2_232_GpioConfig[1] = { EN2_232_PIN | ADL_IO_DIR_OUT};
adl_ioDefs_t RS_485_TX_EN_GpioConfig[1] = { RS485_TX_EN_PIN | ADL_IO_DIR_OUT};

/**************************************************************************/
/
Global Variable Declaration /
/
**************************************************************************/
s32 SDB_232_GpioHandle,EN1_232_GpioHandle,EN2_232_GpioHandle,GPS_EN_GpioHandle;
s32 RS_485_EN_GpioHandle, EN_485_RX_GpioHandle,RS_485_TX_EN_GpioHandle;

/*******************************************************************/
/
Function : cbMtInit /
/
-------------------------------------------------------------------------
/
/
Object : Subscribe to the AT+WDU command /
/
/
/
Return : None /
/
-------------------------------------------------------------------------
/
/
Variable Name |IN |OUT|GLB| Utilization /
/
--------------------±–±--±–±---------------------------------------
/
/
| | | | /
/
--------------------±–±--±–±---------------------------------------
/
/***************************************************************************/
void cbMtInit ( void )
{
s16 Ret = OK;
adl_InitType_e adlInitType = adl_InitGetType ();

TRACE ( ( UA_MAINTASK_TRACEID, "OK - cbMtInit" ) );
TRACE ( ( UA_MAINTASK_TRACEID, __DATE__ ) );
TRACE ( ( UA_MAINTASK_TRACEID, __TIME__ ) );

/* GPS_EN_PIN Subscribe */
GPS_EN_GpioHandle = adl_ioSubscribe ( 1, GPS_EN_GpioConfig, 0, 0,0 );
TRACE ( ( 1, “Subscribe to GPS_EN[%X] %d error code %X”,
( GPS_EN_GpioConfig[0] & ADL_IO_LABEL_MSK ),
GPS_EN_GpioHandle, ( GPS_EN_GpioConfig[0] & ADL_IO_ERR_MSK ) ) );

   /* SDB_232_PIN Subscribe  */
SDB_232_GpioHandle = adl_ioSubscribe ( 1, SDB_232_GpioConfig, 0, 0,0 );
TRACE ( ( 1,	"Subscribe to SDB_232[%X] %d error code %X",
         ( SDB_232_GpioConfig[0] & ADL_IO_LABEL_MSK ),
            SDB_232_GpioHandle, ( SDB_232_GpioConfig[0] & ADL_IO_ERR_MSK ) ) );

/* EN1_232_PIN Subscribe  */
EN1_232_GpioHandle = adl_ioSubscribe ( 1, EN1_232_GpioConfig, 0, 0,0 );
TRACE ( ( 1,	"Subscribe to EN_232[%X] %d error code %X",
		  ( EN1_232_GpioConfig[0] & ADL_IO_LABEL_MSK ),
		  EN1_232_GpioHandle, ( EN1_232_GpioConfig[0] & ADL_IO_ERR_MSK ) ) );

/* RS_485_EN_PIN Subscribe   */
RS_485_EN_GpioHandle = adl_ioSubscribe ( 1, RS_485_EN_GpioConfig, 0, 0,0 );
TRACE ( ( 1,	"Subscribe to RS_485_EN[%X] %d error code %X",
		( 	RS_485_EN_GpioConfig[0] & ADL_IO_LABEL_MSK ),
			RS_485_EN_GpioHandle, ( RS_485_EN_GpioConfig[0] & ADL_IO_ERR_MSK ) ) );

		/* EN_485_RX_PIN Subscribe  */
EN_485_RX_GpioHandle = adl_ioSubscribe ( 1, EN_485_RX_GpioConfig, 0, 0,0 );
TRACE ( ( 1,	"Subscribe to EN_485_RX[%X] %d error code %X",
		( EN_485_RX_GpioConfig[0] & ADL_IO_LABEL_MSK ),
		EN_485_RX_GpioHandle, ( EN_485_RX_GpioConfig[0] & ADL_IO_ERR_MSK ) ) );

/* EN2_232_PIN Subscribe  */
EN2_232_GpioHandle = adl_ioSubscribe ( 1, EN2_232_GpioConfig, 0, 0,0 );
TRACE ( ( 1,	"Subscribe to EN2_232[%X] %d error code %X",
		( EN2_232_GpioConfig[0] & ADL_IO_LABEL_MSK ),
		 EN2_232_GpioHandle, ( EN2_232_GpioConfig[0] & ADL_IO_ERR_MSK ) ) );

	/* RS_485_TX_EN_PIN Subscribe  */
RS_485_TX_EN_GpioHandle = adl_ioSubscribe ( 1, RS_485_TX_EN_GpioConfig, 0, 0,0 );
  TRACE ( ( 1,	"Subscribe to RS_485_TX_EN_[%X] %d error code %X",
			( 	RS_485_TX_EN_GpioConfig[0] & ADL_IO_LABEL_MSK ),
			RS_485_TX_EN_GpioHandle, ( RS_485_TX_EN_GpioConfig[0] & ADL_IO_ERR_MSK ) ) );


/* Subscription to the +WDU AT command */
Ret = adl_atCmdSubscribe ( ( ascii* ) CmdString, cbDirectUartCmdHandler,
                ( ADL_CMD_TYPE_PARA | UA_WDU_CMD_PARAM_CONFIG ) );


UA_ASSERT ( Ret );
if ( Ret == OK )
{
    adl_atSendResponse ( ADL_AT_RSP, Warning );
    adl_atSendResponse ( ADL_AT_RSP, CmdHelp1 );
    adl_atSendResponse ( ADL_AT_RSP, CmdHelp2 );
}
else
{
    adl_atSendResponse ( ADL_AT_RSP, CmdHelp3 );
    TRACE ( ( UA_MAINTASK_TRACEID, " adl_atCmdSubscribe Returns : %d",
              Ret ) );
}

}

Following is the trace available

2014/01/09;19:00:44:383;001;ADL;1;Binary header at 002A0000
2014/01/09;19:00:44:383;002;ADL;1;OK - cbMtInit
2014/01/09;19:00:44:384;001;ADL;1;Jan 9 2014
2014/01/09;19:00:44:384;002;ADL;1;18:39:11
2014/01/09;19:00:44:388;001;ADL;1;Subscribe to GPS_EN[3002] 403114376 error code 0
2014/01/09;19:00:44:389;001;ADL;1;Subscribe to SDB_232[3004] -11 error code 20000000
2014/01/09;19:00:44:390;001;ADL;1;Subscribe to EN_232[3005] -11 error code 20000000
2014/01/09;19:00:44:390;002;ADL;1;Subscribe to RS_485_EN[3006] -11 error code 20000000
2014/01/09;19:00:44:392;001;ADL;1;Subscribe to EN_485_RX[3007] -11 error code 20000000
2014/01/09;19:00:44:394;001;ADL;1;Subscribe to EN2_232[3009] -11 error code 20000000
2014/01/09;19:00:44:395;001;ADL;1;Subscribe to RS_485_TX_EN_[3008] -11 error code 20000000
2014/01/09;19:00:44:395;002;ADL;3;[cbUART1Rx] Task Context [1]
2014/01/09;19:00:44:395;003;ADL;3;cbUART1Rx [180709a8]
2014/01/09;19:00:44:404;001;ADL;3;Wait for a Received Data…
2014/01/09;19:00:44:404;002;ADL;4;[cbUART2Rx] Task Context [2]
2014/01/09;19:00:44:404;003;ADL;4;cbUART2Rx [1806f678]
2014/01/09;19:00:44:405;001;ADL;4;Wait for a Received Data…

Hiya,

First, PLEASE use the CODE tags to format your code when posting - it makes it much easier to read.

Your code is returning the error code ‘-11’ from all the subscriptions bar the first one. Looking up the ADL API guide, Error -11 is ‘ADL_RET_ERR_DONE’, which the adl_ioSubscribe() doc indicates that you have to look up the adl_ioError_e type.

Doing a bit of maths on your result (20000000) gives the error ADL_IO_ERR_USED - which indicates that the GPIO pin is already used by another section of the Q2686RD.

Moving to the Q2686RD Product Technical Spec (PTS) indicates that GPIO[8:4] are nominally configured as Keypad column drives [4:0], and GPIO[9:13] are keypad row drives [0-4].

The keyboard is enabled by default in a Q2686 modem - so OpenAT cannot access the GPIO assigned to the keyboard.

You have two options:

  1. Move your I/O to different pins (after having a careful read of the PTS);
  2. Disable the keyboard using the AT+WHCNF command.

Two things to learn here:

  1. Examine the error results VERY carefully - and reference back to the API doco (and PTS if you’re doing hardware design).
  2. Read the API and PTS doco VERY carefully - and read ALL of it, not just the function you are using at the time. Although, do be aware that some of the examples haven’t caught up with the API changes…

ciao, Dave

p.s. Don’t forget to use the CODE tags next time you post example code…

Hi,
David

Well i’m able to subscribe for the required GPIO’s and GPS data is available on UART.

i’m learning to read the error results according to the document and work. I’m not familiar with this portal, so, i’m not able use tags. From next i’ll definitely use the tags.