From a10ac1aea3c9077188c979a277579ec19f89717e Mon Sep 17 00:00:00 2001 From: Thomas Jentzsch <76921504+yellobyte@users.noreply.github.com> Date: Sat, 27 Jul 2024 23:19:54 +0200 Subject: [PATCH] Fix for Arduino ESP32 version 3.x.x --- library.json | 2 +- library.properties | 2 +- src/DacESP32.cpp | 16 ++++++++-------- src/DacESP32.h | 5 +++-- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/library.json b/library.json index 7fc5053..54a3727 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "DacESP32", - "version": "1.1.0", + "version": "1.1.1", "platforms": [ "espressif32" diff --git a/library.properties b/library.properties index db8be98..df563a3 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=DacESP32 -version=1.1.0 +version=1.1.1 author=Thomas Jentzsch maintainer=Thomas Jentzsch sentence=Arduino library for using the ESP32 DAC output channels fast and easy. diff --git a/src/DacESP32.cpp b/src/DacESP32.cpp index 4662bb1..b6cda42 100644 --- a/src/DacESP32.cpp +++ b/src/DacESP32.cpp @@ -73,7 +73,7 @@ #endif #define CHANNEL_CHECK \ - if (m_channel == DAC_CHANNEL_UNDEFINED) { \ + if (m_channel == DAC_CHAN_UNDEFINED) { \ log_e("channel setting invalid"); \ return ESP_FAIL; \ } @@ -92,7 +92,7 @@ DacESP32::DacESP32(dac_channel_t channel) m_objectCount++; if (channel != DAC_CHANNEL_1 && channel != DAC_CHANNEL_2) { - m_channel = DAC_CHANNEL_UNDEFINED; + m_channel = DAC_CHAN_UNDEFINED; return; } @@ -114,8 +114,8 @@ DacESP32::DacESP32(dac_channel_t channel) REG_SET_FIELD(RTC_CNTL_CLK_CONF_REG, RTC_CNTL_CK8M_DIV_SEL, 0); } - if (m_objectCount > DAC_CHANNEL_MAX) { - log_w("DacESP32 objects created = %d > %d (DAC channels available) !", m_objectCount, DAC_CHANNEL_MAX); + if (m_objectCount > DAC_CHAN_MAX) { + log_w("DacESP32 objects created = %d > %d (DAC channels available) !", m_objectCount, DAC_CHAN_MAX); } } @@ -125,7 +125,7 @@ DacESP32::DacESP32(dac_channel_t channel) // DacESP32::DacESP32(gpio_num_t pin) : DacESP32((dac_channel_t)(pin == DAC_CHANNEL_1_GPIO_NUM) ? DAC_CHANNEL_1 : - (pin == DAC_CHANNEL_2_GPIO_NUM) ? DAC_CHANNEL_2 : DAC_CHANNEL_UNDEFINED) + (pin == DAC_CHANNEL_2_GPIO_NUM) ? DAC_CHANNEL_2 : DAC_CHAN_UNDEFINED) { } @@ -137,7 +137,7 @@ DacESP32::~DacESP32() // decrease object counter m_objectCount--; - if (m_channel != DAC_CHANNEL_UNDEFINED) { + if (m_channel != DAC_CHAN_UNDEFINED) { dac_output_disable(m_channel); } @@ -169,7 +169,7 @@ esp_err_t DacESP32::setChannel(dac_channel_t channel) } if (m_channel != channel) { - if (m_channel != DAC_CHANNEL_UNDEFINED) { + if (m_channel != DAC_CHAN_UNDEFINED) { dac_output_disable(m_channel); } dac_output_disable(channel); @@ -182,7 +182,7 @@ esp_err_t DacESP32::setChannel(dac_channel_t channel) esp_err_t DacESP32::setPin(gpio_num_t pin) { return setChannel((dac_channel_t)(pin == DAC_CHANNEL_1_GPIO_NUM) ? DAC_CHANNEL_1 : - (pin == DAC_CHANNEL_2_GPIO_NUM) ? DAC_CHANNEL_2 : DAC_CHANNEL_UNDEFINED); + (pin == DAC_CHANNEL_2_GPIO_NUM) ? DAC_CHANNEL_2 : DAC_CHAN_UNDEFINED); } // diff --git a/src/DacESP32.h b/src/DacESP32.h index 7fc63c0..df6a908 100644 --- a/src/DacESP32.h +++ b/src/DacESP32.h @@ -69,9 +69,10 @@ #define RTCIO_PAD_PDAC_DAC_XPD_FORCE_V 0x1 #define RTCIO_PAD_PDAC_DAC_XPD_FORCE_S 10 -#define DAC_CHANNEL_UNDEFINED (dac_channel_t) -1 +#define DAC_CHAN_UNDEFINED (dac_channel_t) -1 +#define DAC_CHAN_MAX (dac_channel_t) 2 #define DAC_CW_OFFSET_DEFAULT 0 -#define CK8M_DIV_MAX 7 +#define CK8M_DIV_MAX 7 // Master clock for digital controller section of both DAC & ADC systems. // According to spec the frequency is approximately 8MHz. Don't change value.