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

cpu/esp*: cleanups mainly to reduce the vera++ warnings

This commit is contained in:
Gunar Schorcht 2022-06-02 16:05:43 +02:00
parent 0ddb6022f3
commit a24ddb8517
13 changed files with 69 additions and 74 deletions

View File

@ -37,7 +37,6 @@
#error "ESP32x family implementation missing" #error "ESP32x family implementation missing"
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif

View File

@ -27,44 +27,44 @@ extern "C" {
* @name Predefined GPIO names * @name Predefined GPIO names
* @{ * @{
*/ */
#define GPIO0 (GPIO_PIN(PORT_GPIO,0)) #define GPIO0 (GPIO_PIN(PORT_GPIO, 0))
#define GPIO1 (GPIO_PIN(PORT_GPIO,1)) #define GPIO1 (GPIO_PIN(PORT_GPIO, 1))
#define GPIO2 (GPIO_PIN(PORT_GPIO,2)) #define GPIO2 (GPIO_PIN(PORT_GPIO, 2))
#define GPIO3 (GPIO_PIN(PORT_GPIO,3)) #define GPIO3 (GPIO_PIN(PORT_GPIO, 3))
#define GPIO4 (GPIO_PIN(PORT_GPIO,4)) #define GPIO4 (GPIO_PIN(PORT_GPIO, 4))
#define GPIO5 (GPIO_PIN(PORT_GPIO,5)) #define GPIO5 (GPIO_PIN(PORT_GPIO, 5))
#define GPIO6 (GPIO_PIN(PORT_GPIO,6)) #define GPIO6 (GPIO_PIN(PORT_GPIO, 6))
#define GPIO7 (GPIO_PIN(PORT_GPIO,7)) #define GPIO7 (GPIO_PIN(PORT_GPIO, 7))
#define GPIO8 (GPIO_PIN(PORT_GPIO,8)) #define GPIO8 (GPIO_PIN(PORT_GPIO, 8))
#define GPIO9 (GPIO_PIN(PORT_GPIO,9)) #define GPIO9 (GPIO_PIN(PORT_GPIO, 9))
#define GPIO10 (GPIO_PIN(PORT_GPIO,10)) #define GPIO10 (GPIO_PIN(PORT_GPIO, 10))
#define GPIO11 (GPIO_PIN(PORT_GPIO,11)) #define GPIO11 (GPIO_PIN(PORT_GPIO, 11))
#define GPIO12 (GPIO_PIN(PORT_GPIO,12)) #define GPIO12 (GPIO_PIN(PORT_GPIO, 12))
#define GPIO13 (GPIO_PIN(PORT_GPIO,13)) #define GPIO13 (GPIO_PIN(PORT_GPIO, 13))
#define GPIO14 (GPIO_PIN(PORT_GPIO,14)) #define GPIO14 (GPIO_PIN(PORT_GPIO, 14))
#define GPIO15 (GPIO_PIN(PORT_GPIO,15)) #define GPIO15 (GPIO_PIN(PORT_GPIO, 15))
#define GPIO16 (GPIO_PIN(PORT_GPIO,16)) #define GPIO16 (GPIO_PIN(PORT_GPIO, 16))
#define GPIO17 (GPIO_PIN(PORT_GPIO,17)) #define GPIO17 (GPIO_PIN(PORT_GPIO, 17))
#define GPIO18 (GPIO_PIN(PORT_GPIO,18)) #define GPIO18 (GPIO_PIN(PORT_GPIO, 18))
#define GPIO19 (GPIO_PIN(PORT_GPIO,19)) #define GPIO19 (GPIO_PIN(PORT_GPIO, 19))
/* GPIO 20 is not available */ /* GPIO 20 is not available */
#define GPIO21 (GPIO_PIN(PORT_GPIO,21)) #define GPIO21 (GPIO_PIN(PORT_GPIO, 21))
#define GPIO22 (GPIO_PIN(PORT_GPIO,22)) #define GPIO22 (GPIO_PIN(PORT_GPIO, 22))
#define GPIO23 (GPIO_PIN(PORT_GPIO,23)) #define GPIO23 (GPIO_PIN(PORT_GPIO, 23))
/* GPIO 24 is not available */ /* GPIO 24 is not available */
#define GPIO25 (GPIO_PIN(PORT_GPIO,25)) #define GPIO25 (GPIO_PIN(PORT_GPIO, 25))
#define GPIO26 (GPIO_PIN(PORT_GPIO,26)) #define GPIO26 (GPIO_PIN(PORT_GPIO, 26))
#define GPIO27 (GPIO_PIN(PORT_GPIO,27)) #define GPIO27 (GPIO_PIN(PORT_GPIO, 27))
/* GPIOs 28 ...32 are not available */ /* GPIOs 28 ...32 are not available */
#define GPIO32 (GPIO_PIN(PORT_GPIO,32)) #define GPIO32 (GPIO_PIN(PORT_GPIO, 32))
#define GPIO33 (GPIO_PIN(PORT_GPIO,33)) #define GPIO33 (GPIO_PIN(PORT_GPIO, 33))
/* GPIOs 34 ... 39 can only be used as inputs and do not have pullups/pulldowns */ /* GPIOs 34 ... 39 can only be used as inputs and do not have pullups/pulldowns */
#define GPIO34 (GPIO_PIN(PORT_GPIO,34)) #define GPIO34 (GPIO_PIN(PORT_GPIO, 34))
#define GPIO35 (GPIO_PIN(PORT_GPIO,35)) #define GPIO35 (GPIO_PIN(PORT_GPIO, 35))
#define GPIO36 (GPIO_PIN(PORT_GPIO,36)) #define GPIO36 (GPIO_PIN(PORT_GPIO, 36))
#define GPIO37 (GPIO_PIN(PORT_GPIO,37)) #define GPIO37 (GPIO_PIN(PORT_GPIO, 37))
#define GPIO38 (GPIO_PIN(PORT_GPIO,38)) #define GPIO38 (GPIO_PIN(PORT_GPIO, 38))
#define GPIO39 (GPIO_PIN(PORT_GPIO,39)) #define GPIO39 (GPIO_PIN(PORT_GPIO, 39))
/** @} */ /** @} */
/** /**

View File

@ -24,7 +24,6 @@
#include "esp_common.h" #include "esp_common.h"
#include "soc/adc_channel.h" #include "soc/adc_channel.h"
#define ENABLE_DEBUG 0 #define ENABLE_DEBUG 0
#include "debug.h" #include "debug.h"

View File

@ -84,9 +84,9 @@ static bool _gpio_pin_pd[GPIO_PIN_NUMOF] = { };
#if defined(CPU_FAM_ESP32) #if defined(CPU_FAM_ESP32)
#define GPIO_IN_GET(b) (b < 32) ? GPIO.in & BIT(b) : GPIO.in1.val & BIT(b-32) #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_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_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_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 #define GPIO_OUT_GET(b) (b < 32) ? (GPIO.out >> b) & 1 : (GPIO.out1.val >> (b-32)) & 1
#else #else

View File

@ -316,7 +316,7 @@ void spi_print_config(void)
{ {
for (unsigned bus = 0; bus < SPI_NUMOF; bus++) { for (unsigned bus = 0; bus < SPI_NUMOF; bus++) {
printf("\tSPI_DEV(%u)\t%s ", bus, _spi_names[_spi[bus].hostid]); 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("miso=%d ", spi_config[bus].miso);
printf("mosi=%d ", spi_config[bus].mosi); printf("mosi=%d ", spi_config[bus].mosi);
printf("cs0=%d\n", spi_config[bus].cs); printf("cs0=%d\n", spi_config[bus].cs);

View File

@ -110,7 +110,7 @@ void _exit_r(struct _reent *r, int status)
#if !IS_USED(MODULE_VFS) #if !IS_USED(MODULE_VFS)
int _fcntl_r(struct _reent *r, int fd, int cmd, int arg) 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 #endif
#ifndef CLOCK_REALTIME #ifndef CLOCK_REALTIME

View File

@ -323,10 +323,10 @@ void spi_print_config(void)
{ {
for (unsigned bus = 0; bus < SPI_NUMOF; bus++) { for (unsigned bus = 0; bus < SPI_NUMOF; bus++) {
printf("\tSPI_DEV(%u)\t%s ", bus, _spi_names[spi_config[bus].ctrl]); 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("miso=%d ", spi_config[bus].miso);
printf("mosi=%d ", spi_config[bus].mosi); printf("mosi=%d ", spi_config[bus].mosi);
printf("cs=%d\n" , spi_config[bus].cs); printf("cs=%d\n", spi_config[bus].cs);
} }
} }

View File

@ -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, esp_wifi_sta_wpa2_ent_set_password((const unsigned char *)ESP_WIFI_EAP_PASS,
strlen(ESP_WIFI_EAP_PASS)); strlen(ESP_WIFI_EAP_PASS));
#else /* defined(ESP_WIFI_EAP_USER) && defined(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 \ #error "ESP_WIFI_EAP_USER and ESP_WIFI_EAP_PASS have to be defined for EAP phase 2 authentication"
and the password for EAP phase 2 authentication in esp_wifi_enterprise
#endif /* defined(ESP_WIFI_EAP_USER) && defined(ESP_WIFI_EAP_PASS) */ #endif /* defined(ESP_WIFI_EAP_USER) && defined(ESP_WIFI_EAP_PASS) */
esp_wifi_sta_wpa2_ent_enable(); esp_wifi_sta_wpa2_ent_enable();
#endif /* defined(MODULE_ESP_WIFI_ENTERPRISE) && !defined(MODULE_ESP_WIFI_AP) */ #endif /* defined(MODULE_ESP_WIFI_ENTERPRISE) && !defined(MODULE_ESP_WIFI_AP) */

View File

@ -33,11 +33,11 @@
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
#include "freertos/task.h" #include "freertos/task.h"
#define MHZ 1000000
#ifdef MCU_ESP8266 #ifdef MCU_ESP8266
#include "rom/ets_sys.h" #include "rom/ets_sys.h"
#endif
#ifndef PRO_CPU_NUM
#define PRO_CPU_NUM (0) #define PRO_CPU_NUM (0)
#endif #endif
@ -371,7 +371,7 @@ BaseType_t xTaskNotifyWait(uint32_t ulBitsToClearOnEntry,
{ {
kernel_pid_t pid = thread_getpid(); 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); pid, ulBitsToClearOnEntry, ulBitsToClearOnExit, xTicksToWait);
assert(pid_is_valid(pid)); assert(pid_is_valid(pid));

View File

@ -65,7 +65,7 @@ extern "C" {
* @param cond the condition * @param cond the condition
* @param err the return value in the case the condition is not fulfilled. * @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 ") " \ DEBUG("%s parameter condition (" #cond ") " \
"not fulfilled\n", __func__); \ "not fulfilled\n", __func__); \
@ -88,19 +88,19 @@ extern "C" {
#else /* ENABLE_DEBUG */ #else /* ENABLE_DEBUG */
#define CHECK_PARAM_RET(cond,err) if (!(cond)) return err; #define CHECK_PARAM_RET(cond, err) if (!(cond)) { return err; }
#define CHECK_PARAM(cond) if (!(cond)) return; #define CHECK_PARAM(cond) if (!(cond)) { return; }
#endif /* ENABLE_DEBUG */ #endif /* ENABLE_DEBUG */
/** gives the minimum of a and b */ /** gives the minimum of a and b */
#ifndef MIN #ifndef MIN
#define MIN(a,b) ((a) < (b) ? (a) : (b)) #define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif #endif
/** gives the maximum of a and b */ /** gives the maximum of a and b */
#ifndef MAX #ifndef MAX
#define MAX(a,b) ((a) > (b) ? (a) : (b)) #define MAX(a, b) ((a) > (b) ? (a) : (b))
#endif #endif
/** /**

View File

@ -64,14 +64,14 @@ extern int ets_printf(const char *fmt, ...);
printf(LOG_FORMAT(letter, format), system_get_time_ms(), tag, ##__VA_ARGS__); \ printf(LOG_FORMAT(letter, format), system_get_time_ms(), tag, ##__VA_ARGS__); \
fflush(stdout); \ fflush(stdout); \
} \ } \
} while(0) } while (0)
#define LOG_TAG_EARLY(level, letter, tag, format, ...) \ #define LOG_TAG_EARLY(level, letter, tag, format, ...) \
do { \ do { \
if (LOG_LEVEL >= level) { \ if (LOG_LEVEL >= level) { \
ets_printf(LOG_FORMAT(letter, format), system_get_time_ms(), tag, ##__VA_ARGS__); \ ets_printf(LOG_FORMAT(letter, format), system_get_time_ms(), tag, ##__VA_ARGS__); \
} \ } \
} while(0) } while (0)
#else /* MODULE_ESP_LOG_TAGGED */ #else /* MODULE_ESP_LOG_TAGGED */
@ -105,32 +105,32 @@ extern int ets_printf(const char *fmt, ...);
#undef LOG_INFO #undef LOG_INFO
#undef LOG_WARNING #undef LOG_WARNING
#undef LOG_DEBUG #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_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_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_DEBUG(format, ...) LOG_TAG(LOG_DEBUG, D, __func__, format, ##__VA_ARGS__)
#endif #endif
/** Tagged LOG_* definitions */ /** 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_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_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_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_ALL(tag, format, ...) LOG_TAG(LOG_ALL, V, tag, format, ##__VA_ARGS__)
/** definitions for source code compatibility with ESP-IDF */ /** 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_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_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 #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_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_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 #endif
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -36,8 +36,7 @@ extern "C" {
/** /**
* @brief Definition of possible GPIO usage types (for internal use only) * @brief Definition of possible GPIO usage types (for internal use only)
*/ */
typedef enum typedef enum {
{
_GPIO = 0, /**< pin used as standard GPIO */ _GPIO = 0, /**< pin used as standard GPIO */
#ifndef MCU_ESP8266 #ifndef MCU_ESP8266
_ADC, /**< pin is used as ADC input */ _ADC, /**< pin is used as ADC input */

View File

@ -59,8 +59,8 @@
#define I2C_CLOCK_STRETCH 200 #define I2C_CLOCK_STRETCH 200
/* gpio access macros */ /* 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_SET(lo, hi, b) if (b < 32) { GPIO.lo = BIT(b); } else { GPIO.hi.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(lo, hi, b) ((b < 32) ? GPIO.lo & BIT(b) : GPIO.hi.val & BIT(b-32))
#else /* MCU_ESP8266 */ #else /* MCU_ESP8266 */
@ -86,8 +86,7 @@ extern bool system_update_cpu_freq(uint8_t freq);
#endif /* MCU_ESP8266 */ #endif /* MCU_ESP8266 */
typedef struct typedef struct {
{
i2c_speed_t speed; i2c_speed_t speed;
i2c_t dev; i2c_t dev;