HWA
Bare metal programming with style
hwa/espressif/esp8266/examples/01-1-blink-soft/user.c
Blink a LED using an OS timer.

This program configures the LED pin as a digital output, then in an infinite loop it toggles the LED state using an OS timer.

Symbols:

user.c
#include BOARD_H
#define IROM __attribute__((section (".irom.text")))
#define IRAM
#if !defined PIN_LED
# define PIN_LED gpio2
#endif
/* Function called every 10 ms.
* Toggle the LED on/off.
*/
void IROM every10ms ( )
{
if ( hw( read, PIN_LED ) == 0 )
hw( write, PIN_LED, 1 );
else
hw( write, PIN_LED, 1 );
}
void IROM user_init()
{
/* Configure the LED output
*/
hw( configure, PIN_LED, mode, digital_output );
/* Trigger a function call every 10 ms (about)
*/
static os_timer_t timer ;
os_timer_disarm( &timer );
os_timer_setfn( &timer, (os_timer_func_t *)every10ms, NULL );
os_timer_arm( &timer, 10, 1 );
}
hw
#define hw(...)
hw( action, object [,...] ) executes an action immediately on an object.
Definition: hwa_macros.h:523