cpu/esp8266: move esp_wifi to cpu/esp_common

This commit is contained in:
Gunar Schorcht 2019-12-16 01:47:44 +01:00
parent 9723e3e3cf
commit 98ca108be5
11 changed files with 46 additions and 39 deletions

View File

@ -8,10 +8,6 @@ DIRS += periph
DIRS += sdk
DIRS += vendor
ifneq (, $(filter esp_wifi, $(USEMODULE)))
DIRS += esp-wifi
endif
INCLUDES += -I$(ESP8266_RTOS_SDK_DIR)/components/esp8266/include/internal
include $(RIOTBASE)/Makefile.base

View File

@ -1,7 +0,0 @@
MODULE=esp_wifi
# we have to do it in that way to avoid that pkg/lwip is found first
CFLAGS += -I$(ESP8266_RTOS_SDK_DIR)/components/lwip/lwip/src/include
CFLAGS += -I$(ESP8266_RTOS_SDK_DIR)/components/lwip/port/esp8266/include/
include $(RIOTBASE)/Makefile.base

View File

@ -10,4 +10,8 @@ ifneq (,$(filter esp_now,$(USEMODULE)))
DIRS += esp-now
endif
ifneq (,$(filter esp_wifi,$(USEMODULE)))
DIRS += esp-wifi
endif
include $(RIOTBASE)/Makefile.base

View File

@ -97,7 +97,12 @@ ifneq (,$(filter esp_wifi esp_now esp_eth,$(USEMODULE)))
CFLAGS += -DSCHED_PRIO_LEVELS=32
endif
# lwIP thread priority has to be lower than that of ESP hardware driver threads
ifneq (,$(filter esp_wifi esp_now esp_eth,$(USEMODULE)))
INCLUDES += -I$(RIOTCPU)/esp_common/esp-wifi
endif
# The threads for handling the ESP hardware have the priorities from 2 to 4.
# The priority of lwIP TCPIP thread should be lower than these priorities.
ifneq (,$(filter lwip,$(USEMODULE)))
CFLAGS += -DTCPIP_THREAD_PRIO=5
endif

View File

@ -9,6 +9,8 @@
/**
* @defgroup cpu_esp_common_esp_now ESP-NOW netdev interface
* @ingroup cpu_esp_common
* @ingroup cpu_esp32
* @ingroup cpu_esp8266
* @brief WiFi based ESP-NOW network device driver
*
* @author Gunar Schorcht <gunar@schorcht.net>

View File

@ -0,0 +1,9 @@
MODULE=esp_wifi
ifeq (esp8266,$(CPU))
# we have to do it in that way to avoid that pkg/lwip is found first
CFLAGS += -I$(ESP8266_RTOS_SDK_DIR)/components/lwip/lwip/src/include
CFLAGS += -I$(ESP8266_RTOS_SDK_DIR)/components/lwip/port/esp8266/include/
endif
include $(RIOTBASE)/Makefile.base

View File

@ -7,14 +7,16 @@
*/
/**
* @defgroup cpu_esp8266_esp_wifi ESP8266 WiFi netdev interface
* @defgroup cpu_esp_common_esp_wifi ESP-WiFi netdev interface
* @ingroup cpu_esp_common
* @ingroup cpu_esp32
* @ingroup cpu_esp8266
* @brief Network device driver for the ESP8266 WiFi interface
* @brief Network device driver for the ESP SoC WiFi interface
*
* @author Gunar Schorcht <gunar@schorcht.net>
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.
This module realizes a `netdev` interface for the built-in WiFi interface of
ESP SoCs. To enable the WiFi interface, module `esp_wifi` has to be used.
Furthermore, the following configuration parameters have to be defined:
Configuration Parameter | Description
@ -34,7 +36,7 @@ make -C examples/gnrc_networking BOARD=...
```
@note The Wifi network interface (module `esp_wifi`) and the
\ref esp8266_esp_now_network_interface "ESP-NOW network interface" (module `esp_now`)
ESP-NOW network interface (module `esp_now`)
can be used simultaneously, for example, to realize a border router for
a mesh network which uses ESP-NOW.
*/

View File

@ -7,20 +7,22 @@
*/
/**
* @ingroup cpu_esp8266_esp_wifi
* @ingroup cpu_esp_common_esp_wifi
* @{
*
* @file
* @brief GNRC network interface part for ESP8266 WiFi interface
* @brief GNRC network interface part for ESP WiFi interface
*
* @author Gunar Schorcht <gunar@schorcht.net>
*/
#if defined(MODULE_ESP_WIFI) && defined(MODULE_GNRC_NETIF_ETHERNET)
#include "net/ethernet.h"
#include "net/gnrc/netif/ethernet.h"
#include "esp_wifi_params.h"
#include "esp_wifi_netdev.h"
#include "net/gnrc/netif/ethernet.h"
/** the only ESP WiFi device */
extern esp_wifi_netdev_t _esp_wifi_dev;

