Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions drivers/counter/counter_esp32_rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,20 @@

#define DT_DRV_COMPAT espressif_esp32_rtc_timer

/*
* Include esp-idf headers first to avoid
* redefining BIT() macro
*/
#include "soc/rtc_cntl_reg.h"
#include "soc/rtc.h"

#include <zephyr/device.h>
#include <zephyr/drivers/counter.h>
#include <zephyr/spinlock.h>
#include <zephyr/kernel.h>

#if defined(CONFIG_SOC_ESP32C3)
#include <zephyr/drivers/interrupt_controller/intc_esp32c3.h>
#else
#include <zephyr/drivers/interrupt_controller/intc_esp32.h>
#endif

#include <zephyr/logging/log.h>

#include <soc/rtc_cntl_reg.h>
#include <soc/rtc.h>

LOG_MODULE_REGISTER(esp32_counter_rtc, CONFIG_COUNTER_LOG_LEVEL);

#if defined(CONFIG_SOC_ESP32C3)
Expand Down
16 changes: 9 additions & 7 deletions drivers/counter/counter_esp32_tmr.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,8 @@

#define DT_DRV_COMPAT espressif_esp32_timer

/* Include esp-idf headers first to avoid redefining BIT() macro */
#include <soc/rtc_cntl_reg.h>
#include <soc/timer_group_reg.h>
#include <driver/periph_ctrl.h>
#include <soc/periph_defs.h>
#include <hal/timer_types.h>
#include <hal/timer_hal.h>
#include <string.h>

#include <zephyr/drivers/counter.h>
#include <zephyr/spinlock.h>
#include <zephyr/kernel.h>
Expand All @@ -24,6 +18,14 @@
#endif
#include <zephyr/device.h>
#include <zephyr/logging/log.h>

#include <driver/periph_ctrl.h>
#include <hal/timer_types.h>
#include <hal/timer_hal.h>
#include <soc/periph_defs.h>
#include <soc/rtc_cntl_reg.h>
#include <soc/timer_group_reg.h>

LOG_MODULE_REGISTER(esp32_counter, CONFIG_COUNTER_LOG_LEVEL);

#ifdef CONFIG_SOC_ESP32C3
Expand Down
21 changes: 10 additions & 11 deletions drivers/gpio/gpio_esp32.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,8 @@

#define DT_DRV_COMPAT espressif_esp32_gpio

/* Include esp-idf headers first to avoid redefining BIT() macro */
#include <soc/gpio_reg.h>
#include <soc/io_mux_reg.h>
#include <soc/soc.h>
#include <hal/gpio_ll.h>
#include <esp_attr.h>
#include <hal/rtc_io_hal.h>

#include <soc.h>
#include <errno.h>

#include <zephyr/device.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/dt-bindings/gpio/espressif-esp32-gpio.h>
Expand All @@ -27,10 +19,17 @@
#endif
#include <zephyr/kernel.h>
#include <zephyr/sys/util.h>

#include <zephyr/drivers/gpio/gpio_utils.h>

#include <zephyr/logging/log.h>

#include <esp_attr.h>
#include <hal/gpio_ll.h>
#include <hal/rtc_io_hal.h>
#include <soc.h>
#include <soc/gpio_reg.h>
#include <soc/io_mux_reg.h>
#include <soc/soc.h>

LOG_MODULE_REGISTER(gpio_esp32, CONFIG_LOG_DEFAULT_LEVEL);

#ifdef CONFIG_SOC_ESP32C3
Expand Down
20 changes: 10 additions & 10 deletions drivers/i2c/i2c_esp32.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@

#define DT_DRV_COMPAT espressif_esp32_i2c

/* Include esp-idf headers first to avoid redefining BIT() macro */
#include <esp32/rom/gpio.h>
#include <soc/gpio_sig_map.h>
#include <hal/i2c_ll.h>
#include <hal/i2c_hal.h>
#include <hal/gpio_hal.h>

#include <soc.h>
#include <errno.h>
#include <string.h>

#include <zephyr/drivers/gpio.h>
#include <zephyr/drivers/pinctrl.h>
#include <zephyr/drivers/i2c.h>
#include <zephyr/drivers/interrupt_controller/intc_esp32.h>
#include <zephyr/drivers/clock_control.h>
#include <zephyr/sys/util.h>
#include <string.h>

#include <zephyr/logging/log.h>

#include <esp32/rom/gpio.h>
#include <hal/i2c_ll.h>
#include <hal/i2c_hal.h>
#include <hal/gpio_hal.h>
#include <soc.h>
#include <soc/gpio_sig_map.h>

LOG_MODULE_REGISTER(i2c_esp32, CONFIG_I2C_LOG_LEVEL);

