From 5d4230d39bea552b0e7f8603036ca6124dc2b5a5 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sun, 29 Sep 2024 17:11:13 +0200 Subject: [PATCH] Attempt to fix Dali core 3 compilation (#22214) --- .../xdrv_89_esp32_dali.ino | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_89_esp32_dali.ino b/tasmota/tasmota_xdrv_driver/xdrv_89_esp32_dali.ino index 5168d077f..86a5ced0f 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_89_esp32_dali.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_89_esp32_dali.ino @@ -78,7 +78,8 @@ struct DALI { * @param None * @retval None */ -void IRAM_ATTR DALI_Tick_Handler(void) +void IRAM_ATTR DALI_Tick_Handler(void); +void DALI_Tick_Handler(void) { if (getDaliFlag() == DALI_RECEIVING_DATA) { @@ -97,7 +98,8 @@ void IRAM_ATTR DALI_Tick_Handler(void) */ void enableDaliRxInterrupt() { Dali->flag = DALI_NO_ACTION; - timerAlarmDisable(Dali->timer); +// timerAlarmDisable(Dali->timer); + timerStop(Dali->timer); attachInterrupt(Pin(GPIO_DALI_RX), receiveDaliData, FALLING); } @@ -107,7 +109,8 @@ void enableDaliRxInterrupt() { * @retval None */ void disableRxInterrupt() { - timerAlarmEnable(Dali->timer); +// timerAlarmEnable(Dali->timer); + timerStart(Dali->timer); detachInterrupt(Pin(GPIO_DALI_RX)); } @@ -383,9 +386,18 @@ void DaliPreInit() { AddLog(LOG_LEVEL_INFO, PSTR("DLI: Memory allocation error")); return; } - Dali->timer = timerBegin(DALI_TIMER, 13, true); - timerAttachInterrupt(Dali->timer, &DALI_Tick_Handler, true); - timerAlarmWrite(Dali->timer, 641, true); +// Dali->timer = timerBegin(DALI_TIMER, 13, true); + Dali->timer = timerBegin(12307692); // 160MHz????? / 13 + if (nullptr == Dali->timer) { + AddLog(LOG_LEVEL_INFO, PSTR("DLI: Bad timer init")); + free(Dali); + Dali = nullptr; + return; + } +// timerAttachInterrupt(Dali->timer, &DALI_Tick_Handler, true); + timerAttachInterrupt(Dali->timer, &DALI_Tick_Handler); +// timerAlarmWrite(Dali->timer, 641, true); + timerAlarm(Dali->timer, 641, true, 0); attachInterrupt(Pin(GPIO_DALI_RX), receiveDaliData, FALLING); enableDaliRxInterrupt();