Skip to content

Commit 9bb1360

Browse files
committed
Merge branch 'develop'
2 parents 93745b5 + 8ab8279 commit 9bb1360

80 files changed

Lines changed: 1321 additions & 468 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

boards/m5stack-nanoh2.json

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
{
22
"build": {
3-
"core": "esp32",
3+
"core": "esp32",
44
"extra_flags": [
55
"-DARDUINO_M5STACK_NANO_H2"
66
],
7-
"f_cpu": "96000000L",
8-
"f_flash": "16000000L",
9-
"flash_mode": "qio",
10-
"mcu": "esp32h2",
11-
"variant": "esp32h2"
7+
"f_cpu": "96000000L",
8+
"f_flash": "16000000L",
9+
"flash_mode": "qio",
10+
"mcu": "esp32h2",
11+
"variant": "esp32h2"
1212
},
1313
"connectivity": [
14-
"bluetooth",
15-
"zigbee"
14+
"bluetooth",
15+
"zigbee"
1616
],
1717
"debug": {
18-
"openocd_target": "esp32h2.cfg"
18+
"openocd_target": "esp32h2.cfg"
1919
},
2020
"frameworks": [
21-
"arduino",
22-
"espidf"
21+
"arduino",
22+
"espidf"
2323
],
2424
"name": "M5Stack NanoH2",
2525
"upload": {
26-
"flash_size": "4MB",
27-
"maximum_ram_size": 327680,
28-
"maximum_size": 4194304,
29-
"require_upload_port": true,
30-
"speed": 460800
26+
"flash_size": "4MB",
27+
"maximum_ram_size": 327680,
28+
"maximum_size": 4194304,
29+
"require_upload_port": true,
30+
"speed": 460800
3131
},
3232
"url": "https://docs.m5stack.com/en/core/M5NanoH2",
3333
"vendor": "M5Stack"

cap_cc1101_env.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
; For CapCC1101 / CapCC1101NFC (SPI, ST25R3916)
2+
;
3+
; Every env here extends [Cardputer]: Cardputer-Adv builds exactly like the plain Cardputer
4+
; (generic ESP32-S3), and M5.getBoard() tells board_M5CardputerADV apart at runtime. A separate
5+
; [CardputerADV] section would only repeat the same settings.
26

37
; --------------------------------
48
; UnitTest

examples/UnitUnified/NFCA/Detect/Detect.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
// *************************************************************
1414
#if !defined(USING_UNIT_NFC) && !defined(USING_CAP_CC1101) && !defined(USING_UNIT_RFID2) && \
1515
!defined(USING_M5DIAL_BUILTIN_WS1850S)
16-
// For UnitNFC (ST25R3916, I2C)
16+
// For UnitNFC (U216)
1717
// #define USING_UNIT_NFC
18-
// For CapCC1101NFC (ST25R3916, SPI)
18+
// For CapCC1101 (U219)
1919
// #define USING_CAP_CC1101
20-
// For UnitRFID2 (WS1850S external, I2C GROVE)
20+
// For UnitRFID2 (U031-B)
2121
// #define USING_UNIT_RFID2
22-
// For M5Dial Builtin WS1850S (internal I2C)
22+
// For M5Dial Builtin WS1850S (K130)
2323
// #define USING_M5DIAL_BUILTIN_WS1850S
2424
#endif
2525
#include "main/Detect.cpp"

examples/UnitUnified/NFCA/Detect/main/idf_component.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
## Dependencies for the ESP-IDF build of the NFC-A Detect example.
2-
## - M5Unit-NFC is taken from a local checkout (override_path) so in-progress changes on
3-
## this dev machine are picked up without re-fetching.
4-
## - M5UnitUnified is NOT listed here: it is declared as a dependency of M5Unit-NFC's own
5-
## idf_component.yml (root manifest), currently pinned to feature/esp-idf-native-support.
6-
## The component manager pulls it in transitively. Update the root manifest when the
7-
## feature branch is merged / a release ships.
8-
## - M5Unified >=0.2.17 declares M5GFX as a transitive dependency in its idf_component.yml.
9-
## Earlier release 0.2.16 was missing the declaration which caused a manual M5GFX entry
10-
## to be required here; with 0.2.17 the registry version is self-contained.
2+
## - M5Unit-NFC is taken from this repository itself (self reference via path).
3+
## - M5UnitUnified is declared as a dependency of M5Unit-NFC's root idf_component.yml
4+
## and pulled in transitively by the component manager. That manifest tracks main until
5+
## M5UnitUnified is published to the ESP Component Registry, when it becomes >=x.y.z.
6+
## - M5Unified >=0.2.17 pulls in M5GFX transitively, so no explicit M5GFX entry is needed here.
117
dependencies:
128
idf: ">=5.0"
139
m5stack/M5Unit-NFC:

examples/UnitUnified/NFCA/Dump/Dump.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
// *************************************************************
1414
#if !defined(USING_UNIT_NFC) && !defined(USING_CAP_CC1101) && !defined(USING_UNIT_RFID2) && \
1515
!defined(USING_M5DIAL_BUILTIN_WS1850S)
16-
// For UnitNFC (ST25R3916, I2C)
16+
// For UnitNFC (U216)
1717
// #define USING_UNIT_NFC
18-
// For CapCC1101NFC (ST25R3916, SPI)
18+
// For CapCC1101 (U219)
1919
// #define USING_CAP_CC1101
20-
// For UnitRFID2 (WS1850S external, I2C GROVE)
20+
// For UnitRFID2 (U031-B)
2121
// #define USING_UNIT_RFID2
22-
// For M5Dial Builtin WS1850S (internal I2C)
22+
// For M5Dial Builtin WS1850S (K130)
2323
// #define USING_M5DIAL_BUILTIN_WS1850S
2424
#endif
2525
#include "main/Dump.cpp"

examples/UnitUnified/NFCA/Dump/main/idf_component.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
## Dependencies for the ESP-IDF build of the NFC-A Dump example.
2-
## - M5Unit-NFC is taken from a local checkout (override_path) so in-progress changes on
3-
## this dev machine are picked up without re-fetching.
4-
## - M5UnitUnified is NOT listed here: it is declared as a dependency of M5Unit-NFC's own
5-
## idf_component.yml (root manifest), currently pinned to feature/esp-idf-native-support.
6-
## The component manager pulls it in transitively. Update the root manifest when the
7-
## feature branch is merged / a release ships.
8-
## - M5Unified >=0.2.17 declares M5GFX as a transitive dependency in its idf_component.yml.
9-
## Earlier release 0.2.16 was missing the declaration which caused a manual M5GFX entry
10-
## to be required here; with 0.2.17 the registry version is self-contained.
2+
## - M5Unit-NFC is taken from this repository itself (self reference via path).
3+
## - M5UnitUnified is declared as a dependency of M5Unit-NFC's root idf_component.yml
4+
## and pulled in transitively by the component manager. That manifest tracks main until
5+
## M5UnitUnified is published to the ESP Component Registry, when it becomes >=x.y.z.
6+
## - M5Unified >=0.2.17 pulls in M5GFX transitively, so no explicit M5GFX entry is needed here.
117
dependencies:
128
idf: ">=5.0"
139
m5stack/M5Unit-NFC:

examples/UnitUnified/NFCA/Emulation/Emulation.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
// UnitRFID2 (WS1850S) and M5Dial Builtin (WS1850S) do NOT support emulation.
1414
// *************************************************************
1515
#if !defined(USING_UNIT_NFC) && !defined(USING_CAP_CC1101)
16-
// For UnitNFC (ST25R3916, I2C)
16+
// For UnitNFC (U216)
1717
// #define USING_UNIT_NFC
18-
// For CapCC1101NFC (ST25R3916, SPI)
18+
// For CapCC1101 (U219)
1919
// #define USING_CAP_CC1101
2020
#endif
2121
#include "main/Emulation.cpp"

examples/UnitUnified/NFCA/Emulation/main/Emulation.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include <M5Utility.h>
1414
#include <wiring/m5_unit_unified_wiring.hpp>
1515
#include <vector>
16+
#include <algorithm>
17+
#include <cstring>
1618

1719
// *************************************************************
1820
// Choose ONE define symbol to match the unit you are using
@@ -143,6 +145,38 @@ uint8_t bcc8(const uint8_t* p, const uint8_t len, const uint8_t init = 0)
143145
}
144146

