Skip to content

Commit

Permalink
Merge pull request #12955 from gschorcht/cpu/esp/deduplicate_and_cleanup
Browse files Browse the repository at this point in the history
cpu/esp*: code deduplication and cleanup
  • Loading branch information
benpicco authored Feb 22, 2020
2 parents e74484c + 5b4389c commit ce947b4
Show file tree
Hide file tree
Showing 133 changed files with 1,428 additions and 10,241 deletions.
2 changes: 2 additions & 0 deletions boards/common/esp8266/Makefile.features
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ FEATURES_PROVIDED += periph_pwm
FEATURES_PROVIDED += periph_spi
FEATURES_PROVIDED += periph_uart
FEATURES_PROVIDED += periph_uart_modecfg

FEATURES_PROVIDED += arduino
4 changes: 2 additions & 2 deletions boards/esp8266-esp-12x/include/arduino_board.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ extern "C" {
#endif

/**
* @brief The on-board LED is connected to pin 2 on this board
* @brief The on-board LED is connected to GPIO2 (Arduino pin 3) on this board
*/
#define ARDUINO_LED (GPIO2)
#define ARDUINO_LED (3)

/**
* @brief Look-up table for the Arduino's digital pins
Expand Down
4 changes: 2 additions & 2 deletions boards/esp8266-olimex-mod/include/arduino_board.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ extern "C" {
#endif

/**
* @brief The on-board LED is connected to pin 2 on this board
* @brief The on-board LED is connected to GPIO1 (Arduino pin 0) on this board
*/
#define ARDUINO_LED (GPIO1)
#define ARDUINO_LED (0)

/**
* @brief Look-up table for the Arduino's digital pins
Expand Down
4 changes: 2 additions & 2 deletions boards/esp8266-sparkfun-thing/include/arduino_board.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ extern "C" {
#endif

/**
* @brief The on-board LED is connected to pin 2 on this board
* @brief The on-board LED is connected to GPIO5 (Arduino pin 6) on this board
*/
#define ARDUINO_LED (GPIO5)
#define ARDUINO_LED (6)

/**
* @brief Look-up table for the Arduino's digital pins
Expand Down
6 changes: 1 addition & 5 deletions cpu/esp32/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ ifneq (, $(filter esp_eth, $(USEMODULE)))
DIRS += esp-eth
endif

ifneq (, $(filter esp_wifi, $(USEMODULE)))
DIRS += esp-wifi
endif

ifneq (, $(filter riot_freertos, $(USEMODULE)))
ifneq (, $(filter esp_freertos, $(USEMODULE)))
DIRS += freertos
endif

Expand Down
123 changes: 41 additions & 82 deletions cpu/esp32/Makefile.dep
Original file line number Diff line number Diff line change
@@ -1,46 +1,36 @@
# additional modules dependencies

include $(RIOTCPU)/esp_common/Makefile.dep

ifneq (,$(filter cpp,$(FEATURES_USED)))
USEMODULE += pthread
BASELIBS += -lstdc++
USEMODULE += pthread
BASELIBS += -lstdc++
endif

ifneq (,$(filter esp_eth,$(USEMODULE)))
USEMODULE += esp_idf_eth
USEMODULE += esp_idf_eth_phy
USEMODULE += netdev_eth
USEMODULE += netopt
USEMODULE += riot_freertos
USEMODULE += xtimer
INCLUDES += -I$(RIOTCPU)/$(CPU)/vendor/esp-idf/include/ethernet
INCLUDES += -I$(ESP32_SDK_DIR)/components/ethernet/include
endif

ifneq (,$(filter esp_now,$(USEMODULE)))
USEMODULE += esp_wifi_any
USEMODULE += netopt
endif

ifneq (,$(filter esp_wifi,$(USEMODULE)))
USEMODULE += esp_wifi_any
USEMODULE += netopt
USEMODULE += netdev_eth
USEMODULE += esp_freertos
USEMODULE += esp_idf_eth
USEMODULE += esp_idf_eth_phy
USEMODULE += netdev_eth
USEMODULE += netopt
USEMODULE += xtimer
INCLUDES += -I$(RIOTCPU)/$(CPU)/vendor/esp-idf/include/ethernet
INCLUDES += -I$(ESP32_SDK_DIR)/components/ethernet/include
endif

ifneq (,$(filter esp_wifi_any,$(USEMODULE)))
# add additional modules used for any WiFi interface
USEMODULE += esp_idf_heap
USEMODULE += esp_idf_wpa_supplicant_crypto
USEMODULE += esp_idf_wpa_supplicant_port
USEMODULE += esp_idf_nvs_flash
USEMODULE += riot_freertos
USEMODULE += xtimer
# add additional modules used for any WiFi interface
USEMODULE += esp_freertos
USEMODULE += esp_idf_heap
USEMODULE += esp_idf_nvs_flash
USEMODULE += esp_idf_wpa_supplicant_crypto
USEMODULE += esp_idf_wpa_supplicant_port
endif

ifneq (,$(filter esp_idf_nvs_flash,$(USEMODULE)))
# add additional modules required by esp_idf_nvs_flash
USEMODULE += mtd
USEMODULE += pthread
# add additional modules required by esp_idf_nvs_flash
USEMODULE += mtd
USEMODULE += pthread
endif

ifneq (,$(filter periph_rtc,$(USEMODULE)))
Expand All @@ -56,68 +46,37 @@ ifneq (,$(filter esp_rtc_timer_32k,$(USEMODULE)))
endif

ifneq (,$(filter periph_i2c,$(USEMODULE)))
ifneq (,$(filter esp_i2c_hw,$(USEMODULE)))
USEMODULE += core_thread_flags
USEMODULE += xtimer
USEMODULE += periph_i2c_hw
else
# PLEASE NOTE: because of the very poor and faulty hardware implementation
# we use software implementation by default for the moment (if module
# esp_i2c_hw is not explicitly used)
USEMODULE += esp_i2c_sw
USEMODULE += periph_i2c_sw
endif
ifneq (,$(filter esp_i2c_hw,$(USEMODULE)))
USEMODULE += core_thread_flags
USEMODULE += xtimer
USEMODULE += periph_i2c_hw
else
# PLEASE NOTE: because of the very poor and faulty hardware implementation
# we use software implementation by default for the moment (if module
# esp_i2c_hw is not explicitly used)
USEMODULE += esp_i2c_sw
USEMODULE += periph_i2c_sw
endif
endif

ifneq (, $(filter esp_spi_ram, $(DISABLE_MODULE)))
USEMODULE := $(filter-out esp_spi_ram, $(USEMODULE))
ifneq (,$(filter esp_spi_ram,$(DISABLE_MODULE)))
USEMODULE := $(filter-out esp_spi_ram,$(USEMODULE))
endif

# each device has SPI flash memory, but must be explicitly enabled
ifneq (,$(filter esp_spiffs,$(USEMODULE)))
USEMODULE += spiffs
ifneq (,$(filter esp_now esp_wifi esp_spi_ram,$(USEMODULE)))
# the ESP-IDF heap has to be used if SPI RAM is used
USEMODULE += esp_idf_heap
endif

ifneq (,$(filter mtd,$(USEMODULE)))
USEMODULE += esp_idf_spi_flash
USEMODULE += esp_idf_spi_flash
endif

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

ifneq (,$(filter shell,$(USEMODULE)))
USEMODULE += ps
endif

ifneq (,$(filter log_color,$(USEMODULE)))
USEMODULE += esp_log_colored
endif

# if SPI RAM is enabled, ESP-IDF heap and quot flash mode have to be used
ifneq (,$(filter esp_spi_ram,$(USEMODULE)))
USEMODULE += esp_idf_heap
export FLASH_MODE = qout
CFLAGS += -DFLASH_MODE_QOUT=1
else
ifeq ($(FLASH_MODE), qio)
CFLAGS += -DFLASH_MODE_QIO=1
endif
ifeq ($(FLASH_MODE), qout)
CFLAGS += -DFLASH_MODE_QOUT=1
endif
ifeq ($(FLASH_MODE), dio)
CFLAGS += -DFLASH_MODE_DIO=1
endif
ifeq ($(FLASH_MODE), dout)
CFLAGS += -DFLASH_MODE_DOUT=1
endif
endif

ifneq (,$(filter esp_idf_heap,$(USEMODULE)))
LINKFLAGS += -Wl,-wrap,_malloc_r
LINKFLAGS += -Wl,-wrap,_calloc_r
LINKFLAGS += -Wl,-wrap,_realloc_r
LINKFLAGS += -Wl,-wrap,_free_r
USEMODULE += ps
endif
11 changes: 4 additions & 7 deletions cpu/esp32/Makefile.features
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
FEATURES_PROVIDED += arch_32bit
# MCU defined features that are provided independent on board definitions

include $(RIOTCPU)/esp_common/Makefile.features

FEATURES_PROVIDED += arch_esp32
FEATURES_PROVIDED += cpp
FEATURES_PROVIDED += periph_cpuid
FEATURES_PROVIDED += periph_hwrng
FEATURES_PROVIDED += periph_pm
FEATURES_PROVIDED += periph_rtc
FEATURES_PROVIDED += periph_timer
FEATURES_PROVIDED += ssp
Loading

0 comments on commit ce947b4

Please sign in to comment.