@@ -230,6 +230,7 @@ typedef struct {
230
230
******************************************************************************/
231
231
static QueueHandle_t xCmdQueue ;
232
232
static QueueHandle_t xRxQueue ;
233
+ static QueueHandle_t xCbQueue ;
233
234
static EventGroupHandle_t LoRaEvents ;
234
235
235
236
static RadioEvents_t RadioEvents ;
@@ -249,7 +250,7 @@ static const char *modlora_nvs_data_key[E_LORA_NVS_NUM_KEYS] = { "JOINED", "UPLN
249
250
"MACPARAMS" , "CHANNELS" , "SRVACK" , "MACNXTTX" ,
250
251
"MACBUFIDX" , "MACRPTIDX" , "MACBUF" , "MACRPTBUF" ,
251
252
"REGION" , "CHANMASK" , "CHANMASKREM" };
252
-
253
+ DRAM_ATTR static modlora_timerCallback modlora_timer_cb ;
253
254
/******************************************************************************
254
255
DECLARE PUBLIC DATA
255
256
******************************************************************************/
@@ -259,6 +260,7 @@ extern TaskHandle_t xLoRaTaskHndl;
259
260
DECLARE PRIVATE FUNCTIONS
260
261
******************************************************************************/
261
262
static void TASK_LoRa (void * pvParameters );
263
+ static void TASK_LoRa_Timer (void * pvParameters );
262
264
static void OnTxDone (void );
263
265
static void OnRxDone (uint8_t * payload , uint32_t timestamp , uint16_t size , int16_t rssi , int8_t snr , uint8_t sf );
264
266
static void OnTxTimeout (void );
@@ -306,6 +308,7 @@ SemaphoreHandle_t xLoRaSigfoxSem;
306
308
void modlora_init0 (void ) {
307
309
xCmdQueue = xQueueCreate (LORA_CMD_QUEUE_SIZE_MAX , sizeof (lora_cmd_data_t ));
308
310
xRxQueue = xQueueCreate (LORA_DATA_QUEUE_SIZE_MAX , sizeof (lora_rx_data_t ));
311
+ xCbQueue = xQueueCreate (LORA_CB_QUEUE_SIZE_MAX , sizeof (modlora_timerCallback ));
309
312
LoRaEvents = xEventGroupCreate ();
310
313
#if defined(FIPY ) || defined(LOPY4 )
311
314
xLoRaSigfoxSem = xSemaphoreCreateMutex ();
@@ -320,6 +323,7 @@ void modlora_init0(void) {
320
323
BoardInitPeriph ();
321
324
322
325
xTaskCreatePinnedToCore (TASK_LoRa , "LoRa" , LORA_STACK_SIZE / sizeof (StackType_t ), NULL , LORA_TASK_PRIORITY , & xLoRaTaskHndl , 1 );
326
+ xTaskCreatePinnedToCore (TASK_LoRa_Timer , "LoRa_Timer_callback" , LORA_TIMER_STACK_SIZE / sizeof (StackType_t ), NULL , LORA_TIMER_TASK_PRIORITY , & xLoRaTimerTaskHndl , 1 );
323
327
}
324
328
325
329
bool modlora_nvs_set_uint (uint32_t key_idx , uint32_t value ) {
@@ -352,6 +356,14 @@ bool modlora_nvs_get_blob(uint32_t key_idx, void *value, uint32_t *length) {
352
356
return false;
353
357
}
354
358
359
+ IRAM_ATTR void modlora_set_timer_callback (modlora_timerCallback cb )
360
+ {
361
+ modlora_timer_cb = cb ;
362
+ {
363
+ if (cb != NULL )
364
+ xQueueSendFromISR (xCbQueue , & cb , NULL );
365
+ }
366
+ }
355
367
/******************************************************************************
356
368
DEFINE PRIVATE FUNCTIONS
357
369
******************************************************************************/
@@ -1030,6 +1042,25 @@ static void TASK_LoRa (void *pvParameters) {
1030
1042
}
1031
1043
}
1032
1044
1045
+ static void TASK_LoRa_Timer (void * pvParameters ) {
1046
+
1047
+ static uint32_t thread_notification ;
1048
+
1049
+ for (;;)
1050
+ {
1051
+ thread_notification = ulTaskNotifyTake (pdTRUE , portMAX_DELAY );
1052
+ if (thread_notification ) {
1053
+
1054
+ modlora_timerCallback cb ;
1055
+ xQueueReceive (xCbQueue , & cb , 0 );
1056
+ if (cb != NULL )
1057
+ {
1058
+ cb ();
1059
+ }
1060
+ }
1061
+ }
1062
+ }
1063
+
1033
1064
static void lora_callback_handler (void * arg ) {
1034
1065
lora_obj_t * self = arg ;
1035
1066
0 commit comments