Skip to content

Commit

Permalink
Attempt to make the library compatible with old SDKs (1.5 and 2.0) an…
Browse files Browse the repository at this point in the history
…d newer (2.1.0 + )
  • Loading branch information
slav-at-attachix committed Nov 5, 2017
1 parent 9b51274 commit c967121
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Sming/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ EXTRA_INCDIR += third-party/ws_parser/
# => SDK
ifneq (,$(findstring third-party/ESP8266_NONOS_SDK, $(SDK_BASE)))
THIRD_PARTY_DATA += third-party/ESP8266_NONOS_SDK/Makefile
CFLAGS += -DSDK_INTERNAL
endif

# => esp-gdbstub
Expand Down Expand Up @@ -233,7 +234,7 @@ endif
MFORCE32 := $(shell $(CC) --help=target | grep mforce-l32)

# compiler flags using during compilation of source files. Add '-pg' for debugging
CFLAGS = -Wpointer-arith -Wundef -Werror -Wl,-EL -nostdlib -mlongcalls -mtext-section-literals -finline-functions -fdata-sections -ffunction-sections \
CFLAGS += -Wpointer-arith -Wundef -Werror -Wl,-EL -nostdlib -mlongcalls -mtext-section-literals -finline-functions -fdata-sections -ffunction-sections \
-D__ets__ -DICACHE_FLASH -DARDUINO=106 -DCOM_SPEED_SERIAL=$(COM_SPEED_SERIAL) -DENABLE_CMD_EXECUTOR=$(ENABLE_CMD_EXECUTOR) -DESP8266=1
ifeq ($(SMING_RELEASE),1)
# See: https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
Expand Down
4 changes: 4 additions & 0 deletions Sming/Makefile-project.mk
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ endif

# compiler flags using during compilation of source files
CFLAGS = -Wpointer-arith -Wundef -Werror -Wl,-EL -nostdlib -mlongcalls -mtext-section-literals -finline-functions -fdata-sections -ffunction-sections -D__ets__ -DICACHE_FLASH -DARDUINO=106 -DCOM_SPEED_SERIAL=$(COM_SPEED_SERIAL) $(USER_CFLAGS) -DENABLE_CMD_EXECUTOR=$(ENABLE_CMD_EXECUTOR)
# => SDK
ifneq (,$(findstring third-party/ESP8266_NONOS_SDK, $(SDK_BASE)))
CFLAGS += -DSDK_INTERNAL
endif
ifeq ($(SMING_RELEASE),1)
# See: https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
# for full list of optimization options
Expand Down
4 changes: 4 additions & 0 deletions Sming/Makefile-rboot.mk
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ USER_LIBDIR = $(SMING_HOME)/compiler/lib/

# compiler flags using during compilation of source files
CFLAGS = -Wpointer-arith -Wundef -Werror -Wl,-EL -nostdlib -mlongcalls -mtext-section-literals -finline-functions -fdata-sections -ffunction-sections -D__ets__ -DICACHE_FLASH -DARDUINO=106 -DCOM_SPEED_SERIAL=$(COM_SPEED_SERIAL) $(USER_CFLAGS) -DENABLE_CMD_EXECUTOR=$(ENABLE_CMD_EXECUTOR)
# => SDK
ifneq (,$(findstring third-party/ESP8266_NONOS_SDK, $(SDK_BASE)))
CFLAGS += -DSDK_INTERNAL
endif
ifeq ($(SMING_RELEASE),1)
# See: https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
# for full list of optimization options
Expand Down
59 changes: 58 additions & 1 deletion Sming/system/include/esp_systemapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#ifndef __ESP_SYSTEM_API_H__
#define __ESP_SYSTEM_API_H__

#include "ets_sys.h"
#include <ets_sys.h>
#include <osapi.h>
#include <gpio.h>
#include <os_type.h>
Expand Down Expand Up @@ -43,6 +43,63 @@
#endif
#define assert(condition) if (!(condition)) SYSTEM_ERROR("ASSERT: %s %d", __FUNCTION__, __LINE__)
#define SYSTEM_ERROR(fmt, ...) m_printf("ERROR: " fmt "\r\n", ##__VA_ARGS__)

#ifndef SDK_INTERNAL
extern void ets_timer_arm_new(ETSTimer *ptimer, uint32_t milliseconds, bool repeat_flag, int isMstimer);
extern void ets_timer_disarm(ETSTimer *a);
extern void ets_timer_setfn(ETSTimer *t, ETSTimerFunc *pfunction, void *parg);

//extern void ets_wdt_init(uint32_t val); // signature?
extern void ets_wdt_enable(void);
extern void ets_wdt_disable(void);
extern void wdt_feed(void);
//extern void wd_reset_cnt(void);
extern void ets_delay_us(uint32_t us);

extern void ets_isr_mask(unsigned intr);
extern void ets_isr_unmask(unsigned intr);

typedef void (* ets_isr_t)(void *);

//extern void ets_isr_attach(int intr, void *handler, void *arg);
extern void ets_isr_attach(int i, ets_isr_t func, void *arg);

extern int ets_memcmp(const void *s1, const void *s2, size_t n);
extern void *ets_memcpy(void *dest, const void *src, size_t n);
extern void *ets_memset(void *s, int c, size_t n);

//extern void ets_install_putc1(void *routine);
extern void ets_install_putc1(void (*p)(char c));
extern int ets_sprintf(char *str, const char *format, ...) __attribute__ ((format (printf, 2, 3)));
extern int ets_str2macaddr(void *, void *);
extern int ets_strcmp(const char *s1, const char *s2);
extern char *ets_strcpy(char *dest, const char *src);
//extern int os_random();
//extern char *ets_strdup(const char *str); // :(
const char * ets_strrchr(const char *str, int character);
extern int ets_strlen(const char *s);
extern int ets_strncmp(const char *s1, const char *s2, unsigned int len);
extern char *ets_strncpy(char *dest, const char *src, size_t n);
extern char *ets_strstr(const char *haystack, const char *needle);
extern int os_printf_plus(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
extern int os_snprintf(char *str, size_t size, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
extern int ets_vsnprintf(char * s, size_t n, const char * format, va_list arg) __attribute__ ((format (printf, 3, 0)));

extern void *pvPortMalloc(size_t xWantedSize, const char *file, uint32 line);
extern void *pvPortZalloc(size_t xWantedSize, const char *file, uint32 line);
extern void pvPortFree(void *ptr);
extern void vPortFree(void *ptr, const char *file, uint32 line);
extern void *vPortMalloc(size_t xWantedSize);

extern void uart_div_modify(uint8 uart_no, uint32 DivLatchValue);
extern int ets_uart_printf(const char *fmt, ...);
extern void uart_tx_one_char(char ch);

extern void ets_intr_lock();
extern void ets_intr_unlock();

#endif /* SDK_INTERNAL */

// CPU Frequency
extern void ets_update_cpu_frequency(uint32_t frq);
extern uint32_t ets_get_cpu_frequency();
Expand Down

0 comments on commit c967121

Please sign in to comment.