st25r3916.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  1. /******************************************************************************
  2. * \attention
  3. *
  4. * <h2><center>&copy; COPYRIGHT 2020 STMicroelectronics</center></h2>
  5. *
  6. * Licensed under ST MYLIBERTY SOFTWARE LICENSE AGREEMENT (the "License");
  7. * You may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at:
  9. *
  10. * www.st.com/myliberty
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
  15. * AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
  17. * See the License for the specific language governing permissions and
  18. * limitations under the License.
  19. *
  20. ******************************************************************************/
  21. /*
  22. * PROJECT: ST25R3916 firmware
  23. * Revision:
  24. * LANGUAGE: ISO C99
  25. */
  26. /*! \file
  27. *
  28. * \author Gustavo Patricio
  29. *
  30. * \brief ST25R3916 high level interface
  31. *
  32. *
  33. * \addtogroup RFAL
  34. * @{
  35. *
  36. * \addtogroup RFAL-HAL
  37. * \brief RFAL Hardware Abstraction Layer
  38. * @{
  39. *
  40. * \addtogroup ST25R3916
  41. * \brief RFAL ST25R3916 Driver
  42. * @{
  43. *
  44. * \addtogroup ST25R3916_Driver
  45. * \brief RFAL ST25R3916 Driver
  46. * @{
  47. *
  48. */
  49. #ifndef ST25R3916_H
  50. #define ST25R3916_H
  51. /*
  52. ******************************************************************************
  53. * INCLUDES
  54. ******************************************************************************
  55. */
  56. #include "platform.h"
  57. #include "st_errno.h"
  58. #include "st25r3916_com.h"
  59. /*
  60. ******************************************************************************
  61. * GLOBAL DATATYPES
  62. ******************************************************************************
  63. */
  64. /*! Struct to represent all regs on ST25R3916 */
  65. typedef struct{
  66. uint8_t RsA[(ST25R3916_REG_IC_IDENTITY+1U)]; /*!< Registers contained on ST25R3916 space A (Rs-A) */
  67. uint8_t RsB[ST25R3916_SPACE_B_REG_LEN]; /*!< Registers contained on ST25R3916 space B (Rs-B) */
  68. }t_st25r3916Regs;
  69. /*! Parameters how the stream mode should work */
  70. struct st25r3916StreamConfig {
  71. uint8_t useBPSK; /*!< 0: subcarrier, 1:BPSK */
  72. uint8_t din; /*!< Divider for the in subcarrier frequency: fc/2^din */
  73. uint8_t dout; /*!< Divider for the in subcarrier frequency fc/2^dout */
  74. uint8_t report_period_length; /*!< Length of the reporting period 2^report_period_length*/
  75. };
  76. /*
  77. ******************************************************************************
  78. * GLOBAL DEFINES
  79. ******************************************************************************
  80. */
  81. /* ST25R3916 direct commands */
  82. #define ST25R3916_CMD_SET_DEFAULT 0xC1U /*!< Puts the chip in default state (same as after power-up) */
  83. #define ST25R3916_CMD_STOP 0xC2U /*!< Stops all activities and clears FIFO */
  84. #define ST25R3916_CMD_TRANSMIT_WITH_CRC 0xC4U /*!< Transmit with CRC */
  85. #define ST25R3916_CMD_TRANSMIT_WITHOUT_CRC 0xC5U /*!< Transmit without CRC */
  86. #define ST25R3916_CMD_TRANSMIT_REQA 0xC6U /*!< Transmit REQA */
  87. #define ST25R3916_CMD_TRANSMIT_WUPA 0xC7U /*!< Transmit WUPA */
  88. #define ST25R3916_CMD_INITIAL_RF_COLLISION 0xC8U /*!< NFC transmit with Initial RF Collision Avoidance */
  89. #define ST25R3916_CMD_RESPONSE_RF_COLLISION_N 0xC9U /*!< NFC transmit with Response RF Collision Avoidance */
  90. #define ST25R3916_CMD_GOTO_SENSE 0xCDU /*!< Passive target logic to Sense/Idle state */
  91. #define ST25R3916_CMD_GOTO_SLEEP 0xCEU /*!< Passive target logic to Sleep/Halt state */
  92. #define ST25R3916_CMD_MASK_RECEIVE_DATA 0xD0U /*!< Mask receive data */
  93. #define ST25R3916_CMD_UNMASK_RECEIVE_DATA 0xD1U /*!< Unmask receive data */
  94. #define ST25R3916_CMD_AM_MOD_STATE_CHANGE 0xD2U /*!< AM Modulation state change */
  95. #define ST25R3916_CMD_MEASURE_AMPLITUDE 0xD3U /*!< Measure singal amplitude on RFI inputs */
  96. #define ST25R3916_CMD_RESET_RXGAIN 0xD5U /*!< Reset RX Gain */
  97. #define ST25R3916_CMD_ADJUST_REGULATORS 0xD6U /*!< Adjust regulators */
  98. #define ST25R3916_CMD_CALIBRATE_DRIVER_TIMING 0xD8U /*!< Starts the sequence to adjust the driver timing */
  99. #define ST25R3916_CMD_MEASURE_PHASE 0xD9U /*!< Measure phase between RFO and RFI signal */
  100. #define ST25R3916_CMD_CLEAR_RSSI 0xDAU /*!< Clear RSSI bits and restart the measurement */
  101. #define ST25R3916_CMD_CLEAR_FIFO 0xDBU /*!< Clears FIFO, Collision and IRQ status */
  102. #define ST25R3916_CMD_TRANSPARENT_MODE 0xDCU /*!< Transparent mode */
  103. #define ST25R3916_CMD_CALIBRATE_C_SENSOR 0xDDU /*!< Calibrate the capacitive sensor */
  104. #define ST25R3916_CMD_MEASURE_CAPACITANCE 0xDEU /*!< Measure capacitance */
  105. #define ST25R3916_CMD_MEASURE_VDD 0xDFU /*!< Measure power supply voltage */
  106. #define ST25R3916_CMD_START_GP_TIMER 0xE0U /*!< Start the general purpose timer */
  107. #define ST25R3916_CMD_START_WUP_TIMER 0xE1U /*!< Start the wake-up timer */
  108. #define ST25R3916_CMD_START_MASK_RECEIVE_TIMER 0xE2U /*!< Start the mask-receive timer */
  109. #define ST25R3916_CMD_START_NO_RESPONSE_TIMER 0xE3U /*!< Start the no-response timer */
  110. #define ST25R3916_CMD_START_PPON2_TIMER 0xE4U /*!< Start PPon2 timer */
  111. #define ST25R3916_CMD_STOP_NRT 0xE8U /*!< Stop No Response Timer */
  112. #define ST25R3916_CMD_SPACE_B_ACCESS 0xFBU /*!< Enable R/W access to the test registers */
  113. #define ST25R3916_CMD_TEST_ACCESS 0xFCU /*!< Enable R/W access to the test registers */
  114. #define ST25R3916_THRESHOLD_DO_NOT_SET 0xFFU /*!< Indicates not to change this Threshold */
  115. #define ST25R3916_BR_DO_NOT_SET 0xFFU /*!< Indicates not to change this Bit Rate */
  116. #define ST25R3916_BR_106 0x00U /*!< ST25R3916 Bit Rate 106 kbit/s (fc/128) */
  117. #define ST25R3916_BR_212 0x01U /*!< ST25R3916 Bit Rate 212 kbit/s (fc/64) */
  118. #define ST25R3916_BR_424 0x02U /*!< ST25R3916 Bit Rate 424 kbit/s (fc/32) */
  119. #define ST25R3916_BR_848 0x03U /*!< ST25R3916 Bit Rate 848 kbit/s (fc/16) */
  120. #define ST25R3916_BR_1695 0x04U /*!< ST25R3916 Bit Rate 1696 kbit/s (fc/8) */
  121. #define ST25R3916_BR_3390 0x05U /*!< ST25R3916 Bit Rate 3390 kbit/s (fc/4) */
  122. #define ST25R3916_BR_6780 0x07U /*!< ST25R3916 Bit Rate 6780 kbit/s (fc/2) */
  123. #define ST25R3916_FIFO_DEPTH 512U /*!< Depth of FIFO */
  124. #define ST25R3916_TOUT_OSC_STABLE 10U /*!< Max timeout for Oscillator to get stable DS: 700us */
  125. /*
  126. ******************************************************************************
  127. * GLOBAL MACROS
  128. ******************************************************************************
  129. */
  130. /*! Enables the Transmitter (Field On) and Receiver */
  131. #define st25r3916TxRxOn() st25r3916SetRegisterBits( ST25R3916_REG_OP_CONTROL, (ST25R3916_REG_OP_CONTROL_rx_en | ST25R3916_REG_OP_CONTROL_tx_en ) )
  132. /*! Disables the Transmitter (Field Off) and Receiver */
  133. #define st25r3916TxRxOff() st25r3916ClrRegisterBits( ST25R3916_REG_OP_CONTROL, (ST25R3916_REG_OP_CONTROL_rx_en | ST25R3916_REG_OP_CONTROL_tx_en ) )
  134. /*! Disables the Transmitter (Field Off) */
  135. #define st25r3916TxOff() st25r3916ClrRegisterBits( ST25R3916_REG_OP_CONTROL, ST25R3916_REG_OP_CONTROL_tx_en )
  136. /*! Checks if General Purpose Timer is still running by reading gpt_on flag */
  137. #define st25r3916IsGPTRunning( ) st25r3916CheckReg( ST25R3916_REG_NFCIP1_BIT_RATE, ST25R3916_REG_NFCIP1_BIT_RATE_gpt_on, ST25R3916_REG_NFCIP1_BIT_RATE_gpt_on )
  138. /*! Checks if External Filed is detected by reading ST25R3916 External Field Detector output */
  139. #define st25r3916IsExtFieldOn() st25r3916CheckReg( ST25R3916_REG_AUX_DISPLAY, ST25R3916_REG_AUX_DISPLAY_efd_o, ST25R3916_REG_AUX_DISPLAY_efd_o )
  140. /*! Checks if Transmitter is enabled (Field On) */
  141. #define st25r3916IsTxEnabled() st25r3916CheckReg( ST25R3916_REG_OP_CONTROL, ST25R3916_REG_OP_CONTROL_tx_en, ST25R3916_REG_OP_CONTROL_tx_en )
  142. /*! Checks if NRT is in EMV mode */
  143. #define st25r3916IsNRTinEMV() st25r3916CheckReg( ST25R3916_REG_TIMER_EMV_CONTROL, ST25R3916_REG_TIMER_EMV_CONTROL_nrt_emv, ST25R3916_REG_TIMER_EMV_CONTROL_nrt_emv_on )
  144. /*! Checks if last FIFO byte is complete */
  145. #define st25r3916IsLastFIFOComplete() st25r3916CheckReg( ST25R3916_REG_FIFO_STATUS2, ST25R3916_REG_FIFO_STATUS2_fifo_lb_mask, 0 )
  146. /*! Checks if the Oscillator is enabled */
  147. #define st25r3916IsOscOn() st25r3916CheckReg( ST25R3916_REG_OP_CONTROL, ST25R3916_REG_OP_CONTROL_en, ST25R3916_REG_OP_CONTROL_en )
  148. /*
  149. ******************************************************************************
  150. * GLOBAL FUNCTION PROTOTYPES
  151. ******************************************************************************
  152. */
  153. /*!
  154. *****************************************************************************
  155. * \brief Initialise ST25R3916 driver
  156. *
  157. * This function initialises the ST25R3916 driver.
  158. *
  159. * \return ERR_NONE : Operation successful
  160. * \return ERR_HW_MISMATCH : Expected HW do not match or communication error
  161. * \return ERR_IO : Error during communication selftest. Check communication interface
  162. * \return ERR_TIMEOUT : Timeout during IRQ selftest. Check IRQ handling
  163. * \return ERR_SYSTEM : Failure during oscillator activation or timer error
  164. *
  165. *****************************************************************************
  166. */
  167. ReturnCode st25r3916Initialize( void );
  168. /*!
  169. *****************************************************************************
  170. * \brief Deinitialize ST25R3916 driver
  171. *
  172. * Calling this function deinitializes the ST25R3916 driver.
  173. *
  174. *****************************************************************************
  175. */
  176. void st25r3916Deinitialize( void );
  177. /*!
  178. *****************************************************************************
  179. * \brief Turn on Oscillator and Regulator
  180. *
  181. * This function turn on oscillator and regulator and waits for the
  182. * oscillator to become stable
  183. *
  184. * \return ERR_SYSTEM : Failure dusring Oscillator activation
  185. * \return ERR_NONE : No error, Oscillator is active and stable, Regulator is on
  186. *
  187. *****************************************************************************
  188. */
  189. ReturnCode st25r3916OscOn( void );
  190. /*!
  191. *****************************************************************************
  192. * \brief Sets the bitrate
  193. *
  194. * This function sets the bitrates for rx and tx
  195. *
  196. * \param txrate : speed is 2^txrate * 106 kb/s
  197. * 0xff : don't set txrate (ST25R3916_BR_DO_NOT_SET)
  198. * \param rxrate : speed is 2^rxrate * 106 kb/s
  199. * 0xff : don't set rxrate (ST25R3916_BR_DO_NOT_SET)
  200. *
  201. * \return ERR_PARAM: At least one bit rate was invalid
  202. * \return ERR_NONE : No error, both bit rates were set
  203. *
  204. *****************************************************************************
  205. */
  206. ReturnCode st25r3916SetBitrate( uint8_t txrate, uint8_t rxrate );
  207. /*!
  208. *****************************************************************************
  209. * \brief Adjusts supply regulators according to the current supply voltage
  210. *
  211. * This function the power level is measured in maximum load conditions and
  212. * the regulated voltage reference is set to 250mV below this level.
  213. * Execution of this function lasts arround 5ms.
  214. *
  215. * The regulated voltages will be set to the result of Adjust Regulators
  216. *
  217. * \param [out] result_mV : Result of calibration in milliVolts
  218. *
  219. * \return ERR_IO : Error during communication with ST25R3916
  220. * \return ERR_NONE : No error
  221. *
  222. *****************************************************************************
  223. */
  224. ReturnCode st25r3916AdjustRegulators( uint16_t* result_mV );
  225. /*!
  226. *****************************************************************************
  227. * \brief Measure Amplitude
  228. *
  229. * This function measured the amplitude on the RFI inputs and stores the
  230. * result in parameter \a result.
  231. *
  232. * \param[out] result: result of RF measurement.
  233. *
  234. * \return ERR_PARAM : Invalid parameter
  235. * \return ERR_NONE : No error
  236. *
  237. *****************************************************************************
  238. */
  239. ReturnCode st25r3916MeasureAmplitude( uint8_t* result );
  240. /*!
  241. *****************************************************************************
  242. * \brief Measure Power Supply
  243. *
  244. * This function executes Measure Power Supply and returns the raw value
  245. *
  246. * \param[in] mpsv : one of ST25R3916_REG_REGULATOR_CONTROL_mpsv_vdd
  247. * ST25R3916_REG_REGULATOR_CONTROL_mpsv_vdd_rf
  248. * ST25R3916_REG_REGULATOR_CONTROL_mpsv_vdd_a
  249. * ST25R3916_REG_REGULATOR_CONTROL_mpsv_vdd_d
  250. * ST25R3916_REG_REGULATOR_CONTROL_mpsv_vdd_am
  251. *
  252. * \return the measured voltage in raw format.
  253. *
  254. *****************************************************************************
  255. */
  256. uint8_t st25r3916MeasurePowerSupply( uint8_t mpsv );
  257. /*!
  258. *****************************************************************************
  259. * \brief Measure Voltage
  260. *
  261. * This function measures the voltage on one of VDD and VDD_* and returns
  262. * the result in mV
  263. *
  264. * \param[in] mpsv : one of ST25R3916_REG_REGULATOR_CONTROL_mpsv_vdd
  265. * ST25R3916_REG_REGULATOR_CONTROL_mpsv_vdd_rf
  266. * ST25R3916_REG_REGULATOR_CONTROL_mpsv_vdd_a
  267. * ST25R3916_REG_REGULATOR_CONTROL_mpsv_vdd_d
  268. * or ST25R3916_REG_REGULATOR_CONTROL_mpsv_vdd_am
  269. *
  270. * \return the measured voltage in mV
  271. *
  272. *****************************************************************************
  273. */
  274. uint16_t st25r3916MeasureVoltage( uint8_t mpsv );
  275. /*!
  276. *****************************************************************************
  277. * \brief Measure Phase
  278. *
  279. * This function performs a Phase measurement.
  280. * The result is stored in the \a result parameter.
  281. *
  282. * \param[out] result: 8 bit long result of the measurement.
  283. *
  284. * \return ERR_PARAM : Invalid parameter
  285. * \return ERR_NONE : No error
  286. *
  287. *****************************************************************************
  288. */
  289. ReturnCode st25r3916MeasurePhase( uint8_t* result );
  290. /*!
  291. *****************************************************************************
  292. * \brief Measure Capacitance
  293. *
  294. * This function performs the capacitance measurement and stores the
  295. * result in parameter \a result.
  296. *
  297. * \param[out] result: 8 bit long result of RF measurement.
  298. *
  299. * \return ERR_PARAM : Invalid parameter
  300. * \return ERR_NONE : No error
  301. *
  302. *****************************************************************************
  303. */
  304. ReturnCode st25r3916MeasureCapacitance( uint8_t* result );
  305. /*!
  306. *****************************************************************************
  307. * \brief Calibrates Capacitive Sensor
  308. *
  309. * This function performs automatic calibration of the capacitive sensor
  310. * and stores the result in parameter \a result.
  311. *
  312. * \warning To avoid interference with Xtal oscillator and reader magnetic
  313. * field, it is strongly recommended to perform calibration
  314. * in Power-down mode only.
  315. * This method does not modify the Oscillator nor transmitter state,
  316. * these should be configured before by user.
  317. *
  318. * \param[out] result: 5 bit long result of the calibration.
  319. * Binary weighted, step 0.1 pF, max 3.1 pF
  320. *
  321. * \return ERR_PARAM : Invalid parameter
  322. * \return ERR_IO : The calibration was not successful
  323. * \return ERR_NONE : No error
  324. *
  325. *****************************************************************************
  326. */
  327. ReturnCode st25r3916CalibrateCapacitiveSensor( uint8_t* result );
  328. /*!
  329. *****************************************************************************
  330. * \brief Get NRT time
  331. *
  332. * This returns the last value set on the NRT
  333. *
  334. * \warning it does not read chip register, just the sw var that contains the
  335. * last value set before
  336. *
  337. * \return the value of the NRT in 64/fc
  338. */
  339. uint32_t st25r3916GetNoResponseTime( void );
  340. /*!
  341. *****************************************************************************
  342. * \brief Set NRT time
  343. *
  344. * This function sets the No Response Time with the given value
  345. *
  346. * \param [in] nrt_64fcs : no response time in steps of 64/fc (4.72us)
  347. *
  348. * \return ERR_PARAM : Invalid parameter (time is too large)
  349. * \return ERR_NONE : No error
  350. *
  351. *****************************************************************************
  352. */
  353. ReturnCode st25r3916SetNoResponseTime( uint32_t nrt_64fcs );
  354. /*!
  355. *****************************************************************************
  356. * \brief Set and Start NRT
  357. *
  358. * This function sets the No Response Time with the given value and
  359. * immediately starts it
  360. * Used when needs to add more time before timeout without performing Tx
  361. *
  362. * \param [in] nrt_64fcs : no response time in steps of 64/fc (4.72us)
  363. *
  364. * \return ERR_PARAM : Invalid parameter
  365. * \return ERR_NONE : No error
  366. *
  367. *****************************************************************************
  368. */
  369. ReturnCode st25r3916SetStartNoResponseTimer( uint32_t nrt_64fcs );
  370. /*!
  371. *****************************************************************************
  372. * \brief Set GPT time
  373. *
  374. * This function sets the General Purpose Timer time registers
  375. *
  376. * \param [in] gpt_8fcs : general purpose timer timeout in steps of 8/fc (590ns)
  377. *
  378. *****************************************************************************
  379. */
  380. void st25r3916SetGPTime( uint16_t gpt_8fcs );
  381. /*!
  382. *****************************************************************************
  383. * \brief Set and Start GPT
  384. *
  385. * This function sets the General Purpose Timer with the given timeout and
  386. * immediately starts it ONLY if the trigger source is not set to none.
  387. *
  388. * \param [in] gpt_8fcs : general purpose timer timeout in steps of8/fc (590ns)
  389. * \param [in] trigger_source : no trigger, start of Rx, end of Rx, end of Tx in NFC mode
  390. *
  391. * \return ERR_PARAM : Invalid parameter
  392. * \return ERR_NONE : No error
  393. *
  394. *****************************************************************************
  395. */
  396. ReturnCode st25r3916SetStartGPTimer( uint16_t gpt_8fcs, uint8_t trigger_source );
  397. /*!
  398. *****************************************************************************
  399. * \brief Sets the number Tx Bits
  400. *
  401. * Sets ST25R3916 internal registers with correct number of complete bytes and
  402. * bits to be sent
  403. *
  404. * \param [in] nBits : number of bits to be set/transmitted
  405. *
  406. *****************************************************************************
  407. */
  408. void st25r3916SetNumTxBits( uint16_t nBits );
  409. /*!
  410. *****************************************************************************
  411. * \brief Get amount of bytes in FIFO
  412. *
  413. * Gets the number of bytes currently in the FIFO
  414. *
  415. * \return the number of bytes currently in the FIFO
  416. *
  417. *****************************************************************************
  418. */
  419. uint16_t st25r3916GetNumFIFOBytes( void );
  420. /*!
  421. *****************************************************************************
  422. * \brief Get amount of bits of the last FIFO byte if incomplete
  423. *
  424. * Gets the number of bits of the last FIFO byte if incomplete
  425. *
  426. * \return the number of bits of the last FIFO byte if incomplete, 0 if
  427. * the last byte is complete
  428. *
  429. *****************************************************************************
  430. */
  431. uint8_t st25r3916GetNumFIFOLastBits( void );
  432. /*!
  433. *****************************************************************************
  434. * \brief Perform Collision Avoidance
  435. *
  436. * Performs Collision Avoidance with the given threshold and with the
  437. * n number of TRFW
  438. *
  439. * \param[in] FieldONCmd : Field ON command to be executed ST25R3916_CMD_INITIAL_RF_COLLISION
  440. * or ST25R3916_CMD_RESPONSE_RF_COLLISION_N
  441. * \param[in] pdThreshold : Peer Detection Threshold (ST25R3916_REG_FIELD_THRESHOLD_trg_xx)
  442. * 0xff : don't set Threshold (ST25R3916_THRESHOLD_DO_NOT_SET)
  443. * \param[in] caThreshold : Collision Avoidance Threshold (ST25R3916_REG_FIELD_THRESHOLD_rfe_xx)
  444. * 0xff : don't set Threshold (ST25R3916_THRESHOLD_DO_NOT_SET)
  445. * \param[in] nTRFW : Number of TRFW
  446. *
  447. * \return ERR_PARAM : Invalid parameter
  448. * \return ERR_RF_COLLISION : Collision detected
  449. * \return ERR_NONE : No collision detected
  450. *
  451. *****************************************************************************
  452. */
  453. ReturnCode st25r3916PerformCollisionAvoidance( uint8_t FieldONCmd, uint8_t pdThreshold, uint8_t caThreshold, uint8_t nTRFW );
  454. /*!
  455. *****************************************************************************
  456. * \brief Check Identity
  457. *
  458. * Checks if the chip ID is as expected.
  459. *
  460. * 5 bit IC type code for ST25R3916: 00101
  461. * The 3 lsb contain the IC revision code
  462. *
  463. * \param[out] rev : the IC revision code
  464. *
  465. * \return true when IC type is as expected
  466. * \return false otherwise
  467. */
  468. bool st25r3916CheckChipID( uint8_t *rev );
  469. /*!
  470. *****************************************************************************
  471. * \brief Retrieves all internal registers from ST25R3916
  472. *
  473. * \param[out] regDump : pointer to the struct/buffer where the reg dump
  474. * will be written
  475. *
  476. * \return ERR_PARAM : Invalid parameter
  477. * \return ERR_NONE : No error
  478. *****************************************************************************
  479. */
  480. ReturnCode st25r3916GetRegsDump( t_st25r3916Regs* regDump );
  481. /*!
  482. *****************************************************************************
  483. * \brief Check if command is valid
  484. *
  485. * Checks if the given command is a valid ST25R3916 command
  486. *
  487. * \param[in] cmd: Command to check
  488. *
  489. * \return true if is a valid command
  490. * \return false otherwise
  491. *
  492. *****************************************************************************
  493. */
  494. bool st25r3916IsCmdValid( uint8_t cmd );
  495. /*!
  496. *****************************************************************************
  497. * \brief Configure the stream mode of ST25R3916
  498. *
  499. * This function initializes the stream with the given parameters
  500. *
  501. * \param[in] config : all settings for bitrates, type, etc.
  502. *
  503. * \return ERR_PARAM : Invalid parameter
  504. * \return ERR_NONE : No error, stream mode driver initialized
  505. *
  506. *****************************************************************************
  507. */
  508. ReturnCode st25r3916StreamConfigure( const struct st25r3916StreamConfig *config );
  509. /*!
  510. *****************************************************************************
  511. * \brief Executes a direct command and returns the result
  512. *
  513. * This function executes the direct command given by \a cmd waits for
  514. * \a sleeptime for I_dct and returns the result read from register \a resreg.
  515. * The value of cmd is not checked.
  516. *
  517. * \param[in] cmd : direct command to execute
  518. * \param[in] resReg: address of the register containing the result
  519. * \param[in] tout : time in milliseconds to wait before reading the result
  520. * \param[out] result: result
  521. *
  522. * \return ERR_NONE : No error
  523. *
  524. *****************************************************************************
  525. */
  526. ReturnCode st25r3916ExecuteCommandAndGetResult( uint8_t cmd, uint8_t resReg, uint8_t tout, uint8_t* result );
  527. /*!
  528. *****************************************************************************
  529. * \brief Gets the RSSI values
  530. *
  531. * This function gets the RSSI value of the previous reception taking into
  532. * account the gain reductions that were used.
  533. * RSSI value for both AM and PM channel can be retrieved.
  534. *
  535. * \param[out] amRssi: the RSSI on the AM channel expressed in mV
  536. * \param[out] pmRssi: the RSSI on the PM channel expressed in mV
  537. *
  538. * \return ERR_PARAM : Invalid parameter
  539. * \return ERR_NONE : No error
  540. *
  541. *****************************************************************************
  542. */
  543. ReturnCode st25r3916GetRSSI( uint16_t *amRssi, uint16_t *pmRssi );
  544. #endif /* ST25R3916_H */
  545. /**
  546. * @}
  547. *
  548. * @}
  549. *
  550. * @}
  551. *
  552. * @}
  553. */