Examples: add blinky
This commit is contained in:
parent
ea91b81598
commit
b8694b40a7
@ -6,9 +6,12 @@ LDFLAGS = -Teagle.app.v6.ld
|
||||
blinky-0x00000.bin: blinky
|
||||
esptool.py elf2image $^
|
||||
|
||||
blinky: blinky.o blinky_main.o
|
||||
blinky: blinky.o
|
||||
|
||||
blinky.o: blinky.c
|
||||
|
||||
flash: blinky-0x00000.bin
|
||||
esptool.py write_flash 0 blinky-0x00000.bin 0x40000 blinky-0x40000.bin
|
||||
|
||||
clean:
|
||||
rm -f blinky blinky.o blinky-0x00000.bin blinky-0x400000.bin
|
||||
BIN
examples/blinky/blinky
Executable file
BIN
examples/blinky/blinky
Executable file
Binary file not shown.
36
examples/blinky/blinky.c
Normal file
36
examples/blinky/blinky.c
Normal file
@ -0,0 +1,36 @@
|
||||
#include "ets_sys.h"
|
||||
#include "osapi.h"
|
||||
#include "gpio.h"
|
||||
#include "os_type.h"
|
||||
|
||||
static const int pin = 1;
|
||||
static volatile os_timer_t some_timer;
|
||||
|
||||
void some_timerfunc(void *arg)
|
||||
{
|
||||
//Do blinky stuff
|
||||
if (GPIO_REG_READ(GPIO_OUT_ADDRESS) & (1 << pin))
|
||||
{
|
||||
// set gpio low
|
||||
gpio_output_set(0, (1 << pin), 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// set gpio high
|
||||
gpio_output_set((1 << pin), 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void ICACHE_FLASH_ATTR user_init()
|
||||
{
|
||||
// init gpio sussytem
|
||||
gpio_init();
|
||||
|
||||
// configure UART TXD to be GPIO1, set as output
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_GPIO1);
|
||||
gpio_output_set(0, 0, (1 << pin), 0);
|
||||
|
||||
// setup timer (500ms, repeating)
|
||||
os_timer_setfn(&some_timer, (os_timer_func_t *)some_timerfunc, NULL);
|
||||
os_timer_arm(&some_timer, 500, 1);
|
||||
}
|
||||
0
examples/blinky/user_config.h
Normal file
0
examples/blinky/user_config.h
Normal file
Loading…
Reference in New Issue
Block a user