1 /*---------------------------------------------------------------------------*
2   Project:  Cafe
3   File:     nfc.h
4 
5   Copyright (C) Nintendo.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law.  They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13  *---------------------------------------------------------------------------*/
14 
15 #ifndef __NFC_H__
16 #define __NFC_H__
17 
18 #include <types.h>
19 #include <cafe/os.h>
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 
26 /*************************************/
27 /*        Error Code                 */
28 /*************************************/
29 #define NFC_ERR_BASE       (-5000)
30 enum {
31     NFC_ERR_NONE = 0,               // No error.
32     NFC_ERR_INIT = NFC_ERR_BASE,    // An error occurred during initialization.
33     NFC_ERR_NOT_INIT,               // Error from an uninitialized NFC module.
34     NFC_ERR_TIMEOUT,                // Configured timeout occurred.
35     NFC_ERR_INVALID_COMMAND,        // Error that occurs if an invalid command is issued.
36     NFC_ERR_INVALID_TAG,            // Detected an invalid tag.
37     NFC_ERR_GET_TAG_INFO,           // <tt>GetTagInfo</tt> function error.
38     NFC_ERR_ABORT       ,           // Error caused by aborted processing.
39     NFC_ERR_OTHER,                  // Other error.
40     NFC_ERR_GET_TAG_INFO_MULTI,     // <tt>GetTagInfoMulti</tt> function error.
41 };
42 
43 typedef s32    NFCError;
44 
45 
46 
47 // Definition of NFC tag information.
48 #define NFC_MAX_UID_SIZE    (10)
49 
50 #define NFC_POLL_TYPE_A     (0x00)
51 #define NFC_POLL_TYPE_B     (0x01)
52 #define NFC_POLL_TYPE_F     (0x02)
53 #define NFC_POLL_TYPE_15693 (0x06)
54 
55 #define NFC_TYPE_1_TAG      (0x01)
56 #define NFC_TYPE_2_TAG      (0x02)
57 #define NFC_TYPE_3_TAG      (0x03)
58 #define NFC_TYPE_4_TAG      (0x04)
59 #define NFC_TYPE_ISO_15693  (0x83)
60 
61 
62 
63 typedef struct
64 {
65     u8 uid_len ;
66     u8 uid[NFC_MAX_UID_SIZE];
67     u8 rf_mode ;
68     u8 tag_type ;
69     u8 reserved[32];
70 } NFCTagInfo;
71 
72 
73 
74 typedef void (*NFCGetTagInfoCallback)(s32 chan,  NFCError errorCode,
75                                       const NFCTagInfo* tagInfo,
76                                       void* userData );
77 typedef void (*NFCGetTagInfoMultiCallback)(s32 chan,  NFCError errorCode,
78                                            u8 tagNum,
79                                            const NFCTagInfo* tagInfo1,
80                                            const NFCTagInfo* tagInfo2,
81                                            const NFCTagInfo* tagInfo3,
82                                            void* userData );
83 
84 
85 NFCError NFCGetTagInfo(s32 chan, u16 polling_time,
86                        NFCGetTagInfoCallback callback, void* userData) ;
87 NFCError NFCGetTagInfoMulti(s32 chan, u16 polling_time,
88                             NFCGetTagInfoMultiCallback callback,
89                             void* userData) ;
90 
91 
92 #ifdef __cplusplus
93 }
94 #endif
95 
96 #endif  // __NFC_H__
97