diff --git a/cpu/esp32/bootloader/sdkconfig.h b/cpu/esp32/bootloader/sdkconfig.h index 64068ae60b..27fead5ab1 100644 --- a/cpu/esp32/bootloader/sdkconfig.h +++ b/cpu/esp32/bootloader/sdkconfig.h @@ -37,7 +37,6 @@ #error "ESP32x family implementation missing" #endif - #ifdef __cplusplus extern "C" { #endif diff --git a/cpu/esp32/include/periph_cpu_esp32.h b/cpu/esp32/include/periph_cpu_esp32.h index e89e59cafa..9bdda88cad 100644 --- a/cpu/esp32/include/periph_cpu_esp32.h +++ b/cpu/esp32/include/periph_cpu_esp32.h @@ -27,44 +27,44 @@ extern "C" { * @name Predefined GPIO names * @{ */ -#define GPIO0 (GPIO_PIN(PORT_GPIO,0)) -#define GPIO1 (GPIO_PIN(PORT_GPIO,1)) -#define GPIO2 (GPIO_PIN(PORT_GPIO,2)) -#define GPIO3 (GPIO_PIN(PORT_GPIO,3)) -#define GPIO4 (GPIO_PIN(PORT_GPIO,4)) -#define GPIO5 (GPIO_PIN(PORT_GPIO,5)) -#define GPIO6 (GPIO_PIN(PORT_GPIO,6)) -#define GPIO7 (GPIO_PIN(PORT_GPIO,7)) -#define GPIO8 (GPIO_PIN(PORT_GPIO,8)) -#define GPIO9 (GPIO_PIN(PORT_GPIO,9)) -#define GPIO10 (GPIO_PIN(PORT_GPIO,10)) -#define GPIO11 (GPIO_PIN(PORT_GPIO,11)) -#define GPIO12 (GPIO_PIN(PORT_GPIO,12)) -#define GPIO13 (GPIO_PIN(PORT_GPIO,13)) -#define GPIO14 (GPIO_PIN(PORT_GPIO,14)) -#define GPIO15 (GPIO_PIN(PORT_GPIO,15)) -#define GPIO16 (GPIO_PIN(PORT_GPIO,16)) -#define GPIO17 (GPIO_PIN(PORT_GPIO,17)) -#define GPIO18 (GPIO_PIN(PORT_GPIO,18)) -#define GPIO19 (GPIO_PIN(PORT_GPIO,19)) +#define GPIO0 (GPIO_PIN(PORT_GPIO, 0)) +#define GPIO1 (GPIO_PIN(PORT_GPIO, 1)) +#define GPIO2 (GPIO_PIN(PORT_GPIO, 2)) +#define GPIO3 (GPIO_PIN(PORT_GPIO, 3)) +#define GPIO4 (GPIO_PIN(PORT_GPIO, 4)) +#define GPIO5 (GPIO_PIN(PORT_GPIO, 5)) +#define GPIO6 (GPIO_PIN(PORT_GPIO, 6)) +#define GPIO7 (GPIO_PIN(PORT_GPIO, 7)) +#define GPIO8 (GPIO_PIN(PORT_GPIO, 8)) +#define GPIO9 (GPIO_PIN(PORT_GPIO, 9)) +#define GPIO10 (GPIO_PIN(PORT_GPIO, 10)) +#define GPIO11 (GPIO_PIN(PORT_GPIO, 11)) +#define GPIO12 (GPIO_PIN(PORT_GPIO, 12)) +#define GPIO13 (GPIO_PIN(PORT_GPIO, 13)) +#define GPIO14 (GPIO_PIN(PORT_GPIO, 14)) +#define GPIO15 (GPIO_PIN(PORT_GPIO, 15)) +#define GPIO16 (GPIO_PIN(PORT_GPIO, 16)) +#define GPIO17 (GPIO_PIN(PORT_GPIO, 17)) +#define GPIO18 (GPIO_PIN(PORT_GPIO, 18)) +#define GPIO19 (GPIO_PIN(PORT_GPIO, 19)) /* GPIO 20 is not available */ -#define GPIO21 (GPIO_PIN(PORT_GPIO,21)) -#define GPIO22 (GPIO_PIN(PORT_GPIO,22)) -#define GPIO23 (GPIO_PIN(PORT_GPIO,23)) +#define GPIO21 (GPIO_PIN(PORT_GPIO, 21)) +#define GPIO22 (GPIO_PIN(PORT_GPIO, 22)) +#define GPIO23 (GPIO_PIN(PORT_GPIO, 23)) /* GPIO 24 is not available */ -#define GPIO25 (GPIO_PIN(PORT_GPIO,25)) -#define GPIO26 (GPIO_PIN(PORT_GPIO,26)) -#define GPIO27 (GPIO_PIN(PORT_GPIO,27)) +#define GPIO25 (GPIO_PIN(PORT_GPIO, 25)) +#define GPIO26 (GPIO_PIN(PORT_GPIO, 26)) +#define GPIO27 (GPIO_PIN(PORT_GPIO, 27)) /* GPIOs 28 ...32 are not available */ -#define GPIO32 (GPIO_PIN(PORT_GPIO,32)) -#define GPIO33 (GPIO_PIN(PORT_GPIO,33)) +#define GPIO32 (GPIO_PIN(PORT_GPIO, 32)) +#define GPIO33 (GPIO_PIN(PORT_GPIO, 33)) /* GPIOs 34 ... 39 can only be used as inputs and do not have pullups/pulldowns */ -#define GPIO34 (GPIO_PIN(PORT_GPIO,34)) -#define GPIO35 (GPIO_PIN(PORT_GPIO,35)) -#define GPIO36 (GPIO_PIN(PORT_GPIO,36)) -#define GPIO37 (GPIO_PIN(PORT_GPIO,37)) -#define GPIO38 (GPIO_PIN(PORT_GPIO,38)) -#define GPIO39 (GPIO_PIN(PORT_GPIO,39)) +#define GPIO34 (GPIO_PIN(PORT_GPIO, 34)) +#define GPIO35 (GPIO_PIN(PORT_GPIO, 35)) +#define GPIO36 (GPIO_PIN(PORT_GPIO, 36)) +#define GPIO37 (GPIO_PIN(PORT_GPIO, 37)) +#define GPIO38 (GPIO_PIN(PORT_GPIO, 38)) +#define GPIO39 (GPIO_PIN(PORT_GPIO, 39)) /** @} */ /** diff --git a/cpu/esp32/periph/adc_arch_esp32.c b/cpu/esp32/periph/adc_arch_esp32.c index 1a9182be21..881fe5c12f 100644 --- a/cpu/esp32/periph/adc_arch_esp32.c +++ b/cpu/esp32/periph/adc_arch_esp32.c @@ -24,7 +24,6 @@ #include "esp_common.h" #include "soc/adc_channel.h" - #define ENABLE_DEBUG 0 #include "debug.h" diff --git a/cpu/esp32/periph/gpio.c b/cpu/esp32/periph/gpio.c index b7659db7b5..2e3c3f345e 100644 --- a/cpu/esp32/periph/gpio.c +++ b/cpu/esp32/periph/gpio.c @@ -84,9 +84,9 @@ static bool _gpio_pin_pd[GPIO_PIN_NUMOF] = { }; #if defined(CPU_FAM_ESP32) #define GPIO_IN_GET(b) (b < 32) ? GPIO.in & BIT(b) : GPIO.in1.val & BIT(b-32) -#define GPIO_OUT_SET(b) if (b < 32) GPIO.out_w1ts = BIT(b); else GPIO.out1_w1ts.val = BIT(b-32) -#define GPIO_OUT_CLR(b) if (b < 32) GPIO.out_w1tc = BIT(b); else GPIO.out1_w1tc.val = BIT(b-32) -#define GPIO_OUT_XOR(b) if (b < 32) GPIO.out ^= BIT(b); else GPIO.out1.val ^= BIT(b-32) +#define GPIO_OUT_SET(b) if (b < 32) { GPIO.out_w1ts = BIT(b); } else { GPIO.out1_w1ts.val = BIT(b-32); } +#define GPIO_OUT_CLR(b) if (b < 32) { GPIO.out_w1tc = BIT(b); } else { GPIO.out1_w1tc.val = BIT(b-32); } +#define GPIO_OUT_XOR(b) if (b < 32) { GPIO.out ^= BIT(b); } else { GPIO.out1.val ^= BIT(b-32); } #define GPIO_OUT_GET(b) (b < 32) ? (GPIO.out >> b) & 1 : (GPIO.out1.val >> (b-32)) & 1 #else diff --git a/cpu/esp32/periph/spi.c b/cpu/esp32/periph/spi.c index 1def1797d1..6f3f8d3613 100644 --- a/cpu/esp32/periph/spi.c +++ b/cpu/esp32/periph/spi.c @@ -316,7 +316,7 @@ void spi_print_config(void) { for (unsigned bus = 0; bus < SPI_NUMOF; bus++) { printf("\tSPI_DEV(%u)\t%s ", bus, _spi_names[_spi[bus].hostid]); - printf("sck=%d " , spi_config[bus].sck); + printf("sck=%d ", spi_config[bus].sck); printf("miso=%d ", spi_config[bus].miso); printf("mosi=%d ", spi_config[bus].mosi); printf("cs0=%d\n", spi_config[bus].cs); diff --git a/cpu/esp32/syscalls.c b/cpu/esp32/syscalls.c index a8f93f46d1..d92d81c15d 100644 --- a/cpu/esp32/syscalls.c +++ b/cpu/esp32/syscalls.c @@ -110,7 +110,7 @@ void _exit_r(struct _reent *r, int status) #if !IS_USED(MODULE_VFS) int _fcntl_r(struct _reent *r, int fd, int cmd, int arg) - __attribute__((weak,alias("_no_sys_func"))); + __attribute__((weak, alias("_no_sys_func"))); #endif #ifndef CLOCK_REALTIME diff --git a/cpu/esp8266/periph/spi.c b/cpu/esp8266/periph/spi.c index 6beb525bee..4782593e93 100644 --- a/cpu/esp8266/periph/spi.c +++ b/cpu/esp8266/periph/spi.c @@ -323,10 +323,10 @@ void spi_print_config(void) { for (unsigned bus = 0; bus < SPI_NUMOF; bus++) { printf("\tSPI_DEV(%u)\t%s ", bus, _spi_names[spi_config[bus].ctrl]); - printf("sck=%d " , spi_config[bus].sck); + printf("sck=%d ", spi_config[bus].sck); printf("miso=%d ", spi_config[bus].miso); printf("mosi=%d ", spi_config[bus].mosi); - printf("cs=%d\n" , spi_config[bus].cs); + printf("cs=%d\n", spi_config[bus].cs); } } diff --git a/cpu/esp_common/esp-wifi/esp_wifi_netdev.c b/cpu/esp_common/esp-wifi/esp_wifi_netdev.c index 26b162317f..a621cbbce6 100644 --- a/cpu/esp_common/esp-wifi/esp_wifi_netdev.c +++ b/cpu/esp_common/esp-wifi/esp_wifi_netdev.c @@ -959,8 +959,7 @@ void esp_wifi_setup (esp_wifi_netdev_t* dev) esp_wifi_sta_wpa2_ent_set_password((const unsigned char *)ESP_WIFI_EAP_PASS, strlen(ESP_WIFI_EAP_PASS)); #else /* defined(ESP_WIFI_EAP_USER) && defined(ESP_WIFI_EAP_PASS) */ -#error ESP_WIFI_EAP_USER and ESP_WIFI_EAP_PASS have to define the user name \ - and the password for EAP phase 2 authentication in esp_wifi_enterprise +#error "ESP_WIFI_EAP_USER and ESP_WIFI_EAP_PASS have to be defined for EAP phase 2 authentication" #endif /* defined(ESP_WIFI_EAP_USER) && defined(ESP_WIFI_EAP_PASS) */ esp_wifi_sta_wpa2_ent_enable(); #endif /* defined(MODULE_ESP_WIFI_ENTERPRISE) && !defined(MODULE_ESP_WIFI_AP) */ diff --git a/cpu/esp_common/freertos/task.c b/cpu/esp_common/freertos/task.c index 9834e47eab..285bab2298 100644 --- a/cpu/esp_common/freertos/task.c +++ b/cpu/esp_common/freertos/task.c @@ -33,11 +33,11 @@ #include "freertos/FreeRTOS.h" #include "freertos/task.h" -#define MHZ 1000000 - #ifdef MCU_ESP8266 #include "rom/ets_sys.h" +#endif +#ifndef PRO_CPU_NUM #define PRO_CPU_NUM (0) #endif @@ -371,7 +371,7 @@ BaseType_t xTaskNotifyWait(uint32_t ulBitsToClearOnEntry, { kernel_pid_t pid = thread_getpid(); - DEBUG("%s task=%d entry=%08"PRIx32" exit=%08"PRIx32" wait=%u\n", __func__, + DEBUG("%s task=%d entry=%08"PRIx32" exit=%08"PRIx32" wait=%"PRIu32"\n", __func__, pid, ulBitsToClearOnEntry, ulBitsToClearOnExit, xTicksToWait); assert(pid_is_valid(pid)); diff --git a/cpu/esp_common/include/esp_common.h b/cpu/esp_common/include/esp_common.h index 7df0002fa5..5c35864d69 100644 --- a/cpu/esp_common/include/esp_common.h +++ b/cpu/esp_common/include/esp_common.h @@ -65,7 +65,7 @@ extern "C" { * @param cond the condition * @param err the return value in the case the condition is not fulfilled. */ -#define CHECK_PARAM_RET(cond,err) if (!(cond)) \ +#define CHECK_PARAM_RET(cond, err) if (!(cond)) \ { \ DEBUG("%s parameter condition (" #cond ") " \ "not fulfilled\n", __func__); \ @@ -88,19 +88,19 @@ extern "C" { #else /* ENABLE_DEBUG */ -#define CHECK_PARAM_RET(cond,err) if (!(cond)) return err; -#define CHECK_PARAM(cond) if (!(cond)) return; +#define CHECK_PARAM_RET(cond, err) if (!(cond)) { return err; } +#define CHECK_PARAM(cond) if (!(cond)) { return; } #endif /* ENABLE_DEBUG */ /** gives the minimum of a and b */ #ifndef MIN -#define MIN(a,b) ((a) < (b) ? (a) : (b)) +#define MIN(a, b) ((a) < (b) ? (a) : (b)) #endif /** gives the maximum of a and b */ #ifndef MAX -#define MAX(a,b) ((a) > (b) ? (a) : (b)) +#define MAX(a, b) ((a) > (b) ? (a) : (b)) #endif /** diff --git a/cpu/esp_common/include/esp_common_log.h b/cpu/esp_common/include/esp_common_log.h index c64855a75a..548c3e00c3 100644 --- a/cpu/esp_common/include/esp_common_log.h +++ b/cpu/esp_common/include/esp_common_log.h @@ -64,14 +64,14 @@ extern int ets_printf(const char *fmt, ...); printf(LOG_FORMAT(letter, format), system_get_time_ms(), tag, ##__VA_ARGS__); \ fflush(stdout); \ } \ - } while(0) + } while (0) #define LOG_TAG_EARLY(level, letter, tag, format, ...) \ do { \ if (LOG_LEVEL >= level) { \ ets_printf(LOG_FORMAT(letter, format), system_get_time_ms(), tag, ##__VA_ARGS__); \ } \ - } while(0) + } while (0) #else /* MODULE_ESP_LOG_TAGGED */ @@ -105,32 +105,32 @@ extern int ets_printf(const char *fmt, ...); #undef LOG_INFO #undef LOG_WARNING #undef LOG_DEBUG -#define LOG_ERROR(format, ...) LOG_TAG(LOG_ERROR , E, __func__, format, ##__VA_ARGS__) +#define LOG_ERROR(format, ...) LOG_TAG(LOG_ERROR, E, __func__, format, ##__VA_ARGS__) #define LOG_WARNING(format, ...) LOG_TAG(LOG_WARNING, W, __func__, format, ##__VA_ARGS__) -#define LOG_INFO(format, ...) LOG_TAG(LOG_INFO , I, __func__, format, ##__VA_ARGS__) -#define LOG_DEBUG(format, ...) LOG_TAG(LOG_DEBUG , D, __func__, format, ##__VA_ARGS__) +#define LOG_INFO(format, ...) LOG_TAG(LOG_INFO, I, __func__, format, ##__VA_ARGS__) +#define LOG_DEBUG(format, ...) LOG_TAG(LOG_DEBUG, D, __func__, format, ##__VA_ARGS__) #endif /** Tagged LOG_* definitions */ -#define LOG_TAG_ERROR(tag, format, ...) LOG_TAG(LOG_ERROR , E, tag, format, ##__VA_ARGS__) +#define LOG_TAG_ERROR(tag, format, ...) LOG_TAG(LOG_ERROR, E, tag, format, ##__VA_ARGS__) #define LOG_TAG_WARNING(tag, format, ...) LOG_TAG(LOG_WARNING, W, tag, format, ##__VA_ARGS__) -#define LOG_TAG_INFO(tag, format, ...) LOG_TAG(LOG_INFO , I, tag, format, ##__VA_ARGS__) -#define LOG_TAG_DEBUG(tag, format, ...) LOG_TAG(LOG_DEBUG , D, tag, format, ##__VA_ARGS__) -#define LOG_TAG_ALL(tag, format, ...) LOG_TAG(LOG_ALL , V, tag, format, ##__VA_ARGS__) +#define LOG_TAG_INFO(tag, format, ...) LOG_TAG(LOG_INFO, I, tag, format, ##__VA_ARGS__) +#define LOG_TAG_DEBUG(tag, format, ...) LOG_TAG(LOG_DEBUG, D, tag, format, ##__VA_ARGS__) +#define LOG_TAG_ALL(tag, format, ...) LOG_TAG(LOG_ALL, V, tag, format, ##__VA_ARGS__) /** definitions for source code compatibility with ESP-IDF */ -#define ESP_EARLY_LOGE(tag, format, ...) LOG_TAG_EARLY(LOG_ERROR , E, tag, format "\n", ##__VA_ARGS__) +#define ESP_EARLY_LOGE(tag, format, ...) LOG_TAG_EARLY(LOG_ERROR, E, tag, format "\n", ##__VA_ARGS__) #define ESP_EARLY_LOGW(tag, format, ...) LOG_TAG_EARLY(LOG_WARNING, W, tag, format "\n", ##__VA_ARGS__) -#define ESP_EARLY_LOGI(tag, format, ...) LOG_TAG_EARLY(LOG_INFO , I, tag, format "\n", ##__VA_ARGS__) +#define ESP_EARLY_LOGI(tag, format, ...) LOG_TAG_EARLY(LOG_INFO, I, tag, format "\n", ##__VA_ARGS__) #define ESP_EARLY_LOGD(tag, format, ...) LOG_TAG_EARLY(LOG_DEBUG, D, tag, format "\n", ##__VA_ARGS__) -#define ESP_EARLY_LOGV(tag, format, ...) LOG_TAG_EARLY(LOG_ALL , V, tag, format "\n", ##__VA_ARGS__) +#define ESP_EARLY_LOGV(tag, format, ...) LOG_TAG_EARLY(LOG_ALL, V, tag, format "\n", ##__VA_ARGS__) #ifdef MCU_ESP8266 -#define ESP_LOGE(tag, format, ...) LOG_TAG(LOG_ERROR , E, tag, format "\n", ##__VA_ARGS__) +#define ESP_LOGE(tag, format, ...) LOG_TAG(LOG_ERROR, E, tag, format "\n", ##__VA_ARGS__) #define ESP_LOGW(tag, format, ...) LOG_TAG(LOG_WARNING, W, tag, format "\n", ##__VA_ARGS__) -#define ESP_LOGI(tag, format, ...) LOG_TAG(LOG_INFO , I, tag, format "\n", ##__VA_ARGS__) +#define ESP_LOGI(tag, format, ...) LOG_TAG(LOG_INFO, I, tag, format "\n", ##__VA_ARGS__) #define ESP_LOGD(tag, format, ...) LOG_TAG(LOG_DEBUG, D, tag, format "\n", ##__VA_ARGS__) -#define ESP_LOGV(tag, format, ...) LOG_TAG(LOG_ALL , V, tag, format "\n", ##__VA_ARGS__) +#define ESP_LOGV(tag, format, ...) LOG_TAG(LOG_ALL, V, tag, format "\n", ##__VA_ARGS__) #endif #ifdef __cplusplus diff --git a/cpu/esp_common/include/gpio_arch_common.h b/cpu/esp_common/include/gpio_arch_common.h index f4b1541880..3bdbed000b 100644 --- a/cpu/esp_common/include/gpio_arch_common.h +++ b/cpu/esp_common/include/gpio_arch_common.h @@ -36,8 +36,7 @@ extern "C" { /** * @brief Definition of possible GPIO usage types (for internal use only) */ -typedef enum -{ +typedef enum { _GPIO = 0, /**< pin used as standard GPIO */ #ifndef MCU_ESP8266 _ADC, /**< pin is used as ADC input */ diff --git a/cpu/esp_common/periph/i2c_sw.c b/cpu/esp_common/periph/i2c_sw.c index 2fc141ca4f..9057dbadff 100644 --- a/cpu/esp_common/periph/i2c_sw.c +++ b/cpu/esp_common/periph/i2c_sw.c @@ -59,8 +59,8 @@ #define I2C_CLOCK_STRETCH 200 /* gpio access macros */ -#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_SET(lo, hi, b) if (b < 32) { GPIO.lo = BIT(b); } else { GPIO.hi.val = BIT(b-32); } +#define GPIO_GET(lo, hi, b) ((b < 32) ? GPIO.lo & BIT(b) : GPIO.hi.val & BIT(b-32)) #else /* MCU_ESP8266 */ @@ -86,8 +86,7 @@ extern bool system_update_cpu_freq(uint8_t freq); #endif /* MCU_ESP8266 */ -typedef struct -{ +typedef struct { i2c_speed_t speed; i2c_t dev;