aboutsummaryrefslogtreecommitdiffstats
path: root/testhal/STM32L1xx/IRQ_STORM/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'testhal/STM32L1xx/IRQ_STORM/main.c')
-rw-r--r--testhal/STM32L1xx/IRQ_STORM/main.c65
1 files changed, 34 insertions, 31 deletions
diff --git a/testhal/STM32L1xx/IRQ_STORM/main.c b/testhal/STM32L1xx/IRQ_STORM/main.c
index ac3909c0c..71b5128e2 100644
--- a/testhal/STM32L1xx/IRQ_STORM/main.c
+++ b/testhal/STM32L1xx/IRQ_STORM/main.c
@@ -46,18 +46,18 @@
#define MSG_SEND_LEFT 0
#define MSG_SEND_RIGHT 1
-static bool_t saturated;
+static bool saturated;
/*
* Mailboxes and buffers.
*/
-static Mailbox mb[NUM_THREADS];
+static mailbox_t mb[NUM_THREADS];
static msg_t b[NUM_THREADS][MAILBOX_SIZE];
/*
* Test worker threads.
*/
-static WORKING_AREA(waWorkerThread[NUM_THREADS], 128);
+static THD_WORKING_AREA(waWorkerThread[NUM_THREADS], 128);
static msg_t WorkerThread(void *arg) {
static volatile unsigned x = 0;
static unsigned cnt = 0;
@@ -101,7 +101,7 @@ static msg_t WorkerThread(void *arg) {
/* If this thread is not at the end of a chain re-sending the message,
note this check works because the variable target is unsigned.*/
msg = chMBPost(&mb[target], msg, TIME_IMMEDIATE);
- if (msg != RDY_OK)
+ if (msg != MSG_OK)
saturated = TRUE;
}
else {
@@ -117,15 +117,15 @@ static msg_t WorkerThread(void *arg) {
/*
* GPT2 callback.
*/
-static void gpt2cb(GPTDriver *gptp) {
+static void gpt4cb(GPTDriver *gptp) {
msg_t msg;
(void)gptp;
- chSysLockFromIsr();
+ chSysLockFromISR();
msg = chMBPostI(&mb[0], MSG_SEND_RIGHT);
- if (msg != RDY_OK)
+ if (msg != MSG_OK)
saturated = TRUE;
- chSysUnlockFromIsr();
+ chSysUnlockFromISR();
}
/*
@@ -135,19 +135,19 @@ static void gpt3cb(GPTDriver *gptp) {
msg_t msg;
(void)gptp;
- chSysLockFromIsr();
+ chSysLockFromISR();
msg = chMBPostI(&mb[NUM_THREADS - 1], MSG_SEND_LEFT);
- if (msg != RDY_OK)
+ if (msg != MSG_OK)
saturated = TRUE;
- chSysUnlockFromIsr();
+ chSysUnlockFromISR();
}
/*
* GPT2 configuration.
*/
-static const GPTConfig gpt2cfg = {
+static const GPTConfig gpt4cfg = {
1000000, /* 1MHz timer clock.*/
- gpt2cb, /* Timer callback.*/
+ gpt4cb, /* Timer callback.*/
0
};
@@ -212,19 +212,23 @@ int main(void) {
chSysInit();
/*
- * Prepares the Serial driver 1 and GPT drivers 2 and 3.
+ * Activates the serial driver 1, PA9 and PA10 are routed to USART1.
*/
- sdStart(&SD1, NULL); /* Default is 38400-8-N-1.*/
- palSetPadMode(GPIOA, 9, PAL_MODE_ALTERNATE(7));
- palSetPadMode(GPIOA, 10, PAL_MODE_ALTERNATE(7));
- gptStart(&GPTD2, &gpt2cfg);
+ sdStart(&SD1, NULL);
+ palSetPadMode(GPIOA, 9, PAL_MODE_ALTERNATE(7)); /* USART1 TX. */
+ palSetPadMode(GPIOA, 10, PAL_MODE_ALTERNATE(7)); /* USART1 RX. */
+
+ /*
+ * Activates GPTs.
+ */
+ gptStart(&GPTD4, &gpt4cfg);
gptStart(&GPTD3, &gpt3cfg);
/*
* Initializes the mailboxes and creates the worker threads.
*/
for (i = 0; i < NUM_THREADS; i++) {
- chMBInit(&mb[i], b[i], MAILBOX_SIZE);
+ chMBObjectInit(&mb[i], b[i], MAILBOX_SIZE);
chThdCreateStatic(waWorkerThread[i], sizeof waWorkerThread[i],
NORMALPRIO - 20, WorkerThread, (void *)i);
}
@@ -239,19 +243,19 @@ int main(void) {
println(CH_KERNEL_VERSION);
print("*** Compiled: ");
println(__DATE__ " - " __TIME__);
-#ifdef CH_COMPILER_NAME
+#ifdef PORT_COMPILER_NAME
print("*** Compiler: ");
- println(CH_COMPILER_NAME);
+ println(PORT_COMPILER_NAME);
#endif
print("*** Architecture: ");
- println(CH_ARCHITECTURE_NAME);
-#ifdef CH_CORE_VARIANT_NAME
+ println(PORT_ARCHITECTURE_NAME);
+#ifdef PORT_CORE_VARIANT_NAME
print("*** Core Variant: ");
- println(CH_CORE_VARIANT_NAME);
+ println(PORT_CORE_VARIANT_NAME);
#endif
-#ifdef CH_PORT_INFO
+#ifdef PORT_INFO
print("*** Port Info: ");
- println(CH_PORT_INFO);
+ println(PORT_INFO);
#endif
#ifdef PLATFORM_NAME
print("*** Platform: ");
@@ -286,11 +290,11 @@ int main(void) {
println("");
saturated = FALSE;
threshold = 0;
- for (interval = 2000; interval >= 20; interval -= interval / 10) {
- gptStartContinuous(&GPTD2, interval - 1); /* Slightly out of phase.*/
+ for (interval = 2000; interval >= 10; interval -= interval / 10) {
+ gptStartContinuous(&GPTD4, interval - 1); /* Slightly out of phase.*/
gptStartContinuous(&GPTD3, interval + 1); /* Slightly out of phase.*/
chThdSleepMilliseconds(1000);
- gptStopTimer(&GPTD2);
+ gptStopTimer(&GPTD4);
gptStopTimer(&GPTD3);
if (!saturated)
print(".");
@@ -311,7 +315,7 @@ int main(void) {
if (threshold > worst)
worst = threshold;
}
- gptStopTimer(&GPTD2);
+ gptStopTimer(&GPTD4);
gptStopTimer(&GPTD3);
print("Worst case at ");
@@ -326,5 +330,4 @@ int main(void) {
while (TRUE) {
chThdSleepMilliseconds(5000);
}
- return 0;
}