aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios/demos/AVR/RT-ARDUINO-NANO/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios/demos/AVR/RT-ARDUINO-NANO/main.c')
-rw-r--r--lib/chibios/demos/AVR/RT-ARDUINO-NANO/main.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/lib/chibios/demos/AVR/RT-ARDUINO-NANO/main.c b/lib/chibios/demos/AVR/RT-ARDUINO-NANO/main.c
new file mode 100644
index 000000000..c8e077d43
--- /dev/null
+++ b/lib/chibios/demos/AVR/RT-ARDUINO-NANO/main.c
@@ -0,0 +1,64 @@
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 "ch.h"
18#include "hal.h"
19
20/*
21 * LED blinker thread, times are in milliseconds.
22 */
23static THD_WORKING_AREA(waThread1, 32);
24static THD_FUNCTION(Thread1, arg) {
25
26 (void)arg;
27 chRegSetThreadName("Blinker");
28 while (true) {
29 palTogglePad(IOPORT2, PORTB_LED1);
30 chThdSleepMilliseconds(100);
31 }
32}
33
34/*
35 * Application entry point.
36 */
37int main(void) {
38
39 /*
40 * System initializations.
41 * - HAL initialization, this also initializes the configured device drivers
42 * and performs the board-specific initializations.
43 * - Kernel initialization, the main() function becomes a thread and the
44 * RTOS is active.
45 */
46 halInit();
47 chSysInit();
48
49 /*
50 * Activates the serial driver 1 using the driver default configuration.
51 */
52 sdStart(&SD1, NULL);
53
54 /*
55 * Starts the LED blinker thread.
56 */
57 chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
58
59 chnWrite(&SD1, (const uint8_t *)"Hello World!\r\n", 14);
60
61 while (true) {
62 chThdSleepMilliseconds(1000);
63 }
64}