-->
Page 1 of 2

Timers...Help.

PostPosted: Wed Feb 11, 2015 7:35 pm
by Eddiie
Hello,
I have gone through all of this so quickly, forgive me if something is incorrect.

Using Espressif and IoT SDK along with Sprite's webserver. (Sprite, you da man!)

I just want to throw a GPIO high for 3 seconds and put it low again after. THATS IT!!!!

Can't use a loop, watchdog kicks in and resets the chip (thanks for pointing that out Sprite)

I found a timer function in some of the code, it looks like it has 3 calls -
Arm, reset, callback.

I set the reset and arm. I eliminated the callback because I could not think of anything to put in there. To my surprise, the timer doesn't work.

I've spent hours on this and am frustrated. When I can't do simple things, it gets to me. Being a Windows person, I've jumped through many hoops to make a compiling environment on Linux. That was simple compared to making a 3 second pause.

Links on Google don't seem to help, they use while(1) which I am pretty sure is blocking. Another example uses C++ in C code, I am not even sure if all C functions are available.

So, before I waste any more time, start breaking more things, can someone show me a simple easy to understand timer example using the above SDK(s), compilers, whatever? Don't write the whole code for me, not looking for that but want to make the connections in my head so I understand where I am going wrong!! GRRRR Just show me a simple working example.

Furthermore, is there a link or document somewhere that shows all the available functions for the SDK? With code samples?

Thank you.

Re: Timers...Help.

PostPosted: Wed Feb 11, 2015 8:42 pm
by Eddiie
Maybe the callback function should set the gpio low when called!
Will try it when I get home.

Re: Timers...Help.

PostPosted: Wed Feb 11, 2015 11:24 pm
by Eddiie
So, in Sprite's sample code - cgiwifi.c there is a timer..

Code: Select allfuncton here  {
     static ETSTimer resetTimer;
.....

     os_timer_disarm(&resetTimer);
     os_timer_setfn(&resetTimer, resetTimerCb, NULL);
     os_timer_arm(&resetTimer, 4000, 0);
......
}


Callback
Code: Select allstatic void ICACHE_FLASH_ATTR resetTimerCb(void *arg) {
       ....
}



So, os_timer_disarm(), os_timer_setfn(), os_timer_arm() are functions... Typing through this, it seems

os_timer_disarm to disable any pre-existing timer?
os_setfn to define what to do when the timer expires
os_arm to start the timer!

?

Re: Timers...Help.

PostPosted: Thu Feb 12, 2015 1:50 am
by Eddiie
Yep. Works now.