More randomization.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@14434 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
Giovanni Di Sirio 2021-05-27 05:50:46 +00:00
parent d434cdedd1
commit 8d55a9ecc0
2 changed files with 61 additions and 1 deletions

View File

@ -103,6 +103,18 @@ static void sweeper0_cb(virtual_timer_t *vtp, void *p) {
(void)p;
chSysLockFromISR();
#if VT_STORM_CFG_RANDOMIZE != FALSE
/* Pseudo-random delay.*/
{
static volatile unsigned x = 0;
unsigned r;
r = rand() & 15;
while (r--) {
x++;
}
}
#endif
chVTSetI(&wrapper, (sysinterval_t)-1, wrapper_cb, NULL);
chVTSetI(vtp, delay, sweeper0_cb, NULL);
chSysUnlockFromISR();
@ -113,6 +125,18 @@ static void sweeperm1_cb(virtual_timer_t *vtp, void *p) {
(void)p;
chSysLockFromISR();
#if VT_STORM_CFG_RANDOMIZE != FALSE
/* Pseudo-random delay.*/
{
static volatile unsigned x = 0;
unsigned r;
r = rand() & 15;
while (r--) {
x++;
}
}
#endif
chVTSetI(vtp, delay - 1, sweeperm1_cb, NULL);
chSysUnlockFromISR();
}
@ -122,6 +146,18 @@ static void sweeperp1_cb(virtual_timer_t *vtp, void *p) {
(void)p;
chSysLockFromISR();
#if VT_STORM_CFG_RANDOMIZE != FALSE
/* Pseudo-random delay.*/
{
static volatile unsigned x = 0;
unsigned r;
r = rand() & 15;
while (r--) {
x++;
}
}
#endif
chVTSetI(vtp, delay + 1, sweeperp1_cb, NULL);
chSysUnlockFromISR();
}
@ -131,6 +167,18 @@ static void sweeperm3_cb(virtual_timer_t *vtp, void *p) {
(void)p;
chSysLockFromISR();
#if VT_STORM_CFG_RANDOMIZE != FALSE
/* Pseudo-random delay.*/
{
static volatile unsigned x = 0;
unsigned r;
r = rand() & 15;
while (r--) {
x++;
}
}
#endif
chVTSetI(vtp, delay - 3, sweeperm3_cb, NULL);
chSysUnlockFromISR();
}
@ -140,6 +188,18 @@ static void sweeperp3_cb(virtual_timer_t *vtp, void *p) {
(void)p;
chSysLockFromISR();
#if VT_STORM_CFG_RANDOMIZE != FALSE
/* Pseudo-random delay.*/
{
static volatile unsigned x = 0;
unsigned r;
r = rand() & 15;
while (r--) {
x++;
}
}
#endif
chVTSetI(vtp, delay + 3, sweeperp3_cb, NULL);
chSysUnlockFromISR();
}

View File

@ -55,7 +55,7 @@
* @brief Minimum delay for each iteration.
*/
#if !defined(VT_STORM_CFG_MIN_DELAY) || defined(__DOXYGEN__)
#define VT_STORM_CFG_MIN_DELAY 10
#define VT_STORM_CFG_MIN_DELAY 5
#endif
/**