44 * @author MMY Application Team
55 * @version $Revision: 3306 $
66 * @date $Date: 2017-01-13 11:18:15 +0100 (Fri, 13 Jan 2017) $
7- * @brief This file provides a set of functions needed to manage a nfc dual
7+ * @brief This file provides a set of functions needed to manage a nfc dual
88 * interface eeprom memory.
99 ******************************************************************************
1010 * @attention
1515 * You may not use this file except in compliance with the License.
1616 * You may obtain a copy of the License at:
1717 *
18- * http://www.st.com/myliberty
18+ * http://www.st.com/myliberty
1919 *
20- * Unless required by applicable law or agreed to in writing, software
21- * distributed under the License is distributed on an "AS IS" BASIS,
20+ * Unless required by applicable law or agreed to in writing, software
21+ * distributed under the License is distributed on an "AS IS" BASIS,
2222 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
2323 * AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
2424 * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
2525 * See the License for the specific language governing permissions and
2626 * limitations under the License.
2727 *
2828 ******************************************************************************
29- */
29+ */
3030
3131/* Includes ------------------------------------------------------------------*/
3232#include " st25dv_nfctag.h"
5151 */
5252
5353/* Private macros ------------------------------------------------------------*/
54- /* Private variables ---------------------------------------------------------*/
54+ /* Private variables ---------------------------------------------------------*/
5555/* Global variables ----------------------------------------------------------*/
5656/* * @defgroup ST25DV_NFCTAG_Private_Variables
5757 * @{
@@ -71,39 +71,33 @@ static uint8_t NfctagInitialized = 0;
7171 * @param None
7272 * @retval NFCTAG enum status
7373 */
74- NFCTAG_StatusTypeDef BSP_NFCTAG_Init ( void )
75- {
74+ NFCTAG_StatusTypeDef BSP_NFCTAG_Init (void )
75+ {
7676 uint8_t nfctag_id = 0 ;
77-
78- if ( !NfctagInitialized )
79- {
80- if ( St25Dv_i2c_Drv.Init == NULL )
81- {
77+
78+ if (!NfctagInitialized) {
79+ if (St25Dv_i2c_Drv.Init == NULL ) {
8280 return NFCTAG_ERROR;
8381 }
8482 /* ST25DV Init */
85- if ( St25Dv_i2c_Drv.Init () != NFCTAG_OK )
86- {
83+ if (St25Dv_i2c_Drv.Init () != NFCTAG_OK) {
8784 return NFCTAG_ERROR;
8885 }
8986
9087 /* Check ST25DV driver ID */
9188 St25Dv_i2c_Drv.ReadID (&nfctag_id);
92-
93- if ( (nfctag_id == I_AM_ST25DV04) || (nfctag_id == I_AM_ST25DV64) )
94- {
89+
90+ if ((nfctag_id == I_AM_ST25DV04) || (nfctag_id == I_AM_ST25DV64)) {
9591 NfctagInitialized = 1 ;
9692 Nfctag_Drv = &St25Dv_i2c_Drv;
9793 Nfctag_Drv->pData = &St25Dv_i2c_ExtDrv;
98- }
99- else
100- {
101- Nfctag_Drv = NULL ;
94+ } else {
95+ Nfctag_Drv = NULL ;
10296 NfctagInitialized = 0 ;
10397 return NFCTAG_ERROR;
10498 }
10599 }
106-
100+
107101 return NFCTAG_OK;
108102}
109103
@@ -112,8 +106,8 @@ NFCTAG_StatusTypeDef BSP_NFCTAG_Init( void )
112106 * @param None
113107 * @retval None
114108 */
115- void BSP_NFCTAG_DeInit ( void )
116- {
109+ void BSP_NFCTAG_DeInit (void )
110+ {
117111 Nfctag_Drv->pData = NULL ;
118112 Nfctag_Drv = NULL ;
119113 NfctagInitialized = 0 ;
@@ -124,7 +118,7 @@ void BSP_NFCTAG_DeInit( void )
124118 * @param None
125119 * @retval 0 if the nfctag is not initialized, 1 if the nfctag is already initialized
126120 */
127- uint8_t BSP_NFCTAG_isInitialized ( void )
121+ uint8_t BSP_NFCTAG_isInitialized (void )
128122{
129123 return NfctagInitialized;
130124}
@@ -134,40 +128,38 @@ uint8_t BSP_NFCTAG_isInitialized( void )
134128 * @param wai_id : the pointer where the who_am_i of the device is stored
135129 * @retval NFCTAG enum status
136130 */
137- NFCTAG_StatusTypeDef BSP_NFCTAG_ReadID ( uint8_t * const wai_id )
131+ NFCTAG_StatusTypeDef BSP_NFCTAG_ReadID (uint8_t *const wai_id)
138132{
139- if ( Nfctag_Drv->ReadID == NULL )
140- {
133+ if (Nfctag_Drv->ReadID == NULL ) {
141134 return NFCTAG_ERROR;
142135 }
143-
144- return Nfctag_Drv->ReadID ( wai_id );
136+
137+ return Nfctag_Drv->ReadID (wai_id);
145138}
146139
147140/* *
148141 * @brief Return the size of the nfctag
149142 * @retval Size of the NFCtag in Bytes
150143 */
151- uint32_t BSP_NFCTAG_GetByteSize ( void )
144+ uint32_t BSP_NFCTAG_GetByteSize (void )
152145{
153146 ST25DV_MEM_SIZE mem_size;
154- ((NFCTAG_ExtDrvTypeDef *)Nfctag_Drv->pData )->ReadMemSize ( &mem_size );
155- return (mem_size.BlockSize + 1 ) * (mem_size.Mem_Size + 1 );
147+ ((NFCTAG_ExtDrvTypeDef *)Nfctag_Drv->pData )->ReadMemSize (&mem_size);
148+ return (mem_size.BlockSize + 1 ) * (mem_size.Mem_Size + 1 );
156149}
157150
158151/* *
159152 * @brief Check if the nfctag is available
160153 * @param Trials : Number of trials
161154 * @retval NFCTAG enum status
162155 */
163- NFCTAG_StatusTypeDef BSP_NFCTAG_IsDeviceReady ( const uint32_t Trials )
156+ NFCTAG_StatusTypeDef BSP_NFCTAG_IsDeviceReady (const uint32_t Trials)
164157{
165- if ( Nfctag_Drv->IsReady == NULL )
166- {
158+ if (Nfctag_Drv->IsReady == NULL ) {
167159 return NFCTAG_ERROR;
168160 }
169-
170- return Nfctag_Drv->IsReady ( Trials );
161+
162+ return Nfctag_Drv->IsReady (Trials);
171163}
172164
173165/* *
@@ -177,13 +169,12 @@ NFCTAG_StatusTypeDef BSP_NFCTAG_IsDeviceReady( const uint32_t Trials )
177169 * - 0x02 => WIP
178170 * @retval NFCTAG enum status
179171 */
180- NFCTAG_StatusTypeDef BSP_NFCTAG_ConfigIT ( const uint16_t ITConfig )
172+ NFCTAG_StatusTypeDef BSP_NFCTAG_ConfigIT (const uint16_t ITConfig)
181173{
182- if ( Nfctag_Drv->ConfigIT == NULL )
183- {
174+ if (Nfctag_Drv->ConfigIT == NULL ) {
184175 return NFCTAG_ERROR;
185176 }
186- return Nfctag_Drv->ConfigIT ( ITConfig );
177+ return Nfctag_Drv->ConfigIT (ITConfig);
187178}
188179
189180/* *
@@ -193,14 +184,13 @@ NFCTAG_StatusTypeDef BSP_NFCTAG_ConfigIT( const uint16_t ITConfig )
193184 * - 0x02 => WIP
194185 * @retval NFCTAG enum status
195186 */
196- NFCTAG_StatusTypeDef BSP_NFCTAG_GetITStatus ( uint16_t * const ITConfig )
187+ NFCTAG_StatusTypeDef BSP_NFCTAG_GetITStatus (uint16_t *const ITConfig)
197188{
198- if ( Nfctag_Drv->GetITStatus == NULL )
199- {
189+ if (Nfctag_Drv->GetITStatus == NULL ) {
200190 return NFCTAG_ERROR;
201191 }
202-
203- return Nfctag_Drv->GetITStatus ( ITConfig );
192+
193+ return Nfctag_Drv->GetITStatus (ITConfig);
204194}
205195
206196/* *
@@ -210,14 +200,13 @@ NFCTAG_StatusTypeDef BSP_NFCTAG_GetITStatus( uint16_t * const ITConfig )
210200 * @param Size : Size in bytes of the value to be read
211201 * @retval NFCTAG enum status
212202 */
213- NFCTAG_StatusTypeDef BSP_NFCTAG_ReadData ( uint8_t * const pData, const uint16_t TarAddr, const uint16_t Size )
203+ NFCTAG_StatusTypeDef BSP_NFCTAG_ReadData (uint8_t *const pData, const uint16_t TarAddr, const uint16_t Size)
214204{
215- if ( Nfctag_Drv->ReadData == NULL )
216- {
205+ if (Nfctag_Drv->ReadData == NULL ) {
217206 return NFCTAG_ERROR;
218207 }
219-
220- return Nfctag_Drv->ReadData ( pData, TarAddr, Size );
208+
209+ return Nfctag_Drv->ReadData (pData, TarAddr, Size);
221210}
222211
223212/* *
@@ -227,14 +216,13 @@ NFCTAG_StatusTypeDef BSP_NFCTAG_ReadData( uint8_t * const pData, const uint16_t
227216 * @param Size : Size in bytes of the value to be written
228217 * @retval NFCTAG enum status
229218 */
230- NFCTAG_StatusTypeDef BSP_NFCTAG_WriteData ( const uint8_t * const pData, const uint16_t TarAddr, const uint16_t Size )
219+ NFCTAG_StatusTypeDef BSP_NFCTAG_WriteData (const uint8_t *const pData, const uint16_t TarAddr, const uint16_t Size)
231220{
232- if ( Nfctag_Drv->WriteData == NULL )
233- {
221+ if (Nfctag_Drv->WriteData == NULL ) {
234222 return NFCTAG_ERROR;
235223 }
236-
237- return Nfctag_Drv->WriteData ( pData, TarAddr, Size );
224+
225+ return Nfctag_Drv->WriteData (pData, TarAddr, Size);
238226}
239227
240228/* *
@@ -244,14 +232,13 @@ NFCTAG_StatusTypeDef BSP_NFCTAG_WriteData( const uint8_t * const pData, const ui
244232 * @param Size : Size in bytes of the value to be read
245233 * @retval NFCTAG enum status
246234 */
247- NFCTAG_StatusTypeDef BSP_NFCTAG_ReadRegister ( uint8_t * const pData, const uint16_t TarAddr, const uint16_t Size )
235+ NFCTAG_StatusTypeDef BSP_NFCTAG_ReadRegister (uint8_t *const pData, const uint16_t TarAddr, const uint16_t Size)
248236{
249- if ( Nfctag_Drv->ReadRegister == NULL )
250- {
237+ if (Nfctag_Drv->ReadRegister == NULL ) {
251238 return NFCTAG_ERROR;
252239 }
253-
254- return Nfctag_Drv->ReadRegister ( pData, TarAddr, Size );
240+
241+ return Nfctag_Drv->ReadRegister (pData, TarAddr, Size);
255242}
256243
257244/* *
@@ -261,21 +248,19 @@ NFCTAG_StatusTypeDef BSP_NFCTAG_ReadRegister( uint8_t * const pData, const uint1
261248 * @param Size : Size in bytes of the value to be written
262249 * @retval NFCTAG enum status
263250 */
264- NFCTAG_StatusTypeDef BSP_NFCTAG_WriteRegister ( const uint8_t * const pData, const uint16_t TarAddr, const uint16_t Size )
251+ NFCTAG_StatusTypeDef BSP_NFCTAG_WriteRegister (const uint8_t *const pData, const uint16_t TarAddr, const uint16_t Size)
265252{
266253 NFCTAG_StatusTypeDef ret_value;
267- if ( Nfctag_Drv->WriteRegister == NULL )
268- {
254+ if (Nfctag_Drv->WriteRegister == NULL ) {
269255 return NFCTAG_ERROR;
270256 }
271-
272- ret_value = Nfctag_Drv->WriteRegister ( pData, TarAddr, Size );
273- if ( ret_value == NFCTAG_OK )
274- {
275- while ( BSP_NFCTAG_IsDeviceReady ( 1 ) != NFCTAG_OK ) {};
276- return NFCTAG_OK;
257+
258+ ret_value = Nfctag_Drv->WriteRegister (pData, TarAddr, Size);
259+ if (ret_value == NFCTAG_OK) {
260+ while (BSP_NFCTAG_IsDeviceReady (1 ) != NFCTAG_OK) {};
261+ return NFCTAG_OK;
277262 }
278-
263+
279264 return ret_value;
280265}
281266
@@ -284,7 +269,7 @@ NFCTAG_StatusTypeDef BSP_NFCTAG_WriteRegister( const uint8_t * const pData, cons
284269 * @param None
285270 * @retval address of the Extended Component Structure
286271 */
287- NFCTAG_ExtDrvTypeDef *BSP_NFCTAG_GetExtended_Drv ( void )
272+ NFCTAG_ExtDrvTypeDef *BSP_NFCTAG_GetExtended_Drv (void )
288273{
289274 return (NFCTAG_ExtDrvTypeDef *)Nfctag_Drv->pData ;
290275}
0 commit comments