Added a simplified accuracy test to VT Storm for continuous timers.
@@ -52,8 +52,10 @@ | ||
52 | 52 | static virtual_timer_t watchdog; |
53 | 53 | static virtual_timer_t wrapper; |
54 | 54 | static virtual_timer_t sweeper0, sweeperm1, sweeperp1, sweeperm3, sweeperp3; |
55 | +static virtual_timer_t continuous; | |
55 | 56 | static volatile sysinterval_t delay; |
56 | 57 | static volatile bool saturated; |
58 | +static uint32_t vtcus; | |
57 | 59 | |
58 | 60 | /*===========================================================================*/ |
59 | 61 | /* Module local functions. */ |
@@ -128,6 +130,13 @@ | ||
128 | 130 | chSysUnlockFromISR(); |
129 | 131 | } |
130 | 132 | |
133 | +static void continuous_cb(virtual_timer_t *vtp, void *p) { | |
134 | + | |
135 | + (void)vtp; | |
136 | + (void)p; | |
137 | + vtcus++; | |
138 | +} | |
139 | + | |
131 | 140 | /*===========================================================================*/ |
132 | 141 | /* Module exported functions. */ |
133 | 142 | /*===========================================================================*/ |
@@ -177,7 +186,11 @@ | ||
177 | 186 | for (i = 1; i <= VT_STORM_CFG_ITERATIONS; i++) { |
178 | 187 | |
179 | 188 | chprintf(cfg->out, "Iteration %d\r\n", i); |
189 | + chThdSleepS(TIME_MS2I(10)); | |
180 | 190 | |
191 | + /* Starting continuous timer.*/ | |
192 | + vtcus = 0; | |
193 | + | |
181 | 194 | delay = 120; |
182 | 195 | saturated = false; |
183 | 196 | do { |
@@ -190,6 +203,7 @@ | ||
190 | 203 | chVTSetI(&sweeperm3, delay - 3, sweeperm3_cb, NULL); |
191 | 204 | chVTSetI(&sweeperp3, delay + 3, sweeperp3_cb, NULL); |
192 | 205 | chVTSetI(&wrapper, (sysinterval_t) - 1, wrapper_cb, NULL); |
206 | + chVTSetContinuousI(&continuous, TIME_US2I(50), continuous_cb, NULL); | |
193 | 207 | |
194 | 208 | /* Letting them run for half second.*/ |
195 | 209 | chThdSleepS(TIME_MS2I(500)); |
@@ -202,6 +216,7 @@ | ||
202 | 216 | chVTResetI(&sweeperm3); |
203 | 217 | chVTResetI(&sweeperp3); |
204 | 218 | chVTResetI(&wrapper); |
219 | + chVTResetI(&continuous); | |
205 | 220 | chSysUnlock(); |
206 | 221 | |
207 | 222 | if (saturated) { |
@@ -215,11 +230,11 @@ | ||
215 | 230 | } while (delay >= 5); |
216 | 231 | |
217 | 232 | if (saturated) { |
218 | - chprintf(cfg->out, "\r\nSaturated at %d uS\r\n\r\n", TIME_I2US(delay)); | |
233 | + chprintf(cfg->out, "\r\nSaturated at %u uS", TIME_I2US(delay)); | |
234 | + chprintf(cfg->out, "\r\nContinuous ticks %u\r\n\r\n", vtcus); | |
219 | 235 | } |
220 | 236 | else { |
221 | - | |
222 | - chprintf(cfg->out, "\r\n\r\n"); | |
237 | + chprintf(cfg->out, "\r\nContinuous ticks %u\r\n\r\n", vtcus); | |
223 | 238 | } |
224 | 239 | } |
225 | 240 | } |