aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios/demos/AVR/NIL-ARDUINO-NANO/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios/demos/AVR/NIL-ARDUINO-NANO/main.c')
-rw-r--r--lib/chibios/demos/AVR/NIL-ARDUINO-NANO/main.c84
1 files changed, 84 insertions, 0 deletions
diff --git a/lib/chibios/demos/AVR/NIL-ARDUINO-NANO/main.c b/lib/chibios/demos/AVR/NIL-ARDUINO-NANO/main.c
new file mode 100644
index 000000000..5a5dc2491
--- /dev/null
+++ b/lib/chibios/demos/AVR/NIL-ARDUINO-NANO/main.c
@@ -0,0 +1,84 @@
1/*
2 ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
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 "hal.h"
18#include "ch.h"
19
20/*
21 * Thread 1.
22 */
23THD_WORKING_AREA(waThread1, 128);
24THD_FUNCTION(Thread1, arg) {
25
26 (void)arg;
27
28 while (true) {
29 palTogglePad(IOPORT2, PORTB_LED1);
30 chThdSleepMilliseconds(500);
31 }
32}
33
34/*
35 * Thread 2.
36 */
37THD_WORKING_AREA(waThread2, 128);
38THD_FUNCTION(Thread2, arg) {
39
40 (void)arg;
41
42 /*
43 * Activates the serial driver 1 using the driver default configuration.
44 * PD0(RX) and PD1(TX) are routed to USART0.
45 */
46 sdStart(&SD1, NULL);
47
48 while (true) {
49 chnWrite(&SD1, (const uint8_t *)"Hello World!\r\n", 14);
50 chThdSleepMilliseconds(2000);
51 }
52}
53
54/*
55 * Threads static table, one entry per thread. The number of entries must
56 * match NIL_CFG_NUM_THREADS.
57 */
58THD_TABLE_BEGIN
59 THD_TABLE_THREAD(1, "blinker", waThread1, Thread1, NULL)
60 THD_TABLE_THREAD(0, "hello", waThread2, Thread2, NULL)
61THD_TABLE_END
62
63/*
64 * Application entry point.
65 */
66int main(void) {
67
68 /*
69 * System initializations.
70 * - HAL initialization, this also initializes the configured device drivers
71 * and performs the board-specific initializations.
72 * - Kernel initialization, the main() function becomes a thread and the
73 * RTOS is active.
74 */
75 halInit();
76 chSysInit();
77
78 /* This is now the idle thread loop, you may perform here a low priority
79 task but you must never try to sleep or wait in this loop. Note that
80 this tasks runs at the lowest priority level so any instruction added
81 here will be executed after all other tasks have been started.*/
82 while (true) {
83 }
84}