Skip to content

Commit a450ab7

Browse files
committed
Merge branch 'develop'
2 parents d8076ed + 71fe5f0 commit a450ab7

31 files changed

Lines changed: 1622 additions & 373 deletions

.github/workflows/arduino-esp-v2-build-check.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ jobs:
5959

6060
nfctype:
6161
- NFCA
62+
- NFCB
6263

6364
sketch:
6465
- Detect
@@ -85,7 +86,7 @@ jobs:
8586
- esp32
8687

8788
include:
88-
# Specific sketches
89+
# Specific sketches (NFCA, USING_UNIT_RFID2, Core only)
8990
- sketch: Dump
9091
nfctype: NFCA
9192
platform-url: https://espressif.github.io/arduino-esp32/package_esp32_index.json
@@ -118,6 +119,15 @@ jobs:
118119
platform-version: 2.0.17
119120
board: m5stack-core-esp32
120121
build-properties: "-DUSING_UNIT_RFID2"
122+
# JapanIDCard (NFCB, USING_UNIT_RFID2, Core only)
123+
- sketch: JapanIDCard
124+
nfctype: NFCB
125+
platform-url: https://espressif.github.io/arduino-esp32/package_esp32_index.json
126+
platform: esp32
127+
archi: esp32
128+
platform-version: 2.0.17
129+
board: m5stack-core-esp32
130+
build-properties: "-DUSING_UNIT_RFID2"
121131

122132
steps:
123133
- name: Checkout

.github/workflows/arduino-esp-v3-build-check.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ jobs:
5959

6060
nfctype:
6161
- NFCA
62+
- NFCB
6263

6364
sketch:
6465
- Detect
@@ -96,7 +97,7 @@ jobs:
9697
- esp32
9798

9899
include:
99-
# Specific sketches
100+
# Specific sketches (NFCA, USING_UNIT_RFID2, Core only)
100101
- sketch: Dump
101102
nfctype: NFCA
102103
platform-url: https://espressif.github.io/arduino-esp32/package_esp32_index.json
@@ -129,6 +130,24 @@ jobs:
129130
platform-version: 3.3.6
130131
board: m5stack_core
131132
build-properties: "-DUSING_UNIT_RFID2"
133+
# Detect on M5Dial with builtin WS1850S (NFCA, USING_M5DIAL_BUILTIN_WS1850S)
134+
- sketch: Detect
135+
nfctype: NFCA
136+
platform-url: https://espressif.github.io/arduino-esp32/package_esp32_index.json
137+
platform: esp32
138+
archi: esp32
139+
platform-version: 3.3.6
140+
board: m5stack_dial
141+
build-properties: "-DUSING_M5DIAL_BUILTIN_WS1850S"
142+
# JapanIDCard (NFCB, USING_UNIT_RFID2, Core only)
143+
- sketch: JapanIDCard
144+
nfctype: NFCB
145+
platform-url: https://espressif.github.io/arduino-esp32/package_esp32_index.json
146+
platform: esp32
147+
archi: esp32
148+
platform-version: 3.3.6
149+
board: m5stack_core
150+
build-properties: "-DUSING_UNIT_RFID2"
132151

133152
steps:
134153
- name: Checkout

.github/workflows/arduino-m5-build-check.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ jobs:
5959

6060
nfctype:
6161
- NFCA
62+
- NFCB
6263

6364
sketch:
6465
- Detect
@@ -100,7 +101,7 @@ jobs:
100101
- esp32
101102

