# GPIO on Q2686

**URL:** <https://forum.sierrawireless.com/t/gpio-on-q2686/3055>\
**Category:** Legacy AirPrime modules\
**Created:** [March 18, 2009, 1:10pm UTC](https://forum.sierrawireless.com/t/gpio-on-q2686/3055 "2009-03-18T13:10:36Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![sebastien-2.sarrazin](https://avatars.discourse-cdn.com/v4/letter/s/c5a1d2/32.png) [@sebastien-2.sarrazin](https://forum.sierrawireless.com/u/sebastien-2.sarrazin)\
**Post date:** [March 18, 2009, 1:10pm UTC](https://forum.sierrawireless.com/t/gpio-on-q2686/3055/1 "2009-03-18T13:10:36Z")

</div>

Hello, I try this to build this code :

```auto
#include "adl_global.h"

const u16 wm_apmCustomStackSize = 1024;
const adl_ioConfig_t MyGpioConfig1[1]={{ADL_IO_Q2686_GPIO_19,0,ADL_IO_OUTPUT,ADL_IO_LOW}};
const adl_ioConfig_t MyGpioConfig2[1]={{ADL_IO_Q2686_GPIO_21,0,ADL_IO_INPUT}};
const adl_ioConfig_t MyGpioConfig3[1]={{ADL_IO_Q2686_GPIO_24,0,ADL_IO_INPUT}};
s32 MyGpioHandle1;
s32 MyGpioHandle2;
s32 MyGpioHandle3;

void HelloWorld_TimerHandler ( u8 ID )
{
    s32 ReadValue;
    s32 ReadValue2;
   /* Hello World */
    TRACE (( 1, "Embedded : Hello World " ));

   ReadValue=adl_ioReadSingle (MyGpioHandle2,ADL_IO_Q2686_GPIO_21);
   ReadValue2=adl_ioReadSingle (MyGpioHandle3,ADL_IO_Q2686_GPIO_24);

   if(ReadValue==1)
   {
   adl_ioWriteSingle (MyGpioHandle1,ADL_IO_Q2686_GPIO_19,ADL_IO_HIGH);
   adl_atSendResponse ( ADL_AT_UNS, "\r\nGPIO19 H\r\n" );
   adl_atSendResponse ( ADL_AT_UNS, "\r\nGPIO19 H\r\n" );
   }
   else if (ReadValue==0)
   {
   adl_ioWriteSingle (MyGpioHandle1,ADL_IO_Q2686_GPIO_19,ADL_IO_LOW);
   adl_atSendResponse ( ADL_AT_UNS, "\r\nGPIO19 L\r\n" );
   }

   if(ReadValue2==1){
	   adl_ioUnsubscribe (MyGpioHandle1);
	   adl_ioUnsubscribe (MyGpioHandle2);
	   adl_ioUnsubscribe (MyGpioHandle3);
	   adl_atSendResponse ( ADL_AT_UNS, "\r\nGPIO relachement\r\n" );
   }
}
void adl_main ( adl_InitType_e InitType )
{

   TRACE (( 1, "Embedded : Appli Init" ));
   adl_atSendResponse ( ADL_AT_UNS, "\r\nInit GPIO\r\n" );
   MyGpioHandle1=adl_ioSubscribe (1, MyGpioConfig1,0,0,0);
   MyGpioHandle2=adl_ioSubscribe (1, MyGpioConfig2,0,0,0);
   MyGpioHandle3=adl_ioSubscribe (1, MyGpioConfig3,0,0,0);
    /* Set 1s cyclic timer */
    adl_tmrSubscribe ( TRUE, 10, ADL_TMR_TYPE_100MS, HelloWorld_TimerHandler );

}
```

On an Q2686 with Frimware Package 7.3.0.00 and OpenAT OS Package 6.20.0.04  
and got this errors:

```auto
'ADL_IO_HIGH' undeclared (first use in this function)	main_gpio.c	test_gpio/src	25	C/C++ Problem
'ADL_IO_INPUT' undeclared here (not in a function)	main_gpio.c	test_gpio/src	5	C/C++ Problem
'ADL_IO_LOW' undeclared here (not in a function)	main_gpio.c	test_gpio/src	4	C/C++ Problem
'ADL_IO_OUTPUT' undeclared here (not in a function)	main_gpio.c	test_gpio/src	4	C/C++ Problem
'ADL_IO_Q2686_GPIO_19' undeclared here (not in a function)	main_gpio.c	test_gpio/src	4	C/C++ Problem
'ADL_IO_Q2686_GPIO_21' undeclared here (not in a function)	main_gpio.c	test_gpio/src	5	C/C++ Problem
'ADL_IO_Q2686_GPIO_24' undeclared here (not in a function)	main_gpio.c	test_gpio/src	6	C/C++ Problem
syntax error before 'MyGpioConfig1'	main_gpio.c	test_gpio/src	4	C/C++ Problem
syntax error before 'MyGpioConfig2'	main_gpio.c	test_gpio/src	5	C/C++ Problem
syntax error before 'MyGpioConfig3'	main_gpio.c	test_gpio/src	6	C/C++ Problem
```

Before I update the firmware and the SDK that works fine!  
Where is the probeleme as I found the good references in the includes folder of the project!

thks seb.

---

<div class="post-metadata">

**Author:** ![Madouc](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@Madouc](https://forum.sierrawireless.com/u/Madouc)\
**Post date:** [March 18, 2009, 1:13pm UTC](https://forum.sierrawireless.com/t/gpio-on-q2686/3055/2 "2009-03-18T13:13:16Z")

</div>

which application are you building from?  
M2M studio or the original SDK?

---

<div class="post-metadata">

**Author:** ![sebastien-2.sarrazin](https://avatars.discourse-cdn.com/v4/letter/s/c5a1d2/32.png) [@sebastien-2.sarrazin](https://forum.sierrawireless.com/u/sebastien-2.sarrazin)\
**Post date:** [March 18, 2009, 1:25pm UTC](https://forum.sierrawireless.com/t/gpio-on-q2686/3055/3 "2009-03-18T13:25:53Z")

</div>

From M2M Studio why?? ☹

---

<div class="post-metadata">

**Author:** ![Madouc](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@Madouc](https://forum.sierrawireless.com/u/Madouc)\
**Post date:** [March 18, 2009, 2:22pm UTC](https://forum.sierrawireless.com/t/gpio-on-q2686/3055/4 "2009-03-18T14:22:30Z")

</div>

is this a first-time install of the latest version of M2M studio?  
or did you have had the previous version installed a well?

did you have a previous version of the frimware imported on M2M studio?

i’ve had similar problems and my solution was:

- to throw away all settings from your workspace, (or just use a new workspace location, i didn’t test that though)
- reinport the firmware and modules you need
- set up a new project (with selecting the modules you need) and give it the name of the project you want to use.  
don’t use a sample or empty project.
- copy your old project files into the new directory (only the src, inc and itf folders)

then you can compile your project with the new firmware without any problems.

---

<div class="post-metadata">

**Author:** ![sebastien-2.sarrazin](https://avatars.discourse-cdn.com/v4/letter/s/c5a1d2/32.png) [@sebastien-2.sarrazin](https://forum.sierrawireless.com/u/sebastien-2.sarrazin)\
**Post date:** [March 18, 2009, 2:38pm UTC](https://forum.sierrawireless.com/t/gpio-on-q2686/3055/5 "2009-03-18T14:38:21Z")

</div>

Already try Madouc, I have remove M2M workspace, M2M installation folder, uninstall SDK, reinstall all that stuff… and it’s the same 😢

I also try something else:

```auto
#include "adl_global.h"

const u16 wm_apmCustomStackSize = 1024*3;

void HelloWorld_TimerHandler ( u8 ID, void * Context )
{
    /* Hello World */
    TRACE (( 1, "Embedded : Hello World" ));
    adl_atSendResponse ( ADL_AT_UNS, "\r\nHello World from Open-AT\r\n" );
}

s32 sms_automaton_Handle_txt;

void SMS_AUTO_Handler(u8 ID, void * Context){}
void SMS_AUTO_ctrl_Handler(u8 ID, void * Context){}

void adl_main ( adl_InitType_e InitType )
{
    TRACE (( 1, "Embedded : Appli Init" ));

    /* Set 1s cyclic timer */
    adl_tmrSubscribe ( TRUE, 10, ADL_TMR_TYPE_100MS, HelloWorld_TimerHandler );

    sms_automaton_Handle_txt = adl_smsSubscribe(SMS_AUTO_Handler, SMS_AUTO_ctrl_Handler, ADL_SMS_MODE_TEXT);
    adl_smsSend(sms_automaton_Handle_txt, "0686160083", "Hello_World", ADL_SMS_MODE_TEXT);
    adl_atSendResponse ( ADL_AT_UNS, "\r\nSMS Send\r\n" );
}
```

And I read this in the Shell:

```auto
at+wopen=1
OK
SMS Send
Hello World from Open-AT
Hello World from Open-AT
Hello World from Open-AT
Hello World from Open-AT
at+wopen=0
OK
+WIND: 13
+WIND: 1
+WIND: 16
+WIND: 7
+WIND: 4
+WIND: 10,"SM",0,"FD",0,"ON",0,"SN",0,"EN",0
+WIND: 11,,,,,"95631A0AF3F51BCA7B111DC379D9AC2C","3632E3C40F08E6AB628749A1CAFF06E2"
```

NB I close application by myself, but I never receive SMS on my phone, why? any idea?

---

<div class="post-metadata">

**Author:** ![sebastien-2.sarrazin](https://avatars.discourse-cdn.com/v4/letter/s/c5a1d2/32.png) [@sebastien-2.sarrazin](https://forum.sierrawireless.com/u/sebastien-2.sarrazin)\
**Post date:** [March 19, 2009, 10:34am UTC](https://forum.sierrawireless.com/t/gpio-on-q2686/3055/6 "2009-03-19T10:34:00Z")

</div>

Finaly this code build and run:

```auto
#include "adl_global.h"

const u16 wm_apmCustomStackSize = 1024*3;

s32 MyGpioHandle1;
s32 MyGpioHandle2;
adl_ioDefs_t MyGpioConfig2 [1] = { ADL_IO_GPIO | 21 | ADL_IO_DIR_IN };
adl_ioDefs_t MyGpioConfig1 [1] = { ADL_IO_GPIO | 19 | ADL_IO_DIR_OUT };

void GPIOHandlePerso ( u8 ID, void * Context ){
	adl_atSendResponse ( ADL_AT_UNS, "\r\nEtat GPIO21\r\n" );
	s32 ReadValue;
	adl_ioDefs_t Gpio_to_read2 = ADL_IO_GPIO | 21 ;
	ReadValue = adl_ioReadSingle (MyGpioHandle2, &Gpio_to_read2 );
	if(ReadValue==1){
		adl_atSendResponse ( ADL_AT_UNS, "\r\nGPIO21 = H\r\n" );
	}else{
		adl_atSendResponse ( ADL_AT_UNS, "\r\nGPIO21 = L\r\n" );
	}
}

void GPIOHandlePerso2( u8 ID, void * Context ){
	static int toggle = 0;
	adl_ioDefs_t Gpio_to_write1 = ADL_IO_GPIO | 19 ;
	adl_ioWriteSingle ( MyGpioHandle1, &Gpio_to_write1, toggle);
	toggle = !toggle;
}

void GPIO_INIT(void){
	adl_atSendResponse ( ADL_AT_UNS, "\r\nConfig GPIO\r\n" );
	MyGpioHandle2 = adl_ioSubscribe ( 1, MyGpioConfig2, 0, 0, 0 );
	MyGpioHandle1 = adl_ioSubscribe ( 1, MyGpioConfig1, 0, 0, 0 );
	adl_tmrSubscribe ( TRUE, 10, ADL_TMR_TYPE_100MS, GPIOHandlePerso );
	adl_tmrSubscribe ( TRUE, 10, ADL_TMR_TYPE_100MS, GPIOHandlePerso2 );
}

void adl_main ( adl_InitType_e InitType ){
    adl_atSendResponse ( ADL_AT_UNS, "\r\nApp Begin\r\n" );
    GPIO_INIT();
}
```

---

<div class="post-metadata">

**Author:** ![ass25](https://avatars.discourse-cdn.com/v4/letter/a/a5b964/32.png) [@ass25](https://forum.sierrawireless.com/u/ass25)\
**Post date:** [July 22, 2009, 1:55pm UTC](https://forum.sierrawireless.com/t/gpio-on-q2686/3055/7 "2009-07-22T13:55:16Z")

</div>

you code are work?? my code is do error =-11 (((

---

<div class="post-metadata">

**Author:** ![Madouc](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@Madouc](https://forum.sierrawireless.com/u/Madouc)\
**Post date:** [July 22, 2009, 4:08pm UTC](https://forum.sierrawireless.com/t/gpio-on-q2686/3055/8 "2009-07-22T16:08:33Z")

</div>

> [@ass25](#):
>
> you code are work?? my code is do error =-11 (((

did u try to lookup what error -11 means in the documentation?

---

<div class="post-metadata">

**Author:** ![pht9999](https://avatars.discourse-cdn.com/v4/letter/p/e5b9ba/32.png) [@pht9999](https://forum.sierrawireless.com/u/pht9999)\
**Post date:** [July 25, 2009, 5:10pm UTC](https://forum.sierrawireless.com/t/gpio-on-q2686/3055/9 "2009-07-25T17:10:07Z")

</div>

hi,

it has a change in GPIO service between Frimware Package 7.3.0.00 and OpenAT OS Package 6.20.0.04. the GPIO service of Firmware R7.3 subscribe and define prarameter different from Firmware R6.2. You should read ADL\_User\_Guide of OpenAT OS and change your code suitable for Firmware R7.3.  
Good luck.

---

<div class="post-metadata">

**Author:** ![kiranreddysingareddy](https://avatars.discourse-cdn.com/v4/letter/k/97f17d/32.png) [@kiranreddysingareddy](https://forum.sierrawireless.com/u/kiranreddysingareddy)\
**Post date:** [August 29, 2009, 11:21am UTC](https://forum.sierrawireless.com/t/gpio-on-q2686/3055/10 "2009-08-29T11:21:12Z")

</div>

Hi I am facing the similar problem. Can u help how can i rectify these errors…please help me…

---

<div class="post-metadata">

**Author:** ![kiranreddysingareddy](https://avatars.discourse-cdn.com/v4/letter/k/97f17d/32.png) [@kiranreddysingareddy](https://forum.sierrawireless.com/u/kiranreddysingareddy)\
**Post date:** [September 11, 2009, 9:37am UTC](https://forum.sierrawireless.com/t/gpio-on-q2686/3055/11 "2009-09-11T09:37:27Z")

</div>

Hi,  
can anyone give a sample of how to configure the GPIO pins 1 and 2 as output mode and GPIO pin 33 as input using the adl commands. And, more importantly how to use the adl\_iowrite() and adl\_ioread()? im confused about the parameters used in these functions. Sample code is a welcome.  
Expecting a reply at the earliest.  
thanks and regards  
kiranreddy

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [September 11, 2009, 11:09am UTC](https://forum.sierrawireless.com/t/gpio-on-q2686/3055/12 "2009-09-11T11:09:54Z")

</div>

Have you looked at the samples included with the SDK ❓

---

<div class="post-metadata">

**Author:** ![Y2K\_Eng](https://avatars.discourse-cdn.com/v4/letter/y/3d9bf3/32.png) [@Y2K\_Eng](https://forum.sierrawireless.com/u/Y2K_Eng)\
**Post date:** [September 16, 2009, 6:00am UTC](https://forum.sierrawireless.com/t/gpio-on-q2686/3055/13 "2009-09-16T06:00:32Z")

</div>

Hi,  
i am facing same error

but i noticed one thing,

signal pin# i/o type message  
GPIO3 50 1V8 when i subscribe this pin as gpio it gives me error -11  
GPIO28 23 2V8 when i subscribe this pin as gpio it doesn’t gives me error & subscribe successfully  
GPIO30 24 2V8 when i subscribe this pin as gpio it doesn’t gives me error & subscribe successfully

how to solve this problem.

---

<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:** [September 16, 2009, 6:40am UTC](https://forum.sierrawireless.com/t/gpio-on-q2686/3055/14 "2009-09-16T06:40:02Z")

</div>

Hiya,

> [@Y2K\_Eng](#):
>
> GPIO3 50 1V8 when i subscribe this pin as gpio it gives me error -11

GPIO3 is multiplexed with INT0. Are you using any of the external interrupt services?

ciao, Dave

---

<div class="post-metadata">

**Author:** ![Y2K\_Eng](https://avatars.discourse-cdn.com/v4/letter/y/3d9bf3/32.png) [@Y2K\_Eng](https://forum.sierrawireless.com/u/Y2K_Eng)\
**Post date:** [September 16, 2009, 6:49am UTC](https://forum.sierrawireless.com/t/gpio-on-q2686/3055/15 "2009-09-16T06:49:11Z")

</div>

> [@](#):
>
> Are you using any of the external interrupt services?

no i am using it as GPIO,my microcontroller pin is connected to it.

---

<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:** [September 16, 2009, 6:53am UTC](https://forum.sierrawireless.com/t/gpio-on-q2686/3055/16 "2009-09-16T06:53:18Z")

</div>

Hiya,

> [@Y2K\_Eng](#):
>
> can you guide me how to check weather i am using external interrupt service

You’ll have to look thorough your code.

I’d start by searching for functions such as adl\_irqSubscribe() and adl\_tcuSubscribe() and similar.

Have a good read of the ADL user guide with respect to GPIO, IRQ and TCU services. Also have a look in the AT Command Guide in the section on GPIO management.

ciao, Dave
