Commit 182d45f9 authored by Johny Mattsson's avatar Johny Mattsson
Browse files

Enable -std=gnu11 for modules dir.

Plus boat-load of fixes to actually make that build.
parent 5cbea0a6
...@@ -192,6 +192,11 @@ void coap_setup(void); ...@@ -192,6 +192,11 @@ void coap_setup(void);
void endpoint_setup(void); void endpoint_setup(void);
int coap_buildOptionHeader(uint32_t optDelta, size_t length, uint8_t *buf, size_t buflen); int coap_buildOptionHeader(uint32_t optDelta, size_t length, uint8_t *buf, size_t buflen);
int check_token(coap_packet_t *pkt);
#include "uri.h"
int coap_make_request(coap_rw_buffer_t *scratch, coap_packet_t *pkt, coap_msgtype_t t, coap_method_t m, coap_uri_t *uri, const uint8_t *payload, size_t payload_len);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include "driver/key.h" #include "driver/key.h"
LOCAL void key_intr_handler(struct keys_param *keys); LOCAL void ICACHE_RAM_ATTR key_intr_handler(void *arg);
/****************************************************************************** /******************************************************************************
* FunctionName : key_init_single * FunctionName : key_init_single
...@@ -130,8 +130,9 @@ key_50ms_cb(struct single_key_param *single_key) ...@@ -130,8 +130,9 @@ key_50ms_cb(struct single_key_param *single_key)
* Returns : none * Returns : none
*******************************************************************************/ *******************************************************************************/
LOCAL void LOCAL void
key_intr_handler(struct keys_param *keys) 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);
......
...@@ -306,8 +306,9 @@ pwm_get_freq(uint8 channel) ...@@ -306,8 +306,9 @@ pwm_get_freq(uint8 channel)
* Returns : NONE * Returns : NONE
*******************************************************************************/ *******************************************************************************/
LOCAL void ICACHE_RAM_ATTR LOCAL void ICACHE_RAM_ATTR
pwm_tim1_intr_handler(void) pwm_tim1_intr_handler(void *p)
{ {
(void)p;
uint8 local_toggle = pwm_toggle; // pwm_toggle may change outside uint8 local_toggle = pwm_toggle; // pwm_toggle may change outside
RTC_CLR_REG_MASK(FRC1_INT_ADDRESS, FRC1_INT_CLR_MASK); RTC_CLR_REG_MASK(FRC1_INT_ADDRESS, FRC1_INT_CLR_MASK);
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#define SPI_APP_H #define SPI_APP_H
#include "spi_register.h" #include "spi_register.h"
#include "ets_sys.h" #include "rom.h"
#include "osapi.h" #include "osapi.h"
#include "uart.h" #include "uart.h"
#include "os_type.h" #include "os_type.h"
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#define _ROM_H_ #define _ROM_H_
#include "c_types.h" #include "c_types.h"
#include "ets_sys.h"
// SHA1 is assumed to match the netbsd sha1.h headers // SHA1 is assumed to match the netbsd sha1.h headers
#define SHA1_DIGEST_LENGTH 20 #define SHA1_DIGEST_LENGTH 20
...@@ -44,7 +45,7 @@ extern unsigned char * base64_decode(const unsigned char *src, size_t len, size_ ...@@ -44,7 +45,7 @@ extern unsigned char * base64_decode(const unsigned char *src, size_t len, size_
extern void mem_init(void * start_addr); extern void mem_init(void * start_addr);
// Interrupt Service Routine functions // Interrupt Service Routine functions
typedef void (*ets_isr_fn) (void *arg, uint32_t sp); typedef void (*ets_isr_fn) (void *arg);
extern int ets_isr_attach (unsigned int interrupt, ets_isr_fn, void *arg); extern int ets_isr_attach (unsigned int interrupt, ets_isr_fn, void *arg);
extern void ets_isr_mask (unsigned intr); extern void ets_isr_mask (unsigned intr);
extern void ets_isr_unmask (unsigned intr); extern void ets_isr_unmask (unsigned intr);
...@@ -108,4 +109,35 @@ typedef void (*exception_handler_fn) (struct exception_frame *ef, uint32_t cause ...@@ -108,4 +109,35 @@ typedef void (*exception_handler_fn) (struct exception_frame *ef, uint32_t cause
*/ */
exception_handler_fn _xtos_set_exception_handler (uint32_t cause, exception_handler_fn handler); exception_handler_fn _xtos_set_exception_handler (uint32_t cause, exception_handler_fn handler);
void ets_update_cpu_frequency (uint32_t mhz);
uint32_t ets_get_cpu_frequency (void);
void *ets_memcpy (void *dst, const void *src, size_t n);
void *ets_memmove (void *dst, const void *src, size_t n);
void *ets_memset (void *dst, int c, size_t n);
int ets_memcmp (const void *s1, const void *s2, size_t n);
char *ets_strcpy (char *dst, const char *src);
size_t ets_strlen (const char *s);
int ets_strcmp (const char *s1, const char *s2);
int ets_strncmp (const char *s1, const char *s2, size_t n);
void ets_delay_us (uint32_t us);
int ets_printf(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
int ets_sprintf(char *str, const char *format, ...) __attribute__ ((format (printf, 2, 3)));
void ets_str2macaddr (uint8_t *dst, const char *str);
void ets_timer_disarm (ETSTimer *a);
void ets_timer_setfn (ETSTimer *t, ETSTimerFunc *fn, void *parg);
void Cache_Read_Enable(uint32_t b0, uint32_t b1, uint32_t use_40108000);
void Cache_Read_Disable(void);
void ets_intr_lock(void);
void ets_intr_unlock(void);
#endif #endif
...@@ -126,6 +126,7 @@ ...@@ -126,6 +126,7 @@
#include <ets_sys.h> #include <ets_sys.h>
#include "rom.h" #include "rom.h"
#include "rtcaccess.h" #include "rtcaccess.h"
#include "user_interface.h"
// Layout of the RTC storage space: // Layout of the RTC storage space:
// //
......
...@@ -272,7 +272,6 @@ strtoupper(char *p) ...@@ -272,7 +272,6 @@ strtoupper(char *p)
//#include <string.h> //#include <string.h>
//#include <pmon.h> //#include <pmon.h>
#include "c_string.h" #include "c_string.h"
typedef int int32_t;
typedef unsigned int u_int32_t; typedef unsigned int u_int32_t;
typedef unsigned int u_int; typedef unsigned int u_int;
typedef unsigned long u_long; typedef unsigned long u_long;
......
...@@ -15,6 +15,8 @@ ifndef PDIR ...@@ -15,6 +15,8 @@ ifndef PDIR
GEN_LIBS = libmodules.a GEN_LIBS = libmodules.a
endif endif
EXTRA_CCFLAGS+=-std=gnu11
############################################################# #############################################################
# Configuration i.e. compile options etc. # Configuration i.e. compile options etc.
# Target specific stuff (defines etc.) goes in here! # Target specific stuff (defines etc.) goes in here!
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include "c_limits.h" #include "c_limits.h"
#include "lauxlib.h" #include "lauxlib.h"
#include "flash_api.h" #include "flash_api.h"
#include "ctype.h"
#include "strbuf.h" #include "strbuf.h"
#include "cjson_mem.h" #include "cjson_mem.h"
......
...@@ -372,7 +372,7 @@ static int coap_request( lua_State* L, coap_method_t m ) ...@@ -372,7 +372,7 @@ static int coap_request( lua_State* L, coap_method_t m )
if(!pdu){ if(!pdu){
if(uri) if(uri)
c_free(uri); c_free(uri);
return; return luaL_error (L, "alloc fail");
} }
const char *payload = NULL; const char *payload = NULL;
......
...@@ -36,11 +36,11 @@ ...@@ -36,11 +36,11 @@
#include "platform.h" #include "platform.h"
#include "c_stdlib.h" #include "c_stdlib.h"
#include "c_string.h" #include "c_string.h"
#include "ctype.h"
#include "user_interface.h" #include "user_interface.h"
#include "espconn.h" #include "espconn.h"
#include "flash_fs.h" #include "flash_fs.h"
#define MIN(x, y) (((x) < (y)) ? (x) : (y)) #define MIN(x, y) (((x) < (y)) ? (x) : (y))
#define ENDUSER_SETUP_ERR_FATAL (1 << 0) #define ENDUSER_SETUP_ERR_FATAL (1 << 0)
...@@ -96,7 +96,7 @@ static void enduser_setup_station_start(void); ...@@ -96,7 +96,7 @@ static void enduser_setup_station_start(void);
static void enduser_setup_station_start(void); static void enduser_setup_station_start(void);
static void enduser_setup_ap_start(void); static void enduser_setup_ap_start(void);
static void enduser_setup_ap_stop(void); static void enduser_setup_ap_stop(void);
static void enduser_setup_check_station(void); static void enduser_setup_check_station(void *p);
static void enduser_setup_debug(lua_State *L, const char *str); static void enduser_setup_debug(lua_State *L, const char *str);
...@@ -177,8 +177,9 @@ static void enduser_setup_check_station_stop(void) ...@@ -177,8 +177,9 @@ static void enduser_setup_check_station_stop(void)
* *
* Check that we've successfully entered station mode. * Check that we've successfully entered station mode.
*/ */
static void enduser_setup_check_station(void) static void enduser_setup_check_station(void *p)
{ {
(void)p;
struct ip_info ip; struct ip_info ip;
c_memset(&ip, 0, sizeof(struct ip_info)); c_memset(&ip, 0, sizeof(struct ip_info));
...@@ -391,7 +392,7 @@ static int enduser_setup_http_handle_credentials(char *data, unsigned short data ...@@ -391,7 +392,7 @@ static int enduser_setup_http_handle_credentials(char *data, unsigned short data
err = wifi_station_disconnect(); err = wifi_station_disconnect();
if (err == FALSE) if (err == FALSE)
{ {
ENDUSER_SETUP_ERROR_VOID("enduser_setup_station_start failed. wifi_station_disconnect failed.", ENDUSER_SETUP_ERR_UNKOWN_ERROR, ENDUSER_SETUP_ERR_NONFATAL); ENDUSER_SETUP_ERROR("enduser_setup_station_start failed. wifi_station_disconnect failed.", ENDUSER_SETUP_ERR_UNKOWN_ERROR, ENDUSER_SETUP_ERR_NONFATAL);
} }
err = wifi_station_connect(); err = wifi_station_connect();
if (err == FALSE) if (err == FALSE)
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include "module.h" #include "module.h"
#include "lauxlib.h" #include "lauxlib.h"
#include "platform.h" #include "platform.h"
#include "rom.h"
#include "c_types.h" #include "c_types.h"
#include "c_string.h" #include "c_string.h"
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
#include "mqtt_msg.h" #include "mqtt_msg.h"
#include "msg_queue.h" #include "msg_queue.h"
#include "user_interface.h"
#define MQTT_BUF_SIZE 1024 #define MQTT_BUF_SIZE 1024
#define MQTT_DEFAULT_KEEPALIVE 60 #define MQTT_DEFAULT_KEEPALIVE 60
#define MQTT_MAX_CLIENT_LEN 64 #define MQTT_MAX_CLIENT_LEN 64
...@@ -831,7 +833,7 @@ static void socket_connect(struct espconn *pesp_conn) ...@@ -831,7 +833,7 @@ static void socket_connect(struct espconn *pesp_conn)
} }
static void socket_dns_found(const char *name, ip_addr_t *ipaddr, void *arg); static void socket_dns_found(const char *name, ip_addr_t *ipaddr, void *arg);
static dns_reconn_count = 0; static int dns_reconn_count = 0;
static ip_addr_t host_ip; // for dns static ip_addr_t host_ip; // for dns
static void socket_dns_found(const char *name, ip_addr_t *ipaddr, void *arg) static void socket_dns_found(const char *name, ip_addr_t *ipaddr, void *arg)
{ {
......
...@@ -610,7 +610,7 @@ static void socket_connect(struct espconn *pesp_conn) ...@@ -610,7 +610,7 @@ static void socket_connect(struct espconn *pesp_conn)
} }
static void socket_dns_found(const char *name, ip_addr_t *ipaddr, void *arg); static void socket_dns_found(const char *name, ip_addr_t *ipaddr, void *arg);
static dns_reconn_count = 0; static int dns_reconn_count = 0;
static void socket_dns_found(const char *name, ip_addr_t *ipaddr, void *arg) static void socket_dns_found(const char *name, ip_addr_t *ipaddr, void *arg)
{ {
NODE_DBG("socket_dns_found is called.\n"); NODE_DBG("socket_dns_found is called.\n");
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "flash_api.h" #include "flash_api.h"
#include "flash_fs.h" #include "flash_fs.h"
#include "user_version.h" #include "user_version.h"
#include "rom.h"
#define CPU80MHZ 80 #define CPU80MHZ 80
#define CPU160MHZ 160 #define CPU160MHZ 160
...@@ -49,7 +50,7 @@ static int node_deepsleep( lua_State* L ) ...@@ -49,7 +50,7 @@ static int node_deepsleep( lua_State* L )
if ( option < 0 || option > 4) if ( option < 0 || option > 4)
return luaL_error( L, "wrong arg range" ); return luaL_error( L, "wrong arg range" );
else else
deep_sleep_set_option( option ); system_deep_sleep_set_option( option );
} }
// Set deleep time, skip if nil // Set deleep time, skip if nil
if ( lua_isnumber(L, 1) ) if ( lua_isnumber(L, 1) )
......
#include "module.h" #include "module.h"
#include "lauxlib.h" #include "lauxlib.h"
#include "platform.h" #include "platform.h"
#include "rom.h"
//#include "driver/easygpio.h" //#include "driver/easygpio.h"
//static Ping_Data pingA; //static Ping_Data pingA;
#define defPulseLen 185 #define defPulseLen 185
......
...@@ -87,7 +87,7 @@ static void do_sleep_opt (lua_State *L, int idx) ...@@ -87,7 +87,7 @@ static void do_sleep_opt (lua_State *L, int idx)
uint32_t opt = lua_tonumber (L, idx); uint32_t opt = lua_tonumber (L, idx);
if (opt < 0 || opt > 4) if (opt < 0 || opt > 4)
luaL_error (L, "unknown sleep option"); luaL_error (L, "unknown sleep option");
deep_sleep_set_option (opt); system_deep_sleep_set_option (opt);
} }
} }
......
...@@ -59,20 +59,6 @@ tmr.softwd(int) ...@@ -59,20 +59,6 @@ tmr.softwd(int)
#define TIMER_MODE_AUTO 1 #define TIMER_MODE_AUTO 1
#define TIMER_IDLE_FLAG (1<<7) #define TIMER_IDLE_FLAG (1<<7)
//well, the following are my assumptions
//why, oh why is there no good documentation
//chinese companies should learn from Atmel
extern void ets_timer_arm_new(os_timer_t* t, uint32_t milliseconds, uint32_t repeat_flag, uint32_t isMstimer);
extern void ets_timer_disarm(os_timer_t* t);
extern void ets_timer_setfn(os_timer_t* t, os_timer_func_t *f, void *arg);
extern void ets_delay_us(uint32_t us);
extern uint32_t system_get_time();
extern uint32_t platform_tmr_exists(uint32_t t);
extern uint32_t system_rtc_clock_cali_proc();
extern uint32_t system_get_rtc_time();
extern void system_restart();
extern void system_soft_wdt_feed();
//in fact lua_State is constant, it's pointless to pass it around //in fact lua_State is constant, it's pointless to pass it around
//but hey, whatever, I'll just pass it, still we waste 28B here //but hey, whatever, I'll just pass it, still we waste 28B here
typedef struct{ typedef struct{
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "c_types.h" #include "c_types.h"
#include "c_string.h" #include "c_string.h"
#include "rom.h"
static lua_State *gL = NULL; static lua_State *gL = NULL;
static int uart_receive_rf = LUA_NOREF; static int uart_receive_rf = LUA_NOREF;
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "c_string.h" #include "c_string.h"
#include "c_stdlib.h" #include "c_stdlib.h"
#include "ctype.h"
#include "c_types.h" #include "c_types.h"
#include "user_interface.h" #include "user_interface.h"
...@@ -22,7 +23,7 @@ static bool FLAG_wifi_force_sleep_enabled=0; ...@@ -22,7 +23,7 @@ static bool FLAG_wifi_force_sleep_enabled=0;
//variables for wifi event monitor //variables for wifi event monitor
static sint32_t wifi_status_cb_ref[6] = {LUA_NOREF,LUA_NOREF,LUA_NOREF,LUA_NOREF,LUA_NOREF,LUA_NOREF}; static sint32_t wifi_status_cb_ref[6] = {LUA_NOREF,LUA_NOREF,LUA_NOREF,LUA_NOREF,LUA_NOREF,LUA_NOREF};
static volatile os_timer_t wifi_sta_status_timer; static os_timer_t wifi_sta_status_timer;
static uint8 prev_wifi_status=0; static uint8 prev_wifi_status=0;
......
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