Mostly updated header files for use in C++

This commit is contained in:
Michael Jacobsen 2015-07-30 19:34:13 +02:00 committed by Angus Gratton
parent 9d62d09d3f
commit 436aa8b8cc
13 changed files with 97 additions and 8 deletions

View file

@ -5,6 +5,6 @@
#ifndef _VERSION_H
#define AXTLS_VERSION "esp-open-rtos axTLS "GITSHORTREV
#define AXTLS_VERSION "esp-open-rtos axTLS " GITSHORTREV
#endif

View file

@ -94,14 +94,19 @@ OWN_LIBC ?= 1
# Note: you will need a recent esp
ENTRY_SYMBOL ?= call_user_start
CFLAGS = -Wall -Werror -Wl,-EL -nostdlib -mlongcalls -mtext-section-literals -std=gnu99 $(CPPFLAGS)
# Common flags for both C & C++_
C_CXX_FLAGS = -Wall -Werror -Wl,-EL -nostdlib -mlongcalls -mtext-section-literals $(CPPFLAGS)
# Flags for C only
CFLAGS = $(C_CXX_FLAGS) -std=gnu99
# Flags for C++ only
CXXFLAGS = $(C_CXX_FLAGS) -fno-exceptions
LDFLAGS = -nostdlib -Wl,--no-check-sections -Wl,-L$(BUILD_DIR)sdklib -Wl,-L$(ROOT)lib -u $(ENTRY_SYMBOL) -Wl,-static -Wl,-Map=build/${PROGRAM}.map $(EXTRA_LDFLAGS)
ifeq ($(FLAVOR),debug)
CFLAGS += -g -O0
C_CXX_FLAGS += -g -O0
LDFLAGS += -g -O0
else
CFLAGS += -g -O2
C_CXX_FLAGS += -g -O2
LDFLAGS += -g -O2
endif
@ -138,8 +143,8 @@ endif
LINKER_SCRIPTS_PROCESSED = $(addprefix $(LD_DIR),$(LINKER_SCRIPTS))
# derive various parts of compiler/linker arguments
SDK_LIB_ARGS = $(addprefix -l,$(SDK_LIBS))
LIB_ARGS = $(addprefix -l,$(LIBS))
SDK_LIB_ARGS = $(addprefix -l,$(SDK_LIBS))
LIB_ARGS = $(addprefix -l,$(LIBS))
PROGRAM_OUT = $(BUILD_DIR)$(PROGRAM).out
LDFLAGS += $(addprefix -T,$(LINKER_SCRIPTS_PROCESSED))
@ -228,7 +233,9 @@ $(1)_MAKEFILE ?= $(lastword $(MAKEFILE_LIST))
### determine compiler arguments ###
$(1)_CFLAGS ?= $(CFLAGS)
$(1)_CXXFLAGS ?= $(CXXFLAGS)
$(1)_CC_ARGS = $(Q) $(CC) $$(addprefix -I,$$(INC_DIRS)) $$(addprefix -I,$$($(1)_INC_DIR)) $$($(1)_CFLAGS)
$(1)_CXX_ARGS = $(Q) $(C++) $$(addprefix -I,$$(INC_DIRS)) $$(addprefix -I,$$($(1)_INC_DIR)) $$($(1)_CXXFLAGS)
$(1)_AR = $(call lc,$(BUILD_DIR)$(1).a)
$$($(1)_OBJ_DIR)%.o: $$($(1)_REAL_ROOT)%.c $$($(1)_MAKEFILE) $(wildcard $(ROOT)*.mk) | $$($(1)_SRC_DIR)

View file

@ -45,7 +45,11 @@
Important to note: IROM flash can only be accessed via 32-bit word
aligned reads. It's up to the user of this attribute to ensure this.
*/
#define IROM __attribute__((section(".irom0.literal"))) const
#ifdef __cplusplus
#define IROM __attribute__((section(".irom0.literal")))
#else
#define IROM __attribute__((section(".irom0.literal"))) const
#endif
#define INLINED inline static __attribute__((always_inline)) __attribute__((unused))

View file

@ -6,6 +6,10 @@
#ifndef __ESP8266_H__
#define __ESP8266_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "ets_sys.h"
#include "eagle_soc.h"
#include "gpio_register.h"
@ -14,5 +18,9 @@
#include "timer_register.h"
#include "uart_register.h"
#ifdef __cplusplus
}
#endif
#endif

