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.
rfal_iso15693_2.h
00001 00002 /****************************************************************************** 00003 * @attention 00004 * 00005 * <h2><center>© COPYRIGHT 2016 STMicroelectronics</center></h2> 00006 * 00007 * Licensed under ST MYLIBERTY SOFTWARE LICENSE AGREEMENT (the "License"); 00008 * You may not use this file except in compliance with the License. 00009 * You may obtain a copy of the License at: 00010 * 00011 * http://www.st.com/myliberty 00012 * 00013 * Unless required by applicable law or agreed to in writing, software 00014 * distributed under the License is distributed on an "AS IS" BASIS, 00015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, 00016 * AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY, 00017 * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. 00018 * See the License for the specific language governing permissions and 00019 * limitations under the License. 00020 * 00021 ******************************************************************************/ 00022 00023 /* 00024 * PROJECT: ST25R391x firmware 00025 * $Revision: $ 00026 * LANGUAGE: ISO C99 00027 */ 00028 00029 /*! \file rfal_iso15693.h 00030 * 00031 * \author Ulrich Herrmann 00032 * 00033 * \brief Implementation of ISO-15693-2 00034 * 00035 */ 00036 /*! 00037 * 00038 */ 00039 00040 #ifndef RFAL_ISO_15693_2_H 00041 #define RFAL_ISO_15693_2_H 00042 00043 /* 00044 ****************************************************************************** 00045 * INCLUDES 00046 ****************************************************************************** 00047 */ 00048 #include "platform1.h" 00049 #include "st_errno.h" 00050 #include <stdbool.h> 00051 /* 00052 ****************************************************************************** 00053 * GLOBAL DATATYPES 00054 ****************************************************************************** 00055 */ 00056 /*! 00057 * enum holding possible VCD codings 00058 */ 00059 typedef enum 00060 { 00061 ISO15693_VCD_CODING_1_4, 00062 ISO15693_VCD_CODING_1_256 00063 }iso15693VcdCoding_t; 00064 00065 /*! 00066 * enum holding possible VICC datarates 00067 */ 00068 00069 /*! 00070 * Configuration parameter used by #iso15693PhyConfigure 00071 */ 00072 typedef struct 00073 { 00074 iso15693VcdCoding_t coding ; /*!< desired VCD coding */ 00075 bool fastMode ; /*!< Fast mode - all pulse numbers and times are divided by 2 */ 00076 }iso15693PhyConfig_t ; 00077 00078 /*! Parameters how the stream mode should work */ 00079 struct iso15693StreamConfig { 00080 uint8_t useBPSK ; /*!< 0: subcarrier, 1:BPSK */ 00081 uint8_t din ; /*!< the divider for the in subcarrier frequency: fc/2^din */ 00082 uint8_t dout ; /*!< the divider for the in subcarrier frequency fc/2^dout */ 00083 uint8_t report_period_length ; /*!< the length of the reporting period 2^report_period_length*/ 00084 }; 00085 /* 00086 ****************************************************************************** 00087 * GLOBAL CONSTANTS 00088 ****************************************************************************** 00089 */ 00090 00091 /* t1min = 308,2us = 4192/fc = 65.5 * 64/fc */ 00092 #define ISO15693_MASK_RECEIVE_TIME (65) 00093 00094 /* t1max = 323,3us = 4384/fc = 68.5 * 64/fc 00095 * 12 = 768/fc unmodulated time of single subcarrior SoF */ 00096 #define ISO15693_NO_RESPONSE_TIME (69 + 12) 00097 00098 00099 #define ISO15693_REQ_FLAG_TWO_SUBCARRIERS 0x01 00100 #define ISO15693_REQ_FLAG_HIGH_DATARATE 0x02 00101 /* 00102 ****************************************************************************** 00103 * GLOBAL FUNCTION PROTOTYPES 00104 ****************************************************************************** 00105 */ 00106 /*! 00107 ***************************************************************************** 00108 * \brief Initialize the ISO15693 phy. 00109 * \note This function needs to be called every time after switching 00110 * from a different mode and before #iso15693Initialize 00111 * 00112 * \param[in] config : ISO15693 phy related configuration (See #iso15693PhyConfig_t) 00113 * \param[out] needed_stream_config : return a pointer to the stream config 00114 * needed for this iso15693 config. To be used for configure RF chip. 00115 * 00116 * \return ERR_IO : Error during communication. 00117 * \return ERR_NONE : No error. 00118 * 00119 ***************************************************************************** 00120 */ 00121 extern ReturnCode iso15693PhyConfigure(const iso15693PhyConfig_t * config, 00122 const struct iso15693StreamConfig ** needed_stream_config ); 00123 00124 /*! 00125 ***************************************************************************** 00126 * \brief Return current phy configuration. 00127 * 00128 * This function returns current Phy configuration previously 00129 * set by #iso15693PhyConfigure 00130 * 00131 * \param[out] config : ISO15693 phy configuration. 00132 * 00133 * \return ERR_NONE : No error. 00134 * 00135 ***************************************************************************** 00136 */ 00137 extern ReturnCode iso15693PhyGetConfiguration(iso15693PhyConfig_t * config); 00138 00139 /*! 00140 ***************************************************************************** 00141 * \brief Code an ISO15693 compatible frame 00142 * 00143 * This function takes \a length bytes from \a buffer, perform proper 00144 * encoding and sends out the frame to the ST25R3911. 00145 * 00146 * \param[in] buffer : data to send, modified to adapt flags. 00147 * \param[in] length : number of bytes to send. 00148 * \param[in] sendCrc : If set to true, CRC is appended to the frame 00149 * \param[in] sendFlags: If set to true, flag field is sent according to 00150 * ISO15693. 00151 * \param[in] picopassMode : If set to true, the coding will be according to Picopass 00152 * \param[out] subbit_total_length : Return the complete bytes which need to 00153 * be send for the current coding 00154 * \param[in,out] offset : Set to 0 for first transfer, function will update it to 00155 point to next byte to be coded 00156 * \param[out] outbuf : buffer where the function will store the coded subbit stream 00157 * \param[out] outBufSize : the size of the output buffer 00158 * \param[out] actOutBufSize : the amount of data stored into the buffer at this call 00159 * 00160 * \return ERR_IO : Error during communication. 00161 * \return ERR_AGAIN : Data was not coded all the way. Call function again with a new/emptied buffer 00162 * \return ERR_NO_MEM : In case outBuf is not big enough. Needs to have at 00163 least 5 bytes for 1of4 coding and 65 bytes for 1of256 coding 00164 * \return ERR_NONE : No error. 00165 * 00166 ***************************************************************************** 00167 */ 00168 extern ReturnCode iso15693VCDCode(uint8_t* buffer, uint16_t length, bool sendCrc, bool sendFlags, bool picopassMode, 00169 uint16_t *subbit_total_length, uint16_t *offset, 00170 uint8_t* outbuf, uint16_t outBufSize, uint16_t* actOutBufSize); 00171 00172 00173 /*! 00174 ***************************************************************************** 00175 * \brief Receive an ISO15693 compatible frame 00176 * 00177 * This function receives an ISO15693 frame from the ST25R3911, decodes the frame 00178 * and writes the raw data to \a buffer. 00179 * \note Buffer needs to be big enough to hold CRC also (+2 bytes) 00180 * 00181 * \param[out] inBuf : buffer with the hamming coded stream to be decoded 00182 * \param[in] inBufLen : number of bytes to decode (=length of buffer). 00183 * \param[out] outBuf : buffer where received data shall be written to. 00184 * \param[in] outBufLen : Length of output buffer, should be approx twice the size of inBuf 00185 * \param[out] outBufPos : The number of decoded bytes. Could be used in 00186 * extended implementation to allow multiple calls 00187 * \param[out] bitsBeforeCol : in case of ERR_COLLISION this value holds the 00188 * number of bits in the current byte where the collision happened. 00189 * \param[in] ignoreBits : number of bits in the beginning where collisions will be ignored 00190 * \param[in] picopassMode : if set to true, the decoding will be according to Picopass 00191 * 00192 * \return ERR_COLLISION : collision occured, data uncorrect 00193 * \return ERR_CRC : CRC error, data uncorrect 00194 * \return ERR_TIMEOUT : timeout waiting for data. 00195 * \return ERR_NONE : No error. 00196 * 00197 ***************************************************************************** 00198 */ 00199 extern ReturnCode iso15693VICCDecode(uint8_t *inBuf, 00200 uint16_t inBufLen, 00201 uint8_t* outBuf, 00202 uint16_t outBufLen, 00203 uint16_t* outBufPos, 00204 uint16_t* bitsBeforeCol, 00205 uint16_t ignoreBits, 00206 bool picopassMode ); 00207 00208 #endif /* RFAL_ISO_15693_2_H */ 00209
Generated on Sat Jul 16 2022 13:00:53 by
1.7.2