1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-18 11:03:50 +01:00

cpu/esp_common: inverse MCU_* conditionals to deal with ESP32 variants

The MCU_* conditionals are inverted so that they can be tested for ESP8266. In all other cases the MCU is any ESP32x SoC
This commit is contained in:
Gunar Schorcht 2022-06-23 07:18:48 +02:00
parent 45aa420c42
commit b60b47ff51
4 changed files with 29 additions and 29 deletions

View File

@ -615,7 +615,7 @@ static int _esp_wifi_send(netdev_t *netdev, const iolist_t *iolist)
/* send the the packet to the peer(s) mac address */ /* send the the packet to the peer(s) mac address */
if (esp_wifi_internal_tx(ESP_IF_WIFI_STA, dev->tx_buf, dev->tx_len) == ESP_OK) { if (esp_wifi_internal_tx(ESP_IF_WIFI_STA, dev->tx_buf, dev->tx_len) == ESP_OK) {
#endif #endif
#ifdef MCU_ESP32 #ifndef MCU_ESP8266
/* for ESP8266 it is done in _esp_wifi_tx_cb */ /* for ESP8266 it is done in _esp_wifi_tx_cb */
_esp_wifi_send_is_in = false; _esp_wifi_send_is_in = false;
netdev->event_callback(netdev, NETDEV_EVENT_TX_COMPLETE); netdev->event_callback(netdev, NETDEV_EVENT_TX_COMPLETE);
@ -872,7 +872,7 @@ void esp_wifi_setup (esp_wifi_netdev_t* dev)
#ifndef MODULE_ESP_NOW #ifndef MODULE_ESP_NOW
/* if module esp_now is used, the following part is already done */ /* if module esp_now is used, the following part is already done */
#ifdef MCU_ESP32 #ifndef MCU_ESP8266
extern portMUX_TYPE g_intr_lock_mux; extern portMUX_TYPE g_intr_lock_mux;
mutex_init(&g_intr_lock_mux); mutex_init(&g_intr_lock_mux);
#endif #endif

View File

@ -45,7 +45,7 @@ extern "C" {
#define RTC_BSS_ATTR __attribute__((section(".rtc.bss"))) #define RTC_BSS_ATTR __attribute__((section(".rtc.bss")))
#endif #endif
#ifndef MCU_ESP32 #ifdef MCU_ESP8266
#ifndef RTC_DATA_ATTR #ifndef RTC_DATA_ATTR
#define RTC_DATA_ATTR __attribute__((section(".rtc.data"))) #define RTC_DATA_ATTR __attribute__((section(".rtc.data")))
#endif #endif

View File

@ -39,12 +39,12 @@ extern "C" {
typedef enum typedef enum
{ {
_GPIO = 0, /**< pin used as standard GPIO */ _GPIO = 0, /**< pin used as standard GPIO */
#ifdef MCU_ESP32 #ifndef MCU_ESP8266
_ADC, /**< pin is used as ADC input */ _ADC, /**< pin is used as ADC input */
_CAN, /**< pin is used as CAN signal */ _CAN, /**< pin is used as CAN signal */
_DAC, /**< pin is used as DAC output */ _DAC, /**< pin is used as DAC output */
_EMAC, /**< pin is used as EMAC signal */ _EMAC, /**< pin is used as EMAC signal */
#endif /* MCU_ESP32 */ #endif /* !MCU_ESP8266 */
_I2C, /**< pin is used as I2C signal */ _I2C, /**< pin is used as I2C signal */
_PWM, /**< pin is used as PWM output */ _PWM, /**< pin is used as PWM output */
_SPI, /**< pin is used as SPI interface */ _SPI, /**< pin is used as SPI interface */

View File

@ -45,7 +45,7 @@
#include "gpio_arch.h" #include "gpio_arch.h"
#include "rom/ets_sys.h" #include "rom/ets_sys.h"
#ifdef MCU_ESP32 #ifndef MCU_ESP8266
#include "soc/gpio_reg.h" #include "soc/gpio_reg.h"
#include "soc/gpio_struct.h" #include "soc/gpio_struct.h"
@ -57,7 +57,7 @@
#define GPIO_SET(l,h,b) if (b < 32) GPIO.l = BIT(b); else GPIO.h.val = BIT(b-32) #define GPIO_SET(l,h,b) if (b < 32) GPIO.l = BIT(b); else GPIO.h.val = BIT(b-32)
#define GPIO_GET(l,h,b) ((b < 32) ? GPIO.l & BIT(b) : GPIO.h.val & BIT(b-32)) #define GPIO_GET(l,h,b) ((b < 32) ? GPIO.l & BIT(b) : GPIO.h.val & BIT(b-32))
#else /* MCU_ESP32 */ #else /* MCU_ESP8266 */
#include "esp/gpio_regs.h" #include "esp/gpio_regs.h"
#include "sdk/ets.h" #include "sdk/ets.h"
@ -79,7 +79,7 @@
extern uint8_t system_get_cpu_freq(void); extern uint8_t system_get_cpu_freq(void);
extern bool system_update_cpu_freq(uint8_t freq); extern bool system_update_cpu_freq(uint8_t freq);
#endif /* MCU_ESP32 */ #endif /* MCU_ESP8266 */
typedef struct typedef struct
{ {
@ -203,7 +203,7 @@ void i2c_init(i2c_t dev)
} }
/* Configure and initialize SDA and SCL pin. */ /* Configure and initialize SDA and SCL pin. */
#ifdef MCU_ESP32 #ifndef MCU_ESP8266
/* /*
* ESP32 pins are used in input/output mode with open-drain output driver. * ESP32 pins are used in input/output mode with open-drain output driver.
* Signal levels are then realized as following: * Signal levels are then realized as following:
@ -225,7 +225,7 @@ void i2c_init(i2c_t dev)
} }
gpio_set(i2c_config[dev].sda); gpio_set(i2c_config[dev].sda);
#else /* MCU_ESP32 */ #else /* !MCU_ESP8266 */
/* /*
* Due to critical timing required by the I2C software implementation, * Due to critical timing required by the I2C software implementation,
* the ESP8266 GPIOs can not be used directly in GPIO_OD_PU mode. * the ESP8266 GPIOs can not be used directly in GPIO_OD_PU mode.
@ -245,7 +245,7 @@ void i2c_init(i2c_t dev)
gpio_init(_i2c_bus[dev].sda, GPIO_IN_PU)) { gpio_init(_i2c_bus[dev].sda, GPIO_IN_PU)) {
return; return;
} }
#endif /* MCU_ESP32 */ #endif /* !MCU_ESP8266 */
/* store the usage type in GPIO table */ /* store the usage type in GPIO table */
gpio_set_pin_usage(_i2c_bus[dev].scl, _I2C); gpio_set_pin_usage(_i2c_bus[dev].scl, _I2C);
@ -438,29 +438,29 @@ static inline void _i2c_delay(_i2c_bus_t* bus)
static inline bool _i2c_scl_read(_i2c_bus_t* bus) static inline bool _i2c_scl_read(_i2c_bus_t* bus)
{ {
/* read SCL status (pin is in open-drain mode and set) */ /* read SCL status (pin is in open-drain mode and set) */
#ifdef MCU_ESP32 #ifndef MCU_ESP8266
return GPIO_GET(in, in1, bus->scl); return GPIO_GET(in, in1, bus->scl);
#else /* MCU_ESP32 */ #else /* !MCU_ESP8266 */
return GPIO.IN & bus->scl_bit; return GPIO.IN & bus->scl_bit;
#endif /* MCU_ESP32 */ #endif /* !MCU_ESP8266 */
} }
static inline bool _i2c_sda_read(_i2c_bus_t* bus) static inline bool _i2c_sda_read(_i2c_bus_t* bus)
{ {
/* read SDA status (pin is in open-drain mode and set) */ /* read SDA status (pin is in open-drain mode and set) */
#ifdef MCU_ESP32 #ifndef MCU_ESP8266
return GPIO_GET(in, in1, bus->sda); return GPIO_GET(in, in1, bus->sda);
#else /* MCU_ESP32 */ #else /* !MCU_ESP8266 */
return GPIO.IN & bus->sda_bit; return GPIO.IN & bus->sda_bit;
#endif /* MCU_ESP32 */ #endif /* !MCU_ESP8266 */
} }
static inline void _i2c_scl_high(_i2c_bus_t* bus) static inline void _i2c_scl_high(_i2c_bus_t* bus)
{ {
#ifdef MCU_ESP32 #ifndef MCU_ESP8266
/* set SCL signal high (pin is in open-drain mode and pulled-up) */ /* set SCL signal high (pin is in open-drain mode and pulled-up) */
GPIO_SET(out_w1ts, out1_w1ts, bus->scl); GPIO_SET(out_w1ts, out1_w1ts, bus->scl);
#else /* MCU_ESP32 */ #else /* !MCU_ESP8266 */
#if I2C_CLOCK_STRETCH > 0 #if I2C_CLOCK_STRETCH > 0
/* /*
* set SCL signal high (switch back to GPIO_IN_PU mode, that is the pin is * set SCL signal high (switch back to GPIO_IN_PU mode, that is the pin is
@ -471,15 +471,15 @@ static inline void _i2c_scl_high(_i2c_bus_t* bus)
/* No clock stretching supported, always drive the SCL pin. */ /* No clock stretching supported, always drive the SCL pin. */
GPIO.OUT_SET = bus->scl_bit; GPIO.OUT_SET = bus->scl_bit;
#endif /* I2C_CLOCK_STRETCH > 0 */ #endif /* I2C_CLOCK_STRETCH > 0 */
#endif /* MCU_ESP32 */ #endif /* !MCU_ESP8266 */
} }
static inline void _i2c_scl_low(_i2c_bus_t* bus) static inline void _i2c_scl_low(_i2c_bus_t* bus)
{ {
#ifdef MCU_ESP32 #ifndef MCU_ESP8266
/* set SCL signal low (actively driven to low) */ /* set SCL signal low (actively driven to low) */
GPIO_SET(out_w1tc, out1_w1tc, bus->scl); GPIO_SET(out_w1tc, out1_w1tc, bus->scl);
#else /* MCU_ESP32 */ #else /* !MCU_ESP8266 */
#if I2C_CLOCK_STRETCH > 0 #if I2C_CLOCK_STRETCH > 0
/* /*
* set SCL signal low (switch temporarily to GPIO_OD_PU where the * set SCL signal low (switch temporarily to GPIO_OD_PU where the
@ -490,35 +490,35 @@ static inline void _i2c_scl_low(_i2c_bus_t* bus)
/* No clock stretching supported, always drive the SCL pin. */ /* No clock stretching supported, always drive the SCL pin. */
GPIO.OUT_CLEAR = bus->scl_bit; GPIO.OUT_CLEAR = bus->scl_bit;
#endif /* I2C_CLOCK_STRETCH > 0 */ #endif /* I2C_CLOCK_STRETCH > 0 */
#endif /* MCU_ESP32 */ #endif /* !MCU_ESP8266 */
} }
static inline void _i2c_sda_high(_i2c_bus_t* bus) static inline void _i2c_sda_high(_i2c_bus_t* bus)
{ {
#ifdef MCU_ESP32 #ifndef MCU_ESP8266
/* set SDA signal high (pin is in open-drain mode and pulled-up) */ /* set SDA signal high (pin is in open-drain mode and pulled-up) */
GPIO_SET(out_w1ts, out1_w1ts, bus->sda); GPIO_SET(out_w1ts, out1_w1ts, bus->sda);
#else /* MCU_ESP32 */ #else /* !MCU_ESP8266 */
/* /*
* set SDA signal high (switch back to GPIO_IN_PU mode, that is the pin is * set SDA signal high (switch back to GPIO_IN_PU mode, that is the pin is
* in open-drain mode and pulled-up to high) * in open-drain mode and pulled-up to high)
*/ */
GPIO.ENABLE_OUT_CLEAR = bus->sda_bit; GPIO.ENABLE_OUT_CLEAR = bus->sda_bit;
#endif /* MCU_ESP32 */ #endif /* !MCU_ESP8266 */
} }
static inline void _i2c_sda_low(_i2c_bus_t* bus) static inline void _i2c_sda_low(_i2c_bus_t* bus)
{ {
#ifdef MCU_ESP32 #ifndef MCU_ESP8266
/* set SDA signal low (actively driven to low) */ /* set SDA signal low (actively driven to low) */
GPIO_SET(out_w1tc, out1_w1tc, bus->sda); GPIO_SET(out_w1tc, out1_w1tc, bus->sda);
#else /* MCU_ESP32 */ #else /* !MCU_ESP8266 */
/* /*
* set SDA signal low (switch temporarily to GPIO_OD_PU where the * set SDA signal low (switch temporarily to GPIO_OD_PU where the
* written output value 0 drives the pin actively to low) * written output value 0 drives the pin actively to low)
*/ */
GPIO.ENABLE_OUT_SET = bus->sda_bit; GPIO.ENABLE_OUT_SET = bus->sda_bit;
#endif /* MCU_ESP32 */ #endif /* !MCU_ESP8266 */
} }
static void _i2c_clear(_i2c_bus_t* bus) static void _i2c_clear(_i2c_bus_t* bus)