drivers: counter: esp32c2: Add support
Add counter support to ESP32C2 and ESP8684 Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
This commit is contained in:
parent
cc2e0f2131
commit
c1f8948e76
3 changed files with 17 additions and 7 deletions
|
@ -22,7 +22,7 @@
|
|||
#include <zephyr/drivers/clock_control.h>
|
||||
#include <zephyr/drivers/clock_control/esp32_clock_control.h>
|
||||
|
||||
#if defined(CONFIG_SOC_SERIES_ESP32C3)
|
||||
#if defined(CONFIG_SOC_SERIES_ESP32C2) || defined(CONFIG_SOC_SERIES_ESP32C3)
|
||||
#include <zephyr/drivers/interrupt_controller/intc_esp32c3.h>
|
||||
#else
|
||||
#include <zephyr/drivers/interrupt_controller/intc_esp32.h>
|
||||
|
@ -31,7 +31,7 @@
|
|||
#include <zephyr/logging/log.h>
|
||||
LOG_MODULE_REGISTER(esp32_counter_rtc, CONFIG_COUNTER_LOG_LEVEL);
|
||||
|
||||
#if defined(CONFIG_SOC_SERIES_ESP32C3)
|
||||
#if defined(CONFIG_SOC_SERIES_ESP32C2) || defined(CONFIG_SOC_SERIES_ESP32C3)
|
||||
#define ESP32_COUNTER_RTC_ISR_HANDLER isr_handler_t
|
||||
#else
|
||||
#define ESP32_COUNTER_RTC_ISR_HANDLER intr_handler_t
|
||||
|
@ -108,7 +108,8 @@ static int counter_esp32_set_alarm(const struct device *dev, uint8_t chan_id,
|
|||
uint32_t now;
|
||||
uint32_t ticks = 0;
|
||||
|
||||
#if defined(CONFIG_SOC_SERIES_ESP32) || defined(CONFIG_SOC_SERIES_ESP32C3)
|
||||
#if defined(CONFIG_SOC_SERIES_ESP32) || defined(CONFIG_SOC_SERIES_ESP32C2) || \
|
||||
defined(CONFIG_SOC_SERIES_ESP32C3)
|
||||
/* In ESP32/C3 Series the min possible value is 30 us*/
|
||||
if (counter_ticks_to_us(dev, alarm_cfg->ticks) < 30) {
|
||||
return -EINVAL;
|
||||
|
|
|
@ -18,16 +18,16 @@
|
|||
#include <zephyr/drivers/counter.h>
|
||||
#include <zephyr/spinlock.h>
|
||||
#include <zephyr/kernel.h>
|
||||
#ifndef CONFIG_SOC_SERIES_ESP32C3
|
||||
#include <zephyr/drivers/interrupt_controller/intc_esp32.h>
|
||||
#else
|
||||
#if defined(CONFIG_SOC_SERIES_ESP32C2) || defined(CONFIG_SOC_SERIES_ESP32C3)
|
||||
#include <zephyr/drivers/interrupt_controller/intc_esp32c3.h>
|
||||
#else
|
||||
#include <zephyr/drivers/interrupt_controller/intc_esp32.h>
|
||||
#endif
|
||||
#include <zephyr/device.h>
|
||||
#include <zephyr/logging/log.h>
|
||||
LOG_MODULE_REGISTER(esp32_counter, CONFIG_COUNTER_LOG_LEVEL);
|
||||
|
||||
#ifdef CONFIG_SOC_SERIES_ESP32C3
|
||||
#if defined(CONFIG_SOC_SERIES_ESP32C2) || defined(CONFIG_SOC_SERIES_ESP32C3)
|
||||
#define ISR_HANDLER isr_handler_t
|
||||
#else
|
||||
#define ISR_HANDLER intr_handler_t
|
||||
|
@ -70,9 +70,11 @@ static int counter_esp32_init(const struct device *dev)
|
|||
case TIMER_GROUP_0:
|
||||
periph_module_enable(PERIPH_TIMG0_MODULE);
|
||||
break;
|
||||
#if !defined(CONFIG_SOC_SERIES_ESP32C2)
|
||||
case TIMER_GROUP_1:
|
||||
periph_module_enable(PERIPH_TIMG1_MODULE);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
&timer0 {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&rtc_timer {
|
||||
status = "okay";
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue