| Digital Power Starter Kit 3 Firmware dsPIC33C Boost Converter Voltage Mode Control Example |

apps.c
1 /*
2 * File: apps.c
3 * Author: M91406
4 *
5 * Created on June 10, 2021, 1:06 PM
6 */
7
8
9 #include <xc.h> // include processor files - each processor file is guarded.
10 #include <stdint.h> // include standard integer data types
11 #include <stdbool.h> // include standard boolean data types
12 #include <stddef.h> // include standard definition data types
13
14 #include "apps.h" // include application layer header file
15 #include "os/apptask_typedef.h" // include task object data structure declarations
16
17 /****************************************************************************************************
18 * @ingroup application-layer-user-tasks-configuration
19 * @var appTask_LED
20 * @brief LED User Task declaration and configuration
21 *****************************************************************************************************/
22 volatile struct APPLICATION_TASK_s appLed =
23 {
24 .Functions.Initialize = &appLED_Initialize,
25 .Functions.Start = &appLED_Start,
26 .Functions.Execute = &appLED_Execute,
27 .Functions.Dispose = &appLED_Dispose,
28
29 .Settings.execClass = APP_CLASS_LOW_PRIORITY,
30 .Settings.Period = 1000,
31 .Settings.Offset = 0,
32
33 .Status.enabled = true
34 };
35
36 /****************************************************************************************************
37 * @ingroup application-layer-user-tasks-configuration
38 * @var appPushButtonConfig
39 * @brief Task configuration of the Push Button User Task
40 *****************************************************************************************************/
41 volatile struct APPLICATION_TASK_s appPushButton =
42 {
43 .Functions.Initialize = &appPushButton_Initialize,
44 .Functions.Start = &appPushButton_Start,
45 .Functions.Execute = &appPushButton_Execute,
46 .Functions.Dispose = &appPushButton_Dispose,
47
48 .Settings.execClass = APP_CLASS_LOW_PRIORITY,
49 .Settings.Period = 200,
50 .Settings.Offset = 20,
51
52 .Status.enabled = true
53 };
54
55 /****************************************************************************************************
56 * @ingroup application-layer-user-tasks-configuration
57 * @var appLcdConfig
58 * @brief Task configuration of the LCD User Task
59 *****************************************************************************************************/
60 volatile struct APPLICATION_TASK_s appLcd =
61 {
62 .Functions.Initialize = &appLCD_Initialize,
63 .Functions.Start = &appLCD_Start,
64 .Functions.Execute = &appLCD_Execute,
65 .Functions.Dispose = &appLCD_Dispose,
66
67 .Settings.execClass = APP_CLASS_LOW_PRIORITY,
68 .Settings.Period = 2000,
69 .Settings.Offset = 40,
70
71 .Status.enabled = true
72 };
73
74 /****************************************************************************************************
75 * @ingroup application-layer-user-tasks-configuration
76 * @var appTask_GUI
77 * @brief GUI User Task declaration and configuration
78 *****************************************************************************************************/
79 //volatile struct APPLICATION_TASK_s appGui =
80 //{
81 // .Functions.Initialize = &appGUI_Initialize, ///< Pointer to user task INITIALIZATION function
82 // .Functions.Start = &appGUI_Start, ///< Pointer to user task START function
83 // .Functions.Execute = &appGUI_Execute, ///< Pointer to user task EXECUTE function
84 // .Functions.Dispose = &appGUI_Dispose, ///< Pointer to user task DISPOSE function
85 //
86 // .Settings.execClass = APP_CLASS_LOW_PRIORITY, ///< Application task lass (high- or low-priority)
87 // .Settings.Period = 1000, ///< Task execution period in OS task manager call ticks
88 // .Settings.Offset = 40, ///< Task execution offset in OS task manager call ticks
89 //
90 // .Status.enabled = true ///< Enable this task right after startup
91 //};
92
93 /****************************************************************************************************
94 * @ingroup application-layer-user-tasks-configuration
95 * @var appPowerSupplyConfig
96 * @brief Task configuration of the Power Supply User Task
97 *****************************************************************************************************/
98 volatile struct APPLICATION_TASK_s appPowerSupply =
99 {
100 .Functions.Initialize = &appPowerSupply_Initialize,
101 .Functions.Start = &appPowerSupply_Start,
102 .Functions.Execute = &appPowerSupply_Execute,
103 .Functions.Dispose = &appPowerSupply_Stop,
104
105 .Settings.execClass = APP_CLASS_HIGH_PRIORITY,
106 .Settings.Period = 0,
107 .Settings.Offset = 0,
108
109 .Status.enabled = true
110 };
111
112 /****************************************************************************************************
113 * @ingroup application-layer-user-tasks-configuration
114 * @var appFaultMonitorConfig
115 * @brief Task configuration of the Power Supply User Task
116 *****************************************************************************************************/
117 volatile struct APPLICATION_TASK_s appFaultMonitor =
118 {
119 .Functions.Initialize = &appFaultMonitor_Initialize,
120 .Functions.Start = &appFaultMonitor_Start,
121 .Functions.Execute = &appFaultMonitor_Execute,
122 .Functions.Dispose = &appFaultMonitor_Dispose,
123
124 .Settings.execClass = APP_CLASS_HIGH_PRIORITY,
125 .Settings.Period = 0,
126 .Settings.Offset = 0,
127
128 .Status.enabled = true
129 };
130
131 /***********************************************************************************
132 * @ingroup application-layer-user-tasks-configuration
133 * @var Queue_Execute
134 * @brief Function pointer array listing all user-tasks of this application
135 * @details
136 * The task list is an array capturing all static tasks of the application.
137 * Each task is an independent, functional entity serving a specific purpose,
138 * and is performing a specific function respectively. The order in which tasks
139 * are added to this list does not reflect their importance/priority and only
140 * serves the purpose of exposing them to the operating system, which will then
141 * group and execute them in priority queues.
142 *
143 * The specific settings of each task can be configured in their respective
144 * settings data structure, where execution period, execution offset and
145 * priority can be defined.
146 *
147 **********************************************************************************/
148 volatile struct APPLICATION_TASK_s* Queue_ExecuteSequence[] =
149 {
150 &appLed,
151 // &appGui, ///< Application Task #0: GUI Task
152 &appLcd,
153 &appPushButton,
154 &appPowerSupply,
155 &appFaultMonitor
156 };
157
158 /***********************************************************************************
159 * @ingroup application-layer-user-tasks-configuration
160 * @var TaskList_Size
161 * @brief Size of the task list covering all user-task managed by the OS
162 * @details
163 * The size of the application task array TaskList needs to be known by the
164 * operating system for runtime control. This variable does not have to be
165 * updated by users. The size of the array will be automatically updated at
166 * compile time.
167 **********************************************************************************/
168 volatile uint16_t Queue_ExecuteSequence_Size = (sizeof(Queue_ExecuteSequence)/sizeof(Queue_ExecuteSequence[0]));
169
170 /***********************************************************************************
171 * @ingroup application-layer-user-tasks-configuration
172 * @var TaskList_StartSequence
173 * @brief Function pointer array listing all user-task start-up functions
174 * @details
175 * The Start Sequence task list covers all user-task Start functions. These
176 * tasks will be called after the user-task Initialize functions have been
177 * executed. It is recommended to structure the code of user-tasks in a way
178 * that the Start function puts the task and all related global variables and
179 * data objects into a defined, initial condition and enables all required
180 * features.
181 *
182 * The list will be executed by the operating system in order of appearance.
183 * Hence, lower indices will be called before higher indices. This allows
184 * programmers to define a deterministic startup sequence of the user application
185 * firmware.
186 **********************************************************************************/
187 volatile struct APPLICATION_TASK_s* Queue_StartSequence[] =
188 {
189 &appLed,
190 // &appGui, ///< Task Startup Sequence Function #0: Start GUI Task
191 &appLcd,
192 &appPushButton,
193 &appPowerSupply,
194 &appFaultMonitor
195 };
196
197 /***********************************************************************************
198 * @ingroup application-layer-user-tasks-configuration
199 * @var Queue_StartSequence_Size
200 * @brief Size of the task list covering all user-task managed by the OS
201 * @details
202 * The size of the application task array TaskList needs to be known by the
203 * operating system for runtime control. This variable does not have to be
204 * updated by users. The size of the array will be automatically updated at
205 * compile time.
206 **********************************************************************************/
207 volatile uint16_t Queue_StartSequence_Size = (sizeof(Queue_StartSequence)/sizeof(Queue_StartSequence[0]));
208
209
210 /***********************************************************************************
211 * @ingroup application-layer-user-tasks-configuration
212 * @var Queue_Initialize
213 * @brief Function pointer array listing all user-task start-up functions
214 * @details
215 * The Start Sequence task list covers all user-task Start functions. These
216 * tasks will be called after the user-task Initialize functions have been
217 * executed. It is recommended to structure the code of user-tasks in a way
218 * that the Start function puts the task and all related global variables and
219 * data objects into a defined, initial condition and enables all required
220 * features.
221 *
222 * The list will be executed by the operating system in order of appearance.
223 * Hence, lower indices will be called before higher indices. This allows
224 * programmers to define a deterministic startup sequence of the user application
225 * firmware.
226 **********************************************************************************/
227 volatile struct APPLICATION_TASK_s* Queue_InitializeSequence[] =
228 {
229 &appLed,
230 // &appGui, ///< Task Startup Sequence Function #0: Start GUI Task
231 &appLcd,
232 &appPushButton,
233 &appPowerSupply,
234 &appFaultMonitor
235 };
236
237 /***********************************************************************************
238 * @ingroup application-layer-user-tasks-configuration
239 * @var Queue_StartSequence_Size
240 * @brief Size of the task list covering all user-task managed by the OS
241 * @details
242 * The size of the application task array TaskList needs to be known by the
243 * operating system for runtime control. This variable does not have to be
244 * updated by users. The size of the array will be automatically updated at
245 * compile time.
246 **********************************************************************************/
247 volatile uint16_t Queue_InitializeSequence_Size = (sizeof(Queue_InitializeSequence)/sizeof(Queue_InitializeSequence[0]));
248
249 /***********************************************************************************
250 * @ingroup application-layer-user-tasks-configuration
251 * @var Queue_StopSequence
252 * @brief Function pointer array listing all user-task start-up functions
253 * @details
254 * The Start Sequence task list covers all user-task Start functions. These
255 * tasks will be called after the user-task Initialize functions have been
256 * executed. It is recommended to structure the code of user-tasks in a way
257 * that the Start function puts the task and all related global variables and
258 * data objects into a defined, initial condition and enables all required
259 * features.
260 *
261 * The list will be executed by the operating system in order of appearance.
262 * Hence, lower indices will be called before higher indices. This allows
263 * programmers to define a deterministic startup sequence of the user application
264 * firmware.
265 **********************************************************************************/
266 volatile struct APPLICATION_TASK_s* Queue_StopSequence[] =
267 {
268 &appPowerSupply,
269 &appFaultMonitor,
270 // &appGui, ///< Task Startup Sequence Function #5: Start GUI Task
271 &appPushButton,
272 &appLcd,
273 &appLed
274
275 };
276
277 /***********************************************************************************
278 * @ingroup application-layer-user-tasks-configuration
279 * @var Queue_StartSequence_Size
280 * @brief Size of the task list covering all user-task managed by the OS
281 * @details
282 * The size of the application task array TaskList needs to be known by the
283 * operating system for runtime control. This variable does not have to be
284 * updated by users. The size of the array will be automatically updated at
285 * compile time.
286 **********************************************************************************/
287 volatile uint16_t Queue_StopSequence_Size = (sizeof(Queue_StopSequence)/sizeof(Queue_StopSequence[0]));
288
289
290
291 // end of file
APPLICATION_TASK_s::Functions
volatile struct APPTASK_TASKLINK_s Functions
Function pointer to main API user task functions.
Definition: apptask_typedef.h:153
APPTASK_TASKLINK_s::Initialize
volatile uint16_t(* Initialize)(void)
Function pointer to INITIALIZATION routine.
Definition: apptask_typedef.h:114
APPLICATION_TASK_s
DESCRIPTION.
Definition: apptask_typedef.h:149