Skip to content

Commit c192433

Browse files
committed
Merge branch 'develop'
2 parents c61a63c + c7e97fb commit c192433

14 files changed

Lines changed: 863 additions & 170 deletions

boards/m5stack-nanoc6.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"build": {
33
"core": "esp32",
44
"extra_flags": [
5-
"-DARDUINO_M5STACK_NANOC6"
5+
"-DARDUINO_M5STACK_NANO_C6"
66
],
77
"f_cpu": "160000000L",
88
"f_flash": "80000000L",
@@ -24,7 +24,7 @@
2424
"upload": {
2525
"flash_size": "4MB",
2626
"maximum_ram_size": 327680,
27-
"maximum_size": 4194384,
27+
"maximum_size": 4194304,
2828
"require_upload_port": true,
2929
"speed": 460800
3030
},

boards/m5stack-nanoh2.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"build": {
3+
"core": "esp32",
4+
"extra_flags": [
5+
"-DARDUINO_M5STACK_NANO_H2"
6+
],
7+
"f_cpu": "96000000L",
8+
"f_flash": "16000000L",
9+
"flash_mode": "qio",
10+
"mcu": "esp32h2",
11+
"variant": "esp32h2"
12+
},
13+
"connectivity": [
14+
"bluetooth",
15+
"zigbee"
16+
],
17+
"debug": {
18+
"openocd_target": "esp32h2.cfg"
19+
},
20+
"frameworks": [
21+
"arduino",
22+
"espidf"
23+
],
24+
"name": "M5Stack NanoH2",
25+
"upload": {
26+
"flash_size": "4MB",
27+
"maximum_ram_size": 327680,
28+
"maximum_size": 4194304,
29+
"require_upload_port": true,
30+
"speed": 460800
31+
},
32+
"url": "https://docs.m5stack.com/en/core/NanoH2",
33+
"vendor": "M5Stack"
34+
}

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"m5stack/M5Utility": ">=0.0.10",
1515
"m5stack/M5HAL": "*"
1616
},
17-
"version": "0.4.6",
17+
"version": "0.4.7",
1818
"frameworks": [
1919
"arduino"
2020
],

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=M5UnitUnified
2-
version=0.4.6
2+
version=0.4.7
33
author=M5Stack
44
maintainer=M5Stack
55
sentence=M5UnitUnified is a library for unified handling of various M5 units products.

platformio.ini

Lines changed: 49 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44
[platformio]
55

66
[env]
7-
build_flags = -Wall -Wextra -Wreturn-local-addr -Werror=format -Werror=return-local-addr
8-
7+
build_flags = -Wall -Wextra -Wreturn-local-addr -Werror=format -Werror=return-local-addr -Wl,--allow-multiple-definition
98
test_framework = googletest
109
test_build_src = true
11-
1210
lib_ldf_mode = deep
1311
lib_deps=m5stack/M5Unified
1412
m5stack/M5Utility
@@ -80,7 +78,18 @@ lib_deps = ${env.lib_deps}
8078
[NanoC6]
8179
extends = m5base
8280
board = m5stack-nanoc6
83-
board_build.partitions = default.csv
81+
build_flags =
82+
-DARDUINO_USB_CDC_ON_BOOT=1
83+
-DARDUINO_USB_MODE=1
84+
lib_deps = ${env.lib_deps}
85+
86+
; Using ./boards/m5stack-nanoh2.json
87+
[NanoH2]
88+
extends = m5base
89+
board = m5stack-nanoh2
90+
build_flags =
91+
-DARDUINO_USB_CDC_ON_BOOT=1
92+
-DARDUINO_USB_MODE=1
8493
lib_deps = ${env.lib_deps}
8594

8695
[StickCPlus]
@@ -131,6 +140,9 @@ extends = m5base
131140
board = esp32-p4-evboard
132141
board_build.mcu = esp32p4
133142
board_build.flash_mode = qio
143+
board_build.partitions = default_16MB.csv
144+
;monitor_dtr = 0
145+
;monitor_rts = 0
134146
build_flags =
135147
-DBOARD_HAS_PSRAM
136148
-DARDUINO_USB_CDC_ON_BOOT=1
@@ -161,13 +173,6 @@ lib_deps = ${env.lib_deps}
161173
platform = espressif32 @ 6.12.0
162174
framework = arduino
163175

164-
[nanoc6_latest]
165-
platform = espressif32 @ 6.12.0
166-
platform_packages =
167-
platformio/framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.7
168-
platformio/framework-arduinoespressif32-libs @ https://github.com/espressif/esp32-arduino-libs.git#idf-release/v5.1
169-
framework = arduino
170-
171176
[pioarduino_latest]
172177
platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.36/platform-espressif32.zip
173178
framework = arduino
@@ -218,12 +223,12 @@ lib_deps = google/googletest@1.12.1
218223
; M5HAL, M5Utility, M5Unit-* are resolved via symlinks in lib/
219224
; M5Unified via lib_deps (depends on M5GFX etc.)
220225
lib_extra_dirs = lib
221-
.
222-
lib_deps = m5stack/M5Unified
226+
.
227+
lib_deps = ${env.lib_deps}
223228
${test_fw.lib_deps}
224-
; Temporarily broken libs (uncomment to skip)
225-
;lib_ignore = M5Unit-RFID
226-
; M5Unit-CRYPTO
229+
lib_ignore = M5UnitUnified
230+
test_filter = embedded/test_update
231+
test_ignore = embedded/test_readme
227232

