Skip to content

Commit

Permalink
Fix bug where ESP32 without DAC wouldn't release LEDC channel
Browse files Browse the repository at this point in the history
(cherry picked from commit e920c21)
  • Loading branch information
vickash committed Jul 26, 2024
1 parent e97fbb7 commit c50a368
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/lib/DenkoCoreIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ void Denko::setMode(byte p, byte m) {
// 111 = Digital Input/Output (ESP32 Only?)
m = m & 0b00000111;

#if defined(ESP32) && defined(SOC_DAC_SUPPORTED)
// Free the LEDC channel if leaving PWM mode.
#if defined(ESP32)
// Free the LEDC channel if leaving PWM mode.
if (m != 0b010) releaseLEDC(p);

// Disable attached DAC if leaving DAC mode.
if (m != 0b100) dacDisable(p);
#if defined(SOC_DAC_SUPPORTED)
if (m != 0b100) dacDisable(p);
#endif
#endif

// On the SAMD21 and RA4M1, mode needs to be INPUT when using the DAC.
Expand Down

0 comments on commit c50a368

Please sign in to comment.