ST25R3911 library for the STMicroelectronics X-NUCLEO-NFC05A1

Dependents:   mbed-os-nfc05a1

Committer:
DiegoOstuni
Date:
Thu Nov 14 14:36:52 2019 +0000
Revision:
0:98fcd1266df0
Fork of the GitHub

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DiegoOstuni 0:98fcd1266df0 1
DiegoOstuni 0:98fcd1266df0 2 /******************************************************************************
DiegoOstuni 0:98fcd1266df0 3 * @attention
DiegoOstuni 0:98fcd1266df0 4 *
DiegoOstuni 0:98fcd1266df0 5 * <h2><center>&copy; COPYRIGHT 2016 STMicroelectronics</center></h2>
DiegoOstuni 0:98fcd1266df0 6 *
DiegoOstuni 0:98fcd1266df0 7 * Licensed under ST MYLIBERTY SOFTWARE LICENSE AGREEMENT (the "License");
DiegoOstuni 0:98fcd1266df0 8 * You may not use this file except in compliance with the License.
DiegoOstuni 0:98fcd1266df0 9 * You may obtain a copy of the License at:
DiegoOstuni 0:98fcd1266df0 10 *
DiegoOstuni 0:98fcd1266df0 11 * http://www.st.com/myliberty
DiegoOstuni 0:98fcd1266df0 12 *
DiegoOstuni 0:98fcd1266df0 13 * Unless required by applicable law or agreed to in writing, software
DiegoOstuni 0:98fcd1266df0 14 * distributed under the License is distributed on an "AS IS" BASIS,
DiegoOstuni 0:98fcd1266df0 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
DiegoOstuni 0:98fcd1266df0 16 * AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
DiegoOstuni 0:98fcd1266df0 17 * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
DiegoOstuni 0:98fcd1266df0 18 * See the License for the specific language governing permissions and
DiegoOstuni 0:98fcd1266df0 19 * limitations under the License.
DiegoOstuni 0:98fcd1266df0 20 *
DiegoOstuni 0:98fcd1266df0 21 ******************************************************************************/
DiegoOstuni 0:98fcd1266df0 22
DiegoOstuni 0:98fcd1266df0 23
DiegoOstuni 0:98fcd1266df0 24 /*
DiegoOstuni 0:98fcd1266df0 25 * PROJECT: NFCC firmware
DiegoOstuni 0:98fcd1266df0 26 * $Revision: $
DiegoOstuni 0:98fcd1266df0 27 * LANGUAGE: ISO C99
DiegoOstuni 0:98fcd1266df0 28 */
DiegoOstuni 0:98fcd1266df0 29
DiegoOstuni 0:98fcd1266df0 30 /*! \file
DiegoOstuni 0:98fcd1266df0 31 *
DiegoOstuni 0:98fcd1266df0 32 * \author Ulrich Herrmann
DiegoOstuni 0:98fcd1266df0 33 *
DiegoOstuni 0:98fcd1266df0 34 * \brief Common and helpful macros
DiegoOstuni 0:98fcd1266df0 35 *
DiegoOstuni 0:98fcd1266df0 36 */
DiegoOstuni 0:98fcd1266df0 37
DiegoOstuni 0:98fcd1266df0 38 #ifndef UTILS_H
DiegoOstuni 0:98fcd1266df0 39 #define UTILS_H
DiegoOstuni 0:98fcd1266df0 40
DiegoOstuni 0:98fcd1266df0 41 /*
DiegoOstuni 0:98fcd1266df0 42 ******************************************************************************
DiegoOstuni 0:98fcd1266df0 43 * INCLUDES
DiegoOstuni 0:98fcd1266df0 44 ******************************************************************************
DiegoOstuni 0:98fcd1266df0 45 */
DiegoOstuni 0:98fcd1266df0 46 #include <string.h>
DiegoOstuni 0:98fcd1266df0 47
DiegoOstuni 0:98fcd1266df0 48 /*
DiegoOstuni 0:98fcd1266df0 49 ******************************************************************************
DiegoOstuni 0:98fcd1266df0 50 * GLOBAL MACROS
DiegoOstuni 0:98fcd1266df0 51 ******************************************************************************
DiegoOstuni 0:98fcd1266df0 52 */
DiegoOstuni 0:98fcd1266df0 53 /*!
DiegoOstuni 0:98fcd1266df0 54 * this macro evaluates an error variable \a ERR against an error code \a EC.
DiegoOstuni 0:98fcd1266df0 55 * in case it is not equal it jumps to the given label \a LABEL.
DiegoOstuni 0:98fcd1266df0 56 */
DiegoOstuni 0:98fcd1266df0 57 #define EVAL_ERR_NE_GOTO(EC, ERR, LABEL) \
DiegoOstuni 0:98fcd1266df0 58 if (EC != ERR) goto LABEL;
DiegoOstuni 0:98fcd1266df0 59
DiegoOstuni 0:98fcd1266df0 60 /*!
DiegoOstuni 0:98fcd1266df0 61 * this macro evaluates an error variable \a ERR against an error code \a EC.
DiegoOstuni 0:98fcd1266df0 62 * in case it is equal it jumps to the given label \a LABEL.
DiegoOstuni 0:98fcd1266df0 63 */
DiegoOstuni 0:98fcd1266df0 64 #define EVAL_ERR_EQ_GOTO(EC, ERR, LABEL) \
DiegoOstuni 0:98fcd1266df0 65 if (EC == ERR) goto LABEL;
DiegoOstuni 0:98fcd1266df0 66
DiegoOstuni 0:98fcd1266df0 67 #define SIZEOF_ARRAY(a) (sizeof(a) / sizeof(a[0])) /*!< Compute the size of an array */
DiegoOstuni 0:98fcd1266df0 68 #define MAX(a, b) (((a) > (b)) ? (a) : (b)) /*!< Return the maximum of the 2 values */
DiegoOstuni 0:98fcd1266df0 69 #define MIN(a, b) (((a) < (b)) ? (a) : (b)) /*!< Return the minimum of the 2 values */
DiegoOstuni 0:98fcd1266df0 70 #define BITMASK_1 (0x01) /*!< Bit mask for lsb bit */
DiegoOstuni 0:98fcd1266df0 71 #define BITMASK_2 (0x03) /*!< Bit mask for two lsb bits */
DiegoOstuni 0:98fcd1266df0 72 #define BITMASK_3 (0x07) /*!< Bit mask for three lsb bits */
DiegoOstuni 0:98fcd1266df0 73 #define BITMASK_4 (0x0F) /*!< Bit mask for four lsb bits */
DiegoOstuni 0:98fcd1266df0 74 #define U16TOU8(a) ((a) & 0x00FF) /*!< Cast 16-bit unsigned to 8-bit unsigned */
DiegoOstuni 0:98fcd1266df0 75 #define GETU16(a) (uint16_t)((a[0] << 8) | a[1])/*!< Cast two Big Endian 8-bits byte array to 16-bits unsigned */
DiegoOstuni 0:98fcd1266df0 76
DiegoOstuni 0:98fcd1266df0 77
DiegoOstuni 0:98fcd1266df0 78 #define REVERSE_BYTES(pData, nDataSize) \
DiegoOstuni 0:98fcd1266df0 79 unsigned char swap, *lo = pData, *hi = pData + nDataSize - 1; \
DiegoOstuni 0:98fcd1266df0 80 while (lo < hi) { swap = *lo; *lo++ = *hi; *hi-- = swap; }
DiegoOstuni 0:98fcd1266df0 81
DiegoOstuni 0:98fcd1266df0 82
DiegoOstuni 0:98fcd1266df0 83 #define ST_MEMMOVE memmove /*!< map memmove to string library code */
DiegoOstuni 0:98fcd1266df0 84 #define ST_MEMCPY memcpy /*!< map memcpy to string library code */
DiegoOstuni 0:98fcd1266df0 85 #define ST_MEMSET memset /*!< map memset to string library code */
DiegoOstuni 0:98fcd1266df0 86 #define ST_BYTECMP memcmp /*!< map bytecmp to string library code */
DiegoOstuni 0:98fcd1266df0 87
DiegoOstuni 0:98fcd1266df0 88 #define NO_WARNING(v) ((void) (v)) /*!< Macro to suppress compiler warning */
DiegoOstuni 0:98fcd1266df0 89
DiegoOstuni 0:98fcd1266df0 90
DiegoOstuni 0:98fcd1266df0 91 #ifndef NULL
DiegoOstuni 0:98fcd1266df0 92 #define NULL (void*)0 /*!< represents a NULL pointer */
DiegoOstuni 0:98fcd1266df0 93 #endif /* !NULL */
DiegoOstuni 0:98fcd1266df0 94
DiegoOstuni 0:98fcd1266df0 95 /*
DiegoOstuni 0:98fcd1266df0 96 ******************************************************************************
DiegoOstuni 0:98fcd1266df0 97 * GLOBAL FUNCTION PROTOTYPES
DiegoOstuni 0:98fcd1266df0 98 ******************************************************************************
DiegoOstuni 0:98fcd1266df0 99 */
DiegoOstuni 0:98fcd1266df0 100
DiegoOstuni 0:98fcd1266df0 101 #endif /* UTILS_H */
DiegoOstuni 0:98fcd1266df0 102