How to use GPIO?

hi

I am trying to write a code to make a flasher using GPIOs. But I couldn’t run it. According to code it must work but when I measure related I/O pin I can’t see any difference.

Q2406B
OpenAT 3.02
GCC

void adl_main ( adl_InitType_e InitType )
{
	TRACE((1,"Embedded application main"));


	GpioHandle = adl_ioSubscribe(ADL_IO_Q24X6_GPIO_5,0,0,0,(adl_ioHdlr_f)NULL);

	adl_atUnSoSubscribe("+WIND: 4",(adl_atUnSoHandler_t)Wind4_Handler);
	
}

s16 Wind4_Handler(adl_atUnSoHandler_t *paras)
{
timerHandleFlashIO = adl_tmrSubscribe(TRUE,5, ADL_TMR_TYPE_100MS,(adl_tmrHandler_t)timerFuncFlashIO);
return TRUE;
}

void timerFuncFlashIO(u8 timerid)
{

s8 ReturnCode;
ascii buffer[30];

if(toggle == 0)
	toggle=1;
else if(toggle != 0)
	toggle = 0;
	
ReturnCode = adl_ioWrite(GpioHandle,ADL_IO_Q24X6_GPIO_5,toggle);

if(ReturnCode == ADL_RET_ERR_UNKNOWN_HDL)
	adl_atSendResponse(ADL_AT_UNS,"\r\nADL_RET_ERR_UNKNOWN_HDL");
else if(ReturnCode == ADL_RET_ERR_PARAM)
	adl_atSendResponse(ADL_AT_UNS,"\r\nADL_RET_ERR_PARAM");
else if(ReturnCode == ADL_RET_ERR_FATAL)
	adl_atSendResponse(ADL_AT_UNS,"\r\nADL_RET_ERR_FATAL");

if(ReturnCode == ADL_ERR_IO_WRITE)
	adl_atSendResponse(ADL_AT_UNS,"\r\nADL_ERR_IO_WRITE");
else if(ReturnCode == OK)
	adl_atSendResponse(ADL_AT_UNS,"\r\nReturnCode of ioWrite is OK");


	wm_sprintf(buffer,"\r\nReturnCode == %d\r\n",ReturnCode);
	adl_atSendResponse(ADL_AT_RSP,buffer);
}

what do You think?

Hi piedos,

I think this

should be

if(toggle == 0)
	toggle=ADL_IO_Q24X6_GPIO_5;
else if(toggle != 0)
	toggle = 0;
	
ReturnCode = adl_ioWrite(GpioHandle,ADL_IO_Q24X6_GPIO_5,toggle);

because adl_ioWrite() can be used to write to several ports at the same time. So you should set a mask and not just a bool value to toggle the port. (I hope that’s right :wink:)

Best Regards,
Jan

ooops! of course the “toggle == 0” should also be changed to “toggle == ADL_IO_Q24X6_GPIO_5”

Are there a wavecom sample code about gpio manegement?

no it doesn’t work!

Hi,

I have a strange problem. When I initiallize the GPIO using :

GpioHandle = adl_ioSubscribe(ADL_IO_Q25X1_GPIO_5,0xFFFFFFFF,0,0,(adl_ioHdlr_f)NULL);

The function always returns “ADL_RET_ERR_PARAM” which means that parameters are not correct !

But it seems Ok to me, Could there be some HardWare issue ??

Thanks,
-Jiten.

Hi Jiten9,
Following reasons can be attributed to the behavior described by you:

  1. You have enabled UART2 (using AT+WMFM command) and are now trying to subscribe to GPIO5. However, from section 2.5 ADL user guide, you can see that after enabling UART2, GPIO5 becomes unavailable for Open-AT application usage. This can be the reason for the stated behavior.
  2. You are using a module other than Q2501 (like Q2406B etc). In this case, the first parameter becomes invalid and is causing the problem.

Could you please check the above mentioned point.
Regards,
Open AT Fan.

Hi Open AT Fan,

I have not enabled it; for the moment I dont use UART 2 at all.

No I am using Q2501B module; this I confirmed it by sending

type = adl_ioGetProductType();

Which returned me : “ADL_IO_PRODUCT_TYPE_Q25X1”

One more thing even when I use this

GpioHandle = adl_ioSubscribe(ADL_IO_Q25X1_GPIO_2,0xFFFFFFFF,0,0,(adl_ioHdlr_f)NULL);

I get the same error :frowning:

I dont know where I am wrong.

-Jiten.

Hi jiten9,
Please check if you are using compatible versions of Open-AT and AT software. You should execute AT+WOPEN=2 command and check out which version of Open-AT your AT software supports (by checking the second parameter of the response). Usually, this kind of error is seen when you execute an Open-AT applicaiton compiled using Open-AT version 3.02 using 650a version of AT software.
If so, please use 651 version of AT software with OAT 3.02 as both are compatible. You can use AT+WOPEN=2 command to check which version of Open-AT you should use with your core AT software.

I think this should solve your problem.
Best Regards,
Open AT Fan.

Hello Open AT Fan,

I shifted to v3.02 and confirmed it by sending AT+WOPEN=2 which returned me
+WOPEN: 2,“AT v03.02”,“AT v03.02”

Now I saw a strange behaviour; when I reflash the Wismo module (using DWLWin software) and my application for the first start I got success in subscribing from adl_ioSubscribe() function which returned me 2.

Then I rebooted the Wismo and again I got the Failiur message -2( Parameter error).

This looks very strange to me !!

I tried this on the Development kit from Wavecom (for 2501 v1.1)

Any idea regarding this ?

-jiten.

Hi Jiten,
Could you please check the output of AT+WMFM? command?
This would tell you if your UART2 is enabled when you execute AT+WOPEN=1 command.
If you get a response +WMFM: 0,2,2,1 from AT+WMFM? command it means that UART2 is activated.
This is the only case in which I got a -2 (as a return value of adl_ioSubscribe () API).

If so, then please execute the following commands:

  1. AT+WOPEN=0 (to stop the OAT application).
  2. Execute AT+WMFM=0,0,2 command.
  3. Execute AT&W command.
  4. Execute AT+WOPEN=1 command and see if the GPIO subscription is successful.

On my side, I did not face the problem as mentioned by you when I executed the code to subscribe to GPIO5.

Best Regards,
Open AT Fan.