aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios-contrib/testhal/NRF52
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios-contrib/testhal/NRF52')
-rw-r--r--lib/chibios-contrib/testhal/NRF52/NRF52832/ADC/Makefile226
-rw-r--r--lib/chibios-contrib/testhal/NRF52/NRF52832/ADC/chconf.h757
-rw-r--r--lib/chibios-contrib/testhal/NRF52/NRF52832/ADC/halconf.h533
-rw-r--r--lib/chibios-contrib/testhal/NRF52/NRF52832/ADC/halconf_community.h173
-rw-r--r--lib/chibios-contrib/testhal/NRF52/NRF52832/ADC/main.c139
-rw-r--r--lib/chibios-contrib/testhal/NRF52/NRF52832/ADC/mcuconf.h25
-rw-r--r--lib/chibios-contrib/testhal/NRF52/NRF52832/I2C/Makefile207
-rw-r--r--lib/chibios-contrib/testhal/NRF52/NRF52832/I2C/chconf.h757
-rw-r--r--lib/chibios-contrib/testhal/NRF52/NRF52832/I2C/halconf.h533
-rw-r--r--lib/chibios-contrib/testhal/NRF52/NRF52832/I2C/halconf_community.h173
-rw-r--r--lib/chibios-contrib/testhal/NRF52/NRF52832/I2C/main.c165
-rw-r--r--lib/chibios-contrib/testhal/NRF52/NRF52832/I2C/mcuconf.h25
-rw-r--r--lib/chibios-contrib/testhal/NRF52/NRF52832/I2C/readme.txt21
-rw-r--r--lib/chibios-contrib/testhal/NRF52/NRF52832/PWM-ICU/Makefile228
-rw-r--r--lib/chibios-contrib/testhal/NRF52/NRF52832/PWM-ICU/chconf.h757
-rw-r--r--lib/chibios-contrib/testhal/NRF52/NRF52832/PWM-ICU/halconf.h533
-rw-r--r--lib/chibios-contrib/testhal/NRF52/NRF52832/PWM-ICU/halconf_community.h173
-rw-r--r--lib/chibios-contrib/testhal/NRF52/NRF52832/PWM-ICU/main.c122
-rw-r--r--lib/chibios-contrib/testhal/NRF52/NRF52832/PWM-ICU/mcuconf.h33
-rw-r--r--lib/chibios-contrib/testhal/NRF52/NRF52832/RADIO-ESB/Makefile212
-rw-r--r--lib/chibios-contrib/testhal/NRF52/NRF52832/RADIO-ESB/chconf.h757
-rw-r--r--lib/chibios-contrib/testhal/NRF52/NRF52832/RADIO-ESB/halconf.h533
-rw-r--r--lib/chibios-contrib/testhal/NRF52/NRF52832/RADIO-ESB/halconf_community.h173
-rw-r--r--lib/chibios-contrib/testhal/NRF52/NRF52832/RADIO-ESB/main.c122
-rw-r--r--lib/chibios-contrib/testhal/NRF52/NRF52832/RADIO-ESB/mcuconf.h28
-rw-r--r--lib/chibios-contrib/testhal/NRF52/NRF52832/RADIO-ESB/nrf52_radio.c1114
-rw-r--r--lib/chibios-contrib/testhal/NRF52/NRF52832/RADIO-ESB/nrf52_radio.h256
-rw-r--r--lib/chibios-contrib/testhal/NRF52/NRF52832/UART/Makefile211
-rw-r--r--lib/chibios-contrib/testhal/NRF52/NRF52832/UART/chconf.h757
-rw-r--r--lib/chibios-contrib/testhal/NRF52/NRF52832/UART/halconf.h533
-rw-r--r--lib/chibios-contrib/testhal/NRF52/NRF52832/UART/halconf_community.h173
-rw-r--r--lib/chibios-contrib/testhal/NRF52/NRF52832/UART/main.c144
-rw-r--r--lib/chibios-contrib/testhal/NRF52/NRF52832/UART/mcuconf.h29
-rw-r--r--lib/chibios-contrib/testhal/NRF52/NRF52832/UART/readme.txt17
34 files changed, 10639 insertions, 0 deletions
diff --git a/lib/chibios-contrib/testhal/NRF52/NRF52832/ADC/Makefile b/lib/chibios-contrib/testhal/NRF52/NRF52832/ADC/Makefile
new file mode 100644
index 000000000..cb4c58fd6
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NRF52/NRF52832/ADC/Makefile
@@ -0,0 +1,226 @@
1##############################################################################
2# Build global options
3# NOTE: Can be overridden externally.
4#
5
6# Compiler options here.
7ifeq ($(USE_OPT),)
8 USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16
9endif
10
11# C specific options here (added to USE_OPT).
12ifeq ($(USE_COPT),)
13 USE_COPT =
14endif
15
16# C++ specific options here (added to USE_OPT).
17ifeq ($(USE_CPPOPT),)
18 USE_CPPOPT = -fno-rtti
19endif
20
21# Enable this if you want the linker to remove unused code and data
22ifeq ($(USE_LINK_GC),)
23 USE_LINK_GC = yes
24endif
25
26# Linker extra options here.
27ifeq ($(USE_LDOPT),)
28 USE_LDOPT =
29endif
30
31# Enable this if you want link time optimizations (LTO)
32ifeq ($(USE_LTO),)
33 USE_LTO = yes
34endif
35
36# If enabled, this option allows to compile the application in THUMB mode.
37ifeq ($(USE_THUMB),)
38 USE_THUMB = yes
39endif
40
41# Enable this if you want to see the full log while compiling.
42ifeq ($(USE_VERBOSE_COMPILE),)
43 USE_VERBOSE_COMPILE = no
44endif
45
46# If enabled, this option makes the build process faster by not compiling
47# modules not used in the current configuration.
48ifeq ($(USE_SMART_BUILD),)
49 USE_SMART_BUILD = yes
50endif
51
52#
53# Build global options
54##############################################################################
55
56##############################################################################
57# Architecture or project specific options
58#
59
60# Stack size to be allocated to the Cortex-M process stack. This stack is
61# the stack used by the main() thread.
62ifeq ($(USE_PROCESS_STACKSIZE),)
63 USE_PROCESS_STACKSIZE = 0x400
64endif
65
66# Stack size to the allocated to the Cortex-M main/exceptions stack. This
67# stack is used for processing interrupts and exceptions.
68ifeq ($(USE_EXCEPTIONS_STACKSIZE),)
69 USE_EXCEPTIONS_STACKSIZE = 0x400
70endif
71
72# Enables the use of FPU on Cortex-M4 (no, softfp, hard).
73ifeq ($(USE_FPU),)
74 USE_FPU = no
75endif
76
77#
78# Architecture or project specific options
79##############################################################################
80
81##############################################################################
82# Project, sources and paths
83#
84
85# Define project name here
86PROJECT = ch
87
88# Imported source files and paths
89CHIBIOS = ../../../../../ChibiOS
90CHIBIOS_CONTRIB = $(CHIBIOS)/../ChibiOS-Contrib
91
92# Startup files.
93include $(CHIBIOS_CONTRIB)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_nrf52.mk
94# Licensing files.
95include $(CHIBIOS)/os/license/license.mk
96# HAL-OSAL files (optional).
97include $(CHIBIOS_CONTRIB)/os/hal/hal.mk
98include $(CHIBIOS_CONTRIB)/os/hal/ports/NRF5/NRF52832/platform.mk
99include $(CHIBIOS_CONTRIB)/os/hal/boards/NRF52-E73-2G4M04S/board.mk
100include $(CHIBIOS)/os/hal/osal/rt-nil/osal.mk
101# RTOS files (optional).
102include $(CHIBIOS)/os/rt/rt.mk
103include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk
104# Other files (optional).
105#include $(CHIBIOS)/test/rt/test.mk
106
107# Define linker script file here
108LDSCRIPT= $(STARTUPLD_CONTRIB)/NRF52832.ld
109
110# C sources that can be compiled in ARM or THUMB mode depending on the global
111# setting.
112CSRC = $(ALLCSRC) \
113 $(TESTSRC) \
114 main.c
115
116# C++ sources that can be compiled in ARM or THUMB mode depending on the global
117# setting.
118CPPSRC = $(ALLCPPSRC)
119
120# C sources to be compiled in ARM mode regardless of the global setting.
121# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
122# option that results in lower performance and larger code size.
123ACSRC =
124
125# C++ sources to be compiled in ARM mode regardless of the global setting.
126# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
127# option that results in lower performance and larger code size.
128ACPPSRC =
129
130# C sources to be compiled in THUMB mode regardless of the global setting.
131# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
132# option that results in lower performance and larger code size.
133TCSRC =
134
135# C sources to be compiled in THUMB mode regardless of the global setting.
136# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
137# option that results in lower performance and larger code size.
138TCPPSRC =
139
140# List ASM source files here
141ASMSRC = $(ALLASMSRC)
142ASMXSRC = $(ALLXASMSRC)
143
144INCDIR = $(ALLINC) $(TESTINC) \
145 $(CHIBIOS)/os/hal/lib/streams \
146 $(TESTHAL)
147
148#
149# Project, sources and paths
150##############################################################################
151
152##############################################################################
153# Compiler settings
154#
155
156MCU = cortex-m4
157
158TRGT = arm-none-eabi-
159CC = $(TRGT)gcc
160CPPC = $(TRGT)g++
161# Enable loading with g++ only if you need C++ runtime support.
162# NOTE: You can use C++ even without C++ support if you are careful. C++
163# runtime support makes code size explode.
164LD = $(TRGT)gcc
165#LD = $(TRGT)g++
166CP = $(TRGT)objcopy
167AS = $(TRGT)gcc -x assembler-with-cpp
168AR = $(TRGT)ar
169OD = $(TRGT)objdump
170SZ = $(TRGT)size
171HEX = $(CP) -O ihex
172BIN = $(CP) -O binary
173SREC = $(CP) -O srec
174
175# ARM-specific options here
176AOPT =
177
178# THUMB-specific options here
179TOPT = -mthumb -DTHUMB
180
181# Define C warning options here
182CWARN = -Wall -Wextra -Wstrict-prototypes
183
184# Define C++ warning options here
185CPPWARN = -Wall -Wextra
186
187#
188# Compiler settings
189##############################################################################
190
191##############################################################################
192# Start of user section
193#
194
195# List all user C define here, like -D_DEBUG=1
196UDEFS =
197
198# Define ASM defines here
199UADEFS =
200
201# List all user directories here
202UINCDIR =
203
204# List the user directory to look for the libraries here
205ULIBDIR =
206
207# List all user libraries here
208ULIBS =
209
210#
211# End of user defines
212##############################################################################
213
214RULESPATH = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk
215include $(RULESPATH)/rules.mk
216
217
218include $(CHIBIOS_CONTRIB)/os/various/jlink.mk
219
220
221JLINK_DEVICE = nrf51422
222JLINK_PRE_FLASH = w4 4001e504 1
223JLINK_ERASE_ALL = w4 4001e504 2\nw4 4001e50c 1\nsleep 100
224
225flash: all jlink-flash
226
diff --git a/lib/chibios-contrib/testhal/NRF52/NRF52832/ADC/chconf.h b/lib/chibios-contrib/testhal/NRF52/NRF52832/ADC/chconf.h
new file mode 100644
index 000000000..1e6dce1c9
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NRF52/NRF52832/ADC/chconf.h
@@ -0,0 +1,757 @@
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 rt/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 config
24 * @details Kernel related settings and hooks.
25 * @{
26 */
27
28#ifndef CHCONF_H
29#define CHCONF_H
30
31#define _CHIBIOS_RT_CONF_
32#define _CHIBIOS_RT_CONF_VER_6_1_
33
34/*===========================================================================*/
35/**
36 * @name System timers settings
37 * @{
38 */
39/*===========================================================================*/
40
41/**
42 * @brief System time counter resolution.
43 * @note Allowed values are 16 or 32 bits.
44 */
45#if !defined(CH_CFG_ST_RESOLUTION)
46#define CH_CFG_ST_RESOLUTION 32
47#endif
48
49/**
50 * @brief System tick frequency.
51 * @details Frequency of the system timer that drives the system ticks. This
52 * setting also defines the system tick time unit.
53 */
54#if !defined(CH_CFG_ST_FREQUENCY)
55#define CH_CFG_ST_FREQUENCY 10000
56#endif
57
58/**
59 * @brief Time intervals data size.
60 * @note Allowed values are 16, 32 or 64 bits.
61 */
62#if !defined(CH_CFG_INTERVALS_SIZE)
63#define CH_CFG_INTERVALS_SIZE 32
64#endif
65
66/**
67 * @brief Time types data size.
68 * @note Allowed values are 16 or 32 bits.
69 */
70#if !defined(CH_CFG_TIME_TYPES_SIZE)
71#define CH_CFG_TIME_TYPES_SIZE 32
72#endif
73
74/**
75 * @brief Time delta constant for the tick-less mode.
76 * @note If this value is zero then the system uses the classic
77 * periodic tick. This value represents the minimum number
78 * of ticks that is safe to specify in a timeout directive.
79 * The value one is not valid, timeouts are rounded up to
80 * this value.
81 */
82#if !defined(CH_CFG_ST_TIMEDELTA)
83#define CH_CFG_ST_TIMEDELTA 5
84#endif
85
86/** @} */
87
88/*===========================================================================*/
89/**
90 * @name Kernel parameters and options
91 * @{
92 */
93/*===========================================================================*/
94
95/**
96 * @brief Round robin interval.
97 * @details This constant is the number of system ticks allowed for the
98 * threads before preemption occurs. Setting this value to zero
99 * disables the preemption for threads with equal priority and the
100 * round robin becomes cooperative. Note that higher priority
101 * threads can still preempt, the kernel is always preemptive.
102 * @note Disabling the round robin preemption makes the kernel more compact
103 * and generally faster.
104 * @note The round robin preemption is not supported in tickless mode and
105 * must be set to zero in that case.
106 */
107#if !defined(CH_CFG_TIME_QUANTUM)
108#define CH_CFG_TIME_QUANTUM 0
109#endif
110
111/**
112 * @brief Idle thread automatic spawn suppression.
113 * @details When this option is activated the function @p chSysInit()
114 * does not spawn the idle thread. The application @p main()
115 * function becomes the idle thread and must implement an
116 * infinite loop.
117 */
118#if !defined(CH_CFG_NO_IDLE_THREAD)
119#define CH_CFG_NO_IDLE_THREAD FALSE
120#endif
121
122/** @} */
123
124/*===========================================================================*/
125/**
126 * @name Performance options
127 * @{
128 */
129/*===========================================================================*/
130
131/**
132 * @brief OS optimization.
133 * @details If enabled then time efficient rather than space efficient code
134 * is used when two possible implementations exist.
135 *
136 * @note This is not related to the compiler optimization options.
137 * @note The default is @p TRUE.
138 */
139#if !defined(CH_CFG_OPTIMIZE_SPEED)
140#define CH_CFG_OPTIMIZE_SPEED TRUE
141#endif
142
143/** @} */
144
145/*===========================================================================*/
146/**
147 * @name Subsystem options
148 * @{
149 */
150/*===========================================================================*/
151
152/**
153 * @brief Time Measurement APIs.
154 * @details If enabled then the time measurement APIs are included in
155 * the kernel.
156 *
157 * @note The default is @p TRUE.
158 */
159#if !defined(CH_CFG_USE_TM)
160#define CH_CFG_USE_TM TRUE
161#endif
162
163/**
164 * @brief Threads registry APIs.
165 * @details If enabled then the registry APIs are included in the kernel.
166 *
167 * @note The default is @p TRUE.
168 */
169#if !defined(CH_CFG_USE_REGISTRY)
170#define CH_CFG_USE_REGISTRY TRUE
171#endif
172
173/**
174 * @brief Threads synchronization APIs.
175 * @details If enabled then the @p chThdWait() function is included in
176 * the kernel.
177 *
178 * @note The default is @p TRUE.
179 */
180#if !defined(CH_CFG_USE_WAITEXIT)
181#define CH_CFG_USE_WAITEXIT TRUE
182#endif
183
184/**
185 * @brief Semaphores APIs.
186 * @details If enabled then the Semaphores APIs are included in the kernel.
187 *
188 * @note The default is @p TRUE.
189 */
190#if !defined(CH_CFG_USE_SEMAPHORES)
191#define CH_CFG_USE_SEMAPHORES TRUE
192#endif
193
194/**
195 * @brief Semaphores queuing mode.
196 * @details If enabled then the threads are enqueued on semaphores by
197 * priority rather than in FIFO order.
198 *
199 * @note The default is @p FALSE. Enable this if you have special
200 * requirements.
201 * @note Requires @p CH_CFG_USE_SEMAPHORES.
202 */
203#if !defined(CH_CFG_USE_SEMAPHORES_PRIORITY)
204#define CH_CFG_USE_SEMAPHORES_PRIORITY FALSE
205#endif
206
207/**
208 * @brief Mutexes APIs.
209 * @details If enabled then the mutexes APIs are included in the kernel.
210 *
211 * @note The default is @p TRUE.
212 */
213#if !defined(CH_CFG_USE_MUTEXES)
214#define CH_CFG_USE_MUTEXES TRUE
215#endif
216
217/**
218 * @brief Enables recursive behavior on mutexes.
219 * @note Recursive mutexes are heavier and have an increased
220 * memory footprint.
221 *
222 * @note The default is @p FALSE.
223 * @note Requires @p CH_CFG_USE_MUTEXES.
224 */
225#if !defined(CH_CFG_USE_MUTEXES_RECURSIVE)
226#define CH_CFG_USE_MUTEXES_RECURSIVE FALSE
227#endif
228
229/**
230 * @brief Conditional Variables APIs.
231 * @details If enabled then the conditional variables APIs are included
232 * in the kernel.
233 *
234 * @note The default is @p TRUE.
235 * @note Requires @p CH_CFG_USE_MUTEXES.
236 */
237#if !defined(CH_CFG_USE_CONDVARS)
238#define CH_CFG_USE_CONDVARS TRUE
239#endif
240
241/**
242 * @brief Conditional Variables APIs with timeout.
243 * @details If enabled then the conditional variables APIs with timeout
244 * specification are included in the kernel.
245 *
246 * @note The default is @p TRUE.
247 * @note Requires @p CH_CFG_USE_CONDVARS.
248 */
249#if !defined(CH_CFG_USE_CONDVARS_TIMEOUT)
250#define CH_CFG_USE_CONDVARS_TIMEOUT TRUE
251#endif
252
253/**
254 * @brief Events Flags APIs.
255 * @details If enabled then the event flags APIs are included in the kernel.
256 *
257 * @note The default is @p TRUE.
258 */
259#if !defined(CH_CFG_USE_EVENTS)
260#define CH_CFG_USE_EVENTS TRUE
261#endif
262
263/**
264 * @brief Events Flags APIs with timeout.
265 * @details If enabled then the events APIs with timeout specification
266 * are included in the kernel.
267 *
268 * @note The default is @p TRUE.
269 * @note Requires @p CH_CFG_USE_EVENTS.
270 */
271#if !defined(CH_CFG_USE_EVENTS_TIMEOUT)
272#define CH_CFG_USE_EVENTS_TIMEOUT TRUE
273#endif
274
275/**
276 * @brief Synchronous Messages APIs.
277 * @details If enabled then the synchronous messages APIs are included
278 * in the kernel.
279 *
280 * @note The default is @p TRUE.
281 */
282#if !defined(CH_CFG_USE_MESSAGES)
283#define CH_CFG_USE_MESSAGES TRUE
284#endif
285
286/**
287 * @brief Synchronous Messages queuing mode.
288 * @details If enabled then messages are served by priority rather than in
289 * FIFO order.
290 *
291 * @note The default is @p FALSE. Enable this if you have special
292 * requirements.
293 * @note Requires @p CH_CFG_USE_MESSAGES.
294 */
295#if !defined(CH_CFG_USE_MESSAGES_PRIORITY)
296#define CH_CFG_USE_MESSAGES_PRIORITY FALSE
297#endif
298
299/**
300 * @brief Dynamic Threads APIs.
301 * @details If enabled then the dynamic threads creation APIs are included
302 * in the kernel.
303 *
304 * @note The default is @p TRUE.
305 * @note Requires @p CH_CFG_USE_WAITEXIT.
306 * @note Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS.
307 */
308#if !defined(CH_CFG_USE_DYNAMIC)
309#define CH_CFG_USE_DYNAMIC TRUE
310#endif
311
312/** @} */
313
314/*===========================================================================*/
315/**
316 * @name OSLIB options
317 * @{
318 */
319/*===========================================================================*/
320
321/**
322 * @brief Mailboxes APIs.
323 * @details If enabled then the asynchronous messages (mailboxes) APIs are
324 * included in the kernel.
325 *
326 * @note The default is @p TRUE.
327 * @note Requires @p CH_CFG_USE_SEMAPHORES.
328 */
329#if !defined(CH_CFG_USE_MAILBOXES)
330#define CH_CFG_USE_MAILBOXES TRUE
331#endif
332
333/**
334 * @brief Core Memory Manager APIs.
335 * @details If enabled then the core memory manager APIs are included
336 * in the kernel.
337 *
338 * @note The default is @p TRUE.
339 */
340#if !defined(CH_CFG_USE_MEMCORE)
341#define CH_CFG_USE_MEMCORE TRUE
342#endif
343
344/**
345 * @brief Managed RAM size.
346 * @details Size of the RAM area to be managed by the OS. If set to zero
347 * then the whole available RAM is used. The core memory is made
348 * available to the heap allocator and/or can be used directly through
349 * the simplified core memory allocator.
350 *
351 * @note In order to let the OS manage the whole RAM the linker script must
352 * provide the @p __heap_base__ and @p __heap_end__ symbols.
353 * @note Requires @p CH_CFG_USE_MEMCORE.
354 */
355#if !defined(CH_CFG_MEMCORE_SIZE)
356#define CH_CFG_MEMCORE_SIZE 0
357#endif
358
359/**
360 * @brief Heap Allocator APIs.
361 * @details If enabled then the memory heap allocator APIs are included
362 * in the kernel.
363 *
364 * @note The default is @p TRUE.
365 * @note Requires @p CH_CFG_USE_MEMCORE and either @p CH_CFG_USE_MUTEXES or
366 * @p CH_CFG_USE_SEMAPHORES.
367 * @note Mutexes are recommended.
368 */
369#if !defined(CH_CFG_USE_HEAP)
370#define CH_CFG_USE_HEAP TRUE
371#endif
372
373/**
374 * @brief Memory Pools Allocator APIs.
375 * @details If enabled then the memory pools allocator APIs are included
376 * in the kernel.
377 *
378 * @note The default is @p TRUE.
379 */
380#if !defined(CH_CFG_USE_MEMPOOLS)
381#define CH_CFG_USE_MEMPOOLS TRUE
382#endif
383
384/**
385 * @brief Objects FIFOs APIs.
386 * @details If enabled then the objects FIFOs APIs are included
387 * in the kernel.
388 *
389 * @note The default is @p TRUE.
390 */
391#if !defined(CH_CFG_USE_OBJ_FIFOS)
392#define CH_CFG_USE_OBJ_FIFOS TRUE
393#endif
394
395/**
396 * @brief Pipes APIs.
397 * @details If enabled then the pipes APIs are included
398 * in the kernel.
399 *
400 * @note The default is @p TRUE.
401 */
402#if !defined(CH_CFG_USE_PIPES)
403#define CH_CFG_USE_PIPES TRUE
404#endif
405
406/**
407 * @brief Objects Caches APIs.
408 * @details If enabled then the objects caches APIs are included
409 * in the kernel.
410 *
411 * @note The default is @p TRUE.
412 */
413#if !defined(CH_CFG_USE_OBJ_CACHES)
414#define CH_CFG_USE_OBJ_CACHES TRUE
415#endif
416
417/**
418 * @brief Delegate threads APIs.
419 * @details If enabled then the delegate threads APIs are included
420 * in the kernel.
421 *
422 * @note The default is @p TRUE.
423 */
424#if !defined(CH_CFG_USE_DELEGATES)
425#define CH_CFG_USE_DELEGATES TRUE
426#endif
427
428/**
429 * @brief Jobs Queues APIs.
430 * @details If enabled then the jobs queues APIs are included
431 * in the kernel.
432 *
433 * @note The default is @p TRUE.
434 */
435#if !defined(CH_CFG_USE_JOBS)
436#define CH_CFG_USE_JOBS TRUE
437#endif
438
439/** @} */
440
441/*===========================================================================*/
442/**
443 * @name Objects factory options
444 * @{
445 */
446/*===========================================================================*/
447
448/**
449 * @brief Objects Factory APIs.
450 * @details If enabled then the objects factory APIs are included in the
451 * kernel.
452 *
453 * @note The default is @p FALSE.
454 */
455#if !defined(CH_CFG_USE_FACTORY)
456#define CH_CFG_USE_FACTORY TRUE
457#endif
458
459/**
460 * @brief Maximum length for object names.
461 * @details If the specified length is zero then the name is stored by
462 * pointer but this could have unintended side effects.
463 */
464#if !defined(CH_CFG_FACTORY_MAX_NAMES_LENGTH)
465#define CH_CFG_FACTORY_MAX_NAMES_LENGTH 8
466#endif
467
468/**
469 * @brief Enables the registry of generic objects.
470 */
471#if !defined(CH_CFG_FACTORY_OBJECTS_REGISTRY)
472#define CH_CFG_FACTORY_OBJECTS_REGISTRY TRUE
473#endif
474
475/**
476 * @brief Enables factory for generic buffers.
477 */
478#if !defined(CH_CFG_FACTORY_GENERIC_BUFFERS)
479#define CH_CFG_FACTORY_GENERIC_BUFFERS TRUE
480#endif
481
482/**
483 * @brief Enables factory for semaphores.
484 */
485#if !defined(CH_CFG_FACTORY_SEMAPHORES)
486#define CH_CFG_FACTORY_SEMAPHORES TRUE
487#endif
488
489/**
490 * @brief Enables factory for mailboxes.
491 */
492#if !defined(CH_CFG_FACTORY_MAILBOXES)
493#define CH_CFG_FACTORY_MAILBOXES TRUE
494#endif
495
496/**
497 * @brief Enables factory for objects FIFOs.
498 */
499#if !defined(CH_CFG_FACTORY_OBJ_FIFOS)
500#define CH_CFG_FACTORY_OBJ_FIFOS TRUE
501#endif
502
503/**
504 * @brief Enables factory for Pipes.
505 */
506#if !defined(CH_CFG_FACTORY_PIPES) || defined(__DOXYGEN__)
507#define CH_CFG_FACTORY_PIPES TRUE
508#endif
509
510/** @} */
511
512/*===========================================================================*/
513/**
514 * @name Debug options
515 * @{
516 */
517/*===========================================================================*/
518
519/**
520 * @brief Debug option, kernel statistics.
521 *
522 * @note The default is @p FALSE.
523 */
524#if !defined(CH_DBG_STATISTICS)
525#define CH_DBG_STATISTICS FALSE
526#endif
527
528/**
529 * @brief Debug option, system state check.
530 * @details If enabled the correct call protocol for system APIs is checked
531 * at runtime.
532 *
533 * @note The default is @p FALSE.
534 */
535#if !defined(CH_DBG_SYSTEM_STATE_CHECK)
536#define CH_DBG_SYSTEM_STATE_CHECK TRUE
537#endif
538
539/**
540 * @brief Debug option, parameters checks.
541 * @details If enabled then the checks on the API functions input
542 * parameters are activated.
543 *
544 * @note The default is @p FALSE.
545 */
546#if !defined(CH_DBG_ENABLE_CHECKS)
547#define CH_DBG_ENABLE_CHECKS TRUE
548#endif
549
550/**
551 * @brief Debug option, consistency checks.
552 * @details If enabled then all the assertions in the kernel code are
553 * activated. This includes consistency checks inside the kernel,
554 * runtime anomalies and port-defined checks.
555 *
556 * @note The default is @p FALSE.
557 */
558#if !defined(CH_DBG_ENABLE_ASSERTS)
559#define CH_DBG_ENABLE_ASSERTS TRUE
560#endif
561
562/**
563 * @brief Debug option, trace buffer.
564 * @details If enabled then the trace buffer is activated.
565 *
566 * @note The default is @p CH_DBG_TRACE_MASK_DISABLED.
567 */
568#if !defined(CH_DBG_TRACE_MASK)
569#define CH_DBG_TRACE_MASK CH_DBG_TRACE_MASK_ALL
570#endif
571
572/**
573 * @brief Trace buffer entries.
574 * @note The trace buffer is only allocated if @p CH_DBG_TRACE_MASK is
575 * different from @p CH_DBG_TRACE_MASK_DISABLED.
576 */
577#if !defined(CH_DBG_TRACE_BUFFER_SIZE)
578#define CH_DBG_TRACE_BUFFER_SIZE 128
579#endif
580
581/**
582 * @brief Debug option, stack checks.
583 * @details If enabled then a runtime stack check is performed.
584 *
585 * @note The default is @p FALSE.
586 * @note The stack check is performed in a architecture/port dependent way.
587 * It may not be implemented or some ports.
588 * @note The default failure mode is to halt the system with the global
589 * @p panic_msg variable set to @p NULL.
590 */
591#if !defined(CH_DBG_ENABLE_STACK_CHECK)
592#define CH_DBG_ENABLE_STACK_CHECK TRUE
593#endif
594
595/**
596 * @brief Debug option, stacks initialization.
597 * @details If enabled then the threads working area is filled with a byte
598 * value when a thread is created. This can be useful for the
599 * runtime measurement of the used stack.
600 *
601 * @note The default is @p FALSE.
602 */
603#if !defined(CH_DBG_FILL_THREADS)
604#define CH_DBG_FILL_THREADS TRUE
605#endif
606
607/**
608 * @brief Debug option, threads profiling.
609 * @details If enabled then a field is added to the @p thread_t structure that
610 * counts the system ticks occurred while executing the thread.
611 *
612 * @note The default is @p FALSE.
613 * @note This debug option is not currently compatible with the
614 * tickless mode.
615 */
616#if !defined(CH_DBG_THREADS_PROFILING)
617#define CH_DBG_THREADS_PROFILING FALSE
618#endif
619
620/** @} */
621
622/*===========================================================================*/
623/**
624 * @name Kernel hooks
625 * @{
626 */
627/*===========================================================================*/
628
629/**
630 * @brief System structure extension.
631 * @details User fields added to the end of the @p ch_system_t structure.
632 */
633#define CH_CFG_SYSTEM_EXTRA_FIELDS \
634 /* Add threads custom fields here.*/
635
636/**
637 * @brief System initialization hook.
638 * @details User initialization code added to the @p chSysInit() function
639 * just before interrupts are enabled globally.
640 */
641#define CH_CFG_SYSTEM_INIT_HOOK() { \
642 /* Add threads initialization code here.*/ \
643}
644
645/**
646 * @brief Threads descriptor structure extension.
647 * @details User fields added to the end of the @p thread_t structure.
648 */
649#define CH_CFG_THREAD_EXTRA_FIELDS \
650 /* Add threads custom fields here.*/
651
652/**
653 * @brief Threads initialization hook.
654 * @details User initialization code added to the @p _thread_init() function.
655 *
656 * @note It is invoked from within @p _thread_init() and implicitly from all
657 * the threads creation APIs.
658 */
659#define CH_CFG_THREAD_INIT_HOOK(tp) { \
660 /* Add threads initialization code here.*/ \
661}
662
663/**
664 * @brief Threads finalization hook.
665 * @details User finalization code added to the @p chThdExit() API.
666 */
667#define CH_CFG_THREAD_EXIT_HOOK(tp) { \
668 /* Add threads finalization code here.*/ \
669}
670
671/**
672 * @brief Context switch hook.
673 * @details This hook is invoked just before switching between threads.
674 */
675#define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) { \
676 /* Context switch code here.*/ \
677}
678
679/**
680 * @brief ISR enter hook.
681 */
682#define CH_CFG_IRQ_PROLOGUE_HOOK() { \
683 /* IRQ prologue code here.*/ \
684}
685
686/**
687 * @brief ISR exit hook.
688 */
689#define CH_CFG_IRQ_EPILOGUE_HOOK() { \
690 /* IRQ epilogue code here.*/ \
691}
692
693/**
694 * @brief Idle thread enter hook.
695 * @note This hook is invoked within a critical zone, no OS functions
696 * should be invoked from here.
697 * @note This macro can be used to activate a power saving mode.
698 */
699#define CH_CFG_IDLE_ENTER_HOOK() { \
700 /* Idle-enter code here.*/ \
701}
702
703/**
704 * @brief Idle thread leave hook.
705 * @note This hook is invoked within a critical zone, no OS functions
706 * should be invoked from here.
707 * @note This macro can be used to deactivate a power saving mode.
708 */
709#define CH_CFG_IDLE_LEAVE_HOOK() { \
710 /* Idle-leave code here.*/ \
711}
712
713/**
714 * @brief Idle Loop hook.
715 * @details This hook is continuously invoked by the idle thread loop.
716 */
717#define CH_CFG_IDLE_LOOP_HOOK() { \
718 /* Idle loop code here.*/ \
719}
720
721/**
722 * @brief System tick event hook.
723 * @details This hook is invoked in the system tick handler immediately
724 * after processing the virtual timers queue.
725 */
726#define CH_CFG_SYSTEM_TICK_HOOK() { \
727 /* System tick event code here.*/ \
728}
729
730/**
731 * @brief System halt hook.
732 * @details This hook is invoked in case to a system halting error before
733 * the system is halted.
734 */
735#define CH_CFG_SYSTEM_HALT_HOOK(reason) { \
736 /* System halt code here.*/ \
737}
738
739/**
740 * @brief Trace hook.
741 * @details This hook is invoked each time a new record is written in the
742 * trace buffer.
743 */
744#define CH_CFG_TRACE_HOOK(tep) { \
745 /* Trace code here.*/ \
746}
747
748
749/** @} */
750
751/*===========================================================================*/
752/* Port-specific settings (override port settings defaulted in chcore.h). */
753/*===========================================================================*/
754
755#endif /* CHCONF_H */
756
757/** @} */
diff --git a/lib/chibios-contrib/testhal/NRF52/NRF52832/ADC/halconf.h b/lib/chibios-contrib/testhal/NRF52/NRF52832/ADC/halconf.h
new file mode 100644
index 000000000..8aa9c4127
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NRF52/NRF52832/ADC/halconf.h
@@ -0,0 +1,533 @@
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 templates/halconf.h
19 * @brief HAL configuration header.
20 * @details HAL configuration file, this file allows to enable or disable the
21 * various device drivers from your application. You may also use
22 * this file in order to override the device drivers default settings.
23 *
24 * @addtogroup HAL_CONF
25 * @{
26 */
27
28#ifndef HALCONF_H
29#define HALCONF_H
30
31#define _CHIBIOS_HAL_CONF_
32#define _CHIBIOS_HAL_CONF_VER_7_1_
33
34#include "mcuconf.h"
35
36/**
37 * @brief Enables the PAL subsystem.
38 */
39#if !defined(HAL_USE_PAL) || defined(__DOXYGEN__)
40#define HAL_USE_PAL TRUE
41#endif
42
43/**
44 * @brief Enables the ADC subsystem.
45 */
46#if !defined(HAL_USE_ADC) || defined(__DOXYGEN__)
47#define HAL_USE_ADC TRUE
48#endif
49
50/**
51 * @brief Enables the CAN subsystem.
52 */
53#if !defined(HAL_USE_CAN) || defined(__DOXYGEN__)
54#define HAL_USE_CAN FALSE
55#endif
56
57/**
58 * @brief Enables the cryptographic subsystem.
59 */
60#if !defined(HAL_USE_CRY) || defined(__DOXYGEN__)
61#define HAL_USE_CRY FALSE
62#endif
63
64/**
65 * @brief Enables the DAC subsystem.
66 */
67#if !defined(HAL_USE_DAC) || defined(__DOXYGEN__)
68#define HAL_USE_DAC FALSE
69#endif
70
71/**
72 * @brief Enables the EFlash subsystem.
73 */
74#if !defined(HAL_USE_EFL) || defined(__DOXYGEN__)
75#define HAL_USE_EFL FALSE
76#endif
77
78/**
79 * @brief Enables the GPT subsystem.
80 */
81#if !defined(HAL_USE_GPT) || defined(__DOXYGEN__)
82#define HAL_USE_GPT FALSE
83#endif
84
85/**
86 * @brief Enables the I2C subsystem.
87 */
88#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__)
89#define HAL_USE_I2C FALSE
90#endif
91
92/**
93 * @brief Enables the I2S subsystem.
94 */
95#if !defined(HAL_USE_I2S) || defined(__DOXYGEN__)
96#define HAL_USE_I2S FALSE
97#endif
98
99/**
100 * @brief Enables the ICU subsystem.
101 */
102#if !defined(HAL_USE_ICU) || defined(__DOXYGEN__)
103#define HAL_USE_ICU FALSE
104#endif
105
106/**
107 * @brief Enables the MAC subsystem.
108 */
109#if !defined(HAL_USE_MAC) || defined(__DOXYGEN__)
110#define HAL_USE_MAC FALSE
111#endif
112
113/**
114 * @brief Enables the MMC_SPI subsystem.
115 */
116#if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__)
117#define HAL_USE_MMC_SPI FALSE
118#endif
119
120/**
121 * @brief Enables the PWM subsystem.
122 */
123#if !defined(HAL_USE_PWM) || defined(__DOXYGEN__)
124#define HAL_USE_PWM FALSE
125#endif
126
127/**
128 * @brief Enables the RTC subsystem.
129 */
130#if !defined(HAL_USE_RTC) || defined(__DOXYGEN__)
131#define HAL_USE_RTC FALSE
132#endif
133
134/**
135 * @brief Enables the SDC subsystem.
136 */
137#if !defined(HAL_USE_SDC) || defined(__DOXYGEN__)
138#define HAL_USE_SDC FALSE
139#endif
140
141/**
142 * @brief Enables the SERIAL subsystem.
143 */
144#if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__)
145#define HAL_USE_SERIAL FALSE
146#endif
147
148/**
149 * @brief Enables the SERIAL over USB subsystem.
150 */
151#if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__)
152#define HAL_USE_SERIAL_USB FALSE
153#endif
154
155/**
156 * @brief Enables the SIO subsystem.
157 */
158#if !defined(HAL_USE_SIO) || defined(__DOXYGEN__)
159#define HAL_USE_SIO FALSE
160#endif
161
162/**
163 * @brief Enables the SPI subsystem.
164 */
165#if !defined(HAL_USE_SPI) || defined(__DOXYGEN__)
166#define HAL_USE_SPI FALSE
167#endif
168
169/**
170 * @brief Enables the TRNG subsystem.
171 */
172#if !defined(HAL_USE_TRNG) || defined(__DOXYGEN__)
173#define HAL_USE_TRNG FALSE
174#endif
175
176/**
177 * @brief Enables the UART subsystem.
178 */
179#if !defined(HAL_USE_UART) || defined(__DOXYGEN__)
180#define HAL_USE_UART FALSE
181#endif
182
183/**
184 * @brief Enables the USB subsystem.
185 */
186#if !defined(HAL_USE_USB) || defined(__DOXYGEN__)
187#define HAL_USE_USB FALSE
188#endif
189
190/**
191 * @brief Enables the WDG subsystem.
192 */
193#if !defined(HAL_USE_WDG) || defined(__DOXYGEN__)
194#define HAL_USE_WDG FALSE
195#endif
196
197/**
198 * @brief Enables the WSPI subsystem.
199 */
200#if !defined(HAL_USE_WSPI) || defined(__DOXYGEN__)
201#define HAL_USE_WSPI FALSE
202#endif
203
204/*===========================================================================*/
205/* PAL driver related settings. */
206/*===========================================================================*/
207
208/**
209 * @brief Enables synchronous APIs.
210 * @note Disabling this option saves both code and data space.
211 */
212#if !defined(PAL_USE_CALLBACKS) || defined(__DOXYGEN__)
213#define PAL_USE_CALLBACKS TRUE
214#endif
215
216/**
217 * @brief Enables synchronous APIs.
218 * @note Disabling this option saves both code and data space.
219 */
220#if !defined(PAL_USE_WAIT) || defined(__DOXYGEN__)
221#define PAL_USE_WAIT TRUE
222#endif
223
224/*===========================================================================*/
225/* ADC driver related settings. */
226/*===========================================================================*/
227
228/**
229 * @brief Enables synchronous APIs.
230 * @note Disabling this option saves both code and data space.
231 */
232#if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__)
233#define ADC_USE_WAIT TRUE
234#endif
235
236/**
237 * @brief Enables the @p adcAcquireBus() and @p adcReleaseBus() APIs.
238 * @note Disabling this option saves both code and data space.
239 */
240#if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
241#define ADC_USE_MUTUAL_EXCLUSION TRUE
242#endif
243
244/*===========================================================================*/
245/* CAN driver related settings. */
246/*===========================================================================*/
247
248/**
249 * @brief Sleep mode related APIs inclusion switch.
250 */
251#if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__)
252#define CAN_USE_SLEEP_MODE TRUE
253#endif
254
255/**
256 * @brief Enforces the driver to use direct callbacks rather than OSAL events.
257 */
258#if !defined(CAN_ENFORCE_USE_CALLBACKS) || defined(__DOXYGEN__)
259#define CAN_ENFORCE_USE_CALLBACKS FALSE
260#endif
261
262/*===========================================================================*/
263/* CRY driver related settings. */
264/*===========================================================================*/
265
266/**
267 * @brief Enables the SW fall-back of the cryptographic driver.
268 * @details When enabled, this option, activates a fall-back software
269 * implementation for algorithms not supported by the underlying
270 * hardware.
271 * @note Fall-back implementations may not be present for all algorithms.
272 */
273#if !defined(HAL_CRY_USE_FALLBACK) || defined(__DOXYGEN__)
274#define HAL_CRY_USE_FALLBACK FALSE
275#endif
276
277/**
278 * @brief Makes the driver forcibly use the fall-back implementations.
279 */
280#if !defined(HAL_CRY_ENFORCE_FALLBACK) || defined(__DOXYGEN__)
281#define HAL_CRY_ENFORCE_FALLBACK FALSE
282#endif
283
284/*===========================================================================*/
285/* DAC driver related settings. */
286/*===========================================================================*/
287
288/**
289 * @brief Enables synchronous APIs.
290 * @note Disabling this option saves both code and data space.
291 */
292#if !defined(DAC_USE_WAIT) || defined(__DOXYGEN__)
293#define DAC_USE_WAIT TRUE
294#endif
295
296/**
297 * @brief Enables the @p dacAcquireBus() and @p dacReleaseBus() APIs.
298 * @note Disabling this option saves both code and data space.
299 */
300#if !defined(DAC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
301#define DAC_USE_MUTUAL_EXCLUSION TRUE
302#endif
303
304/*===========================================================================*/
305/* I2C driver related settings. */
306/*===========================================================================*/
307
308/**
309 * @brief Enables the mutual exclusion APIs on the I2C bus.
310 */
311#if !defined(I2C_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
312#define I2C_USE_MUTUAL_EXCLUSION TRUE
313#endif
314
315/*===========================================================================*/
316/* MAC driver related settings. */
317/*===========================================================================*/
318
319/**
320 * @brief Enables the zero-copy API.
321 */
322#if !defined(MAC_USE_ZERO_COPY) || defined(__DOXYGEN__)
323#define MAC_USE_ZERO_COPY FALSE
324#endif
325
326/**
327 * @brief Enables an event sources for incoming packets.
328 */
329#if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__)
330#define MAC_USE_EVENTS TRUE
331#endif
332
333/*===========================================================================*/
334/* MMC_SPI driver related settings. */
335/*===========================================================================*/
336
337/**
338 * @brief Delays insertions.
339 * @details If enabled this options inserts delays into the MMC waiting
340 * routines releasing some extra CPU time for the threads with
341 * lower priority, this may slow down the driver a bit however.
342 * This option is recommended also if the SPI driver does not
343 * use a DMA channel and heavily loads the CPU.
344 */
345#if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__)
346#define MMC_NICE_WAITING TRUE
347#endif
348
349/*===========================================================================*/
350/* SDC driver related settings. */
351/*===========================================================================*/
352
353/**
354 * @brief Number of initialization attempts before rejecting the card.
355 * @note Attempts are performed at 10mS intervals.
356 */
357#if !defined(SDC_INIT_RETRY) || defined(__DOXYGEN__)
358#define SDC_INIT_RETRY 100
359#endif
360
361/**
362 * @brief Include support for MMC cards.
363 * @note MMC support is not yet implemented so this option must be kept
364 * at @p FALSE.
365 */
366#if !defined(SDC_MMC_SUPPORT) || defined(__DOXYGEN__)
367#define SDC_MMC_SUPPORT FALSE
368#endif
369
370/**
371 * @brief Delays insertions.
372 * @details If enabled this options inserts delays into the MMC waiting
373 * routines releasing some extra CPU time for the threads with
374 * lower priority, this may slow down the driver a bit however.
375 */
376#if !defined(SDC_NICE_WAITING) || defined(__DOXYGEN__)
377#define SDC_NICE_WAITING TRUE
378#endif
379
380/**
381 * @brief OCR initialization constant for V20 cards.
382 */
383#if !defined(SDC_INIT_OCR_V20) || defined(__DOXYGEN__)
384#define SDC_INIT_OCR_V20 0x50FF8000U
385#endif
386
387/**
388 * @brief OCR initialization constant for non-V20 cards.
389 */
390#if !defined(SDC_INIT_OCR) || defined(__DOXYGEN__)
391#define SDC_INIT_OCR 0x80100000U
392#endif
393
394/*===========================================================================*/
395/* SERIAL driver related settings. */
396/*===========================================================================*/
397
398/**
399 * @brief Default bit rate.
400 * @details Configuration parameter, this is the baud rate selected for the
401 * default configuration.
402 */
403#if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__)
404#define SERIAL_DEFAULT_BITRATE 38400
405#endif
406
407/**
408 * @brief Serial buffers size.
409 * @details Configuration parameter, you can change the depth of the queue
410 * buffers depending on the requirements of your application.
411 * @note The default is 16 bytes for both the transmission and receive
412 * buffers.
413 */
414#if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__)
415#define SERIAL_BUFFERS_SIZE 16
416#endif
417
418/*===========================================================================*/
419/* SERIAL_USB driver related setting. */
420/*===========================================================================*/
421
422/**
423 * @brief Serial over USB buffers size.
424 * @details Configuration parameter, the buffer size must be a multiple of
425 * the USB data endpoint maximum packet size.
426 * @note The default is 256 bytes for both the transmission and receive
427 * buffers.
428 */
429#if !defined(SERIAL_USB_BUFFERS_SIZE) || defined(__DOXYGEN__)
430#define SERIAL_USB_BUFFERS_SIZE 256
431#endif
432
433/**
434 * @brief Serial over USB number of buffers.
435 * @note The default is 2 buffers.
436 */
437#if !defined(SERIAL_USB_BUFFERS_NUMBER) || defined(__DOXYGEN__)
438#define SERIAL_USB_BUFFERS_NUMBER 2
439#endif
440
441/*===========================================================================*/
442/* SPI driver related settings. */
443/*===========================================================================*/
444
445/**
446 * @brief Enables synchronous APIs.
447 * @note Disabling this option saves both code and data space.
448 */
449#if !defined(SPI_USE_WAIT) || defined(__DOXYGEN__)
450#define SPI_USE_WAIT TRUE
451#endif
452
453/**
454 * @brief Enables circular transfers APIs.
455 * @note Disabling this option saves both code and data space.
456 */
457#if !defined(SPI_USE_CIRCULAR) || defined(__DOXYGEN__)
458#define SPI_USE_CIRCULAR FALSE
459#endif
460
461/**
462 * @brief Enables the @p spiAcquireBus() and @p spiReleaseBus() APIs.
463 * @note Disabling this option saves both code and data space.
464 */
465#if !defined(SPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
466#define SPI_USE_MUTUAL_EXCLUSION TRUE
467#endif
468
469/**
470 * @brief Handling method for SPI CS line.
471 * @note Disabling this option saves both code and data space.
472 */
473#if !defined(SPI_SELECT_MODE) || defined(__DOXYGEN__)
474#define SPI_SELECT_MODE SPI_SELECT_MODE_PAD
475#endif
476
477/*===========================================================================*/
478/* UART driver related settings. */
479/*===========================================================================*/
480
481/**
482 * @brief Enables synchronous APIs.
483 * @note Disabling this option saves both code and data space.
484 */
485#if !defined(UART_USE_WAIT) || defined(__DOXYGEN__)
486#define UART_USE_WAIT FALSE
487#endif
488
489/**
490 * @brief Enables the @p uartAcquireBus() and @p uartReleaseBus() APIs.
491 * @note Disabling this option saves both code and data space.
492 */
493#if !defined(UART_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
494#define UART_USE_MUTUAL_EXCLUSION FALSE
495#endif
496
497/*===========================================================================*/
498/* USB driver related settings. */
499/*===========================================================================*/
500
501/**
502 * @brief Enables synchronous APIs.
503 * @note Disabling this option saves both code and data space.
504 */
505#if !defined(USB_USE_WAIT) || defined(__DOXYGEN__)
506#define USB_USE_WAIT FALSE
507#endif
508
509/*===========================================================================*/
510/* WSPI driver related settings. */
511/*===========================================================================*/
512
513/**
514 * @brief Enables synchronous APIs.
515 * @note Disabling this option saves both code and data space.
516 */
517#if !defined(WSPI_USE_WAIT) || defined(__DOXYGEN__)
518#define WSPI_USE_WAIT TRUE
519#endif
520
521/**
522 * @brief Enables the @p wspiAcquireBus() and @p wspiReleaseBus() APIs.
523 * @note Disabling this option saves both code and data space.
524 */
525#if !defined(WSPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
526#define WSPI_USE_MUTUAL_EXCLUSION TRUE
527#endif
528
529#include "halconf_community.h"
530
531#endif /* HALCONF_H */
532
533/** @} */
diff --git a/lib/chibios-contrib/testhal/NRF52/NRF52832/ADC/halconf_community.h b/lib/chibios-contrib/testhal/NRF52/NRF52832/ADC/halconf_community.h
new file mode 100644
index 000000000..43fdbf869
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NRF52/NRF52832/ADC/halconf_community.h
@@ -0,0 +1,173 @@
1/*
2 ChibiOS - Copyright (C) 2014 Uladzimir Pylinsky aka barthess
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#ifndef HALCONF_COMMUNITY_H
18#define HALCONF_COMMUNITY_H
19
20/**
21 * @brief Enables the community overlay.
22 */
23#if !defined(HAL_USE_COMMUNITY) || defined(__DOXYGEN__)
24#define HAL_USE_COMMUNITY TRUE
25#endif
26
27/**
28 * @brief Enables the FSMC subsystem.
29 */
30#if !defined(HAL_USE_FSMC) || defined(__DOXYGEN__)
31#define HAL_USE_FSMC FALSE
32#endif
33
34/**
35 * @brief Enables the NAND subsystem.
36 */
37#if !defined(HAL_USE_NAND) || defined(__DOXYGEN__)
38#define HAL_USE_NAND FALSE
39#endif
40
41/**
42 * @brief Enables the 1-wire subsystem.
43 */
44#if !defined(HAL_USE_ONEWIRE) || defined(__DOXYGEN__)
45#define HAL_USE_ONEWIRE FALSE
46#endif
47
48/**
49 * @brief Enables the EICU subsystem.
50 */
51#if !defined(HAL_USE_EICU) || defined(__DOXYGEN__)
52#define HAL_USE_EICU FALSE
53#endif
54
55/**
56 * @brief Enables the CRC subsystem.
57 */
58#if !defined(HAL_USE_CRC) || defined(__DOXYGEN__)
59#define HAL_USE_CRC FALSE
60#endif
61
62/**
63 * @brief Enables the RNG subsystem.
64 */
65#if !defined(HAL_USE_RNG) || defined(__DOXYGEN__)
66#define HAL_USE_RNG FALSE
67#endif
68
69/**
70 * @brief Enables the EEPROM subsystem.
71 */
72#if !defined(HAL_USE_EEPROM) || defined(__DOXYGEN__)
73#define HAL_USE_EEPROM FALSE
74#endif
75
76/**
77 * @brief Enables the TIMCAP subsystem.
78 */
79#if !defined(HAL_USE_TIMCAP) || defined(__DOXYGEN__)
80#define HAL_USE_TIMCAP FALSE
81#endif
82
83/**
84 * @brief Enables the TIMCAP subsystem.
85 */
86#if !defined(HAL_USE_COMP) || defined(__DOXYGEN__)
87#define HAL_USE_COMP FALSE
88#endif
89
90/**
91 * @brief Enables the QEI subsystem.
92 */
93#if !defined(HAL_USE_QEI) || defined(__DOXYGEN__)
94#define HAL_USE_QEI FALSE
95#endif
96
97/**
98 * @brief Enables the USBH subsystem.
99 */
100#if !defined(HAL_USE_USBH) || defined(__DOXYGEN__)
101#define HAL_USE_USBH FALSE
102#endif
103
104/**
105 * @brief Enables the USB_MSD subsystem.
106 */
107#if !defined(HAL_USE_USB_MSD) || defined(__DOXYGEN__)
108#define HAL_USE_USB_MSD FALSE
109#endif
110
111/*===========================================================================*/
112/* FSMCNAND driver related settings. */
113/*===========================================================================*/
114
115/**
116 * @brief Enables the @p nandAcquireBus() and @p nanReleaseBus() APIs.
117 * @note Disabling this option saves both code and data space.
118 */
119#if !defined(NAND_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
120#define NAND_USE_MUTUAL_EXCLUSION TRUE
121#endif
122
123/*===========================================================================*/
124/* 1-wire driver related settings. */
125/*===========================================================================*/
126/**
127 * @brief Enables strong pull up feature.
128 * @note Disabling this option saves both code and data space.
129 */
130#define ONEWIRE_USE_STRONG_PULLUP FALSE
131
132/**
133 * @brief Enables search ROM feature.
134 * @note Disabling this option saves both code and data space.
135 */
136#define ONEWIRE_USE_SEARCH_ROM TRUE
137
138/*===========================================================================*/
139/* QEI driver related settings. */
140/*===========================================================================*/
141
142/**
143 * @brief Enables discard of overlow
144 */
145#if !defined(QEI_USE_OVERFLOW_DISCARD) || defined(__DOXYGEN__)
146#define QEI_USE_OVERFLOW_DISCARD FALSE
147#endif
148
149/**
150 * @brief Enables min max of overlow
151 */
152#if !defined(QEI_USE_OVERFLOW_MINMAX) || defined(__DOXYGEN__)
153#define QEI_USE_OVERFLOW_MINMAX FALSE
154#endif
155
156/*===========================================================================*/
157/* EEProm driver related settings. */
158/*===========================================================================*/
159
160/**
161 * @brief Enables 24xx series I2C eeprom device driver.
162 * @note Disabling this option saves both code and data space.
163 */
164#define EEPROM_USE_EE24XX FALSE
165 /**
166 * @brief Enables 25xx series SPI eeprom device driver.
167 * @note Disabling this option saves both code and data space.
168 */
169#define EEPROM_USE_EE25XX FALSE
170
171#endif /* HALCONF_COMMUNITY_H */
172
173/** @} */
diff --git a/lib/chibios-contrib/testhal/NRF52/NRF52832/ADC/main.c b/lib/chibios-contrib/testhal/NRF52/NRF52832/ADC/main.c
new file mode 100644
index 000000000..68bef479a
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NRF52/NRF52832/ADC/main.c
@@ -0,0 +1,139 @@
1/*
2 Copyright (C) 2020 Konstantin Oblaukhov
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
20#define ADC_GRP1_NUM_CHANNELS 1
21#define ADC_GRP1_BUF_DEPTH 8
22
23#define ADC_GRP2_NUM_CHANNELS 1
24#define ADC_GRP2_BUF_DEPTH 16
25
26static adcsample_t samples1[ADC_GRP1_NUM_CHANNELS * ADC_GRP1_BUF_DEPTH];
27static adcsample_t samples2[ADC_GRP2_NUM_CHANNELS * ADC_GRP2_BUF_DEPTH];
28
29/*
30 * ADC streaming callback.
31 */
32size_t nx = 0;
33static void adccallback(ADCDriver *adcp) {
34
35 (void)adcp;
36 nx++;
37}
38
39/*
40 * ADC conversion group.
41 * Mode: Linear buffer, 8 samples of 1 channel, SW triggered.
42 * Channels: AIN0 (prescaled by 1/6).
43 */
44static const ADCConversionGroup adcgrpcfg1 = {
45 false,
46 ADC_GRP1_NUM_CHANNELS,
47 NULL,
48 NULL,
49 false,
50 SAADC_RESOLUTION_VAL_14bit,
51 0,
52 0,
53 {
54 {SAADC_CH_PSELP_PSELP_AnalogInput0,
55 SAADC_CH_PSELN_PSELN_NC,
56 SAADC_CH_CONFIG_TACQ_40us << SAADC_CH_CONFIG_TACQ_Pos}
57 }
58};
59
60/*
61 * ADC conversion group.
62 * Mode: Continuous, 16 samples of 1 channel, SW triggered.
63 * Channels: VDD (prescaled by 1/6).
64 */
65static const ADCConversionGroup adcgrpcfg2 = {
66 true,
67 ADC_GRP1_NUM_CHANNELS,
68 adccallback,
69 NULL,
70 false,
71 SAADC_RESOLUTION_VAL_14bit,
72 0,
73 0,
74 {
75 {SAADC_CH_PSELP_PSELP_VDD,
76 SAADC_CH_PSELN_PSELN_NC,
77 SAADC_CH_CONFIG_TACQ_40us << SAADC_CH_CONFIG_TACQ_Pos}
78 }
79};
80
81/*
82 * LED blinker thread, times are in milliseconds.
83 */
84static THD_WORKING_AREA(waThread1, 128);
85static THD_FUNCTION(Thread1, arg) {
86
87 (void)arg;
88 chRegSetThreadName("blinker");
89 while (true) {
90 palTogglePad(IOPORT1, LED1);
91 chThdSleepMilliseconds(500);
92 }
93}
94
95/*
96 * Application entry point.
97 */
98int main(void) {
99
100 /*
101 * System initializations.
102 * - HAL initialization, this also initializes the configured device drivers
103 * and performs the board-specific initializations.
104 * - Kernel initialization, the main() function becomes a thread and the
105 * RTOS is active.
106 */
107 halInit();
108 chSysInit();
109
110 /*
111 * Creates the blinker thread.
112 */
113 chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
114
115 /*
116 * Activates the ADC1 driver and the temperature sensor.
117 */
118 adcStart(&ADCD1, NULL);
119
120 /*
121 * Linear conversion.
122 */
123 adcConvert(&ADCD1, &adcgrpcfg1, samples1, ADC_GRP1_BUF_DEPTH);
124 chThdSleepMilliseconds(1000);
125
126 /*
127 * Starts an ADC continuous conversion.
128 */
129 adcStartConversion(&ADCD1, &adcgrpcfg2, samples2, ADC_GRP2_BUF_DEPTH);
130
131 /*
132 * Normal main() thread activity, in this demo it does nothing.
133 */
134 while (true) {
135 if (palReadPad(IOPORT1, BTN1) == 0)
136 adcStopConversion(&ADCD1);
137 chThdSleepMilliseconds(500);
138 }
139}
diff --git a/lib/chibios-contrib/testhal/NRF52/NRF52832/ADC/mcuconf.h b/lib/chibios-contrib/testhal/NRF52/NRF52832/ADC/mcuconf.h
new file mode 100644
index 000000000..facdeb0da
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NRF52/NRF52832/ADC/mcuconf.h
@@ -0,0 +1,25 @@
1/*
2 Copyright (C) 2020 Konstantin Oblaukhov
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#ifndef _MCUCONF_H_
18#define _MCUCONF_H_
19
20/*
21 * HAL driver system settings.
22 */
23#define NRF5_ADC_USE_ADC1 TRUE
24
25#endif /* _MCUCONF_H_ */
diff --git a/lib/chibios-contrib/testhal/NRF52/NRF52832/I2C/Makefile b/lib/chibios-contrib/testhal/NRF52/NRF52832/I2C/Makefile
new file mode 100644
index 000000000..a26a0cde0
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NRF52/NRF52832/I2C/Makefile
@@ -0,0 +1,207 @@
1##############################################################################
2# Build global options
3# NOTE: Can be overridden externally.
4#
5
6# Compiler options here.
7ifeq ($(USE_OPT),)
8 USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16
9endif
10
11# C specific options here (added to USE_OPT).
12ifeq ($(USE_COPT),)
13 USE_COPT =
14endif
15
16# C++ specific options here (added to USE_OPT).
17ifeq ($(USE_CPPOPT),)
18 USE_CPPOPT = -fno-rtti
19endif
20
21# Enable this if you want the linker to remove unused code and data
22ifeq ($(USE_LINK_GC),)
23 USE_LINK_GC = yes
24endif
25
26# Linker extra options here.
27ifeq ($(USE_LDOPT),)
28 USE_LDOPT =
29endif
30
31# Enable this if you want link time optimizations (LTO)
32ifeq ($(USE_LTO),)
33 USE_LTO = yes
34endif
35
36# If enabled, this option allows to compile the application in THUMB mode.
37ifeq ($(USE_THUMB),)
38 USE_THUMB = yes
39endif
40
41# Enable this if you want to see the full log while compiling.
42ifeq ($(USE_VERBOSE_COMPILE),)
43 USE_VERBOSE_COMPILE = no
44endif
45
46#
47# Build global options
48##############################################################################
49
50##############################################################################
51# Architecture or project specific options
52#
53
54# Stack size to be allocated to the Cortex-M process stack. This stack is
55# the stack used by the main() thread.
56ifeq ($(USE_PROCESS_STACKSIZE),)
57 USE_PROCESS_STACKSIZE = 0x400
58endif
59
60# Stack size to the allocated to the Cortex-M main/exceptions stack. This
61# stack is used for processing interrupts and exceptions.
62ifeq ($(USE_EXCEPTIONS_STACKSIZE),)
63 USE_EXCEPTIONS_STACKSIZE = 0x400
64endif
65
66# Enables the use of FPU on Cortex-M4 (no, softfp, hard).
67ifeq ($(USE_FPU),)
68 USE_FPU = no
69endif
70
71#
72# Architecture or project specific options
73##############################################################################
74
75##############################################################################
76# Project, sources and paths
77#
78
79# Define project name here
80PROJECT = ch
81
82# Imported source files and paths
83CHIBIOS = ../../../../../ChibiOS
84CHIBIOS_CONTRIB = $(CHIBIOS)/../ChibiOS-Contrib
85# Licensing files.
86include $(CHIBIOS)/os/license/license.mk
87# Startup files.
88include $(CHIBIOS_CONTRIB)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_nrf52.mk
89# HAL-OSAL files (optional).
90include $(CHIBIOS_CONTRIB)/os/hal/hal.mk
91include $(CHIBIOS_CONTRIB)/os/hal/ports/NRF5/NRF52832/platform.mk
92include $(CHIBIOS_CONTRIB)/os/hal/boards/NRF52-E73-2G4M04S/board.mk
93include $(CHIBIOS)/os/hal/osal/rt-nil/osal.mk
94# RTOS files (optional).
95include $(CHIBIOS)/os/rt/rt.mk
96include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk
97# Other files (optional).
98#include $(CHIBIOS)/test/rt/test.mk
99
100# Define linker script file here
101LDSCRIPT= $(STARTUPLD_CONTRIB)/NRF52832.ld
102
103# C sources that can be compiled in ARM or THUMB mode depending on the global
104# setting.
105CSRC = $(ALLCSRC) \
106 $(TESTSRC) \
107 main.c
108
109# C++ sources that can be compiled in ARM or THUMB mode depending on the global
110# setting.
111CPPSRC = $(ALLCPPSRC)
112
113# C sources to be compiled in ARM mode regardless of the global setting.
114# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
115# option that results in lower performance and larger code size.
116ACSRC =
117
118# C++ sources to be compiled in ARM mode regardless of the global setting.
119# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
120# option that results in lower performance and larger code size.
121ACPPSRC =
122
123# C sources to be compiled in THUMB mode regardless of the global setting.
124# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
125# option that results in lower performance and larger code size.
126TCSRC =
127
128# C sources to be compiled in THUMB mode regardless of the global setting.
129# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
130# option that results in lower performance and larger code size.
131TCPPSRC =
132
133# List ASM source files here
134ASMSRC = $(ALLASMSRC)
135ASMXSRC = $(ALLXASMSRC)
136
137INCDIR = $(ALLINC) $(TESTINC) \
138 $(TESTHAL)
139
140#
141# Project, sources and paths
142##############################################################################
143
144##############################################################################
145# Compiler settings
146#
147
148MCU = cortex-m4
149
150TRGT = arm-none-eabi-
151CC = $(TRGT)gcc
152CPPC = $(TRGT)g++
153# Enable loading with g++ only if you need C++ runtime support.
154# NOTE: You can use C++ even without C++ support if you are careful. C++
155# runtime support makes code size explode.
156LD = $(TRGT)gcc
157#LD = $(TRGT)g++
158CP = $(TRGT)objcopy
159AS = $(TRGT)gcc -x assembler-with-cpp
160AR = $(TRGT)ar
161OD = $(TRGT)objdump
162SZ = $(TRGT)size
163HEX = $(CP) -O ihex
164BIN = $(CP) -O binary
165SREC = $(CP) -O srec
166
167# ARM-specific options here
168AOPT =
169
170# THUMB-specific options here
171TOPT = -mthumb -DTHUMB
172
173# Define C warning options here
174CWARN = -Wall -Wextra -Wstrict-prototypes
175
176# Define C++ warning options here
177CPPWARN = -Wall -Wextra
178
179#
180# Compiler settings
181##############################################################################
182
183##############################################################################
184# Start of user section
185#
186
187# List all user C define here, like -D_DEBUG=1
188UDEFS =
189
190# Define ASM defines here
191UADEFS =
192
193# List all user directories here
194UINCDIR =
195
196# List the user directory to look for the libraries here
197ULIBDIR =
198
199# List all user libraries here
200ULIBS =
201
202#
203# End of user defines
204##############################################################################
205
206RULESPATH = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk
207include $(RULESPATH)/rules.mk
diff --git a/lib/chibios-contrib/testhal/NRF52/NRF52832/I2C/chconf.h b/lib/chibios-contrib/testhal/NRF52/NRF52832/I2C/chconf.h
new file mode 100644
index 000000000..6687603e0
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NRF52/NRF52832/I2C/chconf.h
@@ -0,0 +1,757 @@
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 rt/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 config
24 * @details Kernel related settings and hooks.
25 * @{
26 */
27
28#ifndef CHCONF_H
29#define CHCONF_H
30
31#define _CHIBIOS_RT_CONF_
32#define _CHIBIOS_RT_CONF_VER_6_1_
33
34/*===========================================================================*/
35/**
36 * @name System timers settings
37 * @{
38 */
39/*===========================================================================*/
40
41/**
42 * @brief System time counter resolution.
43 * @note Allowed values are 16 or 32 bits.
44 */
45#if !defined(CH_CFG_ST_RESOLUTION)
46#define CH_CFG_ST_RESOLUTION 32
47#endif
48
49/**
50 * @brief System tick frequency.
51 * @details Frequency of the system timer that drives the system ticks. This
52 * setting also defines the system tick time unit.
53 */
54#if !defined(CH_CFG_ST_FREQUENCY)
55#define CH_CFG_ST_FREQUENCY 1000
56#endif
57
58/**
59 * @brief Time intervals data size.
60 * @note Allowed values are 16, 32 or 64 bits.
61 */
62#if !defined(CH_CFG_INTERVALS_SIZE)
63#define CH_CFG_INTERVALS_SIZE 32
64#endif
65
66/**
67 * @brief Time types data size.
68 * @note Allowed values are 16 or 32 bits.
69 */
70#if !defined(CH_CFG_TIME_TYPES_SIZE)
71#define CH_CFG_TIME_TYPES_SIZE 32
72#endif
73
74/**
75 * @brief Time delta constant for the tick-less mode.
76 * @note If this value is zero then the system uses the classic
77 * periodic tick. This value represents the minimum number
78 * of ticks that is safe to specify in a timeout directive.
79 * The value one is not valid, timeouts are rounded up to
80 * this value.
81 */
82#if !defined(CH_CFG_ST_TIMEDELTA)
83#define CH_CFG_ST_TIMEDELTA 0
84#endif
85
86/** @} */
87
88/*===========================================================================*/
89/**
90 * @name Kernel parameters and options
91 * @{
92 */
93/*===========================================================================*/
94
95/**
96 * @brief Round robin interval.
97 * @details This constant is the number of system ticks allowed for the
98 * threads before preemption occurs. Setting this value to zero
99 * disables the preemption for threads with equal priority and the
100 * round robin becomes cooperative. Note that higher priority
101 * threads can still preempt, the kernel is always preemptive.
102 * @note Disabling the round robin preemption makes the kernel more compact
103 * and generally faster.
104 * @note The round robin preemption is not supported in tickless mode and
105 * must be set to zero in that case.
106 */
107#if !defined(CH_CFG_TIME_QUANTUM)
108#define CH_CFG_TIME_QUANTUM 0
109#endif
110
111/**
112 * @brief Idle thread automatic spawn suppression.
113 * @details When this option is activated the function @p chSysInit()
114 * does not spawn the idle thread. The application @p main()
115 * function becomes the idle thread and must implement an
116 * infinite loop.
117 */
118#if !defined(CH_CFG_NO_IDLE_THREAD)
119#define CH_CFG_NO_IDLE_THREAD FALSE
120#endif
121
122/** @} */
123
124/*===========================================================================*/
125/**
126 * @name Performance options
127 * @{
128 */
129/*===========================================================================*/
130
131/**
132 * @brief OS optimization.
133 * @details If enabled then time efficient rather than space efficient code
134 * is used when two possible implementations exist.
135 *
136 * @note This is not related to the compiler optimization options.
137 * @note The default is @p TRUE.
138 */
139#if !defined(CH_CFG_OPTIMIZE_SPEED)
140#define CH_CFG_OPTIMIZE_SPEED TRUE
141#endif
142
143/** @} */
144
145/*===========================================================================*/
146/**
147 * @name Subsystem options
148 * @{
149 */
150/*===========================================================================*/
151
152/**
153 * @brief Time Measurement APIs.
154 * @details If enabled then the time measurement APIs are included in
155 * the kernel.
156 *
157 * @note The default is @p TRUE.
158 */
159#if !defined(CH_CFG_USE_TM)
160#define CH_CFG_USE_TM TRUE
161#endif
162
163/**
164 * @brief Threads registry APIs.
165 * @details If enabled then the registry APIs are included in the kernel.
166 *
167 * @note The default is @p TRUE.
168 */
169#if !defined(CH_CFG_USE_REGISTRY)
170#define CH_CFG_USE_REGISTRY TRUE
171#endif
172
173/**
174 * @brief Threads synchronization APIs.
175 * @details If enabled then the @p chThdWait() function is included in
176 * the kernel.
177 *
178 * @note The default is @p TRUE.
179 */
180#if !defined(CH_CFG_USE_WAITEXIT)
181#define CH_CFG_USE_WAITEXIT TRUE
182#endif
183
184/**
185 * @brief Semaphores APIs.
186 * @details If enabled then the Semaphores APIs are included in the kernel.
187 *
188 * @note The default is @p TRUE.
189 */
190#if !defined(CH_CFG_USE_SEMAPHORES)
191#define CH_CFG_USE_SEMAPHORES TRUE
192#endif
193
194/**
195 * @brief Semaphores queuing mode.
196 * @details If enabled then the threads are enqueued on semaphores by
197 * priority rather than in FIFO order.
198 *
199 * @note The default is @p FALSE. Enable this if you have special
200 * requirements.
201 * @note Requires @p CH_CFG_USE_SEMAPHORES.
202 */
203#if !defined(CH_CFG_USE_SEMAPHORES_PRIORITY)
204#define CH_CFG_USE_SEMAPHORES_PRIORITY FALSE
205#endif
206
207/**
208 * @brief Mutexes APIs.
209 * @details If enabled then the mutexes APIs are included in the kernel.
210 *
211 * @note The default is @p TRUE.
212 */
213#if !defined(CH_CFG_USE_MUTEXES)
214#define CH_CFG_USE_MUTEXES TRUE
215#endif
216
217/**
218 * @brief Enables recursive behavior on mutexes.
219 * @note Recursive mutexes are heavier and have an increased
220 * memory footprint.
221 *
222 * @note The default is @p FALSE.
223 * @note Requires @p CH_CFG_USE_MUTEXES.
224 */
225#if !defined(CH_CFG_USE_MUTEXES_RECURSIVE)
226#define CH_CFG_USE_MUTEXES_RECURSIVE FALSE
227#endif
228
229/**
230 * @brief Conditional Variables APIs.
231 * @details If enabled then the conditional variables APIs are included
232 * in the kernel.
233 *
234 * @note The default is @p TRUE.
235 * @note Requires @p CH_CFG_USE_MUTEXES.
236 */
237#if !defined(CH_CFG_USE_CONDVARS)
238#define CH_CFG_USE_CONDVARS TRUE
239#endif
240
241/**
242 * @brief Conditional Variables APIs with timeout.
243 * @details If enabled then the conditional variables APIs with timeout
244 * specification are included in the kernel.
245 *
246 * @note The default is @p TRUE.
247 * @note Requires @p CH_CFG_USE_CONDVARS.
248 */
249#if !defined(CH_CFG_USE_CONDVARS_TIMEOUT)
250#define CH_CFG_USE_CONDVARS_TIMEOUT TRUE
251#endif
252
253/**
254 * @brief Events Flags APIs.
255 * @details If enabled then the event flags APIs are included in the kernel.
256 *
257 * @note The default is @p TRUE.
258 */
259#if !defined(CH_CFG_USE_EVENTS)
260#define CH_CFG_USE_EVENTS TRUE
261#endif
262
263/**
264 * @brief Events Flags APIs with timeout.
265 * @details If enabled then the events APIs with timeout specification
266 * are included in the kernel.
267 *
268 * @note The default is @p TRUE.
269 * @note Requires @p CH_CFG_USE_EVENTS.
270 */
271#if !defined(CH_CFG_USE_EVENTS_TIMEOUT)
272#define CH_CFG_USE_EVENTS_TIMEOUT TRUE
273#endif
274
275/**
276 * @brief Synchronous Messages APIs.
277 * @details If enabled then the synchronous messages APIs are included
278 * in the kernel.
279 *
280 * @note The default is @p TRUE.
281 */
282#if !defined(CH_CFG_USE_MESSAGES)
283#define CH_CFG_USE_MESSAGES TRUE
284#endif
285
286/**
287 * @brief Synchronous Messages queuing mode.
288 * @details If enabled then messages are served by priority rather than in
289 * FIFO order.
290 *
291 * @note The default is @p FALSE. Enable this if you have special
292 * requirements.
293 * @note Requires @p CH_CFG_USE_MESSAGES.
294 */
295#if !defined(CH_CFG_USE_MESSAGES_PRIORITY)
296#define CH_CFG_USE_MESSAGES_PRIORITY FALSE
297#endif
298
299/**
300 * @brief Dynamic Threads APIs.
301 * @details If enabled then the dynamic threads creation APIs are included
302 * in the kernel.
303 *
304 * @note The default is @p TRUE.
305 * @note Requires @p CH_CFG_USE_WAITEXIT.
306 * @note Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS.
307 */
308#if !defined(CH_CFG_USE_DYNAMIC)
309#define CH_CFG_USE_DYNAMIC TRUE
310#endif
311
312/** @} */
313
314/*===========================================================================*/
315/**
316 * @name OSLIB options
317 * @{
318 */
319/*===========================================================================*/
320
321/**
322 * @brief Mailboxes APIs.
323 * @details If enabled then the asynchronous messages (mailboxes) APIs are
324 * included in the kernel.
325 *
326 * @note The default is @p TRUE.
327 * @note Requires @p CH_CFG_USE_SEMAPHORES.
328 */
329#if !defined(CH_CFG_USE_MAILBOXES)
330#define CH_CFG_USE_MAILBOXES TRUE
331#endif
332
333/**
334 * @brief Core Memory Manager APIs.
335 * @details If enabled then the core memory manager APIs are included
336 * in the kernel.
337 *
338 * @note The default is @p TRUE.
339 */
340#if !defined(CH_CFG_USE_MEMCORE)
341#define CH_CFG_USE_MEMCORE TRUE
342#endif
343
344/**
345 * @brief Managed RAM size.
346 * @details Size of the RAM area to be managed by the OS. If set to zero
347 * then the whole available RAM is used. The core memory is made
348 * available to the heap allocator and/or can be used directly through
349 * the simplified core memory allocator.
350 *
351 * @note In order to let the OS manage the whole RAM the linker script must
352 * provide the @p __heap_base__ and @p __heap_end__ symbols.
353 * @note Requires @p CH_CFG_USE_MEMCORE.
354 */
355#if !defined(CH_CFG_MEMCORE_SIZE)
356#define CH_CFG_MEMCORE_SIZE 0
357#endif
358
359/**
360 * @brief Heap Allocator APIs.
361 * @details If enabled then the memory heap allocator APIs are included
362 * in the kernel.
363 *
364 * @note The default is @p TRUE.
365 * @note Requires @p CH_CFG_USE_MEMCORE and either @p CH_CFG_USE_MUTEXES or
366 * @p CH_CFG_USE_SEMAPHORES.
367 * @note Mutexes are recommended.
368 */
369#if !defined(CH_CFG_USE_HEAP)
370#define CH_CFG_USE_HEAP TRUE
371#endif
372
373/**
374 * @brief Memory Pools Allocator APIs.
375 * @details If enabled then the memory pools allocator APIs are included
376 * in the kernel.
377 *
378 * @note The default is @p TRUE.
379 */
380#if !defined(CH_CFG_USE_MEMPOOLS)
381#define CH_CFG_USE_MEMPOOLS TRUE
382#endif
383
384/**
385 * @brief Objects FIFOs APIs.
386 * @details If enabled then the objects FIFOs APIs are included
387 * in the kernel.
388 *
389 * @note The default is @p TRUE.
390 */
391#if !defined(CH_CFG_USE_OBJ_FIFOS)
392#define CH_CFG_USE_OBJ_FIFOS TRUE
393#endif
394
395/**
396 * @brief Pipes APIs.
397 * @details If enabled then the pipes APIs are included
398 * in the kernel.
399 *
400 * @note The default is @p TRUE.
401 */
402#if !defined(CH_CFG_USE_PIPES)
403#define CH_CFG_USE_PIPES TRUE
404#endif
405
406/**
407 * @brief Objects Caches APIs.
408 * @details If enabled then the objects caches APIs are included
409 * in the kernel.
410 *
411 * @note The default is @p TRUE.
412 */
413#if !defined(CH_CFG_USE_OBJ_CACHES)
414#define CH_CFG_USE_OBJ_CACHES TRUE
415#endif
416
417/**
418 * @brief Delegate threads APIs.
419 * @details If enabled then the delegate threads APIs are included
420 * in the kernel.
421 *
422 * @note The default is @p TRUE.
423 */
424#if !defined(CH_CFG_USE_DELEGATES)
425#define CH_CFG_USE_DELEGATES TRUE
426#endif
427
428/**
429 * @brief Jobs Queues APIs.
430 * @details If enabled then the jobs queues APIs are included
431 * in the kernel.
432 *
433 * @note The default is @p TRUE.
434 */
435#if !defined(CH_CFG_USE_JOBS)
436#define CH_CFG_USE_JOBS TRUE
437#endif
438
439/** @} */
440
441/*===========================================================================*/
442/**
443 * @name Objects factory options
444 * @{
445 */
446/*===========================================================================*/
447
448/**
449 * @brief Objects Factory APIs.
450 * @details If enabled then the objects factory APIs are included in the
451 * kernel.
452 *
453 * @note The default is @p FALSE.
454 */
455#if !defined(CH_CFG_USE_FACTORY)
456#define CH_CFG_USE_FACTORY TRUE
457#endif
458
459/**
460 * @brief Maximum length for object names.
461 * @details If the specified length is zero then the name is stored by
462 * pointer but this could have unintended side effects.
463 */
464#if !defined(CH_CFG_FACTORY_MAX_NAMES_LENGTH)
465#define CH_CFG_FACTORY_MAX_NAMES_LENGTH 8
466#endif
467
468/**
469 * @brief Enables the registry of generic objects.
470 */
471#if !defined(CH_CFG_FACTORY_OBJECTS_REGISTRY)
472#define CH_CFG_FACTORY_OBJECTS_REGISTRY TRUE
473#endif
474
475/**
476 * @brief Enables factory for generic buffers.
477 */
478#if !defined(CH_CFG_FACTORY_GENERIC_BUFFERS)
479#define CH_CFG_FACTORY_GENERIC_BUFFERS TRUE
480#endif
481
482/**
483 * @brief Enables factory for semaphores.
484 */
485#if !defined(CH_CFG_FACTORY_SEMAPHORES)
486#define CH_CFG_FACTORY_SEMAPHORES TRUE
487#endif
488
489/**
490 * @brief Enables factory for mailboxes.
491 */
492#if !defined(CH_CFG_FACTORY_MAILBOXES)
493#define CH_CFG_FACTORY_MAILBOXES TRUE
494#endif
495
496/**
497 * @brief Enables factory for objects FIFOs.
498 */
499#if !defined(CH_CFG_FACTORY_OBJ_FIFOS)
500#define CH_CFG_FACTORY_OBJ_FIFOS TRUE
501#endif
502
503/**
504 * @brief Enables factory for Pipes.
505 */
506#if !defined(CH_CFG_FACTORY_PIPES) || defined(__DOXYGEN__)
507#define CH_CFG_FACTORY_PIPES TRUE
508#endif
509
510/** @} */
511
512/*===========================================================================*/
513/**
514 * @name Debug options
515 * @{
516 */
517/*===========================================================================*/
518
519/**
520 * @brief Debug option, kernel statistics.
521 *
522 * @note The default is @p FALSE.
523 */
524#if !defined(CH_DBG_STATISTICS)
525#define CH_DBG_STATISTICS FALSE
526#endif
527
528/**
529 * @brief Debug option, system state check.
530 * @details If enabled the correct call protocol for system APIs is checked
531 * at runtime.
532 *
533 * @note The default is @p FALSE.
534 */
535#if !defined(CH_DBG_SYSTEM_STATE_CHECK)
536#define CH_DBG_SYSTEM_STATE_CHECK TRUE
537#endif
538
539/**
540 * @brief Debug option, parameters checks.
541 * @details If enabled then the checks on the API functions input
542 * parameters are activated.
543 *
544 * @note The default is @p FALSE.
545 */
546#if !defined(CH_DBG_ENABLE_CHECKS)
547#define CH_DBG_ENABLE_CHECKS TRUE
548#endif
549
550/**
551 * @brief Debug option, consistency checks.
552 * @details If enabled then all the assertions in the kernel code are
553 * activated. This includes consistency checks inside the kernel,
554 * runtime anomalies and port-defined checks.
555 *
556 * @note The default is @p FALSE.
557 */
558#if !defined(CH_DBG_ENABLE_ASSERTS)
559#define CH_DBG_ENABLE_ASSERTS TRUE
560#endif
561
562/**
563 * @brief Debug option, trace buffer.
564 * @details If enabled then the trace buffer is activated.
565 *
566 * @note The default is @p CH_DBG_TRACE_MASK_DISABLED.
567 */
568#if !defined(CH_DBG_TRACE_MASK)
569#define CH_DBG_TRACE_MASK CH_DBG_TRACE_MASK_DISABLED
570#endif
571
572/**
573 * @brief Trace buffer entries.
574 * @note The trace buffer is only allocated if @p CH_DBG_TRACE_MASK is
575 * different from @p CH_DBG_TRACE_MASK_DISABLED.
576 */
577#if !defined(CH_DBG_TRACE_BUFFER_SIZE)
578#define CH_DBG_TRACE_BUFFER_SIZE 128
579#endif
580
581/**
582 * @brief Debug option, stack checks.
583 * @details If enabled then a runtime stack check is performed.
584 *
585 * @note The default is @p FALSE.
586 * @note The stack check is performed in a architecture/port dependent way.
587 * It may not be implemented or some ports.
588 * @note The default failure mode is to halt the system with the global
589 * @p panic_msg variable set to @p NULL.
590 */
591#if !defined(CH_DBG_ENABLE_STACK_CHECK)
592#define CH_DBG_ENABLE_STACK_CHECK FALSE
593#endif
594
595/**
596 * @brief Debug option, stacks initialization.
597 * @details If enabled then the threads working area is filled with a byte
598 * value when a thread is created. This can be useful for the
599 * runtime measurement of the used stack.
600 *
601 * @note The default is @p FALSE.
602 */
603#if !defined(CH_DBG_FILL_THREADS)
604#define CH_DBG_FILL_THREADS FALSE
605#endif
606
607/**
608 * @brief Debug option, threads profiling.
609 * @details If enabled then a field is added to the @p thread_t structure that
610 * counts the system ticks occurred while executing the thread.
611 *
612 * @note The default is @p FALSE.
613 * @note This debug option is not currently compatible with the
614 * tickless mode.
615 */
616#if !defined(CH_DBG_THREADS_PROFILING)
617#define CH_DBG_THREADS_PROFILING FALSE
618#endif
619
620/** @} */
621
622/*===========================================================================*/
623/**
624 * @name Kernel hooks
625 * @{
626 */
627/*===========================================================================*/
628
629/**
630 * @brief System structure extension.
631 * @details User fields added to the end of the @p ch_system_t structure.
632 */
633#define CH_CFG_SYSTEM_EXTRA_FIELDS \
634 /* Add threads custom fields here.*/
635
636/**
637 * @brief System initialization hook.
638 * @details User initialization code added to the @p chSysInit() function
639 * just before interrupts are enabled globally.
640 */
641#define CH_CFG_SYSTEM_INIT_HOOK() { \
642 /* Add threads initialization code here.*/ \
643}
644
645/**
646 * @brief Threads descriptor structure extension.
647 * @details User fields added to the end of the @p thread_t structure.
648 */
649#define CH_CFG_THREAD_EXTRA_FIELDS \
650 /* Add threads custom fields here.*/
651
652/**
653 * @brief Threads initialization hook.
654 * @details User initialization code added to the @p _thread_init() function.
655 *
656 * @note It is invoked from within @p _thread_init() and implicitly from all
657 * the threads creation APIs.
658 */
659#define CH_CFG_THREAD_INIT_HOOK(tp) { \
660 /* Add threads initialization code here.*/ \
661}
662
663/**
664 * @brief Threads finalization hook.
665 * @details User finalization code added to the @p chThdExit() API.
666 */
667#define CH_CFG_THREAD_EXIT_HOOK(tp) { \
668 /* Add threads finalization code here.*/ \
669}
670
671/**
672 * @brief Context switch hook.
673 * @details This hook is invoked just before switching between threads.
674 */
675#define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) { \
676 /* Context switch code here.*/ \
677}
678
679/**
680 * @brief ISR enter hook.
681 */
682#define CH_CFG_IRQ_PROLOGUE_HOOK() { \
683 /* IRQ prologue code here.*/ \
684}
685
686/**
687 * @brief ISR exit hook.
688 */
689#define CH_CFG_IRQ_EPILOGUE_HOOK() { \
690 /* IRQ epilogue code here.*/ \
691}
692
693/**
694 * @brief Idle thread enter hook.
695 * @note This hook is invoked within a critical zone, no OS functions
696 * should be invoked from here.
697 * @note This macro can be used to activate a power saving mode.
698 */
699#define CH_CFG_IDLE_ENTER_HOOK() { \
700 /* Idle-enter code here.*/ \
701}
702
703/**
704 * @brief Idle thread leave hook.
705 * @note This hook is invoked within a critical zone, no OS functions
706 * should be invoked from here.
707 * @note This macro can be used to deactivate a power saving mode.
708 */
709#define CH_CFG_IDLE_LEAVE_HOOK() { \
710 /* Idle-leave code here.*/ \
711}
712
713/**
714 * @brief Idle Loop hook.
715 * @details This hook is continuously invoked by the idle thread loop.
716 */
717#define CH_CFG_IDLE_LOOP_HOOK() { \
718 /* Idle loop code here.*/ \
719}
720
721/**
722 * @brief System tick event hook.
723 * @details This hook is invoked in the system tick handler immediately
724 * after processing the virtual timers queue.
725 */
726#define CH_CFG_SYSTEM_TICK_HOOK() { \
727 /* System tick event code here.*/ \
728}
729
730/**
731 * @brief System halt hook.
732 * @details This hook is invoked in case to a system halting error before
733 * the system is halted.
734 */
735#define CH_CFG_SYSTEM_HALT_HOOK(reason) { \
736 /* System halt code here.*/ \
737}
738
739/**
740 * @brief Trace hook.
741 * @details This hook is invoked each time a new record is written in the
742 * trace buffer.
743 */
744#define CH_CFG_TRACE_HOOK(tep) { \
745 /* Trace code here.*/ \
746}
747
748
749/** @} */
750
751/*===========================================================================*/
752/* Port-specific settings (override port settings defaulted in chcore.h). */
753/*===========================================================================*/
754
755#endif /* CHCONF_H */
756
757/** @} */
diff --git a/lib/chibios-contrib/testhal/NRF52/NRF52832/I2C/halconf.h b/lib/chibios-contrib/testhal/NRF52/NRF52832/I2C/halconf.h
new file mode 100644
index 000000000..efa566740
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NRF52/NRF52832/I2C/halconf.h
@@ -0,0 +1,533 @@
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 templates/halconf.h
19 * @brief HAL configuration header.
20 * @details HAL configuration file, this file allows to enable or disable the
21 * various device drivers from your application. You may also use
22 * this file in order to override the device drivers default settings.
23 *
24 * @addtogroup HAL_CONF
25 * @{
26 */
27
28#ifndef HALCONF_H
29#define HALCONF_H
30
31#define _CHIBIOS_HAL_CONF_
32#define _CHIBIOS_HAL_CONF_VER_7_1_
33
34#include "mcuconf.h"
35
36/**
37 * @brief Enables the PAL subsystem.
38 */
39#if !defined(HAL_USE_PAL) || defined(__DOXYGEN__)
40#define HAL_USE_PAL TRUE
41#endif
42
43/**
44 * @brief Enables the ADC subsystem.
45 */
46#if !defined(HAL_USE_ADC) || defined(__DOXYGEN__)
47#define HAL_USE_ADC FALSE
48#endif
49
50/**
51 * @brief Enables the CAN subsystem.
52 */
53#if !defined(HAL_USE_CAN) || defined(__DOXYGEN__)
54#define HAL_USE_CAN FALSE
55#endif
56
57/**
58 * @brief Enables the cryptographic subsystem.
59 */
60#if !defined(HAL_USE_CRY) || defined(__DOXYGEN__)
61#define HAL_USE_CRY FALSE
62#endif
63
64/**
65 * @brief Enables the DAC subsystem.
66 */
67#if !defined(HAL_USE_DAC) || defined(__DOXYGEN__)
68#define HAL_USE_DAC FALSE
69#endif
70
71/**
72 * @brief Enables the EFlash subsystem.
73 */
74#if !defined(HAL_USE_EFL) || defined(__DOXYGEN__)
75#define HAL_USE_EFL FALSE
76#endif
77
78/**
79 * @brief Enables the GPT subsystem.
80 */
81#if !defined(HAL_USE_GPT) || defined(__DOXYGEN__)
82#define HAL_USE_GPT FALSE
83#endif
84
85/**
86 * @brief Enables the I2C subsystem.
87 */
88#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__)
89#define HAL_USE_I2C TRUE
90#endif
91
92/**
93 * @brief Enables the I2S subsystem.
94 */
95#if !defined(HAL_USE_I2S) || defined(__DOXYGEN__)
96#define HAL_USE_I2S FALSE
97#endif
98
99/**
100 * @brief Enables the ICU subsystem.
101 */
102#if !defined(HAL_USE_ICU) || defined(__DOXYGEN__)
103#define HAL_USE_ICU FALSE
104#endif
105
106/**
107 * @brief Enables the MAC subsystem.
108 */
109#if !defined(HAL_USE_MAC) || defined(__DOXYGEN__)
110#define HAL_USE_MAC FALSE
111#endif
112
113/**
114 * @brief Enables the MMC_SPI subsystem.
115 */
116#if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__)
117#define HAL_USE_MMC_SPI FALSE
118#endif
119
120/**
121 * @brief Enables the PWM subsystem.
122 */
123#if !defined(HAL_USE_PWM) || defined(__DOXYGEN__)
124#define HAL_USE_PWM FALSE
125#endif
126
127/**
128 * @brief Enables the RTC subsystem.
129 */
130#if !defined(HAL_USE_RTC) || defined(__DOXYGEN__)
131#define HAL_USE_RTC FALSE
132#endif
133
134/**
135 * @brief Enables the SDC subsystem.
136 */
137#if !defined(HAL_USE_SDC) || defined(__DOXYGEN__)
138#define HAL_USE_SDC FALSE
139#endif
140
141/**
142 * @brief Enables the SERIAL subsystem.
143 */
144#if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__)
145#define HAL_USE_SERIAL FALSE
146#endif
147
148/**
149 * @brief Enables the SERIAL over USB subsystem.
150 */
151#if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__)
152#define HAL_USE_SERIAL_USB FALSE
153#endif
154
155/**
156 * @brief Enables the SIO subsystem.
157 */
158#if !defined(HAL_USE_SIO) || defined(__DOXYGEN__)
159#define HAL_USE_SIO FALSE
160#endif
161
162/**
163 * @brief Enables the SPI subsystem.
164 */
165#if !defined(HAL_USE_SPI) || defined(__DOXYGEN__)
166#define HAL_USE_SPI FALSE
167#endif
168
169/**
170 * @brief Enables the TRNG subsystem.
171 */
172#if !defined(HAL_USE_TRNG) || defined(__DOXYGEN__)
173#define HAL_USE_TRNG FALSE
174#endif
175
176/**
177 * @brief Enables the UART subsystem.
178 */
179#if !defined(HAL_USE_UART) || defined(__DOXYGEN__)
180#define HAL_USE_UART FALSE
181#endif
182
183/**
184 * @brief Enables the USB subsystem.
185 */
186#if !defined(HAL_USE_USB) || defined(__DOXYGEN__)
187#define HAL_USE_USB FALSE
188#endif
189
190/**
191 * @brief Enables the WDG subsystem.
192 */
193#if !defined(HAL_USE_WDG) || defined(__DOXYGEN__)
194#define HAL_USE_WDG FALSE
195#endif
196
197/**
198 * @brief Enables the WSPI subsystem.
199 */
200#if !defined(HAL_USE_WSPI) || defined(__DOXYGEN__)
201#define HAL_USE_WSPI FALSE
202#endif
203
204/*===========================================================================*/
205/* PAL driver related settings. */
206/*===========================================================================*/
207
208/**
209 * @brief Enables synchronous APIs.
210 * @note Disabling this option saves both code and data space.
211 */
212#if !defined(PAL_USE_CALLBACKS) || defined(__DOXYGEN__)
213#define PAL_USE_CALLBACKS TRUE
214#endif
215
216/**
217 * @brief Enables synchronous APIs.
218 * @note Disabling this option saves both code and data space.
219 */
220#if !defined(PAL_USE_WAIT) || defined(__DOXYGEN__)
221#define PAL_USE_WAIT TRUE
222#endif
223
224/*===========================================================================*/
225/* ADC driver related settings. */
226/*===========================================================================*/
227
228/**
229 * @brief Enables synchronous APIs.
230 * @note Disabling this option saves both code and data space.
231 */
232#if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__)
233#define ADC_USE_WAIT TRUE
234#endif
235
236/**
237 * @brief Enables the @p adcAcquireBus() and @p adcReleaseBus() APIs.
238 * @note Disabling this option saves both code and data space.
239 */
240#if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
241#define ADC_USE_MUTUAL_EXCLUSION TRUE
242#endif
243
244/*===========================================================================*/
245/* CAN driver related settings. */
246/*===========================================================================*/
247
248/**
249 * @brief Sleep mode related APIs inclusion switch.
250 */
251#if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__)
252#define CAN_USE_SLEEP_MODE TRUE
253#endif
254
255/**
256 * @brief Enforces the driver to use direct callbacks rather than OSAL events.
257 */
258#if !defined(CAN_ENFORCE_USE_CALLBACKS) || defined(__DOXYGEN__)
259#define CAN_ENFORCE_USE_CALLBACKS FALSE
260#endif
261
262/*===========================================================================*/
263/* CRY driver related settings. */
264/*===========================================================================*/
265
266/**
267 * @brief Enables the SW fall-back of the cryptographic driver.
268 * @details When enabled, this option, activates a fall-back software
269 * implementation for algorithms not supported by the underlying
270 * hardware.
271 * @note Fall-back implementations may not be present for all algorithms.
272 */
273#if !defined(HAL_CRY_USE_FALLBACK) || defined(__DOXYGEN__)
274#define HAL_CRY_USE_FALLBACK FALSE
275#endif
276
277/**
278 * @brief Makes the driver forcibly use the fall-back implementations.
279 */
280#if !defined(HAL_CRY_ENFORCE_FALLBACK) || defined(__DOXYGEN__)
281#define HAL_CRY_ENFORCE_FALLBACK FALSE
282#endif
283
284/*===========================================================================*/
285/* DAC driver related settings. */
286/*===========================================================================*/
287
288/**
289 * @brief Enables synchronous APIs.
290 * @note Disabling this option saves both code and data space.
291 */
292#if !defined(DAC_USE_WAIT) || defined(__DOXYGEN__)
293#define DAC_USE_WAIT TRUE
294#endif
295
296/**
297 * @brief Enables the @p dacAcquireBus() and @p dacReleaseBus() APIs.
298 * @note Disabling this option saves both code and data space.
299 */
300#if !defined(DAC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
301#define DAC_USE_MUTUAL_EXCLUSION TRUE
302#endif
303
304/*===========================================================================*/
305/* I2C driver related settings. */
306/*===========================================================================*/
307
308/**
309 * @brief Enables the mutual exclusion APIs on the I2C bus.
310 */
311#if !defined(I2C_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
312#define I2C_USE_MUTUAL_EXCLUSION TRUE
313#endif
314
315/*===========================================================================*/
316/* MAC driver related settings. */
317/*===========================================================================*/
318
319/**
320 * @brief Enables the zero-copy API.
321 */
322#if !defined(MAC_USE_ZERO_COPY) || defined(__DOXYGEN__)
323#define MAC_USE_ZERO_COPY FALSE
324#endif
325
326/**
327 * @brief Enables an event sources for incoming packets.
328 */
329#if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__)
330#define MAC_USE_EVENTS TRUE
331#endif
332
333/*===========================================================================*/
334/* MMC_SPI driver related settings. */
335/*===========================================================================*/
336
337/**
338 * @brief Delays insertions.
339 * @details If enabled this options inserts delays into the MMC waiting
340 * routines releasing some extra CPU time for the threads with
341 * lower priority, this may slow down the driver a bit however.
342 * This option is recommended also if the SPI driver does not
343 * use a DMA channel and heavily loads the CPU.
344 */
345#if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__)
346#define MMC_NICE_WAITING TRUE
347#endif
348
349/*===========================================================================*/
350/* SDC driver related settings. */
351/*===========================================================================*/
352
353/**
354 * @brief Number of initialization attempts before rejecting the card.
355 * @note Attempts are performed at 10mS intervals.
356 */
357#if !defined(SDC_INIT_RETRY) || defined(__DOXYGEN__)
358#define SDC_INIT_RETRY 100
359#endif
360
361/**
362 * @brief Include support for MMC cards.
363 * @note MMC support is not yet implemented so this option must be kept
364 * at @p FALSE.
365 */
366#if !defined(SDC_MMC_SUPPORT) || defined(__DOXYGEN__)
367#define SDC_MMC_SUPPORT FALSE
368#endif
369
370/**
371 * @brief Delays insertions.
372 * @details If enabled this options inserts delays into the MMC waiting
373 * routines releasing some extra CPU time for the threads with
374 * lower priority, this may slow down the driver a bit however.
375 */
376#if !defined(SDC_NICE_WAITING) || defined(__DOXYGEN__)
377#define SDC_NICE_WAITING TRUE
378#endif
379
380/**
381 * @brief OCR initialization constant for V20 cards.
382 */
383#if !defined(SDC_INIT_OCR_V20) || defined(__DOXYGEN__)
384#define SDC_INIT_OCR_V20 0x50FF8000U
385#endif
386
387/**
388 * @brief OCR initialization constant for non-V20 cards.
389 */
390#if !defined(SDC_INIT_OCR) || defined(__DOXYGEN__)
391#define SDC_INIT_OCR 0x80100000U
392#endif
393
394/*===========================================================================*/
395/* SERIAL driver related settings. */
396/*===========================================================================*/
397
398/**
399 * @brief Default bit rate.
400 * @details Configuration parameter, this is the baud rate selected for the
401 * default configuration.
402 */
403#if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__)
404#define SERIAL_DEFAULT_BITRATE 38400
405#endif
406
407/**
408 * @brief Serial buffers size.
409 * @details Configuration parameter, you can change the depth of the queue
410 * buffers depending on the requirements of your application.
411 * @note The default is 16 bytes for both the transmission and receive
412 * buffers.
413 */
414#if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__)
415#define SERIAL_BUFFERS_SIZE 16
416#endif
417
418/*===========================================================================*/
419/* SERIAL_USB driver related setting. */
420/*===========================================================================*/
421
422/**
423 * @brief Serial over USB buffers size.
424 * @details Configuration parameter, the buffer size must be a multiple of
425 * the USB data endpoint maximum packet size.
426 * @note The default is 256 bytes for both the transmission and receive
427 * buffers.
428 */
429#if !defined(SERIAL_USB_BUFFERS_SIZE) || defined(__DOXYGEN__)
430#define SERIAL_USB_BUFFERS_SIZE 256
431#endif
432
433/**
434 * @brief Serial over USB number of buffers.
435 * @note The default is 2 buffers.
436 */
437#if !defined(SERIAL_USB_BUFFERS_NUMBER) || defined(__DOXYGEN__)
438#define SERIAL_USB_BUFFERS_NUMBER 2
439#endif
440
441/*===========================================================================*/
442/* SPI driver related settings. */
443/*===========================================================================*/
444
445/**
446 * @brief Enables synchronous APIs.
447 * @note Disabling this option saves both code and data space.
448 */
449#if !defined(SPI_USE_WAIT) || defined(__DOXYGEN__)
450#define SPI_USE_WAIT TRUE
451#endif
452
453/**
454 * @brief Enables circular transfers APIs.
455 * @note Disabling this option saves both code and data space.
456 */
457#if !defined(SPI_USE_CIRCULAR) || defined(__DOXYGEN__)
458#define SPI_USE_CIRCULAR FALSE
459#endif
460
461/**
462 * @brief Enables the @p spiAcquireBus() and @p spiReleaseBus() APIs.
463 * @note Disabling this option saves both code and data space.
464 */
465#if !defined(SPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
466#define SPI_USE_MUTUAL_EXCLUSION TRUE
467#endif
468
469/**
470 * @brief Handling method for SPI CS line.
471 * @note Disabling this option saves both code and data space.
472 */
473#if !defined(SPI_SELECT_MODE) || defined(__DOXYGEN__)
474#define SPI_SELECT_MODE SPI_SELECT_MODE_PAD
475#endif
476
477/*===========================================================================*/
478/* UART driver related settings. */
479/*===========================================================================*/
480
481/**
482 * @brief Enables synchronous APIs.
483 * @note Disabling this option saves both code and data space.
484 */
485#if !defined(UART_USE_WAIT) || defined(__DOXYGEN__)
486#define UART_USE_WAIT FALSE
487#endif
488
489/**
490 * @brief Enables the @p uartAcquireBus() and @p uartReleaseBus() APIs.
491 * @note Disabling this option saves both code and data space.
492 */
493#if !defined(UART_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
494#define UART_USE_MUTUAL_EXCLUSION FALSE
495#endif
496
497/*===========================================================================*/
498/* USB driver related settings. */
499/*===========================================================================*/
500
501/**
502 * @brief Enables synchronous APIs.
503 * @note Disabling this option saves both code and data space.
504 */
505#if !defined(USB_USE_WAIT) || defined(__DOXYGEN__)
506#define USB_USE_WAIT FALSE
507#endif
508
509/*===========================================================================*/
510/* WSPI driver related settings. */
511/*===========================================================================*/
512
513/**
514 * @brief Enables synchronous APIs.
515 * @note Disabling this option saves both code and data space.
516 */
517#if !defined(WSPI_USE_WAIT) || defined(__DOXYGEN__)
518#define WSPI_USE_WAIT TRUE
519#endif
520
521/**
522 * @brief Enables the @p wspiAcquireBus() and @p wspiReleaseBus() APIs.
523 * @note Disabling this option saves both code and data space.
524 */
525#if !defined(WSPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
526#define WSPI_USE_MUTUAL_EXCLUSION TRUE
527#endif
528
529#include "halconf_community.h"
530
531#endif /* HALCONF_H */
532
533/** @} */
diff --git a/lib/chibios-contrib/testhal/NRF52/NRF52832/I2C/halconf_community.h b/lib/chibios-contrib/testhal/NRF52/NRF52832/I2C/halconf_community.h
new file mode 100644
index 000000000..43fdbf869
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NRF52/NRF52832/I2C/halconf_community.h
@@ -0,0 +1,173 @@
1/*
2 ChibiOS - Copyright (C) 2014 Uladzimir Pylinsky aka barthess
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#ifndef HALCONF_COMMUNITY_H
18#define HALCONF_COMMUNITY_H
19
20/**
21 * @brief Enables the community overlay.
22 */
23#if !defined(HAL_USE_COMMUNITY) || defined(__DOXYGEN__)
24#define HAL_USE_COMMUNITY TRUE
25#endif
26
27/**
28 * @brief Enables the FSMC subsystem.
29 */
30#if !defined(HAL_USE_FSMC) || defined(__DOXYGEN__)
31#define HAL_USE_FSMC FALSE
32#endif
33
34/**
35 * @brief Enables the NAND subsystem.
36 */
37#if !defined(HAL_USE_NAND) || defined(__DOXYGEN__)
38#define HAL_USE_NAND FALSE
39#endif
40
41/**
42 * @brief Enables the 1-wire subsystem.
43 */
44#if !defined(HAL_USE_ONEWIRE) || defined(__DOXYGEN__)
45#define HAL_USE_ONEWIRE FALSE
46#endif
47
48/**
49 * @brief Enables the EICU subsystem.
50 */
51#if !defined(HAL_USE_EICU) || defined(__DOXYGEN__)
52#define HAL_USE_EICU FALSE
53#endif
54
55/**
56 * @brief Enables the CRC subsystem.
57 */
58#if !defined(HAL_USE_CRC) || defined(__DOXYGEN__)
59#define HAL_USE_CRC FALSE
60#endif
61
62/**
63 * @brief Enables the RNG subsystem.
64 */
65#if !defined(HAL_USE_RNG) || defined(__DOXYGEN__)
66#define HAL_USE_RNG FALSE
67#endif
68
69/**
70 * @brief Enables the EEPROM subsystem.
71 */
72#if !defined(HAL_USE_EEPROM) || defined(__DOXYGEN__)
73#define HAL_USE_EEPROM FALSE
74#endif
75
76/**
77 * @brief Enables the TIMCAP subsystem.
78 */
79#if !defined(HAL_USE_TIMCAP) || defined(__DOXYGEN__)
80#define HAL_USE_TIMCAP FALSE
81#endif
82
83/**
84 * @brief Enables the TIMCAP subsystem.
85 */
86#if !defined(HAL_USE_COMP) || defined(__DOXYGEN__)
87#define HAL_USE_COMP FALSE
88#endif
89
90/**
91 * @brief Enables the QEI subsystem.
92 */
93#if !defined(HAL_USE_QEI) || defined(__DOXYGEN__)
94#define HAL_USE_QEI FALSE
95#endif
96
97/**
98 * @brief Enables the USBH subsystem.
99 */
100#if !defined(HAL_USE_USBH) || defined(__DOXYGEN__)
101#define HAL_USE_USBH FALSE
102#endif
103
104/**
105 * @brief Enables the USB_MSD subsystem.
106 */
107#if !defined(HAL_USE_USB_MSD) || defined(__DOXYGEN__)
108#define HAL_USE_USB_MSD FALSE
109#endif
110
111/*===========================================================================*/
112/* FSMCNAND driver related settings. */
113/*===========================================================================*/
114
115/**
116 * @brief Enables the @p nandAcquireBus() and @p nanReleaseBus() APIs.
117 * @note Disabling this option saves both code and data space.
118 */
119#if !defined(NAND_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
120#define NAND_USE_MUTUAL_EXCLUSION TRUE
121#endif
122
123/*===========================================================================*/
124/* 1-wire driver related settings. */
125/*===========================================================================*/
126/**
127 * @brief Enables strong pull up feature.
128 * @note Disabling this option saves both code and data space.
129 */
130#define ONEWIRE_USE_STRONG_PULLUP FALSE
131
132/**
133 * @brief Enables search ROM feature.
134 * @note Disabling this option saves both code and data space.
135 */
136#define ONEWIRE_USE_SEARCH_ROM TRUE
137
138/*===========================================================================*/
139/* QEI driver related settings. */
140/*===========================================================================*/
141
142/**
143 * @brief Enables discard of overlow
144 */
145#if !defined(QEI_USE_OVERFLOW_DISCARD) || defined(__DOXYGEN__)
146#define QEI_USE_OVERFLOW_DISCARD FALSE
147#endif
148
149/**
150 * @brief Enables min max of overlow
151 */
152#if !defined(QEI_USE_OVERFLOW_MINMAX) || defined(__DOXYGEN__)
153#define QEI_USE_OVERFLOW_MINMAX FALSE
154#endif
155
156/*===========================================================================*/
157/* EEProm driver related settings. */
158/*===========================================================================*/
159
160/**
161 * @brief Enables 24xx series I2C eeprom device driver.
162 * @note Disabling this option saves both code and data space.
163 */
164#define EEPROM_USE_EE24XX FALSE
165 /**
166 * @brief Enables 25xx series SPI eeprom device driver.
167 * @note Disabling this option saves both code and data space.
168 */
169#define EEPROM_USE_EE25XX FALSE
170
171#endif /* HALCONF_COMMUNITY_H */
172
173/** @} */
diff --git a/lib/chibios-contrib/testhal/NRF52/NRF52832/I2C/main.c b/lib/chibios-contrib/testhal/NRF52/NRF52832/I2C/main.c
new file mode 100644
index 000000000..15fa5e7b0
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NRF52/NRF52832/I2C/main.c
@@ -0,0 +1,165 @@
1/*
2 Copyright (C) 2015 Stephen Caudle
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 This demo:
19 1) Writes bytes to the EEPROM
20 2) Reads the same bytes back
21 3) Inverts the byte values
22 4) Writes them
23 5) Reads them back
24 */
25
26#include <stdlib.h>
27
28#include "ch.h"
29#include "hal.h"
30
31#define I2C_ADDR 0x50
32#define I2C_FAKE_ADDR 0x4C
33#define EEPROM_START_ADDR 0x00
34
35/*
36 * EEPROM thread.
37 */
38static THD_WORKING_AREA(PollEepromThreadWA, 1024);
39static THD_FUNCTION(PollEepromThread, arg) {
40
41 unsigned i;
42 uint8_t tx_data[6];
43 uint8_t rx_data[4];
44 msg_t status;
45
46 (void)arg;
47
48 chRegSetThreadName("PollEeprom");
49
50 /* set initial data to write */
51 tx_data[0] = EEPROM_START_ADDR;
52 tx_data[1] = EEPROM_START_ADDR;
53 tx_data[2] = 0xA0;
54 tx_data[3] = 0xA1;
55 tx_data[4] = 0xA2;
56 tx_data[5] = 0xA3;
57
58 while (true) {
59
60 /* write out initial data */
61 i2cAcquireBus(&I2CD1);
62 status = i2cMasterTransmitTimeout(&I2CD1, I2C_ADDR, tx_data, sizeof(tx_data), NULL, 0, TIME_INFINITE);
63 i2cReleaseBus(&I2CD1);
64 osalDbgCheck(MSG_OK == status);
65
66 /* read back inital data */
67 osalThreadSleepMilliseconds(2);
68 i2cAcquireBus(&I2CD1);
69 status = i2cMasterTransmitTimeout(&I2CD1, I2C_ADDR, tx_data, 2, rx_data, sizeof(rx_data), TIME_INFINITE);
70 i2cReleaseBus(&I2CD1);
71 osalDbgCheck(MSG_OK == status);
72
73 /* invert the data */
74 for (i = 2; i < sizeof(tx_data); i++)
75 tx_data[i] ^= 0xff;
76
77 /* write out inverted data */
78 osalThreadSleepMilliseconds(2);
79 i2cAcquireBus(&I2CD1);
80 status = i2cMasterTransmitTimeout(&I2CD1, I2C_ADDR, tx_data, sizeof(tx_data), NULL, 0, TIME_INFINITE);
81 i2cReleaseBus(&I2CD1);
82 osalDbgCheck(MSG_OK == status);
83
84 /* read back inverted data */
85 osalThreadSleepMilliseconds(2);
86 i2cAcquireBus(&I2CD1);
87 status = i2cMasterTransmitTimeout(&I2CD1, I2C_ADDR, tx_data, 2, rx_data, sizeof(rx_data), TIME_INFINITE);
88 i2cReleaseBus(&I2CD1);
89 osalDbgCheck(MSG_OK == status);
90
91 osalThreadSleepMilliseconds(TIME_INFINITE);
92 }
93}
94
95/*
96 * Fake polling thread.
97 */
98static THD_WORKING_AREA(PollFakeThreadWA, 256);
99static THD_FUNCTION(PollFakeThread, arg) {
100
101 (void)arg;
102
103 chRegSetThreadName("PollFake");
104 while (true) {
105
106 msg_t status;
107 uint8_t rx_data[2];
108 i2cflags_t errors;
109
110 i2cAcquireBus(&I2CD1);
111 status = i2cMasterReceiveTimeout(&I2CD1, I2C_FAKE_ADDR, rx_data, 2, TIME_MS2I(4));
112 i2cReleaseBus(&I2CD1);
113
114 if (status == MSG_RESET){
115 errors = i2cGetErrors(&I2CD1);
116 osalDbgCheck(I2C_ACK_FAILURE == errors);
117 }
118
119 palTogglePad(IOPORT1, LED1); /* on */
120 osalThreadSleepMilliseconds(1000);
121 }
122}
123
124/*
125 * I2C1 config.
126 */
127static const I2CConfig i2cfg = {
128 100000,
129 I2C_SCL,
130 I2C_SDA,
131};
132
133/*
134 * Entry point, note, the main() function is already a thread in the system
135 * on entry.
136 */
137int main(void) {
138
139 halInit();
140 chSysInit();
141
142 i2cStart(&I2CD1, &i2cfg);
143
144 /* Create EEPROM thread. */
145 chThdCreateStatic(PollEepromThreadWA,
146 sizeof(PollEepromThreadWA),
147 NORMALPRIO,
148 PollEepromThread,
149 NULL);
150
151 /* Create not responding thread. */
152 chThdCreateStatic(PollFakeThreadWA,
153 sizeof(PollFakeThreadWA),
154 NORMALPRIO,
155 PollFakeThread,
156 NULL);
157
158 /* main loop handles LED */
159 while (true) {
160 palTogglePad(IOPORT1, LED2); /* on */
161 osalThreadSleepMilliseconds(500);
162 }
163
164 return 0;
165}
diff --git a/lib/chibios-contrib/testhal/NRF52/NRF52832/I2C/mcuconf.h b/lib/chibios-contrib/testhal/NRF52/NRF52832/I2C/mcuconf.h
new file mode 100644
index 000000000..4c9c0ab0a
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NRF52/NRF52832/I2C/mcuconf.h
@@ -0,0 +1,25 @@
1/*
2 Copyright (C) 2015 Stephen Caudle
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#ifndef _MCUCONF_H_
18#define _MCUCONF_H_
19
20/*
21 * HAL driver system settings.
22 */
23#define NRF5_I2C_USE_I2C0 TRUE
24
25#endif /* _MCUCONF_H_ */
diff --git a/lib/chibios-contrib/testhal/NRF52/NRF52832/I2C/readme.txt b/lib/chibios-contrib/testhal/NRF52/NRF52832/I2C/readme.txt
new file mode 100644
index 000000000..7298be5d3
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NRF52/NRF52832/I2C/readme.txt
@@ -0,0 +1,21 @@
1*****************************************************************************
2** ChibiOS/HAL - I2C driver demo for NRF52832. **
3*****************************************************************************
4
5** TARGET **
6
7The demo runs on an EByte E73-2G4M04S board.
8
9** The Demo **
10
11The application demonstrates the use of the NRF52832 I2C driver.
12
13** Board Setup **
14
15- Connect AT24CXX EEPROM board to I2C port on E73-2G4M04S board
16
17** Build Procedure **
18
19The demo has been tested using the free Codesourcery GCC-based toolchain
20and YAGARTO.
21Just modify the TRGT line in the makefile in order to use different GCC ports.
diff --git a/lib/chibios-contrib/testhal/NRF52/NRF52832/PWM-ICU/Makefile b/lib/chibios-contrib/testhal/NRF52/NRF52832/PWM-ICU/Makefile
new file mode 100644
index 000000000..e7c6ba3ed
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NRF52/NRF52832/PWM-ICU/Makefile
@@ -0,0 +1,228 @@
1##############################################################################
2# Build global options
3# NOTE: Can be overridden externally.
4#
5
6# Compiler options here.
7ifeq ($(USE_OPT),)
8 USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16
9endif
10
11# C specific options here (added to USE_OPT).
12ifeq ($(USE_COPT),)
13 USE_COPT =
14endif
15
16# C++ specific options here (added to USE_OPT).
17ifeq ($(USE_CPPOPT),)
18 USE_CPPOPT = -fno-rtti
19endif
20
21# Enable this if you want the linker to remove unused code and data
22ifeq ($(USE_LINK_GC),)
23 USE_LINK_GC = yes
24endif
25
26# Linker extra options here.
27ifeq ($(USE_LDOPT),)
28 USE_LDOPT =
29endif
30
31# Enable this if you want link time optimizations (LTO)
32ifeq ($(USE_LTO),)
33 USE_LTO = yes
34endif
35
36# If enabled, this option allows to compile the application in THUMB mode.
37ifeq ($(USE_THUMB),)
38 USE_THUMB = yes
39endif
40
41# Enable this if you want to see the full log while compiling.
42ifeq ($(USE_VERBOSE_COMPILE),)
43 USE_VERBOSE_COMPILE = no
44endif
45
46# If enabled, this option makes the build process faster by not compiling
47# modules not used in the current configuration.
48ifeq ($(USE_SMART_BUILD),)
49 USE_SMART_BUILD = yes
50endif
51
52#
53# Build global options
54##############################################################################
55
56##############################################################################
57# Architecture or project specific options
58#
59
60# Stack size to be allocated to the Cortex-M process stack. This stack is
61# the stack used by the main() thread.
62ifeq ($(USE_PROCESS_STACKSIZE),)
63 USE_PROCESS_STACKSIZE = 0x400
64endif
65
66# Stack size to the allocated to the Cortex-M main/exceptions stack. This
67# stack is used for processing interrupts and exceptions.
68ifeq ($(USE_EXCEPTIONS_STACKSIZE),)
69 USE_EXCEPTIONS_STACKSIZE = 0x400
70endif
71
72# Enables the use of FPU on Cortex-M4 (no, softfp, hard).
73ifeq ($(USE_FPU),)
74 USE_FPU = no
75endif
76
77#
78# Architecture or project specific options
79##############################################################################
80
81##############################################################################
82# Project, sources and paths
83#
84
85# Define project name here
86PROJECT = ch
87
88# Imported source files and paths
89CHIBIOS = ../../../../../ChibiOS
90CHIBIOS_CONTRIB = $(CHIBIOS)/../ChibiOS-Contrib
91
92# Startup files.
93include $(CHIBIOS_CONTRIB)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_nrf52.mk
94# Licensing files.
95include $(CHIBIOS)/os/license/license.mk
96# HAL-OSAL files (optional).
97include $(CHIBIOS_CONTRIB)/os/hal/hal.mk
98include $(CHIBIOS_CONTRIB)/os/hal/ports/NRF5/NRF52832/platform.mk
99include $(CHIBIOS_CONTRIB)/os/hal/boards/NRF52-E73-2G4M04S/board.mk
100include $(CHIBIOS)/os/hal/osal/rt-nil/osal.mk
101# RTOS files (optional).
102include $(CHIBIOS)/os/rt/rt.mk
103include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk
104# Other files (optional).
105#include $(CHIBIOS)/test/rt/test.mk
106
107# Define linker script file here
108LDSCRIPT= $(STARTUPLD_CONTRIB)/NRF52832.ld
109
110# C sources that can be compiled in ARM or THUMB mode depending on the global
111# setting.
112CSRC = $(ALLCSRC) \
113 $(TESTSRC) \
114 $(CHIBIOS)/os/hal/lib/streams/memstreams.c \
115 $(CHIBIOS)/os/hal/lib/streams/chprintf.c \
116 main.c
117
118# C++ sources that can be compiled in ARM or THUMB mode depending on the global
119# setting.
120CPPSRC = $(ALLCPPSRC)
121
122# C sources to be compiled in ARM mode regardless of the global setting.
123# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
124# option that results in lower performance and larger code size.
125ACSRC =
126
127# C++ sources to be compiled in ARM mode regardless of the global setting.
128# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
129# option that results in lower performance and larger code size.
130ACPPSRC =
131
132# C sources to be compiled in THUMB mode regardless of the global setting.
133# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
134# option that results in lower performance and larger code size.
135TCSRC =
136
137# C sources to be compiled in THUMB mode regardless of the global setting.
138# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
139# option that results in lower performance and larger code size.
140TCPPSRC =
141
142# List ASM source files here
143ASMSRC = $(ALLASMSRC)
144ASMXSRC = $(ALLXASMSRC)
145
146INCDIR = $(ALLINC) $(TESTINC) \
147 $(CHIBIOS)/os/hal/lib/streams \
148 $(TESTHAL)
149
150#
151# Project, sources and paths
152##############################################################################
153
154##############################################################################
155# Compiler settings
156#
157
158MCU = cortex-m4
159
160TRGT = arm-none-eabi-
161CC = $(TRGT)gcc
162CPPC = $(TRGT)g++
163# Enable loading with g++ only if you need C++ runtime support.
164# NOTE: You can use C++ even without C++ support if you are careful. C++
165# runtime support makes code size explode.
166LD = $(TRGT)gcc
167#LD = $(TRGT)g++
168CP = $(TRGT)objcopy
169AS = $(TRGT)gcc -x assembler-with-cpp
170AR = $(TRGT)ar
171OD = $(TRGT)objdump
172SZ = $(TRGT)size
173HEX = $(CP) -O ihex
174BIN = $(CP) -O binary
175SREC = $(CP) -O srec
176
177# ARM-specific options here
178AOPT =
179
180# THUMB-specific options here
181TOPT = -mthumb -DTHUMB
182
183# Define C warning options here
184CWARN = -Wall -Wextra -Wstrict-prototypes
185
186# Define C++ warning options here
187CPPWARN = -Wall -Wextra
188
189#
190# Compiler settings
191##############################################################################
192
193##############################################################################
194# Start of user section
195#
196
197# List all user C define here, like -D_DEBUG=1
198UDEFS =
199
200# Define ASM defines here
201UADEFS =
202
203# List all user directories here
204UINCDIR =
205
206# List the user directory to look for the libraries here
207ULIBDIR =
208
209# List all user libraries here
210ULIBS =
211
212#
213# End of user defines
214##############################################################################
215
216RULESPATH = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk
217include $(RULESPATH)/rules.mk
218
219
220include $(CHIBIOS_CONTRIB)/os/various/jlink.mk
221
222
223JLINK_DEVICE = nrf51422
224JLINK_PRE_FLASH = w4 4001e504 1
225JLINK_ERASE_ALL = w4 4001e504 2\nw4 4001e50c 1\nsleep 100
226
227flash: all jlink-flash
228
diff --git a/lib/chibios-contrib/testhal/NRF52/NRF52832/PWM-ICU/chconf.h b/lib/chibios-contrib/testhal/NRF52/NRF52832/PWM-ICU/chconf.h
new file mode 100644
index 000000000..6687603e0
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NRF52/NRF52832/PWM-ICU/chconf.h
@@ -0,0 +1,757 @@
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 rt/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 config
24 * @details Kernel related settings and hooks.
25 * @{
26 */
27
28#ifndef CHCONF_H
29#define CHCONF_H
30
31#define _CHIBIOS_RT_CONF_
32#define _CHIBIOS_RT_CONF_VER_6_1_
33
34/*===========================================================================*/
35/**
36 * @name System timers settings
37 * @{
38 */
39/*===========================================================================*/
40
41/**
42 * @brief System time counter resolution.
43 * @note Allowed values are 16 or 32 bits.
44 */
45#if !defined(CH_CFG_ST_RESOLUTION)
46#define CH_CFG_ST_RESOLUTION 32
47#endif
48
49/**
50 * @brief System tick frequency.
51 * @details Frequency of the system timer that drives the system ticks. This
52 * setting also defines the system tick time unit.
53 */
54#if !defined(CH_CFG_ST_FREQUENCY)
55#define CH_CFG_ST_FREQUENCY 1000
56#endif
57
58/**
59 * @brief Time intervals data size.
60 * @note Allowed values are 16, 32 or 64 bits.
61 */
62#if !defined(CH_CFG_INTERVALS_SIZE)
63#define CH_CFG_INTERVALS_SIZE 32
64#endif
65
66/**
67 * @brief Time types data size.
68 * @note Allowed values are 16 or 32 bits.
69 */
70#if !defined(CH_CFG_TIME_TYPES_SIZE)
71#define CH_CFG_TIME_TYPES_SIZE 32
72#endif
73
74/**
75 * @brief Time delta constant for the tick-less mode.
76 * @note If this value is zero then the system uses the classic
77 * periodic tick. This value represents the minimum number
78 * of ticks that is safe to specify in a timeout directive.
79 * The value one is not valid, timeouts are rounded up to
80 * this value.
81 */
82#if !defined(CH_CFG_ST_TIMEDELTA)
83#define CH_CFG_ST_TIMEDELTA 0
84#endif
85
86/** @} */
87
88/*===========================================================================*/
89/**
90 * @name Kernel parameters and options
91 * @{
92 */
93/*===========================================================================*/
94
95/**
96 * @brief Round robin interval.
97 * @details This constant is the number of system ticks allowed for the
98 * threads before preemption occurs. Setting this value to zero
99 * disables the preemption for threads with equal priority and the
100 * round robin becomes cooperative. Note that higher priority
101 * threads can still preempt, the kernel is always preemptive.
102 * @note Disabling the round robin preemption makes the kernel more compact
103 * and generally faster.
104 * @note The round robin preemption is not supported in tickless mode and
105 * must be set to zero in that case.
106 */
107#if !defined(CH_CFG_TIME_QUANTUM)
108#define CH_CFG_TIME_QUANTUM 0
109#endif
110
111/**
112 * @brief Idle thread automatic spawn suppression.
113 * @details When this option is activated the function @p chSysInit()
114 * does not spawn the idle thread. The application @p main()
115 * function becomes the idle thread and must implement an
116 * infinite loop.
117 */
118#if !defined(CH_CFG_NO_IDLE_THREAD)
119#define CH_CFG_NO_IDLE_THREAD FALSE
120#endif
121
122/** @} */
123
124/*===========================================================================*/
125/**
126 * @name Performance options
127 * @{
128 */
129/*===========================================================================*/
130
131/**
132 * @brief OS optimization.
133 * @details If enabled then time efficient rather than space efficient code
134 * is used when two possible implementations exist.
135 *
136 * @note This is not related to the compiler optimization options.
137 * @note The default is @p TRUE.
138 */
139#if !defined(CH_CFG_OPTIMIZE_SPEED)
140#define CH_CFG_OPTIMIZE_SPEED TRUE
141#endif
142
143/** @} */
144
145/*===========================================================================*/
146/**
147 * @name Subsystem options
148 * @{
149 */
150/*===========================================================================*/
151
152/**
153 * @brief Time Measurement APIs.
154 * @details If enabled then the time measurement APIs are included in
155 * the kernel.
156 *
157 * @note The default is @p TRUE.
158 */
159#if !defined(CH_CFG_USE_TM)
160#define CH_CFG_USE_TM TRUE
161#endif
162
163/**
164 * @brief Threads registry APIs.
165 * @details If enabled then the registry APIs are included in the kernel.
166 *
167 * @note The default is @p TRUE.
168 */
169#if !defined(CH_CFG_USE_REGISTRY)
170#define CH_CFG_USE_REGISTRY TRUE
171#endif
172
173/**
174 * @brief Threads synchronization APIs.
175 * @details If enabled then the @p chThdWait() function is included in
176 * the kernel.
177 *
178 * @note The default is @p TRUE.
179 */
180#if !defined(CH_CFG_USE_WAITEXIT)
181#define CH_CFG_USE_WAITEXIT TRUE
182#endif
183
184/**
185 * @brief Semaphores APIs.
186 * @details If enabled then the Semaphores APIs are included in the kernel.
187 *
188 * @note The default is @p TRUE.
189 */
190#if !defined(CH_CFG_USE_SEMAPHORES)
191#define CH_CFG_USE_SEMAPHORES TRUE
192#endif
193
194/**
195 * @brief Semaphores queuing mode.
196 * @details If enabled then the threads are enqueued on semaphores by
197 * priority rather than in FIFO order.
198 *
199 * @note The default is @p FALSE. Enable this if you have special
200 * requirements.
201 * @note Requires @p CH_CFG_USE_SEMAPHORES.
202 */
203#if !defined(CH_CFG_USE_SEMAPHORES_PRIORITY)
204#define CH_CFG_USE_SEMAPHORES_PRIORITY FALSE
205#endif
206
207/**
208 * @brief Mutexes APIs.
209 * @details If enabled then the mutexes APIs are included in the kernel.
210 *
211 * @note The default is @p TRUE.
212 */
213#if !defined(CH_CFG_USE_MUTEXES)
214#define CH_CFG_USE_MUTEXES TRUE
215#endif
216
217/**
218 * @brief Enables recursive behavior on mutexes.
219 * @note Recursive mutexes are heavier and have an increased
220 * memory footprint.
221 *
222 * @note The default is @p FALSE.
223 * @note Requires @p CH_CFG_USE_MUTEXES.
224 */
225#if !defined(CH_CFG_USE_MUTEXES_RECURSIVE)
226#define CH_CFG_USE_MUTEXES_RECURSIVE FALSE
227#endif
228
229/**
230 * @brief Conditional Variables APIs.
231 * @details If enabled then the conditional variables APIs are included
232 * in the kernel.
233 *
234 * @note The default is @p TRUE.
235 * @note Requires @p CH_CFG_USE_MUTEXES.
236 */
237#if !defined(CH_CFG_USE_CONDVARS)
238#define CH_CFG_USE_CONDVARS TRUE
239#endif
240
241/**
242 * @brief Conditional Variables APIs with timeout.
243 * @details If enabled then the conditional variables APIs with timeout
244 * specification are included in the kernel.
245 *
246 * @note The default is @p TRUE.
247 * @note Requires @p CH_CFG_USE_CONDVARS.
248 */
249#if !defined(CH_CFG_USE_CONDVARS_TIMEOUT)
250#define CH_CFG_USE_CONDVARS_TIMEOUT TRUE
251#endif
252
253/**
254 * @brief Events Flags APIs.
255 * @details If enabled then the event flags APIs are included in the kernel.
256 *
257 * @note The default is @p TRUE.
258 */
259#if !defined(CH_CFG_USE_EVENTS)
260#define CH_CFG_USE_EVENTS TRUE
261#endif
262
263/**
264 * @brief Events Flags APIs with timeout.
265 * @details If enabled then the events APIs with timeout specification
266 * are included in the kernel.
267 *
268 * @note The default is @p TRUE.
269 * @note Requires @p CH_CFG_USE_EVENTS.
270 */
271#if !defined(CH_CFG_USE_EVENTS_TIMEOUT)
272#define CH_CFG_USE_EVENTS_TIMEOUT TRUE
273#endif
274
275/**
276 * @brief Synchronous Messages APIs.
277 * @details If enabled then the synchronous messages APIs are included
278 * in the kernel.
279 *
280 * @note The default is @p TRUE.
281 */
282#if !defined(CH_CFG_USE_MESSAGES)
283#define CH_CFG_USE_MESSAGES TRUE
284#endif
285
286/**
287 * @brief Synchronous Messages queuing mode.
288 * @details If enabled then messages are served by priority rather than in
289 * FIFO order.
290 *
291 * @note The default is @p FALSE. Enable this if you have special
292 * requirements.
293 * @note Requires @p CH_CFG_USE_MESSAGES.
294 */
295#if !defined(CH_CFG_USE_MESSAGES_PRIORITY)
296#define CH_CFG_USE_MESSAGES_PRIORITY FALSE
297#endif
298
299/**
300 * @brief Dynamic Threads APIs.
301 * @details If enabled then the dynamic threads creation APIs are included
302 * in the kernel.
303 *
304 * @note The default is @p TRUE.
305 * @note Requires @p CH_CFG_USE_WAITEXIT.
306 * @note Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS.
307 */
308#if !defined(CH_CFG_USE_DYNAMIC)
309#define CH_CFG_USE_DYNAMIC TRUE
310#endif
311
312/** @} */
313
314/*===========================================================================*/
315/**
316 * @name OSLIB options
317 * @{
318 */
319/*===========================================================================*/
320
321/**
322 * @brief Mailboxes APIs.
323 * @details If enabled then the asynchronous messages (mailboxes) APIs are
324 * included in the kernel.
325 *
326 * @note The default is @p TRUE.
327 * @note Requires @p CH_CFG_USE_SEMAPHORES.
328 */
329#if !defined(CH_CFG_USE_MAILBOXES)
330#define CH_CFG_USE_MAILBOXES TRUE
331#endif
332
333/**
334 * @brief Core Memory Manager APIs.
335 * @details If enabled then the core memory manager APIs are included
336 * in the kernel.
337 *
338 * @note The default is @p TRUE.
339 */
340#if !defined(CH_CFG_USE_MEMCORE)
341#define CH_CFG_USE_MEMCORE TRUE
342#endif
343
344/**
345 * @brief Managed RAM size.
346 * @details Size of the RAM area to be managed by the OS. If set to zero
347 * then the whole available RAM is used. The core memory is made
348 * available to the heap allocator and/or can be used directly through
349 * the simplified core memory allocator.
350 *
351 * @note In order to let the OS manage the whole RAM the linker script must
352 * provide the @p __heap_base__ and @p __heap_end__ symbols.
353 * @note Requires @p CH_CFG_USE_MEMCORE.
354 */
355#if !defined(CH_CFG_MEMCORE_SIZE)
356#define CH_CFG_MEMCORE_SIZE 0
357#endif
358
359/**
360 * @brief Heap Allocator APIs.
361 * @details If enabled then the memory heap allocator APIs are included
362 * in the kernel.
363 *
364 * @note The default is @p TRUE.
365 * @note Requires @p CH_CFG_USE_MEMCORE and either @p CH_CFG_USE_MUTEXES or
366 * @p CH_CFG_USE_SEMAPHORES.
367 * @note Mutexes are recommended.
368 */
369#if !defined(CH_CFG_USE_HEAP)
370#define CH_CFG_USE_HEAP TRUE
371#endif
372
373/**
374 * @brief Memory Pools Allocator APIs.
375 * @details If enabled then the memory pools allocator APIs are included
376 * in the kernel.
377 *
378 * @note The default is @p TRUE.
379 */
380#if !defined(CH_CFG_USE_MEMPOOLS)
381#define CH_CFG_USE_MEMPOOLS TRUE
382#endif
383
384/**
385 * @brief Objects FIFOs APIs.
386 * @details If enabled then the objects FIFOs APIs are included
387 * in the kernel.
388 *
389 * @note The default is @p TRUE.
390 */
391#if !defined(CH_CFG_USE_OBJ_FIFOS)
392#define CH_CFG_USE_OBJ_FIFOS TRUE
393#endif
394
395/**
396 * @brief Pipes APIs.
397 * @details If enabled then the pipes APIs are included
398 * in the kernel.
399 *
400 * @note The default is @p TRUE.
401 */
402#if !defined(CH_CFG_USE_PIPES)
403#define CH_CFG_USE_PIPES TRUE
404#endif
405
406/**
407 * @brief Objects Caches APIs.
408 * @details If enabled then the objects caches APIs are included
409 * in the kernel.
410 *
411 * @note The default is @p TRUE.
412 */
413#if !defined(CH_CFG_USE_OBJ_CACHES)
414#define CH_CFG_USE_OBJ_CACHES TRUE
415#endif
416
417/**
418 * @brief Delegate threads APIs.
419 * @details If enabled then the delegate threads APIs are included
420 * in the kernel.
421 *
422 * @note The default is @p TRUE.
423 */
424#if !defined(CH_CFG_USE_DELEGATES)
425#define CH_CFG_USE_DELEGATES TRUE
426#endif
427
428/**
429 * @brief Jobs Queues APIs.
430 * @details If enabled then the jobs queues APIs are included
431 * in the kernel.
432 *
433 * @note The default is @p TRUE.
434 */
435#if !defined(CH_CFG_USE_JOBS)
436#define CH_CFG_USE_JOBS TRUE
437#endif
438
439/** @} */
440
441/*===========================================================================*/
442/**
443 * @name Objects factory options
444 * @{
445 */
446/*===========================================================================*/
447
448/**
449 * @brief Objects Factory APIs.
450 * @details If enabled then the objects factory APIs are included in the
451 * kernel.
452 *
453 * @note The default is @p FALSE.
454 */
455#if !defined(CH_CFG_USE_FACTORY)
456#define CH_CFG_USE_FACTORY TRUE
457#endif
458
459/**
460 * @brief Maximum length for object names.
461 * @details If the specified length is zero then the name is stored by
462 * pointer but this could have unintended side effects.
463 */
464#if !defined(CH_CFG_FACTORY_MAX_NAMES_LENGTH)
465#define CH_CFG_FACTORY_MAX_NAMES_LENGTH 8
466#endif
467
468/**
469 * @brief Enables the registry of generic objects.
470 */
471#if !defined(CH_CFG_FACTORY_OBJECTS_REGISTRY)
472#define CH_CFG_FACTORY_OBJECTS_REGISTRY TRUE
473#endif
474
475/**
476 * @brief Enables factory for generic buffers.
477 */
478#if !defined(CH_CFG_FACTORY_GENERIC_BUFFERS)
479#define CH_CFG_FACTORY_GENERIC_BUFFERS TRUE
480#endif
481
482/**
483 * @brief Enables factory for semaphores.
484 */
485#if !defined(CH_CFG_FACTORY_SEMAPHORES)
486#define CH_CFG_FACTORY_SEMAPHORES TRUE
487#endif
488
489/**
490 * @brief Enables factory for mailboxes.
491 */
492#if !defined(CH_CFG_FACTORY_MAILBOXES)
493#define CH_CFG_FACTORY_MAILBOXES TRUE
494#endif
495
496/**
497 * @brief Enables factory for objects FIFOs.
498 */
499#if !defined(CH_CFG_FACTORY_OBJ_FIFOS)
500#define CH_CFG_FACTORY_OBJ_FIFOS TRUE
501#endif
502
503/**
504 * @brief Enables factory for Pipes.
505 */
506#if !defined(CH_CFG_FACTORY_PIPES) || defined(__DOXYGEN__)
507#define CH_CFG_FACTORY_PIPES TRUE
508#endif
509
510/** @} */
511
512/*===========================================================================*/
513/**
514 * @name Debug options
515 * @{
516 */
517/*===========================================================================*/
518
519/**
520 * @brief Debug option, kernel statistics.
521 *
522 * @note The default is @p FALSE.
523 */
524#if !defined(CH_DBG_STATISTICS)
525#define CH_DBG_STATISTICS FALSE
526#endif
527
528/**
529 * @brief Debug option, system state check.
530 * @details If enabled the correct call protocol for system APIs is checked
531 * at runtime.
532 *
533 * @note The default is @p FALSE.
534 */
535#if !defined(CH_DBG_SYSTEM_STATE_CHECK)
536#define CH_DBG_SYSTEM_STATE_CHECK TRUE
537#endif
538
539/**
540 * @brief Debug option, parameters checks.
541 * @details If enabled then the checks on the API functions input
542 * parameters are activated.
543 *
544 * @note The default is @p FALSE.
545 */
546#if !defined(CH_DBG_ENABLE_CHECKS)
547#define CH_DBG_ENABLE_CHECKS TRUE
548#endif
549
550/**
551 * @brief Debug option, consistency checks.
552 * @details If enabled then all the assertions in the kernel code are
553 * activated. This includes consistency checks inside the kernel,
554 * runtime anomalies and port-defined checks.
555 *
556 * @note The default is @p FALSE.
557 */
558#if !defined(CH_DBG_ENABLE_ASSERTS)
559#define CH_DBG_ENABLE_ASSERTS TRUE
560#endif
561
562/**
563 * @brief Debug option, trace buffer.
564 * @details If enabled then the trace buffer is activated.
565 *
566 * @note The default is @p CH_DBG_TRACE_MASK_DISABLED.
567 */
568#if !defined(CH_DBG_TRACE_MASK)
569#define CH_DBG_TRACE_MASK CH_DBG_TRACE_MASK_DISABLED
570#endif
571
572/**
573 * @brief Trace buffer entries.
574 * @note The trace buffer is only allocated if @p CH_DBG_TRACE_MASK is
575 * different from @p CH_DBG_TRACE_MASK_DISABLED.
576 */
577#if !defined(CH_DBG_TRACE_BUFFER_SIZE)
578#define CH_DBG_TRACE_BUFFER_SIZE 128
579#endif
580
581/**
582 * @brief Debug option, stack checks.
583 * @details If enabled then a runtime stack check is performed.
584 *
585 * @note The default is @p FALSE.
586 * @note The stack check is performed in a architecture/port dependent way.
587 * It may not be implemented or some ports.
588 * @note The default failure mode is to halt the system with the global
589 * @p panic_msg variable set to @p NULL.
590 */
591#if !defined(CH_DBG_ENABLE_STACK_CHECK)
592#define CH_DBG_ENABLE_STACK_CHECK FALSE
593#endif
594
595/**
596 * @brief Debug option, stacks initialization.
597 * @details If enabled then the threads working area is filled with a byte
598 * value when a thread is created. This can be useful for the
599 * runtime measurement of the used stack.
600 *
601 * @note The default is @p FALSE.
602 */
603#if !defined(CH_DBG_FILL_THREADS)
604#define CH_DBG_FILL_THREADS FALSE
605#endif
606
607/**
608 * @brief Debug option, threads profiling.
609 * @details If enabled then a field is added to the @p thread_t structure that
610 * counts the system ticks occurred while executing the thread.
611 *
612 * @note The default is @p FALSE.
613 * @note This debug option is not currently compatible with the
614 * tickless mode.
615 */
616#if !defined(CH_DBG_THREADS_PROFILING)
617#define CH_DBG_THREADS_PROFILING FALSE
618#endif
619
620/** @} */
621
622/*===========================================================================*/
623/**
624 * @name Kernel hooks
625 * @{
626 */
627/*===========================================================================*/
628
629/**
630 * @brief System structure extension.
631 * @details User fields added to the end of the @p ch_system_t structure.
632 */
633#define CH_CFG_SYSTEM_EXTRA_FIELDS \
634 /* Add threads custom fields here.*/
635
636/**
637 * @brief System initialization hook.
638 * @details User initialization code added to the @p chSysInit() function
639 * just before interrupts are enabled globally.
640 */
641#define CH_CFG_SYSTEM_INIT_HOOK() { \
642 /* Add threads initialization code here.*/ \
643}
644
645/**
646 * @brief Threads descriptor structure extension.
647 * @details User fields added to the end of the @p thread_t structure.
648 */
649#define CH_CFG_THREAD_EXTRA_FIELDS \
650 /* Add threads custom fields here.*/
651
652/**
653 * @brief Threads initialization hook.
654 * @details User initialization code added to the @p _thread_init() function.
655 *
656 * @note It is invoked from within @p _thread_init() and implicitly from all
657 * the threads creation APIs.
658 */
659#define CH_CFG_THREAD_INIT_HOOK(tp) { \
660 /* Add threads initialization code here.*/ \
661}
662
663/**
664 * @brief Threads finalization hook.
665 * @details User finalization code added to the @p chThdExit() API.
666 */
667#define CH_CFG_THREAD_EXIT_HOOK(tp) { \
668 /* Add threads finalization code here.*/ \
669}
670
671/**
672 * @brief Context switch hook.
673 * @details This hook is invoked just before switching between threads.
674 */
675#define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) { \
676 /* Context switch code here.*/ \
677}
678
679/**
680 * @brief ISR enter hook.
681 */
682#define CH_CFG_IRQ_PROLOGUE_HOOK() { \
683 /* IRQ prologue code here.*/ \
684}
685
686/**
687 * @brief ISR exit hook.
688 */
689#define CH_CFG_IRQ_EPILOGUE_HOOK() { \
690 /* IRQ epilogue code here.*/ \
691}
692
693/**
694 * @brief Idle thread enter hook.
695 * @note This hook is invoked within a critical zone, no OS functions
696 * should be invoked from here.
697 * @note This macro can be used to activate a power saving mode.
698 */
699#define CH_CFG_IDLE_ENTER_HOOK() { \
700 /* Idle-enter code here.*/ \
701}
702
703/**
704 * @brief Idle thread leave hook.
705 * @note This hook is invoked within a critical zone, no OS functions
706 * should be invoked from here.
707 * @note This macro can be used to deactivate a power saving mode.
708 */
709#define CH_CFG_IDLE_LEAVE_HOOK() { \
710 /* Idle-leave code here.*/ \
711}
712
713/**
714 * @brief Idle Loop hook.
715 * @details This hook is continuously invoked by the idle thread loop.
716 */
717#define CH_CFG_IDLE_LOOP_HOOK() { \
718 /* Idle loop code here.*/ \
719}
720
721/**
722 * @brief System tick event hook.
723 * @details This hook is invoked in the system tick handler immediately
724 * after processing the virtual timers queue.
725 */
726#define CH_CFG_SYSTEM_TICK_HOOK() { \
727 /* System tick event code here.*/ \
728}
729
730/**
731 * @brief System halt hook.
732 * @details This hook is invoked in case to a system halting error before
733 * the system is halted.
734 */
735#define CH_CFG_SYSTEM_HALT_HOOK(reason) { \
736 /* System halt code here.*/ \
737}
738
739/**
740 * @brief Trace hook.
741 * @details This hook is invoked each time a new record is written in the
742 * trace buffer.
743 */
744#define CH_CFG_TRACE_HOOK(tep) { \
745 /* Trace code here.*/ \
746}
747
748
749/** @} */
750
751/*===========================================================================*/
752/* Port-specific settings (override port settings defaulted in chcore.h). */
753/*===========================================================================*/
754
755#endif /* CHCONF_H */
756
757/** @} */
diff --git a/lib/chibios-contrib/testhal/NRF52/NRF52832/PWM-ICU/halconf.h b/lib/chibios-contrib/testhal/NRF52/NRF52832/PWM-ICU/halconf.h
new file mode 100644
index 000000000..acb2fd2e5
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NRF52/NRF52832/PWM-ICU/halconf.h
@@ -0,0 +1,533 @@
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 templates/halconf.h
19 * @brief HAL configuration header.
20 * @details HAL configuration file, this file allows to enable or disable the
21 * various device drivers from your application. You may also use
22 * this file in order to override the device drivers default settings.
23 *
24 * @addtogroup HAL_CONF
25 * @{
26 */
27
28#ifndef HALCONF_H
29#define HALCONF_H
30
31#define _CHIBIOS_HAL_CONF_
32#define _CHIBIOS_HAL_CONF_VER_7_1_
33
34#include "mcuconf.h"
35
36/**
37 * @brief Enables the PAL subsystem.
38 */
39#if !defined(HAL_USE_PAL) || defined(__DOXYGEN__)
40#define HAL_USE_PAL TRUE
41#endif
42
43/**
44 * @brief Enables the ADC subsystem.
45 */
46#if !defined(HAL_USE_ADC) || defined(__DOXYGEN__)
47#define HAL_USE_ADC FALSE
48#endif
49
50/**
51 * @brief Enables the CAN subsystem.
52 */
53#if !defined(HAL_USE_CAN) || defined(__DOXYGEN__)
54#define HAL_USE_CAN FALSE
55#endif
56
57/**
58 * @brief Enables the cryptographic subsystem.
59 */
60#if !defined(HAL_USE_CRY) || defined(__DOXYGEN__)
61#define HAL_USE_CRY FALSE
62#endif
63
64/**
65 * @brief Enables the DAC subsystem.
66 */
67#if !defined(HAL_USE_DAC) || defined(__DOXYGEN__)
68#define HAL_USE_DAC FALSE
69#endif
70
71/**
72 * @brief Enables the EFlash subsystem.
73 */
74#if !defined(HAL_USE_EFL) || defined(__DOXYGEN__)
75#define HAL_USE_EFL FALSE
76#endif
77
78/**
79 * @brief Enables the GPT subsystem.
80 */
81#if !defined(HAL_USE_GPT) || defined(__DOXYGEN__)
82#define HAL_USE_GPT FALSE
83#endif
84
85/**
86 * @brief Enables the I2C subsystem.
87 */
88#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__)
89#define HAL_USE_I2C FALSE
90#endif
91
92/**
93 * @brief Enables the I2S subsystem.
94 */
95#if !defined(HAL_USE_I2S) || defined(__DOXYGEN__)
96#define HAL_USE_I2S FALSE
97#endif
98
99/**
100 * @brief Enables the ICU subsystem.
101 */
102#if !defined(HAL_USE_ICU) || defined(__DOXYGEN__)
103#define HAL_USE_ICU TRUE
104#endif
105
106/**
107 * @brief Enables the MAC subsystem.
108 */
109#if !defined(HAL_USE_MAC) || defined(__DOXYGEN__)
110#define HAL_USE_MAC FALSE
111#endif
112
113/**
114 * @brief Enables the MMC_SPI subsystem.
115 */
116#if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__)
117#define HAL_USE_MMC_SPI FALSE
118#endif
119
120/**
121 * @brief Enables the PWM subsystem.
122 */
123#if !defined(HAL_USE_PWM) || defined(__DOXYGEN__)
124#define HAL_USE_PWM TRUE
125#endif
126
127/**
128 * @brief Enables the RTC subsystem.
129 */
130#if !defined(HAL_USE_RTC) || defined(__DOXYGEN__)
131#define HAL_USE_RTC FALSE
132#endif
133
134/**
135 * @brief Enables the SDC subsystem.
136 */
137#if !defined(HAL_USE_SDC) || defined(__DOXYGEN__)
138#define HAL_USE_SDC FALSE
139#endif
140
141/**
142 * @brief Enables the SERIAL subsystem.
143 */
144#if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__)
145#define HAL_USE_SERIAL TRUE
146#endif
147
148/**
149 * @brief Enables the SERIAL over USB subsystem.
150 */
151#if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__)
152#define HAL_USE_SERIAL_USB FALSE
153#endif
154
155/**
156 * @brief Enables the SIO subsystem.
157 */
158#if !defined(HAL_USE_SIO) || defined(__DOXYGEN__)
159#define HAL_USE_SIO FALSE
160#endif
161
162/**
163 * @brief Enables the SPI subsystem.
164 */
165#if !defined(HAL_USE_SPI) || defined(__DOXYGEN__)
166#define HAL_USE_SPI FALSE
167#endif
168
169/**
170 * @brief Enables the TRNG subsystem.
171 */
172#if !defined(HAL_USE_TRNG) || defined(__DOXYGEN__)
173#define HAL_USE_TRNG FALSE
174#endif
175
176/**
177 * @brief Enables the UART subsystem.
178 */
179#if !defined(HAL_USE_UART) || defined(__DOXYGEN__)
180#define HAL_USE_UART FALSE
181#endif
182
183/**
184 * @brief Enables the USB subsystem.
185 */
186#if !defined(HAL_USE_USB) || defined(__DOXYGEN__)
187#define HAL_USE_USB FALSE
188#endif
189
190/**
191 * @brief Enables the WDG subsystem.
192 */
193#if !defined(HAL_USE_WDG) || defined(__DOXYGEN__)
194#define HAL_USE_WDG FALSE
195#endif
196
197/**
198 * @brief Enables the WSPI subsystem.
199 */
200#if !defined(HAL_USE_WSPI) || defined(__DOXYGEN__)
201#define HAL_USE_WSPI FALSE
202#endif
203
204/*===========================================================================*/
205/* PAL driver related settings. */
206/*===========================================================================*/
207
208/**
209 * @brief Enables synchronous APIs.
210 * @note Disabling this option saves both code and data space.
211 */
212#if !defined(PAL_USE_CALLBACKS) || defined(__DOXYGEN__)
213#define PAL_USE_CALLBACKS TRUE
214#endif
215
216/**
217 * @brief Enables synchronous APIs.
218 * @note Disabling this option saves both code and data space.
219 */
220#if !defined(PAL_USE_WAIT) || defined(__DOXYGEN__)
221#define PAL_USE_WAIT TRUE
222#endif
223
224/*===========================================================================*/
225/* ADC driver related settings. */
226/*===========================================================================*/
227
228/**
229 * @brief Enables synchronous APIs.
230 * @note Disabling this option saves both code and data space.
231 */
232#if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__)
233#define ADC_USE_WAIT TRUE
234#endif
235
236/**
237 * @brief Enables the @p adcAcquireBus() and @p adcReleaseBus() APIs.
238 * @note Disabling this option saves both code and data space.
239 */
240#if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
241#define ADC_USE_MUTUAL_EXCLUSION TRUE
242#endif
243
244/*===========================================================================*/
245/* CAN driver related settings. */
246/*===========================================================================*/
247
248/**
249 * @brief Sleep mode related APIs inclusion switch.
250 */
251#if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__)
252#define CAN_USE_SLEEP_MODE TRUE
253#endif
254
255/**
256 * @brief Enforces the driver to use direct callbacks rather than OSAL events.
257 */
258#if !defined(CAN_ENFORCE_USE_CALLBACKS) || defined(__DOXYGEN__)
259#define CAN_ENFORCE_USE_CALLBACKS FALSE
260#endif
261
262/*===========================================================================*/
263/* CRY driver related settings. */
264/*===========================================================================*/
265
266/**
267 * @brief Enables the SW fall-back of the cryptographic driver.
268 * @details When enabled, this option, activates a fall-back software
269 * implementation for algorithms not supported by the underlying
270 * hardware.
271 * @note Fall-back implementations may not be present for all algorithms.
272 */
273#if !defined(HAL_CRY_USE_FALLBACK) || defined(__DOXYGEN__)
274#define HAL_CRY_USE_FALLBACK FALSE
275#endif
276
277/**
278 * @brief Makes the driver forcibly use the fall-back implementations.
279 */
280#if !defined(HAL_CRY_ENFORCE_FALLBACK) || defined(__DOXYGEN__)
281#define HAL_CRY_ENFORCE_FALLBACK FALSE
282#endif
283
284/*===========================================================================*/
285/* DAC driver related settings. */
286/*===========================================================================*/
287
288/**
289 * @brief Enables synchronous APIs.
290 * @note Disabling this option saves both code and data space.
291 */
292#if !defined(DAC_USE_WAIT) || defined(__DOXYGEN__)
293#define DAC_USE_WAIT TRUE
294#endif
295
296/**
297 * @brief Enables the @p dacAcquireBus() and @p dacReleaseBus() APIs.
298 * @note Disabling this option saves both code and data space.
299 */
300#if !defined(DAC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
301#define DAC_USE_MUTUAL_EXCLUSION TRUE
302#endif
303
304/*===========================================================================*/
305/* I2C driver related settings. */
306/*===========================================================================*/
307
308/**
309 * @brief Enables the mutual exclusion APIs on the I2C bus.
310 */
311#if !defined(I2C_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
312#define I2C_USE_MUTUAL_EXCLUSION TRUE
313#endif
314
315/*===========================================================================*/
316/* MAC driver related settings. */
317/*===========================================================================*/
318
319/**
320 * @brief Enables the zero-copy API.
321 */
322#if !defined(MAC_USE_ZERO_COPY) || defined(__DOXYGEN__)
323#define MAC_USE_ZERO_COPY FALSE
324#endif
325
326/**
327 * @brief Enables an event sources for incoming packets.
328 */
329#if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__)
330#define MAC_USE_EVENTS TRUE
331#endif
332
333/*===========================================================================*/
334/* MMC_SPI driver related settings. */
335/*===========================================================================*/
336
337/**
338 * @brief Delays insertions.
339 * @details If enabled this options inserts delays into the MMC waiting
340 * routines releasing some extra CPU time for the threads with
341 * lower priority, this may slow down the driver a bit however.
342 * This option is recommended also if the SPI driver does not
343 * use a DMA channel and heavily loads the CPU.
344 */
345#if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__)
346#define MMC_NICE_WAITING TRUE
347#endif
348
349/*===========================================================================*/
350/* SDC driver related settings. */
351/*===========================================================================*/
352
353/**
354 * @brief Number of initialization attempts before rejecting the card.
355 * @note Attempts are performed at 10mS intervals.
356 */
357#if !defined(SDC_INIT_RETRY) || defined(__DOXYGEN__)
358#define SDC_INIT_RETRY 100
359#endif
360
361/**
362 * @brief Include support for MMC cards.
363 * @note MMC support is not yet implemented so this option must be kept
364 * at @p FALSE.
365 */
366#if !defined(SDC_MMC_SUPPORT) || defined(__DOXYGEN__)
367#define SDC_MMC_SUPPORT FALSE
368#endif
369
370/**
371 * @brief Delays insertions.
372 * @details If enabled this options inserts delays into the MMC waiting
373 * routines releasing some extra CPU time for the threads with
374 * lower priority, this may slow down the driver a bit however.
375 */
376#if !defined(SDC_NICE_WAITING) || defined(__DOXYGEN__)
377#define SDC_NICE_WAITING TRUE
378#endif
379
380/**
381 * @brief OCR initialization constant for V20 cards.
382 */
383#if !defined(SDC_INIT_OCR_V20) || defined(__DOXYGEN__)
384#define SDC_INIT_OCR_V20 0x50FF8000U
385#endif
386
387/**
388 * @brief OCR initialization constant for non-V20 cards.
389 */
390#if !defined(SDC_INIT_OCR) || defined(__DOXYGEN__)
391#define SDC_INIT_OCR 0x80100000U
392#endif
393
394/*===========================================================================*/
395/* SERIAL driver related settings. */
396/*===========================================================================*/
397
398/**
399 * @brief Default bit rate.
400 * @details Configuration parameter, this is the baud rate selected for the
401 * default configuration.
402 */
403#if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__)
404#define SERIAL_DEFAULT_BITRATE 38400
405#endif
406
407/**
408 * @brief Serial buffers size.
409 * @details Configuration parameter, you can change the depth of the queue
410 * buffers depending on the requirements of your application.
411 * @note The default is 16 bytes for both the transmission and receive
412 * buffers.
413 */
414#if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__)
415#define SERIAL_BUFFERS_SIZE 16
416#endif
417
418/*===========================================================================*/
419/* SERIAL_USB driver related setting. */
420/*===========================================================================*/
421
422/**
423 * @brief Serial over USB buffers size.
424 * @details Configuration parameter, the buffer size must be a multiple of
425 * the USB data endpoint maximum packet size.
426 * @note The default is 256 bytes for both the transmission and receive
427 * buffers.
428 */
429#if !defined(SERIAL_USB_BUFFERS_SIZE) || defined(__DOXYGEN__)
430#define SERIAL_USB_BUFFERS_SIZE 256
431#endif
432
433/**
434 * @brief Serial over USB number of buffers.
435 * @note The default is 2 buffers.
436 */
437#if !defined(SERIAL_USB_BUFFERS_NUMBER) || defined(__DOXYGEN__)
438#define SERIAL_USB_BUFFERS_NUMBER 2
439#endif
440
441/*===========================================================================*/
442/* SPI driver related settings. */
443/*===========================================================================*/
444
445/**
446 * @brief Enables synchronous APIs.
447 * @note Disabling this option saves both code and data space.
448 */
449#if !defined(SPI_USE_WAIT) || defined(__DOXYGEN__)
450#define SPI_USE_WAIT TRUE
451#endif
452
453/**
454 * @brief Enables circular transfers APIs.
455 * @note Disabling this option saves both code and data space.
456 */
457#if !defined(SPI_USE_CIRCULAR) || defined(__DOXYGEN__)
458#define SPI_USE_CIRCULAR FALSE
459#endif
460
461/**
462 * @brief Enables the @p spiAcquireBus() and @p spiReleaseBus() APIs.
463 * @note Disabling this option saves both code and data space.
464 */
465#if !defined(SPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
466#define SPI_USE_MUTUAL_EXCLUSION TRUE
467#endif
468
469/**
470 * @brief Handling method for SPI CS line.
471 * @note Disabling this option saves both code and data space.
472 */
473#if !defined(SPI_SELECT_MODE) || defined(__DOXYGEN__)
474#define SPI_SELECT_MODE SPI_SELECT_MODE_PAD
475#endif
476
477/*===========================================================================*/
478/* UART driver related settings. */
479/*===========================================================================*/
480
481/**
482 * @brief Enables synchronous APIs.
483 * @note Disabling this option saves both code and data space.
484 */
485#if !defined(UART_USE_WAIT) || defined(__DOXYGEN__)
486#define UART_USE_WAIT FALSE
487#endif
488
489/**
490 * @brief Enables the @p uartAcquireBus() and @p uartReleaseBus() APIs.
491 * @note Disabling this option saves both code and data space.
492 */
493#if !defined(UART_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
494#define UART_USE_MUTUAL_EXCLUSION FALSE
495#endif
496
497/*===========================================================================*/
498/* USB driver related settings. */
499/*===========================================================================*/
500
501/**
502 * @brief Enables synchronous APIs.
503 * @note Disabling this option saves both code and data space.
504 */
505#if !defined(USB_USE_WAIT) || defined(__DOXYGEN__)
506#define USB_USE_WAIT FALSE
507#endif
508
509/*===========================================================================*/
510/* WSPI driver related settings. */
511/*===========================================================================*/
512
513/**
514 * @brief Enables synchronous APIs.
515 * @note Disabling this option saves both code and data space.
516 */
517#if !defined(WSPI_USE_WAIT) || defined(__DOXYGEN__)
518#define WSPI_USE_WAIT TRUE
519#endif
520
521/**
522 * @brief Enables the @p wspiAcquireBus() and @p wspiReleaseBus() APIs.
523 * @note Disabling this option saves both code and data space.
524 */
525#if !defined(WSPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
526#define WSPI_USE_MUTUAL_EXCLUSION TRUE
527#endif
528
529#include "halconf_community.h"
530
531#endif /* HALCONF_H */
532
533/** @} */
diff --git a/lib/chibios-contrib/testhal/NRF52/NRF52832/PWM-ICU/halconf_community.h b/lib/chibios-contrib/testhal/NRF52/NRF52832/PWM-ICU/halconf_community.h
new file mode 100644
index 000000000..43fdbf869
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NRF52/NRF52832/PWM-ICU/halconf_community.h
@@ -0,0 +1,173 @@
1/*
2 ChibiOS - Copyright (C) 2014 Uladzimir Pylinsky aka barthess
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#ifndef HALCONF_COMMUNITY_H
18#define HALCONF_COMMUNITY_H
19
20/**
21 * @brief Enables the community overlay.
22 */
23#if !defined(HAL_USE_COMMUNITY) || defined(__DOXYGEN__)
24#define HAL_USE_COMMUNITY TRUE
25#endif
26
27/**
28 * @brief Enables the FSMC subsystem.
29 */
30#if !defined(HAL_USE_FSMC) || defined(__DOXYGEN__)
31#define HAL_USE_FSMC FALSE
32#endif
33
34/**
35 * @brief Enables the NAND subsystem.
36 */
37#if !defined(HAL_USE_NAND) || defined(__DOXYGEN__)
38#define HAL_USE_NAND FALSE
39#endif
40
41/**
42 * @brief Enables the 1-wire subsystem.
43 */
44#if !defined(HAL_USE_ONEWIRE) || defined(__DOXYGEN__)
45#define HAL_USE_ONEWIRE FALSE
46#endif
47
48/**
49 * @brief Enables the EICU subsystem.
50 */
51#if !defined(HAL_USE_EICU) || defined(__DOXYGEN__)
52#define HAL_USE_EICU FALSE
53#endif
54
55/**
56 * @brief Enables the CRC subsystem.
57 */
58#if !defined(HAL_USE_CRC) || defined(__DOXYGEN__)
59#define HAL_USE_CRC FALSE
60#endif
61
62/**
63 * @brief Enables the RNG subsystem.
64 */
65#if !defined(HAL_USE_RNG) || defined(__DOXYGEN__)
66#define HAL_USE_RNG FALSE
67#endif
68
69/**
70 * @brief Enables the EEPROM subsystem.
71 */
72#if !defined(HAL_USE_EEPROM) || defined(__DOXYGEN__)
73#define HAL_USE_EEPROM FALSE
74#endif
75
76/**
77 * @brief Enables the TIMCAP subsystem.
78 */
79#if !defined(HAL_USE_TIMCAP) || defined(__DOXYGEN__)
80#define HAL_USE_TIMCAP FALSE
81#endif
82
83/**
84 * @brief Enables the TIMCAP subsystem.
85 */
86#if !defined(HAL_USE_COMP) || defined(__DOXYGEN__)
87#define HAL_USE_COMP FALSE
88#endif
89
90/**
91 * @brief Enables the QEI subsystem.
92 */
93#if !defined(HAL_USE_QEI) || defined(__DOXYGEN__)
94#define HAL_USE_QEI FALSE
95#endif
96
97/**
98 * @brief Enables the USBH subsystem.
99 */
100#if !defined(HAL_USE_USBH) || defined(__DOXYGEN__)
101#define HAL_USE_USBH FALSE
102#endif
103
104/**
105 * @brief Enables the USB_MSD subsystem.
106 */
107#if !defined(HAL_USE_USB_MSD) || defined(__DOXYGEN__)
108#define HAL_USE_USB_MSD FALSE
109#endif
110
111/*===========================================================================*/
112/* FSMCNAND driver related settings. */
113/*===========================================================================*/
114
115/**
116 * @brief Enables the @p nandAcquireBus() and @p nanReleaseBus() APIs.
117 * @note Disabling this option saves both code and data space.
118 */
119#if !defined(NAND_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
120#define NAND_USE_MUTUAL_EXCLUSION TRUE
121#endif
122
123/*===========================================================================*/
124/* 1-wire driver related settings. */
125/*===========================================================================*/
126/**
127 * @brief Enables strong pull up feature.
128 * @note Disabling this option saves both code and data space.
129 */
130#define ONEWIRE_USE_STRONG_PULLUP FALSE
131
132/**
133 * @brief Enables search ROM feature.
134 * @note Disabling this option saves both code and data space.
135 */
136#define ONEWIRE_USE_SEARCH_ROM TRUE
137
138/*===========================================================================*/
139/* QEI driver related settings. */
140/*===========================================================================*/
141
142/**
143 * @brief Enables discard of overlow
144 */
145#if !defined(QEI_USE_OVERFLOW_DISCARD) || defined(__DOXYGEN__)
146#define QEI_USE_OVERFLOW_DISCARD FALSE
147#endif
148
149/**
150 * @brief Enables min max of overlow
151 */
152#if !defined(QEI_USE_OVERFLOW_MINMAX) || defined(__DOXYGEN__)
153#define QEI_USE_OVERFLOW_MINMAX FALSE
154#endif
155
156/*===========================================================================*/
157/* EEProm driver related settings. */
158/*===========================================================================*/
159
160/**
161 * @brief Enables 24xx series I2C eeprom device driver.
162 * @note Disabling this option saves both code and data space.
163 */
164#define EEPROM_USE_EE24XX FALSE
165 /**
166 * @brief Enables 25xx series SPI eeprom device driver.
167 * @note Disabling this option saves both code and data space.
168 */
169#define EEPROM_USE_EE25XX FALSE
170
171#endif /* HALCONF_COMMUNITY_H */
172
173/** @} */
diff --git a/lib/chibios-contrib/testhal/NRF52/NRF52832/PWM-ICU/main.c b/lib/chibios-contrib/testhal/NRF52/NRF52832/PWM-ICU/main.c
new file mode 100644
index 000000000..ee34c43f6
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NRF52/NRF52832/PWM-ICU/main.c
@@ -0,0 +1,122 @@
1/*
2 Copyright (C) 2018 andru
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 "chprintf.h"
20
21static icucnt_t last_width, last_period;
22
23static SerialConfig serial_config = {
24 .speed = 38400,
25 .tx_pad = UART_TX,
26 .rx_pad = UART_RX,
27#if NRF5_SERIAL_USE_HWFLOWCTRL == TRUE
28 .rts_pad = UART_RTS,
29 .cts_pad = UART_CTS,
30#endif
31};
32
33static void pwm_cb_period(PWMDriver *pwmp) {
34 (void)pwmp;
35 palTogglePad(IOPORT1, LED1);
36}
37
38void icu_width_cb(ICUDriver *icup) {
39 last_width = icuGetWidthX(icup);
40}
41
42void icu_period_cb(ICUDriver *icup) {
43 last_period = icuGetPeriodX(icup);
44}
45
46ICUConfig icucfg = {
47 .frequency = ICU_FREQUENCY_250KHZ,
48 .width_cb = icu_width_cb,
49 .period_cb = icu_period_cb,
50 NULL,
51 .iccfgp = {
52 {
53 .ioline = { BTN1, BTN2 },
54 .mode = ICU_INPUT_ACTIVE_HIGH,
55 .gpiote_channel = { 0, 1 },
56 .ppi_channel = { 0, 1 },
57 },
58 },
59};
60
61PWMConfig pwmcfg = {
62 .frequency = PWM_FREQUENCY_125KHZ,
63 .period = 12500,
64 .callback = pwm_cb_period,
65 {
66 { .mode = PWM_OUTPUT_DISABLED,
67 },
68 { .mode = PWM_OUTPUT_ACTIVE_HIGH,
69 .ioline = LINE_LED2,
70 },
71 },
72};
73
74/*
75 * Application entry point.
76 */
77int main(void) {
78 /*
79 * System initializations.
80 * - HAL initialization, this also initializes the configured device drivers
81 * and performs the board-specific initializations.
82 * - Kernel initialization, the main() function becomes a thread and the
83 * RTOS is active.
84 */
85 halInit();
86 chSysInit();
87
88 sdStart(&SD1, &serial_config);
89
90 /*
91 *
92 */
93 pwmStart(&PWMD1, &pwmcfg);
94 pwmEnablePeriodicNotification(&PWMD1);
95
96 icuStart(&ICUD1, &icucfg);
97 icuStartCapture(&ICUD1);
98
99 pwmEnableChannel(&PWMD1, 1, PWM_PERCENTAGE_TO_WIDTH(&PWMD1, 2500)); // 25%
100 chThdSleepMilliseconds(5000);
101 chprintf((BaseSequentialStream *) &SD1, "period=%d, width=%d\r\n", last_period, last_width);
102
103 pwmEnableChannel(&PWMD1, 1, PWM_PERCENTAGE_TO_WIDTH(&PWMD1, 5000)); // 50%
104 chThdSleepMilliseconds(5000);
105 chprintf((BaseSequentialStream *) &SD1, "period=%d, width=%d\r\n", last_period, last_width);
106
107 pwmEnableChannel(&PWMD1, 1, PWM_PERCENTAGE_TO_WIDTH(&PWMD1, 7500)); // 75%
108 chThdSleepMilliseconds(5000);
109 chprintf((BaseSequentialStream *) &SD1, "period=%d, width=%d\r\n", last_period, last_width);
110
111 pwmChangePeriod(&PWMD1, 5000);
112 chThdSleepMilliseconds(5000);
113
114 pwmDisableChannel(&PWMD1, 1);
115 pwmStop(&PWMD1);
116 icuStopCapture(&ICUD1);
117 icuStop(&ICUD1);
118
119 while (true) {
120 chThdSleepMilliseconds(500);
121 }
122}
diff --git a/lib/chibios-contrib/testhal/NRF52/NRF52832/PWM-ICU/mcuconf.h b/lib/chibios-contrib/testhal/NRF52/NRF52832/PWM-ICU/mcuconf.h
new file mode 100644
index 000000000..429309ae5
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NRF52/NRF52832/PWM-ICU/mcuconf.h
@@ -0,0 +1,33 @@
1/*
2 Copyright (C) 2015 Fabio Utzig
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#ifndef _MCUCONF_H_
18#define _MCUCONF_H_
19
20/*
21 * HAL driver system settings.
22 */
23#define NRF5_SERIAL_USE_UART0 TRUE
24#define NRF5_ST_USE_RTC0 TRUE
25#define NRF5_ST_USE_RTC1 FALSE
26#define NRF5_ST_USE_TIMER0 FALSE
27#define NRF5_PWM_USE_PWM0 TRUE
28#define NRF5_PWM_PWM0_PRIORITY 6
29#define NRF5_ICU_USE_TIMER0 TRUE
30#define NRF5_ICU_GPIOTE_IRQ_PRIORITY 4
31#define NRF5_ICU_TIMER0_IRQ_PRIORITY 4
32
33#endif /* _MCUCONF_H_ */
diff --git a/lib/chibios-contrib/testhal/NRF52/NRF52832/RADIO-ESB/Makefile b/lib/chibios-contrib/testhal/NRF52/NRF52832/RADIO-ESB/Makefile
new file mode 100644
index 000000000..b5c9e4616
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NRF52/NRF52832/RADIO-ESB/Makefile
@@ -0,0 +1,212 @@
1##############################################################################
2# Build global options
3# NOTE: Can be overridden externally.
4#
5
6# Compiler options here.
7ifeq ($(USE_OPT),)
8 USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16
9endif
10
11# C specific options here (added to USE_OPT).
12ifeq ($(USE_COPT),)
13 USE_COPT =
14endif
15
16# C++ specific options here (added to USE_OPT).
17ifeq ($(USE_CPPOPT),)
18 USE_CPPOPT = -fno-rtti
19endif
20
21# Enable this if you want the linker to remove unused code and data
22ifeq ($(USE_LINK_GC),)
23 USE_LINK_GC = yes
24endif
25
26# Linker extra options here.
27ifeq ($(USE_LDOPT),)
28 USE_LDOPT =
29endif
30
31# Enable this if you want link time optimizations (LTO)
32ifeq ($(USE_LTO),)
33 USE_LTO = no
34endif
35
36# If enabled, this option allows to compile the application in THUMB mode.
37ifeq ($(USE_THUMB),)
38 USE_THUMB = yes
39endif
40
41# Enable this if you want to see the full log while compiling.
42ifeq ($(USE_VERBOSE_COMPILE),)
43 USE_VERBOSE_COMPILE = no
44endif
45
46#
47# Build global options
48##############################################################################
49
50##############################################################################
51# Architecture or project specific options
52#
53
54# Stack size to be allocated to the Cortex-M process stack. This stack is
55# the stack used by the main() thread.
56ifeq ($(USE_PROCESS_STACKSIZE),)
57 USE_PROCESS_STACKSIZE = 0x400
58endif
59
60# Stack size to the allocated to the Cortex-M main/exceptions stack. This
61# stack is used for processing interrupts and exceptions.
62ifeq ($(USE_EXCEPTIONS_STACKSIZE),)
63 USE_EXCEPTIONS_STACKSIZE = 0x400
64endif
65
66# Enables the use of FPU on Cortex-M4 (no, softfp, hard).
67ifeq ($(USE_FPU),)
68 USE_FPU = no
69endif
70
71#
72# Architecture or project specific options
73##############################################################################
74
75##############################################################################
76# Project, sources and paths
77#
78
79# Define project name here
80PROJECT = ch
81
82# Imported source files and paths
83CHIBIOS = ../../../../../ChibiOS-RT
84CHIBIOS_CONTRIB = $(CHIBIOS)/../ChibiOS-Contrib
85# Licensing files.
86include $(CHIBIOS)/os/license/license.mk
87# Startup files.
88include $(CHIBIOS_CONTRIB)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_nrf52.mk
89# HAL-OSAL files (optional).
90include $(CHIBIOS_CONTRIB)/os/hal/hal.mk
91include $(CHIBIOS_CONTRIB)/os/hal/ports/NRF5/NRF52832/platform.mk
92include $(CHIBIOS_CONTRIB)/os/hal/boards/NRF52-E73-2G4M04S/board.mk
93include $(CHIBIOS)/os/hal/osal/rt-nil/osal.mk
94# RTOS files (optional).
95include $(CHIBIOS)/os/rt/rt.mk
96include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk
97# Other files (optional).
98#include $(CHIBIOS)/test/rt/test.mk
99
100# Define linker script file here
101LDSCRIPT= $(STARTUPLD_CONTRIB)/NRF52832.ld
102
103# C sources that can be compiled in ARM or THUMB mode depending on the global
104# setting.
105CSRC = $(ALLCSRC) \
106 $(TESTSRC) \
107 $(CHIBIOS)/os/various/syscalls.c \
108 $(CHIBIOS)/os/hal/lib/streams/memstreams.c \
109 $(CHIBIOS)/os/hal/lib/streams/chprintf.c \
110 nrf52_radio.c \
111 main.c
112
113# C++ sources that can be compiled in ARM or THUMB mode depending on the global
114# setting.
115CPPSRC = $(ALLCPPSRC)
116
117# C sources to be compiled in ARM mode regardless of the global setting.
118# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
119# option that results in lower performance and larger code size.
120ACSRC =
121
122# C++ sources to be compiled in ARM mode regardless of the global setting.
123# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
124# option that results in lower performance and larger code size.
125ACPPSRC =
126
127# C sources to be compiled in THUMB mode regardless of the global setting.
128# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
129# option that results in lower performance and larger code size.
130TCSRC =
131
132# C sources to be compiled in THUMB mode regardless of the global setting.
133# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
134# option that results in lower performance and larger code size.
135TCPPSRC =
136
137# List ASM source files here
138ASMSRC = $(ALLASMSRC)
139ASMXSRC = $(ALLXASMSRC)
140
141INCDIR = $(ALLINC) $(TESTINC) \
142 $(CHIBIOS)/os/hal/lib/streams \
143 $(TESTHAL)
144
145#
146# Project, sources and paths
147##############################################################################
148
149##############################################################################
150# Compiler settings
151#
152
153MCU = cortex-m4
154
155TRGT = arm-none-eabi-
156CC = $(TRGT)gcc
157CPPC = $(TRGT)g++
158# Enable loading with g++ only if you need C++ runtime support.
159# NOTE: You can use C++ even without C++ support if you are careful. C++
160# runtime support makes code size explode.
161LD = $(TRGT)gcc
162#LD = $(TRGT)g++
163CP = $(TRGT)objcopy
164AS = $(TRGT)gcc -x assembler-with-cpp
165AR = $(TRGT)ar
166OD = $(TRGT)objdump
167SZ = $(TRGT)size
168HEX = $(CP) -O ihex
169BIN = $(CP) -O binary
170SREC = $(CP) -O srec
171
172# ARM-specific options here
173AOPT =
174
175# THUMB-specific options here
176TOPT = -mthumb -DTHUMB
177
178# Define C warning options here
179CWARN = -Wall -Wextra -Wstrict-prototypes
180
181# Define C++ warning options here
182CPPWARN = -Wall -Wextra
183
184#
185# Compiler settings
186##############################################################################
187
188##############################################################################
189# Start of user section
190#
191
192# List all user C define here, like -D_DEBUG=1
193UDEFS =
194
195# Define ASM defines here
196UADEFS =
197
198# List all user directories here
199UINCDIR =
200
201# List the user directory to look for the libraries here
202ULIBDIR =
203
204# List all user libraries here
205ULIBS =
206
207#
208# End of user defines
209##############################################################################
210
211RULESPATH = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk
212include $(RULESPATH)/rules.mk
diff --git a/lib/chibios-contrib/testhal/NRF52/NRF52832/RADIO-ESB/chconf.h b/lib/chibios-contrib/testhal/NRF52/NRF52832/RADIO-ESB/chconf.h
new file mode 100644
index 000000000..6687603e0
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NRF52/NRF52832/RADIO-ESB/chconf.h
@@ -0,0 +1,757 @@
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 rt/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 config
24 * @details Kernel related settings and hooks.
25 * @{
26 */
27
28#ifndef CHCONF_H
29#define CHCONF_H
30
31#define _CHIBIOS_RT_CONF_
32#define _CHIBIOS_RT_CONF_VER_6_1_
33
34/*===========================================================================*/
35/**
36 * @name System timers settings
37 * @{
38 */
39/*===========================================================================*/
40
41/**
42 * @brief System time counter resolution.
43 * @note Allowed values are 16 or 32 bits.
44 */
45#if !defined(CH_CFG_ST_RESOLUTION)
46#define CH_CFG_ST_RESOLUTION 32
47#endif
48
49/**
50 * @brief System tick frequency.
51 * @details Frequency of the system timer that drives the system ticks. This
52 * setting also defines the system tick time unit.
53 */
54#if !defined(CH_CFG_ST_FREQUENCY)
55#define CH_CFG_ST_FREQUENCY 1000
56#endif
57
58/**
59 * @brief Time intervals data size.
60 * @note Allowed values are 16, 32 or 64 bits.
61 */
62#if !defined(CH_CFG_INTERVALS_SIZE)
63#define CH_CFG_INTERVALS_SIZE 32
64#endif
65
66/**
67 * @brief Time types data size.
68 * @note Allowed values are 16 or 32 bits.
69 */
70#if !defined(CH_CFG_TIME_TYPES_SIZE)
71#define CH_CFG_TIME_TYPES_SIZE 32
72#endif
73
74/**
75 * @brief Time delta constant for the tick-less mode.
76 * @note If this value is zero then the system uses the classic
77 * periodic tick. This value represents the minimum number
78 * of ticks that is safe to specify in a timeout directive.
79 * The value one is not valid, timeouts are rounded up to
80 * this value.
81 */
82#if !defined(CH_CFG_ST_TIMEDELTA)
83#define CH_CFG_ST_TIMEDELTA 0
84#endif
85
86/** @} */
87
88/*===========================================================================*/
89/**
90 * @name Kernel parameters and options
91 * @{
92 */
93/*===========================================================================*/
94
95/**
96 * @brief Round robin interval.
97 * @details This constant is the number of system ticks allowed for the
98 * threads before preemption occurs. Setting this value to zero
99 * disables the preemption for threads with equal priority and the
100 * round robin becomes cooperative. Note that higher priority
101 * threads can still preempt, the kernel is always preemptive.
102 * @note Disabling the round robin preemption makes the kernel more compact
103 * and generally faster.
104 * @note The round robin preemption is not supported in tickless mode and
105 * must be set to zero in that case.
106 */
107#if !defined(CH_CFG_TIME_QUANTUM)
108#define CH_CFG_TIME_QUANTUM 0
109#endif
110
111/**
112 * @brief Idle thread automatic spawn suppression.
113 * @details When this option is activated the function @p chSysInit()
114 * does not spawn the idle thread. The application @p main()
115 * function becomes the idle thread and must implement an
116 * infinite loop.
117 */
118#if !defined(CH_CFG_NO_IDLE_THREAD)
119#define CH_CFG_NO_IDLE_THREAD FALSE
120#endif
121
122/** @} */
123
124/*===========================================================================*/
125/**
126 * @name Performance options
127 * @{
128 */
129/*===========================================================================*/
130
131/**
132 * @brief OS optimization.
133 * @details If enabled then time efficient rather than space efficient code
134 * is used when two possible implementations exist.
135 *
136 * @note This is not related to the compiler optimization options.
137 * @note The default is @p TRUE.
138 */
139#if !defined(CH_CFG_OPTIMIZE_SPEED)
140#define CH_CFG_OPTIMIZE_SPEED TRUE
141#endif
142
143/** @} */
144
145/*===========================================================================*/
146/**
147 * @name Subsystem options
148 * @{
149 */
150/*===========================================================================*/
151
152/**
153 * @brief Time Measurement APIs.
154 * @details If enabled then the time measurement APIs are included in
155 * the kernel.
156 *
157 * @note The default is @p TRUE.
158 */
159#if !defined(CH_CFG_USE_TM)
160#define CH_CFG_USE_TM TRUE
161#endif
162
163/**
164 * @brief Threads registry APIs.
165 * @details If enabled then the registry APIs are included in the kernel.
166 *
167 * @note The default is @p TRUE.
168 */
169#if !defined(CH_CFG_USE_REGISTRY)
170#define CH_CFG_USE_REGISTRY TRUE
171#endif
172
173/**
174 * @brief Threads synchronization APIs.
175 * @details If enabled then the @p chThdWait() function is included in
176 * the kernel.
177 *
178 * @note The default is @p TRUE.
179 */
180#if !defined(CH_CFG_USE_WAITEXIT)
181#define CH_CFG_USE_WAITEXIT TRUE
182#endif
183
184/**
185 * @brief Semaphores APIs.
186 * @details If enabled then the Semaphores APIs are included in the kernel.
187 *
188 * @note The default is @p TRUE.
189 */
190#if !defined(CH_CFG_USE_SEMAPHORES)
191#define CH_CFG_USE_SEMAPHORES TRUE
192#endif
193
194/**
195 * @brief Semaphores queuing mode.
196 * @details If enabled then the threads are enqueued on semaphores by
197 * priority rather than in FIFO order.
198 *
199 * @note The default is @p FALSE. Enable this if you have special
200 * requirements.
201 * @note Requires @p CH_CFG_USE_SEMAPHORES.
202 */
203#if !defined(CH_CFG_USE_SEMAPHORES_PRIORITY)
204#define CH_CFG_USE_SEMAPHORES_PRIORITY FALSE
205#endif
206
207/**
208 * @brief Mutexes APIs.
209 * @details If enabled then the mutexes APIs are included in the kernel.
210 *
211 * @note The default is @p TRUE.
212 */
213#if !defined(CH_CFG_USE_MUTEXES)
214#define CH_CFG_USE_MUTEXES TRUE
215#endif
216
217/**
218 * @brief Enables recursive behavior on mutexes.
219 * @note Recursive mutexes are heavier and have an increased
220 * memory footprint.
221 *
222 * @note The default is @p FALSE.
223 * @note Requires @p CH_CFG_USE_MUTEXES.
224 */
225#if !defined(CH_CFG_USE_MUTEXES_RECURSIVE)
226#define CH_CFG_USE_MUTEXES_RECURSIVE FALSE
227#endif
228
229/**
230 * @brief Conditional Variables APIs.
231 * @details If enabled then the conditional variables APIs are included
232 * in the kernel.
233 *
234 * @note The default is @p TRUE.
235 * @note Requires @p CH_CFG_USE_MUTEXES.
236 */
237#if !defined(CH_CFG_USE_CONDVARS)
238#define CH_CFG_USE_CONDVARS TRUE
239#endif
240
241/**
242 * @brief Conditional Variables APIs with timeout.
243 * @details If enabled then the conditional variables APIs with timeout
244 * specification are included in the kernel.
245 *
246 * @note The default is @p TRUE.
247 * @note Requires @p CH_CFG_USE_CONDVARS.
248 */
249#if !defined(CH_CFG_USE_CONDVARS_TIMEOUT)
250#define CH_CFG_USE_CONDVARS_TIMEOUT TRUE
251#endif
252
253/**
254 * @brief Events Flags APIs.
255 * @details If enabled then the event flags APIs are included in the kernel.
256 *
257 * @note The default is @p TRUE.
258 */
259#if !defined(CH_CFG_USE_EVENTS)
260#define CH_CFG_USE_EVENTS TRUE
261#endif
262
263/**
264 * @brief Events Flags APIs with timeout.
265 * @details If enabled then the events APIs with timeout specification
266 * are included in the kernel.
267 *
268 * @note The default is @p TRUE.
269 * @note Requires @p CH_CFG_USE_EVENTS.
270 */
271#if !defined(CH_CFG_USE_EVENTS_TIMEOUT)
272#define CH_CFG_USE_EVENTS_TIMEOUT TRUE
273#endif
274
275/**
276 * @brief Synchronous Messages APIs.
277 * @details If enabled then the synchronous messages APIs are included
278 * in the kernel.
279 *
280 * @note The default is @p TRUE.
281 */
282#if !defined(CH_CFG_USE_MESSAGES)
283#define CH_CFG_USE_MESSAGES TRUE
284#endif
285
286/**
287 * @brief Synchronous Messages queuing mode.
288 * @details If enabled then messages are served by priority rather than in
289 * FIFO order.
290 *
291 * @note The default is @p FALSE. Enable this if you have special
292 * requirements.
293 * @note Requires @p CH_CFG_USE_MESSAGES.
294 */
295#if !defined(CH_CFG_USE_MESSAGES_PRIORITY)
296#define CH_CFG_USE_MESSAGES_PRIORITY FALSE
297#endif
298
299/**
300 * @brief Dynamic Threads APIs.
301 * @details If enabled then the dynamic threads creation APIs are included
302 * in the kernel.
303 *
304 * @note The default is @p TRUE.
305 * @note Requires @p CH_CFG_USE_WAITEXIT.
306 * @note Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS.
307 */
308#if !defined(CH_CFG_USE_DYNAMIC)
309#define CH_CFG_USE_DYNAMIC TRUE
310#endif
311
312/** @} */
313
314/*===========================================================================*/
315/**
316 * @name OSLIB options
317 * @{
318 */
319/*===========================================================================*/
320
321/**
322 * @brief Mailboxes APIs.
323 * @details If enabled then the asynchronous messages (mailboxes) APIs are
324 * included in the kernel.
325 *
326 * @note The default is @p TRUE.
327 * @note Requires @p CH_CFG_USE_SEMAPHORES.
328 */
329#if !defined(CH_CFG_USE_MAILBOXES)
330#define CH_CFG_USE_MAILBOXES TRUE
331#endif
332
333/**
334 * @brief Core Memory Manager APIs.
335 * @details If enabled then the core memory manager APIs are included
336 * in the kernel.
337 *
338 * @note The default is @p TRUE.
339 */
340#if !defined(CH_CFG_USE_MEMCORE)
341#define CH_CFG_USE_MEMCORE TRUE
342#endif
343
344/**
345 * @brief Managed RAM size.
346 * @details Size of the RAM area to be managed by the OS. If set to zero
347 * then the whole available RAM is used. The core memory is made
348 * available to the heap allocator and/or can be used directly through
349 * the simplified core memory allocator.
350 *
351 * @note In order to let the OS manage the whole RAM the linker script must
352 * provide the @p __heap_base__ and @p __heap_end__ symbols.
353 * @note Requires @p CH_CFG_USE_MEMCORE.
354 */
355#if !defined(CH_CFG_MEMCORE_SIZE)
356#define CH_CFG_MEMCORE_SIZE 0
357#endif
358
359/**
360 * @brief Heap Allocator APIs.
361 * @details If enabled then the memory heap allocator APIs are included
362 * in the kernel.
363 *
364 * @note The default is @p TRUE.
365 * @note Requires @p CH_CFG_USE_MEMCORE and either @p CH_CFG_USE_MUTEXES or
366 * @p CH_CFG_USE_SEMAPHORES.
367 * @note Mutexes are recommended.
368 */
369#if !defined(CH_CFG_USE_HEAP)
370#define CH_CFG_USE_HEAP TRUE
371#endif
372
373/**
374 * @brief Memory Pools Allocator APIs.
375 * @details If enabled then the memory pools allocator APIs are included
376 * in the kernel.
377 *
378 * @note The default is @p TRUE.
379 */
380#if !defined(CH_CFG_USE_MEMPOOLS)
381#define CH_CFG_USE_MEMPOOLS TRUE
382#endif
383
384/**
385 * @brief Objects FIFOs APIs.
386 * @details If enabled then the objects FIFOs APIs are included
387 * in the kernel.
388 *
389 * @note The default is @p TRUE.
390 */
391#if !defined(CH_CFG_USE_OBJ_FIFOS)
392#define CH_CFG_USE_OBJ_FIFOS TRUE
393#endif
394
395/**
396 * @brief Pipes APIs.
397 * @details If enabled then the pipes APIs are included
398 * in the kernel.
399 *
400 * @note The default is @p TRUE.
401 */
402#if !defined(CH_CFG_USE_PIPES)
403#define CH_CFG_USE_PIPES TRUE
404#endif
405
406/**
407 * @brief Objects Caches APIs.
408 * @details If enabled then the objects caches APIs are included
409 * in the kernel.
410 *
411 * @note The default is @p TRUE.
412 */
413#if !defined(CH_CFG_USE_OBJ_CACHES)
414#define CH_CFG_USE_OBJ_CACHES TRUE
415#endif
416
417/**
418 * @brief Delegate threads APIs.
419 * @details If enabled then the delegate threads APIs are included
420 * in the kernel.
421 *
422 * @note The default is @p TRUE.
423 */
424#if !defined(CH_CFG_USE_DELEGATES)
425#define CH_CFG_USE_DELEGATES TRUE
426#endif
427
428/**
429 * @brief Jobs Queues APIs.
430 * @details If enabled then the jobs queues APIs are included
431 * in the kernel.
432 *
433 * @note The default is @p TRUE.
434 */
435#if !defined(CH_CFG_USE_JOBS)
436#define CH_CFG_USE_JOBS TRUE
437#endif
438
439/** @} */
440
441/*===========================================================================*/
442/**
443 * @name Objects factory options
444 * @{
445 */
446/*===========================================================================*/
447
448/**
449 * @brief Objects Factory APIs.
450 * @details If enabled then the objects factory APIs are included in the
451 * kernel.
452 *
453 * @note The default is @p FALSE.
454 */
455#if !defined(CH_CFG_USE_FACTORY)
456#define CH_CFG_USE_FACTORY TRUE
457#endif
458
459/**
460 * @brief Maximum length for object names.
461 * @details If the specified length is zero then the name is stored by
462 * pointer but this could have unintended side effects.
463 */
464#if !defined(CH_CFG_FACTORY_MAX_NAMES_LENGTH)
465#define CH_CFG_FACTORY_MAX_NAMES_LENGTH 8
466#endif
467
468/**
469 * @brief Enables the registry of generic objects.
470 */
471#if !defined(CH_CFG_FACTORY_OBJECTS_REGISTRY)
472#define CH_CFG_FACTORY_OBJECTS_REGISTRY TRUE
473#endif
474
475/**
476 * @brief Enables factory for generic buffers.
477 */
478#if !defined(CH_CFG_FACTORY_GENERIC_BUFFERS)
479#define CH_CFG_FACTORY_GENERIC_BUFFERS TRUE
480#endif
481
482/**
483 * @brief Enables factory for semaphores.
484 */
485#if !defined(CH_CFG_FACTORY_SEMAPHORES)
486#define CH_CFG_FACTORY_SEMAPHORES TRUE
487#endif
488
489/**
490 * @brief Enables factory for mailboxes.
491 */
492#if !defined(CH_CFG_FACTORY_MAILBOXES)
493#define CH_CFG_FACTORY_MAILBOXES TRUE
494#endif
495
496/**
497 * @brief Enables factory for objects FIFOs.
498 */
499#if !defined(CH_CFG_FACTORY_OBJ_FIFOS)
500#define CH_CFG_FACTORY_OBJ_FIFOS TRUE
501#endif
502
503/**
504 * @brief Enables factory for Pipes.
505 */
506#if !defined(CH_CFG_FACTORY_PIPES) || defined(__DOXYGEN__)
507#define CH_CFG_FACTORY_PIPES TRUE
508#endif
509
510/** @} */
511
512/*===========================================================================*/
513/**
514 * @name Debug options
515 * @{
516 */
517/*===========================================================================*/
518
519/**
520 * @brief Debug option, kernel statistics.
521 *
522 * @note The default is @p FALSE.
523 */
524#if !defined(CH_DBG_STATISTICS)
525#define CH_DBG_STATISTICS FALSE
526#endif
527
528/**
529 * @brief Debug option, system state check.
530 * @details If enabled the correct call protocol for system APIs is checked
531 * at runtime.
532 *
533 * @note The default is @p FALSE.
534 */
535#if !defined(CH_DBG_SYSTEM_STATE_CHECK)
536#define CH_DBG_SYSTEM_STATE_CHECK TRUE
537#endif
538
539/**
540 * @brief Debug option, parameters checks.
541 * @details If enabled then the checks on the API functions input
542 * parameters are activated.
543 *
544 * @note The default is @p FALSE.
545 */
546#if !defined(CH_DBG_ENABLE_CHECKS)
547#define CH_DBG_ENABLE_CHECKS TRUE
548#endif
549
550/**
551 * @brief Debug option, consistency checks.
552 * @details If enabled then all the assertions in the kernel code are
553 * activated. This includes consistency checks inside the kernel,
554 * runtime anomalies and port-defined checks.
555 *
556 * @note The default is @p FALSE.
557 */
558#if !defined(CH_DBG_ENABLE_ASSERTS)
559#define CH_DBG_ENABLE_ASSERTS TRUE
560#endif
561
562/**
563 * @brief Debug option, trace buffer.
564 * @details If enabled then the trace buffer is activated.
565 *
566 * @note The default is @p CH_DBG_TRACE_MASK_DISABLED.
567 */
568#if !defined(CH_DBG_TRACE_MASK)
569#define CH_DBG_TRACE_MASK CH_DBG_TRACE_MASK_DISABLED
570#endif
571
572/**
573 * @brief Trace buffer entries.
574 * @note The trace buffer is only allocated if @p CH_DBG_TRACE_MASK is
575 * different from @p CH_DBG_TRACE_MASK_DISABLED.
576 */
577#if !defined(CH_DBG_TRACE_BUFFER_SIZE)
578#define CH_DBG_TRACE_BUFFER_SIZE 128
579#endif
580
581/**
582 * @brief Debug option, stack checks.
583 * @details If enabled then a runtime stack check is performed.
584 *
585 * @note The default is @p FALSE.
586 * @note The stack check is performed in a architecture/port dependent way.
587 * It may not be implemented or some ports.
588 * @note The default failure mode is to halt the system with the global
589 * @p panic_msg variable set to @p NULL.
590 */
591#if !defined(CH_DBG_ENABLE_STACK_CHECK)
592#define CH_DBG_ENABLE_STACK_CHECK FALSE
593#endif
594
595/**
596 * @brief Debug option, stacks initialization.
597 * @details If enabled then the threads working area is filled with a byte
598 * value when a thread is created. This can be useful for the
599 * runtime measurement of the used stack.
600 *
601 * @note The default is @p FALSE.
602 */
603#if !defined(CH_DBG_FILL_THREADS)
604#define CH_DBG_FILL_THREADS FALSE
605#endif
606
607/**
608 * @brief Debug option, threads profiling.
609 * @details If enabled then a field is added to the @p thread_t structure that
610 * counts the system ticks occurred while executing the thread.
611 *
612 * @note The default is @p FALSE.
613 * @note This debug option is not currently compatible with the
614 * tickless mode.
615 */
616#if !defined(CH_DBG_THREADS_PROFILING)
617#define CH_DBG_THREADS_PROFILING FALSE
618#endif
619
620/** @} */
621
622/*===========================================================================*/
623/**
624 * @name Kernel hooks
625 * @{
626 */
627/*===========================================================================*/
628
629/**
630 * @brief System structure extension.
631 * @details User fields added to the end of the @p ch_system_t structure.
632 */
633#define CH_CFG_SYSTEM_EXTRA_FIELDS \
634 /* Add threads custom fields here.*/
635
636/**
637 * @brief System initialization hook.
638 * @details User initialization code added to the @p chSysInit() function
639 * just before interrupts are enabled globally.
640 */
641#define CH_CFG_SYSTEM_INIT_HOOK() { \
642 /* Add threads initialization code here.*/ \
643}
644
645/**
646 * @brief Threads descriptor structure extension.
647 * @details User fields added to the end of the @p thread_t structure.
648 */
649#define CH_CFG_THREAD_EXTRA_FIELDS \
650 /* Add threads custom fields here.*/
651
652/**
653 * @brief Threads initialization hook.
654 * @details User initialization code added to the @p _thread_init() function.
655 *
656 * @note It is invoked from within @p _thread_init() and implicitly from all
657 * the threads creation APIs.
658 */
659#define CH_CFG_THREAD_INIT_HOOK(tp) { \
660 /* Add threads initialization code here.*/ \
661}
662
663/**
664 * @brief Threads finalization hook.
665 * @details User finalization code added to the @p chThdExit() API.
666 */
667#define CH_CFG_THREAD_EXIT_HOOK(tp) { \
668 /* Add threads finalization code here.*/ \
669}
670
671/**
672 * @brief Context switch hook.
673 * @details This hook is invoked just before switching between threads.
674 */
675#define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) { \
676 /* Context switch code here.*/ \
677}
678
679/**
680 * @brief ISR enter hook.
681 */
682#define CH_CFG_IRQ_PROLOGUE_HOOK() { \
683 /* IRQ prologue code here.*/ \
684}
685
686/**
687 * @brief ISR exit hook.
688 */
689#define CH_CFG_IRQ_EPILOGUE_HOOK() { \
690 /* IRQ epilogue code here.*/ \
691}
692
693/**
694 * @brief Idle thread enter hook.
695 * @note This hook is invoked within a critical zone, no OS functions
696 * should be invoked from here.
697 * @note This macro can be used to activate a power saving mode.
698 */
699#define CH_CFG_IDLE_ENTER_HOOK() { \
700 /* Idle-enter code here.*/ \
701}
702
703/**
704 * @brief Idle thread leave hook.
705 * @note This hook is invoked within a critical zone, no OS functions
706 * should be invoked from here.
707 * @note This macro can be used to deactivate a power saving mode.
708 */
709#define CH_CFG_IDLE_LEAVE_HOOK() { \
710 /* Idle-leave code here.*/ \
711}
712
713/**
714 * @brief Idle Loop hook.
715 * @details This hook is continuously invoked by the idle thread loop.
716 */
717#define CH_CFG_IDLE_LOOP_HOOK() { \
718 /* Idle loop code here.*/ \
719}
720
721/**
722 * @brief System tick event hook.
723 * @details This hook is invoked in the system tick handler immediately
724 * after processing the virtual timers queue.
725 */
726#define CH_CFG_SYSTEM_TICK_HOOK() { \
727 /* System tick event code here.*/ \
728}
729
730/**
731 * @brief System halt hook.
732 * @details This hook is invoked in case to a system halting error before
733 * the system is halted.
734 */
735#define CH_CFG_SYSTEM_HALT_HOOK(reason) { \
736 /* System halt code here.*/ \
737}
738
739/**
740 * @brief Trace hook.
741 * @details This hook is invoked each time a new record is written in the
742 * trace buffer.
743 */
744#define CH_CFG_TRACE_HOOK(tep) { \
745 /* Trace code here.*/ \
746}
747
748
749/** @} */
750
751/*===========================================================================*/
752/* Port-specific settings (override port settings defaulted in chcore.h). */
753/*===========================================================================*/
754
755#endif /* CHCONF_H */
756
757/** @} */
diff --git a/lib/chibios-contrib/testhal/NRF52/NRF52832/RADIO-ESB/halconf.h b/lib/chibios-contrib/testhal/NRF52/NRF52832/RADIO-ESB/halconf.h
new file mode 100644
index 000000000..2d31dde82
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NRF52/NRF52832/RADIO-ESB/halconf.h
@@ -0,0 +1,533 @@
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 templates/halconf.h
19 * @brief HAL configuration header.
20 * @details HAL configuration file, this file allows to enable or disable the
21 * various device drivers from your application. You may also use
22 * this file in order to override the device drivers default settings.
23 *
24 * @addtogroup HAL_CONF
25 * @{
26 */
27
28#ifndef HALCONF_H
29#define HALCONF_H
30
31#define _CHIBIOS_HAL_CONF_
32#define _CHIBIOS_HAL_CONF_VER_7_1_
33
34#include "mcuconf.h"
35
36/**
37 * @brief Enables the PAL subsystem.
38 */
39#if !defined(HAL_USE_PAL) || defined(__DOXYGEN__)
40#define HAL_USE_PAL TRUE
41#endif
42
43/**
44 * @brief Enables the ADC subsystem.
45 */
46#if !defined(HAL_USE_ADC) || defined(__DOXYGEN__)
47#define HAL_USE_ADC FALSE
48#endif
49
50/**
51 * @brief Enables the CAN subsystem.
52 */
53#if !defined(HAL_USE_CAN) || defined(__DOXYGEN__)
54#define HAL_USE_CAN FALSE
55#endif
56
57/**
58 * @brief Enables the cryptographic subsystem.
59 */
60#if !defined(HAL_USE_CRY) || defined(__DOXYGEN__)
61#define HAL_USE_CRY FALSE
62#endif
63
64/**
65 * @brief Enables the DAC subsystem.
66 */
67#if !defined(HAL_USE_DAC) || defined(__DOXYGEN__)
68#define HAL_USE_DAC FALSE
69#endif
70
71/**
72 * @brief Enables the EFlash subsystem.
73 */
74#if !defined(HAL_USE_EFL) || defined(__DOXYGEN__)
75#define HAL_USE_EFL FALSE
76#endif
77
78/**
79 * @brief Enables the GPT subsystem.
80 */
81#if !defined(HAL_USE_GPT) || defined(__DOXYGEN__)
82#define HAL_USE_GPT FALSE
83#endif
84
85/**
86 * @brief Enables the I2C subsystem.
87 */
88#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__)
89#define HAL_USE_I2C FALSE
90#endif
91
92/**
93 * @brief Enables the I2S subsystem.
94 */
95#if !defined(HAL_USE_I2S) || defined(__DOXYGEN__)
96#define HAL_USE_I2S FALSE
97#endif
98
99/**
100 * @brief Enables the ICU subsystem.
101 */
102#if !defined(HAL_USE_ICU) || defined(__DOXYGEN__)
103#define HAL_USE_ICU FALSE
104#endif
105
106/**
107 * @brief Enables the MAC subsystem.
108 */
109#if !defined(HAL_USE_MAC) || defined(__DOXYGEN__)
110#define HAL_USE_MAC FALSE
111#endif
112
113/**
114 * @brief Enables the MMC_SPI subsystem.
115 */
116#if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__)
117#define HAL_USE_MMC_SPI FALSE
118#endif
119
120/**
121 * @brief Enables the PWM subsystem.
122 */
123#if !defined(HAL_USE_PWM) || defined(__DOXYGEN__)
124#define HAL_USE_PWM FALSE
125#endif
126
127/**
128 * @brief Enables the RTC subsystem.
129 */
130#if !defined(HAL_USE_RTC) || defined(__DOXYGEN__)
131#define HAL_USE_RTC FALSE
132#endif
133
134/**
135 * @brief Enables the SDC subsystem.
136 */
137#if !defined(HAL_USE_SDC) || defined(__DOXYGEN__)
138#define HAL_USE_SDC FALSE
139#endif
140
141/**
142 * @brief Enables the SERIAL subsystem.
143 */
144#if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__)
145#define HAL_USE_SERIAL TRUE
146#endif
147
148/**
149 * @brief Enables the SERIAL over USB subsystem.
150 */
151#if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__)
152#define HAL_USE_SERIAL_USB FALSE
153#endif
154
155/**
156 * @brief Enables the SIO subsystem.
157 */
158#if !defined(HAL_USE_SIO) || defined(__DOXYGEN__)
159#define HAL_USE_SIO FALSE
160#endif
161
162/**
163 * @brief Enables the SPI subsystem.
164 */
165#if !defined(HAL_USE_SPI) || defined(__DOXYGEN__)
166#define HAL_USE_SPI FALSE
167#endif
168
169/**
170 * @brief Enables the TRNG subsystem.
171 */
172#if !defined(HAL_USE_TRNG) || defined(__DOXYGEN__)
173#define HAL_USE_TRNG FALSE
174#endif
175
176/**
177 * @brief Enables the UART subsystem.
178 */
179#if !defined(HAL_USE_UART) || defined(__DOXYGEN__)
180#define HAL_USE_UART FALSE
181#endif
182
183/**
184 * @brief Enables the USB subsystem.
185 */
186#if !defined(HAL_USE_USB) || defined(__DOXYGEN__)
187#define HAL_USE_USB FALSE
188#endif
189
190/**
191 * @brief Enables the WDG subsystem.
192 */
193#if !defined(HAL_USE_WDG) || defined(__DOXYGEN__)
194#define HAL_USE_WDG FALSE
195#endif
196
197/**
198 * @brief Enables the WSPI subsystem.
199 */
200#if !defined(HAL_USE_WSPI) || defined(__DOXYGEN__)
201#define HAL_USE_WSPI FALSE
202#endif
203
204/*===========================================================================*/
205/* PAL driver related settings. */
206/*===========================================================================*/
207
208/**
209 * @brief Enables synchronous APIs.
210 * @note Disabling this option saves both code and data space.
211 */
212#if !defined(PAL_USE_CALLBACKS) || defined(__DOXYGEN__)
213#define PAL_USE_CALLBACKS TRUE
214#endif
215
216/**
217 * @brief Enables synchronous APIs.
218 * @note Disabling this option saves both code and data space.
219 */
220#if !defined(PAL_USE_WAIT) || defined(__DOXYGEN__)
221#define PAL_USE_WAIT TRUE
222#endif
223
224/*===========================================================================*/
225/* ADC driver related settings. */
226/*===========================================================================*/
227
228/**
229 * @brief Enables synchronous APIs.
230 * @note Disabling this option saves both code and data space.
231 */
232#if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__)
233#define ADC_USE_WAIT TRUE
234#endif
235
236/**
237 * @brief Enables the @p adcAcquireBus() and @p adcReleaseBus() APIs.
238 * @note Disabling this option saves both code and data space.
239 */
240#if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
241#define ADC_USE_MUTUAL_EXCLUSION TRUE
242#endif
243
244/*===========================================================================*/
245/* CAN driver related settings. */
246/*===========================================================================*/
247
248/**
249 * @brief Sleep mode related APIs inclusion switch.
250 */
251#if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__)
252#define CAN_USE_SLEEP_MODE TRUE
253#endif
254
255/**
256 * @brief Enforces the driver to use direct callbacks rather than OSAL events.
257 */
258#if !defined(CAN_ENFORCE_USE_CALLBACKS) || defined(__DOXYGEN__)
259#define CAN_ENFORCE_USE_CALLBACKS FALSE
260#endif
261
262/*===========================================================================*/
263/* CRY driver related settings. */
264/*===========================================================================*/
265
266/**
267 * @brief Enables the SW fall-back of the cryptographic driver.
268 * @details When enabled, this option, activates a fall-back software
269 * implementation for algorithms not supported by the underlying
270 * hardware.
271 * @note Fall-back implementations may not be present for all algorithms.
272 */
273#if !defined(HAL_CRY_USE_FALLBACK) || defined(__DOXYGEN__)
274#define HAL_CRY_USE_FALLBACK FALSE
275#endif
276
277/**
278 * @brief Makes the driver forcibly use the fall-back implementations.
279 */
280#if !defined(HAL_CRY_ENFORCE_FALLBACK) || defined(__DOXYGEN__)
281#define HAL_CRY_ENFORCE_FALLBACK FALSE
282#endif
283
284/*===========================================================================*/
285/* DAC driver related settings. */
286/*===========================================================================*/
287
288/**
289 * @brief Enables synchronous APIs.
290 * @note Disabling this option saves both code and data space.
291 */
292#if !defined(DAC_USE_WAIT) || defined(__DOXYGEN__)
293#define DAC_USE_WAIT TRUE
294#endif
295
296/**
297 * @brief Enables the @p dacAcquireBus() and @p dacReleaseBus() APIs.
298 * @note Disabling this option saves both code and data space.
299 */
300#if !defined(DAC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
301#define DAC_USE_MUTUAL_EXCLUSION TRUE
302#endif
303
304/*===========================================================================*/
305/* I2C driver related settings. */
306/*===========================================================================*/
307
308/**
309 * @brief Enables the mutual exclusion APIs on the I2C bus.
310 */
311#if !defined(I2C_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
312#define I2C_USE_MUTUAL_EXCLUSION TRUE
313#endif
314
315/*===========================================================================*/
316/* MAC driver related settings. */
317/*===========================================================================*/
318
319/**
320 * @brief Enables the zero-copy API.
321 */
322#if !defined(MAC_USE_ZERO_COPY) || defined(__DOXYGEN__)
323#define MAC_USE_ZERO_COPY FALSE
324#endif
325
326/**
327 * @brief Enables an event sources for incoming packets.
328 */
329#if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__)
330#define MAC_USE_EVENTS TRUE
331#endif
332
333/*===========================================================================*/
334/* MMC_SPI driver related settings. */
335/*===========================================================================*/
336
337/**
338 * @brief Delays insertions.
339 * @details If enabled this options inserts delays into the MMC waiting
340 * routines releasing some extra CPU time for the threads with
341 * lower priority, this may slow down the driver a bit however.
342 * This option is recommended also if the SPI driver does not
343 * use a DMA channel and heavily loads the CPU.
344 */
345#if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__)
346#define MMC_NICE_WAITING TRUE
347#endif
348
349/*===========================================================================*/
350/* SDC driver related settings. */
351/*===========================================================================*/
352
353/**
354 * @brief Number of initialization attempts before rejecting the card.
355 * @note Attempts are performed at 10mS intervals.
356 */
357#if !defined(SDC_INIT_RETRY) || defined(__DOXYGEN__)
358#define SDC_INIT_RETRY 100
359#endif
360
361/**
362 * @brief Include support for MMC cards.
363 * @note MMC support is not yet implemented so this option must be kept
364 * at @p FALSE.
365 */
366#if !defined(SDC_MMC_SUPPORT) || defined(__DOXYGEN__)
367#define SDC_MMC_SUPPORT FALSE
368#endif
369
370/**
371 * @brief Delays insertions.
372 * @details If enabled this options inserts delays into the MMC waiting
373 * routines releasing some extra CPU time for the threads with
374 * lower priority, this may slow down the driver a bit however.
375 */
376#if !defined(SDC_NICE_WAITING) || defined(__DOXYGEN__)
377#define SDC_NICE_WAITING TRUE
378#endif
379
380/**
381 * @brief OCR initialization constant for V20 cards.
382 */
383#if !defined(SDC_INIT_OCR_V20) || defined(__DOXYGEN__)
384#define SDC_INIT_OCR_V20 0x50FF8000U
385#endif
386
387/**
388 * @brief OCR initialization constant for non-V20 cards.
389 */
390#if !defined(SDC_INIT_OCR) || defined(__DOXYGEN__)
391#define SDC_INIT_OCR 0x80100000U
392#endif
393
394/*===========================================================================*/
395/* SERIAL driver related settings. */
396/*===========================================================================*/
397
398/**
399 * @brief Default bit rate.
400 * @details Configuration parameter, this is the baud rate selected for the
401 * default configuration.
402 */
403#if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__)
404#define SERIAL_DEFAULT_BITRATE 38400
405#endif
406
407/**
408 * @brief Serial buffers size.
409 * @details Configuration parameter, you can change the depth of the queue
410 * buffers depending on the requirements of your application.
411 * @note The default is 16 bytes for both the transmission and receive
412 * buffers.
413 */
414#if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__)
415#define SERIAL_BUFFERS_SIZE 16
416#endif
417
418/*===========================================================================*/
419/* SERIAL_USB driver related setting. */
420/*===========================================================================*/
421
422/**
423 * @brief Serial over USB buffers size.
424 * @details Configuration parameter, the buffer size must be a multiple of
425 * the USB data endpoint maximum packet size.
426 * @note The default is 256 bytes for both the transmission and receive
427 * buffers.
428 */
429#if !defined(SERIAL_USB_BUFFERS_SIZE) || defined(__DOXYGEN__)
430#define SERIAL_USB_BUFFERS_SIZE 256
431#endif
432
433/**
434 * @brief Serial over USB number of buffers.
435 * @note The default is 2 buffers.
436 */
437#if !defined(SERIAL_USB_BUFFERS_NUMBER) || defined(__DOXYGEN__)
438#define SERIAL_USB_BUFFERS_NUMBER 2
439#endif
440
441/*===========================================================================*/
442/* SPI driver related settings. */
443/*===========================================================================*/
444
445/**
446 * @brief Enables synchronous APIs.
447 * @note Disabling this option saves both code and data space.
448 */
449#if !defined(SPI_USE_WAIT) || defined(__DOXYGEN__)
450#define SPI_USE_WAIT TRUE
451#endif
452
453/**
454 * @brief Enables circular transfers APIs.
455 * @note Disabling this option saves both code and data space.
456 */
457#if !defined(SPI_USE_CIRCULAR) || defined(__DOXYGEN__)
458#define SPI_USE_CIRCULAR FALSE
459#endif
460
461/**
462 * @brief Enables the @p spiAcquireBus() and @p spiReleaseBus() APIs.
463 * @note Disabling this option saves both code and data space.
464 */
465#if !defined(SPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
466#define SPI_USE_MUTUAL_EXCLUSION TRUE
467#endif
468
469/**
470 * @brief Handling method for SPI CS line.
471 * @note Disabling this option saves both code and data space.
472 */
473#if !defined(SPI_SELECT_MODE) || defined(__DOXYGEN__)
474#define SPI_SELECT_MODE SPI_SELECT_MODE_PAD
475#endif
476
477/*===========================================================================*/
478/* UART driver related settings. */
479/*===========================================================================*/
480
481/**
482 * @brief Enables synchronous APIs.
483 * @note Disabling this option saves both code and data space.
484 */
485#if !defined(UART_USE_WAIT) || defined(__DOXYGEN__)
486#define UART_USE_WAIT FALSE
487#endif
488
489/**
490 * @brief Enables the @p uartAcquireBus() and @p uartReleaseBus() APIs.
491 * @note Disabling this option saves both code and data space.
492 */
493#if !defined(UART_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
494#define UART_USE_MUTUAL_EXCLUSION FALSE
495#endif
496
497/*===========================================================================*/
498/* USB driver related settings. */
499/*===========================================================================*/
500
501/**
502 * @brief Enables synchronous APIs.
503 * @note Disabling this option saves both code and data space.
504 */
505#if !defined(USB_USE_WAIT) || defined(__DOXYGEN__)
506#define USB_USE_WAIT FALSE
507#endif
508
509/*===========================================================================*/
510/* WSPI driver related settings. */
511/*===========================================================================*/
512
513/**
514 * @brief Enables synchronous APIs.
515 * @note Disabling this option saves both code and data space.
516 */
517#if !defined(WSPI_USE_WAIT) || defined(__DOXYGEN__)
518#define WSPI_USE_WAIT TRUE
519#endif
520
521/**
522 * @brief Enables the @p wspiAcquireBus() and @p wspiReleaseBus() APIs.
523 * @note Disabling this option saves both code and data space.
524 */
525#if !defined(WSPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
526#define WSPI_USE_MUTUAL_EXCLUSION TRUE
527#endif
528
529#include "halconf_community.h"
530
531#endif /* HALCONF_H */
532
533/** @} */
diff --git a/lib/chibios-contrib/testhal/NRF52/NRF52832/RADIO-ESB/halconf_community.h b/lib/chibios-contrib/testhal/NRF52/NRF52832/RADIO-ESB/halconf_community.h
new file mode 100644
index 000000000..43fdbf869
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NRF52/NRF52832/RADIO-ESB/halconf_community.h
@@ -0,0 +1,173 @@
1/*
2 ChibiOS - Copyright (C) 2014 Uladzimir Pylinsky aka barthess
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#ifndef HALCONF_COMMUNITY_H
18#define HALCONF_COMMUNITY_H
19
20/**
21 * @brief Enables the community overlay.
22 */
23#if !defined(HAL_USE_COMMUNITY) || defined(__DOXYGEN__)
24#define HAL_USE_COMMUNITY TRUE
25#endif
26
27/**
28 * @brief Enables the FSMC subsystem.
29 */
30#if !defined(HAL_USE_FSMC) || defined(__DOXYGEN__)
31#define HAL_USE_FSMC FALSE
32#endif
33
34/**
35 * @brief Enables the NAND subsystem.
36 */
37#if !defined(HAL_USE_NAND) || defined(__DOXYGEN__)
38#define HAL_USE_NAND FALSE
39#endif
40
41/**
42 * @brief Enables the 1-wire subsystem.
43 */
44#if !defined(HAL_USE_ONEWIRE) || defined(__DOXYGEN__)
45#define HAL_USE_ONEWIRE FALSE
46#endif
47
48/**
49 * @brief Enables the EICU subsystem.
50 */
51#if !defined(HAL_USE_EICU) || defined(__DOXYGEN__)
52#define HAL_USE_EICU FALSE
53#endif
54
55/**
56 * @brief Enables the CRC subsystem.
57 */
58#if !defined(HAL_USE_CRC) || defined(__DOXYGEN__)
59#define HAL_USE_CRC FALSE
60#endif
61
62/**
63 * @brief Enables the RNG subsystem.
64 */
65#if !defined(HAL_USE_RNG) || defined(__DOXYGEN__)
66#define HAL_USE_RNG FALSE
67#endif
68
69/**
70 * @brief Enables the EEPROM subsystem.
71 */
72#if !defined(HAL_USE_EEPROM) || defined(__DOXYGEN__)
73#define HAL_USE_EEPROM FALSE
74#endif
75
76/**
77 * @brief Enables the TIMCAP subsystem.
78 */
79#if !defined(HAL_USE_TIMCAP) || defined(__DOXYGEN__)
80#define HAL_USE_TIMCAP FALSE
81#endif
82
83/**
84 * @brief Enables the TIMCAP subsystem.
85 */
86#if !defined(HAL_USE_COMP) || defined(__DOXYGEN__)
87#define HAL_USE_COMP FALSE
88#endif
89
90/**
91 * @brief Enables the QEI subsystem.
92 */
93#if !defined(HAL_USE_QEI) || defined(__DOXYGEN__)
94#define HAL_USE_QEI FALSE
95#endif
96
97/**
98 * @brief Enables the USBH subsystem.
99 */
100#if !defined(HAL_USE_USBH) || defined(__DOXYGEN__)
101#define HAL_USE_USBH FALSE
102#endif
103
104/**
105 * @brief Enables the USB_MSD subsystem.
106 */
107#if !defined(HAL_USE_USB_MSD) || defined(__DOXYGEN__)
108#define HAL_USE_USB_MSD FALSE
109#endif
110
111/*===========================================================================*/
112/* FSMCNAND driver related settings. */
113/*===========================================================================*/
114
115/**
116 * @brief Enables the @p nandAcquireBus() and @p nanReleaseBus() APIs.
117 * @note Disabling this option saves both code and data space.
118 */
119#if !defined(NAND_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
120#define NAND_USE_MUTUAL_EXCLUSION TRUE
121#endif
122
123/*===========================================================================*/
124/* 1-wire driver related settings. */
125/*===========================================================================*/
126/**
127 * @brief Enables strong pull up feature.
128 * @note Disabling this option saves both code and data space.
129 */
130#define ONEWIRE_USE_STRONG_PULLUP FALSE
131
132/**
133 * @brief Enables search ROM feature.
134 * @note Disabling this option saves both code and data space.
135 */
136#define ONEWIRE_USE_SEARCH_ROM TRUE
137
138/*===========================================================================*/
139/* QEI driver related settings. */
140/*===========================================================================*/
141
142/**
143 * @brief Enables discard of overlow
144 */
145#if !defined(QEI_USE_OVERFLOW_DISCARD) || defined(__DOXYGEN__)
146#define QEI_USE_OVERFLOW_DISCARD FALSE
147#endif
148
149/**
150 * @brief Enables min max of overlow
151 */
152#if !defined(QEI_USE_OVERFLOW_MINMAX) || defined(__DOXYGEN__)
153#define QEI_USE_OVERFLOW_MINMAX FALSE
154#endif
155
156/*===========================================================================*/
157/* EEProm driver related settings. */
158/*===========================================================================*/
159
160/**
161 * @brief Enables 24xx series I2C eeprom device driver.
162 * @note Disabling this option saves both code and data space.
163 */
164#define EEPROM_USE_EE24XX FALSE
165 /**
166 * @brief Enables 25xx series SPI eeprom device driver.
167 * @note Disabling this option saves both code and data space.
168 */
169#define EEPROM_USE_EE25XX FALSE
170
171#endif /* HALCONF_COMMUNITY_H */
172
173/** @} */
diff --git a/lib/chibios-contrib/testhal/NRF52/NRF52832/RADIO-ESB/main.c b/lib/chibios-contrib/testhal/NRF52/NRF52832/RADIO-ESB/main.c
new file mode 100644
index 000000000..8971fef82
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NRF52/NRF52832/RADIO-ESB/main.c
@@ -0,0 +1,122 @@
1#include <stdint.h>
2#include <string.h>
3#include <stdio.h>
4
5#include "ch.h"
6#include "hal.h"
7#include "chprintf.h"
8
9#include "nrf52_radio.h"
10
11static SerialConfig serial_config = {
12 .speed = 38400,
13 .tx_pad = UART_TX,
14 .rx_pad = UART_RX,
15#if NRF5_SERIAL_USE_HWFLOWCTRL == TRUE
16 .rts_pad = UART_RTS,
17 .cts_pad = UART_CTS,
18#endif
19};
20
21static THD_WORKING_AREA(waLEDThread, 64);
22static THD_FUNCTION(LEDThread, arg) {
23 (void)arg;
24
25 chRegSetThreadName("blinker");
26 palSetPadMode(IOPORT1, LED1, PAL_MODE_OUTPUT_PUSHPULL);
27
28 while (1) {
29 palTogglePad(IOPORT1, LED1);
30 chThdSleepMilliseconds(500);
31 }
32}
33
34static nrf52_config_t radiocfg = {
35 .protocol = NRF52_PROTOCOL_ESB_DPL,
36 .mode = NRF52_MODE_PRX,
37 .bitrate = NRF52_BITRATE_1MBPS,
38 .crc = NRF52_CRC_8BIT,
39 .tx_power = NRF52_TX_POWER_0DBM,
40 .tx_mode = NRF52_TXMODE_MANUAL_START,
41 .selective_auto_ack = false,
42 .retransmit = { 1000, 3 },
43 .payload_length = 0,
44 .address = {
45 .base_addr_p0 = { 0xF3, 0xF3, 0xF3, 0x01 },
46 .base_addr_p1 = { 0x3F, 0x3F, 0x3F, 0x01 },
47 .pipe_prefixes = { 0xF3, 0x3F, },
48 .num_pipes = 2,
49 .addr_length = 5,
50 .rx_pipes = 1 << 0,
51 .rf_channel = 1,
52 },
53};
54
55static uint16_t cnt, fail_pkt, good_pkt;
56static nrf52_payload_t tx_payload = {
57 .pipe = 1,
58};
59static nrf52_payload_t rx_payload;
60
61static THD_WORKING_AREA(waRadioThread, 256);
62static THD_FUNCTION(RadioThread, arg) {
63 (void)arg;
64
65 event_listener_t el;
66 chEvtRegisterMask(&RFD1.eventsrc, &el, EVENT_MASK(0));
67
68 chRegSetThreadName("radio");
69
70 while (1) {
71 chEvtWaitAny(EVENT_MASK(0));
72 eventflags_t flags = chEvtGetAndClearFlags(&el);
73 if (flags & NRF52_EVENT_TX_SUCCESS) {
74 radio_start_rx();
75 good_pkt++;
76 }
77 if (flags & NRF52_EVENT_TX_FAILED) {
78 radio_start_rx();
79 fail_pkt++;
80 }
81 if (flags & NRF52_EVENT_RX_RECEIVED) {
82 memset(rx_payload.data, 0, 32);
83 radio_read_rx_payload(&rx_payload);
84 }
85 }
86}
87
88/**@brief Function for application main entry.
89 */
90int main(void) {
91
92 halInit();
93 chSysInit();
94
95 sdStart(&SD1, &serial_config);
96
97 chThdCreateStatic(waLEDThread, sizeof(waLEDThread), NORMALPRIO, LEDThread, NULL);
98 chThdCreateStatic(waRadioThread, sizeof(waRadioThread), NORMALPRIO, RadioThread, NULL);
99
100 radio_init(&radiocfg);
101 radio_flush_tx();
102 radio_flush_rx();
103 radio_start_rx();
104
105 cnt = good_pkt = fail_pkt = 0;
106
107 while (true) {
108 memset(tx_payload.data, 0, 32);
109 sprintf((char*)tx_payload.data, "counter value=%d" , cnt++);
110 tx_payload.length = strlen((char *)tx_payload.data);
111 radio_stop_rx();
112 radio_write_payload(&tx_payload);
113 radio_start_tx();
114 chprintf((BaseSequentialStream *)&SD1, "packets: good=%d, fail=%d, sent=%s\r\n", good_pkt, fail_pkt, tx_payload.data);
115 chThdSleepMilliseconds(500);
116 if (strlen((char*) rx_payload.data)) {
117 chprintf((BaseSequentialStream *)&SD1, "rssi=%d, received=%s\r\n", rx_payload.rssi, rx_payload.data);
118 rx_payload.data[0] = 0;
119 }
120 }
121}
122
diff --git a/lib/chibios-contrib/testhal/NRF52/NRF52832/RADIO-ESB/mcuconf.h b/lib/chibios-contrib/testhal/NRF52/NRF52832/RADIO-ESB/mcuconf.h
new file mode 100644
index 000000000..96d088556
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NRF52/NRF52832/RADIO-ESB/mcuconf.h
@@ -0,0 +1,28 @@
1/*
2 Copyright (C) 2015 Stephen Caudle
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#ifndef _MCUCONF_H_
18#define _MCUCONF_H_
19
20/*
21 * HAL driver system settings.
22 */
23#define NRF5_SERIAL_USE_UART0 TRUE
24#define NRF5_ST_USE_RTC0 TRUE
25#define NRF5_ST_USE_RTC1 FALSE
26#define NRF5_ST_USE_TIMER0 FALSE
27
28#endif /* _MCUCONF_H_ */
diff --git a/lib/chibios-contrib/testhal/NRF52/NRF52832/RADIO-ESB/nrf52_radio.c b/lib/chibios-contrib/testhal/NRF52/NRF52832/RADIO-ESB/nrf52_radio.c
new file mode 100644
index 000000000..9829935e7
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NRF52/NRF52832/RADIO-ESB/nrf52_radio.c
@@ -0,0 +1,1114 @@
1/* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved.
2 *
3 * The information contained herein is property of Nordic Semiconductor ASA.
4 * Terms and conditions of usage are described in detail in NORDIC
5 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
6 *
7 * Licensees are granted free, non-transferable use of the information. NO
8 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
9 * the file.
10 *
11 * Enhanced ShockBurst proprietary protocol to ChibiOS port
12 *
13 * ported on: 25/10/2018, by andru
14 *
15 */
16
17#include <stdint.h>
18#include <string.h>
19
20#include "ch.h"
21#include "hal.h"
22
23#include "nrf52_radio.h"
24
25
26#define BIT_MASK_UINT_8(x) (0xFF >> (8 - (x)))
27#define NRF52_PIPE_COUNT 9
28
29#define RADIO_SHORTS_COMMON ( RADIO_SHORTS_READY_START_Msk | RADIO_SHORTS_END_DISABLE_Msk | \
30 RADIO_SHORTS_ADDRESS_RSSISTART_Msk | RADIO_SHORTS_DISABLED_RSSISTOP_Msk )
31
32// Constant parameters
33#define RX_WAIT_FOR_ACK_TIMEOUT_US_2MBPS (48) /**< 2MBit RX wait for ack timeout value. Smallest reliable value - 43 */
34#define RX_WAIT_FOR_ACK_TIMEOUT_US_1MBPS (64) /**< 1MBit RX wait for ack timeout value. Smallest reliable value - 59 */
35
36#define NRF52_ADDR_UPDATE_MASK_BASE0 (1 << 0) /*< Mask value to signal updating BASE0 radio address. */
37#define NRF52_ADDR_UPDATE_MASK_BASE1 (1 << 1) /*< Mask value to signal updating BASE1 radio address. */
38#define NRF52_ADDR_UPDATE_MASK_PREFIX (1 << 2) /*< Mask value to signal updating radio prefixes */
39
40#define NRF52_PID_RESET_VALUE 0xFF /**< Invalid PID value which is guaranteed to not collide with any valid PID value. */
41#define NRF52_PID_MAX 3 /**< Maximum value for PID. */
42#define NRF52_CRC_RESET_VALUE 0xFFFF /**< CRC reset value*/
43
44#ifndef NRF52_RADIO_USE_TIMER0
45#define NRF52_RADIO_USE_TIMER0 FALSE
46#endif
47
48#ifndef NRF52_RADIO_USE_TIMER1
49#define NRF52_RADIO_USE_TIMER1 FALSE
50#endif
51
52#ifndef NRF52_RADIO_USE_TIMER2
53#define NRF52_RADIO_USE_TIMER2 FALSE
54#endif
55
56#ifndef NRF52_RADIO_USE_TIMER3
57#define NRF52_RADIO_USE_TIMER3 FALSE
58#endif
59
60#ifndef NRF52_RADIO_USE_TIMER4
61#define NRF52_RADIO_USE_TIMER4 FALSE
62#endif
63
64#ifndef NRF52_RADIO_IRQ_PRIORITY
65#define NRF52_RADIO_IRQ_PRIORITY 3 /**< RADIO interrupt priority. */
66#endif
67
68#ifndef NRF52_RADIO_PPI_TIMER_START
69#error "PPI channel NRF52_RADIO_PPI_TIMER_START need to be defined"
70#endif
71
72#ifndef NRF52_RADIO_PPI_TIMER_STOP
73#error "PPI channel NRF52_RADIO_PPI_TIMER_STOP need to be defined"
74#endif
75
76#ifndef NRF52_RADIO_PPI_RX_TIMEOUT
77#error "PPI channel NRF52_RADIO_PPI_RX_TIMEOUT need to be defined"
78#endif
79
80#ifndef NRF52_RADIO_PPI_TX_START
81#error "PPI channel NRF52_RADIO_PPI_TX_START need to be defined"
82#endif
83
84#if (NRF52_RADIO_USE_TIMER0 == FALSE) && (NRF52_RADIO_USE_TIMER1 == FALSE) && \
85 (NRF52_RADIO_USE_TIMER2 == FALSE) && (NRF52_RADIO_USE_TIMER3 == FALSE) && \
86 (NRF52_RADIO_USE_TIMER4 == FALSE)
87#error "At least one hardware TIMER must be defined"
88#endif
89
90#ifndef NRF52_RADIO_INTTHD_PRIORITY
91#error "Interrupt handle thread priority need to be defined"
92#endif
93
94#ifndef NRF52_RADIO_EVTTHD_PRIORITY
95#error "Event thread priority need to be defined"
96#endif
97
98#define VERIFY_PAYLOAD_LENGTH(p) \
99do \
100{ \
101 if(p->length == 0 || \
102 p->length > NRF52_MAX_PAYLOAD_LENGTH || \
103 (RFD1.config.protocol == NRF52_PROTOCOL_ESB && \
104 p->length > RFD1.config.payload_length)) \
105 { \
106 return NRF52_ERROR_INVALID_LENGTH; \
107 } \
108}while(0)
109
110//Structure holding pipe info PID and CRC and ack payload.
111typedef struct
112{
113 uint16_t m_crc;
114 uint8_t m_pid;
115 uint8_t m_ack_payload;
116} pipe_info_t;
117
118// First in first out queue of payloads to be transmitted.
119typedef struct
120{
121 nrf52_payload_t * p_payload[NRF52_TX_FIFO_SIZE]; /**< Pointer to the actual queue. */
122 uint32_t entry_point; /**< Current start of queue. */
123 uint32_t exit_point; /**< Current end of queue. */
124 uint32_t count; /**< Current number of elements in the queue. */
125} nrf52_payload_tx_fifo_t;
126
127// First in first out queue of received payloads.
128typedef struct
129{
130 nrf52_payload_t * p_payload[NRF52_RX_FIFO_SIZE]; /**< Pointer to the actual queue. */
131 uint32_t entry_point; /**< Current start of queue. */
132 uint32_t exit_point; /**< Current end of queue. */
133 uint32_t count; /**< Current number of elements in the queue. */
134} nrf52_payload_rx_fifo_t;
135
136// These function pointers are changed dynamically, depending on protocol configuration and state.
137//static void (*on_radio_end)(RFDriver *rfp) = NULL;
138static void (*set_rf_payload_format)(RFDriver *rfp, uint32_t payload_length) = NULL;
139
140// The following functions are assigned to the function pointers above.
141static void on_radio_disabled_tx_noack(RFDriver *rfp);
142static void on_radio_disabled_tx(RFDriver *rfp);
143static void on_radio_disabled_tx_wait_for_ack(RFDriver *rfp);
144static void on_radio_disabled_rx(RFDriver *rfp);
145static void on_radio_disabled_rx_ack(RFDriver *rfp);
146
147static volatile uint16_t wait_for_ack_timeout_us;
148static nrf52_payload_t * p_current_payload;
149
150// TX FIFO
151static nrf52_payload_t tx_fifo_payload[NRF52_TX_FIFO_SIZE];
152static nrf52_payload_tx_fifo_t tx_fifo;
153
154// RX FIFO
155static nrf52_payload_t rx_fifo_payload[NRF52_RX_FIFO_SIZE];
156static nrf52_payload_rx_fifo_t rx_fifo;
157
158// Payload buffers
159static uint8_t tx_payload_buffer[NRF52_MAX_PAYLOAD_LENGTH + 2];
160static uint8_t rx_payload_buffer[NRF52_MAX_PAYLOAD_LENGTH + 2];
161
162static uint8_t pids[NRF52_PIPE_COUNT];
163static pipe_info_t rx_pipe_info[NRF52_PIPE_COUNT];
164
165 // disable and events semaphores.
166static binary_semaphore_t disable_sem;
167static binary_semaphore_t events_sem;
168
169RFDriver RFD1;
170
171// Function to do bytewise bit-swap on a unsigned 32 bit value
172static uint32_t bytewise_bit_swap(uint8_t const * p_inp) {
173 uint32_t inp = (*(uint32_t*)p_inp);
174
175 return __REV((uint32_t)__RBIT(inp)); //lint -esym(628, __rev) -esym(526, __rev) -esym(628, __rbit) -esym(526, __rbit) */
176}
177
178// Internal function to convert base addresses from nRF24L type addressing to nRF52 type addressing
179static uint32_t addr_conv(uint8_t const* p_addr) {
180 return __REV(bytewise_bit_swap(p_addr)); //lint -esym(628, __rev) -esym(526, __rev) */
181}
182
183static thread_t *rfEvtThread_p;
184static THD_WORKING_AREA(waRFEvtThread, 128);
185static THD_FUNCTION(rfEvtThread, arg) {
186 (void)arg;
187
188 chRegSetThreadName("rfevent");
189
190 while (!chThdShouldTerminateX()) {
191 chBSemWait(&events_sem);
192
193 nrf52_int_flags_t interrupts = RFD1.flags;
194 RFD1.flags = 0;
195
196 if (interrupts & NRF52_INT_TX_SUCCESS_MSK) {
197 chEvtBroadcastFlags(&RFD1.eventsrc, (eventflags_t) NRF52_EVENT_TX_SUCCESS);
198 }
199 if (interrupts & NRF52_INT_TX_FAILED_MSK) {
200 chEvtBroadcastFlags(&RFD1.eventsrc, (eventflags_t) NRF52_EVENT_TX_FAILED);
201 }
202 if (interrupts & NRF52_INT_RX_DR_MSK) {
203 chEvtBroadcastFlags(&RFD1.eventsrc, (eventflags_t) NRF52_EVENT_RX_RECEIVED);
204 }
205 }
206 chThdExit((msg_t) 0);
207}
208
209static thread_t *rfIntThread_p;
210static THD_WORKING_AREA(waRFIntThread, 128);
211static THD_FUNCTION(rfIntThread, arg) {
212 (void)arg;
213
214 chRegSetThreadName("rfint");
215
216 while (!chThdShouldTerminateX()) {
217 chBSemWait(&disable_sem);
218 switch (RFD1.state) {
219 case NRF52_STATE_PTX_TX:
220 on_radio_disabled_tx_noack(&RFD1);
221 break;
222 case NRF52_STATE_PTX_TX_ACK:
223 on_radio_disabled_tx(&RFD1);
224 break;
225 case NRF52_STATE_PTX_RX_ACK:
226 on_radio_disabled_tx_wait_for_ack(&RFD1);
227 break;
228 case NRF52_STATE_PRX:
229 on_radio_disabled_rx(&RFD1);
230 break;
231 case NRF52_STATE_PRX_SEND_ACK:
232 on_radio_disabled_rx_ack(&RFD1);
233 break;
234 default:
235 break;
236 }
237 }
238 chThdExit((msg_t) 0);
239}
240
241static void serve_radio_interrupt(RFDriver *rfp) {
242 if ((NRF_RADIO->INTENSET & RADIO_INTENSET_READY_Msk) && NRF_RADIO->EVENTS_READY) {
243 NRF_RADIO->EVENTS_READY = 0;
244 (void) NRF_RADIO->EVENTS_READY;
245 }
246 if ((NRF_RADIO->INTENSET & RADIO_INTENSET_DISABLED_Msk) && NRF_RADIO->EVENTS_DISABLED) {
247 NRF_RADIO->EVENTS_DISABLED = 0;
248 (void) NRF_RADIO->EVENTS_DISABLED;
249 chSysLockFromISR();
250 chBSemSignalI(&disable_sem);
251 chSysUnlockFromISR();
252 }
253}
254
255/**
256 * @brief RADIO events interrupt handler.
257 *
258 * @isr
259 */
260OSAL_IRQ_HANDLER(Vector44) {
261
262 OSAL_IRQ_PROLOGUE();
263
264 serve_radio_interrupt(&RFD1);
265
266 OSAL_IRQ_EPILOGUE();
267}
268
269static void set_rf_payload_format_esb_dpl(RFDriver *rfp, uint32_t payload_length) {
270#if (NRF52_MAX_PAYLOAD_LENGTH <= 32)
271 // Using 6 bits for length
272 NRF_RADIO->PCNF0 = (0 << RADIO_PCNF0_S0LEN_Pos) |
273 (6 << RADIO_PCNF0_LFLEN_Pos) |
274 (3 << RADIO_PCNF0_S1LEN_Pos) ;
275#else
276 // Using 8 bits for length
277 NRF_RADIO->PCNF0 = (0 << RADIO_PCNF0_S0LEN_Pos) |
278 (8 << RADIO_PCNF0_LFLEN_Pos) |
279 (3 << RADIO_PCNF0_S1LEN_Pos) ;
280#endif
281 NRF_RADIO->PCNF1 = (RADIO_PCNF1_WHITEEN_Disabled << RADIO_PCNF1_WHITEEN_Pos) |
282 (RADIO_PCNF1_ENDIAN_Big << RADIO_PCNF1_ENDIAN_Pos) |
283 ((rfp->config.address.addr_length - 1) << RADIO_PCNF1_BALEN_Pos) |
284 (0 << RADIO_PCNF1_STATLEN_Pos) |
285 (NRF52_MAX_PAYLOAD_LENGTH << RADIO_PCNF1_MAXLEN_Pos);
286}
287
288static void set_rf_payload_format_esb(RFDriver *rfp, uint32_t payload_length) {
289 NRF_RADIO->PCNF0 = (1 << RADIO_PCNF0_S0LEN_Pos) |
290 (0 << RADIO_PCNF0_LFLEN_Pos) |
291 (1 << RADIO_PCNF0_S1LEN_Pos);
292
293 NRF_RADIO->PCNF1 = (RADIO_PCNF1_WHITEEN_Disabled << RADIO_PCNF1_WHITEEN_Pos) |
294 (RADIO_PCNF1_ENDIAN_Big << RADIO_PCNF1_ENDIAN_Pos) |
295 ((rfp->config.address.addr_length - 1) << RADIO_PCNF1_BALEN_Pos) |
296 (payload_length << RADIO_PCNF1_STATLEN_Pos) |
297 (payload_length << RADIO_PCNF1_MAXLEN_Pos);
298}
299
300/* Set BASE0 and BASE1 addresses & prefixes registers
301 * NRF52 { prefixes[0], base0_addr[0], base0_addr[1], base0_addr[2], base0_addr[3] } ==
302 * NRF24 { addr[0], addr[1], addr[2], addr[3], addr[4] }
303 */
304static void set_addresses(RFDriver *rfp, uint8_t update_mask) {
305 if (update_mask & NRF52_ADDR_UPDATE_MASK_BASE0) {
306 NRF_RADIO->BASE0 = addr_conv(rfp->config.address.base_addr_p0);
307 NRF_RADIO->DAB[0] = addr_conv(rfp->config.address.base_addr_p0);
308 }
309
310 if (update_mask & NRF52_ADDR_UPDATE_MASK_BASE1) {
311 NRF_RADIO->BASE1 = addr_conv(rfp->config.address.base_addr_p1);
312 NRF_RADIO->DAB[1] = addr_conv(rfp->config.address.base_addr_p1);
313 }
314
315 if (update_mask & NRF52_ADDR_UPDATE_MASK_PREFIX) {
316 NRF_RADIO->PREFIX0 = bytewise_bit_swap(&rfp->config.address.pipe_prefixes[0]);
317 NRF_RADIO->DAP[0] = bytewise_bit_swap(&rfp->config.address.pipe_prefixes[0]);
318 NRF_RADIO->PREFIX1 = bytewise_bit_swap(&rfp->config.address.pipe_prefixes[4]);
319 NRF_RADIO->DAP[1] = bytewise_bit_swap(&rfp->config.address.pipe_prefixes[4]);
320 }
321}
322
323static void set_tx_power(RFDriver *rfp) {
324 NRF_RADIO->TXPOWER = rfp->config.tx_power << RADIO_TXPOWER_TXPOWER_Pos;
325}
326
327static void set_bitrate(RFDriver *rfp) {
328 NRF_RADIO->MODE = rfp->config.bitrate << RADIO_MODE_MODE_Pos;
329
330 switch (rfp->config.bitrate) {
331 case NRF52_BITRATE_2MBPS:
332 wait_for_ack_timeout_us = RX_WAIT_FOR_ACK_TIMEOUT_US_2MBPS;
333 break;
334 case NRF52_BITRATE_1MBPS:
335 wait_for_ack_timeout_us = RX_WAIT_FOR_ACK_TIMEOUT_US_1MBPS;
336 break;
337 }
338}
339
340static void set_protocol(RFDriver *rfp) {
341 switch (rfp->config.protocol) {
342 case NRF52_PROTOCOL_ESB_DPL:
343 set_rf_payload_format = set_rf_payload_format_esb_dpl;
344 break;
345 case NRF52_PROTOCOL_ESB:
346 set_rf_payload_format = set_rf_payload_format_esb;
347 break;
348 }
349}
350
351static void set_crc(RFDriver *rfp) {
352 NRF_RADIO->CRCCNF = rfp->config.crc << RADIO_CRCCNF_LEN_Pos;
353
354 if (rfp->config.crc == RADIO_CRCCNF_LEN_Two)
355 {
356 NRF_RADIO->CRCINIT = 0xFFFFUL; // Initial value
357 NRF_RADIO->CRCPOLY = 0x11021UL; // CRC poly: x^16+x^12^x^5+1
358 }
359 else if (rfp->config.crc == RADIO_CRCCNF_LEN_One)
360 {
361 NRF_RADIO->CRCINIT = 0xFFUL; // Initial value
362 NRF_RADIO->CRCPOLY = 0x107UL; // CRC poly: x^8+x^2^x^1+1
363 }
364}
365
366static void ppi_init(RFDriver *rfp) {
367 NRF_PPI->CH[NRF52_RADIO_PPI_TIMER_START].EEP = (uint32_t)&NRF_RADIO->EVENTS_READY;
368 NRF_PPI->CH[NRF52_RADIO_PPI_TIMER_START].TEP = (uint32_t)&rfp->timer->TASKS_START;
369
370 NRF_PPI->CH[NRF52_RADIO_PPI_TIMER_STOP].EEP = (uint32_t)&NRF_RADIO->EVENTS_ADDRESS;
371 NRF_PPI->CH[NRF52_RADIO_PPI_TIMER_STOP].TEP = (uint32_t)&rfp->timer->TASKS_STOP;
372
373 NRF_PPI->CH[NRF52_RADIO_PPI_RX_TIMEOUT].EEP = (uint32_t)&rfp->timer->EVENTS_COMPARE[0];
374 NRF_PPI->CH[NRF52_RADIO_PPI_RX_TIMEOUT].TEP = (uint32_t)&NRF_RADIO->TASKS_DISABLE;
375
376 NRF_PPI->CH[NRF52_RADIO_PPI_TX_START].EEP = (uint32_t)&rfp->timer->EVENTS_COMPARE[1];
377 NRF_PPI->CH[NRF52_RADIO_PPI_TX_START].TEP = (uint32_t)&NRF_RADIO->TASKS_TXEN;
378}
379
380static void set_parameters(RFDriver *rfp) {
381 set_tx_power(rfp);
382 set_bitrate(rfp);
383 set_protocol(rfp);
384 set_crc(rfp);
385 set_rf_payload_format(rfp, rfp->config.payload_length);
386}
387
388static void reset_fifo(void) {
389 tx_fifo.entry_point = 0;
390 tx_fifo.exit_point = 0;
391 tx_fifo.count = 0;
392
393 rx_fifo.entry_point = 0;
394 rx_fifo.exit_point = 0;
395 rx_fifo.count = 0;
396}
397
398static void init_fifo(void) {
399 reset_fifo();
400
401 for (int i = 0; i < NRF52_TX_FIFO_SIZE; i++) {
402 tx_fifo.p_payload[i] = &tx_fifo_payload[i];
403 }
404
405 for (int i = 0; i < NRF52_RX_FIFO_SIZE; i++) {
406 rx_fifo.p_payload[i] = &rx_fifo_payload[i];
407 }
408}
409
410static void tx_fifo_remove_last(void) {
411 if (tx_fifo.count > 0) {
412 nvicDisableVector(RADIO_IRQn);
413
414 tx_fifo.count--;
415 if (++tx_fifo.exit_point >= NRF52_TX_FIFO_SIZE) {
416 tx_fifo.exit_point = 0;
417 }
418
419 nvicEnableVector(RADIO_IRQn, NRF52_RADIO_IRQ_PRIORITY);
420 }
421}
422
423/** @brief Function to push the content of the rx_buffer to the RX FIFO.
424 *
425 * The module will point the register NRF_RADIO->PACKETPTR to a buffer for receiving packets.
426 * After receiving a packet the module will call this function to copy the received data to
427 * the RX FIFO.
428 *
429 * @param pipe Pipe number to set for the packet.
430 * @param pid Packet ID.
431 *
432 * @retval true Operation successful.
433 * @retval false Operation failed.
434 */
435static bool rx_fifo_push_rfbuf(RFDriver *rfp, uint8_t pipe, uint8_t pid) {
436 if (rx_fifo.count < NRF52_RX_FIFO_SIZE) {
437 if (rfp->config.protocol == NRF52_PROTOCOL_ESB_DPL) {
438 if (rx_payload_buffer[0] > NRF52_MAX_PAYLOAD_LENGTH) {
439 return false;
440 }
441
442 rx_fifo.p_payload[rx_fifo.entry_point]->length = rx_payload_buffer[0];
443 }
444 else if (rfp->state == NRF52_STATE_PTX_RX_ACK) {
445 // Received packet is an acknowledgment
446 rx_fifo.p_payload[rx_fifo.entry_point]->length = 0;
447 }
448 else {
449 rx_fifo.p_payload[rx_fifo.entry_point]->length = rfp->config.payload_length;
450 }
451
452 memcpy(rx_fifo.p_payload[rx_fifo.entry_point]->data, &rx_payload_buffer[2],
453 rx_fifo.p_payload[rx_fifo.entry_point]->length);
454
455 rx_fifo.p_payload[rx_fifo.entry_point]->pipe = pipe;
456 rx_fifo.p_payload[rx_fifo.entry_point]->rssi = NRF_RADIO->RSSISAMPLE;
457 rx_fifo.p_payload[rx_fifo.entry_point]->pid = pid;
458 if (++rx_fifo.entry_point >= NRF52_RX_FIFO_SIZE) {
459 rx_fifo.entry_point = 0;
460 }
461 rx_fifo.count++;
462
463 return true;
464 }
465
466 return false;
467}
468
469static void timer_init(RFDriver *rfp) {
470 // Configure the system timer with a 1 MHz base frequency
471 rfp->timer->PRESCALER = 4;
472 rfp->timer->BITMODE = TIMER_BITMODE_BITMODE_16Bit;
473 rfp->timer->SHORTS = TIMER_SHORTS_COMPARE1_CLEAR_Msk | TIMER_SHORTS_COMPARE1_STOP_Msk;
474}
475
476static void start_tx_transaction(RFDriver *rfp) {
477 bool ack;
478
479 rfp->tx_attempt = 1;
480 rfp->tx_remaining = rfp->config.retransmit.count;
481
482 // Prepare the payload
483 p_current_payload = tx_fifo.p_payload[tx_fifo.exit_point];
484
485 // Handling ack if noack is set to false or if selctive auto ack is turned turned off
486 ack = !p_current_payload->noack || !rfp->config.selective_auto_ack;
487
488 switch (rfp->config.protocol) {
489 case NRF52_PROTOCOL_ESB:
490 set_rf_payload_format(rfp, p_current_payload->length);
491 tx_payload_buffer[0] = p_current_payload->pid;
492 tx_payload_buffer[1] = 0;
493 memcpy(&tx_payload_buffer[2], p_current_payload->data, p_current_payload->length);
494
495 NRF_RADIO->SHORTS = RADIO_SHORTS_COMMON | RADIO_SHORTS_DISABLED_RXEN_Msk;
496 NRF_RADIO->INTENSET = RADIO_INTENSET_DISABLED_Msk | RADIO_INTENSET_READY_Msk;
497
498 // Configure the retransmit counter
499 rfp->tx_remaining = rfp->config.retransmit.count;
500 rfp->state = NRF52_STATE_PTX_TX_ACK;
501 break;
502
503 case NRF52_PROTOCOL_ESB_DPL:
504 tx_payload_buffer[0] = p_current_payload->length;
505 tx_payload_buffer[1] = p_current_payload->pid << 1;
506 tx_payload_buffer[1] |= ack ? 0x00 : 0x01;
507 memcpy(&tx_payload_buffer[2], p_current_payload->data, p_current_payload->length);
508
509 if (ack) {
510 NRF_RADIO->SHORTS = RADIO_SHORTS_COMMON | RADIO_SHORTS_DISABLED_RXEN_Msk;
511 NRF_RADIO->INTENSET = RADIO_INTENSET_DISABLED_Msk | RADIO_INTENSET_READY_Msk;
512
513 // Configure the retransmit counter
514 rfp->tx_remaining = rfp->config.retransmit.count;
515 rfp->state = NRF52_STATE_PTX_TX_ACK;
516 }
517 else {
518 NRF_RADIO->SHORTS = RADIO_SHORTS_COMMON;
519 NRF_RADIO->INTENSET = RADIO_INTENSET_DISABLED_Msk;
520 rfp->state = NRF52_STATE_PTX_TX;
521 }
522 break;
523 }
524
525 NRF_RADIO->TXADDRESS = p_current_payload->pipe;
526 NRF_RADIO->RXADDRESSES = 1 << p_current_payload->pipe;
527
528 NRF_RADIO->FREQUENCY = rfp->config.address.rf_channel;
529 NRF_RADIO->PACKETPTR = (uint32_t)tx_payload_buffer;
530
531 NRF_RADIO->EVENTS_READY = 0;
532 NRF_RADIO->EVENTS_DISABLED = 0;
533 (void)NRF_RADIO->EVENTS_READY;
534 (void)NRF_RADIO->EVENTS_DISABLED;
535
536 nvicClearPending(RADIO_IRQn);
537 nvicEnableVector(RADIO_IRQn, NRF52_RADIO_IRQ_PRIORITY);
538
539 NRF_RADIO->TASKS_TXEN = 1;
540}
541
542static void on_radio_disabled_tx_noack(RFDriver *rfp) {
543 rfp->flags |= NRF52_INT_TX_SUCCESS_MSK;
544 tx_fifo_remove_last();
545
546 chBSemSignal(&events_sem);
547
548 if (tx_fifo.count == 0) {
549 rfp->state = NRF52_STATE_IDLE;
550 }
551 else {
552 start_tx_transaction(rfp);
553 }
554}
555
556static void on_radio_disabled_tx(RFDriver *rfp) {
557 // Remove the DISABLED -> RXEN shortcut, to make sure the radio stays
558 // disabled after the RX window
559 NRF_RADIO->SHORTS = RADIO_SHORTS_COMMON;
560
561 // Make sure the timer is started the next time the radio is ready,
562 // and that it will disable the radio automatically if no packet is
563 // received by the time defined in m_wait_for_ack_timeout_us
564 rfp->timer->CC[0] = wait_for_ack_timeout_us + 130;
565 rfp->timer->CC[1] = rfp->config.retransmit.delay - 130;
566 rfp->timer->TASKS_CLEAR = 1;
567 rfp->timer->EVENTS_COMPARE[0] = 0;
568 rfp->timer->EVENTS_COMPARE[1] = 0;
569 (void)rfp->timer->EVENTS_COMPARE[0];
570 (void)rfp->timer->EVENTS_COMPARE[1];
571
572 NRF_PPI->CHENSET = (1 << NRF52_RADIO_PPI_TIMER_START) |
573 (1 << NRF52_RADIO_PPI_RX_TIMEOUT) |
574 (1 << NRF52_RADIO_PPI_TIMER_STOP);
575 NRF_PPI->CHENCLR = (1 << NRF52_RADIO_PPI_TX_START);
576
577 NRF_RADIO->EVENTS_END = 0;
578 (void)NRF_RADIO->EVENTS_END;
579
580 if (rfp->config.protocol == NRF52_PROTOCOL_ESB) {
581 set_rf_payload_format(rfp, 0);
582 }
583
584 NRF_RADIO->PACKETPTR = (uint32_t)rx_payload_buffer;
585 rfp->state = NRF52_STATE_PTX_RX_ACK;
586}
587
588static void on_radio_disabled_tx_wait_for_ack(RFDriver *rfp) {
589 // This marks the completion of a TX_RX sequence (TX with ACK)
590
591 // Make sure the timer will not deactivate the radio if a packet is received
592 NRF_PPI->CHENCLR = (1 << NRF52_RADIO_PPI_TIMER_START) |
593 (1 << NRF52_RADIO_PPI_RX_TIMEOUT) |
594 (1 << NRF52_RADIO_PPI_TIMER_STOP);
595
596 // If the radio has received a packet and the CRC status is OK
597 if (NRF_RADIO->EVENTS_END && NRF_RADIO->CRCSTATUS != 0) {
598 rfp->timer->TASKS_STOP = 1;
599 NRF_PPI->CHENCLR = (1 << NRF52_RADIO_PPI_TX_START);
600 rfp->flags |= NRF52_INT_TX_SUCCESS_MSK;
601 rfp->tx_attempt++;// = rfp->config.retransmit.count - rfp->tx_remaining + 1;
602
603 tx_fifo_remove_last();
604
605 if (rfp->config.protocol != NRF52_PROTOCOL_ESB && rx_payload_buffer[0] > 0) {
606 if (rx_fifo_push_rfbuf(rfp, (uint8_t)NRF_RADIO->TXADDRESS, 0)) {
607 rfp->flags |= NRF52_INT_RX_DR_MSK;
608 }
609 }
610
611 chBSemSignal(&events_sem);
612
613 if ((tx_fifo.count == 0) || (rfp->config.tx_mode == NRF52_TXMODE_MANUAL)) {
614 rfp->state = NRF52_STATE_IDLE;
615 }
616 else {
617 start_tx_transaction(rfp);
618 }
619 }
620 else {
621 if (rfp->tx_remaining-- == 0) {
622 rfp->timer->TASKS_STOP = 1;
623 NRF_PPI->CHENCLR = (1 << NRF52_RADIO_PPI_TX_START);
624 // All retransmits are expended, and the TX operation is suspended
625 rfp->tx_attempt = rfp->config.retransmit.count + 1;
626 rfp->flags |= NRF52_INT_TX_FAILED_MSK;
627
628 chBSemSignal(&events_sem);
629
630 rfp->state = NRF52_STATE_IDLE;
631 }
632 else {
633 // There are still have more retransmits left, TX mode should be
634 // entered again as soon as the system timer reaches CC[1].
635 NRF_RADIO->SHORTS = RADIO_SHORTS_COMMON | RADIO_SHORTS_DISABLED_RXEN_Msk;
636 set_rf_payload_format(rfp, p_current_payload->length);
637 NRF_RADIO->PACKETPTR = (uint32_t)tx_payload_buffer;
638 rfp->state = NRF52_STATE_PTX_TX_ACK;
639 rfp->timer->TASKS_START = 1;
640 NRF_PPI->CHENSET = (1 << NRF52_RADIO_PPI_TX_START);
641 if (rfp->timer->EVENTS_COMPARE[1])
642 NRF_RADIO->TASKS_TXEN = 1;
643 }
644 }
645}
646
647static void clear_events_restart_rx(RFDriver *rfp) {
648 NRF_RADIO->SHORTS = RADIO_SHORTS_COMMON;
649 set_rf_payload_format(rfp, rfp->config.payload_length);
650 NRF_RADIO->PACKETPTR = (uint32_t)rx_payload_buffer;
651
652 NRF_RADIO->INTENCLR = RADIO_INTENCLR_DISABLED_Msk;
653 NRF_RADIO->EVENTS_DISABLED = 0;
654 (void) NRF_RADIO->EVENTS_DISABLED;
655
656 NRF_RADIO->TASKS_DISABLE = 1;
657 while (NRF_RADIO->EVENTS_DISABLED == 0);
658
659 NRF_RADIO->EVENTS_DISABLED = 0;
660 (void) NRF_RADIO->EVENTS_DISABLED;
661 NRF_RADIO->INTENSET = RADIO_INTENSET_DISABLED_Msk;
662
663 NRF_RADIO->SHORTS = RADIO_SHORTS_COMMON | RADIO_SHORTS_DISABLED_TXEN_Msk;
664 NRF_RADIO->TASKS_RXEN = 1;
665}
666
667static void on_radio_disabled_rx(RFDriver *rfp) {
668 bool ack = false;
669 bool retransmit_payload = false;
670 bool send_rx_event = true;
671 pipe_info_t * p_pipe_info;
672
673 if (NRF_RADIO->CRCSTATUS == 0) {
674 clear_events_restart_rx(rfp);
675 return;
676 }
677
678 if(rx_fifo.count >= NRF52_RX_FIFO_SIZE) {
679 clear_events_restart_rx(rfp);
680 return;
681 }
682
683 p_pipe_info = &rx_pipe_info[NRF_RADIO->RXMATCH];
684 if (NRF_RADIO->RXCRC == p_pipe_info->m_crc &&
685 (rx_payload_buffer[1] >> 1) == p_pipe_info->m_pid ) {
686 retransmit_payload = true;
687 send_rx_event = false;
688 }
689
690 p_pipe_info->m_pid = rx_payload_buffer[1] >> 1;
691 p_pipe_info->m_crc = NRF_RADIO->RXCRC;
692
693 if(rfp->config.selective_auto_ack == false || ((rx_payload_buffer[1] & 0x01) == 0))
694 ack = true;
695
696 if(ack) {
697 NRF_RADIO->SHORTS = RADIO_SHORTS_COMMON | RADIO_SHORTS_DISABLED_RXEN_Msk;
698
699 switch(rfp->config.protocol) {
700 case NRF52_PROTOCOL_ESB_DPL:
701 {
702 if (tx_fifo.count > 0 &&
703 (tx_fifo.p_payload[tx_fifo.exit_point]->pipe == NRF_RADIO->RXMATCH))
704 {
705 // Pipe stays in ACK with payload until TX fifo is empty
706 // Do not report TX success on first ack payload or retransmit
707 if (p_pipe_info->m_ack_payload != 0 && !retransmit_payload) {
708 if(++tx_fifo.exit_point >= NRF52_TX_FIFO_SIZE) {
709 tx_fifo.exit_point = 0;
710 }
711
712 tx_fifo.count--;
713
714 // ACK payloads also require TX_DS
715 // (page 40 of the 'nRF24LE1_Product_Specification_rev1_6.pdf').
716 rfp->flags |= NRF52_INT_TX_SUCCESS_MSK;
717 }
718
719 p_pipe_info->m_ack_payload = 1;
720
721 p_current_payload = tx_fifo.p_payload[tx_fifo.exit_point];
722
723 set_rf_payload_format(rfp, p_current_payload->length);
724 tx_payload_buffer[0] = p_current_payload->length;
725 memcpy(&tx_payload_buffer[2],
726 p_current_payload->data,
727 p_current_payload->length);
728 }
729 else {
730 p_pipe_info->m_ack_payload = 0;
731 set_rf_payload_format(rfp, 0);
732 tx_payload_buffer[0] = 0;
733 }
734
735 tx_payload_buffer[1] = rx_payload_buffer[1];
736 }
737 break;
738
739 case NRF52_PROTOCOL_ESB:
740 {
741 set_rf_payload_format(rfp, 0);
742 tx_payload_buffer[0] = rx_payload_buffer[0];
743 tx_payload_buffer[1] = 0;
744 }
745 break;
746 }
747
748 rfp->state = NRF52_STATE_PRX_SEND_ACK;
749 NRF_RADIO->TXADDRESS = NRF_RADIO->RXMATCH;
750 NRF_RADIO->PACKETPTR = (uint32_t)tx_payload_buffer;
751 }
752 else {
753 clear_events_restart_rx(rfp);
754 }
755
756 if (send_rx_event) {
757 // Push the new packet to the RX buffer and trigger a received event if the operation was
758 // successful.
759 if (rx_fifo_push_rfbuf(rfp, NRF_RADIO->RXMATCH, p_pipe_info->m_pid)) {
760 rfp->flags |= NRF52_INT_RX_DR_MSK;
761 chBSemSignal(&events_sem);
762 }
763 }
764}
765
766static void on_radio_disabled_rx_ack(RFDriver *rfp) {
767 NRF_RADIO->SHORTS = RADIO_SHORTS_COMMON | RADIO_SHORTS_DISABLED_TXEN_Msk;
768 set_rf_payload_format(rfp, rfp->config.payload_length);
769
770 NRF_RADIO->PACKETPTR = (uint32_t)rx_payload_buffer;
771
772 rfp->state = NRF52_STATE_PRX;
773}
774
775nrf52_error_t radio_disable(void) {
776 NRF_RADIO->SHORTS = 0;
777 NRF_RADIO->INTENCLR = 0xFFFFFFFF;
778
779 nvicDisableVector(RADIO_IRQn);
780
781 NRF_RADIO->EVENTS_DISABLED = 0;
782 (void) NRF_RADIO->EVENTS_DISABLED;
783
784 NRF_RADIO->TASKS_STOP = 1;
785 NRF_RADIO->TASKS_DISABLE = 1;
786
787 RFD1.state = NRF52_STATE_IDLE;
788
789 // Clear PPI
790 NRF_PPI->CHENCLR = (1 << NRF52_RADIO_PPI_TIMER_START) |
791 (1 << NRF52_RADIO_PPI_TIMER_STOP) |
792 (1 << NRF52_RADIO_PPI_RX_TIMEOUT) |
793 (1 << NRF52_RADIO_PPI_TX_START);
794
795 reset_fifo();
796
797 memset(rx_pipe_info, 0, sizeof(rx_pipe_info));
798 memset(pids, 0, sizeof(pids));
799
800 // Terminate interrupts handle thread
801 chThdTerminate(rfIntThread_p);
802 chBSemSignal(&disable_sem);
803 chThdWait(rfIntThread_p);
804
805 // Terminate events handle thread
806 chThdTerminate(rfEvtThread_p);
807 RFD1.flags = 0;
808 chBSemSignal(&events_sem);
809 chThdWait(rfEvtThread_p);
810
811 RFD1.state = NRF52_STATE_UNINIT;
812
813 return NRF52_SUCCESS;
814}
815
816//
817nrf52_error_t radio_init(nrf52_config_t const *config) {
818 osalDbgAssert(config != NULL,
819 "config must be defined");
820 osalDbgAssert(&config->address != NULL,
821 "address must be defined");
822 osalDbgAssert(NRF52_RADIO_IRQ_PRIORITY <= 7,
823 "wrong radio irq priority");
824
825 if (RFD1.state != NRF52_STATE_UNINIT) {
826 nrf52_error_t err = radio_disable();
827 if (err != NRF52_SUCCESS)
828 return err;
829 }
830
831 RFD1.radio = NRF_RADIO;
832 RFD1.config = *config;
833 RFD1.flags = 0;
834
835 init_fifo();
836
837#if NRF52_RADIO_USE_TIMER0
838 RFD1.timer = NRF_TIMER0;
839#endif
840#if NRF52_RADIO_USE_TIMER1
841 RFD1.timer = NRF_TIMER1;
842#endif
843#if NRF52_RADIO_USE_TIMER2
844 RFD1.timer = NRF_TIMER2;
845#endif
846#if NRF52_RADIO_USE_TIMER3
847 RFD1.timer = NRF_TIMER3;
848#endif
849#if NRF52_RADIO_USE_TIMER4
850 RFD1.timer = NRF_TIMER4;
851#endif
852
853 set_parameters(&RFD1);
854
855 set_addresses(&RFD1, NRF52_ADDR_UPDATE_MASK_BASE0);
856 set_addresses(&RFD1, NRF52_ADDR_UPDATE_MASK_BASE1);
857 set_addresses(&RFD1, NRF52_ADDR_UPDATE_MASK_PREFIX);
858
859 ppi_init(&RFD1);
860 timer_init(&RFD1);
861
862 chBSemObjectInit(&disable_sem, TRUE);
863 chBSemObjectInit(&events_sem, TRUE);
864
865 chEvtObjectInit(&RFD1.eventsrc);
866
867 // interrupt handle thread
868 rfIntThread_p = chThdCreateStatic(waRFIntThread, sizeof(waRFIntThread),
869 NRF52_RADIO_INTTHD_PRIORITY, rfIntThread, NULL);
870
871 // events handle thread
872 rfEvtThread_p = chThdCreateStatic(waRFEvtThread, sizeof(waRFEvtThread),
873 NRF52_RADIO_EVTTHD_PRIORITY, rfEvtThread, NULL);
874
875 nvicEnableVector(RADIO_IRQn, NRF52_RADIO_IRQ_PRIORITY);
876
877 RFD1.state = NRF52_STATE_IDLE;
878
879 return NRF52_SUCCESS;
880}
881
882nrf52_error_t radio_write_payload(nrf52_payload_t const * p_payload) {
883 if (RFD1.state == NRF52_STATE_UNINIT)
884 return NRF52_INVALID_STATE;
885 if(p_payload == NULL)
886 return NRF52_ERROR_NULL;
887 VERIFY_PAYLOAD_LENGTH(p_payload);
888 if (tx_fifo.count >= NRF52_TX_FIFO_SIZE)
889 return NRF52_ERROR_INVALID_LENGTH;
890
891 if (RFD1.config.mode == NRF52_MODE_PTX &&
892 p_payload->noack && !RFD1.config.selective_auto_ack )
893 {
894 return NRF52_ERROR_NOT_SUPPORTED;
895 }
896
897 nvicDisableVector(RADIO_IRQn);
898
899 memcpy(tx_fifo.p_payload[tx_fifo.entry_point], p_payload, sizeof(nrf52_payload_t));
900
901 pids[p_payload->pipe] = (pids[p_payload->pipe] + 1) % (NRF52_PID_MAX + 1);
902 tx_fifo.p_payload[tx_fifo.entry_point]->pid = pids[p_payload->pipe];
903
904 if (++tx_fifo.entry_point >= NRF52_TX_FIFO_SIZE) {
905 tx_fifo.entry_point = 0;
906 }
907
908 tx_fifo.count++;
909
910 nvicEnableVector(RADIO_IRQn, NRF52_RADIO_IRQ_PRIORITY);
911
912 if (RFD1.config.mode == NRF52_MODE_PTX &&
913 RFD1.config.tx_mode == NRF52_TXMODE_AUTO &&
914 RFD1.state == NRF52_STATE_IDLE)
915 {
916 start_tx_transaction(&RFD1);
917 }
918
919 return NRF52_SUCCESS;
920}
921
922nrf52_error_t radio_read_rx_payload(nrf52_payload_t * p_payload) {
923 if (RFD1.state == NRF52_STATE_UNINIT)
924 return NRF52_INVALID_STATE;
925 if (p_payload == NULL)
926 return NRF52_ERROR_NULL;
927
928 if (rx_fifo.count == 0) {
929 return NRF52_ERROR_INVALID_LENGTH;
930 }
931
932 nvicDisableVector(RADIO_IRQn);
933
934 p_payload->length = rx_fifo.p_payload[rx_fifo.exit_point]->length;
935 p_payload->pipe = rx_fifo.p_payload[rx_fifo.exit_point]->pipe;
936 p_payload->rssi = rx_fifo.p_payload[rx_fifo.exit_point]->rssi;
937 p_payload->pid = rx_fifo.p_payload[rx_fifo.exit_point]->pid;
938 memcpy(p_payload->data, rx_fifo.p_payload[rx_fifo.exit_point]->data, p_payload->length);
939
940 if (++rx_fifo.exit_point >= NRF52_RX_FIFO_SIZE) {
941 rx_fifo.exit_point = 0;
942 }
943
944 rx_fifo.count--;
945
946 nvicEnableVector(RADIO_IRQn, NRF52_RADIO_IRQ_PRIORITY);
947
948 return NRF52_SUCCESS;
949}
950
951nrf52_error_t radio_start_tx(void) {
952 if (RFD1.state != NRF52_STATE_IDLE)
953 return NRF52_ERROR_BUSY;
954
955 if (tx_fifo.count == 0) {
956 return NRF52_ERROR_INVALID_LENGTH;
957 }
958
959 start_tx_transaction(&RFD1);
960
961 return NRF52_SUCCESS;
962}
963
964nrf52_error_t radio_start_rx(void) {
965 if (RFD1.state != NRF52_STATE_IDLE)
966 return NRF52_ERROR_BUSY;
967
968 NRF_RADIO->INTENCLR = 0xFFFFFFFF;
969 NRF_RADIO->EVENTS_DISABLED = 0;
970 (void) NRF_RADIO->EVENTS_DISABLED;
971
972 NRF_RADIO->SHORTS = RADIO_SHORTS_COMMON | RADIO_SHORTS_DISABLED_TXEN_Msk;
973 NRF_RADIO->INTENSET = RADIO_INTENSET_DISABLED_Msk;
974 RFD1.state = NRF52_STATE_PRX;
975
976 NRF_RADIO->RXADDRESSES = RFD1.config.address.rx_pipes;
977 NRF_RADIO->FREQUENCY = RFD1.config.address.rf_channel;
978 NRF_RADIO->PACKETPTR = (uint32_t)rx_payload_buffer;
979
980 nvicClearPending(RADIO_IRQn);
981 nvicEnableVector(RADIO_IRQn, NRF52_RADIO_IRQ_PRIORITY);
982
983 NRF_RADIO->EVENTS_ADDRESS = 0;
984 NRF_RADIO->EVENTS_PAYLOAD = 0;
985 NRF_RADIO->EVENTS_DISABLED = 0;
986 (void) NRF_RADIO->EVENTS_ADDRESS;
987 (void) NRF_RADIO->EVENTS_PAYLOAD;
988 (void) NRF_RADIO->EVENTS_DISABLED;
989
990 NRF_RADIO->TASKS_RXEN = 1;
991
992 return NRF52_SUCCESS;
993}
994
995nrf52_error_t radio_stop_rx(void) {
996 if (RFD1.state != NRF52_STATE_PRX) {
997 return NRF52_INVALID_STATE;
998 }
999
1000 NRF_RADIO->SHORTS = 0;
1001 NRF_RADIO->INTENCLR = 0xFFFFFFFF;
1002 NRF_RADIO->EVENTS_DISABLED = 0;
1003 (void) NRF_RADIO->EVENTS_DISABLED;
1004 NRF_RADIO->TASKS_DISABLE = 1;
1005 while (NRF_RADIO->EVENTS_DISABLED == 0);
1006 RFD1.state = NRF52_STATE_IDLE;
1007
1008 return NRF52_SUCCESS;
1009}
1010
1011nrf52_error_t radio_flush_tx(void) {
1012 if (RFD1.state == NRF52_STATE_UNINIT)
1013 return NRF52_INVALID_STATE;
1014
1015 nvicDisableVector(RADIO_IRQn);
1016
1017 tx_fifo.count = 0;
1018 tx_fifo.entry_point = 0;
1019 tx_fifo.exit_point = 0;
1020
1021 nvicEnableVector(RADIO_IRQn, NRF52_RADIO_IRQ_PRIORITY);
1022
1023 return NRF52_SUCCESS;
1024}
1025
1026nrf52_error_t radio_pop_tx(void) {
1027 if (RFD1.state == NRF52_STATE_UNINIT)
1028 return NRF52_INVALID_STATE;
1029 if (tx_fifo.count == 0)
1030 return NRF52_ERROR_INVALID_LENGTH;
1031
1032 nvicDisableVector(RADIO_IRQn);
1033
1034 if (++tx_fifo.entry_point >= NRF52_TX_FIFO_SIZE) {
1035 tx_fifo.entry_point = 0;
1036 }
1037 tx_fifo.count--;
1038
1039 nvicEnableVector(RADIO_IRQn, NRF52_RADIO_IRQ_PRIORITY);
1040
1041 return NRF52_SUCCESS;
1042}
1043
1044nrf52_error_t radio_flush_rx(void) {
1045 if (RFD1.state == NRF52_STATE_UNINIT)
1046 return NRF52_INVALID_STATE;
1047
1048 nvicDisableVector(RADIO_IRQn);
1049
1050 rx_fifo.count = 0;
1051 rx_fifo.entry_point = 0;
1052 rx_fifo.exit_point = 0;
1053
1054 memset(rx_pipe_info, 0, sizeof(rx_pipe_info));
1055
1056 nvicEnableVector(RADIO_IRQn, NRF52_RADIO_IRQ_PRIORITY);
1057
1058 return NRF52_SUCCESS;
1059}
1060
1061nrf52_error_t radio_set_base_address_0(uint8_t const * p_addr) {
1062 if (RFD1.state != NRF52_STATE_IDLE)
1063 return NRF52_ERROR_BUSY;
1064 if (p_addr == NULL)
1065 return NRF52_ERROR_NULL;
1066
1067 memcpy(RFD1.config.address.base_addr_p0, p_addr, 4);
1068 set_addresses(&RFD1, NRF52_ADDR_UPDATE_MASK_BASE0);
1069
1070 return NRF52_SUCCESS;
1071}
1072
1073nrf52_error_t radio_set_base_address_1(uint8_t const * p_addr) {
1074 if (RFD1.state != NRF52_STATE_IDLE)
1075 return NRF52_ERROR_BUSY;
1076 if (p_addr == NULL)
1077 return NRF52_ERROR_NULL;
1078
1079 memcpy(RFD1.config.address.base_addr_p1, p_addr, 4);
1080 set_addresses(&RFD1, NRF52_ADDR_UPDATE_MASK_BASE1);
1081
1082 return NRF52_SUCCESS;
1083}
1084
1085nrf52_error_t radio_set_prefixes(uint8_t const * p_prefixes, uint8_t num_pipes) {
1086 if (RFD1.state != NRF52_STATE_IDLE)
1087 return NRF52_ERROR_BUSY;
1088 if (p_prefixes == NULL)
1089 return NRF52_ERROR_NULL;
1090 if (num_pipes > 8)
1091 return NRF52_ERROR_INVALID_PARAM;
1092
1093 memcpy(RFD1.config.address.pipe_prefixes, p_prefixes, num_pipes);
1094 RFD1.config.address.num_pipes = num_pipes;
1095 RFD1.config.address.rx_pipes = BIT_MASK_UINT_8(num_pipes);
1096
1097 set_addresses(&RFD1, NRF52_ADDR_UPDATE_MASK_PREFIX);
1098
1099 return NRF52_SUCCESS;
1100}
1101
1102nrf52_error_t radio_set_prefix(uint8_t pipe, uint8_t prefix) {
1103 if (RFD1.state != NRF52_STATE_IDLE)
1104 return NRF52_ERROR_BUSY;
1105 if (pipe > 8)
1106 return NRF52_ERROR_INVALID_PARAM;
1107
1108 RFD1.config.address.pipe_prefixes[pipe] = prefix;
1109
1110 NRF_RADIO->PREFIX0 = bytewise_bit_swap(&RFD1.config.address.pipe_prefixes[0]);
1111 NRF_RADIO->PREFIX1 = bytewise_bit_swap(&RFD1.config.address.pipe_prefixes[4]);
1112
1113 return NRF52_SUCCESS;
1114}
diff --git a/lib/chibios-contrib/testhal/NRF52/NRF52832/RADIO-ESB/nrf52_radio.h b/lib/chibios-contrib/testhal/NRF52/NRF52832/RADIO-ESB/nrf52_radio.h
new file mode 100644
index 000000000..9cdea6fc2
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NRF52/NRF52832/RADIO-ESB/nrf52_radio.h
@@ -0,0 +1,256 @@
1/* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved.
2 *
3 * The information contained herein is property of Nordic Semiconductor ASA.
4 * Terms and conditions of usage are described in detail in NORDIC
5 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
6 *
7 * Licensees are granted free, non-transferable use of the information. NO
8 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
9 * the file.
10 *
11 * @brief Enhanced ShockBurst (ESB) is a basic protocol supporting two-way data
12 * packet communication including packet buffering, packet acknowledgment
13 * and automatic retransmission of lost packets.
14 *
15 * ported on: 25/10/2018, by andru
16 *
17 */
18
19#ifndef NRF52_RADIO_H_
20#define NRF52_RADIO_H_
21
22// Hard coded parameters - change if necessary
23#ifndef NRF52_MAX_PAYLOAD_LENGTH
24#define NRF52_MAX_PAYLOAD_LENGTH 32 /**< The max size of the payload. Valid values are 1 to 252 */
25#endif
26
27#define NRF52_CRC_RESET_VALUE 0xFFFF /**< CRC reset value*/
28
29#define NRF52_TX_FIFO_SIZE 8 /**< The size of the transmission first in first out buffer. */
30#define NRF52_RX_FIFO_SIZE 8 /**< The size of the reception first in first out buffer. */
31
32#define NRF52_RADIO_USE_TIMER0 FALSE /**< TIMER0 will be used by the module. */
33#define NRF52_RADIO_USE_TIMER1 TRUE /**< TIMER1 will be used by the module. */
34#define NRF52_RADIO_USE_TIMER2 FALSE /**< TIMER2 will be used by the module. */
35#define NRF52_RADIO_USE_TIMER3 FALSE /**< TIMER3 will be used by the module. */
36#define NRF52_RADIO_USE_TIMER4 FALSE /**< TIMER4 will be used by the module. */
37
38#define NRF52_RADIO_IRQ_PRIORITY 3 /**< RADIO interrupt priority. */
39#define NRF52_RADIO_INTTHD_PRIORITY (NORMALPRIO+4) /**< Interrupts handle thread priority. */
40#define NRF52_RADIO_EVTTHD_PRIORITY (NORMALPRIO+3) /**< Events handle thread priority */
41
42#define NRF52_RADIO_PPI_TIMER_START 10 /**< The PPI channel used for timer start. */
43#define NRF52_RADIO_PPI_TIMER_STOP 11 /**< The PPI channel used for timer stop. */
44#define NRF52_RADIO_PPI_RX_TIMEOUT 12 /**< The PPI channel used for RX timeout. */
45#define NRF52_RADIO_PPI_TX_START 13 /**< The PPI channel used for starting TX. */
46
47
48typedef enum {
49 NRF52_SUCCESS, /* Call was successful. */
50 NRF52_INVALID_STATE, /* Module is not initialized. */
51 NRF52_ERROR_BUSY, /* Module was not in idle state. */
52 NRF52_ERROR_NULL, /* Required parameter was NULL. */
53 NRF52_ERROR_INVALID_PARAM, /* Required parameter is invalid */
54 NRF52_ERROR_NOT_SUPPORTED, /* p_payload->noack was false while selective ack was not enabled. */
55 NRF52_ERROR_INVALID_LENGTH, /* Payload length was invalid (zero or larger than max allowed). */
56} nrf52_error_t;
57
58// Internal radio module state.
59typedef enum {
60 NRF52_STATE_UNINIT, /**< Module not initialized. */
61 NRF52_STATE_IDLE, /**< Module idle. */
62 NRF52_STATE_PTX_TX, /**< Module transmitting without ack. */
63 NRF52_STATE_PTX_TX_ACK, /**< Module transmitting with ack. */
64 NRF52_STATE_PTX_RX_ACK, /**< Module transmitting with ack and reception of payload with the ack response. */
65 NRF52_STATE_PRX, /**< Module receiving packets without ack. */
66 NRF52_STATE_PRX_SEND_ACK, /**< Module transmitting ack in RX mode. */
67} nrf52_state_t;
68
69/**@brief Events to indicate the last transmission/receiving status. */
70typedef enum {
71 NRF52_EVENT_TX_SUCCESS = 0x01, /**< Event triggered on TX success. */
72 NRF52_EVENT_TX_FAILED = 0x02, /**< Event triggered on TX failed. */
73 NRF52_EVENT_RX_RECEIVED = 0x04, /**< Event triggered on RX Received. */
74} nrf52_event_t;
75
76// Interrupt flags
77typedef enum {
78 NRF52_INT_TX_SUCCESS_MSK = 0x01, /**< The flag used to indicate a success since last event. */
79 NRF52_INT_TX_FAILED_MSK = 0x02, /**< The flag used to indicate a failiure since last event. */
80 NRF52_INT_RX_DR_MSK = 0x04, /**< The flag used to indicate a received packet since last event. */
81} nrf52_int_flags_t;
82
83/**Macro to create initializer for a TX data packet.
84 *
85 * @details This macro generates an initializer. It is more efficient
86 * than setting the individual parameters dynamically.
87 *
88 * @param[in] _pipe The pipe to use for the data packet.
89 * @param[in] ... Comma separated list of character data to put in the TX buffer.
90 * Supported values are from 1 to 63 characters.
91 *
92 * @return Initializer that sets up pipe, length and the byte array for content of the TX data.
93 */
94#define NRF52_CREATE_PAYLOAD(_pipe, ...) \
95 {.pipe = _pipe, .length = NUM_VA_ARGS(__VA_ARGS__), .data = {__VA_ARGS__}}; \
96 STATIC_ASSERT(NUM_VA_ARGS(__VA_ARGS__) > 0 && NUM_VA_ARGS(__VA_ARGS__) <= 63)
97
98/**@brief Enhanced ShockBurst protocol. */
99typedef enum {
100 NRF52_PROTOCOL_ESB, /*< Enhanced ShockBurst with fixed payload length. */
101 NRF52_PROTOCOL_ESB_DPL /*< Enhanced ShockBurst with dynamic payload length. */
102} nrf52_protocol_t;
103
104/**@brief Enhanced ShockBurst mode. */
105typedef enum {
106 NRF52_MODE_PTX, /*< Primary transmitter mode. */
107 NRF52_MODE_PRX /*< Primary receiver mode. */
108} nrf52_mode_t;
109
110/**@brief Enhanced ShockBurst bitrate mode. */
111typedef enum {
112 NRF52_BITRATE_2MBPS = RADIO_MODE_MODE_Nrf_2Mbit, /**< 2Mbit radio mode. */
113 NRF52_BITRATE_1MBPS = RADIO_MODE_MODE_Nrf_1Mbit, /**< 1Mbit radio mode. */
114} nrf52_bitrate_t;
115
116/**@brief Enhanced ShockBurst CRC modes. */
117typedef enum {
118 NRF52_CRC_16BIT = RADIO_CRCCNF_LEN_Two, /**< Use two byte CRC. */
119 NRF52_CRC_8BIT = RADIO_CRCCNF_LEN_One, /**< Use one byte CRC. */
120 NRF52_CRC_OFF = RADIO_CRCCNF_LEN_Disabled /**< Disable CRC. */
121} nrf52_crc_t;
122
123/**@brief Enhanced ShockBurst radio transmission power modes. */
124typedef enum {
125 NRF52_TX_POWER_4DBM = RADIO_TXPOWER_TXPOWER_Pos4dBm, /**< 4 dBm radio transmit power. */
126 NRF52_TX_POWER_0DBM = RADIO_TXPOWER_TXPOWER_0dBm, /**< 0 dBm radio transmit power. */
127 NRF52_TX_POWER_NEG4DBM = RADIO_TXPOWER_TXPOWER_Neg4dBm, /**< -4 dBm radio transmit power. */
128 NRF52_TX_POWER_NEG8DBM = RADIO_TXPOWER_TXPOWER_Neg8dBm, /**< -8 dBm radio transmit power. */
129 NRF52_TX_POWER_NEG12DBM = RADIO_TXPOWER_TXPOWER_Neg12dBm, /**< -12 dBm radio transmit power. */
130 NRF52_TX_POWER_NEG16DBM = RADIO_TXPOWER_TXPOWER_Neg16dBm, /**< -16 dBm radio transmit power. */
131 NRF52_TX_POWER_NEG20DBM = RADIO_TXPOWER_TXPOWER_Neg20dBm, /**< -20 dBm radio transmit power. */
132 NRF52_TX_POWER_NEG30DBM = RADIO_TXPOWER_TXPOWER_Neg30dBm /**< -30 dBm radio transmit power. */
133} nrf52_tx_power_t;
134
135/**@brief Enhanced ShockBurst transmission modes. */
136typedef enum {
137 NRF52_TXMODE_AUTO, /*< Automatic TX mode - When the TX fifo is non-empty and the radio is idle packets will be sent automatically. */
138 NRF52_TXMODE_MANUAL, /*< Manual TX mode - Packets will not be sent until radio_start_tx() is called. Can be used to ensure consistent packet timing. */
139 NRF52_TXMODE_MANUAL_START /*< Manual start TX mode - Packets will not be sent until radio_start_tx() is called, but transmission will continue automatically until the TX fifo is empty. */
140} nrf52_tx_mode_t;
141
142/**@brief Enhanced ShockBurst addresses.
143 *
144 * @details The module is able to transmit packets with the TX address stored in tx_address.
145 The module can also receive packets from peers with up to eight different tx_addresses
146 stored in esb_addr_p0 - esb_addr_p7. esb_addr_p0 can have 5 arbitrary bytes
147 independent of the other addresses. esb_addr_p1 - esb_addr_p7 will share the
148 same four byte base address found in the last four bytes of esb_addr_p1.
149 They have an independent prefix byte found in esb_addr_p1[0] and esb_addr_p2 -
150 esb_addr_p7.
151*/
152typedef struct {
153 uint8_t base_addr_p0[4]; /**< Base address for pipe 0 encoded in big endian. */
154 uint8_t base_addr_p1[4]; /**< Base address for pipe 1-7 encoded in big endian. */
155 uint8_t pipe_prefixes[8]; /**< Address prefix for pipe P0 to P7. */
156 uint8_t num_pipes; /**< Number of pipes available. */
157 uint8_t addr_length; /**< Length of address including prefix */
158 uint8_t rx_pipes; /**< Bitfield for enabled RX pipes. */
159 uint8_t rf_channel; /**< Which channel is to be used. Must be in range 0 and 125 to be valid. */
160} nrf52_address_t;
161
162/**@brief Enhanced ShockBurst payload.
163 *
164 * @note The payload is used both for transmission and receive with ack and payload.
165*/
166typedef struct
167{
168 uint8_t length; /**< Length of the packet. Should be equal or less than NRF_ESB_MAX_PAYLOAD_LENGTH. */
169 uint8_t pipe; /**< Pipe used for this payload. */
170 int8_t rssi; /**< RSSI for received packet. */
171 uint8_t noack; /**< Flag indicating that this packet will not be acknowledged. */
172 uint8_t pid; /**< PID assigned during communication. */
173 uint8_t data[NRF52_MAX_PAYLOAD_LENGTH]; /**< The payload data. */
174} nrf52_payload_t;
175
176/**@brief Retransmit attempts delay and counter. */
177typedef struct {
178 uint16_t delay; /**< The delay between each retransmission of unacked packets. */
179 uint16_t count; /**< The number of retransmissions attempts before transmission fail. */
180} nrf52_retransmit_t;
181
182/**@brief Main nrf_esb configuration struct. */
183typedef struct {
184 nrf52_protocol_t protocol; /**< Enhanced ShockBurst protocol. */
185 nrf52_mode_t mode; /**< Enhanced ShockBurst default RX or TX mode. */
186
187 // General RF parameters
188 nrf52_bitrate_t bitrate; /**< Enhanced ShockBurst bitrate mode. */
189 nrf52_crc_t crc; /**< Enhanced ShockBurst CRC mode. */
190 nrf52_tx_power_t tx_power; /**< Enhanced ShockBurst radio transmission power mode.*/
191
192 // Control settings
193 nrf52_tx_mode_t tx_mode; /**< Enhanced ShockBurst transmit mode. */
194
195 bool selective_auto_ack; /**< Enable or disable selective auto acknowledgement. */
196
197 nrf52_retransmit_t retransmit; /**< Packet retransmit parameters */
198
199 uint8_t payload_length; /**< Enhanced ShockBurst static payload length */
200
201 nrf52_address_t address; /**< Address parameters structure */
202} nrf52_config_t;
203
204typedef struct {
205 /**
206 * @brief NRF52 radio peripheral.
207 */
208 NRF_RADIO_Type *radio;
209 /**
210 * @brief NRF52 timer peripheral.
211 */
212 NRF_TIMER_Type *timer;
213 /**
214 * @brief Driver state.
215 */
216 nrf52_state_t state;
217 /**
218 * @brief RF parameters.
219 */
220 nrf52_config_t config;
221 /**
222 * @brief Interrupts flag.
223 */
224 nrf52_int_flags_t flags;
225 /**
226 * @brief TX attempt number.
227 */
228 uint16_t tx_attempt;
229 /**
230 * @brief TX retransmits remaining.
231 */
232 uint16_t tx_remaining;
233 /**
234 * @brief Radio events source.
235 */
236 event_source_t eventsrc;
237} RFDriver;
238
239extern RFDriver RFD1;
240
241nrf52_error_t radio_init(nrf52_config_t const *config);
242nrf52_error_t radio_disable(void);
243nrf52_error_t radio_write_payload(nrf52_payload_t const * p_payload);
244nrf52_error_t radio_read_rx_payload(nrf52_payload_t * p_payload);
245nrf52_error_t radio_start_tx(void);
246nrf52_error_t radio_start_rx(void);
247nrf52_error_t radio_stop_rx(void);
248nrf52_error_t radio_flush_tx(void);
249nrf52_error_t radio_flush_rx(void);
250nrf52_error_t radio_pop_tx(void);
251nrf52_error_t radio_set_base_address_0(uint8_t const * p_addr);
252nrf52_error_t radio_set_base_address_1(uint8_t const * p_addr);
253nrf52_error_t radio_set_prefixes(uint8_t const * p_prefixes, uint8_t num_pipes);
254nrf52_error_t radio_set_prefix(uint8_t pipe, uint8_t prefix);
255
256#endif /* NRF52_RADIO_H_ */
diff --git a/lib/chibios-contrib/testhal/NRF52/NRF52832/UART/Makefile b/lib/chibios-contrib/testhal/NRF52/NRF52832/UART/Makefile
new file mode 100644
index 000000000..5db40b0e6
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NRF52/NRF52832/UART/Makefile
@@ -0,0 +1,211 @@
1##############################################################################
2# Build global options
3# NOTE: Can be overridden externally.
4#
5
6# Compiler options here.
7ifeq ($(USE_OPT),)
8 USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16
9endif
10
11# C specific options here (added to USE_OPT).
12ifeq ($(USE_COPT),)
13 USE_COPT =
14endif
15
16# C++ specific options here (added to USE_OPT).
17ifeq ($(USE_CPPOPT),)
18 USE_CPPOPT = -fno-rtti
19endif
20
21# Enable this if you want the linker to remove unused code and data
22ifeq ($(USE_LINK_GC),)
23 USE_LINK_GC = yes
24endif
25
26# Linker extra options here.
27ifeq ($(USE_LDOPT),)
28 USE_LDOPT =
29endif
30
31# Enable this if you want link time optimizations (LTO)
32ifeq ($(USE_LTO),)
33 USE_LTO = no
34endif
35
36# If enabled, this option allows to compile the application in THUMB mode.
37ifeq ($(USE_THUMB),)
38 USE_THUMB = yes
39endif
40
41# Enable this if you want to see the full log while compiling.
42ifeq ($(USE_VERBOSE_COMPILE),)
43 USE_VERBOSE_COMPILE = no
44endif
45
46#
47# Build global options
48##############################################################################
49
50##############################################################################
51# Architecture or project specific options
52#
53
54# Stack size to be allocated to the Cortex-M process stack. This stack is
55# the stack used by the main() thread.
56ifeq ($(USE_PROCESS_STACKSIZE),)
57 USE_PROCESS_STACKSIZE = 0x400
58endif
59
60# Stack size to the allocated to the Cortex-M main/exceptions stack. This
61# stack is used for processing interrupts and exceptions.
62ifeq ($(USE_EXCEPTIONS_STACKSIZE),)
63 USE_EXCEPTIONS_STACKSIZE = 0x400
64endif
65
66# Enables the use of FPU on Cortex-M4 (no, softfp, hard).
67ifeq ($(USE_FPU),)
68 USE_FPU = no
69endif
70
71#
72# Architecture or project specific options
73##############################################################################
74
75##############################################################################
76# Project, sources and paths
77#
78
79# Define project name here
80PROJECT = ch
81
82# Imported source files and paths
83CHIBIOS = ../../../../../ChibiOS-RT
84CHIBIOS_CONTRIB = $(CHIBIOS)/../ChibiOS-Contrib
85# Licensing files.
86include $(CHIBIOS)/os/license/license.mk
87# Startup files.
88include $(CHIBIOS_CONTRIB)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_nrf52.mk
89# HAL-OSAL files (optional).
90include $(CHIBIOS_CONTRIB)/os/hal/hal.mk
91include $(CHIBIOS_CONTRIB)/os/hal/ports/NRF5/NRF52832/platform.mk
92include $(CHIBIOS_CONTRIB)/os/hal/boards/NRF52-E73-2G4M04S/board.mk
93include $(CHIBIOS)/os/hal/osal/rt-nil/osal.mk
94# RTOS files (optional).
95include $(CHIBIOS)/os/rt/rt.mk
96include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk
97# Other files (optional).
98#include $(CHIBIOS)/test/rt/test.mk
99
100# Define linker script file here
101LDSCRIPT= $(STARTUPLD_CONTRIB)/NRF52832.ld
102
103# C sources that can be compiled in ARM or THUMB mode depending on the global
104# setting.
105CSRC = $(ALLCSRC) \
106 $(TESTSRC) \
107 $(CHIBIOS)/os/various/syscalls.c \
108 $(CHIBIOS)/os/hal/lib/streams/memstreams.c \
109 $(CHIBIOS)/os/hal/lib/streams/chprintf.c \
110 main.c
111
112# C++ sources that can be compiled in ARM or THUMB mode depending on the global
113# setting.
114CPPSRC = $(ALLCPPSRC)
115
116# C sources to be compiled in ARM mode regardless of the global setting.
117# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
118# option that results in lower performance and larger code size.
119ACSRC =
120
121# C++ sources to be compiled in ARM mode regardless of the global setting.
122# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
123# option that results in lower performance and larger code size.
124ACPPSRC =
125
126# C sources to be compiled in THUMB mode regardless of the global setting.
127# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
128# option that results in lower performance and larger code size.
129TCSRC =
130
131# C sources to be compiled in THUMB mode regardless of the global setting.
132# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
133# option that results in lower performance and larger code size.
134TCPPSRC =
135
136# List ASM source files here
137ASMSRC = $(ALLASMSRC)
138ASMXSRC = $(ALLXASMSRC)
139
140INCDIR = $(ALLINC) $(TESTINC) \
141 $(CHIBIOS)/os/hal/lib/streams \
142 $(TESTHAL)
143
144#
145# Project, sources and paths
146##############################################################################
147
148##############################################################################
149# Compiler settings
150#
151
152MCU = cortex-m4
153
154TRGT = arm-none-eabi-
155CC = $(TRGT)gcc
156CPPC = $(TRGT)g++
157# Enable loading with g++ only if you need C++ runtime support.
158# NOTE: You can use C++ even without C++ support if you are careful. C++
159# runtime support makes code size explode.
160LD = $(TRGT)gcc
161#LD = $(TRGT)g++
162CP = $(TRGT)objcopy
163AS = $(TRGT)gcc -x assembler-with-cpp
164AR = $(TRGT)ar
165OD = $(TRGT)objdump
166SZ = $(TRGT)size
167HEX = $(CP) -O ihex
168BIN = $(CP) -O binary
169SREC = $(CP) -O srec
170
171# ARM-specific options here
172AOPT =
173
174# THUMB-specific options here
175TOPT = -mthumb -DTHUMB
176
177# Define C warning options here
178CWARN = -Wall -Wextra -Wstrict-prototypes
179
180# Define C++ warning options here
181CPPWARN = -Wall -Wextra
182
183#
184# Compiler settings
185##############################################################################
186
187##############################################################################
188# Start of user section
189#
190
191# List all user C define here, like -D_DEBUG=1
192UDEFS =
193
194# Define ASM defines here
195UADEFS =
196
197# List all user directories here
198UINCDIR =
199
200# List the user directory to look for the libraries here
201ULIBDIR =
202
203# List all user libraries here
204ULIBS =
205
206#
207# End of user defines
208##############################################################################
209
210RULESPATH = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk
211include $(RULESPATH)/rules.mk
diff --git a/lib/chibios-contrib/testhal/NRF52/NRF52832/UART/chconf.h b/lib/chibios-contrib/testhal/NRF52/NRF52832/UART/chconf.h
new file mode 100644
index 000000000..6687603e0
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NRF52/NRF52832/UART/chconf.h
@@ -0,0 +1,757 @@
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 rt/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 config
24 * @details Kernel related settings and hooks.
25 * @{
26 */
27
28#ifndef CHCONF_H
29#define CHCONF_H
30
31#define _CHIBIOS_RT_CONF_
32#define _CHIBIOS_RT_CONF_VER_6_1_
33
34/*===========================================================================*/
35/**
36 * @name System timers settings
37 * @{
38 */
39/*===========================================================================*/
40
41/**
42 * @brief System time counter resolution.
43 * @note Allowed values are 16 or 32 bits.
44 */
45#if !defined(CH_CFG_ST_RESOLUTION)
46#define CH_CFG_ST_RESOLUTION 32
47#endif
48
49/**
50 * @brief System tick frequency.
51 * @details Frequency of the system timer that drives the system ticks. This
52 * setting also defines the system tick time unit.
53 */
54#if !defined(CH_CFG_ST_FREQUENCY)
55#define CH_CFG_ST_FREQUENCY 1000
56#endif
57
58/**
59 * @brief Time intervals data size.
60 * @note Allowed values are 16, 32 or 64 bits.
61 */
62#if !defined(CH_CFG_INTERVALS_SIZE)
63#define CH_CFG_INTERVALS_SIZE 32
64#endif
65
66/**
67 * @brief Time types data size.
68 * @note Allowed values are 16 or 32 bits.
69 */
70#if !defined(CH_CFG_TIME_TYPES_SIZE)
71#define CH_CFG_TIME_TYPES_SIZE 32
72#endif
73
74/**
75 * @brief Time delta constant for the tick-less mode.
76 * @note If this value is zero then the system uses the classic
77 * periodic tick. This value represents the minimum number
78 * of ticks that is safe to specify in a timeout directive.
79 * The value one is not valid, timeouts are rounded up to
80 * this value.
81 */
82#if !defined(CH_CFG_ST_TIMEDELTA)
83#define CH_CFG_ST_TIMEDELTA 0
84#endif
85
86/** @} */
87
88/*===========================================================================*/
89/**
90 * @name Kernel parameters and options
91 * @{
92 */
93/*===========================================================================*/
94
95/**
96 * @brief Round robin interval.
97 * @details This constant is the number of system ticks allowed for the
98 * threads before preemption occurs. Setting this value to zero
99 * disables the preemption for threads with equal priority and the
100 * round robin becomes cooperative. Note that higher priority
101 * threads can still preempt, the kernel is always preemptive.
102 * @note Disabling the round robin preemption makes the kernel more compact
103 * and generally faster.
104 * @note The round robin preemption is not supported in tickless mode and
105 * must be set to zero in that case.
106 */
107#if !defined(CH_CFG_TIME_QUANTUM)
108#define CH_CFG_TIME_QUANTUM 0
109#endif
110
111/**
112 * @brief Idle thread automatic spawn suppression.
113 * @details When this option is activated the function @p chSysInit()
114 * does not spawn the idle thread. The application @p main()
115 * function becomes the idle thread and must implement an
116 * infinite loop.
117 */
118#if !defined(CH_CFG_NO_IDLE_THREAD)
119#define CH_CFG_NO_IDLE_THREAD FALSE
120#endif
121
122/** @} */
123
124/*===========================================================================*/
125/**
126 * @name Performance options
127 * @{
128 */
129/*===========================================================================*/
130
131/**
132 * @brief OS optimization.
133 * @details If enabled then time efficient rather than space efficient code
134 * is used when two possible implementations exist.
135 *
136 * @note This is not related to the compiler optimization options.
137 * @note The default is @p TRUE.
138 */
139#if !defined(CH_CFG_OPTIMIZE_SPEED)
140#define CH_CFG_OPTIMIZE_SPEED TRUE
141#endif
142
143/** @} */
144
145/*===========================================================================*/
146/**
147 * @name Subsystem options
148 * @{
149 */
150/*===========================================================================*/
151
152/**
153 * @brief Time Measurement APIs.
154 * @details If enabled then the time measurement APIs are included in
155 * the kernel.
156 *
157 * @note The default is @p TRUE.
158 */
159#if !defined(CH_CFG_USE_TM)
160#define CH_CFG_USE_TM TRUE
161#endif
162
163/**
164 * @brief Threads registry APIs.
165 * @details If enabled then the registry APIs are included in the kernel.
166 *
167 * @note The default is @p TRUE.
168 */
169#if !defined(CH_CFG_USE_REGISTRY)
170#define CH_CFG_USE_REGISTRY TRUE
171#endif
172
173/**
174 * @brief Threads synchronization APIs.
175 * @details If enabled then the @p chThdWait() function is included in
176 * the kernel.
177 *
178 * @note The default is @p TRUE.
179 */
180#if !defined(CH_CFG_USE_WAITEXIT)
181#define CH_CFG_USE_WAITEXIT TRUE
182#endif
183
184/**
185 * @brief Semaphores APIs.
186 * @details If enabled then the Semaphores APIs are included in the kernel.
187 *
188 * @note The default is @p TRUE.
189 */
190#if !defined(CH_CFG_USE_SEMAPHORES)
191#define CH_CFG_USE_SEMAPHORES TRUE
192#endif
193
194/**
195 * @brief Semaphores queuing mode.
196 * @details If enabled then the threads are enqueued on semaphores by
197 * priority rather than in FIFO order.
198 *
199 * @note The default is @p FALSE. Enable this if you have special
200 * requirements.
201 * @note Requires @p CH_CFG_USE_SEMAPHORES.
202 */
203#if !defined(CH_CFG_USE_SEMAPHORES_PRIORITY)
204#define CH_CFG_USE_SEMAPHORES_PRIORITY FALSE
205#endif
206
207/**
208 * @brief Mutexes APIs.
209 * @details If enabled then the mutexes APIs are included in the kernel.
210 *
211 * @note The default is @p TRUE.
212 */
213#if !defined(CH_CFG_USE_MUTEXES)
214#define CH_CFG_USE_MUTEXES TRUE
215#endif
216
217/**
218 * @brief Enables recursive behavior on mutexes.
219 * @note Recursive mutexes are heavier and have an increased
220 * memory footprint.
221 *
222 * @note The default is @p FALSE.
223 * @note Requires @p CH_CFG_USE_MUTEXES.
224 */
225#if !defined(CH_CFG_USE_MUTEXES_RECURSIVE)
226#define CH_CFG_USE_MUTEXES_RECURSIVE FALSE
227#endif
228
229/**
230 * @brief Conditional Variables APIs.
231 * @details If enabled then the conditional variables APIs are included
232 * in the kernel.
233 *
234 * @note The default is @p TRUE.
235 * @note Requires @p CH_CFG_USE_MUTEXES.
236 */
237#if !defined(CH_CFG_USE_CONDVARS)
238#define CH_CFG_USE_CONDVARS TRUE
239#endif
240
241/**
242 * @brief Conditional Variables APIs with timeout.
243 * @details If enabled then the conditional variables APIs with timeout
244 * specification are included in the kernel.
245 *
246 * @note The default is @p TRUE.
247 * @note Requires @p CH_CFG_USE_CONDVARS.
248 */
249#if !defined(CH_CFG_USE_CONDVARS_TIMEOUT)
250#define CH_CFG_USE_CONDVARS_TIMEOUT TRUE
251#endif
252
253/**
254 * @brief Events Flags APIs.
255 * @details If enabled then the event flags APIs are included in the kernel.
256 *
257 * @note The default is @p TRUE.
258 */
259#if !defined(CH_CFG_USE_EVENTS)
260#define CH_CFG_USE_EVENTS TRUE
261#endif
262
263/**
264 * @brief Events Flags APIs with timeout.
265 * @details If enabled then the events APIs with timeout specification
266 * are included in the kernel.
267 *
268 * @note The default is @p TRUE.
269 * @note Requires @p CH_CFG_USE_EVENTS.
270 */
271#if !defined(CH_CFG_USE_EVENTS_TIMEOUT)
272#define CH_CFG_USE_EVENTS_TIMEOUT TRUE
273#endif
274
275/**
276 * @brief Synchronous Messages APIs.
277 * @details If enabled then the synchronous messages APIs are included
278 * in the kernel.
279 *
280 * @note The default is @p TRUE.
281 */
282#if !defined(CH_CFG_USE_MESSAGES)
283#define CH_CFG_USE_MESSAGES TRUE
284#endif
285
286/**
287 * @brief Synchronous Messages queuing mode.
288 * @details If enabled then messages are served by priority rather than in
289 * FIFO order.
290 *
291 * @note The default is @p FALSE. Enable this if you have special
292 * requirements.
293 * @note Requires @p CH_CFG_USE_MESSAGES.
294 */
295#if !defined(CH_CFG_USE_MESSAGES_PRIORITY)
296#define CH_CFG_USE_MESSAGES_PRIORITY FALSE
297#endif
298
299/**
300 * @brief Dynamic Threads APIs.
301 * @details If enabled then the dynamic threads creation APIs are included
302 * in the kernel.
303 *
304 * @note The default is @p TRUE.
305 * @note Requires @p CH_CFG_USE_WAITEXIT.
306 * @note Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS.
307 */
308#if !defined(CH_CFG_USE_DYNAMIC)
309#define CH_CFG_USE_DYNAMIC TRUE
310#endif
311
312/** @} */
313
314/*===========================================================================*/
315/**
316 * @name OSLIB options
317 * @{
318 */
319/*===========================================================================*/
320
321/**
322 * @brief Mailboxes APIs.
323 * @details If enabled then the asynchronous messages (mailboxes) APIs are
324 * included in the kernel.
325 *
326 * @note The default is @p TRUE.
327 * @note Requires @p CH_CFG_USE_SEMAPHORES.
328 */
329#if !defined(CH_CFG_USE_MAILBOXES)
330#define CH_CFG_USE_MAILBOXES TRUE
331#endif
332
333/**
334 * @brief Core Memory Manager APIs.
335 * @details If enabled then the core memory manager APIs are included
336 * in the kernel.
337 *
338 * @note The default is @p TRUE.
339 */
340#if !defined(CH_CFG_USE_MEMCORE)
341#define CH_CFG_USE_MEMCORE TRUE
342#endif
343
344/**
345 * @brief Managed RAM size.
346 * @details Size of the RAM area to be managed by the OS. If set to zero
347 * then the whole available RAM is used. The core memory is made
348 * available to the heap allocator and/or can be used directly through
349 * the simplified core memory allocator.
350 *
351 * @note In order to let the OS manage the whole RAM the linker script must
352 * provide the @p __heap_base__ and @p __heap_end__ symbols.
353 * @note Requires @p CH_CFG_USE_MEMCORE.
354 */
355#if !defined(CH_CFG_MEMCORE_SIZE)
356#define CH_CFG_MEMCORE_SIZE 0
357#endif
358
359/**
360 * @brief Heap Allocator APIs.
361 * @details If enabled then the memory heap allocator APIs are included
362 * in the kernel.
363 *
364 * @note The default is @p TRUE.
365 * @note Requires @p CH_CFG_USE_MEMCORE and either @p CH_CFG_USE_MUTEXES or
366 * @p CH_CFG_USE_SEMAPHORES.
367 * @note Mutexes are recommended.
368 */
369#if !defined(CH_CFG_USE_HEAP)
370#define CH_CFG_USE_HEAP TRUE
371#endif
372
373/**
374 * @brief Memory Pools Allocator APIs.
375 * @details If enabled then the memory pools allocator APIs are included
376 * in the kernel.
377 *
378 * @note The default is @p TRUE.
379 */
380#if !defined(CH_CFG_USE_MEMPOOLS)
381#define CH_CFG_USE_MEMPOOLS TRUE
382#endif
383
384/**
385 * @brief Objects FIFOs APIs.
386 * @details If enabled then the objects FIFOs APIs are included
387 * in the kernel.
388 *
389 * @note The default is @p TRUE.
390 */
391#if !defined(CH_CFG_USE_OBJ_FIFOS)
392#define CH_CFG_USE_OBJ_FIFOS TRUE
393#endif
394
395/**
396 * @brief Pipes APIs.
397 * @details If enabled then the pipes APIs are included
398 * in the kernel.
399 *
400 * @note The default is @p TRUE.
401 */
402#if !defined(CH_CFG_USE_PIPES)
403#define CH_CFG_USE_PIPES TRUE
404#endif
405
406/**
407 * @brief Objects Caches APIs.
408 * @details If enabled then the objects caches APIs are included
409 * in the kernel.
410 *
411 * @note The default is @p TRUE.
412 */
413#if !defined(CH_CFG_USE_OBJ_CACHES)
414#define CH_CFG_USE_OBJ_CACHES TRUE
415#endif
416
417/**
418 * @brief Delegate threads APIs.
419 * @details If enabled then the delegate threads APIs are included
420 * in the kernel.
421 *
422 * @note The default is @p TRUE.
423 */
424#if !defined(CH_CFG_USE_DELEGATES)
425#define CH_CFG_USE_DELEGATES TRUE
426#endif
427
428/**
429 * @brief Jobs Queues APIs.
430 * @details If enabled then the jobs queues APIs are included
431 * in the kernel.
432 *
433 * @note The default is @p TRUE.
434 */
435#if !defined(CH_CFG_USE_JOBS)
436#define CH_CFG_USE_JOBS TRUE
437#endif
438
439/** @} */
440
441/*===========================================================================*/
442/**
443 * @name Objects factory options
444 * @{
445 */
446/*===========================================================================*/
447
448/**
449 * @brief Objects Factory APIs.
450 * @details If enabled then the objects factory APIs are included in the
451 * kernel.
452 *
453 * @note The default is @p FALSE.
454 */
455#if !defined(CH_CFG_USE_FACTORY)
456#define CH_CFG_USE_FACTORY TRUE
457#endif
458
459/**
460 * @brief Maximum length for object names.
461 * @details If the specified length is zero then the name is stored by
462 * pointer but this could have unintended side effects.
463 */
464#if !defined(CH_CFG_FACTORY_MAX_NAMES_LENGTH)
465#define CH_CFG_FACTORY_MAX_NAMES_LENGTH 8
466#endif
467
468/**
469 * @brief Enables the registry of generic objects.
470 */
471#if !defined(CH_CFG_FACTORY_OBJECTS_REGISTRY)
472#define CH_CFG_FACTORY_OBJECTS_REGISTRY TRUE
473#endif
474
475/**
476 * @brief Enables factory for generic buffers.
477 */
478#if !defined(CH_CFG_FACTORY_GENERIC_BUFFERS)
479#define CH_CFG_FACTORY_GENERIC_BUFFERS TRUE
480#endif
481
482/**
483 * @brief Enables factory for semaphores.
484 */
485#if !defined(CH_CFG_FACTORY_SEMAPHORES)
486#define CH_CFG_FACTORY_SEMAPHORES TRUE
487#endif
488
489/**
490 * @brief Enables factory for mailboxes.
491 */
492#if !defined(CH_CFG_FACTORY_MAILBOXES)
493#define CH_CFG_FACTORY_MAILBOXES TRUE
494#endif
495
496/**
497 * @brief Enables factory for objects FIFOs.
498 */
499#if !defined(CH_CFG_FACTORY_OBJ_FIFOS)
500#define CH_CFG_FACTORY_OBJ_FIFOS TRUE
501#endif
502
503/**
504 * @brief Enables factory for Pipes.
505 */
506#if !defined(CH_CFG_FACTORY_PIPES) || defined(__DOXYGEN__)
507#define CH_CFG_FACTORY_PIPES TRUE
508#endif
509
510/** @} */
511
512/*===========================================================================*/
513/**
514 * @name Debug options
515 * @{
516 */
517/*===========================================================================*/
518
519/**
520 * @brief Debug option, kernel statistics.
521 *
522 * @note The default is @p FALSE.
523 */
524#if !defined(CH_DBG_STATISTICS)
525#define CH_DBG_STATISTICS FALSE
526#endif
527
528/**
529 * @brief Debug option, system state check.
530 * @details If enabled the correct call protocol for system APIs is checked
531 * at runtime.
532 *
533 * @note The default is @p FALSE.
534 */
535#if !defined(CH_DBG_SYSTEM_STATE_CHECK)
536#define CH_DBG_SYSTEM_STATE_CHECK TRUE
537#endif
538
539/**
540 * @brief Debug option, parameters checks.
541 * @details If enabled then the checks on the API functions input
542 * parameters are activated.
543 *
544 * @note The default is @p FALSE.
545 */
546#if !defined(CH_DBG_ENABLE_CHECKS)
547#define CH_DBG_ENABLE_CHECKS TRUE
548#endif
549
550/**
551 * @brief Debug option, consistency checks.
552 * @details If enabled then all the assertions in the kernel code are
553 * activated. This includes consistency checks inside the kernel,
554 * runtime anomalies and port-defined checks.
555 *
556 * @note The default is @p FALSE.
557 */
558#if !defined(CH_DBG_ENABLE_ASSERTS)
559#define CH_DBG_ENABLE_ASSERTS TRUE
560#endif
561
562/**
563 * @brief Debug option, trace buffer.
564 * @details If enabled then the trace buffer is activated.
565 *
566 * @note The default is @p CH_DBG_TRACE_MASK_DISABLED.
567 */
568#if !defined(CH_DBG_TRACE_MASK)
569#define CH_DBG_TRACE_MASK CH_DBG_TRACE_MASK_DISABLED
570#endif
571
572/**
573 * @brief Trace buffer entries.
574 * @note The trace buffer is only allocated if @p CH_DBG_TRACE_MASK is
575 * different from @p CH_DBG_TRACE_MASK_DISABLED.
576 */
577#if !defined(CH_DBG_TRACE_BUFFER_SIZE)
578#define CH_DBG_TRACE_BUFFER_SIZE 128
579#endif
580
581/**
582 * @brief Debug option, stack checks.
583 * @details If enabled then a runtime stack check is performed.
584 *
585 * @note The default is @p FALSE.
586 * @note The stack check is performed in a architecture/port dependent way.
587 * It may not be implemented or some ports.
588 * @note The default failure mode is to halt the system with the global
589 * @p panic_msg variable set to @p NULL.
590 */
591#if !defined(CH_DBG_ENABLE_STACK_CHECK)
592#define CH_DBG_ENABLE_STACK_CHECK FALSE
593#endif
594
595/**
596 * @brief Debug option, stacks initialization.
597 * @details If enabled then the threads working area is filled with a byte
598 * value when a thread is created. This can be useful for the
599 * runtime measurement of the used stack.
600 *
601 * @note The default is @p FALSE.
602 */
603#if !defined(CH_DBG_FILL_THREADS)
604#define CH_DBG_FILL_THREADS FALSE
605#endif
606
607/**
608 * @brief Debug option, threads profiling.
609 * @details If enabled then a field is added to the @p thread_t structure that
610 * counts the system ticks occurred while executing the thread.
611 *
612 * @note The default is @p FALSE.
613 * @note This debug option is not currently compatible with the
614 * tickless mode.
615 */
616#if !defined(CH_DBG_THREADS_PROFILING)
617#define CH_DBG_THREADS_PROFILING FALSE
618#endif
619
620/** @} */
621
622/*===========================================================================*/
623/**
624 * @name Kernel hooks
625 * @{
626 */
627/*===========================================================================*/
628
629/**
630 * @brief System structure extension.
631 * @details User fields added to the end of the @p ch_system_t structure.
632 */
633#define CH_CFG_SYSTEM_EXTRA_FIELDS \
634 /* Add threads custom fields here.*/
635
636/**
637 * @brief System initialization hook.
638 * @details User initialization code added to the @p chSysInit() function
639 * just before interrupts are enabled globally.
640 */
641#define CH_CFG_SYSTEM_INIT_HOOK() { \
642 /* Add threads initialization code here.*/ \
643}
644
645/**
646 * @brief Threads descriptor structure extension.
647 * @details User fields added to the end of the @p thread_t structure.
648 */
649#define CH_CFG_THREAD_EXTRA_FIELDS \
650 /* Add threads custom fields here.*/
651
652/**
653 * @brief Threads initialization hook.
654 * @details User initialization code added to the @p _thread_init() function.
655 *
656 * @note It is invoked from within @p _thread_init() and implicitly from all
657 * the threads creation APIs.
658 */
659#define CH_CFG_THREAD_INIT_HOOK(tp) { \
660 /* Add threads initialization code here.*/ \
661}
662
663/**
664 * @brief Threads finalization hook.
665 * @details User finalization code added to the @p chThdExit() API.
666 */
667#define CH_CFG_THREAD_EXIT_HOOK(tp) { \
668 /* Add threads finalization code here.*/ \
669}
670
671/**
672 * @brief Context switch hook.
673 * @details This hook is invoked just before switching between threads.
674 */
675#define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) { \
676 /* Context switch code here.*/ \
677}
678
679/**
680 * @brief ISR enter hook.
681 */
682#define CH_CFG_IRQ_PROLOGUE_HOOK() { \
683 /* IRQ prologue code here.*/ \
684}
685
686/**
687 * @brief ISR exit hook.
688 */
689#define CH_CFG_IRQ_EPILOGUE_HOOK() { \
690 /* IRQ epilogue code here.*/ \
691}
692
693/**
694 * @brief Idle thread enter hook.
695 * @note This hook is invoked within a critical zone, no OS functions
696 * should be invoked from here.
697 * @note This macro can be used to activate a power saving mode.
698 */
699#define CH_CFG_IDLE_ENTER_HOOK() { \
700 /* Idle-enter code here.*/ \
701}
702
703/**
704 * @brief Idle thread leave hook.
705 * @note This hook is invoked within a critical zone, no OS functions
706 * should be invoked from here.
707 * @note This macro can be used to deactivate a power saving mode.
708 */
709#define CH_CFG_IDLE_LEAVE_HOOK() { \
710 /* Idle-leave code here.*/ \
711}
712
713/**
714 * @brief Idle Loop hook.
715 * @details This hook is continuously invoked by the idle thread loop.
716 */
717#define CH_CFG_IDLE_LOOP_HOOK() { \
718 /* Idle loop code here.*/ \
719}
720
721/**
722 * @brief System tick event hook.
723 * @details This hook is invoked in the system tick handler immediately
724 * after processing the virtual timers queue.
725 */
726#define CH_CFG_SYSTEM_TICK_HOOK() { \
727 /* System tick event code here.*/ \
728}
729
730/**
731 * @brief System halt hook.
732 * @details This hook is invoked in case to a system halting error before
733 * the system is halted.
734 */
735#define CH_CFG_SYSTEM_HALT_HOOK(reason) { \
736 /* System halt code here.*/ \
737}
738
739/**
740 * @brief Trace hook.
741 * @details This hook is invoked each time a new record is written in the
742 * trace buffer.
743 */
744#define CH_CFG_TRACE_HOOK(tep) { \
745 /* Trace code here.*/ \
746}
747
748
749/** @} */
750
751/*===========================================================================*/
752/* Port-specific settings (override port settings defaulted in chcore.h). */
753/*===========================================================================*/
754
755#endif /* CHCONF_H */
756
757/** @} */
diff --git a/lib/chibios-contrib/testhal/NRF52/NRF52832/UART/halconf.h b/lib/chibios-contrib/testhal/NRF52/NRF52832/UART/halconf.h
new file mode 100644
index 000000000..b40c5dbf3
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NRF52/NRF52832/UART/halconf.h
@@ -0,0 +1,533 @@
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 templates/halconf.h
19 * @brief HAL configuration header.
20 * @details HAL configuration file, this file allows to enable or disable the
21 * various device drivers from your application. You may also use
22 * this file in order to override the device drivers default settings.
23 *
24 * @addtogroup HAL_CONF
25 * @{
26 */
27
28#ifndef HALCONF_H
29#define HALCONF_H
30
31#define _CHIBIOS_HAL_CONF_
32#define _CHIBIOS_HAL_CONF_VER_7_1_
33
34#include "mcuconf.h"
35
36/**
37 * @brief Enables the PAL subsystem.
38 */
39#if !defined(HAL_USE_PAL) || defined(__DOXYGEN__)
40#define HAL_USE_PAL TRUE
41#endif
42
43/**
44 * @brief Enables the ADC subsystem.
45 */
46#if !defined(HAL_USE_ADC) || defined(__DOXYGEN__)
47#define HAL_USE_ADC FALSE
48#endif
49
50/**
51 * @brief Enables the CAN subsystem.
52 */
53#if !defined(HAL_USE_CAN) || defined(__DOXYGEN__)
54#define HAL_USE_CAN FALSE
55#endif
56
57/**
58 * @brief Enables the cryptographic subsystem.
59 */
60#if !defined(HAL_USE_CRY) || defined(__DOXYGEN__)
61#define HAL_USE_CRY FALSE
62#endif
63
64/**
65 * @brief Enables the DAC subsystem.
66 */
67#if !defined(HAL_USE_DAC) || defined(__DOXYGEN__)
68#define HAL_USE_DAC FALSE
69#endif
70
71/**
72 * @brief Enables the EFlash subsystem.
73 */
74#if !defined(HAL_USE_EFL) || defined(__DOXYGEN__)
75#define HAL_USE_EFL FALSE
76#endif
77
78/**
79 * @brief Enables the GPT subsystem.
80 */
81#if !defined(HAL_USE_GPT) || defined(__DOXYGEN__)
82#define HAL_USE_GPT FALSE
83#endif
84
85/**
86 * @brief Enables the I2C subsystem.
87 */
88#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__)
89#define HAL_USE_I2C FALSE
90#endif
91
92/**
93 * @brief Enables the I2S subsystem.
94 */
95#if !defined(HAL_USE_I2S) || defined(__DOXYGEN__)
96#define HAL_USE_I2S FALSE
97#endif
98
99/**
100 * @brief Enables the ICU subsystem.
101 */
102#if !defined(HAL_USE_ICU) || defined(__DOXYGEN__)
103#define HAL_USE_ICU FALSE
104#endif
105
106/**
107 * @brief Enables the MAC subsystem.
108 */
109#if !defined(HAL_USE_MAC) || defined(__DOXYGEN__)
110#define HAL_USE_MAC FALSE
111#endif
112
113/**
114 * @brief Enables the MMC_SPI subsystem.
115 */
116#if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__)
117#define HAL_USE_MMC_SPI FALSE
118#endif
119
120/**
121 * @brief Enables the PWM subsystem.
122 */
123#if !defined(HAL_USE_PWM) || defined(__DOXYGEN__)
124#define HAL_USE_PWM FALSE
125#endif
126
127/**
128 * @brief Enables the RTC subsystem.
129 */
130#if !defined(HAL_USE_RTC) || defined(__DOXYGEN__)
131#define HAL_USE_RTC FALSE
132#endif
133
134/**
135 * @brief Enables the SDC subsystem.
136 */
137#if !defined(HAL_USE_SDC) || defined(__DOXYGEN__)
138#define HAL_USE_SDC FALSE
139#endif
140
141/**
142 * @brief Enables the SERIAL subsystem.
143 */
144#if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__)
145#define HAL_USE_SERIAL FALSE
146#endif
147
148/**
149 * @brief Enables the SERIAL over USB subsystem.
150 */
151#if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__)
152#define HAL_USE_SERIAL_USB FALSE
153#endif
154
155/**
156 * @brief Enables the SIO subsystem.
157 */
158#if !defined(HAL_USE_SIO) || defined(__DOXYGEN__)
159#define HAL_USE_SIO FALSE
160#endif
161
162/**
163 * @brief Enables the SPI subsystem.
164 */
165#if !defined(HAL_USE_SPI) || defined(__DOXYGEN__)
166#define HAL_USE_SPI FALSE
167#endif
168
169/**
170 * @brief Enables the TRNG subsystem.
171 */
172#if !defined(HAL_USE_TRNG) || defined(__DOXYGEN__)
173#define HAL_USE_TRNG FALSE
174#endif
175
176/**
177 * @brief Enables the UART subsystem.
178 */
179#if !defined(HAL_USE_UART) || defined(__DOXYGEN__)
180#define HAL_USE_UART TRUE
181#endif
182
183/**
184 * @brief Enables the USB subsystem.
185 */
186#if !defined(HAL_USE_USB) || defined(__DOXYGEN__)
187#define HAL_USE_USB FALSE
188#endif
189
190/**
191 * @brief Enables the WDG subsystem.
192 */
193#if !defined(HAL_USE_WDG) || defined(__DOXYGEN__)
194#define HAL_USE_WDG FALSE
195#endif
196
197/**
198 * @brief Enables the WSPI subsystem.
199 */
200#if !defined(HAL_USE_WSPI) || defined(__DOXYGEN__)
201#define HAL_USE_WSPI FALSE
202#endif
203
204/*===========================================================================*/
205/* PAL driver related settings. */
206/*===========================================================================*/
207
208/**
209 * @brief Enables synchronous APIs.
210 * @note Disabling this option saves both code and data space.
211 */
212#if !defined(PAL_USE_CALLBACKS) || defined(__DOXYGEN__)
213#define PAL_USE_CALLBACKS TRUE
214#endif
215
216/**
217 * @brief Enables synchronous APIs.
218 * @note Disabling this option saves both code and data space.
219 */
220#if !defined(PAL_USE_WAIT) || defined(__DOXYGEN__)
221#define PAL_USE_WAIT TRUE
222#endif
223
224/*===========================================================================*/
225/* ADC driver related settings. */
226/*===========================================================================*/
227
228/**
229 * @brief Enables synchronous APIs.
230 * @note Disabling this option saves both code and data space.
231 */
232#if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__)
233#define ADC_USE_WAIT TRUE
234#endif
235
236/**
237 * @brief Enables the @p adcAcquireBus() and @p adcReleaseBus() APIs.
238 * @note Disabling this option saves both code and data space.
239 */
240#if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
241#define ADC_USE_MUTUAL_EXCLUSION TRUE
242#endif
243
244/*===========================================================================*/
245/* CAN driver related settings. */
246/*===========================================================================*/
247
248/**
249 * @brief Sleep mode related APIs inclusion switch.
250 */
251#if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__)
252#define CAN_USE_SLEEP_MODE TRUE
253#endif
254
255/**
256 * @brief Enforces the driver to use direct callbacks rather than OSAL events.
257 */
258#if !defined(CAN_ENFORCE_USE_CALLBACKS) || defined(__DOXYGEN__)
259#define CAN_ENFORCE_USE_CALLBACKS FALSE
260#endif
261
262/*===========================================================================*/
263/* CRY driver related settings. */
264/*===========================================================================*/
265
266/**
267 * @brief Enables the SW fall-back of the cryptographic driver.
268 * @details When enabled, this option, activates a fall-back software
269 * implementation for algorithms not supported by the underlying
270 * hardware.
271 * @note Fall-back implementations may not be present for all algorithms.
272 */
273#if !defined(HAL_CRY_USE_FALLBACK) || defined(__DOXYGEN__)
274#define HAL_CRY_USE_FALLBACK FALSE
275#endif
276
277/**
278 * @brief Makes the driver forcibly use the fall-back implementations.
279 */
280#if !defined(HAL_CRY_ENFORCE_FALLBACK) || defined(__DOXYGEN__)
281#define HAL_CRY_ENFORCE_FALLBACK FALSE
282#endif
283
284/*===========================================================================*/
285/* DAC driver related settings. */
286/*===========================================================================*/
287
288/**
289 * @brief Enables synchronous APIs.
290 * @note Disabling this option saves both code and data space.
291 */
292#if !defined(DAC_USE_WAIT) || defined(__DOXYGEN__)
293#define DAC_USE_WAIT TRUE
294#endif
295
296/**
297 * @brief Enables the @p dacAcquireBus() and @p dacReleaseBus() APIs.
298 * @note Disabling this option saves both code and data space.
299 */
300#if !defined(DAC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
301#define DAC_USE_MUTUAL_EXCLUSION TRUE
302#endif
303
304/*===========================================================================*/
305/* I2C driver related settings. */
306/*===========================================================================*/
307
308/**
309 * @brief Enables the mutual exclusion APIs on the I2C bus.
310 */
311#if !defined(I2C_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
312#define I2C_USE_MUTUAL_EXCLUSION TRUE
313#endif
314
315/*===========================================================================*/
316/* MAC driver related settings. */
317/*===========================================================================*/
318
319/**
320 * @brief Enables the zero-copy API.
321 */
322#if !defined(MAC_USE_ZERO_COPY) || defined(__DOXYGEN__)
323#define MAC_USE_ZERO_COPY FALSE
324#endif
325
326/**
327 * @brief Enables an event sources for incoming packets.
328 */
329#if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__)
330#define MAC_USE_EVENTS TRUE
331#endif
332
333/*===========================================================================*/
334/* MMC_SPI driver related settings. */
335/*===========================================================================*/
336
337/**
338 * @brief Delays insertions.
339 * @details If enabled this options inserts delays into the MMC waiting
340 * routines releasing some extra CPU time for the threads with
341 * lower priority, this may slow down the driver a bit however.
342 * This option is recommended also if the SPI driver does not
343 * use a DMA channel and heavily loads the CPU.
344 */
345#if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__)
346#define MMC_NICE_WAITING TRUE
347#endif
348
349/*===========================================================================*/
350/* SDC driver related settings. */
351/*===========================================================================*/
352
353/**
354 * @brief Number of initialization attempts before rejecting the card.
355 * @note Attempts are performed at 10mS intervals.
356 */
357#if !defined(SDC_INIT_RETRY) || defined(__DOXYGEN__)
358#define SDC_INIT_RETRY 100
359#endif
360
361/**
362 * @brief Include support for MMC cards.
363 * @note MMC support is not yet implemented so this option must be kept
364 * at @p FALSE.
365 */
366#if !defined(SDC_MMC_SUPPORT) || defined(__DOXYGEN__)
367#define SDC_MMC_SUPPORT FALSE
368#endif
369
370/**
371 * @brief Delays insertions.
372 * @details If enabled this options inserts delays into the MMC waiting
373 * routines releasing some extra CPU time for the threads with
374 * lower priority, this may slow down the driver a bit however.
375 */
376#if !defined(SDC_NICE_WAITING) || defined(__DOXYGEN__)
377#define SDC_NICE_WAITING TRUE
378#endif
379
380/**
381 * @brief OCR initialization constant for V20 cards.
382 */
383#if !defined(SDC_INIT_OCR_V20) || defined(__DOXYGEN__)
384#define SDC_INIT_OCR_V20 0x50FF8000U
385#endif
386
387/**
388 * @brief OCR initialization constant for non-V20 cards.
389 */
390#if !defined(SDC_INIT_OCR) || defined(__DOXYGEN__)
391#define SDC_INIT_OCR 0x80100000U
392#endif
393
394/*===========================================================================*/
395/* SERIAL driver related settings. */
396/*===========================================================================*/
397
398/**
399 * @brief Default bit rate.
400 * @details Configuration parameter, this is the baud rate selected for the
401 * default configuration.
402 */
403#if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__)
404#define SERIAL_DEFAULT_BITRATE 38400
405#endif
406
407/**
408 * @brief Serial buffers size.
409 * @details Configuration parameter, you can change the depth of the queue
410 * buffers depending on the requirements of your application.
411 * @note The default is 16 bytes for both the transmission and receive
412 * buffers.
413 */
414#if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__)
415#define SERIAL_BUFFERS_SIZE 16
416#endif
417
418/*===========================================================================*/
419/* SERIAL_USB driver related setting. */
420/*===========================================================================*/
421
422/**
423 * @brief Serial over USB buffers size.
424 * @details Configuration parameter, the buffer size must be a multiple of
425 * the USB data endpoint maximum packet size.
426 * @note The default is 256 bytes for both the transmission and receive
427 * buffers.
428 */
429#if !defined(SERIAL_USB_BUFFERS_SIZE) || defined(__DOXYGEN__)
430#define SERIAL_USB_BUFFERS_SIZE 256
431#endif
432
433/**
434 * @brief Serial over USB number of buffers.
435 * @note The default is 2 buffers.
436 */
437#if !defined(SERIAL_USB_BUFFERS_NUMBER) || defined(__DOXYGEN__)
438#define SERIAL_USB_BUFFERS_NUMBER 2
439#endif
440
441/*===========================================================================*/
442/* SPI driver related settings. */
443/*===========================================================================*/
444
445/**
446 * @brief Enables synchronous APIs.
447 * @note Disabling this option saves both code and data space.
448 */
449#if !defined(SPI_USE_WAIT) || defined(__DOXYGEN__)
450#define SPI_USE_WAIT TRUE
451#endif
452
453/**
454 * @brief Enables circular transfers APIs.
455 * @note Disabling this option saves both code and data space.
456 */
457#if !defined(SPI_USE_CIRCULAR) || defined(__DOXYGEN__)
458#define SPI_USE_CIRCULAR FALSE
459#endif
460
461/**
462 * @brief Enables the @p spiAcquireBus() and @p spiReleaseBus() APIs.
463 * @note Disabling this option saves both code and data space.
464 */
465#if !defined(SPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
466#define SPI_USE_MUTUAL_EXCLUSION TRUE
467#endif
468
469/**
470 * @brief Handling method for SPI CS line.
471 * @note Disabling this option saves both code and data space.
472 */
473#if !defined(SPI_SELECT_MODE) || defined(__DOXYGEN__)
474#define SPI_SELECT_MODE SPI_SELECT_MODE_PAD
475#endif
476
477/*===========================================================================*/
478/* UART driver related settings. */
479/*===========================================================================*/
480
481/**
482 * @brief Enables synchronous APIs.
483 * @note Disabling this option saves both code and data space.
484 */
485#if !defined(UART_USE_WAIT) || defined(__DOXYGEN__)
486#define UART_USE_WAIT FALSE
487#endif
488
489/**
490 * @brief Enables the @p uartAcquireBus() and @p uartReleaseBus() APIs.
491 * @note Disabling this option saves both code and data space.
492 */
493#if !defined(UART_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
494#define UART_USE_MUTUAL_EXCLUSION FALSE
495#endif
496
497/*===========================================================================*/
498/* USB driver related settings. */
499/*===========================================================================*/
500
501/**
502 * @brief Enables synchronous APIs.
503 * @note Disabling this option saves both code and data space.
504 */
505#if !defined(USB_USE_WAIT) || defined(__DOXYGEN__)
506#define USB_USE_WAIT FALSE
507#endif
508
509/*===========================================================================*/
510/* WSPI driver related settings. */
511/*===========================================================================*/
512
513/**
514 * @brief Enables synchronous APIs.
515 * @note Disabling this option saves both code and data space.
516 */
517#if !defined(WSPI_USE_WAIT) || defined(__DOXYGEN__)
518#define WSPI_USE_WAIT TRUE
519#endif
520
521/**
522 * @brief Enables the @p wspiAcquireBus() and @p wspiReleaseBus() APIs.
523 * @note Disabling this option saves both code and data space.
524 */
525#if !defined(WSPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
526#define WSPI_USE_MUTUAL_EXCLUSION TRUE
527#endif
528
529#include "halconf_community.h"
530
531#endif /* HALCONF_H */
532
533/** @} */
diff --git a/lib/chibios-contrib/testhal/NRF52/NRF52832/UART/halconf_community.h b/lib/chibios-contrib/testhal/NRF52/NRF52832/UART/halconf_community.h
new file mode 100644
index 000000000..43fdbf869
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NRF52/NRF52832/UART/halconf_community.h
@@ -0,0 +1,173 @@
1/*
2 ChibiOS - Copyright (C) 2014 Uladzimir Pylinsky aka barthess
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#ifndef HALCONF_COMMUNITY_H
18#define HALCONF_COMMUNITY_H
19
20/**
21 * @brief Enables the community overlay.
22 */
23#if !defined(HAL_USE_COMMUNITY) || defined(__DOXYGEN__)
24#define HAL_USE_COMMUNITY TRUE
25#endif
26
27/**
28 * @brief Enables the FSMC subsystem.
29 */
30#if !defined(HAL_USE_FSMC) || defined(__DOXYGEN__)
31#define HAL_USE_FSMC FALSE
32#endif
33
34/**
35 * @brief Enables the NAND subsystem.
36 */
37#if !defined(HAL_USE_NAND) || defined(__DOXYGEN__)
38#define HAL_USE_NAND FALSE
39#endif
40
41/**
42 * @brief Enables the 1-wire subsystem.
43 */
44#if !defined(HAL_USE_ONEWIRE) || defined(__DOXYGEN__)
45#define HAL_USE_ONEWIRE FALSE
46#endif
47
48/**
49 * @brief Enables the EICU subsystem.
50 */
51#if !defined(HAL_USE_EICU) || defined(__DOXYGEN__)
52#define HAL_USE_EICU FALSE
53#endif
54
55/**
56 * @brief Enables the CRC subsystem.
57 */
58#if !defined(HAL_USE_CRC) || defined(__DOXYGEN__)
59#define HAL_USE_CRC FALSE
60#endif
61
62/**
63 * @brief Enables the RNG subsystem.
64 */
65#if !defined(HAL_USE_RNG) || defined(__DOXYGEN__)
66#define HAL_USE_RNG FALSE
67#endif
68
69/**
70 * @brief Enables the EEPROM subsystem.
71 */
72#if !defined(HAL_USE_EEPROM) || defined(__DOXYGEN__)
73#define HAL_USE_EEPROM FALSE
74#endif
75
76/**
77 * @brief Enables the TIMCAP subsystem.
78 */
79#if !defined(HAL_USE_TIMCAP) || defined(__DOXYGEN__)
80#define HAL_USE_TIMCAP FALSE
81#endif
82
83/**
84 * @brief Enables the TIMCAP subsystem.
85 */
86#if !defined(HAL_USE_COMP) || defined(__DOXYGEN__)
87#define HAL_USE_COMP FALSE
88#endif
89
90/**
91 * @brief Enables the QEI subsystem.
92 */
93#if !defined(HAL_USE_QEI) || defined(__DOXYGEN__)
94#define HAL_USE_QEI FALSE
95#endif
96
97/**
98 * @brief Enables the USBH subsystem.
99 */
100#if !defined(HAL_USE_USBH) || defined(__DOXYGEN__)
101#define HAL_USE_USBH FALSE
102#endif
103
104/**
105 * @brief Enables the USB_MSD subsystem.
106 */
107#if !defined(HAL_USE_USB_MSD) || defined(__DOXYGEN__)
108#define HAL_USE_USB_MSD FALSE
109#endif
110
111/*===========================================================================*/
112/* FSMCNAND driver related settings. */
113/*===========================================================================*/
114
115/**
116 * @brief Enables the @p nandAcquireBus() and @p nanReleaseBus() APIs.
117 * @note Disabling this option saves both code and data space.
118 */
119#if !defined(NAND_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
120#define NAND_USE_MUTUAL_EXCLUSION TRUE
121#endif
122
123/*===========================================================================*/
124/* 1-wire driver related settings. */
125/*===========================================================================*/
126/**
127 * @brief Enables strong pull up feature.
128 * @note Disabling this option saves both code and data space.
129 */
130#define ONEWIRE_USE_STRONG_PULLUP FALSE
131
132/**
133 * @brief Enables search ROM feature.
134 * @note Disabling this option saves both code and data space.
135 */
136#define ONEWIRE_USE_SEARCH_ROM TRUE
137
138/*===========================================================================*/
139/* QEI driver related settings. */
140/*===========================================================================*/
141
142/**
143 * @brief Enables discard of overlow
144 */
145#if !defined(QEI_USE_OVERFLOW_DISCARD) || defined(__DOXYGEN__)
146#define QEI_USE_OVERFLOW_DISCARD FALSE
147#endif
148
149/**
150 * @brief Enables min max of overlow
151 */
152#if !defined(QEI_USE_OVERFLOW_MINMAX) || defined(__DOXYGEN__)
153#define QEI_USE_OVERFLOW_MINMAX FALSE
154#endif
155
156/*===========================================================================*/
157/* EEProm driver related settings. */
158/*===========================================================================*/
159
160/**
161 * @brief Enables 24xx series I2C eeprom device driver.
162 * @note Disabling this option saves both code and data space.
163 */
164#define EEPROM_USE_EE24XX FALSE
165 /**
166 * @brief Enables 25xx series SPI eeprom device driver.
167 * @note Disabling this option saves both code and data space.
168 */
169#define EEPROM_USE_EE25XX FALSE
170
171#endif /* HALCONF_COMMUNITY_H */
172
173/** @} */
diff --git a/lib/chibios-contrib/testhal/NRF52/NRF52832/UART/main.c b/lib/chibios-contrib/testhal/NRF52/NRF52832/UART/main.c
new file mode 100644
index 000000000..00a00e0fb
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NRF52/NRF52832/UART/main.c
@@ -0,0 +1,144 @@
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
20static virtual_timer_t vt1, vt2;
21
22static void restart(void *p) {
23
24 (void)p;
25
26 chSysLockFromISR();
27 uartStartSendI(&UARTD1, 14, "Hello World!\r\n");
28 chSysUnlockFromISR();
29}
30
31static void ledoff(void *p) {
32
33 (void)p;
34
35 palSetPad(IOPORT1, LED1);
36}
37
38/*
39 * This callback is invoked when a transmission buffer has been completely
40 * read by the driver.
41 */
42static void txend1(UARTDriver *uartp) {
43
44 (void)uartp;
45
46 palClearPad(IOPORT1, LED1);
47}
48
49/*
50 * This callback is invoked when a transmission has physically completed.
51 */
52static void txend2(UARTDriver *uartp) {
53
54 (void)uartp;
55
56 palSetPad(IOPORT1, LED1);
57 chSysLockFromISR();
58 chVTResetI(&vt1);
59 chVTDoSetI(&vt1, TIME_MS2I(5000), restart, NULL);
60 chSysUnlockFromISR();
61}
62
63/*
64 * This callback is invoked on a receive error, the errors mask is passed
65 * as parameter.
66 */
67static void rxerr(UARTDriver *uartp, uartflags_t e) {
68
69 (void)uartp;
70 (void)e;
71}
72
73/*
74 * This callback is invoked when a character is received but the application
75 * was not ready to receive it, the character is passed as parameter.
76 */
77static void rxchar(UARTDriver *uartp, uint16_t c) {
78
79 (void)uartp;
80 (void)c;
81
82 /* Flashing the LED each time a character is received.*/
83 palClearPad(IOPORT1, LED1);
84 chSysLockFromISR();
85 chVTResetI(&vt2);
86 chVTDoSetI(&vt2, TIME_MS2I(200), ledoff, NULL);
87 chSysUnlockFromISR();
88}
89
90/*
91 * This callback is invoked when a receive buffer has been completely written.
92 */
93static void rxend(UARTDriver *uartp) {
94
95 (void)uartp;
96}
97
98/*
99 * UART driver configuration structure.
100 */
101static UARTConfig uart_cfg_1 = {
102 txend1,
103 txend2,
104 rxend,
105 rxchar,
106 rxerr,
107 38400,
108 UART_TX,
109 UART_RX,
110};
111
112/*
113 * Application entry point.
114 */
115int main(void) {
116
117 /*
118 * System initializations.
119 * - HAL initialization, this also initializes the configured device drivers
120 * and performs the board-specific initializations.
121 * - Kernel initialization, the main() function becomes a thread and the
122 * RTOS is active.
123 */
124 halInit();
125 chSysInit();
126
127 /*
128 * Activates the serial driver 2 using the driver default configuration.
129 */
130 uartStart(&UARTD1, &uart_cfg_1);
131
132 /*
133 * Starts the transmission, it will be handled entirely in background.
134 */
135 uartStartSend(&UARTD1, 13, "Starting...\r\n");
136
137 /*
138 * Normal main() thread activity, in this demo it does nothing.
139 */
140 while (true) {
141 chThdSleepMilliseconds(500);
142 }
143 return 0;
144}
diff --git a/lib/chibios-contrib/testhal/NRF52/NRF52832/UART/mcuconf.h b/lib/chibios-contrib/testhal/NRF52/NRF52832/UART/mcuconf.h
new file mode 100644
index 000000000..40cf780d8
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NRF52/NRF52832/UART/mcuconf.h
@@ -0,0 +1,29 @@
1/*
2 Copyright (C) 2015 Stephen Caudle
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#ifndef _MCUCONF_H_
18#define _MCUCONF_H_
19
20/*
21 * HAL driver system settings.
22 */
23#define NRF5_UART_USE_UART0 TRUE
24#define NRF5_UART_UART0_IRQ_PRIORITY 3
25#define NRF5_ST_USE_RTC0 TRUE
26#define NRF5_ST_USE_RTC1 FALSE
27#define NRF5_ST_USE_TIMER0 FALSE
28
29#endif /* _MCUCONF_H_ */
diff --git a/lib/chibios-contrib/testhal/NRF52/NRF52832/UART/readme.txt b/lib/chibios-contrib/testhal/NRF52/NRF52832/UART/readme.txt
new file mode 100644
index 000000000..a9c25f99c
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NRF52/NRF52832/UART/readme.txt
@@ -0,0 +1,17 @@
1*****************************************************************************
2** ChibiOS/HAL - UART driver demo for NRF52832. **
3*****************************************************************************
4
5** TARGET **
6
7The demo runs on an EByte E73-2G4M04S board.
8
9** The Demo **
10
11The application demonstrates the use of the NRF52832 UART driver.
12
13** Build Procedure **
14
15The demo has been tested using the free Codesourcery GCC-based toolchain
16and YAGARTO.
17Just modify the TRGT line in the makefile in order to use different GCC ports.