145147
// Correctly embed the Ultralight and NTAG UIDs into memory
148+
// The emulated memory as it stood at the last hold, so a hold shows only what the reader has
149+
// written since. A click prints everything and leaves this alone, so the two never interfere
150+
uint8_t picc_memory_seen[sizeof(picc_memory)]{};
151+
152+
void dump_emulated_memory(const bool only_changed)
153+
{
154+
constexpr uint16_t BLOCK_SIZE{4};
155+
const uint16_t blocks = (sizeof(picc_memory) + BLOCK_SIZE - 1) / BLOCK_SIZE;
156+
uint16_t shown{};
157+
158+
M5.Log.printf("==== Emulated memory (%s) ====\n", only_changed ? "changed since the last hold" : "all");
159+
for (uint16_t blk = 0; blk < blocks; ++blk) {
160+
const uint16_t offset = blk * BLOCK_SIZE;
161+
const uint16_t len = std::min<uint16_t>(BLOCK_SIZE, sizeof(picc_memory) - offset);
162+
if (only_changed && memcmp(picc_memory + offset, picc_memory_seen + offset, len) == 0) {
163+
continue;
164+
}
165+
M5.Log.printf("[%03X]:", offset);
166+
for (uint16_t i = 0; i < len; ++i) {
167+
M5.Log.printf("%02X ", picc_memory[offset + i]);
168+
}
169+
M5.Log.printf("\n");
170+
++shown;
171+
}
172+
if (only_changed) {
173+
if (!shown) {
174+
M5.Log.printf("No block has changed\n");
175+
}
176+
memcpy(picc_memory_seen, picc_memory, sizeof(picc_memory));
177+
}
178+
}
179+
146180
void embed_uid(uint8_t mem[9], const uint8_t uid[7])
147181
{
148182
memcpy(mem, uid, 3);
@@ -196,6 +230,7 @@ void setup()
196230
lcd.fillScreen(TFT_RED);
197231
if (picc.emulate(type, uid, sizeof(uid))) {
198232
embed_uid(picc_memory, uid);
233+
memcpy(picc_memory_seen, picc_memory, sizeof(picc_memory));
199234
if (emu_a.begin(picc, picc_memory, sizeof(picc_memory))) {
200235
lcd.fillScreen(TFT_DARKGREEN);
201236
lcd.setCursor(0, 16);
@@ -217,6 +252,14 @@ void loop()
217252
Units.update();
218253
emu_a.update(); // Need call in loop
219254

255+
// Take the phone away before asking, since printing stops the emulation answering for as long
256+
// as it runs
257+
if (M5.BtnA.wasClicked()) {
258+
dump_emulated_memory(false);
259+
} else if (M5.BtnA.wasHold()) {
260+
dump_emulated_memory(true);
261+
}
262+
220263
static EmulationLayerA::State latest{};
221264
auto state = emu_a.state();
222265
if (latest != state) {

examples/UnitUnified/NFCA/Emulation/main/idf_component.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
## Dependencies for the ESP-IDF build of the NFC-A Emulation example.
2-
## - M5Unit-NFC is taken from a local checkout (override_path) so in-progress changes on
3-
## this dev machine are picked up without re-fetching.
4-
## - M5UnitUnified is NOT listed here: it is declared as a dependency of M5Unit-NFC's own
5-
## idf_component.yml (root manifest), currently pinned to feature/esp-idf-native-support.
6-
## The component manager pulls it in transitively. Update the root manifest when the
7-
## feature branch is merged / a release ships.
8-
## - M5Unified >=0.2.17 declares M5GFX as a transitive dependency in its idf_component.yml.
9-
## Earlier release 0.2.16 was missing the declaration which caused a manual M5GFX entry
10-
## to be required here; with 0.2.17 the registry version is self-contained.
2+
## - M5Unit-NFC is taken from this repository itself (self reference via path).
3+
## - M5UnitUnified is declared as a dependency of M5Unit-NFC's root idf_component.yml
4+
## and pulled in transitively by the component manager. That manifest tracks main until
5+
## M5UnitUnified is published to the ESP Component Registry, when it becomes >=x.y.z.
6+
## - M5Unified >=0.2.17 pulls in M5GFX transitively, so no explicit M5GFX entry is needed here.
117
dependencies:
128
idf: ">=5.0"
139
m5stack/M5Unit-NFC:

examples/UnitUnified/NFCA/NDEF/NDEF.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
// *************************************************************
1414
#if !defined(USING_UNIT_NFC) && !defined(USING_CAP_CC1101) && !defined(USING_UNIT_RFID2) && \
1515
!defined(USING_M5DIAL_BUILTIN_WS1850S)
16-
// For UnitNFC (ST25R3916, I2C)
16+
// For UnitNFC (U216)
1717
// #define USING_UNIT_NFC
18-
// For CapCC1101NFC (ST25R3916, SPI)
18+
// For CapCC1101 (U219)
1919
// #define USING_CAP_CC1101
20-
// For UnitRFID2 (WS1850S external, I2C GROVE)
20+
// For UnitRFID2 (U031-B)
2121
// #define USING_UNIT_RFID2
22-
// For M5Dial Builtin WS1850S (internal I2C)
22+
// For M5Dial Builtin WS1850S (K130)
2323
// #define USING_M5DIAL_BUILTIN_WS1850S
2424
#endif
2525
#include "main/NDEF.cpp"

0 commit comments

Comments
 (0)