diff options
Diffstat (limited to 'lib/chibios/demos/various/NIL-ARMCM0-GENERIC')
-rw-r--r-- | lib/chibios/demos/various/NIL-ARMCM0-GENERIC/Makefile | 189 | ||||
-rw-r--r-- | lib/chibios/demos/various/NIL-ARMCM0-GENERIC/cfg/chconf.h | 479 | ||||
-rw-r--r-- | lib/chibios/demos/various/NIL-ARMCM0-GENERIC/main.c | 103 |
3 files changed, 771 insertions, 0 deletions
diff --git a/lib/chibios/demos/various/NIL-ARMCM0-GENERIC/Makefile b/lib/chibios/demos/various/NIL-ARMCM0-GENERIC/Makefile new file mode 100644 index 000000000..2d2317f70 --- /dev/null +++ b/lib/chibios/demos/various/NIL-ARMCM0-GENERIC/Makefile | |||
@@ -0,0 +1,189 @@ | |||
1 | ############################################################################## | ||
2 | # Build global options | ||
3 | # NOTE: Can be overridden externally. | ||
4 | # | ||
5 | |||
6 | # Compiler options here. | ||
7 | ifeq ($(USE_OPT),) | ||
8 | USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16 | ||
9 | endif | ||
10 | |||
11 | # C specific options here (added to USE_OPT). | ||
12 | ifeq ($(USE_COPT),) | ||
13 | USE_COPT = | ||
14 | endif | ||
15 | |||
16 | # C++ specific options here (added to USE_OPT). | ||
17 | ifeq ($(USE_CPPOPT),) | ||
18 | USE_CPPOPT = -fno-rtti | ||
19 | endif | ||
20 | |||
21 | # Enable this if you want the linker to remove unused code and data. | ||
22 | ifeq ($(USE_LINK_GC),) | ||
23 | USE_LINK_GC = yes | ||
24 | endif | ||
25 | |||
26 | # Linker extra options here. | ||
27 | ifeq ($(USE_LDOPT),) | ||
28 | USE_LDOPT = | ||
29 | endif | ||
30 | |||
31 | # Enable this if you want link time optimizations (LTO). | ||
32 | ifeq ($(USE_LTO),) | ||
33 | USE_LTO = yes | ||
34 | endif | ||
35 | |||
36 | # Enable this if you want to see the full log while compiling. | ||
37 | ifeq ($(USE_VERBOSE_COMPILE),) | ||
38 | USE_VERBOSE_COMPILE = no | ||
39 | endif | ||
40 | |||
41 | # If enabled, this option makes the build process faster by not compiling | ||
42 | # modules not used in the current configuration. | ||
43 | ifeq ($(USE_SMART_BUILD),) | ||
44 | USE_SMART_BUILD = yes | ||
45 | endif | ||
46 | |||
47 | # | ||
48 | # Build global options | ||
49 | ############################################################################## | ||
50 | |||
51 | ############################################################################## | ||
52 | # Architecture or project specific options | ||
53 | # | ||
54 | |||
55 | # Stack size to be allocated to the Cortex-M process stack. This stack is | ||
56 | # the stack used by the main() thread. | ||
57 | ifeq ($(USE_PROCESS_STACKSIZE),) | ||
58 | USE_PROCESS_STACKSIZE = 0x100 | ||
59 | endif | ||
60 | |||
61 | # Stack size to the allocated to the Cortex-M main/exceptions stack. This | ||
62 | # stack is used for processing interrupts and exceptions. | ||
63 | ifeq ($(USE_EXCEPTIONS_STACKSIZE),) | ||
64 | USE_EXCEPTIONS_STACKSIZE = 0x400 | ||
65 | endif | ||
66 | |||
67 | # Enables the use of FPU (no, softfp, hard). | ||
68 | ifeq ($(USE_FPU),) | ||
69 | USE_FPU = no | ||
70 | endif | ||
71 | |||
72 | # FPU-related options. | ||
73 | ifeq ($(USE_FPU_OPT),) | ||
74 | USE_FPU_OPT = -mfloat-abi=$(USE_FPU) -mfpu=fpv4-sp-d16 | ||
75 | endif | ||
76 | |||
77 | # | ||
78 | # Architecture or project specific options | ||
79 | ############################################################################## | ||
80 | |||
81 | ############################################################################## | ||
82 | # Project, target, sources and paths | ||
83 | # | ||
84 | |||
85 | # Define project name here | ||
86 | PROJECT = ch | ||
87 | |||
88 | # Target settings. | ||
89 | MCU = cortex-m0 | ||
90 | |||
91 | # Imported source files and paths. | ||
92 | CHIBIOS := ../../.. | ||
93 | CONFDIR := ./cfg | ||
94 | BUILDDIR := ./build | ||
95 | DEPDIR := ./.dep | ||
96 | |||
97 | # Licensing files. | ||
98 | include $(CHIBIOS)/os/license/license.mk | ||
99 | # Startup files. | ||
100 | include $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_stm32f0xx.mk | ||
101 | # HAL-OSAL files (optional). | ||
102 | #include $(CHIBIOS)/os/hal/hal.mk | ||
103 | #include $(CHIBIOS)/os/hal/ports/STM32/STM32F0xx/platform.mk | ||
104 | #include $(CHIBIOS)/os/hal/boards/ST_STM32F072B_DISCOVERY/board.mk | ||
105 | #include $(CHIBIOS)/os/hal/osal/rt-nil/osal.mk | ||
106 | # RTOS files (optional). | ||
107 | include $(CHIBIOS)/os/nil/nil.mk | ||
108 | include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v6m.mk | ||
109 | # Auto-build files in ./source recursively. | ||
110 | include $(CHIBIOS)/tools/mk/autobuild.mk | ||
111 | # Other files (optional). | ||
112 | #include $(CHIBIOS)/test/lib/test.mk | ||
113 | #include $(CHIBIOS)/test/nil/nil_test.mk | ||
114 | #include $(CHIBIOS)/test/oslib/oslib_test.mk | ||
115 | |||
116 | # Define linker script file here | ||
117 | LDSCRIPT= $(STARTUPLD)/STM32F051x8.ld | ||
118 | |||
119 | # C sources that can be compiled in ARM or THUMB mode depending on the global | ||
120 | # setting. | ||
121 | CSRC = $(ALLCSRC) \ | ||
122 | $(TESTSRC) \ | ||
123 | main.c | ||
124 | |||
125 | # C++ sources that can be compiled in ARM or THUMB mode depending on the global | ||
126 | # setting. | ||
127 | CPPSRC = $(ALLCPPSRC) | ||
128 | |||
129 | # List ASM source files here. | ||
130 | ASMSRC = $(ALLASMSRC) | ||
131 | |||
132 | # List ASM with preprocessor source files here. | ||
133 | ASMXSRC = $(ALLXASMSRC) | ||
134 | |||
135 | # Inclusion directories. | ||
136 | INCDIR = $(CONFDIR) $(ALLINC) $(TESTINC) | ||
137 | |||
138 | # Define C warning options here. | ||
139 | CWARN = -Wall -Wextra -Wundef -Wstrict-prototypes | ||
140 | |||
141 | # Define C++ warning options here. | ||
142 | CPPWARN = -Wall -Wextra -Wundef | ||
143 | |||
144 | # | ||
145 | # Project, target, sources and paths | ||
146 | ############################################################################## | ||
147 | |||
148 | ############################################################################## | ||
149 | # Start of user section | ||
150 | # | ||
151 | |||
152 | # List all user C define here, like -D_DEBUG=1 | ||
153 | UDEFS = -DSTM32F051x8 | ||
154 | |||
155 | # Define ASM defines here | ||
156 | UADEFS = -DSTM32F051x8 | ||
157 | |||
158 | # List all user directories here | ||
159 | UINCDIR = | ||
160 | |||
161 | # List the user directory to look for the libraries here | ||
162 | ULIBDIR = | ||
163 | |||
164 | # List all user libraries here | ||
165 | ULIBS = | ||
166 | |||
167 | # | ||
168 | # End of user section | ||
169 | ############################################################################## | ||
170 | |||
171 | ############################################################################## | ||
172 | # Common rules | ||
173 | # | ||
174 | |||
175 | RULESPATH = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk | ||
176 | include $(RULESPATH)/arm-none-eabi.mk | ||
177 | include $(RULESPATH)/rules.mk | ||
178 | |||
179 | # | ||
180 | # Common rules | ||
181 | ############################################################################## | ||
182 | |||
183 | ############################################################################## | ||
184 | # Custom rules | ||
185 | # | ||
186 | |||
187 | # | ||
188 | # Custom rules | ||
189 | ############################################################################## | ||
diff --git a/lib/chibios/demos/various/NIL-ARMCM0-GENERIC/cfg/chconf.h b/lib/chibios/demos/various/NIL-ARMCM0-GENERIC/cfg/chconf.h new file mode 100644 index 000000000..df2e8e426 --- /dev/null +++ b/lib/chibios/demos/various/NIL-ARMCM0-GENERIC/cfg/chconf.h | |||
@@ -0,0 +1,479 @@ | |||
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 | /** | ||
18 | * @file nil/templates/chconf.h | ||
19 | * @brief Configuration file template. | ||
20 | * @details A copy of this file must be placed in each project directory, it | ||
21 | * contains the application specific kernel settings. | ||
22 | * | ||
23 | * @addtogroup NIL_CONFIG | ||
24 | * @details Kernel related settings and hooks. | ||
25 | * @{ | ||
26 | */ | ||
27 | |||
28 | #ifndef CHCONF_H | ||
29 | #define CHCONF_H | ||
30 | |||
31 | #define _CHIBIOS_NIL_CONF_ | ||
32 | #define _CHIBIOS_NIL_CONF_VER_4_0_ | ||
33 | |||
34 | /*===========================================================================*/ | ||
35 | /** | ||
36 | * @name Kernel parameters and options | ||
37 | * @{ | ||
38 | */ | ||
39 | /*===========================================================================*/ | ||
40 | |||
41 | /** | ||
42 | * @brief Maximum number of user threads in the application. | ||
43 | * @note This number is not inclusive of the idle thread which is | ||
44 | * implicitly handled. | ||
45 | * @note Set this value to be exactly equal to the number of threads you | ||
46 | * will use or you would be wasting RAM and cycles. | ||
47 | * @note This values also defines the number of available priorities | ||
48 | * (0..CH_CFG_MAX_THREADS-1). | ||
49 | */ | ||
50 | #if !defined(CH_CFG_MAX_THREADS) | ||
51 | #define CH_CFG_MAX_THREADS 4 | ||
52 | #endif | ||
53 | |||
54 | /** | ||
55 | * @brief Auto starts threads when @p chSysInit() is invoked. | ||
56 | */ | ||
57 | #if !defined(CH_CFG_AUTOSTART_THREADS) | ||
58 | #define CH_CFG_AUTOSTART_THREADS TRUE | ||
59 | #endif | ||
60 | |||
61 | /** @} */ | ||
62 | |||
63 | /*===========================================================================*/ | ||
64 | /** | ||
65 | * @name System timer settings | ||
66 | * @{ | ||
67 | */ | ||
68 | /*===========================================================================*/ | ||
69 | |||
70 | /** | ||
71 | * @brief System time counter resolution. | ||
72 | * @note Allowed values are 16 or 32 bits. | ||
73 | */ | ||
74 | #if !defined(CH_CFG_ST_RESOLUTION) | ||
75 | #define CH_CFG_ST_RESOLUTION 32 | ||
76 | #endif | ||
77 | |||
78 | /** | ||
79 | * @brief System tick frequency. | ||
80 | * @note This value together with the @p CH_CFG_ST_RESOLUTION | ||
81 | * option defines the maximum amount of time allowed for | ||
82 | * timeouts. | ||
83 | */ | ||
84 | #if !defined(CH_CFG_ST_FREQUENCY) | ||
85 | #define CH_CFG_ST_FREQUENCY 1000 | ||
86 | #endif | ||
87 | |||
88 | /** | ||
89 | * @brief Time delta constant for the tick-less mode. | ||
90 | * @note If this value is zero then the system uses the classic | ||
91 | * periodic tick. This value represents the minimum number | ||
92 | * of ticks that is safe to specify in a timeout directive. | ||
93 | * The value one is not valid, timeouts are rounded up to | ||
94 | * this value. | ||
95 | */ | ||
96 | #if !defined(CH_CFG_ST_TIMEDELTA) | ||
97 | #define CH_CFG_ST_TIMEDELTA 0 | ||
98 | #endif | ||
99 | |||
100 | /** @} */ | ||
101 | |||
102 | /*===========================================================================*/ | ||
103 | /** | ||
104 | * @name Subsystem options | ||
105 | * @{ | ||
106 | */ | ||
107 | /*===========================================================================*/ | ||
108 | |||
109 | /** | ||
110 | * @brief Threads synchronization APIs. | ||
111 | * @details If enabled then the @p chThdWait() function is included in | ||
112 | * the kernel. | ||
113 | * | ||
114 | * @note The default is @p TRUE. | ||
115 | */ | ||
116 | #if !defined(CH_CFG_USE_WAITEXIT) | ||
117 | #define CH_CFG_USE_WAITEXIT TRUE | ||
118 | #endif | ||
119 | |||
120 | /** | ||
121 | * @brief Semaphores APIs. | ||
122 | * @details If enabled then the Semaphores APIs are included in the kernel. | ||
123 | * | ||
124 | * @note The default is @p TRUE. | ||
125 | */ | ||
126 | #if !defined(CH_CFG_USE_SEMAPHORES) | ||
127 | #define CH_CFG_USE_SEMAPHORES TRUE | ||
128 | #endif | ||
129 | |||
130 | /** | ||
131 | * @brief Mutexes APIs. | ||
132 | * @details If enabled then the mutexes APIs are included in the kernel. | ||
133 | * | ||
134 | * @note Feature not currently implemented. | ||
135 | * @note The default is @p FALSE. | ||
136 | */ | ||
137 | #if !defined(CH_CFG_USE_MUTEXES) | ||
138 | #define CH_CFG_USE_MUTEXES FALSE | ||
139 | #endif | ||
140 | |||
141 | /** | ||
142 | * @brief Events Flags APIs. | ||
143 | * @details If enabled then the event flags APIs are included in the kernel. | ||
144 | * | ||
145 | * @note The default is @p TRUE. | ||
146 | */ | ||
147 | #if !defined(CH_CFG_USE_EVENTS) | ||
148 | #define CH_CFG_USE_EVENTS TRUE | ||
149 | #endif | ||
150 | |||
151 | /** | ||
152 | * @brief Synchronous Messages APIs. | ||
153 | * @details If enabled then the synchronous messages APIs are included | ||
154 | * in the kernel. | ||
155 | * | ||
156 | * @note The default is @p TRUE. | ||
157 | */ | ||
158 | #if !defined(CH_CFG_USE_MESSAGES) | ||
159 | #define CH_CFG_USE_MESSAGES TRUE | ||
160 | #endif | ||
161 | |||
162 | /** @} */ | ||
163 | |||
164 | /*===========================================================================*/ | ||
165 | /** | ||
166 | * @name OSLIB options | ||
167 | * @{ | ||
168 | */ | ||
169 | /*===========================================================================*/ | ||
170 | |||
171 | /** | ||
172 | * @brief Mailboxes APIs. | ||
173 | * @details If enabled then the asynchronous messages (mailboxes) APIs are | ||
174 | * included in the kernel. | ||
175 | * | ||
176 | * @note The default is @p TRUE. | ||
177 | * @note Requires @p CH_CFG_USE_SEMAPHORES. | ||
178 | */ | ||
179 | #if !defined(CH_CFG_USE_MAILBOXES) | ||
180 | #define CH_CFG_USE_MAILBOXES TRUE | ||
181 | #endif | ||
182 | |||
183 | /** | ||
184 | * @brief Core Memory Manager APIs. | ||
185 | * @details If enabled then the core memory manager APIs are included | ||
186 | * in the kernel. | ||
187 | * | ||
188 | * @note The default is @p TRUE. | ||
189 | */ | ||
190 | #if !defined(CH_CFG_USE_MEMCORE) | ||
191 | #define CH_CFG_USE_MEMCORE TRUE | ||
192 | #endif | ||
193 | |||
194 | /** | ||
195 | * @brief Managed RAM size. | ||
196 | * @details Size of the RAM area to be managed by the OS. If set to zero | ||
197 | * then the whole available RAM is used. The core memory is made | ||
198 | * available to the heap allocator and/or can be used directly through | ||
199 | * the simplified core memory allocator. | ||
200 | * | ||
201 | * @note In order to let the OS manage the whole RAM the linker script must | ||
202 | * provide the @p __heap_base__ and @p __heap_end__ symbols. | ||
203 | * @note Requires @p CH_CFG_USE_MEMCORE. | ||
204 | */ | ||
205 | #if !defined(CH_CFG_MEMCORE_SIZE) | ||
206 | #define CH_CFG_MEMCORE_SIZE 0 | ||
207 | #endif | ||
208 | |||
209 | /** | ||
210 | * @brief Heap Allocator APIs. | ||
211 | * @details If enabled then the memory heap allocator APIs are included | ||
212 | * in the kernel. | ||
213 | * | ||
214 | * @note The default is @p TRUE. | ||
215 | */ | ||
216 | #if !defined(CH_CFG_USE_HEAP) | ||
217 | #define CH_CFG_USE_HEAP TRUE | ||
218 | #endif | ||
219 | |||
220 | /** | ||
221 | * @brief Memory Pools Allocator APIs. | ||
222 | * @details If enabled then the memory pools allocator APIs are included | ||
223 | * in the kernel. | ||
224 | * | ||
225 | * @note The default is @p TRUE. | ||
226 | */ | ||
227 | #if !defined(CH_CFG_USE_MEMPOOLS) | ||
228 | #define CH_CFG_USE_MEMPOOLS TRUE | ||
229 | #endif | ||
230 | |||
231 | /** | ||
232 | * @brief Objects FIFOs APIs. | ||
233 | * @details If enabled then the objects FIFOs APIs are included | ||
234 | * in the kernel. | ||
235 | * | ||
236 | * @note The default is @p TRUE. | ||
237 | */ | ||
238 | #if !defined(CH_CFG_USE_OBJ_FIFOS) | ||
239 | #define CH_CFG_USE_OBJ_FIFOS TRUE | ||
240 | #endif | ||
241 | |||
242 | /** | ||
243 | * @brief Pipes APIs. | ||
244 | * @details If enabled then the pipes APIs are included | ||
245 | * in the kernel. | ||
246 | * | ||
247 | * @note The default is @p TRUE. | ||
248 | */ | ||
249 | #if !defined(CH_CFG_USE_PIPES) | ||
250 | #define CH_CFG_USE_PIPES TRUE | ||
251 | #endif | ||
252 | |||
253 | /** | ||
254 | * @brief Objects Caches APIs. | ||
255 | * @details If enabled then the objects caches APIs are included | ||
256 | * in the kernel. | ||
257 | * | ||
258 | * @note The default is @p TRUE. | ||
259 | */ | ||
260 | #if !defined(CH_CFG_USE_OBJ_CACHES) | ||
261 | #define CH_CFG_USE_OBJ_CACHES TRUE | ||
262 | #endif | ||
263 | |||
264 | /** | ||
265 | * @brief Delegate threads APIs. | ||
266 | * @details If enabled then the delegate threads APIs are included | ||
267 | * in the kernel. | ||
268 | * | ||
269 | * @note The default is @p TRUE. | ||
270 | */ | ||
271 | #if !defined(CH_CFG_USE_DELEGATES) | ||
272 | #define CH_CFG_USE_DELEGATES TRUE | ||
273 | #endif | ||
274 | |||
275 | /** | ||
276 | * @brief Jobs Queues APIs. | ||
277 | * @details If enabled then the jobs queues APIs are included | ||
278 | * in the kernel. | ||
279 | * | ||
280 | * @note The default is @p TRUE. | ||
281 | */ | ||
282 | #if !defined(CH_CFG_USE_JOBS) | ||
283 | #define CH_CFG_USE_JOBS TRUE | ||
284 | #endif | ||
285 | |||
286 | /** @} */ | ||
287 | |||
288 | /*===========================================================================*/ | ||
289 | /** | ||
290 | * @name Objects factory options | ||
291 | * @{ | ||
292 | */ | ||
293 | /*===========================================================================*/ | ||
294 | |||
295 | /** | ||
296 | * @brief Objects Factory APIs. | ||
297 | * @details If enabled then the objects factory APIs are included in the | ||
298 | * kernel. | ||
299 | * | ||
300 | * @note The default is @p FALSE. | ||
301 | */ | ||
302 | #if !defined(CH_CFG_USE_FACTORY) | ||
303 | #define CH_CFG_USE_FACTORY TRUE | ||
304 | #endif | ||
305 | |||
306 | /** | ||
307 | * @brief Maximum length for object names. | ||
308 | * @details If the specified length is zero then the name is stored by | ||
309 | * pointer but this could have unintended side effects. | ||
310 | */ | ||
311 | #if !defined(CH_CFG_FACTORY_MAX_NAMES_LENGTH) | ||
312 | #define CH_CFG_FACTORY_MAX_NAMES_LENGTH 8 | ||
313 | #endif | ||
314 | |||
315 | /** | ||
316 | * @brief Enables the registry of generic objects. | ||
317 | */ | ||
318 | #if !defined(CH_CFG_FACTORY_OBJECTS_REGISTRY) | ||
319 | #define CH_CFG_FACTORY_OBJECTS_REGISTRY TRUE | ||
320 | #endif | ||
321 | |||
322 | /** | ||
323 | * @brief Enables factory for generic buffers. | ||
324 | */ | ||
325 | #if !defined(CH_CFG_FACTORY_GENERIC_BUFFERS) | ||
326 | #define CH_CFG_FACTORY_GENERIC_BUFFERS TRUE | ||
327 | #endif | ||
328 | |||
329 | /** | ||
330 | * @brief Enables factory for semaphores. | ||
331 | */ | ||
332 | #if !defined(CH_CFG_FACTORY_SEMAPHORES) | ||
333 | #define CH_CFG_FACTORY_SEMAPHORES TRUE | ||
334 | #endif | ||
335 | |||
336 | /** | ||
337 | * @brief Enables factory for mailboxes. | ||
338 | */ | ||
339 | #if !defined(CH_CFG_FACTORY_MAILBOXES) | ||
340 | #define CH_CFG_FACTORY_MAILBOXES TRUE | ||
341 | #endif | ||
342 | |||
343 | /** | ||
344 | * @brief Enables factory for objects FIFOs. | ||
345 | */ | ||
346 | #if !defined(CH_CFG_FACTORY_OBJ_FIFOS) | ||
347 | #define CH_CFG_FACTORY_OBJ_FIFOS TRUE | ||
348 | #endif | ||
349 | |||
350 | /** | ||
351 | * @brief Enables factory for Pipes. | ||
352 | */ | ||
353 | #if !defined(CH_CFG_FACTORY_PIPES) | ||
354 | #define CH_CFG_FACTORY_PIPES TRUE | ||
355 | #endif | ||
356 | |||
357 | /** @} */ | ||
358 | |||
359 | /*===========================================================================*/ | ||
360 | /** | ||
361 | * @name Debug options | ||
362 | * @{ | ||
363 | */ | ||
364 | /*===========================================================================*/ | ||
365 | |||
366 | /** | ||
367 | * @brief Debug option, kernel statistics. | ||
368 | * | ||
369 | * @note Feature not currently implemented. | ||
370 | * @note The default is @p FALSE. | ||
371 | */ | ||
372 | #if !defined(CH_DBG_STATISTICS) | ||
373 | #define CH_DBG_STATISTICS FALSE | ||
374 | #endif | ||
375 | |||
376 | /** | ||
377 | * @brief Debug option, system state check. | ||
378 | * | ||
379 | * @note The default is @p FALSE. | ||
380 | */ | ||
381 | #if !defined(CH_DBG_SYSTEM_STATE_CHECK) | ||
382 | #define CH_DBG_SYSTEM_STATE_CHECK FALSE | ||
383 | #endif | ||
384 | |||
385 | /** | ||
386 | * @brief Debug option, parameters checks. | ||
387 | * | ||
388 | * @note The default is @p FALSE. | ||
389 | */ | ||
390 | #if !defined(CH_DBG_ENABLE_CHECKS) | ||
391 | #define CH_DBG_ENABLE_CHECKS FALSE | ||
392 | #endif | ||
393 | |||
394 | /** | ||
395 | * @brief System assertions. | ||
396 | * | ||
397 | * @note The default is @p FALSE. | ||
398 | */ | ||
399 | #if !defined(CH_DBG_ENABLE_ASSERTS) | ||
400 | #define CH_DBG_ENABLE_ASSERTS FALSE | ||
401 | #endif | ||
402 | |||
403 | /** | ||
404 | * @brief Stack check. | ||
405 | * | ||
406 | * @note The default is @p FALSE. | ||
407 | */ | ||
408 | #if !defined(CH_DBG_ENABLE_STACK_CHECK) | ||
409 | #define CH_DBG_ENABLE_STACK_CHECK FALSE | ||
410 | #endif | ||
411 | |||
412 | /** @} */ | ||
413 | |||
414 | /*===========================================================================*/ | ||
415 | /** | ||
416 | * @name Kernel hooks | ||
417 | * @{ | ||
418 | */ | ||
419 | /*===========================================================================*/ | ||
420 | |||
421 | /** | ||
422 | * @brief System initialization hook. | ||
423 | */ | ||
424 | #define CH_CFG_SYSTEM_INIT_HOOK() { \ | ||
425 | } | ||
426 | |||
427 | /** | ||
428 | * @brief Threads descriptor structure extension. | ||
429 | * @details User fields added to the end of the @p thread_t structure. | ||
430 | */ | ||
431 | #define CH_CFG_THREAD_EXT_FIELDS \ | ||
432 | /* Add threads custom fields here.*/ | ||
433 | |||
434 | /** | ||
435 | * @brief Threads initialization hook. | ||
436 | */ | ||
437 | #define CH_CFG_THREAD_EXT_INIT_HOOK(tr) { \ | ||
438 | /* Add custom threads initialization code here.*/ \ | ||
439 | } | ||
440 | |||
441 | /** | ||
442 | * @brief Threads finalization hook. | ||
443 | * @details User finalization code added to the @p chThdExit() API. | ||
444 | */ | ||
445 | #define CH_CFG_THREAD_EXIT_HOOK(tp) {} | ||
446 | |||
447 | /** | ||
448 | * @brief Idle thread enter hook. | ||
449 | * @note This hook is invoked within a critical zone, no OS functions | ||
450 | * should be invoked from here. | ||
451 | * @note This macro can be used to activate a power saving mode. | ||
452 | */ | ||
453 | #define CH_CFG_IDLE_ENTER_HOOK() { \ | ||
454 | } | ||
455 | |||
456 | /** | ||
457 | * @brief Idle thread leave hook. | ||
458 | * @note This hook is invoked within a critical zone, no OS functions | ||
459 | * should be invoked from here. | ||
460 | * @note This macro can be used to deactivate a power saving mode. | ||
461 | */ | ||
462 | #define CH_CFG_IDLE_LEAVE_HOOK() { \ | ||
463 | } | ||
464 | |||
465 | /** | ||
466 | * @brief System halt hook. | ||
467 | */ | ||
468 | #define CH_CFG_SYSTEM_HALT_HOOK(reason) { \ | ||
469 | } | ||
470 | |||
471 | /** @} */ | ||
472 | |||
473 | /*===========================================================================*/ | ||
474 | /* Port-specific settings (override port settings defaulted in nilcore.h). */ | ||
475 | /*===========================================================================*/ | ||
476 | |||
477 | #endif /* CHCONF_H */ | ||
478 | |||
479 | /** @} */ | ||
diff --git a/lib/chibios/demos/various/NIL-ARMCM0-GENERIC/main.c b/lib/chibios/demos/various/NIL-ARMCM0-GENERIC/main.c new file mode 100644 index 000000000..c4ee399f2 --- /dev/null +++ b/lib/chibios/demos/various/NIL-ARMCM0-GENERIC/main.c | |||
@@ -0,0 +1,103 @@ | |||
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 | |||
19 | #if !defined(SYSTEM_CLOCK) | ||
20 | #define SYSTEM_CLOCK 8000000U | ||
21 | #endif | ||
22 | |||
23 | /* | ||
24 | * @brief System Timer handler. | ||
25 | */ | ||
26 | CH_IRQ_HANDLER(SysTick_Handler) { | ||
27 | |||
28 | CH_IRQ_PROLOGUE(); | ||
29 | |||
30 | chSysLockFromISR(); | ||
31 | chSysTimerHandlerI(); | ||
32 | chSysUnlockFromISR(); | ||
33 | |||
34 | CH_IRQ_EPILOGUE(); | ||
35 | } | ||
36 | |||
37 | static uint32_t seconds_counter; | ||
38 | static uint32_t minutes_counter; | ||
39 | |||
40 | /* | ||
41 | * Seconds counter thread. | ||
42 | */ | ||
43 | static THD_WORKING_AREA(waThread1, 128); | ||
44 | static THD_FUNCTION(Thread1, arg) { | ||
45 | |||
46 | (void)arg; | ||
47 | |||
48 | while (true) { | ||
49 | chThdSleepMilliseconds(1000); | ||
50 | seconds_counter++; | ||
51 | } | ||
52 | } | ||
53 | |||
54 | /* | ||
55 | * Minutes counter thread. | ||
56 | */ | ||
57 | static THD_WORKING_AREA(waThread2, 128); | ||
58 | static THD_FUNCTION(Thread2, arg) { | ||
59 | |||
60 | (void)arg; | ||
61 | |||
62 | while (true) { | ||
63 | chThdSleepSeconds(60); | ||
64 | minutes_counter++; | ||
65 | } | ||
66 | } | ||
67 | |||
68 | /* | ||
69 | * Threads creation table, one entry per thread. | ||
70 | */ | ||
71 | THD_TABLE_BEGIN | ||
72 | THD_TABLE_THREAD(0, "counter1", waThread1, Thread1, NULL) | ||
73 | THD_TABLE_THREAD(1, "counter2", waThread2, Thread2, NULL) | ||
74 | THD_TABLE_END | ||
75 | |||
76 | /* | ||
77 | * Application entry point. | ||
78 | */ | ||
79 | int main(void) { | ||
80 | |||
81 | /* | ||
82 | * Hardware initialization, in this simple demo just the systick timer is | ||
83 | * initialized. | ||
84 | */ | ||
85 | SysTick->LOAD = SYSTEM_CLOCK / CH_CFG_ST_FREQUENCY - (systime_t)1; | ||
86 | SysTick->VAL = (uint32_t)0; | ||
87 | SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk | | ||
88 | SysTick_CTRL_TICKINT_Msk; | ||
89 | |||
90 | /* | ||
91 | * System initializations. | ||
92 | * - Kernel initialization, the main() function becomes a thread and the | ||
93 | * RTOS is active. | ||
94 | */ | ||
95 | chSysInit(); | ||
96 | |||
97 | /* This is now the idle thread loop, you may perform here a low priority | ||
98 | task but you must never try to sleep or wait in this loop. Note that | ||
99 | this tasks runs at the lowest priority level so any instruction added | ||
100 | here will be executed after all other tasks have been started.*/ | ||
101 | while (true) { | ||
102 | } | ||
103 | } | ||