aboutsummaryrefslogtreecommitdiffstats
path: root/testhal
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2017-09-02 16:35:10 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2017-09-02 16:35:10 +0000
commit16e2a55bf42f532404cddd8ddbc7cbee38c39572 (patch)
tree31420acfcb28168ac876f45f0c51253090d8f547 /testhal
parenta489fc365df4d1b4f407438c2efcee428e073e49 (diff)
downloadChibiOS-16e2a55bf42f532404cddd8ddbc7cbee38c39572.tar.gz
ChibiOS-16e2a55bf42f532404cddd8ddbc7cbee38c39572.tar.bz2
ChibiOS-16e2a55bf42f532404cddd8ddbc7cbee38c39572.zip
Made PAL callback and wait APIs independent from each other.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10543 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'testhal')
-rw-r--r--testhal/STM32/multi/PAL/main.c45
1 files changed, 39 insertions, 6 deletions
diff --git a/testhal/STM32/multi/PAL/main.c b/testhal/STM32/multi/PAL/main.c
index a5646c1b2..bc1489cb2 100644
--- a/testhal/STM32/multi/PAL/main.c
+++ b/testhal/STM32/multi/PAL/main.c
@@ -63,8 +63,7 @@ int main(void) {
#endif
/* Enabling events on both edges of the button line.*/
- palEnableLineEvent(PORTAB_LINE_BUTTON, PAL_EVENT_MODE_BOTH_EDGES,
- NULL, NULL);
+ palEnableLineEvent(PORTAB_LINE_BUTTON, PAL_EVENT_MODE_BOTH_EDGES);
/*
* Normal main() thread activity.
@@ -83,7 +82,9 @@ int main(void) {
}
}
-#else /* !PAL_USE_WAIT */
+#endif /* PAL_USE_WAIT */
+
+#if !PAL_USE_WAIT && PAL_USE_CALLBACKS
static event_source_t button_pressed_event;
static event_source_t button_released_event;
@@ -132,8 +133,8 @@ int main(void) {
#endif
/* Enabling events on both edges of the button line.*/
- palEnableLineEvent(PORTAB_LINE_BUTTON, PAL_EVENT_MODE_BOTH_EDGES,
- button_cb, NULL);
+ palEnableLineEvent(PORTAB_LINE_BUTTON, PAL_EVENT_MODE_BOTH_EDGES);
+ palSetLineCallback(PORTAB_LINE_BUTTON, button_cb, NULL);
/*
* Normal main() thread activity.
@@ -150,5 +151,37 @@ int main(void) {
}
}
}
-#endif /* !PAL_USE_WAIT */
+#endif /* !PAL_USE_WAIT && PAL_USE_CALLBACKS */
+
+#if !PAL_USE_WAIT && !PAL_USE_CALLBACKS
+/*
+ * 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
+
+ /*
+ * Normal main() thread activity.
+ */
+ while (true) {
+ palToggleLine(PORTAB_LINE_LED1);
+ chThdSleepMilliseconds(500);
+ }
+}
+#endif /* !PAL_USE_WAIT && !PAL_USE_CALLBACKS */