aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios/demos/AVR/NIL-DIGISPARK-ATTINY-167/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios/demos/AVR/NIL-DIGISPARK-ATTINY-167/main.c')
-rw-r--r--lib/chibios/demos/AVR/NIL-DIGISPARK-ATTINY-167/main.c91
1 files changed, 91 insertions, 0 deletions
diff --git a/lib/chibios/demos/AVR/NIL-DIGISPARK-ATTINY-167/main.c b/lib/chibios/demos/AVR/NIL-DIGISPARK-ATTINY-167/main.c
new file mode 100644
index 000000000..b1919531c
--- /dev/null
+++ b/lib/chibios/demos/AVR/NIL-DIGISPARK-ATTINY-167/main.c
@@ -0,0 +1,91 @@
1/*
2 ChibiOS - Copyright (C) 2016..2017 Theodore Ateba
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 * UART 1 configuration structure.
22 */
23const UARTConfig uartConf = {
24 NULL, /* UART transmission buffer callback. */
25 NULL, /* UART physical end of transmission callback. */
26 NULL, /* UART Receiver receiver filled callback. */
27 NULL, /* UART caracter received callback. */
28 NULL, /* UART received error callback. */
29 38400, /* UART baudrate. */
30};
31
32THD_WORKING_AREA(waThread1, 32);
33THD_FUNCTION(Thread1, arg) {
34
35 (void)arg;
36
37 while (true) {
38 palTogglePad(IOPORT2, PORTB_LED1);
39 uartStartSend(&UARTD1, 30, (const void *) "ChibiOS PORT on ATtiny-167!.\n\r");
40 chThdSleepMilliseconds(1000);
41 }
42}
43
44/*
45 * Threads static table, one entry per thread. The number of entries must
46 * match NIL_CFG_NUM_THREADS.
47 */
48THD_TABLE_BEGIN
49 THD_TABLE_THREAD(0, "blinker", waThread1, Thread1, NULL)
50THD_TABLE_END
51
52/*
53 * Application entry point.
54 */
55int main(void) {
56
57 /*
58 * System initializations.
59 * - HAL initialization, this also initializes the configured device drivers
60 * and performs the board-specific initializations.
61 * - Kernel initialization, the main() function becomes a thread and the
62 * RTOS is active.
63 */
64 halInit();
65 chSysInit();
66
67 /*
68 * Initialize the UART interface.
69 */
70 uartInit();
71
72 /*
73 * Start the Uart 1 interface.
74 */
75 uartStart(&UARTD1, &uartConf);
76
77 /*
78 * Send an message via the UART 1 interface.
79 */
80 uartStartSend(&UARTD1, 15, (const void *) "Hello world!.\n\r");
81
82 /*
83 * This is now the idle thread loop, you may perform here a low priority
84 * task but you must never try to sleep or wait in this loop. Note that
85 * this tasks runs at the lowest priority level so any instruction added
86 * here will be executed after all other tasks have been started.
87 */
88 while (true) {
89 }
90}
91