wut  v1.7.0
Wii U Toolchain
nfc.h
Go to the documentation of this file.
1 #pragma once
2 #include <wut.h>
3 #include <vpadbase/base.h>
4 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 typedef int32_t NFCError;
17 typedef uint8_t NFCProtocol;
18 typedef uint8_t NFCTechnology;
19 typedef uint8_t NFCTechnologyMask;
20 typedef uint8_t NFCNDEFFlags;
21 typedef struct NFCUid NFCUid;
22 typedef struct NFCTagInfo NFCTagInfo;
23 typedef struct NFCNTAGVersion NFCNTAGVersion;
24 typedef struct NFCReadT2TResult NFCReadT2TResult;
25 
26 typedef enum NFCMode
27 {
34 
35 typedef enum NFCProtocolEnum
36 {
44 
45 typedef enum NFCTechnologyEnum
46 {
52 
54 {
61 
62 typedef enum NFCNDEFFlagsEnum
63 {
79  NFC_NDEF_FLAG_OTP = (1 << 7),
81 
82 struct NFCUid
83 {
84  uint8_t uid[7];
85 };
86 WUT_CHECK_OFFSET(NFCUid, 0x00, uid);
87 WUT_CHECK_SIZE(NFCUid, 0x07);
88 
89 struct NFCTagInfo
90 {
91  uint8_t uidSize;
92  uint8_t uid[10];
95  WUT_PADDING_BYTES(0x20); // reserved
96 };
97 WUT_CHECK_OFFSET(NFCTagInfo, 0x00, uidSize);
98 WUT_CHECK_OFFSET(NFCTagInfo, 0x01, uid);
99 WUT_CHECK_OFFSET(NFCTagInfo, 0x0B, technology);
100 WUT_CHECK_OFFSET(NFCTagInfo, 0x0C, protocol);
101 WUT_CHECK_SIZE(NFCTagInfo, 0x2D);
102 
103 // GET_VERSION response for NTAG213, NTAG215 and NTAG216
105 {
106  uint8_t header;
107  uint8_t vendorId;
108  uint8_t productType;
109  uint8_t productSubtype;
112  uint8_t storageSize;
113  uint8_t protocolType;
114 };
115 WUT_CHECK_OFFSET(NFCNTAGVersion, 0x00, header);
116 WUT_CHECK_OFFSET(NFCNTAGVersion, 0x01, vendorId);
117 WUT_CHECK_OFFSET(NFCNTAGVersion, 0x02, productType);
118 WUT_CHECK_OFFSET(NFCNTAGVersion, 0x03, productSubtype);
119 WUT_CHECK_OFFSET(NFCNTAGVersion, 0x04, majorProductVersion);
120 WUT_CHECK_OFFSET(NFCNTAGVersion, 0x05, minorProductversion);
121 WUT_CHECK_OFFSET(NFCNTAGVersion, 0x06, storageSize);
122 WUT_CHECK_OFFSET(NFCNTAGVersion, 0x07, protocolType);
123 WUT_CHECK_SIZE(NFCNTAGVersion, 0x08);
124 
126 {
128  uint8_t numReads;
129  uint8_t read0Start;
130  uint8_t read0End;
131  uint8_t read1Start;
132  uint8_t read1End;
133  uint8_t read2Start;
134  uint8_t read2End;
135  uint8_t read3Start;
136  uint8_t read3End;
138  uint8_t data[0x3A0];
139 };
140 WUT_CHECK_OFFSET(NFCReadT2TResult, 0x00, numReads);
141 WUT_CHECK_OFFSET(NFCReadT2TResult, 0x01, read0Start);
142 WUT_CHECK_OFFSET(NFCReadT2TResult, 0x02, read0End);
143 WUT_CHECK_OFFSET(NFCReadT2TResult, 0x03, read1Start);
144 WUT_CHECK_OFFSET(NFCReadT2TResult, 0x04, read1End);
145 WUT_CHECK_OFFSET(NFCReadT2TResult, 0x05, read2Start);
146 WUT_CHECK_OFFSET(NFCReadT2TResult, 0x06, read2End);
147 WUT_CHECK_OFFSET(NFCReadT2TResult, 0x07, read3Start);
148 WUT_CHECK_OFFSET(NFCReadT2TResult, 0x08, read3End);
149 WUT_CHECK_OFFSET(NFCReadT2TResult, 0x09, data);
150 WUT_CHECK_SIZE(NFCReadT2TResult, 0x3A9);
151 
164 typedef void
165 (*NFCCallbackFn)(VPADChan chan,
166  NFCError error,
167  void *userContext);
168 
181 typedef void
183  BOOL hasTag,
184  void *userContext);
185 
210 typedef void
212  NFCError error,
213  NFCUid *uid,
214  BOOL readOnly,
215  BOOL hasLockedData,
216  NFCNDEFFlags flags,
217  void *userContext);
218 
237 typedef void
239  NFCError error,
240  uint32_t responseSize,
241  void *responseData,
242  void *userContext);
243 
265 typedef void
267  NFCError error,
268  uint8_t numCompleted,
269  uint32_t response0Size,
270  void *response0Data,
271  uint32_t response1Size,
272  void *response1Data,
273  void *userContext);
274 
305 typedef void
307  NFCError error,
308  NFCUid *uid,
309  BOOL readOnly,
310  uint32_t dataSize,
311  void *data,
312  uint32_t lockedDataSize,
313  void *lockedData,
314  void *userContext);
315 
349 typedef void
351  NFCError error,
352  uint8_t rfDiscId,
353  NFCProtocol protocol,
354  NFCTechnology technology,
355  uint8_t uidSize,
356  uint8_t *uid,
357  NFCNTAGVersion *version,
358  NFCReadT2TResult *result,
359  void *userContext);
360 
376 typedef void
378  NFCError error,
379  NFCTagInfo *tagInfo,
380  void *userContext);
381 
400 typedef void
402  NFCError error,
403  uint8_t numTagInfos,
404  NFCTagInfo *tagInfo0,
405  NFCTagInfo *tagInfo1,
406  NFCTagInfo *tagInfo2,
407  void *userContext);
408 
418 NFCError
420 
433 NFCError
435  uint32_t powerMode);
436 
446 NFCError
448 
458 BOOL
460 
468 void
470 
483 void
485  NFCTagDetectCallbackFn callback,
486  void *userContext);
487 
497 NFCMode
499 
512 NFCError
514  NFCMode mode);
515 
531 NFCError
533  NFCCallbackFn callback,
534  void *userContext);
535 
551 NFCError
553  NFCCallbackFn callback,
554  void *userContext);
555 
574 NFCError
576  uint32_t discoveryTimeout,
577  NFCDetectCallbackFn callback,
578  void *userContext);
579 
600 NFCError
602  uint8_t numBlocks,
603  NFCRawDataCallbackFn callback,
604  void *userContext);
605 
632 NFCError
634  uint32_t discoveryTimeout,
635  NFCUid *uid,
636  NFCUid *uidMask,
637  NFCReadCallbackFn callback,
638  void *userContext);
639 
671 NFCError
673  uint32_t discoveryTimeout,
674  NFCUid *uid,
675  NFCUid *uidMask,
676  uint32_t size,
677  void *data,
678  NFCCallbackFn callback,
679  void *userContext);
680 
716 NFCError
718  BOOL startDiscovery,
719  uint32_t discoveryTimeout,
720  uint32_t commandTimeout,
721  uint32_t commandSize,
722  uint32_t responseSize,
723  void *commandData,
724  NFCRawDataCallbackFn callback,
725  void *userContext);
726 
765 NFCError
767  BOOL startDiscovery,
768  uint32_t discoveryTimeout,
769  uint32_t commandTimeout,
770  uint32_t commandSize,
771  uint32_t responseSize,
772  void *commandData,
773  BOOL disableCRC,
774  NFCRawDataCallbackFn callback,
775  void *userContext);
776 
818 NFCError
820  BOOL startDiscovery,
821  uint32_t discoveryTimeout,
822  uint32_t commandTimeout,
823  uint32_t commandSize,
824  uint32_t responseSize,
825  void *commandData,
826  BOOL disableCRC,
827  NFCTechnologyMask techMask,
828  NFCRawDataCallbackFn callback,
829  void *userContext);
830 
868 NFCError
870  BOOL startDiscovery,
871  uint32_t discoveryTimeout,
872  uint32_t commandTimeout,
873  uint32_t commandSize,
874  uint32_t responseSize,
875  void *commandData,
876  NFCRawDataCallbackFn callback,
877  void *userContext);
878 
915 NFCError
917  BOOL startDiscovery,
918  uint32_t discoveryTimeout,
919  uint32_t commandTimeout,
920  uint32_t commandSize,
921  uint32_t responseSize,
922  void *commandData,
923  NFCRawDataCallbackFn callback,
924  void *userContext);
925 
954 NFCError
956  uint32_t command0Timeout,
957  uint32_t command0Size,
958  uint32_t response0Size,
959  void *command0Data,
960  uint32_t command1Timeout,
961  uint32_t command1Size,
962  uint32_t response1Size,
963  void *command1Data,
964  NFCRawDataTwiceCallbackFn callback,
965  void *userContext);
966 
991 NFCError
993  uint32_t discoveryTimeout,
994  NFCUid *uid,
995  NFCUid *uidMask,
996  NFCCallbackFn callback,
997  void *userContext);
998 
1017 NFCError
1019  uint32_t discoveryTimeout,
1020  NFCGetTagInfoCallbackFn callback,
1021  void *userContext);
1022 
1041 NFCError
1043  uint32_t discoveryTimeout,
1045  void *userContext);
1046 
1071 NFCError
1073  uint32_t discoveryTimeout,
1074  NFCUid *uid,
1075  NFCUid *uidMask,
1076  NFCCallbackFn callback,
1077  void *userContext);
1078 
1106 NFCError
1108  uint32_t discoveryTimeout,
1109  NFCUid *uid,
1110  NFCUid *uidMask,
1111  BOOL readOnly,
1112  NFCCallbackFn callback,
1113  void *userContext);
1114 
1158 NFCError
1160  uint32_t discoveryTimeout,
1161  NFCUid *uid,
1162  NFCUid *uidMask,
1163  NFCNTAGVersion *version,
1164  uint32_t commandTimeout,
1165  uint8_t numReads,
1166  uint8_t read0Start, uint8_t read0End,
1167  uint8_t read1Start, uint8_t read1End,
1168  uint8_t read2Start, uint8_t read2End,
1169  uint8_t read3Start, uint8_t read3End,
1170  uint8_t authenticate,
1171  NFCReadT2TCallbackFn callback,
1172  void *userContext);
1173 
1234 NFCError
1236  uint16_t discoveryTimeout,
1237  NFCUid *uid,
1238  NFCUid *uidMask,
1239  NFCNTAGVersion *version,
1240  uint32_t commandTimeout,
1241  uint8_t numWrites,
1242  uint8_t write0Start, uint8_t write0Size, void *write0Data,
1243  uint8_t write1Start, uint8_t write1Size, void *write1Data,
1244  uint8_t write2Start, uint8_t write2Size, void *write2Data,
1245  uint8_t write3Start, uint8_t write3Size, void *write3Data,
1246  uint8_t activationStart, uint32_t *deactivationData, uint32_t *activationData,
1247  uint8_t authenticate, uint8_t activate,
1248  NFCCallbackFn callback,
1249  void *userContext);
1250 
1269 void
1271  NFCProtocol *outProtocol,
1272  NFCTechnology *outTechnology,
1273  uint8_t *outUidSize,
1274  uint8_t *outUid);
1275 
1285 NFCError
1287 
1288 #ifdef __cplusplus
1289 }
1290 #endif
1291 
uint8_t productSubtype
Definition: nfc.h:109
uint8_t vendorId
Definition: nfc.h:107
uint8_t productType
Definition: nfc.h:108
NFCTechnology technology
Definition: nfc.h:93
uint8_t header
Definition: nfc.h:106
uint8_t majorProductVersion
Definition: nfc.h:110
NFCProtocol protocol
Definition: nfc.h:94
uint8_t minorProductversion
Definition: nfc.h:111
uint8_t read2Start
Definition: nfc.h:133
uint8_t data[0x3A0]
The data which has been read.
Definition: nfc.h:138
uint8_t read0Start
Definition: nfc.h:129
uint8_t uid[7]
Definition: nfc.h:84
uint8_t numReads
The amount of reads which have been performed.
Definition: nfc.h:128
uint8_t read0End
Definition: nfc.h:130
uint8_t uid[10]
Definition: nfc.h:92
uint8_t read2End
Definition: nfc.h:134
uint8_t protocolType
Definition: nfc.h:113
uint8_t uidSize
Definition: nfc.h:91
uint8_t read1End
Definition: nfc.h:132
uint8_t storageSize
Definition: nfc.h:112
uint8_t read3Start
Definition: nfc.h:135
uint8_t read3End
Definition: nfc.h:136
uint8_t read1Start
Definition: nfc.h:131
NFCError NFCSendRawDataWithPrePolling(VPADChan chan, BOOL startDiscovery, uint32_t discoveryTimeout, uint32_t commandTimeout, uint32_t commandSize, uint32_t responseSize, void *commandData, NFCRawDataCallbackFn callback, void *userContext)
Send a raw NFC command to a tag.
uint8_t NFCNDEFFlags
Definition: nfc.h:20
NFCError NFCWriteT2T(VPADChan chan, uint16_t discoveryTimeout, NFCUid *uid, NFCUid *uidMask, NFCNTAGVersion *version, uint32_t commandTimeout, uint8_t numWrites, uint8_t write0Start, uint8_t write0Size, void *write0Data, uint8_t write1Start, uint8_t write1Size, void *write1Data, uint8_t write2Start, uint8_t write2Size, void *write2Data, uint8_t write3Start, uint8_t write3Size, void *write3Data, uint8_t activationStart, uint32_t *deactivationData, uint32_t *activationData, uint8_t authenticate, uint8_t activate, NFCCallbackFn callback, void *userContext)
Write data to a Type 2 NTAG.
NFCError NFCSendRawData(VPADChan chan, BOOL startDiscovery, uint32_t discoveryTimeout, uint32_t commandTimeout, uint32_t commandSize, uint32_t responseSize, void *commandData, NFCRawDataCallbackFn callback, void *userContext)
Send a raw NFC command to a tag.
NFCTechnologyMaskEnum
Definition: nfc.h:54
NFCError NFCIsTagPresent(VPADChan chan, uint32_t discoveryTimeout, NFCUid *uid, NFCUid *uidMask, NFCCallbackFn callback, void *userContext)
Check if a tag is still present.
void NFCSetTagDetectCallback(VPADChan chan, NFCTagDetectCallbackFn callback, void *userContext)
Set a callback which will be called once a tag is attached / removed.
void NFCProc(VPADChan chan)
Process NFC.
NFCNDEFFlagsEnum
Definition: nfc.h:63
void(* NFCGetTagInfoMultiCallbackFn)(VPADChan chan, NFCError error, uint8_t numTagInfos, NFCTagInfo *tagInfo0, NFCTagInfo *tagInfo1, NFCTagInfo *tagInfo2, void *userContext)
Callback function for NFCGetTagInfoMulti.
Definition: nfc.h:401
NFCError NFCReadT2T(VPADChan chan, uint32_t discoveryTimeout, NFCUid *uid, NFCUid *uidMask, NFCNTAGVersion *version, uint32_t commandTimeout, uint8_t numReads, uint8_t read0Start, uint8_t read0End, uint8_t read1Start, uint8_t read1End, uint8_t read2Start, uint8_t read2End, uint8_t read3Start, uint8_t read3End, uint8_t authenticate, NFCReadT2TCallbackFn callback, void *userContext)
Read data from a Type 2 NTAG.
NFCError NFCWrite(VPADChan chan, uint32_t discoveryTimeout, NFCUid *uid, NFCUid *uidMask, uint32_t size, void *data, NFCCallbackFn callback, void *userContext)
Write to a tag.
void NFCGetUIDFromActivationEventData(void *data, NFCProtocol *outProtocol, NFCTechnology *outTechnology, uint8_t *outUidSize, uint8_t *outUid)
Get the UID and other parameters from activation event data.
void(* NFCRawDataTwiceCallbackFn)(VPADChan chan, NFCError error, uint8_t numCompleted, uint32_t response0Size, void *response0Data, uint32_t response1Size, void *response1Data, void *userContext)
Callback function for NFCSendRawDataTwice and variations.
Definition: nfc.h:266
void(* NFCRawDataCallbackFn)(VPADChan chan, NFCError error, uint32_t responseSize, void *responseData, void *userContext)
Callback function for NFCSendRawData and variations.
Definition: nfc.h:238
int32_t NFCError
Definition: nfc.h:16
uint8_t NFCTechnologyMask
Definition: nfc.h:19
NFCError NFCGetTagInfoMulti(VPADChan chan, uint32_t discoveryTimeout, NFCGetTagInfoMultiCallbackFn callback, void *userContext)
Obtain info about multiple tags.
NFCError NFCRead(VPADChan chan, uint32_t discoveryTimeout, NFCUid *uid, NFCUid *uidMask, NFCReadCallbackFn callback, void *userContext)
Read from a tag.
NFCError NFCSendRawDataWithPrePollingEx(VPADChan chan, BOOL startDiscovery, uint32_t discoveryTimeout, uint32_t commandTimeout, uint32_t commandSize, uint32_t responseSize, void *commandData, NFCRawDataCallbackFn callback, void *userContext)
Send a raw NFC command to a tag.
void(* NFCReadT2TCallbackFn)(VPADChan chan, NFCError error, uint8_t rfDiscId, NFCProtocol protocol, NFCTechnology technology, uint8_t uidSize, uint8_t *uid, NFCNTAGVersion *version, NFCReadT2TResult *result, void *userContext)
Callback function for NFCReadT2T.
Definition: nfc.h:350
NFCError NFCSendRawDataEx(VPADChan chan, BOOL startDiscovery, uint32_t discoveryTimeout, uint32_t commandTimeout, uint32_t commandSize, uint32_t responseSize, void *commandData, BOOL disableCRC, NFCRawDataCallbackFn callback, void *userContext)
Send a raw NFC command to a tag.
void(* NFCReadCallbackFn)(VPADChan chan, NFCError error, NFCUid *uid, BOOL readOnly, uint32_t dataSize, void *data, uint32_t lockedDataSize, void *lockedData, void *userContext)
Callback function for NFCRead.
Definition: nfc.h:306
void(* NFCTagDetectCallbackFn)(VPADChan chan, BOOL hasTag, void *userContext)
Callback function for NFCSetTagDetectCallback.
Definition: nfc.h:182
void(* NFCDetectCallbackFn)(VPADChan chan, NFCError error, NFCUid *uid, BOOL readOnly, BOOL hasLockedData, NFCNDEFFlags flags, void *userContext)
Callback function for NFCDetect.
Definition: nfc.h:211
NFCError NFCInitEx(VPADChan chan, uint32_t powerMode)
Initializes the NFC library.
NFCError NFCSendRawDataEx2(VPADChan chan, BOOL startDiscovery, uint32_t discoveryTimeout, uint32_t commandTimeout, uint32_t commandSize, uint32_t responseSize, void *commandData, BOOL disableCRC, NFCTechnologyMask techMask, NFCRawDataCallbackFn callback, void *userContext)
Send a raw NFC command to a tag.
NFCMode NFCGetMode(VPADChan chan)
Get the current NFC mode.
void(* NFCCallbackFn)(VPADChan chan, NFCError error, void *userContext)
Generic callback function.
Definition: nfc.h:165
NFCMode
Definition: nfc.h:27
NFCProtocolEnum
Definition: nfc.h:36
NFCError NFCAntennaCheck(VPADChan chan, NFCCallbackFn callback, void *userContext)
Check the NFC antenna.
NFCError NFCFormat(VPADChan chan, uint32_t discoveryTimeout, NFCUid *uid, NFCUid *uidMask, NFCCallbackFn callback, void *userContext)
Check if the tag is NDEF Formatable.
NFCError NFCSetMode(VPADChan chan, NFCMode mode)
Set the current NFC mode.
NFCError NFCAbort(VPADChan chan, NFCCallbackFn callback, void *userContext)
Abort pending NFC operations.
NFCError NFCSetLockBitsForT1T(VPADChan chan, uint8_t numBlocks, NFCRawDataCallbackFn callback, void *userContext)
This will lock an area of blocks at the end of a 512-byte Type 1 Tag.
NFCError NFCDetect(VPADChan chan, uint32_t discoveryTimeout, NFCDetectCallbackFn callback, void *userContext)
Start tag discovery and provide info about the first detected tag.
NFCError NFCSetReadOnly(VPADChan chan, uint32_t discoveryTimeout, NFCUid *uid, NFCUid *uidMask, BOOL readOnly, NFCCallbackFn callback, void *userContext)
Make a Type 1 Tag read only by setting the RWA byte.
NFCError __NFCSystemAbort(VPADChan chan)
Abort and call pending callbacks.
NFCError NFCShutdown(VPADChan chan)
Shutdown the NFC library.
void(* NFCGetTagInfoCallbackFn)(VPADChan chan, NFCError error, NFCTagInfo *tagInfo, void *userContext)
Callback function for NFCGetTagInfo.
Definition: nfc.h:377
NFCError NFCInit(VPADChan chan)
Initializes the NFC library.
NFCError NFCSendRawDataTwice(VPADChan chan, uint32_t command0Timeout, uint32_t command0Size, uint32_t response0Size, void *command0Data, uint32_t command1Timeout, uint32_t command1Size, uint32_t response1Size, void *command1Data, NFCRawDataTwiceCallbackFn callback, void *userContext)
Send two raw NFC commands to an activated tag.
NFCError NFCGetTagInfo(VPADChan chan, uint32_t discoveryTimeout, NFCGetTagInfoCallbackFn callback, void *userContext)
Obtain info about tags.
uint8_t NFCTechnology
Definition: nfc.h:18
BOOL NFCIsInit(VPADChan chan)
Check if NFC is initialized.
NFCTechnologyEnum
Definition: nfc.h:46
uint8_t NFCProtocol
Definition: nfc.h:17
@ NFC_TECHNOLOGY_MASK_A
Definition: nfc.h:56
@ NFC_TECHNOLOGY_MASK_F
Definition: nfc.h:58
@ NFC_TECHNOLOGY_MASK_B
Definition: nfc.h:57
@ NFC_TECHNOLOGY_MASK_ISO15693
Definition: nfc.h:59
@ NFC_TECHNOLOGY_MASK_ALL
Definition: nfc.h:55
@ NFC_NDEF_FLAG_SUPPORTED
NDEF supported by the tag.
Definition: nfc.h:69
@ NFC_NDEF_FLAG_OTP
Tag is one time programmable.
Definition: nfc.h:79
@ NFC_NDEF_FLAG_UNKNOWN
Unable to find if tag is ndef capable/formated/read only.
Definition: nfc.h:71
@ NFC_NDEF_FLAG_READ_ONLY
Tag is read only.
Definition: nfc.h:65
@ NFC_NDEF_FLAG_FORMATED
Tag formated for NDEF.
Definition: nfc.h:67
@ NFC_NDEF_FLAG_FORMATABLE
Tag supports format operation.
Definition: nfc.h:73
@ NFC_NDEF_FLAG_HARD_LOCKABLE
Tag can be hard locked.
Definition: nfc.h:77
@ NFC_NDEF_FLAG_SOFT_LOCKABLE
Tag can be soft locked.
Definition: nfc.h:75
@ NFC_MODE_INVALID
Definition: nfc.h:28
@ NFC_MODE_ACTIVE
NFC is discovering / has an active tag.
Definition: nfc.h:32
@ NFC_MODE_IDLE
NFC is idle.
Definition: nfc.h:30
@ NFC_PROTOCOL_T2T
Definition: nfc.h:39
@ NFC_PROTOCOL_UNKNOWN
Definition: nfc.h:37
@ NFC_PROTOCOL_T3T
Definition: nfc.h:40
@ NFC_PROTOCOL_15693
Definition: nfc.h:42
@ NFC_PROTOCOL_T1T
Definition: nfc.h:38
@ NFC_PROTOCOL_ISO_DEP
Definition: nfc.h:41
@ NFC_TECHNOLOGY_F
Definition: nfc.h:49
@ NFC_TECHNOLOGY_B
Definition: nfc.h:48
@ NFC_TECHNOLOGY_ISO15693
Definition: nfc.h:50
@ NFC_TECHNOLOGY_A
Definition: nfc.h:47
Definition: nfc.h:90
Definition: nfc.h:83
VPADChan
Wii U GamePad channel.
Definition: base.h:16
int32_t BOOL
Definition: wut_types.h:7