Skip to content

Commit

Permalink
cpu/esp8266: complete reimplementation
Browse files Browse the repository at this point in the history
This is a development revision but it is already working completely and very stable. It just requires some cleanups before it can be merged.
  • Loading branch information
gschorcht committed Mar 14, 2019
1 parent da36aa3 commit 7db70f4
Show file tree
Hide file tree
Showing 207 changed files with 25,137 additions and 9,419 deletions.
17 changes: 10 additions & 7 deletions boards/common/esp8266/board_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/

#include "board_common.h"
#include "esp_common.h"
#include "log.h"
#include "periph/gpio.h"

Expand All @@ -42,6 +43,7 @@ void board_init(void)
#endif
}

extern void adc_print_config(void);
extern void pwm_print_config(void);
extern void i2c_print_config(void);
extern void spi_print_config(void);
Expand All @@ -50,27 +52,28 @@ extern void timer_print_config(void);

void board_print_config (void)
{
LOG_INFO("\nBoard configuration:\n");
ets_printf("\nBoard configuration:\n");

adc_print_config();
pwm_print_config();
i2c_print_config();
spi_print_config();
uart_print_config();
timer_print_config();

LOG_INFO("\tLED: pins=[ ");
ets_printf("\tLED:\t\tpins=[ ");
#ifdef LED0_PIN
LOG_INFO("%d ", LED0_PIN);
ets_printf("%d ", LED0_PIN);
#endif
#ifdef LED1_PIN
LOG_INFO("%d ", LED1_PIN);
ets_printf("%d ", LED1_PIN);
#endif
#ifdef LED2_PIN
LOG_INFO("%d ", LED2_PIN);
ets_printf("%d ", LED2_PIN);
#endif
LOG_INFO("]\n");
ets_printf("]\n");

LOG_INFO("\n\n");
ets_printf("\n\n");
}

#ifdef __cplusplus
Expand Down
4 changes: 4 additions & 0 deletions boards/common/esp8266/include/board_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
* @{
*/

/* not required when compiling ESP vendor code parts */
#ifndef ESP_PLATFORM

#include <stdint.h>

#include "cpu.h"
Expand Down Expand Up @@ -140,4 +143,5 @@ void board_print_config (void);

/** @} */

#endif /* ESP_PLATFORM */
#endif /* BOARD_COMMON_H */
2 changes: 1 addition & 1 deletion cpu/esp32/esp-wifi/esp_wifi_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ void auto_init_esp_wifi (void)
_esp_wifi_dev.event = SYSTEM_EVENT_MAX; /* no event */
_esp_wifi_dev.netif = gnrc_netif_ethernet_create(_esp_wifi_stack,
ESP_WIFI_STACKSIZE, ESP_WIFI_PRIO,
"netdev-esp-wifi",
"esp_wifi",
(netdev_t *)&_esp_wifi_dev);
}

Expand Down
3 changes: 2 additions & 1 deletion cpu/esp32/periph/adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,8 @@ int rtcio_config_sleep_mode (gpio_t pin, bool mode, bool input)
return 0;
}

