# Multiple GPIO configurations

**URL:** <https://forum.sierrawireless.com/t/multiple-gpio-configurations/6958>\
**Category:** Legacy AirPrime modules\
**Created:** [January 9, 2014, 1:37pm UTC](https://forum.sierrawireless.com/t/multiple-gpio-configurations/6958 "2014-01-09T13:37:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sridhartagv](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@sridhartagv](https://forum.sierrawireless.com/u/sridhartagv)\
**Post date:** [January 9, 2014, 1:37pm UTC](https://forum.sierrawireless.com/t/multiple-gpio-configurations/6958/1 "2014-01-09T13:37:06Z")

</div>

Hi Everyone,

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

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…

---

<div class="post-metadata">

**Author:** ![davidc](https://avatars.discourse-cdn.com/v4/letter/d/a183cd/32.png) [@davidc](https://forum.sierrawireless.com/u/davidc)\
**Post date:** [January 10, 2014, 3:57am UTC](https://forum.sierrawireless.com/t/multiple-gpio-configurations/6958/2 "2014-01-10T03:57:10Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![sridhartagv](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@sridhartagv](https://forum.sierrawireless.com/u/sridhartagv)\
**Post date:** [January 11, 2014, 7:44am UTC](https://forum.sierrawireless.com/t/multiple-gpio-configurations/6958/3 "2014-01-11T07:44:33Z")

</div>

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.