#include "i2c-priv.h"
Expand Down
9 changes: 4 additions & 5 deletions drivers/pinctrl/pinctrl_esp32.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
* SPDX-License-Identifier: Apache-2.0
*/

/* Include esp-idf headers first to avoid redefining BIT() macro */
#include <hal/gpio_ll.h>
#include <hal/rtc_io_hal.h>

#include <soc.h>
#include <zephyr/drivers/pinctrl.h>
#include <zephyr/drivers/pinctrl/pinctrl_esp32_common.h>

#include <soc.h>
#include <hal/gpio_ll.h>
#include <hal/rtc_io_hal.h>

#ifdef CONFIG_SOC_ESP32C3
/* gpio structs in esp32c3 series are different from xtensa ones */
#define out out.data
Expand Down
12 changes: 6 additions & 6 deletions drivers/pwm/pwm_led_esp32.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@

#define DT_DRV_COMPAT espressif_esp32_ledc

/* Include esp-idf headers first to avoid redefining BIT() macro */
#include <hal/ledc_hal.h>
#include <hal/ledc_types.h>

#include <soc.h>
#include <errno.h>
#include <string.h>

#include <zephyr/drivers/pwm.h>
#include <zephyr/kernel.h>
#include <zephyr/drivers/pinctrl.h>
#include <zephyr/drivers/clock_control.h>

#include <zephyr/logging/log.h>

#include <hal/ledc_hal.h>
#include <hal/ledc_types.h>
#include <soc.h>

LOG_MODULE_REGISTER(pwm_ledc_esp32, CONFIG_PWM_LOG_LEVEL);