void adc_print_config(void) {
void adc_print_config(void)
{
ets_printf("\tADC\t\tpins=[ ");
#if defined(ADC_GPIOS)
for (unsigned i = 0; i < adc_chn_num; i++) {
Expand Down
2 changes: 1 addition & 1 deletion cpu/esp32/periph/i2c_hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ void i2c_print_config(void)

void i2c_print_config(void)
{
LOG_TAG_INFO("i2c", "no I2C devices\n");
ets_printf("\tI2C:\tno devices\n");
}

#endif /* defined(I2C0_SPEED) || defined(I2C1_SPEED) */
Expand Down
2 changes: 1 addition & 1 deletion cpu/esp32/periph/i2c_sw.c
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ void i2c_print_config(void)

void i2c_print_config(void)
{
LOG_TAG_INFO("i2c", "no I2C devices\n");
ets_printf("\tI2C:\t\tno devices\n");
}

#endif /* defined(I2C0_SPEED) || defined(I2C1_SPEED) */
Expand Down
2 changes: 1 addition & 1 deletion cpu/esp32/periph/pwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ void pwm_print_config(void)

void pwm_print_config(void)
{
LOG_TAG_INFO("pwm", "no PWM devices\n");
ets_printf("\tPWM:\tno devices\n");
}

#endif /* defined(PWM0_GPIOS) || defined(PWM1_GPIOS) */
2 changes: 1 addition & 1 deletion cpu/esp32/periph/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ void uart_system_init (void)
void uart_print_config(void)
{
for (unsigned uart = 0; uart < UART_NUMOF; uart++) {
ets_printf("\tUART_DEV(%d)\ttxd=%d rxd=%d\n", uart,
ets_printf("\tUART_DEV(%d):\ttxd=%d rxd=%d\n", uart,
__uarts[uart].pin_txd, __uarts[uart].pin_rxd);
}
}
Expand Down
6 changes: 5 additions & 1 deletion cpu/esp32/vendor/esp-idf/esp32/event_loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,13 @@ esp_err_t esp_event_loop_init(system_event_cb_t cb, void *ctx)
s_event_ctx = ctx;
s_event_queue = xQueueCreate(CONFIG_SYSTEM_EVENT_QUEUE_SIZE, sizeof(system_event_t));

#ifdef RIOT_VERSION
xTaskCreatePinnedToCore(esp_event_loop_task, "esp_events",
ESP_TASKD_EVENT_STACK, NULL, ESP_TASKD_EVENT_PRIO, NULL, 0);
#else
xTaskCreatePinnedToCore(esp_event_loop_task, "wifi-event-loop",
ESP_TASKD_EVENT_STACK, NULL, ESP_TASKD_EVENT_PRIO, NULL, 0);

#endif
s_event_init_flag = true;
return ESP_OK;
}
3 changes: 3 additions & 0 deletions cpu/esp8266/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ MODULE = cpu

# Add a list of subdirectories, that should also be built:
DIRS += $(RIOTCPU)/esp_common
DIRS += freertos
DIRS += periph
DIRS += sdk
DIRS += vendor
Expand All @@ -11,4 +12,6 @@ ifneq (, $(filter esp_wifi, $(USEMODULE)))
DIRS += esp-wifi
endif

INCLUDES += -I$(ESP8266_SDK_DIR)/components/esp8266/include/internal

include $(RIOTBASE)/Makefile.base
50 changes: 0 additions & 50 deletions cpu/esp8266/Makefile.dep
Original file line number Diff line number Diff line change
@@ -1,62 +1,12 @@
# additional modules dependencies

ifneq (, $(filter esp_sdk, $(USEMODULE)))
USEMODULE += core_thread_flags
INCLUDES += -I$(ESP8266_SDK_DIR)/third_party/include
LINKFLAGS += -Wl,-wrap=malloc
LINKFLAGS += -Wl,-wrap=free
LINKFLAGS += -Wl,-wrap=calloc
LINKFLAGS += -Wl,-wrap=realloc
LINKFLAGS += -Wl,-wrap=_malloc_r
LINKFLAGS += -Wl,-wrap=_free_r
LINKFLAGS += -Wl,-wrap=_realloc_r
LINKFLAGS += -Wl,-wrap=mallinfo
endif

ifneq (, $(filter esp_spiffs, $(USEMODULE)))
export SPIFFS_STD_OPTION = -std=c99
USEMODULE += spiffs
USEMODULE += vfs
endif

ifneq (, $(filter esp_wifi, $(USEMODULE)))
CFLAGS += -DLWIP_OPEN_SRC
LINKFLAGS += -Wl,-wrap=ethernet_input
USEMODULE += netdev_eth
endif

ifneq (, $(filter lua, $(USEPKG)))
USEMODULE += newlib_syscalls_default
USEMODULE += xtimer
endif

ifneq (, $(filter lwip%, $(USEMODULE)))
USEMODULE += newlib_syscalls_default
endif

ifneq (,$(filter ndn-riot,$(USEPKG)))
USEMODULE += crypto
USEMODULE += cipher_modes
endif

ifneq (, $(filter posix%, $(USEMODULE)))
USEMODULE += newlib_syscalls_default
endif

ifneq (, $(filter shell, $(USEMODULE)))
USEMODULE += newlib_syscalls_default
USEMODULE += xtimer
endif

ifneq (, $(filter xtimer, $(USEMODULE)))
USEMODULE += newlib_syscalls_default
endif

ifneq (, $(filter vfs, $(USEMODULE)))
USEMODULE += newlib_syscalls_default
USEMODULE += xtimer
endif

ifneq (, $(filter newlib_syscalls_default, $(USEMODULE)))
USEMODULE += stdio_uart
endif
1 change: 1 addition & 0 deletions cpu/esp8266/Makefile.features
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# MCU defined features that are provided independent on board definitions

FEATURES_PROVIDED += cpp
FEATURES_PROVIDED += periph_cpuid
FEATURES_PROVIDED += periph_hwrng
FEATURES_PROVIDED += periph_pm
Expand Down
Loading

0 comments on commit 7db70f4

Please sign in to comment.