Improved VT_Storm.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@14440 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
parent
9d1810297e
commit
b143106fe1
|
@ -72,7 +72,7 @@
|
|||
* setting also defines the system tick time unit.
|
||||
*/
|
||||
#if !defined(CH_CFG_ST_FREQUENCY)
|
||||
#define CH_CFG_ST_FREQUENCY 1000000
|
||||
#define CH_CFG_ST_FREQUENCY 21250000
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
|
|
@ -35,12 +35,40 @@
|
|||
/* Module exported variables. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#if VT_STORM_CFG_HAMMERS || defined(__DOXYGEN__)
|
||||
/*
|
||||
* GPT4 configuration.
|
||||
*/
|
||||
static const GPTConfig gpt3cfg = {
|
||||
1000000, /* 1MHz timer clock.*/
|
||||
vt_storm_gpt1_cb, /* Timer callback.*/
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
/*
|
||||
* GPT3 configuration.
|
||||
*/
|
||||
static const GPTConfig gpt4cfg = {
|
||||
1000000, /* 1MHz timer clock.*/
|
||||
vt_storm_gpt2_cb, /* Timer callback.*/
|
||||
0,
|
||||
0
|
||||
};
|
||||
#endif
|
||||
|
||||
/*
|
||||
* VT Storm configuration.
|
||||
*/
|
||||
const vt_storm_config_t portab_vt_storm_config = {
|
||||
(BaseSequentialStream *)&PORTAB_SD1,
|
||||
PORTAB_LINE_LED1,
|
||||
#if VT_STORM_CFG_HAMMERS
|
||||
&GPTD3,
|
||||
&GPTD4,
|
||||
&gpt3cfg,
|
||||
&gpt4cfg,
|
||||
#endif
|
||||
STM32_SYSCLK
|
||||
};
|
||||
|
||||
|
|
|
@ -58,19 +58,6 @@ static volatile sysinterval_t delay;
|
|||
static volatile bool saturated;
|
||||
static uint32_t vtcus;
|
||||
|
||||
#if VT_STORM_CFG_HAMMERS
|
||||
/*
|
||||
* GPTs configuration.
|
||||
*/
|
||||
static void hammer_gpt_cb(GPTDriver *gptp);
|
||||
static const GPTConfig hammer_gpt_cfg = {
|
||||
1000000, /* 1MHz timer clock.*/
|
||||
hammer_gpt_cb, /* Timer callback.*/
|
||||
0,
|
||||
0
|
||||
};
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module local functions. */
|
||||
/*===========================================================================*/
|
||||
|
@ -232,31 +219,6 @@ static void guard_cb(virtual_timer_t *vtp, void *p) {
|
|||
(void)p;
|
||||
}
|
||||
|
||||
#if VT_STORM_CFG_HAMMERS
|
||||
/**
|
||||
* @brief GPT callback.
|
||||
*/
|
||||
static void hammer_gpt_cb(GPTDriver *gptp) {
|
||||
|
||||
(void)gptp;
|
||||
|
||||
#if VT_STORM_CFG_RANDOMIZE != FALSE
|
||||
/* Pseudo-random delay.*/
|
||||
{
|
||||
static volatile unsigned x = 0;
|
||||
unsigned r;
|
||||
|
||||
chSysLockFromISR();
|
||||
r = rand() & 31;
|
||||
chSysUnlockFromISR();
|
||||
while (r--) {
|
||||
x++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module exported functions. */
|
||||
/*===========================================================================*/
|
||||
|
@ -302,15 +264,15 @@ void vt_storm_execute(const vt_storm_config_t *cfg) {
|
|||
chprintf(cfg->out, "*** System Time size: %d bits\r\n", CH_CFG_ST_RESOLUTION);
|
||||
chprintf(cfg->out, "*** Intervals size: %d bits\r\n", CH_CFG_INTERVALS_SIZE);
|
||||
chprintf(cfg->out, "*** SysTick: %d Hz\r\n", CH_CFG_ST_FREQUENCY);
|
||||
chprintf(cfg->out, "*** Delta: %d cycles\r\n", CH_CFG_ST_TIMEDELTA);
|
||||
chprintf(cfg->out, "*** Delta: %d ticks\r\n", CH_CFG_ST_TIMEDELTA);
|
||||
chprintf(cfg->out, "\r\n");
|
||||
|
||||
#if VT_STORM_CFG_HAMMERS
|
||||
/* Starting hammer timers.*/
|
||||
gptStart(&GPTD3, &hammer_gpt_cfg);
|
||||
gptStart(&GPTD4, &hammer_gpt_cfg);
|
||||
gptStartContinuous(&GPTD3, 99);
|
||||
gptStartContinuous(&GPTD4, 101);
|
||||
gptStart(cfg->gpt1p, cfg->gptcfg1p);
|
||||
gptStart(cfg->gpt2p, cfg->gptcfg2p);
|
||||
gptStartContinuous(cfg->gpt1p, 99);
|
||||
gptStartContinuous(cfg->gpt2p, 101);
|
||||
#endif
|
||||
|
||||
for (i = 1; i <= VT_STORM_CFG_ITERATIONS; i++) {
|
||||
|
@ -380,4 +342,52 @@ void vt_storm_execute(const vt_storm_config_t *cfg) {
|
|||
}
|
||||
}
|
||||
|
||||
#if VT_STORM_CFG_HAMMERS || defined(__DOXYGEN__)
|
||||
/**
|
||||
* @brief GPT callback 1.
|
||||
*/
|
||||
void vt_storm_gpt1_cb(GPTDriver *gptp) {
|
||||
|
||||
(void)gptp;
|
||||
|
||||
#if VT_STORM_CFG_RANDOMIZE != FALSE
|
||||
/* Pseudo-random delay.*/
|
||||
{
|
||||
static volatile unsigned x = 0;
|
||||
unsigned r;
|
||||
|
||||
chSysLockFromISR();
|
||||
r = rand() & 31;
|
||||
chSysUnlockFromISR();
|
||||
while (r--) {
|
||||
x++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief GPT callback 2.
|
||||
*/
|
||||
void vt_storm_gpt2_cb(GPTDriver *gptp) {
|
||||
|
||||
(void)gptp;
|
||||
|
||||
#if VT_STORM_CFG_RANDOMIZE != FALSE
|
||||
/* Pseudo-random delay.*/
|
||||
{
|
||||
static volatile unsigned x = 0;
|
||||
unsigned r;
|
||||
|
||||
chSysLockFromISR();
|
||||
r = rand() & 31;
|
||||
chSysUnlockFromISR();
|
||||
while (r--) {
|
||||
x++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
* @brief Timings randomization.
|
||||
*/
|
||||
#if !defined(VT_STORM_CFG_RANDOMIZE) || defined(__DOXYGEN__)
|
||||
#define VT_STORM_CFG_RANDOMIZE 0
|
||||
#define VT_STORM_CFG_RANDOMIZE TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -62,7 +62,7 @@
|
|||
* @brief Enable hammer timers.
|
||||
*/
|
||||
#if !defined(VT_STORM_CFG_HAMMERS) || defined(__DOXYGEN__)
|
||||
#define VT_STORM_CFG_HAMMERS 0
|
||||
#define VT_STORM_CFG_HAMMERS TRUE
|
||||
#endif
|
||||
/** @} */
|
||||
|
||||
|
@ -87,6 +87,24 @@ typedef struct {
|
|||
* @brief LED line.
|
||||
*/
|
||||
ioline_t line;
|
||||
#if VT_STORM_CFG_HAMMERS || defined(__DOXYGEN__)
|
||||
/**
|
||||
* @brief GPT driver 1.
|
||||
*/
|
||||
GPTDriver *gpt1p;
|
||||
/**
|
||||
* @brief GPT driver 2.
|
||||
*/
|
||||
GPTDriver *gpt2p;
|
||||
/**
|
||||
* @brief GPT1 configuration 1.
|
||||
*/
|
||||
const GPTConfig *gptcfg1p;
|
||||
/**
|
||||
* @brief GPT1 configuration 2.
|
||||
*/
|
||||
const GPTConfig *gptcfg2p;
|
||||
#endif
|
||||
/**
|
||||
* @brief System clock.
|
||||
*/
|
||||
|
@ -105,6 +123,10 @@ typedef struct {
|
|||
extern "C" {
|
||||
#endif
|
||||
void vt_storm_execute(const vt_storm_config_t *cfg);
|
||||
#if VT_STORM_CFG_HAMMERS
|
||||
void vt_storm_gpt1_cb(GPTDriver *gptp);
|
||||
void vt_storm_gpt2_cb(GPTDriver *gptp);
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue