Gpio's input and output

How to change settings (input or output) of one gpio, based on some event
This is why im asking this:

s8  GpioHandle;
u8  gpio18=0;
void gpioTmrHandler ( u8 ID ){
      adl_ioWriteSingle(GpioHandle, ADL_IO_Q2686_GPIO_18, ADL_IO_HIGH);
void setGpioInput (void){
   TRACE (( 3, "GPIO = INPUT" ));
   GpioHandle = adl_ioSubscribe (ADL_IO_Q2686_GPIO_18,1,0,0,(adl_ioHdlr_f)NULL); // input 
   adl_tmrSubscribe ( TRUE, 10, ADL_TMR_TYPE_100MS, gpioTmrHandler );
void setGpioOutput (void){
   TRACE (( 3, "GPIO = OUTPUT" ));
   GpioHandle = adl_ioSubscribe (ADL_IO_Q2686_GPIO_18,0,0,0,(adl_ioHdlr_f)NULL); // output 
   adl_tmrSubscribe ( TRUE, 10, ADL_TMR_TYPE_100MS, gpioTmrHandler );

If the hangup event is called i call setGpioOutput and if ring voice is detected then im calling setGpioInput.
My “problem” is that im using the same pin to change the state of the pin but as output a get bunch of weird things.

This is the output from emulator ( not from trace ):
{ŕiď7!ŕiÔC…@%ď7!@%”Fď7!Single Write %d : %dü˙˙˙ţ˙˙˙äĄ!ż!d ţ’%dü˙˙˙ţ˙˙˙äĄ!ż!Si7@%ď7!@%ÔC˙ţ5DL] Gpio Single Write %d : %dü˙˙˙ţ˙˙˙äĄ!ż!Si7ÔC oŹĄ!ż!Si7{@%ď7!@%ÔC˙ţ5Single Write %d : %dü˙˙˙ţ˙˙˙äĄ!ż!ď7 ˙˙äĄ!ż!4Xa

and from trace :
Trace 23 [ADL] Gpio Single Write -2 : -2
Trace 23 [ADL] Gpio Single Write -2 : -2
Trace 23 [ADL] Gpio Single Write -2 : -2
Trace 20 [ADL] tmr unsubs ; id 9 ; hdlr 002102A5 (rem. time : 3)
Trace 1 Unable to find the string of the remote trace in the file (ID = 870172)
Trace 23 [ADL] Gpio subs 20 0 : -4
Trace 20 [ADL] tmr subs ; id 10 ; hdlr 002101A5 ; val 10 ; cycl 1

Trace 4 GPIO = INPUT
Trace 26 SMS send : -2
Trace 23 [ADL] Gpio Single Write -4 : -2
Trace 23 [ADL] Gpio Single Write -4 : -2
Trace 23 [ADL] Gpio Single Write -4 : -2
Trace 23 [ADL] Gpio Single Write -4 : -2

OK. Wrong declaration and already subscribed.
I dont know, maybe i have set the wrong declaration but it looks ok to me.
Beside this, im using pin 18 and this pin is not multiplexed.

How would you declare or call the same gpio setting, to get the same effect?

GpioHandle = adl_ioSubscribe (ADL_IO_Q2686_GPIO_18,1,0,0,(adl_ioHdlr_f)NULL); // input

You have an error there for example.
GpioHandle = adl_ioSubscribe (ADL_IO_Q2686_GPIO_18,ADL_IO_Q2686_GPIO_18,0,0,(adl_ioHdlr_f)NULL); // input

is correct if you want it as an input. Remember that direction is masked just like what GPIO you want to subscribe.

The ioWrite looks wrong too from the documentation I have.

Actually… I see you write Q2686, but then the ioSubscribe doesn’t look like what I see in the documentation I have.

What version of OAT/ADL are you using?

If you are porting an application from previous versions, check the API docs for how to subscribe GPIO on Q2686.

Got me :wink:

I downloaded new user guide for version 4.10.
There is some example on using gpio’s.

Did you tested this example and should i base my application on this code ?

I think it’s better for you to look at what you want done and make new code where possible.
For larger portions of code that need to be ported, make changes where needed and run many tests…