View file

@ -8,6 +8,10 @@
#include "lwip/ip_addr.h"
#ifdef __cplusplus
extern "C" {
#endif
#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
@ -23,4 +27,8 @@ void sdk_os_delay_us(uint16_t us);
void sdk_os_install_putc1(void (*p)(char c));
void sdk_os_putc(char c);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -6,6 +6,10 @@
#ifndef __ESP_SOFTAP_H__
#define __ESP_SOFTAP_H__
#ifdef __cplusplus
extern "C" {
#endif
struct sdk_softap_config {
uint8_t ssid[32];
uint8_t password[64];
@ -20,4 +24,8 @@ struct sdk_softap_config {
bool sdk_wifi_softap_get_config(struct sdk_softap_config *config);
bool sdk_wifi_softap_set_config(struct sdk_softap_config *config);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -10,6 +10,10 @@
#include "queue.h"
#ifdef __cplusplus
extern "C" {
#endif
struct sdk_station_config {
uint8_t ssid[32];
uint8_t password[64];
@ -68,4 +72,8 @@ enum {
uint8_t sdk_wifi_station_get_connect_status(void);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -6,6 +6,10 @@
#ifndef __ESP_SYSTEM_H__
#define __ESP_SYSTEM_H__
#ifdef __cplusplus
extern "C" {
#endif
enum sdk_rst_reason {
DEFAULT_RST = 0,
WDT_RST = 1,
@ -54,4 +58,8 @@ bool sdk_system_rtc_mem_write(uint8_t dst, const void *src, uint16_t n);
void sdk_system_uart_swap(void);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -6,6 +6,10 @@
#ifndef __ESP_TIMER_H__
#define __ESP_TIMER_H__
#ifdef __cplusplus
extern "C" {
#endif
/* timer related */
typedef void sdk_os_timer_func_t(void *timer_arg);
@ -19,4 +23,8 @@ typedef struct _os_timer_t {
void *timer_arg;
} sdk_os_timer_t;
#ifdef __cplusplus
}
#endif
#endif

View file

@ -13,6 +13,10 @@
#include <lwip/ip_addr.h>
#ifdef __cplusplus
extern "C" {
#endif
enum {
NULL_MODE = 0,
STATION_MODE,
@ -67,7 +71,11 @@ enum sdk_phy_mode {
PHY_MODE_11N = 3
};
enum phy_mode sdk_wifi_get_phy_mode(void);
enum sdk_phy_mode sdk_wifi_get_phy_mode(void);
bool sdk_wifi_set_phy_mode(enum sdk_phy_mode mode);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -15,6 +15,11 @@
#define SDK_PRIVATE_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
struct ip_addr;
/*********************************************
@ -49,4 +54,8 @@ void sdk_system_station_got_ip_set(struct ip_addr *ip_addr, struct ip_addr *sn_m
*/
void sdk_system_pp_recycle_rx_pkt(void *eb);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -6,6 +6,10 @@
#ifndef __SPI_FLASH_H__
#define __SPI_FLASH_H__
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
SPI_FLASH_RESULT_OK,
SPI_FLASH_RESULT_ERR,
@ -21,6 +25,7 @@ sdk_SpiFlashOpResult sdk_spi_flash_erase_sector(uint16_t sec);
sdk_SpiFlashOpResult sdk_spi_flash_write(uint32_t des_addr, uint32_t *src_addr, uint32_t size);
sdk_SpiFlashOpResult sdk_spi_flash_read(uint32_t src_addr, uint32_t *des_addr, uint32_t size);
/* SDK uses this structure internally to account for flash size.
chip_size field is initialised during startup from the flash size
@ -42,4 +47,9 @@ typedef struct {
extern sdk_flashchip_t sdk_flashchip;
#ifdef __cplusplus
}
#endif
#endif

View file

@ -166,11 +166,14 @@ SECTIONS
*(.gnu.linkonce.e.*)
*(.gnu.version_r)
*(.eh_frame)
. = (. + 3) & ~ 3;
/* C++ constructor and destructor tables, properly ordered: */
__init_array_start = ABSOLUTE(.);
KEEP (*crtbegin.o(.ctors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
__init_array_end = ABSOLUTE(.);
KEEP (*crtbegin.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
KEEP (*(SORT(.dtors.*)))