diff --git a/Kconfig b/Kconfig index a8590902b646..9b03ba245391 100644 --- a/Kconfig +++ b/Kconfig @@ -9,6 +9,7 @@ mainmenu "RIOT Configuration" # For now, get used modules as macros from this file (see kconfig.mk) osource "$(KCONFIG_GENERATED_DEPENDENCIES)" +rsource "cpu/Kconfig" rsource "sys/Kconfig" # The application may declare new symbols as well diff --git a/cpu/Kconfig b/cpu/Kconfig new file mode 100644 index 000000000000..6d47751275fc --- /dev/null +++ b/cpu/Kconfig @@ -0,0 +1,11 @@ +# Copyright (c) 2020 Gunar Schorcht +# +# This file is subject to the terms and conditions of the GNU Lesser +# General Public License v2.1. See the file LICENSE in the top level +# directory for more details. +# +menu "CPU" + +rsource "*/Kconfig" + +endmenu # CPU diff --git a/cpu/esp32/Kconfig b/cpu/esp32/Kconfig new file mode 100644 index 000000000000..a9336b7f8c88 --- /dev/null +++ b/cpu/esp32/Kconfig @@ -0,0 +1,33 @@ +# Copyright (c) 2020 Gunar Schorcht +# +# This file is subject to the terms and conditions of the GNU Lesser +# General Public License v2.1. See the file LICENSE in the top level +# directory for more details. +# + +menuconfig KCONFIG_CPU_ESP32 + bool "Configure ESP32 CPU" + depends on MODULE_ESP_ESP32 + help + Configure ESP32 CPU via Kconfig. + +if KCONFIG_CPU_ESP32 + +choice ESP32_DEFAULT_CPU_FREQ_MHZ + bool "CPU frequency" + default ESP32_DEFAULT_CPU_FREQ_MHZ_80 + help + Defines the CPU frequency. + +config ESP32_DEFAULT_CPU_FREQ_MHZ_80 + bool "80 MHz" +config ESP32_DEFAULT_CPU_FREQ_MHZ_160 + bool "160 MHz" +config ESP32_DEFAULT_CPU_FREQ_MHZ_240 + bool "240 MHz" +endchoice + +rsource "esp-wifi/Kconfig" +rsource "$(RIOTBASE)/cpu/esp_common/esp-now/Kconfig" + +endif # ESP32 settings diff --git a/cpu/esp32/Makefile.include b/cpu/esp32/Makefile.include index e1d3102cafe3..e00d26ae6700 100644 --- a/cpu/esp32/Makefile.include +++ b/cpu/esp32/Makefile.include @@ -82,6 +82,7 @@ ifneq (,$(filter 4 5,$(LOG_LEVEL))) endif # ESP32 pseudomodules +PSEUDOMODULES += esp_esp32 PSEUDOMODULES += esp_eth_hw PSEUDOMODULES += esp_gdb PSEUDOMODULES += esp_gdbstub @@ -100,6 +101,7 @@ PSEUDOMODULES += esp_wifi_any export TARGET_ARCH ?= xtensa-esp32-elf USEMODULE += esp_common +USEMODULE += esp_esp32 USEMODULE += esp_idf USEMODULE += esp_idf_driver USEMODULE += esp_idf_esp32 diff --git a/cpu/esp32/doc.txt b/cpu/esp32/doc.txt index ff9990ff3ade..af5b68f44f5a 100644 --- a/cpu/esp32/doc.txt +++ b/cpu/esp32/doc.txt @@ -1004,11 +1004,11 @@ Furthermore, the following configuration parameters have to be defined:
-Parameter | Default | Description -:------------------|:--------------------------|:------------ -ESP_WIFI_SSID | "RIOT_AP" | SSID of the AP to be used. -ESP_WIFI_PASS | "ThisistheRIOTporttoESP" | Passphrase used for the AP as clear text (max. 64 chars). -ESP_WIFI_STACKSIZE | #THREAD_STACKSIZE_DEFAULT |Stack size used for the WiFi netdev driver thread. +Parameter | Default | Description +:--------------------------|:--------------------------|:------------ +#CONFIG_ESP_WIFI_SSID | "RIOT_AP" | SSID of the AP to be used. +#CONFIG_ESP_WIFI_PASS | "ThisistheRIOTporttoESP" | Passphrase used for the AP as clear text (max. 64 chars). +#CONFIG_ESP_WIFI_STACKSIZE | #THREAD_STACKSIZE_DEFAULT |Stack size used for the WiFi netdev driver thread.
@@ -1018,7 +1018,7 @@ line, e.g.: ``` USEMODULE=esp_wifi \ -CFLAGS='-DESP_WIFI_SSID=\"MySSID\" -DESP_WIFI_PASS=\"MyPassphrase\"' \ +CFLAGS='-DCONFIG_ESP_WIFI_SSID=\"MySSID\" -DCONFIG_ESP_WIFI_PASS=\"MyPassphrase\"' \ make -C examples/gnrc_networking BOARD=... ``` @@ -1049,10 +1049,10 @@ The following parameters are defined for ESP-NOW nodes. These parameters can be Parameter | Default | Description :---------|:--------|:----------- -ESP_NOW_SCAN_PERIOD | 10000000UL | Defines the period in us at which an node scans for other nodes in its range. The default period is 10 s. -ESP_NOW_SOFT_AP_PASS | "ThisistheRIOTporttoESP" | Defines the passphrase as clear text (max. 64 chars) that is used for the SoftAP interface of ESP-NOW nodes. It has to be same for all nodes in one network. -ESP_NOW_CHANNEL | 6 | Defines the channel that is used as the broadcast medium by all nodes together. -ESP_NOW_KEY | NULL | Defines a key that is used for encrypted communication between nodes. If it is NULL, encryption is disabled. The key has to be of type ```uint8_t[16]``` and has to be exactly 16 bytes long. +#CONFIG_ESP_NOW_SCAN_PERIOD | 10000000UL | Defines the period in us at which an node scans for other nodes in its range. The default period is 10 s. +#CONFIG_ESP_NOW_SOFT_AP_PASS | "ThisistheRIOTporttoESP" | Defines the passphrase as clear text (max. 64 chars) that is used for the SoftAP interface of ESP-NOW nodes. It has to be same for all nodes in one network. +#CONFIG_ESP_NOW_CHANNEL | 6 | Defines the channel that is used as the broadcast medium by all nodes together. +#CONFIG_ESP_NOW_KEY | NULL | Defines a key that is used for encrypted communication between nodes. If it is NULL, encryption is disabled. The key has to be of type ```uint8_t[16]``` and has to be exactly 16 bytes long. diff --git a/cpu/esp32/esp-wifi/Kconfig b/cpu/esp32/esp-wifi/Kconfig new file mode 100644 index 000000000000..276a3ffc1a88 --- /dev/null +++ b/cpu/esp32/esp-wifi/Kconfig @@ -0,0 +1,29 @@ +# Copyright (c) 2020 Gunar Schorcht +# +# This file is subject to the terms and conditions of the GNU Lesser +# General Public License v2.1. See the file LICENSE in the top level +# directory for more details. +# + +menuconfig KCONFIG_MODULE_ESP_WIFI + bool "Configure ESP-WiFi netdev" + depends on MODULE_ESP_WIFI + help + Configure ESP-Wifi netdev when module esp_wifi is used. + +if KCONFIG_MODULE_ESP_WIFI + +config ESP_WIFI_SSID + string "SSID" + default "RIOT_AP" + help + This string defines the SSID of the AP to be used. + +config ESP_WIFI_PASS + string "Passphrase for WPA2" + default "ThisistheRIOTporttoESP" + help + This string defines the passphrase as plain text, which is used for + the AP during WPA2 authentication. It can be up to 64 characters long. + +endif # KCONFIG_MODULE_ESP_WIFI diff --git a/cpu/esp32/esp-wifi/doc.txt b/cpu/esp32/esp-wifi/doc.txt index d3e064e41763..49727cb42d5f 100644 --- a/cpu/esp32/esp-wifi/doc.txt +++ b/cpu/esp32/esp-wifi/doc.txt @@ -29,11 +29,11 @@ USEMODULE += esp_wifi Furthermore, the following configuration parameters have to be defined: -Configuration Parameter | Description -------------------------|------------ -ESP_WIFI_SSID | SSID of the AP to be used. -ESP_WIFI_PASS | Passphrase used for the AP as clear text (max. 64 chars). -ESP_WIFI_STACKSIZE | Stack size used for the WiFi netdev driver thread. +Configuration Parameter | Description +--------------------------|------------ +#CONFIG_ESP_WIFI_SSID | SSID of the AP to be used. +#CONFIG_ESP_WIFI_PASS | Passphrase used for the AP as clear text (max. 64 chars). +#CONFIG_ESP_WIFI_STACKSIZE| Stack size used for the WiFi netdev driver thread. These configuration parameter definitions, as well as enabling the `esp_wifi` module, can be done either in the makefile of the project or at make command @@ -41,7 +41,7 @@ line, e.g.: ``` USEMODULE=esp_wifi \ -CFLAGS='-DESP_WIFI_SSID=\"MySSID\" -DESP_WIFI_PASS=\"MyPassphrase\"' \ +CFLAGS='-DCONFIG_ESP_WIFI_SSID=\"MySSID\" -DCONFIG_ESP_WIFI_PASS=\"MyPassphrase\"' \ make -C examples/gnrc_networking BOARD=... ``` diff --git a/cpu/esp32/esp-wifi/esp_wifi_netdev.c b/cpu/esp32/esp-wifi/esp_wifi_netdev.c index c28e71581856..911f2d8805d4 100644 --- a/cpu/esp32/esp-wifi/esp_wifi_netdev.c +++ b/cpu/esp32/esp-wifi/esp_wifi_netdev.c @@ -99,7 +99,7 @@ static unsigned int rx_buf_write = 0; static unsigned int rx_buf_read = 0; /* device thread stack */ -static char _esp_wifi_stack[ESP_WIFI_STACKSIZE]; +static char _esp_wifi_stack[CONFIG_ESP_WIFI_STACKSIZE]; extern esp_err_t esp_system_event_add_handler (system_event_cb_t handler, void *arg); @@ -291,8 +291,8 @@ static esp_err_t IRAM_ATTR _esp_system_event_handler(void *ctx, system_event_t * /* we use predefined station configuration */ static wifi_config_t wifi_config_sta = { .sta = { - .ssid = ESP_WIFI_SSID, - .password = ESP_WIFI_PASS, + .ssid = CONFIG_ESP_WIFI_SSID, + .password = CONFIG_ESP_WIFI_PASS, .bssid_set = 0, .channel = 0, .scan_method = WIFI_ALL_CHANNEL_SCAN, @@ -578,14 +578,14 @@ void auto_init_esp_wifi (void) esp_wifi_setup(&_esp_wifi_dev); _esp_wifi_dev.netif = gnrc_netif_ethernet_create(_esp_wifi_stack, - ESP_WIFI_STACKSIZE, + CONFIG_ESP_WIFI_STACKSIZE, #ifdef MODULE_ESP_NOW - ESP_WIFI_PRIO - 1, + CONFIG_ESP_WIFI_PRIO - 1, #else - ESP_WIFI_PRIO, + CONFIG_ESP_WIFI_PRIO, #endif - "esp-wifi", - (netdev_t *)&_esp_wifi_dev); + "esp-wifi", + (netdev_t *)&_esp_wifi_dev); } #endif /* MODULE_ESP_WIFI */ diff --git a/cpu/esp32/esp-wifi/esp_wifi_params.h b/cpu/esp32/esp-wifi/esp_wifi_params.h index e6c0c9adfb10..11582cb8f71e 100644 --- a/cpu/esp32/esp-wifi/esp_wifi_params.h +++ b/cpu/esp32/esp-wifi/esp_wifi_params.h @@ -22,37 +22,77 @@ #if defined(MODULE_ESP_WIFI) || defined(DOXYGEN) +/** + * @name Legacy definitions of default configuration parameters + * @{ + */ + +/** + * @brief Legacy definition for compatibility reasons. + * #ESP_WIFI_STACKSIZE is deprecated, please use #CONFIG_ESP_WIFI_STACKSIZE + * instead. + */ +#ifndef ESP_WIFI_STACKSIZE +#define ESP_WIFI_STACKSIZE (THREAD_STACKSIZE_DEFAULT) +#endif + +/** + * @brief Legacy definition for compatibility reasons. + * #ESP_WIFI_PRIO is deprecated, please use #CONFIG_ESP_WIFI_PRIO instead. + */ +#ifndef ESP_WIFI_PRIO +#define ESP_WIFI_PRIO (GNRC_NETIF_PRIO) +#endif + +/** + * @brief Legacy definition for compatibility reasons. + * #ESP_WIFI_SSID is deprecated, please use #CONFIG_ESP_WIFI_SSID instead. + */ +#ifndef ESP_WIFI_SSID +#define ESP_WIFI_SSID "RIOT_AP" +#endif + +/** + * @brief Legacy definition for compatibility reasons. + * #ESP_WIFI_PASS is deprecated, please use #CONFIG_ESP_WIFI_PASS instead. + */ +#ifndef ESP_WIFI_PASS +#define ESP_WIFI_PASS "ThisistheRIOTporttoESP" +#endif + /** * @name Set default configuration parameters for the ESP WiFi netdev driver * @{ */ +/** @} */ + /** * @brief The size of the stack used for the ESP WIFI netdev driver thread. */ -#ifndef ESP_WIFI_STACKSIZE -#define ESP_WIFI_STACKSIZE (THREAD_STACKSIZE_DEFAULT) +#ifndef CONFIG_ESP_WIFI_STACKSIZE +#define CONFIG_ESP_WIFI_STACKSIZE ESP_WIFI_STACKSIZE #endif /** * @brief The priority of the ESP WiFi netdev driver thread. Should not be changed. */ -#ifndef ESP_WIFI_PRIO -#define ESP_WIFI_PRIO (GNRC_NETIF_PRIO) +#ifndef CONFIG_ESP_WIFI_PRIO +#define CONFIG_ESP_WIFI_PRIO ESP_WIFI_PRIO #endif /** * @brief SSID of the AP to be used. */ -#ifndef ESP_WIFI_SSID -#define ESP_WIFI_SSID "RIOT_AP" +#ifndef CONFIG_ESP_WIFI_SSID +#define CONFIG_ESP_WIFI_SSID ESP_WIFI_SSID #endif /** * @brief Passphrase used for the AP as clear text (max. 64 chars). */ -#ifndef ESP_WIFI_PASS -#define ESP_WIFI_PASS "ThisistheRIOTporttoESP" +#ifndef CONFIG_ESP_WIFI_PASS +#define CONFIG_ESP_WIFI_PASS ESP_WIFI_PASS #endif /**@}*/ diff --git a/cpu/esp32/include/sdk_conf.h b/cpu/esp32/include/sdk_conf.h index 2e5fecbb3e19..fdb0572e20d9 100644 --- a/cpu/esp32/include/sdk_conf.h +++ b/cpu/esp32/include/sdk_conf.h @@ -31,10 +31,16 @@ extern "C" { #include "board.h" /** - * @brief Defines the CPU frequency [values = 2, 40, 80, 160 and 240] + * @brief Defines the CPU frequency [values = 80, 160 and 240] */ #ifndef CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ -#define CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ 80 +#if defined(CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ_240) +#define CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ (240) +#elif defined(CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ_160) +#define CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ (160) +#else +#define CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ (80) +#endif #endif /** diff --git a/cpu/esp8266/Kconfig b/cpu/esp8266/Kconfig new file mode 100644 index 000000000000..5237f79b41db --- /dev/null +++ b/cpu/esp8266/Kconfig @@ -0,0 +1,31 @@ +# Copyright (c) 2020 Gunar Schorcht +# +# This file is subject to the terms and conditions of the GNU Lesser +# General Public License v2.1. See the file LICENSE in the top level +# directory for more details. +# + +menuconfig KCONFIG_CPU_ESP8266 + bool "Configure ESP8266 CPU" + depends on MODULE_ESP_ESP8266 + help + Configure ESP8266 CPU via Kconfig. + +if KCONFIG_CPU_ESP8266 + +choice ESP8266_CPU_FREQUENCY + bool "CPU frequency" + default ESP8266_CPU_FREQUENCY_80MHZ + help + Defines the CPU frequency. + +config ESP8266_CPU_FREQUENCY_80MHZ + bool "80 MHz" +config ESP8266_CPU_FREQUENCY_160MHZ + bool "160 MHz" +endchoice + +rsource "esp-wifi/Kconfig" +rsource "$(RIOTBASE)/cpu/esp_common/esp-now/Kconfig" + +endif # ESP8266 settings diff --git a/cpu/esp8266/Makefile.include b/cpu/esp8266/Makefile.include index ecf4b0d864f4..6bd9a58cb888 100644 --- a/cpu/esp8266/Makefile.include +++ b/cpu/esp8266/Makefile.include @@ -72,6 +72,7 @@ endif export TARGET_ARCH ?= xtensa-esp8266-elf # ESP8266 pseudomodules +PSEUDOMODULES += esp_esp8266 PSEUDOMODULES += esp_gdb PSEUDOMODULES += esp_log_colored PSEUDOMODULES += esp_log_tagged @@ -82,6 +83,7 @@ PSEUDOMODULES += esp_spiffs PSEUDOMODULES += esp_wifi_any USEMODULE += esp_common +USEMODULE += esp_esp8266 USEMODULE += esp_freertos USEMODULE += esp_idf USEMODULE += esp_idf_esp8266 diff --git a/cpu/esp8266/doc.txt b/cpu/esp8266/doc.txt index afd263ce529c..d33df2bee585 100644 --- a/cpu/esp8266/doc.txt +++ b/cpu/esp8266/doc.txt @@ -684,11 +684,11 @@ Furthermore, the following configuration parameters have to be defined:
-Parameter | Default | Description -:-------------------|:--------------------------|:------------ -#ESP_WIFI_SSID | "RIOT_AP" | SSID of the AP to be used. -#ESP_WIFI_PASS | "ThisistheRIOTporttoESP" | Passphrase used for the AP as clear text (max. 64 chars). -#ESP_WIFI_STACKSIZE | #THREAD_STACKSIZE_DEFAULT |Stack size used for the WiFi netdev driver thread. +Parameter | Default | Description +:--------------------------|:--------------------------|:------------ +#CONFIG_ESP_WIFI_SSID | "RIOT_AP" | SSID of the AP to be used. +#CONFIG_ESP_WIFI_PASS | "ThisistheRIOTporttoESP" | Passphrase used for the AP as clear text (max. 64 chars). +#CONFIG_ESP_WIFI_STACKSIZE | #THREAD_STACKSIZE_DEFAULT |Stack size used for the WiFi netdev driver thread.
@@ -698,7 +698,7 @@ line, e.g.: ``` USEMODULE=esp_wifi \ -CFLAGS='-DESP_WIFI_SSID=\"MySSID\" -DESP_WIFI_PASS=\"MyPassphrase\"' \ +CFLAGS='-DCONFIG_ESP_WIFI_SSID=\"MySSID\" -DCONFIG_ESP_WIFI_PASS=\"MyPassphrase\"' \ make -C examples/gnrc_networking BOARD=... ``` @@ -741,10 +741,10 @@ be overridden by [application-specific board configurations](#esp8266_applicatio Parameter | Default | Description :---------|:--------|:----------- -#ESP_NOW_SCAN_PERIOD | 10000000UL | Defines the period in us at which an node scans for other nodes in its range. The default period is 10 s. -#ESP_NOW_SOFT_AP_PASS | "ThisistheRIOTporttoESP" | Defines the passphrase as clear text (max. 64 chars) that is used for the SoftAP interface of ESP-NOW nodes. It has to be same for all nodes in one network. -#ESP_NOW_CHANNEL | 6 | Defines the channel that is used as the broadcast medium by all nodes together. -#ESP_NOW_KEY | NULL | Defines a key that is used for encrypted communication between nodes. If it is NULL, encryption is disabled. The key has to be of type `uint8_t[16]` and has to be exactly 16 bytes long. +#CONFIG_ESP_NOW_SCAN_PERIOD | 10000000UL | Defines the period in us at which an node scans for other nodes in its range. The default period is 10 s. +#CONFIG_ESP_NOW_SOFT_AP_PASS | "ThisistheRIOTporttoESP" | Defines the passphrase as clear text (max. 64 chars) that is used for the SoftAP interface of ESP-NOW nodes. It has to be same for all nodes in one network. +#CONFIG_ESP_NOW_CHANNEL | 6 | Defines the channel that is used as the broadcast medium by all nodes together. +#CONFIG_ESP_NOW_KEY | NULL | Defines a key that is used for encrypted communication between nodes. If it is NULL, encryption is disabled. The key has to be of type `uint8_t[16]` and has to be exactly 16 bytes long. diff --git a/cpu/esp8266/esp-wifi/Kconfig b/cpu/esp8266/esp-wifi/Kconfig new file mode 100644 index 000000000000..276a3ffc1a88 --- /dev/null +++ b/cpu/esp8266/esp-wifi/Kconfig @@ -0,0 +1,29 @@ +# Copyright (c) 2020 Gunar Schorcht +# +# This file is subject to the terms and conditions of the GNU Lesser +# General Public License v2.1. See the file LICENSE in the top level +# directory for more details. +# + +menuconfig KCONFIG_MODULE_ESP_WIFI + bool "Configure ESP-WiFi netdev" + depends on MODULE_ESP_WIFI + help + Configure ESP-Wifi netdev when module esp_wifi is used. + +if KCONFIG_MODULE_ESP_WIFI + +config ESP_WIFI_SSID + string "SSID" + default "RIOT_AP" + help + This string defines the SSID of the AP to be used. + +config ESP_WIFI_PASS + string "Passphrase for WPA2" + default "ThisistheRIOTporttoESP" + help + This string defines the passphrase as plain text, which is used for + the AP during WPA2 authentication. It can be up to 64 characters long. + +endif # KCONFIG_MODULE_ESP_WIFI diff --git a/cpu/esp8266/esp-wifi/doc.txt b/cpu/esp8266/esp-wifi/doc.txt index 97031d3a76a6..7b8e4119de2f 100644 --- a/cpu/esp8266/esp-wifi/doc.txt +++ b/cpu/esp8266/esp-wifi/doc.txt @@ -17,11 +17,11 @@ This module realizes a `netdev` interface for the built-in WiFi interface of ESP8266. To enable the WiFi interface, module `esp_wifi` has to be used. Furthermore, the following configuration parameters have to be defined: -Configuration Parameter | Description -------------------------|------------ -ESP_WIFI_SSID | SSID of the AP to be used. -ESP_WIFI_PASS | Passphrase used for the AP as clear text (max. 64 chars). -ESP_WIFI_STACKSIZE | Stack size used for the WiFi netdev driver thread. +Configuration Parameter | Description +---------------------------|------------ +#CONFIG_ESP_WIFI_SSID | SSID of the AP to be used. +#CONFIG_ESP_WIFI_PASS | Passphrase used for the AP as clear text (max. 64 chars). +#CONFIG_ESP_WIFI_STACKSIZE | Stack size used for the WiFi netdev driver thread. These configuration parameter definitions, as well as enabling the `esp_wifi` module, can be done either in the makefile of the project or at make command @@ -29,7 +29,7 @@ line, e.g.: ``` USEMODULE=esp_wifi \ -CFLAGS='-DESP_WIFI_SSID=\"MySSID\" -DESP_WIFI_PASS=\"MyPassphrase\"' \ +CFLAGS='-DCONFIG_ESP_WIFI_SSID=\"MySSID\" -DCONFIG_ESP_WIFI_PASS=\"MyPassphrase\"' \ make -C examples/gnrc_networking BOARD=... ``` diff --git a/cpu/esp8266/esp-wifi/esp_wifi_netdev.c b/cpu/esp8266/esp-wifi/esp_wifi_netdev.c index 8b9c1092f9b8..16c9b1b8fb76 100644 --- a/cpu/esp8266/esp-wifi/esp_wifi_netdev.c +++ b/cpu/esp8266/esp-wifi/esp_wifi_netdev.c @@ -105,7 +105,7 @@ esp_wifi_netdev_t _esp_wifi_dev; static const netdev_driver_t _esp_wifi_driver; /* device thread stack */ -static char _esp_wifi_stack[ESP_WIFI_STACKSIZE]; +static char _esp_wifi_stack[CONFIG_ESP_WIFI_STACKSIZE]; /** guard variable to avoid reentrance to _esp_wifi_send function */ static bool _esp_wifi_send_is_in = false; @@ -697,8 +697,8 @@ static const netdev_driver_t _esp_wifi_driver = */ static wifi_config_t wifi_config_sta = { .sta = { - .ssid = ESP_WIFI_SSID, - .password = ESP_WIFI_PASS, + .ssid = CONFIG_ESP_WIFI_SSID, + .password = CONFIG_ESP_WIFI_PASS, .channel = 0, .scan_method = WIFI_ALL_CHANNEL_SCAN, .sort_method = WIFI_CONNECT_AP_BY_SIGNAL, @@ -727,10 +727,10 @@ static wifi_config_t wifi_config_sta = { */ static wifi_config_t wifi_config_ap = { .ap = { - .ssid = ESP_WIFI_SSID, - .ssid_len = ARRAY_SIZE(ESP_WIFI_SSID), + .ssid = CONFIG_ESP_WIFI_SSID, + .ssid_len = ARRAY_SIZE(CONFIG_ESP_WIFI_SSID), .ssid_hidden = 1, /* don't make the AP visible */ - .password = ESP_WIFI_PASS, + .password = CONFIG_ESP_WIFI_PASS, .authmode = WIFI_AUTH_WPA2_PSK, .max_connection = 0, /* don't allow connections */ .beacon_interval = 60000, /* send beacon only every 60 s */ @@ -830,14 +830,14 @@ void auto_init_esp_wifi (void) esp_wifi_setup(&_esp_wifi_dev); _esp_wifi_dev.netif = gnrc_netif_ethernet_create(_esp_wifi_stack, - ESP_WIFI_STACKSIZE, + CONFIG_ESP_WIFI_STACKSIZE, #ifdef MODULE_ESP_NOW - ESP_WIFI_PRIO - 1, + CONFIG_ESP_WIFI_PRIO - 1, #else - ESP_WIFI_PRIO, + CONFIG_ESP_WIFI_PRIO, #endif - "esp_wifi", - (netdev_t *)&_esp_wifi_dev); + "esp_wifi", + (netdev_t *)&_esp_wifi_dev); } #endif /* MODULE_ESP_WIFI */ diff --git a/cpu/esp8266/esp-wifi/esp_wifi_params.h b/cpu/esp8266/esp-wifi/esp_wifi_params.h index 9298c2d4a30d..56e1a7e9ff82 100644 --- a/cpu/esp8266/esp-wifi/esp_wifi_params.h +++ b/cpu/esp8266/esp-wifi/esp_wifi_params.h @@ -12,7 +12,7 @@ * @{ * * @file - * @brief Parameters for the ESP32 WiFi netdev interface + * @brief Parameters for the ESP8266 WiFi netdev interface * * @author Gunar Schorcht */ @@ -22,37 +22,77 @@ #if defined(MODULE_ESP_WIFI) || defined(DOXYGEN) +/** + * @name Legacy definitions of default configuration parameters + * @{ + */ + +/** + * @brief Legacy definition for compatibility reasons. + * #ESP_WIFI_STACKSIZE is deprecated, please use #CONFIG_ESP_WIFI_STACKSIZE + * instead. + */ +#ifndef ESP_WIFI_STACKSIZE +#define ESP_WIFI_STACKSIZE (THREAD_STACKSIZE_DEFAULT) +#endif + +/** + * @brief Legacy definition for compatibility reasons. + * #ESP_WIFI_PRIO is deprecated, please use #CONFIG_ESP_WIFI_PRIO instead. + */ +#ifndef ESP_WIFI_PRIO +#define ESP_WIFI_PRIO (GNRC_NETIF_PRIO) +#endif + +/** + * @brief Legacy definition for compatibility reasons. + * #ESP_WIFI_SSID is deprecated, please use #CONFIG_ESP_WIFI_SSID instead. + */ +#ifndef ESP_WIFI_SSID +#define ESP_WIFI_SSID "RIOT_AP" +#endif + +/** + * @brief Legacy definition for compatibility reasons. + * #ESP_WIFI_PASS is deprecated, please use #CONFIG_ESP_WIFI_PASS instead. + */ +#ifndef ESP_WIFI_PASS +#define ESP_WIFI_PASS "ThisistheRIOTporttoESP" +#endif + /** * @name Set default configuration parameters for the ESP WiFi netdev driver * @{ */ +/** @} */ + /** * @brief The size of the stack used for the ESP WIFI netdev driver thread. */ -#ifndef ESP_WIFI_STACKSIZE -#define ESP_WIFI_STACKSIZE (THREAD_STACKSIZE_DEFAULT) +#ifndef CONFIG_ESP_WIFI_STACKSIZE +#define CONFIG_ESP_WIFI_STACKSIZE ESP_WIFI_STACKSIZE #endif /** * @brief The priority of the ESP WiFi netdev driver thread. Should not be changed. */ -#ifndef ESP_WIFI_PRIO -#define ESP_WIFI_PRIO (GNRC_NETIF_PRIO) +#ifndef CONFIG_ESP_WIFI_PRIO +#define CONFIG_ESP_WIFI_PRIO ESP_WIFI_PRIO #endif /** * @brief SSID of the AP to be used. */ -#ifndef ESP_WIFI_SSID -#define ESP_WIFI_SSID "RIOT_AP" +#ifndef CONFIG_ESP_WIFI_SSID +#define CONFIG_ESP_WIFI_SSID ESP_WIFI_SSID #endif /** * @brief Passphrase used for the AP as clear text (max. 64 chars). */ -#ifndef ESP_WIFI_PASS -#define ESP_WIFI_PASS "ThisistheRIOTporttoESP" +#ifndef CONFIG_ESP_WIFI_PASS +#define CONFIG_ESP_WIFI_PASS ESP_WIFI_PASS #endif /**@}*/ diff --git a/cpu/esp8266/include/cpu_conf.h b/cpu/esp8266/include/cpu_conf.h index f6931df9b33c..a95121171a01 100644 --- a/cpu/esp8266/include/cpu_conf.h +++ b/cpu/esp8266/include/cpu_conf.h @@ -33,8 +33,12 @@ extern "C" { * * Possible values are 80 and 160 MHz. */ -#ifndef ESP8266_CPU_FREQUENCY -#define ESP8266_CPU_FREQUENCY (80) +#ifndef CONFIG_ESP8266_CPU_FREQUENCY +#if defined(CONFIG_ESP8266_CPU_FREQUENCY_160MHZ) +#define CONFIG_ESP8266_CPU_FREQUENCY (160) +#else +#define CONFIG_ESP8266_CPU_FREQUENCY (80) +#endif #endif /** diff --git a/cpu/esp8266/startup.c b/cpu/esp8266/startup.c index 31534dcd82dd..294bb31f3d04 100644 --- a/cpu/esp8266/startup.c +++ b/cpu/esp8266/startup.c @@ -62,8 +62,8 @@ void esp_riot_init(void) #endif /* set system frequency if not 80 MHz */ - if (ESP8266_CPU_FREQUENCY != 80) { - system_update_cpu_freq(ESP8266_CPU_FREQUENCY); + if (CONFIG_ESP8266_CPU_FREQUENCY != 80) { + system_update_cpu_freq(CONFIG_ESP8266_CPU_FREQUENCY); } ets_printf("\n"); diff --git a/cpu/esp_common/esp-now/Kconfig b/cpu/esp_common/esp-now/Kconfig new file mode 100644 index 000000000000..010b689ef882 --- /dev/null +++ b/cpu/esp_common/esp-now/Kconfig @@ -0,0 +1,41 @@ +# Copyright (c) 2020 Gunar Schorcht +# +# This file is subject to the terms and conditions of the GNU Lesser +# General Public License v2.1. See the file LICENSE in the top level +# directory for more details. +# + +menuconfig KCONFIG_MODULE_ESP_NOW + bool "Configure ESP-NOW netdev" + depends on MODULE_ESP_NOW + help + Configure ESP-NOW netdev when module esp_now is used. + +if KCONFIG_MODULE_ESP_NOW + +config ESP_NOW_CHANNEL + int "WiFi channel" + default 6 + help + The WiFi channel that is used as by all ESP-NOW nodes. + +config ESP_NOW_SCAN_PERIOD + int "Scan period in microseconds" + default 10000000 + help + Period in microseconds at which an ESP-NOW node scans for other + ESP-NOW nodes in its range. + +config ESP_NOW_SOFT_AP_PASS + string "SoftAP interface passphrase" + default "ThisistheRIOTporttoESP" + help + Passphrase used for the SoftAP interface of all ESP-NOW nodes. + + ESP_NOW uses the WiFi interface in Station and SoftAP mode + simultaneously to build a peer-to-peer network. A passphrase is + required for the SoftAP mode. This passphrase is used by all ESP-NOW + nodes to establish the connection between them in the peer-to-peer + network. + +endif # KCONFIG_MODULE_ESP_NOW diff --git a/cpu/esp_common/esp-now/doc.txt b/cpu/esp_common/esp-now/doc.txt index 63ddf4501974..b9e87cf35892 100644 --- a/cpu/esp_common/esp-now/doc.txt +++ b/cpu/esp_common/esp-now/doc.txt @@ -32,10 +32,10 @@ The following parameters are defined for ESP-NOW nodes. Parameter | Default | Description :---------|:--------|:----------- -ESP_NOW_SCAN_PERIOD | 10000000UL | Defines the period in us at which an node scans for other nodes in its range. The default period is 10 s. -ESP_NOW_SOFT_AP_PASS | "ThisistheRIOTporttoESP" | Defines the passphrase as clear text (max. 64 chars) that is used for the SoftAP interface of ESP-NOW nodes. It has to be same for all nodes in one network. -ESP_NOW_CHANNEL | 6 | Defines the channel that is used as the broadcast medium by all nodes together. -ESP_NOW_KEY | NULL | Defines a key that is used for encrypted communication between nodes. If it is NULL, encryption is disabled. The key has to be of type ```uint8_t[16]``` and has to be exactly 16 bytes long. +#CONFIG_ESP_NOW_SCAN_PERIOD | 10000000UL | Defines the period in us at which an node scans for other nodes in its range. The default period is 10 s. +#CONFIG_ESP_NOW_SOFT_AP_PASS | "ThisistheRIOTporttoESP" | Defines the passphrase as clear text (max. 64 chars) that is used for the SoftAP interface of ESP-NOW nodes. It has to be same for all nodes in one network. +#CONFIG_ESP_NOW_CHANNEL | 6 | Defines the channel that is used as the broadcast medium by all nodes together. +#CONFIG_ESP_NOW_KEY | NULL | Defines a key that is used for encrypted communication between nodes. If it is NULL, encryption is disabled. The key has to be of type ```uint8_t[16]``` and has to be exactly 16 bytes long. diff --git a/cpu/esp_common/esp-now/esp_now_gnrc.c b/cpu/esp_common/esp-now/esp_now_gnrc.c index 859a99dfbdc5..d50b3279e5df 100644 --- a/cpu/esp_common/esp-now/esp_now_gnrc.c +++ b/cpu/esp_common/esp-now/esp_now_gnrc.c @@ -202,7 +202,7 @@ gnrc_netif_t *gnrc_netif_esp_now_create(char *stack, int stacksize, char priorit } /* device thread stack */ -static char _esp_now_stack[ESP_NOW_STACKSIZE]; +static char _esp_now_stack[CONFIG_ESP_NOW_STACKSIZE]; void auto_init_esp_now(void) { @@ -213,7 +213,7 @@ void auto_init_esp_now(void) LOG_ERROR("[auto_init_netif] error initializing esp_now\n"); } else { gnrc_netif_esp_now_create(_esp_now_stack, sizeof(_esp_now_stack), - ESP_NOW_PRIO, + CONFIG_ESP_NOW_PRIO, "esp-now", &esp_now_dev->netdev); } diff --git a/cpu/esp_common/esp-now/esp_now_netdev.c b/cpu/esp_common/esp-now/esp_now_netdev.c index 64c2c360fc5e..ab7452597f73 100644 --- a/cpu/esp_common/esp-now/esp_now_netdev.c +++ b/cpu/esp_common/esp-now/esp_now_netdev.c @@ -103,7 +103,7 @@ static uint32_t aps_size = 0; static const wifi_scan_config_t scan_cfg = { .ssid = NULL, .bssid = NULL, - .channel = ESP_NOW_CHANNEL, + .channel = CONFIG_ESP_NOW_CHANNEL, .show_hidden = true, .scan_type = WIFI_SCAN_TYPE_ACTIVE, .scan_time.active.min = 0, diff --git a/cpu/esp_common/esp-now/esp_now_params.h b/cpu/esp_common/esp-now/esp_now_params.h index 289b246733ec..1242b8a41546 100644 --- a/cpu/esp_common/esp-now/esp_now_params.h +++ b/cpu/esp_common/esp-now/esp_now_params.h @@ -21,6 +21,64 @@ #if defined(MODULE_ESP_NOW) || defined(DOXYGEN) +/** + * @name Legacy definitions of default configuration parameters + * @{ + */ + +/** + * @brief Legacy definition for compatibility reasons. + * #ESP_NOW_STACKSIZE is deprecated, please use #CONFIG_ESP_NOW_STACKSIZE + * instead. + */ +#ifndef ESP_NOW_STACKSIZE +#define ESP_NOW_STACKSIZE (THREAD_STACKSIZE_DEFAULT) +#endif + +/** + * @brief Legacy definition for compatibility reasons. + * #ESP_NOW_PRIO is deprecated, please use #CONFIG_ESP_NOW_PRIO instead. + */ +#ifndef ESP_NOW_PRIO +#define ESP_NOW_PRIO (GNRC_NETIF_PRIO) +#endif + +/** + * @brief Legacy definition for compatibility reasons. + * #ESP_NOW_SCAN_PERIOD is deprecated, please use #CONFIG_ESP_NOW_SCAN_PERIOD + * instead. + */ +#ifndef ESP_NOW_SCAN_PERIOD +#define ESP_NOW_SCAN_PERIOD (10000000UL) +#endif + +/** + * @brief Legacy definition for compatibility reasons. + * #ESP_NOW_SOFT_AP_PASS is deprecated, please use #CONFIG_ESP_NOW_SOFT_AP_PASS + * instead. + */ +#ifndef ESP_NOW_SOFT_AP_PASS +#define ESP_NOW_SOFT_AP_PASS "ThisistheRIOTporttoESP" +#endif + +/** + * @brief Legacy definition for compatibility reasons. + * #ESP_NOW_CHANNEL is deprecated, please use #CONFIG_ESP_NOW_CHANNEL instead. + */ +#ifndef ESP_NOW_CHANNEL +#define ESP_NOW_CHANNEL (6) +#endif + +/** + * @brief Legacy definition for compatibility reasons. + * #ESP_NOW_KEY is deprecated, please use #CONFIG_ESP_NOW_KEY instead. + */ +#ifndef ESP_NOW_KEY +#define ESP_NOW_KEY (NULL) +#endif + +/** @} */ + /** * @name Set default configuration parameters for the ESP-NOW netdev driver * @{ @@ -30,8 +88,8 @@ * @brief The size of the stack used for the ESP-NOW netdev driver thread. * @ingroup cpu_esp_common_conf */ -#ifndef ESP_NOW_STACKSIZE -#define ESP_NOW_STACKSIZE (THREAD_STACKSIZE_DEFAULT) +#ifndef CONFIG_ESP_NOW_STACKSIZE +#define CONFIG_ESP_NOW_STACKSIZE ESP_NOW_STACKSIZE #endif /** @@ -39,8 +97,8 @@ * changed. * @ingroup cpu_esp_common_conf */ -#ifndef ESP_NOW_PRIO -#define ESP_NOW_PRIO (GNRC_NETIF_PRIO) +#ifndef CONFIG_ESP_NOW_PRIO +#define CONFIG_ESP_NOW_PRIO ESP_NOW_PRIO #endif /** @@ -48,24 +106,24 @@ * ESP-NOW nodes in its range. * @ingroup cpu_esp_common_conf */ -#ifndef ESP_NOW_SCAN_PERIOD -#define ESP_NOW_SCAN_PERIOD (10000000UL) +#ifndef CONFIG_ESP_NOW_SCAN_PERIOD +#define CONFIG_ESP_NOW_SCAN_PERIOD ESP_NOW_SCAN_PERIOD #endif /** * @brief Passphrase used for the SoftAP interface of for all ESP-NOW nodes. * @ingroup cpu_esp_common_conf */ -#ifndef ESP_NOW_SOFT_AP_PASS -#define ESP_NOW_SOFT_AP_PASS "ThisistheRIOTporttoESP" +#ifndef CONFIG_ESP_NOW_SOFT_AP_PASS +#define CONFIG_ESP_NOW_SOFT_AP_PASS ESP_NOW_SOFT_AP_PASS #endif /** * @brief Channel used as broadcast medium by all ESP-NOW nodes together * @ingroup cpu_esp_common_conf */ -#ifndef ESP_NOW_CHANNEL -#define ESP_NOW_CHANNEL (6) +#ifndef CONFIG_ESP_NOW_CHANNEL +#define CONFIG_ESP_NOW_CHANNEL ESP_NOW_CHANNEL #endif /** @@ -81,8 +139,8 @@ * communicate with each other, while in unencrypted mode, up to 20 nodes can * communicate. */ -#ifndef ESP_NOW_KEY -#define ESP_NOW_KEY (NULL) +#ifndef CONFIG_ESP_NOW_KEY +#define CONFIG_ESP_NOW_KEY ESP_NOW_KEY #endif /** @} */ @@ -91,10 +149,10 @@ * @brief Initializer for default configuration parameters. */ #ifndef ESP_NOW_PARAMS -#define ESP_NOW_PARAMS { .key = ESP_NOW_KEY, \ - .scan_period = ESP_NOW_SCAN_PERIOD, \ - .softap_pass = ESP_NOW_SOFT_AP_PASS, \ - .channel = ESP_NOW_CHANNEL \ +#define ESP_NOW_PARAMS { .key = CONFIG_ESP_NOW_KEY, \ + .scan_period = CONFIG_ESP_NOW_SCAN_PERIOD, \ + .softap_pass = CONFIG_ESP_NOW_SOFT_AP_PASS, \ + .channel = CONFIG_ESP_NOW_CHANNEL \ } #endif