|
5 | 5 | * Download the latest release from the official repository : |
6 | 6 | * |
7 | 7 | * <a style="font-weight:bold" href="https://github.com/kmilo17pet/QuarkTS/releases">QuarkTS Releases</a> |
8 | | -* |
| 8 | +* |
9 | 9 | * Unpack the release package and add the sources files to your project. |
10 | 10 | * |
11 | 11 | * @subsection q_cloneos Cloning QuarkTS |
|
35 | 35 | * @endcode |
36 | 36 | * |
37 | 37 | * @subsection q_getqconfig Get a copy of the OS configuration file |
38 | | -* The file @c qconfig.h provides specific @ref q_configmacros to customize |
39 | | -* several aspects of the OS. In order to build your solution with QuarkTS, you |
| 38 | +* The file @c qconfig.h provides specific @ref q_configmacros to customize |
| 39 | +* several aspects of the OS. In order to build your solution with QuarkTS, you |
40 | 40 | * should provided your own copy of this configuration file. You can obtain a copy |
41 | 41 | * with the default configuration by issuing the following command: |
42 | 42 | * |
|
45 | 45 | * @endcode |
46 | 46 | * |
47 | 47 | @section q_firststeps First steps |
48 | | -* Include the source files to your project. Also, make sure you add a copy of |
49 | | -* the file @c qconfig.h and modify it according to your needs. Setup your |
50 | | -* compiler including the path of the OS directory. Include the header file |
51 | | -* @c QuarkTS.h and setup the instance of the kernel using the qOS_Setup() |
52 | | -* inside the main thread to initialize te kernel, specify the reference clock and |
53 | | -* the idle-task ( see @ref q_timmingapproach). Additional configuration to the |
| 48 | +* Include the source files to your project. Also, make sure you add a copy of |
| 49 | +* the file @c qconfig.h and modify it according to your needs. Setup your |
| 50 | +* compiler including the path of the OS directory. Include the header file |
| 51 | +* @c QuarkTS.h and setup the instance of the kernel using the qOS_Setup() |
| 52 | +* inside the main thread to initialize te kernel, specify the reference clock and |
| 53 | +* the idle-task ( see @ref q_timmingapproach). Additional configuration to the |
54 | 54 | * target compiler may be required to add the path to the directory of header files. |
55 | 55 | * The code below shows a common initialization procedure in the main source file. |
56 | 56 | * |
57 | 57 | * File @c main.c |
58 | 58 | * @code{.c} |
59 | 59 | * #include "QuarkTS.h" |
60 | 60 | * #define TIMER_TICK ( 0.001f ) // 1ms |
61 | | -* |
| 61 | +* |
62 | 62 | * void main( void ) { |
63 | 63 | * //device startup with hardware-specific code |
64 | 64 | * HardwareSetup(); |
65 | 65 | * Configure_Periodic_Timer_Interrupt_1ms(); |
66 | 66 | * //end of device startup with hardware-specific code |
67 | | -* qOS_Setup( NULL , TIMER_TICK , IdleTask_Callback ); |
| 67 | +* qOS_Setup( NULL , TIMER_TICK , IdleTask_Callback, NULL ); |
68 | 68 | * // TODO: add Tasks to the scheduler scheme and run the OS |
69 | 69 | * } |
70 | 70 | * @endcode |
71 | 71 | * |
72 | 72 | * In the above code, the following considerations should be taken: |
73 | 73 | * - The function qOS_Setup() must be called before any interaction with the OS. |
74 | | -* - The procedure @c HardwareSetup() should be a function with all the hardware |
| 74 | +* - The procedure @c HardwareSetup() should be a function with all the hardware |
75 | 75 | * instructions needed to initialize the target system. |
76 | | -* - The procedure @c Configure_Periodic_Timer_Interrupt_1ms() should be a |
77 | | -* function with all the hardware instructions needed to initialize and enable a |
| 76 | +* - The procedure @c Configure_Periodic_Timer_Interrupt_1ms() should be a |
| 77 | +* function with all the hardware instructions needed to initialize and enable a |
78 | 78 | * timer with an overflow tick of one millisecond. |
79 | 79 | * |
80 | | -* Tasks can be later added to the scheduling scheme by simply calling |
| 80 | +* Tasks can be later added to the scheduling scheme by simply calling |
81 | 81 | * qOS_Add_Task() or any of the other available APIs for specific purpose tasks. |
82 | 82 | * |
83 | 83 | * @section q_os_demo Two simple demonstrative examples |
84 | 84 | * |
85 | 85 | * @subsection q_os_example1 A simple scheduling |
86 | | -* This example demonstrates a simple environment setup for multiple tasks. |
87 | | -* Initially, only @c task1 and @c task2 are enabled. @c task1 runs every 2 |
88 | | -* seconds 10 times and then stops. @c task2 runs every 3 seconds indefinitely. |
89 | | -* @c task1 enables @c task3 at its first run. @c task3 run every 5 seconds. |
90 | | -* @c task1 disables @c task3 on its last iteration and change @c task2 to run |
91 | | -* every 1/2 seconds. In the end, @c task2 is the only task running every 1/2 |
| 86 | +* This example demonstrates a simple environment setup for multiple tasks. |
| 87 | +* Initially, only @c task1 and @c task2 are enabled. @c task1 runs every 2 |
| 88 | +* seconds 10 times and then stops. @c task2 runs every 3 seconds indefinitely. |
| 89 | +* @c task1 enables @c task3 at its first run. @c task3 run every 5 seconds. |
| 90 | +* @c task1 disables @c task3 on its last iteration and change @c task2 to run |
| 91 | +* every 1/2 seconds. In the end, @c task2 is the only task running every 1/2 |
92 | 92 | * seconds. |
93 | 93 | * |
94 | 94 | * @code{.c} |
95 | 95 | * #include <stdio.h> |
96 | 96 | * #include <stdlib.h> |
97 | 97 | * #include <stdint.h> |
98 | 98 | * #include "BSP.h" |
99 | | -* |
| 99 | +* |
100 | 100 | * #include "QuarkTS.h" |
101 | 101 | * #define TIMER_TICK ( 0.001f ) /* 1ms */ |
102 | | -* |
| 102 | +* |
103 | 103 | * qTask_t task1, task2, task3; /*task nodes*/ |
104 | 104 | * /*==================================================================*/ |
105 | 105 | * void interrupt Timer0_ISR( void ) { |
|
108 | 108 | * /*==================================================================*/ |
109 | 109 | * void Task1_Callback( qEvent_t e ) { |
110 | 110 | * BSP_UART1_WriteString( "Task1" ); |
111 | | -* |
| 111 | +* |
112 | 112 | * if ( e->FirstIteration ) { |
113 | 113 | * qTask_Resume( &Task3 ); |
114 | 114 | * } |
115 | | -* |
| 115 | +* |
116 | 116 | * if ( e->LastIteration ) { |
117 | 117 | * qTask_Suspend( &Task3 ); |
118 | 118 | * qTask_Set_Time( &Task2, 0.5 ); |
|
131 | 131 | * HardwareSetup(); /*hardware initialization function*/ |
132 | 132 | * /*function to fire an interrupt at 1ms - timer tick*/ |
133 | 133 | * Configure_Periodic_Timer0_Interrupt_1ms(); |
134 | | -* |
135 | | -* qOS_Setup( NULL, TIMER_TICK, NULL ); |
| 134 | +* |
| 135 | +* qOS_Setup( NULL, TIMER_TICK, NULL, NULL ); |
136 | 136 | * qOS_Add_Task( &Task1, Task1_Callback, 50, 2.0f, 10, qEnabled, NULL ); |
137 | 137 | * qOS_Add_Task( &Task2, Task2_Callback, 50, 3.0f, qPeriodic, qEnabled, NULL ); |
138 | 138 | * qOS_Add_Task( &Task2, Task3_Callback, 50, 5.0f, qPeriodic, qDisabled, NULL ); |
|
144 | 144 | * |
145 | 145 | * @subsection q_os_example2 Using the task argument |
146 | 146 | * When adding tasks, they can accept a parameter of type pointer to void @c void* |
147 | | -* also called the storage pointer. This parameter could be used for multiple |
| 147 | +* also called the storage pointer. This parameter could be used for multiple |
148 | 148 | * applications, including storage, task identification, duplication removal and |
149 | | -* others. The following example shows the usage of this argument to avoid |
| 149 | +* others. The following example shows the usage of this argument to avoid |
150 | 150 | * callback duplication among tasks with the same behavior. |
151 | 151 | * |
152 | | -* Consider a scenario where you have to build a digital controller for several |
| 152 | +* Consider a scenario where you have to build a digital controller for several |
153 | 153 | * physical variables, for example, a PID controller for temperature, humidity and |
154 | | -* light. The PID algorithm will be the same for all variables. The only |
155 | | -* difference will be the variable input, the controlled output action and the |
156 | | -* PID gains. In this case, each of the PID tasks will utilize the same callback |
157 | | -* methods. The only difference will be the I/O parameters (specific for each |
| 154 | +* light. The PID algorithm will be the same for all variables. The only |
| 155 | +* difference will be the variable input, the controlled output action and the |
| 156 | +* PID gains. In this case, each of the PID tasks will utilize the same callback |
| 157 | +* methods. The only difference will be the I/O parameters (specific for each |
158 | 158 | * PID controller). |
159 | 159 | * |
160 | 160 | * Let’s define a PID data structure with the I/O variables and gains. |
|
169 | 169 | * float sp; /*Set-Point*/ |
170 | 170 | * float Kc, Ki, Kd; /*PID Gains*/ |
171 | 171 | * } PID_Params_t; |
172 | | -* |
| 172 | +* |
173 | 173 | * PID_Params_t TemperatureControl = { |
174 | 174 | * 0.0f, 0.0f, 0.0f, 0.0f, /*Initial IO state of yt and ut*/ |
175 | 175 | * 1.5f, /*time step*/ |
|
190 | 190 | * }; |
191 | 191 | * @endcode |
192 | 192 | * |
193 | | -* A task will be added to the scheme to collect the sensor data and apply |
| 193 | +* A task will be added to the scheme to collect the sensor data and apply |
194 | 194 | * the respective control output. |
195 | 195 | * |
196 | 196 | * @code{.c} |
|
208 | 208 | * } |
209 | 209 | * @endcode |
210 | 210 | * |
211 | | -* Then, three different tasks are created to apply the respective PID controller. |
212 | | -* Note that these tasks refer to the same callback method and we assign |
| 211 | +* Then, three different tasks are created to apply the respective PID controller. |
| 212 | +* Note that these tasks refer to the same callback method and we assign |
213 | 213 | * pointers to the respective variables. |
214 | 214 | * |
215 | 215 | * @code{.c} |
|
0 commit comments