Skip to content
Snippets Groups Projects
Commit e49ce1e6 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Add support for arduino-like loop function + blinky on esp8266

parent 82b77994
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,10 @@ CXXFLAGS = -std=c++14 ...@@ -7,6 +7,10 @@ CXXFLAGS = -std=c++14
TARGETS = src/os/main.cc TARGETS = src/os/main.cc
ifeq (${arduino}, 1)
COMMON_FLAGS += -DWITH_LOOP
endif
include src/arch/${arch}/Makefile.inc include src/arch/${arch}/Makefile.inc
clean: arch_clean clean: arch_clean
......
...@@ -11,7 +11,7 @@ AR = ${TOOLCHAIN_BASE}/xtensa-lx106-elf-ar ...@@ -11,7 +11,7 @@ AR = ${TOOLCHAIN_BASE}/xtensa-lx106-elf-ar
LD = ${TOOLCHAIN_BASE}/xtensa-lx106-elf-gcc LD = ${TOOLCHAIN_BASE}/xtensa-lx106-elf-gcc
INCLUDES += -Iinclude/esp8266 -I${SDK_BASE}/include INCLUDES += -Iinclude/esp8266 -I${SDK_BASE}/include
COMMON_FLAGS += -nostdlib -mlongcalls COMMON_FLAGS += -nostdlib -mlongcalls -D__ets__ -DICACHE_FLASH
CXXFLAGS = -std=c++11 CXXFLAGS = -std=c++11
LDFLAGS += -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static LDFLAGS += -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static
......
...@@ -7,15 +7,34 @@ extern "C" { ...@@ -7,15 +7,34 @@ extern "C" {
#include "user_interface.h" #include "user_interface.h"
#include "gpio.h" #include "gpio.h"
#include "mem.h" #include "mem.h"
void ets_timer_arm_new(os_timer_t *ptimer, uint32_t milliseconds, bool repeat_flag, bool us_flag);
void ets_timer_disarm(os_timer_t *ptimer);
void ets_timer_setfn(os_timer_t *ptimer, os_timer_func_t *pfunction, void *parg);
} }
#define user_procTaskPrio 0 #define user_procTaskPrio 0
#define user_procTaskQueueLen 1 #define user_procTaskQueueLen 1
#ifdef WITH_LOOP
LOCAL os_timer_t loop_timer;
extern void loop(void);
static void ICACHE_FLASH_ATTR jump_to_loop(void *arg)
{
loop();
}
#endif
extern int main(void); extern int main(void);
static void ICACHE_FLASH_ATTR jump_to_main(void) void ICACHE_FLASH_ATTR jump_to_main(void)
{ {
#ifdef WITH_LOOP
os_timer_disarm(&loop_timer);
os_timer_setfn(&loop_timer, (os_timer_func_t *)jump_to_loop, (void *)0);
os_timer_arm(&loop_timer, 1000, 1);
#endif
main(); main();
} }
......
...@@ -30,7 +30,7 @@ void ICACHE_FLASH_ATTR GPIO::led_off(unsigned char id) ...@@ -30,7 +30,7 @@ void ICACHE_FLASH_ATTR GPIO::led_off(unsigned char id)
void ICACHE_FLASH_ATTR GPIO::led_toggle(unsigned char id) void ICACHE_FLASH_ATTR GPIO::led_toggle(unsigned char id)
{ {
if (GPIO_REG_READ(GPIO_OUT_ADDRESS) & BIT2) { if (gpio_input_get() & BIT2) {
led_on(0); led_on(0);
} else { } else {
led_off(0); led_off(0);
......
...@@ -84,11 +84,16 @@ void check_command(unsigned char argc, char** argv) ...@@ -84,11 +84,16 @@ void check_command(unsigned char argc, char** argv)
} }
*/ */
void loop(void)
{
gpio.led_toggle(1);
}
int main(void) int main(void)
{ {
arch.setup(); arch.setup();
gpio.setup(); gpio.setup();
gpio.led_on(1); gpio.led_on(0);
arch.idle_loop(); arch.idle_loop();
//uart_setup(); //uart_setup();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment