Fork of the GitHub

Dependents:   mbed-os-nfc04a1

Committer:
DiegoOstuni
Date:
Thu Nov 14 10:36:30 2019 +0000
Revision:
0:bea5dbf3f7d5
Add Files

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DiegoOstuni 0:bea5dbf3f7d5 1 /**
DiegoOstuni 0:bea5dbf3f7d5 2 ******************************************************************************
DiegoOstuni 0:bea5dbf3f7d5 3 * @file st25dv.c
DiegoOstuni 0:bea5dbf3f7d5 4 * @author MMY Application Team
DiegoOstuni 0:bea5dbf3f7d5 5 * @version $Revision: 3308 $
DiegoOstuni 0:bea5dbf3f7d5 6 * @date $Date: 2017-01-13 11:19:33 +0100 (Fri, 13 Jan 2017) $
DiegoOstuni 0:bea5dbf3f7d5 7 * @brief This file provides set of driver functions to manage communication
DiegoOstuni 0:bea5dbf3f7d5 8 * between BSP and ST25DV chip.
DiegoOstuni 0:bea5dbf3f7d5 9 ******************************************************************************
DiegoOstuni 0:bea5dbf3f7d5 10 * @attention
DiegoOstuni 0:bea5dbf3f7d5 11 *
DiegoOstuni 0:bea5dbf3f7d5 12 * <h2><center>&copy; COPYRIGHT 2016 STMicroelectronics</center></h2>
DiegoOstuni 0:bea5dbf3f7d5 13 *
DiegoOstuni 0:bea5dbf3f7d5 14 * Licensed under ST MYLIBERTY SOFTWARE LICENSE AGREEMENT (the "License");
DiegoOstuni 0:bea5dbf3f7d5 15 * You may not use this file except in compliance with the License.
DiegoOstuni 0:bea5dbf3f7d5 16 * You may obtain a copy of the License at:
DiegoOstuni 0:bea5dbf3f7d5 17 *
DiegoOstuni 0:bea5dbf3f7d5 18 * http://www.st.com/myliberty
DiegoOstuni 0:bea5dbf3f7d5 19 *
DiegoOstuni 0:bea5dbf3f7d5 20 * Unless required by applicable law or agreed to in writing, software
DiegoOstuni 0:bea5dbf3f7d5 21 * distributed under the License is distributed on an "AS IS" BASIS,
DiegoOstuni 0:bea5dbf3f7d5 22 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
DiegoOstuni 0:bea5dbf3f7d5 23 * AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
DiegoOstuni 0:bea5dbf3f7d5 24 * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
DiegoOstuni 0:bea5dbf3f7d5 25 * See the License for the specific language governing permissions and
DiegoOstuni 0:bea5dbf3f7d5 26 * limitations under the License.
DiegoOstuni 0:bea5dbf3f7d5 27 *
DiegoOstuni 0:bea5dbf3f7d5 28 ******************************************************************************
DiegoOstuni 0:bea5dbf3f7d5 29 */
DiegoOstuni 0:bea5dbf3f7d5 30
DiegoOstuni 0:bea5dbf3f7d5 31 /* Includes ------------------------------------------------------------------*/
DiegoOstuni 0:bea5dbf3f7d5 32 #include "st25dv.h"
DiegoOstuni 0:bea5dbf3f7d5 33
DiegoOstuni 0:bea5dbf3f7d5 34 #include "x_nucleo_nfc04.h"
DiegoOstuni 0:bea5dbf3f7d5 35
DiegoOstuni 0:bea5dbf3f7d5 36
DiegoOstuni 0:bea5dbf3f7d5 37
DiegoOstuni 0:bea5dbf3f7d5 38
DiegoOstuni 0:bea5dbf3f7d5 39 /** @addtogroup BSP
DiegoOstuni 0:bea5dbf3f7d5 40 * @{
DiegoOstuni 0:bea5dbf3f7d5 41 */
DiegoOstuni 0:bea5dbf3f7d5 42
DiegoOstuni 0:bea5dbf3f7d5 43 /** @defgroup ST25DV ST25DV driver
DiegoOstuni 0:bea5dbf3f7d5 44 * @brief This module implements the functions to drive the ST25DV NFC dynamic tag.
DiegoOstuni 0:bea5dbf3f7d5 45 * @details As recommended by the STM32 Cube methodology, this driver provides a standard structure to expose the NFC tag standard API.\n
DiegoOstuni 0:bea5dbf3f7d5 46 * It also provides an extended API through its extended driver structure.\n
DiegoOstuni 0:bea5dbf3f7d5 47 * To be usable on any MCU, this driver calls several IOBus functions.
DiegoOstuni 0:bea5dbf3f7d5 48 * The IOBus functions are implemented outside this driver, and are in charge of accessing the MCU peripherals used for the communication with the tag.
DiegoOstuni 0:bea5dbf3f7d5 49 * @{
DiegoOstuni 0:bea5dbf3f7d5 50 */
DiegoOstuni 0:bea5dbf3f7d5 51
DiegoOstuni 0:bea5dbf3f7d5 52 /* External variables --------------------------------------------------------*/
DiegoOstuni 0:bea5dbf3f7d5 53 /* Private typedef -----------------------------------------------------------*/
DiegoOstuni 0:bea5dbf3f7d5 54 /* Private defines -----------------------------------------------------------*/
DiegoOstuni 0:bea5dbf3f7d5 55 /** @brief This component driver only supports 1 instance of the component */
DiegoOstuni 0:bea5dbf3f7d5 56 #define ST25DV_MAX_INSTANCE 1
DiegoOstuni 0:bea5dbf3f7d5 57
DiegoOstuni 0:bea5dbf3f7d5 58
DiegoOstuni 0:bea5dbf3f7d5 59 /* Private macros ------------------------------------------------------------*/
DiegoOstuni 0:bea5dbf3f7d5 60 /* Private function prototypes -----------------------------------------------*/
DiegoOstuni 0:bea5dbf3f7d5 61 NFCTAG_StatusTypeDef ST25DV_i2c_Init( I2C * mi2cChannel, DigitalOut* mLPD );
DiegoOstuni 0:bea5dbf3f7d5 62 NFCTAG_StatusTypeDef ST25DV_i2c_ReadID( uint8_t * const pICRef, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 63 NFCTAG_StatusTypeDef ST25DV_i2c_ReadICRev( uint8_t * const pICRev, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 64 NFCTAG_StatusTypeDef ST25DV_i2c_IsDeviceReady( const uint32_t Trials, I2C * mi2cChannel);
DiegoOstuni 0:bea5dbf3f7d5 65 NFCTAG_StatusTypeDef ST25DV_i2c_GetGPOStatus( uint16_t * const pGPOStatus, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 66 NFCTAG_StatusTypeDef ST25DV_i2c_ConfigureGPO( const uint16_t ITConf, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 67 NFCTAG_StatusTypeDef ST25DV_i2c_ReadITPulse( ST25DV_PULSE_DURATION * const pITtime, I2C * mi2cChannel);
DiegoOstuni 0:bea5dbf3f7d5 68 NFCTAG_StatusTypeDef ST25DV_i2c_WriteITPulse( const ST25DV_PULSE_DURATION ITtime, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 69 NFCTAG_StatusTypeDef ST25DV_i2c_ReadData( uint8_t * const pData, const uint16_t TarAddr, const uint16_t NbByte, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 70 NFCTAG_StatusTypeDef ST25DV_i2c_WriteData( const uint8_t * const pData, const uint16_t TarAddr, const uint16_t NbByte, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 71 NFCTAG_StatusTypeDef ST25DV_i2c_ReadDataCurrentAddr( uint8_t * const pData, const uint16_t NbByte, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 72 NFCTAG_StatusTypeDef ST25DV_i2c_ReadRegister( uint8_t * const pData, const uint16_t TarAddr, const uint16_t NbByte , I2C * mi2cChannel);
DiegoOstuni 0:bea5dbf3f7d5 73 NFCTAG_StatusTypeDef ST25DV_i2c_WriteRegister( const uint8_t * const pData, const uint16_t TarAddr, const uint16_t NbByte, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 74 NFCTAG_StatusTypeDef ST25DV_i2c_ReadUID( ST25DV_UID * const pUid, I2C * mi2cChannel);
DiegoOstuni 0:bea5dbf3f7d5 75 NFCTAG_StatusTypeDef ST25DV_i2c_ReadDSFID( uint8_t * const pDsfid, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 76 NFCTAG_StatusTypeDef ST25DV_i2c_ReadDsfidRFProtection( ST25DV_LOCK_STATUS * const pLockDsfid, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 77 NFCTAG_StatusTypeDef ST25DV_i2c_ReadAFI( uint8_t * const pAfi, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 78 NFCTAG_StatusTypeDef ST25DV_i2c_ReadAfiRFProtection( ST25DV_LOCK_STATUS * const pLockAfi, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 79 NFCTAG_StatusTypeDef ST25DV_i2c_ReadI2CProtectZone( ST25DV_I2C_PROT_ZONE * const pProtZone, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 80 NFCTAG_StatusTypeDef ST25DV_i2c_WriteI2CProtectZonex( const ST25DV_PROTECTION_ZONE Zone, const ST25DV_PROTECTION_CONF ReadWriteProtection, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 81 NFCTAG_StatusTypeDef ST25DV_i2c_ReadLockCCFile( ST25DV_LOCK_CCFILE * const pLockCCFile, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 82 NFCTAG_StatusTypeDef ST25DV_i2c_WriteLockCCFile( const ST25DV_CCFILE_BLOCK NbBlockCCFile, const ST25DV_LOCK_STATUS LockCCFile, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 83 NFCTAG_StatusTypeDef ST25DV_i2c_ReadLockCFG( ST25DV_LOCK_STATUS * const pLockCfg, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 84 NFCTAG_StatusTypeDef ST25DV_i2c_WriteLockCFG( const ST25DV_LOCK_STATUS LockCfg, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 85 NFCTAG_StatusTypeDef ST25DV_i2c_PresentI2CPassword( const ST25DV_PASSWD PassWord, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 86 NFCTAG_StatusTypeDef ST25DV_i2c_WriteI2CPassword( const ST25DV_PASSWD PassWord, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 87 NFCTAG_StatusTypeDef ST25DV_i2c_ReadRFZxSS( const ST25DV_PROTECTION_ZONE Zone, ST25DV_RF_PROT_ZONE * const pRfprotZone, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 88 NFCTAG_StatusTypeDef ST25DV_i2c_WriteRFZxSS( const ST25DV_PROTECTION_ZONE Zone, const ST25DV_RF_PROT_ZONE RfProtZone , I2C * mi2cChannel);
DiegoOstuni 0:bea5dbf3f7d5 89 NFCTAG_StatusTypeDef ST25DV_i2c_ReadEndZonex( const ST25DV_END_ZONE EndZone, uint8_t * const pEndZ, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 90 NFCTAG_StatusTypeDef ST25DV_i2c_WriteEndZonex( const ST25DV_END_ZONE EndZone, const uint8_t EndZ, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 91 NFCTAG_StatusTypeDef ST25DV_i2c_InitEndZone( I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 92 NFCTAG_StatusTypeDef ST25DV_i2c_CreateUserZone( uint16_t Zone1Length, uint16_t Zone2Length, uint16_t Zone3Length, uint16_t Zone4Length, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 93 NFCTAG_StatusTypeDef ST25DV_i2c_ReadMemSize( ST25DV_MEM_SIZE * const pSizeInfo, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 94 NFCTAG_StatusTypeDef ST25DV_i2c_ReadEHMode( ST25DV_EH_MODE_STATUS * const pEH_mode, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 95 NFCTAG_StatusTypeDef ST25DV_i2c_WriteEHMode( const ST25DV_EH_MODE_STATUS EH_mode, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 96 NFCTAG_StatusTypeDef ST25DV_i2c_ReadRFMngt( ST25DV_RF_MNGT * const pRF_Mngt, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 97 NFCTAG_StatusTypeDef ST25DV_i2c_WriteRFMngt( const uint8_t Rfmngt, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 98 NFCTAG_StatusTypeDef ST25DV_i2c_GetRFDisable( ST25DV_EN_STATUS * const pRFDisable, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 99 NFCTAG_StatusTypeDef ST25DV_i2c_SetRFDisable( I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 100 NFCTAG_StatusTypeDef ST25DV_i2c_ResetRFDisable( I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 101 NFCTAG_StatusTypeDef ST25DV_i2c_GetRFSleep( ST25DV_EN_STATUS * const pRFSleep, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 102 NFCTAG_StatusTypeDef ST25DV_i2c_SetRFSleep( I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 103 NFCTAG_StatusTypeDef ST25DV_i2c_ResetRFSleep( I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 104 NFCTAG_StatusTypeDef ST25DV_i2c_ReadMBMode( ST25DV_EN_STATUS * const pMB_mode, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 105 NFCTAG_StatusTypeDef ST25DV_i2c_WriteMBMode( const ST25DV_EN_STATUS MB_mode, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 106 NFCTAG_StatusTypeDef ST25DV_i2c_ReadMBWDG( uint8_t * const pWdgDela, I2C * mi2cChannely );
DiegoOstuni 0:bea5dbf3f7d5 107 NFCTAG_StatusTypeDef ST25DV_i2c_WriteMBWDG( const uint8_t WdgDelay, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 108 NFCTAG_StatusTypeDef ST25DV_i2c_ReadMailboxData( uint8_t * const pData, const uint16_t TarAddr, const uint16_t NbByte, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 109 NFCTAG_StatusTypeDef ST25DV_i2c_WriteMailboxData( const uint8_t * const pData, const uint16_t NbByte, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 110 NFCTAG_StatusTypeDef ST25DV_i2c_ReadMailboxRegister( uint8_t * const pData, const uint16_t TarAddr, const uint16_t NbByte, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 111 NFCTAG_StatusTypeDef ST25DV_i2c_WriteMailboxRegister( const uint8_t * const pData, const uint16_t TarAddr, const uint16_t NbByte, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 112 NFCTAG_StatusTypeDef ST25DV_i2c_ReadI2CSecuritySession_Dyn( ST25DV_I2CSSO_STATUS * const pSession, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 113 NFCTAG_StatusTypeDef ST25DV_i2c_ReadITSTStatus_Dyn( uint8_t * const pITStatus, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 114 NFCTAG_StatusTypeDef ST25DV_i2c_ReadGPO_Dyn( uint8_t *GPOConfig, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 115 NFCTAG_StatusTypeDef ST25DV_i2c_GetGPO_en_Dyn( ST25DV_EN_STATUS * const pGPO_en, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 116 NFCTAG_StatusTypeDef ST25DV_i2c_SetGPO_en_Dyn( I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 117 NFCTAG_StatusTypeDef ST25DV_i2c_ResetGPO_en_Dyn( I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 118 NFCTAG_StatusTypeDef ST25DV_i2c_ReadEHCtrl_Dyn( ST25DV_EH_CTRL * const pEH_CTRL, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 119 NFCTAG_StatusTypeDef ST25DV_i2c_GetEHENMode_Dyn( ST25DV_EN_STATUS * const pEH_Val, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 120 NFCTAG_StatusTypeDef ST25DV_i2c_SetEHENMode_Dyn( I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 121 NFCTAG_StatusTypeDef ST25DV_i2c_ResetEHENMode_Dyn( I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 122 NFCTAG_StatusTypeDef ST25DV_i2c_GetEHON_Dyn( ST25DV_EN_STATUS * const pEHON, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 123 NFCTAG_StatusTypeDef ST25DV_i2c_GetRFField_Dyn( ST25DV_FIELD_STATUS * const pRF_Field, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 124 NFCTAG_StatusTypeDef ST25DV_i2c_GetVCC_Dyn( ST25DV_VCC_STATUS * const pVCC, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 125 NFCTAG_StatusTypeDef ST25DV_i2c_ReadRFMngt_Dyn( ST25DV_RF_MNGT * const pRF_Mngt, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 126 NFCTAG_StatusTypeDef ST25DV_i2c_WriteRFMngt_Dyn( const uint8_t RF_Mngt, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 127 NFCTAG_StatusTypeDef ST25DV_i2c_GetRFDisable_Dyn( ST25DV_EN_STATUS * const pRFDisable, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 128 NFCTAG_StatusTypeDef ST25DV_i2c_SetRFDisable_Dyn( I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 129 NFCTAG_StatusTypeDef ST25DV_i2c_ResetRFDisable_Dyn( I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 130 NFCTAG_StatusTypeDef ST25DV_i2c_GetRFSleep_Dyn( ST25DV_EN_STATUS * const pRFSleep, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 131 NFCTAG_StatusTypeDef ST25DV_i2c_SetRFSleep_Dyn( I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 132 NFCTAG_StatusTypeDef ST25DV_i2c_ResetRFSleep_Dyn( I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 133 NFCTAG_StatusTypeDef ST25DV_i2c_ReadMBCtrl_Dyn( ST25DV_MB_CTRL_DYN_STATUS * const pCtrlStatus, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 134 NFCTAG_StatusTypeDef ST25DV_i2c_GetMBEN_Dyn( ST25DV_EN_STATUS * const pMBEN, I2C * mi2cChannel);
DiegoOstuni 0:bea5dbf3f7d5 135 NFCTAG_StatusTypeDef ST25DV_i2c_SetMBEN_Dyn( I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 136 NFCTAG_StatusTypeDef ST25DV_i2c_ResetMBEN_Dyn( I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 137 NFCTAG_StatusTypeDef ST25DV_i2c_ReadMBLength_Dyn( uint8_t * const pMBLength, I2C * mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 138
DiegoOstuni 0:bea5dbf3f7d5 139 /* Global variables ---------------------------------------------------------*/
DiegoOstuni 0:bea5dbf3f7d5 140 /**
DiegoOstuni 0:bea5dbf3f7d5 141 * @brief Standard NFC tag driver API for the ST25DV.
DiegoOstuni 0:bea5dbf3f7d5 142 * @details Provides a generic way to access the ST25DV implementation of the NFC tag standard driver functions.
DiegoOstuni 0:bea5dbf3f7d5 143 */
DiegoOstuni 0:bea5dbf3f7d5 144 NFCTAG_DrvTypeDef St25Dv_i2c_Drv =
DiegoOstuni 0:bea5dbf3f7d5 145 {
DiegoOstuni 0:bea5dbf3f7d5 146 ST25DV_i2c_Init,
DiegoOstuni 0:bea5dbf3f7d5 147 ST25DV_i2c_ReadID,
DiegoOstuni 0:bea5dbf3f7d5 148 ST25DV_i2c_IsDeviceReady,
DiegoOstuni 0:bea5dbf3f7d5 149 ST25DV_i2c_GetGPOStatus,
DiegoOstuni 0:bea5dbf3f7d5 150 ST25DV_i2c_ConfigureGPO,
DiegoOstuni 0:bea5dbf3f7d5 151 ST25DV_i2c_ReadData,
DiegoOstuni 0:bea5dbf3f7d5 152 ST25DV_i2c_WriteData,
DiegoOstuni 0:bea5dbf3f7d5 153 ST25DV_i2c_ReadRegister,
DiegoOstuni 0:bea5dbf3f7d5 154 ST25DV_i2c_WriteRegister,
DiegoOstuni 0:bea5dbf3f7d5 155 NULL
DiegoOstuni 0:bea5dbf3f7d5 156 };
DiegoOstuni 0:bea5dbf3f7d5 157
DiegoOstuni 0:bea5dbf3f7d5 158 /**
DiegoOstuni 0:bea5dbf3f7d5 159 * @brief Extended NFC tag driver API for the ST25DV.
DiegoOstuni 0:bea5dbf3f7d5 160 * @details Provides a generic way to access the ST25DV extended driver functions.
DiegoOstuni 0:bea5dbf3f7d5 161 */
DiegoOstuni 0:bea5dbf3f7d5 162 NFCTAG_ExtDrvTypeDef St25Dv_i2c_ExtDrv =
DiegoOstuni 0:bea5dbf3f7d5 163 {
DiegoOstuni 0:bea5dbf3f7d5 164 ST25DV_i2c_ReadICRev,
DiegoOstuni 0:bea5dbf3f7d5 165 ST25DV_i2c_WriteITPulse,
DiegoOstuni 0:bea5dbf3f7d5 166 ST25DV_i2c_ReadITPulse,
DiegoOstuni 0:bea5dbf3f7d5 167 ST25DV_i2c_ReadDataCurrentAddr,
DiegoOstuni 0:bea5dbf3f7d5 168 ST25DV_i2c_ReadUID,
DiegoOstuni 0:bea5dbf3f7d5 169 ST25DV_i2c_ReadDSFID,
DiegoOstuni 0:bea5dbf3f7d5 170 ST25DV_i2c_ReadDsfidRFProtection,
DiegoOstuni 0:bea5dbf3f7d5 171 ST25DV_i2c_ReadAFI,
DiegoOstuni 0:bea5dbf3f7d5 172 ST25DV_i2c_ReadAfiRFProtection,
DiegoOstuni 0:bea5dbf3f7d5 173 ST25DV_i2c_ReadI2CProtectZone,
DiegoOstuni 0:bea5dbf3f7d5 174 ST25DV_i2c_WriteI2CProtectZonex,
DiegoOstuni 0:bea5dbf3f7d5 175 ST25DV_i2c_ReadLockCCFile,
DiegoOstuni 0:bea5dbf3f7d5 176 ST25DV_i2c_WriteLockCCFile,
DiegoOstuni 0:bea5dbf3f7d5 177 ST25DV_i2c_ReadLockCFG,
DiegoOstuni 0:bea5dbf3f7d5 178 ST25DV_i2c_WriteLockCFG,
DiegoOstuni 0:bea5dbf3f7d5 179 ST25DV_i2c_PresentI2CPassword,
DiegoOstuni 0:bea5dbf3f7d5 180 ST25DV_i2c_WriteI2CPassword,
DiegoOstuni 0:bea5dbf3f7d5 181 ST25DV_i2c_ReadRFZxSS,
DiegoOstuni 0:bea5dbf3f7d5 182 ST25DV_i2c_WriteRFZxSS,
DiegoOstuni 0:bea5dbf3f7d5 183 ST25DV_i2c_ReadEndZonex,
DiegoOstuni 0:bea5dbf3f7d5 184 ST25DV_i2c_WriteEndZonex,
DiegoOstuni 0:bea5dbf3f7d5 185 ST25DV_i2c_InitEndZone,
DiegoOstuni 0:bea5dbf3f7d5 186 ST25DV_i2c_CreateUserZone,
DiegoOstuni 0:bea5dbf3f7d5 187 ST25DV_i2c_ReadMemSize,
DiegoOstuni 0:bea5dbf3f7d5 188 ST25DV_i2c_ReadEHMode,
DiegoOstuni 0:bea5dbf3f7d5 189 ST25DV_i2c_WriteEHMode,
DiegoOstuni 0:bea5dbf3f7d5 190 ST25DV_i2c_ReadRFMngt,
DiegoOstuni 0:bea5dbf3f7d5 191 ST25DV_i2c_WriteRFMngt,
DiegoOstuni 0:bea5dbf3f7d5 192 ST25DV_i2c_GetRFDisable,
DiegoOstuni 0:bea5dbf3f7d5 193 ST25DV_i2c_SetRFDisable,
DiegoOstuni 0:bea5dbf3f7d5 194 ST25DV_i2c_ResetRFDisable,
DiegoOstuni 0:bea5dbf3f7d5 195 ST25DV_i2c_GetRFSleep,
DiegoOstuni 0:bea5dbf3f7d5 196 ST25DV_i2c_SetRFSleep,
DiegoOstuni 0:bea5dbf3f7d5 197 ST25DV_i2c_ResetRFSleep,
DiegoOstuni 0:bea5dbf3f7d5 198 ST25DV_i2c_ReadMBMode,
DiegoOstuni 0:bea5dbf3f7d5 199 ST25DV_i2c_WriteMBMode,
DiegoOstuni 0:bea5dbf3f7d5 200 ST25DV_i2c_ReadMBWDG,
DiegoOstuni 0:bea5dbf3f7d5 201 ST25DV_i2c_WriteMBWDG,
DiegoOstuni 0:bea5dbf3f7d5 202 ST25DV_i2c_ReadMailboxData,
DiegoOstuni 0:bea5dbf3f7d5 203 ST25DV_i2c_WriteMailboxData,
DiegoOstuni 0:bea5dbf3f7d5 204 ST25DV_i2c_ReadMailboxRegister,
DiegoOstuni 0:bea5dbf3f7d5 205 ST25DV_i2c_WriteMailboxRegister,
DiegoOstuni 0:bea5dbf3f7d5 206 ST25DV_i2c_ReadI2CSecuritySession_Dyn,
DiegoOstuni 0:bea5dbf3f7d5 207 ST25DV_i2c_ReadITSTStatus_Dyn,
DiegoOstuni 0:bea5dbf3f7d5 208 ST25DV_i2c_ReadGPO_Dyn,
DiegoOstuni 0:bea5dbf3f7d5 209 ST25DV_i2c_GetGPO_en_Dyn,
DiegoOstuni 0:bea5dbf3f7d5 210 ST25DV_i2c_SetGPO_en_Dyn,
DiegoOstuni 0:bea5dbf3f7d5 211 ST25DV_i2c_ResetGPO_en_Dyn,
DiegoOstuni 0:bea5dbf3f7d5 212 ST25DV_i2c_ReadEHCtrl_Dyn,
DiegoOstuni 0:bea5dbf3f7d5 213 ST25DV_i2c_GetEHENMode_Dyn,
DiegoOstuni 0:bea5dbf3f7d5 214 ST25DV_i2c_SetEHENMode_Dyn,
DiegoOstuni 0:bea5dbf3f7d5 215 ST25DV_i2c_ResetEHENMode_Dyn,
DiegoOstuni 0:bea5dbf3f7d5 216 ST25DV_i2c_GetEHON_Dyn,
DiegoOstuni 0:bea5dbf3f7d5 217 ST25DV_i2c_GetRFField_Dyn,
DiegoOstuni 0:bea5dbf3f7d5 218 ST25DV_i2c_GetVCC_Dyn,
DiegoOstuni 0:bea5dbf3f7d5 219 ST25DV_i2c_ReadRFMngt_Dyn,
DiegoOstuni 0:bea5dbf3f7d5 220 ST25DV_i2c_WriteRFMngt_Dyn,
DiegoOstuni 0:bea5dbf3f7d5 221 ST25DV_i2c_GetRFDisable_Dyn,
DiegoOstuni 0:bea5dbf3f7d5 222 ST25DV_i2c_SetRFDisable_Dyn,
DiegoOstuni 0:bea5dbf3f7d5 223 ST25DV_i2c_ResetRFDisable_Dyn,
DiegoOstuni 0:bea5dbf3f7d5 224 ST25DV_i2c_GetRFSleep_Dyn,
DiegoOstuni 0:bea5dbf3f7d5 225 ST25DV_i2c_SetRFSleep_Dyn,
DiegoOstuni 0:bea5dbf3f7d5 226 ST25DV_i2c_ResetRFSleep_Dyn,
DiegoOstuni 0:bea5dbf3f7d5 227 ST25DV_i2c_ReadMBCtrl_Dyn,
DiegoOstuni 0:bea5dbf3f7d5 228 ST25DV_i2c_GetMBEN_Dyn,
DiegoOstuni 0:bea5dbf3f7d5 229 ST25DV_i2c_SetMBEN_Dyn,
DiegoOstuni 0:bea5dbf3f7d5 230 ST25DV_i2c_ResetMBEN_Dyn,
DiegoOstuni 0:bea5dbf3f7d5 231 ST25DV_i2c_ReadMBLength_Dyn
DiegoOstuni 0:bea5dbf3f7d5 232 };
DiegoOstuni 0:bea5dbf3f7d5 233
DiegoOstuni 0:bea5dbf3f7d5 234
DiegoOstuni 0:bea5dbf3f7d5 235 /** @brief ST25DV instances by address. */
DiegoOstuni 0:bea5dbf3f7d5 236 uint8_t aSt25Dv[ST25DV_MAX_INSTANCE] = {0};
DiegoOstuni 0:bea5dbf3f7d5 237
DiegoOstuni 0:bea5dbf3f7d5 238
DiegoOstuni 0:bea5dbf3f7d5 239 /* Public functions ---------------------------------------------------------*/
DiegoOstuni 0:bea5dbf3f7d5 240 /**
DiegoOstuni 0:bea5dbf3f7d5 241 * @brief ST25DV nfctag Initialization.
DiegoOstuni 0:bea5dbf3f7d5 242 * @param mi2cChannel : I2C channel
DiegoOstuni 0:bea5dbf3f7d5 243 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 244 */
DiegoOstuni 0:bea5dbf3f7d5 245 NFCTAG_StatusTypeDef ST25DV_i2c_Init( I2C* mi2cChannel, DigitalOut * mLPD )
DiegoOstuni 0:bea5dbf3f7d5 246 {
DiegoOstuni 0:bea5dbf3f7d5 247 /* Configure the low level interface */
DiegoOstuni 0:bea5dbf3f7d5 248 return ST25DV_IO_Init( mi2cChannel, mLPD );
DiegoOstuni 0:bea5dbf3f7d5 249 }
DiegoOstuni 0:bea5dbf3f7d5 250
DiegoOstuni 0:bea5dbf3f7d5 251 /**
DiegoOstuni 0:bea5dbf3f7d5 252 * @brief Reads the ST25DV ID.
DiegoOstuni 0:bea5dbf3f7d5 253 * @param pICRef Pointeron a uint8_t used to return the ST25DV ID.
DiegoOstuni 0:bea5dbf3f7d5 254 * @param mi2cChannel : I2C channel
DiegoOstuni 0:bea5dbf3f7d5 255 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 256 */
DiegoOstuni 0:bea5dbf3f7d5 257 NFCTAG_StatusTypeDef ST25DV_i2c_ReadID( uint8_t * const pICRef, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 258 {
DiegoOstuni 0:bea5dbf3f7d5 259 /* Read ICRef on device */
DiegoOstuni 0:bea5dbf3f7d5 260 return ST25DV_i2c_ReadRegister( pICRef, ST25DV_ICREF_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 261 }
DiegoOstuni 0:bea5dbf3f7d5 262
DiegoOstuni 0:bea5dbf3f7d5 263 /**
DiegoOstuni 0:bea5dbf3f7d5 264 * @brief Reads the ST25DV IC Revision.
DiegoOstuni 0:bea5dbf3f7d5 265 * @param pICRev Pointer on the uint8_t used to return the ST25DV IC Revision number.
DiegoOstuni 0:bea5dbf3f7d5 266 * @param mi2cChannel : I2C channel
DiegoOstuni 0:bea5dbf3f7d5 267 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 268 */
DiegoOstuni 0:bea5dbf3f7d5 269 NFCTAG_StatusTypeDef ST25DV_i2c_ReadICRev( uint8_t * const pICRev, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 270 {
DiegoOstuni 0:bea5dbf3f7d5 271 /* Read ICRev on device */
DiegoOstuni 0:bea5dbf3f7d5 272 return ST25DV_i2c_ReadRegister( pICRev, ST25DV_ICREV_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 273 }
DiegoOstuni 0:bea5dbf3f7d5 274
DiegoOstuni 0:bea5dbf3f7d5 275 /**
DiegoOstuni 0:bea5dbf3f7d5 276 * @brief Checks the ST25DV availability.
DiegoOstuni 0:bea5dbf3f7d5 277 * @details The ST25DV I2C is NACKed when a RF communication is on-going.
DiegoOstuni 0:bea5dbf3f7d5 278 * This function determines if the ST25DV is ready to answer an I2C request.
DiegoOstuni 0:bea5dbf3f7d5 279 * @param Trials Max number of tentative.
DiegoOstuni 0:bea5dbf3f7d5 280 * @param mi2cChannel : I2C channel
DiegoOstuni 0:bea5dbf3f7d5 281 * @retval NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 282 */
DiegoOstuni 0:bea5dbf3f7d5 283 NFCTAG_StatusTypeDef ST25DV_i2c_IsDeviceReady( const uint32_t Trials, I2C * mi2cChannel)
DiegoOstuni 0:bea5dbf3f7d5 284 {
DiegoOstuni 0:bea5dbf3f7d5 285 /* Test communication with device */
DiegoOstuni 0:bea5dbf3f7d5 286 return ST25DV_IO_IsDeviceReady( ST25DV_ADDR_DATA_I2C, Trials, mi2cChannel);
DiegoOstuni 0:bea5dbf3f7d5 287 }
DiegoOstuni 0:bea5dbf3f7d5 288
DiegoOstuni 0:bea5dbf3f7d5 289 /**
DiegoOstuni 0:bea5dbf3f7d5 290 * @brief Reads the ST25DV GPO configuration.
DiegoOstuni 0:bea5dbf3f7d5 291 * @param pGPOStatus Pointer on a uint16_t used to return the current GPO consiguration, as:
DiegoOstuni 0:bea5dbf3f7d5 292 * - RFUSERSTATE = 0x01
DiegoOstuni 0:bea5dbf3f7d5 293 * - RFBUSY = 0x02
DiegoOstuni 0:bea5dbf3f7d5 294 * - RFINTERRUPT = 0x04
DiegoOstuni 0:bea5dbf3f7d5 295 * - FIELDFALLING = 0x08
DiegoOstuni 0:bea5dbf3f7d5 296 * - FIELDRISING = 0x10
DiegoOstuni 0:bea5dbf3f7d5 297 * - RFPUTMSG = 0x20
DiegoOstuni 0:bea5dbf3f7d5 298 * - RFGETMSG = 0x40
DiegoOstuni 0:bea5dbf3f7d5 299 * - RFWRITE = 0x80
DiegoOstuni 0:bea5dbf3f7d5 300 * @param mi2cChannel : I2C channel
DiegoOstuni 0:bea5dbf3f7d5 301 * @retval NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 302 */
DiegoOstuni 0:bea5dbf3f7d5 303 NFCTAG_StatusTypeDef ST25DV_i2c_GetGPOStatus( uint16_t * const pGPOStatus, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 304 {
DiegoOstuni 0:bea5dbf3f7d5 305 uint8_t reg_value;
DiegoOstuni 0:bea5dbf3f7d5 306 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 307
DiegoOstuni 0:bea5dbf3f7d5 308 /* Read value of GPO register */
DiegoOstuni 0:bea5dbf3f7d5 309 status = ST25DV_i2c_ReadRegister( &reg_value, ST25DV_GPO_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 310 if( status != NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 311 return status;
DiegoOstuni 0:bea5dbf3f7d5 312
DiegoOstuni 0:bea5dbf3f7d5 313 /* Extract GPO configuration */
DiegoOstuni 0:bea5dbf3f7d5 314 *pGPOStatus = (uint16_t)reg_value;
DiegoOstuni 0:bea5dbf3f7d5 315
DiegoOstuni 0:bea5dbf3f7d5 316 return NFCTAG_OK;
DiegoOstuni 0:bea5dbf3f7d5 317 }
DiegoOstuni 0:bea5dbf3f7d5 318
DiegoOstuni 0:bea5dbf3f7d5 319 /**
DiegoOstuni 0:bea5dbf3f7d5 320 * @brief Configures the ST25DV GPO.
DiegoOstuni 0:bea5dbf3f7d5 321 * @details Needs the I2C Password presentation to be effective.
DiegoOstuni 0:bea5dbf3f7d5 322 * @param ITConf Provides the GPO configuration to apply:
DiegoOstuni 0:bea5dbf3f7d5 323 * - RFUSERSTATE = 0x01
DiegoOstuni 0:bea5dbf3f7d5 324 * - RFBUSY = 0x02
DiegoOstuni 0:bea5dbf3f7d5 325 * - RFINTERRUPT = 0x04
DiegoOstuni 0:bea5dbf3f7d5 326 * - FIELDFALLING = 0x08
DiegoOstuni 0:bea5dbf3f7d5 327 * - FIELDRISING = 0x10
DiegoOstuni 0:bea5dbf3f7d5 328 * - RFPUTMSG = 0x20
DiegoOstuni 0:bea5dbf3f7d5 329 * - RFGETMSG = 0x40
DiegoOstuni 0:bea5dbf3f7d5 330 * - RFWRITE = 0x80
DiegoOstuni 0:bea5dbf3f7d5 331 *
DiegoOstuni 0:bea5dbf3f7d5 332 * @param mi2cChannel : I2C channel
DiegoOstuni 0:bea5dbf3f7d5 333 *
DiegoOstuni 0:bea5dbf3f7d5 334 * @retval NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 335 */
DiegoOstuni 0:bea5dbf3f7d5 336 NFCTAG_StatusTypeDef ST25DV_i2c_ConfigureGPO( const uint16_t ITConf, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 337 {
DiegoOstuni 0:bea5dbf3f7d5 338 /* Write GPO configuration to register */
DiegoOstuni 0:bea5dbf3f7d5 339 return ST25DV_i2c_WriteRegister( (uint8_t *)&ITConf, ST25DV_GPO_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 340 }
DiegoOstuni 0:bea5dbf3f7d5 341
DiegoOstuni 0:bea5dbf3f7d5 342
DiegoOstuni 0:bea5dbf3f7d5 343 /**
DiegoOstuni 0:bea5dbf3f7d5 344 * @brief Reads the ST25DV ITtime duration for the GPO pulses.
DiegoOstuni 0:bea5dbf3f7d5 345 * @param pITtime Pointer used to return the coefficient for the GPO Pulse duration (Pulse duration = 302,06 us - ITtime * 512 / fc).
DiegoOstuni 0:bea5dbf3f7d5 346 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 347 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 348 */
DiegoOstuni 0:bea5dbf3f7d5 349 NFCTAG_StatusTypeDef ST25DV_i2c_ReadITPulse( ST25DV_PULSE_DURATION * const pITtime, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 350 {
DiegoOstuni 0:bea5dbf3f7d5 351 uint8_t reg_value;
DiegoOstuni 0:bea5dbf3f7d5 352 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 353
DiegoOstuni 0:bea5dbf3f7d5 354 /* Read ITtime register value */
DiegoOstuni 0:bea5dbf3f7d5 355 status = ST25DV_i2c_ReadRegister( &reg_value, ST25DV_ITTIME_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 356 if( status != NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 357 {
DiegoOstuni 0:bea5dbf3f7d5 358 return status;
DiegoOstuni 0:bea5dbf3f7d5 359 }
DiegoOstuni 0:bea5dbf3f7d5 360
DiegoOstuni 0:bea5dbf3f7d5 361 /* Extract delay coefficient value */
DiegoOstuni 0:bea5dbf3f7d5 362 *pITtime = (ST25DV_PULSE_DURATION)reg_value;
DiegoOstuni 0:bea5dbf3f7d5 363
DiegoOstuni 0:bea5dbf3f7d5 364 return NFCTAG_OK;
DiegoOstuni 0:bea5dbf3f7d5 365 }
DiegoOstuni 0:bea5dbf3f7d5 366
DiegoOstuni 0:bea5dbf3f7d5 367 /**
DiegoOstuni 0:bea5dbf3f7d5 368 * @brief Configures the ST25DV ITtime duration for the GPO pulse.
DiegoOstuni 0:bea5dbf3f7d5 369 * @details Needs the I2C Password presentation to be effective.
DiegoOstuni 0:bea5dbf3f7d5 370 * @param ITtime Coefficient for the Pulse duration to be written (Pulse duration = 302,06 us - ITtime * 512 / fc)
DiegoOstuni 0:bea5dbf3f7d5 371 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 372 * @retval NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 373 */
DiegoOstuni 0:bea5dbf3f7d5 374 NFCTAG_StatusTypeDef ST25DV_i2c_WriteITPulse( const ST25DV_PULSE_DURATION ITtime, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 375 {
DiegoOstuni 0:bea5dbf3f7d5 376 uint8_t reg_value;
DiegoOstuni 0:bea5dbf3f7d5 377
DiegoOstuni 0:bea5dbf3f7d5 378 /* prepare data to write */
DiegoOstuni 0:bea5dbf3f7d5 379 reg_value = (uint8_t)ITtime;
DiegoOstuni 0:bea5dbf3f7d5 380
DiegoOstuni 0:bea5dbf3f7d5 381 /* Write value for ITtime register */
DiegoOstuni 0:bea5dbf3f7d5 382 return ST25DV_i2c_WriteRegister( &reg_value, ST25DV_ITTIME_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 383 }
DiegoOstuni 0:bea5dbf3f7d5 384
DiegoOstuni 0:bea5dbf3f7d5 385 /**
DiegoOstuni 0:bea5dbf3f7d5 386 * @brief Reads N bytes of Data, starting from the specified I2C address.
DiegoOstuni 0:bea5dbf3f7d5 387 * @param pData Pointer used to return the read data.
DiegoOstuni 0:bea5dbf3f7d5 388 * @param TarAddr I2C data memory address to read.
DiegoOstuni 0:bea5dbf3f7d5 389 * @param NbByte Number of bytes to be read.
DiegoOstuni 0:bea5dbf3f7d5 390 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 391 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 392 */
DiegoOstuni 0:bea5dbf3f7d5 393 NFCTAG_StatusTypeDef ST25DV_i2c_ReadData( uint8_t * const pData, const uint16_t TarAddr, const uint16_t NbByte, I2C * mi2cChannel)
DiegoOstuni 0:bea5dbf3f7d5 394 {
DiegoOstuni 0:bea5dbf3f7d5 395 /* Read Data in user memory */
DiegoOstuni 0:bea5dbf3f7d5 396 return ST25DV_IO_MemRead( pData, ST25DV_ADDR_DATA_I2C, TarAddr, NbByte, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 397 }
DiegoOstuni 0:bea5dbf3f7d5 398
DiegoOstuni 0:bea5dbf3f7d5 399 /**
DiegoOstuni 0:bea5dbf3f7d5 400 * @brief Writes N bytes of Data starting from the specified I2C Address.
DiegoOstuni 0:bea5dbf3f7d5 401 * @param pData Pointer on the data to be written.
DiegoOstuni 0:bea5dbf3f7d5 402 * @param TarAddr I2C data memory address to be written.
DiegoOstuni 0:bea5dbf3f7d5 403 * @param NbByte Number of bytes to be written.
DiegoOstuni 0:bea5dbf3f7d5 404 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 405 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 406 */
DiegoOstuni 0:bea5dbf3f7d5 407 NFCTAG_StatusTypeDef ST25DV_i2c_WriteData( const uint8_t * const pData, const uint16_t TarAddr, const uint16_t NbByte, I2C* mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 408 {
DiegoOstuni 0:bea5dbf3f7d5 409 NFCTAG_StatusTypeDef ret;
DiegoOstuni 0:bea5dbf3f7d5 410 NFCTAG_StatusTypeDef pollstatus;
DiegoOstuni 0:bea5dbf3f7d5 411 uint16_t split_data_nb;
DiegoOstuni 0:bea5dbf3f7d5 412 const uint8_t *pdata_index = (const uint8_t *)pData;
DiegoOstuni 0:bea5dbf3f7d5 413
DiegoOstuni 0:bea5dbf3f7d5 414 uint16_t bytes_to_write = NbByte;
DiegoOstuni 0:bea5dbf3f7d5 415 uint16_t mem_addr = TarAddr;
DiegoOstuni 0:bea5dbf3f7d5 416
DiegoOstuni 0:bea5dbf3f7d5 417 /* ST25DV can write a maximum of 256 bytes in EEPROM per i2c communication */
DiegoOstuni 0:bea5dbf3f7d5 418 do
DiegoOstuni 0:bea5dbf3f7d5 419 {
DiegoOstuni 0:bea5dbf3f7d5 420 /* Split write if data to write is superior of max write bytes for ST25DV */
DiegoOstuni 0:bea5dbf3f7d5 421 if( bytes_to_write > ST25DV_MAX_WRITE_BYTE )
DiegoOstuni 0:bea5dbf3f7d5 422 {
DiegoOstuni 0:bea5dbf3f7d5 423 /* DataSize higher than max page write, copy data by page */
DiegoOstuni 0:bea5dbf3f7d5 424 split_data_nb = (uint16_t)ST25DV_MAX_WRITE_BYTE;
DiegoOstuni 0:bea5dbf3f7d5 425 }
DiegoOstuni 0:bea5dbf3f7d5 426 else
DiegoOstuni 0:bea5dbf3f7d5 427 {
DiegoOstuni 0:bea5dbf3f7d5 428 /* DataSize lower or equal to max page write, copy only last bytes */
DiegoOstuni 0:bea5dbf3f7d5 429 split_data_nb = bytes_to_write;
DiegoOstuni 0:bea5dbf3f7d5 430 }
DiegoOstuni 0:bea5dbf3f7d5 431 /* Write split_data_nb bytes in memory */
DiegoOstuni 0:bea5dbf3f7d5 432 ret = ST25DV_IO_MemWrite( pdata_index, ST25DV_ADDR_DATA_I2C, mem_addr, split_data_nb, mi2cChannel);
DiegoOstuni 0:bea5dbf3f7d5 433
DiegoOstuni 0:bea5dbf3f7d5 434 Timer t;
DiegoOstuni 0:bea5dbf3f7d5 435 /* POLLING, NEW CODE */
DiegoOstuni 0:bea5dbf3f7d5 436 if( ret == 0 )
DiegoOstuni 0:bea5dbf3f7d5 437 {
DiegoOstuni 0:bea5dbf3f7d5 438 /* Poll until EEPROM is available */
DiegoOstuni 0:bea5dbf3f7d5 439
DiegoOstuni 0:bea5dbf3f7d5 440 int ms = 0;
DiegoOstuni 0:bea5dbf3f7d5 441 /* Wait until ST25DV is ready or timeout occurs */
DiegoOstuni 0:bea5dbf3f7d5 442 do
DiegoOstuni 0:bea5dbf3f7d5 443 {
DiegoOstuni 0:bea5dbf3f7d5 444 t.start();
DiegoOstuni 0:bea5dbf3f7d5 445 pollstatus = ST25DV_IO_IsDeviceReady( ST25DV_ADDR_DATA_I2C , 1, mi2cChannel);
DiegoOstuni 0:bea5dbf3f7d5 446 ms = t.read_ms();
DiegoOstuni 0:bea5dbf3f7d5 447 t.stop();
DiegoOstuni 0:bea5dbf3f7d5 448 } while( ( ms < ST25DV_I2C_TIMEOUT) && (pollstatus != NFCTAG_OK) );
DiegoOstuni 0:bea5dbf3f7d5 449
DiegoOstuni 0:bea5dbf3f7d5 450
DiegoOstuni 0:bea5dbf3f7d5 451 if( pollstatus != NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 452 {
DiegoOstuni 0:bea5dbf3f7d5 453 return NFCTAG_TIMEOUT;
DiegoOstuni 0:bea5dbf3f7d5 454 }
DiegoOstuni 0:bea5dbf3f7d5 455 }
DiegoOstuni 0:bea5dbf3f7d5 456
DiegoOstuni 0:bea5dbf3f7d5 457 /* update index, dest address, size for next write */
DiegoOstuni 0:bea5dbf3f7d5 458 pdata_index += split_data_nb;
DiegoOstuni 0:bea5dbf3f7d5 459 mem_addr += split_data_nb;
DiegoOstuni 0:bea5dbf3f7d5 460 bytes_to_write -= split_data_nb;
DiegoOstuni 0:bea5dbf3f7d5 461 }
DiegoOstuni 0:bea5dbf3f7d5 462 while( ( bytes_to_write > 0 ) && ( ret == NFCTAG_OK ) );
DiegoOstuni 0:bea5dbf3f7d5 463
DiegoOstuni 0:bea5dbf3f7d5 464 return ret;
DiegoOstuni 0:bea5dbf3f7d5 465 }
DiegoOstuni 0:bea5dbf3f7d5 466
DiegoOstuni 0:bea5dbf3f7d5 467 /**
DiegoOstuni 0:bea5dbf3f7d5 468 * @brief Reads N bytes of Data, starting at current address.
DiegoOstuni 0:bea5dbf3f7d5 469 * @param pData Pointer used to return the read data.
DiegoOstuni 0:bea5dbf3f7d5 470 * @param NbByte Number of bytes to be read.
DiegoOstuni 0:bea5dbf3f7d5 471 * @param mi2cChannel : I2C channel
DiegoOstuni 0:bea5dbf3f7d5 472 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 473 */
DiegoOstuni 0:bea5dbf3f7d5 474 NFCTAG_StatusTypeDef ST25DV_i2c_ReadDataCurrentAddr( uint8_t * const pData, const uint16_t NbByte, I2C* mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 475 {
DiegoOstuni 0:bea5dbf3f7d5 476 /* Read Data in user memory */
DiegoOstuni 0:bea5dbf3f7d5 477 return ST25DV_IO_Read( pData, ST25DV_ADDR_DATA_I2C, NbByte, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 478 }
DiegoOstuni 0:bea5dbf3f7d5 479
DiegoOstuni 0:bea5dbf3f7d5 480 /**
DiegoOstuni 0:bea5dbf3f7d5 481 * @brief Reads N bytes from Registers, starting at the specified I2C address.
DiegoOstuni 0:bea5dbf3f7d5 482 * @param pData Pointer used to return the read data.
DiegoOstuni 0:bea5dbf3f7d5 483 * @param TarAddr I2C memory address to be read.
DiegoOstuni 0:bea5dbf3f7d5 484 * @param NbByte Number of bytes to be read.
DiegoOstuni 0:bea5dbf3f7d5 485 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 486 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 487 */
DiegoOstuni 0:bea5dbf3f7d5 488 NFCTAG_StatusTypeDef ST25DV_i2c_ReadRegister( uint8_t * const pData, const uint16_t TarAddr, const uint16_t NbByte, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 489 {
DiegoOstuni 0:bea5dbf3f7d5 490 /* Read Data in system memory */
DiegoOstuni 0:bea5dbf3f7d5 491 return ST25DV_IO_MemRead( pData, ST25DV_ADDR_SYST_I2C, TarAddr, NbByte, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 492 }
DiegoOstuni 0:bea5dbf3f7d5 493
DiegoOstuni 0:bea5dbf3f7d5 494 /**
DiegoOstuni 0:bea5dbf3f7d5 495 * @brief Writes N bytes to the specified register.
DiegoOstuni 0:bea5dbf3f7d5 496 * @details Needs the I2C Password presentation to be effective.
DiegoOstuni 0:bea5dbf3f7d5 497 * @param pData Pointer on the data to be written.
DiegoOstuni 0:bea5dbf3f7d5 498 * @param TarAddr I2C register address to written.
DiegoOstuni 0:bea5dbf3f7d5 499 * @param NbByte Number of bytes to be written.
DiegoOstuni 0:bea5dbf3f7d5 500 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 501 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 502 */
DiegoOstuni 0:bea5dbf3f7d5 503 NFCTAG_StatusTypeDef ST25DV_i2c_WriteRegister( const uint8_t * const pData, const uint16_t TarAddr, const uint16_t NbByte, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 504 {
DiegoOstuni 0:bea5dbf3f7d5 505 NFCTAG_StatusTypeDef ret;
DiegoOstuni 0:bea5dbf3f7d5 506 NFCTAG_StatusTypeDef pollstatus;
DiegoOstuni 0:bea5dbf3f7d5 507 uint8_t split_data_nb;
DiegoOstuni 0:bea5dbf3f7d5 508 uint16_t bytes_to_write = NbByte;
DiegoOstuni 0:bea5dbf3f7d5 509 uint16_t mem_addr = TarAddr;
DiegoOstuni 0:bea5dbf3f7d5 510 const uint8_t *pdata_index = (const uint8_t *)pData;
DiegoOstuni 0:bea5dbf3f7d5 511
DiegoOstuni 0:bea5dbf3f7d5 512 /* ST25DV can write a maximum of 256 bytes in EEPROM per i2c communication */
DiegoOstuni 0:bea5dbf3f7d5 513 do
DiegoOstuni 0:bea5dbf3f7d5 514 {
DiegoOstuni 0:bea5dbf3f7d5 515 /* Split write if data to write is superior of max write bytes for ST25DV */
DiegoOstuni 0:bea5dbf3f7d5 516 if( bytes_to_write > ST25DV_MAX_WRITE_BYTE )
DiegoOstuni 0:bea5dbf3f7d5 517 {
DiegoOstuni 0:bea5dbf3f7d5 518 /* DataSize higher than max page write, copy data by page */
DiegoOstuni 0:bea5dbf3f7d5 519 split_data_nb = (uint8_t)ST25DV_MAX_WRITE_BYTE;
DiegoOstuni 0:bea5dbf3f7d5 520 }
DiegoOstuni 0:bea5dbf3f7d5 521 else
DiegoOstuni 0:bea5dbf3f7d5 522 {
DiegoOstuni 0:bea5dbf3f7d5 523 /* DataSize lower or equal to max page write, copy only last bytes */
DiegoOstuni 0:bea5dbf3f7d5 524 split_data_nb = bytes_to_write;
DiegoOstuni 0:bea5dbf3f7d5 525 }
DiegoOstuni 0:bea5dbf3f7d5 526 /* Write split_data_nb bytes in register */
DiegoOstuni 0:bea5dbf3f7d5 527 ret = ST25DV_IO_MemWrite( pdata_index, ST25DV_ADDR_SYST_I2C, mem_addr, split_data_nb, mi2cChannel);
DiegoOstuni 0:bea5dbf3f7d5 528
DiegoOstuni 0:bea5dbf3f7d5 529 Timer t;
DiegoOstuni 0:bea5dbf3f7d5 530 /* POLLING, NEW CODE */
DiegoOstuni 0:bea5dbf3f7d5 531 if( ret == 0 )
DiegoOstuni 0:bea5dbf3f7d5 532 {
DiegoOstuni 0:bea5dbf3f7d5 533 int ms = 0;
DiegoOstuni 0:bea5dbf3f7d5 534 /* Wait until ST25DV is ready or timeout occurs */
DiegoOstuni 0:bea5dbf3f7d5 535 do
DiegoOstuni 0:bea5dbf3f7d5 536 {
DiegoOstuni 0:bea5dbf3f7d5 537 t.start();
DiegoOstuni 0:bea5dbf3f7d5 538 pollstatus = ST25DV_IO_IsDeviceReady( ST25DV_ADDR_DATA_I2C , 1, mi2cChannel);
DiegoOstuni 0:bea5dbf3f7d5 539 ms = t.read_ms();
DiegoOstuni 0:bea5dbf3f7d5 540 t.stop();
DiegoOstuni 0:bea5dbf3f7d5 541 } while( ( ms < ST25DV_I2C_TIMEOUT) && (pollstatus != NFCTAG_OK) );
DiegoOstuni 0:bea5dbf3f7d5 542
DiegoOstuni 0:bea5dbf3f7d5 543 if( pollstatus != NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 544 {
DiegoOstuni 0:bea5dbf3f7d5 545 return NFCTAG_TIMEOUT;
DiegoOstuni 0:bea5dbf3f7d5 546 }
DiegoOstuni 0:bea5dbf3f7d5 547 }
DiegoOstuni 0:bea5dbf3f7d5 548
DiegoOstuni 0:bea5dbf3f7d5 549
DiegoOstuni 0:bea5dbf3f7d5 550 /* update index, dest address, size for next write */
DiegoOstuni 0:bea5dbf3f7d5 551 pdata_index += split_data_nb;
DiegoOstuni 0:bea5dbf3f7d5 552 mem_addr += split_data_nb;
DiegoOstuni 0:bea5dbf3f7d5 553 bytes_to_write -= split_data_nb;
DiegoOstuni 0:bea5dbf3f7d5 554 }
DiegoOstuni 0:bea5dbf3f7d5 555 while( ( bytes_to_write > 0 ) && ( ret == NFCTAG_OK ) );
DiegoOstuni 0:bea5dbf3f7d5 556
DiegoOstuni 0:bea5dbf3f7d5 557
DiegoOstuni 0:bea5dbf3f7d5 558
DiegoOstuni 0:bea5dbf3f7d5 559 return ret;
DiegoOstuni 0:bea5dbf3f7d5 560 }
DiegoOstuni 0:bea5dbf3f7d5 561
DiegoOstuni 0:bea5dbf3f7d5 562 /**
DiegoOstuni 0:bea5dbf3f7d5 563 * @brief Reads the ST25DV UID.
DiegoOstuni 0:bea5dbf3f7d5 564 * @param pUid Pointer used to return the ST25DV UID value.
DiegoOstuni 0:bea5dbf3f7d5 565 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 566 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 567 */
DiegoOstuni 0:bea5dbf3f7d5 568 NFCTAG_StatusTypeDef ST25DV_i2c_ReadUID( ST25DV_UID * const pUid, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 569 {
DiegoOstuni 0:bea5dbf3f7d5 570 uint8_t reg_value[8];
DiegoOstuni 0:bea5dbf3f7d5 571 uint8_t i;
DiegoOstuni 0:bea5dbf3f7d5 572 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 573
DiegoOstuni 0:bea5dbf3f7d5 574 /* Read value of UID registers */
DiegoOstuni 0:bea5dbf3f7d5 575 status = ST25DV_i2c_ReadRegister( reg_value, ST25DV_UID_REG, 8, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 576 if( status != NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 577 {
DiegoOstuni 0:bea5dbf3f7d5 578 return status;
DiegoOstuni 0:bea5dbf3f7d5 579 }
DiegoOstuni 0:bea5dbf3f7d5 580
DiegoOstuni 0:bea5dbf3f7d5 581 /* Store information in 2 WORD */
DiegoOstuni 0:bea5dbf3f7d5 582 pUid->MsbUid = 0;
DiegoOstuni 0:bea5dbf3f7d5 583
DiegoOstuni 0:bea5dbf3f7d5 584 for( i = 0; i < 4; i++ )
DiegoOstuni 0:bea5dbf3f7d5 585 {
DiegoOstuni 0:bea5dbf3f7d5 586 pUid->MsbUid = (pUid->MsbUid << 8) | reg_value[7 - i];
DiegoOstuni 0:bea5dbf3f7d5 587 }
DiegoOstuni 0:bea5dbf3f7d5 588
DiegoOstuni 0:bea5dbf3f7d5 589 pUid->LsbUid = 0;
DiegoOstuni 0:bea5dbf3f7d5 590
DiegoOstuni 0:bea5dbf3f7d5 591 for( i = 0; i < 4; i++ )
DiegoOstuni 0:bea5dbf3f7d5 592 {
DiegoOstuni 0:bea5dbf3f7d5 593 pUid->LsbUid = (pUid->LsbUid << 8) | reg_value[3 - i];
DiegoOstuni 0:bea5dbf3f7d5 594 }
DiegoOstuni 0:bea5dbf3f7d5 595
DiegoOstuni 0:bea5dbf3f7d5 596 return NFCTAG_OK;
DiegoOstuni 0:bea5dbf3f7d5 597 }
DiegoOstuni 0:bea5dbf3f7d5 598
DiegoOstuni 0:bea5dbf3f7d5 599 /**
DiegoOstuni 0:bea5dbf3f7d5 600 * @brief Reads the ST25DV DSFID.
DiegoOstuni 0:bea5dbf3f7d5 601 * @param pDsfid Pointer used to return the ST25DV DSFID value.
DiegoOstuni 0:bea5dbf3f7d5 602 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 603 */
DiegoOstuni 0:bea5dbf3f7d5 604 NFCTAG_StatusTypeDef ST25DV_i2c_ReadDSFID( uint8_t * const pDsfid, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 605 {
DiegoOstuni 0:bea5dbf3f7d5 606 /* Read DSFID register */
DiegoOstuni 0:bea5dbf3f7d5 607 return ST25DV_i2c_ReadRegister( pDsfid, ST25DV_DSFID_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 608 }
DiegoOstuni 0:bea5dbf3f7d5 609
DiegoOstuni 0:bea5dbf3f7d5 610 /**
DiegoOstuni 0:bea5dbf3f7d5 611 * @brief Reads the ST25DV DSFID RF Lock state.
DiegoOstuni 0:bea5dbf3f7d5 612 * @param pLockDsfid Pointer on a ST25DV_LOCK_STATUS used to return the DSFID lock state.
DiegoOstuni 0:bea5dbf3f7d5 613 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 614 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 615 */
DiegoOstuni 0:bea5dbf3f7d5 616 NFCTAG_StatusTypeDef ST25DV_i2c_ReadDsfidRFProtection( ST25DV_LOCK_STATUS * const pLockDsfid, I2C * mi2cChannel)
DiegoOstuni 0:bea5dbf3f7d5 617 {
DiegoOstuni 0:bea5dbf3f7d5 618 uint8_t reg_value;
DiegoOstuni 0:bea5dbf3f7d5 619 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 620
DiegoOstuni 0:bea5dbf3f7d5 621 /* Read register */
DiegoOstuni 0:bea5dbf3f7d5 622 status = ST25DV_i2c_ReadRegister( &reg_value, ST25DV_LOCKDSFID_REG, 1 , mi2cChannel);
DiegoOstuni 0:bea5dbf3f7d5 623 if( status != NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 624 {
DiegoOstuni 0:bea5dbf3f7d5 625 return status;
DiegoOstuni 0:bea5dbf3f7d5 626 }
DiegoOstuni 0:bea5dbf3f7d5 627
DiegoOstuni 0:bea5dbf3f7d5 628 /* Extract Lock Status */
DiegoOstuni 0:bea5dbf3f7d5 629 if( reg_value == 0 )
DiegoOstuni 0:bea5dbf3f7d5 630 {
DiegoOstuni 0:bea5dbf3f7d5 631 *pLockDsfid = ST25DV_UNLOCKED;
DiegoOstuni 0:bea5dbf3f7d5 632 }
DiegoOstuni 0:bea5dbf3f7d5 633 else
DiegoOstuni 0:bea5dbf3f7d5 634 {
DiegoOstuni 0:bea5dbf3f7d5 635 *pLockDsfid = ST25DV_LOCKED;
DiegoOstuni 0:bea5dbf3f7d5 636 }
DiegoOstuni 0:bea5dbf3f7d5 637 return NFCTAG_OK;
DiegoOstuni 0:bea5dbf3f7d5 638 }
DiegoOstuni 0:bea5dbf3f7d5 639
DiegoOstuni 0:bea5dbf3f7d5 640 /**
DiegoOstuni 0:bea5dbf3f7d5 641 * @brief Reads the ST25DV AFI.
DiegoOstuni 0:bea5dbf3f7d5 642 * @param pAfi Pointer used to return the ST25DV AFI value.
DiegoOstuni 0:bea5dbf3f7d5 643 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 644 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 645 */
DiegoOstuni 0:bea5dbf3f7d5 646 NFCTAG_StatusTypeDef ST25DV_i2c_ReadAFI( uint8_t * const pAfi, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 647 {
DiegoOstuni 0:bea5dbf3f7d5 648 /* Read AFI register */
DiegoOstuni 0:bea5dbf3f7d5 649 return ST25DV_i2c_ReadRegister( pAfi, ST25DV_AFI_REG, 1 , mi2cChannel);
DiegoOstuni 0:bea5dbf3f7d5 650 }
DiegoOstuni 0:bea5dbf3f7d5 651
DiegoOstuni 0:bea5dbf3f7d5 652 /**
DiegoOstuni 0:bea5dbf3f7d5 653 * @brief Reads the AFI RF Lock state.
DiegoOstuni 0:bea5dbf3f7d5 654 * @param pLockAfi Pointer on a ST25DV_LOCK_STATUS used to return the ASFID lock state.
DiegoOstuni 0:bea5dbf3f7d5 655 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 656 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 657 */
DiegoOstuni 0:bea5dbf3f7d5 658 NFCTAG_StatusTypeDef ST25DV_i2c_ReadAfiRFProtection( ST25DV_LOCK_STATUS * const pLockAfi, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 659 {
DiegoOstuni 0:bea5dbf3f7d5 660 uint8_t reg_value;
DiegoOstuni 0:bea5dbf3f7d5 661 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 662
DiegoOstuni 0:bea5dbf3f7d5 663 /* Read register */
DiegoOstuni 0:bea5dbf3f7d5 664 status = ST25DV_i2c_ReadRegister( &reg_value, ST25DV_LOCKAFI_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 665 if( status != NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 666 {
DiegoOstuni 0:bea5dbf3f7d5 667 return status;
DiegoOstuni 0:bea5dbf3f7d5 668 }
DiegoOstuni 0:bea5dbf3f7d5 669
DiegoOstuni 0:bea5dbf3f7d5 670 /* Extract Lock Status */
DiegoOstuni 0:bea5dbf3f7d5 671 if( reg_value == 0 )
DiegoOstuni 0:bea5dbf3f7d5 672 {
DiegoOstuni 0:bea5dbf3f7d5 673 *pLockAfi = ST25DV_UNLOCKED;
DiegoOstuni 0:bea5dbf3f7d5 674 }
DiegoOstuni 0:bea5dbf3f7d5 675 else
DiegoOstuni 0:bea5dbf3f7d5 676 {
DiegoOstuni 0:bea5dbf3f7d5 677 *pLockAfi = ST25DV_LOCKED;
DiegoOstuni 0:bea5dbf3f7d5 678 }
DiegoOstuni 0:bea5dbf3f7d5 679 return NFCTAG_OK;
DiegoOstuni 0:bea5dbf3f7d5 680 }
DiegoOstuni 0:bea5dbf3f7d5 681
DiegoOstuni 0:bea5dbf3f7d5 682 /**
DiegoOstuni 0:bea5dbf3f7d5 683 * @brief Reads the I2C Protected Area state.
DiegoOstuni 0:bea5dbf3f7d5 684 * @param pProtZone Pointer on a ST25DV_I2C_PROT_ZONE structure used to return the Protected Area state.
DiegoOstuni 0:bea5dbf3f7d5 685 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 686 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 687 */
DiegoOstuni 0:bea5dbf3f7d5 688 NFCTAG_StatusTypeDef ST25DV_i2c_ReadI2CProtectZone( ST25DV_I2C_PROT_ZONE * const pProtZone, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 689 {
DiegoOstuni 0:bea5dbf3f7d5 690 uint8_t reg_value;
DiegoOstuni 0:bea5dbf3f7d5 691 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 692
DiegoOstuni 0:bea5dbf3f7d5 693 /* Read value of I2c Protected Zone register */
DiegoOstuni 0:bea5dbf3f7d5 694 status = ST25DV_i2c_ReadRegister( &reg_value, ST25DV_I2CZSS_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 695 if( status != NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 696 {
DiegoOstuni 0:bea5dbf3f7d5 697 return status;
DiegoOstuni 0:bea5dbf3f7d5 698 }
DiegoOstuni 0:bea5dbf3f7d5 699
DiegoOstuni 0:bea5dbf3f7d5 700 /* Dispatch information to corresponding struct member */
DiegoOstuni 0:bea5dbf3f7d5 701 pProtZone->ProtectZone1 = (ST25DV_PROTECTION_CONF)( (reg_value & ST25DV_I2CZSS_PZ1_MASK) >> ST25DV_I2CZSS_PZ1_SHIFT );
DiegoOstuni 0:bea5dbf3f7d5 702 pProtZone->ProtectZone2 = (ST25DV_PROTECTION_CONF)( (reg_value & ST25DV_I2CZSS_PZ2_MASK) >> ST25DV_I2CZSS_PZ2_SHIFT );
DiegoOstuni 0:bea5dbf3f7d5 703 pProtZone->ProtectZone3 = (ST25DV_PROTECTION_CONF)( (reg_value & ST25DV_I2CZSS_PZ3_MASK) >> ST25DV_I2CZSS_PZ3_SHIFT );
DiegoOstuni 0:bea5dbf3f7d5 704 pProtZone->ProtectZone4 = (ST25DV_PROTECTION_CONF)( (reg_value & ST25DV_I2CZSS_PZ4_MASK) >> ST25DV_I2CZSS_PZ4_SHIFT );
DiegoOstuni 0:bea5dbf3f7d5 705
DiegoOstuni 0:bea5dbf3f7d5 706 return NFCTAG_OK;
DiegoOstuni 0:bea5dbf3f7d5 707 }
DiegoOstuni 0:bea5dbf3f7d5 708
DiegoOstuni 0:bea5dbf3f7d5 709 /**
DiegoOstuni 0:bea5dbf3f7d5 710 * @brief Sets the I2C write-protected state to an EEPROM Area.
DiegoOstuni 0:bea5dbf3f7d5 711 * @details Needs the I2C Password presentation to be effective.
DiegoOstuni 0:bea5dbf3f7d5 712 * @param Zone ST25DV_PROTECTION_ZONE value coresponding to the area to protect.
DiegoOstuni 0:bea5dbf3f7d5 713 * @param ReadWriteProtection ST25DV_PROTECTION_CONF value corresponding to the protection to be set.
DiegoOstuni 0:bea5dbf3f7d5 714 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 715 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 716 */
DiegoOstuni 0:bea5dbf3f7d5 717 NFCTAG_StatusTypeDef ST25DV_i2c_WriteI2CProtectZonex( const ST25DV_PROTECTION_ZONE Zone, const ST25DV_PROTECTION_CONF ReadWriteProtection, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 718 {
DiegoOstuni 0:bea5dbf3f7d5 719 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 720 uint8_t reg_value = 0;
DiegoOstuni 0:bea5dbf3f7d5 721
DiegoOstuni 0:bea5dbf3f7d5 722 /* Read actual i2c Zone Security Status */
DiegoOstuni 0:bea5dbf3f7d5 723 status = ST25DV_i2c_ReadRegister( &reg_value, ST25DV_I2CZSS_REG, 1, mi2cChannel);
DiegoOstuni 0:bea5dbf3f7d5 724 if( status != NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 725 return status;
DiegoOstuni 0:bea5dbf3f7d5 726
DiegoOstuni 0:bea5dbf3f7d5 727 /* Compute and update new i2c Zone Security Status */
DiegoOstuni 0:bea5dbf3f7d5 728 switch( Zone )
DiegoOstuni 0:bea5dbf3f7d5 729 {
DiegoOstuni 0:bea5dbf3f7d5 730 case ST25DV_PROT_ZONE1:
DiegoOstuni 0:bea5dbf3f7d5 731 reg_value &= ST25DV_I2CZSS_PZ1_FIELD;
DiegoOstuni 0:bea5dbf3f7d5 732 /* Read protection is not allowed for Zone 1 */
DiegoOstuni 0:bea5dbf3f7d5 733 reg_value |= (ReadWriteProtection & 0x01) << ST25DV_I2CZSS_PZ1_SHIFT;
DiegoOstuni 0:bea5dbf3f7d5 734 break;
DiegoOstuni 0:bea5dbf3f7d5 735 case ST25DV_PROT_ZONE2:
DiegoOstuni 0:bea5dbf3f7d5 736 reg_value &= ST25DV_I2CZSS_PZ2_FIELD;
DiegoOstuni 0:bea5dbf3f7d5 737 reg_value |= ReadWriteProtection << ST25DV_I2CZSS_PZ2_SHIFT;
DiegoOstuni 0:bea5dbf3f7d5 738 break;
DiegoOstuni 0:bea5dbf3f7d5 739 case ST25DV_PROT_ZONE3:
DiegoOstuni 0:bea5dbf3f7d5 740 reg_value &= ST25DV_I2CZSS_PZ3_FIELD;
DiegoOstuni 0:bea5dbf3f7d5 741 reg_value |= ReadWriteProtection << ST25DV_I2CZSS_PZ3_SHIFT;
DiegoOstuni 0:bea5dbf3f7d5 742 break;
DiegoOstuni 0:bea5dbf3f7d5 743 case ST25DV_PROT_ZONE4:
DiegoOstuni 0:bea5dbf3f7d5 744 reg_value &= ST25DV_I2CZSS_PZ4_FIELD;
DiegoOstuni 0:bea5dbf3f7d5 745 reg_value |= ReadWriteProtection << ST25DV_I2CZSS_PZ4_SHIFT;
DiegoOstuni 0:bea5dbf3f7d5 746 break;
DiegoOstuni 0:bea5dbf3f7d5 747
DiegoOstuni 0:bea5dbf3f7d5 748 default:
DiegoOstuni 0:bea5dbf3f7d5 749 return NFCTAG_ERROR;
DiegoOstuni 0:bea5dbf3f7d5 750 }
DiegoOstuni 0:bea5dbf3f7d5 751
DiegoOstuni 0:bea5dbf3f7d5 752 /* Write I2CZSS register */
DiegoOstuni 0:bea5dbf3f7d5 753 return ST25DV_i2c_WriteRegister( &reg_value, ST25DV_I2CZSS_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 754 }
DiegoOstuni 0:bea5dbf3f7d5 755
DiegoOstuni 0:bea5dbf3f7d5 756 /**
DiegoOstuni 0:bea5dbf3f7d5 757 * @brief Reads the CCile protection state.
DiegoOstuni 0:bea5dbf3f7d5 758 * @param pLockCCFile Pointer on a ST25DV_LOCK_CCFILE value corresponding to the lock state of the CCFile.
DiegoOstuni 0:bea5dbf3f7d5 759 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 760 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 761 */
DiegoOstuni 0:bea5dbf3f7d5 762 NFCTAG_StatusTypeDef ST25DV_i2c_ReadLockCCFile( ST25DV_LOCK_CCFILE * const pLockCCFile, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 763 {
DiegoOstuni 0:bea5dbf3f7d5 764 uint8_t reg_value;
DiegoOstuni 0:bea5dbf3f7d5 765 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 766
DiegoOstuni 0:bea5dbf3f7d5 767 /* Get actual LOCKCCFILE register value */
DiegoOstuni 0:bea5dbf3f7d5 768 status = ST25DV_i2c_ReadRegister( &reg_value, ST25DV_LOCKCCFILE_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 769 if( status != NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 770 {
DiegoOstuni 0:bea5dbf3f7d5 771 return status;
DiegoOstuni 0:bea5dbf3f7d5 772 }
DiegoOstuni 0:bea5dbf3f7d5 773
DiegoOstuni 0:bea5dbf3f7d5 774 /* Extract CCFile block information */
DiegoOstuni 0:bea5dbf3f7d5 775 if( (reg_value & ST25DV_LOCKCCFILE_BLCK0_MASK) == ST25DV_LOCKCCFILE_BLCK0_MASK )
DiegoOstuni 0:bea5dbf3f7d5 776 {
DiegoOstuni 0:bea5dbf3f7d5 777 pLockCCFile->LckBck0 = ST25DV_LOCKED;
DiegoOstuni 0:bea5dbf3f7d5 778 }
DiegoOstuni 0:bea5dbf3f7d5 779 else
DiegoOstuni 0:bea5dbf3f7d5 780 {
DiegoOstuni 0:bea5dbf3f7d5 781 pLockCCFile->LckBck0 = ST25DV_UNLOCKED;
DiegoOstuni 0:bea5dbf3f7d5 782 }
DiegoOstuni 0:bea5dbf3f7d5 783
DiegoOstuni 0:bea5dbf3f7d5 784 if( (reg_value & ST25DV_LOCKCCFILE_BLCK1_MASK) == ST25DV_LOCKCCFILE_BLCK1_MASK )
DiegoOstuni 0:bea5dbf3f7d5 785 {
DiegoOstuni 0:bea5dbf3f7d5 786 pLockCCFile->LckBck1 = ST25DV_LOCKED;
DiegoOstuni 0:bea5dbf3f7d5 787 }
DiegoOstuni 0:bea5dbf3f7d5 788 else
DiegoOstuni 0:bea5dbf3f7d5 789 {
DiegoOstuni 0:bea5dbf3f7d5 790 pLockCCFile->LckBck1 = ST25DV_UNLOCKED;
DiegoOstuni 0:bea5dbf3f7d5 791 }
DiegoOstuni 0:bea5dbf3f7d5 792
DiegoOstuni 0:bea5dbf3f7d5 793 return status;
DiegoOstuni 0:bea5dbf3f7d5 794 }
DiegoOstuni 0:bea5dbf3f7d5 795
DiegoOstuni 0:bea5dbf3f7d5 796 /**
DiegoOstuni 0:bea5dbf3f7d5 797 * @brief Locks the CCile to prevent any RF write access.
DiegoOstuni 0:bea5dbf3f7d5 798 * @details Needs the I2C Password presentation to be effective.
DiegoOstuni 0:bea5dbf3f7d5 799 * @param NbBlockCCFile ST25DV_CCFILE_BLOCK value corresponding to the number of blocks to be locked.
DiegoOstuni 0:bea5dbf3f7d5 800 * @param LockCCFile ST25DV_LOCK_CCFILE value corresponding to the lock state to apply on the CCFile.
DiegoOstuni 0:bea5dbf3f7d5 801 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 802 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 803 */
DiegoOstuni 0:bea5dbf3f7d5 804 NFCTAG_StatusTypeDef ST25DV_i2c_WriteLockCCFile( const ST25DV_CCFILE_BLOCK NbBlockCCFile, const ST25DV_LOCK_STATUS LockCCFile, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 805 {
DiegoOstuni 0:bea5dbf3f7d5 806 uint8_t reg_value;
DiegoOstuni 0:bea5dbf3f7d5 807
DiegoOstuni 0:bea5dbf3f7d5 808 /* Configure value to write on register */
DiegoOstuni 0:bea5dbf3f7d5 809 if( NbBlockCCFile == ST25DV_CCFILE_1BLCK )
DiegoOstuni 0:bea5dbf3f7d5 810 {
DiegoOstuni 0:bea5dbf3f7d5 811 if( LockCCFile == ST25DV_LOCKED )
DiegoOstuni 0:bea5dbf3f7d5 812 {
DiegoOstuni 0:bea5dbf3f7d5 813 reg_value = ST25DV_LOCKCCFILE_BLCK0_MASK;
DiegoOstuni 0:bea5dbf3f7d5 814 }
DiegoOstuni 0:bea5dbf3f7d5 815 else
DiegoOstuni 0:bea5dbf3f7d5 816 {
DiegoOstuni 0:bea5dbf3f7d5 817 reg_value = 0x00;
DiegoOstuni 0:bea5dbf3f7d5 818 }
DiegoOstuni 0:bea5dbf3f7d5 819 }
DiegoOstuni 0:bea5dbf3f7d5 820 else
DiegoOstuni 0:bea5dbf3f7d5 821 {
DiegoOstuni 0:bea5dbf3f7d5 822 if( LockCCFile == ST25DV_LOCKED )
DiegoOstuni 0:bea5dbf3f7d5 823 {
DiegoOstuni 0:bea5dbf3f7d5 824 reg_value = ST25DV_LOCKCCFILE_BLCK0_MASK | ST25DV_LOCKCCFILE_BLCK1_MASK;
DiegoOstuni 0:bea5dbf3f7d5 825 }
DiegoOstuni 0:bea5dbf3f7d5 826 else
DiegoOstuni 0:bea5dbf3f7d5 827 {
DiegoOstuni 0:bea5dbf3f7d5 828 reg_value = 0x00;
DiegoOstuni 0:bea5dbf3f7d5 829 }
DiegoOstuni 0:bea5dbf3f7d5 830 }
DiegoOstuni 0:bea5dbf3f7d5 831
DiegoOstuni 0:bea5dbf3f7d5 832 /* Write LOCKCCFILE register */
DiegoOstuni 0:bea5dbf3f7d5 833 return ST25DV_i2c_WriteRegister( &reg_value, ST25DV_LOCKCCFILE_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 834 }
DiegoOstuni 0:bea5dbf3f7d5 835
DiegoOstuni 0:bea5dbf3f7d5 836 /**
DiegoOstuni 0:bea5dbf3f7d5 837 * @brief Reads the Cfg registers protection.
DiegoOstuni 0:bea5dbf3f7d5 838 * @param pLockCfg Pointer on a ST25DV_LOCK_STATUS value corresponding to the Cfg registers lock state.
DiegoOstuni 0:bea5dbf3f7d5 839 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 840 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 841 */
DiegoOstuni 0:bea5dbf3f7d5 842 NFCTAG_StatusTypeDef ST25DV_i2c_ReadLockCFG( ST25DV_LOCK_STATUS * const pLockCfg, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 843 {
DiegoOstuni 0:bea5dbf3f7d5 844 uint8_t reg_value;
DiegoOstuni 0:bea5dbf3f7d5 845 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 846
DiegoOstuni 0:bea5dbf3f7d5 847 /* Get actual LOCKCCFILE register value */
DiegoOstuni 0:bea5dbf3f7d5 848 status = ST25DV_i2c_ReadRegister( &reg_value, ST25DV_LOCKCFG_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 849 if( status != NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 850 {
DiegoOstuni 0:bea5dbf3f7d5 851 return status;
DiegoOstuni 0:bea5dbf3f7d5 852 }
DiegoOstuni 0:bea5dbf3f7d5 853
DiegoOstuni 0:bea5dbf3f7d5 854 /* Extract LOCKCFG block information */
DiegoOstuni 0:bea5dbf3f7d5 855 if( (reg_value & ST25DV_LOCKCFG_B0_MASK) == ST25DV_LOCKCFG_B0_MASK )
DiegoOstuni 0:bea5dbf3f7d5 856 {
DiegoOstuni 0:bea5dbf3f7d5 857 *pLockCfg = ST25DV_LOCKED;
DiegoOstuni 0:bea5dbf3f7d5 858 }
DiegoOstuni 0:bea5dbf3f7d5 859 else
DiegoOstuni 0:bea5dbf3f7d5 860 {
DiegoOstuni 0:bea5dbf3f7d5 861 *pLockCfg = ST25DV_UNLOCKED;
DiegoOstuni 0:bea5dbf3f7d5 862 }
DiegoOstuni 0:bea5dbf3f7d5 863 return NFCTAG_OK;
DiegoOstuni 0:bea5dbf3f7d5 864 }
DiegoOstuni 0:bea5dbf3f7d5 865
DiegoOstuni 0:bea5dbf3f7d5 866 /**
DiegoOstuni 0:bea5dbf3f7d5 867 * @brief Lock/Unlock the Cfg registers, to prevent any RF write access.
DiegoOstuni 0:bea5dbf3f7d5 868 * @details Needs the I2C Password presentation to be effective.
DiegoOstuni 0:bea5dbf3f7d5 869 * @param LockCfg ST25DV_LOCK_STATUS value corresponding to the lock state to be written.
DiegoOstuni 0:bea5dbf3f7d5 870 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 871 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 872 */
DiegoOstuni 0:bea5dbf3f7d5 873 NFCTAG_StatusTypeDef ST25DV_i2c_WriteLockCFG( const ST25DV_LOCK_STATUS LockCfg, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 874 {
DiegoOstuni 0:bea5dbf3f7d5 875 uint8_t reg_value;
DiegoOstuni 0:bea5dbf3f7d5 876
DiegoOstuni 0:bea5dbf3f7d5 877 /* Configure value to write on register */
DiegoOstuni 0:bea5dbf3f7d5 878 reg_value = (uint8_t)LockCfg;
DiegoOstuni 0:bea5dbf3f7d5 879
DiegoOstuni 0:bea5dbf3f7d5 880 /* Write LOCKCFG register */
DiegoOstuni 0:bea5dbf3f7d5 881 return ST25DV_i2c_WriteRegister( &reg_value, ST25DV_LOCKCFG_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 882 }
DiegoOstuni 0:bea5dbf3f7d5 883
DiegoOstuni 0:bea5dbf3f7d5 884 /**
DiegoOstuni 0:bea5dbf3f7d5 885 * @brief Presents I2C password, to authorize the I2C writes to protected areas.
DiegoOstuni 0:bea5dbf3f7d5 886 * @param PassWord Password value on 32bits
DiegoOstuni 0:bea5dbf3f7d5 887 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 888 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 889 */
DiegoOstuni 0:bea5dbf3f7d5 890 NFCTAG_StatusTypeDef ST25DV_i2c_PresentI2CPassword( const ST25DV_PASSWD PassWord, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 891 {
DiegoOstuni 0:bea5dbf3f7d5 892 uint8_t ai2c_message[17] = {0};
DiegoOstuni 0:bea5dbf3f7d5 893 uint8_t i;
DiegoOstuni 0:bea5dbf3f7d5 894
DiegoOstuni 0:bea5dbf3f7d5 895 /* Build I2C Message with Password + Validation code 0x09 + Password */
DiegoOstuni 0:bea5dbf3f7d5 896 ai2c_message[8] = 0x09;
DiegoOstuni 0:bea5dbf3f7d5 897 for( i = 0; i < 4; i++ )
DiegoOstuni 0:bea5dbf3f7d5 898 {
DiegoOstuni 0:bea5dbf3f7d5 899 ai2c_message[i] = ( PassWord.MsbPasswd >> ( (3 - i) * 8) ) & 0xFF;
DiegoOstuni 0:bea5dbf3f7d5 900 ai2c_message[i + 4] = ( PassWord.LsbPasswd >> ( (3 - i) * 8) ) & 0xFF;
DiegoOstuni 0:bea5dbf3f7d5 901 ai2c_message[i + 9] = ai2c_message[i];
DiegoOstuni 0:bea5dbf3f7d5 902 ai2c_message[i + 13] = ai2c_message[i + 4];
DiegoOstuni 0:bea5dbf3f7d5 903 };
DiegoOstuni 0:bea5dbf3f7d5 904
DiegoOstuni 0:bea5dbf3f7d5 905 /* Present password to ST25DV */
DiegoOstuni 0:bea5dbf3f7d5 906 return ST25DV_i2c_WriteRegister( ai2c_message, ST25DV_I2CPASSWD_REG, 17, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 907 }
DiegoOstuni 0:bea5dbf3f7d5 908
DiegoOstuni 0:bea5dbf3f7d5 909 /**
DiegoOstuni 0:bea5dbf3f7d5 910 * @brief Writes a new I2C password.
DiegoOstuni 0:bea5dbf3f7d5 911 * @details Needs the I2C Password presentation to be effective.
DiegoOstuni 0:bea5dbf3f7d5 912 * @param PassWord New I2C PassWord value on 32bits.
DiegoOstuni 0:bea5dbf3f7d5 913 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 914 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 915 */
DiegoOstuni 0:bea5dbf3f7d5 916 NFCTAG_StatusTypeDef ST25DV_i2c_WriteI2CPassword( const ST25DV_PASSWD PassWord, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 917 {
DiegoOstuni 0:bea5dbf3f7d5 918 uint8_t ai2c_message[17] = {0};
DiegoOstuni 0:bea5dbf3f7d5 919 uint8_t i;
DiegoOstuni 0:bea5dbf3f7d5 920
DiegoOstuni 0:bea5dbf3f7d5 921 /* Build I2C Message with Password + Validation code 0x07 + Password */
DiegoOstuni 0:bea5dbf3f7d5 922 ai2c_message[8] = 0x07;
DiegoOstuni 0:bea5dbf3f7d5 923
DiegoOstuni 0:bea5dbf3f7d5 924 for( i = 0; i < 4; i++ )
DiegoOstuni 0:bea5dbf3f7d5 925 {
DiegoOstuni 0:bea5dbf3f7d5 926 ai2c_message[i] = ( PassWord.MsbPasswd >> ( (3 - i) * 8) ) & 0xFF;
DiegoOstuni 0:bea5dbf3f7d5 927 ai2c_message[i + 4] = ( PassWord.LsbPasswd >> ( (3 - i) * 8) ) & 0xFF;
DiegoOstuni 0:bea5dbf3f7d5 928 ai2c_message[i + 9] = ai2c_message[i];
DiegoOstuni 0:bea5dbf3f7d5 929 ai2c_message[i + 13] = ai2c_message[i + 4];
DiegoOstuni 0:bea5dbf3f7d5 930 };
DiegoOstuni 0:bea5dbf3f7d5 931
DiegoOstuni 0:bea5dbf3f7d5 932 /* Write new password in I2CPASSWD register */
DiegoOstuni 0:bea5dbf3f7d5 933 return ST25DV_i2c_WriteRegister( ai2c_message, ST25DV_I2CPASSWD_REG, 17, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 934 }
DiegoOstuni 0:bea5dbf3f7d5 935
DiegoOstuni 0:bea5dbf3f7d5 936 /**
DiegoOstuni 0:bea5dbf3f7d5 937 * @brief Reads the RF Zone Security Status (defining the allowed RF accesses).
DiegoOstuni 0:bea5dbf3f7d5 938 * @param Zone ST25DV_PROTECTION_ZONE value coresponding to the protected area.
DiegoOstuni 0:bea5dbf3f7d5 939 * @param pRfprotZone Pointer on a ST25DV_RF_PROT_ZONE value corresponding to the area protection state.
DiegoOstuni 0:bea5dbf3f7d5 940 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 941 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 942 */
DiegoOstuni 0:bea5dbf3f7d5 943 NFCTAG_StatusTypeDef ST25DV_i2c_ReadRFZxSS( const ST25DV_PROTECTION_ZONE Zone, ST25DV_RF_PROT_ZONE * const pRfprotZone, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 944 {
DiegoOstuni 0:bea5dbf3f7d5 945 uint8_t reg_value;
DiegoOstuni 0:bea5dbf3f7d5 946 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 947 uint16_t sector_security_addr;
DiegoOstuni 0:bea5dbf3f7d5 948
DiegoOstuni 0:bea5dbf3f7d5 949 /* Select Sector Security register address */
DiegoOstuni 0:bea5dbf3f7d5 950 switch( Zone )
DiegoOstuni 0:bea5dbf3f7d5 951 {
DiegoOstuni 0:bea5dbf3f7d5 952 case ST25DV_PROT_ZONE1:
DiegoOstuni 0:bea5dbf3f7d5 953 sector_security_addr = ST25DV_RFZ1SS_REG;
DiegoOstuni 0:bea5dbf3f7d5 954 break;
DiegoOstuni 0:bea5dbf3f7d5 955 case ST25DV_PROT_ZONE2:
DiegoOstuni 0:bea5dbf3f7d5 956 sector_security_addr = ST25DV_RFZ2SS_REG;
DiegoOstuni 0:bea5dbf3f7d5 957 break;
DiegoOstuni 0:bea5dbf3f7d5 958 case ST25DV_PROT_ZONE3:
DiegoOstuni 0:bea5dbf3f7d5 959 sector_security_addr = ST25DV_RFZ3SS_REG;
DiegoOstuni 0:bea5dbf3f7d5 960 break;
DiegoOstuni 0:bea5dbf3f7d5 961 case ST25DV_PROT_ZONE4:
DiegoOstuni 0:bea5dbf3f7d5 962 sector_security_addr = ST25DV_RFZ4SS_REG;
DiegoOstuni 0:bea5dbf3f7d5 963 break;
DiegoOstuni 0:bea5dbf3f7d5 964
DiegoOstuni 0:bea5dbf3f7d5 965 default:
DiegoOstuni 0:bea5dbf3f7d5 966 return NFCTAG_ERROR;
DiegoOstuni 0:bea5dbf3f7d5 967 }
DiegoOstuni 0:bea5dbf3f7d5 968
DiegoOstuni 0:bea5dbf3f7d5 969 /* Read actual value of Sector Security Status register */
DiegoOstuni 0:bea5dbf3f7d5 970 status = ST25DV_i2c_ReadRegister( &reg_value, sector_security_addr, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 971 if( status != NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 972 {
DiegoOstuni 0:bea5dbf3f7d5 973 return status;
DiegoOstuni 0:bea5dbf3f7d5 974 }
DiegoOstuni 0:bea5dbf3f7d5 975
DiegoOstuni 0:bea5dbf3f7d5 976 /* Extract Sector Security Status configuration */
DiegoOstuni 0:bea5dbf3f7d5 977 pRfprotZone->PasswdCtrl = (ST25DV_PASSWD_PROT_STATUS)((reg_value & ST25DV_RFZSS_PWDCTRL_MASK) >> ST25DV_RFZSS_PWDCTRL_SHIFT);
DiegoOstuni 0:bea5dbf3f7d5 978 pRfprotZone->RWprotection = (ST25DV_PROTECTION_CONF)((reg_value & ST25DV_RFZSS_RWPROT_MASK) >> ST25DV_RFZSS_RWPROT_SHIFT);
DiegoOstuni 0:bea5dbf3f7d5 979
DiegoOstuni 0:bea5dbf3f7d5 980 return NFCTAG_OK;
DiegoOstuni 0:bea5dbf3f7d5 981 }
DiegoOstuni 0:bea5dbf3f7d5 982
DiegoOstuni 0:bea5dbf3f7d5 983 /**
DiegoOstuni 0:bea5dbf3f7d5 984 * @brief Writes the RF Zone Security Status (defining the allowed RF accesses)
DiegoOstuni 0:bea5dbf3f7d5 985 * @details Needs the I2C Password presentation to be effective.
DiegoOstuni 0:bea5dbf3f7d5 986 * @param Zone ST25DV_PROTECTION_ZONE value corresponding to the area on which to set the RF protection.
DiegoOstuni 0:bea5dbf3f7d5 987 * @param RfProtZone Pointer on a ST25DV_RF_PROT_ZONE value defininf the protection to be set on the area.
DiegoOstuni 0:bea5dbf3f7d5 988 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 989 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 990 */
DiegoOstuni 0:bea5dbf3f7d5 991 NFCTAG_StatusTypeDef ST25DV_i2c_WriteRFZxSS( const ST25DV_PROTECTION_ZONE Zone, const ST25DV_RF_PROT_ZONE RfProtZone, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 992 {
DiegoOstuni 0:bea5dbf3f7d5 993 uint8_t reg_value;
DiegoOstuni 0:bea5dbf3f7d5 994 uint16_t sector_security_addr;
DiegoOstuni 0:bea5dbf3f7d5 995
DiegoOstuni 0:bea5dbf3f7d5 996 /* Select Sector Security register address */
DiegoOstuni 0:bea5dbf3f7d5 997 switch( Zone )
DiegoOstuni 0:bea5dbf3f7d5 998 {
DiegoOstuni 0:bea5dbf3f7d5 999 case ST25DV_PROT_ZONE1:
DiegoOstuni 0:bea5dbf3f7d5 1000 sector_security_addr = ST25DV_RFZ1SS_REG;
DiegoOstuni 0:bea5dbf3f7d5 1001 break;
DiegoOstuni 0:bea5dbf3f7d5 1002 case ST25DV_PROT_ZONE2:
DiegoOstuni 0:bea5dbf3f7d5 1003 sector_security_addr = ST25DV_RFZ2SS_REG;
DiegoOstuni 0:bea5dbf3f7d5 1004 break;
DiegoOstuni 0:bea5dbf3f7d5 1005 case ST25DV_PROT_ZONE3:
DiegoOstuni 0:bea5dbf3f7d5 1006 sector_security_addr = ST25DV_RFZ3SS_REG;
DiegoOstuni 0:bea5dbf3f7d5 1007 break;
DiegoOstuni 0:bea5dbf3f7d5 1008 case ST25DV_PROT_ZONE4:
DiegoOstuni 0:bea5dbf3f7d5 1009 sector_security_addr = ST25DV_RFZ4SS_REG;
DiegoOstuni 0:bea5dbf3f7d5 1010 break;
DiegoOstuni 0:bea5dbf3f7d5 1011
DiegoOstuni 0:bea5dbf3f7d5 1012 default:
DiegoOstuni 0:bea5dbf3f7d5 1013 return NFCTAG_ERROR;
DiegoOstuni 0:bea5dbf3f7d5 1014 }
DiegoOstuni 0:bea5dbf3f7d5 1015
DiegoOstuni 0:bea5dbf3f7d5 1016 /* Update Sector Security Status */
DiegoOstuni 0:bea5dbf3f7d5 1017 reg_value = (RfProtZone.RWprotection << ST25DV_RFZSS_RWPROT_SHIFT) & ST25DV_RFZSS_RWPROT_MASK;
DiegoOstuni 0:bea5dbf3f7d5 1018 reg_value |= ((RfProtZone.PasswdCtrl << ST25DV_RFZSS_PWDCTRL_SHIFT) & ST25DV_RFZSS_PWDCTRL_MASK);
DiegoOstuni 0:bea5dbf3f7d5 1019
DiegoOstuni 0:bea5dbf3f7d5 1020 /* Write Sector Security register */
DiegoOstuni 0:bea5dbf3f7d5 1021 return ST25DV_i2c_WriteRegister( &reg_value, sector_security_addr, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1022 }
DiegoOstuni 0:bea5dbf3f7d5 1023
DiegoOstuni 0:bea5dbf3f7d5 1024 /**
DiegoOstuni 0:bea5dbf3f7d5 1025 * @brief Reads the value of the an area end address.
DiegoOstuni 0:bea5dbf3f7d5 1026 * @param EndZone ST25DV_END_ZONE value corresponding to an area end address.
DiegoOstuni 0:bea5dbf3f7d5 1027 * @param pEndZ Pointer used to return the end address of the area.
DiegoOstuni 0:bea5dbf3f7d5 1028 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 1029 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 1030 */
DiegoOstuni 0:bea5dbf3f7d5 1031 NFCTAG_StatusTypeDef ST25DV_i2c_ReadEndZonex( const ST25DV_END_ZONE EndZone, uint8_t * const pEndZ, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 1032 {
DiegoOstuni 0:bea5dbf3f7d5 1033 uint16_t mem_addr;
DiegoOstuni 0:bea5dbf3f7d5 1034
DiegoOstuni 0:bea5dbf3f7d5 1035 /* End zone register address to read */
DiegoOstuni 0:bea5dbf3f7d5 1036 switch( EndZone )
DiegoOstuni 0:bea5dbf3f7d5 1037 {
DiegoOstuni 0:bea5dbf3f7d5 1038 case ST25DV_ZONE_END1:
DiegoOstuni 0:bea5dbf3f7d5 1039 mem_addr = ST25DV_END1_REG;
DiegoOstuni 0:bea5dbf3f7d5 1040 break;
DiegoOstuni 0:bea5dbf3f7d5 1041 case ST25DV_ZONE_END2:
DiegoOstuni 0:bea5dbf3f7d5 1042 mem_addr = ST25DV_END2_REG;
DiegoOstuni 0:bea5dbf3f7d5 1043 break;
DiegoOstuni 0:bea5dbf3f7d5 1044 case ST25DV_ZONE_END3:
DiegoOstuni 0:bea5dbf3f7d5 1045 mem_addr = ST25DV_END3_REG;
DiegoOstuni 0:bea5dbf3f7d5 1046 break;
DiegoOstuni 0:bea5dbf3f7d5 1047
DiegoOstuni 0:bea5dbf3f7d5 1048 default:
DiegoOstuni 0:bea5dbf3f7d5 1049 return NFCTAG_ERROR;
DiegoOstuni 0:bea5dbf3f7d5 1050 }
DiegoOstuni 0:bea5dbf3f7d5 1051
DiegoOstuni 0:bea5dbf3f7d5 1052 /* Read the corresponding End zone */
DiegoOstuni 0:bea5dbf3f7d5 1053 return ST25DV_i2c_ReadRegister( pEndZ, mem_addr, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1054 }
DiegoOstuni 0:bea5dbf3f7d5 1055
DiegoOstuni 0:bea5dbf3f7d5 1056 /**
DiegoOstuni 0:bea5dbf3f7d5 1057 * @brief Sets the end address of an area.
DiegoOstuni 0:bea5dbf3f7d5 1058 * @details Needs the I2C Password presentation to be effective.
DiegoOstuni 0:bea5dbf3f7d5 1059 * @note The ST25DV answers a NACK when setting the EndZone2 & EndZone3 to same value than repectively EndZone1 & EndZone2.\n
DiegoOstuni 0:bea5dbf3f7d5 1060 * These NACKs are ok.
DiegoOstuni 0:bea5dbf3f7d5 1061 * @param EndZone ST25DV_END_ZONE value corresponding to an area.
DiegoOstuni 0:bea5dbf3f7d5 1062 * @param EndZ End zone value to be written.
DiegoOstuni 0:bea5dbf3f7d5 1063 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 1064 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 1065 */
DiegoOstuni 0:bea5dbf3f7d5 1066 NFCTAG_StatusTypeDef ST25DV_i2c_WriteEndZonex( const ST25DV_END_ZONE EndZone, const uint8_t EndZ , I2C * mi2cChannel)
DiegoOstuni 0:bea5dbf3f7d5 1067 {
DiegoOstuni 0:bea5dbf3f7d5 1068 uint16_t mem_addr;
DiegoOstuni 0:bea5dbf3f7d5 1069 NFCTAG_StatusTypeDef ret;
DiegoOstuni 0:bea5dbf3f7d5 1070
DiegoOstuni 0:bea5dbf3f7d5 1071 /* End zone register address to write */
DiegoOstuni 0:bea5dbf3f7d5 1072 switch( EndZone )
DiegoOstuni 0:bea5dbf3f7d5 1073 {
DiegoOstuni 0:bea5dbf3f7d5 1074 case ST25DV_ZONE_END1:
DiegoOstuni 0:bea5dbf3f7d5 1075 mem_addr = ST25DV_END1_REG;
DiegoOstuni 0:bea5dbf3f7d5 1076 break;
DiegoOstuni 0:bea5dbf3f7d5 1077 case ST25DV_ZONE_END2:
DiegoOstuni 0:bea5dbf3f7d5 1078 mem_addr = ST25DV_END2_REG;
DiegoOstuni 0:bea5dbf3f7d5 1079 break;
DiegoOstuni 0:bea5dbf3f7d5 1080 case ST25DV_ZONE_END3:
DiegoOstuni 0:bea5dbf3f7d5 1081 mem_addr = ST25DV_END3_REG;
DiegoOstuni 0:bea5dbf3f7d5 1082 break;
DiegoOstuni 0:bea5dbf3f7d5 1083
DiegoOstuni 0:bea5dbf3f7d5 1084 default:
DiegoOstuni 0:bea5dbf3f7d5 1085 return NFCTAG_ERROR;
DiegoOstuni 0:bea5dbf3f7d5 1086 }
DiegoOstuni 0:bea5dbf3f7d5 1087
DiegoOstuni 0:bea5dbf3f7d5 1088 /* Write the corresponding End zone value in register */
DiegoOstuni 0:bea5dbf3f7d5 1089 ret = ST25DV_i2c_WriteRegister( &EndZ, mem_addr, 1,mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1090
DiegoOstuni 0:bea5dbf3f7d5 1091 return ret;
DiegoOstuni 0:bea5dbf3f7d5 1092 }
DiegoOstuni 0:bea5dbf3f7d5 1093
DiegoOstuni 0:bea5dbf3f7d5 1094 /**
DiegoOstuni 0:bea5dbf3f7d5 1095 * @brief Initializes the end address of the ST25DV areas with their default values (end of memory).
DiegoOstuni 0:bea5dbf3f7d5 1096 * @details Needs the I2C Password presentation to be effective..
DiegoOstuni 0:bea5dbf3f7d5 1097 * The ST25DV answers a NACK when setting the EndZone2 & EndZone3 to same value than repectively EndZone1 & EndZone2.
DiegoOstuni 0:bea5dbf3f7d5 1098 * These NACKs are ok.
DiegoOstuni 0:bea5dbf3f7d5 1099 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 1100 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 1101 */
DiegoOstuni 0:bea5dbf3f7d5 1102 NFCTAG_StatusTypeDef ST25DV_i2c_InitEndZone( I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 1103 {
DiegoOstuni 0:bea5dbf3f7d5 1104 uint8_t endval = 0xFF;
DiegoOstuni 0:bea5dbf3f7d5 1105 uint32_t maxmemlength;
DiegoOstuni 0:bea5dbf3f7d5 1106 ST25DV_MEM_SIZE memsize;
DiegoOstuni 0:bea5dbf3f7d5 1107 NFCTAG_StatusTypeDef ret;
DiegoOstuni 0:bea5dbf3f7d5 1108
DiegoOstuni 0:bea5dbf3f7d5 1109 memsize.Mem_Size = 0;
DiegoOstuni 0:bea5dbf3f7d5 1110 memsize.BlockSize = 0;
DiegoOstuni 0:bea5dbf3f7d5 1111
DiegoOstuni 0:bea5dbf3f7d5 1112 /* Get EEPROM mem size */
DiegoOstuni 0:bea5dbf3f7d5 1113 ST25DV_i2c_ReadMemSize( &memsize, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1114 maxmemlength = (memsize.Mem_Size + 1) * (memsize.BlockSize + 1);
DiegoOstuni 0:bea5dbf3f7d5 1115
DiegoOstuni 0:bea5dbf3f7d5 1116 /* Compute Max value for endzone register */
DiegoOstuni 0:bea5dbf3f7d5 1117 endval = (maxmemlength / 32) - 1;
DiegoOstuni 0:bea5dbf3f7d5 1118
DiegoOstuni 0:bea5dbf3f7d5 1119 /* Write EndZone value to ST25DV registers */
DiegoOstuni 0:bea5dbf3f7d5 1120 ret = ST25DV_i2c_WriteEndZonex( ST25DV_ZONE_END3, endval, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1121 if( (ret != NFCTAG_OK) && (ret != NFCTAG_NACK) )
DiegoOstuni 0:bea5dbf3f7d5 1122 {
DiegoOstuni 0:bea5dbf3f7d5 1123 return ret;
DiegoOstuni 0:bea5dbf3f7d5 1124 }
DiegoOstuni 0:bea5dbf3f7d5 1125
DiegoOstuni 0:bea5dbf3f7d5 1126 ret = ST25DV_i2c_WriteEndZonex( ST25DV_ZONE_END2, endval, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1127 if( (ret != NFCTAG_OK) && (ret != NFCTAG_NACK) )
DiegoOstuni 0:bea5dbf3f7d5 1128 {
DiegoOstuni 0:bea5dbf3f7d5 1129 return ret;
DiegoOstuni 0:bea5dbf3f7d5 1130 }
DiegoOstuni 0:bea5dbf3f7d5 1131
DiegoOstuni 0:bea5dbf3f7d5 1132 ret = ST25DV_i2c_WriteEndZonex( ST25DV_ZONE_END1, endval, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1133 if( (ret != NFCTAG_OK) && (ret != NFCTAG_NACK) )
DiegoOstuni 0:bea5dbf3f7d5 1134 {
DiegoOstuni 0:bea5dbf3f7d5 1135 return ret;
DiegoOstuni 0:bea5dbf3f7d5 1136 }
DiegoOstuni 0:bea5dbf3f7d5 1137
DiegoOstuni 0:bea5dbf3f7d5 1138 return ret;
DiegoOstuni 0:bea5dbf3f7d5 1139 }
DiegoOstuni 0:bea5dbf3f7d5 1140
DiegoOstuni 0:bea5dbf3f7d5 1141 /**
DiegoOstuni 0:bea5dbf3f7d5 1142 * @brief Creates user areas with defined lengths.
DiegoOstuni 0:bea5dbf3f7d5 1143 * @details Needs the I2C Password presentation to be effective.
DiegoOstuni 0:bea5dbf3f7d5 1144 * @param Zone1Length Length of area1 in bytes (32 to 8192, 0x20 to 0x2000)
DiegoOstuni 0:bea5dbf3f7d5 1145 * @param Zone2Length Length of area2 in bytes (0 to 8128, 0x00 to 0x1FC0)
DiegoOstuni 0:bea5dbf3f7d5 1146 * @param Zone3Length Length of area3 in bytes (0 to 8064, 0x00 to 0x1F80)
DiegoOstuni 0:bea5dbf3f7d5 1147 * @param Zone4Length Length of area4 in bytes (0 to 8000, 0x00 to 0x1F40)
DiegoOstuni 0:bea5dbf3f7d5 1148 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 1149 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 1150 */
DiegoOstuni 0:bea5dbf3f7d5 1151 NFCTAG_StatusTypeDef ST25DV_i2c_CreateUserZone( uint16_t Zone1Length, uint16_t Zone2Length, uint16_t Zone3Length, uint16_t Zone4Length, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 1152 {
DiegoOstuni 0:bea5dbf3f7d5 1153 uint8_t EndVal;
DiegoOstuni 0:bea5dbf3f7d5 1154 ST25DV_MEM_SIZE memsize;
DiegoOstuni 0:bea5dbf3f7d5 1155 uint16_t maxmemlength = 0;
DiegoOstuni 0:bea5dbf3f7d5 1156 NFCTAG_StatusTypeDef ret;
DiegoOstuni 0:bea5dbf3f7d5 1157
DiegoOstuni 0:bea5dbf3f7d5 1158 memsize.Mem_Size = 0;
DiegoOstuni 0:bea5dbf3f7d5 1159 memsize.BlockSize = 0;
DiegoOstuni 0:bea5dbf3f7d5 1160
DiegoOstuni 0:bea5dbf3f7d5 1161 ST25DV_i2c_ReadMemSize( &memsize, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1162
DiegoOstuni 0:bea5dbf3f7d5 1163 maxmemlength = (memsize.Mem_Size + 1) * (memsize.BlockSize + 1);
DiegoOstuni 0:bea5dbf3f7d5 1164
DiegoOstuni 0:bea5dbf3f7d5 1165 /* Checks that values of different zones are in bounds */
DiegoOstuni 0:bea5dbf3f7d5 1166 if( ( Zone1Length < 32 ) || ( Zone1Length > maxmemlength ) || ( Zone2Length > (maxmemlength - 32) )
DiegoOstuni 0:bea5dbf3f7d5 1167 || ( Zone3Length > (maxmemlength - 64) ) || ( Zone4Length > (maxmemlength - 96) ) )
DiegoOstuni 0:bea5dbf3f7d5 1168 {
DiegoOstuni 0:bea5dbf3f7d5 1169 return NFCTAG_ERROR;
DiegoOstuni 0:bea5dbf3f7d5 1170 }
DiegoOstuni 0:bea5dbf3f7d5 1171
DiegoOstuni 0:bea5dbf3f7d5 1172 /* Checks that the total is less than the authorised maximum */
DiegoOstuni 0:bea5dbf3f7d5 1173 if( ( Zone1Length + Zone2Length + Zone3Length + Zone4Length ) > maxmemlength )
DiegoOstuni 0:bea5dbf3f7d5 1174 {
DiegoOstuni 0:bea5dbf3f7d5 1175 return NFCTAG_ERROR;
DiegoOstuni 0:bea5dbf3f7d5 1176 }
DiegoOstuni 0:bea5dbf3f7d5 1177
DiegoOstuni 0:bea5dbf3f7d5 1178 /* if The value for each Length is not a multiple of 64 correct it. */
DiegoOstuni 0:bea5dbf3f7d5 1179 if( (Zone1Length % 32) != 0 )
DiegoOstuni 0:bea5dbf3f7d5 1180 {
DiegoOstuni 0:bea5dbf3f7d5 1181 Zone1Length = Zone1Length - ( Zone1Length % 32 );
DiegoOstuni 0:bea5dbf3f7d5 1182 }
DiegoOstuni 0:bea5dbf3f7d5 1183
DiegoOstuni 0:bea5dbf3f7d5 1184 if( (Zone2Length % 32) != 0 )
DiegoOstuni 0:bea5dbf3f7d5 1185 {
DiegoOstuni 0:bea5dbf3f7d5 1186 Zone2Length = Zone2Length - ( Zone2Length % 32 );
DiegoOstuni 0:bea5dbf3f7d5 1187 }
DiegoOstuni 0:bea5dbf3f7d5 1188
DiegoOstuni 0:bea5dbf3f7d5 1189 if( (Zone3Length % 32) != 0 )
DiegoOstuni 0:bea5dbf3f7d5 1190 {
DiegoOstuni 0:bea5dbf3f7d5 1191 Zone3Length = Zone3Length - ( Zone3Length % 32 );
DiegoOstuni 0:bea5dbf3f7d5 1192 }
DiegoOstuni 0:bea5dbf3f7d5 1193
DiegoOstuni 0:bea5dbf3f7d5 1194 /* First right 0xFF in each Endx value */
DiegoOstuni 0:bea5dbf3f7d5 1195 ret = ST25DV_i2c_InitEndZone( mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1196 if( (ret != NFCTAG_OK) && (ret != NFCTAG_NACK) )
DiegoOstuni 0:bea5dbf3f7d5 1197 {
DiegoOstuni 0:bea5dbf3f7d5 1198 return ret;
DiegoOstuni 0:bea5dbf3f7d5 1199 }
DiegoOstuni 0:bea5dbf3f7d5 1200
DiegoOstuni 0:bea5dbf3f7d5 1201 /* Then Write corresponding value for each zone */
DiegoOstuni 0:bea5dbf3f7d5 1202 EndVal = (uint8_t)( (Zone1Length / 32 ) - 1 );
DiegoOstuni 0:bea5dbf3f7d5 1203 ret = ST25DV_i2c_WriteEndZonex( ST25DV_ZONE_END1, EndVal, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1204 if( (ret != NFCTAG_OK) && (ret != NFCTAG_NACK) )
DiegoOstuni 0:bea5dbf3f7d5 1205 {
DiegoOstuni 0:bea5dbf3f7d5 1206 return ret;
DiegoOstuni 0:bea5dbf3f7d5 1207 }
DiegoOstuni 0:bea5dbf3f7d5 1208
DiegoOstuni 0:bea5dbf3f7d5 1209 EndVal = (uint8_t)( ((Zone1Length + Zone2Length) / 32 ) - 1 );
DiegoOstuni 0:bea5dbf3f7d5 1210 ret = ST25DV_i2c_WriteEndZonex( ST25DV_ZONE_END2, EndVal, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1211 if( (ret != NFCTAG_OK) && (ret != NFCTAG_NACK) )
DiegoOstuni 0:bea5dbf3f7d5 1212 {
DiegoOstuni 0:bea5dbf3f7d5 1213 return ret;
DiegoOstuni 0:bea5dbf3f7d5 1214 }
DiegoOstuni 0:bea5dbf3f7d5 1215
DiegoOstuni 0:bea5dbf3f7d5 1216 EndVal = (uint8_t)( ((Zone1Length + Zone2Length + Zone3Length) / 32 ) - 1 );
DiegoOstuni 0:bea5dbf3f7d5 1217 ret = ST25DV_i2c_WriteEndZonex( ST25DV_ZONE_END3, EndVal, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1218 if( (ret != NFCTAG_OK) && (ret != NFCTAG_NACK) )
DiegoOstuni 0:bea5dbf3f7d5 1219 {
DiegoOstuni 0:bea5dbf3f7d5 1220 return ret;
DiegoOstuni 0:bea5dbf3f7d5 1221 }
DiegoOstuni 0:bea5dbf3f7d5 1222
DiegoOstuni 0:bea5dbf3f7d5 1223 return NFCTAG_OK;
DiegoOstuni 0:bea5dbf3f7d5 1224 }
DiegoOstuni 0:bea5dbf3f7d5 1225
DiegoOstuni 0:bea5dbf3f7d5 1226 /**
DiegoOstuni 0:bea5dbf3f7d5 1227 * @brief Reads the ST25DV Memory Size.
DiegoOstuni 0:bea5dbf3f7d5 1228 * @param pSizeInfo Pointer on a ST25DV_MEM_SIZE structure used to return the Memory size information.
DiegoOstuni 0:bea5dbf3f7d5 1229 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 1230 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 1231 */
DiegoOstuni 0:bea5dbf3f7d5 1232 NFCTAG_StatusTypeDef ST25DV_i2c_ReadMemSize( ST25DV_MEM_SIZE * const pSizeInfo, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 1233 {
DiegoOstuni 0:bea5dbf3f7d5 1234 uint8_t reg_value[3];
DiegoOstuni 0:bea5dbf3f7d5 1235 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 1236
DiegoOstuni 0:bea5dbf3f7d5 1237 /* Read actual value of MEM_SIZE register,cheeeeeeeeeeeeeck*/
DiegoOstuni 0:bea5dbf3f7d5 1238 status = ST25DV_i2c_ReadRegister( reg_value, ST25DV_MEM_SIZE_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1239 status = ST25DV_i2c_ReadRegister( reg_value + 1, ST25DV_MEM_SIZE_REG + 1, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1240 status = ST25DV_i2c_ReadRegister( reg_value + 2, ST25DV_MEM_SIZE_REG + 2, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1241
DiegoOstuni 0:bea5dbf3f7d5 1242
DiegoOstuni 0:bea5dbf3f7d5 1243 if( status != NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 1244 return status;
DiegoOstuni 0:bea5dbf3f7d5 1245
DiegoOstuni 0:bea5dbf3f7d5 1246 /* Extract Memory information */
DiegoOstuni 0:bea5dbf3f7d5 1247 pSizeInfo->BlockSize = reg_value[2];
DiegoOstuni 0:bea5dbf3f7d5 1248 pSizeInfo->Mem_Size = reg_value[1];
DiegoOstuni 0:bea5dbf3f7d5 1249 pSizeInfo->Mem_Size = (pSizeInfo->Mem_Size << 8) | reg_value[0];
DiegoOstuni 0:bea5dbf3f7d5 1250 return NFCTAG_OK;
DiegoOstuni 0:bea5dbf3f7d5 1251 }
DiegoOstuni 0:bea5dbf3f7d5 1252
DiegoOstuni 0:bea5dbf3f7d5 1253 /**
DiegoOstuni 0:bea5dbf3f7d5 1254 * @brief Reads the Energy harvesting mode.
DiegoOstuni 0:bea5dbf3f7d5 1255 * @param pEH_mode Pointer on a ST25DV_EH_MODE_STATUS value corresponding to the Energy Harvesting state.
DiegoOstuni 0:bea5dbf3f7d5 1256 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 1257 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 1258 */
DiegoOstuni 0:bea5dbf3f7d5 1259 NFCTAG_StatusTypeDef ST25DV_i2c_ReadEHMode( ST25DV_EH_MODE_STATUS * const pEH_mode, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 1260 {
DiegoOstuni 0:bea5dbf3f7d5 1261 uint8_t reg_value;
DiegoOstuni 0:bea5dbf3f7d5 1262 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 1263
DiegoOstuni 0:bea5dbf3f7d5 1264 /* Read actual value of EH_MODE register */
DiegoOstuni 0:bea5dbf3f7d5 1265 status = ST25DV_i2c_ReadRegister( &reg_value, ST25DV_EH_MODE_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1266 if( status != NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 1267 return status;
DiegoOstuni 0:bea5dbf3f7d5 1268
DiegoOstuni 0:bea5dbf3f7d5 1269 /* Extract EH_mode configuration */
DiegoOstuni 0:bea5dbf3f7d5 1270 if( (reg_value & ST25DV_EH_MODE_MASK) == ST25DV_EH_MODE_MASK )
DiegoOstuni 0:bea5dbf3f7d5 1271 {
DiegoOstuni 0:bea5dbf3f7d5 1272 *pEH_mode = ST25DV_EH_ON_DEMAND;
DiegoOstuni 0:bea5dbf3f7d5 1273 }
DiegoOstuni 0:bea5dbf3f7d5 1274 else
DiegoOstuni 0:bea5dbf3f7d5 1275 {
DiegoOstuni 0:bea5dbf3f7d5 1276 *pEH_mode = ST25DV_EH_ACTIVE_AFTER_BOOT;
DiegoOstuni 0:bea5dbf3f7d5 1277 }
DiegoOstuni 0:bea5dbf3f7d5 1278
DiegoOstuni 0:bea5dbf3f7d5 1279 return NFCTAG_OK;
DiegoOstuni 0:bea5dbf3f7d5 1280 }
DiegoOstuni 0:bea5dbf3f7d5 1281
DiegoOstuni 0:bea5dbf3f7d5 1282 /**
DiegoOstuni 0:bea5dbf3f7d5 1283 * @brief Sets the Energy harvesting mode.
DiegoOstuni 0:bea5dbf3f7d5 1284 * @details Needs the I2C Password presentation to be effective.
DiegoOstuni 0:bea5dbf3f7d5 1285 * @param EH_mode ST25DV_EH_MODE_STATUS value for the Energy harvesting mode to be set.
DiegoOstuni 0:bea5dbf3f7d5 1286 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 1287 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 1288 */
DiegoOstuni 0:bea5dbf3f7d5 1289 NFCTAG_StatusTypeDef ST25DV_i2c_WriteEHMode( const ST25DV_EH_MODE_STATUS EH_mode, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 1290 {
DiegoOstuni 0:bea5dbf3f7d5 1291 uint8_t reg_value;
DiegoOstuni 0:bea5dbf3f7d5 1292
DiegoOstuni 0:bea5dbf3f7d5 1293 /* Update EH_mode */
DiegoOstuni 0:bea5dbf3f7d5 1294 reg_value = (uint8_t)EH_mode;
DiegoOstuni 0:bea5dbf3f7d5 1295
DiegoOstuni 0:bea5dbf3f7d5 1296 /* Write EH_MODE register */
DiegoOstuni 0:bea5dbf3f7d5 1297 return ST25DV_i2c_WriteRegister( &reg_value, ST25DV_EH_MODE_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1298 }
DiegoOstuni 0:bea5dbf3f7d5 1299
DiegoOstuni 0:bea5dbf3f7d5 1300 /**
DiegoOstuni 0:bea5dbf3f7d5 1301 * @brief Reads the RF Management configuration.
DiegoOstuni 0:bea5dbf3f7d5 1302 * @param pRF_Mngt Pointer on a ST25DV_RF_MNGT structure used to return the RF Management configuration.
DiegoOstuni 0:bea5dbf3f7d5 1303 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 1304 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 1305 */
DiegoOstuni 0:bea5dbf3f7d5 1306 NFCTAG_StatusTypeDef ST25DV_i2c_ReadRFMngt( ST25DV_RF_MNGT * const pRF_Mngt, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 1307 {
DiegoOstuni 0:bea5dbf3f7d5 1308 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 1309 uint8_t reg_value = 0;
DiegoOstuni 0:bea5dbf3f7d5 1310
DiegoOstuni 0:bea5dbf3f7d5 1311 /* Read actual value of RF_MNGT register */
DiegoOstuni 0:bea5dbf3f7d5 1312 status = ST25DV_i2c_ReadRegister( &reg_value, ST25DV_RF_MNGT_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1313
DiegoOstuni 0:bea5dbf3f7d5 1314 if( status == NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 1315 {
DiegoOstuni 0:bea5dbf3f7d5 1316 /* Extract RF Disable information */
DiegoOstuni 0:bea5dbf3f7d5 1317 if( (reg_value & ST25DV_RF_MNGT_RFDIS_MASK) == ST25DV_RF_MNGT_RFDIS_MASK )
DiegoOstuni 0:bea5dbf3f7d5 1318 {
DiegoOstuni 0:bea5dbf3f7d5 1319 pRF_Mngt->RfDisable = ST25DV_ENABLE;
DiegoOstuni 0:bea5dbf3f7d5 1320 }
DiegoOstuni 0:bea5dbf3f7d5 1321 else
DiegoOstuni 0:bea5dbf3f7d5 1322 {
DiegoOstuni 0:bea5dbf3f7d5 1323 pRF_Mngt->RfDisable = ST25DV_DISABLE;
DiegoOstuni 0:bea5dbf3f7d5 1324 }
DiegoOstuni 0:bea5dbf3f7d5 1325
DiegoOstuni 0:bea5dbf3f7d5 1326 /* Extract RF Sleep information */
DiegoOstuni 0:bea5dbf3f7d5 1327 if( (reg_value & ST25DV_RF_MNGT_RFSLEEP_MASK) == ST25DV_RF_MNGT_RFSLEEP_MASK )
DiegoOstuni 0:bea5dbf3f7d5 1328 {
DiegoOstuni 0:bea5dbf3f7d5 1329 pRF_Mngt->RfSleep = ST25DV_ENABLE;
DiegoOstuni 0:bea5dbf3f7d5 1330 }
DiegoOstuni 0:bea5dbf3f7d5 1331 else
DiegoOstuni 0:bea5dbf3f7d5 1332 {
DiegoOstuni 0:bea5dbf3f7d5 1333 pRF_Mngt->RfSleep = ST25DV_DISABLE;
DiegoOstuni 0:bea5dbf3f7d5 1334 }
DiegoOstuni 0:bea5dbf3f7d5 1335 }
DiegoOstuni 0:bea5dbf3f7d5 1336
DiegoOstuni 0:bea5dbf3f7d5 1337 return status;
DiegoOstuni 0:bea5dbf3f7d5 1338 }
DiegoOstuni 0:bea5dbf3f7d5 1339
DiegoOstuni 0:bea5dbf3f7d5 1340 /**
DiegoOstuni 0:bea5dbf3f7d5 1341 * @brief Sets the RF Management configuration.
DiegoOstuni 0:bea5dbf3f7d5 1342 * @details Needs the I2C Password presentation to be effective.
DiegoOstuni 0:bea5dbf3f7d5 1343 * @param Rfmngt Value of the RF Management configuration to be written.
DiegoOstuni 0:bea5dbf3f7d5 1344 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 1345 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 1346 */
DiegoOstuni 0:bea5dbf3f7d5 1347 NFCTAG_StatusTypeDef ST25DV_i2c_WriteRFMngt( const uint8_t Rfmngt, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 1348 {
DiegoOstuni 0:bea5dbf3f7d5 1349 /* Write RF_MNGT register */
DiegoOstuni 0:bea5dbf3f7d5 1350 return ST25DV_i2c_WriteRegister( &Rfmngt, ST25DV_RF_MNGT_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1351 }
DiegoOstuni 0:bea5dbf3f7d5 1352
DiegoOstuni 0:bea5dbf3f7d5 1353 /**
DiegoOstuni 0:bea5dbf3f7d5 1354 * @brief Reads the RFDisable register information.
DiegoOstuni 0:bea5dbf3f7d5 1355 * @param pRFDisable Pointer on a ST25DV_EN_STATUS value corresponding to the RF Disable status.
DiegoOstuni 0:bea5dbf3f7d5 1356 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 1357 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 1358 */
DiegoOstuni 0:bea5dbf3f7d5 1359 NFCTAG_StatusTypeDef ST25DV_i2c_GetRFDisable( ST25DV_EN_STATUS * const pRFDisable, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 1360 {
DiegoOstuni 0:bea5dbf3f7d5 1361 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 1362 uint8_t reg_value = 0;
DiegoOstuni 0:bea5dbf3f7d5 1363
DiegoOstuni 0:bea5dbf3f7d5 1364 /* Read actual value of RF_MNGT register */
DiegoOstuni 0:bea5dbf3f7d5 1365 status = ST25DV_i2c_ReadMailboxRegister( &reg_value, ST25DV_RF_MNGT_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1366
DiegoOstuni 0:bea5dbf3f7d5 1367 /* Extract RFDisable information */
DiegoOstuni 0:bea5dbf3f7d5 1368 if( status == NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 1369 {
DiegoOstuni 0:bea5dbf3f7d5 1370 if( (reg_value & ST25DV_RF_MNGT_RFDIS_MASK) == ST25DV_RF_MNGT_RFDIS_MASK )
DiegoOstuni 0:bea5dbf3f7d5 1371 {
DiegoOstuni 0:bea5dbf3f7d5 1372 *pRFDisable = ST25DV_ENABLE;
DiegoOstuni 0:bea5dbf3f7d5 1373 }
DiegoOstuni 0:bea5dbf3f7d5 1374 else
DiegoOstuni 0:bea5dbf3f7d5 1375 {
DiegoOstuni 0:bea5dbf3f7d5 1376 *pRFDisable = ST25DV_DISABLE;
DiegoOstuni 0:bea5dbf3f7d5 1377 }
DiegoOstuni 0:bea5dbf3f7d5 1378 return NFCTAG_OK;
DiegoOstuni 0:bea5dbf3f7d5 1379 }
DiegoOstuni 0:bea5dbf3f7d5 1380
DiegoOstuni 0:bea5dbf3f7d5 1381 return status;
DiegoOstuni 0:bea5dbf3f7d5 1382 }
DiegoOstuni 0:bea5dbf3f7d5 1383
DiegoOstuni 0:bea5dbf3f7d5 1384 /**
DiegoOstuni 0:bea5dbf3f7d5 1385 * @brief Sets the RF Disable configuration.
DiegoOstuni 0:bea5dbf3f7d5 1386 * @details Needs the I2C Password presentation to be effective.7
DiegoOstuni 0:bea5dbf3f7d5 1387 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 1388 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 1389 */
DiegoOstuni 0:bea5dbf3f7d5 1390 NFCTAG_StatusTypeDef ST25DV_i2c_SetRFDisable( I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 1391 {
DiegoOstuni 0:bea5dbf3f7d5 1392 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 1393 uint8_t reg_value = 0;
DiegoOstuni 0:bea5dbf3f7d5 1394
DiegoOstuni 0:bea5dbf3f7d5 1395 /* Read actual value of RF_RMNGT register */
DiegoOstuni 0:bea5dbf3f7d5 1396 status = ST25DV_i2c_ReadRegister( &reg_value, ST25DV_RF_MNGT_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1397 if( status != NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 1398 {
DiegoOstuni 0:bea5dbf3f7d5 1399 return status;
DiegoOstuni 0:bea5dbf3f7d5 1400 }
DiegoOstuni 0:bea5dbf3f7d5 1401
DiegoOstuni 0:bea5dbf3f7d5 1402 /* Update RF Disable field configuration */
DiegoOstuni 0:bea5dbf3f7d5 1403 reg_value |= ST25DV_RF_MNGT_RFDIS_MASK;
DiegoOstuni 0:bea5dbf3f7d5 1404
DiegoOstuni 0:bea5dbf3f7d5 1405 /* Write RF_MNGT register */
DiegoOstuni 0:bea5dbf3f7d5 1406 return ST25DV_i2c_WriteRegister( &reg_value, ST25DV_RF_MNGT_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1407 }
DiegoOstuni 0:bea5dbf3f7d5 1408
DiegoOstuni 0:bea5dbf3f7d5 1409 /**
DiegoOstuni 0:bea5dbf3f7d5 1410 * @brief Resets the RF Disable configuration
DiegoOstuni 0:bea5dbf3f7d5 1411 * @details Needs the I2C Password presentation to be effective.
DiegoOstuni 0:bea5dbf3f7d5 1412 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 1413 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 1414 */
DiegoOstuni 0:bea5dbf3f7d5 1415 NFCTAG_StatusTypeDef ST25DV_i2c_ResetRFDisable( I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 1416 {
DiegoOstuni 0:bea5dbf3f7d5 1417 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 1418 uint8_t reg_value = 0;
DiegoOstuni 0:bea5dbf3f7d5 1419
DiegoOstuni 0:bea5dbf3f7d5 1420 /* Read actual value of RF_RMNGT register */
DiegoOstuni 0:bea5dbf3f7d5 1421 status = ST25DV_i2c_ReadRegister( &reg_value, ST25DV_RF_MNGT_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1422 if( status != NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 1423 {
DiegoOstuni 0:bea5dbf3f7d5 1424 return status;
DiegoOstuni 0:bea5dbf3f7d5 1425 }
DiegoOstuni 0:bea5dbf3f7d5 1426
DiegoOstuni 0:bea5dbf3f7d5 1427 /* Update RF Disable field configuration */
DiegoOstuni 0:bea5dbf3f7d5 1428 reg_value &= ST25DV_RF_MNGT_RFDIS_FIELD;
DiegoOstuni 0:bea5dbf3f7d5 1429
DiegoOstuni 0:bea5dbf3f7d5 1430 /* Write RF_MNGT register */
DiegoOstuni 0:bea5dbf3f7d5 1431 return ST25DV_i2c_WriteRegister( &reg_value, ST25DV_RF_MNGT_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1432 }
DiegoOstuni 0:bea5dbf3f7d5 1433
DiegoOstuni 0:bea5dbf3f7d5 1434 /**
DiegoOstuni 0:bea5dbf3f7d5 1435 * @brief Reads the RFSleep register information.
DiegoOstuni 0:bea5dbf3f7d5 1436 * @param pRFSleep Pointer on a ST25DV_EN_STATUS value corresponding to the RF Sleep status.
DiegoOstuni 0:bea5dbf3f7d5 1437 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 1438 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 1439 */
DiegoOstuni 0:bea5dbf3f7d5 1440 NFCTAG_StatusTypeDef ST25DV_i2c_GetRFSleep( ST25DV_EN_STATUS * const pRFSleep, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 1441 {
DiegoOstuni 0:bea5dbf3f7d5 1442 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 1443 uint8_t reg_value = 0;
DiegoOstuni 0:bea5dbf3f7d5 1444
DiegoOstuni 0:bea5dbf3f7d5 1445 /* Read actual value of RF_MNGT register */
DiegoOstuni 0:bea5dbf3f7d5 1446 status = ST25DV_i2c_ReadMailboxRegister( &reg_value, ST25DV_RF_MNGT_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1447
DiegoOstuni 0:bea5dbf3f7d5 1448 /* Extract RFSleep information */
DiegoOstuni 0:bea5dbf3f7d5 1449 if( status == NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 1450 {
DiegoOstuni 0:bea5dbf3f7d5 1451 if( (reg_value & ST25DV_RF_MNGT_RFDIS_MASK) == ST25DV_RF_MNGT_RFDIS_MASK )
DiegoOstuni 0:bea5dbf3f7d5 1452 {
DiegoOstuni 0:bea5dbf3f7d5 1453 *pRFSleep = ST25DV_ENABLE;
DiegoOstuni 0:bea5dbf3f7d5 1454 }
DiegoOstuni 0:bea5dbf3f7d5 1455 else
DiegoOstuni 0:bea5dbf3f7d5 1456 {
DiegoOstuni 0:bea5dbf3f7d5 1457 *pRFSleep = ST25DV_DISABLE;
DiegoOstuni 0:bea5dbf3f7d5 1458 }
DiegoOstuni 0:bea5dbf3f7d5 1459 return NFCTAG_OK;
DiegoOstuni 0:bea5dbf3f7d5 1460 }
DiegoOstuni 0:bea5dbf3f7d5 1461
DiegoOstuni 0:bea5dbf3f7d5 1462 return status;
DiegoOstuni 0:bea5dbf3f7d5 1463 }
DiegoOstuni 0:bea5dbf3f7d5 1464
DiegoOstuni 0:bea5dbf3f7d5 1465 /**
DiegoOstuni 0:bea5dbf3f7d5 1466 * @brief Sets the RF Sleep configuration.
DiegoOstuni 0:bea5dbf3f7d5 1467 * @details Needs the I2C Password presentation to be effective.
DiegoOstuni 0:bea5dbf3f7d5 1468 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 1469 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 1470 */
DiegoOstuni 0:bea5dbf3f7d5 1471 NFCTAG_StatusTypeDef ST25DV_i2c_SetRFSleep( I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 1472 {
DiegoOstuni 0:bea5dbf3f7d5 1473 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 1474 uint8_t reg_value = 0;
DiegoOstuni 0:bea5dbf3f7d5 1475
DiegoOstuni 0:bea5dbf3f7d5 1476 /* Read actual value of RF_RMNGT register */
DiegoOstuni 0:bea5dbf3f7d5 1477 status = ST25DV_i2c_ReadRegister( &reg_value, ST25DV_RF_MNGT_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1478 if( status != NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 1479 {
DiegoOstuni 0:bea5dbf3f7d5 1480 return status;
DiegoOstuni 0:bea5dbf3f7d5 1481 }
DiegoOstuni 0:bea5dbf3f7d5 1482
DiegoOstuni 0:bea5dbf3f7d5 1483 /* Update RF Sleep field configuration */
DiegoOstuni 0:bea5dbf3f7d5 1484 reg_value |= ST25DV_RF_MNGT_RFSLEEP_MASK;
DiegoOstuni 0:bea5dbf3f7d5 1485
DiegoOstuni 0:bea5dbf3f7d5 1486 /* Write RF_MNGT register */
DiegoOstuni 0:bea5dbf3f7d5 1487 return ST25DV_i2c_WriteRegister( &reg_value, ST25DV_RF_MNGT_REG, 1,mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1488 }
DiegoOstuni 0:bea5dbf3f7d5 1489
DiegoOstuni 0:bea5dbf3f7d5 1490 /**
DiegoOstuni 0:bea5dbf3f7d5 1491 * @brief Resets the RF Sleep configuration.
DiegoOstuni 0:bea5dbf3f7d5 1492 * @details Needs the I2C Password presentation to be effective.
DiegoOstuni 0:bea5dbf3f7d5 1493 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 1494 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 1495 */
DiegoOstuni 0:bea5dbf3f7d5 1496 NFCTAG_StatusTypeDef ST25DV_i2c_ResetRFSleep( I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 1497 {
DiegoOstuni 0:bea5dbf3f7d5 1498 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 1499 uint8_t reg_value = 0;
DiegoOstuni 0:bea5dbf3f7d5 1500
DiegoOstuni 0:bea5dbf3f7d5 1501 /* Read actual value of RF_RMNGT register */
DiegoOstuni 0:bea5dbf3f7d5 1502 status = ST25DV_i2c_ReadRegister( &reg_value, ST25DV_RF_MNGT_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1503 if( status != NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 1504 {
DiegoOstuni 0:bea5dbf3f7d5 1505 return status;
DiegoOstuni 0:bea5dbf3f7d5 1506 }
DiegoOstuni 0:bea5dbf3f7d5 1507
DiegoOstuni 0:bea5dbf3f7d5 1508 /* Update RF Sleep field configuration */
DiegoOstuni 0:bea5dbf3f7d5 1509 reg_value &= ST25DV_RF_MNGT_RFSLEEP_FIELD;
DiegoOstuni 0:bea5dbf3f7d5 1510
DiegoOstuni 0:bea5dbf3f7d5 1511 /* Write RF_MNGT register */
DiegoOstuni 0:bea5dbf3f7d5 1512 return ST25DV_i2c_WriteRegister( &reg_value, ST25DV_RF_MNGT_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1513 }
DiegoOstuni 0:bea5dbf3f7d5 1514
DiegoOstuni 0:bea5dbf3f7d5 1515 /**
DiegoOstuni 0:bea5dbf3f7d5 1516 * @brief Reads the Mailbox mode.
DiegoOstuni 0:bea5dbf3f7d5 1517 * @param pMB_mode Pointer on a ST25DV_EH_MODE_STATUS value used to return the Mailbox mode.
DiegoOstuni 0:bea5dbf3f7d5 1518 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 1519 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 1520 */
DiegoOstuni 0:bea5dbf3f7d5 1521 NFCTAG_StatusTypeDef ST25DV_i2c_ReadMBMode( ST25DV_EN_STATUS * const pMB_mode, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 1522 {
DiegoOstuni 0:bea5dbf3f7d5 1523 uint8_t reg_value;
DiegoOstuni 0:bea5dbf3f7d5 1524 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 1525
DiegoOstuni 0:bea5dbf3f7d5 1526 /* Read actual value of MB_MODE register */
DiegoOstuni 0:bea5dbf3f7d5 1527 status = ST25DV_i2c_ReadRegister( &reg_value, ST25DV_MB_MODE_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1528 if( status != NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 1529 {
DiegoOstuni 0:bea5dbf3f7d5 1530 return status;
DiegoOstuni 0:bea5dbf3f7d5 1531 }
DiegoOstuni 0:bea5dbf3f7d5 1532
DiegoOstuni 0:bea5dbf3f7d5 1533 /* Extract Mailbox mode status */
DiegoOstuni 0:bea5dbf3f7d5 1534 if( (reg_value & ST25DV_MB_MODE_RW_MASK) == ST25DV_MB_MODE_RW_MASK )
DiegoOstuni 0:bea5dbf3f7d5 1535 {
DiegoOstuni 0:bea5dbf3f7d5 1536 *pMB_mode = ST25DV_ENABLE;
DiegoOstuni 0:bea5dbf3f7d5 1537 }
DiegoOstuni 0:bea5dbf3f7d5 1538 else
DiegoOstuni 0:bea5dbf3f7d5 1539 {
DiegoOstuni 0:bea5dbf3f7d5 1540 *pMB_mode = ST25DV_DISABLE;
DiegoOstuni 0:bea5dbf3f7d5 1541 }
DiegoOstuni 0:bea5dbf3f7d5 1542
DiegoOstuni 0:bea5dbf3f7d5 1543 return NFCTAG_OK;
DiegoOstuni 0:bea5dbf3f7d5 1544 }
DiegoOstuni 0:bea5dbf3f7d5 1545
DiegoOstuni 0:bea5dbf3f7d5 1546 /**
DiegoOstuni 0:bea5dbf3f7d5 1547 * @brief Sets the Mailbox mode.
DiegoOstuni 0:bea5dbf3f7d5 1548 * @details Needs the I2C Password presentation to be effective.
DiegoOstuni 0:bea5dbf3f7d5 1549 * @param MB_mode ST25DV_EN_STATUS value corresponding to the Mailbox mode to be set.
DiegoOstuni 0:bea5dbf3f7d5 1550 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 1551 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 1552 */
DiegoOstuni 0:bea5dbf3f7d5 1553 NFCTAG_StatusTypeDef ST25DV_i2c_WriteMBMode( const ST25DV_EN_STATUS MB_mode, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 1554 {
DiegoOstuni 0:bea5dbf3f7d5 1555 uint8_t reg_value;
DiegoOstuni 0:bea5dbf3f7d5 1556
DiegoOstuni 0:bea5dbf3f7d5 1557 /* Update Mailbox mode status */
DiegoOstuni 0:bea5dbf3f7d5 1558 reg_value = (uint8_t)MB_mode;
DiegoOstuni 0:bea5dbf3f7d5 1559
DiegoOstuni 0:bea5dbf3f7d5 1560 /* Write MB_MODE register */
DiegoOstuni 0:bea5dbf3f7d5 1561 return ST25DV_i2c_WriteRegister( &reg_value, ST25DV_MB_MODE_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1562 }
DiegoOstuni 0:bea5dbf3f7d5 1563
DiegoOstuni 0:bea5dbf3f7d5 1564 /**
DiegoOstuni 0:bea5dbf3f7d5 1565 * @brief Reads the Mailbox watchdog duration coefficient.
DiegoOstuni 0:bea5dbf3f7d5 1566 * @param pWdgDelay Pointer on a uint8_t used to return the watchdog duration coefficient.
DiegoOstuni 0:bea5dbf3f7d5 1567 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 1568 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 1569 */
DiegoOstuni 0:bea5dbf3f7d5 1570 NFCTAG_StatusTypeDef ST25DV_i2c_ReadMBWDG( uint8_t * const pWdgDelay, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 1571 {
DiegoOstuni 0:bea5dbf3f7d5 1572 uint8_t reg_value;
DiegoOstuni 0:bea5dbf3f7d5 1573 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 1574
DiegoOstuni 0:bea5dbf3f7d5 1575 /* Read actual value of MB_WDG register */
DiegoOstuni 0:bea5dbf3f7d5 1576 status = ST25DV_i2c_ReadRegister( &reg_value, ST25DV_MB_WDG_REG, 1 , mi2cChannel);
DiegoOstuni 0:bea5dbf3f7d5 1577 if( status != NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 1578 {
DiegoOstuni 0:bea5dbf3f7d5 1579 return status;
DiegoOstuni 0:bea5dbf3f7d5 1580 }
DiegoOstuni 0:bea5dbf3f7d5 1581
DiegoOstuni 0:bea5dbf3f7d5 1582 /* Extract watchdog coefficient delay configuration */
DiegoOstuni 0:bea5dbf3f7d5 1583 *pWdgDelay = (reg_value & ST25DV_MB_WDG_DELAY_MASK) >> ST25DV_MB_WDG_DELAY_SHIFT;
DiegoOstuni 0:bea5dbf3f7d5 1584
DiegoOstuni 0:bea5dbf3f7d5 1585 return NFCTAG_OK;
DiegoOstuni 0:bea5dbf3f7d5 1586 }
DiegoOstuni 0:bea5dbf3f7d5 1587
DiegoOstuni 0:bea5dbf3f7d5 1588 /**
DiegoOstuni 0:bea5dbf3f7d5 1589 * @brief Writes the Mailbox watchdog coefficient delay
DiegoOstuni 0:bea5dbf3f7d5 1590 * @details Needs the I2C Password presentation to be effective.
DiegoOstuni 0:bea5dbf3f7d5 1591 * @param WdgDelay Watchdog duration coefficient to be written (Watch dog duration = MB_WDG*30 ms +/- 6%).
DiegoOstuni 0:bea5dbf3f7d5 1592 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 1593 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 1594 */
DiegoOstuni 0:bea5dbf3f7d5 1595 NFCTAG_StatusTypeDef ST25DV_i2c_WriteMBWDG( const uint8_t WdgDelay, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 1596 {
DiegoOstuni 0:bea5dbf3f7d5 1597 uint8_t reg_value;
DiegoOstuni 0:bea5dbf3f7d5 1598
DiegoOstuni 0:bea5dbf3f7d5 1599 /* Set Watchdog coefficient delay */
DiegoOstuni 0:bea5dbf3f7d5 1600 reg_value = WdgDelay & ST25DV_MB_WDG_DELAY_MASK;
DiegoOstuni 0:bea5dbf3f7d5 1601
DiegoOstuni 0:bea5dbf3f7d5 1602 /* Write MB_MODE register */
DiegoOstuni 0:bea5dbf3f7d5 1603 return ST25DV_i2c_WriteRegister( &reg_value, ST25DV_MB_WDG_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1604 }
DiegoOstuni 0:bea5dbf3f7d5 1605
DiegoOstuni 0:bea5dbf3f7d5 1606 /**
DiegoOstuni 0:bea5dbf3f7d5 1607 * @brief Reads N bytes of data from the Mailbox, starting at the specified byte offset.
DiegoOstuni 0:bea5dbf3f7d5 1608 * @param pData Pointer on the buffer used to return the read data.
DiegoOstuni 0:bea5dbf3f7d5 1609 * @param Offset Offset in the Mailbox memory, byte number to start the read.
DiegoOstuni 0:bea5dbf3f7d5 1610 * @param NbByte Number of bytes to be read.
DiegoOstuni 0:bea5dbf3f7d5 1611 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 1612 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 1613 */
DiegoOstuni 0:bea5dbf3f7d5 1614 NFCTAG_StatusTypeDef ST25DV_i2c_ReadMailboxData( uint8_t * const pData, const uint16_t Offset, const uint16_t NbByte, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 1615 {
DiegoOstuni 0:bea5dbf3f7d5 1616 if( Offset > ST25DV_MAX_MAILBOX_LENGTH )
DiegoOstuni 0:bea5dbf3f7d5 1617 {
DiegoOstuni 0:bea5dbf3f7d5 1618 return NFCTAG_ERROR;
DiegoOstuni 0:bea5dbf3f7d5 1619 }
DiegoOstuni 0:bea5dbf3f7d5 1620
DiegoOstuni 0:bea5dbf3f7d5 1621 /* Read Data in user memory */
DiegoOstuni 0:bea5dbf3f7d5 1622 return ST25DV_IO_MemRead( pData, ST25DV_ADDR_DATA_I2C, ST25DV_MAILBOX_RAM_REG + Offset, NbByte, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1623 }
DiegoOstuni 0:bea5dbf3f7d5 1624
DiegoOstuni 0:bea5dbf3f7d5 1625 /**
DiegoOstuni 0:bea5dbf3f7d5 1626 * @brief Writes N bytes of data in the Mailbox, starting from first Mailbox Address.
DiegoOstuni 0:bea5dbf3f7d5 1627 * @param pData Pointer to the buffer containing the data to be written.
DiegoOstuni 0:bea5dbf3f7d5 1628 * @param NbByte Number of bytes to be written.
DiegoOstuni 0:bea5dbf3f7d5 1629 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 1630 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 1631 */
DiegoOstuni 0:bea5dbf3f7d5 1632 NFCTAG_StatusTypeDef ST25DV_i2c_WriteMailboxData( const uint8_t * const pData, const uint16_t NbByte, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 1633 {
DiegoOstuni 0:bea5dbf3f7d5 1634 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 1635
DiegoOstuni 0:bea5dbf3f7d5 1636 /* ST25DV can write a maximum of 256 bytes in Mailbox */
DiegoOstuni 0:bea5dbf3f7d5 1637 if( NbByte < ST25DV_MAX_MAILBOX_LENGTH )
DiegoOstuni 0:bea5dbf3f7d5 1638 {
DiegoOstuni 0:bea5dbf3f7d5 1639 /* Write NbByte data in memory */
DiegoOstuni 0:bea5dbf3f7d5 1640 status = ST25DV_IO_MemWrite( pData, ST25DV_ADDR_DATA_I2C, ST25DV_MAILBOX_RAM_REG, NbByte, mi2cChannel);
DiegoOstuni 0:bea5dbf3f7d5 1641 }
DiegoOstuni 0:bea5dbf3f7d5 1642 else
DiegoOstuni 0:bea5dbf3f7d5 1643 {
DiegoOstuni 0:bea5dbf3f7d5 1644 status = NFCTAG_ERROR;
DiegoOstuni 0:bea5dbf3f7d5 1645 }
DiegoOstuni 0:bea5dbf3f7d5 1646
DiegoOstuni 0:bea5dbf3f7d5 1647 return status;
DiegoOstuni 0:bea5dbf3f7d5 1648 }
DiegoOstuni 0:bea5dbf3f7d5 1649
DiegoOstuni 0:bea5dbf3f7d5 1650 /**
DiegoOstuni 0:bea5dbf3f7d5 1651 * @brief Reads N bytes from the mailbox registers, starting at the specified I2C address.
DiegoOstuni 0:bea5dbf3f7d5 1652 * @param pData Pointer on the buffer used to return the data.
DiegoOstuni 0:bea5dbf3f7d5 1653 * @param TarAddr I2C memory address to be read.
DiegoOstuni 0:bea5dbf3f7d5 1654 * @param NbByte Number of bytes to be read.
DiegoOstuni 0:bea5dbf3f7d5 1655 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 1656 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 1657 */
DiegoOstuni 0:bea5dbf3f7d5 1658 NFCTAG_StatusTypeDef ST25DV_i2c_ReadMailboxRegister( uint8_t * const pData, const uint16_t TarAddr, const uint16_t NbByte, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 1659 {
DiegoOstuni 0:bea5dbf3f7d5 1660 if( (TarAddr < ST25DV_GPO_DYN_REG) || (TarAddr > ST25DV_MBLEN_DYN_REG) )
DiegoOstuni 0:bea5dbf3f7d5 1661 {
DiegoOstuni 0:bea5dbf3f7d5 1662 return NFCTAG_ERROR;
DiegoOstuni 0:bea5dbf3f7d5 1663 }
DiegoOstuni 0:bea5dbf3f7d5 1664
DiegoOstuni 0:bea5dbf3f7d5 1665 return ST25DV_IO_MemRead( pData, ST25DV_ADDR_DATA_I2C, TarAddr, NbByte, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1666 }
DiegoOstuni 0:bea5dbf3f7d5 1667
DiegoOstuni 0:bea5dbf3f7d5 1668 /**
DiegoOstuni 0:bea5dbf3f7d5 1669 * @brief Writes N bytes to the specified mailbox register.
DiegoOstuni 0:bea5dbf3f7d5 1670 * @param pData Pointer on the data to be written.
DiegoOstuni 0:bea5dbf3f7d5 1671 * @param TarAddr I2C register address to be written.
DiegoOstuni 0:bea5dbf3f7d5 1672 * @param NbByte Number of bytes to be written.
DiegoOstuni 0:bea5dbf3f7d5 1673 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 1674 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 1675 */
DiegoOstuni 0:bea5dbf3f7d5 1676 NFCTAG_StatusTypeDef ST25DV_i2c_WriteMailboxRegister( const uint8_t * const pData, const uint16_t TarAddr, const uint16_t NbByte, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 1677 {
DiegoOstuni 0:bea5dbf3f7d5 1678 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 1679
DiegoOstuni 0:bea5dbf3f7d5 1680 if( (TarAddr < ST25DV_GPO_DYN_REG) || (TarAddr > ST25DV_MBLEN_DYN_REG) )
DiegoOstuni 0:bea5dbf3f7d5 1681 {
DiegoOstuni 0:bea5dbf3f7d5 1682 return NFCTAG_ERROR;
DiegoOstuni 0:bea5dbf3f7d5 1683 }
DiegoOstuni 0:bea5dbf3f7d5 1684
DiegoOstuni 0:bea5dbf3f7d5 1685 /* ST25DV can write a maximum of 256 bytes in Mailbox */
DiegoOstuni 0:bea5dbf3f7d5 1686 if( NbByte < ST25DV_MAX_MAILBOX_LENGTH )
DiegoOstuni 0:bea5dbf3f7d5 1687 {
DiegoOstuni 0:bea5dbf3f7d5 1688 /* Write NbByte data in memory */
DiegoOstuni 0:bea5dbf3f7d5 1689 status = ST25DV_IO_MemWrite( pData, ST25DV_ADDR_DATA_I2C, TarAddr, NbByte, mi2cChannel);
DiegoOstuni 0:bea5dbf3f7d5 1690 }
DiegoOstuni 0:bea5dbf3f7d5 1691 else
DiegoOstuni 0:bea5dbf3f7d5 1692 {
DiegoOstuni 0:bea5dbf3f7d5 1693 status = NFCTAG_ERROR;
DiegoOstuni 0:bea5dbf3f7d5 1694 }
DiegoOstuni 0:bea5dbf3f7d5 1695
DiegoOstuni 0:bea5dbf3f7d5 1696 return status;
DiegoOstuni 0:bea5dbf3f7d5 1697 }
DiegoOstuni 0:bea5dbf3f7d5 1698
DiegoOstuni 0:bea5dbf3f7d5 1699 /**
DiegoOstuni 0:bea5dbf3f7d5 1700 * @brief Reads the status of the security session open register.
DiegoOstuni 0:bea5dbf3f7d5 1701 * @param pSession Pointer on a ST25DV_I2CSSO_STATUS value used to return the session status.
DiegoOstuni 0:bea5dbf3f7d5 1702 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 1703 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 1704 */
DiegoOstuni 0:bea5dbf3f7d5 1705 NFCTAG_StatusTypeDef ST25DV_i2c_ReadI2CSecuritySession_Dyn( ST25DV_I2CSSO_STATUS * const pSession, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 1706 {
DiegoOstuni 0:bea5dbf3f7d5 1707 uint8_t reg_value;
DiegoOstuni 0:bea5dbf3f7d5 1708 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 1709
DiegoOstuni 0:bea5dbf3f7d5 1710 /* Read actual value of I2C_SSO_DYN register */
DiegoOstuni 0:bea5dbf3f7d5 1711 status = ST25DV_i2c_ReadMailboxRegister( &reg_value, ST25DV_I2C_SSO_DYN_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1712 if( status != NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 1713 {
DiegoOstuni 0:bea5dbf3f7d5 1714 return status;
DiegoOstuni 0:bea5dbf3f7d5 1715 }
DiegoOstuni 0:bea5dbf3f7d5 1716
DiegoOstuni 0:bea5dbf3f7d5 1717 /* Extract Open session information */
DiegoOstuni 0:bea5dbf3f7d5 1718 if( (reg_value & ST25DV_I2C_SSO_DYN_I2CSSO_MASK) == ST25DV_I2C_SSO_DYN_I2CSSO_MASK )
DiegoOstuni 0:bea5dbf3f7d5 1719 {
DiegoOstuni 0:bea5dbf3f7d5 1720 *pSession = ST25DV_SESSION_OPEN;
DiegoOstuni 0:bea5dbf3f7d5 1721 }
DiegoOstuni 0:bea5dbf3f7d5 1722 else
DiegoOstuni 0:bea5dbf3f7d5 1723 {
DiegoOstuni 0:bea5dbf3f7d5 1724 *pSession = ST25DV_SESSION_CLOSED;
DiegoOstuni 0:bea5dbf3f7d5 1725 }
DiegoOstuni 0:bea5dbf3f7d5 1726
DiegoOstuni 0:bea5dbf3f7d5 1727 return NFCTAG_OK;
DiegoOstuni 0:bea5dbf3f7d5 1728 }
DiegoOstuni 0:bea5dbf3f7d5 1729
DiegoOstuni 0:bea5dbf3f7d5 1730 /**
DiegoOstuni 0:bea5dbf3f7d5 1731 * @brief Reads the IT status register from the ST25DV.
DiegoOstuni 0:bea5dbf3f7d5 1732 * @param pITStatus Pointer on uint8_t, used to return the IT status, such as:
DiegoOstuni 0:bea5dbf3f7d5 1733 * - RFUSERSTATE = 0x01
DiegoOstuni 0:bea5dbf3f7d5 1734 * - RFBUSY = 0x02
DiegoOstuni 0:bea5dbf3f7d5 1735 * - RFINTERRUPT = 0x04
DiegoOstuni 0:bea5dbf3f7d5 1736 * - FIELDFALLING = 0x08
DiegoOstuni 0:bea5dbf3f7d5 1737 * - FIELDRISING = 0x10
DiegoOstuni 0:bea5dbf3f7d5 1738 * - RFPUTMSG = 0x20
DiegoOstuni 0:bea5dbf3f7d5 1739 * - RFGETMSG = 0x40
DiegoOstuni 0:bea5dbf3f7d5 1740 * - RFWRITE = 0x80
DiegoOstuni 0:bea5dbf3f7d5 1741 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 1742 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 1743 */
DiegoOstuni 0:bea5dbf3f7d5 1744 NFCTAG_StatusTypeDef ST25DV_i2c_ReadITSTStatus_Dyn( uint8_t * const pITStatus, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 1745 {
DiegoOstuni 0:bea5dbf3f7d5 1746 /* Read value of ITStatus register */
DiegoOstuni 0:bea5dbf3f7d5 1747 return ST25DV_i2c_ReadMailboxRegister( pITStatus, ST25DV_ITSTS_DYN_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1748 }
DiegoOstuni 0:bea5dbf3f7d5 1749
DiegoOstuni 0:bea5dbf3f7d5 1750 /**
DiegoOstuni 0:bea5dbf3f7d5 1751 * @brief Read value of dynamic GPO register configuration.
DiegoOstuni 0:bea5dbf3f7d5 1752 * @param pGPO ST25DV_GPO pointer of the dynamic GPO configuration to store.
DiegoOstuni 0:bea5dbf3f7d5 1753 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 1754 * @retval NFCTAG enum status.
DiegoOstuni 0:bea5dbf3f7d5 1755 */
DiegoOstuni 0:bea5dbf3f7d5 1756 NFCTAG_StatusTypeDef ST25DV_i2c_ReadGPO_Dyn( uint8_t *GPOConfig, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 1757 {
DiegoOstuni 0:bea5dbf3f7d5 1758 /* Read actual value of ST25DV_GPO_DYN_REG register */
DiegoOstuni 0:bea5dbf3f7d5 1759 return ST25DV_i2c_ReadMailboxRegister( GPOConfig, ST25DV_GPO_DYN_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1760 }
DiegoOstuni 0:bea5dbf3f7d5 1761
DiegoOstuni 0:bea5dbf3f7d5 1762
DiegoOstuni 0:bea5dbf3f7d5 1763 /**
DiegoOstuni 0:bea5dbf3f7d5 1764 * @brief Get dynamique GPO enable status
DiegoOstuni 0:bea5dbf3f7d5 1765 * @param pGPO_en ST25DV_EN_STATUS pointer of the GPO enable status to store
DiegoOstuni 0:bea5dbf3f7d5 1766 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 1767 * @retval NFCTAG enum status
DiegoOstuni 0:bea5dbf3f7d5 1768 */
DiegoOstuni 0:bea5dbf3f7d5 1769 NFCTAG_StatusTypeDef ST25DV_i2c_GetGPO_en_Dyn( ST25DV_EN_STATUS * const pGPO_en, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 1770 {
DiegoOstuni 0:bea5dbf3f7d5 1771 uint8_t reg_value;
DiegoOstuni 0:bea5dbf3f7d5 1772 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 1773 /* Read actual value of GPO_DYN register */
DiegoOstuni 0:bea5dbf3f7d5 1774 status = ST25DV_i2c_ReadMailboxRegister( &reg_value, ST25DV_GPO_DYN_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1775 if( status != NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 1776 {
DiegoOstuni 0:bea5dbf3f7d5 1777 return status;
DiegoOstuni 0:bea5dbf3f7d5 1778 }
DiegoOstuni 0:bea5dbf3f7d5 1779
DiegoOstuni 0:bea5dbf3f7d5 1780 /* Extract GPO enable status information */
DiegoOstuni 0:bea5dbf3f7d5 1781 if( (reg_value & ST25DV_GPO_DYN_ENABLE_MASK) == ST25DV_GPO_DYN_ENABLE_MASK )
DiegoOstuni 0:bea5dbf3f7d5 1782 {
DiegoOstuni 0:bea5dbf3f7d5 1783 *pGPO_en = ST25DV_ENABLE;
DiegoOstuni 0:bea5dbf3f7d5 1784 }
DiegoOstuni 0:bea5dbf3f7d5 1785 else
DiegoOstuni 0:bea5dbf3f7d5 1786 {
DiegoOstuni 0:bea5dbf3f7d5 1787 *pGPO_en = ST25DV_DISABLE;
DiegoOstuni 0:bea5dbf3f7d5 1788 }
DiegoOstuni 0:bea5dbf3f7d5 1789
DiegoOstuni 0:bea5dbf3f7d5 1790 return NFCTAG_OK;
DiegoOstuni 0:bea5dbf3f7d5 1791 }
DiegoOstuni 0:bea5dbf3f7d5 1792
DiegoOstuni 0:bea5dbf3f7d5 1793 /**
DiegoOstuni 0:bea5dbf3f7d5 1794 * @brief Set dynamique GPO enable configuration.
DiegoOstuni 0:bea5dbf3f7d5 1795 * @param None No parameters.
DiegoOstuni 0:bea5dbf3f7d5 1796 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 1797 * @retval NFCTAG enum status.
DiegoOstuni 0:bea5dbf3f7d5 1798 */
DiegoOstuni 0:bea5dbf3f7d5 1799 NFCTAG_StatusTypeDef ST25DV_i2c_SetGPO_en_Dyn( I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 1800 {
DiegoOstuni 0:bea5dbf3f7d5 1801 uint8_t reg_value;
DiegoOstuni 0:bea5dbf3f7d5 1802 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 1803
DiegoOstuni 0:bea5dbf3f7d5 1804 /* Read actual value of GPO_DYN register */
DiegoOstuni 0:bea5dbf3f7d5 1805 status = ST25DV_i2c_ReadMailboxRegister( &reg_value, ST25DV_GPO_DYN_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1806 if( status != NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 1807 {
DiegoOstuni 0:bea5dbf3f7d5 1808 return status;
DiegoOstuni 0:bea5dbf3f7d5 1809 }
DiegoOstuni 0:bea5dbf3f7d5 1810
DiegoOstuni 0:bea5dbf3f7d5 1811 /* Update GPO enable configuration */
DiegoOstuni 0:bea5dbf3f7d5 1812 reg_value |= ST25DV_GPO_DYN_ENABLE_MASK;
DiegoOstuni 0:bea5dbf3f7d5 1813
DiegoOstuni 0:bea5dbf3f7d5 1814 /* Write GPO_DYN Register */
DiegoOstuni 0:bea5dbf3f7d5 1815 return ST25DV_i2c_WriteMailboxRegister( &reg_value, ST25DV_GPO_DYN_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1816 }
DiegoOstuni 0:bea5dbf3f7d5 1817
DiegoOstuni 0:bea5dbf3f7d5 1818 /**
DiegoOstuni 0:bea5dbf3f7d5 1819 * @brief Reset dynamique GPO enable configuration.
DiegoOstuni 0:bea5dbf3f7d5 1820 * @param None No parameters.
DiegoOstuni 0:bea5dbf3f7d5 1821 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 1822 * @retval NFCTAG enum status.
DiegoOstuni 0:bea5dbf3f7d5 1823 */
DiegoOstuni 0:bea5dbf3f7d5 1824 NFCTAG_StatusTypeDef ST25DV_i2c_ResetGPO_en_Dyn( I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 1825 {
DiegoOstuni 0:bea5dbf3f7d5 1826 uint8_t reg_value;
DiegoOstuni 0:bea5dbf3f7d5 1827 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 1828
DiegoOstuni 0:bea5dbf3f7d5 1829 /* Read actual value of GPO_DYN register */
DiegoOstuni 0:bea5dbf3f7d5 1830 status = ST25DV_i2c_ReadMailboxRegister( &reg_value, ST25DV_GPO_DYN_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1831 if( status != NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 1832 {
DiegoOstuni 0:bea5dbf3f7d5 1833 return status;
DiegoOstuni 0:bea5dbf3f7d5 1834 }
DiegoOstuni 0:bea5dbf3f7d5 1835
DiegoOstuni 0:bea5dbf3f7d5 1836 /* Update GPO enable configuration */
DiegoOstuni 0:bea5dbf3f7d5 1837 reg_value &= ST25DV_GPO_DYN_ENABLE_FIELD;
DiegoOstuni 0:bea5dbf3f7d5 1838
DiegoOstuni 0:bea5dbf3f7d5 1839 /* Write GPO_DYN Register */
DiegoOstuni 0:bea5dbf3f7d5 1840 return ST25DV_i2c_WriteMailboxRegister( &reg_value, ST25DV_GPO_DYN_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1841 }
DiegoOstuni 0:bea5dbf3f7d5 1842
DiegoOstuni 0:bea5dbf3f7d5 1843 /**
DiegoOstuni 0:bea5dbf3f7d5 1844 * @brief Read value of dynamic EH Ctrl register configuration
DiegoOstuni 0:bea5dbf3f7d5 1845 * @param pEH_CTRL : ST25DV_EH_CTRL pointer of the dynamic EH Ctrl configuration to store
DiegoOstuni 0:bea5dbf3f7d5 1846 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 1847 * @retval NFCTAG enum status
DiegoOstuni 0:bea5dbf3f7d5 1848 */
DiegoOstuni 0:bea5dbf3f7d5 1849 NFCTAG_StatusTypeDef ST25DV_i2c_ReadEHCtrl_Dyn( ST25DV_EH_CTRL * const pEH_CTRL, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 1850 {
DiegoOstuni 0:bea5dbf3f7d5 1851 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 1852 uint8_t reg_value = 0;
DiegoOstuni 0:bea5dbf3f7d5 1853
DiegoOstuni 0:bea5dbf3f7d5 1854 /* Read actual value of ST25DV_EH_CTRL_DYN_REG register */
DiegoOstuni 0:bea5dbf3f7d5 1855 status = ST25DV_i2c_ReadMailboxRegister( &reg_value, ST25DV_EH_CTRL_DYN_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1856
DiegoOstuni 0:bea5dbf3f7d5 1857 if( status == NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 1858 {
DiegoOstuni 0:bea5dbf3f7d5 1859 /* Extract EH EN Mode configuration */
DiegoOstuni 0:bea5dbf3f7d5 1860 if( (reg_value & ST25DV_EH_CTRL_DYN_EH_EN_MASK) == ST25DV_EH_CTRL_DYN_EH_EN_MASK )
DiegoOstuni 0:bea5dbf3f7d5 1861 {
DiegoOstuni 0:bea5dbf3f7d5 1862 pEH_CTRL->EH_EN_Mode = ST25DV_ENABLE;
DiegoOstuni 0:bea5dbf3f7d5 1863 }
DiegoOstuni 0:bea5dbf3f7d5 1864 else
DiegoOstuni 0:bea5dbf3f7d5 1865 {
DiegoOstuni 0:bea5dbf3f7d5 1866 pEH_CTRL->EH_EN_Mode = ST25DV_DISABLE;
DiegoOstuni 0:bea5dbf3f7d5 1867 }
DiegoOstuni 0:bea5dbf3f7d5 1868
DiegoOstuni 0:bea5dbf3f7d5 1869 /* Extract EH_ON configuration */
DiegoOstuni 0:bea5dbf3f7d5 1870 if( (reg_value & ST25DV_EH_CTRL_DYN_EH_ON_MASK) == ST25DV_EH_CTRL_DYN_EH_ON_MASK )
DiegoOstuni 0:bea5dbf3f7d5 1871 {
DiegoOstuni 0:bea5dbf3f7d5 1872 pEH_CTRL->EH_on = ST25DV_ENABLE;
DiegoOstuni 0:bea5dbf3f7d5 1873 }
DiegoOstuni 0:bea5dbf3f7d5 1874 else
DiegoOstuni 0:bea5dbf3f7d5 1875 {
DiegoOstuni 0:bea5dbf3f7d5 1876 pEH_CTRL->EH_on = ST25DV_DISABLE;
DiegoOstuni 0:bea5dbf3f7d5 1877 }
DiegoOstuni 0:bea5dbf3f7d5 1878
DiegoOstuni 0:bea5dbf3f7d5 1879 /* Extract FIELD_ON configuration */
DiegoOstuni 0:bea5dbf3f7d5 1880 if( (reg_value & ST25DV_EH_CTRL_DYN_FIELD_ON_MASK) == ST25DV_EH_CTRL_DYN_FIELD_ON_MASK )
DiegoOstuni 0:bea5dbf3f7d5 1881 {
DiegoOstuni 0:bea5dbf3f7d5 1882 pEH_CTRL->Field_on = ST25DV_ENABLE;
DiegoOstuni 0:bea5dbf3f7d5 1883 }
DiegoOstuni 0:bea5dbf3f7d5 1884 else
DiegoOstuni 0:bea5dbf3f7d5 1885 {
DiegoOstuni 0:bea5dbf3f7d5 1886 pEH_CTRL->Field_on = ST25DV_DISABLE;
DiegoOstuni 0:bea5dbf3f7d5 1887 }
DiegoOstuni 0:bea5dbf3f7d5 1888
DiegoOstuni 0:bea5dbf3f7d5 1889 /* Extract VCC_ON configuration */
DiegoOstuni 0:bea5dbf3f7d5 1890 if( (reg_value & ST25DV_EH_CTRL_DYN_VCC_ON_MASK) == ST25DV_EH_CTRL_DYN_VCC_ON_MASK )
DiegoOstuni 0:bea5dbf3f7d5 1891 {
DiegoOstuni 0:bea5dbf3f7d5 1892 pEH_CTRL->VCC_on = ST25DV_ENABLE;
DiegoOstuni 0:bea5dbf3f7d5 1893 }
DiegoOstuni 0:bea5dbf3f7d5 1894 else
DiegoOstuni 0:bea5dbf3f7d5 1895 {
DiegoOstuni 0:bea5dbf3f7d5 1896 pEH_CTRL->VCC_on = ST25DV_DISABLE;
DiegoOstuni 0:bea5dbf3f7d5 1897 }
DiegoOstuni 0:bea5dbf3f7d5 1898
DiegoOstuni 0:bea5dbf3f7d5 1899 return NFCTAG_OK;
DiegoOstuni 0:bea5dbf3f7d5 1900 }
DiegoOstuni 0:bea5dbf3f7d5 1901
DiegoOstuni 0:bea5dbf3f7d5 1902 return status;
DiegoOstuni 0:bea5dbf3f7d5 1903 }
DiegoOstuni 0:bea5dbf3f7d5 1904
DiegoOstuni 0:bea5dbf3f7d5 1905 /**
DiegoOstuni 0:bea5dbf3f7d5 1906 * @brief Reads the Energy Harvesting dynamic status.
DiegoOstuni 0:bea5dbf3f7d5 1907 * @param pEH_Val Pointer on a ST25DV_EN_STATUS value used to return the Energy Harvesting dynamic status.
DiegoOstuni 0:bea5dbf3f7d5 1908 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 1909 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 1910 */
DiegoOstuni 0:bea5dbf3f7d5 1911 NFCTAG_StatusTypeDef ST25DV_i2c_GetEHENMode_Dyn( ST25DV_EN_STATUS * const pEH_Val, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 1912 {
DiegoOstuni 0:bea5dbf3f7d5 1913 uint8_t reg_value;
DiegoOstuni 0:bea5dbf3f7d5 1914 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 1915
DiegoOstuni 0:bea5dbf3f7d5 1916 /* Read actual value of EH_CTRL_DYN register */
DiegoOstuni 0:bea5dbf3f7d5 1917 status = ST25DV_i2c_ReadMailboxRegister( &reg_value, ST25DV_EH_CTRL_DYN_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1918 if( status != NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 1919 {
DiegoOstuni 0:bea5dbf3f7d5 1920 return status;
DiegoOstuni 0:bea5dbf3f7d5 1921 }
DiegoOstuni 0:bea5dbf3f7d5 1922
DiegoOstuni 0:bea5dbf3f7d5 1923 /* Extract Energy Harvesting status information */
DiegoOstuni 0:bea5dbf3f7d5 1924 if( (reg_value & ST25DV_EH_CTRL_DYN_EH_EN_MASK) == ST25DV_EH_CTRL_DYN_EH_EN_MASK )
DiegoOstuni 0:bea5dbf3f7d5 1925 {
DiegoOstuni 0:bea5dbf3f7d5 1926 *pEH_Val = ST25DV_ENABLE;
DiegoOstuni 0:bea5dbf3f7d5 1927 }
DiegoOstuni 0:bea5dbf3f7d5 1928 else
DiegoOstuni 0:bea5dbf3f7d5 1929 {
DiegoOstuni 0:bea5dbf3f7d5 1930 *pEH_Val = ST25DV_DISABLE;
DiegoOstuni 0:bea5dbf3f7d5 1931 }
DiegoOstuni 0:bea5dbf3f7d5 1932
DiegoOstuni 0:bea5dbf3f7d5 1933 return NFCTAG_OK;
DiegoOstuni 0:bea5dbf3f7d5 1934 }
DiegoOstuni 0:bea5dbf3f7d5 1935
DiegoOstuni 0:bea5dbf3f7d5 1936 /**
DiegoOstuni 0:bea5dbf3f7d5 1937 * @brief Dynamically sets the Energy Harvesting mode.
DiegoOstuni 0:bea5dbf3f7d5 1938 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 1939 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 1940 */
DiegoOstuni 0:bea5dbf3f7d5 1941 NFCTAG_StatusTypeDef ST25DV_i2c_SetEHENMode_Dyn( I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 1942 {
DiegoOstuni 0:bea5dbf3f7d5 1943 uint8_t reg_value;
DiegoOstuni 0:bea5dbf3f7d5 1944 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 1945
DiegoOstuni 0:bea5dbf3f7d5 1946 /* Read actual value of EH_CTRL_DYN register */
DiegoOstuni 0:bea5dbf3f7d5 1947 status = ST25DV_i2c_ReadMailboxRegister( &reg_value, ST25DV_EH_CTRL_DYN_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1948 if( status != NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 1949 {
DiegoOstuni 0:bea5dbf3f7d5 1950 return status;
DiegoOstuni 0:bea5dbf3f7d5 1951 }
DiegoOstuni 0:bea5dbf3f7d5 1952
DiegoOstuni 0:bea5dbf3f7d5 1953 /* Update Energy Harvesting configuration */
DiegoOstuni 0:bea5dbf3f7d5 1954 reg_value |= ST25DV_EH_CTRL_DYN_EH_EN_MASK;
DiegoOstuni 0:bea5dbf3f7d5 1955
DiegoOstuni 0:bea5dbf3f7d5 1956 /* Write EH_CTRL_DYN Register */
DiegoOstuni 0:bea5dbf3f7d5 1957 return ST25DV_i2c_WriteMailboxRegister( &reg_value, ST25DV_EH_CTRL_DYN_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1958 }
DiegoOstuni 0:bea5dbf3f7d5 1959
DiegoOstuni 0:bea5dbf3f7d5 1960 /**
DiegoOstuni 0:bea5dbf3f7d5 1961 * @brief Dynamically unsets the Energy Harvesting mode.
DiegoOstuni 0:bea5dbf3f7d5 1962 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 1963 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 1964 */
DiegoOstuni 0:bea5dbf3f7d5 1965 NFCTAG_StatusTypeDef ST25DV_i2c_ResetEHENMode_Dyn( I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 1966 {
DiegoOstuni 0:bea5dbf3f7d5 1967 uint8_t reg_value;
DiegoOstuni 0:bea5dbf3f7d5 1968 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 1969
DiegoOstuni 0:bea5dbf3f7d5 1970 /* Read actual value of EH_CTRL_DYN register */
DiegoOstuni 0:bea5dbf3f7d5 1971 status = ST25DV_i2c_ReadMailboxRegister( &reg_value, ST25DV_EH_CTRL_DYN_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1972 if( status != NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 1973 {
DiegoOstuni 0:bea5dbf3f7d5 1974 return status;
DiegoOstuni 0:bea5dbf3f7d5 1975 }
DiegoOstuni 0:bea5dbf3f7d5 1976
DiegoOstuni 0:bea5dbf3f7d5 1977 /* Update Energy Harvesting configuration */
DiegoOstuni 0:bea5dbf3f7d5 1978 reg_value &= ST25DV_EH_CTRL_DYN_EH_EN_FIELD;
DiegoOstuni 0:bea5dbf3f7d5 1979
DiegoOstuni 0:bea5dbf3f7d5 1980 /* Write EH_CTRL_DYN Register */
DiegoOstuni 0:bea5dbf3f7d5 1981 return ST25DV_i2c_WriteMailboxRegister( &reg_value, ST25DV_EH_CTRL_DYN_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1982 }
DiegoOstuni 0:bea5dbf3f7d5 1983
DiegoOstuni 0:bea5dbf3f7d5 1984 /**
DiegoOstuni 0:bea5dbf3f7d5 1985 * @brief Reads the EH_ON status from the EH_CTRL_DYN register.
DiegoOstuni 0:bea5dbf3f7d5 1986 * @param pEHON Pointer on a ST25DV_EN_STATUS value used to return the EHON status.
DiegoOstuni 0:bea5dbf3f7d5 1987 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 1988 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 1989 */
DiegoOstuni 0:bea5dbf3f7d5 1990 NFCTAG_StatusTypeDef ST25DV_i2c_GetEHON_Dyn( ST25DV_EN_STATUS * const pEHON, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 1991 {
DiegoOstuni 0:bea5dbf3f7d5 1992 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 1993 uint8_t reg_value = 0;
DiegoOstuni 0:bea5dbf3f7d5 1994
DiegoOstuni 0:bea5dbf3f7d5 1995 /* Read actual value of EH_CTRL_DYN register */
DiegoOstuni 0:bea5dbf3f7d5 1996 status = ST25DV_i2c_ReadMailboxRegister( &reg_value, ST25DV_EH_CTRL_DYN_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 1997
DiegoOstuni 0:bea5dbf3f7d5 1998 /* Extract RF Field information */
DiegoOstuni 0:bea5dbf3f7d5 1999 if( status == NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 2000 {
DiegoOstuni 0:bea5dbf3f7d5 2001 if( (reg_value & ST25DV_EH_CTRL_DYN_EH_ON_MASK) == ST25DV_EH_CTRL_DYN_EH_ON_MASK )
DiegoOstuni 0:bea5dbf3f7d5 2002 {
DiegoOstuni 0:bea5dbf3f7d5 2003 *pEHON = ST25DV_ENABLE;
DiegoOstuni 0:bea5dbf3f7d5 2004 }
DiegoOstuni 0:bea5dbf3f7d5 2005 else
DiegoOstuni 0:bea5dbf3f7d5 2006 {
DiegoOstuni 0:bea5dbf3f7d5 2007 *pEHON = ST25DV_DISABLE;
DiegoOstuni 0:bea5dbf3f7d5 2008 }
DiegoOstuni 0:bea5dbf3f7d5 2009 return NFCTAG_OK;
DiegoOstuni 0:bea5dbf3f7d5 2010 }
DiegoOstuni 0:bea5dbf3f7d5 2011
DiegoOstuni 0:bea5dbf3f7d5 2012 return status;
DiegoOstuni 0:bea5dbf3f7d5 2013 }
DiegoOstuni 0:bea5dbf3f7d5 2014
DiegoOstuni 0:bea5dbf3f7d5 2015 /**
DiegoOstuni 0:bea5dbf3f7d5 2016 * @brief Checks if RF Field is present in front of the ST25DV.
DiegoOstuni 0:bea5dbf3f7d5 2017 * @param pRF_Field Pointer on a ST25DV_FIELD_STATUS value used to return the field presence.
DiegoOstuni 0:bea5dbf3f7d5 2018 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 2019 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 2020 */
DiegoOstuni 0:bea5dbf3f7d5 2021 NFCTAG_StatusTypeDef ST25DV_i2c_GetRFField_Dyn( ST25DV_FIELD_STATUS * const pRF_Field, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 2022 {
DiegoOstuni 0:bea5dbf3f7d5 2023 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 2024 uint8_t reg_value = 0;
DiegoOstuni 0:bea5dbf3f7d5 2025
DiegoOstuni 0:bea5dbf3f7d5 2026 /* Read actual value of EH_CTRL_DYN register */
DiegoOstuni 0:bea5dbf3f7d5 2027 status = ST25DV_i2c_ReadMailboxRegister( &reg_value, ST25DV_EH_CTRL_DYN_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 2028
DiegoOstuni 0:bea5dbf3f7d5 2029 /* Extract RF Field information */
DiegoOstuni 0:bea5dbf3f7d5 2030 if( status == NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 2031 {
DiegoOstuni 0:bea5dbf3f7d5 2032 if( (reg_value & ST25DV_EH_CTRL_DYN_FIELD_ON_MASK) == ST25DV_EH_CTRL_DYN_FIELD_ON_MASK )
DiegoOstuni 0:bea5dbf3f7d5 2033 {
DiegoOstuni 0:bea5dbf3f7d5 2034 *pRF_Field = ST25DV_FIELD_ON;
DiegoOstuni 0:bea5dbf3f7d5 2035 }
DiegoOstuni 0:bea5dbf3f7d5 2036 else
DiegoOstuni 0:bea5dbf3f7d5 2037 {
DiegoOstuni 0:bea5dbf3f7d5 2038 *pRF_Field = ST25DV_FIELD_OFF;
DiegoOstuni 0:bea5dbf3f7d5 2039 }
DiegoOstuni 0:bea5dbf3f7d5 2040 return NFCTAG_OK;
DiegoOstuni 0:bea5dbf3f7d5 2041 }
DiegoOstuni 0:bea5dbf3f7d5 2042
DiegoOstuni 0:bea5dbf3f7d5 2043 return status;
DiegoOstuni 0:bea5dbf3f7d5 2044 }
DiegoOstuni 0:bea5dbf3f7d5 2045
DiegoOstuni 0:bea5dbf3f7d5 2046 /**
DiegoOstuni 0:bea5dbf3f7d5 2047 * @brief Check if VCC is supplying the ST25DV.
DiegoOstuni 0:bea5dbf3f7d5 2048 * @param pVCC ST25DV_VCC_STATUS pointer of the VCC status to store
DiegoOstuni 0:bea5dbf3f7d5 2049 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 2050 * @retval NFCTAG enum status.
DiegoOstuni 0:bea5dbf3f7d5 2051 */
DiegoOstuni 0:bea5dbf3f7d5 2052 NFCTAG_StatusTypeDef ST25DV_i2c_GetVCC_Dyn( ST25DV_VCC_STATUS * const pVCC, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 2053 {
DiegoOstuni 0:bea5dbf3f7d5 2054 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 2055 uint8_t reg_value = 0;
DiegoOstuni 0:bea5dbf3f7d5 2056
DiegoOstuni 0:bea5dbf3f7d5 2057 /* Read actual value of EH_CTRL_DYN register */
DiegoOstuni 0:bea5dbf3f7d5 2058 status = ST25DV_i2c_ReadMailboxRegister( &reg_value, ST25DV_EH_CTRL_DYN_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 2059
DiegoOstuni 0:bea5dbf3f7d5 2060 /* Extract VCC information */
DiegoOstuni 0:bea5dbf3f7d5 2061 if( status == NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 2062 {
DiegoOstuni 0:bea5dbf3f7d5 2063 if( (reg_value & ST25DV_EH_CTRL_DYN_VCC_ON_MASK) == ST25DV_EH_CTRL_DYN_VCC_ON_MASK )
DiegoOstuni 0:bea5dbf3f7d5 2064 {
DiegoOstuni 0:bea5dbf3f7d5 2065 *pVCC = ST25DV_VCC_ON;
DiegoOstuni 0:bea5dbf3f7d5 2066 }
DiegoOstuni 0:bea5dbf3f7d5 2067 else
DiegoOstuni 0:bea5dbf3f7d5 2068 {
DiegoOstuni 0:bea5dbf3f7d5 2069 *pVCC = ST25DV_VCC_OFF;
DiegoOstuni 0:bea5dbf3f7d5 2070 }
DiegoOstuni 0:bea5dbf3f7d5 2071 return NFCTAG_OK;
DiegoOstuni 0:bea5dbf3f7d5 2072 }
DiegoOstuni 0:bea5dbf3f7d5 2073
DiegoOstuni 0:bea5dbf3f7d5 2074 return status;
DiegoOstuni 0:bea5dbf3f7d5 2075 }
DiegoOstuni 0:bea5dbf3f7d5 2076
DiegoOstuni 0:bea5dbf3f7d5 2077 /**
DiegoOstuni 0:bea5dbf3f7d5 2078 * @brief Read value of dynamic RF Management configuration
DiegoOstuni 0:bea5dbf3f7d5 2079 * @param pRF_Mngt : ST25DV_RF_MNGT pointer of the dynamic RF Management configuration to store
DiegoOstuni 0:bea5dbf3f7d5 2080 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 2081 * @retval NFCTAG enum status
DiegoOstuni 0:bea5dbf3f7d5 2082 */
DiegoOstuni 0:bea5dbf3f7d5 2083 NFCTAG_StatusTypeDef ST25DV_i2c_ReadRFMngt_Dyn( ST25DV_RF_MNGT * const pRF_Mngt, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 2084 {
DiegoOstuni 0:bea5dbf3f7d5 2085 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 2086 uint8_t reg_value = 0;
DiegoOstuni 0:bea5dbf3f7d5 2087
DiegoOstuni 0:bea5dbf3f7d5 2088 /* Read actual value of RF_MNGT_DYN register */
DiegoOstuni 0:bea5dbf3f7d5 2089 status = ST25DV_i2c_ReadMailboxRegister( &reg_value, ST25DV_RF_MNGT_DYN_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 2090
DiegoOstuni 0:bea5dbf3f7d5 2091 if( status == NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 2092 {
DiegoOstuni 0:bea5dbf3f7d5 2093 /* Extract RF Disable configuration */
DiegoOstuni 0:bea5dbf3f7d5 2094 if( (reg_value & ST25DV_RF_MNGT_DYN_RFDIS_MASK) == ST25DV_RF_MNGT_DYN_RFDIS_MASK )
DiegoOstuni 0:bea5dbf3f7d5 2095 {
DiegoOstuni 0:bea5dbf3f7d5 2096 pRF_Mngt->RfDisable = ST25DV_ENABLE;
DiegoOstuni 0:bea5dbf3f7d5 2097 }
DiegoOstuni 0:bea5dbf3f7d5 2098 else
DiegoOstuni 0:bea5dbf3f7d5 2099 {
DiegoOstuni 0:bea5dbf3f7d5 2100 pRF_Mngt->RfDisable = ST25DV_DISABLE;
DiegoOstuni 0:bea5dbf3f7d5 2101 }
DiegoOstuni 0:bea5dbf3f7d5 2102
DiegoOstuni 0:bea5dbf3f7d5 2103 /* Extract RF Sleep configuration */
DiegoOstuni 0:bea5dbf3f7d5 2104 if( (reg_value & ST25DV_RF_MNGT_DYN_RFSLEEP_MASK) == ST25DV_RF_MNGT_DYN_RFSLEEP_MASK )
DiegoOstuni 0:bea5dbf3f7d5 2105 {
DiegoOstuni 0:bea5dbf3f7d5 2106 pRF_Mngt->RfSleep = ST25DV_ENABLE;
DiegoOstuni 0:bea5dbf3f7d5 2107 }
DiegoOstuni 0:bea5dbf3f7d5 2108 else
DiegoOstuni 0:bea5dbf3f7d5 2109 {
DiegoOstuni 0:bea5dbf3f7d5 2110 pRF_Mngt->RfSleep = ST25DV_DISABLE;
DiegoOstuni 0:bea5dbf3f7d5 2111 }
DiegoOstuni 0:bea5dbf3f7d5 2112
DiegoOstuni 0:bea5dbf3f7d5 2113 return NFCTAG_OK;
DiegoOstuni 0:bea5dbf3f7d5 2114 }
DiegoOstuni 0:bea5dbf3f7d5 2115
DiegoOstuni 0:bea5dbf3f7d5 2116 return status;
DiegoOstuni 0:bea5dbf3f7d5 2117 }
DiegoOstuni 0:bea5dbf3f7d5 2118
DiegoOstuni 0:bea5dbf3f7d5 2119 /**
DiegoOstuni 0:bea5dbf3f7d5 2120 * @brief Writes a value to the RF Management dynamic register.
DiegoOstuni 0:bea5dbf3f7d5 2121 * @param RF_Mngt Value to be written to the RF Management dynamic register.
DiegoOstuni 0:bea5dbf3f7d5 2122 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 2123 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 2124 */
DiegoOstuni 0:bea5dbf3f7d5 2125 NFCTAG_StatusTypeDef ST25DV_i2c_WriteRFMngt_Dyn( const uint8_t RF_Mngt, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 2126 {
DiegoOstuni 0:bea5dbf3f7d5 2127 /* Write value to RF_MNGT_DYN register */
DiegoOstuni 0:bea5dbf3f7d5 2128 return ST25DV_i2c_WriteMailboxRegister( &RF_Mngt, ST25DV_RF_MNGT_DYN_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 2129 }
DiegoOstuni 0:bea5dbf3f7d5 2130
DiegoOstuni 0:bea5dbf3f7d5 2131 /**
DiegoOstuni 0:bea5dbf3f7d5 2132 * @brief Reads the RFDisable dynamic register information.
DiegoOstuni 0:bea5dbf3f7d5 2133 * @param pRFDisable Pointer on a ST25DV_EN_STATUS value used to return the RF Disable state.
DiegoOstuni 0:bea5dbf3f7d5 2134 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 2135 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 2136 */
DiegoOstuni 0:bea5dbf3f7d5 2137 NFCTAG_StatusTypeDef ST25DV_i2c_GetRFDisable_Dyn( ST25DV_EN_STATUS * const pRFDisable, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 2138 {
DiegoOstuni 0:bea5dbf3f7d5 2139 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 2140 uint8_t reg_value = 0;
DiegoOstuni 0:bea5dbf3f7d5 2141
DiegoOstuni 0:bea5dbf3f7d5 2142 /* Read actual value of RF_MNGT_DYN register */
DiegoOstuni 0:bea5dbf3f7d5 2143 status = ST25DV_i2c_ReadMailboxRegister( &reg_value, ST25DV_RF_MNGT_DYN_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 2144
DiegoOstuni 0:bea5dbf3f7d5 2145 /* Extract RFDisable information */
DiegoOstuni 0:bea5dbf3f7d5 2146 if( status == NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 2147 {
DiegoOstuni 0:bea5dbf3f7d5 2148 if( (reg_value & ST25DV_RF_MNGT_DYN_RFDIS_MASK) == ST25DV_RF_MNGT_DYN_RFDIS_MASK )
DiegoOstuni 0:bea5dbf3f7d5 2149 {
DiegoOstuni 0:bea5dbf3f7d5 2150 *pRFDisable = ST25DV_ENABLE;
DiegoOstuni 0:bea5dbf3f7d5 2151 }
DiegoOstuni 0:bea5dbf3f7d5 2152 else
DiegoOstuni 0:bea5dbf3f7d5 2153 {
DiegoOstuni 0:bea5dbf3f7d5 2154 *pRFDisable = ST25DV_DISABLE;
DiegoOstuni 0:bea5dbf3f7d5 2155 }
DiegoOstuni 0:bea5dbf3f7d5 2156 return NFCTAG_OK;
DiegoOstuni 0:bea5dbf3f7d5 2157 }
DiegoOstuni 0:bea5dbf3f7d5 2158
DiegoOstuni 0:bea5dbf3f7d5 2159 return status;
DiegoOstuni 0:bea5dbf3f7d5 2160 }
DiegoOstuni 0:bea5dbf3f7d5 2161
DiegoOstuni 0:bea5dbf3f7d5 2162 /**
DiegoOstuni 0:bea5dbf3f7d5 2163 * @brief Sets the RF Disable dynamic configuration.
DiegoOstuni 0:bea5dbf3f7d5 2164 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 2165 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 2166 */
DiegoOstuni 0:bea5dbf3f7d5 2167 NFCTAG_StatusTypeDef ST25DV_i2c_SetRFDisable_Dyn( I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 2168 {
DiegoOstuni 0:bea5dbf3f7d5 2169 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 2170 uint8_t reg_value = 0;
DiegoOstuni 0:bea5dbf3f7d5 2171
DiegoOstuni 0:bea5dbf3f7d5 2172 /* Read actual value of RF_MNGT_DYN register */
DiegoOstuni 0:bea5dbf3f7d5 2173 status = ST25DV_i2c_ReadMailboxRegister( &reg_value, ST25DV_RF_MNGT_DYN_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 2174 if( status != NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 2175 {
DiegoOstuni 0:bea5dbf3f7d5 2176 return status;
DiegoOstuni 0:bea5dbf3f7d5 2177 }
DiegoOstuni 0:bea5dbf3f7d5 2178
DiegoOstuni 0:bea5dbf3f7d5 2179 /* Update dynamic RF Disable field */
DiegoOstuni 0:bea5dbf3f7d5 2180 reg_value |= ST25DV_RF_MNGT_DYN_RFDIS_MASK;
DiegoOstuni 0:bea5dbf3f7d5 2181
DiegoOstuni 0:bea5dbf3f7d5 2182 /* Write RF_MNGT_DYN register */
DiegoOstuni 0:bea5dbf3f7d5 2183 return ST25DV_i2c_WriteMailboxRegister( &reg_value, ST25DV_RF_MNGT_DYN_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 2184 }
DiegoOstuni 0:bea5dbf3f7d5 2185
DiegoOstuni 0:bea5dbf3f7d5 2186 /**
DiegoOstuni 0:bea5dbf3f7d5 2187 * @brief Unsets the RF Disable dynamic configuration.
DiegoOstuni 0:bea5dbf3f7d5 2188 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 2189 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 2190 */
DiegoOstuni 0:bea5dbf3f7d5 2191 NFCTAG_StatusTypeDef ST25DV_i2c_ResetRFDisable_Dyn( I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 2192 {
DiegoOstuni 0:bea5dbf3f7d5 2193 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 2194 uint8_t reg_value = 0;
DiegoOstuni 0:bea5dbf3f7d5 2195
DiegoOstuni 0:bea5dbf3f7d5 2196 /* Read actual value of RF_MNGT_DYN register */
DiegoOstuni 0:bea5dbf3f7d5 2197 status = ST25DV_i2c_ReadMailboxRegister( &reg_value, ST25DV_RF_MNGT_DYN_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 2198 if( status != NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 2199 {
DiegoOstuni 0:bea5dbf3f7d5 2200 return status;
DiegoOstuni 0:bea5dbf3f7d5 2201 }
DiegoOstuni 0:bea5dbf3f7d5 2202
DiegoOstuni 0:bea5dbf3f7d5 2203 /* Update dynamic RF Disable field configuration */
DiegoOstuni 0:bea5dbf3f7d5 2204 reg_value &= ST25DV_RF_MNGT_DYN_RFDIS_FIELD;
DiegoOstuni 0:bea5dbf3f7d5 2205
DiegoOstuni 0:bea5dbf3f7d5 2206 /* Write RF_MNGT_DYN register */
DiegoOstuni 0:bea5dbf3f7d5 2207 return ST25DV_i2c_WriteMailboxRegister( &reg_value, ST25DV_RF_MNGT_DYN_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 2208 }
DiegoOstuni 0:bea5dbf3f7d5 2209
DiegoOstuni 0:bea5dbf3f7d5 2210 /**
DiegoOstuni 0:bea5dbf3f7d5 2211 * @brief Reads the RFSleep dynamic register information.
DiegoOstuni 0:bea5dbf3f7d5 2212 * @param pRFSleep Pointer on a ST25DV_EN_STATUS values used to return the RF Sleep state.
DiegoOstuni 0:bea5dbf3f7d5 2213 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 2214 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 2215 */
DiegoOstuni 0:bea5dbf3f7d5 2216 NFCTAG_StatusTypeDef ST25DV_i2c_GetRFSleep_Dyn( ST25DV_EN_STATUS * const pRFSleep, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 2217 {
DiegoOstuni 0:bea5dbf3f7d5 2218 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 2219 uint8_t reg_value = 0;
DiegoOstuni 0:bea5dbf3f7d5 2220
DiegoOstuni 0:bea5dbf3f7d5 2221 /* Read actual value of RF_MNGT_DYN register */
DiegoOstuni 0:bea5dbf3f7d5 2222 status = ST25DV_i2c_ReadMailboxRegister( &reg_value, ST25DV_RF_MNGT_DYN_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 2223
DiegoOstuni 0:bea5dbf3f7d5 2224 /* Extract RFSleep information */
DiegoOstuni 0:bea5dbf3f7d5 2225 if( status == NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 2226 {
DiegoOstuni 0:bea5dbf3f7d5 2227 if( (reg_value & ST25DV_RF_MNGT_DYN_RFDIS_MASK) == ST25DV_RF_MNGT_DYN_RFDIS_MASK )
DiegoOstuni 0:bea5dbf3f7d5 2228 {
DiegoOstuni 0:bea5dbf3f7d5 2229 *pRFSleep = ST25DV_ENABLE;
DiegoOstuni 0:bea5dbf3f7d5 2230 }
DiegoOstuni 0:bea5dbf3f7d5 2231 else
DiegoOstuni 0:bea5dbf3f7d5 2232 {
DiegoOstuni 0:bea5dbf3f7d5 2233 *pRFSleep = ST25DV_DISABLE;
DiegoOstuni 0:bea5dbf3f7d5 2234 }
DiegoOstuni 0:bea5dbf3f7d5 2235 return NFCTAG_OK;
DiegoOstuni 0:bea5dbf3f7d5 2236 }
DiegoOstuni 0:bea5dbf3f7d5 2237
DiegoOstuni 0:bea5dbf3f7d5 2238 return status;
DiegoOstuni 0:bea5dbf3f7d5 2239 }
DiegoOstuni 0:bea5dbf3f7d5 2240
DiegoOstuni 0:bea5dbf3f7d5 2241 /**
DiegoOstuni 0:bea5dbf3f7d5 2242 * @brief Sets the RF Sleep dynamic configuration.
DiegoOstuni 0:bea5dbf3f7d5 2243 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 2244 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 2245 */
DiegoOstuni 0:bea5dbf3f7d5 2246 NFCTAG_StatusTypeDef ST25DV_i2c_SetRFSleep_Dyn( I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 2247 {
DiegoOstuni 0:bea5dbf3f7d5 2248 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 2249 uint8_t reg_value = 0;
DiegoOstuni 0:bea5dbf3f7d5 2250
DiegoOstuni 0:bea5dbf3f7d5 2251 /* Read actual value of RF_MNGT_DYN register */
DiegoOstuni 0:bea5dbf3f7d5 2252 status = ST25DV_i2c_ReadMailboxRegister( &reg_value, ST25DV_RF_MNGT_DYN_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 2253 if( status != NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 2254 {
DiegoOstuni 0:bea5dbf3f7d5 2255 return status;
DiegoOstuni 0:bea5dbf3f7d5 2256 }
DiegoOstuni 0:bea5dbf3f7d5 2257
DiegoOstuni 0:bea5dbf3f7d5 2258 /* Update dynamic RF Disable field configuration */
DiegoOstuni 0:bea5dbf3f7d5 2259 reg_value |= ST25DV_RF_MNGT_DYN_RFSLEEP_MASK;
DiegoOstuni 0:bea5dbf3f7d5 2260
DiegoOstuni 0:bea5dbf3f7d5 2261 /* Write RF_MNGT_DYN register */
DiegoOstuni 0:bea5dbf3f7d5 2262 return ST25DV_i2c_WriteMailboxRegister( &reg_value, ST25DV_RF_MNGT_DYN_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 2263 }
DiegoOstuni 0:bea5dbf3f7d5 2264
DiegoOstuni 0:bea5dbf3f7d5 2265 /**
DiegoOstuni 0:bea5dbf3f7d5 2266 * @brief Unsets the RF Sleep dynamic configuration.
DiegoOstuni 0:bea5dbf3f7d5 2267 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 2268 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 2269 */
DiegoOstuni 0:bea5dbf3f7d5 2270 NFCTAG_StatusTypeDef ST25DV_i2c_ResetRFSleep_Dyn( I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 2271 {
DiegoOstuni 0:bea5dbf3f7d5 2272 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 2273 uint8_t reg_value = 0;
DiegoOstuni 0:bea5dbf3f7d5 2274
DiegoOstuni 0:bea5dbf3f7d5 2275 /* Read actual value of RF_MNGT_DYN register */
DiegoOstuni 0:bea5dbf3f7d5 2276 status = ST25DV_i2c_ReadMailboxRegister( &reg_value, ST25DV_RF_MNGT_DYN_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 2277 if( status != NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 2278 {
DiegoOstuni 0:bea5dbf3f7d5 2279 return status;
DiegoOstuni 0:bea5dbf3f7d5 2280 }
DiegoOstuni 0:bea5dbf3f7d5 2281
DiegoOstuni 0:bea5dbf3f7d5 2282 /* Update dynamic RF Disable field configuration */
DiegoOstuni 0:bea5dbf3f7d5 2283 reg_value &= ST25DV_RF_MNGT_DYN_RFSLEEP_FIELD;
DiegoOstuni 0:bea5dbf3f7d5 2284
DiegoOstuni 0:bea5dbf3f7d5 2285 /* Write RF_MNGT_DYN register */
DiegoOstuni 0:bea5dbf3f7d5 2286 return ST25DV_i2c_WriteMailboxRegister( &reg_value, ST25DV_RF_MNGT_DYN_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 2287 }
DiegoOstuni 0:bea5dbf3f7d5 2288
DiegoOstuni 0:bea5dbf3f7d5 2289 /**
DiegoOstuni 0:bea5dbf3f7d5 2290 * @brief Reads the Mailbox ctrl dynamic register.
DiegoOstuni 0:bea5dbf3f7d5 2291 * @param pCtrlStatus Pointer on a ST25DV_MB_CTRL_DYN_STATUS structure used to return the dynamic Mailbox ctrl information.
DiegoOstuni 0:bea5dbf3f7d5 2292 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 2293 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 2294 */
DiegoOstuni 0:bea5dbf3f7d5 2295 NFCTAG_StatusTypeDef ST25DV_i2c_ReadMBCtrl_Dyn( ST25DV_MB_CTRL_DYN_STATUS * const pCtrlStatus, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 2296 {
DiegoOstuni 0:bea5dbf3f7d5 2297 uint8_t reg_value;
DiegoOstuni 0:bea5dbf3f7d5 2298 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 2299
DiegoOstuni 0:bea5dbf3f7d5 2300 /* Read MB_CTRL_DYN register */
DiegoOstuni 0:bea5dbf3f7d5 2301 status = ST25DV_i2c_ReadMailboxRegister( &reg_value, ST25DV_MB_CTRL_DYN_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 2302 if( status != NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 2303 {
DiegoOstuni 0:bea5dbf3f7d5 2304 return status;
DiegoOstuni 0:bea5dbf3f7d5 2305 }
DiegoOstuni 0:bea5dbf3f7d5 2306
DiegoOstuni 0:bea5dbf3f7d5 2307 /* Extract Mailbox ctrl information */
DiegoOstuni 0:bea5dbf3f7d5 2308 pCtrlStatus->MbEnable = (reg_value & ST25DV_MB_CTRL_DYN_MBEN_MASK) >> ST25DV_MB_CTRL_DYN_MBEN_SHIFT;
DiegoOstuni 0:bea5dbf3f7d5 2309 pCtrlStatus->HostPutMsg = (reg_value & ST25DV_MB_CTRL_DYN_HOSTPUTMSG_MASK) >> ST25DV_MB_CTRL_DYN_HOSTPUTMSG_SHIFT;
DiegoOstuni 0:bea5dbf3f7d5 2310 pCtrlStatus->RfPutMsg = (reg_value & ST25DV_MB_CTRL_DYN_RFPUTMSG_MASK) >> ST25DV_MB_CTRL_DYN_RFPUTMSG_SHIFT;
DiegoOstuni 0:bea5dbf3f7d5 2311 pCtrlStatus->HostMissMsg = (reg_value & ST25DV_MB_CTRL_DYN_HOSTMISSMSG_MASK) >> ST25DV_MB_CTRL_DYN_HOSTMISSMSG_SHIFT;
DiegoOstuni 0:bea5dbf3f7d5 2312 pCtrlStatus->RFMissMsg = (reg_value & ST25DV_MB_CTRL_DYN_RFMISSMSG_MASK) >> ST25DV_MB_CTRL_DYN_RFMISSMSG_SHIFT;
DiegoOstuni 0:bea5dbf3f7d5 2313 pCtrlStatus->CurrentMsg = (ST25DV_CURRENT_MSG)((reg_value & ST25DV_MB_CTRL_DYN_CURRENTMSG_MASK) >> ST25DV_MB_CTRL_DYN_CURRENTMSG_SHIFT);
DiegoOstuni 0:bea5dbf3f7d5 2314
DiegoOstuni 0:bea5dbf3f7d5 2315 return NFCTAG_OK;
DiegoOstuni 0:bea5dbf3f7d5 2316 }
DiegoOstuni 0:bea5dbf3f7d5 2317
DiegoOstuni 0:bea5dbf3f7d5 2318 /**
DiegoOstuni 0:bea5dbf3f7d5 2319 * @brief Reads the Mailbox Enable dynamic configuration.
DiegoOstuni 0:bea5dbf3f7d5 2320 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 2321 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 2322 */
DiegoOstuni 0:bea5dbf3f7d5 2323 NFCTAG_StatusTypeDef ST25DV_i2c_GetMBEN_Dyn( ST25DV_EN_STATUS * const pMBEN, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 2324 {
DiegoOstuni 0:bea5dbf3f7d5 2325 uint8_t reg_value;
DiegoOstuni 0:bea5dbf3f7d5 2326 NFCTAG_StatusTypeDef status;
DiegoOstuni 0:bea5dbf3f7d5 2327
DiegoOstuni 0:bea5dbf3f7d5 2328 /* Read MB_CTRL_DYN register */
DiegoOstuni 0:bea5dbf3f7d5 2329 status = ST25DV_i2c_ReadMailboxRegister( &reg_value, ST25DV_MB_CTRL_DYN_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 2330 if( status != NFCTAG_OK )
DiegoOstuni 0:bea5dbf3f7d5 2331 {
DiegoOstuni 0:bea5dbf3f7d5 2332 return status;
DiegoOstuni 0:bea5dbf3f7d5 2333 }
DiegoOstuni 0:bea5dbf3f7d5 2334
DiegoOstuni 0:bea5dbf3f7d5 2335 if( (reg_value & ST25DV_MB_MODE_RW_MASK ) == ST25DV_MB_MODE_RW_MASK )
DiegoOstuni 0:bea5dbf3f7d5 2336 {
DiegoOstuni 0:bea5dbf3f7d5 2337 *pMBEN = ST25DV_ENABLE;
DiegoOstuni 0:bea5dbf3f7d5 2338 }
DiegoOstuni 0:bea5dbf3f7d5 2339 else
DiegoOstuni 0:bea5dbf3f7d5 2340 {
DiegoOstuni 0:bea5dbf3f7d5 2341 *pMBEN = ST25DV_DISABLE;
DiegoOstuni 0:bea5dbf3f7d5 2342 }
DiegoOstuni 0:bea5dbf3f7d5 2343
DiegoOstuni 0:bea5dbf3f7d5 2344 return NFCTAG_OK;
DiegoOstuni 0:bea5dbf3f7d5 2345 }
DiegoOstuni 0:bea5dbf3f7d5 2346
DiegoOstuni 0:bea5dbf3f7d5 2347 /**
DiegoOstuni 0:bea5dbf3f7d5 2348 * @brief Sets the Mailbox Enable dynamic configuration.
DiegoOstuni 0:bea5dbf3f7d5 2349 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 2350 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 2351 */
DiegoOstuni 0:bea5dbf3f7d5 2352 NFCTAG_StatusTypeDef ST25DV_i2c_SetMBEN_Dyn( I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 2353 {
DiegoOstuni 0:bea5dbf3f7d5 2354 uint8_t reg_value;
DiegoOstuni 0:bea5dbf3f7d5 2355
DiegoOstuni 0:bea5dbf3f7d5 2356 /* Set dynamic Mailbox enable */
DiegoOstuni 0:bea5dbf3f7d5 2357 reg_value = ST25DV_MB_CTRL_DYN_MBEN_MASK;
DiegoOstuni 0:bea5dbf3f7d5 2358
DiegoOstuni 0:bea5dbf3f7d5 2359 /* Write MB_CTRL_DYN register */
DiegoOstuni 0:bea5dbf3f7d5 2360 return ST25DV_i2c_WriteMailboxRegister( &reg_value, ST25DV_MB_CTRL_DYN_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 2361 }
DiegoOstuni 0:bea5dbf3f7d5 2362
DiegoOstuni 0:bea5dbf3f7d5 2363 /**
DiegoOstuni 0:bea5dbf3f7d5 2364 * @brief Unsets the Mailbox Enable dynamic configuration.
DiegoOstuni 0:bea5dbf3f7d5 2365 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 2366 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 2367 */
DiegoOstuni 0:bea5dbf3f7d5 2368 NFCTAG_StatusTypeDef ST25DV_i2c_ResetMBEN_Dyn( I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 2369 {
DiegoOstuni 0:bea5dbf3f7d5 2370 uint8_t reg_value;
DiegoOstuni 0:bea5dbf3f7d5 2371
DiegoOstuni 0:bea5dbf3f7d5 2372
DiegoOstuni 0:bea5dbf3f7d5 2373 /* Set dynamic Mailbox disable */
DiegoOstuni 0:bea5dbf3f7d5 2374 reg_value = 0;
DiegoOstuni 0:bea5dbf3f7d5 2375
DiegoOstuni 0:bea5dbf3f7d5 2376 /* Write MB_CTRL_DYN register */
DiegoOstuni 0:bea5dbf3f7d5 2377 ST25DV_i2c_ReadMailboxRegister( &reg_value, ST25DV_MB_CTRL_DYN_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 2378 return ST25DV_i2c_WriteMailboxRegister( &reg_value, ST25DV_MB_CTRL_DYN_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 2379
DiegoOstuni 0:bea5dbf3f7d5 2380 }
DiegoOstuni 0:bea5dbf3f7d5 2381
DiegoOstuni 0:bea5dbf3f7d5 2382 /**
DiegoOstuni 0:bea5dbf3f7d5 2383 * @brief Reads the Mailbox message length dynamic register.
DiegoOstuni 0:bea5dbf3f7d5 2384 * @param pMBLength Pointer on a uint8_t used to return the Mailbox message length.
DiegoOstuni 0:bea5dbf3f7d5 2385 * @param mi2cChannel I2C channel
DiegoOstuni 0:bea5dbf3f7d5 2386 * @return NFCTAG_StatusTypeDef enum status.
DiegoOstuni 0:bea5dbf3f7d5 2387 */
DiegoOstuni 0:bea5dbf3f7d5 2388 NFCTAG_StatusTypeDef ST25DV_i2c_ReadMBLength_Dyn( uint8_t * const pMBLength, I2C * mi2cChannel )
DiegoOstuni 0:bea5dbf3f7d5 2389 {
DiegoOstuni 0:bea5dbf3f7d5 2390 /* Read actual value of MBLEN_DYN register */
DiegoOstuni 0:bea5dbf3f7d5 2391 return ST25DV_i2c_ReadMailboxRegister( pMBLength, ST25DV_MBLEN_DYN_REG, 1, mi2cChannel );
DiegoOstuni 0:bea5dbf3f7d5 2392 }
DiegoOstuni 0:bea5dbf3f7d5 2393
DiegoOstuni 0:bea5dbf3f7d5 2394 /**
DiegoOstuni 0:bea5dbf3f7d5 2395 * @}
DiegoOstuni 0:bea5dbf3f7d5 2396 */
DiegoOstuni 0:bea5dbf3f7d5 2397
DiegoOstuni 0:bea5dbf3f7d5 2398 /**
DiegoOstuni 0:bea5dbf3f7d5 2399 * @}
DiegoOstuni 0:bea5dbf3f7d5 2400 */
DiegoOstuni 0:bea5dbf3f7d5 2401
DiegoOstuni 0:bea5dbf3f7d5 2402
DiegoOstuni 0:bea5dbf3f7d5 2403 /******************* (C) COPYRIGHT 2016 STMicroelectronics *****END OF FILE****/