aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/EFL/main.c
diff options
context:
space:
mode:
authorAkshay <[email protected]>2022-04-10 12:13:40 +0100
committerAkshay <[email protected]>2022-04-10 12:13:40 +0100
commitdc90387ce7d8ba7b607d9c48540bf6d8b560f14d (patch)
tree4ccb8fa5886b66fa9d480edef74236c27f035e16 /lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/EFL/main.c
Diffstat (limited to 'lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/EFL/main.c')
-rw-r--r--lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/EFL/main.c99
1 files changed, 99 insertions, 0 deletions
diff --git a/lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/EFL/main.c b/lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/EFL/main.c
new file mode 100644
index 000000000..06998c425
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/EFL/main.c
@@ -0,0 +1,99 @@
1/*
2 Copyright (C) 2021 Alex Lewontin
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 "shcfg.h"
19
20
21const SerialConfig shell_serial_cfg = {
22 .speed = 57600,
23 .mode = NUC123_SERIAL_MODE_DEFAULT,
24 .data = NUC123_SERIAL_DATA_8BITS,
25 .parity = NUC123_SERIAL_PARITY_N,
26 .stop = NUC123_SERIAL_STOP_1};
27
28
29/*
30 * Onboard LED blinker thread, times are in milliseconds.
31 */
32static THD_WORKING_AREA(waBlinkThread, 128);
33static THD_FUNCTION(BlinkThread, arg)
34{
35 (void)arg;
36 chRegSetThreadName("blinker");
37 while (true) {
38 systime_t time = 500;
39 OnboardLED_Toggle();
40 chThdSleepMilliseconds(time);
41 }
42}
43
44/*
45 * Application entry point.
46 */
47int main(void)
48{
49 /*
50 * System initializations.
51 * - HAL initialization, this also initializes the configured device drivers
52 * and performs the board-specific initializations.
53 * - Kernel initialization, the main() function becomes a thread and the
54 * RTOS is active.
55 */
56 halInit();
57 chSysInit();
58 OnboardLED_Init();
59
60 /*
61 * Turn off the onboard LED.
62 */
63 OnboardLED_Off();
64
65 chDbgSuspendTrace(CH_DBG_TRACE_MASK_SWITCH);
66
67 /*
68 * Activates the serial driver.
69 */
70 sdStart(&SHELL_SERIAL_DRIVER, &shell_serial_cfg);
71
72 /*
73 * Shell manager initialization.
74 */
75 shellInit();
76
77
78 eflStart(&EFLD1, NULL);
79 EFLD1.bank = NUC123_EFL_BANK_DATAFLASH;
80 mfsObjectInit(&mfsd);
81 mfsStart(&mfsd, &mfsd_config);
82
83 /*
84 * Creates the blinker thread.
85 */
86 chThdCreateStatic(
87 waBlinkThread, sizeof(waBlinkThread), NORMALPRIO, BlinkThread, NULL);
88
89 while (true) {
90 thread_t *shelltp = chThdCreateFromHeap(NULL,
91 SHELL_WA_SIZE,
92 "shell",
93 NORMALPRIO + 1,
94 shellThread,
95 (void *)&shell_cfg);
96 chThdWait(shelltp); /* Waiting termination. */
97 chThdSleepMilliseconds(1000);
98 }
99}