Microchip® Advanced Software Framework

system_task_manager.c File Reference

This is the implementation of LoRaWAN system task manager.

Copyright (c) 2018 Microchip Technology Inc. and its subsidiaries.

#include "system_init.h"
#include "atomic.h"
#include "system_task_manager.h"

Macros

#define SYSTEM_TASK_ID_COUNT   5u
 

Functions

SYSTEM_TaskStatus_t APP_TaskHandler (void)
 This function is called to process APP task. SHOULD be defined in APP. More...
 
SYSTEM_TaskStatus_t LORAWAN_TaskHandler (void)
 This function is called to process LORAWAN task. SHOULD be defined in LORAWAN. More...
 
SYSTEM_TaskStatus_t PDS_TaskHandler (void)
 This function is called to process pds task. SHOULD be defined in PDS. More...
 
SYSTEM_TaskStatus_t RADIO_TaskHandler (void)
 This function is called to process RADIO task. SHOULD be defined in RADIO. More...
 
void SYSTEM_PostTask (SYSTEM_Task_t task)
 Posts a task to the task manager, which is later processed by the task handler of the corresponding stack layer. More...
 
bool SYSTEM_ReadyToSleep (void)
 Returns the readiness of the system for sleep. More...
 
void SYSTEM_RunTasks (void)
 System tasks execution entry point. More...
 
SYSTEM_TaskStatus_t TIMER_TaskHandler (void)
 This function is called to process system timer task. SHOULD be defined in TIMER. More...
 

Variables

static volatile uint16_t sysTaskFlag = 0u
 
static SYSTEM_TaskStatus_t(* taskHandlers [SYSTEM_TASK_ID_COUNT])(void)
 

#define SYSTEM_TASK_ID_COUNT   5u

Referenced by SYSTEM_RunTasks().

SYSTEM_TaskStatus_t APP_TaskHandler ( void  )

This function is called to process APP task. SHOULD be defined in APP.

References APP_TASK_ID, APP_TASKS_COUNT, appTaskFlags, appTaskHandlers, ATOMIC_SECTION_ENTER, ATOMIC_SECTION_EXIT, SYSTEM_PostTask(), and SYSTEM_TASK_SUCCESS.

Referenced by main(), and wsndemo_task().

SYSTEM_TaskStatus_t LORAWAN_TaskHandler ( void  )

This function is called to process LORAWAN task. SHOULD be defined in LORAWAN.

SYSTEM_TaskStatus_t PDS_TaskHandler ( void  )

This function is called to process pds task. SHOULD be defined in PDS.

This function is called to process pds task. SHOULD be defined in PDS.

SYSTEM_TaskStatus_t RADIO_TaskHandler ( void  )

This function is called to process RADIO task. SHOULD be defined in RADIO.

void SYSTEM_PostTask ( SYSTEM_Task_t  task)

Posts a task to the task manager, which is later processed by the task handler of the corresponding stack layer.

A task is processed when the SYSTEM_RunTasks() function.
IDs of the tasks are listed in the SYSTEM_Task_t enum. Each task has its own priority and is called only if there is no any task with higher priority.
A handler is called when respective task can be run. Each task has its own task handler.
Correspondence between tasks and handlers is listed below:
RADIO RADIO_TaskHandler()
HAL - HAL_TaskHandler()
LORAWAN - LORAWAN_TaskHandler()
APP - APP_TaskHandler()

Parameters
[in]task- ID of the posted task.

References ATOMIC_SECTION_ENTER, ATOMIC_SECTION_EXIT, and sysTaskFlag.

Referenced by APP_TaskHandler(), appPostTask(), messageTimerCb(), MSG_Send(), PDS_TaskHandler(), pdsPostTask(), processRunRestoreBand(), processRxDataAvailable(), and Stack_Init().

bool SYSTEM_ReadyToSleep ( void  )

Returns the readiness of the system for sleep.

Returns
'true' if the system is ready, 'false' otherwise

References sysTaskFlag.

Referenced by PMM_Sleep().

void SYSTEM_RunTasks ( void  )

System tasks execution entry point.

This function is called by the stack or from the main()

References ATOMIC_SECTION_ENTER, ATOMIC_SECTION_EXIT, sysTaskFlag, SYSTEM_TASK_ID_COUNT, and taskHandlers.

Referenced by main(), and pxp_monitor_start_scan().

SYSTEM_TaskStatus_t TIMER_TaskHandler ( void  )

This function is called to process system timer task. SHOULD be defined in TIMER.

volatile uint16_t sysTaskFlag = 0u
static
SYSTEM_TaskStatus_t(* taskHandlers[SYSTEM_TASK_ID_COUNT])(void)
static
Initial value:
={
}
SYSTEM_TaskStatus_t PDS_TaskHandler(void)
This function is called to process pds task. SHOULD be defined in PDS.
Definition: pds_task_handler.c:118
SYSTEM_TaskStatus_t RADIO_TaskHandler(void)
This function is called to process RADIO task. SHOULD be defined in RADIO.
SYSTEM_TaskStatus_t TIMER_TaskHandler(void)
This function is called to process system timer task. SHOULD be defined in TIMER. ...
SYSTEM_TaskStatus_t APP_TaskHandler(void)
This function is called to process APP task. SHOULD be defined in APP.
Definition: enddevice_demo.c:1062
SYSTEM_TaskStatus_t LORAWAN_TaskHandler(void)
This function is called to process LORAWAN task. SHOULD be defined in LORAWAN.

Referenced by SYSTEM_RunTasks().