Unverified Commit 6db74142 authored by Terry Ellison's avatar Terry Ellison Committed by GitHub
Browse files

Merge branch 'dev' into dev-LFS

parents 88bd9e01 f427951f
...@@ -2,24 +2,26 @@ ...@@ -2,24 +2,26 @@
# #
.NOTPARALLEL: .NOTPARALLEL:
# SDK version NodeMCU is locked to # SDK base version, as released by Espressif
SDK_VER:=2.1.0 SDK_BASE_VER:=2.2.0
# no patch: SDK_BASE_VER equals SDK_VER and sdk dir depends on sdk_extracted # no patch: SDK_VER equals SDK_BASE_VER and sdk dir depends on sdk_extracted
SDK_BASE_VER:=$(SDK_VER) #SDK_VER:=$(SDK_BASE_VER)
SDK_DIR_DEPENDS:=sdk_extracted #SDK_DIR_DEPENDS:=sdk_extracted
# with patch: SDK_BASE_VER differs from SDK_VER and sdk dir depends on sdk_patched
#SDK_BASE_VER:=1.5.4 # with patch: SDK_VER differs from SDK_BASE_VER and sdk dir depends on sdk_patched
#SDK_DIR_DEPENDS:=sdk_patched SDK_PATCH_VER:=f8f27ce
SDK_VER:=$(SDK_BASE_VER)-$(SDK_PATCH_VER)
SDK_DIR_DEPENDS:=sdk_patched
SDK_FILE_VER:=$(SDK_BASE_VER) SDK_FILE_VER:=$(SDK_BASE_VER)
SDK_FILE_SHA1:=66a4272894dc1bcec19f5f8bf79fee80f60a021b SDK_FILE_SHA1:=8b63f1066d3560ff77f119e8ba30a9c39e7baaad
#SDK_PATCH_VER:=$(SDK_VER)_patch_20160704 SDK_PATCH_SHA1:=0bc21ec77b08488f04d3e1c9d161b711d07201a8
#SDK_PATCH_SHA1:=388d9e91df74e3b49fca126da482cf822cf1ebf1
# Ensure we search "our" SDK before the tool-chain's SDK (if any) # Ensure we search "our" SDK before the tool-chain's SDK (if any)
TOP_DIR:=$(abspath $(dir $(lastword $(MAKEFILE_LIST)))) TOP_DIR:=$(abspath $(dir $(lastword $(MAKEFILE_LIST))))
SDK_DIR:=$(TOP_DIR)/sdk/esp_iot_sdk_v$(SDK_VER) SDK_REL_DIR=sdk/esp_iot_sdk_v$(SDK_VER)
CCFLAGS:= -I$(TOP_DIR)/sdk-overrides/include -I$(SDK_DIR)/include SDK_DIR:=$(TOP_DIR)/$(SDK_REL_DIR)
CCFLAGS:= -I$(TOP_DIR)/sdk-overrides/include -I$(TOP_DIR)/app/include/lwip/app -I$(SDK_DIR)/include
LDFLAGS:= -L$(SDK_DIR)/lib -L$(SDK_DIR)/ld $(LDFLAGS) LDFLAGS:= -L$(SDK_DIR)/lib -L$(SDK_DIR)/ld $(LDFLAGS)
ifdef DEBUG ifdef DEBUG
...@@ -39,6 +41,7 @@ ifeq ($(OS),Windows_NT) ...@@ -39,6 +41,7 @@ ifeq ($(OS),Windows_NT)
# It is xcc # It is xcc
AR = xt-ar AR = xt-ar
CC = xt-xcc CC = xt-xcc
CXX = xt-xcc
NM = xt-nm NM = xt-nm
CPP = xt-cpp CPP = xt-cpp
OBJCOPY = xt-objcopy OBJCOPY = xt-objcopy
...@@ -50,6 +53,7 @@ ifeq ($(OS),Windows_NT) ...@@ -50,6 +53,7 @@ ifeq ($(OS),Windows_NT)
CCFLAGS += -ffunction-sections -fno-jump-tables -fdata-sections CCFLAGS += -ffunction-sections -fno-jump-tables -fdata-sections
AR = xtensa-lx106-elf-ar AR = xtensa-lx106-elf-ar
CC = xtensa-lx106-elf-gcc CC = xtensa-lx106-elf-gcc
CXX = xtensa-lx106-elf-g++
NM = xtensa-lx106-elf-nm NM = xtensa-lx106-elf-nm
CPP = xtensa-lx106-elf-cpp CPP = xtensa-lx106-elf-cpp
OBJCOPY = xtensa-lx106-elf-objcopy OBJCOPY = xtensa-lx106-elf-objcopy
...@@ -77,6 +81,7 @@ else ...@@ -77,6 +81,7 @@ else
CCFLAGS += -ffunction-sections -fno-jump-tables -fdata-sections CCFLAGS += -ffunction-sections -fno-jump-tables -fdata-sections
AR = xtensa-lx106-elf-ar AR = xtensa-lx106-elf-ar
CC = $(WRAPCC) xtensa-lx106-elf-gcc CC = $(WRAPCC) xtensa-lx106-elf-gcc
CXX = $(WRAPCC) xtensa-lx106-elf-g++
NM = xtensa-lx106-elf-nm NM = xtensa-lx106-elf-nm
CPP = $(WRAPCC) xtensa-lx106-elf-gcc -E CPP = $(WRAPCC) xtensa-lx106-elf-gcc -E
OBJCOPY = xtensa-lx106-elf-objcopy OBJCOPY = xtensa-lx106-elf-objcopy
...@@ -104,6 +109,7 @@ ESPTOOL ?= ../tools/esptool.py ...@@ -104,6 +109,7 @@ ESPTOOL ?= ../tools/esptool.py
CSRCS ?= $(wildcard *.c) CSRCS ?= $(wildcard *.c)
CXXSRCS ?= $(wildcard *.cpp)
ASRCs ?= $(wildcard *.s) ASRCs ?= $(wildcard *.s)
ASRCS ?= $(wildcard *.S) ASRCS ?= $(wildcard *.S)
SUBDIRS ?= $(patsubst %/,%,$(dir $(filter-out tools/Makefile,$(wildcard */Makefile)))) SUBDIRS ?= $(patsubst %/,%,$(dir $(filter-out tools/Makefile,$(wildcard */Makefile))))
...@@ -112,10 +118,12 @@ ODIR := .output ...@@ -112,10 +118,12 @@ ODIR := .output
OBJODIR := $(ODIR)/$(TARGET)/$(FLAVOR)/obj OBJODIR := $(ODIR)/$(TARGET)/$(FLAVOR)/obj
OBJS := $(CSRCS:%.c=$(OBJODIR)/%.o) \ OBJS := $(CSRCS:%.c=$(OBJODIR)/%.o) \
$(CXXSRCS:%.cpp=$(OBJODIR)/%.o) \
$(ASRCs:%.s=$(OBJODIR)/%.o) \ $(ASRCs:%.s=$(OBJODIR)/%.o) \
$(ASRCS:%.S=$(OBJODIR)/%.o) $(ASRCS:%.S=$(OBJODIR)/%.o)
DEPS := $(CSRCS:%.c=$(OBJODIR)/%.d) \ DEPS := $(CSRCS:%.c=$(OBJODIR)/%.d) \
$(CXXSCRS:%.cpp=$(OBJODIR)/%.d) \
$(ASRCs:%.s=$(OBJODIR)/%.d) \ $(ASRCs:%.s=$(OBJODIR)/%.d) \
$(ASRCS:%.S=$(OBJODIR)/%.d) $(ASRCS:%.S=$(OBJODIR)/%.d)
...@@ -196,26 +204,31 @@ $(BINODIR)/%.bin: $(IMAGEODIR)/%.out ...@@ -196,26 +204,31 @@ $(BINODIR)/%.bin: $(IMAGEODIR)/%.out
# Should be done in top-level makefile only # Should be done in top-level makefile only
# #
all: $(SDK_DIR_DEPENDS) pre_build .subdirs $(OBJS) $(OLIBS) $(OIMAGES) $(OBINS) $(SPECIAL_MKTARGETS) all: sdk_pruned pre_build .subdirs $(OBJS) $(OLIBS) $(OIMAGES) $(OBINS) $(SPECIAL_MKTARGETS)
.PHONY: sdk_extracted .PHONY: sdk_extracted
.PHONY: sdk_patched .PHONY: sdk_patched
.PHONY: sdk_pruned
sdk_extracted: $(TOP_DIR)/sdk/.extracted-$(SDK_BASE_VER) sdk_extracted: $(TOP_DIR)/sdk/.extracted-$(SDK_BASE_VER)
sdk_patched: sdk_extracted $(TOP_DIR)/sdk/.patched-$(SDK_VER) sdk_patched: sdk_extracted $(TOP_DIR)/sdk/.patched-$(SDK_VER)
sdk_pruned: $(SDK_DIR_DEPENDS) $(TOP_DIR)/sdk/.pruned-$(SDK_VER)
$(TOP_DIR)/sdk/.extracted-$(SDK_BASE_VER): $(TOP_DIR)/cache/v$(SDK_FILE_VER).zip $(TOP_DIR)/sdk/.extracted-$(SDK_BASE_VER): $(TOP_DIR)/cache/v$(SDK_FILE_VER).zip
mkdir -p "$(dir $@)" mkdir -p "$(dir $@)"
(cd "$(dir $@)" && rm -fr esp_iot_sdk_v$(SDK_VER) ESP8266_NONOS_SDK-$(SDK_VER) && unzip $(TOP_DIR)/cache/v$(SDK_FILE_VER).zip ESP8266_NONOS_SDK-$(SDK_VER)/lib/* ESP8266_NONOS_SDK-$(SDK_VER)/ld/eagle.rom.addr.v6.ld ESP8266_NONOS_SDK-$(SDK_VER)/include/* ESP8266_NONOS_SDK-$(SDK_VER)/bin/esp_init_data_default.bin) (cd "$(dir $@)" && rm -fr esp_iot_sdk_v$(SDK_VER) ESP8266_NONOS_SDK-$(SDK_BASE_VER) && unzip $(TOP_DIR)/cache/v$(SDK_FILE_VER).zip ESP8266_NONOS_SDK-$(SDK_BASE_VER)/lib/* ESP8266_NONOS_SDK-$(SDK_BASE_VER)/ld/eagle.rom.addr.v6.ld ESP8266_NONOS_SDK-$(SDK_BASE_VER)/include/* ESP8266_NONOS_SDK-$(SDK_BASE_VER)/bin/esp_init_data_default_v05.bin)
mv $(dir $@)/ESP8266_NONOS_SDK-$(SDK_VER) $(dir $@)/esp_iot_sdk_v$(SDK_VER) mv $(dir $@)/ESP8266_NONOS_SDK-$(SDK_BASE_VER) $(dir $@)/esp_iot_sdk_v$(SDK_BASE_VER)
rm -f $(SDK_DIR)/lib/liblwip.a touch $@
$(TOP_DIR)/sdk/.patched-$(SDK_VER): $(TOP_DIR)/cache/$(SDK_PATCH_VER).patch
mv $(dir $@)/esp_iot_sdk_v$(SDK_BASE_VER) $(dir $@)/esp_iot_sdk_v$(SDK_VER)
git apply --verbose -p1 --exclude='*VERSION' --exclude='*bin/at*' --directory=$(SDK_REL_DIR) $<
touch $@ touch $@
$(TOP_DIR)/sdk/.patched-$(SDK_VER): $(TOP_DIR)/cache/esp_iot_sdk_v$(SDK_PATCH_VER).zip $(TOP_DIR)/sdk/.pruned-$(SDK_VER):
mkdir -p "$(dir $@)/patch" rm -f $(SDK_DIR)/lib/liblwip.a $(SDK_DIR)/lib/libssl.a $(SDK_DIR)/lib/libmbedtls.a
(cd "$(dir $@)/patch" && unzip $(TOP_DIR)/cache/esp_iot_sdk_v$(SDK_PATCH_VER)*.zip *.a esp_init_data_default.bin && mv *.a $(SDK_DIR)/lib/ && mv esp_init_data_default.bin $(SDK_DIR)/bin/) ar d $(SDK_DIR)/lib/libmain.a time.o
rmdir $(dir $@)/patch ar d $(SDK_DIR)/lib/libc.a lib_a-time.o
rm -f $(SDK_DIR)/lib/liblwip.a
touch $@ touch $@
$(TOP_DIR)/cache/v$(SDK_FILE_VER).zip: $(TOP_DIR)/cache/v$(SDK_FILE_VER).zip:
...@@ -223,9 +236,9 @@ $(TOP_DIR)/cache/v$(SDK_FILE_VER).zip: ...@@ -223,9 +236,9 @@ $(TOP_DIR)/cache/v$(SDK_FILE_VER).zip:
wget --tries=10 --timeout=15 --waitretry=30 --read-timeout=20 --retry-connrefused https://github.com/espressif/ESP8266_NONOS_SDK/archive/v$(SDK_FILE_VER).zip -O $@ || { rm -f "$@"; exit 1; } wget --tries=10 --timeout=15 --waitretry=30 --read-timeout=20 --retry-connrefused https://github.com/espressif/ESP8266_NONOS_SDK/archive/v$(SDK_FILE_VER).zip -O $@ || { rm -f "$@"; exit 1; }
(echo "$(SDK_FILE_SHA1) $@" | sha1sum -c -) || { rm -f "$@"; exit 1; } (echo "$(SDK_FILE_SHA1) $@" | sha1sum -c -) || { rm -f "$@"; exit 1; }
$(TOP_DIR)/cache/esp_iot_sdk_v$(SDK_PATCH_VER).zip: $(TOP_DIR)/cache/$(SDK_PATCH_VER).patch:
mkdir -p "$(dir $@)" mkdir -p "$(dir $@)"
wget --tries=10 --timeout=15 --waitretry=30 --read-timeout=20 --retry-connrefused http://espressif.com/sites/default/files/sdks/esp8266_nonos_sdk_v$(SDK_PATCH_VER).zip -O $@ || { rm -f "$@"; exit 1; } wget --tries=10 --timeout=15 --waitretry=30 --read-timeout=20 --retry-connrefused "https://github.com/espressif/ESP8266_NONOS_SDK/compare/v$(SDK_BASE_VER)...$(SDK_PATCH_VER).patch" -O $@ || { rm -f "$@"; exit 1; }
(echo "$(SDK_PATCH_SHA1) $@" | sha1sum -c -) || { rm -f "$@"; exit 1; } (echo "$(SDK_PATCH_SHA1) $@" | sha1sum -c -) || { rm -f "$@"; exit 1; }
clean: clean:
...@@ -306,6 +319,17 @@ $(OBJODIR)/%.d: %.c ...@@ -306,6 +319,17 @@ $(OBJODIR)/%.d: %.c
sed 's,\($*\.o\)[ :]*,$(OBJODIR)/\1 $@ : ,g' < $@.$$$$ > $@; \ sed 's,\($*\.o\)[ :]*,$(OBJODIR)/\1 $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$ rm -f $@.$$$$
$(OBJODIR)/%.o: %.cpp
@mkdir -p $(OBJODIR);
$(CXX) $(if $(findstring $<,$(DSRCS)),$(DFLAGS),$(CFLAGS)) $(COPTS_$(*F)) -o $@ -c $<
$(OBJODIR)/%.d: %.cpp
@mkdir -p $(OBJODIR);
@echo DEPEND: $(CXX) -M $(CFLAGS) $<
@set -e; rm -f $@; \
sed 's,\($*\.o\)[ :]*,$(OBJODIR)/\1 $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$
$(OBJODIR)/%.o: %.s $(OBJODIR)/%.o: %.s
@mkdir -p $(OBJODIR); @mkdir -p $(OBJODIR);
$(CC) $(CFLAGS) -o $@ -c $< $(CC) $(CFLAGS) -o $@ -c $<
......
# **NodeMCU 2.1.0** # # **NodeMCU 2.2.0** #
[![Join the chat at https://gitter.im/nodemcu/nodemcu-firmware](https://img.shields.io/gitter/room/badges/shields.svg)](https://gitter.im/nodemcu/nodemcu-firmware?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Join the chat at https://gitter.im/nodemcu/nodemcu-firmware](https://img.shields.io/gitter/room/badges/shields.svg)](https://gitter.im/nodemcu/nodemcu-firmware?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build Status](https://travis-ci.org/nodemcu/nodemcu-firmware.svg)](https://travis-ci.org/nodemcu/nodemcu-firmware) [![Build Status](https://travis-ci.org/nodemcu/nodemcu-firmware.svg)](https://travis-ci.org/nodemcu/nodemcu-firmware)
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
### A Lua based firmware for ESP8266 WiFi SOC ### A Lua based firmware for ESP8266 WiFi SOC
NodeMCU is an [eLua](http://www.eluaproject.net/) based firmware for the [ESP8266 WiFi SOC from Espressif](http://espressif.com/en/products/esp8266/). The firmware is based on the [Espressif NON-OS SDK 2.1.0](https://github.com/espressif/ESP8266_NONOS_SDK/releases/tag/v2.1.0) and uses a file system based on [spiffs](https://github.com/pellepl/spiffs). The code repository consists of 98.1% C-code that glues the thin Lua veneer to the SDK. NodeMCU is an [eLua](http://www.eluaproject.net/) based firmware for the [ESP8266 WiFi SOC from Espressif](http://espressif.com/en/products/esp8266/). The firmware is based on the [Espressif NON-OS SDK 2.2.0](https://github.com/espressif/ESP8266_NONOS_SDK/releases/tag/v2.2.0) and uses a file system based on [spiffs](https://github.com/pellepl/spiffs). The code repository consists of 98.1% C-code that glues the thin Lua veneer to the SDK.
The NodeMCU *firmware* is a companion project to the popular [NodeMCU dev kits](https://github.com/nodemcu/nodemcu-devkit-v1.0), ready-made open source development boards with ESP8266-12E chips. The NodeMCU *firmware* is a companion project to the popular [NodeMCU dev kits](https://github.com/nodemcu/nodemcu-devkit-v1.0), ready-made open source development boards with ESP8266-12E chips.
......
...@@ -82,6 +82,7 @@ COMPONENTS_eagle.app.v6 = \ ...@@ -82,6 +82,7 @@ COMPONENTS_eagle.app.v6 = \
misc/libmisc.a \ misc/libmisc.a \
$(OPT_SEL_COMPONENTS) $(OPT_SEL_COMPONENTS)
# Inspect the modules library and work out which modules need to be linked. # Inspect the modules library and work out which modules need to be linked.
# For each enabled module, a symbol name of the form XYZ_module_selected is # For each enabled module, a symbol name of the form XYZ_module_selected is
# returned. At link time those names are declared undefined, so those (and # returned. At link time those names are declared undefined, so those (and
...@@ -140,6 +141,7 @@ CONFIGURATION_DEFINES = -D__ets__ \ ...@@ -140,6 +141,7 @@ CONFIGURATION_DEFINES = -D__ets__ \
-DLWIP_OPEN_SRC \ -DLWIP_OPEN_SRC \
-DPBUF_RSV_FOR_WLAN \ -DPBUF_RSV_FOR_WLAN \
-DEBUF_LWIP \ -DEBUF_LWIP \
-DUSE_OPTIMIZE_PRINTF \
-DMBEDTLS_USER_CONFIG_FILE=\"user_mbedtls.h\" \ -DMBEDTLS_USER_CONFIG_FILE=\"user_mbedtls.h\" \
DEFINES += \ DEFINES += \
......
#include "node.h" #include "node.h"
#include "coap_timer.h" #include "coap_timer.h"
#include "os_type.h" #include "os_type.h"
#include "pm/swtimer.h"
static os_timer_t coap_timer; static os_timer_t coap_timer;
static coap_tick_t basetime = 0; static coap_tick_t basetime = 0;
...@@ -48,6 +49,8 @@ void coap_timer_tick(void *arg){ ...@@ -48,6 +49,8 @@ void coap_timer_tick(void *arg){
void coap_timer_setup(coap_queue_t ** queue, coap_tick_t t){ void coap_timer_setup(coap_queue_t ** queue, coap_tick_t t){
os_timer_disarm(&coap_timer); os_timer_disarm(&coap_timer);
os_timer_setfn(&coap_timer, (os_timer_func_t *)coap_timer_tick, queue); os_timer_setfn(&coap_timer, (os_timer_func_t *)coap_timer_tick, queue);
SWTIMER_REG_CB(coap_timer_tick, SWTIMER_RESUME);
//coap_timer_tick processes a queue, my guess is that it is ok to resume the timer from where it left off
os_timer_arm(&coap_timer, t, 0); // no repeat os_timer_arm(&coap_timer, t, 0); // no repeat
} }
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "mem.h" #include "mem.h"
#include "gpio.h" #include "gpio.h"
#include "user_interface.h" #include "user_interface.h"
#include "pm/swtimer.h"
#include "driver/key.h" #include "driver/key.h"
...@@ -132,9 +133,9 @@ key_50ms_cb(struct single_key_param *single_key) ...@@ -132,9 +133,9 @@ key_50ms_cb(struct single_key_param *single_key)
LOCAL void LOCAL void
key_intr_handler(void *arg) key_intr_handler(void *arg)
{ {
struct keys_param *keys = arg;
uint8 i; uint8 i;
uint32 gpio_status = GPIO_REG_READ(GPIO_STATUS_ADDRESS); uint32 gpio_status = GPIO_REG_READ(GPIO_STATUS_ADDRESS);
struct keys_param *keys = arg;
for (i = 0; i < keys->key_num; i++) { for (i = 0; i < keys->key_num; i++) {
if (gpio_status & BIT(keys->single_key[i]->gpio_id)) { if (gpio_status & BIT(keys->single_key[i]->gpio_id)) {
...@@ -148,6 +149,8 @@ key_intr_handler(void *arg) ...@@ -148,6 +149,8 @@ key_intr_handler(void *arg)
// 5s, restart & enter softap mode // 5s, restart & enter softap mode
os_timer_disarm(&keys->single_key[i]->key_5s); os_timer_disarm(&keys->single_key[i]->key_5s);
os_timer_setfn(&keys->single_key[i]->key_5s, (os_timer_func_t *)key_5s_cb, keys->single_key[i]); os_timer_setfn(&keys->single_key[i]->key_5s, (os_timer_func_t *)key_5s_cb, keys->single_key[i]);
SWTIMER_REG_CB(key_5s_cb, SWTIMER_DROP);
// key_5s_cb checks the state of a gpio. After resume, gpio state would be invalid
os_timer_arm(&keys->single_key[i]->key_5s, 5000, 0); os_timer_arm(&keys->single_key[i]->key_5s, 5000, 0);
keys->single_key[i]->key_level = 0; keys->single_key[i]->key_level = 0;
gpio_pin_intr_state_set(GPIO_ID_PIN(keys->single_key[i]->gpio_id), GPIO_PIN_INTR_POSEDGE); gpio_pin_intr_state_set(GPIO_ID_PIN(keys->single_key[i]->gpio_id), GPIO_PIN_INTR_POSEDGE);
...@@ -155,6 +158,8 @@ key_intr_handler(void *arg) ...@@ -155,6 +158,8 @@ key_intr_handler(void *arg)
// 50ms, check if this is a real key up // 50ms, check if this is a real key up
os_timer_disarm(&keys->single_key[i]->key_50ms); os_timer_disarm(&keys->single_key[i]->key_50ms);
os_timer_setfn(&keys->single_key[i]->key_50ms, (os_timer_func_t *)key_50ms_cb, keys->single_key[i]); os_timer_setfn(&keys->single_key[i]->key_50ms, (os_timer_func_t *)key_50ms_cb, keys->single_key[i]);
SWTIMER_REG_CB(key_50ms_cb, SWTIMER_DROP);
// key_50ms_cb checks the state of a gpio. After resume, gpio state would be invalid
os_timer_arm(&keys->single_key[i]->key_50ms, 50, 0); os_timer_arm(&keys->single_key[i]->key_50ms, 50, 0);
} }
} }
......
...@@ -527,6 +527,7 @@ void spi_slave_init(uint8 spi_no) ...@@ -527,6 +527,7 @@ void spi_slave_init(uint8 spi_no)
#ifdef SPI_SLAVE_DEBUG #ifdef SPI_SLAVE_DEBUG
#include "pm/swtimer.h"
/****************************************************************************** /******************************************************************************
* FunctionName : hspi_master_readwrite_repeat * FunctionName : hspi_master_readwrite_repeat
* Description : SPI master test function for reading and writing esp8266 slave buffer, * Description : SPI master test function for reading and writing esp8266 slave buffer,
...@@ -545,6 +546,8 @@ void hspi_master_readwrite_repeat(void) ...@@ -545,6 +546,8 @@ void hspi_master_readwrite_repeat(void)
temp++; temp++;
spi_byte_write_espslave(SPI_HSPI,temp); spi_byte_write_espslave(SPI_HSPI,temp);
os_timer_setfn(&timer2, (os_timer_func_t *)hspi_master_readwrite_repeat, NULL); os_timer_setfn(&timer2, (os_timer_func_t *)hspi_master_readwrite_repeat, NULL);
SWTIMER_REGISTER_CB_PTR(hspi_master_readwrite_repeat, SWTIMER_RESUME);
//hspi_master_readwrite_repeat timer will be resumed on wake up, maybe data will still be in buffer?
os_timer_arm(&timer2, 500, 0); os_timer_arm(&timer2, 500, 0);
} }
#endif #endif
......
...@@ -323,11 +323,14 @@ uart_autobaud_timeout(void *timer_arg) ...@@ -323,11 +323,14 @@ uart_autobaud_timeout(void *timer_arg)
uart_div_modify(uart_no, divisor); uart_div_modify(uart_no, divisor);
} }
} }
#include "pm/swtimer.h"
static void static void
uart_init_autobaud(uint32_t uart_no) uart_init_autobaud(uint32_t uart_no)
{ {
os_timer_setfn(&autobaud_timer, uart_autobaud_timeout, (void *) uart_no); os_timer_setfn(&autobaud_timer, uart_autobaud_timeout, (void *) uart_no);
SWTIMER_REG_CB(uart_autobaud_timeout, SWTIMER_DROP);
//if autobaud hasn't done it's thing by the time light sleep triggered, it probably isn't going to happen.
os_timer_arm(&autobaud_timer, 100, TRUE); os_timer_arm(&autobaud_timer, 100, TRUE);
} }
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "limits.h" #include "limits.h"
#include "httpclient.h" #include "httpclient.h"
#include "stdlib.h" #include "stdlib.h"
#include "pm/swtimer.h"
#define REDIRECTION_FOLLOW_MAX 20 #define REDIRECTION_FOLLOW_MAX 20
...@@ -525,6 +526,8 @@ static void ICACHE_FLASH_ATTR http_dns_callback( const char * hostname, ip_addr_ ...@@ -525,6 +526,8 @@ static void ICACHE_FLASH_ATTR http_dns_callback( const char * hostname, ip_addr_
/* Set connection timeout timer */ /* Set connection timeout timer */
os_timer_disarm( &(req->timeout_timer) ); os_timer_disarm( &(req->timeout_timer) );
os_timer_setfn( &(req->timeout_timer), (os_timer_func_t *) http_timeout_callback, conn ); os_timer_setfn( &(req->timeout_timer), (os_timer_func_t *) http_timeout_callback, conn );
SWTIMER_REG_CB(http_timeout_callback, SWTIMER_IMMEDIATE);
//http_timeout_callback frees memory used by this function and timer cannot be dropped
os_timer_arm( &(req->timeout_timer), req->timeout, false ); os_timer_arm( &(req->timeout_timer), req->timeout, false );
#ifdef CLIENT_SSL_ENABLE #ifdef CLIENT_SSL_ENABLE
......
...@@ -65,7 +65,7 @@ typedef uint32_t mem_ptr_t; ...@@ -65,7 +65,7 @@ typedef uint32_t mem_ptr_t;
#define U32_F "d" #define U32_F "d"
#define X32_F "x" #define X32_F "x"
#define LWIP_ERR_T s32_t
//#define PACK_STRUCT_FIELD(x) x __attribute__((packed)) //#define PACK_STRUCT_FIELD(x) x __attribute__((packed))
#define PACK_STRUCT_FIELD(x) x #define PACK_STRUCT_FIELD(x) x
......
/*
* ESPRESSIF MIT License
*
* Copyright (c) 2016 <ESPRESSIF SYSTEMS (SHANGHAI) PTE LTD>
*
* Permission is hereby granted for use on ESPRESSIF SYSTEMS ESP8266 only, in which case,
* it is free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished
* to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef __ESPCONN_H__ #ifndef __ESPCONN_H__
#define __ESPCONN_H__ #define __ESPCONN_H__
#include "lwip/err.h"
#include "lwip/dns.h" #include "lwip/dns.h"
#include "os_type.h" #include "os_type.h"
#include "lwip/app/espconn_buf.h" #include "lwip/app/espconn_buf.h"
...@@ -37,8 +62,7 @@ typedef void (* espconn_reconnect_callback)(void *arg, sint8 err); ...@@ -37,8 +62,7 @@ typedef void (* espconn_reconnect_callback)(void *arg, sint8 err);
#define ESPCONN_NODATA -17 /* No data can be read */ #define ESPCONN_NODATA -17 /* No data can be read */
#define ESPCONN_HANDSHAKE -28 /* ssl handshake failed */ #define ESPCONN_HANDSHAKE -28 /* ssl handshake failed */
#define ESPCONN_RESP_TIMEOUT -29 /* ssl handshake no response*/ #define ESPCONN_SSL_INVALID_DATA -61 /* ssl application invalid */
#define ESPCONN_PROTO_MSG -61 /* ssl application invalid */
#define ESPCONN_SSL 0x01 #define ESPCONN_SSL 0x01
#define ESPCONN_NORM 0x00 #define ESPCONN_NORM 0x00
...@@ -121,6 +145,7 @@ enum espconn_option{ ...@@ -121,6 +145,7 @@ enum espconn_option{
ESPCONN_NODELAY = 0x02, ESPCONN_NODELAY = 0x02,
ESPCONN_COPY = 0x04, ESPCONN_COPY = 0x04,
ESPCONN_KEEPALIVE = 0x08, ESPCONN_KEEPALIVE = 0x08,
ESPCONN_MANUALRECV = 0x10,
ESPCONN_END ESPCONN_END
}; };
...@@ -461,6 +486,17 @@ extern sint8 espconn_regist_sentcb(struct espconn *espconn, espconn_sent_callbac ...@@ -461,6 +486,17 @@ extern sint8 espconn_regist_sentcb(struct espconn *espconn, espconn_sent_callbac
*******************************************************************************/ *******************************************************************************/
extern sint8 espconn_regist_write_finish(struct espconn *espconn, espconn_connect_callback write_finish_fn); extern sint8 espconn_regist_write_finish(struct espconn *espconn, espconn_connect_callback write_finish_fn);
/******************************************************************************
* FunctionName : espconn_send
* Description : sent data for client or server
* Parameters : espconn -- espconn to set for client or server
* psent -- data to send
* length -- length of data to send
* Returns : none
*******************************************************************************/
extern sint8 espconn_send(struct espconn *espconn, uint8 *psent, uint16 length);
/****************************************************************************** /******************************************************************************
* FunctionName : espconn_sent * FunctionName : espconn_sent
* Description : sent data for client or server * Description : sent data for client or server
...@@ -573,7 +609,163 @@ extern sint8 espconn_get_keepalive(struct espconn *espconn, uint8 level, void *o ...@@ -573,7 +609,163 @@ extern sint8 espconn_get_keepalive(struct espconn *espconn, uint8 level, void *o
* - ESPCONN_ARG: dns client not initialized or invalid hostname * - ESPCONN_ARG: dns client not initialized or invalid hostname
*******************************************************************************/ *******************************************************************************/
extern sint8 espconn_gethostbyname(struct espconn *pespconn, const char *name, ip_addr_t *addr, dns_found_callback found); extern err_t espconn_gethostbyname(struct espconn *pespconn, const char *name, ip_addr_t *addr, dns_found_callback found);
/******************************************************************************
* FunctionName : espconn_abort
* Description : Forcely abort with host
* Parameters : espconn -- the espconn used to connect with the host
* Returns : result
*******************************************************************************/
extern sint8 espconn_abort(struct espconn *espconn);
/******************************************************************************
* FunctionName : espconn_encry_connect
* Description : The function given as connection
* Parameters : espconn -- the espconn used to connect with the host
* Returns : none
*******************************************************************************/
extern sint8 espconn_secure_connect(struct espconn *espconn);
/******************************************************************************
* FunctionName : espconn_encry_disconnect
* Description : The function given as the disconnection
* Parameters : espconn -- the espconn used to disconnect with the host
* Returns : none
*******************************************************************************/
extern sint8 espconn_secure_disconnect(struct espconn *espconn);
/******************************************************************************
* FunctionName : espconn_secure_send
* Description : sent data for client or server
* Parameters : espconn -- espconn to set for client or server
* psent -- data to send
* length -- length of data to send
* Returns : none
*******************************************************************************/
extern sint8 espconn_secure_send(struct espconn *espconn, uint8 *psent, uint16 length);
/******************************************************************************
* FunctionName : espconn_encry_sent
* Description : sent data for client or server
* Parameters : espconn -- espconn to set for client or server
* psent -- data to send
* length -- length of data to send
* Returns : none
*******************************************************************************/
extern sint8 espconn_secure_sent(struct espconn *espconn, uint8 *psent, uint16 length);
/******************************************************************************
* FunctionName : espconn_secure_set_size
* Description : set the buffer size for client or server
* Parameters : level -- set for client or server
* 1: client,2:server,3:client and server
* size -- buffer size
* Returns : true or false
*******************************************************************************/
extern bool espconn_secure_set_size(uint8 level, uint16 size);
/******************************************************************************
* FunctionName : espconn_secure_get_size
* Description : get buffer size for client or server
* Parameters : level -- set for client or server
* 1: client,2:server,3:client and server
* Returns : buffer size for client or server
*******************************************************************************/
extern sint16 espconn_secure_get_size(uint8 level);
/******************************************************************************
* FunctionName : espconn_secure_ca_enable
* Description : enable the certificate authenticate and set the flash sector
* as client or server
* Parameters : level -- set for client or server
* 1: client,2:server,3:client and server
* flash_sector -- flash sector for save certificate
* Returns : result true or false
*******************************************************************************/
extern bool espconn_secure_ca_enable(uint8 level, uint32 flash_sector );
/******************************************************************************
* FunctionName : espconn_secure_ca_disable
* Description : disable the certificate authenticate as client or server
* Parameters : level -- set for client or server
* 1: client,2:server,3:client and server
* Returns : result true or false
*******************************************************************************/
extern bool espconn_secure_ca_disable(uint8 level);
/******************************************************************************
* FunctionName : espconn_secure_cert_req_enable
* Description : enable the client certificate authenticate and set the flash sector
* as client or server
* Parameters : level -- set for client or server
* 1: client,2:server,3:client and server
* flash_sector -- flash sector for save certificate
* Returns : result true or false
*******************************************************************************/
extern bool espconn_secure_cert_req_enable(uint8 level, uint32 flash_sector );
/******************************************************************************
* FunctionName : espconn_secure_ca_disable
* Description : disable the client certificate authenticate as client or server
* Parameters : level -- set for client or server
* 1: client,2:server,3:client and server
* Returns : result true or false
*******************************************************************************/
extern bool espconn_secure_cert_req_disable(uint8 level);
/******************************************************************************
* FunctionName : espconn_secure_set_default_certificate
* Description : Load the certificates in memory depending on compile-time
* and user options.
* Parameters : certificate -- Load the certificate
* length -- Load the certificate length
* Returns : result true or false
*******************************************************************************/
extern bool espconn_secure_set_default_certificate(const uint8* certificate, uint16 length);
/******************************************************************************
* FunctionName : espconn_secure_set_default_private_key
* Description : Load the key in memory depending on compile-time
* and user options.
* Parameters : private_key -- Load the key
* length -- Load the key length
* Returns : result true or false
*******************************************************************************/
extern bool espconn_secure_set_default_private_key(const uint8* private_key, uint16 length);
/******************************************************************************
* FunctionName : espconn_secure_accept
* Description : The function given as the listen
* Parameters : espconn -- the espconn used to listen the connection
* Returns : result
*******************************************************************************/
extern sint8 espconn_secure_accept(struct espconn *espconn);
/******************************************************************************
* FunctionName : espconn_secure_accepts
* Description : delete the secure server host
* Parameters : espconn -- the espconn used to listen the connection
* Returns : result
*******************************************************************************/
extern sint8 espconn_secure_delete(struct espconn *espconn);
/****************************************************************************** /******************************************************************************
* FunctionName : espconn_igmp_join * FunctionName : espconn_igmp_join
...@@ -593,6 +785,22 @@ extern sint8 espconn_igmp_join(ip_addr_t *host_ip, ip_addr_t *multicast_ip); ...@@ -593,6 +785,22 @@ extern sint8 espconn_igmp_join(ip_addr_t *host_ip, ip_addr_t *multicast_ip);
*******************************************************************************/ *******************************************************************************/
extern sint8 espconn_igmp_leave(ip_addr_t *host_ip, ip_addr_t *multicast_ip); extern sint8 espconn_igmp_leave(ip_addr_t *host_ip, ip_addr_t *multicast_ip);
/******************************************************************************
* FunctionName : espconn_recv_hold
* Description : hold tcp receive
* Parameters : espconn -- espconn to hold
* Returns : none
*******************************************************************************/
extern sint8 espconn_recv_hold(struct espconn *pespconn);
/******************************************************************************
* FunctionName : espconn_recv_unhold
* Description : unhold tcp receive
* Parameters : espconn -- espconn to unhold
* Returns : none
*******************************************************************************/
extern sint8 espconn_recv_unhold(struct espconn *pespconn);
/****************************************************************************** /******************************************************************************
* FunctionName : espconn_mdns_init * FunctionName : espconn_mdns_init
* Description : register a device with mdns * Description : register a device with mdns
......
...@@ -13,6 +13,9 @@ ...@@ -13,6 +13,9 @@
#define espconn_keepalive_enable(pcb) ((pcb)->so_options |= SOF_KEEPALIVE) #define espconn_keepalive_enable(pcb) ((pcb)->so_options |= SOF_KEEPALIVE)
#define espconn_keepalive_disable(pcb) ((pcb)->so_options &= ~SOF_KEEPALIVE) #define espconn_keepalive_disable(pcb) ((pcb)->so_options &= ~SOF_KEEPALIVE)
#define espconn_manual_recv_disabled(espconn) (((espconn)->pcommon.espconn_opt & ESPCONN_MANUALRECV) != 0)
#define espconn_manual_recv_enabled(espconn) (((espconn)->pcommon.espconn_opt & ESPCONN_MANUALRECV) == 0)
/****************************************************************************** /******************************************************************************
* FunctionName : espconn_kill_oldest_pcb * FunctionName : espconn_kill_oldest_pcb
* Description : A oldest incoming connection has been killed. * Description : A oldest incoming connection has been killed.
......
/*
* time.h
*
* Created on: May 31, 2016
* Author: liuhan
*/
#ifndef TIME_H_
#define TIME_H_
#include "osapi.h"
#include "os_type.h"
#include "lwip/sntp.h"
struct timeval {
unsigned long tv_sec; /* seconds */
unsigned long tv_usec; /* and microseconds */
};
/***************************RTC TIME OPTION***************************************/
// daylight settings
// Base calculated with value obtained from NTP server (64 bits)
#define sntp_base (*((uint64_t*)RTC_STORE0))
// Timer value when base was obtained
#define TIM_REF_SET(value) WRITE_PERI_REG(RTC_STORE2, value)
#define TIM_REF_GET() READ_PERI_REG(RTC_STORE2)
// Setters and getters for CAL, TZ and DST.
#define RTC_CAL_SET(val) do {uint32 value = READ_PERI_REG(RTC_STORE3);\
value |= ((val) & 0x0000FFFF);\
WRITE_PERI_REG(RTC_STORE3, value);\
}while(0)
#define RTC_DST_SET(val) do {uint32 value = READ_PERI_REG(RTC_STORE3);\
value |= (((val)<<16) & 0x00010000);\
WRITE_PERI_REG(RTC_STORE3, value);\
}while(0)
#define RTC_TZ_SET(val) do {uint32 value = READ_PERI_REG(RTC_STORE3);\
value |= (((val)<<24) & 0xFF000000);\
WRITE_PERI_REG(RTC_STORE3, value);\
}while(0)
#define RTC_CAL_GET() (READ_PERI_REG(RTC_STORE3) & 0x0000FFFF)
#define RTC_DST_GET() ((READ_PERI_REG(RTC_STORE3) & 0x00010000)>>16)
#define RTC_TZ_GET() ((((int)READ_PERI_REG(RTC_STORE3)) & ((int)0xFF000000))>>24)
void system_update_rtc(time_t t, uint32_t us);
time_t sntp_get_rtc_time(sint32_t *us);
int gettimeofday(struct timeval* t, void* timezone);
void updateTime(uint32 ms);
bool configTime(int timezone, int daylightOffset, char *server1, char *server2, char *server3, bool enable);
time_t time(time_t *t);
unsigned long millis(void);
unsigned long micros(void);
#endif /* TIME_H_ */
...@@ -78,7 +78,7 @@ do{\ ...@@ -78,7 +78,7 @@ do{\
#define mem_malloc(s) ({const char *file = mem_debug_file; pvPortMalloc(s, file, __LINE__);}) #define mem_malloc(s) ({const char *file = mem_debug_file; pvPortMalloc(s, file, __LINE__);})
#endif #endif
#ifndef mem_calloc #ifndef mem_calloc
#define mem_calloc(s) ({const char *file = mem_debug_file; pvPortCalloc(s, file, __LINE__);}) #define mem_calloc(l, s) ({const char *file = mem_debug_file; pvPortCalloc(l, s, file, __LINE__);})
#endif #endif
#ifndef mem_realloc #ifndef mem_realloc
#define mem_realloc(p, s) ({const char *file = mem_debug_file; pvPortRealloc(p, s, file, __LINE__);}) #define mem_realloc(p, s) ({const char *file = mem_debug_file; pvPortRealloc(p, s, file, __LINE__);})
......
#ifndef LWIP_SNTP_H
#define LWIP_SNTP_H
#include "lwip/opt.h"
#include "lwip/ip_addr.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef long time_t;
/** The maximum number of SNTP servers that can be set */
#ifndef SNTP_MAX_SERVERS
#define SNTP_MAX_SERVERS 3
#endif
/** Set this to 1 to implement the callback function called by dhcp when
* NTP servers are received. */
#ifndef SNTP_GET_SERVERS_FROM_DHCP
#define SNTP_GET_SERVERS_FROM_DHCP 0//LWIP_DHCP_GET_NTP_SRV
#endif
/* Set this to 1 to support DNS names (or IP address strings) to set sntp servers */
#ifndef SNTP_SERVER_DNS
#define SNTP_SERVER_DNS 1
#endif
bool sntp_get_timetype(void);
void sntp_set_receive_time_size(void);
/** One server address/name can be defined as default if SNTP_SERVER_DNS == 1:
* #define SNTP_SERVER_ADDRESS "pool.ntp.org"
*/
uint32 sntp_get_current_timestamp();
char* sntp_get_real_time(long t);
void sntp_init(void);
void sntp_stop(void);
sint8 sntp_get_timezone(void);
bool sntp_set_timezone(sint8 timezone);
void sntp_setserver(u8_t idx, ip_addr_t *addr);
ip_addr_t sntp_getserver(u8_t idx);
#if SNTP_SERVER_DNS
void sntp_setservername(u8_t idx, char *server);
char *sntp_getservername(u8_t idx);
#endif /* SNTP_SERVER_DNS */
#if SNTP_GET_SERVERS_FROM_DHCP
void sntp_servermode_dhcp(int set_servers_from_dhcp);
#else /* SNTP_GET_SERVERS_FROM_DHCP */
#define sntp_servermode_dhcp(x)
#endif /* SNTP_GET_SERVERS_FROM_DHCP */
#ifdef __cplusplus
}
#endif
#endif /* LWIP_SNTP_H */
#ifndef __DYNARR_H__
#define __DYNARR_H__
#include "user_interface.h"
#include "c_stdio.h"
#include "c_stdlib.h"
//#define DYNARR_DEBUG
//#define DYNARR_ERROR
typedef struct _dynarr{
void* data_ptr;
size_t used;
size_t array_size;
size_t data_size;
} dynarr_t;
bool dynarr_init(dynarr_t* array_ptr, size_t array_size, size_t data_size);
bool dynarr_resize(dynarr_t* array_ptr, size_t elements_to_add);
bool dynarr_remove(dynarr_t* array_ptr, void* element_ptr);
bool dynarr_add(dynarr_t* array_ptr, void* data_ptr, size_t data_size);
bool dynarr_boundaryCheck(dynarr_t* array_ptr, void* element_ptr);
bool dynarr_free(dynarr_t* array_ptr);
#if 0 || defined(DYNARR_DEBUG) || defined(NODE_DEBUG)
#define DYNARR_DBG(fmt, ...) c_printf("\n DYNARR_DBG(%s): "fmt"\n", __FUNCTION__, ##__VA_ARGS__)
#else
#define DYNARR_DBG(...)
#endif
#if 0 || defined(DYNARR_ERROR) || defined(NODE_ERROR)
#define DYNARR_ERR(fmt, ...) c_printf("\n DYNARR: "fmt"\n", ##__VA_ARGS__)
#else
#define DYNARR_ERR(...)
#endif
#endif // __DYNARR_H__
/*
* swtimer.h
*
* Created on: Aug 4, 2017
* Author: anonymous
*/
#ifndef APP_INCLUDE_PM_SWTIMER_H_
#define APP_INCLUDE_PM_SWTIMER_H_
void swtmr_cb_register(void* timer_cb_ptr, uint8 suspend_policy);
#define SWTIMER_RESUME 0 //save remaining time
#define SWTIMER_RESTART 1 //use timer_period as remaining time
#define SWTIMER_IMMEDIATE 2 //fire timer immediately after resume
#define SWTIMER_DROP 3 //disarm timer, do not resume
#if defined(TIMER_SUSPEND_ENABLE)
#define SWTIMER_REG_CB(cb_ptr, suspend_policy) do{ \
static bool cb_ptr##_registered_flag;\
if(!cb_ptr##_registered_flag){ \
cb_ptr##_registered_flag = true; \
swtmr_cb_register(cb_ptr, suspend_policy);\
} \
}while(0);
#else
#define SWTIMER_REG_CB(...)
#endif
#endif /* APP_INCLUDE_PM_SWTIMER_H_ */
...@@ -689,11 +689,15 @@ static inline void rtc_time_switch_to_system_clock(void) ...@@ -689,11 +689,15 @@ static inline void rtc_time_switch_to_system_clock(void)
static inline void rtc_time_tmrfn(void* arg); static inline void rtc_time_tmrfn(void* arg);
#include "pm/swtimer.h"
static void rtc_time_install_timer(void) static void rtc_time_install_timer(void)
{ {
static ETSTimer tmr; static ETSTimer tmr;
os_timer_setfn(&tmr,rtc_time_tmrfn,NULL); os_timer_setfn(&tmr,rtc_time_tmrfn,NULL);
SWTIMER_REG_CB(rtc_time_tmrfn, SWTIMER_RESUME);
//I believe the function rtc_time_tmrfn compensates for drift in the clock and updates rtc time accordingly, This timer should probably be resumed
os_timer_arm(&tmr,10000,1); os_timer_arm(&tmr,10000,1);
} }
......
#ifndef __SW_TIMER_H__
#define __SW_TIMER_H__
#include "user_interface.h"
//#define SWTMR_DEBUG
#define USE_SWTMR_ERROR_STRINGS
#if defined(DEVELOP_VERSION)
#define SWTMR_DEBUG
#endif
#if defined(SWTMR_DEBUG)
#define SWTMR_DBG(fmt, ...) dbg_printf("\tSWTIMER(%s):"fmt"\n", __FUNCTION__, ##__VA_ARGS__)
#else
#define SWTMR_DBG(...)
#endif
#if defined(NODE_ERROR)
#define SWTMR_ERR(fmt, ...) NODE_ERR("%s"fmt"\n", "SWTIMER:", ##__VA_ARGS__)
#else
#define SWTMR_ERR(...)
#endif
enum SWTMR_STATUS{
SWTMR_FAIL = 0,
SWTMR_OK = 1,
SWTMR_MALLOC_FAIL = 10,
SWTMR_TIMER_NOT_ARMED,
// SWTMR_NULL_PTR,
SWTMR_REGISTRY_NO_REGISTERED_TIMERS,
// SWTMR_SUSPEND_ARRAY_INITIALIZATION_FAILED,
// SWTMR_SUSPEND_ARRAY_ADD_FAILED,
// SWTMR_SUSPEND_ARRAY_REMOVE_FAILED,
SWTMR_SUSPEND_TIMER_ALREADY_SUSPENDED,
SWTMR_SUSPEND_TIMER_ALREADY_REARMED,
SWTMR_SUSPEND_NO_SUSPENDED_TIMERS,
SWTMR_SUSPEND_TIMER_NOT_SUSPENDED,
};
/* Global Function Declarations */
void swtmr_register(void* timer_ptr);
void swtmr_unregister(void* timer_ptr);
int swtmr_suspend(os_timer_t* timer_ptr);
int swtmr_resume(os_timer_t* timer_ptr);
void swtmr_print_registry(void);
void swtmr_print_suspended(void);
void swtmr_print_timer_list(void);
const char* swtmr_errorcode2str(int error_value);
bool swtmr_suspended_test(os_timer_t* timer_ptr);
#endif // __SW_TIMER_H__
...@@ -218,7 +218,9 @@ extern void luaL_dbgbreak(void); ...@@ -218,7 +218,9 @@ extern void luaL_dbgbreak(void);
// #define GPIO_SAFE_NO_INTR_ENABLE // #define GPIO_SAFE_NO_INTR_ENABLE
#define ICACHE_STORE_TYPEDEF_ATTR __attribute__((aligned(4),packed)) #define ICACHE_STORE_TYPEDEF_ATTR __attribute__((aligned(4),packed))
#define ICACHE_STORE_ATTR __attribute__((aligned(4))) #define ICACHE_STORE_ATTR __attribute__((aligned(4)))
#define ICACHE_RAM_ATTR __attribute__((section(".iram0.text"))) #define ICACHE_RAM_STRING(x) ICACHE_RAM_STRING2(x)
#define ICACHE_RAM_STRING2(x) #x
#define ICACHE_RAM_ATTR __attribute__((section(".iram0.text." __FILE__ "." ICACHE_RAM_STRING(__LINE__))))
#ifdef GPIO_SAFE_NO_INTR_ENABLE #ifdef GPIO_SAFE_NO_INTR_ENABLE
#define NO_INTR_CODE ICACHE_RAM_ATTR __attribute__ ((noinline)) #define NO_INTR_CODE ICACHE_RAM_ATTR __attribute__ ((noinline))
#else #else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment