|
1 |
| -/* |
2 |
| - ChibiOS/RT - Copyright (C) 2006-2013 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 "test.h" |
20 |
| - |
21 |
| -#include "lwipthread.h" |
22 |
| - |
23 |
| -#include "web/web.h" |
24 |
| - |
25 |
| -/* |
26 |
| - * Green LED blinker thread, times are in milliseconds. |
27 |
| - */ |
28 |
| -static WORKING_AREA(waThread1, 128); |
29 |
| -static msg_t Thread1(void *arg) { |
30 |
| - |
31 |
| - (void)arg; |
32 |
| - chRegSetThreadName("blinker"); |
33 |
| - while (TRUE) { |
34 |
| - palClearPad(GPIO0, GPIO0_LED2_RED); |
35 |
| - chThdSleepMilliseconds(500); |
36 |
| - palSetPad(GPIO0, GPIO0_LED2_RED); |
37 |
| - chThdSleepMilliseconds(500); |
38 |
| - } |
39 |
| -} |
40 |
| - |
41 |
| -/* |
42 |
| - * Application entry point. |
43 |
| - */ |
44 |
| -int main(void) { |
45 |
| - |
46 |
| - /* |
47 |
| - * System initializations. |
48 |
| - * - HAL initialization, this also initializes the configured device drivers |
49 |
| - * and performs the board-specific initializations. |
50 |
| - * - Kernel initialization, the main() function becomes a thread and the |
51 |
| - * RTOS is active. |
52 |
| - */ |
53 |
| - halInit(); |
54 |
| - chSysInit(); |
55 |
| - |
56 |
| - /* |
57 |
| - * Activates the serial driver 6 using the driver default configuration. |
58 |
| - */ |
59 |
| - sdStart(&SD1, NULL); |
60 |
| - |
61 |
| - /* |
62 |
| - * Creates the blinker thread. |
63 |
| - */ |
64 |
| - chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); |
65 |
| - |
66 |
| - /* |
67 |
| - * Creates the LWIP threads (it changes priority internally). |
68 |
| - */ |
69 |
| - chThdCreateStatic(wa_lwip_thread, LWIP_THREAD_STACK_SIZE, NORMALPRIO + 1, |
70 |
| - lwip_thread, NULL); |
71 |
| - |
72 |
| - /* |
73 |
| - * Creates the HTTP thread (it changes priority internally). |
74 |
| - */ |
75 |
| - chThdCreateStatic(wa_http_server, sizeof(wa_http_server), NORMALPRIO + 1, |
76 |
| - http_server, NULL); |
77 |
| - |
78 |
| - /* |
79 |
| - * Normal main() thread activity, in this demo it does nothing except |
80 |
| - * sleeping in a loop and check the button state. |
81 |
| - */ |
82 |
| - while (TRUE) { |
83 |
| - if (palReadPad(GPIO2, GPIO2_PIN12_TO_GND) == 0) |
84 |
| - TestThread(&SD1); |
85 |
| - chThdSleepMilliseconds(500); |
86 |
| - } |
87 |
| -} |
| 1 | +/* |
| 2 | + ChibiOS/RT - Copyright (C) 2006-2013 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 "test.h" |
| 20 | + |
| 21 | +#include "lwipthread.h" |
| 22 | + |
| 23 | +#include "web/web.h" |
| 24 | + |
| 25 | +/* |
| 26 | + * Green LED blinker thread, times are in milliseconds. |
| 27 | + */ |
| 28 | +static WORKING_AREA(waThread1, 128); |
| 29 | +static msg_t Thread1(void *arg) { |
| 30 | + |
| 31 | + (void)arg; |
| 32 | + chRegSetThreadName("blinker"); |
| 33 | + while (TRUE) { |
| 34 | + palClearPad(GPIO0, GPIO0_LED2_RED); |
| 35 | + chThdSleepMilliseconds(500); |
| 36 | + palSetPad(GPIO0, GPIO0_LED2_RED); |
| 37 | + chThdSleepMilliseconds(500); |
| 38 | + } |
| 39 | +} |
| 40 | + |
| 41 | +/* |
| 42 | + * Application entry point. |
| 43 | + */ |
| 44 | +int main(void) { |
| 45 | + |
| 46 | + /* |
| 47 | + * System initializations. |
| 48 | + * - HAL initialization, this also initializes the configured device drivers |
| 49 | + * and performs the board-specific initializations. |
| 50 | + * - Kernel initialization, the main() function becomes a thread and the |
| 51 | + * RTOS is active. |
| 52 | + */ |
| 53 | + halInit(); |
| 54 | + chSysInit(); |
| 55 | + |
| 56 | + /* |
| 57 | + * Activates the serial driver 6 using the driver default configuration. |
| 58 | + */ |
| 59 | + sdStart(&SD1, NULL); |
| 60 | + |
| 61 | + /* |
| 62 | + * Creates the blinker thread. |
| 63 | + */ |
| 64 | + chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); |
| 65 | + |
| 66 | + /* |
| 67 | + * Creates the LWIP threads (it changes priority internally). |
| 68 | + */ |
| 69 | + chThdCreateStatic(wa_lwip_thread, LWIP_THREAD_STACK_SIZE, NORMALPRIO + 1, |
| 70 | + lwip_thread, NULL); |
| 71 | + |
| 72 | + /* |
| 73 | + * Creates the HTTP thread (it changes priority internally). |
| 74 | + */ |
| 75 | + chThdCreateStatic(wa_http_server, sizeof(wa_http_server), NORMALPRIO + 1, |
| 76 | + http_server, NULL); |
| 77 | + |
| 78 | + /* |
| 79 | + * Normal main() thread activity, in this demo it does nothing except |
| 80 | + * sleeping in a loop and check the button state. |
| 81 | + */ |
| 82 | + while (TRUE) { |
| 83 | + if (palReadPad(GPIO2, GPIO2_PIN12_TO_GND) == 0) |
| 84 | + TestThread(&SD1); |
| 85 | + chThdSleepMilliseconds(500); |
| 86 | + } |
| 87 | +} |
0 commit comments