aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios/demos/STM32/RT-STM32F107-OLIMEX_P107-LWIP/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios/demos/STM32/RT-STM32F107-OLIMEX_P107-LWIP/main.c')
-rw-r--r--lib/chibios/demos/STM32/RT-STM32F107-OLIMEX_P107-LWIP/main.c85
1 files changed, 85 insertions, 0 deletions
diff --git a/lib/chibios/demos/STM32/RT-STM32F107-OLIMEX_P107-LWIP/main.c b/lib/chibios/demos/STM32/RT-STM32F107-OLIMEX_P107-LWIP/main.c
new file mode 100644
index 000000000..fc984a3fa
--- /dev/null
+++ b/lib/chibios/demos/STM32/RT-STM32F107-OLIMEX_P107-LWIP/main.c
@@ -0,0 +1,85 @@
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#include "rt_test_root.h"
20#include "oslib_test_root.h"
21
22#include "lwipthread.h"
23
24#include "web/web.h"
25
26/*
27 * Green LED blinker thread, times are in milliseconds.
28 */
29static THD_WORKING_AREA(waThread1, 128);
30static THD_FUNCTION(Thread1, arg) {
31
32 (void)arg;
33 chRegSetThreadName("blinker");
34 while (TRUE) {
35 palClearPad(GPIOC, GPIOC_LED_STATUS1);
36 chThdSleepMilliseconds(500);
37 palSetPad(GPIOC, GPIOC_LED_STATUS1);
38 chThdSleepMilliseconds(500);
39 }
40}
41
42/*
43 * Application entry point.
44 */
45int main(void) {
46
47 /*
48 * System initializations.
49 * - HAL initialization, this also initializes the configured device drivers
50 * and performs the board-specific initializations.
51 * - Kernel initialization, the main() function becomes a thread and the
52 * RTOS is active.
53 */
54 halInit();
55 chSysInit();
56 lwipInit(NULL);
57
58 /*
59 * Activates the serial driver 3 using the driver default configuration.
60 */
61 sdStart(&SD3, NULL);
62
63 /*
64 * Creates the blinker thread.
65 */
66 chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
67
68 /*
69 * Creates the HTTP thread (it changes priority internally).
70 */
71 chThdCreateStatic(wa_http_server, sizeof(wa_http_server), NORMALPRIO + 1,
72 http_server, NULL);
73
74 /*
75 * Normal main() thread activity, in this demo it does nothing except
76 * sleeping in a loop and check the button state.
77 */
78 while (true) {
79 if (palReadPad(GPIOC, GPIOC_SWITCH_TAMPER) == 0) {
80 test_execute((BaseSequentialStream *)&SD3, &rt_test_suite);
81 test_execute((BaseSequentialStream *)&SD3, &oslib_test_suite);
82 }
83 chThdSleepMilliseconds(500);
84 }
85}