mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
19425: drivers/servo: Fix typo in comment r=benpicco a=maribu ### Contribution description As the title says ### Testing procedure Not needed; code review will confirm that this is a comment only change. ### Issues/PRs references None 19426: cpu/esp32: cleanup of ESP-IDF interface API (module `esp_idf_api`) r=benpicco a=gschorcht ### Contribution description This PR cleans up the wrapper library (module `esp_idf_api`) that is used to interface to ESP-IDF driver modules. A number of ESP-IDF header files needed to compile RIOT include the ESP-IDF header file `driver/gpio.h` only because of the definition of the type `gpio_num_t`. However, `driver/gpio.h` does not only define `gpio_num_t` but the complete ESP-IDF GPIO API which conflicts with that in RIOT. The solution was to use a wrapper library when compiling the RIOT code that does not need to include the ESP-IDF header file `driver/gpio.h`. The disadvantage of this approach was that for each ESP-IDF function to be used in RIOT, a corresponding function in the wrapper library had to be defined which does nothing else than calling the corresponding ESP-IDF function. This PR provides another approach which does not require such a wrapper library in most cases and allows to clean up the wrapper library (module `esp_idf_api`). It just provides its own `driver/gpio.h` that is included by ESP-IDF header files instead of the original ESP-IDF header file `driver/gpio.h`. It defines only the required `gpio_num_t` when RIOT code is compiled but includes the original ESP-IDF header file `driver/gpio.h` when ESP-IDF code is compiled. As a result. most of the functions in the wrapper library could be eliminated. A further advantage is that further ESP-IDF API functions can be used without defining corresponding wrapper functions. ### Testing procedure Green CI ### Issues/PRs references Co-authored-by: Marian Buschsieweke <marian.buschsieweke@ovgu.de> Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
This commit is contained in:
commit
f8d7762f0e
@ -1,65 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Gunar Schorcht
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup cpu_esp32_esp_idf_api
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Interface for the ESP-IDF ADC HAL API
|
||||
*
|
||||
* @author Gunar Schorcht <gunar@schorcht.net>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "driver/adc.h"
|
||||
|
||||
void esp_idf_adc_power_acquire(void)
|
||||
{
|
||||
adc_power_acquire();
|
||||
}
|
||||
|
||||
void esp_idf_adc_power_release(void)
|
||||
{
|
||||
adc_power_release();
|
||||
}
|
||||
|
||||
esp_err_t esp_idf_adc1_config_width(adc_bits_width_t width_bit)
|
||||
{
|
||||
return adc1_config_width(width_bit);
|
||||
}
|
||||
|
||||
esp_err_t esp_idf_adc1_config_channel_atten(adc_channel_t channel,
|
||||
adc_atten_t atten)
|
||||
{
|
||||
return adc1_config_channel_atten(channel, atten);
|
||||
}
|
||||
|
||||
int esp_idf_adc1_get_raw(adc1_channel_t channel)
|
||||
{
|
||||
return adc1_get_raw(channel);
|
||||
}
|
||||
|
||||
esp_err_t esp_idf_adc2_config_channel_atten(adc_channel_t channel,
|
||||
adc_atten_t atten)
|
||||
{
|
||||
return adc2_config_channel_atten(channel, atten);
|
||||
}
|
||||
|
||||
esp_err_t esp_idf_adc2_get_raw(adc2_channel_t channel,
|
||||
adc_bits_width_t width_bit, int *raw_out)
|
||||
{
|
||||
return adc2_get_raw(channel, width_bit, raw_out);
|
||||
}
|
||||
|
||||
esp_err_t esp_idf_adc_vref_to_gpio(adc_unit_t adc_unit, gpio_num_t gpio)
|
||||
{
|
||||
return adc_vref_to_gpio(adc_unit, gpio);
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Gunar Schorcht
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup cpu_esp32_esp_idf_api
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Interface for the ESP-IDF DAC HAL API
|
||||
*
|
||||
* @author Gunar Schorcht <gunar@schorcht.net>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef MODULE_PERIPH_DAC
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "driver/dac_common.h"
|
||||
|
||||
esp_err_t esp_idf_dac_output_voltage(dac_channel_t channel, uint8_t dac_value)
|
||||
{
|
||||
return dac_output_voltage(channel, dac_value);
|
||||
}
|
||||
|
||||
esp_err_t esp_idf_dac_output_enable(dac_channel_t channel)
|
||||
{
|
||||
return dac_output_enable(channel);
|
||||
}
|
||||
|
||||
esp_err_t esp_idf_dac_output_disable(dac_channel_t channel)
|
||||
{
|
||||
return dac_output_disable(channel);
|
||||
}
|
||||
|
||||
#endif
|
@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Gunar Schorcht
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup cpu_esp32_esp_idf_api
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Interface for the ESP-IDF LEDC HAL API
|
||||
*
|
||||
* @author Gunar Schorcht <gunar@schorcht.net>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "driver/ledc.h"
|
||||
|
||||
int esp_ledc_channel_config(const ledc_channel_config_t* ledc_conf)
|
||||
{
|
||||
return ledc_channel_config(ledc_conf);
|
||||
}
|
||||
|
||||
int esp_ledc_timer_config(const ledc_timer_config_t* timer_conf)
|
||||
{
|
||||
return ledc_timer_config(timer_conf);
|
||||
}
|
||||
|
||||
int esp_ledc_update_duty(ledc_mode_t speed_mode, ledc_channel_t channel)
|
||||
{
|
||||
return ledc_update_duty(speed_mode, channel);
|
||||
}
|
||||
|
||||
int esp_ledc_set_duty_with_hpoint(ledc_mode_t speed_mode,
|
||||
ledc_channel_t channel,
|
||||
uint32_t duty, uint32_t hpoint)
|
||||
{
|
||||
return ledc_set_duty_with_hpoint(speed_mode, channel, duty, hpoint);
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Gunar Schorcht
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup cpu_esp32_esp_idf_api
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Interface for ESP-IDF peripherals control API
|
||||
*
|
||||
* @author Gunar Schorcht <gunar@schorcht.net>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include "driver/periph_ctrl.h"
|
||||
|
||||
void esp_idf_periph_module_enable(periph_module_t periph)
|
||||
{
|
||||
periph_module_enable(periph);
|
||||
}
|
||||
|
||||
void esp_idf_periph_module_disable(periph_module_t periph)
|
||||
{
|
||||
periph_module_disable(periph);
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
# common definitions for all ESP-IDF modules
|
||||
|
||||
# additional include pathes required by als ESP-IDF module
|
||||
# additional include pathes required by ESP-IDF module
|
||||
INCLUDES += -I$(ESP32_SDK_DIR)/components/bootloader_support/include
|
||||
INCLUDES += -I$(ESP32_SDK_DIR)/components/bootloader_support/include_bootloader
|
||||
INCLUDES += -I$(ESP32_SDK_DIR)/components/driver/$(CPU_FAM)/include
|
||||
|
@ -1,5 +1,8 @@
|
||||
# common definitions for all ESP-IDF modules
|
||||
|
||||
# indicate that ESP-IDF code is compiled
|
||||
CFLAGS += -DESP_IDF_CODE
|
||||
|
||||
# shortcuts used by ESP-IDF
|
||||
CFLAGS += -Dasm=__asm
|
||||
CFLAGS += -Dtypeof=__typeof__
|
||||
|
24
cpu/esp32/esp-idf/include/driver/gpio.h
Normal file
24
cpu/esp32/esp-idf/include/driver/gpio.h
Normal file
@ -0,0 +1,24 @@
|
||||
#ifndef DRIVER_GPIO_H
|
||||
#define DRIVER_GPIO_H
|
||||
|
||||
#ifdef ESP_IDF_CODE
|
||||
|
||||
#include_next "driver/gpio.h"
|
||||
|
||||
#else
|
||||
|
||||
#include "hal/gpio_types.h"
|
||||
|
||||
#define GPIO_PIN_COUNT (SOC_GPIO_PIN_COUNT)
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DRIVER_GPIO_H */
|
@ -34,10 +34,9 @@ extern "C" {
|
||||
#include "periph/adc.h"
|
||||
#include "periph/gpio.h"
|
||||
|
||||
#include "driver/adc.h"
|
||||
#include "hal/adc_types.h"
|
||||
|
||||
#include "esp_idf_api/adc.h"
|
||||
|
||||
/**
|
||||
* @brief Attenuations that can be set for ADC lines
|
||||
*
|
||||
@ -112,9 +111,9 @@ int adc_line_vref_to_gpio(adc_t line, gpio_t gpio);
|
||||
* @return 0 on success
|
||||
* @return -1 on invalid ADC line
|
||||
*/
|
||||
static inline int adc_vref_to_gpio25 (void)
|
||||
static inline int adc_vref_to_gpio25(void)
|
||||
{
|
||||
return esp_idf_adc_vref_to_gpio(ADC_UNIT_2, GPIO25);
|
||||
return adc_vref_to_gpio(ADC_UNIT_2, GPIO25);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Gunar Schorcht
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup cpu_esp32_esp_idf_api
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Interface for the ESP-IDF ADC HAL API
|
||||
*
|
||||
* @author Gunar Schorcht <gunar@schorcht.net>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifndef ESP_IDF_API_ADC_H
|
||||
#define ESP_IDF_API_ADC_H
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "hal/adc_types.h"
|
||||
#include "hal/gpio_types.h"
|
||||
|
||||
#ifndef DOXYGEN /* Hide implementation details from doxygen */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @name ESP-IDF interface mapper functions
|
||||
* @{
|
||||
*/
|
||||
/** @} */
|
||||
void esp_idf_adc_power_acquire(void);
|
||||
void esp_idf_adc_power_release(void);
|
||||
|
||||
esp_err_t esp_idf_adc1_config_width(adc_bits_width_t width_bit);
|
||||
esp_err_t esp_idf_adc1_config_channel_atten(adc_channel_t channel,
|
||||
adc_atten_t atten);
|
||||
int esp_idf_adc1_get_raw(adc_channel_t channel);
|
||||
|
||||
esp_err_t esp_idf_adc2_config_channel_atten(adc_channel_t channel,
|
||||
adc_atten_t atten);
|
||||
esp_err_t esp_idf_adc2_get_raw(adc_channel_t channel,
|
||||
adc_bits_width_t width_bit, int *raw_out);
|
||||
esp_err_t esp_idf_adc_vref_to_gpio(adc_unit_t adc_unit, gpio_num_t gpio);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DOXYGEN */
|
||||
#endif /* ESP_IDF_API_ADC_H */
|
@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Gunar Schorcht
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup cpu_esp32_esp_idf_api
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Interface for the ESP-IDF DAC HAL API
|
||||
*
|
||||
* @author Gunar Schorcht <gunar@schorcht.net>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifndef ESP_IDF_API_DAC_H
|
||||
#define ESP_IDF_API_DAC_H
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "hal/dac_types.h"
|
||||
|
||||
#ifndef DOXYGEN /* Hide implementation details from doxygen */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @name ESP-IDF interface wrapper functions
|
||||
* @{
|
||||
*/
|
||||
esp_err_t esp_idf_dac_output_voltage(dac_channel_t channel, uint8_t dac_value);
|
||||
esp_err_t esp_idf_dac_output_enable(dac_channel_t channel);
|
||||
esp_err_t esp_idf_dac_output_disable(dac_channel_t channel);
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DOXYGEN */
|
||||
#endif /* ESP_IDF_API_DAC_H */
|
@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Gunar Schorcht
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup cpu_esp32_esp_idf_api
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Interface for the ESP-IDF LEDC HAL API
|
||||
*
|
||||
* @author Gunar Schorcht <gunar@schorcht.net>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifndef ESP_IDF_API_LEDC_H
|
||||
#define ESP_IDF_API_LEDC_H
|
||||
|
||||
#include "hal/ledc_types.h"
|
||||
|
||||
#ifndef DOXYGEN /* Hide implementation details from doxygen */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @name ESP-IDF interface wrapper functions
|
||||
* @{
|
||||
*/
|
||||
int esp_ledc_channel_config(const ledc_channel_config_t* ledc_conf);
|
||||
int esp_ledc_timer_config(const ledc_timer_config_t* timer_conf);
|
||||
int esp_ledc_update_duty(ledc_mode_t speed_mode, ledc_channel_t channel);
|
||||
int esp_ledc_set_duty_with_hpoint(ledc_mode_t speed_mode,
|
||||
ledc_channel_t channel,
|
||||
uint32_t duty, uint32_t hpoint);
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DOXYGEN */
|
||||
#endif /* ESP_IDF_API_LEDC_H */
|
@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Gunar Schorcht
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup cpu_esp32_esp_idf_api
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Interface for ESP-IDF peripherals control API
|
||||
*
|
||||
* @author Gunar Schorcht <gunar@schorcht.net>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifndef ESP_IDF_API_PERIPH_CTRL_H
|
||||
#define ESP_IDF_API_PERIPH_CTRL_H
|
||||
|
||||
#ifndef DOXYGEN /* Hide implementation details from doxygen */
|
||||
|
||||
#include "soc/periph_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void esp_idf_periph_module_enable(periph_module_t periph);
|
||||
void esp_idf_periph_module_disable(periph_module_t periph);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DOXYGEN */
|
||||
#endif /* ESP_IDF_API_PERIPH_CTRL_H */
|
@ -36,7 +36,7 @@
|
||||
#include "esp_common.h"
|
||||
#include "gpio_arch.h"
|
||||
|
||||
#include "esp_idf_api/adc.h"
|
||||
#include "driver/adc.h"
|
||||
|
||||
#define ENABLE_DEBUG 0
|
||||
#include "debug.h"
|
||||
@ -134,15 +134,13 @@ int adc_init(adc_t line)
|
||||
/* initialize the ADC1 unit if needed */
|
||||
_adc1_ctrl_init();
|
||||
/* set the attenuation and configure its associated GPIO pin mux */
|
||||
esp_idf_adc1_config_channel_atten(_adc_hw[rtcio].adc_channel,
|
||||
ADC_ATTEN_DB_11);
|
||||
adc1_config_channel_atten(_adc_hw[rtcio].adc_channel, ADC_ATTEN_DB_11);
|
||||
}
|
||||
else if (_adc_hw[rtcio].adc_ctrl == ADC_UNIT_2) {
|
||||
/* initialize the ADC2 unit if needed */
|
||||
_adc2_ctrl_init();
|
||||
/* set the attenuation and configure its associated GPIO pin mux */
|
||||
esp_idf_adc2_config_channel_atten(_adc_hw[rtcio].adc_channel,
|
||||
ADC_ATTEN_DB_11);
|
||||
adc2_config_channel_atten(_adc_hw[rtcio].adc_channel, ADC_ATTEN_DB_11);
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
@ -166,15 +164,15 @@ int32_t adc_sample(adc_t line, adc_res_t res)
|
||||
int raw;
|
||||
|
||||
if (_adc_hw[rtcio].adc_ctrl == ADC_UNIT_1) {
|
||||
esp_idf_adc1_config_width(_adc_esp_res_map[res].res);
|
||||
raw = esp_idf_adc1_get_raw(_adc_hw[rtcio].adc_channel);
|
||||
adc1_config_width(_adc_esp_res_map[res].res);
|
||||
raw = adc1_get_raw(_adc_hw[rtcio].adc_channel);
|
||||
if (raw < 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if (_adc_hw[rtcio].adc_ctrl == ADC_UNIT_2) {
|
||||
if (esp_idf_adc2_get_raw(_adc_hw[rtcio].adc_channel,
|
||||
_adc_esp_res_map[res].res, &raw) < 0) {
|
||||
if (adc2_get_raw(_adc_hw[rtcio].adc_channel,
|
||||
_adc_esp_res_map[res].res, &raw) < 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -191,12 +189,10 @@ int adc_set_attenuation(adc_t line, adc_atten_t atten)
|
||||
assert(rtcio != RTCIO_NA);
|
||||
|
||||
if (_adc_hw[rtcio].adc_ctrl == ADC_UNIT_1) {
|
||||
return esp_idf_adc1_config_channel_atten(_adc_hw[rtcio].adc_channel,
|
||||
atten);
|
||||
return adc1_config_channel_atten(_adc_hw[rtcio].adc_channel, atten);
|
||||
}
|
||||
else if (_adc_hw[rtcio].adc_ctrl == ADC_UNIT_2) {
|
||||
return esp_idf_adc2_config_channel_atten(_adc_hw[rtcio].adc_channel,
|
||||
atten);
|
||||
return adc2_config_channel_atten(_adc_hw[rtcio].adc_channel, atten);
|
||||
}
|
||||
|
||||
return -1;
|
||||
@ -221,10 +217,10 @@ int adc_line_vref_to_gpio(adc_t line, gpio_t gpio)
|
||||
esp_err_t res = ESP_OK;
|
||||
|
||||
if (_adc_hw[rtcio_vref].adc_ctrl == ADC_UNIT_1) {
|
||||
res = esp_idf_adc_vref_to_gpio(ADC_UNIT_1, gpio);
|
||||
res = adc_vref_to_gpio(ADC_UNIT_1, gpio);
|
||||
}
|
||||
else if (_adc_hw[rtcio_vref].adc_ctrl == ADC_UNIT_2) {
|
||||
res = esp_idf_adc_vref_to_gpio(ADC_UNIT_2, gpio);
|
||||
res = adc_vref_to_gpio(ADC_UNIT_2, gpio);
|
||||
}
|
||||
if (res != ESP_OK) {
|
||||
LOG_TAG_ERROR("adc", "Could not route Vref of ADC line %d to GPIO%d\n",
|
||||
|
@ -23,8 +23,8 @@
|
||||
#include "periph/dac.h"
|
||||
|
||||
#include "esp_common.h"
|
||||
#include "driver/dac_common.h"
|
||||
#include "soc/dac_periph.h"
|
||||
#include "esp_idf_api/dac.h"
|
||||
|
||||
#define ENABLE_DEBUG 0
|
||||
#include "debug.h"
|
||||
@ -61,22 +61,21 @@ void dac_set(dac_t line, uint16_t value)
|
||||
{
|
||||
assert(line < DAC_NUMOF);
|
||||
assert(_dac_channels[line] != DAC_CHANNEL_MAX);
|
||||
esp_idf_dac_output_voltage(_dac_channels[line],
|
||||
value >> (16 - SOC_DAC_RESOLUTION));
|
||||
dac_output_voltage(_dac_channels[line], value >> (16 - SOC_DAC_RESOLUTION));
|
||||
}
|
||||
|
||||
void dac_poweroff(dac_t line)
|
||||
{
|
||||
assert(line < DAC_NUMOF);
|
||||
assert(_dac_channels[line] != DAC_CHANNEL_MAX);
|
||||
esp_idf_dac_output_disable(_dac_channels[line]);
|
||||
dac_output_disable(_dac_channels[line]);
|
||||
}
|
||||
|
||||
void dac_poweron(dac_t line)
|
||||
{
|
||||
assert(line < DAC_NUMOF);
|
||||
assert(_dac_channels[line] != DAC_CHANNEL_MAX);
|
||||
esp_idf_dac_output_enable(_dac_channels[line]);
|
||||
dac_output_enable(_dac_channels[line]);
|
||||
}
|
||||
|
||||
static bool _dac_conf_check(void)
|
||||
|
@ -28,14 +28,13 @@
|
||||
#include "periph/pwm.h"
|
||||
#include "periph/gpio.h"
|
||||
|
||||
#include "driver/periph_ctrl.h"
|
||||
#include "esp_common.h"
|
||||
#include "esp_rom_gpio.h"
|
||||
#include "hal/ledc_hal.h"
|
||||
#include "soc/ledc_struct.h"
|
||||
#include "soc/rtc.h"
|
||||
|
||||
#include "esp_idf_api/periph_ctrl.h"
|
||||
|
||||
#define ENABLE_DEBUG 0
|
||||
#include "debug.h"
|
||||
|
||||
@ -253,7 +252,7 @@ void pwm_poweron(pwm_t pwm)
|
||||
DEBUG("%s pwm=%u\n", __func__, pwm);
|
||||
|
||||
/* enable and init the module and select the right clock source */
|
||||
esp_idf_periph_module_enable(_CFG.module);
|
||||
periph_module_enable(_CFG.module);
|
||||
ledc_hal_init(&_DEV.hw, _CFG.group);
|
||||
ledc_hal_set_slow_clk_sel(&_DEV.hw, LEDC_SLOW_CLK_APB);
|
||||
ledc_hal_set_clock_source(&_DEV.hw, _CFG.timer, LEDC_APB_CLK);
|
||||
@ -317,7 +316,7 @@ void pwm_poweroff(pwm_t pwm)
|
||||
|
||||
/* if all devices of the same hardware module are disable, it is powered off */
|
||||
if (i == PWM_NUMOF) {
|
||||
esp_idf_periph_module_disable(_CFG.module);
|
||||
periph_module_disable(_CFG.module);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,13 +38,13 @@
|
||||
#include "periph/spi.h"
|
||||
#include "syscalls.h"
|
||||
|
||||
#include "driver/periph_ctrl.h"
|
||||
#include "esp_attr.h"
|
||||
#include "esp_rom_gpio.h"
|
||||
#include "hal/spi_hal.h"
|
||||
#include "hal/spi_types.h"
|
||||
#include "soc/rtc.h"
|
||||
|
||||
#include "esp_idf_api/periph_ctrl.h"
|
||||
#include "esp_idf_api/gpio.h"
|
||||
|
||||
#undef MHZ
|
||||
@ -117,7 +117,7 @@ void IRAM_ATTR spi_init(spi_t bus)
|
||||
}
|
||||
|
||||
/* enable (power on) the according SPI module */
|
||||
esp_idf_periph_module_enable(_spi[bus].periph->module);
|
||||
periph_module_enable(_spi[bus].periph->module);
|
||||
|
||||
/* initialize SPI peripheral */
|
||||
spi_ll_master_init(_spi[bus].periph->hw);
|
||||
|
@ -26,6 +26,7 @@
|
||||
*/
|
||||
#include "periph/timer.h"
|
||||
|
||||
#include "driver/periph_ctrl.h"
|
||||
#include "esp/common_macros.h"
|
||||
#include "hal/interrupt_controller_types.h"
|
||||
#include "hal/interrupt_controller_ll.h"
|
||||
@ -40,8 +41,6 @@
|
||||
#include "xtensa/xtensa_api.h"
|
||||
#endif
|
||||
|
||||
#include "esp_idf_api/periph_ctrl.h"
|
||||
|
||||
#include "esp_common.h"
|
||||
#include "irq_arch.h"
|
||||
#include "syscalls.h"
|
||||
@ -244,7 +243,7 @@ int timer_init(tim_t dev, uint32_t freq, timer_cb_t cb, void *arg)
|
||||
intr_cntrl_ll_enable_interrupts(BIT(CPU_INUM_TIMER));
|
||||
|
||||
/* enable TMG module */
|
||||
esp_idf_periph_module_enable(_timers_desc[dev].module);
|
||||
periph_module_enable(_timers_desc[dev].module);
|
||||
|
||||
/* hardware timer configuration */
|
||||
timer_hal_init(&_timers[dev].hw, _timers_desc[dev].group, _timers_desc[dev].index);
|
||||
|
@ -59,6 +59,7 @@
|
||||
|
||||
#else /* defined(MCU_ESP8266) */
|
||||
|
||||
#include "driver/periph_ctrl.h"
|
||||
#include "esp_rom_gpio.h"
|
||||
#include "esp_rom_uart.h"
|
||||
#include "hal/interrupt_controller_types.h"
|
||||
@ -73,8 +74,6 @@
|
||||
#include "soc/uart_reg.h"
|
||||
#include "soc/uart_struct.h"
|
||||
|
||||
#include "esp_idf_api/periph_ctrl.h"
|
||||
|
||||
#undef UART_CLK_FREQ
|
||||
#define UART_CLK_FREQ rtc_clk_apb_freq_get() /* APB_CLK is used */
|
||||
|
||||
@ -232,7 +231,7 @@ void uart_poweron(uart_t uart)
|
||||
assert(uart < UART_NUMOF);
|
||||
|
||||
#ifndef MCU_ESP8266
|
||||
esp_idf_periph_module_enable(_uarts[uart].mod);
|
||||
periph_module_enable(_uarts[uart].mod);
|
||||
#endif
|
||||
_uart_config(uart);
|
||||
}
|
||||
@ -242,7 +241,7 @@ void uart_poweroff(uart_t uart)
|
||||
assert(uart < UART_NUMOF);
|
||||
|
||||
#ifndef MCU_ESP8266
|
||||
esp_idf_periph_module_disable(_uarts[uart].mod);
|
||||
periph_module_disable(_uarts[uart].mod);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ static unsigned ticks_from_us(uint64_t duration, uint64_t freq)
|
||||
* timer chan n+1 ------------+
|
||||
*
|
||||
* Channel 0 is set to the period of one PWM control cycle and due to flag
|
||||
* `TIM_FLAG_RESET_ON_MATCH` will end the period and stat the new period. As
|
||||
* `TIM_FLAG_RESET_ON_MATCH` will end the period and start the new period. As
|
||||
* a result, n+1 channels are needed to control n servos.
|
||||
*/
|
||||
static void timer_cb(void *arg, int chan)
|
||||
|
Loading…
Reference in New Issue
Block a user