102103
include:
103-
# Specific sketches
104+
# Specific sketches (NFCA, USING_UNIT_RFID2, Core only)
104105
- sketch: Dump
105106
nfctype: NFCA
106107
platform-url: https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/arduino/package_m5stack_index.json
@@ -133,6 +134,24 @@ jobs:
133134
platform-version: 3.2.5
134135
board: m5stack_core
135136
build-properties: "-DUSING_UNIT_RFID2"
137+
# Detect on M5Dial with builtin WS1850S (NFCA, USING_M5DIAL_BUILTIN_WS1850S)
138+
- sketch: Detect
139+
nfctype: NFCA
140+
platform-url: https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/arduino/package_m5stack_index.json
141+
platform: m5stack
142+
archi: esp32
143+
platform-version: 3.2.5
144+
board: m5stack_dial
145+
build-properties: "-DUSING_M5DIAL_BUILTIN_WS1850S"
146+
# JapanIDCard (NFCB, USING_UNIT_RFID2, Core only)
147+
- sketch: JapanIDCard
148+
nfctype: NFCB
149+
platform-url: https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/arduino/package_m5stack_index.json
150+
platform: m5stack
151+
archi: esp32
152+
platform-version: 3.2.5
153+
board: m5stack_core
154+
build-properties: "-DUSING_UNIT_RFID2"
136155

137156
steps:
138157
- name: Checkout

.github/workflows/platformio-build-check.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ jobs:
5555
matrix:
5656
example:
5757
- NFCA_Detect
58+
- NFCB_Detect
5859

5960
board:
6061
- Core
@@ -83,7 +84,7 @@ jobs:
8384
- latest
8485

8586
include:
86-
# Specific sketches
87+
# NFCA Specific sketches (Core only)
8788
- example: NFCA_Dump
8889
board: Core
8990
framework: Arduino
@@ -100,6 +101,16 @@ jobs:
100101
board: Core
101102
framework: Arduino
102103
espressif32: latest
104+
# NFCA Detect on M5Dial with builtin WS1850S
105+
- example: NFCA_Detect
106+
board: Dial_Builtin
107+
framework: Arduino
108+
espressif32: latest
109+
# NFCB JapanIDCard (Core only)
110+
- example: NFCB_JapanIDCard
111+
board: Core
112+
framework: Arduino
113+
espressif32: latest
103114

104115
steps:
105116
- name: Checkout

README.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,20 @@ Support may be expanded in future updates to cover PICCs not listed here.
4949

5050
- \*1 MIFARE Plus SL3 operation has issues.
5151

52+
### NFC-B
53+
54+
**Available on UnitRFID2 (WS1850S) only.** UnitRFID (MFRC522) does NOT support NFC-B.
55+
56+
| PICC Type | NFC Forum Tag (NDEF) | Detect | Identify | Raw R/W | Notes |
57+
|---|---|---|---|---|---|
58+
| Unclassified | None | Yes | Partial | Yes | ISO-DEP transport only |
59+
60+
> **Note:** NFC-B is **not supported on the M5Dial builtin WS1850S**. The builtin small loop antenna cannot generate sufficient RF field for Type B PICC activation (Type B uses 10% ASK + BPSK subcarrier which is more sensitive to field strength and SNR than Type A). NFC-B requires the external **UnitRFID2** (with larger antenna).
61+
5262

5363
## Emulation
5464

55-
Emulation is **NOT** supported on Unit-RFID.
65+
Emulation is **NOT** supported on UnitRFID and UnitRFID2.
5666

5767
## Known Issues
5868

@@ -84,14 +94,17 @@ Use **QWIIC port (port_a)** with a QWIIC-GROVE conversion cable instead.
8494
## Examples
8595
See also [examples/UnitUnified](examples/UnitUnified)
8696

