Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit efa74cb

Browse files
author
iwahdan88
committed
[PYFW-325] Hardware timer for Lora ticks fully implemented #close #comment Fix tested
1 parent 1c79bea commit efa74cb

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

esp32/hal/esp32_mphal.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ IRAM_ATTR static void HAL_TimerCallback (void* arg) {
5858
HAL_tick_user_cb();
5959
}
6060

61-
TIMERG0.int_clr_timers.t1 = 1;
62-
TIMERG0.hw_timer[1].update=1;
63-
TIMERG0.hw_timer[1].config.alarm_en = 1;
61+
TIMERG0.int_clr_timers.t1 = 1;
62+
TIMERG0.hw_timer[1].update=1;
63+
TIMERG0.hw_timer[1].config.alarm_en = 1;
6464

6565
}
6666

esp32/lora/timer-board.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,17 @@ static TimerTime_t TimerTickCounterContext = 0;
5656
* Value trigging the IRQ
5757
*/
5858
DRAM_ATTR volatile TimerTime_t TimeoutCntValue = 0;
59-
59+
extern TaskHandle_t xLoRaTimerTaskHndl;
6060

6161
static IRAM_ATTR void TimerCallback (void) {
62+
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
63+
6264
TimerTickCounter++;
6365
if (TimeoutCntValue > 0 && TimerTickCounter == TimeoutCntValue) {
6466
TimerIrqHandler();
67+
// Notify the thread so it will wake up when the ISR is complete
68+
vTaskNotifyGiveFromISR(xLoRaTimerTaskHndl, &xHigherPriorityTaskWoken);
69+
portYIELD_FROM_ISR();
6570
}
6671
}
6772

esp32/mods/modlora.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -1052,10 +1052,12 @@ static void TASK_LoRa_Timer (void *pvParameters) {
10521052
if (thread_notification) {
10531053

10541054
modlora_timerCallback cb;
1055-
xQueueReceive(xCbQueue, &cb, 0);
1056-
if(cb != NULL)
1055+
while (pdTRUE == xQueueReceive(xCbQueue, &cb, 0))
10571056
{
1058-
cb();
1057+
if(cb != NULL)
1058+
{
1059+
cb();
1060+
}
10591061
}
10601062
}
10611063
}

lib/lora/system/timer.c

-5
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,6 @@ IRAM_ATTR void TimerIrqHandler( void )
229229
if( elapsedTimer->Callback != NULL )
230230
{
231231
modlora_set_timer_callback(elapsedTimer->Callback);
232-
233-
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
234-
// Notify the thread so it will wake up when the ISR is complete
235-
vTaskNotifyGiveFromISR(xLoRaTimerTaskHndl, &xHigherPriorityTaskWoken);
236-
portYIELD_FROM_ISR();
237232
}
238233
}
239234

0 commit comments

Comments
 (0)