Skip to content

Add compatibility to Arduino Core 3.0.x and ESP32-IDF 5.xx #358

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/dscClassic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,21 @@ void dscClassicInterface::begin(Stream &_stream) {
timer1_enable(TIM_DIV16, TIM_EDGE, TIM_SINGLE);

// esp32 timer1 calls dscDataInterrupt() from dscClockInterrupt()

#elif defined(ESP32)
#if ESP_IDF_VERSION_MAJOR >= 5
timer1 = timerBegin(1000000);
timerStop(timer1);
timerAttachInterrupt(timer1, &dscDataInterrupt);
timerAlarm(timer1, 250, true, 0);
#elif
timer1 = timerBegin(1, 80, true);
timerStop(timer1);
timerAttachInterrupt(timer1, &dscDataInterrupt, true);
timerAlarmWrite(timer1, 250, true);
timerAlarmEnable(timer1);
#endif
#endif

// Generates an interrupt when the Keybus clock rises or falls - requires a hardware interrupt pin on Arduino/AVR
attachInterrupt(digitalPinToInterrupt(dscClockPin), dscClockInterrupt, CHANGE);
Expand All @@ -90,7 +98,9 @@ void dscClassicInterface::stop() {

// Disables esp32 timer1
#elif defined(ESP32)
#if ESP_IDF_VERSION_MAJOR < 5
timerAlarmDisable(timer1);
#endif
timerEnd(timer1);
#endif

Expand Down
9 changes: 9 additions & 0 deletions src/dscClassicKeypad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,22 @@ void dscClassicKeypadInterface::begin(Stream &_stream) {
timer1_write(5000);

// esp32 timer1 calls dscClockInterrupt()


#elif defined(ESP32)
#if ESP_IDF_VERSION_MAJOR >= 5
timer1 = timerBegin(1000000);
timerStop(timer1);
timerAttachInterrupt(timer1, &dscClockInterrupt);
timerAlarm(timer1, 1000, true, 0);
#elif
timer1 = timerBegin(1, 80, true);
timerStop(timer1);
timerAttachInterrupt(timer1, &dscClockInterrupt, true);
timerAlarmWrite(timer1, 1000, true);
timerAlarmEnable(timer1);
#endif
#endif

intervalStart = millis();

Expand Down
9 changes: 9 additions & 0 deletions src/dscKeybusInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,19 @@ void dscKeybusInterface::begin(Stream &_stream) {

// esp32 timer1 calls dscDataInterrupt() from dscClockInterrupt()
#elif defined(ESP32)
#if ESP_IDF_VERSION_MAJOR >= 5
timer1 = timerBegin(1000000);
timerStop(timer1);
timerAttachInterrupt(timer1, &dscDataInterrupt);
timerAlarm(timer1, 250, true, 0);
#elif
timer1 = timerBegin(1, 80, true);
timerStop(timer1);
timerAttachInterrupt(timer1, &dscDataInterrupt, true);
timerAlarmWrite(timer1, 250, true);
timerAlarmEnable(timer1);
#endif
#endif

// Generates an interrupt when the Keybus clock rises or falls - requires a hardware interrupt pin on Arduino/AVR
attachInterrupt(digitalPinToInterrupt(dscClockPin), dscClockInterrupt, CHANGE);
Expand All @@ -84,7 +91,9 @@ void dscKeybusInterface::stop() {

// Disables esp32 timer1
#elif defined(ESP32)
#if ESP_IDF_VERSION_MAJOR < 5
timerAlarmDisable(timer1);
#endif
timerEnd(timer1);
#endif

Expand Down
9 changes: 9 additions & 0 deletions src/dscKeybusReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,19 @@ void dscKeybusReaderInterface::begin(Stream &_stream) {

// esp32 timer1 calls dscDataInterrupt() from dscClockInterrupt()
#elif defined(ESP32)
#if ESP_IDF_VERSION_MAJOR >= 5
timer1 = timerBegin(1000000);
timerStop(timer1);
timerAttachInterrupt(timer1, &dscDataInterrupt);
timerAlarm(timer1, 250, true, 0);
#elif
timer1 = timerBegin(1, 80, true);
timerStop(timer1);
timerAttachInterrupt(timer1, &dscDataInterrupt, true);
timerAlarmWrite(timer1, 250, true);
timerAlarmEnable(timer1);
#endif
#endif

// Generates an interrupt when the Keybus clock rises or falls - requires a hardware interrupt pin on Arduino/AVR
attachInterrupt(digitalPinToInterrupt(dscClockPin), dscClockInterrupt, CHANGE);
Expand All @@ -84,7 +91,9 @@ void dscKeybusReaderInterface::stop() {

// Disables esp32 timer1
#elif defined(ESP32)
#if ESP_IDF_VERSION_MAJOR < 5
timerAlarmDisable(timer1);
#endif
timerEnd(timer1);
#endif

Expand Down
7 changes: 7 additions & 0 deletions src/dscKeypad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,19 @@ void dscKeypadInterface::begin(Stream &_stream) {

// esp32 timer1 calls dscClockInterrupt()
#elif defined(ESP32)
#if ESP_IDF_VERSION_MAJOR >= 5
timer1 = timerBegin(1000000);
timerStop(timer1);
timerAttachInterrupt(timer1, &dscClockInterrupt);
timerAlarm(timer1, 500, true, 0);
#elif
timer1 = timerBegin(1, 80, true);
timerStop(timer1);
timerAttachInterrupt(timer1, &dscClockInterrupt, true);
timerAlarmWrite(timer1, 500, true);
timerAlarmEnable(timer1);
#endif
#endif

intervalStart = millis();

Expand Down