97+
> **Note:** The examples in this library are imported from [M5Unit-NFC](https://github.com/m5stack/M5Unit-NFC) and shared between both libraries.
98+
> The same source file supports multiple units via `#define` switches.
99+
87100
### For ArduinoIDE
88101
Each example contains the following block to select the unit:
89102

90103
```cpp
91104
// For UnitNFC
92105
// #define USING_UNIT_NFC
93106
// For CapNFC
94-
// #define USING_HACKER_CAP
107+
// #define USING_CAP_CC1101
95108
// For UnitRFID2
96109
// #define USING_UNIT_RFID2
97110
```
@@ -101,7 +114,7 @@ For this library, uncomment `USING_UNIT_RFID2`:
101114

102115
```cpp
103116
// #define USING_UNIT_NFC
104-
// #define USING_HACKER_CAP
117+
// #define USING_CAP_CC1101
105118
#define USING_UNIT_RFID2
106119
```
107120

examples/UnitUnified/NFCA/Detect/Detect.ino

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,17 @@
99
This example is shared with M5Unit-RFID
1010
*/
1111
// *************************************************************
12-
// Choose one define symbol to match the unit you are using
12+
// Choose ONE define symbol to match the unit/board you are using
1313
// *************************************************************
14-
#if !defined(USING_UNIT_NFC) && !defined(USING_HACKER_CAP) && !defined(USING_UNIT_RFID2)
15-
// For UnitNFC
14+
#if !defined(USING_UNIT_NFC) && !defined(USING_CAP_CC1101) && !defined(USING_UNIT_RFID2) && \
15+
!defined(USING_M5DIAL_BUILTIN_WS1850S)
16+
// For UnitNFC (ST25R3916, I2C)
1617
// #define USING_UNIT_NFC
17-
// For CapNFC
18-
// #define USING_HACKER_CAP
19-
// For UnitRFID2
18+
// For CapCC1101NFC (ST25R3916, SPI)
19+
// #define USING_CAP_CC1101
20+
// For UnitRFID2 (WS1850S external, I2C GROVE)
2021
// #define USING_UNIT_RFID2
22+
// For M5Dial Builtin WS1850S (internal I2C)
23+
// #define USING_M5DIAL_BUILTIN_WS1850S
2124
#endif
2225
#include "main/Detect.cpp"

examples/UnitUnified/NFCA/Detect/main/Detect.cpp

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,24 @@
1313
#include <M5UnitUnifiedNFC.h>
1414
#include <M5Utility.h>
1515
#include <Wire.h>
16-
#include <M5HAL.hpp> // For NessoN1
1716
#include <vector>
1817

1918
// *************************************************************
20-
// Choose one define symbol to match the unit you are using
19+
// Choose ONE define symbol to match the unit/board you are using
2120
// *************************************************************
22-
#if !defined(USING_UNIT_NFC) && !defined(USING_HACKER_CAP) && !defined(USING_UNIT_RFID2)
23-
// For UnitNFC
21+
#if !defined(USING_UNIT_NFC) && !defined(USING_CAP_CC1101) && !defined(USING_UNIT_RFID2) && \
22+
!defined(USING_M5DIAL_BUILTIN_WS1850S)
23+
// For UnitNFC (ST25R3916, I2C)
2424
// #define USING_UNIT_NFC
25-
// For CapNFC
26-
// #define USING_HACKER_CAP
27-
// For UnitRFID2
25+
// For CapCC1101NFC (ST25R3916, SPI)
26+
// #define USING_CAP_CC1101
27+
// For UnitRFID2 (WS1850S external, I2C GROVE)
2828
// #define USING_UNIT_RFID2
29+
// For M5Dial Builtin WS1850S (internal I2C)
30+
// #define USING_M5DIAL_BUILTIN_WS1850S
2931
#endif
3032

31-
#if defined(USING_UNIT_RFID2)
33+
#if defined(USING_UNIT_RFID2) || defined(USING_M5DIAL_BUILTIN_WS1850S)
3234
#include <M5UnitUnifiedRFID.h>
3335
#endif
3436

@@ -41,14 +43,17 @@ m5::unit::UnitUnified Units;
4143
#if defined(USING_UNIT_NFC)
4244
#pragma message "Choose UnitNFC"
4345
m5::unit::UnitNFC unit{}; // I2C
44-
#elif defined(USING_HACKER_CAP)
45-
#pragma message "Choose HackerCapNFC"
46-
m5::unit::HackerCapNFC unit{}; // HackerCap (SPI)
46+
#elif defined(USING_CAP_CC1101)
47+
#pragma message "Choose CapCC1101NFC"
48+
m5::unit::CapCC1101NFC unit{}; // CapCC1101 (SPI)
4749
#elif defined(USING_UNIT_RFID2)
4850
#pragma message "Choose UnitRFID2"
49-
m5::unit::UnitRFID2 unit{}; // UnitRFID2 (M5Unit-RFID)
51+
m5::unit::UnitRFID2 unit{}; // UnitRFID2 external (M5Unit-RFID, GROVE)
52+
#elif defined(USING_M5DIAL_BUILTIN_WS1850S)
53+
#pragma message "Choose UnitRFID2 (M5Dial Builtin)"
54+
m5::unit::UnitRFID2 unit{}; // M5Dial builtin WS1850S (internal I2C)
5055
#else
51-
#error Choose unit please!
56+
#error Choose ONE: USING_UNIT_NFC / USING_CAP_CC1101 / USING_UNIT_RFID2 / USING_M5DIAL_BUILTIN_WS1850S
5257
#endif
5358
m5::nfc::NFCLayerA nfc_a{unit};
5459
} // namespace
@@ -63,25 +68,26 @@ void setup()
6368
lcd.setRotation(1);
6469
}
6570

