aboutsummaryrefslogtreecommitdiffstats
path: root/testhal/STM32/multi
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2017-09-02 12:40:56 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2017-09-02 12:40:56 +0000
commit6b9d1341109e01d45edc17f91abbd1c71b3d8b57 (patch)
tree3756f4d16b970ca9ed514cdcff4d3af0cd478694 /testhal/STM32/multi
parentdec89f7333a6cdd598ceaf10ce510064ba8863f8 (diff)
downloadChibiOS-6b9d1341109e01d45edc17f91abbd1c71b3d8b57.tar.gz
ChibiOS-6b9d1341109e01d45edc17f91abbd1c71b3d8b57.tar.bz2
ChibiOS-6b9d1341109e01d45edc17f91abbd1c71b3d8b57.zip
PAL synchronous API.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10528 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'testhal/STM32/multi')
-rw-r--r--testhal/STM32/multi/PAL/main.c52
1 files changed, 51 insertions, 1 deletions
diff --git a/testhal/STM32/multi/PAL/main.c b/testhal/STM32/multi/PAL/main.c
index 46a714dd2..5d53b97b2 100644
--- a/testhal/STM32/multi/PAL/main.c
+++ b/testhal/STM32/multi/PAL/main.c
@@ -38,6 +38,53 @@ static THD_FUNCTION(Thread1, arg) {
}
#endif
+#if defined(PAL_USE_WAIT) || defined(__DOXYGEN__)
+
+/*
+ * Application entry point.
+ */
+int main(void) {
+
+ /*
+ * System initializations.
+ * - HAL initialization, this also initializes the configured device drivers
+ * and performs the board-specific initializations.
+ * - Kernel initialization, the main() function becomes a thread and the
+ * RTOS is active.
+ */
+ halInit();
+ chSysInit();
+
+#if defined(PORTAB_LINE_LED2)
+ /*
+ * Creates the blinker thread.
+ */
+ chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
+#endif
+
+ /* Enabling callback on both edges of the button line.*/
+ palEnableLineEvent(PORTAB_LINE_BUTTON, PAL_EVENT_MODE_BOTH_EDGES,
+ NULL, NULL);
+
+ /*
+ * Normal main() thread activity.
+ */
+ while (true) {
+ /* Waiting for an edge on the button.*/
+ palWaitLineTimeout(PORTAB_LINE_BUTTON, TIME_INFINITE);
+
+ /* Action depending on button state.*/
+ if (palReadLine(PORTAB_LINE_BUTTON) == PORTAB_BUTTON_PRESSED) {
+ palWriteLine(PORTAB_LINE_LED1, PORTAB_LEN_ON);
+ }
+ else {
+ palWriteLine(PORTAB_LINE_LED1, PORTAB_LEN_OFF);
+ }
+ }
+}
+
+#else /* !defined(PAL_USE_WAIT) */
+
static event_source_t button_pressed_event;
static event_source_t button_released_event;
@@ -85,7 +132,7 @@ int main(void) {
#endif
/* Enabling callback on both edges of the button line.*/
- palLineEnableEvent(PORTAB_LINE_BUTTON, PAL_EVENT_MODE_BOTH_EDGES,
+ palEnableLineEvent(PORTAB_LINE_BUTTON, PAL_EVENT_MODE_BOTH_EDGES,
button_cb, NULL);
/*
@@ -103,3 +150,6 @@ int main(void) {
}
}
}
+#endif /* !defined(PAL_USE_WAIT) */
+
+