From 443c13d8785cbcbd3550bc091ba502fd156a5c8b Mon Sep 17 00:00:00 2001 From: Fabio Utzig Date: Fri, 15 May 2015 20:45:44 -0300 Subject: Demo with extra thread for blinker using PAL --- demos/NRF51/RT-WVSHARE_BLE400/halconf.h | 2 +- demos/NRF51/RT-WVSHARE_BLE400/main.c | 25 ++++++++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) (limited to 'demos') diff --git a/demos/NRF51/RT-WVSHARE_BLE400/halconf.h b/demos/NRF51/RT-WVSHARE_BLE400/halconf.h index 28f2cc5..8061b96 100644 --- a/demos/NRF51/RT-WVSHARE_BLE400/halconf.h +++ b/demos/NRF51/RT-WVSHARE_BLE400/halconf.h @@ -34,7 +34,7 @@ * @brief Enables the PAL subsystem. */ #if !defined(HAL_USE_PAL) || defined(__DOXYGEN__) -#define HAL_USE_PAL FALSE +#define HAL_USE_PAL TRUE #endif /** diff --git a/demos/NRF51/RT-WVSHARE_BLE400/main.c b/demos/NRF51/RT-WVSHARE_BLE400/main.c index 6545d30..2f1cb2a 100644 --- a/demos/NRF51/RT-WVSHARE_BLE400/main.c +++ b/demos/NRF51/RT-WVSHARE_BLE400/main.c @@ -18,6 +18,20 @@ #include "hal.h" #include "test.h" +static THD_WORKING_AREA(waThread1, 64); +static THD_FUNCTION(Thread1, arg) { + + (void)arg; + uint8_t led = LED0; + chRegSetThreadName("Blinker"); + while (1) { + palSetPad(IOPORT1, led); + chThdSleepMilliseconds(100); + palClearPad(IOPORT1, led); + if (++led > LED4) led = LED0; + } +} + /* * Application entry point. */ @@ -33,13 +47,18 @@ int main(void) { halInit(); chSysInit(); + /* + * Activates UART0 using the driver default configuration. + */ sdStart(&SD1, NULL); + /* + * Creates the blinker thread. + */ + chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); + TestThread(&SD1); while (1) { - NRF_GPIO->OUTCLR = (uint32_t) 1 << 18; - chThdSleepMilliseconds(500); - NRF_GPIO->OUTSET = (uint32_t) 1 << 18; chThdSleepMilliseconds(500); } } -- cgit v1.2.3