aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/I2C
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/I2C')
-rw-r--r--lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/I2C/Makefile212
-rw-r--r--lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/I2C/cfg/chconf.h773
-rw-r--r--lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/I2C/cfg/halconf.h531
-rw-r--r--lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/I2C/cfg/mcuconf.h33
-rw-r--r--lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/I2C/cfg/osalconf.h67
-rw-r--r--lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/I2C/main.c239
-rw-r--r--lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/I2C/readme.txt26
-rw-r--r--lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/I2C/ssd1306.c193
-rw-r--r--lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/I2C/ssd1306.h90
9 files changed, 2164 insertions, 0 deletions
diff --git a/lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/I2C/Makefile b/lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/I2C/Makefile
new file mode 100644
index 000000000..235d95b86
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/I2C/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 = -ggdb -g3 -gdwarf-3 -gstrict-dwarf -fomit-frame-pointer -falign-functions=16 -O
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# Enable this if you want to see the full log while compiling.
37ifeq ($(USE_VERBOSE_COMPILE),)
38 USE_VERBOSE_COMPILE = no
39endif
40
41# If enabled, this option makes the build process faster by not compiling
42# modules not used in the current configuration.
43ifeq ($(USE_SMART_BUILD),)
44 USE_SMART_BUILD = yes
45endif
46
47#
48# Build global options
49##############################################################################
50
51##############################################################################
52# Architecture or project specific options
53#
54
55# Stack size to be allocated to the Cortex-M process stack. This stack is
56# the stack used by the main() thread.
57ifeq ($(USE_PROCESS_STACKSIZE),)
58 USE_PROCESS_STACKSIZE = 0x400
59endif
60
61# Stack size to the allocated to the Cortex-M main/exceptions stack. This
62# stack is used for processing interrupts and exceptions.
63ifeq ($(USE_EXCEPTIONS_STACKSIZE),)
64 USE_EXCEPTIONS_STACKSIZE = 0x400
65endif
66
67# Enables the use of FPU (no, softfp, hard).
68ifeq ($(USE_FPU),)
69 USE_FPU = no
70endif
71
72# FPU-related options.
73ifeq ($(USE_FPU_OPT),)
74 USE_FPU_OPT = -mfloat-abi=$(USE_FPU) -mfpu=fpv4-sp-d16
75endif
76
77#
78# Architecture or project specific options
79##############################################################################
80
81##############################################################################
82# Project, target, sources and paths
83#
84
85# Define project name here
86PROJECT = ch
87
88# Target settings.
89MCU = cortex-m0
90
91# Imported source files and paths.
92BASE_PATH := ../../../../../../..
93CHIBIOS := $(BASE_PATH)/ChibiOS/ChibiOS
94CHIBIOS_CONTRIB := $(BASE_PATH)/ChibiOS/ChibiOS-Contrib
95CONFDIR := ./cfg
96BUILDDIR := ./build
97DEPDIR := ./.dep
98
99# Licensing files.
100include $(CHIBIOS)/os/license/license.mk
101# Startup files.
102include $(CHIBIOS_CONTRIB)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_NUC123.mk
103# HAL-OSAL files (optional).
104include $(CHIBIOS)/os/hal/hal.mk
105include $(CHIBIOS_CONTRIB)/os/hal/ports/NUMICRO/NUC123/platform.mk
106include $(CHIBIOS_CONTRIB)/os/hal/boards/NUTINY-SDK-NUC123-V2.0/board.mk
107#include $(CHIBIOS)/os/hal/osal/os-less/ARMCMx/osal.mk
108include $(CHIBIOS)/os/hal/osal/rt-nil/osal.mk
109# RTOS files (optional).
110#include $(CHIBIOS)/os/nil/nil.mk
111include $(CHIBIOS)/os/rt/rt.mk
112include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v6m.mk
113#include $(CHIBIOS)/os/common/ports/ARMv7-M/compilers/GCC/mk/port.mk
114# Auto-build files in ./source recursively.
115include $(CHIBIOS)/tools/mk/autobuild.mk
116# Other files (optional).
117#include $(CHIBIOS)/test/lib/test.mk
118#include $(CHIBIOS)/test/rt/rt_test.mk
119#include $(CHIBIOS)/test/oslib/oslib_test.mk
120
121# Define linker script file here
122LDSCRIPT= $(STARTUPLD_CONTRIB)/NUC123xD4xx0.ld
123
124# C sources that can be compiled in ARM or THUMB mode depending on the global
125# setting.
126CSRC = $(ALLCSRC) \
127 $(TESTSRC) \
128 main.c \
129 ssd1306.c
130
131# C++ sources that can be compiled in ARM or THUMB mode depending on the global
132# setting.
133CPPSRC = $(ALLCPPSRC)
134
135# List ASM source files here.
136ASMSRC = $(ALLASMSRC)
137
138# List ASM with preprocessor source files here.
139ASMXSRC = $(ALLXASMSRC)
140
141# Inclusion directories.
142INCDIR = $(CONFDIR) $(ALLINC) $(TESTINC)
143
144# Define C warning options here.
145CWARN = -Wall -Wextra -Wundef -Wstrict-prototypes
146
147# Define C++ warning options here.
148CPPWARN = -Wall -Wextra -Wundef
149
150#
151# Project, target, sources and paths
152##############################################################################
153
154##############################################################################
155# Start of user section
156#
157
158# List all user C define here, like -D_DEBUG=1
159UDEFS =
160
161# Define ASM defines here
162UADEFS =
163
164# List all user directories here
165UINCDIR =
166
167# List the user directory to look for the libraries here
168ULIBDIR =
169
170# List all user libraries here
171ULIBS =
172
173#
174# End of user section
175##############################################################################
176
177##############################################################################
178# Common rules
179#
180
181RULESPATH = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk
182include $(RULESPATH)/arm-none-eabi.mk
183include $(RULESPATH)/rules.mk
184
185#
186# Common rules
187##############################################################################
188
189##############################################################################
190# Custom rules
191#
192
193
194OPENOCD:=$(shell readlink -f `which openocd`)
195OPENOCDPATH:=$(shell dirname $(OPENOCD))/../share/openocd
196
197install-openocd-config:
198 rm $(OPENOCDPATH)/scripts/target/numicroM0.cfg && cp $(CHIBIOS_CONTRIB)/ext/numicroM0.cfg $(OPENOCDPATH)/scripts/target/
199
200connect:
201 openocd -f ../scripts/interface/nulink.cfg -f ../scripts/target/numicroM0.cfg
202
203flash: $(BUILDDIR)/$(PROJECT).elf
204 openocd -f ../scripts/interface/nulink.cfg -f ../scripts/target/numicroM0.cfg -c "program $< verify reset exit"
205
206
207
208
209#
210# Custom rules
211##############################################################################
212
diff --git a/lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/I2C/cfg/chconf.h b/lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/I2C/cfg/chconf.h
new file mode 100644
index 000000000..6255a9219
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/I2C/cfg/chconf.h
@@ -0,0 +1,773 @@
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 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#if !defined(CH_CFG_MAX_THREADS)
123#define CH_CFG_MAX_THREADS 8
124#endif
125
126#if !defined(CH_CFG_AUTOSTART_THREADS)
127#define CH_CFG_AUTOSTART_THREADS TRUE
128#endif
129
130#if !defined(CH_CFG_THREAD_EXT_FIELDS)
131#define CH_CFG_THREAD_EXT_FIELDS /* Add threads custom fields here.*/
132#endif
133
134#define CH_CFG_THREAD_EXT_INIT_HOOK(tr) { \
135 /* Add custom threads initialization code here.*/ \
136}
137
138/** @} */
139
140/*===========================================================================*/
141/**
142 * @name Performance options
143 * @{
144 */
145/*===========================================================================*/
146
147/**
148 * @brief OS optimization.
149 * @details If enabled then time efficient rather than space efficient code
150 * is used when two possible implementations exist.
151 *
152 * @note This is not related to the compiler optimization options.
153 * @note The default is @p TRUE.
154 */
155#if !defined(CH_CFG_OPTIMIZE_SPEED)
156#define CH_CFG_OPTIMIZE_SPEED TRUE
157#endif
158
159/** @} */
160
161/*===========================================================================*/
162/**
163 * @name Subsystem options
164 * @{
165 */
166/*===========================================================================*/
167
168/**
169 * @brief Time Measurement APIs.
170 * @details If enabled then the time measurement APIs are included in
171 * the kernel.
172 *
173 * @note The default is @p TRUE.
174 */
175#if !defined(CH_CFG_USE_TM)
176#define CH_CFG_USE_TM FALSE
177#endif
178
179/**
180 * @brief Threads registry APIs.
181 * @details If enabled then the registry APIs are included in the kernel.
182 *
183 * @note The default is @p TRUE.
184 */
185#if !defined(CH_CFG_USE_REGISTRY)
186#define CH_CFG_USE_REGISTRY TRUE
187#endif
188
189/**
190 * @brief Threads synchronization APIs.
191 * @details If enabled then the @p chThdWait() function is included in
192 * the kernel.
193 *
194 * @note The default is @p TRUE.
195 */
196#if !defined(CH_CFG_USE_WAITEXIT)
197#define CH_CFG_USE_WAITEXIT TRUE
198#endif
199
200/**
201 * @brief Semaphores APIs.
202 * @details If enabled then the Semaphores APIs are included in the kernel.
203 *
204 * @note The default is @p TRUE.
205 */
206#if !defined(CH_CFG_USE_SEMAPHORES)
207#define CH_CFG_USE_SEMAPHORES TRUE
208#endif
209
210/**
211 * @brief Semaphores queuing mode.
212 * @details If enabled then the threads are enqueued on semaphores by
213 * priority rather than in FIFO order.
214 *
215 * @note The default is @p FALSE. Enable this if you have special
216 * requirements.
217 * @note Requires @p CH_CFG_USE_SEMAPHORES.
218 */
219#if !defined(CH_CFG_USE_SEMAPHORES_PRIORITY)
220#define CH_CFG_USE_SEMAPHORES_PRIORITY FALSE
221#endif
222
223/**
224 * @brief Mutexes APIs.
225 * @details If enabled then the mutexes APIs are included in the kernel.
226 *
227 * @note The default is @p TRUE.
228 */
229#if !defined(CH_CFG_USE_MUTEXES)
230#define CH_CFG_USE_MUTEXES TRUE
231#endif
232
233/**
234 * @brief Enables recursive behavior on mutexes.
235 * @note Recursive mutexes are heavier and have an increased
236 * memory footprint.
237 *
238 * @note The default is @p FALSE.
239 * @note Requires @p CH_CFG_USE_MUTEXES.
240 */
241#if !defined(CH_CFG_USE_MUTEXES_RECURSIVE)
242#define CH_CFG_USE_MUTEXES_RECURSIVE FALSE
243#endif
244
245/**
246 * @brief Conditional Variables APIs.
247 * @details If enabled then the conditional variables APIs are included
248 * in the kernel.
249 *
250 * @note The default is @p TRUE.
251 * @note Requires @p CH_CFG_USE_MUTEXES.
252 */
253#if !defined(CH_CFG_USE_CONDVARS)
254#define CH_CFG_USE_CONDVARS FALSE
255#endif
256
257/**
258 * @brief Conditional Variables APIs with timeout.
259 * @details If enabled then the conditional variables APIs with timeout
260 * specification are included in the kernel.
261 *
262 * @note The default is @p TRUE.
263 * @note Requires @p CH_CFG_USE_CONDVARS.
264 */
265#if !defined(CH_CFG_USE_CONDVARS_TIMEOUT)
266#define CH_CFG_USE_CONDVARS_TIMEOUT TRUE
267#endif
268
269/**
270 * @brief Events Flags APIs.
271 * @details If enabled then the event flags APIs are included in the kernel.
272 *
273 * @note The default is @p TRUE.
274 */
275#if !defined(CH_CFG_USE_EVENTS)
276#define CH_CFG_USE_EVENTS TRUE
277#endif
278
279/**
280 * @brief Events Flags APIs with timeout.
281 * @details If enabled then the events APIs with timeout specification
282 * are included in the kernel.
283 *
284 * @note The default is @p TRUE.
285 * @note Requires @p CH_CFG_USE_EVENTS.
286 */
287#if !defined(CH_CFG_USE_EVENTS_TIMEOUT)
288#define CH_CFG_USE_EVENTS_TIMEOUT TRUE
289#endif
290
291/**
292 * @brief Synchronous Messages APIs.
293 * @details If enabled then the synchronous messages APIs are included
294 * in the kernel.
295 *
296 * @note The default is @p TRUE.
297 */
298#if !defined(CH_CFG_USE_MESSAGES)
299#define CH_CFG_USE_MESSAGES TRUE
300#endif
301
302/**
303 * @brief Synchronous Messages queuing mode.
304 * @details If enabled then messages are served by priority rather than in
305 * FIFO order.
306 *
307 * @note The default is @p FALSE. Enable this if you have special
308 * requirements.
309 * @note Requires @p CH_CFG_USE_MESSAGES.
310 */
311#if !defined(CH_CFG_USE_MESSAGES_PRIORITY)
312#define CH_CFG_USE_MESSAGES_PRIORITY FALSE
313#endif
314
315/**
316 * @brief Dynamic Threads APIs.
317 * @details If enabled then the dynamic threads creation APIs are included
318 * in the kernel.
319 *
320 * @note The default is @p TRUE.
321 * @note Requires @p CH_CFG_USE_WAITEXIT.
322 * @note Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS.
323 */
324#if !defined(CH_CFG_USE_DYNAMIC)
325#define CH_CFG_USE_DYNAMIC TRUE
326#endif
327
328/** @} */
329
330/*===========================================================================*/
331/**
332 * @name OSLIB options
333 * @{
334 */
335/*===========================================================================*/
336
337/**
338 * @brief Mailboxes APIs.
339 * @details If enabled then the asynchronous messages (mailboxes) APIs are
340 * included in the kernel.
341 *
342 * @note The default is @p TRUE.
343 * @note Requires @p CH_CFG_USE_SEMAPHORES.
344 */
345#if !defined(CH_CFG_USE_MAILBOXES)
346#define CH_CFG_USE_MAILBOXES TRUE
347#endif
348
349/**
350 * @brief Core Memory Manager APIs.
351 * @details If enabled then the core memory manager APIs are included
352 * in the kernel.
353 *
354 * @note The default is @p TRUE.
355 */
356#if !defined(CH_CFG_USE_MEMCORE)
357#define CH_CFG_USE_MEMCORE TRUE
358#endif
359
360/**
361 * @brief Managed RAM size.
362 * @details Size of the RAM area to be managed by the OS. If set to zero
363 * then the whole available RAM is used. The core memory is made
364 * available to the heap allocator and/or can be used directly through
365 * the simplified core memory allocator.
366 *
367 * @note In order to let the OS manage the whole RAM the linker script must
368 * provide the @p __heap_base__ and @p __heap_end__ symbols.
369 * @note Requires @p CH_CFG_USE_MEMCORE.
370 */
371#if !defined(CH_CFG_MEMCORE_SIZE)
372#define CH_CFG_MEMCORE_SIZE 0
373#endif
374
375/**
376 * @brief Heap Allocator APIs.
377 * @details If enabled then the memory heap allocator APIs are included
378 * in the kernel.
379 *
380 * @note The default is @p TRUE.
381 * @note Requires @p CH_CFG_USE_MEMCORE and either @p CH_CFG_USE_MUTEXES or
382 * @p CH_CFG_USE_SEMAPHORES.
383 * @note Mutexes are recommended.
384 */
385#if !defined(CH_CFG_USE_HEAP)
386#define CH_CFG_USE_HEAP TRUE
387#endif
388
389/**
390 * @brief Memory Pools Allocator APIs.
391 * @details If enabled then the memory pools allocator APIs are included
392 * in the kernel.
393 *
394 * @note The default is @p TRUE.
395 */
396#if !defined(CH_CFG_USE_MEMPOOLS)
397#define CH_CFG_USE_MEMPOOLS TRUE
398#endif
399
400/**
401 * @brief Objects FIFOs APIs.
402 * @details If enabled then the objects FIFOs APIs are included
403 * in the kernel.
404 *
405 * @note The default is @p TRUE.
406 */
407#if !defined(CH_CFG_USE_OBJ_FIFOS)
408#define CH_CFG_USE_OBJ_FIFOS TRUE
409#endif
410
411/**
412 * @brief Pipes APIs.
413 * @details If enabled then the pipes APIs are included
414 * in the kernel.
415 *
416 * @note The default is @p TRUE.
417 */
418#if !defined(CH_CFG_USE_PIPES)
419#define CH_CFG_USE_PIPES TRUE
420#endif
421
422/**
423 * @brief Objects Caches APIs.
424 * @details If enabled then the objects caches APIs are included
425 * in the kernel.
426 *
427 * @note The default is @p TRUE.
428 */
429#if !defined(CH_CFG_USE_OBJ_CACHES)
430#define CH_CFG_USE_OBJ_CACHES TRUE
431#endif
432
433/**
434 * @brief Delegate threads APIs.
435 * @details If enabled then the delegate threads APIs are included
436 * in the kernel.
437 *
438 * @note The default is @p TRUE.
439 */
440#if !defined(CH_CFG_USE_DELEGATES)
441#define CH_CFG_USE_DELEGATES TRUE
442#endif
443
444/**
445 * @brief Jobs Queues APIs.
446 * @details If enabled then the jobs queues APIs are included
447 * in the kernel.
448 *
449 * @note The default is @p TRUE.
450 */
451#if !defined(CH_CFG_USE_JOBS)
452#define CH_CFG_USE_JOBS TRUE
453#endif
454
455/** @} */
456
457/*===========================================================================*/
458/**
459 * @name Objects factory options
460 * @{
461 */
462/*===========================================================================*/
463
464/**
465 * @brief Objects Factory APIs.
466 * @details If enabled then the objects factory APIs are included in the
467 * kernel.
468 *
469 * @note The default is @p FALSE.
470 */
471#if !defined(CH_CFG_USE_FACTORY)
472#define CH_CFG_USE_FACTORY TRUE
473#endif
474
475/**
476 * @brief Maximum length for object names.
477 * @details If the specified length is zero then the name is stored by
478 * pointer but this could have unintended side effects.
479 */
480#if !defined(CH_CFG_FACTORY_MAX_NAMES_LENGTH)
481#define CH_CFG_FACTORY_MAX_NAMES_LENGTH 8
482#endif
483
484/**
485 * @brief Enables the registry of generic objects.
486 */
487#if !defined(CH_CFG_FACTORY_OBJECTS_REGISTRY)
488#define CH_CFG_FACTORY_OBJECTS_REGISTRY TRUE
489#endif
490
491/**
492 * @brief Enables factory for generic buffers.
493 */
494#if !defined(CH_CFG_FACTORY_GENERIC_BUFFERS)
495#define CH_CFG_FACTORY_GENERIC_BUFFERS TRUE
496#endif
497
498/**
499 * @brief Enables factory for semaphores.
500 */
501#if !defined(CH_CFG_FACTORY_SEMAPHORES)
502#define CH_CFG_FACTORY_SEMAPHORES TRUE
503#endif
504
505/**
506 * @brief Enables factory for mailboxes.
507 */
508#if !defined(CH_CFG_FACTORY_MAILBOXES)
509#define CH_CFG_FACTORY_MAILBOXES TRUE
510#endif
511
512/**
513 * @brief Enables factory for objects FIFOs.
514 */
515#if !defined(CH_CFG_FACTORY_OBJ_FIFOS)
516#define CH_CFG_FACTORY_OBJ_FIFOS TRUE
517#endif
518
519/**
520 * @brief Enables factory for Pipes.
521 */
522#if !defined(CH_CFG_FACTORY_PIPES) || defined(__DOXYGEN__)
523#define CH_CFG_FACTORY_PIPES TRUE
524#endif
525
526/** @} */
527
528/*===========================================================================*/
529/**
530 * @name Debug options
531 * @{
532 */
533/*===========================================================================*/
534
535/**
536 * @brief Debug option, kernel statistics.
537 *
538 * @note The default is @p FALSE.
539 */
540#if !defined(CH_DBG_STATISTICS)
541#define CH_DBG_STATISTICS FALSE
542#endif
543
544/**
545 * @brief Debug option, system state check.
546 * @details If enabled the correct call protocol for system APIs is checked
547 * at runtime.
548 *
549 * @note The default is @p FALSE.
550 */
551#if !defined(CH_DBG_SYSTEM_STATE_CHECK)
552#define CH_DBG_SYSTEM_STATE_CHECK FALSE
553#endif
554
555/**
556 * @brief Debug option, parameters checks.
557 * @details If enabled then the checks on the API functions input
558 * parameters are activated.
559 *
560 * @note The default is @p FALSE.
561 */
562#if !defined(CH_DBG_ENABLE_CHECKS)
563#define CH_DBG_ENABLE_CHECKS FALSE
564#endif
565
566/**
567 * @brief Debug option, consistency checks.
568 * @details If enabled then all the assertions in the kernel code are
569 * activated. This includes consistency checks inside the kernel,
570 * runtime anomalies and port-defined checks.
571 *
572 * @note The default is @p FALSE.
573 */
574#if !defined(CH_DBG_ENABLE_ASSERTS)
575#define CH_DBG_ENABLE_ASSERTS FALSE
576#endif
577
578/**
579 * @brief Debug option, trace buffer.
580 * @details If enabled then the trace buffer is activated.
581 *
582 * @note The default is @p CH_DBG_TRACE_MASK_DISABLED.
583 */
584#if !defined(CH_DBG_TRACE_MASK)
585#define CH_DBG_TRACE_MASK CH_DBG_TRACE_MASK_DISABLED
586#endif
587
588/**
589 * @brief Trace buffer entries.
590 * @note The trace buffer is only allocated if @p CH_DBG_TRACE_MASK is
591 * different from @p CH_DBG_TRACE_MASK_DISABLED.
592 */
593#if !defined(CH_DBG_TRACE_BUFFER_SIZE)
594#define CH_DBG_TRACE_BUFFER_SIZE 128
595#endif
596
597/**
598 * @brief Debug option, stack checks.
599 * @details If enabled then a runtime stack check is performed.
600 *
601 * @note The default is @p FALSE.
602 * @note The stack check is performed in a architecture/port dependent way.
603 * It may not be implemented or some ports.
604 * @note The default failure mode is to halt the system with the global
605 * @p panic_msg variable set to @p NULL.
606 */
607#if !defined(CH_DBG_ENABLE_STACK_CHECK)
608#define CH_DBG_ENABLE_STACK_CHECK FALSE
609#endif
610
611/**
612 * @brief Debug option, stacks initialization.
613 * @details If enabled then the threads working area is filled with a byte
614 * value when a thread is created. This can be useful for the
615 * runtime measurement of the used stack.
616 *
617 * @note The default is @p FALSE.
618 */
619#if !defined(CH_DBG_FILL_THREADS)
620#define CH_DBG_FILL_THREADS FALSE
621#endif
622
623/**
624 * @brief Debug option, threads profiling.
625 * @details If enabled then a field is added to the @p thread_t structure that
626 * counts the system ticks occurred while executing the thread.
627 *
628 * @note The default is @p FALSE.
629 * @note This debug option is not currently compatible with the
630 * tickless mode.
631 */
632#if !defined(CH_DBG_THREADS_PROFILING)
633#define CH_DBG_THREADS_PROFILING FALSE
634#endif
635
636/** @} */
637
638/*===========================================================================*/
639/**
640 * @name Kernel hooks
641 * @{
642 */
643/*===========================================================================*/
644
645/**
646 * @brief System structure extension.
647 * @details User fields added to the end of the @p ch_system_t structure.
648 */
649#define CH_CFG_SYSTEM_EXTRA_FIELDS \
650 /* Add threads custom fields here.*/
651
652/**
653 * @brief System initialization hook.
654 * @details User initialization code added to the @p chSysInit() function
655 * just before interrupts are enabled globally.
656 */
657#define CH_CFG_SYSTEM_INIT_HOOK() { \
658 /* Add threads initialization code here.*/ \
659}
660
661/**
662 * @brief Threads descriptor structure extension.
663 * @details User fields added to the end of the @p thread_t structure.
664 */
665#define CH_CFG_THREAD_EXTRA_FIELDS \
666 /* Add threads custom fields here.*/
667
668/**
669 * @brief Threads initialization hook.
670 * @details User initialization code added to the @p _thread_init() function.
671 *
672 * @note It is invoked from within @p _thread_init() and implicitly from all
673 * the threads creation APIs.
674 */
675#define CH_CFG_THREAD_INIT_HOOK(tp) { \
676 /* Add threads initialization code here.*/ \
677}
678
679/**
680 * @brief Threads finalization hook.
681 * @details User finalization code added to the @p chThdExit() API.
682 */
683#define CH_CFG_THREAD_EXIT_HOOK(tp) { \
684 /* Add threads finalization code here.*/ \
685}
686
687/**
688 * @brief Context switch hook.
689 * @details This hook is invoked just before switching between threads.
690 */
691#define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) { \
692 /* Context switch code here.*/ \
693}
694
695/**
696 * @brief ISR enter hook.
697 */
698#define CH_CFG_IRQ_PROLOGUE_HOOK() { \
699 /* IRQ prologue code here.*/ \
700}
701
702/**
703 * @brief ISR exit hook.
704 */
705#define CH_CFG_IRQ_EPILOGUE_HOOK() { \
706 /* IRQ epilogue code here.*/ \
707}
708
709/**
710 * @brief Idle thread enter hook.
711 * @note This hook is invoked within a critical zone, no OS functions
712 * should be invoked from here.
713 * @note This macro can be used to activate a power saving mode.
714 */
715#define CH_CFG_IDLE_ENTER_HOOK() { \
716 /* Idle-enter code here.*/ \
717}
718
719/**
720 * @brief Idle thread leave hook.
721 * @note This hook is invoked within a critical zone, no OS functions
722 * should be invoked from here.
723 * @note This macro can be used to deactivate a power saving mode.
724 */
725#define CH_CFG_IDLE_LEAVE_HOOK() { \
726 /* Idle-leave code here.*/ \
727}
728
729/**
730 * @brief Idle Loop hook.
731 * @details This hook is continuously invoked by the idle thread loop.
732 */
733#define CH_CFG_IDLE_LOOP_HOOK() { \
734 /* Idle loop code here.*/ \
735}
736
737/**
738 * @brief System tick event hook.
739 * @details This hook is invoked in the system tick handler immediately
740 * after processing the virtual timers queue.
741 */
742#define CH_CFG_SYSTEM_TICK_HOOK() { \
743 /* System tick event code here.*/ \
744}
745
746/**
747 * @brief System halt hook.
748 * @details This hook is invoked in case to a system halting error before
749 * the system is halted.
750 */
751#define CH_CFG_SYSTEM_HALT_HOOK(reason) { \
752 /* System halt code here.*/ \
753}
754
755/**
756 * @brief Trace hook.
757 * @details This hook is invoked each time a new record is written in the
758 * trace buffer.
759 */
760#define CH_CFG_TRACE_HOOK(tep) { \
761 /* Trace code here.*/ \
762}
763
764
765/** @} */
766
767/*===========================================================================*/
768/* Port-specific settings (override port settings defaulted in chcore.h). */
769/*===========================================================================*/
770
771#endif /* CHCONF_H */
772
773/** @} */
diff --git a/lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/I2C/cfg/halconf.h b/lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/I2C/cfg/halconf.h
new file mode 100644
index 000000000..ec8b26247
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/I2C/cfg/halconf.h
@@ -0,0 +1,531 @@
1/*
2 ChibiOS - Copyright (C) 2020 Alex Lewontin
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17/**
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 FALSE
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 FALSE
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 32
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#endif /* HALCONF_H */
530
531/** @} */
diff --git a/lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/I2C/cfg/mcuconf.h b/lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/I2C/cfg/mcuconf.h
new file mode 100644
index 000000000..0ca12d24d
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/I2C/cfg/mcuconf.h
@@ -0,0 +1,33 @@
1/*
2 Copyright (C) 2016 Stephane D'Alu
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 * Board setting
22 */
23
24/*
25 * HAL driver system settings.
26 */
27
28#define NUC123_I2C_USE_I2C0 TRUE
29#define NUC123_I2C_USE_I2C1 TRUE
30
31#define NUC123_MCUCONF
32
33#endif /* _MCUCONF_H_ */
diff --git a/lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/I2C/cfg/osalconf.h b/lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/I2C/cfg/osalconf.h
new file mode 100644
index 000000000..666d0c375
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/I2C/cfg/osalconf.h
@@ -0,0 +1,67 @@
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 Bare-metal OSAL configuration header.
20 *
21 * @addtogroup OSAL_CONF
22 * @{
23 */
24
25#ifndef OSALCONF_H
26#define OSALCONF_H
27
28/**
29 * @brief Frequency in Hertz of the system tick.
30 */
31#if !defined(OSAL_ST_FREQUENCY) || defined(__DOXYGEN__)
32#define OSAL_ST_FREQUENCY 10000
33#endif
34
35/**
36 * @brief Enables OSAL assertions.
37 */
38#if !defined(OSAL_DBG_ENABLE_ASSERTS) || defined(__DOXYGEN__)
39#define OSAL_DBG_ENABLE_ASSERTS FALSE
40#endif
41
42/**
43 * @brief Enables OSAL functions parameters checks.
44 */
45#if !defined(OSAL_DBG_ENABLE_CHECKS) || defined(__DOXYGEN__)
46#define OSAL_DBG_ENABLE_CHECKS FALSE
47#endif
48
49/**
50 * @brief OSAL initialization hook.
51 */
52#if !defined(OSAL_INIT_HOOK) || defined(__DOXYGEN__)
53#define OSAL_INIT_HOOK() { \
54}
55#endif
56
57/**
58 * @brief Idle loop hook macro.
59 */
60#if !defined(OSAL_IDLE_HOOK) || defined(__DOXYGEN__)
61#define OSAL_IDLE_HOOK() { \
62}
63#endif
64
65#endif /* OSALCONF_H */
66
67/** @} */
diff --git a/lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/I2C/main.c b/lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/I2C/main.c
new file mode 100644
index 000000000..82c56d6b3
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/I2C/main.c
@@ -0,0 +1,239 @@
1
2/*
3 Copyright (C) 2020 Ein Terakawa
4
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16*/
17
18#include "hal.h"
19#include "ssd1306.h"
20
21static const uint8_t logo_bits[] = {
22 0x00, 0x00, 0x00, 0x80, 0xF0, 0xF8, 0xFC, 0xFC,
23 0xFE, 0x3E, 0x1E, 0x1E, 0x7E, 0x7C, 0x7C, 0x78,
24 0x70, 0x40, 0x00, 0x00, 0xFE, 0xFE, 0xFE, 0xFE,
25 0xFE, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xC0, 0x00,
26 0x00, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0x00, 0x00,
27 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xC0, 0xE0, 0xE0,
28 0xE0, 0xC0, 0x00, 0x00, 0xEE, 0xEE, 0xEE, 0xEE,
29 0xEE, 0x00, 0x80, 0xF0, 0xF8, 0xFC, 0xFC, 0xFE,
30 0x1E, 0x1E, 0x1E, 0xFE, 0xFC, 0xFC, 0xF8, 0xF0,
31 0x80, 0x60, 0xF8, 0xFC, 0xFC, 0xFE, 0xFE, 0xDE,
32 0x9E, 0xBE, 0xBC, 0xBC, 0x38, 0x20, 0x00, 0x00,
33 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38 0x00, 0x00, 0x00, 0x01, 0x0F, 0x1F, 0x3F, 0x3F,
39 0x7F, 0x7C, 0x78, 0x78, 0x7E, 0x3E, 0x3E, 0x3E,
40 0x0E, 0x02, 0x00, 0x00, 0x7F, 0x7F, 0x7F, 0x7F,
41 0x7F, 0x00, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x00,
42 0x00, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x00, 0x00,
43 0x7F, 0x7F, 0x7F, 0x7F, 0x1F, 0x79, 0x7F, 0x7F,
44 0x7F, 0x3F, 0x0F, 0x00, 0x7F, 0x7F, 0x7F, 0x7F,
45 0x7F, 0x00, 0x01, 0x0F, 0x1F, 0x3F, 0x3F, 0x7F,
46 0x78, 0x78, 0x78, 0x7F, 0x3F, 0x3F, 0x1F, 0x0F,
47 0x01, 0x04, 0x1C, 0x3D, 0x3D, 0x7D, 0x79, 0x7B,
48 0x7B, 0x7F, 0x7F, 0x3F, 0x1F, 0x0C, 0x00, 0x00,
49 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
53 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
54 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
55 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
56 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
57 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
58 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
59 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFE, 0xFE, 0xFE,
60 0xFE, 0xFE, 0xF8, 0xC0, 0xFE, 0xFE, 0xFE, 0xFE,
61 0xFE, 0x00, 0x00, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
62 0xFE, 0x00, 0x00, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
63 0xFE, 0x00, 0x80, 0xF0, 0xF8, 0xFC, 0xFC, 0xFE,
64 0x3E, 0x1E, 0x1E, 0x7E, 0x7C, 0x7C, 0x78, 0x70,
65 0x40, 0x00, 0x38, 0x38, 0x38, 0xFE, 0xFE, 0xFE,
66 0xFE, 0xFE, 0xFE, 0x00, 0x00, 0x20, 0x38, 0x3C,
67 0x3C, 0x3E, 0x9E, 0x9E, 0xFE, 0xFE, 0xFC, 0xF8,
68 0x70, 0x00, 0x20, 0x38, 0x3C, 0xFC, 0xFE, 0xDE,
69 0xDE, 0xFE, 0xFE, 0x7C, 0x78, 0x20, 0x00, 0x00,
70 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
71 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
72 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
73 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
74 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
75 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x7F, 0x7F,
76 0x7F, 0x01, 0x07, 0x1F, 0x7F, 0x7F, 0x7F, 0x7F,
77 0x7F, 0x00, 0x00, 0x03, 0x0F, 0x1F, 0x3F, 0x7F,
78 0x7F, 0x7C, 0x7C, 0x7F, 0x7F, 0x3F, 0x3F, 0x1F,
79 0x03, 0x00, 0x01, 0x0F, 0x1F, 0x3F, 0x3F, 0x7F,
80 0x7C, 0x78, 0x78, 0x7E, 0x3E, 0x3E, 0x3E, 0x0E,
81 0x02, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x7F,
82 0x7F, 0x7F, 0x7F, 0x00, 0x00, 0x70, 0x7C, 0x7E,
83 0x7F, 0x7F, 0x7F, 0x7F, 0x7B, 0x7B, 0x79, 0x79,
84 0x78, 0x00, 0x04, 0x1C, 0x3C, 0x7D, 0x79, 0x79,
85 0x79, 0x7F, 0x7F, 0x3F, 0x3F, 0x0E, 0x00, 0x00,
86};
87
88static void draw_logo(SSD1306_DRIVER *ssd1306, bool invert, char xx) {
89 uint8_t width = ssd1306->width;
90 uint8_t height = ssd1306->height;
91 uint8_t num_pages = height / 8;
92 uint8_t invert_bits = invert ? 0xff : 0x00;
93 uint8_t *buf = SSD1306_GET_FRAMEBUFFER(ssd1306);
94
95 for (uint8_t row = 0; row < num_pages; ++row) {
96 for (uint8_t x = 0; x < width; ++x) {
97 uint8_t dat = logo_bits[(128 - xx + x) % 128 + (row % 4) * width];
98 if (row / 2 % 2 == 0) {
99 dat ^= 0xff;
100 }
101 dat ^= invert_bits; /* Invert Imeage Bits */
102 if (true) {
103 /* Horizontal Addressing Mode */
104 buf[row * width + x] = dat;
105 } else {
106 /* Vertical Addressing Mode */
107 buf[x * num_pages + row] = dat;
108 }
109 }
110 }
111}
112
113#define I2C_CLK_FREQ 1000000
114static const I2CConfig i2ccfg = { I2C_CLK_FREQ };
115#if NUC123_I2C_USE_I2C0
116DEFINE_SSD1306_DRIVER(ssd1306_128x64, &I2CD0, SSD1306_ADDRESS, 128, 64, false);
117#endif
118#if NUC123_I2C_USE_I2C1
119DEFINE_SSD1306_DRIVER(ssd1306_128x32, &I2CD1, SSD1306_ADDRESS, 128, 32, true);
120#endif
121
122#if I2C_USE_MUTUAL_EXCLUSION
123#define ACQUIRE_BUS(oled_driver) i2cAcquireBus((oled_driver)->i2cd)
124#define RELEASE_BUS(oled_driver) i2cReleaseBus((oled_driver)->i2cd)
125#else
126#define ACQUIRE_BUS(oled_driver)
127#define RELEASE_BUS(oled_driver)
128#endif
129
130thread_reference_t thread1_ref = NULL;
131
132static THD_WORKING_AREA(waThread1, 128);
133static THD_FUNCTION(Thread1, arg) {
134 chRegSetThreadName("blinker");
135
136 (void)arg;
137 while (true) {
138 if(osalThreadSuspendS(&thread1_ref) == MSG_OK) {
139 OnboardLED_On();
140 }else{
141 OnboardLED_Off();
142 }
143 }
144}
145
146#define I2C_THREAD_STACK_SIZE 256
147#if NUC123_I2C_USE_I2C0
148static THD_WORKING_AREA(waThread2, I2C_THREAD_STACK_SIZE);
149static THD_FUNCTION(Thread2, arg) {
150 chRegSetThreadName("oled1");
151
152 SSD1306_DRIVER *ssd1306 = (SSD1306_DRIVER *)arg;
153 ssd1306->i2ccfg = &i2ccfg;
154 ACQUIRE_BUS(ssd1306);
155 ssd1306_init(ssd1306);
156 RELEASE_BUS(ssd1306);
157 char x = 0;
158 while (true) {
159 osalThreadSleepMilliseconds(127);
160 bool invert = false;
161 draw_logo(ssd1306, invert, x);
162 ACQUIRE_BUS(ssd1306);
163 ssd1306_data(ssd1306);
164 /* RELEASE_BUS(ssd1306); */
165 /* ACQUIRE_BUS(ssd1306); */
166 if (x % 16 == 12) {
167 ssd1306_display_off(ssd1306);
168 } else if (x % 16 == 0) {
169 ssd1306_display_on(ssd1306);
170 }
171 RELEASE_BUS(ssd1306);
172 x = (x + 1) % 128;
173 }
174}
175#endif
176
177#if NUC123_I2C_USE_I2C1
178static THD_WORKING_AREA(waThread3, I2C_THREAD_STACK_SIZE);
179static THD_FUNCTION(Thread3, arg) {
180 chRegSetThreadName("oled2");
181
182 SSD1306_DRIVER *ssd1306 = (SSD1306_DRIVER *)arg;
183 ssd1306->i2ccfg = &i2ccfg;
184 ACQUIRE_BUS(ssd1306);
185#if true
186 /* Workaround for some 128x32 OLED modules typically with black PCB. */
187 while (!ssd1306_init(ssd1306)) {
188 RELEASE_BUS(ssd1306);
189 osalThreadSleepMilliseconds(100);
190 ACQUIRE_BUS(ssd1306);
191 }
192#endif
193 ssd1306_init(ssd1306);
194 RELEASE_BUS(ssd1306);
195 char x = 0;
196 while (true) {
197 osalThreadSleepMilliseconds(131);
198 bool invert = true;
199 draw_logo(ssd1306, invert, x);
200 ACQUIRE_BUS(ssd1306);
201 ssd1306_data(ssd1306);
202 RELEASE_BUS(ssd1306);
203 x = (x - 1) % 128;
204 }
205}
206#endif
207
208/*
209 * Application entry point.
210 */
211int main(void) {
212
213 /*
214 * System initializations.
215 * - HAL initialization, this also initializes the configured device drivers
216 * and performs the board-specific initializations.
217 */
218 halInit();
219
220 /*
221 * chSysInit() will also enable interrupts.
222 */
223 chSysInit();
224
225 chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO + 2, Thread1, NULL);
226#if NUC123_I2C_USE_I2C0
227 chThdCreateStatic(waThread2, sizeof(waThread2), NORMALPRIO + 1, Thread2, &ssd1306_128x64);
228#endif
229#if NUC123_I2C_USE_I2C1
230 chThdCreateStatic(waThread3, sizeof(waThread3), NORMALPRIO + 1, Thread3, &ssd1306_128x32);
231#endif
232
233 while (true) {
234 osalThreadResumeS(&thread1_ref, MSG_OK);
235 osalThreadSleepMilliseconds(100);
236 osalThreadResumeS(&thread1_ref, MSG_RESET);
237 osalThreadSleepMilliseconds(400);
238 }
239}
diff --git a/lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/I2C/readme.txt b/lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/I2C/readme.txt
new file mode 100644
index 000000000..0ef953c3c
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/I2C/readme.txt
@@ -0,0 +1,26 @@
1*****************************************************************************
2** ChibiOS/HAL - I2C driver demo for NUC123. **
3*****************************************************************************
4
5** TARGET **
6
7The demo runs on a NUTINY-SDK-NUC123-V2.0 board with a NUC123SD4AN0 MCU.
8
9** The Demo **
10
11The application demonstrates the use of the NUC123 platform driver, and a little
12bit of the PAL. A successful run of the test involves the on-board LED blinking at 2 Hz
13(on for 100 ms, then off for 400 ms).
14
15
16** Board Setup **
17
18- Connect 128x32 OLED module to PA.10=I2C1_SDA and PA.11=I2C1_SCL .
19- Connect 128x64 OLED module to PF.2=I2C0_SDA and PF.3=I2C0_SCL .
20- If any of the OLED modules are absent, pull-up resistors are required instead.
21
22** Build Procedure **
23
24The demo has been tested using gcc version 9.3.1 (GNU Arm Embedded Toolchain 9-2020-q2-update).
25Just add overriding setting for TRGT in the command line in order to use specific version of GCC.
26for example: make -j TRGT=/opt/ARM/gcc-arm-none-eabi-9-2020-q2-update/bin/arm-none-eabi-
diff --git a/lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/I2C/ssd1306.c b/lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/I2C/ssd1306.c
new file mode 100644
index 000000000..f4b37c195
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/I2C/ssd1306.c
@@ -0,0 +1,193 @@
1/*
2 Copyright (C) 2020 Ein Terakawa
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17#include "hal.h"
18#include "ssd1306.h"
19#include "string.h"
20
21/* timeout value must be increased for i2cclk less than its default, 100kHz. */
22#define CMD_TRANSMIT_TIMEOUT TIME_MS2I(10)
23#define DATA_TRANSMIT_TIMEOUT TIME_MS2I(100)
24
25#define CTRL_CMD_STREAM 0x00
26#define CTRL_DATA_STREAM 0x40
27#define CTRL_CMD_SINGLE 0x80
28
29#define I2CD ((ssd1306)->i2cd)
30#define ADDR ((ssd1306)->i2caddr)
31
32#define send_cmd(ssd1306, ...) \
33 do { \
34 uint8_t buf[] = { CTRL_CMD_STREAM, __VA_ARGS__ }; \
35 bool _success = _send_cmd(I2CD, ADDR, buf, sizeof(buf)); \
36 if (!_success) goto done; \
37 } while(0)
38
39#define send_cmd_static(ssd1306, ...) \
40 do{ \
41 static const uint8_t buf[] = { CTRL_CMD_STREAM, __VA_ARGS__ }; \
42 bool _success = _send_cmd(I2CD, ADDR, buf, sizeof(buf)); \
43 if (!_success) goto done; \
44 } while(0)
45
46#define CMD1(c) c
47#define CMD2(c, d) c, d
48#define CMD3(c, d, e) c, d, e
49
50static bool _send_cmd(I2CDriver *i2cd, uint8_t addr, const uint8_t *buf, int len) {
51
52 msg_t status = i2cMasterTransmitTimeout(i2cd, addr,
53 buf, len, NULL, 0, CMD_TRANSMIT_TIMEOUT);
54
55 if (MSG_OK != status) {
56 /* i2cflags_t error_code = i2cGetErrors(i2cd); */
57 return false;
58 }
59
60 return true;
61}
62
63#define send_data(ssd1306, buf, len) \
64 do { \
65 bool _success = _send_data(I2CD, ADDR, buf, len); \
66 if (!_success) goto done; \
67 } while(0)
68
69static bool _send_data(I2CDriver *i2cd, uint8_t addr, const uint8_t *buf, int len) {
70 bool success = false;
71
72 msg_t status = i2cMasterTransmitTimeout(i2cd, addr,
73 buf, len, NULL, 0, DATA_TRANSMIT_TIMEOUT);
74
75 if (MSG_OK != status) {
76 /* i2cflags_t error_code = i2cGetErrors(I2CD); */
77 goto done;
78 }
79
80 success = true;
81
82done:
83 return success;
84}
85
86bool ssd1306_init(SSD1306_DRIVER *ssd1306) {
87 bool success = false;
88 uint8_t width = ssd1306->width;
89 uint8_t height = ssd1306->height;
90 uint8_t num_pages = height / 8;
91
92 i2cStart(I2CD, ssd1306->i2ccfg);
93
94 send_cmd_static(ssd1306,
95 CMD1(SetDisplayOff),
96 CMD1(DeactivateScroll),
97 CMD1(DisableEntireDisplayOn),
98 CMD2(SetOscFreqAndClkDiv, 0x80),
99 CMD2(SetDisplayOffset, 0x00),
100 CMD1(SetDisplayStartLine | 0x00),
101 CMD2(SetMemoryAddressMode, 0x00)); /* Horizontal Addressing Mode */
102
103 send_cmd(ssd1306, CMD2(SetMultiplexRatio, height - 1));
104
105 if (ssd1306->rotate180) {
106 /* rotate 180 degrees == upside down */
107 send_cmd_static(ssd1306,
108 CMD1(SetSegmentRemapReverse),
109 CMD1(SetComScanOrderReverse));
110 } else {
111 /* no rotation */
112 send_cmd_static(ssd1306,
113 CMD1(SetSegmentRemapNormal),
114 CMD1(SetComScanOrderNormal));
115 }
116
117 if (height == 32) {
118 /* 128x32 module uses SequentialComMode */
119 send_cmd_static(ssd1306, CMD2(SetComPins, 0x02));
120 } else {
121 /* 128x64 module uses AlternativeComMode */
122 send_cmd_static(ssd1306, CMD2(SetComPins, 0x12));
123 }
124
125 /* Clear Graphic Display Data RAM */
126 send_cmd(ssd1306,
127 CMD3(SetPageAddress, 0, num_pages - 1),
128 CMD3(SetColumnAddress, 0, width - 1));
129
130 uint8_t *buf = ssd1306->buf;
131 size_t len = SSD1306_PREAMBLE_LENGTH + num_pages * width;
132 memset(buf, 0, len);
133 buf[0] = CTRL_DATA_STREAM; /* need this byte proceeding the actual data */
134 send_data(ssd1306, buf, len);
135
136 send_cmd_static(ssd1306,
137 CMD2(SetPreChargePeriod, 0xC4),
138 CMD2(SetVcomhLevel, 0x20),
139 CMD1(SetNormalDisplay),
140 CMD2(SetContrastControl, 0x3F),
141 CMD2(ChargePumpSetting, 0x14),
142 CMD1(SetDisplayOn));
143
144 success = true;
145
146done:
147 i2cStop(I2CD);
148 return success;
149}
150
151bool ssd1306_data(SSD1306_DRIVER *ssd1306) {
152 bool success = false;
153 uint8_t width = ssd1306->width;
154 uint8_t height = ssd1306->height;
155 uint8_t num_pages = height / 8;
156
157 i2cStart(I2CD, ssd1306->i2ccfg);
158
159 /* Transfer to Graphic Display Data RAM */
160 send_cmd(ssd1306,
161 CMD3(SetPageAddress, 0, num_pages - 1),
162 CMD3(SetColumnAddress, 0, width - 1));
163
164 uint8_t *buf = ssd1306->buf;
165 size_t len = SSD1306_PREAMBLE_LENGTH + num_pages * width;
166 send_data(ssd1306, buf, len);
167
168 success = true;
169
170done:
171 i2cStop(I2CD);
172 return success;
173}
174
175bool ssd1306_display_on(SSD1306_DRIVER *ssd1306) {
176 bool success = false;
177 i2cStart(I2CD, ssd1306->i2ccfg);
178 send_cmd_static(ssd1306, CMD1(SetDisplayOn));
179 success = true;
180done:
181 i2cStop(I2CD);
182 return success;
183}
184
185bool ssd1306_display_off(SSD1306_DRIVER *ssd1306) {
186 bool success = false;
187 i2cStart(I2CD, ssd1306->i2ccfg);
188 send_cmd_static(ssd1306, CMD1(SetDisplayOff));
189 success = true;
190done:
191 i2cStop(I2CD);
192 return success;
193}
diff --git a/lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/I2C/ssd1306.h b/lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/I2C/ssd1306.h
new file mode 100644
index 000000000..2ee7471a5
--- /dev/null
+++ b/lib/chibios-contrib/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/I2C/ssd1306.h
@@ -0,0 +1,90 @@
1#ifndef SSD1306_H
2#define SSD1306_H
3
4#include <chtypes.h>
5
6enum ssd1306_cmds {
7
8 /* Fundamental Command */
9 SetContrastControl = 0x81,
10 DisableEntireDisplayOn = 0xA4,
11 EnableEntireDisplayOn = 0xA5,
12 SetNormalDisplay = 0xA6,
13 SetInvertDisplay = 0xA7,
14 SetDisplayOff = 0xAE,
15 SetDisplayOn = 0xAF,
16
17 /* Charge Pump Command */
18 ChargePumpSetting = 0x8D,
19
20 /* Timing & Driving Scheme Setting Command */
21 SetOscFreqAndClkDiv = 0xD5,
22 SetPreChargePeriod = 0xD9,
23 SetVcomhLevel = 0xDB,
24
25 /* Addressing Setting Command */
26 SetMemoryAddressMode = 0x20,
27 SetColumnAddress = 0x21,
28 SetPageAddress = 0x22,
29 // SetLowColumn = 0x00, /* 0x00 - 0x0F */
30 // SetHighColumn = 0x10, /* 0x10 - 0x1F */
31 // SetPageStartAddress = 0xB0, /* 0xB0 - 0xB7 */
32
33 /* Hardware Configuration Command */
34 SetDisplayStartLine = 0x40, /* 0x40 - 0x7F */
35 SetSegmentRemapNormal = 0xA0,
36 SetSegmentRemapReverse = 0xA1,
37 SetMultiplexRatio = 0xA8,
38 SetComScanOrderNormal = 0xC0,
39 SetComScanOrderReverse = 0xC8,
40 SetDisplayOffset = 0xD3,
41 SetComPins = 0xDA,
42
43 /* Scrolling Command */
44 RightHorizontalScroll = 0x26,
45 LeftHorizontalScroll = 0x27,
46 VerticalAndRightHorizontalScroll = 0x29,
47 VerticalAndLeftHorizontalScroll = 0x2A,
48 DeactivateScroll = 0x2E,
49 ActivateScroll = 0x2F,
50 SetVerticalScrollArea = 0xA3,
51
52 /* Other Command */
53 NoOperation = 0xE3,
54};
55
56#ifndef SSD1306_ADDRESS
57/* for your reference (0x3C << 1) == 0x78 , (0x3D << 1) == 0x7A . */
58#define SSD1306_ADDRESS 0x3C
59#endif
60
61typedef struct I2CDriver I2CDriver;
62typedef struct I2CConfig I2CConfig;
63typedef struct SSD1306_DRIVER {
64 I2CDriver *i2cd;
65 I2CConfig const *i2ccfg;
66 uint8_t i2caddr;
67 uint8_t width;
68 uint8_t height;
69 bool rotate180;
70 uint8_t *buf;
71} SSD1306_DRIVER;
72
73#define SSD1306_PREAMBLE_LENGTH 1
74#define DEFINE_SSD1306_DRIVER(name, i2cd, addr, width, height, rotate180) \
75 _Static_assert(width == 128, "Only support width of 128 for simplicity."); \
76 _Static_assert(height == 32 || height == 64, "Only support height of 32 or 64 for simplicity."); \
77 uint8_t name##_buf[SSD1306_PREAMBLE_LENGTH + width * height / 8]; \
78 struct SSD1306_DRIVER name = { \
79 i2cd, NULL, addr, width, height, rotate180, name##_buf \
80 }
81
82#define SSD1306_GET_FRAMEBUFFER(ssd1306) \
83 (&((ssd1306)->buf[SSD1306_PREAMBLE_LENGTH]))
84
85bool ssd1306_init(SSD1306_DRIVER *ssd1306);
86bool ssd1306_data(SSD1306_DRIVER *ssd1306);
87bool ssd1306_display_on(SSD1306_DRIVER *ssd1306);
88bool ssd1306_display_off(SSD1306_DRIVER *ssd1306);
89
90#endif