STM32 RTC Scheduler
RTC-based scheduler for ultra-low power applications
freertos_tasks_c_additions.h
Go to the documentation of this file.
1 
15 #ifndef FREERTOS_TASKS_C_ADDITIONS_H
16 #define FREERTOS_TASKS_C_ADDITIONS_H
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
27 TickType_t GetExpectedIdleTime(void)
28 {
29  TickType_t xReturn;
30  UBaseType_t uxHigherPriorityReadyTasks = pdFALSE;
31 
32  /* uxHigherPriorityReadyTasks takes care of the case where
33  configUSE_PREEMPTION is 0, so there may be tasks above the idle priority
34  task that are in the Ready state, even though the idle task is running. */
35 #if(configUSE_PORT_OPTIMISED_TASK_SELECTION == 0)
36  {
37  if(uxTopReadyPriority > tskIDLE_PRIORITY)
38  {
39  uxHigherPriorityReadyTasks = pdTRUE;
40  }
41  }
42 #else
43  {
44  const UBaseType_t uxLeastSignificantBit = (UBaseType_t)0x01;
45 
46  /* When port optimised task selection is used the uxTopReadyPriority
47  variable is used as a bit map. If bits other than the least
48  significant bit are set then there are tasks that have a priority
49  above the idle priority that are in the Ready state. This takes
50  care of the case where the co-operative scheduler is in use. */
51  if(uxTopReadyPriority > uxLeastSignificantBit)
52  {
53  uxHigherPriorityReadyTasks = pdTRUE;
54  }
55  }
56 #endif
57 
58  if(pxCurrentTCB->uxPriority > tskIDLE_PRIORITY)
59  {
60  xReturn = 0;
61  }
62  else if(listCURRENT_LIST_LENGTH(&(pxReadyTasksLists[tskIDLE_PRIORITY])) > 1)
63  {
64  /* There are other idle priority tasks in the ready state. If
65  time slicing is used then the very next tick interrupt must be
66  processed. */
67  xReturn = 0;
68  }
69  else if(uxHigherPriorityReadyTasks != pdFALSE)
70  {
71  /* There are tasks in the Ready state that have a priority above the
72  idle priority. This path can only be reached if
73  configUSE_PREEMPTION is 0. */
74  xReturn = 0;
75  }
76  else
77  {
78  xReturn = xNextTaskUnblockTime - xTickCount;
79  }
80 
81  return xReturn;
82 }
83 
90 UBaseType_t IsDelayedTaskListEmpty(void)
91 {
92  return (listCURRENT_LIST_LENGTH(pxDelayedTaskList)) ? pdFALSE : pdTRUE;
93 }
94 
95 #ifdef __cplusplus
96 }
97 #endif
98 
99 #endif /* FREERTOS_TASKS_C_ADDITIONS_H */
IsDelayedTaskListEmpty
UBaseType_t IsDelayedTaskListEmpty(void)
Check whether the delayed task list of RTOS is empty.
Definition: freertos_tasks_c_additions.h:90
GetExpectedIdleTime
TickType_t GetExpectedIdleTime(void)
Get the expected idle time from RTOS kernel.
Definition: freertos_tasks_c_additions.h:27