From 16e2a55bf42f532404cddd8ddbc7cbee38c39572 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Sat, 2 Sep 2017 16:35:10 +0000 Subject: 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 --- testhal/STM32/multi/PAL/main.c | 45 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-) (limited to 'testhal/STM32') 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 */ -- cgit v1.2.3