66-
#if defined(USING_UNIT_NFC) || defined(USING_UNIT_RFID2)
67-
// NessoN1: Arduino Wire (I2C_NUM_0) cannot be used for GROVE port.
68-
// Wire is used by M5Unified In_I2C for internal devices.
69-
// Reconfiguring Wire to GROVE pins breaks In_I2C.
70-
// Solution: Use SoftwareI2C via M5HAL (bit-banging) for the GROVE port.
71-
// NanoC6: Wire.begin() on GROVE pins conflicts with Ex_I2C on the same I2C_NUM_0.
72-
// Solution: Use M5.Ex_I2C directly instead of Arduino Wire.
73-
auto board = M5.getBoard();
7471
bool unit_ready{};
72+
7573
#if defined(USING_M5DIAL_BUILTIN_WS1850S)
74+
// M5Dial builtin WS1850S: small loop antenna; reduce RxGain to 33dB to mitigate
75+
// reflection interference (default 48dB causes unstable WUPA on Builtin).
76+
{
77+
auto cfg = unit.config();
78+
cfg.receiver_gain = m5::unit::mfrc522::ReceiverGain::dB33;
79+
unit.config(cfg);
80+
}
7681
// M5Dial builtin WS1850S on In_I2C (G12/G11, shared with RTC8563)
7782
M5_LOGI("Using M5.In_I2C for builtin WS1850S");
7883
unit_ready = Units.add(unit, M5.In_I2C) && Units.begin();
79-
#else
80-
// NessoN1: port_b (GROVE) uses SoftwareI2C (M5HAL Bus) which causes I2C register
81-
// polling latency too high for MFRC522/WS1850S RF timing requirements.
82-
// Use QWIIC (port_a) with Wire instead. (Requires QWIIC-GROVE conversion cable)
83-
if (board == m5::board_t::board_M5NanoC6) {
84-
// NanoC6: Use M5.Ex_I2C (m5::I2C_Class, not Arduino Wire)
84+
85+
#elif defined(USING_UNIT_NFC) || defined(USING_UNIT_RFID2)
86+
// External I2C unit (GROVE port).
87+
// NessoN1: Arduino Wire (I2C_NUM_0) cannot be used for GROVE port (used by In_I2C internals).
88+
// Use QWIIC (port_a) with Wire. (Requires QWIIC-GROVE conversion cable)
89+
// NanoC6: Wire.begin() on GROVE pins conflicts with Ex_I2C on I2C_NUM_0; use M5.Ex_I2C directly.
90+
if (M5.getBoard() == m5::board_t::board_M5NanoC6) {
8591
M5_LOGI("Using M5.Ex_I2C");
8692
unit_ready = Units.add(unit, M5.Ex_I2C) && Units.begin();
8793
} else {
@@ -92,32 +98,26 @@ void setup()
9298
Wire.begin(pin_num_sda, pin_num_scl, 400 * 1000U);
9399
unit_ready = Units.add(unit, Wire) && Units.begin();
94100
}
95-
#endif // USING_M5DIAL_BUILTIN_WS1850S
96-
if (!unit_ready) {
97-
M5_LOGE("Failed to begin");
98-
lcd.fillScreen(TFT_RED);
99-
while (true) {
100-
m5::utility::delay(10000);
101-
}
102-
}
103-
#elif defined(USING_HACKER_CAP)
101+
102+
#elif defined(USING_CAP_CC1101)
104103
if (!SPI.bus()) {
105104
auto spi_sclk = M5.getPin(m5::pin_name_t::sd_spi_sclk);
106105
auto spi_mosi = M5.getPin(m5::pin_name_t::sd_spi_mosi);
107106
auto spi_miso = M5.getPin(m5::pin_name_t::sd_spi_miso);
108107
M5_LOGI("getPin: %d,%d,%d", spi_sclk, spi_mosi, spi_miso);
109108
SPI.begin(spi_sclk, spi_miso, spi_mosi /* SS is shared SD, CC1101, ST25R3916 */);
110109
}
111-
112110
SPISettings settings = {10000000, MSBFIRST, SPI_MODE1};
113-
if (!Units.add(unit, SPI, settings) || !Units.begin()) {
111+
unit_ready = Units.add(unit, SPI, settings) && Units.begin();
112+
#endif
113+
114+
if (!unit_ready) {
114115
M5_LOGE("Failed to begin");
115116
lcd.fillScreen(TFT_RED);
116117
while (true) {
117118
m5::utility::delay(10000);
118119
}
119120
}
120-
#endif
121121
M5_LOGI("M5UnitUnified initialized");
122122
M5_LOGI("%s", Units.debugInfo().c_str());
123123

@@ -142,7 +142,8 @@ void loop()
142142
if (nfc_a.identify(u)) {
143143
M5.Log.printf("PICC:%s %s %04X/%02X %u/%u\n", u.uidAsString().c_str(), u.typeAsString().c_str(), u.atqa,
144144
u.sak, u.userAreaSize(), u.totalSize());
145-
lcd.printf("[%2u]:PICC:<%s> %s\n", idx, u.uidAsString().c_str(), u.typeAsString().c_str());
145+
lcd.printf("[%2u]:PICC:<%s> %s\n", static_cast<unsigned>(idx), u.uidAsString().c_str(),
146+
u.typeAsString().c_str());
146147
++idx;
147148
} else {
148149
M5_LOGW("Failed to identify %s %s %04X/%02X %u/%u", u.uidAsString().c_str(), u.typeAsString().c_str(),

examples/UnitUnified/NFCA/Dump/Dump.ino

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,17 @@
99
This example is shared with M5Unit-RFID
1010
*/
1111
// *************************************************************
12-
// Choose one define symbol to match the unit you are using
12+
// Choose ONE define symbol to match the unit/board you are using
1313
// *************************************************************
14-
#if !defined(USING_UNIT_NFC) && !defined(USING_HACKER_CAP) && !defined(USING_UNIT_RFID2)
15-
// For UnitNFC
14+
#if !defined(USING_UNIT_NFC) && !defined(USING_CAP_CC1101) && !defined(USING_UNIT_RFID2) && \
15+
!defined(USING_M5DIAL_BUILTIN_WS1850S)
16+
// For UnitNFC (ST25R3916, I2C)
1617
// #define USING_UNIT_NFC
17-
// For CapNFC
18-
// #define USING_HACKER_CAP
19-
// For UnitRFID2
18+
// For CapCC1101NFC (ST25R3916, SPI)
19+
// #define USING_CAP_CC1101
20+
// For UnitRFID2 (WS1850S external, I2C GROVE)
2021
// #define USING_UNIT_RFID2
22+
// For M5Dial Builtin WS1850S (internal I2C)
23+
// #define USING_M5DIAL_BUILTIN_WS1850S
2124
#endif
2225
#include "main/Dump.cpp"

0 commit comments

Comments
 (0)