Mistake on this page?
Report an issue in GitHub or email us
pn512.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013-2018, ARM Limited, All Rights Reserved
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License"); you may
6  * not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 /**
18  * \file pn512.h
19  * \copyright Copyright (c) ARM Ltd 2013
20  * \author Donatien Garnier
21  */
22 
23 #ifndef PN512_H_
24 #define PN512_H_
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 #include "stack/nfc_common.h"
32 
33 #include "pn512_types.h"
34 #include "pn512_callback.h"
35 
36 typedef enum __pn512_state {
37  pn512_state_ready,
38  pn512_state_target_autocoll,
39  pn512_state_initiator_transceive_first_frame,
40  pn512_state_transceive,
41  pn512_state_transceive_last_frame,
42 } pn512_state_t;
43 
44 typedef enum __pn512_transceive_mode {
45  pn512_transceive_mode_idle,
46  pn512_transceive_mode_target_autocoll,
47  pn512_transceive_mode_transmit,
48  pn512_transceive_mode_transmit_and_target_autocoll,
49  pn512_transceive_mode_transceive,
50  pn512_transceive_mode_receive,
51 } pn512_transceive_mode_t;
52 
53 struct __pn512 {
54  nfc_transceiver_t transceiver;
55  //Impl specific
56  pn512_registers_t registers;
57  bool rf_on;
58  struct {
59  bool out;
60  bool in;
61  } crc;
62  int timeout;
63 
64  struct {
65  nfc_tech_t initiators;
66  nfc_tech_t targets;
67  polling_options_t options;
68  } config;
69 
70  //Transceive options
71  pn512_transceive_mode_t nextFrameMode;
72 
73  nfc_framing_t framing;
74  uint16_t irqsEn;
75  uint8_t payload[256]; //Incoming buffer
76 
77  ac_buffer_builder_t readBufBldr;
78  ac_buffer_t writeBuf;
79 
80  uint8_t readFirstByteAlign;
81  uint8_t readLastByteLength;
82  uint8_t writeLastByteLength;
83 
84  //Task parameters
85  struct {
86  //Polling
87  struct {
88  enum {
89  pn512_polling_state_start_listening,
90 
91  pn512_polling_state_listen_wait_for_remote_field,
92  pn512_polling_state_listen_anticollision,
93 
94  pn512_polling_state_listen_no_target_found,
95 
96  pn512_polling_state_start_polling,
97 
98  pn512_polling_state_rf_collision_avoidance, // TID + n × TRFW, n is random, TID>4096/(13.56E6) ~ 302.06us, TRFW=51/(13.56E6) ~ 37.76us
99  pn512_polling_state_polling_nfc_a_start,
100  pn512_polling_state_polling_nfc_a_gt, // guard time nfc a >= 5.0 ms
101  pn512_polling_state_polling_nfc_a_anticollision, // polling for nfc a
102  pn512_polling_state_polling_nfc_b_start,
103  pn512_polling_state_polling_nfc_b_gt, // guard time nfc b >= 5.0 ms
104  pn512_polling_state_polling_nfc_b_anticollision, // polling for nfc b
105  pn512_polling_state_polling_nfc_f_start,
106  pn512_polling_state_polling_nfc_f_gt, // guard time nfc f >= 20 ms
107  pn512_polling_state_polling_nfc_f_anticollision, // polling for nfc f
108 
109  pn512_polling_state_finish_polling,
110 
111  } state;
112 
113  pn512_cb_t cb;
114  } poll;
115  struct {
116  pn512_cb_t cb;
117  pn512_transceive_mode_t mode;
118  } transceive;
119  struct {
120  pn512_cb_t cb;
121  } rf;
122  struct {
123  union {
124  // ISO A
125  struct {
126  bool more_targets; // Collision detected
127  uint8_t cascade_level;
128  uint8_t cln[5];
129  uint8_t valid_bits; // valid bits within cascade level
130  } iso_a;
131  // ISO B
132  struct {
133  bool more_targets; // Collision detected
134  uint8_t slots_num_exponent;
135  uint8_t slot_number;
136  bool found_one;
137  } iso_b;
138  };
139  pn512_cb_t cb;
140  } anticollision;
141  };
142 
143 };
144 
145 nfc_err_t pn512_init(pn512_t *pPN512, nfc_transport_t *pTransport, nfc_scheduler_timer_t *pTimer);
146 
147 nfc_transceiver_t *pn512_get_transceiver(pn512_t *pPN512);
148 
149 #ifdef __cplusplus
150 }
151 #endif
152 
153 #endif /* PN512_H_ */
Definition: pn512.h:53
int nfc_err_t
Type for NFC errors.
Definition: nfc_errors.h:59
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.