Skip to content
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
19 changes: 13 additions & 6 deletions src/dscClassic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,15 @@ void dscClassicInterface::begin(Stream &_stream) {

// esp32 timer1 calls dscDataInterrupt() from dscClockInterrupt()
#elif defined(ESP32)
timer1 = timerBegin(1, 80, true);
//timer1 = timerBegin(1, 80, true);
//timerStop(timer1);
//timerAttachInterrupt(timer1, &dscDataInterrupt, true);
//timerAlarmWrite(timer1, 250, true);
//timerAlarmEnable(timer1);
timer1 = timerBegin(1000000); // 1 MHz = 1 µs per tick
timerStop(timer1);
timerAttachInterrupt(timer1, &dscDataInterrupt, true);
timerAlarmWrite(timer1, 250, true);
timerAlarmEnable(timer1);
timerAttachInterrupt(timer1, &dscDataInterrupt);
timerAlarm(timer1, 250, true, 0); // 1000 ticks = 1 ms interval
#endif

// Generates an interrupt when the Keybus clock rises or falls - requires a hardware interrupt pin on Arduino/AVR
Expand All @@ -89,8 +93,11 @@ void dscClassicInterface::stop() {

// Disables esp32 timer1
#elif defined(ESP32)
timerAlarmDisable(timer1);
timerEnd(timer1);
//timerAlarmDisable(timer1);
//timerEnd(timer1);
timerDetachInterrupt(timer1); // Detach the interrupt handler
timerStop(timer1); // Stop counting
timerEnd(timer1); // Free the timer resource
#endif

// Disables the Keybus clock pin interrupt
Expand Down
12 changes: 8 additions & 4 deletions src/dscClassicKeypad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,15 @@ void dscClassicKeypadInterface::begin(Stream &_stream) {

// esp32 timer1 calls dscClockInterrupt()
#elif defined(ESP32)
timer1 = timerBegin(1, 80, true);
//timer1 = timerBegin(1, 80, true);
//timerStop(timer1);
//timerAttachInterrupt(timer1, &dscClockInterrupt, true);
//timerAlarmWrite(timer1, 1000, true);
//timerAlarmEnable(timer1);
timer1 = timerBegin(1000000); // 1 MHz = 1 µs per tick
timerStop(timer1);
timerAttachInterrupt(timer1, &dscClockInterrupt, true);
timerAlarmWrite(timer1, 1000, true);
timerAlarmEnable(timer1);
timerAttachInterrupt(timer1, &dscClockInterrupt);
timerAlarm(timer1, 1000, true, 0); // 1000 ticks = 1 ms interval
#endif

intervalStart = millis();
Expand Down
19 changes: 13 additions & 6 deletions src/dscKeybusInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,15 @@ void dscKeybusInterface::begin(Stream &_stream) {

// esp32 timer1 calls dscDataInterrupt() from dscClockInterrupt()
#elif defined(ESP32)
timer1 = timerBegin(1, 80, true);
//timer1 = timerBegin(1, 80, true);
//timerStop(timer1);
//timerAttachInterrupt(timer1, &dscDataInterrupt, true);
//timerAlarmWrite(timer1, 250, true);
//timerAlarmEnable(timer1);
timer1 = timerBegin(1000000); // 1 MHz = 1 µs per tick
timerStop(timer1);
timerAttachInterrupt(timer1, &dscDataInterrupt, true);
timerAlarmWrite(timer1, 250, true);
timerAlarmEnable(timer1);
timerAttachInterrupt(timer1, &dscDataInterrupt);
timerAlarm(timer1, 250, true, 0); // 1000 ticks = 1 ms interval
#endif

// Generates an interrupt when the Keybus clock rises or falls - requires a hardware interrupt pin on Arduino/AVR
Expand All @@ -87,8 +91,11 @@ void dscKeybusInterface::stop() {

// Disables esp32 timer1
#elif defined(ESP32)
timerAlarmDisable(timer1);
timerEnd(timer1);
//timerAlarmDisable(timer1);
//timerEnd(timer1);
timerDetachInterrupt(timer1); // Detach the interrupt handler
timerStop(timer1); // Stop counting
timerEnd(timer1); // Free the timer resource
#endif

// Disables the Keybus clock pin interrupt
Expand Down
12 changes: 8 additions & 4 deletions src/dscKeypad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,15 @@ void dscKeypadInterface::begin(Stream &_stream) {

// esp32 timer1 calls dscClockInterrupt()
#elif defined(ESP32)
timer1 = timerBegin(1, 80, true);
//timer1 = timerBegin(1, 80, true);
//timerStop(timer1);
//timerAttachInterrupt(timer1, &dscClockInterrupt, true);
//timerAlarmWrite(timer1, 500, true);
//timerAlarmEnable(timer1);
timer1 = timerBegin(1000000); // 1 MHz = 1 µs per tick
timerStop(timer1);
timerAttachInterrupt(timer1, &dscClockInterrupt, true);
timerAlarmWrite(timer1, 500, true);
timerAlarmEnable(timer1);
timerAttachInterrupt(timer1, &dscClockInterrupt);
timerAlarm(timer1, 500, true, 0); // 1000 ticks = 1 ms interval
#endif

intervalStart = millis();
Expand Down