struct pwm_ledc_esp32_data {
Expand Down
14 changes: 7 additions & 7 deletions drivers/sensor/pcnt_esp32/pcnt_esp32.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@

#define DT_DRV_COMPAT espressif_esp32_pcnt

/* Include esp-idf headers first to avoid redefining BIT() macro */
#include <hal/pcnt_hal.h>
#include <hal/pcnt_ll.h>
#include <hal/pcnt_types.h>

#include <soc.h>
#include <errno.h>
#include <string.h>

#include <zephyr/drivers/sensor.h>
#include <zephyr/kernel.h>
#include <zephyr/drivers/pinctrl.h>
#include <zephyr/drivers/clock_control.h>
#ifdef CONFIG_PCNT_ESP32_TRIGGER
#include <zephyr/drivers/interrupt_controller/intc_esp32.h>
#endif /* CONFIG_PCNT_ESP32_TRIGGER */

#include <zephyr/logging/log.h>

#include <hal/pcnt_hal.h>
#include <hal/pcnt_ll.h>
#include <hal/pcnt_types.h>
#include <soc.h>

LOG_MODULE_REGISTER(pcnt_esp32, CONFIG_SENSOR_LOG_LEVEL);

#define PCNT_INTR_UNIT_0 BIT(0)
Expand Down
43 changes: 22 additions & 21 deletions drivers/serial/uart_esp32.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,25 @@

#define DT_DRV_COMPAT espressif_esp32_uart

/* Include esp-idf headers first to avoid redefining BIT() macro */
#include <errno.h>

#include <zephyr/device.h>
#ifdef CONFIG_UART_ASYNC_API
#include <zephyr/drivers/dma.h>
#include <zephyr/drivers/dma/dma_esp32.h>
#include <zephyr/dt-bindings/clock/esp32c3_clock.h>
#endif
#ifndef CONFIG_SOC_ESP32C3
#include <zephyr/drivers/interrupt_controller/intc_esp32.h>
#else
#include <zephyr/drivers/interrupt_controller/intc_esp32c3.h>
#endif
#include <zephyr/drivers/clock_control.h>
#include <zephyr/drivers/pinctrl.h>
#include <zephyr/drivers/uart.h>
#include <zephyr/logging/log.h>
#include <zephyr/sys/util.h>

/* TODO: include w/o prefix */
#ifdef CONFIG_SOC_ESP32
#include <esp32/rom/ets_sys.h>
Expand All @@ -23,34 +41,17 @@
#include <esp32c3/rom/ets_sys.h>
#include <esp32c3/rom/gpio.h>
#ifdef CONFIG_UART_ASYNC_API
#include <zephyr/drivers/dma.h>
#include <zephyr/drivers/dma/dma_esp32.h>
#include <hal/uhci_ll.h>
#include <zephyr/dt-bindings/clock/esp32c3_clock.h>
#endif
#endif
#include <soc/uart_struct.h>
#include <esp_attr.h>
#include <hal/uart_ll.h>
#include <hal/uart_hal.h>
#include <hal/uart_types.h>

#include <zephyr/drivers/pinctrl.h>

#include <soc/uart_reg.h>
#include <zephyr/device.h>
#include <soc.h>
#include <zephyr/drivers/uart.h>
#include <soc/uart_struct.h>
#include <soc/uart_reg.h>

#ifndef CONFIG_SOC_ESP32C3
#include <zephyr/drivers/interrupt_controller/intc_esp32.h>
#else
#include <zephyr/drivers/interrupt_controller/intc_esp32c3.h>
#endif
#include <zephyr/drivers/clock_control.h>
#include <errno.h>
#include <zephyr/sys/util.h>
#include <esp_attr.h>
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(uart_esp32, CONFIG_UART_LOG_LEVEL);

#ifdef CONFIG_SOC_ESP32C3
Expand Down
22 changes: 11 additions & 11 deletions drivers/spi/spi_esp32_spim.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,28 @@

#define DT_DRV_COMPAT espressif_esp32_spi

/* Include esp-idf headers first to avoid redefining BIT() macro */
#include <hal/spi_hal.h>
#include <esp_attr.h>

#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(esp32_spi, CONFIG_SPI_LOG_LEVEL);
#include "spi_context.h"
#include "spi_esp32_spim.h"

#include <soc.h>
#include <soc/soc_memory_types.h>
#include <zephyr/drivers/spi.h>
#ifndef CONFIG_SOC_ESP32C3
#include <zephyr/drivers/interrupt_controller/intc_esp32.h>
#else
#include <zephyr/drivers/interrupt_controller/intc_esp32c3.h>
#endif
#include <zephyr/drivers/clock_control.h>
#include <zephyr/logging/log.h>

#include <esp_attr.h>
#ifdef SOC_GDMA_SUPPORTED
#include <hal/gdma_hal.h>
#include <hal/gdma_ll.h>
#endif
#include <zephyr/drivers/clock_control.h>
#include "spi_context.h"
#include "spi_esp32_spim.h"
#include <hal/spi_hal.h>
#include <soc.h>
#include <soc/soc_memory_types.h>

LOG_MODULE_REGISTER(esp32_spi, CONFIG_SPI_LOG_LEVEL);

#ifdef CONFIG_SOC_ESP32C3
#define ISR_HANDLER isr_handler_t
Expand Down
16 changes: 8 additions & 8 deletions drivers/watchdog/wdt_esp32.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@

#define DT_DRV_COMPAT espressif_esp32_watchdog

/* Include esp-idf headers first to avoid redefining BIT() macro */
#include <soc/rtc_cntl_reg.h>
#include <soc/timer_group_reg.h>
#include <hal/mwdt_ll.h>
#include <hal/wdt_hal.h>

#include <string.h>

#include <zephyr/device.h>
#include <zephyr/drivers/watchdog.h>
#include <zephyr/drivers/clock_control.h>
#ifndef CONFIG_SOC_ESP32C3
#include <zephyr/drivers/interrupt_controller/intc_esp32.h>
#else
#include <zephyr/drivers/interrupt_controller/intc_esp32c3.h>
#endif
#include <zephyr/device.h>

#include <zephyr/logging/log.h>

#include <hal/mwdt_ll.h>
#include <hal/wdt_hal.h>
#include <soc/rtc_cntl_reg.h>
#include <soc/timer_group_reg.h>

LOG_MODULE_REGISTER(wdt_esp32, CONFIG_WDT_LOG_LEVEL);

#ifdef CONFIG_SOC_ESP32C3
Expand Down
6 changes: 0 additions & 6 deletions include/zephyr/sys/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ extern "C" {
#define ceiling_fraction(numerator, divider) __DEPRECATED_MACRO \
DIV_ROUND_UP(numerator, divider)

#ifndef MAX
/**
* @brief Obtain the maximum of two values.
*
Expand All @@ -280,9 +279,7 @@ extern "C" {
* @returns Maximum value of @p a and @p b.
*/
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#endif

#ifndef MIN
/**
* @brief Obtain the minimum of two values.
*
Expand All @@ -295,9 +292,7 @@ extern "C" {
* @returns Minimum value of @p a and @p b.
*/
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#endif

#ifndef CLAMP
/**
* @brief Clamp a value to a given range.
*
Expand All @@ -311,7 +306,6 @@ extern "C" {
* @returns Clamped value.
*/
#define CLAMP(val, low, high) (((val) <= (low)) ? (low) : MIN(val, high))
#endif

/**
* @brief Checks if a value is within range.
Expand Down
2 changes: 0 additions & 2 deletions include/zephyr/sys/util_macro.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ extern "C" {
*/
#include <zephyr/sys/util_internal.h>

#ifndef BIT
#if defined(_ASMLANGUAGE)
#define BIT(n) (1 << (n))
#else
Expand All @@ -43,7 +42,6 @@ extern "C" {
*/
#define BIT(n) (1UL << (n))
#endif
#endif

/** @brief 64-bit unsigned integer with bit position @p _n set. */
#define BIT64(_n) (1ULL << (_n))
Expand Down
Loading