228233
[env:test_Core]
229234
extends=Core, option_release, test_base, arduino_latest
@@ -253,8 +258,18 @@ extends=AtomS3, option_release, test_base, arduino_latest
253258
extends=AtomS3R, option_release, test_base, arduino_latest
254259

255260
[env:test_NanoC6]
256-
extends=NanoC6, option_release, test_base, nanoc6_latest
257-
lib_ignore = bsec2
261+
extends=NanoC6, option_release, test_base, pioarduino_latest
262+
build_flags = ${NanoC6.build_flags}
263+
${option_release.build_flags}
264+
lib_ignore = ${test_base.lib_ignore}
265+
bsec2
266+
267+
[env:test_NanoH2]
268+
extends=NanoH2, option_release, test_base, pioarduino_latest
269+
build_flags = ${NanoH2.build_flags}
270+
${option_release.build_flags}
271+
lib_ignore = ${test_base.lib_ignore}
272+
bsec2
258273

259274
[env:test_StickCPlus]
260275
extends=StickCPlus, option_release, test_base, arduino_latest
@@ -282,6 +297,8 @@ build_flags = ${Cardputer.build_flags}
282297
extends=Tab5, option_release, test_base, pioarduino_latest
283298
build_flags = ${Tab5.build_flags}
284299
${option_release.build_flags}
300+
lib_ignore = ${test_base.lib_ignore}
301+
bsec2
285302

286303
[env:test_NessoN1]
287304
extends=NessoN1, option_release, test_base, pioarduino_latest
@@ -292,10 +309,11 @@ extends=NessoN1, option_release, test_base, pioarduino_latest
292309
; Works in CI without lib/ symlinks
293310
; --------------------------------
294311
[readme_base]
295-
lib_deps = m5stack/M5Unified
296-
m5stack/M5Utility
297-
m5stack/M5HAL
312+
lib_extra_dirs = lib
313+
.
314+
lib_deps = ${env.lib_deps}
298315
${test_fw.lib_deps}
316+
lib_ignore = M5UnitUnified
299317
test_filter = embedded/test_readme
300318
test_ignore = embedded/test_update
301319
build_flags = ${option_release.build_flags}
@@ -329,7 +347,14 @@ extends=AtomS3, readme_base, arduino_latest
329347
extends=AtomS3R, readme_base, arduino_latest
330348

331349
[env:test_readme_NanoC6]
332-
extends=NanoC6, readme_base, nanoc6_latest
350+
extends=NanoC6, readme_base, pioarduino_latest
351+
build_flags = ${NanoC6.build_flags}
352+
${option_release.build_flags}
353+
354+
[env:test_readme_NanoH2]
355+
extends=NanoH2, readme_base, pioarduino_latest
356+
build_flags = ${NanoH2.build_flags}
357+
${option_release.build_flags}
333358

334359
[env:test_readme_StickCPlus]
335360
extends=StickCPlus, readme_base, arduino_latest
@@ -357,6 +382,8 @@ build_flags = ${Cardputer.build_flags}
357382
extends=Tab5, readme_base, pioarduino_latest
358383
build_flags = ${Tab5.build_flags}
359384
${readme_base.build_flags}
385+
lib_ignore = ${test_base.lib_ignore}
386+
bsec2
360387

361388
[env:test_readme_NessoN1]
362389
extends=NessoN1, readme_base, pioarduino_latest

src/M5UnitComponent.cpp

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,35 @@ Component* Component::child(const uint8_t ch) const
135135

136136
bool Component::assign(m5::hal::bus::Bus* bus)
137137
{
138-
if (_addr) {
139-
_adapter = std::make_shared<AdapterI2C>(bus, _addr, _component_cfg.clock);
138+
if (!bus) {
139+
return false;
140+
}
141+
142+
// Bus type and unit access capability must agree
143+
switch (bus->getBusType()) {
144+
case m5::hal::types::BusType::I2C:
145+
if (!canAccessI2C() || !_addr) return false;
146+
_adapter = std::make_shared<AdapterI2C>(bus, _addr, _component_cfg.clock);
147+
return static_cast<bool>(_adapter);
148+
149+
case m5::hal::types::BusType::SPI:
150+
if (!canAccessSPI()) return false;
151+
M5_LIB_LOGE("M5HAL SPI bus assign is not yet implemented");
152+
return false;
153+
154+
case m5::hal::types::BusType::UART:
155+
if (!canAccessUART()) return false;
156+
M5_LIB_LOGE("M5HAL UART bus assign is not yet implemented");
157+
return false;
158+
159+
case m5::hal::types::BusType::GPIO:
160+
if (!canAccessGPIO()) return false;
161+
M5_LIB_LOGE("M5HAL GPIO bus assign is not yet implemented");
162+
return false;
163+
164+
default:
165+
return false;
140166
}
141-
return static_cast<bool>(_adapter);
142167
}
143168

144169
bool Component::assign(TwoWire& wire)

0 commit comments

Comments
 (0)