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_AnalogConfig.h
00001 /****************************************************************************** 00002 * @attention 00003 * 00004 * <h2><center>© COPYRIGHT 2016 STMicroelectronics</center></h2> 00005 * 00006 * Licensed under ST MYLIBERTY SOFTWARE LICENSE AGREEMENT (the "License"); 00007 * You may not use this file except in compliance with the License. 00008 * You may obtain a copy of the License at: 00009 * 00010 * http://www.st.com/myliberty 00011 * 00012 * Unless required by applicable law or agreed to in writing, software 00013 * distributed under the License is distributed on an "AS IS" BASIS, 00014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, 00015 * AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY, 00016 * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. 00017 * See the License for the specific language governing permissions and 00018 * limitations under the License. 00019 * 00020 ******************************************************************************/ 00021 00022 /* 00023 * PROJECT: ST25R391x firmware 00024 * $Revision: $ 00025 * LANGUAGE: ISO C99 00026 */ 00027 00028 /*! \file rfal_AnalogConfig.h 00029 * 00030 * \author bkam 00031 * 00032 * \brief RF Chip Analog Configuration Settings 00033 * 00034 * 00035 * @addtogroup RFAL 00036 * @{ 00037 * 00038 * @addtogroup RFAL-HAL 00039 * @brief RFAL Hardware Abstraction Layer 00040 * @{ 00041 * 00042 * @addtogroup AnalogConfig 00043 * @brief RFAL Analog Config Module 00044 * @{ 00045 * 00046 */ 00047 00048 #ifndef RFAL_ANALOG_CONFIG_H 00049 #define RFAL_ANALOG_CONFIG_H 00050 00051 /* 00052 ****************************************************************************** 00053 * INCLUDES 00054 ****************************************************************************** 00055 */ 00056 #include "platform1.h" 00057 #include "st_errno.h" 00058 #include "ST25R3911.h" 00059 00060 /* 00061 ****************************************************************************** 00062 * DEFINES 00063 ****************************************************************************** 00064 */ 00065 00066 #define RFAL_ANALOG_CONFIG_LUT_SIZE (87) /*!< Maximum number of Configuration IDs in the Loop Up Table */ 00067 #define RFAL_ANALOG_CONFIG_LUT_NOT_FOUND (0xFF) /*!< Index value indicating no Configuration IDs found */ 00068 00069 #define RFAL_ANALOG_CONFIG_TBL_SIZE (1024) /*!< Maximum number of Register-Mask-Value in the Setting List */ 00070 00071 00072 #define RFAL_ANALOG_CONFIG_POLL_LISTEN_MODE_MASK (0x8000) /*!< Mask bit of Poll Mode in Analog Configuration ID */ 00073 #define RFAL_ANALOG_CONFIG_TECH_MASK (0x7F00) /*!< Mask bits for Technology in Analog Configuration ID */ 00074 #define RFAL_ANALOG_CONFIG_BITRATE_MASK (0x00F0) /*!< Mask bits for Bit rate in Analog Configuration ID */ 00075 #define RFAL_ANALOG_CONFIG_DIRECTION_MASK (0x0003) /*!< Mask bits for Direction in Analog Configuration ID */ 00076 00077 #define RFAL_ANALOG_CONFIG_POLL_LISTEN_MODE_SHIFT (15) /*!< Shift value of Poll Mode in Analog Configuration ID */ 00078 #define RFAL_ANALOG_CONFIG_TECH_SHIFT (8) /*!< Shift value for Technology in Analog Configuration ID */ 00079 #define RFAL_ANALOG_CONFIG_BITRATE_SHIFT (4) /*!< Shift value for Technology in Analog Configuration ID */ 00080 #define RFAL_ANALOG_CONFIG_DIRECTION_SHIFT (0) /*!< Shift value for Direction in Analog Configuration ID */ 00081 00082 #define RFAL_ANALOG_CONFIG_POLL (0x0000) /*!< Poll Mode bit setting in Analog Configuration ID */ 00083 #define RFAL_ANALOG_CONFIG_LISTEN (0x8000) /*!< Listen Mode bit setting in Analog Configuration ID */ 00084 00085 #define RFAL_ANALOG_CONFIG_TECH_CHIP (0x0000) /*!< Chip-Specific bit setting in Analog Configuration ID */ 00086 #define RFAL_ANALOG_CONFIG_TECH_NFCA (0x0100) /*!< NFC-A Technology bits setting in Analog Configuration ID */ 00087 #define RFAL_ANALOG_CONFIG_TECH_NFCB (0x0200) /*!< NFC-B Technology bits setting in Analog Configuration ID */ 00088 #define RFAL_ANALOG_CONFIG_TECH_NFCF (0x0400) /*!< NFC-F Technology bits setting in Analog Configuration ID */ 00089 #define RFAL_ANALOG_CONFIG_TECH_AP2P (0x0800) /*!< AP2P Technology bits setting in Analog Configuration ID */ 00090 #define RFAL_ANALOG_CONFIG_TECH_NFCV (0x1000) /*!< NFC-V Technology bits setting in Analog Configuration ID */ 00091 #define RFAL_ANALOG_CONFIG_TECH_RFU (0x2000) /*!< RFU for Technology bits */ 00092 00093 #define RFAL_ANALOG_CONFIG_BITRATE_COMMON (0x0000) /*!< Common settings for all bit rates in Analog Configuration ID */ 00094 #define RFAL_ANALOG_CONFIG_BITRATE_106 (0x0010) /*!< 106kbits/s settings in Analog Configuration ID */ 00095 #define RFAL_ANALOG_CONFIG_BITRATE_212 (0x0020) /*!< 212kbits/s settings in Analog Configuration ID */ 00096 #define RFAL_ANALOG_CONFIG_BITRATE_424 (0x0030) /*!< 424kbits/s settings in Analog Configuration ID */ 00097 #define RFAL_ANALOG_CONFIG_BITRATE_848 (0x0040) /*!< 848kbits/s settings in Analog Configuration ID */ 00098 #define RFAL_ANALOG_CONFIG_BITRATE_1695 (0x0050) /*!< 1695kbits/s settings in Analog Configuration ID */ 00099 #define RFAL_ANALOG_CONFIG_BITRATE_3390 (0x0060) /*!< 3390kbits/s settings in Analog Configuration ID */ 00100 #define RFAL_ANALOG_CONFIG_BITRATE_6780 (0x0070) /*!< 6780kbits/s settings in Analog Configuration ID */ 00101 #define RFAL_ANALOG_CONFIG_BITRATE_1OF4 (0x00C0) /*!< 1 out of 4 for NFC-V setting in Analog Configuration ID */ 00102 #define RFAL_ANALOG_CONFIG_BITRATE_1OF256 (0x00D0) /*!< 1 out of 256 for NFC-V setting in Analog Configuration ID */ 00103 00104 #define RFAL_ANALOG_CONFIG_NO_DIRECTION (0x0000) /*!< No direction setting in Analog Conf ID (Chip Specific only) */ 00105 #define RFAL_ANALOG_CONFIG_TX (0x0001) /*!< Transmission bit setting in Analog Configuration ID */ 00106 #define RFAL_ANALOG_CONFIG_RX (0x0002) /*!< Reception bit setting in Analog Configuration ID */ 00107 00108 #define RFAL_ANALOG_CONFIG_UPDATE_LAST (0x00) /*!< Value indicating Last configuration set during update */ 00109 #define RFAL_ANALOG_CONFIG_UPDATE_MORE (0x01) /*!< Value indicating More configuration set coming during update */ 00110 00111 /* 00112 ****************************************************************************** 00113 * GLOBAL MACROS 00114 ****************************************************************************** 00115 */ 00116 00117 #define RFAL_ANALOG_CONFIG_ID_GET_POLL_LISTEN(id) (RFAL_ANALOG_CONFIG_POLL_LISTEN_MODE_MASK & id) /*!< Check if id indicates Listen mode */ 00118 00119 #define RFAL_ANALOG_CONFIG_ID_GET_TECH(id) (RFAL_ANALOG_CONFIG_TECH_MASK & id) /*!< Get the technology of Configuration ID */ 00120 #define RFAL_ANALOG_CONFIG_ID_IS_CHIP(id) (RFAL_ANALOG_CONFIG_TECH_MASK & id) /*!< Check if ID indicates Chip-specific */ 00121 #define RFAL_ANALOG_CONFIG_ID_IS_NFCA(id) (RFAL_ANALOG_CONFIG_TECH_NFCA & id) /*!< Check if ID indicates NFC-A */ 00122 #define RFAL_ANALOG_CONFIG_ID_IS_NFCB(id) (RFAL_ANALOG_CONFIG_TECH_NFCB & id) /*!< Check if ID indicates NFC-B */ 00123 #define RFAL_ANALOG_CONFIG_ID_IS_NFCF(id) (RFAL_ANALOG_CONFIG_TECH_NFCF & id) /*!< Check if ID indicates NFC-F */ 00124 #define RFAL_ANALOG_CONFIG_ID_IS_AP2P(id) (RFAL_ANALOG_CONFIG_TECH_AP2P & id) /*!< Check if ID indicates AP2P */ 00125 #define RFAL_ANALOG_CONFIG_ID_IS_NFCV(id) (RFAL_ANALOG_CONFIG_TECH_NFCV & id) /*!< Check if ID indicates NFC-V */ 00126 00127 #define RFAL_ANALOG_CONFIG_ID_GET_BITRATE(id) (RFAL_ANALOG_CONFIG_BITRATE_MASK & id) /*!< Get Bitrate of Configuration ID */ 00128 #define RFAL_ANALOG_CONFIG_ID_IS_COMMON(id) (RFAL_ANALOG_CONFIG_BITRATE_MASK & id) /*!< Check if ID indicates common bitrate */ 00129 #define RFAL_ANALOG_CONFIG_ID_IS_106(id) (RFAL_ANALOG_CONFIG_BITRATE_106 & id) /*!< Check if ID indicates 106kbits/s */ 00130 #define RFAL_ANALOG_CONFIG_ID_IS_212(id) (RFAL_ANALOG_CONFIG_BITRATE_212 & id) /*!< Check if ID indicates 212kbits/s */ 00131 #define RFAL_ANALOG_CONFIG_ID_IS_424(id) (RFAL_ANALOG_CONFIG_BITRATE_424 & id) /*!< Check if ID indicates 424kbits/s */ 00132 #define RFAL_ANALOG_CONFIG_ID_IS_848(id) (RFAL_ANALOG_CONFIG_BITRATE_848 & id) /*!< Check if ID indicates 848kbits/s */ 00133 #define RFAL_ANALOG_CONFIG_ID_IS_1695(id) (RFAL_ANALOG_CONFIG_BITRATE_1695 & id) /*!< Check if ID indicates 1695kbits/s */ 00134 #define RFAL_ANALOG_CONFIG_ID_IS_3390(id) (RFAL_ANALOG_CONFIG_BITRATE_3390 & id) /*!< Check if ID indicates 3390kbits/s */ 00135 #define RFAL_ANALOG_CONFIG_ID_IS_6780(id) (RFAL_ANALOG_CONFIG_BITRATE_6780 & id) /*!< Check if ID indicates 6780kbits/s */ 00136 #define RFAL_ANALOG_CONFIG_ID_IS_1OF4(id) (RFAL_ANALOG_CONFIG_BITRATE_1OF4 & id) /*!< Check if ID indicates 1 out of 4 bitrate */ 00137 #define RFAL_ANALOG_CONFIG_ID_IS_1OF256(id) (RFAL_ANALOG_CONFIG_BITRATE_1OF256 & id) /*!< Check if ID indicates 1 out of 256 bitrate */ 00138 00139 #define RFAL_ANALOG_CONFIG_ID_GET_DIRECTION(id) (RFAL_ANALOG_CONFIG_DIRECTION_MASK & id) /*!< Get Direction of Configuration ID */ 00140 #define RFAL_ANALOG_CONFIG_ID_IS_TX(id) (RFAL_ANALOG_CONFIG_TX & id) /*!< Check if id indicates TX */ 00141 #define RFAL_ANALOG_CONFIG_ID_IS_RX(id) (RFAL_ANALOG_CONFIG_RX & id) /*!< Check if id indicates RX */ 00142 00143 #define RFAL_ANALOG_CONFIG_CONFIG_NUM(x) (sizeof(x)/sizeof(x[0])) /*!< Get Analog Config number */ 00144 00145 /*! Set Analog Config ID value by: Mode, Technology, Bitrate and Direction */ 00146 #define RFAL_ANALOG_CONFIG_ID_SET(mode, tech, br, direction) \ 00147 ( RFAL_ANALOG_CONFIG_ID_GET_POLL_LISTEN(mode) \ 00148 | RFAL_ANALOG_CONFIG_ID_GET_TECH(tech) \ 00149 | RFAL_ANALOG_CONFIG_ID_GET_BITRATE(br) \ 00150 | RFAL_ANALOG_CONFIG_ID_GET_DIRECTION(direction) \ 00151 ) 00152 00153 /* 00154 ****************************************************************************** 00155 * GLOBAL DATA TYPES 00156 ****************************************************************************** 00157 */ 00158 00159 typedef uint8_t rfalAnalogConfigMode ; /*!< Polling or Listening Mode of Configuration */ 00160 typedef uint8_t rfalAnalogConfigTech ; /*!< Technology of Configuration */ 00161 typedef uint8_t rfalAnalogConfigBitrate ; /*!< Bitrate of Configuration */ 00162 typedef uint8_t rfalAnalogConfigDirection ; /*!< Transmit/Receive direction of Configuration */ 00163 00164 typedef uint8_t rfalAnalogConfigRegAddr [2]; /*!< Register Address to ST Chip */ 00165 typedef uint8_t rfalAnalogConfigRegMask ; /*!< Register Mask Value */ 00166 typedef uint8_t rfalAnalogConfigRegVal ; /*!< Register Value */ 00167 00168 typedef uint16_t rfalAnalogConfigId ; /*!< Analog Configuration ID */ 00169 typedef uint16_t rfalAnalogConfigOffset ; /*!< Analog Configuration offset address in the table */ 00170 typedef uint8_t rfalAnalogConfigNum ; /*!< Number of Analog settings for the respective Configuration ID */ 00171 00172 00173 /*! Struct that contain the Register-Mask-Value set. Make sure that the whole structure size is even and unaligned! */ 00174 typedef struct { 00175 rfalAnalogConfigRegAddr addr ; /*!< Register Address */ 00176 rfalAnalogConfigRegMask mask ; /*!< Register Mask Value */ 00177 rfalAnalogConfigRegVal val ; /*!< Register Value */ 00178 } rfalAnalogConfigRegAddrMaskVal ; 00179 00180 00181 /*! Struct that represents the Analog Configs */ 00182 typedef struct { 00183 uint8_t id[sizeof(rfalAnalogConfigId )]; /*!< Configuration ID */ 00184 rfalAnalogConfigNum num ; /*!< Number of Config Sets to follow */ 00185 rfalAnalogConfigRegAddrMaskVal regSet[]; /*!< Register-Mask-Value sets */ 00186 } rfalAnalogConfig ; 00187 00188 00189 /* 00190 ****************************************************************************** 00191 * GLOBAL FUNCTION PROTOTYPES 00192 ****************************************************************************** 00193 */ 00194 00195 /*! 00196 ***************************************************************************** 00197 * \brief Initialize the Analog Configuration 00198 * 00199 * Reset the Analog Configuration LUT pointer to reference to default settings. 00200 * 00201 ***************************************************************************** 00202 */ 00203 void rfalAnalogConfigInitialize( void ); 00204 00205 00206 /*! 00207 ***************************************************************************** 00208 * \brief Indicate if the current Analog Configuration Table is complete and ready to be used. 00209 * 00210 * \return true if current Analog Configuration Table is complete and ready to be used. 00211 * \return false if current Analog Configuration Table is incomplete 00212 * 00213 ***************************************************************************** 00214 */ 00215 bool rfalAnalogConfigIsReady( void ); 00216 00217 /*! 00218 ***************************************************************************** 00219 * \brief Write the whole Analog Configuration table in raw format 00220 * 00221 * Writes the Analog Configuration and Look Up Table with the given raw table 00222 * 00223 * NOTE: Function does not check the validity of the given Table contents 00224 * 00225 * \param[in] configTbl: location of config Table to be loaded 00226 * \param[in] configTblSize: size of the config Table to be loaded 00227 * 00228 * \return ERR_NONE : if setting is updated 00229 * \return ERR_PARAM : if configTbl is invalid 00230 * \return ERR_NOMEM : if the given Table is bigger exceeds the max size 00231 * \return ERR_REQUEST : if the update Configuration Id is disabled 00232 * 00233 ***************************************************************************** 00234 */ 00235 ReturnCode rfalAnalogConfigListWriteRaw( const uint8_t *configTbl, uint16_t configTblSize ); 00236 00237 /*! 00238 ***************************************************************************** 00239 * \brief Write the Analog Configuration table with new analog settings. 00240 * 00241 * Writes the Analog Configuration and Look Up Table with the new list of register-mask-value 00242 * and Configuration ID respectively. 00243 * 00244 * NOTE: Function does not check for the validity of the Register Address. 00245 * 00246 * \param[in] more: 0x00 indicates it is last Configuration ID settings; 00247 * 0x01 indicates more Configuration ID setting(s) are coming. 00248 * \param[in] *config: reference to the configuration list of current Configuraiton ID. 00249 * 00250 * \return ERR_PARAM : if Configuration ID or parameter is invalid 00251 * \return ERR_NOMEM : if LUT is full 00252 * \return ERR_REQUEST : if the update Configuration Id is disabled 00253 * \return ERR_NONE : if setting is updated 00254 * 00255 ***************************************************************************** 00256 */ 00257 ReturnCode rfalAnalogConfigListWrite( uint8_t more, rfalAnalogConfig *config ); 00258 00259 /*! 00260 ***************************************************************************** 00261 * \brief Read the whole Analog Configuration table in raw format 00262 * 00263 * Reads the whole Analog Configuration Table in raw format 00264 * 00265 * \param[out] tblBuf: location to the buffer to place the Config Table 00266 * \param[in] tblBufLen: length of the buffer to place the Config Table 00267 * \param[out] configTblSize: Config Table size 00268 * 00269 * \return ERR_PARAM : if configTbl or configTblSize is invalid 00270 * \return ERR_NOMEM : if configTblSize is not enough for the whole table 00271 * \return ERR_NONE : if read is successful 00272 * 00273 ***************************************************************************** 00274 */ 00275 ReturnCode rfalAnalogConfigListReadRaw( uint8_t *tblBuf, uint16_t tblBufLen, uint16_t *configTblSize ); 00276 00277 /*! 00278 ***************************************************************************** 00279 * \brief Read the Analog Configuration table. 00280 * 00281 * Read the Analog Configuration Table 00282 * 00283 * \param[in] configOffset: offset to the next Configuration ID in the List Table to be read. 00284 * \param[out] more: 0x00 indicates it is last Configuration ID settings; 00285 * 0x01 indicates more Configuration ID setting(s) are coming. 00286 * \param[out] config: configuration id, number of configuration sets and register-mask-value sets 00287 * \param[in] numConfig: the remaining configuration settings space available; 00288 * 00289 * \return ERR_NOMEM : if number of Configuration for respective Configuration ID is greater the the remaining configuration setting space available 00290 * \return ERR_NONE : if read is successful 00291 * 00292 ***************************************************************************** 00293 */ 00294 ReturnCode rfalAnalogConfigListRead( rfalAnalogConfigOffset *configOffset, uint8_t *more, rfalAnalogConfig *config, rfalAnalogConfigNum numConfig ); 00295 00296 /*! 00297 ***************************************************************************** 00298 * \brief Set the Analog settings of indicated Configuration ID. 00299 * 00300 * Update the chip with indicated analog settings of indicated Configuration ID. 00301 * 00302 * \param[in] configId: configuration ID 00303 * 00304 * \return ERR_PARAM if Configuration ID is invalid 00305 * \return ERR_INTERNAL if error updating setting to chip 00306 * \return ERR_NONE if new settings is applied to chip 00307 * 00308 ***************************************************************************** 00309 */ 00310 ReturnCode rfalSetAnalogConfig( rfalAnalogConfigId configId, SPI* mspiChannel, ST25R3911* mST25, DigitalOut* gpio_cs, InterruptIn* IRQ, DigitalOut* fieldLED_01, DigitalOut* fieldLED_02, DigitalOut* fieldLED_03, DigitalOut* fieldLED_04, DigitalOut* fieldLED_05, DigitalOut* fieldLED_06 ); 00311 00312 00313 #endif /* RFAL_ANALOG_CONFIG_H */ 00314 00315 /** 00316 * @} 00317 * 00318 * @} 00319 * 00320 * @} 00321 */
Generated on Sat Jul 16 2022 13:00:53 by
1.7.2