diff options
Diffstat (limited to 'lib/chibios-contrib/demos/NRF51/MICROBIT/main.c')
-rw-r--r-- | lib/chibios-contrib/demos/NRF51/MICROBIT/main.c | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/lib/chibios-contrib/demos/NRF51/MICROBIT/main.c b/lib/chibios-contrib/demos/NRF51/MICROBIT/main.c new file mode 100644 index 000000000..a88775c88 --- /dev/null +++ b/lib/chibios-contrib/demos/NRF51/MICROBIT/main.c | |||
@@ -0,0 +1,85 @@ | |||
1 | /* | ||
2 | Copyright (C) 2016 Stephane D'Alu | ||
3 | |||
4 | Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | you may not use this file except in compliance with the License. | ||
6 | You may obtain a copy of the License at | ||
7 | |||
8 | http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | |||
10 | Unless required by applicable law or agreed to in writing, software | ||
11 | distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | See the License for the specific language governing permissions and | ||
14 | limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #include "ch.h" | ||
18 | #include "hal.h" | ||
19 | #include "rt_test_root.h" | ||
20 | #include "oslib_test_root.h" | ||
21 | |||
22 | /* See: https://lancaster-university.github.io/microbit-docs/ubit/display/ | ||
23 | */ | ||
24 | |||
25 | static THD_WORKING_AREA(waThread1, 64); | ||
26 | static THD_FUNCTION(Thread1, arg) { | ||
27 | (void)arg; | ||
28 | chRegSetThreadName("Blinker"); | ||
29 | |||
30 | ioline_t cols[] = { | ||
31 | LINE_LED_COL_1, LINE_LED_COL_2, LINE_LED_COL_3, | ||
32 | LINE_LED_COL_4, LINE_LED_COL_5, LINE_LED_COL_6, | ||
33 | LINE_LED_COL_7, LINE_LED_COL_8, LINE_LED_COL_9, | ||
34 | PAL_NOLINE | ||
35 | }; | ||
36 | for (ioline_t *col = cols ; *col != PAL_NOLINE ; col++) | ||
37 | palClearLine(col); | ||
38 | |||
39 | while (1) { | ||
40 | palSetLine(LINE_LED_ROW_2); | ||
41 | chThdSleepMilliseconds(100); | ||
42 | palClearLine(LINE_LED_ROW_2); | ||
43 | chThdSleepMilliseconds(500); | ||
44 | } | ||
45 | } | ||
46 | |||
47 | |||
48 | /* | ||
49 | * Application entry point. | ||
50 | */ | ||
51 | int main(void) { | ||
52 | |||
53 | SerialConfig serial_config = { | ||
54 | .speed = 115200, | ||
55 | .tx_pad = IOPORT1_UART_TX, | ||
56 | .rx_pad = IOPORT1_UART_RX, | ||
57 | }; | ||
58 | |||
59 | /* | ||
60 | * System initializations. | ||
61 | * - HAL initialization, this also initializes the configured device drivers | ||
62 | * and performs the board-specific initializations. | ||
63 | * - Kernel initialization, the main() function becomes a thread and the | ||
64 | * RTOS is active. | ||
65 | */ | ||
66 | halInit(); | ||
67 | chSysInit(); | ||
68 | |||
69 | /* | ||
70 | * Activates UART0 using the driver default configuration. | ||
71 | */ | ||
72 | sdStart(&SD1, &serial_config); | ||
73 | |||
74 | /* | ||
75 | * Creates the blinker thread. | ||
76 | */ | ||
77 | chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); | ||
78 | |||
79 | |||
80 | test_execute((BaseSequentialStream *)&SD1, &rt_test_suite); | ||
81 | test_execute((BaseSequentialStream *)&SD1, &oslib_test_suite); | ||
82 | while (1) { | ||
83 | chThdSleepMilliseconds(500); | ||
84 | } | ||
85 | } | ||