Skip to content

Commit

Permalink
Fix for Arduino ESP32 version 3.x.x
Browse files Browse the repository at this point in the history
  • Loading branch information
yellobyte committed Jul 27, 2024
1 parent a2ba22b commit a10ac1a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "DacESP32",
"version": "1.1.0",
"version": "1.1.1",
"platforms":
[
"espressif32"
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=DacESP32
version=1.1.0
version=1.1.1
author=Thomas Jentzsch
maintainer=Thomas Jentzsch <[email protected]>
sentence=Arduino library for using the ESP32 DAC output channels fast and easy.
Expand Down
16 changes: 8 additions & 8 deletions src/DacESP32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; \
}
Expand All @@ -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;
}

Expand All @@ -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);
}
}

Expand All @@ -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)
{
}

Expand All @@ -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);
}

Expand Down Expand Up @@ -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);
Expand All @@ -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);
}

//
Expand Down
5 changes: 3 additions & 2 deletions src/DacESP32.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit a10ac1a

Please sign in to comment.