Added randomization.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@14406 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
Giovanni Di Sirio 2021-05-21 10:14:57 +00:00
parent 282cbaad2e
commit 35621dd185
2 changed files with 16 additions and 2 deletions

View File

@ -135,6 +135,20 @@ static void continuous_cb(virtual_timer_t *vtp, void *p) {
(void)vtp;
(void)p;
vtcus++;
#if VT_STORM_CFG_RANDOMIZE != FALSE
/* Pseudo-random delay.*/
{
static volatile unsigned x = 0;
unsigned r;
chSysLockFromISR();
r = rand() & 255;
chSysUnlockFromISR();
while (r--)
x++;
}
#endif
}
/*===========================================================================*/
@ -227,7 +241,7 @@ void vt_storm_execute(const vt_storm_config_t *cfg) {
palToggleLine(config->line);
chprintf(cfg->out, ".");
delay--;
} while (delay >= 10);
} while (delay >= 5);
if (saturated) {
chprintf(cfg->out, "\r\nSaturated at %u uS", TIME_I2US(delay));

View File

@ -41,7 +41,7 @@
* @brief Timings randomization.
*/
#if !defined(VT_STORM_CFG_RANDOMIZE) || defined(__DOXYGEN__)
#define VT_STORM_CFG_RANDOMIZE FALSE
#define VT_STORM_CFG_RANDOMIZE TRUE
#endif
/**