Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
pn512.h
00001 /* 00002 * Copyright (c) 2013-2018, ARM Limited, All Rights Reserved 00003 * SPDX-License-Identifier: Apache-2.0 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); you may 00006 * not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 00013 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 /** 00018 * \file pn512.h 00019 * \copyright Copyright (c) ARM Ltd 2013 00020 * \author Donatien Garnier 00021 */ 00022 00023 #ifndef PN512_H_ 00024 #define PN512_H_ 00025 00026 #ifdef __cplusplus 00027 extern "C" { 00028 #endif 00029 00030 #include "stack/nfc_common.h" 00031 #include "transceiver/transceiver.h" 00032 00033 #include "pn512_types.h" 00034 #include "pn512_callback.h" 00035 00036 typedef enum __pn512_state { 00037 pn512_state_ready, 00038 pn512_state_target_autocoll, 00039 pn512_state_initiator_transceive_first_frame, 00040 pn512_state_transceive, 00041 pn512_state_transceive_last_frame, 00042 } pn512_state_t; 00043 00044 typedef enum __pn512_transceive_mode { 00045 pn512_transceive_mode_idle, 00046 pn512_transceive_mode_target_autocoll, 00047 pn512_transceive_mode_transmit, 00048 pn512_transceive_mode_transmit_and_target_autocoll, 00049 pn512_transceive_mode_transceive, 00050 pn512_transceive_mode_receive, 00051 } pn512_transceive_mode_t; 00052 00053 struct __pn512 { 00054 nfc_transceiver_t transceiver; 00055 //Impl specific 00056 pn512_registers_t registers; 00057 bool rf_on; 00058 struct { 00059 bool out; 00060 bool in; 00061 } crc; 00062 int timeout; 00063 00064 struct { 00065 nfc_tech_t initiators; 00066 nfc_tech_t targets; 00067 polling_options_t options; 00068 } config; 00069 00070 //Transceive options 00071 pn512_transceive_mode_t nextFrameMode; 00072 00073 nfc_framing_t framing; 00074 uint16_t irqsEn; 00075 uint8_t payload[256]; //Incoming buffer 00076 00077 ac_buffer_builder_t readBufBldr; 00078 ac_buffer_t writeBuf; 00079 00080 uint8_t readFirstByteAlign; 00081 uint8_t readLastByteLength; 00082 uint8_t writeLastByteLength; 00083 00084 //Task parameters 00085 struct { 00086 //Polling 00087 struct { 00088 enum { 00089 pn512_polling_state_start_listening, 00090 00091 pn512_polling_state_listen_wait_for_remote_field, 00092 pn512_polling_state_listen_anticollision, 00093 00094 pn512_polling_state_listen_no_target_found, 00095 00096 pn512_polling_state_start_polling, 00097 00098 pn512_polling_state_rf_collision_avoidance, // TID + n × TRFW, n is random, TID>4096/(13.56E6) ~ 302.06us, TRFW=51/(13.56E6) ~ 37.76us 00099 pn512_polling_state_polling_nfc_a_start, 00100 pn512_polling_state_polling_nfc_a_gt, // guard time nfc a >= 5.0 ms 00101 pn512_polling_state_polling_nfc_a_anticollision, // polling for nfc a 00102 pn512_polling_state_polling_nfc_b_start, 00103 pn512_polling_state_polling_nfc_b_gt, // guard time nfc b >= 5.0 ms 00104 pn512_polling_state_polling_nfc_b_anticollision, // polling for nfc b 00105 pn512_polling_state_polling_nfc_f_start, 00106 pn512_polling_state_polling_nfc_f_gt, // guard time nfc f >= 20 ms 00107 pn512_polling_state_polling_nfc_f_anticollision, // polling for nfc f 00108 00109 pn512_polling_state_finish_polling, 00110 00111 } state; 00112 00113 pn512_cb_t cb; 00114 } poll; 00115 struct { 00116 pn512_cb_t cb; 00117 pn512_transceive_mode_t mode; 00118 } transceive; 00119 struct { 00120 pn512_cb_t cb; 00121 } rf; 00122 struct { 00123 union { 00124 // ISO A 00125 struct { 00126 bool more_targets; // Collision detected 00127 uint8_t cascade_level; 00128 uint8_t cln[5]; 00129 uint8_t valid_bits; // valid bits within cascade level 00130 } iso_a; 00131 // ISO B 00132 struct { 00133 bool more_targets; // Collision detected 00134 uint8_t slots_num_exponent; 00135 uint8_t slot_number; 00136 bool found_one; 00137 } iso_b; 00138 }; 00139 pn512_cb_t cb; 00140 } anticollision; 00141 }; 00142 00143 }; 00144 00145 nfc_err_t pn512_init(pn512_t *pPN512, nfc_transport_t *pTransport, nfc_scheduler_timer_t *pTimer); 00146 00147 nfc_transceiver_t *pn512_get_transceiver(pn512_t *pPN512); 00148 00149 #ifdef __cplusplus 00150 } 00151 #endif 00152 00153 #endif /* PN512_H_ */
Generated on Tue Jul 12 2022 13:54:41 by