View File

@ -7,11 +7,11 @@
*/
/**
* @ingroup cpu_esp8266_esp_wifi
* @ingroup cpu_esp_common_esp_wifi
* @{
*
* @file
* @brief Network device driver for the ESP8266 WiFi interface
* @brief Network device driver for the ESP SoCs WiFi interface
*
* @author Gunar Schorcht <gunar@schorcht.net>
*/
@ -22,9 +22,6 @@
#include <assert.h>
#include <errno.h>
#include "net/gnrc/netif/ethernet.h"
#include "net/gnrc/netif/raw.h"
#include "net/gnrc.h"
#include "net/ethernet.h"
#include "net/netdev/eth.h"
#include "od.h"
@ -50,9 +47,6 @@
#include "debug.h"
#include "log.h"
#define SYSTEM_EVENT_WIFI_RX_DONE (SYSTEM_EVENT_MAX + 3)
#define SYSTEM_EVENT_WIFI_TX_DONE (SYSTEM_EVENT_MAX + 4)
#define ESP_WIFI_DEBUG(f, ...) \
DEBUG("[esp_wifi] %s: " f "\n", __func__, ## __VA_ARGS__)
@ -77,7 +71,7 @@
/**
* The SDK interface of the WiFi module uses the lwIP `pbuf` structure for
* packets sent to and received from the WiFi interface. For compatibility
* reasons with the binary SDK libraries we need to incclude the SDK lwIP
* reasons with the binary SDK libraries we need to include the SDK lwIP
* `pbuf` header here.
*
* To avoid compilation errors, we need to undefine all our pkg/lwIP settings
@ -321,9 +315,8 @@ esp_err_t _esp_wifi_rx_cb(void *buffer, uint16_t len, void *eb)
ESP_WIFI_DEBUG("buf=%p len=%d eb=%p", buffer, len, eb);
/*
* The ring buffer uses a single byte for the pkt length, followed by the mac address,
* followed by the actual packet data. The MTU for ESP-NOW is 250 bytes, so len will never
* exceed the limits of a byte as the mac address length is not included.
* The ring buffer uses two bytes for the pkt length, followed by the
* actual packet data.
*/
if (ringbuffer_get_free(&_esp_wifi_dev.rx_buf) < len + sizeof(uint16_t)) {
ESP_WIFI_DEBUG("buffer full, dropping incoming packet of %d bytes", len);
@ -453,7 +446,7 @@ static esp_err_t IRAM_ATTR _esp_system_event_handler(void *ctx, system_event_t *
else if (reason <= REASON_HANDSHAKE_TIMEOUT) {
reason_str = _esp_wifi_disc_reasons[reason - INDEX_BEACON_TIMEOUT];
}
ESP_WIFI_LOG_INFO("Wifi disconnected from ssid %s, reason %d (%s)",
ESP_WIFI_LOG_INFO("WiFi disconnected from ssid %s, reason %d (%s)",
event->event_info.disconnected.ssid,
event->event_info.disconnected.reason, reason_str);
@ -754,7 +747,7 @@ void esp_wifi_setup (esp_wifi_netdev_t* dev)
#ifndef MODULE_ESP_NOW
/* if module esp_now is used, the following part is already done */
#if MCU_ESP32
#ifdef MCU_ESP32
extern portMUX_TYPE g_intr_lock_mux;
mutex_init(&g_intr_lock_mux);
#endif
@ -820,5 +813,6 @@ void esp_wifi_setup (esp_wifi_netdev_t* dev)
dev->event_conn = 0;
dev->event_disc = 0;
}
#endif /* MODULE_ESP_WIFI */
/**@}*/

View File

@ -7,11 +7,11 @@
*/
/**
* @ingroup cpu_esp8266_esp_wifi
* @ingroup cpu_esp_common_esp_wifi
* @{
*
* @file
* @brief Network device driver for the ESP32 WiFi interface
* @brief Network device driver for the ESP SoCs WiFi interface
*
* @author Gunar Schorcht <gunar@schorcht.net>
*/

View File

@ -7,12 +7,12 @@
*/
/**
* @ingroup cpu_esp8266_esp_wifi
* @ingroup cpu_esp8266_conf
* @ingroup cpu_esp_common_esp_wifi
* @ingroup cpu_esp_common_conf
* @{
*
* @file
* @brief Parameters for the ESP32 WiFi netdev interface
* @brief Parameters for the ESP SoCs WiFi netdev interface
*
* @author Gunar Schorcht <gunar@schorcht.net>
*/