components/lwip,esp32: fixes for C++

- put contents of a few headers into c++ guard blocks
- fix off-by-one error in do_global_ctors
- remove system_init from startup code (should be called from main)
This commit is contained in:
Ivan Grokhotkov 2016-09-26 03:05:25 +08:00
parent 10c69514b7
commit b190dc3e9f
4 changed files with 28 additions and 7 deletions

View file

@ -134,7 +134,7 @@ void IRAM_ATTR user_start_cpu1(void)
static void do_global_ctors(void) static void do_global_ctors(void)
{ {
void (**p)(void); void (**p)(void);
for (p = &__init_array_end; p >= &__init_array_start; --p) { for (p = &__init_array_end - 1; p >= &__init_array_start; --p) {
(*p)(); (*p)();
} }
} }
@ -153,9 +153,6 @@ void user_start_cpu0(void)
do_global_ctors(); do_global_ctors();
esp_ipc_init(); esp_ipc_init();
spi_flash_init(); spi_flash_init();
#ifdef CONFIG_WIFI_ENABLED
system_init();
#endif
xTaskCreatePinnedToCore(&mainTask, "mainTask", xTaskCreatePinnedToCore(&mainTask, "mainTask",
ESP_TASK_MAIN_STACK, NULL, ESP_TASK_MAIN_STACK, NULL,
ESP_TASK_MAIN_PRIO, NULL, 0); ESP_TASK_MAIN_PRIO, NULL, 0);

View file

@ -38,6 +38,11 @@
#include "freertos/queue.h" #include "freertos/queue.h"
#include "freertos/semphr.h" #include "freertos/semphr.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef xSemaphoreHandle sys_sem_t; typedef xSemaphoreHandle sys_sem_t;
typedef xSemaphoreHandle sys_mutex_t; typedef xSemaphoreHandle sys_mutex_t;
typedef xTaskHandle sys_thread_t; typedef xTaskHandle sys_thread_t;
@ -67,6 +72,11 @@ uint32_t system_get_time(void);
void sys_delay_ms(uint32_t ms); void sys_delay_ms(uint32_t ms);
sys_sem_t* sys_thread_sem_init(void); sys_sem_t* sys_thread_sem_init(void);
void sys_thread_sem_deinit(void); void sys_thread_sem_deinit(void);
sys_sem_t* sys_thread_sem_get(void); sys_sem_t* sys_thread_sem_get(void);
#ifdef __cplusplus
}
#endif
#endif /* __SYS_ARCH_H__ */ #endif /* __SYS_ARCH_H__ */

View file

@ -10,6 +10,10 @@
#include "lwip/err.h" #include "lwip/err.h"
#ifdef __cplusplus
extern "C" {
#endif
err_t wlanif_init(struct netif *netif); err_t wlanif_init(struct netif *netif);
void wlanif_input(struct netif *netif, void *buffer, u16_t len, void* eb); void wlanif_input(struct netif *netif, void *buffer, u16_t len, void* eb);
@ -20,4 +24,8 @@ wifi_interface_t wifi_get_interface(void *dev);
void netif_reg_addr_change_cb(void* cb); void netif_reg_addr_change_cb(void* cb);
#ifdef __cplusplus
}
#endif
#endif /* _WLAN_LWIP_IF_H_ */ #endif /* _WLAN_LWIP_IF_H_ */

View file

@ -16,9 +16,7 @@
#define _TCPIP_ADAPTER_H_ #define _TCPIP_ADAPTER_H_
#include <stdint.h> #include <stdint.h>
#include "rom/queue.h" #include "rom/queue.h"
#include "esp_wifi.h" #include "esp_wifi.h"
#define CONFIG_TCPIP_LWIP 1 #define CONFIG_TCPIP_LWIP 1
@ -28,6 +26,10 @@
#include "lwip/ip_addr.h" #include "lwip/ip_addr.h"
#include "apps/dhcpserver.h" #include "apps/dhcpserver.h"
#ifdef __cplusplus
extern "C" {
#endif
#define IP2STR(ipaddr) ip4_addr1_16(ipaddr), \ #define IP2STR(ipaddr) ip4_addr1_16(ipaddr), \
ip4_addr2_16(ipaddr), \ ip4_addr2_16(ipaddr), \
ip4_addr3_16(ipaddr), \ ip4_addr3_16(ipaddr), \
@ -129,5 +131,9 @@ wifi_interface_t tcpip_adapter_get_wifi_if(void *dev);
esp_err_t tcpip_adapter_get_sta_list(struct station_info *sta_info, struct station_list **sta_list); esp_err_t tcpip_adapter_get_sta_list(struct station_info *sta_info, struct station_list **sta_list);
esp_err_t tcpip_adapter_free_sta_list(struct station_list *sta_list); esp_err_t tcpip_adapter_free_sta_list(struct station_list *sta_list);
#ifdef __cplusplus
}
#endif
#endif /* _TCPIP_ADAPTER_H_ */ #endif /* _TCPIP_ADAPTER_H_ */