Naming and coding style convention, new linter tool. (#945)

* Makefile, Scripts: new linter
* About: remove ID from IC
* Firmware: remove double define for DIVC/DIVR
* Scripts: check folder names too. Docker: replace syntax check with make lint.
* Reformat Sources and Migrate to new file naming convention
* Docker: symlink clang-format-12 to clang-format
* Add coding style guide
This commit is contained in:
あく
2022-01-05 19:10:18 +03:00
committed by GitHub
parent c98e54da10
commit 389ff92cc1
899 changed files with 379245 additions and 373421 deletions
+188 -110
View File
@@ -64,66 +64,114 @@
******************************************************************************
*/
#define RFAL_ANALOG_CONFIG_LUT_SIZE (87U) /*!< Maximum number of Configuration IDs in the Loop Up Table */
#define RFAL_ANALOG_CONFIG_LUT_NOT_FOUND (0xFFU) /*!< Index value indicating no Configuration IDs found */
#define RFAL_ANALOG_CONFIG_LUT_SIZE \
(87U) /*!< Maximum number of Configuration IDs in the Loop Up Table */
#define RFAL_ANALOG_CONFIG_LUT_NOT_FOUND \
(0xFFU) /*!< Index value indicating no Configuration IDs found */
#define RFAL_ANALOG_CONFIG_TBL_SIZE (1024U) /*!< Maximum number of Register-Mask-Value in the Setting List */
#define RFAL_ANALOG_CONFIG_TBL_SIZE \
(1024U) /*!< Maximum number of Register-Mask-Value in the Setting List */
#define RFAL_ANALOG_CONFIG_POLL_LISTEN_MODE_MASK \
(0x8000U) /*!< Mask bit of Poll Mode in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_TECH_MASK \
(0x7F00U) /*!< Mask bits for Technology in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_BITRATE_MASK \
(0x00F0U) /*!< Mask bits for Bit rate in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_DIRECTION_MASK \
(0x000FU) /*!< Mask bits for Direction in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_CHIP_SPECIFIC_MASK \
(0x00FFU) /*!< Mask bits for Chip Specific Technology */
#define RFAL_ANALOG_CONFIG_POLL_LISTEN_MODE_MASK (0x8000U) /*!< Mask bit of Poll Mode in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_TECH_MASK (0x7F00U) /*!< Mask bits for Technology in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_BITRATE_MASK (0x00F0U) /*!< Mask bits for Bit rate in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_DIRECTION_MASK (0x000FU) /*!< Mask bits for Direction in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_CHIP_SPECIFIC_MASK (0x00FFU) /*!< Mask bits for Chip Specific Technology */
#define RFAL_ANALOG_CONFIG_POLL_LISTEN_MODE_SHIFT \
(15U) /*!< Shift value of Poll Mode in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_TECH_SHIFT \
(8U) /*!< Shift value for Technology in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_BITRATE_SHIFT \
(4U) /*!< Shift value for Technology in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_DIRECTION_SHIFT \
(0U) /*!< Shift value for Direction in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_POLL_LISTEN_MODE_SHIFT (15U) /*!< Shift value of Poll Mode in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_TECH_SHIFT (8U) /*!< Shift value for Technology in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_BITRATE_SHIFT (4U) /*!< Shift value for Technology in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_DIRECTION_SHIFT (0U) /*!< Shift value for Direction in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_POLL \
(0x0000U) /*!< Poll Mode bit setting in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_LISTEN \
(0x8000U) /*!< Listen Mode bit setting in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_POLL (0x0000U) /*!< Poll Mode bit setting in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_LISTEN (0x8000U) /*!< Listen Mode bit setting in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_TECH_CHIP \
(0x0000U) /*!< Chip-Specific bit setting in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_TECH_NFCA \
(0x0100U) /*!< NFC-A Technology bits setting in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_TECH_NFCB \
(0x0200U) /*!< NFC-B Technology bits setting in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_TECH_NFCF \
(0x0400U) /*!< NFC-F Technology bits setting in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_TECH_AP2P \
(0x0800U) /*!< AP2P Technology bits setting in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_TECH_NFCV \
(0x1000U) /*!< NFC-V Technology bits setting in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_TECH_RFU (0x2000U) /*!< RFU for Technology bits */
#define RFAL_ANALOG_CONFIG_TECH_CHIP (0x0000U) /*!< Chip-Specific bit setting in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_TECH_NFCA (0x0100U) /*!< NFC-A Technology bits setting in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_TECH_NFCB (0x0200U) /*!< NFC-B Technology bits setting in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_TECH_NFCF (0x0400U) /*!< NFC-F Technology bits setting in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_TECH_AP2P (0x0800U) /*!< AP2P Technology bits setting in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_TECH_NFCV (0x1000U) /*!< NFC-V Technology bits setting in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_TECH_RFU (0x2000U) /*!< RFU for Technology bits */
#define RFAL_ANALOG_CONFIG_BITRATE_COMMON \
(0x0000U) /*!< Common settings for all bit rates in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_BITRATE_106 \
(0x0010U) /*!< 106kbits/s settings in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_BITRATE_212 \
(0x0020U) /*!< 212kbits/s settings in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_BITRATE_424 \
(0x0030U) /*!< 424kbits/s settings in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_BITRATE_848 \
(0x0040U) /*!< 848kbits/s settings in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_BITRATE_1695 \
(0x0050U) /*!< 1695kbits/s settings in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_BITRATE_3390 \
(0x0060U) /*!< 3390kbits/s settings in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_BITRATE_6780 \
(0x0070U) /*!< 6780kbits/s settings in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_BITRATE_1OF4 \
(0x00C0U) /*!< 1 out of 4 for NFC-V setting in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_BITRATE_1OF256 \
(0x00D0U) /*!< 1 out of 256 for NFC-V setting in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_BITRATE_COMMON (0x0000U) /*!< Common settings for all bit rates in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_BITRATE_106 (0x0010U) /*!< 106kbits/s settings in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_BITRATE_212 (0x0020U) /*!< 212kbits/s settings in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_BITRATE_424 (0x0030U) /*!< 424kbits/s settings in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_BITRATE_848 (0x0040U) /*!< 848kbits/s settings in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_BITRATE_1695 (0x0050U) /*!< 1695kbits/s settings in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_BITRATE_3390 (0x0060U) /*!< 3390kbits/s settings in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_BITRATE_6780 (0x0070U) /*!< 6780kbits/s settings in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_BITRATE_1OF4 (0x00C0U) /*!< 1 out of 4 for NFC-V setting in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_BITRATE_1OF256 (0x00D0U) /*!< 1 out of 256 for NFC-V setting in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_NO_DIRECTION \
(0x0000U) /*!< No direction setting in Analog Conf ID (Chip Specific only) */
#define RFAL_ANALOG_CONFIG_TX \
(0x0001U) /*!< Transmission bit setting in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_RX \
(0x0002U) /*!< Reception bit setting in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_ANTICOL \
(0x0003U) /*!< Anticollision setting in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_DPO \
(0x0004U) /*!< DPO setting in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_NO_DIRECTION (0x0000U) /*!< No direction setting in Analog Conf ID (Chip Specific only) */
#define RFAL_ANALOG_CONFIG_TX (0x0001U) /*!< Transmission bit setting in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_RX (0x0002U) /*!< Reception bit setting in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_ANTICOL (0x0003U) /*!< Anticollision setting in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_DPO (0x0004U) /*!< DPO setting in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_CHIP_INIT \
(0x0000U) /*!< Chip-Specific event: Startup;Reset;Initialize */
#define RFAL_ANALOG_CONFIG_CHIP_DEINIT \
(0x0001U) /*!< Chip-Specific event: Deinitialize */
#define RFAL_ANALOG_CONFIG_CHIP_FIELD_ON \
(0x0002U) /*!< Chip-Specific event: Field On */
#define RFAL_ANALOG_CONFIG_CHIP_FIELD_OFF \
(0x0003U) /*!< Chip-Specific event: Field Off */
#define RFAL_ANALOG_CONFIG_CHIP_WAKEUP_ON \
(0x0004U) /*!< Chip-Specific event: Wake-up On */
#define RFAL_ANALOG_CONFIG_CHIP_WAKEUP_OFF \
(0x0005U) /*!< Chip-Specific event: Wake-up Off */
#define RFAL_ANALOG_CONFIG_CHIP_LISTEN_ON \
(0x0006U) /*!< Chip-Specific event: Listen On */
#define RFAL_ANALOG_CONFIG_CHIP_LISTEN_OFF \
(0x0007U) /*!< Chip-Specific event: Listen Off */
#define RFAL_ANALOG_CONFIG_CHIP_POLL_COMMON \
(0x0008U) /*!< Chip-Specific event: Poll common */
#define RFAL_ANALOG_CONFIG_CHIP_LISTEN_COMMON \
(0x0009U) /*!< Chip-Specific event: Listen common */
#define RFAL_ANALOG_CONFIG_CHIP_LOWPOWER_ON \
(0x000AU) /*!< Chip-Specific event: Low Power On */
#define RFAL_ANALOG_CONFIG_CHIP_LOWPOWER_OFF \
(0x000BU) /*!< Chip-Specific event: Low Power Off */
#define RFAL_ANALOG_CONFIG_CHIP_INIT (0x0000U) /*!< Chip-Specific event: Startup;Reset;Initialize */
#define RFAL_ANALOG_CONFIG_CHIP_DEINIT (0x0001U) /*!< Chip-Specific event: Deinitialize */
#define RFAL_ANALOG_CONFIG_CHIP_FIELD_ON (0x0002U) /*!< Chip-Specific event: Field On */
#define RFAL_ANALOG_CONFIG_CHIP_FIELD_OFF (0x0003U) /*!< Chip-Specific event: Field Off */
#define RFAL_ANALOG_CONFIG_CHIP_WAKEUP_ON (0x0004U) /*!< Chip-Specific event: Wake-up On */
#define RFAL_ANALOG_CONFIG_CHIP_WAKEUP_OFF (0x0005U) /*!< Chip-Specific event: Wake-up Off */
#define RFAL_ANALOG_CONFIG_CHIP_LISTEN_ON (0x0006U) /*!< Chip-Specific event: Listen On */
#define RFAL_ANALOG_CONFIG_CHIP_LISTEN_OFF (0x0007U) /*!< Chip-Specific event: Listen Off */
#define RFAL_ANALOG_CONFIG_CHIP_POLL_COMMON (0x0008U) /*!< Chip-Specific event: Poll common */
#define RFAL_ANALOG_CONFIG_CHIP_LISTEN_COMMON (0x0009U) /*!< Chip-Specific event: Listen common */
#define RFAL_ANALOG_CONFIG_CHIP_LOWPOWER_ON (0x000AU) /*!< Chip-Specific event: Low Power On */
#define RFAL_ANALOG_CONFIG_CHIP_LOWPOWER_OFF (0x000BU) /*!< Chip-Specific event: Low Power Off */
#define RFAL_ANALOG_CONFIG_UPDATE_LAST (0x00U) /*!< Value indicating Last configuration set during update */
#define RFAL_ANALOG_CONFIG_UPDATE_MORE (0x01U) /*!< Value indicating More configuration set coming during update */
#define RFAL_ANALOG_CONFIG_UPDATE_LAST \
(0x00U) /*!< Value indicating Last configuration set during update */
#define RFAL_ANALOG_CONFIG_UPDATE_MORE \
(0x01U) /*!< Value indicating More configuration set coming during update */
/*
******************************************************************************
@@ -131,41 +179,61 @@
******************************************************************************
*/
#define RFAL_ANALOG_CONFIG_ID_GET_POLL_LISTEN(id) (RFAL_ANALOG_CONFIG_POLL_LISTEN_MODE_MASK & (id)) /*!< Check if id indicates Listen mode */
#define RFAL_ANALOG_CONFIG_ID_GET_POLL_LISTEN(id) \
(RFAL_ANALOG_CONFIG_POLL_LISTEN_MODE_MASK & (id)) /*!< Check if id indicates Listen mode */
#define RFAL_ANALOG_CONFIG_ID_GET_TECH(id) (RFAL_ANALOG_CONFIG_TECH_MASK & (id)) /*!< Get the technology of Configuration ID */
#define RFAL_ANALOG_CONFIG_ID_IS_CHIP(id) (RFAL_ANALOG_CONFIG_TECH_MASK & (id)) /*!< Check if ID indicates Chip-specific */
#define RFAL_ANALOG_CONFIG_ID_IS_NFCA(id) (RFAL_ANALOG_CONFIG_TECH_NFCA & (id)) /*!< Check if ID indicates NFC-A */
#define RFAL_ANALOG_CONFIG_ID_IS_NFCB(id) (RFAL_ANALOG_CONFIG_TECH_NFCB & (id)) /*!< Check if ID indicates NFC-B */
#define RFAL_ANALOG_CONFIG_ID_IS_NFCF(id) (RFAL_ANALOG_CONFIG_TECH_NFCF & (id)) /*!< Check if ID indicates NFC-F */
#define RFAL_ANALOG_CONFIG_ID_IS_AP2P(id) (RFAL_ANALOG_CONFIG_TECH_AP2P & (id)) /*!< Check if ID indicates AP2P */
#define RFAL_ANALOG_CONFIG_ID_IS_NFCV(id) (RFAL_ANALOG_CONFIG_TECH_NFCV & (id)) /*!< Check if ID indicates NFC-V */
#define RFAL_ANALOG_CONFIG_ID_GET_TECH(id) \
(RFAL_ANALOG_CONFIG_TECH_MASK & (id)) /*!< Get the technology of Configuration ID */
#define RFAL_ANALOG_CONFIG_ID_IS_CHIP(id) \
(RFAL_ANALOG_CONFIG_TECH_MASK & (id)) /*!< Check if ID indicates Chip-specific */
#define RFAL_ANALOG_CONFIG_ID_IS_NFCA(id) \
(RFAL_ANALOG_CONFIG_TECH_NFCA & (id)) /*!< Check if ID indicates NFC-A */
#define RFAL_ANALOG_CONFIG_ID_IS_NFCB(id) \
(RFAL_ANALOG_CONFIG_TECH_NFCB & (id)) /*!< Check if ID indicates NFC-B */
#define RFAL_ANALOG_CONFIG_ID_IS_NFCF(id) \
(RFAL_ANALOG_CONFIG_TECH_NFCF & (id)) /*!< Check if ID indicates NFC-F */
#define RFAL_ANALOG_CONFIG_ID_IS_AP2P(id) \
(RFAL_ANALOG_CONFIG_TECH_AP2P & (id)) /*!< Check if ID indicates AP2P */
#define RFAL_ANALOG_CONFIG_ID_IS_NFCV(id) \
(RFAL_ANALOG_CONFIG_TECH_NFCV & (id)) /*!< Check if ID indicates NFC-V */
#define RFAL_ANALOG_CONFIG_ID_GET_BITRATE(id) (RFAL_ANALOG_CONFIG_BITRATE_MASK & (id)) /*!< Get Bitrate of Configuration ID */
#define RFAL_ANALOG_CONFIG_ID_IS_COMMON(id) (RFAL_ANALOG_CONFIG_BITRATE_MASK & (id)) /*!< Check if ID indicates common bitrate */
#define RFAL_ANALOG_CONFIG_ID_IS_106(id) (RFAL_ANALOG_CONFIG_BITRATE_106 & (id)) /*!< Check if ID indicates 106kbits/s */
#define RFAL_ANALOG_CONFIG_ID_IS_212(id) (RFAL_ANALOG_CONFIG_BITRATE_212 & (id)) /*!< Check if ID indicates 212kbits/s */
#define RFAL_ANALOG_CONFIG_ID_IS_424(id) (RFAL_ANALOG_CONFIG_BITRATE_424 & (id)) /*!< Check if ID indicates 424kbits/s */
#define RFAL_ANALOG_CONFIG_ID_IS_848(id) (RFAL_ANALOG_CONFIG_BITRATE_848 & (id)) /*!< Check if ID indicates 848kbits/s */
#define RFAL_ANALOG_CONFIG_ID_IS_1695(id) (RFAL_ANALOG_CONFIG_BITRATE_1695 & (id)) /*!< Check if ID indicates 1695kbits/s */
#define RFAL_ANALOG_CONFIG_ID_IS_3390(id) (RFAL_ANALOG_CONFIG_BITRATE_3390 & (id)) /*!< Check if ID indicates 3390kbits/s */
#define RFAL_ANALOG_CONFIG_ID_IS_6780(id) (RFAL_ANALOG_CONFIG_BITRATE_6780 & (id)) /*!< Check if ID indicates 6780kbits/s */
#define RFAL_ANALOG_CONFIG_ID_IS_1OF4(id) (RFAL_ANALOG_CONFIG_BITRATE_1OF4 & (id)) /*!< Check if ID indicates 1 out of 4 bitrate */
#define RFAL_ANALOG_CONFIG_ID_IS_1OF256(id) (RFAL_ANALOG_CONFIG_BITRATE_1OF256 & (id)) /*!< Check if ID indicates 1 out of 256 bitrate */
#define RFAL_ANALOG_CONFIG_ID_GET_BITRATE(id) \
(RFAL_ANALOG_CONFIG_BITRATE_MASK & (id)) /*!< Get Bitrate of Configuration ID */
#define RFAL_ANALOG_CONFIG_ID_IS_COMMON(id) \
(RFAL_ANALOG_CONFIG_BITRATE_MASK & (id)) /*!< Check if ID indicates common bitrate */
#define RFAL_ANALOG_CONFIG_ID_IS_106(id) \
(RFAL_ANALOG_CONFIG_BITRATE_106 & (id)) /*!< Check if ID indicates 106kbits/s */
#define RFAL_ANALOG_CONFIG_ID_IS_212(id) \
(RFAL_ANALOG_CONFIG_BITRATE_212 & (id)) /*!< Check if ID indicates 212kbits/s */
#define RFAL_ANALOG_CONFIG_ID_IS_424(id) \
(RFAL_ANALOG_CONFIG_BITRATE_424 & (id)) /*!< Check if ID indicates 424kbits/s */
#define RFAL_ANALOG_CONFIG_ID_IS_848(id) \
(RFAL_ANALOG_CONFIG_BITRATE_848 & (id)) /*!< Check if ID indicates 848kbits/s */
#define RFAL_ANALOG_CONFIG_ID_IS_1695(id) \
(RFAL_ANALOG_CONFIG_BITRATE_1695 & (id)) /*!< Check if ID indicates 1695kbits/s */
#define RFAL_ANALOG_CONFIG_ID_IS_3390(id) \
(RFAL_ANALOG_CONFIG_BITRATE_3390 & (id)) /*!< Check if ID indicates 3390kbits/s */
#define RFAL_ANALOG_CONFIG_ID_IS_6780(id) \
(RFAL_ANALOG_CONFIG_BITRATE_6780 & (id)) /*!< Check if ID indicates 6780kbits/s */
#define RFAL_ANALOG_CONFIG_ID_IS_1OF4(id) \
(RFAL_ANALOG_CONFIG_BITRATE_1OF4 & (id)) /*!< Check if ID indicates 1 out of 4 bitrate */
#define RFAL_ANALOG_CONFIG_ID_IS_1OF256(id) \
(RFAL_ANALOG_CONFIG_BITRATE_1OF256 & (id)) /*!< Check if ID indicates 1 out of 256 bitrate */
#define RFAL_ANALOG_CONFIG_ID_GET_DIRECTION(id) (RFAL_ANALOG_CONFIG_DIRECTION_MASK & (id)) /*!< Get Direction of Configuration ID */
#define RFAL_ANALOG_CONFIG_ID_IS_TX(id) (RFAL_ANALOG_CONFIG_TX & (id)) /*!< Check if id indicates TX */
#define RFAL_ANALOG_CONFIG_ID_IS_RX(id) (RFAL_ANALOG_CONFIG_RX & (id)) /*!< Check if id indicates RX */
#define RFAL_ANALOG_CONFIG_ID_GET_DIRECTION(id) \
(RFAL_ANALOG_CONFIG_DIRECTION_MASK & (id)) /*!< Get Direction of Configuration ID */
#define RFAL_ANALOG_CONFIG_ID_IS_TX(id) \
(RFAL_ANALOG_CONFIG_TX & (id)) /*!< Check if id indicates TX */
#define RFAL_ANALOG_CONFIG_ID_IS_RX(id) \
(RFAL_ANALOG_CONFIG_RX & (id)) /*!< Check if id indicates RX */
#define RFAL_ANALOG_CONFIG_CONFIG_NUM(x) (sizeof(x)/sizeof((x)[0])) /*!< Get Analog Config number */
#define RFAL_ANALOG_CONFIG_CONFIG_NUM(x) \
(sizeof(x) / sizeof((x)[0])) /*!< Get Analog Config number */
/*! Set Analog Config ID value by: Mode, Technology, Bitrate and Direction */
#define RFAL_ANALOG_CONFIG_ID_SET(mode, tech, br, direction) \
( RFAL_ANALOG_CONFIG_ID_GET_POLL_LISTEN(mode) \
| RFAL_ANALOG_CONFIG_ID_GET_TECH(tech) \
| RFAL_ANALOG_CONFIG_ID_GET_BITRATE(br) \
| RFAL_ANALOG_CONFIG_ID_GET_DIRECTION(direction) \
)
#define RFAL_ANALOG_CONFIG_ID_SET(mode, tech, br, direction) \
(RFAL_ANALOG_CONFIG_ID_GET_POLL_LISTEN(mode) | RFAL_ANALOG_CONFIG_ID_GET_TECH(tech) | \
RFAL_ANALOG_CONFIG_ID_GET_BITRATE(br) | RFAL_ANALOG_CONFIG_ID_GET_DIRECTION(direction))
/*
******************************************************************************
@@ -173,36 +241,44 @@
******************************************************************************
*/
typedef uint8_t rfalAnalogConfigMode; /*!< Polling or Listening Mode of Configuration */
typedef uint8_t rfalAnalogConfigTech; /*!< Technology of Configuration */
typedef uint8_t rfalAnalogConfigBitrate; /*!< Bitrate of Configuration */
typedef uint8_t rfalAnalogConfigDirection; /*!< Transmit/Receive direction of Configuration */
typedef uint8_t
rfalAnalogConfigMode; /*!< Polling or Listening Mode of Configuration */
typedef uint8_t
rfalAnalogConfigTech; /*!< Technology of Configuration */
typedef uint8_t
rfalAnalogConfigBitrate; /*!< Bitrate of Configuration */
typedef uint8_t
rfalAnalogConfigDirection; /*!< Transmit/Receive direction of Configuration */
typedef uint8_t rfalAnalogConfigRegAddr[2]; /*!< Register Address to ST Chip */
typedef uint8_t rfalAnalogConfigRegMask; /*!< Register Mask Value */
typedef uint8_t rfalAnalogConfigRegVal; /*!< Register Value */
typedef uint16_t rfalAnalogConfigId; /*!< Analog Configuration ID */
typedef uint16_t rfalAnalogConfigOffset; /*!< Analog Configuration offset address in the table */
typedef uint8_t rfalAnalogConfigNum; /*!< Number of Analog settings for the respective Configuration ID */
typedef uint8_t
rfalAnalogConfigRegAddr[2]; /*!< Register Address to ST Chip */
typedef uint8_t
rfalAnalogConfigRegMask; /*!< Register Mask Value */
typedef uint8_t
rfalAnalogConfigRegVal; /*!< Register Value */
typedef uint16_t
rfalAnalogConfigId; /*!< Analog Configuration ID */
typedef uint16_t
rfalAnalogConfigOffset; /*!< Analog Configuration offset address in the table */
typedef uint8_t
rfalAnalogConfigNum; /*!< Number of Analog settings for the respective Configuration ID */
/*! Struct that contain the Register-Mask-Value set. Make sure that the whole structure size is even and unaligned! */
typedef struct {
rfalAnalogConfigRegAddr addr; /*!< Register Address */
rfalAnalogConfigRegMask mask; /*!< Register Mask Value */
rfalAnalogConfigRegVal val; /*!< Register Value */
rfalAnalogConfigRegAddr addr; /*!< Register Address */
rfalAnalogConfigRegMask mask; /*!< Register Mask Value */
rfalAnalogConfigRegVal val; /*!< Register Value */
} rfalAnalogConfigRegAddrMaskVal;
/*! Struct that represents the Analog Configs */
typedef struct {
uint8_t id[sizeof(rfalAnalogConfigId)]; /*!< Configuration ID */
rfalAnalogConfigNum num; /*!< Number of Config Sets to follow */
rfalAnalogConfigRegAddrMaskVal regSet[]; /*!< Register-Mask-Value sets */ /* PRQA S 1060 # MISRA 18.7 - Flexible Array Members are the only meaningful way of denoting a variable length input buffer which follows a fixed header structure. */
uint8_t id[sizeof(rfalAnalogConfigId)]; /*!< Configuration ID */
rfalAnalogConfigNum num; /*!< Number of Config Sets to follow */
rfalAnalogConfigRegAddrMaskVal regSet[];
/*!< Register-Mask-Value sets */ /* PRQA S 1060 # MISRA 18.7 - Flexible Array Members are the only meaningful way of denoting a variable length input buffer which follows a fixed header structure. */
} rfalAnalogConfig;
/*
******************************************************************************
* GLOBAL FUNCTION PROTOTYPES
@@ -217,8 +293,7 @@ typedef struct {
*
*****************************************************************************
*/
void rfalAnalogConfigInitialize( void );
void rfalAnalogConfigInitialize(void);
/*!
*****************************************************************************
@@ -229,7 +304,7 @@ void rfalAnalogConfigInitialize( void );
*
*****************************************************************************
*/
bool rfalAnalogConfigIsReady( void );
bool rfalAnalogConfigIsReady(void);
/*!
*****************************************************************************
@@ -249,7 +324,7 @@ bool rfalAnalogConfigIsReady( void );
*
*****************************************************************************
*/
ReturnCode rfalAnalogConfigListWriteRaw( const uint8_t *configTbl, uint16_t configTblSize );
ReturnCode rfalAnalogConfigListWriteRaw(const uint8_t* configTbl, uint16_t configTblSize);
/*!
*****************************************************************************
@@ -271,7 +346,7 @@ ReturnCode rfalAnalogConfigListWriteRaw( const uint8_t *configTbl, uint16_t conf
*
*****************************************************************************
*/
ReturnCode rfalAnalogConfigListWrite( uint8_t more, const rfalAnalogConfig *config );
ReturnCode rfalAnalogConfigListWrite(uint8_t more, const rfalAnalogConfig* config);
/*!
*****************************************************************************
@@ -289,7 +364,8 @@ ReturnCode rfalAnalogConfigListWrite( uint8_t more, const rfalAnalogConfig *conf
*
*****************************************************************************
*/
ReturnCode rfalAnalogConfigListReadRaw( uint8_t *tblBuf, uint16_t tblBufLen, uint16_t *configTblSize );
ReturnCode
rfalAnalogConfigListReadRaw(uint8_t* tblBuf, uint16_t tblBufLen, uint16_t* configTblSize);
/*!
*****************************************************************************
@@ -308,7 +384,11 @@ ReturnCode rfalAnalogConfigListReadRaw( uint8_t *tblBuf, uint16_t tblBufLen, uin
*
*****************************************************************************
*/
ReturnCode rfalAnalogConfigListRead( rfalAnalogConfigOffset *configOffset, uint8_t *more, rfalAnalogConfig *config, rfalAnalogConfigNum numConfig );
ReturnCode rfalAnalogConfigListRead(
rfalAnalogConfigOffset* configOffset,
uint8_t* more,
rfalAnalogConfig* config,
rfalAnalogConfigNum numConfig);
/*!
*****************************************************************************
@@ -324,8 +404,7 @@ ReturnCode rfalAnalogConfigListRead( rfalAnalogConfigOffset *configOffset, uint8
*
*****************************************************************************
*/
ReturnCode rfalSetAnalogConfig( rfalAnalogConfigId configId );
ReturnCode rfalSetAnalogConfig(rfalAnalogConfigId configId);
/*!
*****************************************************************************
@@ -343,8 +422,7 @@ ReturnCode rfalSetAnalogConfig( rfalAnalogConfigId configId );
*
*****************************************************************************
*/
uint16_t rfalAnalogConfigGenModeID( rfalMode md, rfalBitRate br, uint16_t dir );
uint16_t rfalAnalogConfigGenModeID(rfalMode md, rfalBitRate br, uint16_t dir);
#endif /* RFAL_ANALOG_CONFIG_H */
+13 -22
View File
@@ -20,7 +20,6 @@
*
******************************************************************************/
/*
* PROJECT: ST25R391x firmware
* Revision:
@@ -50,7 +49,6 @@
*
*/
#ifndef RFAL_CHIP_H
#define RFAL_CHIP_H
@@ -63,7 +61,6 @@
#include "st_errno.h"
#include "rfal_rf.h"
/*****************************************************************************
* RF Chip *
*****************************************************************************/
@@ -85,7 +82,7 @@
* \return ERR_NONE : Write done with no error
*****************************************************************************
*/
ReturnCode rfalChipWriteReg( uint16_t reg, const uint8_t* values, uint8_t len );
ReturnCode rfalChipWriteReg(uint16_t reg, const uint8_t* values, uint8_t len);
/*!
*****************************************************************************
@@ -103,7 +100,7 @@ ReturnCode rfalChipWriteReg( uint16_t reg, const uint8_t* values, uint8_t len );
* \return ERR_NONE : Read done with no error
*****************************************************************************
*/
ReturnCode rfalChipReadReg( uint16_t reg, uint8_t* values, uint8_t len );
ReturnCode rfalChipReadReg(uint16_t reg, uint8_t* values, uint8_t len);
/*!
*****************************************************************************
@@ -120,7 +117,7 @@ ReturnCode rfalChipReadReg( uint16_t reg, uint8_t* values, uint8_t len );
* \return ERR_OK : Change done with no error
*****************************************************************************
*/
ReturnCode rfalChipChangeRegBits( uint16_t reg, uint8_t valueMask, uint8_t value );
ReturnCode rfalChipChangeRegBits(uint16_t reg, uint8_t valueMask, uint8_t value);
/*!
*****************************************************************************
@@ -137,7 +134,7 @@ ReturnCode rfalChipChangeRegBits( uint16_t reg, uint8_t valueMask, uint8_t value
* \return ERR_NONE : Write done with no error
*****************************************************************************
*/
ReturnCode rfalChipWriteTestReg( uint16_t reg, uint8_t value );
ReturnCode rfalChipWriteTestReg(uint16_t reg, uint8_t value);
/*!
*****************************************************************************
@@ -153,7 +150,7 @@ ReturnCode rfalChipWriteTestReg( uint16_t reg, uint8_t value );
* \return ERR_NONE : Read done with no error
*****************************************************************************
*/
ReturnCode rfalChipReadTestReg( uint16_t reg, uint8_t* value );
ReturnCode rfalChipReadTestReg(uint16_t reg, uint8_t* value);
/*!
*****************************************************************************
@@ -170,7 +167,7 @@ ReturnCode rfalChipReadTestReg( uint16_t reg, uint8_t* value );
* \return ERR_OK : Change done with no error
*****************************************************************************
*/
ReturnCode rfalChipChangeTestRegBits( uint16_t reg, uint8_t valueMask, uint8_t value );
ReturnCode rfalChipChangeTestRegBits(uint16_t reg, uint8_t valueMask, uint8_t value);
/*!
*****************************************************************************
@@ -186,7 +183,7 @@ ReturnCode rfalChipChangeTestRegBits( uint16_t reg, uint8_t valueMask, uint8_t v
* \return ERR_NONE : Direct command executed with no error
*****************************************************************************
*/
ReturnCode rfalChipExecCmd( uint16_t cmd );
ReturnCode rfalChipExecCmd(uint16_t cmd);
/*!
*****************************************************************************
@@ -201,8 +198,7 @@ ReturnCode rfalChipExecCmd( uint16_t cmd );
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalChipSetRFO( uint8_t rfo );
ReturnCode rfalChipSetRFO(uint8_t rfo);
/*!
*****************************************************************************
@@ -217,8 +213,7 @@ ReturnCode rfalChipSetRFO( uint8_t rfo );
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalChipGetRFO( uint8_t* result );
ReturnCode rfalChipGetRFO(uint8_t* result);
/*!
*****************************************************************************
@@ -233,8 +228,7 @@ ReturnCode rfalChipGetRFO( uint8_t* result );
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalChipMeasureAmplitude( uint8_t* result );
ReturnCode rfalChipMeasureAmplitude(uint8_t* result);
/*!
*****************************************************************************
@@ -249,8 +243,7 @@ ReturnCode rfalChipMeasureAmplitude( uint8_t* result );
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalChipMeasurePhase( uint8_t* result );
ReturnCode rfalChipMeasurePhase(uint8_t* result);
/*!
*****************************************************************************
@@ -265,8 +258,7 @@ ReturnCode rfalChipMeasurePhase( uint8_t* result );
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalChipMeasureCapacitance( uint8_t* result );
ReturnCode rfalChipMeasureCapacitance(uint8_t* result);
/*!
*****************************************************************************
@@ -282,8 +274,7 @@ ReturnCode rfalChipMeasureCapacitance( uint8_t* result );
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalChipMeasurePowerSupply( uint8_t param, uint8_t* result );
ReturnCode rfalChipMeasurePowerSupply(uint8_t param, uint8_t* result);
#endif /* RFAL_CHIP_H */
-1
View File
@@ -72,4 +72,3 @@
extern uint16_t rfalCrcCalculateCcitt(uint16_t preloadValue, const uint8_t* buf, uint16_t length);
#endif /* RFAL_CRC_H_ */
+11 -13
View File
@@ -48,7 +48,6 @@
*
*/
#ifndef RFAL_DPO_H
#define RFAL_DPO_H
@@ -66,8 +65,8 @@
******************************************************************************
*/
#define RFAL_DPO_TABLE_SIZE_MAX 15U /*!< Max DPO table size */
#define RFAL_DPO_TABLE_PARAMETER 3U /*!< DPO table Parameter length */
#define RFAL_DPO_TABLE_SIZE_MAX 15U /*!< Max DPO table size */
#define RFAL_DPO_TABLE_PARAMETER 3U /*!< DPO table Parameter length */
/*
******************************************************************************
@@ -78,9 +77,9 @@
/*! DPO table entry struct */
typedef struct {
uint8_t rfoRes; /*!< Setting for the resistance level of the RFO */
uint8_t inc; /*!< Threshold for incrementing the output power */
uint8_t dec; /*!< Threshold for decrementing the output power */
}rfalDpoEntry;
uint8_t inc; /*!< Threshold for incrementing the output power */
uint8_t dec; /*!< Threshold for decrementing the output power */
} rfalDpoEntry;
/*! Function pointer to methode doing the reference measurement */
typedef ReturnCode (*rfalDpoMeasureFunc)(uint8_t*);
@@ -91,7 +90,6 @@ typedef ReturnCode (*rfalDpoMeasureFunc)(uint8_t*);
******************************************************************************
*/
/*!
*****************************************************************************
* \brief Initialize dynamic power table
@@ -101,7 +99,7 @@ typedef ReturnCode (*rfalDpoMeasureFunc)(uint8_t*);
*
*****************************************************************************
*/
void rfalDpoInitialize( void );
void rfalDpoInitialize(void);
/*!
*****************************************************************************
@@ -114,7 +112,7 @@ void rfalDpoInitialize( void );
*
*****************************************************************************
*/
void rfalDpoSetMeasureCallback( rfalDpoMeasureFunc dpoMeasureFunc );
void rfalDpoSetMeasureCallback(rfalDpoMeasureFunc dpoMeasureFunc);
/*!
*****************************************************************************
@@ -130,7 +128,7 @@ void rfalDpoSetMeasureCallback( rfalDpoMeasureFunc dpoMeasureFunc );
* \return ERR_NOMEM : if the given Table is bigger exceeds the max size
*****************************************************************************
*/
ReturnCode rfalDpoTableWrite( rfalDpoEntry* powerTbl, uint8_t powerTblEntries );
ReturnCode rfalDpoTableWrite(rfalDpoEntry* powerTbl, uint8_t powerTblEntries);
/*!
*****************************************************************************
@@ -146,7 +144,7 @@ ReturnCode rfalDpoTableWrite( rfalDpoEntry* powerTbl, uint8_t powerTblEntries );
* \return ERR_PARAM : if configTbl is invalid or parameters are invalid
*****************************************************************************
*/
ReturnCode rfalDpoTableRead( rfalDpoEntry* tblBuf, uint8_t tblBufEntries, uint8_t* tableEntries );
ReturnCode rfalDpoTableRead(rfalDpoEntry* tblBuf, uint8_t tblBufEntries, uint8_t* tableEntries);
/*!
*****************************************************************************
@@ -160,7 +158,7 @@ ReturnCode rfalDpoTableRead( rfalDpoEntry* tblBuf, uint8_t tblBufEntries, uint8_
* \return ERR_WRONG_STATE : if the current state is valid for DPO Adjustment
*****************************************************************************
*/
ReturnCode rfalDpoAdjust( void );
ReturnCode rfalDpoAdjust(void);
/*!
*****************************************************************************
@@ -184,7 +182,7 @@ rfalDpoEntry* rfalDpoGetCurrentTableEntry(void);
*
*****************************************************************************
*/
void rfalDpoSetEnabled( bool enable );
void rfalDpoSetEnabled(bool enable);
/*!
*****************************************************************************
+38 -34
View File
@@ -54,26 +54,22 @@
******************************************************************************
*/
/*! Enum holding possible VCD codings */
typedef enum
{
ISO15693_VCD_CODING_1_4,
ISO15693_VCD_CODING_1_256
}iso15693VcdCoding_t;
typedef enum { ISO15693_VCD_CODING_1_4, ISO15693_VCD_CODING_1_256 } iso15693VcdCoding_t;
/*! Enum holding possible VICC datarates */
/*! Configuration parameter used by #iso15693PhyConfigure */
typedef struct
{
iso15693VcdCoding_t coding; /*!< desired VCD coding */
uint32_t speedMode; /*!< 0: normal mode, 1: 2^1 = x2 Fast mode, 2 : 2^2 = x4 mode, 3 : 2^3 = x8 mode - all rx pulse numbers and times are divided by 1,2,4,8 */
}iso15693PhyConfig_t;
typedef struct {
iso15693VcdCoding_t coding; /*!< desired VCD coding */
uint32_t
speedMode; /*!< 0: normal mode, 1: 2^1 = x2 Fast mode, 2 : 2^2 = x4 mode, 3 : 2^3 = x8 mode - all rx pulse numbers and times are divided by 1,2,4,8 */
} iso15693PhyConfig_t;
/*! Parameters how the stream mode should work */
struct iso15693StreamConfig {
uint8_t useBPSK; /*!< 0: subcarrier, 1:BPSK */
uint8_t din; /*!< the divider for the in subcarrier frequency: fc/2^din */
uint8_t dout; /*!< the divider for the in subcarrier frequency fc/2^dout */
uint8_t useBPSK; /*!< 0: subcarrier, 1:BPSK */
uint8_t din; /*!< the divider for the in subcarrier frequency: fc/2^din */
uint8_t dout; /*!< the divider for the in subcarrier frequency fc/2^dout */
uint8_t report_period_length; /*!< the length of the reporting period 2^report_period_length*/
};
/*
@@ -82,17 +78,17 @@ struct iso15693StreamConfig {
******************************************************************************
*/
#define ISO15693_REQ_FLAG_TWO_SUBCARRIERS 0x01U /*!< Flag indication that communication uses two subcarriers */
#define ISO15693_REQ_FLAG_HIGH_DATARATE 0x02U /*!< Flag indication that communication uses high bitrate */
#define ISO15693_MASK_FDT_LISTEN (65) /*!< t1min = 308,2us = 4192/fc = 65.5 * 64/fc */
#define ISO15693_REQ_FLAG_TWO_SUBCARRIERS \
0x01U /*!< Flag indication that communication uses two subcarriers */
#define ISO15693_REQ_FLAG_HIGH_DATARATE \
0x02U /*!< Flag indication that communication uses high bitrate */
#define ISO15693_MASK_FDT_LISTEN \
(65) /*!< t1min = 308,2us = 4192/fc = 65.5 * 64/fc */
/*! t1max = 323,3us = 4384/fc = 68.5 * 64/fc
* 12 = 768/fc unmodulated time of single subcarrior SoF */
#define ISO15693_FWT (69 + 12)
/*
******************************************************************************
* GLOBAL FUNCTION PROTOTYPES
@@ -111,8 +107,9 @@ struct iso15693StreamConfig {
*
*****************************************************************************
*/
extern ReturnCode iso15693PhyConfigure(const iso15693PhyConfig_t* config,
const struct iso15693StreamConfig ** needed_stream_config );
extern ReturnCode iso15693PhyConfigure(
const iso15693PhyConfig_t* config,
const struct iso15693StreamConfig** needed_stream_config);
/*!
*****************************************************************************
@@ -158,10 +155,17 @@ extern ReturnCode iso15693PhyGetConfiguration(iso15693PhyConfig_t* config);
*
*****************************************************************************
*/
extern ReturnCode iso15693VCDCode(uint8_t* buffer, uint16_t length, bool sendCrc, bool sendFlags, bool picopassMode,
uint16_t *subbit_total_length, uint16_t *offset,
uint8_t* outbuf, uint16_t outBufSize, uint16_t* actOutBufSize);
extern ReturnCode iso15693VCDCode(
uint8_t* buffer,
uint16_t length,
bool sendCrc,
bool sendFlags,
bool picopassMode,
uint16_t* subbit_total_length,
uint16_t* offset,
uint8_t* outbuf,
uint16_t outBufSize,
uint16_t* actOutBufSize);
/*!
*****************************************************************************
@@ -189,14 +193,14 @@ extern ReturnCode iso15693VCDCode(uint8_t* buffer, uint16_t length, bool sendCrc
*
*****************************************************************************
*/
extern ReturnCode iso15693VICCDecode(const uint8_t *inBuf,
uint16_t inBufLen,
uint8_t* outBuf,
uint16_t outBufLen,
uint16_t* outBufPos,
uint16_t* bitsBeforeCol,
uint16_t ignoreBits,
bool picopassMode );
extern ReturnCode iso15693VICCDecode(
const uint8_t* inBuf,
uint16_t inBufLen,
uint8_t* outBuf,
uint16_t outBufLen,
uint16_t* outBufPos,
uint16_t* bitsBeforeCol,
uint16_t ignoreBits,
bool picopassMode);
#endif /* RFAL_ISO_15693_2_H */
+382 -307
View File
@@ -20,7 +20,6 @@
*
******************************************************************************/
/*
* PROJECT: ST25R391x firmware
* Revision:
@@ -61,7 +60,6 @@
#include "platform.h"
#include "rfal_nfcb.h"
/*
******************************************************************************
* ENABLE SWITCH
@@ -69,16 +67,17 @@
*/
#ifndef RFAL_FEATURE_ISO_DEP
#define RFAL_FEATURE_ISO_DEP false /*!< ISO-DEP module configuration missing. Disabled by default */
#define RFAL_FEATURE_ISO_DEP \
false /*!< ISO-DEP module configuration missing. Disabled by default */
#endif
/* If module is disabled remove the need for the user to set lengths */
#if !RFAL_FEATURE_ISO_DEP
#undef RFAL_FEATURE_ISO_DEP_IBLOCK_MAX_LEN
#undef RFAL_FEATURE_ISO_DEP_APDU_MAX_LEN
#undef RFAL_FEATURE_ISO_DEP_IBLOCK_MAX_LEN
#undef RFAL_FEATURE_ISO_DEP_APDU_MAX_LEN
#define RFAL_FEATURE_ISO_DEP_IBLOCK_MAX_LEN (1U) /*!< ISO-DEP I-Block max length, set to "none" */
#define RFAL_FEATURE_ISO_DEP_APDU_MAX_LEN (1U) /*!< ISO-DEP APDU max length, set to "none" */
#define RFAL_FEATURE_ISO_DEP_IBLOCK_MAX_LEN (1U) /*!< ISO-DEP I-Block max length, set to "none" */
#define RFAL_FEATURE_ISO_DEP_APDU_MAX_LEN (1U) /*!< ISO-DEP APDU max length, set to "none" */
#endif /* !RFAL_FEATURE_NFC_DEP */
/*
@@ -87,127 +86,210 @@
******************************************************************************
*/
#define RFAL_ISODEP_PROLOGUE_SIZE (3U) /*!< Length of Prologue Field for I-Block Format */
#define RFAL_ISODEP_PROLOGUE_SIZE \
(3U) /*!< Length of Prologue Field for I-Block Format */
#define RFAL_ISODEP_PCB_LEN (1U) /*!< PCB length */
#define RFAL_ISODEP_DID_LEN (1U) /*!< DID length */
#define RFAL_ISODEP_NAD_LEN (1U) /*!< NAD length */
#define RFAL_ISODEP_NO_DID (0x00U) /*!< DID value indicating the ISO-DEP layer not to use DID */
#define RFAL_ISODEP_NO_NAD (0xFFU) /*!< NAD value indicating the ISO-DEP layer not to use NAD */
#define RFAL_ISODEP_PCB_LEN \
(1U) /*!< PCB length */
#define RFAL_ISODEP_DID_LEN \
(1U) /*!< DID length */
#define RFAL_ISODEP_NAD_LEN \
(1U) /*!< NAD length */
#define RFAL_ISODEP_NO_DID \
(0x00U) /*!< DID value indicating the ISO-DEP layer not to use DID */
#define RFAL_ISODEP_NO_NAD \
(0xFFU) /*!< NAD value indicating the ISO-DEP layer not to use NAD */
#define RFAL_ISODEP_FWI_MASK (0xF0U) /*!< Mask bits of FWI */
#define RFAL_ISODEP_FWI_SHIFT (4U) /*!< Shift val of FWI */
#define RFAL_ISODEP_FWI_DEFAULT (4U) /*!< Default value for FWI Digital 1.0 11.6.2.17 */
#define RFAL_ISODEP_ADV_FEATURE (0x0FU) /*!< Indicate 256 Bytes FSD and Advanc Proto Feature support:NAD & DID */
#define RFAL_ISODEP_FWI_MASK \
(0xF0U) /*!< Mask bits of FWI */
#define RFAL_ISODEP_FWI_SHIFT \
(4U) /*!< Shift val of FWI */
#define RFAL_ISODEP_FWI_DEFAULT \
(4U) /*!< Default value for FWI Digital 1.0 11.6.2.17 */
#define RFAL_ISODEP_ADV_FEATURE \
(0x0FU) /*!< Indicate 256 Bytes FSD and Advanc Proto Feature support:NAD & DID */
#define RFAL_ISODEP_DID_MAX (14U) /*!< Maximum DID value */
#define RFAL_ISODEP_DID_MAX \
(14U) /*!< Maximum DID value */
#define RFAL_ISODEP_BRI_MASK (0x07U) /*!< Mask bits for Poll to Listen Send bitrate */
#define RFAL_ISODEP_BSI_MASK (0x70U) /*!< Mask bits for Listen to Poll Send bitrate */
#define RFAL_ISODEP_SAME_BITRATE_MASK (0x80U) /*!< Mask bit indicate only same bit rate D for both direction support */
#define RFAL_ISODEP_BITRATE_RFU_MASK (0x08U) /*!< Mask bit for RFU */
#define RFAL_ISODEP_BRI_MASK \
(0x07U) /*!< Mask bits for Poll to Listen Send bitrate */
#define RFAL_ISODEP_BSI_MASK \
(0x70U) /*!< Mask bits for Listen to Poll Send bitrate */
#define RFAL_ISODEP_SAME_BITRATE_MASK \
(0x80U) /*!< Mask bit indicate only same bit rate D for both direction support */
#define RFAL_ISODEP_BITRATE_RFU_MASK \
(0x08U) /*!< Mask bit for RFU */
/*! Maximum Frame Waiting Time = ((256 * 16/fc) * 2^FWImax) = ((256*16/fc)*2^14) = (67108864)/fc = 2^26 (1/fc) */
#define RFAL_ISODEP_MAX_FWT ((uint32_t)1U<<26)
#define RFAL_ISODEP_MAX_FWT ((uint32_t)1U << 26)
#define RFAL_ISODEP_FSDI_DEFAULT \
RFAL_ISODEP_FSXI_256 /*!< Default Frame Size Integer in Poll mode */
#define RFAL_ISODEP_FSX_KEEP (0xFFU) /*!< Flag to keep FSX from activation */
#define RFAL_ISODEP_DEFAULT_FSCI \
RFAL_ISODEP_FSXI_256 /*!< FSCI default value to be used in Listen Mode */
#define RFAL_ISODEP_DEFAULT_FSC \
RFAL_ISODEP_FSX_256 /*!< FSC default value (aligned RFAL_ISODEP_DEFAULT_FSCI) */
#define RFAL_ISODEP_DEFAULT_SFGI (0U) /*!< SFGI Default value to be used in Listen Mode */
#define RFAL_ISODEP_DEFAULT_FWI (8U) /*!< Default Listener FWI (Max) Digital 2.0 B7 & B3 */
#define RFAL_ISODEP_APDU_MAX_LEN \
RFAL_ISODEP_FSX_1024 /*!< Max APDU length */
#define RFAL_ISODEP_FSDI_DEFAULT RFAL_ISODEP_FSXI_256 /*!< Default Frame Size Integer in Poll mode */
#define RFAL_ISODEP_FSX_KEEP (0xFFU) /*!< Flag to keep FSX from activation */
#define RFAL_ISODEP_DEFAULT_FSCI RFAL_ISODEP_FSXI_256 /*!< FSCI default value to be used in Listen Mode */
#define RFAL_ISODEP_DEFAULT_FSC RFAL_ISODEP_FSX_256 /*!< FSC default value (aligned RFAL_ISODEP_DEFAULT_FSCI) */
#define RFAL_ISODEP_DEFAULT_SFGI (0U) /*!< SFGI Default value to be used in Listen Mode */
#define RFAL_ISODEP_DEFAULT_FWI (8U) /*!< Default Listener FWI (Max) Digital 2.0 B7 & B3 */
#define RFAL_ISODEP_ATTRIB_RES_MBLI_NO_INFO \
(0x00U) /*!< MBLI indicating no information on its internal input buffer size */
#define RFAL_ISODEP_ATTRIB_REQ_PARAM1_DEFAULT \
(0x00U) /*!< Default values of Param 1 of ATTRIB_REQ Digital 1.0 12.6.1.3-5 */
#define RFAL_ISODEP_ATTRIB_HLINFO_LEN \
(32U) /*!< Maximum Size of Higher Layer Information */
#define RFAL_ISODEP_ATS_HB_MAX_LEN \
(15U) /*!< Maximum length of Historical Bytes Digital 1.1 13.6.2.23 */
#define RFAL_ISODEP_ATTRIB_REQ_MIN_LEN \
(9U) /*!< Minimum Length of ATTRIB_REQ command */
#define RFAL_ISODEP_ATTRIB_RES_MIN_LEN \
(1U) /*!< Minimum Length of ATTRIB_RES response */
#define RFAL_ISODEP_APDU_MAX_LEN RFAL_ISODEP_FSX_1024 /*!< Max APDU length */
#define RFAL_ISODEP_SPARAM_VALUES_MAX_LEN \
(16U) /*!< Maximum Length of the value field on S(PARAMETERS) */
#define RFAL_ISODEP_SPARAM_TAG_BLOCKINFO \
(0xA0U) /*!< S(PARAMETERS) tag Block information */
#define RFAL_ISODEP_SPARAM_TAG_BRREQ \
(0xA1U) /*!< S(PARAMETERS) tag Bit rates Request */
#define RFAL_ISODEP_SPARAM_TAG_BRIND \
(0xA2U) /*!< S(PARAMETERS) tag Bit rates Indication */
#define RFAL_ISODEP_SPARAM_TAG_BRACT \
(0xA3U) /*!< S(PARAMETERS) tag Bit rates Activation */
#define RFAL_ISODEP_SPARAM_TAG_BRACK \
(0xA4U) /*!< S(PARAMETERS) tag Bit rates Acknowledgement */
#define RFAL_ISODEP_ATTRIB_RES_MBLI_NO_INFO (0x00U) /*!< MBLI indicating no information on its internal input buffer size */
#define RFAL_ISODEP_ATTRIB_REQ_PARAM1_DEFAULT (0x00U) /*!< Default values of Param 1 of ATTRIB_REQ Digital 1.0 12.6.1.3-5 */
#define RFAL_ISODEP_ATTRIB_HLINFO_LEN (32U) /*!< Maximum Size of Higher Layer Information */
#define RFAL_ISODEP_ATS_HB_MAX_LEN (15U) /*!< Maximum length of Historical Bytes Digital 1.1 13.6.2.23 */
#define RFAL_ISODEP_ATTRIB_REQ_MIN_LEN (9U) /*!< Minimum Length of ATTRIB_REQ command */
#define RFAL_ISODEP_ATTRIB_RES_MIN_LEN (1U) /*!< Minimum Length of ATTRIB_RES response */
#define RFAL_ISODEP_SPARAM_TAG_SUP_PCD2PICC \
(0x80U) /*!< S(PARAMETERS) tag Supported bit rates from PCD to PICC */
#define RFAL_ISODEP_SPARAM_TAG_SUP_PICC2PCD \
(0x81U) /*!< S(PARAMETERS) tag Supported bit rates from PICC to PCD */
#define RFAL_ISODEP_SPARAM_TAG_SUP_FRAME \
(0x82U) /*!< S(PARAMETERS) tag Supported framing options PICC to PCD */
#define RFAL_ISODEP_SPARAM_TAG_SEL_PCD2PICC \
(0x83U) /*!< S(PARAMETERS) tag Selected bit rate from PCD to PICC */
#define RFAL_ISODEP_SPARAM_TAG_SEL_PICC2PCD \
(0x84U) /*!< S(PARAMETERS) tag Selected bit rate from PICC to PCD */
#define RFAL_ISODEP_SPARAM_TAG_SEL_FRAME \
(0x85U) /*!< S(PARAMETERS) tag Selected framing options PICC to PCD */
#define RFAL_ISODEP_SPARAM_VALUES_MAX_LEN (16U) /*!< Maximum Length of the value field on S(PARAMETERS) */
#define RFAL_ISODEP_SPARAM_TAG_BLOCKINFO (0xA0U) /*!< S(PARAMETERS) tag Block information */
#define RFAL_ISODEP_SPARAM_TAG_BRREQ (0xA1U) /*!< S(PARAMETERS) tag Bit rates Request */
#define RFAL_ISODEP_SPARAM_TAG_BRIND (0xA2U) /*!< S(PARAMETERS) tag Bit rates Indication */
#define RFAL_ISODEP_SPARAM_TAG_BRACT (0xA3U) /*!< S(PARAMETERS) tag Bit rates Activation */
#define RFAL_ISODEP_SPARAM_TAG_BRACK (0xA4U) /*!< S(PARAMETERS) tag Bit rates Acknowledgement */
#define RFAL_ISODEP_SPARAM_TAG_LEN \
(1) /*!< S(PARAMETERS) Tag Length */
#define RFAL_ISODEP_SPARAM_TAG_BRREQ_LEN \
(0U) /*!< S(PARAMETERS) tag Bit rates Request Length */
#define RFAL_ISODEP_SPARAM_TAG_PICC2PCD_LEN \
(2U) /*!< S(PARAMETERS) bit rates from PCD to PICC Length */
#define RFAL_ISODEP_SPARAM_TAG_PCD2PICC_LEN \
(2U) /*!< S(PARAMETERS) bit rates from PICC to PCD Length */
#define RFAL_ISODEP_SPARAM_TAG_BRACK_LEN \
(0U) /*!< S(PARAMETERS) tag Bit rates Acknowledgement Length */
#define RFAL_ISODEP_SPARAM_TAG_SUP_PCD2PICC (0x80U) /*!< S(PARAMETERS) tag Supported bit rates from PCD to PICC */
#define RFAL_ISODEP_SPARAM_TAG_SUP_PICC2PCD (0x81U) /*!< S(PARAMETERS) tag Supported bit rates from PICC to PCD */
#define RFAL_ISODEP_SPARAM_TAG_SUP_FRAME (0x82U) /*!< S(PARAMETERS) tag Supported framing options PICC to PCD */
#define RFAL_ISODEP_SPARAM_TAG_SEL_PCD2PICC (0x83U) /*!< S(PARAMETERS) tag Selected bit rate from PCD to PICC */
#define RFAL_ISODEP_SPARAM_TAG_SEL_PICC2PCD (0x84U) /*!< S(PARAMETERS) tag Selected bit rate from PICC to PCD */
#define RFAL_ISODEP_SPARAM_TAG_SEL_FRAME (0x85U) /*!< S(PARAMETERS) tag Selected framing options PICC to PCD */
#define RFAL_ISODEP_ATS_TA_DPL_212 \
(0x01U) /*!< ATS TA DSI 212 kbps support bit mask */
#define RFAL_ISODEP_ATS_TA_DPL_424 \
(0x02U) /*!< ATS TA DSI 424 kbps support bit mask */
#define RFAL_ISODEP_ATS_TA_DPL_848 \
(0x04U) /*!< ATS TA DSI 848 kbps support bit mask */
#define RFAL_ISODEP_ATS_TA_DLP_212 \
(0x10U) /*!< ATS TA DSI 212 kbps support bit mask */
#define RFAL_ISODEP_ATS_TA_DLP_424 \
(0x20U) /*!< ATS TA DRI 424 kbps support bit mask */
#define RFAL_ISODEP_ATS_TA_DLP_848 \
(0x40U) /*!< ATS TA DRI 848 kbps support bit mask */
#define RFAL_ISODEP_ATS_TA_SAME_D \
(0x80U) /*!< ATS TA same bit both directions bit mask */
#define RFAL_ISODEP_ATS_TB_FWI_MASK \
(0xF0U) /*!< Mask bits for FWI (Frame Waiting Integer) in TB byte */
#define RFAL_ISODEP_ATS_TB_SFGI_MASK \
(0x0FU) /*!< Mask bits for SFGI (Start-Up Frame Guard Integer) in TB byte */
#define RFAL_ISODEP_SPARAM_TAG_LEN (1) /*!< S(PARAMETERS) Tag Length */
#define RFAL_ISODEP_SPARAM_TAG_BRREQ_LEN (0U) /*!< S(PARAMETERS) tag Bit rates Request Length */
#define RFAL_ISODEP_SPARAM_TAG_PICC2PCD_LEN (2U) /*!< S(PARAMETERS) bit rates from PCD to PICC Length */
#define RFAL_ISODEP_SPARAM_TAG_PCD2PICC_LEN (2U) /*!< S(PARAMETERS) bit rates from PICC to PCD Length */
#define RFAL_ISODEP_SPARAM_TAG_BRACK_LEN (0U) /*!< S(PARAMETERS) tag Bit rates Acknowledgement Length */
#define RFAL_ISODEP_ATS_T0_TA_PRESENCE_MASK \
(0x10U) /*!< Mask bit for TA presence */
#define RFAL_ISODEP_ATS_T0_TB_PRESENCE_MASK \
(0x20U) /*!< Mask bit for TB presence */
#define RFAL_ISODEP_ATS_T0_TC_PRESENCE_MASK \
(0x40U) /*!< Mask bit for TC presence */
#define RFAL_ISODEP_ATS_T0_FSCI_MASK \
(0x0FU) /*!< Mask bit for FSCI presence */
#define RFAL_ISODEP_ATS_T0_OFFSET \
(0x01U) /*!< Offset of T0 in ATS Response */
#define RFAL_ISODEP_ATS_TA_DPL_212 (0x01U) /*!< ATS TA DSI 212 kbps support bit mask */
#define RFAL_ISODEP_ATS_TA_DPL_424 (0x02U) /*!< ATS TA DSI 424 kbps support bit mask */
#define RFAL_ISODEP_ATS_TA_DPL_848 (0x04U) /*!< ATS TA DSI 848 kbps support bit mask */
#define RFAL_ISODEP_ATS_TA_DLP_212 (0x10U) /*!< ATS TA DSI 212 kbps support bit mask */
#define RFAL_ISODEP_ATS_TA_DLP_424 (0x20U) /*!< ATS TA DRI 424 kbps support bit mask */
#define RFAL_ISODEP_ATS_TA_DLP_848 (0x40U) /*!< ATS TA DRI 848 kbps support bit mask */
#define RFAL_ISODEP_ATS_TA_SAME_D (0x80U) /*!< ATS TA same bit both directions bit mask */
#define RFAL_ISODEP_ATS_TB_FWI_MASK (0xF0U) /*!< Mask bits for FWI (Frame Waiting Integer) in TB byte */
#define RFAL_ISODEP_ATS_TB_SFGI_MASK (0x0FU) /*!< Mask bits for SFGI (Start-Up Frame Guard Integer) in TB byte */
#define RFAL_ISODEP_ATS_T0_TA_PRESENCE_MASK (0x10U) /*!< Mask bit for TA presence */
#define RFAL_ISODEP_ATS_T0_TB_PRESENCE_MASK (0x20U) /*!< Mask bit for TB presence */
#define RFAL_ISODEP_ATS_T0_TC_PRESENCE_MASK (0x40U) /*!< Mask bit for TC presence */
#define RFAL_ISODEP_ATS_T0_FSCI_MASK (0x0FU) /*!< Mask bit for FSCI presence */
#define RFAL_ISODEP_ATS_T0_OFFSET (0x01U) /*!< Offset of T0 in ATS Response */
#define RFAL_ISODEP_MAX_I_RETRYS (2U) /*!< Number of retries for a I-Block Digital 2.0 16.2.5.4 */
#define RFAL_ISODEP_MAX_R_RETRYS (3U) /*!< Number of retries for a R-Block Digital 2.0 B9 - nRETRY ACK/NAK: [2,5] */
#define RFAL_ISODEP_MAX_WTX_NACK_RETRYS (3U) /*!< Number of S(WTX) replied with NACK Digital 2.0 B9 - nRETRY WTX[2,5] */
#define RFAL_ISODEP_MAX_WTX_RETRYS (20U) /*!< Number of overall S(WTX) retries Digital 2.0 16.2.5.2 */
#define RFAL_ISODEP_MAX_WTX_RETRYS_ULTD (255U) /*!< Use unlimited number of overall S(WTX) */
#define RFAL_ISODEP_MAX_DSL_RETRYS (0U) /*!< Number of retries for a S(DESELECT) Digital 2.0 B9 - nRETRY DESELECT: [0,5] */
#define RFAL_ISODEP_RATS_RETRIES (1U) /*!< RATS retries upon fail Digital 2.0 B7 - nRETRY RATS [0,1] */
#define RFAL_ISODEP_MAX_I_RETRYS \
(2U) /*!< Number of retries for a I-Block Digital 2.0 16.2.5.4 */
#define RFAL_ISODEP_MAX_R_RETRYS \
(3U) /*!< Number of retries for a R-Block Digital 2.0 B9 - nRETRY ACK/NAK: [2,5] */
#define RFAL_ISODEP_MAX_WTX_NACK_RETRYS \
(3U) /*!< Number of S(WTX) replied with NACK Digital 2.0 B9 - nRETRY WTX[2,5] */
#define RFAL_ISODEP_MAX_WTX_RETRYS \
(20U) /*!< Number of overall S(WTX) retries Digital 2.0 16.2.5.2 */
#define RFAL_ISODEP_MAX_WTX_RETRYS_ULTD \
(255U) /*!< Use unlimited number of overall S(WTX) */
#define RFAL_ISODEP_MAX_DSL_RETRYS \
(0U) /*!< Number of retries for a S(DESELECT) Digital 2.0 B9 - nRETRY DESELECT: [0,5] */
#define RFAL_ISODEP_RATS_RETRIES \
(1U) /*!< RATS retries upon fail Digital 2.0 B7 - nRETRY RATS [0,1] */
/*! Frame Size for Proximity Card Integer definitions */
typedef enum
{
RFAL_ISODEP_FSXI_16 = 0, /*!< Frame Size for Proximity Card Integer with 16 bytes */
RFAL_ISODEP_FSXI_24 = 1, /*!< Frame Size for Proximity Card Integer with 24 bytes */
RFAL_ISODEP_FSXI_32 = 2, /*!< Frame Size for Proximity Card Integer with 32 bytes */
RFAL_ISODEP_FSXI_40 = 3, /*!< Frame Size for Proximity Card Integer with 40 bytes */
RFAL_ISODEP_FSXI_48 = 4, /*!< Frame Size for Proximity Card Integer with 48 bytes */
RFAL_ISODEP_FSXI_64 = 5, /*!< Frame Size for Proximity Card Integer with 64 bytes */
RFAL_ISODEP_FSXI_96 = 6, /*!< Frame Size for Proximity Card Integer with 96 bytes */
RFAL_ISODEP_FSXI_128 = 7, /*!< Frame Size for Proximity Card Integer with 128 bytes */
RFAL_ISODEP_FSXI_256 = 8, /*!< Frame Size for Proximity Card Integer with 256 bytes */
RFAL_ISODEP_FSXI_512 = 9, /*!< Frame Size for Proximity Card Integer with 512 bytes ISO14443-3 Amd2 2012 */
RFAL_ISODEP_FSXI_1024 = 10, /*!< Frame Size for Proximity Card Integer with 1024 bytes ISO14443-3 Amd2 2012 */
RFAL_ISODEP_FSXI_2048 = 11, /*!< Frame Size for Proximity Card Integer with 2048 bytes ISO14443-3 Amd2 2012 */
RFAL_ISODEP_FSXI_4096 = 12 /*!< Frame Size for Proximity Card Integer with 4096 bytes ISO14443-3 Amd2 2012 */
typedef enum {
RFAL_ISODEP_FSXI_16 =
0, /*!< Frame Size for Proximity Card Integer with 16 bytes */
RFAL_ISODEP_FSXI_24 =
1, /*!< Frame Size for Proximity Card Integer with 24 bytes */
RFAL_ISODEP_FSXI_32 =
2, /*!< Frame Size for Proximity Card Integer with 32 bytes */
RFAL_ISODEP_FSXI_40 =
3, /*!< Frame Size for Proximity Card Integer with 40 bytes */
RFAL_ISODEP_FSXI_48 =
4, /*!< Frame Size for Proximity Card Integer with 48 bytes */
RFAL_ISODEP_FSXI_64 =
5, /*!< Frame Size for Proximity Card Integer with 64 bytes */
RFAL_ISODEP_FSXI_96 =
6, /*!< Frame Size for Proximity Card Integer with 96 bytes */
RFAL_ISODEP_FSXI_128 =
7, /*!< Frame Size for Proximity Card Integer with 128 bytes */
RFAL_ISODEP_FSXI_256 =
8, /*!< Frame Size for Proximity Card Integer with 256 bytes */
RFAL_ISODEP_FSXI_512 =
9, /*!< Frame Size for Proximity Card Integer with 512 bytes ISO14443-3 Amd2 2012 */
RFAL_ISODEP_FSXI_1024 =
10, /*!< Frame Size for Proximity Card Integer with 1024 bytes ISO14443-3 Amd2 2012 */
RFAL_ISODEP_FSXI_2048 =
11, /*!< Frame Size for Proximity Card Integer with 2048 bytes ISO14443-3 Amd2 2012 */
RFAL_ISODEP_FSXI_4096 =
12 /*!< Frame Size for Proximity Card Integer with 4096 bytes ISO14443-3 Amd2 2012 */
} rfalIsoDepFSxI;
/*! Frame Size for Proximity Card definitions */
typedef enum
{
RFAL_ISODEP_FSX_16 = 16, /*!< Frame Size for Proximity Card with 16 bytes */
RFAL_ISODEP_FSX_24 = 24, /*!< Frame Size for Proximity Card with 24 bytes */
RFAL_ISODEP_FSX_32 = 32, /*!< Frame Size for Proximity Card with 32 bytes */
RFAL_ISODEP_FSX_40 = 40, /*!< Frame Size for Proximity Card with 40 bytes */
RFAL_ISODEP_FSX_48 = 48, /*!< Frame Size for Proximity Card with 48 bytes */
RFAL_ISODEP_FSX_64 = 64, /*!< Frame Size for Proximity Card with 64 bytes */
RFAL_ISODEP_FSX_96 = 96, /*!< Frame Size for Proximity Card with 96 bytes */
RFAL_ISODEP_FSX_128 = 128, /*!< Frame Size for Proximity Card with 128 bytes */
RFAL_ISODEP_FSX_256 = 256, /*!< Frame Size for Proximity Card with 256 bytes */
RFAL_ISODEP_FSX_512 = 512, /*!< Frame Size for Proximity Card with 512 bytes ISO14443-3 Amd2 2012 */
RFAL_ISODEP_FSX_1024 = 1024, /*!< Frame Size for Proximity Card with 1024 bytes ISO14443-3 Amd2 2012 */
RFAL_ISODEP_FSX_2048 = 2048, /*!< Frame Size for Proximity Card with 2048 bytes ISO14443-3 Amd2 2012 */
RFAL_ISODEP_FSX_4096 = 4096, /*!< Frame Size for Proximity Card with 4096 bytes ISO14443-3 Amd2 2012 */
typedef enum {
RFAL_ISODEP_FSX_16 =
16, /*!< Frame Size for Proximity Card with 16 bytes */
RFAL_ISODEP_FSX_24 =
24, /*!< Frame Size for Proximity Card with 24 bytes */
RFAL_ISODEP_FSX_32 =
32, /*!< Frame Size for Proximity Card with 32 bytes */
RFAL_ISODEP_FSX_40 =
40, /*!< Frame Size for Proximity Card with 40 bytes */
RFAL_ISODEP_FSX_48 =
48, /*!< Frame Size for Proximity Card with 48 bytes */
RFAL_ISODEP_FSX_64 =
64, /*!< Frame Size for Proximity Card with 64 bytes */
RFAL_ISODEP_FSX_96 =
96, /*!< Frame Size for Proximity Card with 96 bytes */
RFAL_ISODEP_FSX_128 =
128, /*!< Frame Size for Proximity Card with 128 bytes */
RFAL_ISODEP_FSX_256 =
256, /*!< Frame Size for Proximity Card with 256 bytes */
RFAL_ISODEP_FSX_512 =
512, /*!< Frame Size for Proximity Card with 512 bytes ISO14443-3 Amd2 2012 */
RFAL_ISODEP_FSX_1024 =
1024, /*!< Frame Size for Proximity Card with 1024 bytes ISO14443-3 Amd2 2012 */
RFAL_ISODEP_FSX_2048 =
2048, /*!< Frame Size for Proximity Card with 2048 bytes ISO14443-3 Amd2 2012 */
RFAL_ISODEP_FSX_4096 =
4096, /*!< Frame Size for Proximity Card with 4096 bytes ISO14443-3 Amd2 2012 */
} rfalIsoDepFSx;
/*
@@ -223,205 +305,177 @@ typedef enum
*/
/*! RATS format Digital 1.1 13.6.1 */
typedef struct
{
uint8_t CMD; /*!< RATS command byte: 0xE0 */
uint8_t PARAM; /*!< Param indicating FSDI and DID */
typedef struct {
uint8_t CMD; /*!< RATS command byte: 0xE0 */
uint8_t PARAM; /*!< Param indicating FSDI and DID */
} rfalIsoDepRats;
/*! ATS response format Digital 1.1 13.6.2 */
typedef struct
{
uint8_t TL; /*!< Length Byte, including TL byte itself */
uint8_t T0; /*!< Format Byte T0 indicating if TA, TB, TC */
uint8_t TA; /*!< Interface Byte TA(1) */
uint8_t TB; /*!< Interface Byte TB(1) */
uint8_t TC; /*!< Interface Byte TC(1) */
uint8_t HB[RFAL_ISODEP_ATS_HB_MAX_LEN]; /*!< Historical Bytes */
typedef struct {
uint8_t TL; /*!< Length Byte, including TL byte itself */
uint8_t T0; /*!< Format Byte T0 indicating if TA, TB, TC */
uint8_t TA; /*!< Interface Byte TA(1) */
uint8_t TB; /*!< Interface Byte TB(1) */
uint8_t TC; /*!< Interface Byte TC(1) */
uint8_t HB[RFAL_ISODEP_ATS_HB_MAX_LEN]; /*!< Historical Bytes */
} rfalIsoDepAts;
/*! PPS Request format (Protocol and Parameter Selection) ISO14443-4 5.3 */
typedef struct
{
uint8_t PPSS; /*!< Start Byte: [ 1101b | CID[4b] ] */
uint8_t PPS0; /*!< Parameter 0:[ 000b | PPS1[1n] | 0001b ] */
uint8_t PPS1; /*!< Parameter 1:[ 0000b | DSI[2b] | DRI[2b] ]*/
typedef struct {
uint8_t PPSS; /*!< Start Byte: [ 1101b | CID[4b] ] */
uint8_t PPS0; /*!< Parameter 0:[ 000b | PPS1[1n] | 0001b ] */
uint8_t PPS1; /*!< Parameter 1:[ 0000b | DSI[2b] | DRI[2b] ]*/
} rfalIsoDepPpsReq;
/*! PPS Response format (Protocol and Parameter Selection) ISO14443-4 5.4 */
typedef struct
{
uint8_t PPSS; /*!< Start Byte: [ 1101b | CID[4b] ] */
typedef struct {
uint8_t PPSS; /*!< Start Byte: [ 1101b | CID[4b] ] */
} rfalIsoDepPpsRes;
/*! ATTRIB Command Format Digital 1.1 15.6.1 */
typedef struct
{
uint8_t cmd; /*!< ATTRIB_REQ command byte */
uint8_t nfcid0[RFAL_NFCB_NFCID0_LEN]; /*!< NFCID0 of the card to be selected */
struct{
uint8_t PARAM1; /*!< PARAM1 of ATTRIB command */
uint8_t PARAM2; /*!< PARAM2 of ATTRIB command */
uint8_t PARAM3; /*!< PARAM3 of ATTRIB command */
uint8_t PARAM4; /*!< PARAM4 of ATTRIB command */
}Param; /*!< Parameter of ATTRIB command */
uint8_t HLInfo[RFAL_ISODEP_ATTRIB_HLINFO_LEN]; /*!< Higher Layer Information */
typedef struct {
uint8_t cmd; /*!< ATTRIB_REQ command byte */
uint8_t nfcid0[RFAL_NFCB_NFCID0_LEN]; /*!< NFCID0 of the card to be selected */
struct {
uint8_t PARAM1; /*!< PARAM1 of ATTRIB command */
uint8_t PARAM2; /*!< PARAM2 of ATTRIB command */
uint8_t PARAM3; /*!< PARAM3 of ATTRIB command */
uint8_t PARAM4; /*!< PARAM4 of ATTRIB command */
} Param; /*!< Parameter of ATTRIB command */
uint8_t HLInfo[RFAL_ISODEP_ATTRIB_HLINFO_LEN]; /*!< Higher Layer Information */
} rfalIsoDepAttribCmd;
/*! ATTRIB Response Format Digital 1.1 15.6.2 */
typedef struct
{
uint8_t mbliDid; /*!< Contains MBLI and DID */
uint8_t HLInfo[RFAL_ISODEP_ATTRIB_HLINFO_LEN]; /*!< Higher Layer Information */
typedef struct {
uint8_t mbliDid; /*!< Contains MBLI and DID */
uint8_t HLInfo[RFAL_ISODEP_ATTRIB_HLINFO_LEN]; /*!< Higher Layer Information */
} rfalIsoDepAttribRes;
/*! S(Parameters) Command Format ISO14443-4 (2016) Table 4 */
typedef struct
{
uint8_t tag; /*!< S(PARAMETERS) Tag field */
uint8_t length; /*!< S(PARAMETERS) Length field */
uint8_t value[RFAL_ISODEP_SPARAM_VALUES_MAX_LEN]; /*!< S(PARAMETERS) Value field */
typedef struct {
uint8_t tag; /*!< S(PARAMETERS) Tag field */
uint8_t length; /*!< S(PARAMETERS) Length field */
uint8_t value[RFAL_ISODEP_SPARAM_VALUES_MAX_LEN]; /*!< S(PARAMETERS) Value field */
} rfalIsoDepSParameter;
/*! Activation info as Poller and Listener for NFC-A and NFC-B */
typedef union {/* PRQA S 0750 # MISRA 19.2 - Both members of the union will not be used concurrently, device is only of type A or B at a time. Thus no problem can occur. */
typedef union { /* PRQA S 0750 # MISRA 19.2 - Both members of the union will not be used concurrently, device is only of type A or B at a time. Thus no problem can occur. */
/*! NFC-A information */
union {/* PRQA S 0750 # MISRA 19.2 - Both members of the union will not be used concurrently, device is only PCD or PICC at a time. Thus no problem can occur. */
union { /* PRQA S 0750 # MISRA 19.2 - Both members of the union will not be used concurrently, device is only PCD or PICC at a time. Thus no problem can occur. */
struct {
rfalIsoDepAts ATS; /*!< ATS response (Poller mode) */
uint8_t ATSLen; /*!< ATS response length (Poller mode) */
}Listener;
rfalIsoDepAts ATS; /*!< ATS response (Poller mode) */
uint8_t ATSLen; /*!< ATS response length (Poller mode) */
} Listener;
struct {
rfalIsoDepRats RATS; /*!< RATS request (Listener mode) */
}Poller;
}A;
/*! NFC-B information */
union {/* PRQA S 0750 # MISRA 19.2 - Both members of the union will not be used concurrently, device is only PCD or PICC at a time. Thus no problem can occur. */
struct{
rfalIsoDepAttribRes ATTRIB_RES; /*!< ATTRIB_RES (Poller mode) */
uint8_t ATTRIB_RESLen; /*!< ATTRIB_RES length (Poller mode) */
}Listener;
struct{
rfalIsoDepAttribCmd ATTRIB; /*!< ATTRIB request (Listener mode) */
uint8_t ATTRIBLen; /*!< ATTRIB request length (Listener mode) */
}Poller;
}B;
}rfalIsoDepActivation;
rfalIsoDepRats RATS; /*!< RATS request (Listener mode) */
} Poller;
} A;
/*! NFC-B information */
union { /* PRQA S 0750 # MISRA 19.2 - Both members of the union will not be used concurrently, device is only PCD or PICC at a time. Thus no problem can occur. */
struct {
rfalIsoDepAttribRes ATTRIB_RES; /*!< ATTRIB_RES (Poller mode) */
uint8_t ATTRIB_RESLen; /*!< ATTRIB_RES length (Poller mode) */
} Listener;
struct {
rfalIsoDepAttribCmd ATTRIB; /*!< ATTRIB request (Listener mode) */
uint8_t ATTRIBLen; /*!< ATTRIB request length (Listener mode) */
} Poller;
} B;
} rfalIsoDepActivation;
/*! ISO-DEP device Info */
typedef struct {
uint8_t FWI; /*!< Frame Waiting Integer */
uint32_t FWT; /*!< Frame Waiting Time (1/fc) */
uint32_t dFWT; /*!< Delta Frame Waiting Time (1/fc) */
uint32_t SFGI; /*!< Start-up Frame Guard time Integer */
uint32_t SFGT; /*!< Start-up Frame Guard Time (ms) */
uint8_t FSxI; /*!< Frame Size Device/Card Integer (FSDI or FSCI) */
uint16_t FSx; /*!< Frame Size Device/Card (FSD or FSC) */
uint32_t MBL; /*!< Maximum Buffer Length (optional for NFC-B) */
rfalBitRate DSI; /*!< Bit Rate coding from Listener (PICC) to Poller (PCD) */
rfalBitRate DRI; /*!< Bit Rate coding from Poller (PCD) to Listener (PICC) */
uint8_t DID; /*!< Device ID */
uint8_t NAD; /*!< Node ADdress */
bool supDID; /*!< DID supported flag */
bool supNAD; /*!< NAD supported flag */
bool supAdFt; /*!< Advanced Features supported flag */
uint8_t FWI; /*!< Frame Waiting Integer */
uint32_t FWT; /*!< Frame Waiting Time (1/fc) */
uint32_t dFWT; /*!< Delta Frame Waiting Time (1/fc) */
uint32_t SFGI; /*!< Start-up Frame Guard time Integer */
uint32_t SFGT; /*!< Start-up Frame Guard Time (ms) */
uint8_t FSxI; /*!< Frame Size Device/Card Integer (FSDI or FSCI) */
uint16_t FSx; /*!< Frame Size Device/Card (FSD or FSC) */
uint32_t MBL; /*!< Maximum Buffer Length (optional for NFC-B) */
rfalBitRate DSI; /*!< Bit Rate coding from Listener (PICC) to Poller (PCD) */
rfalBitRate DRI; /*!< Bit Rate coding from Poller (PCD) to Listener (PICC) */
uint8_t DID; /*!< Device ID */
uint8_t NAD; /*!< Node ADdress */
bool supDID; /*!< DID supported flag */
bool supNAD; /*!< NAD supported flag */
bool supAdFt; /*!< Advanced Features supported flag */
} rfalIsoDepInfo;
/*! ISO-DEP Device structure */
typedef struct {
rfalIsoDepActivation activation; /*!< Activation Info */
rfalIsoDepInfo info; /*!< ISO-DEP (ISO14443-4) device Info */
rfalIsoDepActivation activation; /*!< Activation Info */
rfalIsoDepInfo info; /*!< ISO-DEP (ISO14443-4) device Info */
} rfalIsoDepDevice;
/*! ATTRIB Response parameters */
typedef struct
{
uint8_t mbli; /*!< MBLI */
uint8_t HLInfo[RFAL_ISODEP_ATTRIB_HLINFO_LEN]; /*!< Hi Layer Information */
uint8_t HLInfoLen; /*!< Hi Layer Information Length */
typedef struct {
uint8_t mbli; /*!< MBLI */
uint8_t HLInfo[RFAL_ISODEP_ATTRIB_HLINFO_LEN]; /*!< Hi Layer Information */
uint8_t HLInfoLen; /*!< Hi Layer Information Length */
} rfalIsoDepAttribResParam;
/*! ATS Response parameter */
typedef struct
{
uint8_t fsci; /*!< Frame Size of Proximity Card Integer */
uint8_t fwi; /*!< Frame Waiting Time Integer */
uint8_t sfgi; /*!< Start-Up Frame Guard Time Integer */
bool didSupport; /*!< DID Supported */
uint8_t ta; /*!< Max supported bitrate both direction */
uint8_t *hb; /*!< Historical Bytes data */
uint8_t hbLen; /*!< Historical Bytes Length */
typedef struct {
uint8_t fsci; /*!< Frame Size of Proximity Card Integer */
uint8_t fwi; /*!< Frame Waiting Time Integer */
uint8_t sfgi; /*!< Start-Up Frame Guard Time Integer */
bool didSupport; /*!< DID Supported */
uint8_t ta; /*!< Max supported bitrate both direction */
uint8_t* hb; /*!< Historical Bytes data */
uint8_t hbLen; /*!< Historical Bytes Length */
} rfalIsoDepAtsParam;
/*! Structure of I-Block Buffer format from caller */
typedef struct
{
uint8_t prologue[RFAL_ISODEP_PROLOGUE_SIZE]; /*!< Prologue/SoD buffer */
uint8_t inf[RFAL_FEATURE_ISO_DEP_IBLOCK_MAX_LEN]; /*!< INF/Payload buffer */
typedef struct {
uint8_t prologue[RFAL_ISODEP_PROLOGUE_SIZE]; /*!< Prologue/SoD buffer */
uint8_t
inf[RFAL_FEATURE_ISO_DEP_IBLOCK_MAX_LEN]; /*!< INF/Payload buffer */
} rfalIsoDepBufFormat;
/*! Structure of APDU Buffer format from caller */
typedef struct
{
uint8_t prologue[RFAL_ISODEP_PROLOGUE_SIZE]; /*!< Prologue/SoD buffer */
uint8_t apdu[RFAL_FEATURE_ISO_DEP_APDU_MAX_LEN]; /*!< APDU/Payload buffer */
typedef struct {
uint8_t prologue[RFAL_ISODEP_PROLOGUE_SIZE]; /*!< Prologue/SoD buffer */
uint8_t apdu[RFAL_FEATURE_ISO_DEP_APDU_MAX_LEN]; /*!< APDU/Payload buffer */
} rfalIsoDepApduBufFormat;
/*! Listen Activation Parameters Structure */
typedef struct
{
rfalIsoDepBufFormat *rxBuf; /*!< Receive Buffer struct reference */
uint16_t *rxLen; /*!< Received INF data length in Bytes */
bool *isRxChaining; /*!< Received data is not complete */
rfalIsoDepDevice *isoDepDev; /*!< ISO-DEP device info */
typedef struct {
rfalIsoDepBufFormat* rxBuf; /*!< Receive Buffer struct reference */
uint16_t* rxLen; /*!< Received INF data length in Bytes */
bool* isRxChaining; /*!< Received data is not complete */
rfalIsoDepDevice* isoDepDev; /*!< ISO-DEP device info */
} rfalIsoDepListenActvParam;
/*! Structure of parameters used on ISO DEP Transceive */
typedef struct
{
rfalIsoDepBufFormat *txBuf; /*!< Transmit Buffer struct reference */
uint16_t txBufLen; /*!< Transmit Buffer INF field length in Bytes*/
bool isTxChaining; /*!< Transmit data is not complete */
rfalIsoDepBufFormat *rxBuf; /*!< Receive Buffer struct reference in Bytes */
uint16_t *rxLen; /*!< Received INF data length in Bytes */
bool *isRxChaining; /*!< Received data is not complete */
uint32_t FWT; /*!< FWT to be used (ignored in Listen Mode) */
uint32_t dFWT; /*!< Delta FWT to be used */
uint16_t ourFSx; /*!< Our device Frame Size (FSD or FSC) */
uint16_t FSx; /*!< Other device Frame Size (FSD or FSC) */
uint8_t DID; /*!< Device ID (RFAL_ISODEP_NO_DID if no DID) */
typedef struct {
rfalIsoDepBufFormat* txBuf; /*!< Transmit Buffer struct reference */
uint16_t txBufLen; /*!< Transmit Buffer INF field length in Bytes*/
bool isTxChaining; /*!< Transmit data is not complete */
rfalIsoDepBufFormat* rxBuf; /*!< Receive Buffer struct reference in Bytes */
uint16_t* rxLen; /*!< Received INF data length in Bytes */
bool* isRxChaining; /*!< Received data is not complete */
uint32_t FWT; /*!< FWT to be used (ignored in Listen Mode) */
uint32_t dFWT; /*!< Delta FWT to be used */
uint16_t ourFSx; /*!< Our device Frame Size (FSD or FSC) */
uint16_t FSx; /*!< Other device Frame Size (FSD or FSC) */
uint8_t DID; /*!< Device ID (RFAL_ISODEP_NO_DID if no DID) */
} rfalIsoDepTxRxParam;
/*! Structure of parameters used on ISO DEP APDU Transceive */
typedef struct
{
rfalIsoDepApduBufFormat *txBuf; /*!< Transmit Buffer struct reference */
uint16_t txBufLen; /*!< Transmit Buffer INF field length in Bytes*/
rfalIsoDepApduBufFormat *rxBuf; /*!< Receive Buffer struct reference in Bytes */
uint16_t *rxLen; /*!< Received INF data length in Bytes */
rfalIsoDepBufFormat *tmpBuf; /*!< Temp buffer for Rx I-Blocks (internal) */
uint32_t FWT; /*!< FWT to be used (ignored in Listen Mode) */
uint32_t dFWT; /*!< Delta FWT to be used */
uint16_t FSx; /*!< Other device Frame Size (FSD or FSC) */
uint16_t ourFSx; /*!< Our device Frame Size (FSD or FSC) */
uint8_t DID; /*!< Device ID (RFAL_ISODEP_NO_DID if no DID) */
typedef struct {
rfalIsoDepApduBufFormat* txBuf; /*!< Transmit Buffer struct reference */
uint16_t txBufLen; /*!< Transmit Buffer INF field length in Bytes*/
rfalIsoDepApduBufFormat* rxBuf; /*!< Receive Buffer struct reference in Bytes */
uint16_t* rxLen; /*!< Received INF data length in Bytes */
rfalIsoDepBufFormat* tmpBuf; /*!< Temp buffer for Rx I-Blocks (internal) */
uint32_t FWT; /*!< FWT to be used (ignored in Listen Mode) */
uint32_t dFWT; /*!< Delta FWT to be used */
uint16_t FSx; /*!< Other device Frame Size (FSD or FSC) */
uint16_t ourFSx; /*!< Our device Frame Size (FSD or FSC) */
uint8_t DID; /*!< Device ID (RFAL_ISODEP_NO_DID if no DID) */
} rfalIsoDepApduTxRxParam;
/*
@@ -430,7 +484,6 @@ typedef struct
******************************************************************************
*/
/*!
******************************************************************************
* \brief Initialize the ISO-DEP protocol
@@ -438,8 +491,7 @@ typedef struct
* Initialize the ISO-DEP protocol layer with default config
******************************************************************************
*/
void rfalIsoDepInitialize( void );
void rfalIsoDepInitialize(void);
/*!
******************************************************************************
@@ -466,14 +518,14 @@ void rfalIsoDepInitialize( void );
*
******************************************************************************
*/
void rfalIsoDepInitializeWithParams( rfalComplianceMode compMode,
uint8_t maxRetriesR,
uint8_t maxRetriesSnWTX,
uint8_t maxRetriesSWTX,
uint8_t maxRetriesSDSL,
uint8_t maxRetriesI,
uint8_t maxRetriesRATS );
void rfalIsoDepInitializeWithParams(
rfalComplianceMode compMode,
uint8_t maxRetriesR,
uint8_t maxRetriesSnWTX,
uint8_t maxRetriesSWTX,
uint8_t maxRetriesSDSL,
uint8_t maxRetriesI,
uint8_t maxRetriesRATS);
/*!
*****************************************************************************
@@ -496,8 +548,7 @@ void rfalIsoDepInitializeWithParams( rfalComplianceMode compMode,
*
*****************************************************************************
*/
uint16_t rfalIsoDepFSxI2FSx( uint8_t FSxI );
uint16_t rfalIsoDepFSxI2FSx(uint8_t FSxI);
/*!
*****************************************************************************
@@ -512,8 +563,7 @@ uint16_t rfalIsoDepFSxI2FSx( uint8_t FSxI );
*
*****************************************************************************
*/
uint32_t rfalIsoDepFWI2FWT( uint8_t fwi );
uint32_t rfalIsoDepFWI2FWT(uint8_t fwi);
/*!
*****************************************************************************
@@ -528,8 +578,7 @@ uint32_t rfalIsoDepFWI2FWT( uint8_t fwi );
* \return true if the data indicates a RATS command; false otherwise
*****************************************************************************
*/
bool rfalIsoDepIsRats( const uint8_t *buf, uint8_t bufLen );
bool rfalIsoDepIsRats(const uint8_t* buf, uint8_t bufLen);
/*!
*****************************************************************************
@@ -544,8 +593,7 @@ bool rfalIsoDepIsRats( const uint8_t *buf, uint8_t bufLen );
* \return true if the data indicates a ATTRIB command; false otherwise
*****************************************************************************
*/
bool rfalIsoDepIsAttrib( const uint8_t *buf, uint8_t bufLen );
bool rfalIsoDepIsAttrib(const uint8_t* buf, uint8_t bufLen);
/*!
*****************************************************************************
@@ -585,8 +633,12 @@ bool rfalIsoDepIsAttrib( const uint8_t *buf, uint8_t bufLen );
* \return ERR_NOTSUPP : Feature not supported
*****************************************************************************
*/
ReturnCode rfalIsoDepListenStartActivation( rfalIsoDepAtsParam *atsParam, const rfalIsoDepAttribResParam *attribResParam, const uint8_t *buf, uint16_t bufLen, rfalIsoDepListenActvParam actParam );
ReturnCode rfalIsoDepListenStartActivation(
rfalIsoDepAtsParam* atsParam,
const rfalIsoDepAttribResParam* attribResParam,
const uint8_t* buf,
uint16_t bufLen,
rfalIsoDepListenActvParam actParam);
/*!
*****************************************************************************
@@ -597,8 +649,7 @@ ReturnCode rfalIsoDepListenStartActivation( rfalIsoDepAtsParam *atsParam, const
* \return ERR_LINK_LOSS if Remote Field is turned off
*****************************************************************************
*/
ReturnCode rfalIsoDepListenGetActivationStatus( void );
ReturnCode rfalIsoDepListenGetActivationStatus(void);
/*!
*****************************************************************************
@@ -610,8 +661,7 @@ ReturnCode rfalIsoDepListenGetActivationStatus( void );
* \return maximum INF length in bytes
*****************************************************************************
*/
uint16_t rfalIsoDepGetMaxInfLen( void );
uint16_t rfalIsoDepGetMaxInfLen(void);
/*!
*****************************************************************************
@@ -635,8 +685,7 @@ uint16_t rfalIsoDepGetMaxInfLen( void );
* \return ERR_NONE : The Transceive request has been started
*****************************************************************************
*/
ReturnCode rfalIsoDepStartTransceive( rfalIsoDepTxRxParam param );
ReturnCode rfalIsoDepStartTransceive(rfalIsoDepTxRxParam param);
/*!
*****************************************************************************
@@ -666,8 +715,7 @@ ReturnCode rfalIsoDepStartTransceive( rfalIsoDepTxRxParam param );
* this method to retrieve the remaining blocks
*****************************************************************************
*/
ReturnCode rfalIsoDepGetTransceiveStatus( void );
ReturnCode rfalIsoDepGetTransceiveStatus(void);
/*!
*****************************************************************************
@@ -690,8 +738,7 @@ ReturnCode rfalIsoDepGetTransceiveStatus( void );
* \return ERR_NONE : The Transceive request has been started
*****************************************************************************
*/
ReturnCode rfalIsoDepStartApduTransceive( rfalIsoDepApduTxRxParam param );
ReturnCode rfalIsoDepStartApduTransceive(rfalIsoDepApduTxRxParam param);
/*!
*****************************************************************************
@@ -708,7 +755,7 @@ ReturnCode rfalIsoDepStartApduTransceive( rfalIsoDepApduTxRxParam param );
* has turned off its field
*****************************************************************************
*/
ReturnCode rfalIsoDepGetApduTransceiveStatus( void );
ReturnCode rfalIsoDepGetApduTransceiveStatus(void);
/*!
*****************************************************************************
@@ -733,8 +780,7 @@ ReturnCode rfalIsoDepGetApduTransceiveStatus( void );
* \return ERR_NONE : No error, ATS received
*****************************************************************************
*/
ReturnCode rfalIsoDepRATS( rfalIsoDepFSxI FSDI, uint8_t DID, rfalIsoDepAts *ats , uint8_t *atsLen );
ReturnCode rfalIsoDepRATS(rfalIsoDepFSxI FSDI, uint8_t DID, rfalIsoDepAts* ats, uint8_t* atsLen);
/*!
*****************************************************************************
@@ -760,8 +806,7 @@ ReturnCode rfalIsoDepRATS( rfalIsoDepFSxI FSDI, uint8_t DID, rfalIsoDepAts *ats
* \return ERR_NONE : No error, PPS Response received
*****************************************************************************
*/
ReturnCode rfalIsoDepPPS( uint8_t DID, rfalBitRate DSI, rfalBitRate DRI, rfalIsoDepPpsRes *ppsRes );
ReturnCode rfalIsoDepPPS(uint8_t DID, rfalBitRate DSI, rfalBitRate DRI, rfalIsoDepPpsRes* ppsRes);
/*!
*****************************************************************************
@@ -793,8 +838,19 @@ ReturnCode rfalIsoDepPPS( uint8_t DID, rfalBitRate DSI, rfalBitRate DRI, rfalIso
* \return ERR_NONE : No error, ATTRIB Response received
*****************************************************************************
*/
ReturnCode rfalIsoDepATTRIB( const uint8_t* nfcid0, uint8_t PARAM1, rfalBitRate DSI, rfalBitRate DRI, rfalIsoDepFSxI FSDI, uint8_t PARAM3, uint8_t DID, const uint8_t* HLInfo, uint8_t HLInfoLen, uint32_t fwt, rfalIsoDepAttribRes *attribRes, uint8_t *attribResLen );
ReturnCode rfalIsoDepATTRIB(
const uint8_t* nfcid0,
uint8_t PARAM1,
rfalBitRate DSI,
rfalBitRate DRI,
rfalIsoDepFSxI FSDI,
uint8_t PARAM3,
uint8_t DID,
const uint8_t* HLInfo,
uint8_t HLInfoLen,
uint32_t fwt,
rfalIsoDepAttribRes* attribRes,
uint8_t* attribResLen);
/*!
*****************************************************************************
@@ -808,8 +864,7 @@ ReturnCode rfalIsoDepATTRIB( const uint8_t* nfcid0, uint8_t PARAM1, rfalBitRate
*
*****************************************************************************
*/
ReturnCode rfalIsoDepDeselect( void );
ReturnCode rfalIsoDepDeselect(void);
/*!
*****************************************************************************
@@ -836,8 +891,11 @@ ReturnCode rfalIsoDepDeselect( void );
* \return ERR_NONE : No error, activation successful
*****************************************************************************
*/
ReturnCode rfalIsoDepPollAHandleActivation( rfalIsoDepFSxI FSDI, uint8_t DID, rfalBitRate maxBR, rfalIsoDepDevice *isoDepDev );
ReturnCode rfalIsoDepPollAHandleActivation(
rfalIsoDepFSxI FSDI,
uint8_t DID,
rfalBitRate maxBR,
rfalIsoDepDevice* isoDepDev);
/*!
*****************************************************************************
@@ -868,8 +926,15 @@ ReturnCode rfalIsoDepPollAHandleActivation( rfalIsoDepFSxI FSDI, uint8_t DID, rf
* \return ERR_NONE : No error, activation successful
*****************************************************************************
*/
ReturnCode rfalIsoDepPollBHandleActivation( rfalIsoDepFSxI FSDI, uint8_t DID, rfalBitRate maxBR, uint8_t PARAM1, const rfalNfcbListenDevice *nfcbDev, const uint8_t* HLInfo, uint8_t HLInfoLen, rfalIsoDepDevice *isoDepDev );
ReturnCode rfalIsoDepPollBHandleActivation(
rfalIsoDepFSxI FSDI,
uint8_t DID,
rfalBitRate maxBR,
uint8_t PARAM1,
const rfalNfcbListenDevice* nfcbDev,
const uint8_t* HLInfo,
uint8_t HLInfoLen,
rfalIsoDepDevice* isoDepDev);
/*!
*****************************************************************************
@@ -892,8 +957,10 @@ ReturnCode rfalIsoDepPollBHandleActivation( rfalIsoDepFSxI FSDI, uint8_t DID, rf
* \return ERR_NONE : No error, S(PARAMETERS) selection successful
*****************************************************************************
*/
ReturnCode rfalIsoDepPollHandleSParameters( rfalIsoDepDevice *isoDepDev, rfalBitRate maxTxBR, rfalBitRate maxRxBR );
ReturnCode rfalIsoDepPollHandleSParameters(
rfalIsoDepDevice* isoDepDev,
rfalBitRate maxTxBR,
rfalBitRate maxRxBR);
/*!
*****************************************************************************
@@ -923,8 +990,11 @@ ReturnCode rfalIsoDepPollHandleSParameters( rfalIsoDepDevice *isoDepDev, rfalBit
* \return ERR_NONE : No error, start of asynchronous operation successful
*****************************************************************************
*/
ReturnCode rfalIsoDepPollAStartActivation( rfalIsoDepFSxI FSDI, uint8_t DID, rfalBitRate maxBR, rfalIsoDepDevice *isoDepDev );
ReturnCode rfalIsoDepPollAStartActivation(
rfalIsoDepFSxI FSDI,
uint8_t DID,
rfalBitRate maxBR,
rfalIsoDepDevice* isoDepDev);
/*!
*****************************************************************************
@@ -946,8 +1016,7 @@ ReturnCode rfalIsoDepPollAStartActivation( rfalIsoDepFSxI FSDI, uint8_t DID, rfa
* \return ERR_NONE : No error, activation successful
*****************************************************************************
*/
ReturnCode rfalIsoDepPollAGetActivationStatus( void );
ReturnCode rfalIsoDepPollAGetActivationStatus(void);
/*!
*****************************************************************************
@@ -980,8 +1049,15 @@ ReturnCode rfalIsoDepPollAGetActivationStatus( void );
* \return ERR_NONE : No error, start of asynchronous operation successful
*****************************************************************************
*/
ReturnCode rfalIsoDepPollBStartActivation( rfalIsoDepFSxI FSDI, uint8_t DID, rfalBitRate maxBR, uint8_t PARAM1, const rfalNfcbListenDevice *nfcbDev, const uint8_t* HLInfo, uint8_t HLInfoLen, rfalIsoDepDevice *isoDepDev );
ReturnCode rfalIsoDepPollBStartActivation(
rfalIsoDepFSxI FSDI,
uint8_t DID,
rfalBitRate maxBR,
uint8_t PARAM1,
const rfalNfcbListenDevice* nfcbDev,
const uint8_t* HLInfo,
uint8_t HLInfoLen,
rfalIsoDepDevice* isoDepDev);
/*!
*****************************************************************************
@@ -1003,8 +1079,7 @@ ReturnCode rfalIsoDepPollBStartActivation( rfalIsoDepFSxI FSDI, uint8_t DID, rfa
* \return ERR_NONE : No error, activation successful
*****************************************************************************
*/
ReturnCode rfalIsoDepPollBGetActivationStatus( void );
ReturnCode rfalIsoDepPollBGetActivationStatus(void);
#endif /* RFAL_ISODEP_H_ */
+116 -116
View File
@@ -20,7 +20,6 @@
*
******************************************************************************/
/*
* PROJECT: ST25R391x firmware
* Revision:
@@ -73,25 +72,23 @@
#include "rfal_nfcDep.h"
#include "rfal_isoDep.h"
/*
******************************************************************************
* GLOBAL DEFINES
******************************************************************************
*/
#define RFAL_NFC_TECH_NONE 0x0000U /*!< No technology */
#define RFAL_NFC_POLL_TECH_A 0x0001U /*!< NFC-A technology Flag */
#define RFAL_NFC_POLL_TECH_B 0x0002U /*!< NFC-B technology Flag */
#define RFAL_NFC_POLL_TECH_F 0x0004U /*!< NFC-F technology Flag */
#define RFAL_NFC_POLL_TECH_V 0x0008U /*!< NFC-V technology Flag */
#define RFAL_NFC_POLL_TECH_AP2P 0x0010U /*!< AP2P technology Flag */
#define RFAL_NFC_POLL_TECH_ST25TB 0x0020U /*!< ST25TB technology Flag */
#define RFAL_NFC_LISTEN_TECH_A 0x1000U /*!< NFC-V technology Flag */
#define RFAL_NFC_LISTEN_TECH_B 0x2000U /*!< NFC-V technology Flag */
#define RFAL_NFC_LISTEN_TECH_F 0x4000U /*!< NFC-V technology Flag */
#define RFAL_NFC_LISTEN_TECH_AP2P 0x8000U /*!< NFC-V technology Flag */
#define RFAL_NFC_TECH_NONE 0x0000U /*!< No technology */
#define RFAL_NFC_POLL_TECH_A 0x0001U /*!< NFC-A technology Flag */
#define RFAL_NFC_POLL_TECH_B 0x0002U /*!< NFC-B technology Flag */
#define RFAL_NFC_POLL_TECH_F 0x0004U /*!< NFC-F technology Flag */
#define RFAL_NFC_POLL_TECH_V 0x0008U /*!< NFC-V technology Flag */
#define RFAL_NFC_POLL_TECH_AP2P 0x0010U /*!< AP2P technology Flag */
#define RFAL_NFC_POLL_TECH_ST25TB 0x0020U /*!< ST25TB technology Flag */
#define RFAL_NFC_LISTEN_TECH_A 0x1000U /*!< NFC-V technology Flag */
#define RFAL_NFC_LISTEN_TECH_B 0x2000U /*!< NFC-V technology Flag */
#define RFAL_NFC_LISTEN_TECH_F 0x4000U /*!< NFC-V technology Flag */
#define RFAL_NFC_LISTEN_TECH_AP2P 0x8000U /*!< NFC-V technology Flag */
/*
******************************************************************************
@@ -100,16 +97,20 @@
*/
/*! Checks if a device is currently activated */
#define rfalNfcIsDevActivated( st ) ( ((st)>= RFAL_NFC_STATE_ACTIVATED) && ((st)<RFAL_NFC_STATE_DEACTIVATION) )
#define rfalNfcIsDevActivated(st) \
(((st) >= RFAL_NFC_STATE_ACTIVATED) && ((st) < RFAL_NFC_STATE_DEACTIVATION))
/*! Checks if a device is in discovery */
#define rfalNfcIsInDiscovery( st ) ( ((st)>= RFAL_NFC_STATE_START_DISCOVERY) && ((st)<RFAL_NFC_STATE_ACTIVATED) )
#define rfalNfcIsInDiscovery(st) \
(((st) >= RFAL_NFC_STATE_START_DISCOVERY) && ((st) < RFAL_NFC_STATE_ACTIVATED))
/*! Checks if remote device is in Poll mode */
#define rfalNfcIsRemDevPoller( tp ) ( ((tp)>= RFAL_NFC_POLL_TYPE_NFCA) && ((tp)<=RFAL_NFC_POLL_TYPE_AP2P ) )
#define rfalNfcIsRemDevPoller(tp) \
(((tp) >= RFAL_NFC_POLL_TYPE_NFCA) && ((tp) <= RFAL_NFC_POLL_TYPE_AP2P))
/*! Checks if remote device is in Listen mode */
#define rfalNfcIsRemDevListener( tp ) ( ((int16_t)(tp)>= (int16_t)RFAL_NFC_LISTEN_TYPE_NFCA) && ((tp)<=RFAL_NFC_LISTEN_TYPE_AP2P) )
#define rfalNfcIsRemDevListener(tp) \
(((int16_t)(tp) >= (int16_t)RFAL_NFC_LISTEN_TYPE_NFCA) && ((tp) <= RFAL_NFC_LISTEN_TYPE_AP2P))
/*
******************************************************************************
@@ -124,106 +125,101 @@
*/
/*! Main state */
typedef enum{
RFAL_NFC_STATE_NOTINIT = 0, /*!< Not Initialized state */
RFAL_NFC_STATE_IDLE = 1, /*!< Initialize state */
RFAL_NFC_STATE_START_DISCOVERY = 2, /*!< Start Discovery loop state */
RFAL_NFC_STATE_WAKEUP_MODE = 3, /*!< Wake-Up state */
RFAL_NFC_STATE_POLL_TECHDETECT = 10, /*!< Technology Detection state */
RFAL_NFC_STATE_POLL_COLAVOIDANCE = 11, /*!< Collision Avoidance state */
RFAL_NFC_STATE_POLL_SELECT = 12, /*!< Wait for Selection state */
RFAL_NFC_STATE_POLL_ACTIVATION = 13, /*!< Activation state */
RFAL_NFC_STATE_LISTEN_TECHDETECT = 20, /*!< Listen Tech Detect */
RFAL_NFC_STATE_LISTEN_COLAVOIDANCE = 21, /*!< Listen Collision Avoidance */
RFAL_NFC_STATE_LISTEN_ACTIVATION = 22, /*!< Listen Activation state */
RFAL_NFC_STATE_LISTEN_SLEEP = 23, /*!< Listen Sleep state */
RFAL_NFC_STATE_ACTIVATED = 30, /*!< Activated state */
RFAL_NFC_STATE_DATAEXCHANGE = 31, /*!< Data Exchange Start state */
RFAL_NFC_STATE_DATAEXCHANGE_DONE = 33, /*!< Data Exchange terminated */
RFAL_NFC_STATE_DEACTIVATION = 34 /*!< Deactivation state */
}rfalNfcState;
typedef enum {
RFAL_NFC_STATE_NOTINIT = 0, /*!< Not Initialized state */
RFAL_NFC_STATE_IDLE = 1, /*!< Initialize state */
RFAL_NFC_STATE_START_DISCOVERY = 2, /*!< Start Discovery loop state */
RFAL_NFC_STATE_WAKEUP_MODE = 3, /*!< Wake-Up state */
RFAL_NFC_STATE_POLL_TECHDETECT = 10, /*!< Technology Detection state */
RFAL_NFC_STATE_POLL_COLAVOIDANCE = 11, /*!< Collision Avoidance state */
RFAL_NFC_STATE_POLL_SELECT = 12, /*!< Wait for Selection state */
RFAL_NFC_STATE_POLL_ACTIVATION = 13, /*!< Activation state */
RFAL_NFC_STATE_LISTEN_TECHDETECT = 20, /*!< Listen Tech Detect */
RFAL_NFC_STATE_LISTEN_COLAVOIDANCE = 21, /*!< Listen Collision Avoidance */
RFAL_NFC_STATE_LISTEN_ACTIVATION = 22, /*!< Listen Activation state */
RFAL_NFC_STATE_LISTEN_SLEEP = 23, /*!< Listen Sleep state */
RFAL_NFC_STATE_ACTIVATED = 30, /*!< Activated state */
RFAL_NFC_STATE_DATAEXCHANGE = 31, /*!< Data Exchange Start state */
RFAL_NFC_STATE_DATAEXCHANGE_DONE = 33, /*!< Data Exchange terminated */
RFAL_NFC_STATE_DEACTIVATION = 34 /*!< Deactivation state */
} rfalNfcState;
/*! Device type */
typedef enum{
RFAL_NFC_LISTEN_TYPE_NFCA = 0, /*!< NFC-A Listener device type */
RFAL_NFC_LISTEN_TYPE_NFCB = 1, /*!< NFC-B Listener device type */
RFAL_NFC_LISTEN_TYPE_NFCF = 2, /*!< NFC-F Listener device type */
RFAL_NFC_LISTEN_TYPE_NFCV = 3, /*!< NFC-V Listener device type */
RFAL_NFC_LISTEN_TYPE_ST25TB = 4, /*!< ST25TB Listener device type */
RFAL_NFC_LISTEN_TYPE_AP2P = 5, /*!< AP2P Listener device type */
RFAL_NFC_POLL_TYPE_NFCA = 10, /*!< NFC-A Poller device type */
RFAL_NFC_POLL_TYPE_NFCB = 11, /*!< NFC-B Poller device type */
RFAL_NFC_POLL_TYPE_NFCF = 12, /*!< NFC-F Poller device type */
RFAL_NFC_POLL_TYPE_NFCV = 13, /*!< NFC-V Poller device type */
RFAL_NFC_POLL_TYPE_AP2P = 15 /*!< AP2P Poller device type */
}rfalNfcDevType;
typedef enum {
RFAL_NFC_LISTEN_TYPE_NFCA = 0, /*!< NFC-A Listener device type */
RFAL_NFC_LISTEN_TYPE_NFCB = 1, /*!< NFC-B Listener device type */
RFAL_NFC_LISTEN_TYPE_NFCF = 2, /*!< NFC-F Listener device type */
RFAL_NFC_LISTEN_TYPE_NFCV = 3, /*!< NFC-V Listener device type */
RFAL_NFC_LISTEN_TYPE_ST25TB = 4, /*!< ST25TB Listener device type */
RFAL_NFC_LISTEN_TYPE_AP2P = 5, /*!< AP2P Listener device type */
RFAL_NFC_POLL_TYPE_NFCA = 10, /*!< NFC-A Poller device type */
RFAL_NFC_POLL_TYPE_NFCB = 11, /*!< NFC-B Poller device type */
RFAL_NFC_POLL_TYPE_NFCF = 12, /*!< NFC-F Poller device type */
RFAL_NFC_POLL_TYPE_NFCV = 13, /*!< NFC-V Poller device type */
RFAL_NFC_POLL_TYPE_AP2P = 15 /*!< AP2P Poller device type */
} rfalNfcDevType;
/*! Device interface */
typedef enum{
RFAL_NFC_INTERFACE_RF = 0, /*!< RF Frame interface */
RFAL_NFC_INTERFACE_ISODEP = 1, /*!< ISO-DEP interface */
RFAL_NFC_INTERFACE_NFCDEP = 2 /*!< NFC-DEP interface */
}rfalNfcRfInterface;
typedef enum {
RFAL_NFC_INTERFACE_RF = 0, /*!< RF Frame interface */
RFAL_NFC_INTERFACE_ISODEP = 1, /*!< ISO-DEP interface */
RFAL_NFC_INTERFACE_NFCDEP = 2 /*!< NFC-DEP interface */
} rfalNfcRfInterface;
/*! Device struct containing all its details */
typedef struct{
rfalNfcDevType type; /*!< Device's type */
union{ /* PRQA S 0750 # MISRA 19.2 - Members of the union will not be used concurrently, only one technology at a time */
rfalNfcaListenDevice nfca; /*!< NFC-A Listen Device instance */
rfalNfcbListenDevice nfcb; /*!< NFC-B Listen Device instance */
rfalNfcfListenDevice nfcf; /*!< NFC-F Listen Device instance */
rfalNfcvListenDevice nfcv; /*!< NFC-V Listen Device instance */
rfalSt25tbListenDevice st25tb; /*!< ST25TB Listen Device instance*/
}dev; /*!< Device's instance */
uint8_t *nfcid; /*!< Device's NFCID */
uint8_t nfcidLen; /*!< Device's NFCID length */
rfalNfcRfInterface rfInterface; /*!< Device's interface */
union{ /* PRQA S 0750 # MISRA 19.2 - Members of the union will not be used concurrently, only one protocol at a time */
rfalIsoDepDevice isoDep; /*!< ISO-DEP instance */
rfalNfcDepDevice nfcDep; /*!< NFC-DEP instance */
}proto; /*!< Device's protocol */
}rfalNfcDevice;
typedef struct {
rfalNfcDevType type; /*!< Device's type */
union { /* PRQA S 0750 # MISRA 19.2 - Members of the union will not be used concurrently, only one technology at a time */
rfalNfcaListenDevice nfca; /*!< NFC-A Listen Device instance */
rfalNfcbListenDevice nfcb; /*!< NFC-B Listen Device instance */
rfalNfcfListenDevice nfcf; /*!< NFC-F Listen Device instance */
rfalNfcvListenDevice nfcv; /*!< NFC-V Listen Device instance */
rfalSt25tbListenDevice st25tb; /*!< ST25TB Listen Device instance*/
} dev; /*!< Device's instance */
uint8_t* nfcid; /*!< Device's NFCID */
uint8_t nfcidLen; /*!< Device's NFCID length */
rfalNfcRfInterface rfInterface; /*!< Device's interface */
union { /* PRQA S 0750 # MISRA 19.2 - Members of the union will not be used concurrently, only one protocol at a time */
rfalIsoDepDevice isoDep; /*!< ISO-DEP instance */
rfalNfcDepDevice nfcDep; /*!< NFC-DEP instance */
} proto; /*!< Device's protocol */
} rfalNfcDevice;
/*! Discovery parameters */
typedef struct{
rfalComplianceMode compMode; /*!< Compliancy mode to be used */
uint16_t techs2Find; /*!< Technologies to search for */
uint16_t totalDuration; /*!< Duration of a whole Poll + Listen cycle */
uint8_t devLimit; /*!< Max number of devices */
rfalBitRate maxBR; /*!< Max Bit rate to be used for communications */
rfalBitRate nfcfBR; /*!< Bit rate to poll for NFC-F */
uint8_t nfcid3[RFAL_NFCDEP_NFCID3_LEN]; /*!< NFCID3 to be used on the ATR_REQ/ATR_RES */
uint8_t GB[RFAL_NFCDEP_GB_MAX_LEN]; /*!< General bytes to be used on the ATR-REQ */
uint8_t GBLen; /*!< Length of the General Bytes */
rfalBitRate ap2pBR; /*!< Bit rate to poll for AP2P */
typedef struct {
rfalComplianceMode compMode; /*!< Compliancy mode to be used */
uint16_t techs2Find; /*!< Technologies to search for */
uint16_t totalDuration; /*!< Duration of a whole Poll + Listen cycle */
uint8_t devLimit; /*!< Max number of devices */
rfalBitRate maxBR; /*!< Max Bit rate to be used for communications */
rfalLmConfPA lmConfigPA; /*!< Configuration for Passive Listen mode NFC-A */
rfalLmConfPF lmConfigPF; /*!< Configuration for Passive Listen mode NFC-A */
void (*notifyCb)( rfalNfcState st ); /*!< Callback to Notify upper layer */
bool wakeupEnabled; /*!< Enable Wake-Up mode before polling */
bool wakeupConfigDefault; /*!< Wake-Up mode default configuration */
rfalWakeUpConfig wakeupConfig; /*!< Wake-Up mode configuration */
rfalBitRate nfcfBR; /*!< Bit rate to poll for NFC-F */
uint8_t
nfcid3[RFAL_NFCDEP_NFCID3_LEN]; /*!< NFCID3 to be used on the ATR_REQ/ATR_RES */
uint8_t GB[RFAL_NFCDEP_GB_MAX_LEN]; /*!< General bytes to be used on the ATR-REQ */
uint8_t GBLen; /*!< Length of the General Bytes */
rfalBitRate ap2pBR; /*!< Bit rate to poll for AP2P */
bool activate_after_sak; // Set device to Active mode after SAK responce
}rfalNfcDiscoverParam;
rfalLmConfPA lmConfigPA; /*!< Configuration for Passive Listen mode NFC-A */
rfalLmConfPF lmConfigPF; /*!< Configuration for Passive Listen mode NFC-A */
void (*notifyCb)(rfalNfcState st); /*!< Callback to Notify upper layer */
bool wakeupEnabled; /*!< Enable Wake-Up mode before polling */
bool wakeupConfigDefault; /*!< Wake-Up mode default configuration */
rfalWakeUpConfig wakeupConfig; /*!< Wake-Up mode configuration */
bool activate_after_sak; // Set device to Active mode after SAK responce
} rfalNfcDiscoverParam;
/*! Buffer union, only one interface is used at a time */
typedef union{ /* PRQA S 0750 # MISRA 19.2 - Members of the union will not be used concurrently, only one interface at a time */
uint8_t rfBuf[RFAL_FEATURE_NFC_RF_BUF_LEN]; /*!< RF buffer */
rfalIsoDepApduBufFormat isoDepBuf; /*!< ISO-DEP buffer format (with header/prologue) */
rfalNfcDepPduBufFormat nfcDepBuf; /*!< NFC-DEP buffer format (with header/prologue) */
}rfalNfcBuffer;
typedef union { /* PRQA S 0750 # MISRA 19.2 - Members of the union will not be used concurrently, only one interface at a time */
uint8_t rfBuf[RFAL_FEATURE_NFC_RF_BUF_LEN]; /*!< RF buffer */
rfalIsoDepApduBufFormat isoDepBuf; /*!< ISO-DEP buffer format (with header/prologue) */
rfalNfcDepPduBufFormat nfcDepBuf; /*!< NFC-DEP buffer format (with header/prologue) */
} rfalNfcBuffer;
/*******************************************************************************/
@@ -240,7 +236,7 @@ typedef union{ /* PRQA S 0750 # MISRA 19.2 - Members of the union will not be
* It runs the internal state machine and runs the RFAL RF worker.
*****************************************************************************
*/
void rfalNfcWorker( void );
void rfalNfcWorker(void);
/*!
*****************************************************************************
@@ -253,7 +249,7 @@ void rfalNfcWorker( void );
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcInitialize( void );
ReturnCode rfalNfcInitialize(void);
/*!
*****************************************************************************
@@ -274,7 +270,7 @@ ReturnCode rfalNfcInitialize( void );
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcDiscover( const rfalNfcDiscoverParam *disParams );
ReturnCode rfalNfcDiscover(const rfalNfcDiscoverParam* disParams);
/*!
*****************************************************************************
@@ -285,7 +281,7 @@ ReturnCode rfalNfcDiscover( const rfalNfcDiscoverParam *disParams );
* \return rfalNfcState : the current state
*****************************************************************************
*/
rfalNfcState rfalNfcGetState( void );
rfalNfcState rfalNfcGetState(void);
/*!
*****************************************************************************
@@ -303,7 +299,7 @@ rfalNfcState rfalNfcGetState( void );
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcGetDevicesFound( rfalNfcDevice **devList, uint8_t *devCnt );
ReturnCode rfalNfcGetDevicesFound(rfalNfcDevice** devList, uint8_t* devCnt);
/*!
*****************************************************************************
@@ -319,8 +315,7 @@ ReturnCode rfalNfcGetDevicesFound( rfalNfcDevice **devList, uint8_t *devCnt );
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcGetActiveDevice( rfalNfcDevice **dev );
ReturnCode rfalNfcGetActiveDevice(rfalNfcDevice** dev);
/*!
*****************************************************************************
@@ -338,7 +333,7 @@ ReturnCode rfalNfcGetActiveDevice( rfalNfcDevice **dev );
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcSelect( uint8_t devIdx );
ReturnCode rfalNfcSelect(uint8_t devIdx);
/*!
*****************************************************************************
@@ -364,7 +359,13 @@ ReturnCode rfalNfcSelect( uint8_t devIdx );
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcDataExchangeStart( uint8_t *txData, uint16_t txDataLen, uint8_t **rxData, uint16_t **rvdLen, uint32_t fwt, uint32_t tx_flag);
ReturnCode rfalNfcDataExchangeStart(
uint8_t* txData,
uint16_t txDataLen,
uint8_t** rxData,
uint16_t** rvdLen,
uint32_t fwt,
uint32_t tx_flag);
/*!
*****************************************************************************
@@ -387,7 +388,7 @@ ReturnCode rfalNfcDataExchangeStart( uint8_t *txData, uint16_t txDataLen, uint8_
* \return ERR_IO : Internal error
*****************************************************************************
*/
ReturnCode rfalNfcDataExchangeGetStatus( void );
ReturnCode rfalNfcDataExchangeGetStatus(void);
/*!
*****************************************************************************
@@ -403,11 +404,10 @@ ReturnCode rfalNfcDataExchangeGetStatus( void );
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcDeactivate( bool discovery );
ReturnCode rfalNfcDeactivate(bool discovery);
#endif /* RFAL_NFC_H */
/**
* @}
*
+303 -261
View File
@@ -20,7 +20,6 @@
*
******************************************************************************/
/*
* PROJECT: ST25R391x firmware
* Revision:
@@ -65,24 +64,24 @@
#include "st_errno.h"
#include "rfal_rf.h"
/*
******************************************************************************
* ENABLE SWITCH
******************************************************************************
*/
#ifndef RFAL_FEATURE_NFC_DEP
#define RFAL_FEATURE_NFC_DEP false /*!< NFC-DEP module configuration missing. Disabled by default */
#define RFAL_FEATURE_NFC_DEP \
false /*!< NFC-DEP module configuration missing. Disabled by default */
#endif
/* If module is disabled remove the need for the user to set lengths */
#if !RFAL_FEATURE_NFC_DEP
#undef RFAL_FEATURE_NFC_DEP_BLOCK_MAX_LEN
#undef RFAL_FEATURE_NFC_DEP_PDU_MAX_LEN
#undef RFAL_FEATURE_NFC_DEP_BLOCK_MAX_LEN
#undef RFAL_FEATURE_NFC_DEP_PDU_MAX_LEN
#define RFAL_FEATURE_NFC_DEP_BLOCK_MAX_LEN 1U /*!< NFC-DEP Block/Payload length, set to "none" */
#define RFAL_FEATURE_NFC_DEP_PDU_MAX_LEN 1U /*!< NFC-DEP PDU length, set to "none" */
#define RFAL_FEATURE_NFC_DEP_BLOCK_MAX_LEN 1U /*!< NFC-DEP Block/Payload length, set to "none" */
#define RFAL_FEATURE_NFC_DEP_PDU_MAX_LEN 1U /*!< NFC-DEP PDU length, set to "none" */
#endif /* !RFAL_FEATURE_NFC_DEP */
/*
@@ -90,86 +89,138 @@
* DEFINES
******************************************************************************
*/
#define RFAL_NFCDEP_FRAME_SIZE_MAX_LEN 254U /*!< Maximum Frame Size Digital 2.0 Table 90 */
#define RFAL_NFCDEP_DEPREQ_HEADER_LEN 5U /*!< DEP_REQ header length: CMD_TYPE + CMD_CMD + PBF + DID + NAD */
#define RFAL_NFCDEP_FRAME_SIZE_MAX_LEN \
254U /*!< Maximum Frame Size Digital 2.0 Table 90 */
#define RFAL_NFCDEP_DEPREQ_HEADER_LEN \
5U /*!< DEP_REQ header length: CMD_TYPE + CMD_CMD + PBF + DID + NAD */
/*! Length NFCIP DEP REQ or RES header (incl LEN) */
#define RFAL_NFCDEP_DEP_HEADER ( RFAL_NFCDEP_LEN_LEN + RFAL_NFCDEP_CMDTYPE_LEN + RFAL_NFCDEP_CMD_LEN + RFAL_NFCDEP_DEP_PFB_LEN )
#define RFAL_NFCDEP_HEADER ( RFAL_NFCDEP_CMDTYPE_LEN + RFAL_NFCDEP_CMD_LEN ) /*!< NFCIP header length */
#define RFAL_NFCDEP_SB_LEN 1U /*!< SB length on NFCIP fram for NFC-A */
#define RFAL_NFCDEP_LEN_LEN 1U /*!< LEN length on NFCIP frame */
#define RFAL_NFCDEP_CMDTYPE_LEN 1U /*!< Length of the cmd type (REQ | RES) on NFCIP frame */
#define RFAL_NFCDEP_CMD_LEN 1U /*!< Length of the cmd on NFCIP frame */
#define RFAL_NFCDEP_DID_LEN 1U /*!< Length of did on NFCIP frame */
#define RFAL_NFCDEP_DEP_PFB_LEN 1U /*!< Length of the PFB field on NFCIP frame */
#define RFAL_NFCDEP_DEP_HEADER \
(RFAL_NFCDEP_LEN_LEN + RFAL_NFCDEP_CMDTYPE_LEN + RFAL_NFCDEP_CMD_LEN + RFAL_NFCDEP_DEP_PFB_LEN)
#define RFAL_NFCDEP_HEADER \
(RFAL_NFCDEP_CMDTYPE_LEN + RFAL_NFCDEP_CMD_LEN) /*!< NFCIP header length */
#define RFAL_NFCDEP_SB_LEN \
1U /*!< SB length on NFCIP fram for NFC-A */
#define RFAL_NFCDEP_LEN_LEN \
1U /*!< LEN length on NFCIP frame */
#define RFAL_NFCDEP_CMDTYPE_LEN \
1U /*!< Length of the cmd type (REQ | RES) on NFCIP frame */
#define RFAL_NFCDEP_CMD_LEN \
1U /*!< Length of the cmd on NFCIP frame */
#define RFAL_NFCDEP_DID_LEN \
1U /*!< Length of did on NFCIP frame */
#define RFAL_NFCDEP_DEP_PFB_LEN \
1U /*!< Length of the PFB field on NFCIP frame */
#define RFAL_NFCDEP_DSL_RLS_LEN_NO_DID (RFAL_NFCDEP_LEN_LEN + RFAL_NFCDEP_CMDTYPE_LEN + RFAL_NFCDEP_CMD_LEN) /*!< Length of DSL_REQ and RLS_REQ with no DID */
#define RFAL_NFCDEP_DSL_RLS_LEN_DID (RFAL_NFCDEP_DSL_RLS_LEN_NO_DID + RFAL_NFCDEP_DID_LEN) /*!< Length of DSL_REQ and RLS_REQ with DID */
#define RFAL_NFCDEP_DSL_RLS_LEN_NO_DID \
(RFAL_NFCDEP_LEN_LEN + RFAL_NFCDEP_CMDTYPE_LEN + \
RFAL_NFCDEP_CMD_LEN) /*!< Length of DSL_REQ and RLS_REQ with no DID */
#define RFAL_NFCDEP_DSL_RLS_LEN_DID \
(RFAL_NFCDEP_DSL_RLS_LEN_NO_DID + \
RFAL_NFCDEP_DID_LEN) /*!< Length of DSL_REQ and RLS_REQ with DID */
#define RFAL_NFCDEP_FS_VAL_MIN 64U /*!< Minimum LR value */
#define RFAL_NFCDEP_LR_VAL_MASK 0x03U /*!< Bit mask for a LR value */
#define RFAL_NFCDEP_PP_LR_MASK 0x30U /*!< Bit mask for LR value in PP byte on a ATR REQ/RES */
#define RFAL_NFCDEP_PP_LR_SHIFT 4U /*!< Position of LR value in PP byte on a ATR REQ/RES */
#define RFAL_NFCDEP_FS_VAL_MIN \
64U /*!< Minimum LR value */
#define RFAL_NFCDEP_LR_VAL_MASK \
0x03U /*!< Bit mask for a LR value */
#define RFAL_NFCDEP_PP_LR_MASK \
0x30U /*!< Bit mask for LR value in PP byte on a ATR REQ/RES */
#define RFAL_NFCDEP_PP_LR_SHIFT \
4U /*!< Position of LR value in PP byte on a ATR REQ/RES */
#define RFAL_NFCDEP_DID_MAX 14U /*!< Max DID value Digital 14.6.2.3 */
#define RFAL_NFCDEP_DID_KEEP 0xFFU /*!< Keep DID value already configured */
#define RFAL_NFCDEP_DID_NO 0x00U /*!< No DID shall be used */
#define RFAL_NFCDEP_NAD_NO 0x00U /*!< No NAD shall be used */
#define RFAL_NFCDEP_DID_MAX \
14U /*!< Max DID value Digital 14.6.2.3 */
#define RFAL_NFCDEP_DID_KEEP \
0xFFU /*!< Keep DID value already configured */
#define RFAL_NFCDEP_DID_NO \
0x00U /*!< No DID shall be used */
#define RFAL_NFCDEP_NAD_NO \
0x00U /*!< No NAD shall be used */
#define RFAL_NFCDEP_OPER_RTOX_REQ_DIS 0x01U /*!< Operation config: RTOX REQ disable */
#define RFAL_NFCDEP_OPER_RTOX_REQ_EN 0x00U /*!< Operation config: RTOX REQ enable */
#define RFAL_NFCDEP_OPER_RTOX_REQ_DIS \
0x01U /*!< Operation config: RTOX REQ disable */
#define RFAL_NFCDEP_OPER_RTOX_REQ_EN \
0x00U /*!< Operation config: RTOX REQ enable */
#define RFAL_NFCDEP_OPER_ATN_DIS 0x00U /*!< Operation config: ATN disable */
#define RFAL_NFCDEP_OPER_ATN_EN 0x02U /*!< Operation config: ATN enable */
#define RFAL_NFCDEP_OPER_ATN_DIS \
0x00U /*!< Operation config: ATN disable */
#define RFAL_NFCDEP_OPER_ATN_EN \
0x02U /*!< Operation config: ATN enable */
#define RFAL_NFCDEP_OPER_EMPTY_DEP_DIS 0x04U /*!< Operation config: empty DEPs disable */
#define RFAL_NFCDEP_OPER_EMPTY_DEP_EN 0x00U /*!< Operation config: empty DEPs enable */
#define RFAL_NFCDEP_OPER_EMPTY_DEP_DIS \
0x04U /*!< Operation config: empty DEPs disable */
#define RFAL_NFCDEP_OPER_EMPTY_DEP_EN \
0x00U /*!< Operation config: empty DEPs enable */
#define RFAL_NFCDEP_OPER_FULL_MI_DIS 0x00U /*!< Operation config: full chaining DEPs disable */
#define RFAL_NFCDEP_OPER_FULL_MI_EN 0x08U /*!< Operation config: full chaining DEPs enable */
#define RFAL_NFCDEP_OPER_FULL_MI_DIS \
0x00U /*!< Operation config: full chaining DEPs disable */
#define RFAL_NFCDEP_OPER_FULL_MI_EN \
0x08U /*!< Operation config: full chaining DEPs enable */
#define RFAL_NFCDEP_BRS_MAINTAIN \
0xC0U /*!< Value signalling that BR is to be maintained (no PSL) */
#define RFAL_NFCDEP_BRS_Dx_MASK \
0x07U /*!< Value signalling that BR is to be maintained (no PSL) */
#define RFAL_NFCDEP_BRS_DSI_POS \
3U /*!< Value signalling that BR is to be maintained (no PSL) */
#define RFAL_NFCDEP_BRS_MAINTAIN 0xC0U /*!< Value signalling that BR is to be maintained (no PSL) */
#define RFAL_NFCDEP_BRS_Dx_MASK 0x07U /*!< Value signalling that BR is to be maintained (no PSL) */
#define RFAL_NFCDEP_BRS_DSI_POS 3U /*!< Value signalling that BR is to be maintained (no PSL) */
#define RFAL_NFCDEP_WT_DELTA \
(16U - RFAL_NFCDEP_WT_DELTA_ADJUST) /*!< NFC-DEP dWRT (adjusted) Digital 2.0 B.10 */
#define RFAL_NFCDEP_WT_DELTA_ADJUST \
4U /*!< dWRT value adjustment */
#define RFAL_NFCDEP_WT_DELTA (16U - RFAL_NFCDEP_WT_DELTA_ADJUST) /*!< NFC-DEP dWRT (adjusted) Digital 2.0 B.10 */
#define RFAL_NFCDEP_WT_DELTA_ADJUST 4U /*!< dWRT value adjustment */
#define RFAL_NFCDEP_ATR_REQ_NFCID3_POS \
2U /*!< NFCID3 offset in ATR_REQ frame */
#define RFAL_NFCDEP_NFCID3_LEN \
10U /*!< NFCID3 Length */
#define RFAL_NFCDEP_LEN_MIN \
3U /*!< Minimum length byte LEN value */
#define RFAL_NFCDEP_LEN_MAX \
255U /*!< Maximum length byte LEN value */
#define RFAL_NFCDEP_ATR_REQ_NFCID3_POS 2U /*!< NFCID3 offset in ATR_REQ frame */
#define RFAL_NFCDEP_NFCID3_LEN 10U /*!< NFCID3 Length */
#define RFAL_NFCDEP_ATRRES_HEADER_LEN \
2U /*!< ATR RES Header Len: CmdType: 0xD5 + Cod: 0x01 */
#define RFAL_NFCDEP_ATRRES_MIN_LEN \
17U /*!< Minimum length for an ATR RES */
#define RFAL_NFCDEP_ATRRES_MAX_LEN \
64U /*!< Maximum length for an ATR RES Digital 1.0 14.6.1 */
#define RFAL_NFCDEP_ATRREQ_MIN_LEN \
16U /*!< Minimum length for an ATR REQ */
#define RFAL_NFCDEP_ATRREQ_MAX_LEN \
RFAL_NFCDEP_ATRRES_MAX_LEN /*!< Maximum length for an ATR REQ Digital 1.0 14.6.1 */
#define RFAL_NFCDEP_LEN_MIN 3U /*!< Minimum length byte LEN value */
#define RFAL_NFCDEP_LEN_MAX 255U /*!< Maximum length byte LEN value */
#define RFAL_NFCDEP_GB_MAX_LEN \
(RFAL_NFCDEP_ATRREQ_MAX_LEN - \
RFAL_NFCDEP_ATRREQ_MIN_LEN) /*!< Maximum length the General Bytes on ATR Digital 1.1 16.6.3 */
#define RFAL_NFCDEP_ATRRES_HEADER_LEN 2U /*!< ATR RES Header Len: CmdType: 0xD5 + Cod: 0x01 */
#define RFAL_NFCDEP_ATRRES_MIN_LEN 17U /*!< Minimum length for an ATR RES */
#define RFAL_NFCDEP_ATRRES_MAX_LEN 64U /*!< Maximum length for an ATR RES Digital 1.0 14.6.1 */
#define RFAL_NFCDEP_ATRREQ_MIN_LEN 16U /*!< Minimum length for an ATR REQ */
#define RFAL_NFCDEP_ATRREQ_MAX_LEN RFAL_NFCDEP_ATRRES_MAX_LEN /*!< Maximum length for an ATR REQ Digital 1.0 14.6.1 */
#define RFAL_NFCDEP_WT_INI_DEFAULT \
RFAL_NFCDEP_WT_INI_MAX /*!< WT Initiator default value Digital 1.0 14.6.3.8 */
#define RFAL_NFCDEP_WT_INI_MIN 0U /*!< WT Initiator minimum value Digital 1.0 14.6.3.8 */
#define RFAL_NFCDEP_WT_INI_MAX 14U /*!< WT Initiator maximum value Digital 1.0 14.6.3.8 A.10 */
#define RFAL_NFCDEP_RWT_INI_MAX \
rfalNfcDepWT2RWT(RFAL_NFCDEP_WT_INI_MAX) /*!< RWT Initiator maximum value */
#define RFAL_NFCDEP_GB_MAX_LEN (RFAL_NFCDEP_ATRREQ_MAX_LEN - RFAL_NFCDEP_ATRREQ_MIN_LEN) /*!< Maximum length the General Bytes on ATR Digital 1.1 16.6.3 */
#define RFAL_NFCDEP_WT_INI_DEFAULT RFAL_NFCDEP_WT_INI_MAX /*!< WT Initiator default value Digital 1.0 14.6.3.8 */
#define RFAL_NFCDEP_WT_INI_MIN 0U /*!< WT Initiator minimum value Digital 1.0 14.6.3.8 */
#define RFAL_NFCDEP_WT_INI_MAX 14U /*!< WT Initiator maximum value Digital 1.0 14.6.3.8 A.10 */
#define RFAL_NFCDEP_RWT_INI_MAX rfalNfcDepWT2RWT( RFAL_NFCDEP_WT_INI_MAX ) /*!< RWT Initiator maximum value */
#define RFAL_NFCDEP_WT_TRG_MAX_D10 8U /*!< WT target max Digital 1.0 14.6.3.8 A.10 */
#define RFAL_NFCDEP_WT_TRG_MAX_D11 14U /*!< WT target max Digital 1.1 16.6.3.9 A.9 */
#define RFAL_NFCDEP_WT_TRG_MAX_L13 10U /*!< WT target max [LLCP] 1.3 6.2.1 */
#define RFAL_NFCDEP_WT_TRG_MAX RFAL_NFCDEP_WT_TRG_MAX_D11 /*!< WT target max Digital x.x | LLCP x.x */
#define RFAL_NFCDEP_RWT_TRG_MAX rfalNfcDepWT2RWT( RFAL_NFCDEP_WT_TRG_MAX ) /*!< RWT Initiator maximum value */
#define RFAL_NFCDEP_WT_TRG_MAX_D10 8U /*!< WT target max Digital 1.0 14.6.3.8 A.10 */
#define RFAL_NFCDEP_WT_TRG_MAX_D11 14U /*!< WT target max Digital 1.1 16.6.3.9 A.9 */
#define RFAL_NFCDEP_WT_TRG_MAX_L13 10U /*!< WT target max [LLCP] 1.3 6.2.1 */
#define RFAL_NFCDEP_WT_TRG_MAX \
RFAL_NFCDEP_WT_TRG_MAX_D11 /*!< WT target max Digital x.x | LLCP x.x */
#define RFAL_NFCDEP_RWT_TRG_MAX \
rfalNfcDepWT2RWT(RFAL_NFCDEP_WT_TRG_MAX) /*!< RWT Initiator maximum value */
/*! Maximum Frame Waiting Time = ((256 * 16/fc)*2^FWImax) = ((256*16/fc)*2^14) = (1048576 / 64)/fc = (100000h*64)/fc */
#define RFAL_NFCDEP_MAX_FWT ((uint32_t)1U<<20)
#define RFAL_NFCDEP_MAX_FWT ((uint32_t)1U << 20)
#define RFAL_NFCDEP_WT_MASK 0x0FU /*!< Bit mask for the Wait Time value */
#define RFAL_NFCDEP_WT_MASK \
0x0FU /*!< Bit mask for the Wait Time value */
#define RFAL_NFCDEP_BR_MASK_106 0x01U /*!< Enable mask bit rate 106 */
#define RFAL_NFCDEP_BR_MASK_212 0x02U /*!< Enable mask bit rate 242 */
#define RFAL_NFCDEP_BR_MASK_424 0x04U /*!< Enable mask bit rate 424 */
#define RFAL_NFCDEP_BR_MASK_106 \
0x01U /*!< Enable mask bit rate 106 */
#define RFAL_NFCDEP_BR_MASK_212 \
0x02U /*!< Enable mask bit rate 242 */
#define RFAL_NFCDEP_BR_MASK_424 \
0x04U /*!< Enable mask bit rate 424 */
/*
******************************************************************************
@@ -177,25 +228,44 @@
******************************************************************************
*/
#define rfalNfcDepWT2RWT( wt ) ( (uint32_t)1U << (((uint32_t)(wt) & RFAL_NFCDEP_WT_MASK) + 12U) ) /*!< Converts WT value to RWT (1/fc) */
#define rfalNfcDepWT2RWT(wt) \
((uint32_t)1U \
<< (((uint32_t)(wt)&RFAL_NFCDEP_WT_MASK) + \
12U)) /*!< Converts WT value to RWT (1/fc) */
/*! Returns the BRS value from the given bit rate */
#define rfalNfcDepDx2BRS( br ) ( (((uint8_t)(br) & RFAL_NFCDEP_BRS_Dx_MASK) << RFAL_NFCDEP_BRS_DSI_POS) | ((uint8_t)(br) & RFAL_NFCDEP_BRS_Dx_MASK) )
#define rfalNfcDepDx2BRS(br) \
((((uint8_t)(br)&RFAL_NFCDEP_BRS_Dx_MASK) << RFAL_NFCDEP_BRS_DSI_POS) | \
((uint8_t)(br)&RFAL_NFCDEP_BRS_Dx_MASK))
#define rfalNfcDepBRS2DRI( brs ) (uint8_t)( (uint8_t)(brs) & RFAL_NFCDEP_BRS_Dx_MASK ) /*!< Returns the DRI value from the given BRS byte */
#define rfalNfcDepBRS2DSI( brs ) (uint8_t)( ((uint8_t)(brs) >> RFAL_NFCDEP_BRS_DSI_POS) & RFAL_NFCDEP_BRS_Dx_MASK ) /*!< Returns the DSI value from the given BRS byte */
#define rfalNfcDepBRS2DRI(brs) \
(uint8_t)(( \
uint8_t)(brs)&RFAL_NFCDEP_BRS_Dx_MASK) /*!< Returns the DRI value from the given BRS byte */
#define rfalNfcDepBRS2DSI(brs) \
(uint8_t)( \
((uint8_t)(brs) >> RFAL_NFCDEP_BRS_DSI_POS) & \
RFAL_NFCDEP_BRS_Dx_MASK) /*!< Returns the DSI value from the given BRS byte */
#define rfalNfcDepPP2LR( PPx ) ( ((uint8_t)(PPx) & RFAL_NFCDEP_PP_LR_MASK ) >> RFAL_NFCDEP_PP_LR_SHIFT) /*!< Returns the LR value from the given PPx byte */
#define rfalNfcDepLR2PP( LRx ) ( ((uint8_t)(LRx) << RFAL_NFCDEP_PP_LR_SHIFT) & RFAL_NFCDEP_PP_LR_MASK) /*!< Returns the PP byte with the given LRx value */
#define rfalNfcDepPP2LR(PPx) \
(((uint8_t)(PPx)&RFAL_NFCDEP_PP_LR_MASK) >> \
RFAL_NFCDEP_PP_LR_SHIFT) /*!< Returns the LR value from the given PPx byte */
#define rfalNfcDepLR2PP(LRx) \
(((uint8_t)(LRx) << RFAL_NFCDEP_PP_LR_SHIFT) & \
RFAL_NFCDEP_PP_LR_MASK) /*!< Returns the PP byte with the given LRx value */
/*! Returns the Frame size value from the given LRx value */
#define rfalNfcDepLR2FS( LRx ) (uint16_t)(MIN( (RFAL_NFCDEP_FS_VAL_MIN * ((uint16_t)(LRx) + 1U) ), RFAL_NFCDEP_FRAME_SIZE_MAX_LEN ))
#define rfalNfcDepLR2FS(LRx) \
(uint16_t)( \
MIN((RFAL_NFCDEP_FS_VAL_MIN * ((uint16_t)(LRx) + 1U)), RFAL_NFCDEP_FRAME_SIZE_MAX_LEN))
/*!
* Despite DIGITAL 1.0 14.6.2.1 stating that the last two bytes may filled with
* any value, some devices (Samsung Google Nexus) only accept when these are 0 */
#define rfalNfcDepSetNFCID( dst, src, len ) ST_MEMSET( (dst), 0x00, RFAL_NFCDEP_NFCID3_LEN ); \
if( (len) > 0U ) {ST_MEMCPY( (dst), (src), (len) );}
* any value, some devices (Samsung Google Nexus) only accept when these are 0 */
#define rfalNfcDepSetNFCID(dst, src, len) \
ST_MEMSET((dst), 0x00, RFAL_NFCDEP_NFCID3_LEN); \
if((len) > 0U) { \
ST_MEMCPY((dst), (src), (len)); \
}
/*
******************************************************************************
@@ -204,31 +274,31 @@
*/
/*! Enumeration of NFC-DEP bit rate in ATR Digital 1.0 Table 93 and 94 */
enum{
RFAL_NFCDEP_Bx_NO_HIGH_BR = 0x00, /*!< Peer supports no high bit rates */
RFAL_NFCDEP_Bx_08_848 = 0x01, /*!< Peer also supports 848 */
RFAL_NFCDEP_Bx_16_1695 = 0x02, /*!< Peer also supports 1695 */
RFAL_NFCDEP_Bx_32_3390 = 0x04, /*!< Peer also supports 3390 */
RFAL_NFCDEP_Bx_64_6780 = 0x08 /*!< Peer also supports 6780 */
enum {
RFAL_NFCDEP_Bx_NO_HIGH_BR = 0x00, /*!< Peer supports no high bit rates */
RFAL_NFCDEP_Bx_08_848 = 0x01, /*!< Peer also supports 848 */
RFAL_NFCDEP_Bx_16_1695 = 0x02, /*!< Peer also supports 1695 */
RFAL_NFCDEP_Bx_32_3390 = 0x04, /*!< Peer also supports 3390 */
RFAL_NFCDEP_Bx_64_6780 = 0x08 /*!< Peer also supports 6780 */
};
/*! Enumeration of NFC-DEP bit rate Dividor in PSL Digital 1.0 Table 100 */
enum{
RFAL_NFCDEP_Dx_01_106 = RFAL_BR_106, /*!< Divisor D = 1 : bit rate = 106 */
RFAL_NFCDEP_Dx_02_212 = RFAL_BR_212, /*!< Divisor D = 2 : bit rate = 212 */
RFAL_NFCDEP_Dx_04_424 = RFAL_BR_424, /*!< Divisor D = 4 : bit rate = 424 */
RFAL_NFCDEP_Dx_08_848 = RFAL_BR_848, /*!< Divisor D = 8 : bit rate = 848 */
RFAL_NFCDEP_Dx_16_1695 = RFAL_BR_1695, /*!< Divisor D = 16 : bit rate = 1695 */
RFAL_NFCDEP_Dx_32_3390 = RFAL_BR_3390, /*!< Divisor D = 32 : bit rate = 3390 */
RFAL_NFCDEP_Dx_64_6780 = RFAL_BR_6780 /*!< Divisor D = 64 : bit rate = 6780 */
enum {
RFAL_NFCDEP_Dx_01_106 = RFAL_BR_106, /*!< Divisor D = 1 : bit rate = 106 */
RFAL_NFCDEP_Dx_02_212 = RFAL_BR_212, /*!< Divisor D = 2 : bit rate = 212 */
RFAL_NFCDEP_Dx_04_424 = RFAL_BR_424, /*!< Divisor D = 4 : bit rate = 424 */
RFAL_NFCDEP_Dx_08_848 = RFAL_BR_848, /*!< Divisor D = 8 : bit rate = 848 */
RFAL_NFCDEP_Dx_16_1695 = RFAL_BR_1695, /*!< Divisor D = 16 : bit rate = 1695 */
RFAL_NFCDEP_Dx_32_3390 = RFAL_BR_3390, /*!< Divisor D = 32 : bit rate = 3390 */
RFAL_NFCDEP_Dx_64_6780 = RFAL_BR_6780 /*!< Divisor D = 64 : bit rate = 6780 */
};
/*! Enumeration of NFC-DEP Length Reduction (LR) Digital 1.0 Table 91 */
enum{
RFAL_NFCDEP_LR_64 = 0x00, /*!< Maximum payload size is 64 bytes */
RFAL_NFCDEP_LR_128 = 0x01, /*!< Maximum payload size is 128 bytes */
RFAL_NFCDEP_LR_192 = 0x02, /*!< Maximum payload size is 192 bytes */
RFAL_NFCDEP_LR_254 = 0x03 /*!< Maximum payload size is 254 bytes */
enum {
RFAL_NFCDEP_LR_64 = 0x00, /*!< Maximum payload size is 64 bytes */
RFAL_NFCDEP_LR_128 = 0x01, /*!< Maximum payload size is 128 bytes */
RFAL_NFCDEP_LR_192 = 0x02, /*!< Maximum payload size is 192 bytes */
RFAL_NFCDEP_LR_254 = 0x03 /*!< Maximum payload size is 254 bytes */
};
/*
@@ -238,123 +308,109 @@ enum{
*/
/*! NFC-DEP callback to check if upper layer has deactivation pending */
typedef bool (* rfalNfcDepDeactCallback)(void);
typedef bool (*rfalNfcDepDeactCallback)(void);
/*! Enumeration of the nfcip communication modes */
typedef enum{
RFAL_NFCDEP_COMM_PASSIVE, /*!< Passive communication mode */
RFAL_NFCDEP_COMM_ACTIVE /*!< Active communication mode */
typedef enum {
RFAL_NFCDEP_COMM_PASSIVE, /*!< Passive communication mode */
RFAL_NFCDEP_COMM_ACTIVE /*!< Active communication mode */
} rfalNfcDepCommMode;
/*! Enumeration of the nfcip roles */
typedef enum{
RFAL_NFCDEP_ROLE_INITIATOR, /*!< Perform as Initiator */
RFAL_NFCDEP_ROLE_TARGET /*!< Perform as Target */
typedef enum {
RFAL_NFCDEP_ROLE_INITIATOR, /*!< Perform as Initiator */
RFAL_NFCDEP_ROLE_TARGET /*!< Perform as Target */
} rfalNfcDepRole;
/*! Struct that holds all NFCIP configs */
typedef struct{
typedef struct {
rfalNfcDepRole role; /*!< Current NFCIP role */
rfalNfcDepCommMode commMode; /*!< Current NFCIP communication mode */
uint8_t oper; /*!< Operation config similar to NCI 1.0 Table 81 */
rfalNfcDepRole role; /*!< Current NFCIP role */
rfalNfcDepCommMode commMode; /*!< Current NFCIP communication mode */
uint8_t oper; /*!< Operation config similar to NCI 1.0 Table 81 */
uint8_t did; /*!< Current Device ID (DID) */
uint8_t nad; /*!< Current Node Addressing (NAD) */
uint8_t bs; /*!< Bit rate in Sending Direction */
uint8_t br; /*!< Bit rate in Receiving Direction */
uint8_t nfcid[RFAL_NFCDEP_NFCID3_LEN]; /*!< Pointer to the NFCID to be used */
uint8_t nfcidLen; /*!< Length of the given NFCID in nfcid */
uint8_t gb[RFAL_NFCDEP_GB_MAX_LEN]; /*!< Pointer General Bytes (GB) to be used */
uint8_t gbLen; /*!< Length of the given GB in gb */
uint8_t lr; /*!< Length Reduction (LR) to be used */
uint8_t to; /*!< Timeout (TO) to be used */
uint32_t fwt; /*!< Frame Waiting Time (FWT) to be used */
uint32_t dFwt; /*!< Delta Frame Waiting Time (dFWT) to be used */
uint8_t did; /*!< Current Device ID (DID) */
uint8_t nad; /*!< Current Node Addressing (NAD) */
uint8_t bs; /*!< Bit rate in Sending Direction */
uint8_t br; /*!< Bit rate in Receiving Direction */
uint8_t nfcid[RFAL_NFCDEP_NFCID3_LEN]; /*!< Pointer to the NFCID to be used */
uint8_t nfcidLen; /*!< Length of the given NFCID in nfcid */
uint8_t gb[RFAL_NFCDEP_GB_MAX_LEN]; /*!< Pointer General Bytes (GB) to be used */
uint8_t gbLen; /*!< Length of the given GB in gb */
uint8_t lr; /*!< Length Reduction (LR) to be used */
uint8_t to; /*!< Timeout (TO) to be used */
uint32_t fwt; /*!< Frame Waiting Time (FWT) to be used */
uint32_t dFwt; /*!< Delta Frame Waiting Time (dFWT) to be used */
} rfalNfcDepConfigs;
/*! ATR_REQ command Digital 1.1 16.6.2 */
typedef struct {
uint8_t CMD1; /*!< Command format 0xD4 */
uint8_t CMD2; /*!< Command Value */
uint8_t NFCID3[RFAL_NFCDEP_NFCID3_LEN]; /*!< NFCID3 value */
uint8_t DID; /*!< DID */
uint8_t BSi; /*!< Sending Bitrate for Initiator */
uint8_t BRi; /*!< Receiving Bitrate for Initiator */
uint8_t PPi; /*!< Optional Parameters presence indicator */
uint8_t GBi[RFAL_NFCDEP_GB_MAX_LEN]; /*!< General Bytes */
uint8_t CMD1; /*!< Command format 0xD4 */
uint8_t CMD2; /*!< Command Value */
uint8_t NFCID3[RFAL_NFCDEP_NFCID3_LEN]; /*!< NFCID3 value */
uint8_t DID; /*!< DID */
uint8_t BSi; /*!< Sending Bitrate for Initiator */
uint8_t BRi; /*!< Receiving Bitrate for Initiator */
uint8_t PPi; /*!< Optional Parameters presence indicator */
uint8_t GBi[RFAL_NFCDEP_GB_MAX_LEN]; /*!< General Bytes */
} rfalNfcDepAtrReq;
/*! ATR_RES response Digital 1.1 16.6.3 */
typedef struct {
uint8_t CMD1; /*!< Response Byte 0xD5 */
uint8_t CMD2; /*!< Command Value */
uint8_t NFCID3[RFAL_NFCDEP_NFCID3_LEN]; /*!< NFCID3 value */
uint8_t DID; /*!< DID */
uint8_t BSt; /*!< Sending Bitrate for Initiator */
uint8_t BRt; /*!< Receiving Bitrate for Initiator */
uint8_t TO; /*!< Timeout */
uint8_t PPt; /*!< Optional Parameters presence indicator */
uint8_t GBt[RFAL_NFCDEP_GB_MAX_LEN]; /*!< General Bytes */
uint8_t CMD1; /*!< Response Byte 0xD5 */
uint8_t CMD2; /*!< Command Value */
uint8_t NFCID3[RFAL_NFCDEP_NFCID3_LEN]; /*!< NFCID3 value */
uint8_t DID; /*!< DID */
uint8_t BSt; /*!< Sending Bitrate for Initiator */
uint8_t BRt; /*!< Receiving Bitrate for Initiator */
uint8_t TO; /*!< Timeout */
uint8_t PPt; /*!< Optional Parameters presence indicator */
uint8_t GBt[RFAL_NFCDEP_GB_MAX_LEN]; /*!< General Bytes */
} rfalNfcDepAtrRes;
/*! Structure of transmit I-PDU Buffer format from caller */
typedef struct
{
uint8_t prologue[RFAL_NFCDEP_DEPREQ_HEADER_LEN]; /*!< Prologue space for NFC-DEP header*/
uint8_t inf[RFAL_FEATURE_NFC_DEP_BLOCK_MAX_LEN]; /*!< INF | Data area of the buffer */
typedef struct {
uint8_t prologue[RFAL_NFCDEP_DEPREQ_HEADER_LEN]; /*!< Prologue space for NFC-DEP header*/
uint8_t inf[RFAL_FEATURE_NFC_DEP_BLOCK_MAX_LEN]; /*!< INF | Data area of the buffer */
} rfalNfcDepBufFormat;
/*! Structure of APDU Buffer format from caller */
typedef struct
{
uint8_t prologue[RFAL_NFCDEP_DEPREQ_HEADER_LEN]; /*!< Prologue/SoD buffer */
uint8_t pdu[RFAL_FEATURE_NFC_DEP_PDU_MAX_LEN]; /*!< Complete PDU/Payload buffer */
typedef struct {
uint8_t prologue[RFAL_NFCDEP_DEPREQ_HEADER_LEN]; /*!< Prologue/SoD buffer */
uint8_t pdu[RFAL_FEATURE_NFC_DEP_PDU_MAX_LEN]; /*!< Complete PDU/Payload buffer */
} rfalNfcDepPduBufFormat;
/*! Activation info as Initiator and Target */
typedef union { /* PRQA S 0750 # MISRA 19.2 - Both members of the union will not be used concurrently , device is only initiatior or target a time. No problem can occur. */
struct {
rfalNfcDepAtrRes ATR_RES; /*!< ATR RES (Initiator mode) */
uint8_t ATR_RESLen; /*!< ATR RES length (Initiator mode) */
}Target; /*!< Target */
rfalNfcDepAtrRes ATR_RES; /*!< ATR RES (Initiator mode) */
uint8_t ATR_RESLen; /*!< ATR RES length (Initiator mode) */
} Target; /*!< Target */
struct {
rfalNfcDepAtrReq ATR_REQ; /*!< ATR REQ (Target mode) */
uint8_t ATR_REQLen; /*!< ATR REQ length (Target mode) */
}Initiator; /*!< Initiator */
rfalNfcDepAtrReq ATR_REQ; /*!< ATR REQ (Target mode) */
uint8_t ATR_REQLen; /*!< ATR REQ length (Target mode) */
} Initiator; /*!< Initiator */
} rfalNfcDepActivation;
/*! NFC-DEP device Info */
typedef struct {
uint8_t GBLen; /*!< General Bytes length */
uint8_t WT; /*!< WT to be used (ignored in Listen Mode) */
uint32_t FWT; /*!< FWT to be used (1/fc)(ignored Listen Mode) */
uint32_t dFWT; /*!< Delta FWT to be used (1/fc) */
uint8_t LR; /*!< Length Reduction coding the max payload */
uint16_t FS; /*!< Frame Size */
rfalBitRate DSI; /*!< Bit Rate coding from Initiator to Target */
rfalBitRate DRI; /*!< Bit Rate coding from Target to Initiator */
uint8_t DID; /*!< Device ID (RFAL_NFCDEP_DID_NO if no DID) */
uint8_t NAD; /*!< Node ADdress (RFAL_NFCDEP_NAD_NO if no NAD)*/
uint8_t GBLen; /*!< General Bytes length */
uint8_t WT; /*!< WT to be used (ignored in Listen Mode) */
uint32_t FWT; /*!< FWT to be used (1/fc)(ignored Listen Mode) */
uint32_t dFWT; /*!< Delta FWT to be used (1/fc) */
uint8_t LR; /*!< Length Reduction coding the max payload */
uint16_t FS; /*!< Frame Size */
rfalBitRate DSI; /*!< Bit Rate coding from Initiator to Target */
rfalBitRate DRI; /*!< Bit Rate coding from Target to Initiator */
uint8_t DID; /*!< Device ID (RFAL_NFCDEP_DID_NO if no DID) */
uint8_t NAD; /*!< Node ADdress (RFAL_NFCDEP_NAD_NO if no NAD)*/
} rfalNfcDepInfo;
/*! NFC-DEP Device structure */
typedef struct {
rfalNfcDepActivation activation; /*!< Activation Info */
rfalNfcDepInfo info; /*!< NFC-DEP device Info */
rfalNfcDepActivation activation; /*!< Activation Info */
rfalNfcDepInfo info; /*!< NFC-DEP device Info */
} rfalNfcDepDevice;
/*! NFCIP Protocol structure for P2P Target
*
* operParam : derives from NFC-Forum NCI NFC-DEP Operation Parameter
@@ -367,31 +423,28 @@ typedef struct {
* ]
*
*/
typedef struct{
rfalNfcDepCommMode commMode; /*!< Initiator in Active P2P or Passive P2P*/
uint8_t operParam; /*!< NFC-DEP Operation Parameter */
uint8_t* nfcid; /*!< Initiator's NFCID2 or NFCID3 */
uint8_t nfcidLen; /*!< Initiator's NFCID length (NFCID2/3) */
uint8_t DID; /*!< Initiator's Device ID DID */
uint8_t NAD; /*!< Initiator's Node ID NAD */
uint8_t BS; /*!< Initiator's Bit Rates supported in Tx */
uint8_t BR; /*!< Initiator's Bit Rates supported in Rx */
uint8_t LR; /*!< Initiator's Length reduction */
uint8_t* GB; /*!< Initiator's General Bytes (Gi) */
uint8_t GBLen; /*!< Initiator's General Bytes length */
typedef struct {
rfalNfcDepCommMode commMode; /*!< Initiator in Active P2P or Passive P2P*/
uint8_t operParam; /*!< NFC-DEP Operation Parameter */
uint8_t* nfcid; /*!< Initiator's NFCID2 or NFCID3 */
uint8_t nfcidLen; /*!< Initiator's NFCID length (NFCID2/3) */
uint8_t DID; /*!< Initiator's Device ID DID */
uint8_t NAD; /*!< Initiator's Node ID NAD */
uint8_t BS; /*!< Initiator's Bit Rates supported in Tx */
uint8_t BR; /*!< Initiator's Bit Rates supported in Rx */
uint8_t LR; /*!< Initiator's Length reduction */
uint8_t* GB; /*!< Initiator's General Bytes (Gi) */
uint8_t GBLen; /*!< Initiator's General Bytes length */
} rfalNfcDepAtrParam;
/*! Structure of parameters to be passed in for nfcDepListenStartActivation */
typedef struct
{
rfalNfcDepBufFormat *rxBuf; /*!< Receive Buffer struct reference */
uint16_t *rxLen; /*!< Receive INF data length in bytes */
bool *isRxChaining; /*!< Received data is not complete */
rfalNfcDepDevice *nfcDepDev; /*!< NFC-DEP device info */
typedef struct {
rfalNfcDepBufFormat* rxBuf; /*!< Receive Buffer struct reference */
uint16_t* rxLen; /*!< Receive INF data length in bytes */
bool* isRxChaining; /*!< Received data is not complete */
rfalNfcDepDevice* nfcDepDev; /*!< NFC-DEP device info */
} rfalNfcDepListenActvParam;
/*! NFCIP Protocol structure for P2P Target
*
* operParam : derives from NFC-Forum NCI NFC-DEP Operation Parameter
@@ -404,57 +457,51 @@ typedef struct
* ]
*
*/
typedef struct{
rfalNfcDepCommMode commMode; /*!< Target in Active P2P or Passive P2P */
uint8_t nfcid3[RFAL_NFCDEP_NFCID3_LEN]; /*!< Target's NFCID3 */
uint8_t bst; /*!< Target's Bit Rates supported in Tx */
uint8_t brt; /*!< Target's Bit Rates supported in Rx */
uint8_t to; /*!< Target's timeout (TO) value */
uint8_t ppt; /*!< Target's Presence optional Params(PPt)*/
uint8_t GBt[RFAL_NFCDEP_GB_MAX_LEN]; /*!< Target's General Bytes (Gt) */
uint8_t GBtLen; /*!< Target's General Bytes length */
uint8_t operParam; /*!< NFC-DEP Operation Parameter */
typedef struct {
rfalNfcDepCommMode commMode; /*!< Target in Active P2P or Passive P2P */
uint8_t nfcid3[RFAL_NFCDEP_NFCID3_LEN]; /*!< Target's NFCID3 */
uint8_t bst; /*!< Target's Bit Rates supported in Tx */
uint8_t brt; /*!< Target's Bit Rates supported in Rx */
uint8_t to; /*!< Target's timeout (TO) value */
uint8_t ppt; /*!< Target's Presence optional Params(PPt)*/
uint8_t GBt[RFAL_NFCDEP_GB_MAX_LEN]; /*!< Target's General Bytes (Gt) */
uint8_t GBtLen; /*!< Target's General Bytes length */
uint8_t operParam; /*!< NFC-DEP Operation Parameter */
} rfalNfcDepTargetParam;
/*! Structure of parameters to be passed in for nfcDepStartIpduTransceive */
typedef struct
{
rfalNfcDepBufFormat *txBuf; /*!< Transmit Buffer struct reference */
uint16_t txBufLen; /*!< Transmit Buffer INF field length in bytes */
bool isTxChaining; /*!< Transmit data is not complete */
rfalNfcDepBufFormat *rxBuf; /*!< Receive Buffer struct reference */
uint16_t *rxLen; /*!< Receive INF data length */
bool *isRxChaining; /*!< Received data is not complete */
uint32_t FWT; /*!< FWT to be used (ignored in Listen Mode) */
uint32_t dFWT; /*!< Delta FWT to be used */
uint16_t FSx; /*!< Other device Frame Size (FSD or FSC) */
uint8_t DID; /*!< Device ID (RFAL_ISODEP_NO_DID if no DID) */
typedef struct {
rfalNfcDepBufFormat* txBuf; /*!< Transmit Buffer struct reference */
uint16_t txBufLen; /*!< Transmit Buffer INF field length in bytes */
bool isTxChaining; /*!< Transmit data is not complete */
rfalNfcDepBufFormat* rxBuf; /*!< Receive Buffer struct reference */
uint16_t* rxLen; /*!< Receive INF data length */
bool* isRxChaining; /*!< Received data is not complete */
uint32_t FWT; /*!< FWT to be used (ignored in Listen Mode) */
uint32_t dFWT; /*!< Delta FWT to be used */
uint16_t FSx; /*!< Other device Frame Size (FSD or FSC) */
uint8_t DID; /*!< Device ID (RFAL_ISODEP_NO_DID if no DID) */
} rfalNfcDepTxRxParam;
/*! Structure of parameters used on NFC DEP PDU Transceive */
typedef struct
{
rfalNfcDepPduBufFormat *txBuf; /*!< Transmit Buffer struct reference */
uint16_t txBufLen; /*!< Transmit Buffer INF field length in Bytes*/
rfalNfcDepPduBufFormat *rxBuf; /*!< Receive Buffer struct reference in Bytes */
uint16_t *rxLen; /*!< Received INF data length in Bytes */
rfalNfcDepBufFormat *tmpBuf; /*!< Temp buffer for single PDUs (internal) */
uint32_t FWT; /*!< FWT to be used (ignored in Listen Mode) */
uint32_t dFWT; /*!< Delta FWT to be used */
uint16_t FSx; /*!< Other device Frame Size (FSD or FSC) */
uint8_t DID; /*!< Device ID (RFAL_ISODEP_NO_DID if no DID) */
typedef struct {
rfalNfcDepPduBufFormat* txBuf; /*!< Transmit Buffer struct reference */
uint16_t txBufLen; /*!< Transmit Buffer INF field length in Bytes*/
rfalNfcDepPduBufFormat* rxBuf; /*!< Receive Buffer struct reference in Bytes */
uint16_t* rxLen; /*!< Received INF data length in Bytes */
rfalNfcDepBufFormat* tmpBuf; /*!< Temp buffer for single PDUs (internal) */
uint32_t FWT; /*!< FWT to be used (ignored in Listen Mode) */
uint32_t dFWT; /*!< Delta FWT to be used */
uint16_t FSx; /*!< Other device Frame Size (FSD or FSC) */
uint8_t DID; /*!< Device ID (RFAL_ISODEP_NO_DID if no DID) */
} rfalNfcDepPduTxRxParam;
/*
* *****************************************************************************
* GLOBAL VARIABLE DECLARATIONS
******************************************************************************
*/
/*
******************************************************************************
* GLOBAL FUNCTION PROTOTYPES
@@ -470,8 +517,7 @@ typedef struct
*
******************************************************************************
*/
void rfalNfcDepInitialize( void );
void rfalNfcDepInitialize(void);
/*!
******************************************************************************
@@ -484,8 +530,7 @@ void rfalNfcDepInitialize( void );
* \param[in] pFunc : method pointer to deactivation flag check
******************************************************************************
*/
void rfalNfcDepSetDeactivatingCallback( rfalNfcDepDeactCallback pFunc );
void rfalNfcDepSetDeactivatingCallback(rfalNfcDepDeactCallback pFunc);
/*!
******************************************************************************
@@ -498,8 +543,7 @@ void rfalNfcDepSetDeactivatingCallback( rfalNfcDepDeactCallback pFunc );
* \return RWT value in 1/fc
******************************************************************************
*/
uint32_t rfalNfcDepCalculateRWT( uint8_t wt );
uint32_t rfalNfcDepCalculateRWT(uint8_t wt);
/*!
******************************************************************************
@@ -517,8 +561,8 @@ uint32_t rfalNfcDepCalculateRWT( uint8_t wt );
* \return ERR_PROTO : Protocol error occurred
******************************************************************************
*/
ReturnCode rfalNfcDepATR( const rfalNfcDepAtrParam* param, rfalNfcDepAtrRes *atrRes, uint8_t* atrResLen );
ReturnCode
rfalNfcDepATR(const rfalNfcDepAtrParam* param, rfalNfcDepAtrRes* atrRes, uint8_t* atrResLen);
/*!
******************************************************************************
@@ -537,8 +581,7 @@ ReturnCode rfalNfcDepATR( const rfalNfcDepAtrParam* param, rfalNfcDepAtrRes *atr
* \return ERR_PROTO : Protocol error occurred
******************************************************************************
*/
ReturnCode rfalNfcDepPSL( uint8_t BRS, uint8_t FSL );
ReturnCode rfalNfcDepPSL(uint8_t BRS, uint8_t FSL);
/*!
******************************************************************************
@@ -555,8 +598,7 @@ ReturnCode rfalNfcDepPSL( uint8_t BRS, uint8_t FSL );
* \return ERR_PROTO : Protocol error occurred
******************************************************************************
*/
ReturnCode rfalNfcDepDSL( void );
ReturnCode rfalNfcDepDSL(void);
/*!
******************************************************************************
@@ -573,8 +615,7 @@ ReturnCode rfalNfcDepDSL( void );
* \return ERR_PROTO : Protocol error occurred
******************************************************************************
*/
ReturnCode rfalNfcDepRLS( void );
ReturnCode rfalNfcDepRLS(void);
/*!
*****************************************************************************
@@ -600,8 +641,10 @@ ReturnCode rfalNfcDepRLS( void );
* \return ERR_NONE : No error, activation successful
*****************************************************************************
*/
ReturnCode rfalNfcDepInitiatorHandleActivation( rfalNfcDepAtrParam* param, rfalBitRate desiredBR, rfalNfcDepDevice* nfcDepDev );
ReturnCode rfalNfcDepInitiatorHandleActivation(
rfalNfcDepAtrParam* param,
rfalBitRate desiredBR,
rfalNfcDepDevice* nfcDepDev);
/*!
******************************************************************************
@@ -621,8 +664,7 @@ ReturnCode rfalNfcDepInitiatorHandleActivation( rfalNfcDepAtrParam* param, rfalB
*
******************************************************************************
*/
bool rfalNfcDepIsAtrReq( const uint8_t* buf, uint16_t bufLen, uint8_t* nfcid3 );
bool rfalNfcDepIsAtrReq(const uint8_t* buf, uint16_t bufLen, uint8_t* nfcid3);
/*!
******************************************************************************
@@ -635,7 +677,7 @@ bool rfalNfcDepIsAtrReq( const uint8_t* buf, uint16_t bufLen, uint8_t* nfcid3 );
* \return false : no ATR has been received
******************************************************************************
*/
bool rfalNfcDepTargetRcvdATR( void );
bool rfalNfcDepTargetRcvdATR(void);
/*!
*****************************************************************************
@@ -667,8 +709,11 @@ bool rfalNfcDepTargetRcvdATR( void );
* \return ERR_LINK_LOSS : Remote Field is turned off
*****************************************************************************
*/
ReturnCode rfalNfcDepListenStartActivation( const rfalNfcDepTargetParam *param, const uint8_t *atrReq, uint16_t atrReqLength, rfalNfcDepListenActvParam rxParam );
ReturnCode rfalNfcDepListenStartActivation(
const rfalNfcDepTargetParam* param,
const uint8_t* atrReq,
uint16_t atrReqLength,
rfalNfcDepListenActvParam rxParam);
/*!
*****************************************************************************
@@ -679,7 +724,7 @@ ReturnCode rfalNfcDepListenStartActivation( const rfalNfcDepTargetParam *param,
* \return ERR_LINK_LOSS : Remote Field was turned off
*****************************************************************************
*/
ReturnCode rfalNfcDepListenGetActivationStatus( void );
ReturnCode rfalNfcDepListenGetActivationStatus(void);
/*!
*****************************************************************************
@@ -700,8 +745,7 @@ ReturnCode rfalNfcDepListenGetActivationStatus( void );
* \return ERR_NONE : The Transceive request has been started
*****************************************************************************
*/
ReturnCode rfalNfcDepStartTransceive( const rfalNfcDepTxRxParam *param );
ReturnCode rfalNfcDepStartTransceive(const rfalNfcDepTxRxParam* param);
/*!
*****************************************************************************
@@ -730,8 +774,7 @@ ReturnCode rfalNfcDepStartTransceive( const rfalNfcDepTxRxParam *param );
* this method to retrieve the remaining blocks
*****************************************************************************
*/
ReturnCode rfalNfcDepGetTransceiveStatus( void );
ReturnCode rfalNfcDepGetTransceiveStatus(void);
/*!
*****************************************************************************
@@ -754,8 +797,7 @@ ReturnCode rfalNfcDepGetTransceiveStatus( void );
* \return ERR_NONE : The Transceive request has been started
*****************************************************************************
*/
ReturnCode rfalNfcDepStartPduTransceive( rfalNfcDepPduTxRxParam param );
ReturnCode rfalNfcDepStartPduTransceive(rfalNfcDepPduTxRxParam param);
/*!
*****************************************************************************
@@ -775,7 +817,7 @@ ReturnCode rfalNfcDepStartPduTransceive( rfalNfcDepPduTxRxParam param );
* has turned off its field
*****************************************************************************
*/
ReturnCode rfalNfcDepGetPduTransceiveStatus( void );
ReturnCode rfalNfcDepGetPduTransceiveStatus(void);
#endif /* RFAL_NFCDEP_H_ */
+114 -81
View File
@@ -56,7 +56,6 @@
*
*/
#ifndef RFAL_NFCA_H
#define RFAL_NFCA_H
@@ -76,25 +75,34 @@
******************************************************************************
*/
#define RFAL_NFCA_CASCADE_1_UID_LEN 4U /*!< UID length of cascade level 1 only tag */
#define RFAL_NFCA_CASCADE_2_UID_LEN 7U /*!< UID length of cascade level 2 only tag */
#define RFAL_NFCA_CASCADE_3_UID_LEN 10U /*!< UID length of cascade level 3 only tag */
#define RFAL_NFCA_CASCADE_1_UID_LEN \
4U /*!< UID length of cascade level 1 only tag */
#define RFAL_NFCA_CASCADE_2_UID_LEN \
7U /*!< UID length of cascade level 2 only tag */
#define RFAL_NFCA_CASCADE_3_UID_LEN \
10U /*!< UID length of cascade level 3 only tag */
#define RFAL_NFCA_SENS_RES_PLATFORM_MASK 0x0FU /*!< SENS_RES (ATQA) platform configuration mask Digital 1.1 Table 10 */
#define RFAL_NFCA_SENS_RES_PLATFORM_T1T 0x0CU /*!< SENS_RES (ATQA) T1T platform configuration Digital 1.1 Table 10 */
#define RFAL_NFCA_SEL_RES_CONF_MASK 0x60U /*!< SEL_RES (SAK) platform configuration mask Digital 1.1 Table 19 */
#define RFAL_NFCA_SEL_RES_CONF_T2T 0x00U /*!< SEL_RES (SAK) T2T configuration Digital 1.1 Table 19 */
#define RFAL_NFCA_SEL_RES_CONF_T4T 0x20U /*!< SEL_RES (SAK) T4T configuration Digital 1.1 Table 19 */
#define RFAL_NFCA_SEL_RES_CONF_NFCDEP 0x40U /*!< SEL_RES (SAK) NFC-DEP configuration Digital 1.1 Table 19 */
#define RFAL_NFCA_SEL_RES_CONF_T4T_NFCDEP 0x60U /*!< SEL_RES (SAK) T4T and NFC-DEP configuration Digital 1.1 Table 19 */
#define RFAL_NFCA_SENS_RES_PLATFORM_MASK \
0x0FU /*!< SENS_RES (ATQA) platform configuration mask Digital 1.1 Table 10 */
#define RFAL_NFCA_SENS_RES_PLATFORM_T1T \
0x0CU /*!< SENS_RES (ATQA) T1T platform configuration Digital 1.1 Table 10 */
#define RFAL_NFCA_SEL_RES_CONF_MASK \
0x60U /*!< SEL_RES (SAK) platform configuration mask Digital 1.1 Table 19 */
#define RFAL_NFCA_SEL_RES_CONF_T2T \
0x00U /*!< SEL_RES (SAK) T2T configuration Digital 1.1 Table 19 */
#define RFAL_NFCA_SEL_RES_CONF_T4T \
0x20U /*!< SEL_RES (SAK) T4T configuration Digital 1.1 Table 19 */
#define RFAL_NFCA_SEL_RES_CONF_NFCDEP \
0x40U /*!< SEL_RES (SAK) NFC-DEP configuration Digital 1.1 Table 19 */
#define RFAL_NFCA_SEL_RES_CONF_T4T_NFCDEP \
0x60U /*!< SEL_RES (SAK) T4T and NFC-DEP configuration Digital 1.1 Table 19 */
/*! NFC-A minimum FDT(listen) = ((n * 128 + (84)) / fc) with n_min = 9 Digital 1.1 6.10.1
* = (1236)/fc
* Relax with 3etu: (3*128)/fc as with multiple NFC-A cards, response may take longer (JCOP cards)
* = (1236 + 384)/fc = 1620 / fc */
#define RFAL_NFCA_FDTMIN 1620U
#define RFAL_NFCA_FDTMIN 1620U
/*
******************************************************************************
* GLOBAL MACROS
@@ -102,22 +110,33 @@
*/
/*! Checks if device is a T1T given its SENS_RES */
#define rfalNfcaIsSensResT1T( sensRes ) ((((rfalNfcaSensRes*)(sensRes))->platformInfo & RFAL_NFCA_SENS_RES_PLATFORM_MASK) == RFAL_NFCA_SENS_RES_PLATFORM_T1T )
#define rfalNfcaIsSensResT1T(sensRes) \
((((rfalNfcaSensRes*)(sensRes))->platformInfo & RFAL_NFCA_SENS_RES_PLATFORM_MASK) == \
RFAL_NFCA_SENS_RES_PLATFORM_T1T)
/*! Checks if device is a T2T given its SENS_RES */
#define rfalNfcaIsSelResT2T( selRes ) ((((rfalNfcaSelRes*)(selRes))->sak & RFAL_NFCA_SEL_RES_CONF_MASK) == RFAL_NFCA_SEL_RES_CONF_T2T )
#define rfalNfcaIsSelResT2T(selRes) \
((((rfalNfcaSelRes*)(selRes))->sak & RFAL_NFCA_SEL_RES_CONF_MASK) == \
RFAL_NFCA_SEL_RES_CONF_T2T)
/*! Checks if device is a T4T given its SENS_RES */
#define rfalNfcaIsSelResT4T( selRes ) ((((rfalNfcaSelRes*)(selRes))->sak & RFAL_NFCA_SEL_RES_CONF_MASK) == RFAL_NFCA_SEL_RES_CONF_T4T )
#define rfalNfcaIsSelResT4T(selRes) \
((((rfalNfcaSelRes*)(selRes))->sak & RFAL_NFCA_SEL_RES_CONF_MASK) == \
RFAL_NFCA_SEL_RES_CONF_T4T)
/*! Checks if device supports NFC-DEP protocol given its SENS_RES */
#define rfalNfcaIsSelResNFCDEP( selRes ) ((((rfalNfcaSelRes*)(selRes))->sak & RFAL_NFCA_SEL_RES_CONF_MASK) == RFAL_NFCA_SEL_RES_CONF_NFCDEP )
#define rfalNfcaIsSelResNFCDEP(selRes) \
((((rfalNfcaSelRes*)(selRes))->sak & RFAL_NFCA_SEL_RES_CONF_MASK) == \
RFAL_NFCA_SEL_RES_CONF_NFCDEP)
/*! Checks if device supports ISO-DEP and NFC-DEP protocol given its SENS_RES */
#define rfalNfcaIsSelResT4TNFCDEP( selRes ) ((((rfalNfcaSelRes*)(selRes))->sak & RFAL_NFCA_SEL_RES_CONF_MASK) == RFAL_NFCA_SEL_RES_CONF_T4T_NFCDEP )
#define rfalNfcaIsSelResT4TNFCDEP(selRes) \
((((rfalNfcaSelRes*)(selRes))->sak & RFAL_NFCA_SEL_RES_CONF_MASK) == \
RFAL_NFCA_SEL_RES_CONF_T4T_NFCDEP)
/*! Checks if a NFC-A listener device supports multiple protocols (ISO-DEP and NFC-DEP) */
#define rfalNfcaLisDevIsMultiProto( lisDev ) (((rfalNfcaListenDevice*)(lisDev))->type == RFAL_NFCA_T4T_NFCDEP )
#define rfalNfcaLisDevIsMultiProto(lisDev) \
(((rfalNfcaListenDevice*)(lisDev))->type == RFAL_NFCA_T4T_NFCDEP)
/*
******************************************************************************
@@ -127,67 +146,74 @@
/*! NFC-A Listen device types */
typedef enum {
RFAL_NFCA_T1T = 0x01, /* Device configured for T1T Digital 1.1 Table 9 */
RFAL_NFCA_T2T = 0x00, /* Device configured for T2T Digital 1.1 Table 19 */
RFAL_NFCA_T4T = 0x20, /* Device configured for T4T Digital 1.1 Table 19 */
RFAL_NFCA_NFCDEP = 0x40, /* Device configured for NFC-DEP Digital 1.1 Table 19 */
RFAL_NFCA_T4T_NFCDEP = 0x60 /* Device configured for NFC-DEP and T4T Digital 1.1 Table 19 */
RFAL_NFCA_T1T =
0x01, /* Device configured for T1T Digital 1.1 Table 9 */
RFAL_NFCA_T2T =
0x00, /* Device configured for T2T Digital 1.1 Table 19 */
RFAL_NFCA_T4T =
0x20, /* Device configured for T4T Digital 1.1 Table 19 */
RFAL_NFCA_NFCDEP =
0x40, /* Device configured for NFC-DEP Digital 1.1 Table 19 */
RFAL_NFCA_T4T_NFCDEP =
0x60 /* Device configured for NFC-DEP and T4T Digital 1.1 Table 19 */
} rfalNfcaListenDeviceType;
/*! SENS_RES (ATQA) format Digital 1.1 6.6.3 & Table 7 */
typedef struct
{
uint8_t anticollisionInfo; /*!< SENS_RES Anticollision Information */
uint8_t platformInfo; /*!< SENS_RES Platform Information */
typedef struct {
uint8_t
anticollisionInfo; /*!< SENS_RES Anticollision Information */
uint8_t
platformInfo; /*!< SENS_RES Platform Information */
} rfalNfcaSensRes;
/*! SDD_REQ (Anticollision) format Digital 1.1 6.7.1 & Table 11 */
typedef struct
{
uint8_t selCmd; /*!< SDD_REQ SEL_CMD: cascade Level */
uint8_t selPar; /*!< SDD_REQ SEL_PAR: Byte Count[4b] | Bit Count[4b] (NVB: Number of Valid Bits)*/
typedef struct {
uint8_t
selCmd; /*!< SDD_REQ SEL_CMD: cascade Level */
uint8_t
selPar; /*!< SDD_REQ SEL_PAR: Byte Count[4b] | Bit Count[4b] (NVB: Number of Valid Bits)*/
} rfalNfcaSddReq;
/*! SDD_RES (UID CLn) format Digital 1.1 6.7.2 & Table 15 */
typedef struct
{
uint8_t nfcid1[RFAL_NFCA_CASCADE_1_UID_LEN]; /*!< NFCID1 cascade level NFCID */
uint8_t bcc; /*!< BCC Exclusive-OR over first 4 bytes of SDD_RES */
typedef struct {
uint8_t nfcid1
[RFAL_NFCA_CASCADE_1_UID_LEN]; /*!< NFCID1 cascade level NFCID */
uint8_t bcc; /*!< BCC Exclusive-OR over first 4 bytes of SDD_RES */
} rfalNfcaSddRes;
/*! SEL_REQ (Select) format Digital 1.1 6.8.1 & Table 17 */
typedef struct
{
uint8_t selCmd; /*!< SDD_REQ SEL_CMD: cascade Level */
uint8_t selPar; /*!< SDD_REQ SEL_PAR: Byte Count[4b] | Bit Count[4b] (NVB: Number of Valid Bits)*/
uint8_t nfcid1[RFAL_NFCA_CASCADE_1_UID_LEN]; /*!< NFCID1 data */
uint8_t bcc; /*!< Checksum calculated as exclusive-OR over the 4 bytes of NFCID1 CLn */
typedef struct {
uint8_t
selCmd; /*!< SDD_REQ SEL_CMD: cascade Level */
uint8_t
selPar; /*!< SDD_REQ SEL_PAR: Byte Count[4b] | Bit Count[4b] (NVB: Number of Valid Bits)*/
uint8_t nfcid1
[RFAL_NFCA_CASCADE_1_UID_LEN]; /*!< NFCID1 data */
uint8_t bcc; /*!< Checksum calculated as exclusive-OR over the 4 bytes of NFCID1 CLn */
} rfalNfcaSelReq;
/*! SEL_RES (SAK) format Digital 1.1 6.8.2 & Table 19 */
typedef struct
{
uint8_t sak; /*!< Select Acknowledge */
typedef struct {
uint8_t sak; /*!< Select Acknowledge */
} rfalNfcaSelRes;
/*! NFC-A listener device (PICC) struct */
typedef struct
{
rfalNfcaListenDeviceType type; /*!< NFC-A Listen device type */
rfalNfcaSensRes sensRes; /*!< SENS_RES (ATQA) */
rfalNfcaSelRes selRes; /*!< SEL_RES (SAK) */
uint8_t nfcId1Len; /*!< NFCID1 Length */
uint8_t nfcId1[RFAL_NFCA_CASCADE_3_UID_LEN]; /*!< NFCID1 (UID) */
typedef struct {
rfalNfcaListenDeviceType
type; /*!< NFC-A Listen device type */
rfalNfcaSensRes
sensRes; /*!< SENS_RES (ATQA) */
rfalNfcaSelRes
selRes; /*!< SEL_RES (SAK) */
uint8_t
nfcId1Len; /*!< NFCID1 Length */
uint8_t nfcId1
[RFAL_NFCA_CASCADE_3_UID_LEN]; /*!< NFCID1 (UID) */
#ifdef RFAL_FEATURE_T1T
rfalT1TRidRes ridRes; /*!< RID_RES */
rfalT1TRidRes
ridRes; /*!< RID_RES */
#endif /* RFAL_FEATURE_T1T */
bool isSleep; /*!< Device sleeping flag */
bool isSleep; /*!< Device sleeping flag */
} rfalNfcaListenDevice;
/*
@@ -209,8 +235,7 @@ typedef struct
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcaPollerInitialize( void );
ReturnCode rfalNfcaPollerInitialize(void);
/*!
*****************************************************************************
@@ -234,8 +259,7 @@ ReturnCode rfalNfcaPollerInitialize( void );
* \return ERR_NONE : No error, one or more device in the field
*****************************************************************************
*/
ReturnCode rfalNfcaPollerCheckPresence( rfal14443AShortFrameCmd cmd, rfalNfcaSensRes *sensRes );
ReturnCode rfalNfcaPollerCheckPresence(rfal14443AShortFrameCmd cmd, rfalNfcaSensRes* sensRes);
/*!
*****************************************************************************
@@ -258,8 +282,7 @@ ReturnCode rfalNfcaPollerCheckPresence( rfal14443AShortFrameCmd cmd, rfalNfcaSen
* \return ERR_NONE : No error, SEL_RES received
*****************************************************************************
*/
ReturnCode rfalNfcaPollerSelect( const uint8_t *nfcid1, uint8_t nfcidLen, rfalNfcaSelRes *selRes );
ReturnCode rfalNfcaPollerSelect(const uint8_t* nfcid1, uint8_t nfcidLen, rfalNfcaSelRes* selRes);
/*!
*****************************************************************************
@@ -274,8 +297,7 @@ ReturnCode rfalNfcaPollerSelect( const uint8_t *nfcid1, uint8_t nfcidLen, rfalNf
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcaPollerSleep( void );
ReturnCode rfalNfcaPollerSleep(void);
/*!
*****************************************************************************
@@ -297,8 +319,8 @@ ReturnCode rfalNfcaPollerSleep( void );
* \return ERR_NONE : No error, one or more device in the field
*****************************************************************************
*/
ReturnCode rfalNfcaPollerTechnologyDetection( rfalComplianceMode compMode, rfalNfcaSensRes *sensRes );
ReturnCode
rfalNfcaPollerTechnologyDetection(rfalComplianceMode compMode, rfalNfcaSensRes* sensRes);
/*!
*****************************************************************************
@@ -327,8 +349,12 @@ ReturnCode rfalNfcaPollerTechnologyDetection( rfalComplianceMode compMode, rfalN
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcaPollerSingleCollisionResolution( uint8_t devLimit, bool *collPending, rfalNfcaSelRes *selRes, uint8_t *nfcId1, uint8_t *nfcId1Len );
ReturnCode rfalNfcaPollerSingleCollisionResolution(
uint8_t devLimit,
bool* collPending,
rfalNfcaSelRes* selRes,
uint8_t* nfcId1,
uint8_t* nfcId1Len);
/*!
*****************************************************************************
@@ -358,8 +384,11 @@ ReturnCode rfalNfcaPollerSingleCollisionResolution( uint8_t devLimit, bool *coll
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcaPollerFullCollisionResolution( rfalComplianceMode compMode, uint8_t devLimit, rfalNfcaListenDevice *nfcaDevList, uint8_t *devCnt );
ReturnCode rfalNfcaPollerFullCollisionResolution(
rfalComplianceMode compMode,
uint8_t devLimit,
rfalNfcaListenDevice* nfcaDevList,
uint8_t* devCnt);
/*!
*****************************************************************************
@@ -383,8 +412,10 @@ ReturnCode rfalNfcaPollerFullCollisionResolution( rfalComplianceMode compMode, u
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcaPollerSleepFullCollisionResolution( uint8_t devLimit, rfalNfcaListenDevice *nfcaDevList, uint8_t *devCnt );
ReturnCode rfalNfcaPollerSleepFullCollisionResolution(
uint8_t devLimit,
rfalNfcaListenDevice* nfcaDevList,
uint8_t* devCnt);
/*!
*****************************************************************************
@@ -415,8 +446,11 @@ ReturnCode rfalNfcaPollerSleepFullCollisionResolution( uint8_t devLimit, rfalNfc
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcaPollerStartFullCollisionResolution( rfalComplianceMode compMode, uint8_t devLimit, rfalNfcaListenDevice *nfcaDevList, uint8_t *devCnt );
ReturnCode rfalNfcaPollerStartFullCollisionResolution(
rfalComplianceMode compMode,
uint8_t devLimit,
rfalNfcaListenDevice* nfcaDevList,
uint8_t* devCnt);
/*!
*****************************************************************************
@@ -436,8 +470,7 @@ ReturnCode rfalNfcaPollerStartFullCollisionResolution( rfalComplianceMode compMo
* \return ERR_NONE : No error, activation successful
*****************************************************************************
*/
ReturnCode rfalNfcaPollerGetFullCollisionResolutionStatus( void );
ReturnCode rfalNfcaPollerGetFullCollisionResolutionStatus(void);
/*!
*****************************************************************************
@@ -451,7 +484,7 @@ ReturnCode rfalNfcaPollerGetFullCollisionResolutionStatus( void );
* \return true if data in buf contains a SLP_REQ ; false otherwise
*****************************************************************************
*/
bool rfalNfcaListenerIsSleepReq( const uint8_t *buf, uint16_t bufLen );
bool rfalNfcaListenerIsSleepReq(const uint8_t* buf, uint16_t bufLen);
#endif /* RFAL_NFCA_H */
+113 -86
View File
@@ -52,7 +52,6 @@
*
*/
#ifndef RFAL_NFCB_H
#define RFAL_NFCB_H
@@ -71,37 +70,55 @@
******************************************************************************
*/
#define RFAL_NFCB_FWTSENSB 7680U /*!< NFC-B FWT(SENSB) Digital 2.0 B.3 */
#define RFAL_NFCB_DFWT 49152U /*!< NFC-B dFWT Delta 2.0 7.9.1.3 & B.3 */
#define RFAL_NFCB_DTPOLL_10 rfalConvMsTo1fc(20) /*!< NFC-B Delta Tb Poll Digital 1.0 A.2 */
#define RFAL_NFCB_DTPOLL_20 rfalConvMsTo1fc(17) /*!< NFC-B Delta Tb Poll Digital 2.1 B.3 */
#define RFAL_NFCB_FWTSENSB 7680U /*!< NFC-B FWT(SENSB) Digital 2.0 B.3 */
#define RFAL_NFCB_DFWT 49152U /*!< NFC-B dFWT Delta 2.0 7.9.1.3 & B.3 */
#define RFAL_NFCB_DTPOLL_10 rfalConvMsTo1fc(20) /*!< NFC-B Delta Tb Poll Digital 1.0 A.2 */
#define RFAL_NFCB_DTPOLL_20 rfalConvMsTo1fc(17) /*!< NFC-B Delta Tb Poll Digital 2.1 B.3 */
#define RFAL_NFCB_AFI 0x00U /*!< NFC-B default Application Family Digital 1.1 7.6.1.1 */
#define RFAL_NFCB_PARAM 0x00U /*!< NFC-B default SENSB_REQ PARAM */
#define RFAL_NFCB_CRC_LEN 2U /*!< NFC-B CRC length and CRC_B(AID) Digital 1.1 Table 28 */
#define RFAL_NFCB_NFCID0_LEN 4U /*!< Length of NFC-B NFCID0 */
#define RFAL_NFCB_CMD_LEN 1U /*!< Length of NFC-B Command */
#define RFAL_NFCB_AFI 0x00U /*!< NFC-B default Application Family Digital 1.1 7.6.1.1 */
#define RFAL_NFCB_PARAM 0x00U /*!< NFC-B default SENSB_REQ PARAM */
#define RFAL_NFCB_CRC_LEN 2U /*!< NFC-B CRC length and CRC_B(AID) Digital 1.1 Table 28 */
#define RFAL_NFCB_NFCID0_LEN 4U /*!< Length of NFC-B NFCID0 */
#define RFAL_NFCB_CMD_LEN 1U /*!< Length of NFC-B Command */
#define RFAL_NFCB_SENSB_RES_LEN 12U /*!< Standard length of SENSB_RES without SFGI byte */
#define RFAL_NFCB_SENSB_RES_EXT_LEN 13U /*!< Extended length of SENSB_RES with SFGI byte */
#define RFAL_NFCB_SENSB_RES_LEN 12U /*!< Standard length of SENSB_RES without SFGI byte */
#define RFAL_NFCB_SENSB_RES_EXT_LEN \
13U /*!< Extended length of SENSB_RES with SFGI byte */
#define RFAL_NFCB_SENSB_REQ_ADV_FEATURE 0x20U /*!< Bit mask for Advance Feature in SENSB_REQ */
#define RFAL_NFCB_SENSB_RES_FSCI_MASK 0x0FU /*!< Bit mask for FSCI value in SENSB_RES */
#define RFAL_NFCB_SENSB_RES_FSCI_SHIFT 4U /*!< Shift for FSCI value in SENSB_RES */
#define RFAL_NFCB_SENSB_RES_PROTO_RFU_MASK 0x08U /*!< Bit mask for Protocol Type RFU in SENSB_RES */
#define RFAL_NFCB_SENSB_RES_PROTO_TR2_MASK 0x03U /*!< Bit mask for Protocol Type TR2 in SENSB_RES */
#define RFAL_NFCB_SENSB_RES_PROTO_TR2_SHIFT 1U /*!< Shift for Protocol Type TR2 in SENSB_RES */
#define RFAL_NFCB_SENSB_RES_PROTO_ISO_MASK 0x01U /*!< Bit mask Protocol Type ISO14443 Compliant in SENSB_RES */
#define RFAL_NFCB_SENSB_RES_FWI_MASK 0x0FU /*!< Bit mask for FWI value in SENSB_RES */
#define RFAL_NFCB_SENSB_RES_FWI_SHIFT 4U /*!< Bit mask for FWI value in SENSB_RES */
#define RFAL_NFCB_SENSB_RES_ADC_MASK 0x0CU /*!< Bit mask for ADC value in SENSB_RES */
#define RFAL_NFCB_SENSB_RES_ADC_ADV_FEATURE_MASK 0x08U /*!< Bit mask for ADC.Advanced Proto Features in SENSB_RES */
#define RFAL_NFCB_SENSB_RES_ADC_PROPRIETARY_MASK 0x04U /*!< Bit mask for ADC.Proprietary Application in SENSB_RES */
#define RFAL_NFCB_SENSB_RES_FO_DID_MASK 0x01U /*!< Bit mask for DID in SENSB_RES */
#define RFAL_NFCB_SENSB_RES_FO_NAD_MASK 0x02U /*!< Bit mask for DID in SENSB_RES */
#define RFAL_NFCB_SENSB_RES_FO_MASK 0x03U /*!< Bit mask for FO value in SENSB_RES (NAD and DID) */
#define RFAL_NFCB_SENSB_RES_SFGI_MASK 0x0FU /*!< Bit mask for SFGI in SENSB_RES */
#define RFAL_NFCB_SENSB_RES_SFGI_SHIFT 4U /*!< Shift for SFGI in SENSB_RES */
#define RFAL_NFCB_SENSB_REQ_ADV_FEATURE \
0x20U /*!< Bit mask for Advance Feature in SENSB_REQ */
#define RFAL_NFCB_SENSB_RES_FSCI_MASK \
0x0FU /*!< Bit mask for FSCI value in SENSB_RES */
#define RFAL_NFCB_SENSB_RES_FSCI_SHIFT \
4U /*!< Shift for FSCI value in SENSB_RES */
#define RFAL_NFCB_SENSB_RES_PROTO_RFU_MASK \
0x08U /*!< Bit mask for Protocol Type RFU in SENSB_RES */
#define RFAL_NFCB_SENSB_RES_PROTO_TR2_MASK \
0x03U /*!< Bit mask for Protocol Type TR2 in SENSB_RES */
#define RFAL_NFCB_SENSB_RES_PROTO_TR2_SHIFT \
1U /*!< Shift for Protocol Type TR2 in SENSB_RES */
#define RFAL_NFCB_SENSB_RES_PROTO_ISO_MASK \
0x01U /*!< Bit mask Protocol Type ISO14443 Compliant in SENSB_RES */
#define RFAL_NFCB_SENSB_RES_FWI_MASK \
0x0FU /*!< Bit mask for FWI value in SENSB_RES */
#define RFAL_NFCB_SENSB_RES_FWI_SHIFT \
4U /*!< Bit mask for FWI value in SENSB_RES */
#define RFAL_NFCB_SENSB_RES_ADC_MASK \
0x0CU /*!< Bit mask for ADC value in SENSB_RES */
#define RFAL_NFCB_SENSB_RES_ADC_ADV_FEATURE_MASK \
0x08U /*!< Bit mask for ADC.Advanced Proto Features in SENSB_RES */
#define RFAL_NFCB_SENSB_RES_ADC_PROPRIETARY_MASK \
0x04U /*!< Bit mask for ADC.Proprietary Application in SENSB_RES */
#define RFAL_NFCB_SENSB_RES_FO_DID_MASK \
0x01U /*!< Bit mask for DID in SENSB_RES */
#define RFAL_NFCB_SENSB_RES_FO_NAD_MASK \
0x02U /*!< Bit mask for DID in SENSB_RES */
#define RFAL_NFCB_SENSB_RES_FO_MASK \
0x03U /*!< Bit mask for FO value in SENSB_RES (NAD and DID) */
#define RFAL_NFCB_SENSB_RES_SFGI_MASK \
0x0FU /*!< Bit mask for SFGI in SENSB_RES */
#define RFAL_NFCB_SENSB_RES_SFGI_SHIFT \
4U /*!< Shift for SFGI in SENSB_RES */
/*
******************************************************************************
@@ -110,10 +127,14 @@
*/
/*! Get device's FSCI given its SENSB_RES Digital 1.1 7.6.2 */
#define rfalNfcbGetFSCI( sensbRes ) ((((rfalNfcbSensbRes*)(sensbRes))->protInfo.FsciProType >> RFAL_NFCB_SENSB_RES_FSCI_SHIFT) & RFAL_NFCB_SENSB_RES_FSCI_MASK )
#define rfalNfcbGetFSCI(sensbRes) \
((((rfalNfcbSensbRes*)(sensbRes))->protInfo.FsciProType >> RFAL_NFCB_SENSB_RES_FSCI_SHIFT) & \
RFAL_NFCB_SENSB_RES_FSCI_MASK)
/*! Checks if the given NFC-B device indicates ISO-DEP support */
#define rfalNfcbIsIsoDepSupported( dev ) ( (((rfalNfcbListenDevice*)(dev))->sensbRes.protInfo.FsciProType & RFAL_NFCB_SENSB_RES_PROTO_ISO_MASK) != 0U )
#define rfalNfcbIsIsoDepSupported(dev) \
((((rfalNfcbListenDevice*)(dev))->sensbRes.protInfo.FsciProType & \
RFAL_NFCB_SENSB_RES_PROTO_ISO_MASK) != 0U)
/*
******************************************************************************
@@ -122,60 +143,53 @@
*/
/*! SENSB_REQ and ALLB_REQ param Digital 1.1 7.6.1 */
typedef enum
{
RFAL_NFCB_SENS_CMD_ALLB_REQ = 0x08, /*!< ALLB_REQ (WUPB) */
RFAL_NFCB_SENS_CMD_SENSB_REQ = 0x00 /*!< SENSB_REQ (REQB) */
typedef enum {
RFAL_NFCB_SENS_CMD_ALLB_REQ = 0x08, /*!< ALLB_REQ (WUPB) */
RFAL_NFCB_SENS_CMD_SENSB_REQ = 0x00 /*!< SENSB_REQ (REQB) */
} rfalNfcbSensCmd;
/*! Number of Slots (NI) codes used for NFC-B anti collision Digital 1.1 Table 26 */
typedef enum
{
RFAL_NFCB_SLOT_NUM_1 = 0, /*!< N=0 : 1 slot */
RFAL_NFCB_SLOT_NUM_2 = 1, /*!< N=1 : 2 slots */
RFAL_NFCB_SLOT_NUM_4 = 2, /*!< N=2 : 4 slots */
RFAL_NFCB_SLOT_NUM_8 = 3, /*!< N=3 : 8 slots */
RFAL_NFCB_SLOT_NUM_16 = 4 /*!< N=4 : 16 slots */
}rfalNfcbSlots;
typedef enum {
RFAL_NFCB_SLOT_NUM_1 = 0, /*!< N=0 : 1 slot */
RFAL_NFCB_SLOT_NUM_2 = 1, /*!< N=1 : 2 slots */
RFAL_NFCB_SLOT_NUM_4 = 2, /*!< N=2 : 4 slots */
RFAL_NFCB_SLOT_NUM_8 = 3, /*!< N=3 : 8 slots */
RFAL_NFCB_SLOT_NUM_16 = 4 /*!< N=4 : 16 slots */
} rfalNfcbSlots;
/*! SENSB_RES (ATQB) Application Data Format Digital 1.1 Table 28 */
typedef struct
{
uint8_t AFI; /*!< Application Family Identifier */
uint8_t CRC_B[RFAL_NFCB_CRC_LEN]; /*!< CRC_B of AID */
uint8_t numApps; /*!< Number of Applications */
typedef struct {
uint8_t AFI; /*!< Application Family Identifier */
uint8_t CRC_B[RFAL_NFCB_CRC_LEN]; /*!< CRC_B of AID */
uint8_t numApps; /*!< Number of Applications */
} rfalNfcbSensbResAppData;
/*! SENSB_RES Protocol Info format Digital 1.1 Table 29 */
typedef struct
{
uint8_t BRC; /*!< Bit Rate Capability */
uint8_t FsciProType; /*!< Frame Size Card Integer [4b] | Protocol Type[4 bits] */
uint8_t FwiAdcFo; /*!< Frame Waiting Integer [4b] | Application Data Coding [2b] | Frame Options [2b] */
uint8_t SFGI; /*!< Optional: Start-Up Frame Guard Time Integer[4b] | RFU [4b] */
typedef struct {
uint8_t
BRC; /*!< Bit Rate Capability */
uint8_t
FsciProType; /*!< Frame Size Card Integer [4b] | Protocol Type[4 bits] */
uint8_t
FwiAdcFo; /*!< Frame Waiting Integer [4b] | Application Data Coding [2b] | Frame Options [2b] */
uint8_t
SFGI; /*!< Optional: Start-Up Frame Guard Time Integer[4b] | RFU [4b] */
} rfalNfcbSensbResProtocolInfo;
/*! SENSB_RES format Digital 1.1 7.6.2 */
typedef struct
{
uint8_t cmd; /*!< SENSB_RES: 50h */
uint8_t nfcid0[RFAL_NFCB_NFCID0_LEN]; /*!< NFC Identifier (PUPI)*/
rfalNfcbSensbResAppData appData; /*!< Application Data */
rfalNfcbSensbResProtocolInfo protInfo; /*!< Protocol Information */
typedef struct {
uint8_t cmd; /*!< SENSB_RES: 50h */
uint8_t nfcid0[RFAL_NFCB_NFCID0_LEN]; /*!< NFC Identifier (PUPI)*/
rfalNfcbSensbResAppData appData; /*!< Application Data */
rfalNfcbSensbResProtocolInfo protInfo; /*!< Protocol Information */
} rfalNfcbSensbRes;
/*! NFC-B listener device (PICC) struct */
typedef struct
{
uint8_t sensbResLen; /*!< SENSB_RES length */
rfalNfcbSensbRes sensbRes; /*!< SENSB_RES */
bool isSleep; /*!< Device sleeping flag */
}rfalNfcbListenDevice;
typedef struct {
uint8_t sensbResLen; /*!< SENSB_RES length */
rfalNfcbSensbRes sensbRes; /*!< SENSB_RES */
bool isSleep; /*!< Device sleeping flag */
} rfalNfcbListenDevice;
/*
******************************************************************************
@@ -196,8 +210,7 @@ typedef struct
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcbPollerInitialize( void );
ReturnCode rfalNfcbPollerInitialize(void);
/*!
*****************************************************************************
@@ -217,8 +230,7 @@ ReturnCode rfalNfcbPollerInitialize( void );
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcbPollerInitializeWithParams( uint8_t AFI, uint8_t PARAM );
ReturnCode rfalNfcbPollerInitializeWithParams(uint8_t AFI, uint8_t PARAM);
/*!
*****************************************************************************
@@ -245,8 +257,11 @@ ReturnCode rfalNfcbPollerInitializeWithParams( uint8_t AFI, uint8_t PARAM );
* \return ERR_NONE : No error, SENSB_RES received
*****************************************************************************
*/
ReturnCode rfalNfcbPollerCheckPresence( rfalNfcbSensCmd cmd, rfalNfcbSlots slots, rfalNfcbSensbRes *sensbRes, uint8_t *sensbResLen );
ReturnCode rfalNfcbPollerCheckPresence(
rfalNfcbSensCmd cmd,
rfalNfcbSlots slots,
rfalNfcbSensbRes* sensbRes,
uint8_t* sensbResLen);
/*!
*****************************************************************************
@@ -264,8 +279,7 @@ ReturnCode rfalNfcbPollerCheckPresence( rfalNfcbSensCmd cmd, rfalNfcbSlots slots
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcbPollerSleep( const uint8_t* nfcid0 );
ReturnCode rfalNfcbPollerSleep(const uint8_t* nfcid0);
/*!
*****************************************************************************
@@ -288,7 +302,8 @@ ReturnCode rfalNfcbPollerSleep( const uint8_t* nfcid0 );
* \return ERR_NONE : No error, SEL_RES received
*****************************************************************************
*/
ReturnCode rfalNfcbPollerSlotMarker( uint8_t slotCode, rfalNfcbSensbRes *sensbRes, uint8_t *sensbResLen );
ReturnCode
rfalNfcbPollerSlotMarker(uint8_t slotCode, rfalNfcbSensbRes* sensbRes, uint8_t* sensbResLen);
/*!
*****************************************************************************
@@ -307,7 +322,10 @@ ReturnCode rfalNfcbPollerSlotMarker( uint8_t slotCode, rfalNfcbSensbRes *sensbRe
* \return ERR_NONE : No error, one or more device in the field
*****************************************************************************
*/
ReturnCode rfalNfcbPollerTechnologyDetection( rfalComplianceMode compMode, rfalNfcbSensbRes *sensbRes, uint8_t *sensbResLen );
ReturnCode rfalNfcbPollerTechnologyDetection(
rfalComplianceMode compMode,
rfalNfcbSensbRes* sensbRes,
uint8_t* sensbResLen);
/*!
*****************************************************************************
@@ -332,7 +350,11 @@ ReturnCode rfalNfcbPollerTechnologyDetection( rfalComplianceMode compMode, rfalN
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcbPollerCollisionResolution( rfalComplianceMode compMode, uint8_t devLimit, rfalNfcbListenDevice *nfcbDevList, uint8_t *devCnt );
ReturnCode rfalNfcbPollerCollisionResolution(
rfalComplianceMode compMode,
uint8_t devLimit,
rfalNfcbListenDevice* nfcbDevList,
uint8_t* devCnt);
/*!
*****************************************************************************
@@ -369,8 +391,14 @@ ReturnCode rfalNfcbPollerCollisionResolution( rfalComplianceMode compMode, uint8
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcbPollerSlottedCollisionResolution( rfalComplianceMode compMode, uint8_t devLimit, rfalNfcbSlots initSlots, rfalNfcbSlots endSlots, rfalNfcbListenDevice *nfcbDevList, uint8_t *devCnt, bool *colPending );
ReturnCode rfalNfcbPollerSlottedCollisionResolution(
rfalComplianceMode compMode,
uint8_t devLimit,
rfalNfcbSlots initSlots,
rfalNfcbSlots endSlots,
rfalNfcbListenDevice* nfcbDevList,
uint8_t* devCnt,
bool* colPending);
/*!
*****************************************************************************
@@ -384,8 +412,7 @@ ReturnCode rfalNfcbPollerSlottedCollisionResolution( rfalComplianceMode compMode
* \return FDT in 1/Fc
*****************************************************************************
*/
uint32_t rfalNfcbTR2ToFDT( uint8_t tr2Code );
uint32_t rfalNfcbTR2ToFDT(uint8_t tr2Code);
#endif /* RFAL_NFCB_H */
+131 -98
View File
@@ -49,7 +49,6 @@
*
*/
#ifndef RFAL_NFCF_H
#define RFAL_NFCF_H
@@ -68,66 +67,90 @@
******************************************************************************
*/
#define RFAL_NFCF_NFCID2_LEN 8U /*!< NFCID2 (FeliCa IDm) length */
#define RFAL_NFCF_SENSF_RES_LEN_MIN 16U /*!< SENSF_RES minimum length */
#define RFAL_NFCF_SENSF_RES_LEN_MAX 18U /*!< SENSF_RES maximum length */
#define RFAL_NFCF_SENSF_RES_PAD0_LEN 2U /*!< SENSF_RES PAD0 length */
#define RFAL_NFCF_SENSF_RES_PAD1_LEN 2U /*!< SENSF_RES PAD1 length */
#define RFAL_NFCF_SENSF_RES_RD_LEN 2U /*!< SENSF_RES Request Data length */
#define RFAL_NFCF_SENSF_RES_BYTE1 1U /*!< SENSF_RES first byte value */
#define RFAL_NFCF_SENSF_SC_LEN 2U /*!< Felica SENSF_REQ System Code length */
#define RFAL_NFCF_SENSF_PARAMS_SC1_POS 0U /*!< System Code byte1 position in the SENSF_REQ */
#define RFAL_NFCF_SENSF_PARAMS_SC2_POS 1U /*!< System Code byte2 position in the SENSF_REQ */
#define RFAL_NFCF_SENSF_PARAMS_RC_POS 2U /*!< Request Code position in the SENSF_REQ */
#define RFAL_NFCF_SENSF_PARAMS_TSN_POS 3U /*!< Time Slot Number position in the SENSF_REQ */
#define RFAL_NFCF_POLL_MAXCARDS 16U /*!< Max number slots/cards 16 */
#define RFAL_NFCF_NFCID2_LEN 8U /*!< NFCID2 (FeliCa IDm) length */
#define RFAL_NFCF_SENSF_RES_LEN_MIN 16U /*!< SENSF_RES minimum length */
#define RFAL_NFCF_SENSF_RES_LEN_MAX 18U /*!< SENSF_RES maximum length */
#define RFAL_NFCF_SENSF_RES_PAD0_LEN 2U /*!< SENSF_RES PAD0 length */
#define RFAL_NFCF_SENSF_RES_PAD1_LEN 2U /*!< SENSF_RES PAD1 length */
#define RFAL_NFCF_SENSF_RES_RD_LEN 2U /*!< SENSF_RES Request Data length */
#define RFAL_NFCF_SENSF_RES_BYTE1 1U /*!< SENSF_RES first byte value */
#define RFAL_NFCF_SENSF_SC_LEN 2U /*!< Felica SENSF_REQ System Code length */
#define RFAL_NFCF_SENSF_PARAMS_SC1_POS 0U /*!< System Code byte1 position in the SENSF_REQ */
#define RFAL_NFCF_SENSF_PARAMS_SC2_POS 1U /*!< System Code byte2 position in the SENSF_REQ */
#define RFAL_NFCF_SENSF_PARAMS_RC_POS 2U /*!< Request Code position in the SENSF_REQ */
#define RFAL_NFCF_SENSF_PARAMS_TSN_POS 3U /*!< Time Slot Number position in the SENSF_REQ */
#define RFAL_NFCF_POLL_MAXCARDS 16U /*!< Max number slots/cards 16 */
#define RFAL_NFCF_CMD_POS 0U /*!< Command/Responce code length */
#define RFAL_NFCF_CMD_LEN 1U /*!< Command/Responce code length */
#define RFAL_NFCF_LENGTH_LEN 1U /*!< LEN field length */
#define RFAL_NFCF_HEADER_LEN (RFAL_NFCF_LENGTH_LEN + RFAL_NFCF_CMD_LEN) /*!< Header length*/
#define RFAL_NFCF_CMD_POS 0U /*!< Command/Responce code length */
#define RFAL_NFCF_CMD_LEN 1U /*!< Command/Responce code length */
#define RFAL_NFCF_LENGTH_LEN 1U /*!< LEN field length */
#define RFAL_NFCF_HEADER_LEN (RFAL_NFCF_LENGTH_LEN + RFAL_NFCF_CMD_LEN) /*!< Header length*/
#define RFAL_NFCF_SENSF_NFCID2_BYTE1_POS \
0U /*!< NFCID2 byte1 position */
#define RFAL_NFCF_SENSF_NFCID2_BYTE2_POS \
1U /*!< NFCID2 byte2 position */
#define RFAL_NFCF_SENSF_NFCID2_PROT_TYPE_LEN \
2U /*!< NFCID2 length for byte 1 and byte 2 indicating NFC-DEP or T3T support */
#define RFAL_NFCF_SENSF_NFCID2_BYTE1_NFCDEP \
0x01U /*!< NFCID2 byte1 NFC-DEP support Digital 1.0 Table 44 */
#define RFAL_NFCF_SENSF_NFCID2_BYTE2_NFCDEP \
0xFEU /*!< NFCID2 byte2 NFC-DEP support Digital 1.0 Table 44 */
#define RFAL_NFCF_SENSF_NFCID2_BYTE1_POS 0U /*!< NFCID2 byte1 position */
#define RFAL_NFCF_SENSF_NFCID2_BYTE2_POS 1U /*!< NFCID2 byte2 position */
#define RFAL_NFCF_SYSTEMCODE \
0xFFFFU /*!< SENSF_RES Default System Code Digital 1.0 6.6.1.1 */
#define RFAL_NFCF_SENSF_NFCID2_PROT_TYPE_LEN 2U /*!< NFCID2 length for byte 1 and byte 2 indicating NFC-DEP or T3T support */
#define RFAL_NFCF_SENSF_NFCID2_BYTE1_NFCDEP 0x01U /*!< NFCID2 byte1 NFC-DEP support Digital 1.0 Table 44 */
#define RFAL_NFCF_SENSF_NFCID2_BYTE2_NFCDEP 0xFEU /*!< NFCID2 byte2 NFC-DEP support Digital 1.0 Table 44 */
#define RFAL_NFCF_BLOCK_LEN \
16U /*!< NFCF T3T Block size T3T 1.0 4.1 */
#define RFAL_NFCF_CHECKUPDATE_RES_ST1_POS \
9U /*!< Check|Update Res Status Flag 1 position T3T 1.0 Table 8 */
#define RFAL_NFCF_CHECKUPDATE_RES_ST2_POS \
10U /*!< Check|Update Res Status Flag 2 position T3T 1.0 Table 8 */
#define RFAL_NFCF_CHECKUPDATE_RES_NOB_POS \
11U /*!< Check|Update Res Number of Blocks position T3T 1.0 Table 8 */
#define RFAL_NFCF_SYSTEMCODE 0xFFFFU /*!< SENSF_RES Default System Code Digital 1.0 6.6.1.1 */
#define RFAL_NFCF_STATUS_FLAG_SUCCESS \
0x00U /*!< Check response Number of Blocks position T3T 1.0 Table 11 */
#define RFAL_NFCF_STATUS_FLAG_ERROR \
0xFFU /*!< Check response Number of Blocks position T3T 1.0 Table 11 */
#define RFAL_NFCF_BLOCK_LEN 16U /*!< NFCF T3T Block size T3T 1.0 4.1 */
#define RFAL_NFCF_CHECKUPDATE_RES_ST1_POS 9U /*!< Check|Update Res Status Flag 1 position T3T 1.0 Table 8 */
#define RFAL_NFCF_CHECKUPDATE_RES_ST2_POS 10U /*!< Check|Update Res Status Flag 2 position T3T 1.0 Table 8 */
#define RFAL_NFCF_CHECKUPDATE_RES_NOB_POS 11U /*!< Check|Update Res Number of Blocks position T3T 1.0 Table 8 */
#define RFAL_NFCF_STATUS_FLAG_SUCCESS 0x00U /*!< Check response Number of Blocks position T3T 1.0 Table 11 */
#define RFAL_NFCF_STATUS_FLAG_ERROR 0xFFU /*!< Check response Number of Blocks position T3T 1.0 Table 11 */
#define RFAL_NFCF_BLOCKLISTELEM_LEN 0x80U /*!< Block List Element Length bit (2|3 bytes) T3T 1.0 5.6.1 */
#define RFAL_NFCF_SERVICECODE_RDONLY 0x000BU /*!< NDEF Service Code as Read-Only T3T 1.0 7.2.1 */
#define RFAL_NFCF_SERVICECODE_RDWR 0x0009U /*!< NDEF Service Code as Read and Write T3T 1.0 7.2.1 */
#define RFAL_NFCF_BLOCKLISTELEM_LEN \
0x80U /*!< Block List Element Length bit (2|3 bytes) T3T 1.0 5.6.1 */
#define RFAL_NFCF_SERVICECODE_RDONLY \
0x000BU /*!< NDEF Service Code as Read-Only T3T 1.0 7.2.1 */
#define RFAL_NFCF_SERVICECODE_RDWR \
0x0009U /*!< NDEF Service Code as Read and Write T3T 1.0 7.2.1 */
/*! NFC-F Felica command set JIS X6319-4 9.1 */
enum
{
RFAL_NFCF_CMD_POLLING = 0x00, /*!< SENSF_REQ (Felica Poll/REQC command to identify a card ) */
RFAL_NFCF_CMD_POLLING_RES = 0x01, /*!< SENSF_RES (Felica Poll/REQC command response ) */
RFAL_NFCF_CMD_REQUEST_SERVICE = 0x02, /*!< verify the existence of Area and Service */
RFAL_NFCF_CMD_REQUEST_RESPONSE = 0x04, /*!< verify the existence of a card */
RFAL_NFCF_CMD_READ_WITHOUT_ENCRYPTION = 0x06, /*!< read Block Data from a Service that requires no authentication */
RFAL_NFCF_CMD_READ_WITHOUT_ENCRYPTION_RES = 0x07, /*!< read Block Data response from a Service with no authentication */
RFAL_NFCF_CMD_WRITE_WITHOUT_ENCRYPTION = 0x08, /*!< write Block Data to a Service that requires no authentication */
RFAL_NFCF_CMD_WRITE_WITHOUT_ENCRYPTION_RES = 0x09, /*!< write Block Data response to a Service with no authentication */
RFAL_NFCF_CMD_REQUEST_SYSTEM_CODE = 0x0c, /*!< acquire the System Code registered to a card */
RFAL_NFCF_CMD_AUTHENTICATION1 = 0x10, /*!< authenticate a card */
RFAL_NFCF_CMD_AUTHENTICATION2 = 0x12, /*!< allow a card to authenticate a Reader/Writer */
RFAL_NFCF_CMD_READ = 0x14, /*!< read Block Data from a Service that requires authentication */
RFAL_NFCF_CMD_WRITE = 0x16, /*!< write Block Data to a Service that requires authentication */
enum {
RFAL_NFCF_CMD_POLLING =
0x00, /*!< SENSF_REQ (Felica Poll/REQC command to identify a card ) */
RFAL_NFCF_CMD_POLLING_RES =
0x01, /*!< SENSF_RES (Felica Poll/REQC command response ) */
RFAL_NFCF_CMD_REQUEST_SERVICE =
0x02, /*!< verify the existence of Area and Service */
RFAL_NFCF_CMD_REQUEST_RESPONSE =
0x04, /*!< verify the existence of a card */
RFAL_NFCF_CMD_READ_WITHOUT_ENCRYPTION =
0x06, /*!< read Block Data from a Service that requires no authentication */
RFAL_NFCF_CMD_READ_WITHOUT_ENCRYPTION_RES =
0x07, /*!< read Block Data response from a Service with no authentication */
RFAL_NFCF_CMD_WRITE_WITHOUT_ENCRYPTION =
0x08, /*!< write Block Data to a Service that requires no authentication */
RFAL_NFCF_CMD_WRITE_WITHOUT_ENCRYPTION_RES =
0x09, /*!< write Block Data response to a Service with no authentication */
RFAL_NFCF_CMD_REQUEST_SYSTEM_CODE =
0x0c, /*!< acquire the System Code registered to a card */
RFAL_NFCF_CMD_AUTHENTICATION1 =
0x10, /*!< authenticate a card */
RFAL_NFCF_CMD_AUTHENTICATION2 =
0x12, /*!< allow a card to authenticate a Reader/Writer */
RFAL_NFCF_CMD_READ =
0x14, /*!< read Block Data from a Service that requires authentication */
RFAL_NFCF_CMD_WRITE =
0x16, /*!< write Block Data to a Service that requires authentication */
};
/*
@@ -137,9 +160,11 @@ enum
*/
/*! Checks if the given NFC-F device indicates NFC-DEP support */
#define rfalNfcfIsNfcDepSupported( dev ) ( (((rfalNfcfListenDevice*)(dev))->sensfRes.NFCID2[RFAL_NFCF_SENSF_NFCID2_BYTE1_POS] == RFAL_NFCF_SENSF_NFCID2_BYTE1_NFCDEP) && \
(((rfalNfcfListenDevice*)(dev))->sensfRes.NFCID2[RFAL_NFCF_SENSF_NFCID2_BYTE2_POS] == RFAL_NFCF_SENSF_NFCID2_BYTE2_NFCDEP) )
#define rfalNfcfIsNfcDepSupported(dev) \
((((rfalNfcfListenDevice*)(dev))->sensfRes.NFCID2[RFAL_NFCF_SENSF_NFCID2_BYTE1_POS] == \
RFAL_NFCF_SENSF_NFCID2_BYTE1_NFCDEP) && \
(((rfalNfcfListenDevice*)(dev))->sensfRes.NFCID2[RFAL_NFCF_SENSF_NFCID2_BYTE2_POS] == \
RFAL_NFCF_SENSF_NFCID2_BYTE2_NFCDEP))
/*
******************************************************************************
@@ -147,52 +172,44 @@ enum
******************************************************************************
*/
/*! NFC-F SENSF_RES format Digital 1.1 8.6.2 */
typedef struct
{
uint8_t CMD; /*!< Command Code: 01h */
uint8_t NFCID2[RFAL_NFCF_NFCID2_LEN]; /*!< NFCID2 */
typedef struct {
uint8_t CMD; /*!< Command Code: 01h */
uint8_t NFCID2[RFAL_NFCF_NFCID2_LEN]; /*!< NFCID2 */
uint8_t PAD0[RFAL_NFCF_SENSF_RES_PAD0_LEN]; /*!< PAD0 */
uint8_t PAD1[RFAL_NFCF_SENSF_RES_PAD1_LEN]; /*!< PAD1 */
uint8_t MRTIcheck; /*!< MRTIcheck */
uint8_t MRTIupdate; /*!< MRTIupdate */
uint8_t PAD2; /*!< PAD2 */
uint8_t RD[RFAL_NFCF_SENSF_RES_RD_LEN]; /*!< Request Data */
uint8_t MRTIcheck; /*!< MRTIcheck */
uint8_t MRTIupdate; /*!< MRTIupdate */
uint8_t PAD2; /*!< PAD2 */
uint8_t RD[RFAL_NFCF_SENSF_RES_RD_LEN]; /*!< Request Data */
} rfalNfcfSensfRes;
/*! NFC-F poller device (PCD) struct */
typedef struct
{
uint8_t NFCID2[RFAL_NFCF_NFCID2_LEN]; /*!< NFCID2 */
typedef struct {
uint8_t NFCID2[RFAL_NFCF_NFCID2_LEN]; /*!< NFCID2 */
} rfalNfcfPollDevice;
/*! NFC-F listener device (PICC) struct */
typedef struct
{
uint8_t sensfResLen; /*!< SENF_RES length */
rfalNfcfSensfRes sensfRes; /*!< SENF_RES */
typedef struct {
uint8_t sensfResLen; /*!< SENF_RES length */
rfalNfcfSensfRes sensfRes; /*!< SENF_RES */
} rfalNfcfListenDevice;
typedef uint16_t rfalNfcfServ; /*!< NFC-F Service Code */
typedef uint16_t rfalNfcfServ; /*!< NFC-F Service Code */
/*! NFC-F Block List Element (2 or 3 bytes element) T3T 1.0 5.6.1 */
typedef struct
{
uint8_t conf; /*!< Access Mode | Serv Code List Order */
uint16_t blockNum; /*!< Block Number */
}rfalNfcfBlockListElem;
typedef struct {
uint8_t conf; /*!< Access Mode | Serv Code List Order */
uint16_t blockNum; /*!< Block Number */
} rfalNfcfBlockListElem;
/*! Check Update Service list and Block list parameter */
typedef struct
{
uint8_t numServ; /*!< Number of Services */
rfalNfcfServ *servList; /*!< Service Code List */
uint8_t numBlock; /*!< Number of Blocks */
rfalNfcfBlockListElem *blockList; /*!< Block Number List */
}rfalNfcfServBlockListParam;
typedef struct {
uint8_t numServ; /*!< Number of Services */
rfalNfcfServ* servList; /*!< Service Code List */
uint8_t numBlock; /*!< Number of Blocks */
rfalNfcfBlockListElem* blockList; /*!< Block Number List */
} rfalNfcfServBlockListParam;
/*
******************************************************************************
@@ -214,8 +231,7 @@ typedef struct
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcfPollerInitialize( rfalBitRate bitRate );
ReturnCode rfalNfcfPollerInitialize(rfalBitRate bitRate);
/*!
*****************************************************************************
@@ -235,8 +251,7 @@ ReturnCode rfalNfcfPollerInitialize( rfalBitRate bitRate );
*
*****************************************************************************
*/
ReturnCode rfalNfcfPollerCheckPresence( void );
ReturnCode rfalNfcfPollerCheckPresence(void);
/*!
*****************************************************************************
@@ -265,8 +280,13 @@ ReturnCode rfalNfcfPollerCheckPresence( void );
*
*****************************************************************************
*/
ReturnCode rfalNfcfPollerPoll( rfalFeliCaPollSlots slots, uint16_t sysCode, uint8_t reqCode, rfalFeliCaPollRes *cardList, uint8_t *devCnt, uint8_t *collisions );
ReturnCode rfalNfcfPollerPoll(
rfalFeliCaPollSlots slots,
uint16_t sysCode,
uint8_t reqCode,
rfalFeliCaPollRes* cardList,
uint8_t* devCnt,
uint8_t* collisions);
/*!
*****************************************************************************
@@ -285,8 +305,11 @@ ReturnCode rfalNfcfPollerPoll( rfalFeliCaPollSlots slots, uint16_t sysCode, uint
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcfPollerCollisionResolution( rfalComplianceMode compMode, uint8_t devLimit, rfalNfcfListenDevice *nfcfDevList, uint8_t *devCnt );
ReturnCode rfalNfcfPollerCollisionResolution(
rfalComplianceMode compMode,
uint8_t devLimit,
rfalNfcfListenDevice* nfcfDevList,
uint8_t* devCnt);
/*!
*****************************************************************************
@@ -310,8 +333,12 @@ ReturnCode rfalNfcfPollerCollisionResolution( rfalComplianceMode compMode, uint8
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcfPollerCheck( const uint8_t* nfcid2, const rfalNfcfServBlockListParam *servBlock, uint8_t *rxBuf, uint16_t rxBufLen, uint16_t *rcvdLen );
ReturnCode rfalNfcfPollerCheck(
const uint8_t* nfcid2,
const rfalNfcfServBlockListParam* servBlock,
uint8_t* rxBuf,
uint16_t rxBufLen,
uint16_t* rcvdLen);
/*!
*****************************************************************************
@@ -336,7 +363,14 @@ ReturnCode rfalNfcfPollerCheck( const uint8_t* nfcid2, const rfalNfcfServBlockLi
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcfPollerUpdate( const uint8_t* nfcid2, const rfalNfcfServBlockListParam *servBlock, uint8_t *txBuf, uint16_t txBufLen, const uint8_t *blockData, uint8_t *rxBuf, uint16_t rxBufLen);
ReturnCode rfalNfcfPollerUpdate(
const uint8_t* nfcid2,
const rfalNfcfServBlockListParam* servBlock,
uint8_t* txBuf,
uint16_t txBufLen,
const uint8_t* blockData,
uint8_t* rxBuf,
uint16_t rxBufLen);
/*!
*****************************************************************************
@@ -356,8 +390,7 @@ ReturnCode rfalNfcfPollerUpdate( const uint8_t* nfcid2, const rfalNfcfServBlockL
*
*****************************************************************************
*/
bool rfalNfcfListenerIsT3TReq( const uint8_t* buf, uint16_t bufLen, uint8_t* nfcid2 );
bool rfalNfcfListenerIsT3TReq(const uint8_t* buf, uint16_t bufLen, uint8_t* nfcid2);
#endif /* RFAL_NFCF_H */
+314 -163
View File
@@ -67,124 +67,201 @@
******************************************************************************
*/
#define RFAL_NFCV_UID_LEN 8U /*!< NFC-V UID length */
#define RFAL_NFCV_MAX_BLOCK_LEN 32U /*!< Max Block size: can be of up to 256 bits ISO 15693 2000 5 */
#define RFAL_NFCV_BNO_LEN 1U /*!< NFC-V Block Number length */
#define RFAL_NFCV_CRC_LEN 2U /*!< NFC-V CRC length */
#define RFAL_NFCV_MAX_GEN_DATA_LEN (RFAL_NFCV_MAX_BLOCK_LEN + RFAL_NFCV_BNO_LEN + RFAL_NFCV_UID_LEN) /*!<Max data */
#define RFAL_NFCV_BLOCKNUM_LEN 1U /*!< Block Number length on normal commands: 8 bits */
#define RFAL_NFCV_BLOCKNUM_EXTENDED_LEN 2U /*!< Block Number length on extended commands: 16 bits */
#define RFAL_NFCV_PARAM_SKIP 0U /*!< Skip proprietary Param Request */
/*! NFC-V RequestFlags ISO15693 2000 7.3.1 */
enum{
RFAL_NFCV_REQ_FLAG_DEFAULT = 0x02U, /*!< Default Request Flags */
RFAL_NFCV_REQ_FLAG_SUB_CARRIER = 0x01U, /*!< Sub Carrier flag */
RFAL_NFCV_REQ_FLAG_DATA_RATE = 0x02U, /*!< Data Rate flag */
RFAL_NFCV_REQ_FLAG_INVENTORY = 0x04U, /*!< Inventory flag */
RFAL_NFCV_REQ_FLAG_PROTOCOL_EXT = 0x08U, /*!< Protocol Extension flag */
RFAL_NFCV_REQ_FLAG_SELECT = 0x10U, /*!< Select flag */
RFAL_NFCV_REQ_FLAG_ADDRESS = 0x20U, /*!< Address flag */
RFAL_NFCV_REQ_FLAG_OPTION = 0x40U, /*!< Option flag */
RFAL_NFCV_REQ_FLAG_RFU = 0x80U, /*!< RFU flag */
RFAL_NFCV_REQ_FLAG_AFI = 0x10U, /*!< AFI flag */
RFAL_NFCV_REQ_FLAG_NB_SLOTS = 0x20U, /*!< Number of Slots flag */
};
/*! NFC-V Response Flags ISO15693 2000 7.4.1 */
enum{
RFAL_NFCV_RES_FLAG_ERROR = 0x01U, /*!< Error flag */
RFAL_NFCV_RES_FLAG_RFU1 = 0x02U, /*!< RFU flag */
RFAL_NFCV_RES_FLAG_RFU2 = 0x04U, /*!< RFU flag */
RFAL_NFCV_RES_FLAG_EXTENSION = 0x08U, /*!< Extension flag */
RFAL_NFCV_RES_FLAG_RFU3 = 0x10U, /*!< RFU flag */
RFAL_NFCV_RES_FLAG_RFU4 = 0x20U, /*!< RFU flag */
RFAL_NFCV_RES_FLAG_RFU5 = 0x40U, /*!< RFU flag */
RFAL_NFCV_RES_FLAG_RFU6 = 0x80U /*!< RFU flag */
};
/*! NFC-V Error code ISO15693 2000 7.4.2 */
enum{
RFAL_NFCV_ERROR_CMD_NOT_SUPPORTED = 0x01U, /*!< The command is not supported, code is not recognised */
RFAL_NFCV_ERROR_CMD_NOT_RECOGNIZED = 0x02U, /*!< The command is not recognised, format error occurred */
RFAL_NFCV_ERROR_OPTION_NOT_SUPPORTED = 0x03U, /*!< The option is not supported */
RFAL_NFCV_ERROR_UNKNOWN = 0x0FU, /*!< Unknown error */
RFAL_NFCV_ERROR_BLOCK_NOT_AVALIABLE = 0x10U, /*!< The specified block is not available */
RFAL_NFCV_ERROR_BLOCK_ALREDY_LOCKED = 0x11U, /*!< The specified block is already locked */
RFAL_NFCV_ERROR_BLOCK_LOCKED = 0x12U, /*!< The specified block is locked */
RFAL_NFCV_ERROR_WRITE_FAILED = 0x13U, /*!< The specified block was not successfully programmed */
RFAL_NFCV_ERROR_BLOCK_FAILED = 0x14U /*!< The specified block was not successfully locked */
#define RFAL_NFCV_UID_LEN 8U /*!< NFC-V UID length */
#define RFAL_NFCV_MAX_BLOCK_LEN \
32U /*!< Max Block size: can be of up to 256 bits ISO 15693 2000 5 */
#define RFAL_NFCV_BNO_LEN 1U /*!< NFC-V Block Number length */
#define RFAL_NFCV_CRC_LEN 2U /*!< NFC-V CRC length */
#define RFAL_NFCV_MAX_GEN_DATA_LEN \
(RFAL_NFCV_MAX_BLOCK_LEN + RFAL_NFCV_BNO_LEN + RFAL_NFCV_UID_LEN) /*!<Max data */
#define RFAL_NFCV_BLOCKNUM_LEN \
1U /*!< Block Number length on normal commands: 8 bits */
#define RFAL_NFCV_BLOCKNUM_EXTENDED_LEN \
2U /*!< Block Number length on extended commands: 16 bits */
#define RFAL_NFCV_PARAM_SKIP \
0U /*!< Skip proprietary Param Request */
/*! NFC-V RequestFlags ISO15693 2000 7.3.1 */
enum {
RFAL_NFCV_REQ_FLAG_DEFAULT =
0x02U, /*!< Default Request Flags */
RFAL_NFCV_REQ_FLAG_SUB_CARRIER =
0x01U, /*!< Sub Carrier flag */
RFAL_NFCV_REQ_FLAG_DATA_RATE =
0x02U, /*!< Data Rate flag */
RFAL_NFCV_REQ_FLAG_INVENTORY =
0x04U, /*!< Inventory flag */
RFAL_NFCV_REQ_FLAG_PROTOCOL_EXT =
0x08U, /*!< Protocol Extension flag */
RFAL_NFCV_REQ_FLAG_SELECT =
0x10U, /*!< Select flag */
RFAL_NFCV_REQ_FLAG_ADDRESS =
0x20U, /*!< Address flag */
RFAL_NFCV_REQ_FLAG_OPTION =
0x40U, /*!< Option flag */
RFAL_NFCV_REQ_FLAG_RFU =
0x80U, /*!< RFU flag */
RFAL_NFCV_REQ_FLAG_AFI =
0x10U, /*!< AFI flag */
RFAL_NFCV_REQ_FLAG_NB_SLOTS =
0x20U, /*!< Number of Slots flag */
};
/*! NFC-V Response Flags ISO15693 2000 7.4.1 */
enum {
RFAL_NFCV_RES_FLAG_ERROR =
0x01U, /*!< Error flag */
RFAL_NFCV_RES_FLAG_RFU1 =
0x02U, /*!< RFU flag */
RFAL_NFCV_RES_FLAG_RFU2 =
0x04U, /*!< RFU flag */
RFAL_NFCV_RES_FLAG_EXTENSION =
0x08U, /*!< Extension flag */
RFAL_NFCV_RES_FLAG_RFU3 =
0x10U, /*!< RFU flag */
RFAL_NFCV_RES_FLAG_RFU4 =
0x20U, /*!< RFU flag */
RFAL_NFCV_RES_FLAG_RFU5 =
0x40U, /*!< RFU flag */
RFAL_NFCV_RES_FLAG_RFU6 =
0x80U /*!< RFU flag */
};
/*! NFC-V Error code ISO15693 2000 7.4.2 */
enum {
RFAL_NFCV_ERROR_CMD_NOT_SUPPORTED =
0x01U, /*!< The command is not supported, code is not recognised */
RFAL_NFCV_ERROR_CMD_NOT_RECOGNIZED =
0x02U, /*!< The command is not recognised, format error occurred */
RFAL_NFCV_ERROR_OPTION_NOT_SUPPORTED =
0x03U, /*!< The option is not supported */
RFAL_NFCV_ERROR_UNKNOWN =
0x0FU, /*!< Unknown error */
RFAL_NFCV_ERROR_BLOCK_NOT_AVALIABLE =
0x10U, /*!< The specified block is not available */
RFAL_NFCV_ERROR_BLOCK_ALREDY_LOCKED =
0x11U, /*!< The specified block is already locked */
RFAL_NFCV_ERROR_BLOCK_LOCKED =
0x12U, /*!< The specified block is locked */
RFAL_NFCV_ERROR_WRITE_FAILED =
0x13U, /*!< The specified block was not successfully programmed */
RFAL_NFCV_ERROR_BLOCK_FAILED =
0x14U /*!< The specified block was not successfully locked */
};
/*! NFC-V command set ISO15693 2000 9.1 */
enum
{
RFAL_NFCV_CMD_INVENTORY = 0x01U, /*!< INVENTORY_REQ (Inventory) command */
RFAL_NFCV_CMD_SLPV = 0x02U, /*!< SLPV_REQ (Stay quiet) command */
RFAL_NFCV_CMD_READ_SINGLE_BLOCK = 0x20U, /*!< Read single block command */
RFAL_NFCV_CMD_WRITE_SINGLE_BLOCK = 0x21U, /*!< Write single block command */
RFAL_NFCV_CMD_LOCK_BLOCK = 0x22U, /*!< Lock block command */
RFAL_NFCV_CMD_READ_MULTIPLE_BLOCKS = 0x23U, /*!< Read multiple blocks command */
RFAL_NFCV_CMD_WRITE_MULTIPLE_BLOCKS = 0x24U, /*!< Write multiple blocks command */
RFAL_NFCV_CMD_SELECT = 0x25U, /*!< Select command */
RFAL_NFCV_CMD_RESET_TO_READY = 0x26U, /*!< Reset To Ready command */
RFAL_NFCV_CMD_GET_SYS_INFO = 0x2BU, /*!< Get System Information command */
RFAL_NFCV_CMD_EXTENDED_READ_SINGLE_BLOCK = 0x30U, /*!< Extended read single block command */
RFAL_NFCV_CMD_EXTENDED_WRITE_SINGLE_BLOCK = 0x31U, /*!< Extended write single block command */
RFAL_NFCV_CMD_EXTENDED_LOCK_SINGLE_BLOCK = 0x32U, /*!< Extended lock single block command */
RFAL_NFCV_CMD_EXTENDED_READ_MULTIPLE_BLOCK = 0x33U, /*!< Extended read multiple block command */
RFAL_NFCV_CMD_EXTENDED_WRITE_MULTIPLE_BLOCK = 0x34U, /*!< Extended read multiple block command */
RFAL_NFCV_CMD_EXTENDED_GET_SYS_INFO = 0x3BU /*!< Extended Get System Information command */
enum {
RFAL_NFCV_CMD_INVENTORY =
0x01U, /*!< INVENTORY_REQ (Inventory) command */
RFAL_NFCV_CMD_SLPV =
0x02U, /*!< SLPV_REQ (Stay quiet) command */
RFAL_NFCV_CMD_READ_SINGLE_BLOCK =
0x20U, /*!< Read single block command */
RFAL_NFCV_CMD_WRITE_SINGLE_BLOCK =
0x21U, /*!< Write single block command */
RFAL_NFCV_CMD_LOCK_BLOCK =
0x22U, /*!< Lock block command */
RFAL_NFCV_CMD_READ_MULTIPLE_BLOCKS =
0x23U, /*!< Read multiple blocks command */
RFAL_NFCV_CMD_WRITE_MULTIPLE_BLOCKS =
0x24U, /*!< Write multiple blocks command */
RFAL_NFCV_CMD_SELECT =
0x25U, /*!< Select command */
RFAL_NFCV_CMD_RESET_TO_READY =
0x26U, /*!< Reset To Ready command */
RFAL_NFCV_CMD_GET_SYS_INFO =
0x2BU, /*!< Get System Information command */
RFAL_NFCV_CMD_EXTENDED_READ_SINGLE_BLOCK =
0x30U, /*!< Extended read single block command */
RFAL_NFCV_CMD_EXTENDED_WRITE_SINGLE_BLOCK =
0x31U, /*!< Extended write single block command */
RFAL_NFCV_CMD_EXTENDED_LOCK_SINGLE_BLOCK =
0x32U, /*!< Extended lock single block command */
RFAL_NFCV_CMD_EXTENDED_READ_MULTIPLE_BLOCK =
0x33U, /*!< Extended read multiple block command */
RFAL_NFCV_CMD_EXTENDED_WRITE_MULTIPLE_BLOCK =
0x34U, /*!< Extended read multiple block command */
RFAL_NFCV_CMD_EXTENDED_GET_SYS_INFO =
0x3BU /*!< Extended Get System Information command */
};
/*! ST25TV/ST25DV command set */
enum
{
RFAL_NFCV_CMD_READ_CONFIGURATION = 0xA0U, /*!< Read configuration command */
RFAL_NFCV_CMD_WRITE_CONFIGURATION = 0xA1U, /*!< Write configuration command */
RFAL_NFCV_CMD_SET_EAS = 0xA2U, /*!< Set EAS command */
RFAL_NFCV_CMD_RESET_EAS = 0xA3U, /*!< Reset EAS command */
RFAL_NFCV_CMD_LOCK_EAS = 0xA4U, /*!< Lock EAS command */
RFAL_NFCV_CMD_ENABLE_EAS = 0xA5U, /*!< Enable EAS command */
RFAL_NFCV_CMD_KILL = 0xA6U, /*!< Kill command */
RFAL_NFCV_CMD_WRITE_EAS_ID = 0xA7U, /*!< Write EAS ID command */
RFAL_NFCV_CMD_WRITE_EAS_CONFIG = 0xA8U, /*!< Write EAS CONFIG command */
RFAL_NFCV_CMD_MANAGE_GPO = 0xA9U, /*!< Manage GPO command */
RFAL_NFCV_CMD_WRITE_MESSAGE = 0xAAU, /*!< Write Message command */
RFAL_NFCV_CMD_READ_MESSAGE_LENGTH = 0xABU, /*!< Read Message Length command */
RFAL_NFCV_CMD_READ_MESSAGE = 0xACU, /*!< Read Message command */
RFAL_NFCV_CMD_READ_DYN_CONFIGURATION = 0xADU, /*!< Read Dynamic Configuration command */
RFAL_NFCV_CMD_WRITE_DYN_CONFIGURATION = 0xAEU, /*!< Write Dynamic Configuration command */
RFAL_NFCV_CMD_WRITE_PASSWORD = 0xB1U, /*!< Write Kill Password / Write Password command */
RFAL_NFCV_CMD_LOCK_KILL = 0xB2U, /*!< Lock Kill command */
RFAL_NFCV_CMD_PRESENT_PASSWORD = 0xB3U, /*!< Present Password command */
RFAL_NFCV_CMD_GET_RANDOM_NUMBER = 0xB4U, /*!< Get Random Number command */
RFAL_NFCV_CMD_FAST_READ_SINGLE_BLOCK = 0xC0U, /*!< Fast Read single block command */
RFAL_NFCV_CMD_FAST_READ_MULTIPLE_BLOCKS = 0xC3U, /*!< Fast Read multiple blocks command */
RFAL_NFCV_CMD_FAST_EXTENDED_READ_SINGLE_BLOCK = 0xC4U, /*!< Fast Extended Read single block command */
RFAL_NFCV_CMD_FAST_EXTENDED_READ_MULTIPLE_BLOCKS = 0xC5U, /*!< Fast Extended Read multiple blocks command */
RFAL_NFCV_CMD_FAST_WRITE_MESSAGE = 0xCAU, /*!< Fast Write Message */
RFAL_NFCV_CMD_FAST_READ_MESSAGE_LENGTH = 0xCBU, /*!< Fast Read Message Length */
RFAL_NFCV_CMD_FAST_READ_MESSAGE = 0xCCU, /*!< Fast Read Message */
RFAL_NFCV_CMD_FAST_READ_DYN_CONFIGURATION = 0xCDU, /*!< Fast Read Dynamic configuration */
RFAL_NFCV_CMD_FAST_WRITE_DYN_CONFIGURATION = 0xCEU /*!< Fast Write Dynamic Configuration */
enum {
RFAL_NFCV_CMD_READ_CONFIGURATION =
0xA0U, /*!< Read configuration command */
RFAL_NFCV_CMD_WRITE_CONFIGURATION =
0xA1U, /*!< Write configuration command */
RFAL_NFCV_CMD_SET_EAS =
0xA2U, /*!< Set EAS command */
RFAL_NFCV_CMD_RESET_EAS =
0xA3U, /*!< Reset EAS command */
RFAL_NFCV_CMD_LOCK_EAS =
0xA4U, /*!< Lock EAS command */
RFAL_NFCV_CMD_ENABLE_EAS =
0xA5U, /*!< Enable EAS command */
RFAL_NFCV_CMD_KILL = 0xA6U, /*!< Kill command */
RFAL_NFCV_CMD_WRITE_EAS_ID =
0xA7U, /*!< Write EAS ID command */
RFAL_NFCV_CMD_WRITE_EAS_CONFIG =
0xA8U, /*!< Write EAS CONFIG command */
RFAL_NFCV_CMD_MANAGE_GPO =
0xA9U, /*!< Manage GPO command */
RFAL_NFCV_CMD_WRITE_MESSAGE =
0xAAU, /*!< Write Message command */
RFAL_NFCV_CMD_READ_MESSAGE_LENGTH =
0xABU, /*!< Read Message Length command */
RFAL_NFCV_CMD_READ_MESSAGE =
0xACU, /*!< Read Message command */
RFAL_NFCV_CMD_READ_DYN_CONFIGURATION =
0xADU, /*!< Read Dynamic Configuration command */
RFAL_NFCV_CMD_WRITE_DYN_CONFIGURATION =
0xAEU, /*!< Write Dynamic Configuration command */
RFAL_NFCV_CMD_WRITE_PASSWORD =
0xB1U, /*!< Write Kill Password / Write Password command */
RFAL_NFCV_CMD_LOCK_KILL =
0xB2U, /*!< Lock Kill command */
RFAL_NFCV_CMD_PRESENT_PASSWORD =
0xB3U, /*!< Present Password command */
RFAL_NFCV_CMD_GET_RANDOM_NUMBER =
0xB4U, /*!< Get Random Number command */
RFAL_NFCV_CMD_FAST_READ_SINGLE_BLOCK =
0xC0U, /*!< Fast Read single block command */
RFAL_NFCV_CMD_FAST_READ_MULTIPLE_BLOCKS =
0xC3U, /*!< Fast Read multiple blocks command */
RFAL_NFCV_CMD_FAST_EXTENDED_READ_SINGLE_BLOCK =
0xC4U, /*!< Fast Extended Read single block command */
RFAL_NFCV_CMD_FAST_EXTENDED_READ_MULTIPLE_BLOCKS =
0xC5U, /*!< Fast Extended Read multiple blocks command */
RFAL_NFCV_CMD_FAST_WRITE_MESSAGE =
0xCAU, /*!< Fast Write Message */
RFAL_NFCV_CMD_FAST_READ_MESSAGE_LENGTH =
0xCBU, /*!< Fast Read Message Length */
RFAL_NFCV_CMD_FAST_READ_MESSAGE =
0xCCU, /*!< Fast Read Message */
RFAL_NFCV_CMD_FAST_READ_DYN_CONFIGURATION =
0xCDU, /*!< Fast Read Dynamic configuration */
RFAL_NFCV_CMD_FAST_WRITE_DYN_CONFIGURATION =
0xCEU /*!< Fast Write Dynamic Configuration */
};
/*! ISO 15693 Get System info parameter request field ISO15693 2018 Table 94 */
enum
{
RFAL_NFCV_SYSINFO_DFSID = 0x01U, /*!< Get System info DFSID flag */
RFAL_NFCV_SYSINFO_AFI = 0x02U, /*!< Get System info AFI flag */
RFAL_NFCV_SYSINFO_MEMSIZE = 0x04U, /*!< Get System info MEMSIZE flag */
RFAL_NFCV_SYSINFO_ICREF = 0x08U, /*!< Get System info ICREF flag */
RFAL_NFCV_SYSINFO_MOI = 0x10U, /*!< Get System info MOI flag */
RFAL_NFCV_SYSINFO_CMDLIST = 0x20U, /*!< Get System info CMDLIST flag */
RFAL_NFCV_SYSINFO_CSI = 0x40U, /*!< Get System info CSI flag */
RFAL_NFCV_SYSINFO_REQ_ALL = 0x7FU /*!< Get System info request of all parameters */
enum {
RFAL_NFCV_SYSINFO_DFSID =
0x01U, /*!< Get System info DFSID flag */
RFAL_NFCV_SYSINFO_AFI =
0x02U, /*!< Get System info AFI flag */
RFAL_NFCV_SYSINFO_MEMSIZE =
0x04U, /*!< Get System info MEMSIZE flag */
RFAL_NFCV_SYSINFO_ICREF =
0x08U, /*!< Get System info ICREF flag */
RFAL_NFCV_SYSINFO_MOI =
0x10U, /*!< Get System info MOI flag */
RFAL_NFCV_SYSINFO_CMDLIST =
0x20U, /*!< Get System info CMDLIST flag */
RFAL_NFCV_SYSINFO_CSI =
0x40U, /*!< Get System info CSI flag */
RFAL_NFCV_SYSINFO_REQ_ALL =
0x7FU /*!< Get System info request of all parameters */
};
/*
@@ -193,7 +270,6 @@ enum
******************************************************************************
*/
/*
******************************************************************************
* GLOBAL TYPES
@@ -201,51 +277,41 @@ enum
*/
/*! NFC-V Number of slots Digital 2.0 9.6.1 */
typedef enum
{
RFAL_NFCV_NUM_SLOTS_1 = 0x20, /*!< Number of slots: 1 */
RFAL_NFCV_NUM_SLOTS_16 = 0x00, /*!< Number of slots: 16 */
typedef enum {
RFAL_NFCV_NUM_SLOTS_1 = 0x20, /*!< Number of slots: 1 */
RFAL_NFCV_NUM_SLOTS_16 = 0x00, /*!< Number of slots: 16 */
} rfalNfcvNumSlots;
/*! NFC-V INVENTORY_RES format Digital 2.0 9.6.2 */
typedef struct
{
uint8_t RES_FLAG; /*!< Response Flags */
uint8_t DSFID; /*!< Data Storage Format Identifier */
uint8_t UID[RFAL_NFCV_UID_LEN]; /*!< NFC-V device UID */
uint8_t crc[RFAL_CRC_LEN]; /*!< CRC */
typedef struct {
uint8_t RES_FLAG; /*!< Response Flags */
uint8_t DSFID; /*!< Data Storage Format Identifier */
uint8_t UID[RFAL_NFCV_UID_LEN]; /*!< NFC-V device UID */
uint8_t crc[RFAL_CRC_LEN]; /*!< CRC */
} rfalNfcvInventoryRes;
/*! NFC-V Generic Req format */
typedef struct
{
uint8_t REQ_FLAG; /*!< Request Flags */
uint8_t CMD; /*!< Command code */
typedef struct {
uint8_t REQ_FLAG; /*!< Request Flags */
uint8_t CMD; /*!< Command code */
union { /* PRQA S 0750 # MISRA 19.2 - Both members are of the same type, just different names. Thus no problem can occur. */
uint8_t UID[RFAL_NFCV_UID_LEN]; /*!< Mask Value */
uint8_t data[RFAL_NFCV_MAX_GEN_DATA_LEN]; /*!< Data */
}payload; /*!< Payload */
uint8_t UID[RFAL_NFCV_UID_LEN]; /*!< Mask Value */
uint8_t data[RFAL_NFCV_MAX_GEN_DATA_LEN]; /*!< Data */
} payload; /*!< Payload */
} rfalNfcvGenericReq;
/*! NFC-V Generic Response format */
typedef struct
{
uint8_t RES_FLAG; /*!< Response Flags */
uint8_t data[RFAL_NFCV_MAX_GEN_DATA_LEN]; /*!< Data */
typedef struct {
uint8_t RES_FLAG; /*!< Response Flags */
uint8_t data[RFAL_NFCV_MAX_GEN_DATA_LEN]; /*!< Data */
} rfalNfcvGenericRes;
/*! NFC-V listener device (VICC) struct */
typedef struct
{
rfalNfcvInventoryRes InvRes; /*!< INVENTORY_RES */
bool isSleep; /*!< Device sleeping flag */
typedef struct {
rfalNfcvInventoryRes InvRes; /*!< INVENTORY_RES */
bool isSleep; /*!< Device sleeping flag */
} rfalNfcvListenDevice;
/*
******************************************************************************
* GLOBAL FUNCTION PROTOTYPES
@@ -264,7 +330,7 @@ typedef struct
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcvPollerInitialize( void );
ReturnCode rfalNfcvPollerInitialize(void);
/*!
*****************************************************************************
@@ -282,7 +348,7 @@ ReturnCode rfalNfcvPollerInitialize( void );
* \return ERR_NONE : No error, one or more device in the field
*****************************************************************************
*/
ReturnCode rfalNfcvPollerCheckPresence( rfalNfcvInventoryRes *invRes );
ReturnCode rfalNfcvPollerCheckPresence(rfalNfcvInventoryRes* invRes);
/*!
*****************************************************************************
@@ -308,8 +374,13 @@ ReturnCode rfalNfcvPollerCheckPresence( rfalNfcvInventoryRes *invRes );
* \return ERR_PROTO : Protocol error detected
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcvPollerInventory( rfalNfcvNumSlots nSlots, uint8_t maskLen, const uint8_t *maskVal, rfalNfcvInventoryRes *invRes, uint16_t* rcvdLen );
*/
ReturnCode rfalNfcvPollerInventory(
rfalNfcvNumSlots nSlots,
uint8_t maskLen,
const uint8_t* maskVal,
rfalNfcvInventoryRes* invRes,
uint16_t* rcvdLen);
/*!
*****************************************************************************
@@ -333,7 +404,11 @@ ReturnCode rfalNfcvPollerInventory( rfalNfcvNumSlots nSlots, uint8_t maskLen, co
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcvPollerCollisionResolution( rfalComplianceMode compMode, uint8_t devLimit, rfalNfcvListenDevice *nfcvDevList, uint8_t *devCnt );
ReturnCode rfalNfcvPollerCollisionResolution(
rfalComplianceMode compMode,
uint8_t devLimit,
rfalNfcvListenDevice* nfcvDevList,
uint8_t* devCnt);
/*!
*****************************************************************************
@@ -354,7 +429,10 @@ ReturnCode rfalNfcvPollerCollisionResolution( rfalComplianceMode compMode, uint8
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcvPollerSleepCollisionResolution( uint8_t devLimit, rfalNfcvListenDevice *nfcvDevList, uint8_t *devCnt );
ReturnCode rfalNfcvPollerSleepCollisionResolution(
uint8_t devLimit,
rfalNfcvListenDevice* nfcvDevList,
uint8_t* devCnt);
/*!
*****************************************************************************
@@ -373,7 +451,7 @@ ReturnCode rfalNfcvPollerSleepCollisionResolution( uint8_t devLimit, rfalNfcvLis
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcvPollerSleep( uint8_t flags, const uint8_t* uid );
ReturnCode rfalNfcvPollerSleep(uint8_t flags, const uint8_t* uid);
/*!
*****************************************************************************
@@ -395,7 +473,7 @@ ReturnCode rfalNfcvPollerSleep( uint8_t flags, const uint8_t* uid );
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcvPollerSelect( uint8_t flags, const uint8_t* uid );
ReturnCode rfalNfcvPollerSelect(uint8_t flags, const uint8_t* uid);
/*!
*****************************************************************************
@@ -422,7 +500,13 @@ ReturnCode rfalNfcvPollerSelect( uint8_t flags, const uint8_t* uid );
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcvPollerReadSingleBlock( uint8_t flags, const uint8_t* uid, uint8_t blockNum, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen );
ReturnCode rfalNfcvPollerReadSingleBlock(
uint8_t flags,
const uint8_t* uid,
uint8_t blockNum,
uint8_t* rxBuf,
uint16_t rxBufLen,
uint16_t* rcvLen);
/*!
*****************************************************************************
@@ -448,7 +532,12 @@ ReturnCode rfalNfcvPollerReadSingleBlock( uint8_t flags, const uint8_t* uid, uin
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcvPollerWriteSingleBlock( uint8_t flags, const uint8_t* uid, uint8_t blockNum, const uint8_t* wrData, uint8_t blockLen );
ReturnCode rfalNfcvPollerWriteSingleBlock(
uint8_t flags,
const uint8_t* uid,
uint8_t blockNum,
const uint8_t* wrData,
uint8_t blockLen);
/*!
*****************************************************************************
@@ -476,7 +565,14 @@ ReturnCode rfalNfcvPollerWriteSingleBlock( uint8_t flags, const uint8_t* uid, ui
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcvPollerReadMultipleBlocks( uint8_t flags, const uint8_t* uid, uint8_t firstBlockNum, uint8_t numOfBlocks, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen );
ReturnCode rfalNfcvPollerReadMultipleBlocks(
uint8_t flags,
const uint8_t* uid,
uint8_t firstBlockNum,
uint8_t numOfBlocks,
uint8_t* rxBuf,
uint16_t rxBufLen,
uint16_t* rcvLen);
/*!
*****************************************************************************
@@ -510,7 +606,16 @@ ReturnCode rfalNfcvPollerReadMultipleBlocks( uint8_t flags, const uint8_t* uid,
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcvPollerWriteMultipleBlocks( uint8_t flags, const uint8_t* uid, uint8_t firstBlockNum, uint8_t numOfBlocks, uint8_t *txBuf, uint16_t txBufLen, uint8_t blockLen, const uint8_t* wrData, uint16_t wrDataLen );
ReturnCode rfalNfcvPollerWriteMultipleBlocks(
uint8_t flags,
const uint8_t* uid,
uint8_t firstBlockNum,
uint8_t numOfBlocks,
uint8_t* txBuf,
uint16_t txBufLen,
uint8_t blockLen,
const uint8_t* wrData,
uint16_t wrDataLen);
/*!
*****************************************************************************
@@ -534,8 +639,8 @@ ReturnCode rfalNfcvPollerWriteMultipleBlocks( uint8_t flags, const uint8_t* uid,
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcvPollerLockBlock( uint8_t flags, const uint8_t* uid, uint8_t blockNum );
ReturnCode rfalNfcvPollerLockBlock(uint8_t flags, const uint8_t* uid, uint8_t blockNum);
/*!
*****************************************************************************
* \brief NFC-V Poller Extended Lock Single Block
@@ -558,7 +663,8 @@ ReturnCode rfalNfcvPollerLockBlock( uint8_t flags, const uint8_t* uid, uint8_t b
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcvPollerExtendedLockSingleBlock( uint8_t flags, const uint8_t* uid, uint16_t blockNum );
ReturnCode
rfalNfcvPollerExtendedLockSingleBlock(uint8_t flags, const uint8_t* uid, uint16_t blockNum);
/*!
*****************************************************************************
@@ -585,7 +691,13 @@ ReturnCode rfalNfcvPollerExtendedLockSingleBlock( uint8_t flags, const uint8_t*
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcvPollerExtendedReadSingleBlock( uint8_t flags, const uint8_t* uid, uint16_t blockNum, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen );
ReturnCode rfalNfcvPollerExtendedReadSingleBlock(
uint8_t flags,
const uint8_t* uid,
uint16_t blockNum,
uint8_t* rxBuf,
uint16_t rxBufLen,
uint16_t* rcvLen);
/*!
*****************************************************************************
@@ -611,7 +723,12 @@ ReturnCode rfalNfcvPollerExtendedReadSingleBlock( uint8_t flags, const uint8_t*
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcvPollerExtendedWriteSingleBlock( uint8_t flags, const uint8_t* uid, uint16_t blockNum, const uint8_t* wrData, uint8_t blockLen );
ReturnCode rfalNfcvPollerExtendedWriteSingleBlock(
uint8_t flags,
const uint8_t* uid,
uint16_t blockNum,
const uint8_t* wrData,
uint8_t blockLen);
/*!
*****************************************************************************
@@ -639,7 +756,14 @@ ReturnCode rfalNfcvPollerExtendedWriteSingleBlock( uint8_t flags, const uint8_t*
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcvPollerExtendedReadMultipleBlocks( uint8_t flags, const uint8_t* uid, uint16_t firstBlockNum, uint16_t numOfBlocks, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen );
ReturnCode rfalNfcvPollerExtendedReadMultipleBlocks(
uint8_t flags,
const uint8_t* uid,
uint16_t firstBlockNum,
uint16_t numOfBlocks,
uint8_t* rxBuf,
uint16_t rxBufLen,
uint16_t* rcvLen);
/*!
*****************************************************************************
@@ -673,7 +797,16 @@ ReturnCode rfalNfcvPollerExtendedReadMultipleBlocks( uint8_t flags, const uint8_
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcvPollerExtendedWriteMultipleBlocks( uint8_t flags, const uint8_t* uid, uint16_t firstBlockNum, uint16_t numOfBlocks, uint8_t *txBuf, uint16_t txBufLen, uint8_t blockLen, const uint8_t* wrData, uint16_t wrDataLen );
ReturnCode rfalNfcvPollerExtendedWriteMultipleBlocks(
uint8_t flags,
const uint8_t* uid,
uint16_t firstBlockNum,
uint16_t numOfBlocks,
uint8_t* txBuf,
uint16_t txBufLen,
uint8_t blockLen,
const uint8_t* wrData,
uint16_t wrDataLen);
/*!
*****************************************************************************
@@ -699,7 +832,12 @@ ReturnCode rfalNfcvPollerExtendedWriteMultipleBlocks( uint8_t flags, const uint8
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcvPollerGetSystemInformation( uint8_t flags, const uint8_t* uid, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen );
ReturnCode rfalNfcvPollerGetSystemInformation(
uint8_t flags,
const uint8_t* uid,
uint8_t* rxBuf,
uint16_t rxBufLen,
uint16_t* rcvLen);
/*!
*****************************************************************************
@@ -726,8 +864,13 @@ ReturnCode rfalNfcvPollerGetSystemInformation( uint8_t flags, const uint8_t* uid
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcvPollerExtendedGetSystemInformation( uint8_t flags, const uint8_t* uid, uint8_t requestField, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen );
ReturnCode rfalNfcvPollerExtendedGetSystemInformation(
uint8_t flags,
const uint8_t* uid,
uint8_t requestField,
uint8_t* rxBuf,
uint16_t rxBufLen,
uint16_t* rcvLen);
/*!
*****************************************************************************
@@ -758,7 +901,16 @@ ReturnCode rfalNfcvPollerExtendedGetSystemInformation( uint8_t flags, const uint
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcvPollerTransceiveReq( uint8_t cmd, uint8_t flags, uint8_t param, const uint8_t* uid, const uint8_t *data, uint16_t dataLen, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen );
ReturnCode rfalNfcvPollerTransceiveReq(
uint8_t cmd,
uint8_t flags,
uint8_t param,
const uint8_t* uid,
const uint8_t* data,
uint16_t dataLen,
uint8_t* rxBuf,
uint16_t rxBufLen,
uint16_t* rcvLen);
#endif /* RFAL_NFCV_H */
@@ -769,4 +921,3 @@ ReturnCode rfalNfcvPollerTransceiveReq( uint8_t cmd, uint8_t flags, uint8_t para
*
* @}
*/
+560 -444
View File
File diff suppressed because it is too large Load Diff
+26 -41
View File
@@ -46,7 +46,6 @@
*
*/
#ifndef RFAL_ST25TB_H
#define RFAL_ST25TB_H
@@ -66,10 +65,10 @@
******************************************************************************
*/
#define RFAL_ST25TB_CHIP_ID_LEN 1U /*!< ST25TB chip ID length */
#define RFAL_ST25TB_CRC_LEN 2U /*!< ST25TB CRC length */
#define RFAL_ST25TB_UID_LEN 8U /*!< ST25TB Unique ID length */
#define RFAL_ST25TB_BLOCK_LEN 4U /*!< ST25TB Data Block length */
#define RFAL_ST25TB_CHIP_ID_LEN 1U /*!< ST25TB chip ID length */
#define RFAL_ST25TB_CRC_LEN 2U /*!< ST25TB CRC length */
#define RFAL_ST25TB_UID_LEN 8U /*!< ST25TB Unique ID length */
#define RFAL_ST25TB_BLOCK_LEN 4U /*!< ST25TB Data Block length */
/*
******************************************************************************
@@ -77,25 +76,20 @@
******************************************************************************
*/
/*
******************************************************************************
* GLOBAL TYPES
******************************************************************************
*/
typedef uint8_t rfalSt25tbUID[RFAL_ST25TB_UID_LEN]; /*!< ST25TB UID type */
typedef uint8_t rfalSt25tbBlock[RFAL_ST25TB_BLOCK_LEN]; /*!< ST25TB Block type */
typedef uint8_t rfalSt25tbUID[RFAL_ST25TB_UID_LEN]; /*!< ST25TB UID type */
typedef uint8_t rfalSt25tbBlock[RFAL_ST25TB_BLOCK_LEN]; /*!< ST25TB Block type */
/*! ST25TB listener device (PICC) struct */
typedef struct
{
uint8_t chipID; /*!< Device's session Chip ID */
rfalSt25tbUID UID; /*!< Device's UID */
bool isDeselected; /*!< Device deselect flag */
}rfalSt25tbListenDevice;
typedef struct {
uint8_t chipID; /*!< Device's session Chip ID */
rfalSt25tbUID UID; /*!< Device's UID */
bool isDeselected; /*!< Device deselect flag */
} rfalSt25tbListenDevice;
/*
******************************************************************************
@@ -114,8 +108,7 @@ typedef struct
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalSt25tbPollerInitialize( void );
ReturnCode rfalSt25tbPollerInitialize(void);
/*!
*****************************************************************************
@@ -135,8 +128,7 @@ ReturnCode rfalSt25tbPollerInitialize( void );
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalSt25tbPollerCheckPresence( uint8_t *chipId );
ReturnCode rfalSt25tbPollerCheckPresence(uint8_t* chipId);
/*!
*****************************************************************************
@@ -160,7 +152,10 @@ ReturnCode rfalSt25tbPollerCheckPresence( uint8_t *chipId );
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalSt25tbPollerCollisionResolution( uint8_t devLimit, rfalSt25tbListenDevice *st25tbDevList, uint8_t *devCnt );
ReturnCode rfalSt25tbPollerCollisionResolution(
uint8_t devLimit,
rfalSt25tbListenDevice* st25tbDevList,
uint8_t* devCnt);
/*!
*****************************************************************************
@@ -180,8 +175,7 @@ ReturnCode rfalSt25tbPollerCollisionResolution( uint8_t devLimit, rfalSt25tbList
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalSt25tbPollerInitiate( uint8_t *chipId );
ReturnCode rfalSt25tbPollerInitiate(uint8_t* chipId);
/*!
*****************************************************************************
@@ -200,8 +194,7 @@ ReturnCode rfalSt25tbPollerInitiate( uint8_t *chipId );
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalSt25tbPollerPcall( uint8_t *chipId );
ReturnCode rfalSt25tbPollerPcall(uint8_t* chipId);
/*!
*****************************************************************************
@@ -222,8 +215,7 @@ ReturnCode rfalSt25tbPollerPcall( uint8_t *chipId );
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalSt25tbPollerSlotMarker( uint8_t slotNum, uint8_t *chipIdRes );
ReturnCode rfalSt25tbPollerSlotMarker(uint8_t slotNum, uint8_t* chipIdRes);
/*!
*****************************************************************************
@@ -244,8 +236,7 @@ ReturnCode rfalSt25tbPollerSlotMarker( uint8_t slotNum, uint8_t *chipIdRes );
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalSt25tbPollerSelect( uint8_t chipId );
ReturnCode rfalSt25tbPollerSelect(uint8_t chipId);
/*!
*****************************************************************************
@@ -265,8 +256,7 @@ ReturnCode rfalSt25tbPollerSelect( uint8_t chipId );
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalSt25tbPollerGetUID( rfalSt25tbUID *UID );
ReturnCode rfalSt25tbPollerGetUID(rfalSt25tbUID* UID);
/*!
*****************************************************************************
@@ -285,8 +275,7 @@ ReturnCode rfalSt25tbPollerGetUID( rfalSt25tbUID *UID );
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalSt25tbPollerReadBlock( uint8_t blockAddress, rfalSt25tbBlock *blockData );
ReturnCode rfalSt25tbPollerReadBlock(uint8_t blockAddress, rfalSt25tbBlock* blockData);
/*!
*****************************************************************************
@@ -305,8 +294,7 @@ ReturnCode rfalSt25tbPollerReadBlock( uint8_t blockAddress, rfalSt25tbBlock *blo
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalSt25tbPollerWriteBlock( uint8_t blockAddress, const rfalSt25tbBlock *blockData );
ReturnCode rfalSt25tbPollerWriteBlock(uint8_t blockAddress, const rfalSt25tbBlock* blockData);
/*!
*****************************************************************************
@@ -323,8 +311,7 @@ ReturnCode rfalSt25tbPollerWriteBlock( uint8_t blockAddress, const rfalSt25tbBlo
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalSt25tbPollerCompletion( void );
ReturnCode rfalSt25tbPollerCompletion(void);
/*!
*****************************************************************************
@@ -340,8 +327,7 @@ ReturnCode rfalSt25tbPollerCompletion( void );
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalSt25tbPollerResetToInventory( void );
ReturnCode rfalSt25tbPollerResetToInventory(void);
#endif /* RFAL_ST25TB_H */
@@ -352,4 +338,3 @@ ReturnCode rfalSt25tbPollerResetToInventory( void );
*
* @}
*/
+144 -29
View File
@@ -68,9 +68,10 @@
******************************************************************************
*/
#define RFAL_NFCV_BLOCKNUM_M24LR_LEN 2U /*!< Block Number length of MR24LR tags: 16 bits */
#define RFAL_NFCV_ST_IC_MFG_CODE 0x02 /*!< ST IC Mfg code (used for custom commands) */
#define RFAL_NFCV_BLOCKNUM_M24LR_LEN \
2U /*!< Block Number length of MR24LR tags: 16 bits */
#define RFAL_NFCV_ST_IC_MFG_CODE \
0x02 /*!< ST IC Mfg code (used for custom commands) */
/*!
*****************************************************************************
@@ -98,7 +99,13 @@
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalST25xVPollerM24LRReadSingleBlock( uint8_t flags, const uint8_t* uid, uint16_t blockNum, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen );
ReturnCode rfalST25xVPollerM24LRReadSingleBlock(
uint8_t flags,
const uint8_t* uid,
uint16_t blockNum,
uint8_t* rxBuf,
uint16_t rxBufLen,
uint16_t* rcvLen);
/*!
*****************************************************************************
@@ -126,7 +133,13 @@ ReturnCode rfalST25xVPollerM24LRReadSingleBlock( uint8_t flags, const uint8_t* u
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalST25xVPollerM24LRFastReadSingleBlock( uint8_t flags, const uint8_t* uid, uint16_t blockNum, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen );
ReturnCode rfalST25xVPollerM24LRFastReadSingleBlock(
uint8_t flags,
const uint8_t* uid,
uint16_t blockNum,
uint8_t* rxBuf,
uint16_t rxBufLen,
uint16_t* rcvLen);
/*!
*****************************************************************************
@@ -153,7 +166,12 @@ ReturnCode rfalST25xVPollerM24LRFastReadSingleBlock( uint8_t flags, const uint8_
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalST25xVPollerM24LRWriteSingleBlock( uint8_t flags, const uint8_t* uid, uint16_t blockNum, const uint8_t* wrData, uint8_t blockLen );
ReturnCode rfalST25xVPollerM24LRWriteSingleBlock(
uint8_t flags,
const uint8_t* uid,
uint16_t blockNum,
const uint8_t* wrData,
uint8_t blockLen);
/*!
*****************************************************************************
@@ -182,8 +200,14 @@ ReturnCode rfalST25xVPollerM24LRWriteSingleBlock( uint8_t flags, const uint8_t*
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalST25xVPollerM24LRReadMultipleBlocks( uint8_t flags, const uint8_t* uid, uint16_t firstBlockNum, uint8_t numOfBlocks, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen );
ReturnCode rfalST25xVPollerM24LRReadMultipleBlocks(
uint8_t flags,
const uint8_t* uid,
uint16_t firstBlockNum,
uint8_t numOfBlocks,
uint8_t* rxBuf,
uint16_t rxBufLen,
uint16_t* rcvLen);
/*!
*****************************************************************************
@@ -212,7 +236,14 @@ ReturnCode rfalST25xVPollerM24LRReadMultipleBlocks( uint8_t flags, const uint8_t
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalST25xVPollerM24LRFastReadMultipleBlocks( uint8_t flags, const uint8_t* uid, uint16_t firstBlockNum, uint8_t numOfBlocks, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen );
ReturnCode rfalST25xVPollerM24LRFastReadMultipleBlocks(
uint8_t flags,
const uint8_t* uid,
uint16_t firstBlockNum,
uint8_t numOfBlocks,
uint8_t* rxBuf,
uint16_t rxBufLen,
uint16_t* rcvLen);
/*!
*****************************************************************************
@@ -239,7 +270,13 @@ ReturnCode rfalST25xVPollerM24LRFastReadMultipleBlocks( uint8_t flags, const uin
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalST25xVPollerFastReadSingleBlock( uint8_t flags, const uint8_t* uid, uint8_t blockNum, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen );
ReturnCode rfalST25xVPollerFastReadSingleBlock(
uint8_t flags,
const uint8_t* uid,
uint8_t blockNum,
uint8_t* rxBuf,
uint16_t rxBufLen,
uint16_t* rcvLen);
/*!
*****************************************************************************
@@ -267,7 +304,14 @@ ReturnCode rfalST25xVPollerFastReadSingleBlock( uint8_t flags, const uint8_t* ui
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalST25xVPollerFastReadMultipleBlocks( uint8_t flags, const uint8_t* uid, uint8_t firstBlockNum, uint8_t numOfBlocks, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen );
ReturnCode rfalST25xVPollerFastReadMultipleBlocks(
uint8_t flags,
const uint8_t* uid,
uint8_t firstBlockNum,
uint8_t numOfBlocks,
uint8_t* rxBuf,
uint16_t rxBufLen,
uint16_t* rcvLen);
/*!
*****************************************************************************
@@ -294,7 +338,13 @@ ReturnCode rfalST25xVPollerFastReadMultipleBlocks( uint8_t flags, const uint8_t*
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalST25xVPollerFastExtendedReadSingleBlock( uint8_t flags, const uint8_t* uid, uint16_t blockNum, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen );
ReturnCode rfalST25xVPollerFastExtendedReadSingleBlock(
uint8_t flags,
const uint8_t* uid,
uint16_t blockNum,
uint8_t* rxBuf,
uint16_t rxBufLen,
uint16_t* rcvLen);
/*!
*****************************************************************************
@@ -322,7 +372,14 @@ ReturnCode rfalST25xVPollerFastExtendedReadSingleBlock( uint8_t flags, const uin
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalST25xVPollerFastExtReadMultipleBlocks( uint8_t flags, const uint8_t* uid, uint16_t firstBlockNum, uint16_t numOfBlocks, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen );
ReturnCode rfalST25xVPollerFastExtReadMultipleBlocks(
uint8_t flags,
const uint8_t* uid,
uint16_t firstBlockNum,
uint16_t numOfBlocks,
uint8_t* rxBuf,
uint16_t rxBufLen,
uint16_t* rcvLen);
/*!
*****************************************************************************
@@ -347,7 +404,11 @@ ReturnCode rfalST25xVPollerFastExtReadMultipleBlocks( uint8_t flags, const uint8
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalST25xVPollerReadConfiguration( uint8_t flags, const uint8_t* uid, uint8_t pointer, uint8_t* regValue );
ReturnCode rfalST25xVPollerReadConfiguration(
uint8_t flags,
const uint8_t* uid,
uint8_t pointer,
uint8_t* regValue);
/*!
*****************************************************************************
@@ -372,8 +433,11 @@ ReturnCode rfalST25xVPollerReadConfiguration( uint8_t flags, const uint8_t* uid,
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalST25xVPollerWriteConfiguration( uint8_t flags, const uint8_t* uid, uint8_t pointer, uint8_t regValue );
ReturnCode rfalST25xVPollerWriteConfiguration(
uint8_t flags,
const uint8_t* uid,
uint8_t pointer,
uint8_t regValue);
/*!
*****************************************************************************
@@ -398,7 +462,11 @@ ReturnCode rfalST25xVPollerWriteConfiguration( uint8_t flags, const uint8_t* uid
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalST25xVPollerReadDynamicConfiguration( uint8_t flags, const uint8_t* uid, uint8_t pointer, uint8_t* regValue );
ReturnCode rfalST25xVPollerReadDynamicConfiguration(
uint8_t flags,
const uint8_t* uid,
uint8_t pointer,
uint8_t* regValue);
/*!
*****************************************************************************
@@ -423,7 +491,11 @@ ReturnCode rfalST25xVPollerReadDynamicConfiguration( uint8_t flags, const uint8_
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalST25xVPollerWriteDynamicConfiguration( uint8_t flags, const uint8_t* uid, uint8_t pointer, uint8_t regValue );
ReturnCode rfalST25xVPollerWriteDynamicConfiguration(
uint8_t flags,
const uint8_t* uid,
uint8_t pointer,
uint8_t regValue);
/*!
*****************************************************************************
@@ -448,7 +520,11 @@ ReturnCode rfalST25xVPollerWriteDynamicConfiguration( uint8_t flags, const uint8
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalST25xVPollerFastReadDynamicConfiguration( uint8_t flags, const uint8_t* uid, uint8_t pointer, uint8_t* regValue );
ReturnCode rfalST25xVPollerFastReadDynamicConfiguration(
uint8_t flags,
const uint8_t* uid,
uint8_t pointer,
uint8_t* regValue);
/*!
*****************************************************************************
@@ -473,7 +549,11 @@ ReturnCode rfalST25xVPollerFastReadDynamicConfiguration( uint8_t flags, const ui
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalST25xVPollerFastWriteDynamicConfiguration( uint8_t flags, const uint8_t* uid, uint8_t pointer, uint8_t regValue );
ReturnCode rfalST25xVPollerFastWriteDynamicConfiguration(
uint8_t flags,
const uint8_t* uid,
uint8_t pointer,
uint8_t regValue);
/*!
*****************************************************************************
@@ -499,7 +579,12 @@ ReturnCode rfalST25xVPollerFastWriteDynamicConfiguration( uint8_t flags, const u
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalST25xVPollerPresentPassword( uint8_t flags, const uint8_t* uid, uint8_t pwdNum, const uint8_t* pwd, uint8_t pwdLen );
ReturnCode rfalST25xVPollerPresentPassword(
uint8_t flags,
const uint8_t* uid,
uint8_t pwdNum,
const uint8_t* pwd,
uint8_t pwdLen);
/*!
*****************************************************************************
@@ -525,7 +610,12 @@ ReturnCode rfalST25xVPollerPresentPassword( uint8_t flags, const uint8_t* uid, u
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalST25xVPollerGetRandomNumber( uint8_t flags, const uint8_t* uid, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen );
ReturnCode rfalST25xVPollerGetRandomNumber(
uint8_t flags,
const uint8_t* uid,
uint8_t* rxBuf,
uint16_t rxBufLen,
uint16_t* rcvLen);
/*!
*****************************************************************************
@@ -549,7 +639,7 @@ ReturnCode rfalST25xVPollerGetRandomNumber( uint8_t flags, const uint8_t* uid, u
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalST25xVPollerReadMessageLength( uint8_t flags, const uint8_t* uid, uint8_t* msgLen );
ReturnCode rfalST25xVPollerReadMessageLength(uint8_t flags, const uint8_t* uid, uint8_t* msgLen);
/*!
*****************************************************************************
@@ -573,7 +663,7 @@ ReturnCode rfalST25xVPollerReadMessageLength( uint8_t flags, const uint8_t* uid,
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalST25xVPollerFastReadMsgLength( uint8_t flags, const uint8_t* uid, uint8_t* msgLen );
ReturnCode rfalST25xVPollerFastReadMsgLength(uint8_t flags, const uint8_t* uid, uint8_t* msgLen);
/*!
*****************************************************************************
@@ -609,7 +699,14 @@ ReturnCode rfalST25xVPollerFastReadMsgLength( uint8_t flags, const uint8_t* uid,
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalST25xVPollerReadMessage( uint8_t flags, const uint8_t* uid, uint8_t mbPointer, uint8_t numBytes, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen );
ReturnCode rfalST25xVPollerReadMessage(
uint8_t flags,
const uint8_t* uid,
uint8_t mbPointer,
uint8_t numBytes,
uint8_t* rxBuf,
uint16_t rxBufLen,
uint16_t* rcvLen);
/*!
*****************************************************************************
@@ -645,7 +742,14 @@ ReturnCode rfalST25xVPollerReadMessage( uint8_t flags, const uint8_t* uid, uint8
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalST25xVPollerFastReadMessage( uint8_t flags, const uint8_t* uid, uint8_t mbPointer, uint8_t numBytes, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen );
ReturnCode rfalST25xVPollerFastReadMessage(
uint8_t flags,
const uint8_t* uid,
uint8_t mbPointer,
uint8_t numBytes,
uint8_t* rxBuf,
uint16_t rxBufLen,
uint16_t* rcvLen);
/*!
*****************************************************************************
@@ -680,7 +784,13 @@ ReturnCode rfalST25xVPollerFastReadMessage( uint8_t flags, const uint8_t* uid, u
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalST25xVPollerWriteMessage( uint8_t flags, const uint8_t* uid, uint8_t msgLen, const uint8_t* msgData, uint8_t* txBuf, uint16_t txBufLen );
ReturnCode rfalST25xVPollerWriteMessage(
uint8_t flags,
const uint8_t* uid,
uint8_t msgLen,
const uint8_t* msgData,
uint8_t* txBuf,
uint16_t txBufLen);
/*!
*****************************************************************************
@@ -715,7 +825,13 @@ ReturnCode rfalST25xVPollerWriteMessage( uint8_t flags, const uint8_t* uid, uint
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalST25xVPollerFastWriteMessage( uint8_t flags, const uint8_t* uid, uint8_t msgLen, const uint8_t* msgData, uint8_t* txBuf, uint16_t txBufLen );
ReturnCode rfalST25xVPollerFastWriteMessage(
uint8_t flags,
const uint8_t* uid,
uint8_t msgLen,
const uint8_t* msgData,
uint8_t* txBuf,
uint16_t txBufLen);
#endif /* RFAL_ST25xV_H */
@@ -726,4 +842,3 @@ ReturnCode rfalST25xVPollerFastWriteMessage( uint8_t flags, const uint8_t* uid,
*
* @}
*/
+19 -28
View File
@@ -49,7 +49,6 @@
*
*/
#ifndef RFAL_T1T_H
#define RFAL_T1T_H
@@ -67,37 +66,32 @@
* GLOBAL DEFINES
******************************************************************************
*/
#define RFAL_T1T_UID_LEN 4 /*!< T1T UID length of cascade level 1 only tag */
#define RFAL_T1T_HR_LENGTH 2 /*!< T1T HR(Header ROM) length */
#define RFAL_T1T_HR0_NDEF_MASK 0xF0 /*!< T1T HR0 NDEF capability mask T1T 1.2 2.2.2 */
#define RFAL_T1T_HR0_NDEF_SUPPORT 0x10 /*!< T1T HR0 NDEF capable value T1T 1.2 2.2.2 */
#define RFAL_T1T_UID_LEN 4 /*!< T1T UID length of cascade level 1 only tag */
#define RFAL_T1T_HR_LENGTH 2 /*!< T1T HR(Header ROM) length */
#define RFAL_T1T_HR0_NDEF_MASK 0xF0 /*!< T1T HR0 NDEF capability mask T1T 1.2 2.2.2 */
#define RFAL_T1T_HR0_NDEF_SUPPORT 0x10 /*!< T1T HR0 NDEF capable value T1T 1.2 2.2.2 */
/*! NFC-A T1T (Topaz) command set */
typedef enum
{
RFAL_T1T_CMD_RID = 0x78, /*!< T1T Read UID */
RFAL_T1T_CMD_RALL = 0x00, /*!< T1T Read All */
RFAL_T1T_CMD_READ = 0x01, /*!< T1T Read */
RFAL_T1T_CMD_WRITE_E = 0x53, /*!< T1T Write with erase (single byte) */
RFAL_T1T_CMD_WRITE_NE = 0x1A /*!< T1T Write with no erase (single byte) */
typedef enum {
RFAL_T1T_CMD_RID = 0x78, /*!< T1T Read UID */
RFAL_T1T_CMD_RALL = 0x00, /*!< T1T Read All */
RFAL_T1T_CMD_READ = 0x01, /*!< T1T Read */
RFAL_T1T_CMD_WRITE_E = 0x53, /*!< T1T Write with erase (single byte) */
RFAL_T1T_CMD_WRITE_NE = 0x1A /*!< T1T Write with no erase (single byte) */
} rfalT1Tcmds;
/*
******************************************************************************
* GLOBAL TYPES
******************************************************************************
*/
/*! NFC-A T1T (Topaz) RID_RES Digital 1.1 10.6.2 & Table 50 */
typedef struct
{
uint8_t hr0; /*!< T1T Header ROM: HR0 */
uint8_t hr1; /*!< T1T Header ROM: HR1 */
uint8_t uid[RFAL_T1T_UID_LEN]; /*!< T1T UID */
typedef struct {
uint8_t hr0; /*!< T1T Header ROM: HR0 */
uint8_t hr1; /*!< T1T Header ROM: HR1 */
uint8_t uid[RFAL_T1T_UID_LEN]; /*!< T1T UID */
} rfalT1TRidRes;
/*
@@ -106,7 +100,6 @@ typedef struct
******************************************************************************
*/
/*!
*****************************************************************************
* \brief Initialize NFC-A T1T Poller mode
@@ -118,8 +111,7 @@ typedef struct
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalT1TPollerInitialize( void );
ReturnCode rfalT1TPollerInitialize(void);
/*!
*****************************************************************************
@@ -135,8 +127,7 @@ ReturnCode rfalT1TPollerInitialize( void );
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalT1TPollerRid( rfalT1TRidRes *ridRes );
ReturnCode rfalT1TPollerRid(rfalT1TRidRes* ridRes);
/*!
*****************************************************************************
@@ -155,8 +146,8 @@ ReturnCode rfalT1TPollerRid( rfalT1TRidRes *ridRes );
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalT1TPollerRall( const uint8_t* uid, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rxRcvdLen );
ReturnCode
rfalT1TPollerRall(const uint8_t* uid, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t* rxRcvdLen);
/*!
*****************************************************************************
@@ -174,7 +165,7 @@ ReturnCode rfalT1TPollerRall( const uint8_t* uid, uint8_t* rxBuf, uint16_t rxBuf
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalT1TPollerWrite( const uint8_t* uid, uint8_t address, uint8_t data );
ReturnCode rfalT1TPollerWrite(const uint8_t* uid, uint8_t address, uint8_t data);
#endif /* RFAL_T1T_H */
+7 -10
View File
@@ -49,7 +49,6 @@
*
*/
#ifndef RFAL_T2T_H
#define RFAL_T2T_H
@@ -68,9 +67,9 @@
******************************************************************************
*/
#define RFAL_T2T_BLOCK_LEN 4U /*!< T2T block length */
#define RFAL_T2T_READ_DATA_LEN (4U * RFAL_T2T_BLOCK_LEN) /*!< T2T READ data length */
#define RFAL_T2T_WRITE_DATA_LEN RFAL_T2T_BLOCK_LEN /*!< T2T WRITE data length */
#define RFAL_T2T_BLOCK_LEN 4U /*!< T2T block length */
#define RFAL_T2T_READ_DATA_LEN (4U * RFAL_T2T_BLOCK_LEN) /*!< T2T READ data length */
#define RFAL_T2T_WRITE_DATA_LEN RFAL_T2T_BLOCK_LEN /*!< T2T WRITE data length */
/*
******************************************************************************
@@ -78,7 +77,6 @@
******************************************************************************
*/
/*
******************************************************************************
* GLOBAL FUNCTION PROTOTYPES
@@ -103,8 +101,8 @@
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalT2TPollerRead( uint8_t blockNum, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen );
ReturnCode
rfalT2TPollerRead(uint8_t blockNum, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t* rcvLen);
/*!
*****************************************************************************
@@ -123,8 +121,7 @@ ReturnCode rfalT2TPollerRead( uint8_t blockNum, uint8_t* rxBuf, uint16_t rxBufLe
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalT2TPollerWrite( uint8_t blockNum, const uint8_t* wrData );
ReturnCode rfalT2TPollerWrite(uint8_t blockNum, const uint8_t* wrData);
/*!
*****************************************************************************
@@ -140,7 +137,7 @@ ReturnCode rfalT2TPollerWrite( uint8_t blockNum, const uint8_t* wrData );
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalT2TPollerSectorSelect( uint8_t sectorNum );
ReturnCode rfalT2TPollerSectorSelect(uint8_t sectorNum);
#endif /* RFAL_T2T_H */
+84 -54
View File
@@ -52,7 +52,6 @@
*
*/
#ifndef RFAL_T4T_H
#define RFAL_T4T_H
@@ -72,20 +71,27 @@
******************************************************************************
*/
#define RFAL_T4T_MAX_CAPDU_PROLOGUE_LEN 4U /*!< Command-APDU prologue length (CLA INS P1 P2) */
#define RFAL_T4T_LE_LEN 1U /*!< Le Expected Response Length (short field coding) */
#define RFAL_T4T_LC_LEN 1U /*!< Lc Data field length (short field coding) */
#define RFAL_T4T_MAX_RAPDU_SW1SW2_LEN 2U /*!< SW1 SW2 length */
#define RFAL_T4T_CLA 0x00U /*!< Class byte (contains 00h because secure message are not used) */
#define RFAL_T4T_MAX_CAPDU_PROLOGUE_LEN \
4U /*!< Command-APDU prologue length (CLA INS P1 P2) */
#define RFAL_T4T_LE_LEN 1U /*!< Le Expected Response Length (short field coding) */
#define RFAL_T4T_LC_LEN 1U /*!< Lc Data field length (short field coding) */
#define RFAL_T4T_MAX_RAPDU_SW1SW2_LEN \
2U /*!< SW1 SW2 length */
#define RFAL_T4T_CLA 0x00U /*!< Class byte (contains 00h because secure message are not used) */
#define RFAL_T4T_ISO7816_P1_SELECT_BY_DF_NAME 0x04U /*!< P1 value for Select by name */
#define RFAL_T4T_ISO7816_P1_SELECT_BY_FILEID 0x00U /*!< P1 value for Select by file identifier */
#define RFAL_T4T_ISO7816_P2_SELECT_FIRST_OR_ONLY_OCCURENCE 0x00U /*!< b2b1 P2 value for First or only occurence */
#define RFAL_T4T_ISO7816_P2_SELECT_RETURN_FCI_TEMPLATE 0x00U /*!< b4b3 P2 value for Return FCI template */
#define RFAL_T4T_ISO7816_P2_SELECT_NO_RESPONSE_DATA 0x0CU /*!< b4b3 P2 value for No responce data */
#define RFAL_T4T_ISO7816_STATUS_COMPLETE 0x9000U /*!< Command completed \ Normal processing - No further qualification*/
#define RFAL_T4T_ISO7816_P1_SELECT_BY_DF_NAME \
0x04U /*!< P1 value for Select by name */
#define RFAL_T4T_ISO7816_P1_SELECT_BY_FILEID \
0x00U /*!< P1 value for Select by file identifier */
#define RFAL_T4T_ISO7816_P2_SELECT_FIRST_OR_ONLY_OCCURENCE \
0x00U /*!< b2b1 P2 value for First or only occurence */
#define RFAL_T4T_ISO7816_P2_SELECT_RETURN_FCI_TEMPLATE \
0x00U /*!< b4b3 P2 value for Return FCI template */
#define RFAL_T4T_ISO7816_P2_SELECT_NO_RESPONSE_DATA \
0x0CU /*!< b4b3 P2 value for No responce data */
#define RFAL_T4T_ISO7816_STATUS_COMPLETE \
0x9000U /*!< Command completed \ Normal processing - No further qualification*/
/*
******************************************************************************
@@ -93,47 +99,42 @@
******************************************************************************
*/
/*
******************************************************************************
* GLOBAL TYPES
******************************************************************************
*/
/*! NFC-A T4T Command-APDU structure */
typedef struct
{
uint8_t CLA; /*!< Class byte */
uint8_t INS; /*!< Instruction byte */
uint8_t P1; /*!< Parameter byte 1 */
uint8_t P2; /*!< Parameter byte 2 */
uint8_t Lc; /*!< Data field length */
bool LcFlag; /*!< Lc flag (append Lc when true) */
uint8_t Le; /*!< Expected Response Length */
bool LeFlag; /*!< Le flag (append Le when true) */
rfalIsoDepApduBufFormat *cApduBuf; /*!< Command-APDU buffer (Tx) */
uint16_t *cApduLen; /*!< Command-APDU Length */
}rfalT4tCApduParam;
typedef struct {
uint8_t CLA; /*!< Class byte */
uint8_t INS; /*!< Instruction byte */
uint8_t P1; /*!< Parameter byte 1 */
uint8_t P2; /*!< Parameter byte 2 */
uint8_t Lc; /*!< Data field length */
bool LcFlag; /*!< Lc flag (append Lc when true) */
uint8_t Le; /*!< Expected Response Length */
bool LeFlag; /*!< Le flag (append Le when true) */
rfalIsoDepApduBufFormat* cApduBuf; /*!< Command-APDU buffer (Tx) */
uint16_t* cApduLen; /*!< Command-APDU Length */
} rfalT4tCApduParam;
/*! NFC-A T4T Response-APDU structure */
typedef struct
{
rfalIsoDepApduBufFormat *rApduBuf; /*!< Response-APDU buffer (Rx) */
uint16_t rcvdLen; /*!< Full response length */
uint16_t rApduBodyLen; /*!< Response body length */
uint16_t statusWord; /*!< R-APDU Status Word SW1|SW2 */
}rfalT4tRApduParam;
typedef struct {
rfalIsoDepApduBufFormat* rApduBuf; /*!< Response-APDU buffer (Rx) */
uint16_t rcvdLen; /*!< Full response length */
uint16_t rApduBodyLen; /*!< Response body length */
uint16_t statusWord; /*!< R-APDU Status Word SW1|SW2 */
} rfalT4tRApduParam;
/*! NFC-A T4T command set T4T 1.0 & ISO7816-4 2013 Table 4 */
typedef enum
{
RFAL_T4T_INS_SELECT = 0xA4U, /*!< T4T Select */
RFAL_T4T_INS_READBINARY = 0xB0U, /*!< T4T ReadBinary */
RFAL_T4T_INS_UPDATEBINARY = 0xD6U, /*!< T4T UpdateBinay */
RFAL_T4T_INS_READBINARY_ODO = 0xB1U, /*!< T4T ReadBinary using ODO */
RFAL_T4T_INS_UPDATEBINARY_ODO = 0xD7U /*!< T4T UpdateBinay using ODO */
typedef enum {
RFAL_T4T_INS_SELECT = 0xA4U, /*!< T4T Select */
RFAL_T4T_INS_READBINARY = 0xB0U, /*!< T4T ReadBinary */
RFAL_T4T_INS_UPDATEBINARY = 0xD6U, /*!< T4T UpdateBinay */
RFAL_T4T_INS_READBINARY_ODO = 0xB1U, /*!< T4T ReadBinary using ODO */
RFAL_T4T_INS_UPDATEBINARY_ODO =
0xD7U /*!< T4T UpdateBinay using ODO */
} rfalT4tCmds;
/*
@@ -169,8 +170,7 @@ typedef enum
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalT4TPollerComposeCAPDU( const rfalT4tCApduParam *apduParam );
ReturnCode rfalT4TPollerComposeCAPDU(const rfalT4tCApduParam* apduParam);
/*!
*****************************************************************************
@@ -189,7 +189,7 @@ ReturnCode rfalT4TPollerComposeCAPDU( const rfalT4tCApduParam *apduParam );
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalT4TPollerParseRAPDU( rfalT4tRApduParam *apduParam );
ReturnCode rfalT4TPollerParseRAPDU(rfalT4tRApduParam* apduParam);
/*!
*****************************************************************************
@@ -212,7 +212,11 @@ ReturnCode rfalT4TPollerParseRAPDU( rfalT4tRApduParam *apduParam );
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalT4TPollerComposeSelectAppl( rfalIsoDepApduBufFormat *cApduBuf, const uint8_t* aid, uint8_t aidLen, uint16_t *cApduLen );
ReturnCode rfalT4TPollerComposeSelectAppl(
rfalIsoDepApduBufFormat* cApduBuf,
const uint8_t* aid,
uint8_t aidLen,
uint16_t* cApduLen);
/*!
*****************************************************************************
@@ -235,7 +239,11 @@ ReturnCode rfalT4TPollerComposeSelectAppl( rfalIsoDepApduBufFormat *cApduBuf, co
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalT4TPollerComposeSelectFile( rfalIsoDepApduBufFormat *cApduBuf, const uint8_t* fid, uint8_t fidLen, uint16_t *cApduLen );
ReturnCode rfalT4TPollerComposeSelectFile(
rfalIsoDepApduBufFormat* cApduBuf,
const uint8_t* fid,
uint8_t fidLen,
uint16_t* cApduLen);
/*!
*****************************************************************************
@@ -258,7 +266,11 @@ ReturnCode rfalT4TPollerComposeSelectFile( rfalIsoDepApduBufFormat *cApduBuf, co
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalT4TPollerComposeSelectFileV1Mapping( rfalIsoDepApduBufFormat *cApduBuf, const uint8_t* fid, uint8_t fidLen, uint16_t *cApduLen );
ReturnCode rfalT4TPollerComposeSelectFileV1Mapping(
rfalIsoDepApduBufFormat* cApduBuf,
const uint8_t* fid,
uint8_t fidLen,
uint16_t* cApduLen);
/*!
*****************************************************************************
@@ -281,7 +293,11 @@ ReturnCode rfalT4TPollerComposeSelectFileV1Mapping( rfalIsoDepApduBufFormat *cAp
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalT4TPollerComposeReadData( rfalIsoDepApduBufFormat *cApduBuf, uint16_t offset, uint8_t expLen, uint16_t *cApduLen );
ReturnCode rfalT4TPollerComposeReadData(
rfalIsoDepApduBufFormat* cApduBuf,
uint16_t offset,
uint8_t expLen,
uint16_t* cApduLen);
/*!
*****************************************************************************
@@ -304,7 +320,11 @@ ReturnCode rfalT4TPollerComposeReadData( rfalIsoDepApduBufFormat *cApduBuf, uint
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalT4TPollerComposeReadDataODO( rfalIsoDepApduBufFormat *cApduBuf, uint32_t offset, uint8_t expLen, uint16_t *cApduLen );
ReturnCode rfalT4TPollerComposeReadDataODO(
rfalIsoDepApduBufFormat* cApduBuf,
uint32_t offset,
uint8_t expLen,
uint16_t* cApduLen);
/*!
*****************************************************************************
@@ -328,7 +348,12 @@ ReturnCode rfalT4TPollerComposeReadDataODO( rfalIsoDepApduBufFormat *cApduBuf, u
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalT4TPollerComposeWriteData( rfalIsoDepApduBufFormat *cApduBuf, uint16_t offset, const uint8_t* data, uint8_t dataLen, uint16_t *cApduLen );
ReturnCode rfalT4TPollerComposeWriteData(
rfalIsoDepApduBufFormat* cApduBuf,
uint16_t offset,
const uint8_t* data,
uint8_t dataLen,
uint16_t* cApduLen);
/*!
*****************************************************************************
@@ -352,7 +377,12 @@ ReturnCode rfalT4TPollerComposeWriteData( rfalIsoDepApduBufFormat *cApduBuf, uin
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalT4TPollerComposeWriteDataODO( rfalIsoDepApduBufFormat *cApduBuf, uint32_t offset, const uint8_t* data, uint8_t dataLen, uint16_t *cApduLen );
ReturnCode rfalT4TPollerComposeWriteDataODO(
rfalIsoDepApduBufFormat* cApduBuf,
uint32_t offset,
const uint8_t* data,
uint8_t dataLen,
uint16_t* cApduLen);
#endif /* RFAL_T4T_H */
+9 -9
View File
@@ -2,7 +2,7 @@
#include <assert.h>
#include <main.h>
#include <furi.h>
#include <furi-hal-spi.h>
#include <furi_hal_spi.h>
static osThreadAttr_t platform_irq_thread_attr;
static volatile osThreadId_t platform_irq_thread_id = NULL;
@@ -10,8 +10,7 @@ static volatile PlatformIrqCallback platform_irq_callback = NULL;
static const GpioPin pin = {ST25R_INT_PORT, ST25R_INT_PIN};
void nfc_isr(void* _ctx) {
if(platform_irq_callback
&& platformGpioIsHigh(ST25R_INT_PORT, ST25R_INT_PIN)) {
if(platform_irq_callback && platformGpioIsHigh(ST25R_INT_PORT, ST25R_INT_PIN)) {
osThreadFlagsSet(platform_irq_thread_id, 0x1);
}
}
@@ -19,7 +18,7 @@ void nfc_isr(void* _ctx) {
void platformIrqWorker() {
while(1) {
uint32_t flags = osThreadFlagsWait(0x1, osFlagsWaitAny, osWaitForever);
if (flags & 0x1) {
if(flags & 0x1) {
platform_irq_callback();
}
}
@@ -47,13 +46,14 @@ void platformSetIrqCallback(PlatformIrqCallback callback) {
hal_gpio_disable_int_callback(&pin);
}
HAL_StatusTypeDef platformSpiTxRx(const uint8_t *txBuf, uint8_t *rxBuf, uint16_t len) {
HAL_StatusTypeDef platformSpiTxRx(const uint8_t* txBuf, uint8_t* rxBuf, uint16_t len) {
bool ret = false;
if (txBuf && rxBuf) {
ret = furi_hal_spi_bus_trx(&furi_hal_spi_bus_handle_nfc, (uint8_t*)txBuf, rxBuf, len, 1000);
} else if (txBuf) {
if(txBuf && rxBuf) {
ret =
furi_hal_spi_bus_trx(&furi_hal_spi_bus_handle_nfc, (uint8_t*)txBuf, rxBuf, len, 1000);
} else if(txBuf) {
ret = furi_hal_spi_bus_tx(&furi_hal_spi_bus_handle_nfc, (uint8_t*)txBuf, len, 1000);
} else if (rxBuf) {
} else if(rxBuf) {
ret = furi_hal_spi_bus_rx(&furi_hal_spi_bus_handle_nfc, (uint8_t*)rxBuf, len, 1000);
}
+119 -81
View File
@@ -9,86 +9,124 @@
#include "timer.h"
#include "math.h"
#include "main.h"
#include <furi-hal-gpio.h>
#include <furi-hal-light.h>
#include <furi-hal-spi.h>
#include <furi_hal_gpio.h>
#include <furi_hal_light.h>
#include <furi_hal_spi.h>
typedef void (*PlatformIrqCallback)();
void platformSetIrqCallback(PlatformIrqCallback cb);
void platformEnableIrqCallback();
void platformDisableIrqCallback();
HAL_StatusTypeDef platformSpiTxRx(const uint8_t *txBuf, uint8_t *rxBuf, uint16_t len);
HAL_StatusTypeDef platformSpiTxRx(const uint8_t* txBuf, uint8_t* rxBuf, uint16_t len);
void platformProtectST25RComm();
void platformUnprotectST25RComm();
#define ST25R_SS_PIN NFC_CS_Pin
#define ST25R_SS_PORT NFC_CS_GPIO_Port
#define ST25R_INT_PIN NFC_IRQ_Pin
#define ST25R_INT_PORT NFC_IRQ_GPIO_Port
#define RFAL_ANALOG_CONFIG_CUSTOM true /*!< Enable/Disable RFAL custom analog configuration */
#define RFAL_ANALOG_CONFIG_CUSTOM \
true /*!< Enable/Disable RFAL custom analog configuration */
#define RFAL_FEATURE_LISTEN_MODE true /*!< Enable/Disable RFAL support for Listen Mode */
#define RFAL_FEATURE_WAKEUP_MODE true /*!< Enable/Disable RFAL support for the Wake-Up mode */
#define RFAL_FEATURE_LOWPOWER_MODE true /*!< Enable/Disable RFAL support for the Low Power mode */
#define RFAL_FEATURE_NFCA true /*!< Enable/Disable RFAL support for NFC-A (ISO14443A) */
#define RFAL_FEATURE_NFCB true /*!< Enable/Disable RFAL support for NFC-B (ISO14443B) */
#define RFAL_FEATURE_NFCF true /*!< Enable/Disable RFAL support for NFC-F (FeliCa) */
#define RFAL_FEATURE_NFCV true /*!< Enable/Disable RFAL support for NFC-V (ISO15693) */
#define RFAL_FEATURE_T1T true /*!< Enable/Disable RFAL support for T1T (Topaz) */
#define RFAL_FEATURE_T2T true /*!< Enable/Disable RFAL support for T2T (MIFARE Ultralight) */
#define RFAL_FEATURE_T4T true /*!< Enable/Disable RFAL support for T4T */
#define RFAL_FEATURE_ST25TB true /*!< Enable/Disable RFAL support for ST25TB */
#define RFAL_FEATURE_ST25xV true /*!< Enable/Disable RFAL support for ST25TV/ST25DV */
#define RFAL_FEATURE_DYNAMIC_ANALOG_CONFIG false /*!< Enable/Disable Analog Configs to be dynamically updated (RAM) */
#define RFAL_FEATURE_DPO false /*!< Enable/Disable RFAL Dynamic Power Output upport */
#define RFAL_FEATURE_ISO_DEP true /*!< Enable/Disable RFAL support for ISO-DEP (ISO14443-4) */
#define RFAL_FEATURE_ISO_DEP_POLL true /*!< Enable/Disable RFAL support for Poller mode (PCD) ISO-DEP (ISO14443-4) */
#define RFAL_FEATURE_ISO_DEP_LISTEN true /*!< Enable/Disable RFAL support for Listen mode (PICC) ISO-DEP (ISO14443-4) */
#define RFAL_FEATURE_NFC_DEP true /*!< Enable/Disable RFAL support for NFC-DEP (NFCIP1/P2P) */
#define RFAL_FEATURE_LISTEN_MODE \
true /*!< Enable/Disable RFAL support for Listen Mode */
#define RFAL_FEATURE_WAKEUP_MODE \
true /*!< Enable/Disable RFAL support for the Wake-Up mode */
#define RFAL_FEATURE_LOWPOWER_MODE \
true /*!< Enable/Disable RFAL support for the Low Power mode */
#define RFAL_FEATURE_NFCA \
true /*!< Enable/Disable RFAL support for NFC-A (ISO14443A) */
#define RFAL_FEATURE_NFCB \
true /*!< Enable/Disable RFAL support for NFC-B (ISO14443B) */
#define RFAL_FEATURE_NFCF \
true /*!< Enable/Disable RFAL support for NFC-F (FeliCa) */
#define RFAL_FEATURE_NFCV \
true /*!< Enable/Disable RFAL support for NFC-V (ISO15693) */
#define RFAL_FEATURE_T1T \
true /*!< Enable/Disable RFAL support for T1T (Topaz) */
#define RFAL_FEATURE_T2T \
true /*!< Enable/Disable RFAL support for T2T (MIFARE Ultralight) */
#define RFAL_FEATURE_T4T \
true /*!< Enable/Disable RFAL support for T4T */
#define RFAL_FEATURE_ST25TB \
true /*!< Enable/Disable RFAL support for ST25TB */
#define RFAL_FEATURE_ST25xV \
true /*!< Enable/Disable RFAL support for ST25TV/ST25DV */
#define RFAL_FEATURE_DYNAMIC_ANALOG_CONFIG \
false /*!< Enable/Disable Analog Configs to be dynamically updated (RAM) */
#define RFAL_FEATURE_DPO \
false /*!< Enable/Disable RFAL Dynamic Power Output upport */
#define RFAL_FEATURE_ISO_DEP \
true /*!< Enable/Disable RFAL support for ISO-DEP (ISO14443-4) */
#define RFAL_FEATURE_ISO_DEP_POLL \
true /*!< Enable/Disable RFAL support for Poller mode (PCD) ISO-DEP (ISO14443-4) */
#define RFAL_FEATURE_ISO_DEP_LISTEN \
true /*!< Enable/Disable RFAL support for Listen mode (PICC) ISO-DEP (ISO14443-4) */
#define RFAL_FEATURE_NFC_DEP \
true /*!< Enable/Disable RFAL support for NFC-DEP (NFCIP1/P2P) */
#define RFAL_FEATURE_ISO_DEP_IBLOCK_MAX_LEN 256U /*!< ISO-DEP I-Block max length. Please use values as defined by rfalIsoDepFSx */
#define RFAL_FEATURE_NFC_DEP_BLOCK_MAX_LEN 254U /*!< NFC-DEP Block/Payload length. Allowed values: 64, 128, 192, 254 */
#define RFAL_FEATURE_NFC_RF_BUF_LEN 256U /*!< RF buffer length used by RFAL NFC layer */
#define RFAL_FEATURE_ISO_DEP_IBLOCK_MAX_LEN \
256U /*!< ISO-DEP I-Block max length. Please use values as defined by rfalIsoDepFSx */
#define RFAL_FEATURE_NFC_DEP_BLOCK_MAX_LEN \
254U /*!< NFC-DEP Block/Payload length. Allowed values: 64, 128, 192, 254 */
#define RFAL_FEATURE_NFC_RF_BUF_LEN \
256U /*!< RF buffer length used by RFAL NFC layer */
#define RFAL_FEATURE_ISO_DEP_APDU_MAX_LEN 512U /*!< ISO-DEP APDU max length. */
#define RFAL_FEATURE_NFC_DEP_PDU_MAX_LEN 512U /*!< NFC-DEP PDU max length. */
#define RFAL_FEATURE_ISO_DEP_APDU_MAX_LEN \
512U /*!< ISO-DEP APDU max length. */
#define RFAL_FEATURE_NFC_DEP_PDU_MAX_LEN \
512U /*!< NFC-DEP PDU max length. */
#define platformIrqST25RSetCallback( cb ) platformSetIrqCallback(cb)
#define platformIrqST25RSetCallback(cb) platformSetIrqCallback(cb)
#define platformProtectST25RIrqStatus() platformProtectST25RComm() /*!< Protect unique access to IRQ status var - IRQ disable on single thread environment (MCU) ; Mutex lock on a multi thread environment */
#define platformUnprotectST25RIrqStatus() platformUnprotectST25RComm() /*!< Unprotect the IRQ status var - IRQ enable on a single thread environment (MCU) ; Mutex unlock on a multi thread environment */
#define platformProtectST25RIrqStatus() \
platformProtectST25RComm() /*!< Protect unique access to IRQ status var - IRQ disable on single thread environment (MCU) ; Mutex lock on a multi thread environment */
#define platformUnprotectST25RIrqStatus() \
platformUnprotectST25RComm() /*!< Unprotect the IRQ status var - IRQ enable on a single thread environment (MCU) ; Mutex unlock on a multi thread environment */
#define platformGpioSet( port, pin ) HAL_GPIO_WritePin(port, pin, GPIO_PIN_SET) /*!< Turns the given GPIO High */
#define platformGpioClear( port, pin ) HAL_GPIO_WritePin(port, pin, GPIO_PIN_RESET) /*!< Turns the given GPIO Low */
#define platformGpioToogle( port, pin ) HAL_GPIO_TogglePin(port, pin) /*!< Toogles the given GPIO */
#define platformGpioIsHigh( port, pin ) (HAL_GPIO_ReadPin(port, pin) == GPIO_PIN_SET) /*!< Checks if the given LED is High */
#define platformGpioIsLow( port, pin ) (!platformGpioIsHigh(port, pin)) /*!< Checks if the given LED is Low */
#define platformGpioSet(port, pin) \
HAL_GPIO_WritePin(port, pin, GPIO_PIN_SET) /*!< Turns the given GPIO High */
#define platformGpioClear(port, pin) \
HAL_GPIO_WritePin( \
port, pin, GPIO_PIN_RESET) /*!< Turns the given GPIO Low */
#define platformGpioToogle(port, pin) \
HAL_GPIO_TogglePin(port, pin) /*!< Toogles the given GPIO */
#define platformGpioIsHigh(port, pin) \
(HAL_GPIO_ReadPin(port, pin) == \
GPIO_PIN_SET) /*!< Checks if the given LED is High */
#define platformGpioIsLow(port, pin) \
(!platformGpioIsHigh(port, pin)) /*!< Checks if the given LED is Low */
#define platformTimerCreate( t ) timerCalculateTimer(t) /*!< Create a timer with the given time (ms) */
#define platformTimerIsExpired( timer ) timerIsExpired(timer) /*!< Checks if the given timer is expired */
#define platformDelay( t ) osDelay( t ) /*!< Performs a delay for the given time (ms) */
#define platformTimerCreate(t) \
timerCalculateTimer(t) /*!< Create a timer with the given time (ms) */
#define platformTimerIsExpired(timer) \
timerIsExpired(timer) /*!< Checks if the given timer is expired */
#define platformDelay(t) osDelay(t) /*!< Performs a delay for the given time (ms) */
#define platformGetSysTick() osKernelGetTickCount() /*!< Get System Tick (1 tick = 1 ms) */
#define platformGetSysTick() \
osKernelGetTickCount() /*!< Get System Tick (1 tick = 1 ms) */
#define platformAssert( exp ) assert_param( exp ) /*!< Asserts whether the given expression is true*/
#define platformAssert(exp) assert_param(exp) /*!< Asserts whether the given expression is true*/
#define platformSpiSelect() platformGpioClear( ST25R_SS_PORT, ST25R_SS_PIN ) /*!< SPI SS\CS: Chip|Slave Select */
#define platformSpiDeselect() platformGpioSet( ST25R_SS_PORT, ST25R_SS_PIN ) /*!< SPI SS\CS: Chip|Slave Deselect */
#define platformSpiSelect() \
platformGpioClear( \
ST25R_SS_PORT, ST25R_SS_PIN) /*!< SPI SS\CS: Chip|Slave Select */
#define platformSpiDeselect() \
platformGpioSet( \
ST25R_SS_PORT, ST25R_SS_PIN) /*!< SPI SS\CS: Chip|Slave Deselect */
#define platformI2CTx(txBuf, len, last, txOnly) /*!< I2C Transmit */
#define platformI2CRx(txBuf, len) /*!< I2C Receive */
#define platformI2CStart() /*!< I2C Start condition */
#define platformI2CStop() /*!< I2C Stop condition */
#define platformI2CRepeatStart() /*!< I2C Repeat Start */
#define platformI2CSlaveAddrWR(add) /*!< I2C Slave address for Write operation */
#define platformI2CSlaveAddrRD(add) /*!< I2C Slave address for Read operation */
#define platformI2CTx( txBuf, len, last, txOnly ) /*!< I2C Transmit */
#define platformI2CRx( txBuf, len ) /*!< I2C Receive */
#define platformI2CStart() /*!< I2C Start condition */
#define platformI2CStop() /*!< I2C Stop condition */
#define platformI2CRepeatStart() /*!< I2C Repeat Start */
#define platformI2CSlaveAddrWR(add) /*!< I2C Slave address for Write operation */
#define platformI2CSlaveAddrRD(add) /*!< I2C Slave address for Read operation */
#define platformLog(...) /*!< Log method */
#define platformLog(...) /*!< Log method */
/*
******************************************************************************
@@ -96,57 +134,57 @@ void platformUnprotectST25RComm();
******************************************************************************
*/
#ifndef platformProtectST25RIrqStatus
#define platformProtectST25RIrqStatus() /*!< Protect unique access to IRQ status var - IRQ disable on single thread environment (MCU) ; Mutex lock on a multi thread environment */
#define platformProtectST25RIrqStatus() /*!< Protect unique access to IRQ status var - IRQ disable on single thread environment (MCU) ; Mutex lock on a multi thread environment */
#endif /* platformProtectST25RIrqStatus */
#ifndef platformUnprotectST25RIrqStatus
#define platformUnprotectST25RIrqStatus() /*!< Unprotect the IRQ status var - IRQ enable on a single thread environment (MCU) ; Mutex unlock on a multi thread environment */
#define platformUnprotectST25RIrqStatus() /*!< Unprotect the IRQ status var - IRQ enable on a single thread environment (MCU) ; Mutex unlock on a multi thread environment */
#endif /* platformUnprotectST25RIrqStatus */
#ifndef platformProtectWorker
#define platformProtectWorker() /* Protect RFAL Worker/Task/Process from concurrent execution on multi thread platforms */
#define platformProtectWorker() /* Protect RFAL Worker/Task/Process from concurrent execution on multi thread platforms */
#endif /* platformProtectWorker */
#ifndef platformUnprotectWorker
#define platformUnprotectWorker() /* Unprotect RFAL Worker/Task/Process from concurrent execution on multi thread platforms */
#define platformUnprotectWorker() /* Unprotect RFAL Worker/Task/Process from concurrent execution on multi thread platforms */
#endif /* platformUnprotectWorker */
#ifndef platformIrqST25RPinInitialize
#define platformIrqST25RPinInitialize() /*!< Initializes ST25R IRQ pin */
#define platformIrqST25RPinInitialize() /*!< Initializes ST25R IRQ pin */
#endif /* platformIrqST25RPinInitialize */
#ifndef platformIrqST25RSetCallback
#define platformIrqST25RSetCallback( cb ) /*!< Sets ST25R ISR callback */
#define platformIrqST25RSetCallback(cb) /*!< Sets ST25R ISR callback */
#endif /* platformIrqST25RSetCallback */
#ifndef platformLedsInitialize
#define platformLedsInitialize() /*!< Initializes the pins used as LEDs to outputs */
#define platformLedsInitialize() /*!< Initializes the pins used as LEDs to outputs */
#endif /* platformLedsInitialize */
#ifndef platformLedOff
#define platformLedOff( port, pin ) /*!< Turns the given LED Off */
#endif /* platformLedOff */
#ifndef platformLedOn
#define platformLedOn( port, pin ) /*!< Turns the given LED On */
#endif /* platformLedOn */
#ifndef platformLedToogle
#define platformLedToogle( port, pin ) /*!< Toggles the given LED */
#endif /* platformLedToogle */
#ifndef platformGetSysTick
#define platformGetSysTick() /*!< Get System Tick (1 tick = 1 ms) */
#endif /* platformGetSysTick */
#ifndef platformTimerDestroy
#define platformTimerDestroy( timer ) /*!< Stops and released the given timer */
#define platformLedOff(port, pin) /*!< Turns the given LED Off */
#endif /* platformLedOff */
#ifndef platformLedOn
#define platformLedOn(port, pin) /*!< Turns the given LED On */
#endif /* platformLedOn */
#ifndef platformLedToogle
#define platformLedToogle(port, pin) /*!< Toggles the given LED */
#endif /* platformLedToogle */
#ifndef platformGetSysTick
#define platformGetSysTick() /*!< Get System Tick (1 tick = 1 ms) */
#endif /* platformGetSysTick */
#ifndef platformTimerDestroy
#define platformTimerDestroy(timer) /*!< Stops and released the given timer */
#endif /* platformTimerDestroy */
#ifndef platformAssert
#define platformAssert( exp ) /*!< Asserts whether the given expression is true */
#ifndef platformAssert
#define platformAssert(exp) /*!< Asserts whether the given expression is true */
#endif /* platformAssert */
#ifndef platformErrorHandle
#define platformErrorHandle() /*!< Global error handler or trap */
#ifndef platformErrorHandle
#define platformErrorHandle() /*!< Global error handler or trap */
#endif /* platformErrorHandle */
File diff suppressed because it is too large Load Diff
+199 -202
View File
@@ -25,7 +25,7 @@
* Revision:
* LANGUAGE: ISO C99
*/
/*! \file rfal_analogConfig.c
*
* \author bkam
@@ -45,13 +45,12 @@
#include "platform.h"
#include "utils.h"
/* Check whether the Default Analog settings are to be used or custom ones */
#ifdef RFAL_ANALOG_CONFIG_CUSTOM
extern const uint8_t* rfalAnalogConfigCustomSettings;
extern const uint16_t rfalAnalogConfigCustomSettingsLength;
extern const uint8_t* rfalAnalogConfigCustomSettings;
extern const uint16_t rfalAnalogConfigCustomSettingsLength;
#else
#include "rfal_analogConfigTbl.h"
#include "rfal_analogConfigTbl.h"
#endif
/*
@@ -60,8 +59,7 @@
******************************************************************************
*/
#define RFAL_TEST_REG 0x0080U /*!< Test Register indicator */
#define RFAL_TEST_REG 0x0080U /*!< Test Register indicator */
/*
******************************************************************************
@@ -76,18 +74,19 @@
*/
#if RFAL_FEATURE_DYNAMIC_ANALOG_CONFIG
static uint8_t gRfalAnalogConfig[RFAL_ANALOG_CONFIG_TBL_SIZE]; /*!< Analog Configuration Settings List */
static uint8_t
gRfalAnalogConfig[RFAL_ANALOG_CONFIG_TBL_SIZE]; /*!< Analog Configuration Settings List */
#endif /* RFAL_FEATURE_DYNAMIC_ANALOG_CONFIG */
/*! Struct for Analog Config Look Up Table Update */
typedef struct {
const uint8_t *currentAnalogConfigTbl; /*!< Reference to start of current Analog Configuration */
uint16_t configTblSize; /*!< Total size of Analog Configuration */
bool ready; /*!< Indicate if Look Up Table is complete and ready for use */
const uint8_t*
currentAnalogConfigTbl; /*!< Reference to start of current Analog Configuration */
uint16_t configTblSize; /*!< Total size of Analog Configuration */
bool ready; /*!< Indicate if Look Up Table is complete and ready for use */
} rfalAnalogConfigMgmt;
static rfalAnalogConfigMgmt gRfalAnalogConfigMgmt; /*!< Analog Configuration LUT management */
static rfalAnalogConfigMgmt gRfalAnalogConfigMgmt; /*!< Analog Configuration LUT management */
/*
******************************************************************************
@@ -100,10 +99,11 @@ static rfalAnalogConfigMgmt gRfalAnalogConfigMgmt; /*!< Analog Configuration
* LOCAL FUNCTION PROTOTYPES
******************************************************************************
*/
static rfalAnalogConfigNum rfalAnalogConfigSearch( rfalAnalogConfigId configId, uint16_t *configOffset );
static rfalAnalogConfigNum
rfalAnalogConfigSearch(rfalAnalogConfigId configId, uint16_t* configOffset);
#if RFAL_FEATURE_DYNAMIC_ANALOG_CONFIG
static void rfalAnalogConfigPtrUpdate( const uint8_t* analogConfigTbl );
static void rfalAnalogConfigPtrUpdate(const uint8_t* analogConfigTbl);
#endif /* RFAL_FEATURE_DYNAMIC_ANALOG_CONFIG */
/*
@@ -118,281 +118,280 @@ static rfalAnalogConfigNum rfalAnalogConfigSearch( rfalAnalogConfigId configId,
******************************************************************************
*/
void rfalAnalogConfigInitialize( void )
{
void rfalAnalogConfigInitialize(void) {
/* Use default Analog configuration settings in Flash by default. */
/* Check whether the Default Analog settings are to be used or custom ones */
/* Check whether the Default Analog settings are to be used or custom ones */
#ifdef RFAL_ANALOG_CONFIG_CUSTOM
gRfalAnalogConfigMgmt.currentAnalogConfigTbl = (const uint8_t *)&rfalAnalogConfigCustomSettings;
gRfalAnalogConfigMgmt.configTblSize = rfalAnalogConfigCustomSettingsLength;
#else
gRfalAnalogConfigMgmt.currentAnalogConfigTbl = (const uint8_t *)&rfalAnalogConfigDefaultSettings;
gRfalAnalogConfigMgmt.configTblSize = sizeof(rfalAnalogConfigDefaultSettings);
gRfalAnalogConfigMgmt.currentAnalogConfigTbl = (const uint8_t*)&rfalAnalogConfigCustomSettings;
gRfalAnalogConfigMgmt.configTblSize = rfalAnalogConfigCustomSettingsLength;
#else
gRfalAnalogConfigMgmt.currentAnalogConfigTbl =
(const uint8_t*)&rfalAnalogConfigDefaultSettings;
gRfalAnalogConfigMgmt.configTblSize = sizeof(rfalAnalogConfigDefaultSettings);
#endif
gRfalAnalogConfigMgmt.ready = true;
gRfalAnalogConfigMgmt.ready = true;
} /* rfalAnalogConfigInitialize() */
bool rfalAnalogConfigIsReady( void )
{
bool rfalAnalogConfigIsReady(void) {
return gRfalAnalogConfigMgmt.ready;
}
ReturnCode rfalAnalogConfigListWriteRaw( const uint8_t *configTbl, uint16_t configTblSize )
{
ReturnCode rfalAnalogConfigListWriteRaw(const uint8_t* configTbl, uint16_t configTblSize) {
#if RFAL_FEATURE_DYNAMIC_ANALOG_CONFIG
/* Check if the Configuration Table exceed the Table size */
if ( configTblSize >= RFAL_ANALOG_CONFIG_TBL_SIZE )
{
if(configTblSize >= RFAL_ANALOG_CONFIG_TBL_SIZE) {
rfalAnalogConfigInitialize(); /* Revert to default Analog Configuration */
return ERR_NOMEM;
}
/* Check for invalid parameters */
if( (configTbl == NULL) || (configTblSize == 0U) )
{
if((configTbl == NULL) || (configTblSize == 0U)) {
return ERR_PARAM;
}
/* NOTE: Function does not check for the validity of the Table contents (conf IDs, conf sets, register address) */
ST_MEMCPY( gRfalAnalogConfig, configTbl, configTblSize );
ST_MEMCPY(gRfalAnalogConfig, configTbl, configTblSize);
/* Update the total size of configuration settings */
gRfalAnalogConfigMgmt.configTblSize = configTblSize;
rfalAnalogConfigPtrUpdate(gRfalAnalogConfig);
return ERR_NONE;
#else
// If Analog Configuration Update is to be disabled
NO_WARNING(configTbl);
NO_WARNING(configTblSize);
return ERR_REQUEST;
#endif /* RFAL_FEATURE_DYNAMIC_ANALOG_CONFIG */
}
ReturnCode rfalAnalogConfigListWrite( uint8_t more, const rfalAnalogConfig *config )
{
ReturnCode rfalAnalogConfigListWrite(uint8_t more, const rfalAnalogConfig* config) {
#if RFAL_FEATURE_DYNAMIC_ANALOG_CONFIG
rfalAnalogConfigId configId;
rfalAnalogConfigNum numConfig;
uint8_t configSize;
if (true == gRfalAnalogConfigMgmt.ready)
{ /* First Update to the Configuration list. */
gRfalAnalogConfigMgmt.ready = false; // invalidate the config List
if(true == gRfalAnalogConfigMgmt.ready) { /* First Update to the Configuration list. */
gRfalAnalogConfigMgmt.ready = false; // invalidate the config List
gRfalAnalogConfigMgmt.configTblSize = 0; // Clear the config List
}
configId = GETU16(config->id);
/* Check validity of the Configuration ID. */
if ( (RFAL_ANALOG_CONFIG_TECH_RFU <= RFAL_ANALOG_CONFIG_ID_GET_TECH(configId))
||((RFAL_ANALOG_CONFIG_BITRATE_6780 < RFAL_ANALOG_CONFIG_ID_GET_BITRATE(configId)) && (RFAL_ANALOG_CONFIG_BITRATE_1OF4 > RFAL_ANALOG_CONFIG_ID_GET_BITRATE(configId)))
||(RFAL_ANALOG_CONFIG_BITRATE_1OF256 < RFAL_ANALOG_CONFIG_ID_GET_BITRATE(configId))
)
{
if((RFAL_ANALOG_CONFIG_TECH_RFU <= RFAL_ANALOG_CONFIG_ID_GET_TECH(configId)) ||
((RFAL_ANALOG_CONFIG_BITRATE_6780 < RFAL_ANALOG_CONFIG_ID_GET_BITRATE(configId)) &&
(RFAL_ANALOG_CONFIG_BITRATE_1OF4 > RFAL_ANALOG_CONFIG_ID_GET_BITRATE(configId))) ||
(RFAL_ANALOG_CONFIG_BITRATE_1OF256 < RFAL_ANALOG_CONFIG_ID_GET_BITRATE(configId))) {
rfalAnalogConfigInitialize(); /* Revert to default Analog Configuration */
return ERR_PARAM;
}
numConfig = config->num;
configSize = (uint8_t)(sizeof(rfalAnalogConfigId) + sizeof(rfalAnalogConfigNum) + (numConfig * sizeof(rfalAnalogConfigRegAddrMaskVal)));
configSize =
(uint8_t)(sizeof(rfalAnalogConfigId) + sizeof(rfalAnalogConfigNum) + (numConfig * sizeof(rfalAnalogConfigRegAddrMaskVal)));
/* Check if the Configuration Set exceed the Table size. */
if ( RFAL_ANALOG_CONFIG_TBL_SIZE <= (gRfalAnalogConfigMgmt.configTblSize + configSize) )
{
if(RFAL_ANALOG_CONFIG_TBL_SIZE <= (gRfalAnalogConfigMgmt.configTblSize + configSize)) {
rfalAnalogConfigInitialize(); /* Revert to default Analog Configuration */
return ERR_NOMEM;
}
/* NOTE: Function does not check for the validity of the Register Address. */
ST_MEMCPY(&gRfalAnalogConfig[gRfalAnalogConfigMgmt.configTblSize], (const uint8_t*)config, configSize);
ST_MEMCPY(
&gRfalAnalogConfig[gRfalAnalogConfigMgmt.configTblSize],
(const uint8_t*)config,
configSize);
/* Increment the total size of configuration settings. */
gRfalAnalogConfigMgmt.configTblSize += configSize;
/* Check if it is the last Analog Configuration to load. */
if (RFAL_ANALOG_CONFIG_UPDATE_LAST == more)
{ /* Update the Analog Configuration to the new settings. */
if(RFAL_ANALOG_CONFIG_UPDATE_LAST ==
more) { /* Update the Analog Configuration to the new settings. */
rfalAnalogConfigPtrUpdate(gRfalAnalogConfig);
}
return ERR_NONE;
#else
// If Analog Configuration Update is to be disabled
NO_WARNING(config);
NO_WARNING(more);
return ERR_DISABLED;
#endif /* RFAL_FEATURE_DYNAMIC_ANALOG_CONFIG */
} /* rfalAnalogConfigListUpdate() */
ReturnCode rfalAnalogConfigListReadRaw( uint8_t *tblBuf, uint16_t tblBufLen, uint16_t *configTblSize )
{
ReturnCode
rfalAnalogConfigListReadRaw(uint8_t* tblBuf, uint16_t tblBufLen, uint16_t* configTblSize) {
/* Check if the the current table will fit into the given buffer */
if( tblBufLen < gRfalAnalogConfigMgmt.configTblSize )
{
if(tblBufLen < gRfalAnalogConfigMgmt.configTblSize) {
return ERR_NOMEM;
}
/* Check for invalid parameters */
if( configTblSize == NULL )
{
if(configTblSize == NULL) {
return ERR_PARAM;
}
/* Copy the whole Table to the given buffer */
if( gRfalAnalogConfigMgmt.configTblSize > 0U ) /* MISRA 21.18 */
if(gRfalAnalogConfigMgmt.configTblSize > 0U) /* MISRA 21.18 */
{
ST_MEMCPY( tblBuf, gRfalAnalogConfigMgmt.currentAnalogConfigTbl, gRfalAnalogConfigMgmt.configTblSize );
ST_MEMCPY(
tblBuf,
gRfalAnalogConfigMgmt.currentAnalogConfigTbl,
gRfalAnalogConfigMgmt.configTblSize);
}
*configTblSize = gRfalAnalogConfigMgmt.configTblSize;
return ERR_NONE;
}
ReturnCode rfalAnalogConfigListRead( rfalAnalogConfigOffset *configOffset, uint8_t *more, rfalAnalogConfig *config, rfalAnalogConfigNum numConfig )
{
ReturnCode rfalAnalogConfigListRead(
rfalAnalogConfigOffset* configOffset,
uint8_t* more,
rfalAnalogConfig* config,
rfalAnalogConfigNum numConfig) {
uint16_t configSize;
rfalAnalogConfigOffset offset = *configOffset;
rfalAnalogConfigNum numConfigSet;
/* Check if the number of register-mask-value settings for the respective Configuration ID will fit into the buffer passed in. */
if (gRfalAnalogConfigMgmt.currentAnalogConfigTbl[offset + sizeof(rfalAnalogConfigId)] > numConfig)
{
if(gRfalAnalogConfigMgmt.currentAnalogConfigTbl[offset + sizeof(rfalAnalogConfigId)] >
numConfig) {
return ERR_NOMEM;
}
/* Get the number of Configuration set */
numConfigSet = gRfalAnalogConfigMgmt.currentAnalogConfigTbl[offset + sizeof(rfalAnalogConfigId)];
numConfigSet =
gRfalAnalogConfigMgmt.currentAnalogConfigTbl[offset + sizeof(rfalAnalogConfigId)];
/* Pass Configuration Register-Mask-Value sets */
configSize = (sizeof(rfalAnalogConfigId) + sizeof(rfalAnalogConfigNum) + (uint16_t)(numConfigSet * sizeof(rfalAnalogConfigRegAddrMaskVal)));
ST_MEMCPY( (uint8_t*) config
, &gRfalAnalogConfigMgmt.currentAnalogConfigTbl[offset]
, configSize
);
configSize =
(sizeof(rfalAnalogConfigId) + sizeof(rfalAnalogConfigNum) +
(uint16_t)(numConfigSet * sizeof(rfalAnalogConfigRegAddrMaskVal)));
ST_MEMCPY((uint8_t*)config, &gRfalAnalogConfigMgmt.currentAnalogConfigTbl[offset], configSize);
*configOffset = offset + configSize;
/* Check if it is the last Analog Configuration in the Table.*/
*more = (uint8_t)((*configOffset >= gRfalAnalogConfigMgmt.configTblSize) ? RFAL_ANALOG_CONFIG_UPDATE_LAST
: RFAL_ANALOG_CONFIG_UPDATE_MORE);
*more =
(uint8_t)((*configOffset >= gRfalAnalogConfigMgmt.configTblSize) ? RFAL_ANALOG_CONFIG_UPDATE_LAST : RFAL_ANALOG_CONFIG_UPDATE_MORE);
return ERR_NONE;
} /* rfalAnalogConfigListRead() */
ReturnCode rfalSetAnalogConfig( rfalAnalogConfigId configId )
{
ReturnCode rfalSetAnalogConfig(rfalAnalogConfigId configId) {
rfalAnalogConfigOffset configOffset = 0;
rfalAnalogConfigNum numConfigSet;
const rfalAnalogConfigRegAddrMaskVal *configTbl;
const rfalAnalogConfigRegAddrMaskVal* configTbl;
ReturnCode retCode = ERR_NONE;
rfalAnalogConfigNum i;
if (true != gRfalAnalogConfigMgmt.ready)
{
if(true != gRfalAnalogConfigMgmt.ready) {
return ERR_REQUEST;
}
/* Search LUT for the specific Configuration ID. */
while(true)
{
while(true) {
numConfigSet = rfalAnalogConfigSearch(configId, &configOffset);
if( RFAL_ANALOG_CONFIG_LUT_NOT_FOUND == numConfigSet )
{
if(RFAL_ANALOG_CONFIG_LUT_NOT_FOUND == numConfigSet) {
break;
}
configTbl = (rfalAnalogConfigRegAddrMaskVal *)( (uint32_t)gRfalAnalogConfigMgmt.currentAnalogConfigTbl + (uint32_t)configOffset);
configTbl =
(rfalAnalogConfigRegAddrMaskVal*)((uint32_t)gRfalAnalogConfigMgmt.currentAnalogConfigTbl + (uint32_t)configOffset);
/* Increment the offset to the next index to search from. */
configOffset += (uint16_t)(numConfigSet * sizeof(rfalAnalogConfigRegAddrMaskVal));
if ((gRfalAnalogConfigMgmt.configTblSize + 1U) < configOffset)
{ /* Error check make sure that the we do not access outside the configuration Table Size */
configOffset += (uint16_t)(numConfigSet * sizeof(rfalAnalogConfigRegAddrMaskVal));
if((gRfalAnalogConfigMgmt.configTblSize + 1U) <
configOffset) { /* Error check make sure that the we do not access outside the configuration Table Size */
return ERR_NOMEM;
}
for ( i = 0; i < numConfigSet; i++)
{
if( (GETU16(configTbl[i].addr) & RFAL_TEST_REG) != 0U )
{
EXIT_ON_ERR(retCode, rfalChipChangeTestRegBits( (GETU16(configTbl[i].addr) & ~RFAL_TEST_REG), configTbl[i].mask, configTbl[i].val) );
}
else
{
EXIT_ON_ERR(retCode, rfalChipChangeRegBits( GETU16(configTbl[i].addr), configTbl[i].mask, configTbl[i].val) );
for(i = 0; i < numConfigSet; i++) {
if((GETU16(configTbl[i].addr) & RFAL_TEST_REG) != 0U) {
EXIT_ON_ERR(
retCode,
rfalChipChangeTestRegBits(
(GETU16(configTbl[i].addr) & ~RFAL_TEST_REG),
configTbl[i].mask,
configTbl[i].val));
} else {
EXIT_ON_ERR(
retCode,
rfalChipChangeRegBits(
GETU16(configTbl[i].addr), configTbl[i].mask, configTbl[i].val));
}
}
} /* while(found Analog Config Id) */
return retCode;
} /* rfalSetAnalogConfig() */
uint16_t rfalAnalogConfigGenModeID( rfalMode md, rfalBitRate br, uint16_t dir )
{
uint16_t rfalAnalogConfigGenModeID(rfalMode md, rfalBitRate br, uint16_t dir) {
uint16_t id;
/* Assign Poll/Listen Mode */
id = ((md >= RFAL_MODE_LISTEN_NFCA) ? RFAL_ANALOG_CONFIG_LISTEN : RFAL_ANALOG_CONFIG_POLL);
/* Assign Technology */
switch( md )
{
case RFAL_MODE_POLL_NFCA:
case RFAL_MODE_POLL_NFCA_T1T:
case RFAL_MODE_LISTEN_NFCA:
id |= RFAL_ANALOG_CONFIG_TECH_NFCA;
break;
case RFAL_MODE_POLL_NFCB:
case RFAL_MODE_POLL_B_PRIME:
case RFAL_MODE_POLL_B_CTS:
case RFAL_MODE_LISTEN_NFCB:
id |= RFAL_ANALOG_CONFIG_TECH_NFCB;
break;
case RFAL_MODE_POLL_NFCF:
case RFAL_MODE_LISTEN_NFCF:
id |= RFAL_ANALOG_CONFIG_TECH_NFCF;
break;
case RFAL_MODE_POLL_NFCV:
case RFAL_MODE_POLL_PICOPASS:
id |= RFAL_ANALOG_CONFIG_TECH_NFCV;
break;
case RFAL_MODE_POLL_ACTIVE_P2P:
case RFAL_MODE_LISTEN_ACTIVE_P2P:
id |= RFAL_ANALOG_CONFIG_TECH_AP2P;
break;
default:
id = RFAL_ANALOG_CONFIG_TECH_CHIP;
break;
switch(md) {
case RFAL_MODE_POLL_NFCA:
case RFAL_MODE_POLL_NFCA_T1T:
case RFAL_MODE_LISTEN_NFCA:
id |= RFAL_ANALOG_CONFIG_TECH_NFCA;
break;
case RFAL_MODE_POLL_NFCB:
case RFAL_MODE_POLL_B_PRIME:
case RFAL_MODE_POLL_B_CTS:
case RFAL_MODE_LISTEN_NFCB:
id |= RFAL_ANALOG_CONFIG_TECH_NFCB;
break;
case RFAL_MODE_POLL_NFCF:
case RFAL_MODE_LISTEN_NFCF:
id |= RFAL_ANALOG_CONFIG_TECH_NFCF;
break;
case RFAL_MODE_POLL_NFCV:
case RFAL_MODE_POLL_PICOPASS:
id |= RFAL_ANALOG_CONFIG_TECH_NFCV;
break;
case RFAL_MODE_POLL_ACTIVE_P2P:
case RFAL_MODE_LISTEN_ACTIVE_P2P:
id |= RFAL_ANALOG_CONFIG_TECH_AP2P;
break;
default:
id = RFAL_ANALOG_CONFIG_TECH_CHIP;
break;
}
/* Assign Bitrate */
id |= (((((uint16_t)(br) >= (uint16_t)RFAL_BR_52p97) ? (uint16_t)(br) : ((uint16_t)(br)+1U)) << RFAL_ANALOG_CONFIG_BITRATE_SHIFT) & RFAL_ANALOG_CONFIG_BITRATE_MASK);
id |=
(((((uint16_t)(br) >= (uint16_t)RFAL_BR_52p97) ? (uint16_t)(br) : ((uint16_t)(br) + 1U))
<< RFAL_ANALOG_CONFIG_BITRATE_SHIFT) &
RFAL_ANALOG_CONFIG_BITRATE_MASK);
/* Assign Direction */
id |= ((dir<<RFAL_ANALOG_CONFIG_DIRECTION_SHIFT) & RFAL_ANALOG_CONFIG_DIRECTION_MASK);
id |= ((dir << RFAL_ANALOG_CONFIG_DIRECTION_SHIFT) & RFAL_ANALOG_CONFIG_DIRECTION_MASK);
return id;
} /* rfalAnalogConfigGenModeID() */
/*
@@ -413,16 +412,13 @@ uint16_t rfalAnalogConfigGenModeID( rfalMode md, rfalBitRate br, uint16_t dir )
*****************************************************************************
*/
#if RFAL_FEATURE_DYNAMIC_ANALOG_CONFIG
static void rfalAnalogConfigPtrUpdate( const uint8_t* analogConfigTbl )
{
static void rfalAnalogConfigPtrUpdate(const uint8_t* analogConfigTbl) {
gRfalAnalogConfigMgmt.currentAnalogConfigTbl = analogConfigTbl;
gRfalAnalogConfigMgmt.ready = true;
} /* rfalAnalogConfigPtrUpdate() */
#endif /* RFAL_FEATURE_DYNAMIC_ANALOG_CONFIG */
/*!
*****************************************************************************
* \brief Search the Analog Configuration LUT for a specific Configuration ID.
@@ -436,44 +432,45 @@ static void rfalAnalogConfigPtrUpdate( const uint8_t* analogConfigTbl )
* \return #RFAL_ANALOG_CONFIG_LUT_NOT_FOUND in case Configuration ID is not found.
*****************************************************************************
*/
static rfalAnalogConfigNum rfalAnalogConfigSearch( rfalAnalogConfigId configId, uint16_t *configOffset )
{
static rfalAnalogConfigNum
rfalAnalogConfigSearch(rfalAnalogConfigId configId, uint16_t* configOffset) {
rfalAnalogConfigId foundConfigId;
rfalAnalogConfigId configIdMaskVal;
const uint8_t *configTbl;
const uint8_t *currentConfigTbl;
const uint8_t* configTbl;
const uint8_t* currentConfigTbl;
uint16_t i;
currentConfigTbl = gRfalAnalogConfigMgmt.currentAnalogConfigTbl;
configIdMaskVal = ((RFAL_ANALOG_CONFIG_POLL_LISTEN_MODE_MASK | RFAL_ANALOG_CONFIG_BITRATE_MASK)
|((RFAL_ANALOG_CONFIG_TECH_CHIP == RFAL_ANALOG_CONFIG_ID_GET_TECH(configId)) ? (RFAL_ANALOG_CONFIG_TECH_MASK | RFAL_ANALOG_CONFIG_CHIP_SPECIFIC_MASK) : configId)
|((RFAL_ANALOG_CONFIG_NO_DIRECTION == RFAL_ANALOG_CONFIG_ID_GET_DIRECTION(configId)) ? RFAL_ANALOG_CONFIG_DIRECTION_MASK : configId)
);
configIdMaskVal =
((RFAL_ANALOG_CONFIG_POLL_LISTEN_MODE_MASK | RFAL_ANALOG_CONFIG_BITRATE_MASK) |
((RFAL_ANALOG_CONFIG_TECH_CHIP == RFAL_ANALOG_CONFIG_ID_GET_TECH(configId)) ?
(RFAL_ANALOG_CONFIG_TECH_MASK | RFAL_ANALOG_CONFIG_CHIP_SPECIFIC_MASK) :
configId) |
((RFAL_ANALOG_CONFIG_NO_DIRECTION == RFAL_ANALOG_CONFIG_ID_GET_DIRECTION(configId)) ?
RFAL_ANALOG_CONFIG_DIRECTION_MASK :
configId));
/* When specific ConfigIDs are to be used, override search mask */
if( (RFAL_ANALOG_CONFIG_ID_GET_DIRECTION(configId) == RFAL_ANALOG_CONFIG_DPO) )
{
configIdMaskVal = (RFAL_ANALOG_CONFIG_POLL_LISTEN_MODE_MASK | RFAL_ANALOG_CONFIG_TECH_MASK | RFAL_ANALOG_CONFIG_BITRATE_MASK | RFAL_ANALOG_CONFIG_DIRECTION_MASK);
if((RFAL_ANALOG_CONFIG_ID_GET_DIRECTION(configId) == RFAL_ANALOG_CONFIG_DPO)) {
configIdMaskVal =
(RFAL_ANALOG_CONFIG_POLL_LISTEN_MODE_MASK | RFAL_ANALOG_CONFIG_TECH_MASK |
RFAL_ANALOG_CONFIG_BITRATE_MASK | RFAL_ANALOG_CONFIG_DIRECTION_MASK);
}
i = *configOffset;
while (i < gRfalAnalogConfigMgmt.configTblSize)
{
while(i < gRfalAnalogConfigMgmt.configTblSize) {
configTbl = &currentConfigTbl[i];
foundConfigId = GETU16(configTbl);
if (configId == (foundConfigId & configIdMaskVal))
{
*configOffset = (uint16_t)(i + sizeof(rfalAnalogConfigId) + sizeof(rfalAnalogConfigNum));
if(configId == (foundConfigId & configIdMaskVal)) {
*configOffset =
(uint16_t)(i + sizeof(rfalAnalogConfigId) + sizeof(rfalAnalogConfigNum));
return configTbl[sizeof(rfalAnalogConfigId)];
}
/* If Config Id does not match, increment to next Configuration Id */
i += (uint16_t)( sizeof(rfalAnalogConfigId) + sizeof(rfalAnalogConfigNum)
+ (configTbl[sizeof(rfalAnalogConfigId)] * sizeof(rfalAnalogConfigRegAddrMaskVal) )
);
i +=
(uint16_t)(sizeof(rfalAnalogConfigId) + sizeof(rfalAnalogConfigNum) + (configTbl[sizeof(rfalAnalogConfigId)] * sizeof(rfalAnalogConfigRegAddrMaskVal)));
} /* for */
return RFAL_ANALOG_CONFIG_LUT_NOT_FOUND;
} /* rfalAnalogConfigSearch() */
+6 -10
View File
@@ -53,13 +53,11 @@ static uint16_t rfalCrcUpdateCcitt(uint16_t crcSeed, uint8_t dataByte);
* GLOBAL FUNCTIONS
******************************************************************************
*/
uint16_t rfalCrcCalculateCcitt(uint16_t preloadValue, const uint8_t* buf, uint16_t length)
{
uint16_t rfalCrcCalculateCcitt(uint16_t preloadValue, const uint8_t* buf, uint16_t length) {
uint16_t crc = preloadValue;
uint16_t index;
for (index = 0; index < length; index++)
{
for(index = 0; index < length; index++) {
crc = rfalCrcUpdateCcitt(crc, buf[index]);
}
@@ -71,16 +69,14 @@ uint16_t rfalCrcCalculateCcitt(uint16_t preloadValue, const uint8_t* buf, uint16
* LOCAL FUNCTIONS
******************************************************************************
*/
static uint16_t rfalCrcUpdateCcitt(uint16_t crcSeed, uint8_t dataByte)
{
static uint16_t rfalCrcUpdateCcitt(uint16_t crcSeed, uint8_t dataByte) {
uint16_t crc = crcSeed;
uint8_t dat = dataByte;
uint8_t dat = dataByte;
dat ^= (uint8_t)(crc & 0xFFU);
dat ^= (dat << 4);
crc = (crc >> 8)^(((uint16_t) dat) << 8)^(((uint16_t) dat) << 3)^(((uint16_t) dat) >> 4);
crc = (crc >> 8) ^ (((uint16_t)dat) << 8) ^ (((uint16_t)dat) << 3) ^ (((uint16_t)dat) >> 4);
return crc;
}
+74 -101
View File
@@ -25,7 +25,7 @@
* $Revision: $
* LANGUAGE: ISO C99
*/
/*! \file rfal_dpo.c
*
* \author Martin Zechleitner
@@ -47,7 +47,6 @@
#include "rfal_analogConfig.h"
#include "utils.h"
/*
******************************************************************************
* ENABLE SWITCH
@@ -55,204 +54,178 @@
*/
#ifndef RFAL_FEATURE_DPO
#define RFAL_FEATURE_DPO false /* Dynamic Power Module configuration missing. Disabled by default */
#define RFAL_FEATURE_DPO \
false /* Dynamic Power Module configuration missing. Disabled by default */
#endif
#if RFAL_FEATURE_DPO
/*
******************************************************************************
* DEFINES
******************************************************************************
*/
#define RFAL_DPO_ANALOGCONFIG_SHIFT 13U
#define RFAL_DPO_ANALOGCONFIG_MASK 0x6000U
#define RFAL_DPO_ANALOGCONFIG_SHIFT 13U
#define RFAL_DPO_ANALOGCONFIG_MASK 0x6000U
/*
******************************************************************************
* LOCAL DATA TYPES
******************************************************************************
*/
static bool gRfalDpoIsEnabled = false;
static uint8_t* gRfalCurrentDpo;
static uint8_t gRfalDpoTableEntries;
static uint8_t gRfalDpo[RFAL_DPO_TABLE_SIZE_MAX];
static uint8_t gRfalDpoTableEntry;
static rfalDpoMeasureFunc gRfalDpoMeasureCallback = NULL;
static bool gRfalDpoIsEnabled = false;
static uint8_t* gRfalCurrentDpo;
static uint8_t gRfalDpoTableEntries;
static uint8_t gRfalDpo[RFAL_DPO_TABLE_SIZE_MAX];
static uint8_t gRfalDpoTableEntry;
static rfalDpoMeasureFunc gRfalDpoMeasureCallback = NULL;
/*
******************************************************************************
* GLOBAL FUNCTIONS
******************************************************************************
*/
void rfalDpoInitialize( void )
{
void rfalDpoInitialize(void) {
/* Use the default Dynamic Power values */
gRfalCurrentDpo = (uint8_t*) rfalDpoDefaultSettings;
gRfalCurrentDpo = (uint8_t*)rfalDpoDefaultSettings;
gRfalDpoTableEntries = (sizeof(rfalDpoDefaultSettings) / RFAL_DPO_TABLE_PARAMETER);
ST_MEMCPY( gRfalDpo, gRfalCurrentDpo, sizeof(rfalDpoDefaultSettings) );
ST_MEMCPY(gRfalDpo, gRfalCurrentDpo, sizeof(rfalDpoDefaultSettings));
/* by default use amplitude measurement */
gRfalDpoMeasureCallback = rfalChipMeasureAmplitude;
/* by default DPO is disabled */
gRfalDpoIsEnabled = false;
gRfalDpoTableEntry = 0;
}
void rfalDpoSetMeasureCallback( rfalDpoMeasureFunc pMeasureFunc )
{
gRfalDpoMeasureCallback = pMeasureFunc;
void rfalDpoSetMeasureCallback(rfalDpoMeasureFunc pMeasureFunc) {
gRfalDpoMeasureCallback = pMeasureFunc;
}
/*******************************************************************************/
ReturnCode rfalDpoTableWrite( rfalDpoEntry* powerTbl, uint8_t powerTblEntries )
{
ReturnCode rfalDpoTableWrite(rfalDpoEntry* powerTbl, uint8_t powerTblEntries) {
uint8_t entry = 0;
/* check if the table size parameter is too big */
if( (powerTblEntries * RFAL_DPO_TABLE_PARAMETER) > RFAL_DPO_TABLE_SIZE_MAX)
{
if((powerTblEntries * RFAL_DPO_TABLE_PARAMETER) > RFAL_DPO_TABLE_SIZE_MAX) {
return ERR_NOMEM;
}
/* check if the first increase entry is 0xFF */
if( (powerTblEntries == 0) || (powerTbl == NULL) )
{
if((powerTblEntries == 0) || (powerTbl == NULL)) {
return ERR_PARAM;
}
/* check if the entries of the dynamic power table are valid */
for (entry = 0; entry < powerTblEntries; entry++)
{
if(powerTbl[entry].inc < powerTbl[entry].dec)
{
for(entry = 0; entry < powerTblEntries; entry++) {
if(powerTbl[entry].inc < powerTbl[entry].dec) {
return ERR_PARAM;
}
}
/* copy the data set */
ST_MEMCPY( gRfalDpo, powerTbl, (powerTblEntries * RFAL_DPO_TABLE_PARAMETER) );
ST_MEMCPY(gRfalDpo, powerTbl, (powerTblEntries * RFAL_DPO_TABLE_PARAMETER));
gRfalCurrentDpo = gRfalDpo;
gRfalDpoTableEntries = powerTblEntries;
if(gRfalDpoTableEntry > powerTblEntries)
{
/* is always greater then zero, otherwise we already returned ERR_PARAM */
gRfalDpoTableEntry = (powerTblEntries - 1);
if(gRfalDpoTableEntry > powerTblEntries) {
/* is always greater then zero, otherwise we already returned ERR_PARAM */
gRfalDpoTableEntry = (powerTblEntries - 1);
}
return ERR_NONE;
}
/*******************************************************************************/
ReturnCode rfalDpoTableRead( rfalDpoEntry* tblBuf, uint8_t tblBufEntries, uint8_t* tableEntries )
{
ReturnCode rfalDpoTableRead(rfalDpoEntry* tblBuf, uint8_t tblBufEntries, uint8_t* tableEntries) {
/* wrong request */
if( (tblBuf == NULL) || (tblBufEntries < gRfalDpoTableEntries) || (tableEntries == NULL) )
{
if((tblBuf == NULL) || (tblBufEntries < gRfalDpoTableEntries) || (tableEntries == NULL)) {
return ERR_PARAM;
}
/* Copy the whole Table to the given buffer */
ST_MEMCPY( tblBuf, gRfalCurrentDpo, (tblBufEntries * RFAL_DPO_TABLE_PARAMETER) );
ST_MEMCPY(tblBuf, gRfalCurrentDpo, (tblBufEntries * RFAL_DPO_TABLE_PARAMETER));
*tableEntries = gRfalDpoTableEntries;
return ERR_NONE;
}
/*******************************************************************************/
ReturnCode rfalDpoAdjust( void )
{
uint8_t refValue = 0;
uint16_t modeID;
ReturnCode rfalDpoAdjust(void) {
uint8_t refValue = 0;
uint16_t modeID;
rfalBitRate br;
rfalDpoEntry* dpoTable = (rfalDpoEntry*) gRfalCurrentDpo;
rfalDpoEntry* dpoTable = (rfalDpoEntry*)gRfalCurrentDpo;
/* Check if the Power Adjustment is disabled and *
* if the callback to the measurement method is properly set */
if( (gRfalCurrentDpo == NULL) || (!gRfalDpoIsEnabled) || (gRfalDpoMeasureCallback == NULL) )
{
if((gRfalCurrentDpo == NULL) || (!gRfalDpoIsEnabled) || (gRfalDpoMeasureCallback == NULL)) {
return ERR_PARAM;
}
/* Ensure that the current mode is Passive Poller */
if( !rfalIsModePassivePoll( rfalGetMode() ) )
{
if(!rfalIsModePassivePoll(rfalGetMode())) {
return ERR_WRONG_STATE;
}
/* Ensure a proper measure reference value */
if( ERR_NONE != gRfalDpoMeasureCallback( &refValue ) )
{
if(ERR_NONE != gRfalDpoMeasureCallback(&refValue)) {
return ERR_IO;
}
if( refValue >= dpoTable[gRfalDpoTableEntry].inc )
{ /* Increase the output power */
if(refValue >= dpoTable[gRfalDpoTableEntry].inc) { /* Increase the output power */
/* the top of the table represents the highest amplitude value*/
if( gRfalDpoTableEntry == 0 )
{
if(gRfalDpoTableEntry == 0) {
/* maximum driver value has been reached */
}
else
{
} else {
/* go up in the table to decrease the driver resistance */
gRfalDpoTableEntry--;
}
}
else if(refValue <= dpoTable[gRfalDpoTableEntry].dec)
{ /* decrease the output power */
} else if(refValue <= dpoTable[gRfalDpoTableEntry].dec) { /* decrease the output power */
/* The bottom is the highest possible value */
if( (gRfalDpoTableEntry + 1) >= gRfalDpoTableEntries)
{
if((gRfalDpoTableEntry + 1) >= gRfalDpoTableEntries) {
/* minimum driver value has been reached */
}
else
{
} else {
/* go down in the table to increase the driver resistance */
gRfalDpoTableEntry++;
}
}
else
{
} else {
/* Fall through to always write dpo and its associated analog configs */
}
/* Get the new value for RFO resistance form the table and apply the new RFO resistance setting */
rfalChipSetRFO( dpoTable[gRfalDpoTableEntry].rfoRes );
/* Get the new value for RFO resistance form the table and apply the new RFO resistance setting */
rfalChipSetRFO(dpoTable[gRfalDpoTableEntry].rfoRes);
/* Apply the DPO Analog Config according to this treshold */
/* Technology field is being extended for DPO: 2msb are used for treshold step (only 4 allowed) */
rfalGetBitRate( &br, NULL ); /* Obtain current Tx bitrate */
modeID = rfalAnalogConfigGenModeID( rfalGetMode(), br, RFAL_ANALOG_CONFIG_DPO ); /* Generate Analog Config mode ID */
modeID |= ((gRfalDpoTableEntry << RFAL_DPO_ANALOGCONFIG_SHIFT) & RFAL_DPO_ANALOGCONFIG_MASK); /* Add DPO treshold step|level */
rfalSetAnalogConfig( modeID ); /* Apply DPO Analog Config */
rfalGetBitRate(&br, NULL); /* Obtain current Tx bitrate */
modeID = rfalAnalogConfigGenModeID(
rfalGetMode(), br, RFAL_ANALOG_CONFIG_DPO); /* Generate Analog Config mode ID */
modeID |=
((gRfalDpoTableEntry << RFAL_DPO_ANALOGCONFIG_SHIFT) &
RFAL_DPO_ANALOGCONFIG_MASK); /* Add DPO treshold step|level */
rfalSetAnalogConfig(modeID); /* Apply DPO Analog Config */
return ERR_NONE;
}
/*******************************************************************************/
rfalDpoEntry* rfalDpoGetCurrentTableEntry( void )
{
rfalDpoEntry* dpoTable = (rfalDpoEntry*) gRfalCurrentDpo;
rfalDpoEntry* rfalDpoGetCurrentTableEntry(void) {
rfalDpoEntry* dpoTable = (rfalDpoEntry*)gRfalCurrentDpo;
return &dpoTable[gRfalDpoTableEntry];
}
/*******************************************************************************/
void rfalDpoSetEnabled( bool enable )
{
void rfalDpoSetEnabled(bool enable) {
gRfalDpoIsEnabled = enable;
}
/*******************************************************************************/
bool rfalDpoIsEnabled( void )
{
bool rfalDpoIsEnabled(void) {
return gRfalDpoIsEnabled;
}
+181 -200
View File
@@ -50,7 +50,7 @@
*/
#ifndef RFAL_FEATURE_NFCV
#define RFAL_FEATURE_NFCV false /* NFC-V module configuration missing. Disabled by default */
#define RFAL_FEATURE_NFCV false /* NFC-V module configuration missing. Disabled by default */
#endif
#if RFAL_FEATURE_NFCV
@@ -61,22 +61,22 @@
******************************************************************************
*/
#define ISO_15693_DEBUG(...) /*!< Macro for the log method */
#define ISO_15693_DEBUG(...) /*!< Macro for the log method */
/*
******************************************************************************
* LOCAL DEFINES
******************************************************************************
*/
#define ISO15693_DAT_SOF_1_4 0x21 /* LSB constants */
#define ISO15693_DAT_EOF_1_4 0x04
#define ISO15693_DAT_00_1_4 0x02
#define ISO15693_DAT_01_1_4 0x08
#define ISO15693_DAT_10_1_4 0x20
#define ISO15693_DAT_11_1_4 0x80
#define ISO15693_DAT_SOF_1_4 0x21 /* LSB constants */
#define ISO15693_DAT_EOF_1_4 0x04
#define ISO15693_DAT_00_1_4 0x02
#define ISO15693_DAT_01_1_4 0x08
#define ISO15693_DAT_10_1_4 0x20
#define ISO15693_DAT_11_1_4 0x80
#define ISO15693_DAT_SOF_1_256 0x81
#define ISO15693_DAT_EOF_1_256 0x04
#define ISO15693_DAT_SOF_1_256 0x81
#define ISO15693_DAT_EOF_1_256 0x04
#define ISO15693_DAT_SLOT0_1_256 0x02
#define ISO15693_DAT_SLOT1_1_256 0x08
#define ISO15693_DAT_SLOT2_1_256 0x20
@@ -84,8 +84,8 @@
#define ISO15693_PHY_DAT_MANCHESTER_1 0xaaaa
#define ISO15693_PHY_BIT_BUFFER_SIZE 1000 /*!< size of the receiving buffer. Might be adjusted if longer datastreams are expected. */
#define ISO15693_PHY_BIT_BUFFER_SIZE \
1000 /*!< size of the receiving buffer. Might be adjusted if longer datastreams are expected. */
/*
******************************************************************************
@@ -99,35 +99,39 @@ static iso15693PhyConfig_t iso15693PhyConfig; /*!< current phy configuration */
* LOCAL FUNCTION PROTOTYPES
******************************************************************************
*/
static ReturnCode iso15693PhyVCDCode1Of4(const uint8_t data, uint8_t* outbuffer, uint16_t maxOutBufLen, uint16_t* outBufLen);
static ReturnCode iso15693PhyVCDCode1Of256(const uint8_t data, uint8_t* outbuffer, uint16_t maxOutBufLen, uint16_t* outBufLen);
static ReturnCode iso15693PhyVCDCode1Of4(
const uint8_t data,
uint8_t* outbuffer,
uint16_t maxOutBufLen,
uint16_t* outBufLen);
static ReturnCode iso15693PhyVCDCode1Of256(
const uint8_t data,
uint8_t* outbuffer,
uint16_t maxOutBufLen,
uint16_t* outBufLen);
/*
******************************************************************************
* GLOBAL FUNCTIONS
******************************************************************************
*/
ReturnCode iso15693PhyConfigure(const iso15693PhyConfig_t* config, const struct iso15693StreamConfig ** needed_stream_config )
{
static struct iso15693StreamConfig stream_config = { /* MISRA 8.9 */
.useBPSK = 0, /* 0: subcarrier, 1:BPSK */
.din = 5, /* 2^5*fc = 423750 Hz: divider for the in subcarrier frequency */
.dout = 7, /*!< 2^7*fc = 105937 : divider for the in subcarrier frequency */
ReturnCode iso15693PhyConfigure(
const iso15693PhyConfig_t* config,
const struct iso15693StreamConfig** needed_stream_config) {
static struct iso15693StreamConfig stream_config = {
/* MISRA 8.9 */
.useBPSK = 0, /* 0: subcarrier, 1:BPSK */
.din = 5, /* 2^5*fc = 423750 Hz: divider for the in subcarrier frequency */
.dout = 7, /*!< 2^7*fc = 105937 : divider for the in subcarrier frequency */
.report_period_length = 3, /*!< 8=2^3 the length of the reporting period */
};
/* make a copy of the configuration */
ST_MEMCPY( (uint8_t*)&iso15693PhyConfig, (const uint8_t*)config, sizeof(iso15693PhyConfig_t));
if ( config->speedMode <= 3U)
{ /* If valid speed mode adjust report period accordingly */
ST_MEMCPY((uint8_t*)&iso15693PhyConfig, (const uint8_t*)config, sizeof(iso15693PhyConfig_t));
if(config->speedMode <= 3U) { /* If valid speed mode adjust report period accordingly */
stream_config.report_period_length = (3U - (uint8_t)config->speedMode);
}
else
{ /* If invalid default to normal (high) speed */
} else { /* If invalid default to normal (high) speed */
stream_config.report_period_length = 3;
}
@@ -136,119 +140,118 @@ ReturnCode iso15693PhyConfigure(const iso15693PhyConfig_t* config, const struct
return ERR_NONE;
}
ReturnCode iso15693PhyGetConfiguration(iso15693PhyConfig_t* config)
{
ReturnCode iso15693PhyGetConfiguration(iso15693PhyConfig_t* config) {
ST_MEMCPY(config, &iso15693PhyConfig, sizeof(iso15693PhyConfig_t));
return ERR_NONE;
}
ReturnCode iso15693VCDCode(uint8_t* buffer, uint16_t length, bool sendCrc, bool sendFlags, bool picopassMode,
uint16_t *subbit_total_length, uint16_t *offset,
uint8_t* outbuf, uint16_t outBufSize, uint16_t* actOutBufSize)
{
ReturnCode iso15693VCDCode(
uint8_t* buffer,
uint16_t length,
bool sendCrc,
bool sendFlags,
bool picopassMode,
uint16_t* subbit_total_length,
uint16_t* offset,
uint8_t* outbuf,
uint16_t outBufSize,
uint16_t* actOutBufSize) {
ReturnCode err = ERR_NONE;
uint8_t eof, sof;
uint8_t transbuf[2];
uint16_t crc = 0;
ReturnCode (*txFunc)(const uint8_t data, uint8_t* outbuffer, uint16_t maxOutBufLen, uint16_t* outBufLen);
ReturnCode (*txFunc)(
const uint8_t data, uint8_t* outbuffer, uint16_t maxOutBufLen, uint16_t* outBufLen);
uint8_t crc_len;
uint8_t* outputBuf;
uint16_t outputBufSize;
crc_len = (uint8_t)((sendCrc)?2:0);
crc_len = (uint8_t)((sendCrc) ? 2 : 0);
*actOutBufSize = 0;
if (ISO15693_VCD_CODING_1_4 == iso15693PhyConfig.coding)
{
if(ISO15693_VCD_CODING_1_4 == iso15693PhyConfig.coding) {
sof = ISO15693_DAT_SOF_1_4;
eof = ISO15693_DAT_EOF_1_4;
txFunc = iso15693PhyVCDCode1Of4;
*subbit_total_length = (
( 1U /* SOF */
+ ((length + (uint16_t)crc_len) * 4U)
+ 1U) /* EOF */
);
if (outBufSize < 5U) { /* 5 should be safe: enough for sof + 1byte data in 1of4 */
*subbit_total_length =
((1U /* SOF */
+ ((length + (uint16_t)crc_len) * 4U) + 1U) /* EOF */
);
if(outBufSize < 5U) { /* 5 should be safe: enough for sof + 1byte data in 1of4 */
return ERR_NOMEM;
}
}
else
{
} else {
sof = ISO15693_DAT_SOF_1_256;
eof = ISO15693_DAT_EOF_1_256;
txFunc = iso15693PhyVCDCode1Of256;
*subbit_total_length = (
( 1U /* SOF */
+ ((length + (uint16_t)crc_len) * 64U)
+ 1U) /* EOF */
);
*subbit_total_length =
((1U /* SOF */
+ ((length + (uint16_t)crc_len) * 64U) + 1U) /* EOF */
);
if (*offset != 0U)
{
if (outBufSize < 64U) { /* 64 should be safe: enough a single byte data in 1of256 */
if(*offset != 0U) {
if(outBufSize < 64U) { /* 64 should be safe: enough a single byte data in 1of256 */
return ERR_NOMEM;
}
}
else
{
if (outBufSize < 65U) { /* At beginning of a frame we need at least 65 bytes to start: enough for sof + 1byte data in 1of256 */
} else {
if(outBufSize <
65U) { /* At beginning of a frame we need at least 65 bytes to start: enough for sof + 1byte data in 1of256 */
return ERR_NOMEM;
}
}
}
if (length == 0U)
{
if(length == 0U) {
*subbit_total_length = 1;
}
if ((length != 0U) && (0U == *offset) && sendFlags && !picopassMode)
{
if((length != 0U) && (0U == *offset) && sendFlags && !picopassMode) {
/* set high datarate flag */
buffer[0] |= (uint8_t)ISO15693_REQ_FLAG_HIGH_DATARATE;
/* clear sub-carrier flag - we only support single sub-carrier */
buffer[0] = (uint8_t)(buffer[0] & ~ISO15693_REQ_FLAG_TWO_SUBCARRIERS); /* MISRA 10.3 */
buffer[0] = (uint8_t)(buffer[0] & ~ISO15693_REQ_FLAG_TWO_SUBCARRIERS); /* MISRA 10.3 */
}
outputBuf = outbuf; /* MISRA 17.8: Use intermediate variable */
outputBufSize = outBufSize; /* MISRA 17.8: Use intermediate variable */
outputBuf = outbuf; /* MISRA 17.8: Use intermediate variable */
outputBufSize = outBufSize; /* MISRA 17.8: Use intermediate variable */
/* Send SOF if at 0 offset */
if ((length != 0U) && (0U == *offset))
{
*outputBuf = sof;
if((length != 0U) && (0U == *offset)) {
*outputBuf = sof;
(*actOutBufSize)++;
outputBufSize--;
outputBuf++;
}
while ((*offset < length) && (err == ERR_NONE))
{
while((*offset < length) && (err == ERR_NONE)) {
uint16_t filled_size;
/* send data */
err = txFunc(buffer[*offset], outputBuf, outputBufSize, &filled_size);
(*actOutBufSize) += filled_size;
outputBuf = &outputBuf[filled_size]; /* MISRA 18.4: Avoid pointer arithmetic */
outputBuf = &outputBuf[filled_size]; /* MISRA 18.4: Avoid pointer arithmetic */
outputBufSize -= filled_size;
if (err == ERR_NONE) {
if(err == ERR_NONE) {
(*offset)++;
}
}
if (err != ERR_NONE) {
if(err != ERR_NONE) {
return ERR_AGAIN;
}
while ((err == ERR_NONE) && sendCrc && (*offset < (length + 2U)))
{
while((err == ERR_NONE) && sendCrc && (*offset < (length + 2U))) {
uint16_t filled_size;
if (0U==crc)
{
crc = rfalCrcCalculateCcitt( (uint16_t) ((picopassMode) ? 0xE012U : 0xFFFFU), /* In PicoPass Mode a different Preset Value is used */
((picopassMode) ? (buffer + 1U) : buffer), /* CMD byte is not taken into account in PicoPass mode */
((picopassMode) ? (length - 1U) : length)); /* CMD byte is not taken into account in PicoPass mode */
if(0U == crc) {
crc = rfalCrcCalculateCcitt(
(uint16_t)((picopassMode) ? 0xE012U : 0xFFFFU), /* In PicoPass Mode a different Preset Value is used */
((picopassMode) ?
(buffer + 1U) :
buffer), /* CMD byte is not taken into account in PicoPass mode */
((picopassMode) ?
(length - 1U) :
length)); /* CMD byte is not taken into account in PicoPass mode */
crc = (uint16_t)((picopassMode) ? crc : ~crc);
}
/* send crc */
@@ -256,41 +259,37 @@ ReturnCode iso15693VCDCode(uint8_t* buffer, uint16_t length, bool sendCrc, bool
transbuf[1] = (uint8_t)((crc >> 8) & 0xffU);
err = txFunc(transbuf[*offset - length], outputBuf, outputBufSize, &filled_size);
(*actOutBufSize) += filled_size;
outputBuf = &outputBuf[filled_size]; /* MISRA 18.4: Avoid pointer arithmetic */
outputBuf = &outputBuf[filled_size]; /* MISRA 18.4: Avoid pointer arithmetic */
outputBufSize -= filled_size;
if (err == ERR_NONE) {
if(err == ERR_NONE) {
(*offset)++;
}
}
if (err != ERR_NONE) {
if(err != ERR_NONE) {
return ERR_AGAIN;
}
if ((!sendCrc && (*offset == length))
|| (sendCrc && (*offset == (length + 2U))))
{
*outputBuf = eof;
if((!sendCrc && (*offset == length)) || (sendCrc && (*offset == (length + 2U)))) {
*outputBuf = eof;
(*actOutBufSize)++;
outputBufSize--;
outputBuf++;
}
else
{
} else {
return ERR_AGAIN;
}
return err;
}
ReturnCode iso15693VICCDecode(const uint8_t *inBuf,
uint16_t inBufLen,
uint8_t* outBuf,
uint16_t outBufLen,
uint16_t* outBufPos,
uint16_t* bitsBeforeCol,
uint16_t ignoreBits,
bool picopassMode )
{
ReturnCode iso15693VICCDecode(
const uint8_t* inBuf,
uint16_t inBufLen,
uint8_t* outBuf,
uint16_t outBufLen,
uint16_t* outBufPos,
uint16_t* bitsBeforeCol,
uint16_t ignoreBits,
bool picopassMode) {
ReturnCode err = ERR_NONE;
uint16_t crc;
uint16_t mp; /* Current bit position in manchester bit inBuf*/
@@ -300,68 +299,56 @@ ReturnCode iso15693VICCDecode(const uint8_t *inBuf,
*outBufPos = 0;
/* first check for valid SOF. Since it starts with 3 unmodulated pulses it is 0x17. */
if ((inBuf[0] & 0x1fU) != 0x17U)
{
ISO_15693_DEBUG("0x%x\n", iso15693PhyBitBuffer[0]);
return ERR_FRAMING;
if((inBuf[0] & 0x1fU) != 0x17U) {
ISO_15693_DEBUG("0x%x\n", iso15693PhyBitBuffer[0]);
return ERR_FRAMING;
}
ISO_15693_DEBUG("SOF\n");
if (outBufLen == 0U)
{
if(outBufLen == 0U) {
return ERR_NONE;
}
mp = 5; /* 5 bits were SOF, now manchester starts: 2 bits per payload bit */
bp = 0;
ST_MEMSET(outBuf,0,outBufLen);
ST_MEMSET(outBuf, 0, outBufLen);
if (inBufLen == 0U)
{
if(inBufLen == 0U) {
return ERR_CRC;
}
for ( ; mp < ((inBufLen * 8U) - 2U); mp+=2U )
{
for(; mp < ((inBufLen * 8U) - 2U); mp += 2U) {
bool isEOF = false;
uint8_t man;
man = (inBuf[mp/8U] >> (mp%8U)) & 0x1U;
man |= ((inBuf[(mp+1U)/8U] >> ((mp+1U)%8U)) & 0x1U) << 1;
if (1U == man)
{
man = (inBuf[mp / 8U] >> (mp % 8U)) & 0x1U;
man |= ((inBuf[(mp + 1U) / 8U] >> ((mp + 1U) % 8U)) & 0x1U) << 1;
if(1U == man) {
bp++;
}
if (2U == man)
{
outBuf[bp/8U] = (uint8_t)(outBuf[bp/8U] | (1U <<(bp%8U))); /* MISRA 10.3 */
if(2U == man) {
outBuf[bp / 8U] = (uint8_t)(outBuf[bp / 8U] | (1U << (bp % 8U))); /* MISRA 10.3 */
bp++;
}
if ((bp%8U) == 0U)
{ /* Check for EOF */
ISO_15693_DEBUG("ceof %hhx %hhx\n", inBuf[mp/8U], inBuf[mp/8+1]);
if ( ((inBuf[mp/8U] & 0xe0U) == 0xa0U)
&&(inBuf[(mp/8U)+1U] == 0x03U))
{ /* Now we know that it was 10111000 = EOF */
if((bp % 8U) == 0U) { /* Check for EOF */
ISO_15693_DEBUG("ceof %hhx %hhx\n", inBuf[mp / 8U], inBuf[mp / 8 + 1]);
if(((inBuf[mp / 8U] & 0xe0U) == 0xa0U) &&
(inBuf[(mp / 8U) + 1U] == 0x03U)) { /* Now we know that it was 10111000 = EOF */
ISO_15693_DEBUG("EOF\n");
isEOF = true;
}
}
if ( ((0U == man) || (3U == man)) && !isEOF )
{
if (bp >= ignoreBits)
{
if(((0U == man) || (3U == man)) && !isEOF) {
if(bp >= ignoreBits) {
err = ERR_RF_COLLISION;
}
else
{
} else {
/* ignored collision: leave as 0 */
bp++;
}
}
if ( (bp >= (outBufLen * 8U)) || (err == ERR_RF_COLLISION) || isEOF )
{ /* Don't write beyond the end */
if((bp >= (outBufLen * 8U)) || (err == ERR_RF_COLLISION) ||
isEOF) { /* Don't write beyond the end */
break;
}
}
@@ -369,40 +356,32 @@ ReturnCode iso15693VICCDecode(const uint8_t *inBuf,
*outBufPos = (bp / 8U);
*bitsBeforeCol = bp;
if (err != ERR_NONE)
{
if(err != ERR_NONE) {
return err;
}
if ((bp%8U) != 0U)
{
if((bp % 8U) != 0U) {
return ERR_CRC;
}
if (*outBufPos > 2U)
{
if(*outBufPos > 2U) {
/* finally, check crc */
ISO_15693_DEBUG("Calculate CRC, val: 0x%x, outBufLen: ", *outBuf);
ISO_15693_DEBUG("0x%x ", *outBufPos - 2);
crc = rfalCrcCalculateCcitt(((picopassMode) ? 0xE012U : 0xFFFFU), outBuf, *outBufPos - 2U);
crc = (uint16_t)((picopassMode) ? crc : ~crc);
if (((crc & 0xffU) == outBuf[*outBufPos-2U]) &&
(((crc >> 8U) & 0xffU) == outBuf[*outBufPos-1U]))
{
if(((crc & 0xffU) == outBuf[*outBufPos - 2U]) &&
(((crc >> 8U) & 0xffU) == outBuf[*outBufPos - 1U])) {
err = ERR_NONE;
ISO_15693_DEBUG("OK\n");
}
else
{
} else {
ISO_15693_DEBUG("error! Expected: 0x%x, got ", crc);
ISO_15693_DEBUG("0x%hhx 0x%hhx\n", outBuf[*outBufPos-2], outBuf[*outBufPos-1]);
ISO_15693_DEBUG("0x%hhx 0x%hhx\n", outBuf[*outBufPos - 2], outBuf[*outBufPos - 1]);
err = ERR_CRC;
}
}
else
{
} else {
err = ERR_CRC;
}
@@ -430,8 +409,11 @@ ReturnCode iso15693VICCDecode(const uint8_t *inBuf,
*
*****************************************************************************
*/
static ReturnCode iso15693PhyVCDCode1Of4(const uint8_t data, uint8_t* outbuffer, uint16_t maxOutBufLen, uint16_t* outBufLen)
{
static ReturnCode iso15693PhyVCDCode1Of4(
const uint8_t data,
uint8_t* outbuffer,
uint16_t maxOutBufLen,
uint16_t* outBufLen) {
uint8_t tmp;
ReturnCode err = ERR_NONE;
uint16_t a;
@@ -439,30 +421,28 @@ static ReturnCode iso15693PhyVCDCode1Of4(const uint8_t data, uint8_t* outbuffer,
*outBufLen = 0;
if (maxOutBufLen < 4U) {
if(maxOutBufLen < 4U) {
return ERR_NOMEM;
}
tmp = data;
for (a = 0; a < 4U; a++)
{
switch (tmp & 0x3U)
{
case 0:
*outbuf = ISO15693_DAT_00_1_4;
break;
case 1:
*outbuf = ISO15693_DAT_01_1_4;
break;
case 2:
*outbuf = ISO15693_DAT_10_1_4;
break;
case 3:
*outbuf = ISO15693_DAT_11_1_4;
break;
default:
/* MISRA 16.4: mandatory default statement */
break;
for(a = 0; a < 4U; a++) {
switch(tmp & 0x3U) {
case 0:
*outbuf = ISO15693_DAT_00_1_4;
break;
case 1:
*outbuf = ISO15693_DAT_01_1_4;
break;
case 2:
*outbuf = ISO15693_DAT_10_1_4;
break;
case 3:
*outbuf = ISO15693_DAT_11_1_4;
break;
default:
/* MISRA 16.4: mandatory default statement */
break;
}
outbuf++;
(*outBufLen)++;
@@ -488,8 +468,11 @@ static ReturnCode iso15693PhyVCDCode1Of4(const uint8_t data, uint8_t* outbuffer,
*
*****************************************************************************
*/
static ReturnCode iso15693PhyVCDCode1Of256(const uint8_t data, uint8_t* outbuffer, uint16_t maxOutBufLen, uint16_t* outBufLen)
{
static ReturnCode iso15693PhyVCDCode1Of256(
const uint8_t data,
uint8_t* outbuffer,
uint16_t maxOutBufLen,
uint16_t* outBufLen) {
uint8_t tmp;
ReturnCode err = ERR_NONE;
uint16_t a;
@@ -497,30 +480,28 @@ static ReturnCode iso15693PhyVCDCode1Of256(const uint8_t data, uint8_t* outbuffe
*outBufLen = 0;
if (maxOutBufLen < 64U) {
if(maxOutBufLen < 64U) {
return ERR_NOMEM;
}
tmp = data;
for (a = 0; a < 64U; a++)
{
switch (tmp)
{
case 0:
*outbuf = ISO15693_DAT_SLOT0_1_256;
break;
case 1:
*outbuf = ISO15693_DAT_SLOT1_1_256;
break;
case 2:
*outbuf = ISO15693_DAT_SLOT2_1_256;
break;
case 3:
*outbuf = ISO15693_DAT_SLOT3_1_256;
break;
default:
*outbuf = 0;
break;
for(a = 0; a < 64U; a++) {
switch(tmp) {
case 0:
*outbuf = ISO15693_DAT_SLOT0_1_256;
break;
case 1:
*outbuf = ISO15693_DAT_SLOT1_1_256;
break;
case 2:
*outbuf = ISO15693_DAT_SLOT2_1_256;
break;
case 3:
*outbuf = ISO15693_DAT_SLOT3_1_256;
break;
default:
*outbuf = 0;
break;
}
outbuf++;
(*outBufLen)++;
+2152 -1921
View File
File diff suppressed because it is too large Load Diff
+1362 -1323
View File
File diff suppressed because it is too large Load Diff
+1714 -1698
View File
File diff suppressed because it is too large Load Diff
+540 -507
View File
File diff suppressed because it is too large Load Diff
+295 -280
View File
@@ -49,7 +49,7 @@
*/
#ifndef RFAL_FEATURE_NFCB
#define RFAL_FEATURE_NFCB false /* NFC-B module configuration missing. Disabled by default */
#define RFAL_FEATURE_NFCB false /* NFC-B module configuration missing. Disabled by default */
#endif
#if RFAL_FEATURE_NFCB
@@ -60,26 +60,31 @@
******************************************************************************
*/
#define RFAL_NFCB_SENSB_REQ_EXT_SENSB_RES_SUPPORTED 0x10U /*!< Bit mask for Extended SensB Response support in SENSB_REQ */
#define RFAL_NFCB_SENSB_RES_PROT_TYPE_RFU 0x08U /*!< Bit mask for Protocol Type RFU in SENSB_RES */
#define RFAL_NFCB_SLOT_MARKER_SC_SHIFT 4U /*!< Slot Code position on SLOT_MARKER APn */
#define RFAL_NFCB_SENSB_REQ_EXT_SENSB_RES_SUPPORTED \
0x10U /*!< Bit mask for Extended SensB Response support in SENSB_REQ */
#define RFAL_NFCB_SENSB_RES_PROT_TYPE_RFU \
0x08U /*!< Bit mask for Protocol Type RFU in SENSB_RES */
#define RFAL_NFCB_SLOT_MARKER_SC_SHIFT \
4U /*!< Slot Code position on SLOT_MARKER APn */
#define RFAL_NFCB_SLOTMARKER_SLOTCODE_MIN 1U /*!< SLOT_MARKER Slot Code minimum Digital 1.1 Table 37 */
#define RFAL_NFCB_SLOTMARKER_SLOTCODE_MAX 16U /*!< SLOT_MARKER Slot Code maximum Digital 1.1 Table 37 */
#define RFAL_NFCB_SLOTMARKER_SLOTCODE_MIN \
1U /*!< SLOT_MARKER Slot Code minimum Digital 1.1 Table 37 */
#define RFAL_NFCB_SLOTMARKER_SLOTCODE_MAX \
16U /*!< SLOT_MARKER Slot Code maximum Digital 1.1 Table 37 */
#define RFAL_NFCB_ACTIVATION_FWT (RFAL_NFCB_FWTSENSB + RFAL_NFCB_DTPOLL_20) /*!< FWT(SENSB) + dTbPoll Digital 2.0 7.9.1.3 */
#define RFAL_NFCB_ACTIVATION_FWT \
(RFAL_NFCB_FWTSENSB + RFAL_NFCB_DTPOLL_20) /*!< FWT(SENSB) + dTbPoll Digital 2.0 7.9.1.3 */
/*! Advanced and Extended bit mask in Parameter of SENSB_REQ */
#define RFAL_NFCB_SENSB_REQ_PARAM (RFAL_NFCB_SENSB_REQ_ADV_FEATURE | RFAL_NFCB_SENSB_REQ_EXT_SENSB_RES_SUPPORTED)
#define RFAL_NFCB_SENSB_REQ_PARAM \
(RFAL_NFCB_SENSB_REQ_ADV_FEATURE | RFAL_NFCB_SENSB_REQ_EXT_SENSB_RES_SUPPORTED)
/*! NFC-B commands definition */
enum
{
RFAL_NFCB_CMD_SENSB_REQ = 0x05, /*!< SENSB_REQ (REQB) & SLOT_MARKER Digital 1.1 Table 24 */
RFAL_NFCB_CMD_SENSB_RES = 0x50, /*!< SENSB_RES (ATQB) & SLOT_MARKER Digital 1.1 Table 27 */
RFAL_NFCB_CMD_SLPB_REQ = 0x50, /*!< SLPB_REQ (HLTB command) Digital 1.1 Table 38 */
RFAL_NFCB_CMD_SLPB_RES = 0x00 /*!< SLPB_RES (HLTB Answer) Digital 1.1 Table 39 */
enum {
RFAL_NFCB_CMD_SENSB_REQ = 0x05, /*!< SENSB_REQ (REQB) & SLOT_MARKER Digital 1.1 Table 24 */
RFAL_NFCB_CMD_SENSB_RES = 0x50, /*!< SENSB_RES (ATQB) & SLOT_MARKER Digital 1.1 Table 27 */
RFAL_NFCB_CMD_SLPB_REQ = 0x50, /*!< SLPB_REQ (HLTB command) Digital 1.1 Table 38 */
RFAL_NFCB_CMD_SLPB_RES = 0x00 /*!< SLPB_RES (HLTB Answer) Digital 1.1 Table 39 */
};
/*
@@ -88,7 +93,8 @@ enum
******************************************************************************
*/
#define rfalNfcbNI2NumberOfSlots( ni ) (uint8_t)(1U << (ni)) /*!< Converts the Number of slots Identifier to slot number */
#define rfalNfcbNI2NumberOfSlots(ni) \
(uint8_t)(1U << (ni)) /*!< Converts the Number of slots Identifier to slot number */
/*
******************************************************************************
@@ -97,39 +103,32 @@ enum
*/
/*! ALLB_REQ (WUPB) and SENSB_REQ (REQB) Command Format Digital 1.1 7.6.1 */
typedef struct
{
uint8_t cmd; /*!< xxxxB_REQ: 05h */
uint8_t AFI; /*!< NFC Identifier */
uint8_t PARAM; /*!< Application Data */
typedef struct {
uint8_t cmd; /*!< xxxxB_REQ: 05h */
uint8_t AFI; /*!< NFC Identifier */
uint8_t PARAM; /*!< Application Data */
} rfalNfcbSensbReq;
/*! SLOT_MARKER Command format Digital 1.1 7.7.1 */
typedef struct
{
uint8_t APn; /*!< Slot number 2..16 | 0101b */
typedef struct {
uint8_t APn; /*!< Slot number 2..16 | 0101b */
} rfalNfcbSlotMarker;
/*! SLPB_REQ (HLTB) Command Format Digital 1.1 7.8.1 */
typedef struct
{
uint8_t cmd; /*!< SLPB_REQ: 50h */
uint8_t nfcid0[RFAL_NFCB_NFCID0_LEN]; /*!< NFC Identifier (PUPI)*/
typedef struct {
uint8_t cmd; /*!< SLPB_REQ: 50h */
uint8_t nfcid0[RFAL_NFCB_NFCID0_LEN]; /*!< NFC Identifier (PUPI)*/
} rfalNfcbSlpbReq;
/*! SLPB_RES (HLTB) Response Format Digital 1.1 7.8.2 */
typedef struct
{
uint8_t cmd; /*!< SLPB_RES: 00h */
typedef struct {
uint8_t cmd; /*!< SLPB_RES: 00h */
} rfalNfcbSlpbRes;
/*! RFAL NFC-B instance */
typedef struct
{
uint8_t AFI; /*!< AFI to be used */
uint8_t PARAM; /*!< PARAM to be used */
typedef struct {
uint8_t AFI; /*!< AFI to be used */
uint8_t PARAM; /*!< PARAM to be used */
} rfalNfcb;
/*
@@ -137,8 +136,7 @@ typedef struct
* LOCAL FUNCTION PROTOTYPES
******************************************************************************
*/
static ReturnCode rfalNfcbCheckSensbRes( const rfalNfcbSensbRes *sensbRes, uint8_t sensbResLen );
static ReturnCode rfalNfcbCheckSensbRes(const rfalNfcbSensbRes* sensbRes, uint8_t sensbResLen);
/*
******************************************************************************
@@ -148,7 +146,6 @@ static ReturnCode rfalNfcbCheckSensbRes( const rfalNfcbSensbRes *sensbRes, uint8
static rfalNfcb gRfalNfcb; /*!< RFAL NFC-B Instance */
/*
******************************************************************************
* LOCAL FUNCTIONS
@@ -156,17 +153,16 @@ static rfalNfcb gRfalNfcb; /*!< RFAL NFC-B Instance */
*/
/*******************************************************************************/
static ReturnCode rfalNfcbCheckSensbRes( const rfalNfcbSensbRes *sensbRes, uint8_t sensbResLen )
{
static ReturnCode rfalNfcbCheckSensbRes(const rfalNfcbSensbRes* sensbRes, uint8_t sensbResLen) {
/* Check response length */
if( ( (sensbResLen != RFAL_NFCB_SENSB_RES_LEN) && (sensbResLen != RFAL_NFCB_SENSB_RES_EXT_LEN) ) )
{
if(((sensbResLen != RFAL_NFCB_SENSB_RES_LEN) &&
(sensbResLen != RFAL_NFCB_SENSB_RES_EXT_LEN))) {
return ERR_PROTO;
}
/* Check SENSB_RES and Protocol Type Digital 1.1 7.6.2.19 */
if( ((sensbRes->protInfo.FsciProType & RFAL_NFCB_SENSB_RES_PROT_TYPE_RFU) != 0U) || (sensbRes->cmd != (uint8_t)RFAL_NFCB_CMD_SENSB_RES) )
{
if(((sensbRes->protInfo.FsciProType & RFAL_NFCB_SENSB_RES_PROT_TYPE_RFU) != 0U) ||
(sensbRes->cmd != (uint8_t)RFAL_NFCB_CMD_SENSB_RES)) {
return ERR_PROTO;
}
return ERR_NONE;
@@ -179,326 +175,345 @@ static ReturnCode rfalNfcbCheckSensbRes( const rfalNfcbSensbRes *sensbRes, uint8
*/
/*******************************************************************************/
ReturnCode rfalNfcbPollerInitialize( void )
{
ReturnCode rfalNfcbPollerInitialize(void) {
ReturnCode ret;
EXIT_ON_ERR( ret, rfalSetMode( RFAL_MODE_POLL_NFCB, RFAL_BR_106, RFAL_BR_106 ) );
rfalSetErrorHandling( RFAL_ERRORHANDLING_NFC );
rfalSetGT( RFAL_GT_NFCB );
rfalSetFDTListen( RFAL_FDT_LISTEN_NFCB_POLLER );
rfalSetFDTPoll( RFAL_FDT_POLL_NFCB_POLLER );
gRfalNfcb.AFI = RFAL_NFCB_AFI;
gRfalNfcb.PARAM = RFAL_NFCB_PARAM;
EXIT_ON_ERR(ret, rfalSetMode(RFAL_MODE_POLL_NFCB, RFAL_BR_106, RFAL_BR_106));
rfalSetErrorHandling(RFAL_ERRORHANDLING_NFC);
rfalSetGT(RFAL_GT_NFCB);
rfalSetFDTListen(RFAL_FDT_LISTEN_NFCB_POLLER);
rfalSetFDTPoll(RFAL_FDT_POLL_NFCB_POLLER);
gRfalNfcb.AFI = RFAL_NFCB_AFI;
gRfalNfcb.PARAM = RFAL_NFCB_PARAM;
return ERR_NONE;
}
/*******************************************************************************/
ReturnCode rfalNfcbPollerInitializeWithParams( uint8_t AFI, uint8_t PARAM )
{
ReturnCode rfalNfcbPollerInitializeWithParams(uint8_t AFI, uint8_t PARAM) {
ReturnCode ret;
EXIT_ON_ERR( ret, rfalNfcbPollerInitialize() );
gRfalNfcb.AFI = AFI;
EXIT_ON_ERR(ret, rfalNfcbPollerInitialize());
gRfalNfcb.AFI = AFI;
gRfalNfcb.PARAM = (PARAM & RFAL_NFCB_SENSB_REQ_PARAM);
return ERR_NONE;
}
/*******************************************************************************/
ReturnCode rfalNfcbPollerCheckPresence( rfalNfcbSensCmd cmd, rfalNfcbSlots slots, rfalNfcbSensbRes *sensbRes, uint8_t *sensbResLen )
{
uint16_t rxLen;
ReturnCode ret;
ReturnCode rfalNfcbPollerCheckPresence(
rfalNfcbSensCmd cmd,
rfalNfcbSlots slots,
rfalNfcbSensbRes* sensbRes,
uint8_t* sensbResLen) {
uint16_t rxLen;
ReturnCode ret;
rfalNfcbSensbReq sensbReq;
/* Check if the command requested and given the slot number are valid */
if( ((RFAL_NFCB_SENS_CMD_SENSB_REQ != cmd) && (RFAL_NFCB_SENS_CMD_ALLB_REQ != cmd)) ||
(slots > RFAL_NFCB_SLOT_NUM_16) || (sensbRes == NULL) || (sensbResLen == NULL) )
{
if(((RFAL_NFCB_SENS_CMD_SENSB_REQ != cmd) && (RFAL_NFCB_SENS_CMD_ALLB_REQ != cmd)) ||
(slots > RFAL_NFCB_SLOT_NUM_16) || (sensbRes == NULL) || (sensbResLen == NULL)) {
return ERR_PARAM;
}
*sensbResLen = 0;
ST_MEMSET(sensbRes, 0x00, sizeof(rfalNfcbSensbRes) );
ST_MEMSET(sensbRes, 0x00, sizeof(rfalNfcbSensbRes));
/* Compute SENSB_REQ */
sensbReq.cmd = RFAL_NFCB_CMD_SENSB_REQ;
sensbReq.AFI = gRfalNfcb.AFI;
sensbReq.PARAM = (((uint8_t)gRfalNfcb.PARAM & RFAL_NFCB_SENSB_REQ_PARAM) | (uint8_t)cmd | (uint8_t)slots);
sensbReq.cmd = RFAL_NFCB_CMD_SENSB_REQ;
sensbReq.AFI = gRfalNfcb.AFI;
sensbReq.PARAM =
(((uint8_t)gRfalNfcb.PARAM & RFAL_NFCB_SENSB_REQ_PARAM) | (uint8_t)cmd | (uint8_t)slots);
/* Send SENSB_REQ and disable AGC to detect collisions */
ret = rfalTransceiveBlockingTxRx( (uint8_t*)&sensbReq, sizeof(rfalNfcbSensbReq), (uint8_t*)sensbRes, sizeof(rfalNfcbSensbRes), &rxLen, RFAL_TXRX_FLAGS_DEFAULT, RFAL_NFCB_FWTSENSB );
ret = rfalTransceiveBlockingTxRx(
(uint8_t*)&sensbReq,
sizeof(rfalNfcbSensbReq),
(uint8_t*)sensbRes,
sizeof(rfalNfcbSensbRes),
&rxLen,
RFAL_TXRX_FLAGS_DEFAULT,
RFAL_NFCB_FWTSENSB);
*sensbResLen = (uint8_t)rxLen;
/* Check if a transmission error was detected */
if( (ret == ERR_CRC) || (ret == ERR_FRAMING) )
{
if((ret == ERR_CRC) || (ret == ERR_FRAMING)) {
/* Invalidate received frame as an error was detected (CollisionResolution checks if valid) */
*sensbResLen = 0;
return ERR_NONE;
}
if( ret == ERR_NONE )
{
return rfalNfcbCheckSensbRes( sensbRes, *sensbResLen );
if(ret == ERR_NONE) {
return rfalNfcbCheckSensbRes(sensbRes, *sensbResLen);
}
return ret;
}
/*******************************************************************************/
ReturnCode rfalNfcbPollerSleep( const uint8_t* nfcid0 )
{
uint16_t rxLen;
ReturnCode ret;
ReturnCode rfalNfcbPollerSleep(const uint8_t* nfcid0) {
uint16_t rxLen;
ReturnCode ret;
rfalNfcbSlpbReq slpbReq;
rfalNfcbSlpbRes slpbRes;
if( nfcid0 == NULL )
{
if(nfcid0 == NULL) {
return ERR_PARAM;
}
/* Compute SLPB_REQ */
slpbReq.cmd = RFAL_NFCB_CMD_SLPB_REQ;
ST_MEMCPY( slpbReq.nfcid0, nfcid0, RFAL_NFCB_NFCID0_LEN );
EXIT_ON_ERR( ret, rfalTransceiveBlockingTxRx( (uint8_t*)&slpbReq, sizeof(rfalNfcbSlpbReq), (uint8_t*)&slpbRes, sizeof(rfalNfcbSlpbRes), &rxLen, RFAL_TXRX_FLAGS_DEFAULT, RFAL_NFCB_ACTIVATION_FWT ));
ST_MEMCPY(slpbReq.nfcid0, nfcid0, RFAL_NFCB_NFCID0_LEN);
EXIT_ON_ERR(
ret,
rfalTransceiveBlockingTxRx(
(uint8_t*)&slpbReq,
sizeof(rfalNfcbSlpbReq),
(uint8_t*)&slpbRes,
sizeof(rfalNfcbSlpbRes),
&rxLen,
RFAL_TXRX_FLAGS_DEFAULT,
RFAL_NFCB_ACTIVATION_FWT));
/* Check SLPB_RES */
if( (rxLen != sizeof(rfalNfcbSlpbRes)) || (slpbRes.cmd != (uint8_t)RFAL_NFCB_CMD_SLPB_RES) )
{
if((rxLen != sizeof(rfalNfcbSlpbRes)) || (slpbRes.cmd != (uint8_t)RFAL_NFCB_CMD_SLPB_RES)) {
return ERR_PROTO;
}
return ERR_NONE;
}
/*******************************************************************************/
ReturnCode rfalNfcbPollerSlotMarker( uint8_t slotCode, rfalNfcbSensbRes *sensbRes, uint8_t *sensbResLen )
{
ReturnCode ret;
ReturnCode
rfalNfcbPollerSlotMarker(uint8_t slotCode, rfalNfcbSensbRes* sensbRes, uint8_t* sensbResLen) {
ReturnCode ret;
rfalNfcbSlotMarker slotMarker;
uint16_t rxLen;
uint16_t rxLen;
/* Check parameters */
if( (sensbRes == NULL) || (sensbResLen == NULL) ||
(slotCode < RFAL_NFCB_SLOTMARKER_SLOTCODE_MIN) ||
(slotCode > RFAL_NFCB_SLOTMARKER_SLOTCODE_MAX) )
{
if((sensbRes == NULL) || (sensbResLen == NULL) ||
(slotCode < RFAL_NFCB_SLOTMARKER_SLOTCODE_MIN) ||
(slotCode > RFAL_NFCB_SLOTMARKER_SLOTCODE_MAX)) {
return ERR_PARAM;
}
/* Compose and send SLOT_MARKER with disabled AGC to detect collisions */
slotMarker.APn = ((slotCode << RFAL_NFCB_SLOT_MARKER_SC_SHIFT) | (uint8_t)RFAL_NFCB_CMD_SENSB_REQ);
ret = rfalTransceiveBlockingTxRx( (uint8_t*)&slotMarker, sizeof(rfalNfcbSlotMarker), (uint8_t*)sensbRes, sizeof(rfalNfcbSensbRes), &rxLen, RFAL_TXRX_FLAGS_DEFAULT, RFAL_NFCB_ACTIVATION_FWT );
slotMarker.APn =
((slotCode << RFAL_NFCB_SLOT_MARKER_SC_SHIFT) | (uint8_t)RFAL_NFCB_CMD_SENSB_REQ);
ret = rfalTransceiveBlockingTxRx(
(uint8_t*)&slotMarker,
sizeof(rfalNfcbSlotMarker),
(uint8_t*)sensbRes,
sizeof(rfalNfcbSensbRes),
&rxLen,
RFAL_TXRX_FLAGS_DEFAULT,
RFAL_NFCB_ACTIVATION_FWT);
*sensbResLen = (uint8_t)rxLen;
/* Check if a transmission error was detected */
if( (ret == ERR_CRC) || (ret == ERR_FRAMING) )
{
if((ret == ERR_CRC) || (ret == ERR_FRAMING)) {
return ERR_RF_COLLISION;
}
if( ret == ERR_NONE )
{
return rfalNfcbCheckSensbRes( sensbRes, *sensbResLen );
if(ret == ERR_NONE) {
return rfalNfcbCheckSensbRes(sensbRes, *sensbResLen);
}
return ret;
}
ReturnCode rfalNfcbPollerTechnologyDetection( rfalComplianceMode compMode, rfalNfcbSensbRes *sensbRes, uint8_t *sensbResLen )
{
ReturnCode rfalNfcbPollerTechnologyDetection(
rfalComplianceMode compMode,
rfalNfcbSensbRes* sensbRes,
uint8_t* sensbResLen) {
NO_WARNING(compMode);
return rfalNfcbPollerCheckPresence( RFAL_NFCB_SENS_CMD_SENSB_REQ, RFAL_NFCB_SLOT_NUM_1, sensbRes, sensbResLen );
return rfalNfcbPollerCheckPresence(
RFAL_NFCB_SENS_CMD_SENSB_REQ, RFAL_NFCB_SLOT_NUM_1, sensbRes, sensbResLen);
}
/*******************************************************************************/
ReturnCode rfalNfcbPollerCollisionResolution( rfalComplianceMode compMode, uint8_t devLimit, rfalNfcbListenDevice *nfcbDevList, uint8_t *devCnt )
{
ReturnCode rfalNfcbPollerCollisionResolution(
rfalComplianceMode compMode,
uint8_t devLimit,
rfalNfcbListenDevice* nfcbDevList,
uint8_t* devCnt) {
bool colPending; /* dummy */
return rfalNfcbPollerSlottedCollisionResolution( compMode, devLimit, RFAL_NFCB_SLOT_NUM_1, RFAL_NFCB_SLOT_NUM_16, nfcbDevList, devCnt, &colPending );
return rfalNfcbPollerSlottedCollisionResolution(
compMode,
devLimit,
RFAL_NFCB_SLOT_NUM_1,
RFAL_NFCB_SLOT_NUM_16,
nfcbDevList,
devCnt,
&colPending);
}
/*******************************************************************************/
ReturnCode rfalNfcbPollerSlottedCollisionResolution( rfalComplianceMode compMode, uint8_t devLimit, rfalNfcbSlots initSlots, rfalNfcbSlots endSlots, rfalNfcbListenDevice *nfcbDevList, uint8_t *devCnt, bool *colPending )
{
ReturnCode ret;
uint8_t slotsNum;
uint8_t slotCode;
uint8_t curDevCnt;
/* Check parameters. In ISO | Activity 1.0 mode the initial slots must be 1 as continuation of Technology Detection */
if( (nfcbDevList == NULL) || (devCnt == NULL) || (colPending == NULL) || (initSlots > RFAL_NFCB_SLOT_NUM_16) ||
(endSlots > RFAL_NFCB_SLOT_NUM_16) || ((compMode == RFAL_COMPLIANCE_MODE_ISO) && (initSlots != RFAL_NFCB_SLOT_NUM_1)) )
{
return ERR_PARAM;
}
/* Initialise as no error in case Activity 1.0 where the previous SENSB_RES from technology detection should be used */
ret = ERR_NONE;
*devCnt = 0;
curDevCnt = 0;
*colPending = false;
/* Send ALLB_REQ Activity 1.1 9.3.5.2 and 9.3.5.3 (Symbol 1 and 2) */
if( compMode != RFAL_COMPLIANCE_MODE_ISO )
{
ret = rfalNfcbPollerCheckPresence( RFAL_NFCB_SENS_CMD_ALLB_REQ, initSlots, &nfcbDevList->sensbRes, &nfcbDevList->sensbResLen );
if( (ret != ERR_NONE) && (initSlots == RFAL_NFCB_SLOT_NUM_1) )
{
return ret;
}
}
ReturnCode rfalNfcbPollerSlottedCollisionResolution(
rfalComplianceMode compMode,
uint8_t devLimit,
rfalNfcbSlots initSlots,
rfalNfcbSlots endSlots,
rfalNfcbListenDevice* nfcbDevList,
uint8_t* devCnt,
bool* colPending) {
ReturnCode ret;
uint8_t slotsNum;
uint8_t slotCode;
uint8_t curDevCnt;
/* Check if there was a transmission error on WUPB EMVCo 2.6 9.3.3.1 */
if( (compMode == RFAL_COMPLIANCE_MODE_EMV) && (nfcbDevList->sensbResLen == 0U) )
{
return ERR_FRAMING;
/* Check parameters. In ISO | Activity 1.0 mode the initial slots must be 1 as continuation of Technology Detection */
if((nfcbDevList == NULL) || (devCnt == NULL) || (colPending == NULL) ||
(initSlots > RFAL_NFCB_SLOT_NUM_16) || (endSlots > RFAL_NFCB_SLOT_NUM_16) ||
((compMode == RFAL_COMPLIANCE_MODE_ISO) && (initSlots != RFAL_NFCB_SLOT_NUM_1))) {
return ERR_PARAM;
}
/* Initialise as no error in case Activity 1.0 where the previous SENSB_RES from technology detection should be used */
ret = ERR_NONE;
*devCnt = 0;
curDevCnt = 0;
*colPending = false;
/* Send ALLB_REQ Activity 1.1 9.3.5.2 and 9.3.5.3 (Symbol 1 and 2) */
if(compMode != RFAL_COMPLIANCE_MODE_ISO) {
ret = rfalNfcbPollerCheckPresence(
RFAL_NFCB_SENS_CMD_ALLB_REQ,
initSlots,
&nfcbDevList->sensbRes,
&nfcbDevList->sensbResLen);
if((ret != ERR_NONE) && (initSlots == RFAL_NFCB_SLOT_NUM_1)) {
return ret;
}
for( slotsNum = (uint8_t)initSlots; slotsNum <= (uint8_t)endSlots; slotsNum++ )
{
}
/* Check if there was a transmission error on WUPB EMVCo 2.6 9.3.3.1 */
if((compMode == RFAL_COMPLIANCE_MODE_EMV) && (nfcbDevList->sensbResLen == 0U)) {
return ERR_FRAMING;
}
for(slotsNum = (uint8_t)initSlots; slotsNum <= (uint8_t)endSlots; slotsNum++) {
do {
/* Activity 1.1 9.3.5.23 - Symbol 22 */
if((compMode == RFAL_COMPLIANCE_MODE_NFC) && (curDevCnt != 0U)) {
rfalNfcbPollerSleep(nfcbDevList[((*devCnt) - (uint8_t)1U)].sensbRes.nfcid0);
nfcbDevList[((*devCnt) - (uint8_t)1U)].isSleep = true;
}
/* Send SENSB_REQ with number of slots if not the first Activity 1.1 9.3.5.24 - Symbol 23 */
if((slotsNum != (uint8_t)initSlots) || *colPending) {
/* PRQA S 4342 1 # MISRA 10.5 - Layout of rfalNfcbSlots and above loop guarantee that no invalid enum values are created. */
ret = rfalNfcbPollerCheckPresence(
RFAL_NFCB_SENS_CMD_SENSB_REQ,
(rfalNfcbSlots)slotsNum,
&nfcbDevList[*devCnt].sensbRes,
&nfcbDevList[*devCnt].sensbResLen);
}
/* Activity 1.1 9.3.5.6 - Symbol 5 */
slotCode = 0;
curDevCnt = 0;
*colPending = false;
do {
/* Activity 1.1 9.3.5.23 - Symbol 22 */
if( (compMode == RFAL_COMPLIANCE_MODE_NFC) && (curDevCnt != 0U) )
{
rfalNfcbPollerSleep( nfcbDevList[((*devCnt) - (uint8_t)1U)].sensbRes.nfcid0 );
nfcbDevList[((*devCnt) - (uint8_t)1U)].isSleep = true;
/* Activity 1.1 9.3.5.26 - Symbol 25 */
if(slotCode != 0U) {
ret = rfalNfcbPollerSlotMarker(
slotCode,
&nfcbDevList[*devCnt].sensbRes,
&nfcbDevList[*devCnt].sensbResLen);
}
/* Send SENSB_REQ with number of slots if not the first Activity 1.1 9.3.5.24 - Symbol 23 */
if( (slotsNum != (uint8_t)initSlots) || *colPending )
{
/* PRQA S 4342 1 # MISRA 10.5 - Layout of rfalNfcbSlots and above loop guarantee that no invalid enum values are created. */
ret = rfalNfcbPollerCheckPresence( RFAL_NFCB_SENS_CMD_SENSB_REQ, (rfalNfcbSlots)slotsNum, &nfcbDevList[*devCnt].sensbRes, &nfcbDevList[*devCnt].sensbResLen );
}
/* Activity 1.1 9.3.5.6 - Symbol 5 */
slotCode = 0;
curDevCnt = 0;
*colPending = false;
do{
/* Activity 1.1 9.3.5.26 - Symbol 25 */
if( slotCode != 0U )
{
ret = rfalNfcbPollerSlotMarker( slotCode, &nfcbDevList[*devCnt].sensbRes, &nfcbDevList[*devCnt].sensbResLen );
}
/* Activity 1.1 9.3.5.7 and 9.3.5.8 - Symbol 6 */
if( ret != ERR_TIMEOUT )
{
/* Activity 1.1 9.3.5.8 - Symbol 7 */
if( (rfalNfcbCheckSensbRes( &nfcbDevList[*devCnt].sensbRes, nfcbDevList[*devCnt].sensbResLen) == ERR_NONE) && (ret == ERR_NONE) )
{
nfcbDevList[*devCnt].isSleep = false;
if( compMode == RFAL_COMPLIANCE_MODE_EMV )
{
(*devCnt)++;
/* Activity 1.1 9.3.5.7 and 9.3.5.8 - Symbol 6 */
if(ret != ERR_TIMEOUT) {
/* Activity 1.1 9.3.5.8 - Symbol 7 */
if((rfalNfcbCheckSensbRes(
&nfcbDevList[*devCnt].sensbRes, nfcbDevList[*devCnt].sensbResLen) ==
ERR_NONE) &&
(ret == ERR_NONE)) {
nfcbDevList[*devCnt].isSleep = false;
if(compMode == RFAL_COMPLIANCE_MODE_EMV) {
(*devCnt)++;
return ret;
} else if(compMode == RFAL_COMPLIANCE_MODE_ISO) {
/* Activity 1.0 9.3.5.8 - Symbol 7 */
(*devCnt)++;
curDevCnt++;
/* Activity 1.0 9.3.5.10 - Symbol 9 */
if((*devCnt >= devLimit) ||
(slotsNum == (uint8_t)RFAL_NFCB_SLOT_NUM_1)) {
return ret;
}
else if( compMode == RFAL_COMPLIANCE_MODE_ISO )
{
/* Activity 1.0 9.3.5.8 - Symbol 7 */
(*devCnt)++;
curDevCnt++;
/* Activity 1.0 9.3.5.10 - Symbol 9 */
if( (*devCnt >= devLimit) || (slotsNum == (uint8_t)RFAL_NFCB_SLOT_NUM_1) )
{
return ret;
}
/* Activity 1.0 9.3.5.11 - Symbol 10 */
rfalNfcbPollerSleep( nfcbDevList[*devCnt-1U].sensbRes.nfcid0 );
nfcbDevList[*devCnt-1U].isSleep = true;
/* Activity 1.0 9.3.5.11 - Symbol 10 */
rfalNfcbPollerSleep(nfcbDevList[*devCnt - 1U].sensbRes.nfcid0);
nfcbDevList[*devCnt - 1U].isSleep = true;
} else if(compMode == RFAL_COMPLIANCE_MODE_NFC) {
/* Activity 1.1 9.3.5.10 and 9.3.5.11 - Symbol 9 and Symbol 11*/
if(curDevCnt != 0U) {
rfalNfcbPollerSleep(
nfcbDevList[(*devCnt) - (uint8_t)1U].sensbRes.nfcid0);
nfcbDevList[(*devCnt) - (uint8_t)1U].isSleep = true;
}
else if( compMode == RFAL_COMPLIANCE_MODE_NFC )
{
/* Activity 1.1 9.3.5.10 and 9.3.5.11 - Symbol 9 and Symbol 11*/
if(curDevCnt != 0U)
{
rfalNfcbPollerSleep( nfcbDevList[(*devCnt) - (uint8_t)1U].sensbRes.nfcid0 );
nfcbDevList[(*devCnt) - (uint8_t)1U].isSleep = true;
}
/* Activity 1.1 9.3.5.12 - Symbol 11 */
(*devCnt)++;
curDevCnt++;
/* Activity 1.1 9.3.5.6 - Symbol 13 */
if( (*devCnt >= devLimit) || (slotsNum == (uint8_t)RFAL_NFCB_SLOT_NUM_1) )
{
return ret;
}
}
else
{
/* MISRA 15.7 - Empty else */
/* Activity 1.1 9.3.5.12 - Symbol 11 */
(*devCnt)++;
curDevCnt++;
/* Activity 1.1 9.3.5.6 - Symbol 13 */
if((*devCnt >= devLimit) ||
(slotsNum == (uint8_t)RFAL_NFCB_SLOT_NUM_1)) {
return ret;
}
} else {
/* MISRA 15.7 - Empty else */
}
else
{
/* If deviceLimit is set to 0 the NFC Forum Device is configured to perform collision detection only Activity 1.0 and 1.1 9.3.5.5 - Symbol 4 */
if( (devLimit == 0U) && (slotsNum == (uint8_t)RFAL_NFCB_SLOT_NUM_1) )
{
return ERR_RF_COLLISION;
}
/* Activity 1.1 9.3.5.9 - Symbol 8 */
*colPending = true;
} else {
/* If deviceLimit is set to 0 the NFC Forum Device is configured to perform collision detection only Activity 1.0 and 1.1 9.3.5.5 - Symbol 4 */
if((devLimit == 0U) && (slotsNum == (uint8_t)RFAL_NFCB_SLOT_NUM_1)) {
return ERR_RF_COLLISION;
}
/* Activity 1.1 9.3.5.9 - Symbol 8 */
*colPending = true;
}
/* Activity 1.1 9.3.5.15 - Symbol 14 */
slotCode++;
}
while( slotCode < rfalNfcbNI2NumberOfSlots(slotsNum) );
/* Activity 1.1 9.3.5.17 - Symbol 16 */
if( !(*colPending) )
{
return ERR_NONE;
}
/* Activity 1.1 9.3.5.15 - Symbol 14 */
slotCode++;
} while(slotCode < rfalNfcbNI2NumberOfSlots(slotsNum));
/* Activity 1.1 9.3.5.17 - Symbol 16 */
if(!(*colPending)) {
return ERR_NONE;
}
/* Activity 1.1 9.3.5.18 - Symbol 17 */
} while (curDevCnt != 0U); /* If a collision is detected and card(s) were found on this loop keep the same number of available slots */
}
return ERR_NONE;
} while(
curDevCnt !=
0U); /* If a collision is detected and card(s) were found on this loop keep the same number of available slots */
}
return ERR_NONE;
}
/*******************************************************************************/
uint32_t rfalNfcbTR2ToFDT( uint8_t tr2Code )
{
uint32_t rfalNfcbTR2ToFDT(uint8_t tr2Code) {
/*******************************************************************************/
/* MISRA 8.9 An object should be defined at block scope if its identifier only appears in a single function */
/*! TR2 Table according to Digital 1.1 Table 33 */
const uint16_t rfalNfcbTr2Table[] = { 1792, 3328, 5376, 9472 };
const uint16_t rfalNfcbTr2Table[] = {1792, 3328, 5376, 9472};
/*******************************************************************************/
return rfalNfcbTr2Table[ (tr2Code & RFAL_NFCB_SENSB_RES_PROTO_TR2_MASK) ];
return rfalNfcbTr2Table[(tr2Code & RFAL_NFCB_SENSB_RES_PROTO_TR2_MASK)];
}
#endif /* RFAL_FEATURE_NFCB */
+315 -276
View File
@@ -52,7 +52,7 @@
*/
#ifndef RFAL_FEATURE_NFCF
#define RFAL_FEATURE_NFCF false /* NFC-F module configuration missing. Disabled by default */
#define RFAL_FEATURE_NFCF false /* NFC-F module configuration missing. Disabled by default */
#endif
#if RFAL_FEATURE_NFCF
@@ -62,32 +62,42 @@
* GLOBAL DEFINES
******************************************************************************
*/
#define RFAL_NFCF_SENSF_REQ_LEN_MIN 5U /*!< SENSF_RES minimum length */
#define RFAL_NFCF_SENSF_REQ_LEN_MIN \
5U /*!< SENSF_RES minimum length */
#define RFAL_NFCF_READ_WO_ENCRYPTION_MIN_LEN 15U /*!< Minimum length for a Check Command T3T 5.4.1 */
#define RFAL_NFCF_WRITE_WO_ENCRYPTION_MIN_LEN 31U /*!< Minimum length for an Update Command T3T 5.5.1 */
#define RFAL_NFCF_READ_WO_ENCRYPTION_MIN_LEN \
15U /*!< Minimum length for a Check Command T3T 5.4.1 */
#define RFAL_NFCF_WRITE_WO_ENCRYPTION_MIN_LEN \
31U /*!< Minimum length for an Update Command T3T 5.5.1 */
#define RFAL_NFCF_CHECK_RES_MIN_LEN 11U /*!< CHECK Response minimum length T3T 1.0 Table 8 */
#define RFAL_NFCF_UPDATE_RES_MIN_LEN 11U /*!< UPDATE Response minimum length T3T 1.0 Table 8 */
#define RFAL_NFCF_CHECK_REQ_MAX_LEN 86U /*!< Max length of a Check request T3T 1.0 Table 7 */
#define RFAL_NFCF_CHECK_REQ_MAX_SERV 15U /*!< Max Services number on Check request T3T 1.0 5.4.1.5 */
#define RFAL_NFCF_CHECK_REQ_MAX_BLOCK 15U /*!< Max Blocks number on Check request T3T 1.0 5.4.1.10 */
#define RFAL_NFCF_UPDATE_REQ_MAX_SERV 15U /*!< Max Services number Update request T3T 1.0 5.4.1.5 */
#define RFAL_NFCF_UPDATE_REQ_MAX_BLOCK 13U /*!< Max Blocks number on Update request T3T 1.0 5.4.1.10 */
#define RFAL_NFCF_CHECK_RES_MIN_LEN \
11U /*!< CHECK Response minimum length T3T 1.0 Table 8 */
#define RFAL_NFCF_UPDATE_RES_MIN_LEN \
11U /*!< UPDATE Response minimum length T3T 1.0 Table 8 */
#define RFAL_NFCF_CHECK_REQ_MAX_LEN \
86U /*!< Max length of a Check request T3T 1.0 Table 7 */
#define RFAL_NFCF_CHECK_REQ_MAX_SERV \
15U /*!< Max Services number on Check request T3T 1.0 5.4.1.5 */
#define RFAL_NFCF_CHECK_REQ_MAX_BLOCK \
15U /*!< Max Blocks number on Check request T3T 1.0 5.4.1.10 */
#define RFAL_NFCF_UPDATE_REQ_MAX_SERV \
15U /*!< Max Services number Update request T3T 1.0 5.4.1.5 */
#define RFAL_NFCF_UPDATE_REQ_MAX_BLOCK \
13U /*!< Max Blocks number on Update request T3T 1.0 5.4.1.10 */
/*! MRT Check | Uupdate = (Tt3t x ((A+1) + n (B+1)) x 4^E) + dRWTt3t T3T 5.8
Max values used: A = 7 ; B = 7 ; E = 3 ; n = 15 (NFC Forum n = 15, JIS n = 32)
*/
#define RFAL_NFCF_MRT_CHECK_UPDATE ((4096 * (8 + (15 * 8)) * 64 ) + 16)
#define RFAL_NFCF_MRT_CHECK_UPDATE ((4096 * (8 + (15 * 8)) * 64) + 16)
/*
******************************************************************************
* GLOBAL MACROS
******************************************************************************
*/
#define rfalNfcfSlots2CardNum( s ) ((uint8_t)(s)+1U) /*!< Converts Time Slot Number (TSN) into num of slots */
#define rfalNfcfSlots2CardNum(s) \
((uint8_t)(s) + 1U) /*!< Converts Time Slot Number (TSN) into num of slots */
/*
******************************************************************************
@@ -96,45 +106,44 @@
*/
/*! Structure/Buffer to hold the SENSF_RES with LEN byte prepended */
typedef struct{
uint8_t LEN; /*!< NFC-F LEN byte */
rfalNfcfSensfRes SENSF_RES; /*!< SENSF_RES */
typedef struct {
uint8_t LEN; /*!< NFC-F LEN byte */
rfalNfcfSensfRes SENSF_RES; /*!< SENSF_RES */
} rfalNfcfSensfResBuf;
/*! Greedy collection for NFCF GRE_POLL_F Activity 1.0 Table 10 */
typedef struct{
uint8_t pollFound; /*!< Number of devices found by the Poll */
uint8_t pollCollision; /*!< Number of collisions detected */
rfalFeliCaPollRes POLL_F[RFAL_NFCF_POLL_MAXCARDS]; /*!< GRE_POLL_F Activity 1.0 Table 10 */
typedef struct {
uint8_t pollFound; /*!< Number of devices found by the Poll */
uint8_t pollCollision; /*!< Number of collisions detected */
rfalFeliCaPollRes POLL_F[RFAL_NFCF_POLL_MAXCARDS]; /*!< GRE_POLL_F Activity 1.0 Table 10 */
} rfalNfcfGreedyF;
/*! NFC-F SENSF_REQ format Digital 1.1 8.6.1 */
typedef struct
{
uint8_t CMD; /*!< Command code: 00h */
uint8_t SC[RFAL_NFCF_SENSF_SC_LEN]; /*!< System Code */
uint8_t RC; /*!< Request Code */
uint8_t TSN; /*!< Time Slot Number */
typedef struct {
uint8_t CMD; /*!< Command code: 00h */
uint8_t SC[RFAL_NFCF_SENSF_SC_LEN]; /*!< System Code */
uint8_t RC; /*!< Request Code */
uint8_t TSN; /*!< Time Slot Number */
} rfalNfcfSensfReq;
/*
******************************************************************************
* LOCAL VARIABLES
******************************************************************************
*/
static rfalNfcfGreedyF gRfalNfcfGreedyF; /*!< Activity's NFCF Greedy collection */
static rfalNfcfGreedyF gRfalNfcfGreedyF; /*!< Activity's NFCF Greedy collection */
/*
******************************************************************************
* LOCAL FUNCTION PROTOTYPES
******************************************************************************
*/
static void rfalNfcfComputeValidSENF( rfalNfcfListenDevice *outDevInfo, uint8_t *curDevIdx, uint8_t devLimit, bool overwrite, bool *nfcDepFound );
static void rfalNfcfComputeValidSENF(
rfalNfcfListenDevice* outDevInfo,
uint8_t* curDevIdx,
uint8_t devLimit,
bool overwrite,
bool* nfcDepFound);
/*
******************************************************************************
@@ -143,76 +152,81 @@ static void rfalNfcfComputeValidSENF( rfalNfcfListenDevice *outDevInfo, uint8_t
*/
/*******************************************************************************/
static void rfalNfcfComputeValidSENF( rfalNfcfListenDevice *outDevInfo, uint8_t *curDevIdx, uint8_t devLimit, bool overwrite, bool *nfcDepFound )
{
uint8_t tmpIdx;
bool duplicate;
const rfalNfcfSensfResBuf *sensfBuf;
rfalNfcfSensfResBuf sensfCopy;
static void rfalNfcfComputeValidSENF(
rfalNfcfListenDevice* outDevInfo,
uint8_t* curDevIdx,
uint8_t devLimit,
bool overwrite,
bool* nfcDepFound) {
uint8_t tmpIdx;
bool duplicate;
const rfalNfcfSensfResBuf* sensfBuf;
rfalNfcfSensfResBuf sensfCopy;
/*******************************************************************************/
/* Go through all responses check if valid and duplicates */
/*******************************************************************************/
while( (gRfalNfcfGreedyF.pollFound > 0U) && ((*curDevIdx) < devLimit) )
{
while((gRfalNfcfGreedyF.pollFound > 0U) && ((*curDevIdx) < devLimit)) {
duplicate = false;
gRfalNfcfGreedyF.pollFound--;
/* MISRA 11.3 - Cannot point directly into different object type, use local copy */
ST_MEMCPY( (uint8_t*)&sensfCopy, (uint8_t*)&gRfalNfcfGreedyF.POLL_F[gRfalNfcfGreedyF.pollFound], sizeof(rfalNfcfSensfResBuf) );
ST_MEMCPY(
(uint8_t*)&sensfCopy,
(uint8_t*)&gRfalNfcfGreedyF.POLL_F[gRfalNfcfGreedyF.pollFound],
sizeof(rfalNfcfSensfResBuf));
/* Point to received SENSF_RES */
sensfBuf = &sensfCopy;
/* Check for devices that are already in device list */
for( tmpIdx = 0; tmpIdx < (*curDevIdx); tmpIdx++ )
{
if( ST_BYTECMP( sensfBuf->SENSF_RES.NFCID2, outDevInfo[tmpIdx].sensfRes.NFCID2, RFAL_NFCF_NFCID2_LEN ) == 0 )
{
for(tmpIdx = 0; tmpIdx < (*curDevIdx); tmpIdx++) {
if(ST_BYTECMP(
sensfBuf->SENSF_RES.NFCID2,
outDevInfo[tmpIdx].sensfRes.NFCID2,
RFAL_NFCF_NFCID2_LEN) == 0) {
duplicate = true;
break;
}
}
/* If is a duplicate skip this (and not to overwrite)*/
if(duplicate && !overwrite)
{
/* If is a duplicate skip this (and not to overwrite)*/
if(duplicate && !overwrite) {
continue;
}
/* Check if response length is OK */
if( (( sensfBuf->LEN - RFAL_NFCF_HEADER_LEN) < RFAL_NFCF_SENSF_RES_LEN_MIN) || ((sensfBuf->LEN - RFAL_NFCF_HEADER_LEN) > RFAL_NFCF_SENSF_RES_LEN_MAX) )
{
if(((sensfBuf->LEN - RFAL_NFCF_HEADER_LEN) < RFAL_NFCF_SENSF_RES_LEN_MIN) ||
((sensfBuf->LEN - RFAL_NFCF_HEADER_LEN) > RFAL_NFCF_SENSF_RES_LEN_MAX)) {
continue;
}
/* Check if the response is a SENSF_RES / Polling response */
if( sensfBuf->SENSF_RES.CMD != (uint8_t)RFAL_NFCF_CMD_POLLING_RES )
{
if(sensfBuf->SENSF_RES.CMD != (uint8_t)RFAL_NFCF_CMD_POLLING_RES) {
continue;
}
/* Check if is an overwrite request or new device*/
if(duplicate && overwrite)
{
if(duplicate && overwrite) {
/* overwrite deviceInfo/GRE_SENSF_RES with SENSF_RES */
outDevInfo[tmpIdx].sensfResLen = (sensfBuf->LEN - RFAL_NFCF_LENGTH_LEN);
ST_MEMCPY( &outDevInfo[tmpIdx].sensfRes, &sensfBuf->SENSF_RES, outDevInfo[tmpIdx].sensfResLen );
ST_MEMCPY(
&outDevInfo[tmpIdx].sensfRes,
&sensfBuf->SENSF_RES,
outDevInfo[tmpIdx].sensfResLen);
continue;
}
else
{
} else {
/* fill deviceInfo/GRE_SENSF_RES with new SENSF_RES */
outDevInfo[(*curDevIdx)].sensfResLen = (sensfBuf->LEN - RFAL_NFCF_LENGTH_LEN);
ST_MEMCPY( &outDevInfo[(*curDevIdx)].sensfRes, &sensfBuf->SENSF_RES, outDevInfo[(*curDevIdx)].sensfResLen );
ST_MEMCPY(
&outDevInfo[(*curDevIdx)].sensfRes,
&sensfBuf->SENSF_RES,
outDevInfo[(*curDevIdx)].sensfResLen);
}
/* Check if this device supports NFC-DEP and signal it (ACTIVITY 1.1 9.3.6.63) */
*nfcDepFound = rfalNfcfIsNfcDepSupported( &outDevInfo[(*curDevIdx)] );
/* Check if this device supports NFC-DEP and signal it (ACTIVITY 1.1 9.3.6.63) */
*nfcDepFound = rfalNfcfIsNfcDepSupported(&outDevInfo[(*curDevIdx)]);
(*curDevIdx)++;
}
}
@@ -224,61 +238,69 @@ static void rfalNfcfComputeValidSENF( rfalNfcfListenDevice *outDevInfo, uint8_t
*/
/*******************************************************************************/
ReturnCode rfalNfcfPollerInitialize( rfalBitRate bitRate )
{
ReturnCode rfalNfcfPollerInitialize(rfalBitRate bitRate) {
ReturnCode ret;
if( (bitRate != RFAL_BR_212) && (bitRate != RFAL_BR_424) )
{
if((bitRate != RFAL_BR_212) && (bitRate != RFAL_BR_424)) {
return ERR_PARAM;
}
EXIT_ON_ERR( ret, rfalSetMode( RFAL_MODE_POLL_NFCF, bitRate, bitRate ) );
rfalSetErrorHandling( RFAL_ERRORHANDLING_NFC );
rfalSetGT( RFAL_GT_NFCF );
rfalSetFDTListen( RFAL_FDT_LISTEN_NFCF_POLLER );
rfalSetFDTPoll( RFAL_FDT_POLL_NFCF_POLLER );
EXIT_ON_ERR(ret, rfalSetMode(RFAL_MODE_POLL_NFCF, bitRate, bitRate));
rfalSetErrorHandling(RFAL_ERRORHANDLING_NFC);
rfalSetGT(RFAL_GT_NFCF);
rfalSetFDTListen(RFAL_FDT_LISTEN_NFCF_POLLER);
rfalSetFDTPoll(RFAL_FDT_POLL_NFCF_POLLER);
return ERR_NONE;
}
/*******************************************************************************/
ReturnCode rfalNfcfPollerPoll( rfalFeliCaPollSlots slots, uint16_t sysCode, uint8_t reqCode, rfalFeliCaPollRes *cardList, uint8_t *devCnt, uint8_t *collisions )
{
return rfalFeliCaPoll( slots, sysCode, reqCode, cardList, rfalNfcfSlots2CardNum(slots), devCnt, collisions );
ReturnCode rfalNfcfPollerPoll(
rfalFeliCaPollSlots slots,
uint16_t sysCode,
uint8_t reqCode,
rfalFeliCaPollRes* cardList,
uint8_t* devCnt,
uint8_t* collisions) {
return rfalFeliCaPoll(
slots, sysCode, reqCode, cardList, rfalNfcfSlots2CardNum(slots), devCnt, collisions);
}
/*******************************************************************************/
ReturnCode rfalNfcfPollerCheckPresence( void )
{
gRfalNfcfGreedyF.pollFound = 0;
ReturnCode rfalNfcfPollerCheckPresence(void) {
gRfalNfcfGreedyF.pollFound = 0;
gRfalNfcfGreedyF.pollCollision = 0;
/* ACTIVITY 1.0 & 1.1 - 9.2.3.17 SENSF_REQ must be with number of slots equal to 4
* SC must be 0xFFFF
* RC must be 0x00 (No system code info required) */
return rfalFeliCaPoll( RFAL_FELICA_4_SLOTS, RFAL_NFCF_SYSTEMCODE, RFAL_FELICA_POLL_RC_NO_REQUEST, gRfalNfcfGreedyF.POLL_F, rfalNfcfSlots2CardNum(RFAL_FELICA_4_SLOTS), &gRfalNfcfGreedyF.pollFound, &gRfalNfcfGreedyF.pollCollision );
return rfalFeliCaPoll(
RFAL_FELICA_4_SLOTS,
RFAL_NFCF_SYSTEMCODE,
RFAL_FELICA_POLL_RC_NO_REQUEST,
gRfalNfcfGreedyF.POLL_F,
rfalNfcfSlots2CardNum(RFAL_FELICA_4_SLOTS),
&gRfalNfcfGreedyF.pollFound,
&gRfalNfcfGreedyF.pollCollision);
}
/*******************************************************************************/
ReturnCode rfalNfcfPollerCollisionResolution( rfalComplianceMode compMode, uint8_t devLimit, rfalNfcfListenDevice *nfcfDevList, uint8_t *devCnt )
{
ReturnCode ret;
bool nfcDepFound;
if( (nfcfDevList == NULL) || (devCnt == NULL) )
{
ReturnCode rfalNfcfPollerCollisionResolution(
rfalComplianceMode compMode,
uint8_t devLimit,
rfalNfcfListenDevice* nfcfDevList,
uint8_t* devCnt) {
ReturnCode ret;
bool nfcDepFound;
if((nfcfDevList == NULL) || (devCnt == NULL)) {
return ERR_PARAM;
}
*devCnt = 0;
nfcDepFound = false;
*devCnt = 0;
nfcDepFound = false;
/*******************************************************************************************/
/* ACTIVITY 1.0 - 9.3.6.3 Copy valid SENSF_RES in GRE_POLL_F into GRE_SENSF_RES */
/* ACTIVITY 1.0 - 9.3.6.6 The NFC Forum Device MUST remove all entries from GRE_SENSF_RES[]*/
@@ -287,259 +309,276 @@ ReturnCode rfalNfcfPollerCollisionResolution( rfalComplianceMode compMode, uint8
/* CON_DEVICES_LIMIT = 0 Just check if devices from Tech Detection exceeds -> always true */
/* Allow the number of slots open on Technology Detection */
/*******************************************************************************************/
rfalNfcfComputeValidSENF( nfcfDevList, devCnt, ((devLimit == 0U) ? rfalNfcfSlots2CardNum( RFAL_FELICA_4_SLOTS ) : devLimit), false, &nfcDepFound );
rfalNfcfComputeValidSENF(
nfcfDevList,
devCnt,
((devLimit == 0U) ? rfalNfcfSlots2CardNum(RFAL_FELICA_4_SLOTS) : devLimit),
false,
&nfcDepFound);
/*******************************************************************************/
/* ACTIVITY 1.0 - 9.3.6.4 */
/* ACTIVITY 1.1 - 9.3.63.60 Check if devices found are lower than the limit */
/* and send a SENSF_REQ if so */
/*******************************************************************************/
if( *devCnt < devLimit )
{
if(*devCnt < devLimit) {
/* ACTIVITY 1.0 - 9.3.6.5 Copy valid SENSF_RES and then to remove it
* ACTIVITY 1.1 - 9.3.6.65 Copy and filter duplicates
* For now, due to some devices keep generating different nfcid2, we use 1.0
* Phones detected: Samsung Galaxy Nexus,Samsung Galaxy S3,Samsung Nexus S */
*devCnt = 0;
ret = rfalNfcfPollerPoll( RFAL_FELICA_16_SLOTS, RFAL_NFCF_SYSTEMCODE, RFAL_FELICA_POLL_RC_NO_REQUEST, gRfalNfcfGreedyF.POLL_F, &gRfalNfcfGreedyF.pollFound, &gRfalNfcfGreedyF.pollCollision );
if( ret == ERR_NONE )
{
rfalNfcfComputeValidSENF( nfcfDevList, devCnt, devLimit, false, &nfcDepFound );
ret = rfalNfcfPollerPoll(
RFAL_FELICA_16_SLOTS,
RFAL_NFCF_SYSTEMCODE,
RFAL_FELICA_POLL_RC_NO_REQUEST,
gRfalNfcfGreedyF.POLL_F,
&gRfalNfcfGreedyF.pollFound,
&gRfalNfcfGreedyF.pollCollision);
if(ret == ERR_NONE) {
rfalNfcfComputeValidSENF(nfcfDevList, devCnt, devLimit, false, &nfcDepFound);
}
/*******************************************************************************/
/* ACTIVITY 1.1 - 9.3.6.63 Check if any device supports NFC DEP */
/*******************************************************************************/
if(nfcDepFound && (compMode == RFAL_COMPLIANCE_MODE_NFC)) {
ret = rfalNfcfPollerPoll(
RFAL_FELICA_16_SLOTS,
RFAL_NFCF_SYSTEMCODE,
RFAL_FELICA_POLL_RC_SYSTEM_CODE,
gRfalNfcfGreedyF.POLL_F,
&gRfalNfcfGreedyF.pollFound,
&gRfalNfcfGreedyF.pollCollision);
if(ret == ERR_NONE) {
rfalNfcfComputeValidSENF(nfcfDevList, devCnt, devLimit, true, &nfcDepFound);
}
}
/*******************************************************************************/
/* ACTIVITY 1.1 - 9.3.6.63 Check if any device supports NFC DEP */
/*******************************************************************************/
if( nfcDepFound && (compMode == RFAL_COMPLIANCE_MODE_NFC) )
{
ret = rfalNfcfPollerPoll( RFAL_FELICA_16_SLOTS, RFAL_NFCF_SYSTEMCODE, RFAL_FELICA_POLL_RC_SYSTEM_CODE, gRfalNfcfGreedyF.POLL_F, &gRfalNfcfGreedyF.pollFound, &gRfalNfcfGreedyF.pollCollision );
if( ret == ERR_NONE )
{
rfalNfcfComputeValidSENF( nfcfDevList, devCnt, devLimit, true, &nfcDepFound );
}
}
}
return ERR_NONE;
}
/*******************************************************************************/
ReturnCode rfalNfcfPollerCheck( const uint8_t* nfcid2, const rfalNfcfServBlockListParam *servBlock, uint8_t *rxBuf, uint16_t rxBufLen, uint16_t *rcvdLen )
{
uint8_t txBuf[RFAL_NFCF_CHECK_REQ_MAX_LEN];
uint8_t msgIt;
uint8_t i;
ReturnCode ret;
const uint8_t *checkRes;
ReturnCode rfalNfcfPollerCheck(
const uint8_t* nfcid2,
const rfalNfcfServBlockListParam* servBlock,
uint8_t* rxBuf,
uint16_t rxBufLen,
uint16_t* rcvdLen) {
uint8_t txBuf[RFAL_NFCF_CHECK_REQ_MAX_LEN];
uint8_t msgIt;
uint8_t i;
ReturnCode ret;
const uint8_t* checkRes;
/* Check parameters */
if( (nfcid2 == NULL) || (rxBuf == NULL) || (servBlock == NULL) ||
(servBlock->numBlock == 0U) || (servBlock->numBlock > RFAL_NFCF_CHECK_REQ_MAX_BLOCK) ||
(servBlock->numServ == 0U) || (servBlock->numServ > RFAL_NFCF_CHECK_REQ_MAX_SERV) ||
(rxBufLen < (RFAL_NFCF_LENGTH_LEN + RFAL_NFCF_CHECK_RES_MIN_LEN)) )
{
if((nfcid2 == NULL) || (rxBuf == NULL) || (servBlock == NULL) || (servBlock->numBlock == 0U) ||
(servBlock->numBlock > RFAL_NFCF_CHECK_REQ_MAX_BLOCK) || (servBlock->numServ == 0U) ||
(servBlock->numServ > RFAL_NFCF_CHECK_REQ_MAX_SERV) ||
(rxBufLen < (RFAL_NFCF_LENGTH_LEN + RFAL_NFCF_CHECK_RES_MIN_LEN))) {
return ERR_PARAM;
}
msgIt = 0;
/*******************************************************************************/
/* Compose CHECK command/request */
txBuf[msgIt++] = RFAL_NFCF_CMD_READ_WITHOUT_ENCRYPTION; /* Command Code */
ST_MEMCPY( &txBuf[msgIt], nfcid2, RFAL_NFCF_NFCID2_LEN ); /* NFCID2 */
txBuf[msgIt++] = RFAL_NFCF_CMD_READ_WITHOUT_ENCRYPTION; /* Command Code */
ST_MEMCPY(&txBuf[msgIt], nfcid2, RFAL_NFCF_NFCID2_LEN); /* NFCID2 */
msgIt += RFAL_NFCF_NFCID2_LEN;
txBuf[msgIt++] = servBlock->numServ; /* NoS */
for( i = 0; i < servBlock->numServ; i++)
{
txBuf[msgIt++] = (uint8_t)((servBlock->servList[i] >> 0U) & 0xFFU); /* Service Code */
txBuf[msgIt++] = (uint8_t)((servBlock->servList[i] >> 8U) & 0xFFU);
txBuf[msgIt++] = servBlock->numServ; /* NoS */
for(i = 0; i < servBlock->numServ; i++) {
txBuf[msgIt++] = (uint8_t)((servBlock->servList[i] >> 0U) & 0xFFU); /* Service Code */
txBuf[msgIt++] = (uint8_t)((servBlock->servList[i] >> 8U) & 0xFFU);
}
txBuf[msgIt++] = servBlock->numBlock; /* NoB */
for( i = 0; i < servBlock->numBlock; i++)
{
txBuf[msgIt++] = servBlock->blockList[i].conf; /* Block list element conf (Flag|Access|Service) */
if( (servBlock->blockList[i].conf & 0x80U) != 0U ) /* Check if 2 or 3 byte block list element */
txBuf[msgIt++] = servBlock->numBlock; /* NoB */
for(i = 0; i < servBlock->numBlock; i++) {
txBuf[msgIt++] =
servBlock->blockList[i].conf; /* Block list element conf (Flag|Access|Service) */
if((servBlock->blockList[i].conf & 0x80U) !=
0U) /* Check if 2 or 3 byte block list element */
{
txBuf[msgIt++] = (uint8_t)(servBlock->blockList[i].blockNum & 0xFFU); /* 1byte Block Num */
}
else
{
txBuf[msgIt++] = (uint8_t)((servBlock->blockList[i].blockNum >> 0U) & 0xFFU); /* 2byte Block Num */
txBuf[msgIt++] =
(uint8_t)(servBlock->blockList[i].blockNum & 0xFFU); /* 1byte Block Num */
} else {
txBuf[msgIt++] =
(uint8_t)((servBlock->blockList[i].blockNum >> 0U) & 0xFFU); /* 2byte Block Num */
txBuf[msgIt++] = (uint8_t)((servBlock->blockList[i].blockNum >> 8U) & 0xFFU);
}
}
/*******************************************************************************/
/* Transceive CHECK command/request */
ret = rfalTransceiveBlockingTxRx( txBuf, msgIt, rxBuf, rxBufLen, rcvdLen, RFAL_TXRX_FLAGS_DEFAULT, RFAL_NFCF_MRT_CHECK_UPDATE );
if( ret == ERR_NONE )
{
ret = rfalTransceiveBlockingTxRx(
txBuf,
msgIt,
rxBuf,
rxBufLen,
rcvdLen,
RFAL_TXRX_FLAGS_DEFAULT,
RFAL_NFCF_MRT_CHECK_UPDATE);
if(ret == ERR_NONE) {
/* Skip LEN byte */
checkRes = (rxBuf + RFAL_NFCF_LENGTH_LEN);
/* Check response length */
if( *rcvdLen < (RFAL_NFCF_LENGTH_LEN + RFAL_NFCF_CHECKUPDATE_RES_ST2_POS) )
{
if(*rcvdLen < (RFAL_NFCF_LENGTH_LEN + RFAL_NFCF_CHECKUPDATE_RES_ST2_POS)) {
ret = ERR_PROTO;
}
/* Check for a valid response */
else if( (checkRes[RFAL_NFCF_CMD_POS] != (uint8_t)RFAL_NFCF_CMD_READ_WITHOUT_ENCRYPTION_RES) ||
(checkRes[RFAL_NFCF_CHECKUPDATE_RES_ST1_POS] != RFAL_NFCF_STATUS_FLAG_SUCCESS) ||
(checkRes[RFAL_NFCF_CHECKUPDATE_RES_ST2_POS] != RFAL_NFCF_STATUS_FLAG_SUCCESS) )
{
else if(
(checkRes[RFAL_NFCF_CMD_POS] != (uint8_t)RFAL_NFCF_CMD_READ_WITHOUT_ENCRYPTION_RES) ||
(checkRes[RFAL_NFCF_CHECKUPDATE_RES_ST1_POS] != RFAL_NFCF_STATUS_FLAG_SUCCESS) ||
(checkRes[RFAL_NFCF_CHECKUPDATE_RES_ST2_POS] != RFAL_NFCF_STATUS_FLAG_SUCCESS)) {
ret = ERR_REQUEST;
}
/* CHECK succesfull, remove header */
else
{
else {
(*rcvdLen) -= (RFAL_NFCF_LENGTH_LEN + RFAL_NFCF_CHECKUPDATE_RES_NOB_POS);
if( *rcvdLen > 0U )
{
ST_MEMMOVE( rxBuf, &checkRes[RFAL_NFCF_CHECKUPDATE_RES_NOB_POS], (*rcvdLen) );
if(*rcvdLen > 0U) {
ST_MEMMOVE(rxBuf, &checkRes[RFAL_NFCF_CHECKUPDATE_RES_NOB_POS], (*rcvdLen));
}
}
}
return ret;
}
/*******************************************************************************/
ReturnCode rfalNfcfPollerUpdate( const uint8_t* nfcid2, const rfalNfcfServBlockListParam *servBlock, uint8_t *txBuf, uint16_t txBufLen, const uint8_t *blockData, uint8_t *rxBuf, uint16_t rxBufLen )
{
uint8_t i;
uint16_t msgIt;
uint16_t rcvdLen;
uint16_t auxLen;
const uint8_t *updateRes;
ReturnCode ret;
ReturnCode rfalNfcfPollerUpdate(
const uint8_t* nfcid2,
const rfalNfcfServBlockListParam* servBlock,
uint8_t* txBuf,
uint16_t txBufLen,
const uint8_t* blockData,
uint8_t* rxBuf,
uint16_t rxBufLen) {
uint8_t i;
uint16_t msgIt;
uint16_t rcvdLen;
uint16_t auxLen;
const uint8_t* updateRes;
ReturnCode ret;
/* Check parameters */
if( (nfcid2 == NULL) || (rxBuf == NULL) || (servBlock == NULL) || (txBuf == NULL) ||
(servBlock->numBlock == 0U) || (servBlock->numBlock > RFAL_NFCF_UPDATE_REQ_MAX_BLOCK) ||
(servBlock->numServ == 0U) || (servBlock->numServ > RFAL_NFCF_UPDATE_REQ_MAX_SERV) ||
(rxBufLen < (RFAL_NFCF_LENGTH_LEN + RFAL_NFCF_UPDATE_RES_MIN_LEN)) )
{
if((nfcid2 == NULL) || (rxBuf == NULL) || (servBlock == NULL) || (txBuf == NULL) ||
(servBlock->numBlock == 0U) || (servBlock->numBlock > RFAL_NFCF_UPDATE_REQ_MAX_BLOCK) ||
(servBlock->numServ == 0U) || (servBlock->numServ > RFAL_NFCF_UPDATE_REQ_MAX_SERV) ||
(rxBufLen < (RFAL_NFCF_LENGTH_LEN + RFAL_NFCF_UPDATE_RES_MIN_LEN))) {
return ERR_PARAM;
}
/* Calculate required txBuffer lenth */
auxLen = (uint16_t)( RFAL_NFCF_CMD_LEN + RFAL_NFCF_NFCID2_LEN + ( servBlock->numServ * sizeof(rfalNfcfServ) ) +
(servBlock->numBlock * sizeof(rfalNfcfBlockListElem)) + (uint16_t)((uint16_t)servBlock->numBlock * RFAL_NFCF_BLOCK_LEN) );
/* Check whether the provided buffer is sufficient for this request */
if( txBufLen < auxLen )
{
if(txBufLen < auxLen) {
return ERR_PARAM;
}
msgIt = 0;
/*******************************************************************************/
/* Compose UPDATE command/request */
txBuf[msgIt++] = RFAL_NFCF_CMD_WRITE_WITHOUT_ENCRYPTION; /* Command Code */
ST_MEMCPY( &txBuf[msgIt], nfcid2, RFAL_NFCF_NFCID2_LEN ); /* NFCID2 */
txBuf[msgIt++] = RFAL_NFCF_CMD_WRITE_WITHOUT_ENCRYPTION; /* Command Code */
ST_MEMCPY(&txBuf[msgIt], nfcid2, RFAL_NFCF_NFCID2_LEN); /* NFCID2 */
msgIt += RFAL_NFCF_NFCID2_LEN;
txBuf[msgIt++] = servBlock->numServ; /* NoS */
for( i = 0; i < servBlock->numServ; i++)
{
txBuf[msgIt++] = (uint8_t)((servBlock->servList[i] >> 0U) & 0xFFU); /* Service Code */
txBuf[msgIt++] = (uint8_t)((servBlock->servList[i] >> 8U) & 0xFFU);
txBuf[msgIt++] = servBlock->numServ; /* NoS */
for(i = 0; i < servBlock->numServ; i++) {
txBuf[msgIt++] = (uint8_t)((servBlock->servList[i] >> 0U) & 0xFFU); /* Service Code */
txBuf[msgIt++] = (uint8_t)((servBlock->servList[i] >> 8U) & 0xFFU);
}
txBuf[msgIt++] = servBlock->numBlock; /* NoB */
for( i = 0; i < servBlock->numBlock; i++)
{
txBuf[msgIt++] = servBlock->blockList[i].conf; /* Block list element conf (Flag|Access|Service) */
if( (servBlock->blockList[i].conf & 0x80U) != 0U ) /* Check if 2 or 3 byte block list element */
txBuf[msgIt++] = servBlock->numBlock; /* NoB */
for(i = 0; i < servBlock->numBlock; i++) {
txBuf[msgIt++] =
servBlock->blockList[i].conf; /* Block list element conf (Flag|Access|Service) */
if((servBlock->blockList[i].conf & 0x80U) !=
0U) /* Check if 2 or 3 byte block list element */
{
txBuf[msgIt++] = (uint8_t)(servBlock->blockList[i].blockNum & 0xFFU); /* 1byte Block Num */
}
else
{
txBuf[msgIt++] = (uint8_t)((servBlock->blockList[i].blockNum >> 0U) & 0xFFU); /* 2byte Block Num */
txBuf[msgIt++] =
(uint8_t)(servBlock->blockList[i].blockNum & 0xFFU); /* 1byte Block Num */
} else {
txBuf[msgIt++] =
(uint8_t)((servBlock->blockList[i].blockNum >> 0U) & 0xFFU); /* 2byte Block Num */
txBuf[msgIt++] = (uint8_t)((servBlock->blockList[i].blockNum >> 8U) & 0xFFU);
}
}
auxLen = ((uint16_t)servBlock->numBlock * RFAL_NFCF_BLOCK_LEN);
ST_MEMCPY( &txBuf[msgIt], blockData, auxLen ); /* Block Data */
ST_MEMCPY(&txBuf[msgIt], blockData, auxLen); /* Block Data */
msgIt += auxLen;
/*******************************************************************************/
/* Transceive UPDATE command/request */
ret = rfalTransceiveBlockingTxRx( txBuf, msgIt, rxBuf, rxBufLen, &rcvdLen, RFAL_TXRX_FLAGS_DEFAULT, RFAL_NFCF_MRT_CHECK_UPDATE );
if( ret == ERR_NONE )
{
ret = rfalTransceiveBlockingTxRx(
txBuf,
msgIt,
rxBuf,
rxBufLen,
&rcvdLen,
RFAL_TXRX_FLAGS_DEFAULT,
RFAL_NFCF_MRT_CHECK_UPDATE);
if(ret == ERR_NONE) {
/* Skip LEN byte */
updateRes = (rxBuf + RFAL_NFCF_LENGTH_LEN);
/* Check response length */
if( rcvdLen < (RFAL_NFCF_LENGTH_LEN + RFAL_NFCF_CHECKUPDATE_RES_ST2_POS) )
{
if(rcvdLen < (RFAL_NFCF_LENGTH_LEN + RFAL_NFCF_CHECKUPDATE_RES_ST2_POS)) {
ret = ERR_PROTO;
}
/* Check for a valid response */
else if( (updateRes[RFAL_NFCF_CMD_POS] != (uint8_t)RFAL_NFCF_CMD_WRITE_WITHOUT_ENCRYPTION_RES) ||
(updateRes[RFAL_NFCF_CHECKUPDATE_RES_ST1_POS] != RFAL_NFCF_STATUS_FLAG_SUCCESS) ||
(updateRes[RFAL_NFCF_CHECKUPDATE_RES_ST2_POS] != RFAL_NFCF_STATUS_FLAG_SUCCESS) )
{
else if(
(updateRes[RFAL_NFCF_CMD_POS] !=
(uint8_t)RFAL_NFCF_CMD_WRITE_WITHOUT_ENCRYPTION_RES) ||
(updateRes[RFAL_NFCF_CHECKUPDATE_RES_ST1_POS] != RFAL_NFCF_STATUS_FLAG_SUCCESS) ||
(updateRes[RFAL_NFCF_CHECKUPDATE_RES_ST2_POS] != RFAL_NFCF_STATUS_FLAG_SUCCESS)) {
ret = ERR_REQUEST;
}
else
{
} else {
/* MISRA 15.7 - Empty else */
}
}
return ret;
}
/*******************************************************************************/
bool rfalNfcfListenerIsT3TReq( const uint8_t* buf, uint16_t bufLen, uint8_t* nfcid2 )
{
bool rfalNfcfListenerIsT3TReq(const uint8_t* buf, uint16_t bufLen, uint8_t* nfcid2) {
/* Check cmd byte */
switch( *buf )
{
case RFAL_NFCF_CMD_READ_WITHOUT_ENCRYPTION:
if( bufLen < RFAL_NFCF_READ_WO_ENCRYPTION_MIN_LEN )
{
return false;
}
break;
case RFAL_NFCF_CMD_WRITE_WITHOUT_ENCRYPTION:
if( bufLen < RFAL_NFCF_WRITE_WO_ENCRYPTION_MIN_LEN )
{
return false;
}
break;
default:
return false;
switch(*buf) {
case RFAL_NFCF_CMD_READ_WITHOUT_ENCRYPTION:
if(bufLen < RFAL_NFCF_READ_WO_ENCRYPTION_MIN_LEN) {
return false;
}
break;
case RFAL_NFCF_CMD_WRITE_WITHOUT_ENCRYPTION:
if(bufLen < RFAL_NFCF_WRITE_WO_ENCRYPTION_MIN_LEN) {
return false;
}
break;
default:
return false;
}
/* Output NFID2 if requested */
if( nfcid2 != NULL )
{
ST_MEMCPY( nfcid2, &buf[RFAL_NFCF_CMD_LEN], RFAL_NFCF_NFCID2_LEN );
if(nfcid2 != NULL) {
ST_MEMCPY(nfcid2, &buf[RFAL_NFCF_CMD_LEN], RFAL_NFCF_NFCID2_LEN);
}
return true;
}
+615 -428
View File
File diff suppressed because it is too large Load Diff
+257 -255
View File
@@ -48,7 +48,7 @@
******************************************************************************
*/
#ifndef RFAL_FEATURE_ST25TB
#define RFAL_FEATURE_ST25TB false /* ST25TB module configuration missing. Disabled by default */
#define RFAL_FEATURE_ST25TB false /* ST25TB module configuration missing. Disabled by default */
#endif
#if RFAL_FEATURE_ST25TB
@@ -59,29 +59,28 @@
******************************************************************************
*/
#define RFAL_ST25TB_CMD_LEN 1U /*!< ST25TB length of a command */
#define RFAL_ST25TB_SLOTS 16U /*!< ST25TB number of slots */
#define RFAL_ST25TB_SLOTNUM_MASK 0x0FU /*!< ST25TB Slot Number bit mask on SlotMarker */
#define RFAL_ST25TB_SLOTNUM_SHIFT 4U /*!< ST25TB Slot Number shift on SlotMarker */
#define RFAL_ST25TB_CMD_LEN 1U /*!< ST25TB length of a command */
#define RFAL_ST25TB_SLOTS 16U /*!< ST25TB number of slots */
#define RFAL_ST25TB_SLOTNUM_MASK 0x0FU /*!< ST25TB Slot Number bit mask on SlotMarker */
#define RFAL_ST25TB_SLOTNUM_SHIFT 4U /*!< ST25TB Slot Number shift on SlotMarker */
#define RFAL_ST25TB_INITIATE_CMD1 0x06U /*!< ST25TB Initiate command byte1 */
#define RFAL_ST25TB_INITIATE_CMD2 0x00U /*!< ST25TB Initiate command byte2 */
#define RFAL_ST25TB_PCALL_CMD1 0x06U /*!< ST25TB Pcall16 command byte1 */
#define RFAL_ST25TB_PCALL_CMD2 0x04U /*!< ST25TB Pcall16 command byte2 */
#define RFAL_ST25TB_SELECT_CMD 0x0EU /*!< ST25TB Select command */
#define RFAL_ST25TB_GET_UID_CMD 0x0BU /*!< ST25TB Get UID command */
#define RFAL_ST25TB_COMPLETION_CMD 0x0FU /*!< ST25TB Completion command */
#define RFAL_ST25TB_RESET_INV_CMD 0x0CU /*!< ST25TB Reset to Inventory command */
#define RFAL_ST25TB_READ_BLOCK_CMD 0x08U /*!< ST25TB Read Block command */
#define RFAL_ST25TB_WRITE_BLOCK_CMD 0x09U /*!< ST25TB Write Block command */
#define RFAL_ST25TB_INITIATE_CMD1 0x06U /*!< ST25TB Initiate command byte1 */
#define RFAL_ST25TB_INITIATE_CMD2 0x00U /*!< ST25TB Initiate command byte2 */
#define RFAL_ST25TB_PCALL_CMD1 0x06U /*!< ST25TB Pcall16 command byte1 */
#define RFAL_ST25TB_PCALL_CMD2 0x04U /*!< ST25TB Pcall16 command byte2 */
#define RFAL_ST25TB_SELECT_CMD 0x0EU /*!< ST25TB Select command */
#define RFAL_ST25TB_GET_UID_CMD 0x0BU /*!< ST25TB Get UID command */
#define RFAL_ST25TB_COMPLETION_CMD 0x0FU /*!< ST25TB Completion command */
#define RFAL_ST25TB_RESET_INV_CMD 0x0CU /*!< ST25TB Reset to Inventory command */
#define RFAL_ST25TB_READ_BLOCK_CMD 0x08U /*!< ST25TB Read Block command */
#define RFAL_ST25TB_WRITE_BLOCK_CMD 0x09U /*!< ST25TB Write Block command */
#define RFAL_ST25TB_T0 2157U /*!< ST25TB t0 159 us ST25TB RF characteristics */
#define RFAL_ST25TB_T1 2048U /*!< ST25TB t1 151 us ST25TB RF characteristics */
#define RFAL_ST25TB_T0 2157U /*!< ST25TB t0 159 us ST25TB RF characteristics */
#define RFAL_ST25TB_T1 2048U /*!< ST25TB t1 151 us ST25TB RF characteristics */
#define RFAL_ST25TB_FWT (RFAL_ST25TB_T0 + RFAL_ST25TB_T1) /*!< ST25TB FWT = T0 + T1 */
#define RFAL_ST25TB_TW rfalConvMsTo1fc(7U) /*!< ST25TB TW : Programming time for write max 7ms */
#define RFAL_ST25TB_FWT \
(RFAL_ST25TB_T0 + RFAL_ST25TB_T1) /*!< ST25TB FWT = T0 + T1 */
#define RFAL_ST25TB_TW rfalConvMsTo1fc(7U) /*!< ST25TB TW : Programming time for write max 7ms */
/*
******************************************************************************
@@ -96,43 +95,36 @@
*/
/*! Initiate Request */
typedef struct
{
uint8_t cmd1; /*!< Initiate Request cmd1: 0x06 */
uint8_t cmd2; /*!< Initiate Request cmd2: 0x00 */
typedef struct {
uint8_t cmd1; /*!< Initiate Request cmd1: 0x06 */
uint8_t cmd2; /*!< Initiate Request cmd2: 0x00 */
} rfalSt25tbInitiateReq;
/*! Pcall16 Request */
typedef struct
{
uint8_t cmd1; /*!< Pcal16 Request cmd1: 0x06 */
uint8_t cmd2; /*!< Pcal16 Request cmd2: 0x04 */
typedef struct {
uint8_t cmd1; /*!< Pcal16 Request cmd1: 0x06 */
uint8_t cmd2; /*!< Pcal16 Request cmd2: 0x04 */
} rfalSt25tbPcallReq;
/*! Select Request */
typedef struct
{
uint8_t cmd; /*!< Select Request cmd: 0x0E */
uint8_t chipId; /*!< Chip ID */
typedef struct {
uint8_t cmd; /*!< Select Request cmd: 0x0E */
uint8_t chipId; /*!< Chip ID */
} rfalSt25tbSelectReq;
/*! Read Block Request */
typedef struct
{
uint8_t cmd; /*!< Select Request cmd: 0x08 */
uint8_t address; /*!< Block address */
typedef struct {
uint8_t cmd; /*!< Select Request cmd: 0x08 */
uint8_t address; /*!< Block address */
} rfalSt25tbReadBlockReq;
/*! Write Block Request */
typedef struct
{
uint8_t cmd; /*!< Select Request cmd: 0x09 */
uint8_t address; /*!< Block address */
rfalSt25tbBlock data; /*!< Block Data */
typedef struct {
uint8_t cmd; /*!< Select Request cmd: 0x09 */
uint8_t address; /*!< Block address */
rfalSt25tbBlock data; /*!< Block Data */
} rfalSt25tbWriteBlockReq;
/*
******************************************************************************
* LOCAL FUNCTION PROTOTYPES
@@ -151,7 +143,10 @@ typedef struct
* \return colPending : true if a collision was detected
*****************************************************************************
*/
static bool rfalSt25tbPollerDoCollisionResolution( uint8_t devLimit, rfalSt25tbListenDevice *st25tbDevList, uint8_t *devCnt );
static bool rfalSt25tbPollerDoCollisionResolution(
uint8_t devLimit,
rfalSt25tbListenDevice* st25tbDevList,
uint8_t* devCnt);
/*
******************************************************************************
@@ -159,74 +154,61 @@ static bool rfalSt25tbPollerDoCollisionResolution( uint8_t devLimit, rfalSt25tbL
******************************************************************************
*/
static bool rfalSt25tbPollerDoCollisionResolution( uint8_t devLimit, rfalSt25tbListenDevice *st25tbDevList, uint8_t *devCnt )
{
uint8_t i;
uint8_t chipId;
static bool rfalSt25tbPollerDoCollisionResolution(
uint8_t devLimit,
rfalSt25tbListenDevice* st25tbDevList,
uint8_t* devCnt) {
uint8_t i;
uint8_t chipId;
ReturnCode ret;
bool col;
col = false;
for(i = 0; i < RFAL_ST25TB_SLOTS; i++)
{
platformDelay(1); /* Wait t2: Answer to new request delay */
if( i==0U )
{
for(i = 0; i < RFAL_ST25TB_SLOTS; i++) {
platformDelay(1); /* Wait t2: Answer to new request delay */
if(i == 0U) {
/* Step 2: Send Pcall16 */
ret = rfalSt25tbPollerPcall( &chipId );
}
else
{
ret = rfalSt25tbPollerPcall(&chipId);
} else {
/* Step 3-17: Send Pcall16 */
ret = rfalSt25tbPollerSlotMarker( i, &chipId );
ret = rfalSt25tbPollerSlotMarker(i, &chipId);
}
if( ret == ERR_NONE )
{
if(ret == ERR_NONE) {
/* Found another device */
st25tbDevList[*devCnt].chipID = chipId;
st25tbDevList[*devCnt].chipID = chipId;
st25tbDevList[*devCnt].isDeselected = false;
/* Select Device, retrieve its UID */
ret = rfalSt25tbPollerSelect( chipId );
ret = rfalSt25tbPollerSelect(chipId);
/* By Selecting this device, the previous gets Deselected */
if( (*devCnt) > 0U )
{
st25tbDevList[(*devCnt)-1U].isDeselected = true;
if((*devCnt) > 0U) {
st25tbDevList[(*devCnt) - 1U].isDeselected = true;
}
if( ERR_NONE == ret )
{
rfalSt25tbPollerGetUID( &st25tbDevList[*devCnt].UID );
if(ERR_NONE == ret) {
rfalSt25tbPollerGetUID(&st25tbDevList[*devCnt].UID);
}
if( ERR_NONE == ret )
{
if(ERR_NONE == ret) {
(*devCnt)++;
}
}
else if( (ret == ERR_CRC) || (ret == ERR_FRAMING) )
{
} else if((ret == ERR_CRC) || (ret == ERR_FRAMING)) {
col = true;
}
else
{
} else {
/* MISRA 15.7 - Empty else */
}
if( *devCnt >= devLimit )
{
if(*devCnt >= devLimit) {
break;
}
}
return col;
}
/*
******************************************************************************
* LOCAL VARIABLES
@@ -240,291 +222,301 @@ static bool rfalSt25tbPollerDoCollisionResolution( uint8_t devLimit, rfalSt25tbL
*/
/*******************************************************************************/
ReturnCode rfalSt25tbPollerInitialize( void )
{
ReturnCode rfalSt25tbPollerInitialize(void) {
return rfalNfcbPollerInitialize();
}
/*******************************************************************************/
ReturnCode rfalSt25tbPollerCheckPresence( uint8_t *chipId )
{
ReturnCode rfalSt25tbPollerCheckPresence(uint8_t* chipId) {
ReturnCode ret;
uint8_t chipIdRes;
uint8_t chipIdRes;
chipIdRes = 0x00;
/* Send Initiate Request */
ret = rfalSt25tbPollerInitiate( &chipIdRes );
ret = rfalSt25tbPollerInitiate(&chipIdRes);
/* Check if a transmission error was detected */
if( (ret == ERR_CRC) || (ret == ERR_FRAMING) )
{
if((ret == ERR_CRC) || (ret == ERR_FRAMING)) {
return ERR_NONE;
}
/* Copy chip ID if requested */
if( chipId != NULL )
{
if(chipId != NULL) {
*chipId = chipIdRes;
}
return ret;
}
/*******************************************************************************/
ReturnCode rfalSt25tbPollerInitiate( uint8_t *chipId )
{
ReturnCode ret;
uint16_t rxLen;
ReturnCode rfalSt25tbPollerInitiate(uint8_t* chipId) {
ReturnCode ret;
uint16_t rxLen;
rfalSt25tbInitiateReq initiateReq;
uint8_t rxBuf[RFAL_ST25TB_CHIP_ID_LEN + RFAL_ST25TB_CRC_LEN]; /* In case we receive less data that CRC, RF layer will not remove the CRC from buffer */
uint8_t rxBuf
[RFAL_ST25TB_CHIP_ID_LEN +
RFAL_ST25TB_CRC_LEN]; /* In case we receive less data that CRC, RF layer will not remove the CRC from buffer */
/* Compute Initiate Request */
initiateReq.cmd1 = RFAL_ST25TB_INITIATE_CMD1;
initiateReq.cmd2 = RFAL_ST25TB_INITIATE_CMD2;
initiateReq.cmd1 = RFAL_ST25TB_INITIATE_CMD1;
initiateReq.cmd2 = RFAL_ST25TB_INITIATE_CMD2;
/* Send Initiate Request */
ret = rfalTransceiveBlockingTxRx( (uint8_t*)&initiateReq, sizeof(rfalSt25tbInitiateReq), (uint8_t*)rxBuf, sizeof(rxBuf), &rxLen, RFAL_TXRX_FLAGS_DEFAULT, RFAL_ST25TB_FWT );
ret = rfalTransceiveBlockingTxRx(
(uint8_t*)&initiateReq,
sizeof(rfalSt25tbInitiateReq),
(uint8_t*)rxBuf,
sizeof(rxBuf),
&rxLen,
RFAL_TXRX_FLAGS_DEFAULT,
RFAL_ST25TB_FWT);
/* Check for valid Select Response */
if( (ret == ERR_NONE) && (rxLen != RFAL_ST25TB_CHIP_ID_LEN) )
{
if((ret == ERR_NONE) && (rxLen != RFAL_ST25TB_CHIP_ID_LEN)) {
return ERR_PROTO;
}
/* Copy chip ID if requested */
if( chipId != NULL )
{
if(chipId != NULL) {
*chipId = *rxBuf;
}
return ret;
}
/*******************************************************************************/
ReturnCode rfalSt25tbPollerPcall( uint8_t *chipId )
{
ReturnCode ret;
uint16_t rxLen;
ReturnCode rfalSt25tbPollerPcall(uint8_t* chipId) {
ReturnCode ret;
uint16_t rxLen;
rfalSt25tbPcallReq pcallReq;
/* Compute Pcal16 Request */
pcallReq.cmd1 = RFAL_ST25TB_PCALL_CMD1;
pcallReq.cmd2 = RFAL_ST25TB_PCALL_CMD2;
pcallReq.cmd1 = RFAL_ST25TB_PCALL_CMD1;
pcallReq.cmd2 = RFAL_ST25TB_PCALL_CMD2;
/* Send Pcal16 Request */
ret = rfalTransceiveBlockingTxRx( (uint8_t*)&pcallReq, sizeof(rfalSt25tbPcallReq), (uint8_t*)chipId, RFAL_ST25TB_CHIP_ID_LEN, &rxLen, RFAL_TXRX_FLAGS_DEFAULT, RFAL_ST25TB_FWT );
ret = rfalTransceiveBlockingTxRx(
(uint8_t*)&pcallReq,
sizeof(rfalSt25tbPcallReq),
(uint8_t*)chipId,
RFAL_ST25TB_CHIP_ID_LEN,
&rxLen,
RFAL_TXRX_FLAGS_DEFAULT,
RFAL_ST25TB_FWT);
/* Check for valid Select Response */
if( (ret == ERR_NONE) && (rxLen != RFAL_ST25TB_CHIP_ID_LEN) )
{
if((ret == ERR_NONE) && (rxLen != RFAL_ST25TB_CHIP_ID_LEN)) {
return ERR_PROTO;
}
return ret;
}
/*******************************************************************************/
ReturnCode rfalSt25tbPollerSlotMarker( uint8_t slotNum, uint8_t *chipIdRes )
{
ReturnCode rfalSt25tbPollerSlotMarker(uint8_t slotNum, uint8_t* chipIdRes) {
ReturnCode ret;
uint16_t rxLen;
uint8_t slotMarker;
uint16_t rxLen;
uint8_t slotMarker;
if( (slotNum == 0U) || (slotNum > 15U) )
{
if((slotNum == 0U) || (slotNum > 15U)) {
return ERR_PARAM;
}
/* Compute SlotMarker */
slotMarker = ( ((slotNum & RFAL_ST25TB_SLOTNUM_MASK) << RFAL_ST25TB_SLOTNUM_SHIFT) | RFAL_ST25TB_PCALL_CMD1 );
slotMarker =
(((slotNum & RFAL_ST25TB_SLOTNUM_MASK) << RFAL_ST25TB_SLOTNUM_SHIFT) |
RFAL_ST25TB_PCALL_CMD1);
/* Send SlotMarker */
ret = rfalTransceiveBlockingTxRx( (uint8_t*)&slotMarker, RFAL_ST25TB_CMD_LEN, (uint8_t*)chipIdRes, RFAL_ST25TB_CHIP_ID_LEN, &rxLen, RFAL_TXRX_FLAGS_DEFAULT, RFAL_ST25TB_FWT );
ret = rfalTransceiveBlockingTxRx(
(uint8_t*)&slotMarker,
RFAL_ST25TB_CMD_LEN,
(uint8_t*)chipIdRes,
RFAL_ST25TB_CHIP_ID_LEN,
&rxLen,
RFAL_TXRX_FLAGS_DEFAULT,
RFAL_ST25TB_FWT);
/* Check for valid ChipID Response */
if( (ret == ERR_NONE) && (rxLen != RFAL_ST25TB_CHIP_ID_LEN) )
{
if((ret == ERR_NONE) && (rxLen != RFAL_ST25TB_CHIP_ID_LEN)) {
return ERR_PROTO;
}
return ret;
}
/*******************************************************************************/
ReturnCode rfalSt25tbPollerSelect( uint8_t chipId )
{
ReturnCode ret;
uint16_t rxLen;
ReturnCode rfalSt25tbPollerSelect(uint8_t chipId) {
ReturnCode ret;
uint16_t rxLen;
rfalSt25tbSelectReq selectReq;
uint8_t chipIdRes;
uint8_t chipIdRes;
/* Compute Select Request */
selectReq.cmd = RFAL_ST25TB_SELECT_CMD;
selectReq.cmd = RFAL_ST25TB_SELECT_CMD;
selectReq.chipId = chipId;
/* Send Select Request */
ret = rfalTransceiveBlockingTxRx( (uint8_t*)&selectReq, sizeof(rfalSt25tbSelectReq), (uint8_t*)&chipIdRes, RFAL_ST25TB_CHIP_ID_LEN, &rxLen, RFAL_TXRX_FLAGS_DEFAULT, RFAL_ST25TB_FWT );
ret = rfalTransceiveBlockingTxRx(
(uint8_t*)&selectReq,
sizeof(rfalSt25tbSelectReq),
(uint8_t*)&chipIdRes,
RFAL_ST25TB_CHIP_ID_LEN,
&rxLen,
RFAL_TXRX_FLAGS_DEFAULT,
RFAL_ST25TB_FWT);
/* Check for valid Select Response */
if( (ret == ERR_NONE) && ((rxLen != RFAL_ST25TB_CHIP_ID_LEN) || (chipIdRes != chipId)) )
{
if((ret == ERR_NONE) && ((rxLen != RFAL_ST25TB_CHIP_ID_LEN) || (chipIdRes != chipId))) {
return ERR_PROTO;
}
return ret;
}
/*******************************************************************************/
ReturnCode rfalSt25tbPollerGetUID( rfalSt25tbUID *UID )
{
ReturnCode rfalSt25tbPollerGetUID(rfalSt25tbUID* UID) {
ReturnCode ret;
uint16_t rxLen;
uint8_t getUidReq;
uint16_t rxLen;
uint8_t getUidReq;
/* Compute Get UID Request */
getUidReq = RFAL_ST25TB_GET_UID_CMD;
/* Send Select Request */
ret = rfalTransceiveBlockingTxRx( (uint8_t*)&getUidReq, RFAL_ST25TB_CMD_LEN, (uint8_t*)UID, sizeof(rfalSt25tbUID), &rxLen, RFAL_TXRX_FLAGS_DEFAULT, RFAL_ST25TB_FWT );
ret = rfalTransceiveBlockingTxRx(
(uint8_t*)&getUidReq,
RFAL_ST25TB_CMD_LEN,
(uint8_t*)UID,
sizeof(rfalSt25tbUID),
&rxLen,
RFAL_TXRX_FLAGS_DEFAULT,
RFAL_ST25TB_FWT);
/* Check for valid UID Response */
if( (ret == ERR_NONE) && (rxLen != RFAL_ST25TB_UID_LEN) )
{
if((ret == ERR_NONE) && (rxLen != RFAL_ST25TB_UID_LEN)) {
return ERR_PROTO;
}
return ret;
}
/*******************************************************************************/
ReturnCode rfalSt25tbPollerCollisionResolution( uint8_t devLimit, rfalSt25tbListenDevice *st25tbDevList, uint8_t *devCnt )
{
uint8_t chipId;
ReturnCode rfalSt25tbPollerCollisionResolution(
uint8_t devLimit,
rfalSt25tbListenDevice* st25tbDevList,
uint8_t* devCnt) {
uint8_t chipId;
ReturnCode ret;
bool detected; /* collision or device was detected */
if( (st25tbDevList == NULL) || (devCnt == NULL) || (devLimit == 0U) )
{
bool detected; /* collision or device was detected */
if((st25tbDevList == NULL) || (devCnt == NULL) || (devLimit == 0U)) {
return ERR_PARAM;
}
*devCnt = 0;
/* Step 1: Send Initiate */
ret = rfalSt25tbPollerInitiate( &chipId );
if( ret == ERR_NONE )
{
ret = rfalSt25tbPollerInitiate(&chipId);
if(ret == ERR_NONE) {
/* If only 1 answer is detected */
st25tbDevList[*devCnt].chipID = chipId;
st25tbDevList[*devCnt].chipID = chipId;
st25tbDevList[*devCnt].isDeselected = false;
/* Retrieve its UID and keep it Selected*/
ret = rfalSt25tbPollerSelect( chipId );
if( ERR_NONE == ret )
{
ret = rfalSt25tbPollerGetUID( &st25tbDevList[*devCnt].UID );
ret = rfalSt25tbPollerSelect(chipId);
if(ERR_NONE == ret) {
ret = rfalSt25tbPollerGetUID(&st25tbDevList[*devCnt].UID);
}
if( ERR_NONE == ret )
{
if(ERR_NONE == ret) {
(*devCnt)++;
}
}
/* Always proceed to Pcall16 anticollision as phase differences of tags can lead to no tag recognized, even if there is one */
if( *devCnt < devLimit )
{
if(*devCnt < devLimit) {
/* Multiple device responses */
do
{
detected = rfalSt25tbPollerDoCollisionResolution( devLimit, st25tbDevList, devCnt );
}
while( (detected == true) && (*devCnt < devLimit) );
do {
detected = rfalSt25tbPollerDoCollisionResolution(devLimit, st25tbDevList, devCnt);
} while((detected == true) && (*devCnt < devLimit));
}
return ERR_NONE;
}
/*******************************************************************************/
ReturnCode rfalSt25tbPollerReadBlock( uint8_t blockAddress, rfalSt25tbBlock *blockData )
{
ReturnCode ret;
uint16_t rxLen;
ReturnCode rfalSt25tbPollerReadBlock(uint8_t blockAddress, rfalSt25tbBlock* blockData) {
ReturnCode ret;
uint16_t rxLen;
rfalSt25tbReadBlockReq readBlockReq;
/* Compute Read Block Request */
readBlockReq.cmd = RFAL_ST25TB_READ_BLOCK_CMD;
readBlockReq.cmd = RFAL_ST25TB_READ_BLOCK_CMD;
readBlockReq.address = blockAddress;
/* Send Read Block Request */
ret = rfalTransceiveBlockingTxRx( (uint8_t*)&readBlockReq, sizeof(rfalSt25tbReadBlockReq), (uint8_t*)blockData, sizeof(rfalSt25tbBlock), &rxLen, RFAL_TXRX_FLAGS_DEFAULT, RFAL_ST25TB_FWT );
ret = rfalTransceiveBlockingTxRx(
(uint8_t*)&readBlockReq,
sizeof(rfalSt25tbReadBlockReq),
(uint8_t*)blockData,
sizeof(rfalSt25tbBlock),
&rxLen,
RFAL_TXRX_FLAGS_DEFAULT,
RFAL_ST25TB_FWT);
/* Check for valid UID Response */
if( (ret == ERR_NONE) && (rxLen != RFAL_ST25TB_BLOCK_LEN) )
{
if((ret == ERR_NONE) && (rxLen != RFAL_ST25TB_BLOCK_LEN)) {
return ERR_PROTO;
}
return ret;
}
/*******************************************************************************/
ReturnCode rfalSt25tbPollerWriteBlock( uint8_t blockAddress, const rfalSt25tbBlock *blockData )
{
ReturnCode ret;
uint16_t rxLen;
ReturnCode rfalSt25tbPollerWriteBlock(uint8_t blockAddress, const rfalSt25tbBlock* blockData) {
ReturnCode ret;
uint16_t rxLen;
rfalSt25tbWriteBlockReq writeBlockReq;
rfalSt25tbBlock tmpBlockData;
rfalSt25tbBlock tmpBlockData;
/* Compute Write Block Request */
writeBlockReq.cmd = RFAL_ST25TB_WRITE_BLOCK_CMD;
writeBlockReq.cmd = RFAL_ST25TB_WRITE_BLOCK_CMD;
writeBlockReq.address = blockAddress;
ST_MEMCPY( &writeBlockReq.data, blockData, RFAL_ST25TB_BLOCK_LEN );
ST_MEMCPY(&writeBlockReq.data, blockData, RFAL_ST25TB_BLOCK_LEN);
/* Send Write Block Request */
ret = rfalTransceiveBlockingTxRx( (uint8_t*)&writeBlockReq, sizeof(rfalSt25tbWriteBlockReq), tmpBlockData, RFAL_ST25TB_BLOCK_LEN, &rxLen, RFAL_TXRX_FLAGS_DEFAULT, (RFAL_ST25TB_FWT + RFAL_ST25TB_TW) );
ret = rfalTransceiveBlockingTxRx(
(uint8_t*)&writeBlockReq,
sizeof(rfalSt25tbWriteBlockReq),
tmpBlockData,
RFAL_ST25TB_BLOCK_LEN,
&rxLen,
RFAL_TXRX_FLAGS_DEFAULT,
(RFAL_ST25TB_FWT + RFAL_ST25TB_TW));
/* Check if there was any error besides timeout */
if( ret != ERR_TIMEOUT )
{
if(ret != ERR_TIMEOUT) {
/* Check if an unexpected answer was received */
if( ret == ERR_NONE )
{
if(ret == ERR_NONE) {
return ERR_PROTO;
}
/* Check whether a transmission error occurred */
if( (ret != ERR_CRC) && (ret != ERR_FRAMING) && (ret != ERR_NOMEM) && (ret != ERR_RF_COLLISION) )
{
if((ret != ERR_CRC) && (ret != ERR_FRAMING) && (ret != ERR_NOMEM) &&
(ret != ERR_RF_COLLISION)) {
return ret;
}
/* If a transmission error occurred (maybe noise while commiting data) wait maximum programming time and verify data afterwards */
rfalSetGT( (RFAL_ST25TB_FWT + RFAL_ST25TB_TW) );
rfalSetGT((RFAL_ST25TB_FWT + RFAL_ST25TB_TW));
rfalFieldOnAndStartGT();
}
ret = rfalSt25tbPollerReadBlock(blockAddress, &tmpBlockData);
if( ret == ERR_NONE )
{
if( ST_BYTECMP( &tmpBlockData, blockData, RFAL_ST25TB_BLOCK_LEN ) == 0 )
{
if(ret == ERR_NONE) {
if(ST_BYTECMP(&tmpBlockData, blockData, RFAL_ST25TB_BLOCK_LEN) == 0) {
return ERR_NONE;
}
return ERR_PROTO;
@@ -532,30 +524,40 @@ ReturnCode rfalSt25tbPollerWriteBlock( uint8_t blockAddress, const rfalSt25tbBlo
return ret;
}
/*******************************************************************************/
ReturnCode rfalSt25tbPollerCompletion( void )
{
uint8_t completionReq;
ReturnCode rfalSt25tbPollerCompletion(void) {
uint8_t completionReq;
/* Compute Completion Request */
completionReq = RFAL_ST25TB_COMPLETION_CMD;
/* Send Completion Request, no response is expected */
return rfalTransceiveBlockingTxRx( (uint8_t*)&completionReq, RFAL_ST25TB_CMD_LEN, NULL, 0, NULL, RFAL_TXRX_FLAGS_DEFAULT, RFAL_ST25TB_FWT );
return rfalTransceiveBlockingTxRx(
(uint8_t*)&completionReq,
RFAL_ST25TB_CMD_LEN,
NULL,
0,
NULL,
RFAL_TXRX_FLAGS_DEFAULT,
RFAL_ST25TB_FWT);
}
/*******************************************************************************/
ReturnCode rfalSt25tbPollerResetToInventory( void )
{
ReturnCode rfalSt25tbPollerResetToInventory(void) {
uint8_t resetInvReq;
/* Compute Completion Request */
resetInvReq = RFAL_ST25TB_RESET_INV_CMD;
/* Send Completion Request, no response is expected */
return rfalTransceiveBlockingTxRx( (uint8_t*)&resetInvReq, RFAL_ST25TB_CMD_LEN, NULL, 0, NULL, RFAL_TXRX_FLAGS_DEFAULT, RFAL_ST25TB_FWT );
return rfalTransceiveBlockingTxRx(
(uint8_t*)&resetInvReq,
RFAL_ST25TB_CMD_LEN,
NULL,
0,
NULL,
RFAL_TXRX_FLAGS_DEFAULT,
RFAL_ST25TB_FWT);
}
#endif /* RFAL_FEATURE_ST25TB */
+527 -238
View File
@@ -53,7 +53,7 @@
*/
#ifndef RFAL_FEATURE_ST25xV
#define RFAL_FEATURE_ST25xV false /* ST25xV module configuration missing. Disabled by default */
#define RFAL_FEATURE_ST25xV false /* ST25xV module configuration missing. Disabled by default */
#endif
#if RFAL_FEATURE_ST25xV
@@ -64,22 +64,34 @@
******************************************************************************
*/
#define RFAL_ST25xV_READ_CONFIG_LEN 2U /*!< READ CONFIGURATION length */
#define RFAL_ST25xV_READ_MSG_LEN_LEN 2U /*!< READ MESSAGE LENGTH length */
#define RFAL_ST25xV_CONF_POINTER_LEN 1U /*!< READ/WRITE CONFIGURATION Pointer length */
#define RFAL_ST25xV_CONF_REGISTER_LEN 1U /*!< READ/WRITE CONFIGURATION Register length */
#define RFAL_ST25xV_PWDNUM_LEN 1U /*!< Password Number length */
#define RFAL_ST25xV_PWD_LEN 8U /*!< Password length */
#define RFAL_ST25xV_MBPOINTER_LEN 1U /*!< Read Message MBPointer length */
#define RFAL_ST25xV_NUMBYTES_LEN 1U /*!< Read Message Number of Bytes length */
#define RFAL_ST25xV_READ_CONFIG_LEN \
2U /*!< READ CONFIGURATION length */
#define RFAL_ST25xV_READ_MSG_LEN_LEN \
2U /*!< READ MESSAGE LENGTH length */
#define RFAL_ST25xV_CONF_POINTER_LEN \
1U /*!< READ/WRITE CONFIGURATION Pointer length */
#define RFAL_ST25xV_CONF_REGISTER_LEN \
1U /*!< READ/WRITE CONFIGURATION Register length */
#define RFAL_ST25xV_PWDNUM_LEN \
1U /*!< Password Number length */
#define RFAL_ST25xV_PWD_LEN \
8U /*!< Password length */
#define RFAL_ST25xV_MBPOINTER_LEN \
1U /*!< Read Message MBPointer length */
#define RFAL_ST25xV_NUMBYTES_LEN \
1U /*!< Read Message Number of Bytes length */
#define RFAL_ST25TV02K_TBOOT_RF 1U /*!< RF Boot time (Minimum time from carrier generation to first data) */
#define RFAL_ST25TV02K_TRF_OFF 2U /*!< RF OFF time */
#define RFAL_ST25xV_FDT_POLL_MAX rfalConvMsTo1fc(20) /*!< Maximum Wait time FDTV,EOF 20 ms Digital 2.1 B.5 */
#define RFAL_NFCV_FLAG_POS 0U /*!< Flag byte position */
#define RFAL_NFCV_FLAG_LEN 1U /*!< Flag byte length */
#define RFAL_ST25TV02K_TBOOT_RF \
1U /*!< RF Boot time (Minimum time from carrier generation to first data) */
#define RFAL_ST25TV02K_TRF_OFF \
2U /*!< RF OFF time */
#define RFAL_ST25xV_FDT_POLL_MAX \
rfalConvMsTo1fc(20) /*!< Maximum Wait time FDTV,EOF 20 ms Digital 2.1 B.5 */
#define RFAL_NFCV_FLAG_POS \
0U /*!< Flag byte position */
#define RFAL_NFCV_FLAG_LEN \
1U /*!< Flag byte length */
/*
******************************************************************************
@@ -87,11 +99,40 @@
******************************************************************************
*/
static ReturnCode rfalST25xVPollerGenericReadConfiguration(uint8_t cmd, uint8_t flags, const uint8_t* uid, uint8_t pointer, uint8_t* regValue );
static ReturnCode rfalST25xVPollerGenericWriteConfiguration( uint8_t cmd, uint8_t flags, const uint8_t* uid, uint8_t pointer, uint8_t regValue );
static ReturnCode rfalST25xVPollerGenericReadMessageLength( uint8_t cmd, uint8_t flags, const uint8_t* uid, uint8_t* msgLen );
static ReturnCode rfalST25xVPollerGenericReadMessage( uint8_t cmd, uint8_t flags, const uint8_t* uid, uint8_t mbPointer, uint8_t numBytes, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen );
static ReturnCode rfalST25xVPollerGenericWriteMessage( uint8_t cmd, uint8_t flags, const uint8_t* uid, uint8_t msgLen, const uint8_t* msgData, uint8_t* txBuf, uint16_t txBufLen );
static ReturnCode rfalST25xVPollerGenericReadConfiguration(
uint8_t cmd,
uint8_t flags,
const uint8_t* uid,
uint8_t pointer,
uint8_t* regValue);
static ReturnCode rfalST25xVPollerGenericWriteConfiguration(
uint8_t cmd,
uint8_t flags,
const uint8_t* uid,
uint8_t pointer,
uint8_t regValue);
static ReturnCode rfalST25xVPollerGenericReadMessageLength(
uint8_t cmd,
uint8_t flags,
const uint8_t* uid,
uint8_t* msgLen);
static ReturnCode rfalST25xVPollerGenericReadMessage(
uint8_t cmd,
uint8_t flags,
const uint8_t* uid,
uint8_t mbPointer,
uint8_t numBytes,
uint8_t* rxBuf,
uint16_t rxBufLen,
uint16_t* rcvLen);
static ReturnCode rfalST25xVPollerGenericWriteMessage(
uint8_t cmd,
uint8_t flags,
const uint8_t* uid,
uint8_t msgLen,
const uint8_t* msgData,
uint8_t* txBuf,
uint16_t txBufLen);
/*
******************************************************************************
* LOCAL FUNCTIONS
@@ -99,29 +140,37 @@ static ReturnCode rfalST25xVPollerGenericWriteMessage( uint8_t cmd, uint8_t flag
*/
/*******************************************************************************/
static ReturnCode rfalST25xVPollerGenericReadConfiguration(uint8_t cmd, uint8_t flags, const uint8_t* uid, uint8_t pointer, uint8_t* regValue )
{
ReturnCode ret;
uint8_t p;
uint16_t rcvLen;
static ReturnCode rfalST25xVPollerGenericReadConfiguration(
uint8_t cmd,
uint8_t flags,
const uint8_t* uid,
uint8_t pointer,
uint8_t* regValue) {
ReturnCode ret;
uint8_t p;
uint16_t rcvLen;
rfalNfcvGenericRes res;
if( regValue == NULL )
{
if(regValue == NULL) {
return ERR_PARAM;
}
p = pointer;
ret = rfalNfcvPollerTransceiveReq( cmd, flags, RFAL_NFCV_ST_IC_MFG_CODE, uid, &p, sizeof(uint8_t), (uint8_t*)&res, sizeof(rfalNfcvGenericRes), &rcvLen );
if( ret == ERR_NONE )
{
if( rcvLen < RFAL_ST25xV_READ_CONFIG_LEN )
{
ret = rfalNfcvPollerTransceiveReq(
cmd,
flags,
RFAL_NFCV_ST_IC_MFG_CODE,
uid,
&p,
sizeof(uint8_t),
(uint8_t*)&res,
sizeof(rfalNfcvGenericRes),
&rcvLen);
if(ret == ERR_NONE) {
if(rcvLen < RFAL_ST25xV_READ_CONFIG_LEN) {
ret = ERR_PROTO;
}
else
{
} else {
*regValue = res.data[0];
}
}
@@ -129,43 +178,62 @@ static ReturnCode rfalST25xVPollerGenericReadConfiguration(uint8_t cmd, uint8_t
}
/*******************************************************************************/
static ReturnCode rfalST25xVPollerGenericWriteConfiguration( uint8_t cmd, uint8_t flags, const uint8_t* uid, uint8_t pointer, uint8_t regValue )
{
uint8_t data[RFAL_ST25xV_CONF_POINTER_LEN + RFAL_ST25xV_CONF_REGISTER_LEN];
uint8_t dataLen;
uint16_t rcvLen;
static ReturnCode rfalST25xVPollerGenericWriteConfiguration(
uint8_t cmd,
uint8_t flags,
const uint8_t* uid,
uint8_t pointer,
uint8_t regValue) {
uint8_t data[RFAL_ST25xV_CONF_POINTER_LEN + RFAL_ST25xV_CONF_REGISTER_LEN];
uint8_t dataLen;
uint16_t rcvLen;
rfalNfcvGenericRes res;
dataLen = 0U;
data[dataLen++] = pointer;
data[dataLen++] = regValue;
return rfalNfcvPollerTransceiveReq( cmd, flags, RFAL_NFCV_ST_IC_MFG_CODE, uid, data, dataLen, (uint8_t*)&res, sizeof(rfalNfcvGenericRes), &rcvLen );
return rfalNfcvPollerTransceiveReq(
cmd,
flags,
RFAL_NFCV_ST_IC_MFG_CODE,
uid,
data,
dataLen,
(uint8_t*)&res,
sizeof(rfalNfcvGenericRes),
&rcvLen);
}
/*******************************************************************************/
static ReturnCode rfalST25xVPollerGenericReadMessageLength( uint8_t cmd, uint8_t flags, const uint8_t* uid, uint8_t* msgLen )
{
ReturnCode ret;
uint16_t rcvLen;
static ReturnCode rfalST25xVPollerGenericReadMessageLength(
uint8_t cmd,
uint8_t flags,
const uint8_t* uid,
uint8_t* msgLen) {
ReturnCode ret;
uint16_t rcvLen;
rfalNfcvGenericRes res;
if( msgLen == NULL )
{
if(msgLen == NULL) {
return ERR_PARAM;
}
ret = rfalNfcvPollerTransceiveReq( cmd, flags, RFAL_NFCV_ST_IC_MFG_CODE, uid, NULL, 0, (uint8_t*)&res, sizeof(rfalNfcvGenericRes), &rcvLen );
if( ret == ERR_NONE )
{
if( rcvLen < RFAL_ST25xV_READ_MSG_LEN_LEN )
{
ret = rfalNfcvPollerTransceiveReq(
cmd,
flags,
RFAL_NFCV_ST_IC_MFG_CODE,
uid,
NULL,
0,
(uint8_t*)&res,
sizeof(rfalNfcvGenericRes),
&rcvLen);
if(ret == ERR_NONE) {
if(rcvLen < RFAL_ST25xV_READ_MSG_LEN_LEN) {
ret = ERR_PROTO;
}
else
{
} else {
*msgLen = res.data[0];
}
}
@@ -173,98 +241,117 @@ static ReturnCode rfalST25xVPollerGenericReadMessageLength( uint8_t cmd, uint8_t
}
/*******************************************************************************/
static ReturnCode rfalST25xVPollerGenericReadMessage( uint8_t cmd, uint8_t flags, const uint8_t* uid, uint8_t mbPointer, uint8_t numBytes, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen )
{
static ReturnCode rfalST25xVPollerGenericReadMessage(
uint8_t cmd,
uint8_t flags,
const uint8_t* uid,
uint8_t mbPointer,
uint8_t numBytes,
uint8_t* rxBuf,
uint16_t rxBufLen,
uint16_t* rcvLen) {
uint8_t data[RFAL_ST25xV_MBPOINTER_LEN + RFAL_ST25xV_NUMBYTES_LEN];
uint8_t dataLen;
dataLen = 0;
/* Compute Request Data */
data[dataLen++] = mbPointer;
data[dataLen++] = numBytes;
return rfalNfcvPollerTransceiveReq( cmd, flags, RFAL_NFCV_ST_IC_MFG_CODE, uid, data, dataLen, rxBuf, rxBufLen, rcvLen );
return rfalNfcvPollerTransceiveReq(
cmd, flags, RFAL_NFCV_ST_IC_MFG_CODE, uid, data, dataLen, rxBuf, rxBufLen, rcvLen);
}
/*******************************************************************************/
static ReturnCode rfalST25xVPollerGenericWriteMessage( uint8_t cmd, uint8_t flags, const uint8_t* uid, uint8_t msgLen, const uint8_t* msgData, uint8_t* txBuf, uint16_t txBufLen )
{
ReturnCode ret;
uint8_t reqFlag;
uint16_t msgIt;
rfalBitRate rxBR;
bool fastMode;
static ReturnCode rfalST25xVPollerGenericWriteMessage(
uint8_t cmd,
uint8_t flags,
const uint8_t* uid,
uint8_t msgLen,
const uint8_t* msgData,
uint8_t* txBuf,
uint16_t txBufLen) {
ReturnCode ret;
uint8_t reqFlag;
uint16_t msgIt;
rfalBitRate rxBR;
bool fastMode;
rfalNfcvGenericRes res;
uint16_t rcvLen;
uint16_t rcvLen;
/* Calculate required Tx buf length: Mfg Code UID MSGLen MSGLen+1 */
msgIt = (uint16_t)( msgLen + sizeof(flags) + sizeof(cmd) + 1U + ((uid != NULL) ? RFAL_NFCV_UID_LEN : 0U) + 1U + 1U );
msgIt =
(uint16_t)(msgLen + sizeof(flags) + sizeof(cmd) + 1U + ((uid != NULL) ? RFAL_NFCV_UID_LEN : 0U) + 1U + 1U);
/* Note: MSGlength parameter of the command is the number of Data bytes minus - 1 (00 for 1 byte of data, FFh for 256 bytes of data) */
/* Check for valid parameters */
if( (txBuf == NULL) || (msgData == NULL) || (txBufLen < msgIt) )
{
if((txBuf == NULL) || (msgData == NULL) || (txBufLen < msgIt)) {
return ERR_PARAM;
}
msgIt = 0;
msgIt = 0;
fastMode = false;
/* Check if the command is an ST's Fast command */
if( cmd == (uint8_t)RFAL_NFCV_CMD_FAST_WRITE_MESSAGE )
{
if(cmd == (uint8_t)RFAL_NFCV_CMD_FAST_WRITE_MESSAGE) {
/* Store current Rx bit rate and move to fast mode */
rfalGetBitRate( NULL, &rxBR );
rfalSetBitRate( RFAL_BR_KEEP, RFAL_BR_52p97 );
rfalGetBitRate(NULL, &rxBR);
rfalSetBitRate(RFAL_BR_KEEP, RFAL_BR_52p97);
fastMode = true;
}
/* Compute Request Command */
reqFlag = (uint8_t)(flags & (~((uint32_t)RFAL_NFCV_REQ_FLAG_ADDRESS) & ~((uint32_t)RFAL_NFCV_REQ_FLAG_SELECT)));
reqFlag |= (( uid != NULL ) ? (uint8_t)RFAL_NFCV_REQ_FLAG_ADDRESS : (uint8_t)RFAL_NFCV_REQ_FLAG_SELECT);
/* Compute Request Command */
reqFlag =
(uint8_t)(flags & (~((uint32_t)RFAL_NFCV_REQ_FLAG_ADDRESS) & ~((uint32_t)RFAL_NFCV_REQ_FLAG_SELECT)));
reqFlag |=
((uid != NULL) ? (uint8_t)RFAL_NFCV_REQ_FLAG_ADDRESS : (uint8_t)RFAL_NFCV_REQ_FLAG_SELECT);
txBuf[msgIt++] = reqFlag;
txBuf[msgIt++] = cmd;
txBuf[msgIt++] = RFAL_NFCV_ST_IC_MFG_CODE;
if( uid != NULL )
{
ST_MEMCPY( &txBuf[msgIt], uid, RFAL_NFCV_UID_LEN );
if(uid != NULL) {
ST_MEMCPY(&txBuf[msgIt], uid, RFAL_NFCV_UID_LEN);
msgIt += RFAL_NFCV_UID_LEN;
}
txBuf[msgIt++] = msgLen;
ST_MEMCPY( &txBuf[msgIt], msgData, (uint16_t)(msgLen +(uint16_t) 1U) ); /* Message Data contains (MSGLength + 1) bytes */
ST_MEMCPY(
&txBuf[msgIt],
msgData,
(uint16_t)(msgLen + (uint16_t)1U)); /* Message Data contains (MSGLength + 1) bytes */
msgIt += (uint16_t)(msgLen + (uint16_t)1U);
/* Transceive Command */
ret = rfalTransceiveBlockingTxRx( txBuf, msgIt, (uint8_t*)&res, sizeof(rfalNfcvGenericRes), &rcvLen, RFAL_TXRX_FLAGS_DEFAULT, RFAL_ST25xV_FDT_POLL_MAX );
ret = rfalTransceiveBlockingTxRx(
txBuf,
msgIt,
(uint8_t*)&res,
sizeof(rfalNfcvGenericRes),
&rcvLen,
RFAL_TXRX_FLAGS_DEFAULT,
RFAL_ST25xV_FDT_POLL_MAX);
/* Restore Rx BitRate */
if( fastMode )
{
rfalSetBitRate( RFAL_BR_KEEP, rxBR );
if(fastMode) {
rfalSetBitRate(RFAL_BR_KEEP, rxBR);
}
if( ret != ERR_NONE )
{
if(ret != ERR_NONE) {
return ret;
}
/* Check if the response minimum length has been received */
if( rcvLen < (uint8_t)RFAL_NFCV_FLAG_LEN )
{
if(rcvLen < (uint8_t)RFAL_NFCV_FLAG_LEN) {
return ERR_PROTO;
}
/* Check if an error has been signalled */
if( (res.RES_FLAG & (uint8_t)RFAL_NFCV_RES_FLAG_ERROR) != 0U )
{
if((res.RES_FLAG & (uint8_t)RFAL_NFCV_RES_FLAG_ERROR) != 0U) {
return ERR_PROTO;
}
return ERR_NONE;
}
@@ -275,255 +362,457 @@ static ReturnCode rfalST25xVPollerGenericWriteMessage( uint8_t cmd, uint8_t flag
*/
/*******************************************************************************/
ReturnCode rfalST25xVPollerM24LRReadSingleBlock( uint8_t flags, const uint8_t* uid, uint16_t blockNum, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen )
{
ReturnCode rfalST25xVPollerM24LRReadSingleBlock(
uint8_t flags,
const uint8_t* uid,
uint16_t blockNum,
uint8_t* rxBuf,
uint16_t rxBufLen,
uint16_t* rcvLen) {
uint8_t data[RFAL_NFCV_BLOCKNUM_M24LR_LEN];
uint8_t dataLen;
dataLen = 0;
/* Compute Request Data */
data[dataLen++] = (uint8_t)blockNum; /* Set M24LR Block Number (16 bits) LSB */
data[dataLen++] = (uint8_t)blockNum; /* Set M24LR Block Number (16 bits) LSB */
data[dataLen++] = (uint8_t)(blockNum >> 8U); /* Set M24LR Block Number (16 bits) MSB */
return rfalNfcvPollerTransceiveReq( RFAL_NFCV_CMD_READ_SINGLE_BLOCK, (flags | (uint8_t)RFAL_NFCV_REQ_FLAG_PROTOCOL_EXT), RFAL_NFCV_PARAM_SKIP, uid, data, dataLen, rxBuf, rxBufLen, rcvLen );
return rfalNfcvPollerTransceiveReq(
RFAL_NFCV_CMD_READ_SINGLE_BLOCK,
(flags | (uint8_t)RFAL_NFCV_REQ_FLAG_PROTOCOL_EXT),
RFAL_NFCV_PARAM_SKIP,
uid,
data,
dataLen,
rxBuf,
rxBufLen,
rcvLen);
}
/*******************************************************************************/
ReturnCode rfalST25xVPollerM24LRWriteSingleBlock( uint8_t flags, const uint8_t* uid, uint16_t blockNum, const uint8_t* wrData, uint8_t blockLen )
{
uint8_t data[(RFAL_NFCV_BLOCKNUM_M24LR_LEN + RFAL_NFCV_MAX_BLOCK_LEN)];
uint8_t dataLen;
uint16_t rcvLen;
ReturnCode rfalST25xVPollerM24LRWriteSingleBlock(
uint8_t flags,
const uint8_t* uid,
uint16_t blockNum,
const uint8_t* wrData,
uint8_t blockLen) {
uint8_t data[(RFAL_NFCV_BLOCKNUM_M24LR_LEN + RFAL_NFCV_MAX_BLOCK_LEN)];
uint8_t dataLen;
uint16_t rcvLen;
rfalNfcvGenericRes res;
/* Check for valid parameters */
if( (blockLen == 0U) || (blockLen > (uint8_t)RFAL_NFCV_MAX_BLOCK_LEN) || (wrData == NULL) )
{
if((blockLen == 0U) || (blockLen > (uint8_t)RFAL_NFCV_MAX_BLOCK_LEN) || (wrData == NULL)) {
return ERR_PARAM;
}
dataLen = 0U;
/* Compute Request Data */
data[dataLen++] = (uint8_t)blockNum; /* Set M24LR Block Number (16 bits) LSB */
data[dataLen++] = (uint8_t)blockNum; /* Set M24LR Block Number (16 bits) LSB */
data[dataLen++] = (uint8_t)(blockNum >> 8U); /* Set M24LR Block Number (16 bits) MSB */
ST_MEMCPY( &data[dataLen], wrData, blockLen ); /* Append Block data to write */
ST_MEMCPY(&data[dataLen], wrData, blockLen); /* Append Block data to write */
dataLen += blockLen;
return rfalNfcvPollerTransceiveReq( RFAL_NFCV_CMD_WRITE_SINGLE_BLOCK, (flags | (uint8_t)RFAL_NFCV_REQ_FLAG_PROTOCOL_EXT), RFAL_NFCV_PARAM_SKIP, uid, data, dataLen, (uint8_t*)&res, sizeof(rfalNfcvGenericRes), &rcvLen );
return rfalNfcvPollerTransceiveReq(
RFAL_NFCV_CMD_WRITE_SINGLE_BLOCK,
(flags | (uint8_t)RFAL_NFCV_REQ_FLAG_PROTOCOL_EXT),
RFAL_NFCV_PARAM_SKIP,
uid,
data,
dataLen,
(uint8_t*)&res,
sizeof(rfalNfcvGenericRes),
&rcvLen);
}
/*******************************************************************************/
ReturnCode rfalST25xVPollerM24LRReadMultipleBlocks( uint8_t flags, const uint8_t* uid, uint16_t firstBlockNum, uint8_t numOfBlocks, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen )
{
ReturnCode rfalST25xVPollerM24LRReadMultipleBlocks(
uint8_t flags,
const uint8_t* uid,
uint16_t firstBlockNum,
uint8_t numOfBlocks,
uint8_t* rxBuf,
uint16_t rxBufLen,
uint16_t* rcvLen) {
uint8_t data[(RFAL_NFCV_BLOCKNUM_M24LR_LEN + RFAL_NFCV_BLOCKNUM_M24LR_LEN)];
uint8_t dataLen;
dataLen = 0U;
/* Compute Request Data */
data[dataLen++] = (uint8_t)firstBlockNum; /* Set M24LR Block Number (16 bits) LSB */
data[dataLen++] = (uint8_t)firstBlockNum; /* Set M24LR Block Number (16 bits) LSB */
data[dataLen++] = (uint8_t)(firstBlockNum >> 8U); /* Set M24LR Block Number (16 bits) MSB */
data[dataLen++] = numOfBlocks; /* Set number of blocks to read */
return rfalNfcvPollerTransceiveReq( RFAL_NFCV_CMD_READ_MULTIPLE_BLOCKS, (flags | (uint8_t)RFAL_NFCV_REQ_FLAG_PROTOCOL_EXT), RFAL_NFCV_PARAM_SKIP, uid, data, dataLen, rxBuf, rxBufLen, rcvLen );
data[dataLen++] = numOfBlocks; /* Set number of blocks to read */
return rfalNfcvPollerTransceiveReq(
RFAL_NFCV_CMD_READ_MULTIPLE_BLOCKS,
(flags | (uint8_t)RFAL_NFCV_REQ_FLAG_PROTOCOL_EXT),
RFAL_NFCV_PARAM_SKIP,
uid,
data,
dataLen,
rxBuf,
rxBufLen,
rcvLen);
}
/*******************************************************************************/
ReturnCode rfalST25xVPollerFastReadSingleBlock( uint8_t flags, const uint8_t* uid, uint8_t blockNum, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen )
{
ReturnCode rfalST25xVPollerFastReadSingleBlock(
uint8_t flags,
const uint8_t* uid,
uint8_t blockNum,
uint8_t* rxBuf,
uint16_t rxBufLen,
uint16_t* rcvLen) {
uint8_t bn;
bn = blockNum;
return rfalNfcvPollerTransceiveReq( RFAL_NFCV_CMD_FAST_READ_SINGLE_BLOCK, flags, RFAL_NFCV_ST_IC_MFG_CODE, uid, &bn, sizeof(uint8_t), rxBuf, rxBufLen, rcvLen );
return rfalNfcvPollerTransceiveReq(
RFAL_NFCV_CMD_FAST_READ_SINGLE_BLOCK,
flags,
RFAL_NFCV_ST_IC_MFG_CODE,
uid,
&bn,
sizeof(uint8_t),
rxBuf,
rxBufLen,
rcvLen);
}
/*******************************************************************************/
ReturnCode rfalST25xVPollerM24LRFastReadSingleBlock( uint8_t flags, const uint8_t* uid, uint16_t blockNum, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen )
{
ReturnCode rfalST25xVPollerM24LRFastReadSingleBlock(
uint8_t flags,
const uint8_t* uid,
uint16_t blockNum,
uint8_t* rxBuf,
uint16_t rxBufLen,
uint16_t* rcvLen) {
uint8_t data[RFAL_NFCV_BLOCKNUM_M24LR_LEN];
uint8_t dataLen;
dataLen = 0;
/* Compute Request Data */
data[dataLen++] = (uint8_t)blockNum; /* Set M24LR Block Number (16 bits) LSB */
data[dataLen++] = (uint8_t)blockNum; /* Set M24LR Block Number (16 bits) LSB */
data[dataLen++] = (uint8_t)(blockNum >> 8U); /* Set M24LR Block Number (16 bits) MSB */
return rfalNfcvPollerTransceiveReq( RFAL_NFCV_CMD_FAST_READ_SINGLE_BLOCK, (flags | (uint8_t)RFAL_NFCV_REQ_FLAG_PROTOCOL_EXT), RFAL_NFCV_ST_IC_MFG_CODE, uid, data, dataLen, rxBuf, rxBufLen, rcvLen );
return rfalNfcvPollerTransceiveReq(
RFAL_NFCV_CMD_FAST_READ_SINGLE_BLOCK,
(flags | (uint8_t)RFAL_NFCV_REQ_FLAG_PROTOCOL_EXT),
RFAL_NFCV_ST_IC_MFG_CODE,
uid,
data,
dataLen,
rxBuf,
rxBufLen,
rcvLen);
}
/*******************************************************************************/
ReturnCode rfalST25xVPollerM24LRFastReadMultipleBlocks( uint8_t flags, const uint8_t* uid, uint16_t firstBlockNum, uint8_t numOfBlocks, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen )
{
ReturnCode rfalST25xVPollerM24LRFastReadMultipleBlocks(
uint8_t flags,
const uint8_t* uid,
uint16_t firstBlockNum,
uint8_t numOfBlocks,
uint8_t* rxBuf,
uint16_t rxBufLen,
uint16_t* rcvLen) {
uint8_t data[(RFAL_NFCV_BLOCKNUM_M24LR_LEN + RFAL_NFCV_BLOCKNUM_M24LR_LEN)];
uint8_t dataLen;
dataLen = 0U;
/* Compute Request Data */
data[dataLen++] = (uint8_t)firstBlockNum; /* Set M24LR Block Number (16 bits) LSB */
data[dataLen++] = (uint8_t)firstBlockNum; /* Set M24LR Block Number (16 bits) LSB */
data[dataLen++] = (uint8_t)(firstBlockNum >> 8U); /* Set M24LR Block Number (16 bits) MSB */
data[dataLen++] = numOfBlocks; /* Set number of blocks to read */
return rfalNfcvPollerTransceiveReq( RFAL_NFCV_CMD_FAST_READ_MULTIPLE_BLOCKS, (flags | (uint8_t)RFAL_NFCV_REQ_FLAG_PROTOCOL_EXT), RFAL_NFCV_ST_IC_MFG_CODE, uid, data, dataLen, rxBuf, rxBufLen, rcvLen );
data[dataLen++] = numOfBlocks; /* Set number of blocks to read */
return rfalNfcvPollerTransceiveReq(
RFAL_NFCV_CMD_FAST_READ_MULTIPLE_BLOCKS,
(flags | (uint8_t)RFAL_NFCV_REQ_FLAG_PROTOCOL_EXT),
RFAL_NFCV_ST_IC_MFG_CODE,
uid,
data,
dataLen,
rxBuf,
rxBufLen,
rcvLen);
}
/*******************************************************************************/
ReturnCode rfalST25xVPollerFastReadMultipleBlocks( uint8_t flags, const uint8_t* uid, uint8_t firstBlockNum, uint8_t numOfBlocks, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen )
{
ReturnCode rfalST25xVPollerFastReadMultipleBlocks(
uint8_t flags,
const uint8_t* uid,
uint8_t firstBlockNum,
uint8_t numOfBlocks,
uint8_t* rxBuf,
uint16_t rxBufLen,
uint16_t* rcvLen) {
uint8_t data[(RFAL_NFCV_BLOCKNUM_LEN + RFAL_NFCV_BLOCKNUM_LEN)];
uint8_t dataLen;
dataLen = 0U;
/* Compute Request Data */
data[dataLen++] = firstBlockNum; /* Set first Block Number */
data[dataLen++] = numOfBlocks; /* Set number of blocks to read */
return rfalNfcvPollerTransceiveReq( RFAL_NFCV_CMD_FAST_READ_MULTIPLE_BLOCKS, flags, RFAL_NFCV_ST_IC_MFG_CODE, uid, data, dataLen, rxBuf, rxBufLen, rcvLen );
data[dataLen++] = firstBlockNum; /* Set first Block Number */
data[dataLen++] = numOfBlocks; /* Set number of blocks to read */
return rfalNfcvPollerTransceiveReq(
RFAL_NFCV_CMD_FAST_READ_MULTIPLE_BLOCKS,
flags,
RFAL_NFCV_ST_IC_MFG_CODE,
uid,
data,
dataLen,
rxBuf,
rxBufLen,
rcvLen);
}
/*******************************************************************************/
ReturnCode rfalST25xVPollerFastExtendedReadSingleBlock( uint8_t flags, const uint8_t* uid, uint16_t blockNum, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen )
{
ReturnCode rfalST25xVPollerFastExtendedReadSingleBlock(
uint8_t flags,
const uint8_t* uid,
uint16_t blockNum,
uint8_t* rxBuf,
uint16_t rxBufLen,
uint16_t* rcvLen) {
uint8_t data[RFAL_NFCV_BLOCKNUM_EXTENDED_LEN];
uint8_t dataLen;
dataLen = 0U;
/* Compute Request Data */
data[dataLen++] = (uint8_t)blockNum; /* TS T5T 1.0 BNo is considered as a multi-byte field. TS T5T 1.0 5.1.1.13 multi-byte field follows [DIGITAL]. [DIGITAL] 9.3.1 A multiple byte field is transmitted LSB first. */
data[dataLen++] = (uint8_t)
blockNum; /* TS T5T 1.0 BNo is considered as a multi-byte field. TS T5T 1.0 5.1.1.13 multi-byte field follows [DIGITAL]. [DIGITAL] 9.3.1 A multiple byte field is transmitted LSB first. */
data[dataLen++] = (uint8_t)((blockNum >> 8U) & 0xFFU);
return rfalNfcvPollerTransceiveReq( RFAL_NFCV_CMD_FAST_EXTENDED_READ_SINGLE_BLOCK, flags, RFAL_NFCV_ST_IC_MFG_CODE, uid, data, dataLen, rxBuf, rxBufLen, rcvLen );
return rfalNfcvPollerTransceiveReq(
RFAL_NFCV_CMD_FAST_EXTENDED_READ_SINGLE_BLOCK,
flags,
RFAL_NFCV_ST_IC_MFG_CODE,
uid,
data,
dataLen,
rxBuf,
rxBufLen,
rcvLen);
}
/*******************************************************************************/
ReturnCode rfalST25xVPollerFastExtReadMultipleBlocks( uint8_t flags, const uint8_t* uid, uint16_t firstBlockNum, uint16_t numOfBlocks, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen )
{
ReturnCode rfalST25xVPollerFastExtReadMultipleBlocks(
uint8_t flags,
const uint8_t* uid,
uint16_t firstBlockNum,
uint16_t numOfBlocks,
uint8_t* rxBuf,
uint16_t rxBufLen,
uint16_t* rcvLen) {
uint8_t data[(RFAL_NFCV_BLOCKNUM_EXTENDED_LEN + RFAL_NFCV_BLOCKNUM_EXTENDED_LEN)];
uint8_t dataLen;
dataLen = 0U;
/* Compute Request Data */
data[dataLen++] = (uint8_t)((firstBlockNum >> 0U) & 0xFFU);
data[dataLen++] = (uint8_t)((firstBlockNum >> 8U) & 0xFFU);
data[dataLen++] = (uint8_t)((numOfBlocks >> 0U) & 0xFFU);
data[dataLen++] = (uint8_t)((numOfBlocks >> 8U) & 0xFFU);
return rfalNfcvPollerTransceiveReq( RFAL_NFCV_CMD_FAST_EXTENDED_READ_MULTIPLE_BLOCKS, flags, RFAL_NFCV_ST_IC_MFG_CODE, uid, data, dataLen, rxBuf, rxBufLen, rcvLen );
return rfalNfcvPollerTransceiveReq(
RFAL_NFCV_CMD_FAST_EXTENDED_READ_MULTIPLE_BLOCKS,
flags,
RFAL_NFCV_ST_IC_MFG_CODE,
uid,
data,
dataLen,
rxBuf,
rxBufLen,
rcvLen);
}
/*******************************************************************************/
ReturnCode rfalST25xVPollerReadConfiguration( uint8_t flags, const uint8_t* uid, uint8_t pointer, uint8_t* regValue )
{
return rfalST25xVPollerGenericReadConfiguration(RFAL_NFCV_CMD_READ_CONFIGURATION, flags, uid, pointer, regValue );
ReturnCode rfalST25xVPollerReadConfiguration(
uint8_t flags,
const uint8_t* uid,
uint8_t pointer,
uint8_t* regValue) {
return rfalST25xVPollerGenericReadConfiguration(
RFAL_NFCV_CMD_READ_CONFIGURATION, flags, uid, pointer, regValue);
}
/*******************************************************************************/
ReturnCode rfalST25xVPollerWriteConfiguration( uint8_t flags, const uint8_t* uid, uint8_t pointer, uint8_t regValue )
{
return rfalST25xVPollerGenericWriteConfiguration( RFAL_NFCV_CMD_WRITE_CONFIGURATION, flags, uid, pointer, regValue);
ReturnCode rfalST25xVPollerWriteConfiguration(
uint8_t flags,
const uint8_t* uid,
uint8_t pointer,
uint8_t regValue) {
return rfalST25xVPollerGenericWriteConfiguration(
RFAL_NFCV_CMD_WRITE_CONFIGURATION, flags, uid, pointer, regValue);
}
/*******************************************************************************/
ReturnCode rfalST25xVPollerReadDynamicConfiguration( uint8_t flags, const uint8_t* uid, uint8_t pointer, uint8_t* regValue )
{
return rfalST25xVPollerGenericReadConfiguration(RFAL_NFCV_CMD_READ_DYN_CONFIGURATION, flags, uid, pointer, regValue );
ReturnCode rfalST25xVPollerReadDynamicConfiguration(
uint8_t flags,
const uint8_t* uid,
uint8_t pointer,
uint8_t* regValue) {
return rfalST25xVPollerGenericReadConfiguration(
RFAL_NFCV_CMD_READ_DYN_CONFIGURATION, flags, uid, pointer, regValue);
}
/*******************************************************************************/
ReturnCode rfalST25xVPollerWriteDynamicConfiguration( uint8_t flags, const uint8_t* uid, uint8_t pointer, uint8_t regValue )
{
return rfalST25xVPollerGenericWriteConfiguration( RFAL_NFCV_CMD_WRITE_DYN_CONFIGURATION, flags, uid, pointer, regValue);
ReturnCode rfalST25xVPollerWriteDynamicConfiguration(
uint8_t flags,
const uint8_t* uid,
uint8_t pointer,
uint8_t regValue) {
return rfalST25xVPollerGenericWriteConfiguration(
RFAL_NFCV_CMD_WRITE_DYN_CONFIGURATION, flags, uid, pointer, regValue);
}
/*******************************************************************************/
ReturnCode rfalST25xVPollerFastReadDynamicConfiguration( uint8_t flags, const uint8_t* uid, uint8_t pointer, uint8_t* regValue )
{
return rfalST25xVPollerGenericReadConfiguration(RFAL_NFCV_CMD_FAST_READ_DYN_CONFIGURATION, flags, uid, pointer, regValue );
ReturnCode rfalST25xVPollerFastReadDynamicConfiguration(
uint8_t flags,
const uint8_t* uid,
uint8_t pointer,
uint8_t* regValue) {
return rfalST25xVPollerGenericReadConfiguration(
RFAL_NFCV_CMD_FAST_READ_DYN_CONFIGURATION, flags, uid, pointer, regValue);
}
/*******************************************************************************/
ReturnCode rfalST25xVPollerFastWriteDynamicConfiguration( uint8_t flags, const uint8_t* uid, uint8_t pointer, uint8_t regValue )
{
return rfalST25xVPollerGenericWriteConfiguration( RFAL_NFCV_CMD_FAST_WRITE_DYN_CONFIGURATION, flags, uid, pointer, regValue);
ReturnCode rfalST25xVPollerFastWriteDynamicConfiguration(
uint8_t flags,
const uint8_t* uid,
uint8_t pointer,
uint8_t regValue) {
return rfalST25xVPollerGenericWriteConfiguration(
RFAL_NFCV_CMD_FAST_WRITE_DYN_CONFIGURATION, flags, uid, pointer, regValue);
}
/*******************************************************************************/
ReturnCode rfalST25xVPollerPresentPassword( uint8_t flags, const uint8_t* uid, uint8_t pwdNum, const uint8_t *pwd, uint8_t pwdLen)
{
uint8_t data[RFAL_ST25xV_PWDNUM_LEN + RFAL_ST25xV_PWD_LEN];
uint8_t dataLen;
uint16_t rcvLen;
ReturnCode rfalST25xVPollerPresentPassword(
uint8_t flags,
const uint8_t* uid,
uint8_t pwdNum,
const uint8_t* pwd,
uint8_t pwdLen) {
uint8_t data[RFAL_ST25xV_PWDNUM_LEN + RFAL_ST25xV_PWD_LEN];
uint8_t dataLen;
uint16_t rcvLen;
rfalNfcvGenericRes res;
if( (pwdLen > RFAL_ST25xV_PWD_LEN) || (pwd == NULL) )
{
if((pwdLen > RFAL_ST25xV_PWD_LEN) || (pwd == NULL)) {
return ERR_PARAM;
}
dataLen = 0U;
data[dataLen++] = pwdNum;
if( pwdLen > 0U )
{
if(pwdLen > 0U) {
ST_MEMCPY(&data[dataLen], pwd, pwdLen);
}
dataLen += pwdLen;
return rfalNfcvPollerTransceiveReq( RFAL_NFCV_CMD_PRESENT_PASSWORD, flags, RFAL_NFCV_ST_IC_MFG_CODE, uid, data, dataLen, (uint8_t*)&res, sizeof(rfalNfcvGenericRes), &rcvLen );
return rfalNfcvPollerTransceiveReq(
RFAL_NFCV_CMD_PRESENT_PASSWORD,
flags,
RFAL_NFCV_ST_IC_MFG_CODE,
uid,
data,
dataLen,
(uint8_t*)&res,
sizeof(rfalNfcvGenericRes),
&rcvLen);
}
/*******************************************************************************/
ReturnCode rfalST25xVPollerGetRandomNumber( uint8_t flags, const uint8_t* uid, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen )
{
ReturnCode rfalST25xVPollerGetRandomNumber(
uint8_t flags,
const uint8_t* uid,
uint8_t* rxBuf,
uint16_t rxBufLen,
uint16_t* rcvLen) {
rfalFieldOff();
platformDelay(RFAL_ST25TV02K_TRF_OFF);
rfalNfcvPollerInitialize();
rfalFieldOnAndStartGT();
platformDelay(RFAL_ST25TV02K_TBOOT_RF);
return rfalNfcvPollerTransceiveReq( RFAL_NFCV_CMD_GET_RANDOM_NUMBER, flags, RFAL_NFCV_ST_IC_MFG_CODE, uid, NULL, 0U, rxBuf, rxBufLen, rcvLen );
return rfalNfcvPollerTransceiveReq(
RFAL_NFCV_CMD_GET_RANDOM_NUMBER,
flags,
RFAL_NFCV_ST_IC_MFG_CODE,
uid,
NULL,
0U,
rxBuf,
rxBufLen,
rcvLen);
}
/*******************************************************************************/
ReturnCode rfalST25xVPollerWriteMessage( uint8_t flags, const uint8_t* uid, uint8_t msgLen, const uint8_t* msgData, uint8_t* txBuf, uint16_t txBufLen )
{
return rfalST25xVPollerGenericWriteMessage( RFAL_NFCV_CMD_WRITE_MESSAGE, flags, uid, msgLen, msgData, txBuf, txBufLen);
ReturnCode rfalST25xVPollerWriteMessage(
uint8_t flags,
const uint8_t* uid,
uint8_t msgLen,
const uint8_t* msgData,
uint8_t* txBuf,
uint16_t txBufLen) {
return rfalST25xVPollerGenericWriteMessage(
RFAL_NFCV_CMD_WRITE_MESSAGE, flags, uid, msgLen, msgData, txBuf, txBufLen);
}
/*******************************************************************************/
ReturnCode rfalST25xVPollerFastWriteMessage( uint8_t flags, const uint8_t* uid, uint8_t msgLen, const uint8_t* msgData, uint8_t* txBuf, uint16_t txBufLen )
{
return rfalST25xVPollerGenericWriteMessage( RFAL_NFCV_CMD_FAST_WRITE_MESSAGE, flags, uid, msgLen, msgData, txBuf, txBufLen);
ReturnCode rfalST25xVPollerFastWriteMessage(
uint8_t flags,
const uint8_t* uid,
uint8_t msgLen,
const uint8_t* msgData,
uint8_t* txBuf,
uint16_t txBufLen) {
return rfalST25xVPollerGenericWriteMessage(
RFAL_NFCV_CMD_FAST_WRITE_MESSAGE, flags, uid, msgLen, msgData, txBuf, txBufLen);
}
/*******************************************************************************/
ReturnCode rfalST25xVPollerReadMessageLength( uint8_t flags, const uint8_t* uid, uint8_t* msgLen )
{
return rfalST25xVPollerGenericReadMessageLength(RFAL_NFCV_CMD_READ_MESSAGE_LENGTH, flags, uid, msgLen);
ReturnCode rfalST25xVPollerReadMessageLength(uint8_t flags, const uint8_t* uid, uint8_t* msgLen) {
return rfalST25xVPollerGenericReadMessageLength(
RFAL_NFCV_CMD_READ_MESSAGE_LENGTH, flags, uid, msgLen);
}
/*******************************************************************************/
ReturnCode rfalST25xVPollerFastReadMsgLength( uint8_t flags, const uint8_t* uid, uint8_t* msgLen )
{
return rfalST25xVPollerGenericReadMessageLength(RFAL_NFCV_CMD_FAST_READ_MESSAGE_LENGTH, flags, uid, msgLen);
ReturnCode rfalST25xVPollerFastReadMsgLength(uint8_t flags, const uint8_t* uid, uint8_t* msgLen) {
return rfalST25xVPollerGenericReadMessageLength(
RFAL_NFCV_CMD_FAST_READ_MESSAGE_LENGTH, flags, uid, msgLen);
}
/*******************************************************************************/
ReturnCode rfalST25xVPollerReadMessage( uint8_t flags, const uint8_t* uid, uint8_t mbPointer, uint8_t numBytes, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen )
{
return rfalST25xVPollerGenericReadMessage(RFAL_NFCV_CMD_READ_MESSAGE, flags, uid, mbPointer, numBytes, rxBuf, rxBufLen, rcvLen );
ReturnCode rfalST25xVPollerReadMessage(
uint8_t flags,
const uint8_t* uid,
uint8_t mbPointer,
uint8_t numBytes,
uint8_t* rxBuf,
uint16_t rxBufLen,
uint16_t* rcvLen) {
return rfalST25xVPollerGenericReadMessage(
RFAL_NFCV_CMD_READ_MESSAGE, flags, uid, mbPointer, numBytes, rxBuf, rxBufLen, rcvLen);
}
/*******************************************************************************/
ReturnCode rfalST25xVPollerFastReadMessage( uint8_t flags, const uint8_t* uid, uint8_t mbPointer, uint8_t numBytes, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen )
{
return rfalST25xVPollerGenericReadMessage(RFAL_NFCV_CMD_FAST_READ_MESSAGE, flags, uid, mbPointer, numBytes, rxBuf, rxBufLen, rcvLen );
ReturnCode rfalST25xVPollerFastReadMessage(
uint8_t flags,
const uint8_t* uid,
uint8_t mbPointer,
uint8_t numBytes,
uint8_t* rxBuf,
uint16_t rxBufLen,
uint16_t* rcvLen) {
return rfalST25xVPollerGenericReadMessage(
RFAL_NFCV_CMD_FAST_READ_MESSAGE, flags, uid, mbPointer, numBytes, rxBuf, rxBufLen, rcvLen);
}
#endif /* RFAL_FEATURE_ST25xV */
+99 -86
View File
@@ -52,7 +52,7 @@
*/
#ifndef RFAL_FEATURE_T1T
#define RFAL_FEATURE_T1T false /* T1T module configuration missing. Disabled by default */
#define RFAL_FEATURE_T1T false /* T1T module configuration missing. Disabled by default */
#endif
#if RFAL_FEATURE_T1T
@@ -63,12 +63,17 @@
******************************************************************************
*/
#define RFAL_T1T_DRD_READ (1236U*2U) /*!< DRD for Reads with n=9 => 1236/fc ~= 91 us T1T 1.2 4.4.2 */
#define RFAL_T1T_DRD_WRITE 36052U /*!< DRD for Write with n=281 => 36052/fc ~= 2659 us T1T 1.2 4.4.2 */
#define RFAL_T1T_DRD_WRITE_E 70996U /*!< DRD for Write/Erase with n=554 => 70996/fc ~= 5236 us T1T 1.2 4.4.2 */
#define RFAL_T1T_DRD_READ \
(1236U * 2U) /*!< DRD for Reads with n=9 => 1236/fc ~= 91 us T1T 1.2 4.4.2 */
#define RFAL_T1T_DRD_WRITE \
36052U /*!< DRD for Write with n=281 => 36052/fc ~= 2659 us T1T 1.2 4.4.2 */
#define RFAL_T1T_DRD_WRITE_E \
70996U /*!< DRD for Write/Erase with n=554 => 70996/fc ~= 5236 us T1T 1.2 4.4.2 */
#define RFAL_T1T_RID_RES_HR0_VAL 0x10U /*!< HR0 indicating NDEF support Digital 2.0 (Candidate) 11.6.2.1 */
#define RFAL_T1T_RID_RES_HR0_MASK 0xF0U /*!< HR0 most significant nibble mask */
#define RFAL_T1T_RID_RES_HR0_VAL \
0x10U /*!< HR0 indicating NDEF support Digital 2.0 (Candidate) 11.6.2.1 */
#define RFAL_T1T_RID_RES_HR0_MASK \
0xF0U /*!< HR0 most significant nibble mask */
/*
******************************************************************************
@@ -77,40 +82,33 @@
*/
/*! NFC-A T1T (Topaz) RID_REQ Digital 1.1 10.6.1 & Table 49 */
typedef struct
{
uint8_t cmd; /*!< T1T cmd: RID */
uint8_t add; /*!< ADD: undefined value */
uint8_t data; /*!< DATA: undefined value */
uint8_t uid[RFAL_T1T_UID_LEN]; /*!< UID-echo: undefined value */
typedef struct {
uint8_t cmd; /*!< T1T cmd: RID */
uint8_t add; /*!< ADD: undefined value */
uint8_t data; /*!< DATA: undefined value */
uint8_t uid[RFAL_T1T_UID_LEN]; /*!< UID-echo: undefined value */
} rfalT1TRidReq;
/*! NFC-A T1T (Topaz) RALL_REQ T1T 1.2 Table 4 */
typedef struct
{
uint8_t cmd; /*!< T1T cmd: RALL */
uint8_t add1; /*!< ADD: 0x00 */
uint8_t add0; /*!< ADD: 0x00 */
uint8_t uid[RFAL_T1T_UID_LEN]; /*!< UID */
typedef struct {
uint8_t cmd; /*!< T1T cmd: RALL */
uint8_t add1; /*!< ADD: 0x00 */
uint8_t add0; /*!< ADD: 0x00 */
uint8_t uid[RFAL_T1T_UID_LEN]; /*!< UID */
} rfalT1TRallReq;
/*! NFC-A T1T (Topaz) WRITE_REQ T1T 1.2 Table 4 */
typedef struct
{
uint8_t cmd; /*!< T1T cmd: RALL */
uint8_t add; /*!< ADD */
uint8_t data; /*!< DAT */
uint8_t uid[RFAL_T1T_UID_LEN]; /*!< UID */
typedef struct {
uint8_t cmd; /*!< T1T cmd: RALL */
uint8_t add; /*!< ADD */
uint8_t data; /*!< DAT */
uint8_t uid[RFAL_T1T_UID_LEN]; /*!< UID */
} rfalT1TWriteReq;
/*! NFC-A T1T (Topaz) WRITE_RES T1T 1.2 Table 4 */
typedef struct
{
uint8_t add; /*!< ADD */
uint8_t data; /*!< DAT */
typedef struct {
uint8_t add; /*!< ADD */
uint8_t data; /*!< DAT */
} rfalT1TWriteRes;
/*
@@ -125,92 +123,107 @@ typedef struct
******************************************************************************
*/
ReturnCode rfalT1TPollerInitialize( void )
{
ReturnCode rfalT1TPollerInitialize(void) {
ReturnCode ret;
EXIT_ON_ERR(ret, rfalSetMode( RFAL_MODE_POLL_NFCA_T1T, RFAL_BR_106, RFAL_BR_106 ) );
rfalSetErrorHandling( RFAL_ERRORHANDLING_NFC );
rfalSetGT( RFAL_GT_NONE ); /* T1T should only be initialized after NFC-A mode, therefore the GT has been fulfilled */
rfalSetFDTListen( RFAL_FDT_LISTEN_NFCA_POLLER ); /* T1T uses NFC-A FDT Listen with n=9 Digital 1.1 10.7.2 */
rfalSetFDTPoll( RFAL_FDT_POLL_NFCA_T1T_POLLER );
EXIT_ON_ERR(ret, rfalSetMode(RFAL_MODE_POLL_NFCA_T1T, RFAL_BR_106, RFAL_BR_106));
rfalSetErrorHandling(RFAL_ERRORHANDLING_NFC);
rfalSetGT(
RFAL_GT_NONE); /* T1T should only be initialized after NFC-A mode, therefore the GT has been fulfilled */
rfalSetFDTListen(
RFAL_FDT_LISTEN_NFCA_POLLER); /* T1T uses NFC-A FDT Listen with n=9 Digital 1.1 10.7.2 */
rfalSetFDTPoll(RFAL_FDT_POLL_NFCA_T1T_POLLER);
return ERR_NONE;
}
/*******************************************************************************/
ReturnCode rfalT1TPollerRid( rfalT1TRidRes *ridRes )
{
ReturnCode ret;
rfalT1TRidReq ridReq;
uint16_t rcvdLen;
if( ridRes == NULL )
{
ReturnCode rfalT1TPollerRid(rfalT1TRidRes* ridRes) {
ReturnCode ret;
rfalT1TRidReq ridReq;
uint16_t rcvdLen;
if(ridRes == NULL) {
return ERR_PARAM;
}
/* Compute RID command and set Undefined Values to 0x00 Digital 1.1 10.6.1 */
ST_MEMSET( &ridReq, 0x00, sizeof(rfalT1TRidReq) );
ST_MEMSET(&ridReq, 0x00, sizeof(rfalT1TRidReq));
ridReq.cmd = (uint8_t)RFAL_T1T_CMD_RID;
EXIT_ON_ERR( ret, rfalTransceiveBlockingTxRx( (uint8_t*)&ridReq, sizeof(rfalT1TRidReq), (uint8_t*)ridRes, sizeof(rfalT1TRidRes), &rcvdLen, RFAL_TXRX_FLAGS_DEFAULT, RFAL_T1T_DRD_READ ) );
EXIT_ON_ERR(
ret,
rfalTransceiveBlockingTxRx(
(uint8_t*)&ridReq,
sizeof(rfalT1TRidReq),
(uint8_t*)ridRes,
sizeof(rfalT1TRidRes),
&rcvdLen,
RFAL_TXRX_FLAGS_DEFAULT,
RFAL_T1T_DRD_READ));
/* Check expected RID response length and the HR0 Digital 2.0 (Candidate) 11.6.2.1 */
if( (rcvdLen != sizeof(rfalT1TRidRes)) || ((ridRes->hr0 & RFAL_T1T_RID_RES_HR0_MASK) != RFAL_T1T_RID_RES_HR0_VAL) )
{
if((rcvdLen != sizeof(rfalT1TRidRes)) ||
((ridRes->hr0 & RFAL_T1T_RID_RES_HR0_MASK) != RFAL_T1T_RID_RES_HR0_VAL)) {
return ERR_PROTO;
}
return ERR_NONE;
}
/*******************************************************************************/
ReturnCode rfalT1TPollerRall( const uint8_t* uid, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rxRcvdLen )
{
ReturnCode
rfalT1TPollerRall(const uint8_t* uid, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t* rxRcvdLen) {
rfalT1TRallReq rallReq;
if( (rxBuf == NULL) || (uid == NULL) || (rxRcvdLen == NULL) )
{
if((rxBuf == NULL) || (uid == NULL) || (rxRcvdLen == NULL)) {
return ERR_PARAM;
}
/* Compute RALL command and set Add to 0x00 */
ST_MEMSET( &rallReq, 0x00, sizeof(rfalT1TRallReq) );
ST_MEMSET(&rallReq, 0x00, sizeof(rfalT1TRallReq));
rallReq.cmd = (uint8_t)RFAL_T1T_CMD_RALL;
ST_MEMCPY(rallReq.uid, uid, RFAL_T1T_UID_LEN);
return rfalTransceiveBlockingTxRx( (uint8_t*)&rallReq, sizeof(rfalT1TRallReq), (uint8_t*)rxBuf, rxBufLen, rxRcvdLen, RFAL_TXRX_FLAGS_DEFAULT, RFAL_T1T_DRD_READ );
return rfalTransceiveBlockingTxRx(
(uint8_t*)&rallReq,
sizeof(rfalT1TRallReq),
(uint8_t*)rxBuf,
rxBufLen,
rxRcvdLen,
RFAL_TXRX_FLAGS_DEFAULT,
RFAL_T1T_DRD_READ);
}
/*******************************************************************************/
ReturnCode rfalT1TPollerWrite( const uint8_t* uid, uint8_t address, uint8_t data )
{
ReturnCode rfalT1TPollerWrite(const uint8_t* uid, uint8_t address, uint8_t data) {
rfalT1TWriteReq writeReq;
rfalT1TWriteRes writeRes;
uint16_t rxRcvdLen;
ReturnCode err;
if( uid == NULL )
{
uint16_t rxRcvdLen;
ReturnCode err;
if(uid == NULL) {
return ERR_PARAM;
}
writeReq.cmd = (uint8_t)RFAL_T1T_CMD_WRITE_E;
writeReq.add = address;
writeReq.cmd = (uint8_t)RFAL_T1T_CMD_WRITE_E;
writeReq.add = address;
writeReq.data = data;
ST_MEMCPY(writeReq.uid, uid, RFAL_T1T_UID_LEN);
err = rfalTransceiveBlockingTxRx( (uint8_t*)&writeReq, sizeof(rfalT1TWriteReq), (uint8_t*)&writeRes, sizeof(rfalT1TWriteRes), &rxRcvdLen, RFAL_TXRX_FLAGS_DEFAULT, RFAL_T1T_DRD_WRITE_E );
if( err == ERR_NONE )
{
if( (writeReq.add != writeRes.add) || (writeReq.data != writeRes.data) || (rxRcvdLen != sizeof(rfalT1TWriteRes)) )
{
err = rfalTransceiveBlockingTxRx(
(uint8_t*)&writeReq,
sizeof(rfalT1TWriteReq),
(uint8_t*)&writeRes,
sizeof(rfalT1TWriteRes),
&rxRcvdLen,
RFAL_TXRX_FLAGS_DEFAULT,
RFAL_T1T_DRD_WRITE_E);
if(err == ERR_NONE) {
if((writeReq.add != writeRes.add) || (writeReq.data != writeRes.data) ||
(rxRcvdLen != sizeof(rfalT1TWriteRes))) {
return ERR_PROTO;
}
}
+131 -120
View File
@@ -42,201 +42,212 @@
* INCLUDES
******************************************************************************
*/
#include "rfal_t2t.h"
#include "utils.h"
/*
#include "rfal_t2t.h"
#include "utils.h"
/*
******************************************************************************
* ENABLE SWITCH
******************************************************************************
*/
#ifndef RFAL_FEATURE_T2T
#define RFAL_FEATURE_T2T false /* T2T module configuration missing. Disabled by default */
#define RFAL_FEATURE_T2T false /* T2T module configuration missing. Disabled by default */
#endif
#if RFAL_FEATURE_T2T
/*
/*
******************************************************************************
* GLOBAL DEFINES
******************************************************************************
*/
#define RFAL_FDT_POLL_READ_MAX rfalConvMsTo1fc(5U) /*!< Maximum Wait time for Read command as defined in TS T2T 1.0 table 18 */
#define RFAL_FDT_POLL_WRITE_MAX rfalConvMsTo1fc(10U) /*!< Maximum Wait time for Write command as defined in TS T2T 1.0 table 18 */
#define RFAL_FDT_POLL_SL_MAX rfalConvMsTo1fc(1U) /*!< Maximum Wait time for Sector Select as defined in TS T2T 1.0 table 18 */
#define RFAL_T2T_ACK_NACK_LEN 1U /*!< Len of NACK in bytes (4 bits) */
#define RFAL_T2T_ACK 0x0AU /*!< ACK value */
#define RFAL_T2T_ACK_MASK 0x0FU /*!< ACK value */
#define RFAL_T2T_SECTOR_SELECT_P1_BYTE2 0xFFU /*!< Sector Select Packet 1 byte 2 */
#define RFAL_T2T_SECTOR_SELECT_P2_RFU_LEN 3U /*!< Sector Select RFU length */
/*
#define RFAL_FDT_POLL_READ_MAX \
rfalConvMsTo1fc( \
5U) /*!< Maximum Wait time for Read command as defined in TS T2T 1.0 table 18 */
#define RFAL_FDT_POLL_WRITE_MAX \
rfalConvMsTo1fc( \
10U) /*!< Maximum Wait time for Write command as defined in TS T2T 1.0 table 18 */
#define RFAL_FDT_POLL_SL_MAX \
rfalConvMsTo1fc( \
1U) /*!< Maximum Wait time for Sector Select as defined in TS T2T 1.0 table 18 */
#define RFAL_T2T_ACK_NACK_LEN \
1U /*!< Len of NACK in bytes (4 bits) */
#define RFAL_T2T_ACK \
0x0AU /*!< ACK value */
#define RFAL_T2T_ACK_MASK \
0x0FU /*!< ACK value */
#define RFAL_T2T_SECTOR_SELECT_P1_BYTE2 \
0xFFU /*!< Sector Select Packet 1 byte 2 */
#define RFAL_T2T_SECTOR_SELECT_P2_RFU_LEN \
3U /*!< Sector Select RFU length */
/*
******************************************************************************
* GLOBAL TYPES
******************************************************************************
*/
/*! NFC-A T2T command set T2T 1.0 5.1 */
typedef enum
{
RFAL_T2T_CMD_READ = 0x30, /*!< T2T Read */
RFAL_T2T_CMD_WRITE = 0xA2, /*!< T2T Write */
RFAL_T2T_CMD_SECTOR_SELECT = 0xC2 /*!< T2T Sector Select */
typedef enum {
RFAL_T2T_CMD_READ = 0x30, /*!< T2T Read */
RFAL_T2T_CMD_WRITE = 0xA2, /*!< T2T Write */
RFAL_T2T_CMD_SECTOR_SELECT = 0xC2 /*!< T2T Sector Select */
} rfalT2Tcmds;
/*! NFC-A T2T READ T2T 1.0 5.2 and table 11 */
typedef struct
{
uint8_t code; /*!< Command code */
uint8_t blNo; /*!< Block number */
/*! NFC-A T2T READ T2T 1.0 5.2 and table 11 */
typedef struct {
uint8_t code; /*!< Command code */
uint8_t blNo; /*!< Block number */
} rfalT2TReadReq;
/*! NFC-A T2T WRITE T2T 1.0 5.3 and table 12 */
typedef struct
{
uint8_t code; /*!< Command code */
uint8_t blNo; /*!< Block number */
uint8_t data[RFAL_T2T_WRITE_DATA_LEN]; /*!< Data */
/*! NFC-A T2T WRITE T2T 1.0 5.3 and table 12 */
typedef struct {
uint8_t code; /*!< Command code */
uint8_t blNo; /*!< Block number */
uint8_t data[RFAL_T2T_WRITE_DATA_LEN]; /*!< Data */
} rfalT2TWriteReq;
/*! NFC-A T2T SECTOR SELECT Packet 1 T2T 1.0 5.4 and table 13 */
typedef struct
{
uint8_t code; /*!< Command code */
uint8_t byte2; /*!< Sector Select Packet 1 byte 2 */
typedef struct {
uint8_t code; /*!< Command code */
uint8_t byte2; /*!< Sector Select Packet 1 byte 2 */
} rfalT2TSectorSelectP1Req;
/*! NFC-A T2T SECTOR SELECT Packet 2 T2T 1.0 5.4 and table 13 */
typedef struct
{
uint8_t secNo; /*!< Block number */
uint8_t rfu[RFAL_T2T_SECTOR_SELECT_P2_RFU_LEN]; /*!< Sector Select Packet RFU */
typedef struct {
uint8_t secNo; /*!< Block number */
uint8_t rfu[RFAL_T2T_SECTOR_SELECT_P2_RFU_LEN]; /*!< Sector Select Packet RFU */
} rfalT2TSectorSelectP2Req;
/*
******************************************************************************
* GLOBAL FUNCTIONS
******************************************************************************
*/
ReturnCode rfalT2TPollerRead( uint8_t blockNum, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen )
{
ReturnCode ret;
rfalT2TReadReq req;
if( (rxBuf == NULL) || (rcvLen == NULL) )
{
ReturnCode
rfalT2TPollerRead(uint8_t blockNum, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t* rcvLen) {
ReturnCode ret;
rfalT2TReadReq req;
if((rxBuf == NULL) || (rcvLen == NULL)) {
return ERR_PARAM;
}
req.code = (uint8_t)RFAL_T2T_CMD_READ;
req.blNo = blockNum;
/* Transceive Command */
ret = rfalTransceiveBlockingTxRx( (uint8_t*)&req, sizeof(rfalT2TReadReq), rxBuf, rxBufLen, rcvLen, RFAL_TXRX_FLAGS_DEFAULT, RFAL_FDT_POLL_READ_MAX );
ret = rfalTransceiveBlockingTxRx(
(uint8_t*)&req,
sizeof(rfalT2TReadReq),
rxBuf,
rxBufLen,
rcvLen,
RFAL_TXRX_FLAGS_DEFAULT,
RFAL_FDT_POLL_READ_MAX);
/* T2T 1.0 5.2.1.7 The Reader/Writer SHALL treat a NACK in response to a READ Command as a Protocol Error */
if( (ret == ERR_INCOMPLETE_BYTE) && (*rcvLen == RFAL_T2T_ACK_NACK_LEN) && ((*rxBuf & RFAL_T2T_ACK_MASK) != RFAL_T2T_ACK) )
{
if((ret == ERR_INCOMPLETE_BYTE) && (*rcvLen == RFAL_T2T_ACK_NACK_LEN) &&
((*rxBuf & RFAL_T2T_ACK_MASK) != RFAL_T2T_ACK)) {
return ERR_PROTO;
}
return ret;
}
/*******************************************************************************/
ReturnCode rfalT2TPollerWrite( uint8_t blockNum, const uint8_t* wrData )
{
ReturnCode ret;
rfalT2TWriteReq req;
uint8_t res;
uint16_t rxLen;
}
/*******************************************************************************/
ReturnCode rfalT2TPollerWrite(uint8_t blockNum, const uint8_t* wrData) {
ReturnCode ret;
rfalT2TWriteReq req;
uint8_t res;
uint16_t rxLen;
req.code = (uint8_t)RFAL_T2T_CMD_WRITE;
req.blNo = blockNum;
ST_MEMCPY(req.data, wrData, RFAL_T2T_WRITE_DATA_LEN);
/* Transceive WRITE Command */
ret = rfalTransceiveBlockingTxRx( (uint8_t*)&req, sizeof(rfalT2TWriteReq), &res, sizeof(uint8_t), &rxLen, RFAL_TXRX_FLAGS_DEFAULT, RFAL_FDT_POLL_READ_MAX );
ret = rfalTransceiveBlockingTxRx(
(uint8_t*)&req,
sizeof(rfalT2TWriteReq),
&res,
sizeof(uint8_t),
&rxLen,
RFAL_TXRX_FLAGS_DEFAULT,
RFAL_FDT_POLL_READ_MAX);
/* Check for a valid ACK */
if( (ret == ERR_INCOMPLETE_BYTE) || (ret == ERR_NONE) )
{
if((ret == ERR_INCOMPLETE_BYTE) || (ret == ERR_NONE)) {
ret = ERR_PROTO;
if( (rxLen == RFAL_T2T_ACK_NACK_LEN) && ((res & RFAL_T2T_ACK_MASK) == RFAL_T2T_ACK) )
{
if((rxLen == RFAL_T2T_ACK_NACK_LEN) && ((res & RFAL_T2T_ACK_MASK) == RFAL_T2T_ACK)) {
ret = ERR_NONE;
}
}
return ret;
}
/*******************************************************************************/
ReturnCode rfalT2TPollerSectorSelect( uint8_t sectorNum )
{
return ret;
}
/*******************************************************************************/
ReturnCode rfalT2TPollerSectorSelect(uint8_t sectorNum) {
rfalT2TSectorSelectP1Req p1Req;
rfalT2TSectorSelectP2Req p2Req;
ReturnCode ret;
uint8_t res;
uint16_t rxLen;
ReturnCode ret;
uint8_t res;
uint16_t rxLen;
/* Compute SECTOR SELECT Packet 1 */
p1Req.code = (uint8_t)RFAL_T2T_CMD_SECTOR_SELECT;
p1Req.code = (uint8_t)RFAL_T2T_CMD_SECTOR_SELECT;
p1Req.byte2 = RFAL_T2T_SECTOR_SELECT_P1_BYTE2;
/* Transceive SECTOR SELECT Packet 1 */
ret = rfalTransceiveBlockingTxRx( (uint8_t*)&p1Req, sizeof(rfalT2TSectorSelectP1Req), &res, sizeof(uint8_t), &rxLen, RFAL_TXRX_FLAGS_DEFAULT, RFAL_FDT_POLL_SL_MAX );
ret = rfalTransceiveBlockingTxRx(
(uint8_t*)&p1Req,
sizeof(rfalT2TSectorSelectP1Req),
&res,
sizeof(uint8_t),
&rxLen,
RFAL_TXRX_FLAGS_DEFAULT,
RFAL_FDT_POLL_SL_MAX);
/* Check and report any transmission error */
if( (ret != ERR_INCOMPLETE_BYTE) && (ret != ERR_NONE) )
{
if((ret != ERR_INCOMPLETE_BYTE) && (ret != ERR_NONE)) {
return ret;
}
/* Ensure that an ACK was received */
if( (ret != ERR_INCOMPLETE_BYTE) || (rxLen != RFAL_T2T_ACK_NACK_LEN) || ((res & RFAL_T2T_ACK_MASK) != RFAL_T2T_ACK) )
{
if((ret != ERR_INCOMPLETE_BYTE) || (rxLen != RFAL_T2T_ACK_NACK_LEN) ||
((res & RFAL_T2T_ACK_MASK) != RFAL_T2T_ACK)) {
return ERR_PROTO;
}
/* Compute SECTOR SELECT Packet 2 */
p2Req.secNo = sectorNum;
ST_MEMSET( &p2Req.rfu, 0x00, RFAL_T2T_SECTOR_SELECT_P2_RFU_LEN );
p2Req.secNo = sectorNum;
ST_MEMSET(&p2Req.rfu, 0x00, RFAL_T2T_SECTOR_SELECT_P2_RFU_LEN);
/* Transceive SECTOR SELECT Packet 2 */
ret = rfalTransceiveBlockingTxRx( (uint8_t*)&p2Req, sizeof(rfalT2TSectorSelectP2Req), &res, sizeof(uint8_t), &rxLen, RFAL_TXRX_FLAGS_DEFAULT, RFAL_FDT_POLL_SL_MAX );
ret = rfalTransceiveBlockingTxRx(
(uint8_t*)&p2Req,
sizeof(rfalT2TSectorSelectP2Req),
&res,
sizeof(uint8_t),
&rxLen,
RFAL_TXRX_FLAGS_DEFAULT,
RFAL_FDT_POLL_SL_MAX);
/* T2T 1.0 5.4.1.14 The Reader/Writer SHALL treat any response received before the end of PATT2T,SL,MAX as a Protocol Error */
if( (ret == ERR_NONE) || (ret == ERR_INCOMPLETE_BYTE) )
{
if((ret == ERR_NONE) || (ret == ERR_INCOMPLETE_BYTE)) {
return ERR_PROTO;
}
/* T2T 1.0 5.4.1.13 The Reader/Writer SHALL treat the transmission of the SECTOR SELECT Command Packet 2 as being successful when it receives no response until PATT2T,SL,MAX. */
if( ret == ERR_TIMEOUT )
{
/* T2T 1.0 5.4.1.13 The Reader/Writer SHALL treat the transmission of the SECTOR SELECT Command Packet 2 as being successful when it receives no response until PATT2T,SL,MAX. */
if(ret == ERR_TIMEOUT) {
return ERR_NONE;
}
return ret;
}
}
#endif /* RFAL_FEATURE_T2T */
+190 -192
View File
@@ -46,330 +46,330 @@
* INCLUDES
******************************************************************************
*/
#include "rfal_t4t.h"
#include "utils.h"
/*
#include "rfal_t4t.h"
#include "utils.h"
/*
******************************************************************************
* ENABLE SWITCH
******************************************************************************
*/
#ifndef RFAL_FEATURE_T4T
#define RFAL_FEATURE_T4T false /* T4T module configuration missing. Disabled by default */
#define RFAL_FEATURE_T4T false /* T4T module configuration missing. Disabled by default */
#endif
#if RFAL_FEATURE_T4T
/*
/*
******************************************************************************
* GLOBAL DEFINES
******************************************************************************
*/
#define RFAL_T4T_OFFSET_DO 0x54U /*!< Tag value for offset BER-TLV data object */
#define RFAL_T4T_LENGTH_DO 0x03U /*!< Len value for offset BER-TLV data object */
#define RFAL_T4T_DATA_DO 0x53U /*!< Tag value for data BER-TLV data object */
#define RFAL_T4T_OFFSET_DO 0x54U /*!< Tag value for offset BER-TLV data object */
#define RFAL_T4T_LENGTH_DO 0x03U /*!< Len value for offset BER-TLV data object */
#define RFAL_T4T_DATA_DO 0x53U /*!< Tag value for data BER-TLV data object */
#define RFAL_T4T_MAX_LC 255U /*!< Maximum Lc value for short Lc coding */
/*
#define RFAL_T4T_MAX_LC 255U /*!< Maximum Lc value for short Lc coding */
/*
******************************************************************************
* GLOBAL TYPES
******************************************************************************
*/
/*
******************************************************************************
* GLOBAL MACROS
******************************************************************************
*/
/*
******************************************************************************
* LOCAL VARIABLES
******************************************************************************
*/
/*
******************************************************************************
* GLOBAL FUNCTIONS
******************************************************************************
*/
/*******************************************************************************/
ReturnCode rfalT4TPollerComposeCAPDU( const rfalT4tCApduParam *apduParam )
{
uint8_t hdrLen;
uint16_t msgIt;
if( (apduParam == NULL) || (apduParam->cApduBuf == NULL) || (apduParam->cApduLen == NULL) )
{
/*******************************************************************************/
ReturnCode rfalT4TPollerComposeCAPDU(const rfalT4tCApduParam* apduParam) {
uint8_t hdrLen;
uint16_t msgIt;
if((apduParam == NULL) || (apduParam->cApduBuf == NULL) || (apduParam->cApduLen == NULL)) {
return ERR_PARAM;
}
msgIt = 0;
msgIt = 0;
*(apduParam->cApduLen) = 0;
/*******************************************************************************/
/* Compute Command-APDU according to the format T4T 1.0 5.1.2 & ISO7816-4 2013 Table 1 */
/* Check if Data is present */
if( apduParam->LcFlag )
{
if( apduParam->Lc == 0U )
{
if(apduParam->LcFlag) {
if(apduParam->Lc == 0U) {
/* Extented field coding not supported */
return ERR_PARAM;
}
/* Check whether requested Lc fits */
if( (uint16_t)apduParam->Lc > (uint16_t)(RFAL_FEATURE_ISO_DEP_APDU_MAX_LEN - RFAL_T4T_LE_LEN) )
{
return ERR_PARAM; /* PRQA S 2880 # MISRA 2.1 - Unreachable code due to configuration option being set/unset */
if((uint16_t)apduParam->Lc >
(uint16_t)(RFAL_FEATURE_ISO_DEP_APDU_MAX_LEN - RFAL_T4T_LE_LEN)) {
return ERR_PARAM; /* PRQA S 2880 # MISRA 2.1 - Unreachable code due to configuration option being set/unset */
}
/* Calculate the header length a place the data/body where it should be */
hdrLen = RFAL_T4T_MAX_CAPDU_PROLOGUE_LEN + RFAL_T4T_LC_LEN;
/* make sure not to exceed buffer size */
if( ((uint16_t)hdrLen + (uint16_t)apduParam->Lc + (apduParam->LeFlag ? RFAL_T4T_LC_LEN : 0U)) > RFAL_FEATURE_ISO_DEP_APDU_MAX_LEN )
{
return ERR_NOMEM; /* PRQA S 2880 # MISRA 2.1 - Unreachable code due to configuration option being set/unset */
if(((uint16_t)hdrLen + (uint16_t)apduParam->Lc +
(apduParam->LeFlag ? RFAL_T4T_LC_LEN : 0U)) > RFAL_FEATURE_ISO_DEP_APDU_MAX_LEN) {
return ERR_NOMEM; /* PRQA S 2880 # MISRA 2.1 - Unreachable code due to configuration option being set/unset */
}
ST_MEMMOVE( &apduParam->cApduBuf->apdu[hdrLen], apduParam->cApduBuf->apdu, apduParam->Lc );
ST_MEMMOVE(&apduParam->cApduBuf->apdu[hdrLen], apduParam->cApduBuf->apdu, apduParam->Lc);
}
/* Prepend the ADPDU's header */
apduParam->cApduBuf->apdu[msgIt++] = apduParam->CLA;
apduParam->cApduBuf->apdu[msgIt++] = apduParam->INS;
apduParam->cApduBuf->apdu[msgIt++] = apduParam->P1;
apduParam->cApduBuf->apdu[msgIt++] = apduParam->P2;
/* Check if Data field length is to be added */
if( apduParam->LcFlag )
{
if(apduParam->LcFlag) {
apduParam->cApduBuf->apdu[msgIt++] = apduParam->Lc;
msgIt += apduParam->Lc;
}
/* Check if Expected Response Length is to be added */
if( apduParam->LeFlag )
{
if(apduParam->LeFlag) {
apduParam->cApduBuf->apdu[msgIt++] = apduParam->Le;
}
*(apduParam->cApduLen) = msgIt;
return ERR_NONE;
}
/*******************************************************************************/
ReturnCode rfalT4TPollerParseRAPDU( rfalT4tRApduParam *apduParam )
{
if( (apduParam == NULL) || (apduParam->rApduBuf == NULL) )
{
ReturnCode rfalT4TPollerParseRAPDU(rfalT4tRApduParam* apduParam) {
if((apduParam == NULL) || (apduParam->rApduBuf == NULL)) {
return ERR_PARAM;
}
if( apduParam->rcvdLen < RFAL_T4T_MAX_RAPDU_SW1SW2_LEN )
{
if(apduParam->rcvdLen < RFAL_T4T_MAX_RAPDU_SW1SW2_LEN) {
return ERR_PROTO;
}
apduParam->rApduBodyLen = (apduParam->rcvdLen - (uint16_t)RFAL_T4T_MAX_RAPDU_SW1SW2_LEN);
apduParam->statusWord = GETU16( (&apduParam->rApduBuf->apdu[ apduParam->rApduBodyLen ]) );
apduParam->statusWord = GETU16((&apduParam->rApduBuf->apdu[apduParam->rApduBodyLen]));
/* Check SW1 SW2 T4T 1.0 5.1.3 NOTE */
if( apduParam->statusWord == RFAL_T4T_ISO7816_STATUS_COMPLETE )
{
if(apduParam->statusWord == RFAL_T4T_ISO7816_STATUS_COMPLETE) {
return ERR_NONE;
}
return ERR_REQUEST;
}
/*******************************************************************************/
ReturnCode rfalT4TPollerComposeSelectAppl( rfalIsoDepApduBufFormat *cApduBuf, const uint8_t* aid, uint8_t aidLen, uint16_t *cApduLen )
{
/*******************************************************************************/
ReturnCode rfalT4TPollerComposeSelectAppl(
rfalIsoDepApduBufFormat* cApduBuf,
const uint8_t* aid,
uint8_t aidLen,
uint16_t* cApduLen) {
rfalT4tCApduParam cAPDU;
/* CLA INS P1 P2 Lc Data Le */
/* 00h A4h 00h 00h 07h AID 00h */
cAPDU.CLA = RFAL_T4T_CLA;
cAPDU.INS = (uint8_t)RFAL_T4T_INS_SELECT;
cAPDU.P1 = RFAL_T4T_ISO7816_P1_SELECT_BY_DF_NAME;
cAPDU.P2 = RFAL_T4T_ISO7816_P2_SELECT_FIRST_OR_ONLY_OCCURENCE | RFAL_T4T_ISO7816_P2_SELECT_RETURN_FCI_TEMPLATE;
cAPDU.Lc = aidLen;
cAPDU.Le = 0x00;
cAPDU.LcFlag = true;
cAPDU.LeFlag = true;
cAPDU.CLA = RFAL_T4T_CLA;
cAPDU.INS = (uint8_t)RFAL_T4T_INS_SELECT;
cAPDU.P1 = RFAL_T4T_ISO7816_P1_SELECT_BY_DF_NAME;
cAPDU.P2 = RFAL_T4T_ISO7816_P2_SELECT_FIRST_OR_ONLY_OCCURENCE |
RFAL_T4T_ISO7816_P2_SELECT_RETURN_FCI_TEMPLATE;
cAPDU.Lc = aidLen;
cAPDU.Le = 0x00;
cAPDU.LcFlag = true;
cAPDU.LeFlag = true;
cAPDU.cApduBuf = cApduBuf;
cAPDU.cApduLen = cApduLen;
if( aidLen > 0U )
{
ST_MEMCPY( cAPDU.cApduBuf->apdu, aid, aidLen );
if(aidLen > 0U) {
ST_MEMCPY(cAPDU.cApduBuf->apdu, aid, aidLen);
}
return rfalT4TPollerComposeCAPDU( &cAPDU );
return rfalT4TPollerComposeCAPDU(&cAPDU);
}
/*******************************************************************************/
ReturnCode rfalT4TPollerComposeSelectFile( rfalIsoDepApduBufFormat *cApduBuf, const uint8_t* fid, uint8_t fidLen, uint16_t *cApduLen )
{
/*******************************************************************************/
ReturnCode rfalT4TPollerComposeSelectFile(
rfalIsoDepApduBufFormat* cApduBuf,
const uint8_t* fid,
uint8_t fidLen,
uint16_t* cApduLen) {
rfalT4tCApduParam cAPDU;
/* CLA INS P1 P2 Lc Data Le */
/* 00h A4h 00h 0Ch 02h FID - */
cAPDU.CLA = RFAL_T4T_CLA;
cAPDU.INS = (uint8_t)RFAL_T4T_INS_SELECT;
cAPDU.P1 = RFAL_T4T_ISO7816_P1_SELECT_BY_FILEID;
cAPDU.P2 = RFAL_T4T_ISO7816_P2_SELECT_FIRST_OR_ONLY_OCCURENCE | RFAL_T4T_ISO7816_P2_SELECT_NO_RESPONSE_DATA;
cAPDU.Lc = fidLen;
cAPDU.Le = 0x00;
cAPDU.LcFlag = true;
cAPDU.LeFlag = false;
/* 00h A4h 00h 0Ch 02h FID - */
cAPDU.CLA = RFAL_T4T_CLA;
cAPDU.INS = (uint8_t)RFAL_T4T_INS_SELECT;
cAPDU.P1 = RFAL_T4T_ISO7816_P1_SELECT_BY_FILEID;
cAPDU.P2 = RFAL_T4T_ISO7816_P2_SELECT_FIRST_OR_ONLY_OCCURENCE |
RFAL_T4T_ISO7816_P2_SELECT_NO_RESPONSE_DATA;
cAPDU.Lc = fidLen;
cAPDU.Le = 0x00;
cAPDU.LcFlag = true;
cAPDU.LeFlag = false;
cAPDU.cApduBuf = cApduBuf;
cAPDU.cApduLen = cApduLen;
if( fidLen > 0U )
{
ST_MEMCPY( cAPDU.cApduBuf->apdu, fid, fidLen );
if(fidLen > 0U) {
ST_MEMCPY(cAPDU.cApduBuf->apdu, fid, fidLen);
}
return rfalT4TPollerComposeCAPDU( &cAPDU );
return rfalT4TPollerComposeCAPDU(&cAPDU);
}
/*******************************************************************************/
ReturnCode rfalT4TPollerComposeSelectFileV1Mapping( rfalIsoDepApduBufFormat *cApduBuf, const uint8_t* fid, uint8_t fidLen, uint16_t *cApduLen )
{
/*******************************************************************************/
ReturnCode rfalT4TPollerComposeSelectFileV1Mapping(
rfalIsoDepApduBufFormat* cApduBuf,
const uint8_t* fid,
uint8_t fidLen,
uint16_t* cApduLen) {
rfalT4tCApduParam cAPDU;
/* CLA INS P1 P2 Lc Data Le */
/* 00h A4h 00h 00h 02h FID - */
cAPDU.CLA = RFAL_T4T_CLA;
cAPDU.INS = (uint8_t)RFAL_T4T_INS_SELECT;
cAPDU.P1 = RFAL_T4T_ISO7816_P1_SELECT_BY_FILEID;
cAPDU.P2 = RFAL_T4T_ISO7816_P2_SELECT_FIRST_OR_ONLY_OCCURENCE | RFAL_T4T_ISO7816_P2_SELECT_RETURN_FCI_TEMPLATE;
cAPDU.Lc = fidLen;
cAPDU.Le = 0x00;
cAPDU.LcFlag = true;
cAPDU.LeFlag = false;
/* 00h A4h 00h 00h 02h FID - */
cAPDU.CLA = RFAL_T4T_CLA;
cAPDU.INS = (uint8_t)RFAL_T4T_INS_SELECT;
cAPDU.P1 = RFAL_T4T_ISO7816_P1_SELECT_BY_FILEID;
cAPDU.P2 = RFAL_T4T_ISO7816_P2_SELECT_FIRST_OR_ONLY_OCCURENCE |
RFAL_T4T_ISO7816_P2_SELECT_RETURN_FCI_TEMPLATE;
cAPDU.Lc = fidLen;
cAPDU.Le = 0x00;
cAPDU.LcFlag = true;
cAPDU.LeFlag = false;
cAPDU.cApduBuf = cApduBuf;
cAPDU.cApduLen = cApduLen;
if( fidLen > 0U )
{
ST_MEMCPY( cAPDU.cApduBuf->apdu, fid, fidLen );
if(fidLen > 0U) {
ST_MEMCPY(cAPDU.cApduBuf->apdu, fid, fidLen);
}
return rfalT4TPollerComposeCAPDU( &cAPDU );
return rfalT4TPollerComposeCAPDU(&cAPDU);
}
/*******************************************************************************/
ReturnCode rfalT4TPollerComposeReadData( rfalIsoDepApduBufFormat *cApduBuf, uint16_t offset, uint8_t expLen, uint16_t *cApduLen )
{
/*******************************************************************************/
ReturnCode rfalT4TPollerComposeReadData(
rfalIsoDepApduBufFormat* cApduBuf,
uint16_t offset,
uint8_t expLen,
uint16_t* cApduLen) {
rfalT4tCApduParam cAPDU;
/* CLA INS P1 P2 Lc Data Le */
/* 00h B0h [Offset] - - len */
cAPDU.CLA = RFAL_T4T_CLA;
cAPDU.INS = (uint8_t)RFAL_T4T_INS_READBINARY;
cAPDU.P1 = (uint8_t)((offset >> 8U) & 0xFFU);
cAPDU.P2 = (uint8_t)((offset >> 0U) & 0xFFU);
cAPDU.Le = expLen;
cAPDU.LcFlag = false;
cAPDU.LeFlag = true;
/* 00h B0h [Offset] - - len */
cAPDU.CLA = RFAL_T4T_CLA;
cAPDU.INS = (uint8_t)RFAL_T4T_INS_READBINARY;
cAPDU.P1 = (uint8_t)((offset >> 8U) & 0xFFU);
cAPDU.P2 = (uint8_t)((offset >> 0U) & 0xFFU);
cAPDU.Le = expLen;
cAPDU.LcFlag = false;
cAPDU.LeFlag = true;
cAPDU.cApduBuf = cApduBuf;
cAPDU.cApduLen = cApduLen;
return rfalT4TPollerComposeCAPDU( &cAPDU );
return rfalT4TPollerComposeCAPDU(&cAPDU);
}
/*******************************************************************************/
ReturnCode rfalT4TPollerComposeReadDataODO( rfalIsoDepApduBufFormat *cApduBuf, uint32_t offset, uint8_t expLen, uint16_t *cApduLen )
{
/*******************************************************************************/
ReturnCode rfalT4TPollerComposeReadDataODO(
rfalIsoDepApduBufFormat* cApduBuf,
uint32_t offset,
uint8_t expLen,
uint16_t* cApduLen) {
rfalT4tCApduParam cAPDU;
uint8_t dataIt;
uint8_t dataIt;
/* CLA INS P1 P2 Lc Data Le */
/* 00h B1h 00h 00h Lc 54 03 xxyyzz len */
/* [Offset] */
cAPDU.CLA = RFAL_T4T_CLA;
cAPDU.INS = (uint8_t)RFAL_T4T_INS_READBINARY_ODO;
cAPDU.P1 = 0x00U;
cAPDU.P2 = 0x00U;
cAPDU.Le = expLen;
cAPDU.LcFlag = true;
cAPDU.LeFlag = true;
/* [Offset] */
cAPDU.CLA = RFAL_T4T_CLA;
cAPDU.INS = (uint8_t)RFAL_T4T_INS_READBINARY_ODO;
cAPDU.P1 = 0x00U;
cAPDU.P2 = 0x00U;
cAPDU.Le = expLen;
cAPDU.LcFlag = true;
cAPDU.LeFlag = true;
cAPDU.cApduBuf = cApduBuf;
cAPDU.cApduLen = cApduLen;
dataIt = 0U;
cApduBuf->apdu[dataIt++] = RFAL_T4T_OFFSET_DO;
cApduBuf->apdu[dataIt++] = RFAL_T4T_LENGTH_DO;
cApduBuf->apdu[dataIt++] = (uint8_t)(offset >> 16U);
cApduBuf->apdu[dataIt++] = (uint8_t)(offset >> 8U);
cApduBuf->apdu[dataIt++] = (uint8_t)(offset);
cAPDU.Lc = dataIt;
return rfalT4TPollerComposeCAPDU( &cAPDU );
cAPDU.Lc = dataIt;
return rfalT4TPollerComposeCAPDU(&cAPDU);
}
/*******************************************************************************/
ReturnCode rfalT4TPollerComposeWriteData( rfalIsoDepApduBufFormat *cApduBuf, uint16_t offset, const uint8_t* data, uint8_t dataLen, uint16_t *cApduLen )
{
/*******************************************************************************/
ReturnCode rfalT4TPollerComposeWriteData(
rfalIsoDepApduBufFormat* cApduBuf,
uint16_t offset,
const uint8_t* data,
uint8_t dataLen,
uint16_t* cApduLen) {
rfalT4tCApduParam cAPDU;
/* CLA INS P1 P2 Lc Data Le */
/* 00h D6h [Offset] len Data - */
cAPDU.CLA = RFAL_T4T_CLA;
cAPDU.INS = (uint8_t)RFAL_T4T_INS_UPDATEBINARY;
cAPDU.P1 = (uint8_t)((offset >> 8U) & 0xFFU);
cAPDU.P2 = (uint8_t)((offset >> 0U) & 0xFFU);
cAPDU.Lc = dataLen;
cAPDU.LcFlag = true;
cAPDU.LeFlag = false;
/* 00h D6h [Offset] len Data - */
cAPDU.CLA = RFAL_T4T_CLA;
cAPDU.INS = (uint8_t)RFAL_T4T_INS_UPDATEBINARY;
cAPDU.P1 = (uint8_t)((offset >> 8U) & 0xFFU);
cAPDU.P2 = (uint8_t)((offset >> 0U) & 0xFFU);
cAPDU.Lc = dataLen;
cAPDU.LcFlag = true;
cAPDU.LeFlag = false;
cAPDU.cApduBuf = cApduBuf;
cAPDU.cApduLen = cApduLen;
if( dataLen > 0U )
{
ST_MEMCPY( cAPDU.cApduBuf->apdu, data, dataLen );
if(dataLen > 0U) {
ST_MEMCPY(cAPDU.cApduBuf->apdu, data, dataLen);
}
return rfalT4TPollerComposeCAPDU( &cAPDU );
return rfalT4TPollerComposeCAPDU(&cAPDU);
}
/*******************************************************************************/
ReturnCode rfalT4TPollerComposeWriteDataODO( rfalIsoDepApduBufFormat *cApduBuf, uint32_t offset, const uint8_t* data, uint8_t dataLen, uint16_t *cApduLen )
{
/*******************************************************************************/
ReturnCode rfalT4TPollerComposeWriteDataODO(
rfalIsoDepApduBufFormat* cApduBuf,
uint32_t offset,
const uint8_t* data,
uint8_t dataLen,
uint16_t* cApduLen) {
rfalT4tCApduParam cAPDU;
uint8_t dataIt;
uint8_t dataIt;
/* CLA INS P1 P2 Lc Data Le */
/* 00h D7h 00h 00h len 54 03 xxyyzz 53 Ld data - */
/* [offset] [data] */
cAPDU.CLA = RFAL_T4T_CLA;
cAPDU.INS = (uint8_t)RFAL_T4T_INS_UPDATEBINARY_ODO;
cAPDU.P1 = 0x00U;
cAPDU.P2 = 0x00U;
cAPDU.LcFlag = true;
cAPDU.LeFlag = false;
cAPDU.CLA = RFAL_T4T_CLA;
cAPDU.INS = (uint8_t)RFAL_T4T_INS_UPDATEBINARY_ODO;
cAPDU.P1 = 0x00U;
cAPDU.P2 = 0x00U;
cAPDU.LcFlag = true;
cAPDU.LeFlag = false;
cAPDU.cApduBuf = cApduBuf;
cAPDU.cApduLen = cApduLen;
dataIt = 0U;
cApduBuf->apdu[dataIt++] = RFAL_T4T_OFFSET_DO;
cApduBuf->apdu[dataIt++] = RFAL_T4T_LENGTH_DO;
@@ -378,21 +378,19 @@ ReturnCode rfalT4TPollerComposeWriteDataODO( rfalIsoDepApduBufFormat *cApduBuf,
cApduBuf->apdu[dataIt++] = (uint8_t)(offset);
cApduBuf->apdu[dataIt++] = RFAL_T4T_DATA_DO;
cApduBuf->apdu[dataIt++] = dataLen;
if( (((uint32_t)dataLen + (uint32_t)dataIt) >= RFAL_T4T_MAX_LC) || (((uint32_t)dataLen + (uint32_t)dataIt) >= RFAL_FEATURE_ISO_DEP_APDU_MAX_LEN) )
{
if((((uint32_t)dataLen + (uint32_t)dataIt) >= RFAL_T4T_MAX_LC) ||
(((uint32_t)dataLen + (uint32_t)dataIt) >= RFAL_FEATURE_ISO_DEP_APDU_MAX_LEN)) {
return (ERR_NOMEM);
}
if( dataLen > 0U )
{
ST_MEMCPY( &cAPDU.cApduBuf->apdu[dataIt], data, dataLen );
if(dataLen > 0U) {
ST_MEMCPY(&cAPDU.cApduBuf->apdu[dataIt], data, dataLen);
}
dataIt += dataLen;
cAPDU.Lc = dataIt;
return rfalT4TPollerComposeCAPDU( &cAPDU );
return rfalT4TPollerComposeCAPDU(&cAPDU);
}
#endif /* RFAL_FEATURE_T4T */
+1311 -428
View File
File diff suppressed because it is too large Load Diff
+14 -9
View File
@@ -20,7 +20,6 @@
*
******************************************************************************/
/*
* PROJECT: ST25R391x firmware
* $Revision: $
@@ -34,7 +33,6 @@
* \brief RF Dynamic Power Table default values
*/
#ifndef ST25R3916_DPO_H
#define ST25R3916_DPO_H
@@ -45,19 +43,26 @@
*/
#include "rfal_dpo.h"
/*
******************************************************************************
* GLOBAL DATA TYPES
******************************************************************************
*/
/*! Default DPO table */
const uint8_t rfalDpoDefaultSettings [] = {
0x00, 255, 200,
0x01, 210, 150,
0x02, 160, 100,
0x03, 110, 50,
const uint8_t rfalDpoDefaultSettings[] = {
0x00,
255,
200,
0x01,
210,
150,
0x02,
160,
100,
0x03,
110,
50,
};
#endif /* ST25R3916_DPO_H */
+39 -43
View File
@@ -20,7 +20,6 @@
*
******************************************************************************/
/*
* PROJECT: ST25R391x firmware
* Revision:
@@ -34,7 +33,6 @@
* \brief RFAL Features/Capabilities Definition for ST25R3916
*/
#ifndef RFAL_FEATURES_H
#define RFAL_FEATURES_H
@@ -51,63 +49,61 @@
******************************************************************************
*/
#define RFAL_SUPPORT_MODE_POLL_NFCA true /*!< RFAL Poll NFCA mode support switch */
#define RFAL_SUPPORT_MODE_POLL_NFCB true /*!< RFAL Poll NFCB mode support switch */
#define RFAL_SUPPORT_MODE_POLL_NFCF true /*!< RFAL Poll NFCF mode support switch */
#define RFAL_SUPPORT_MODE_POLL_NFCV true /*!< RFAL Poll NFCV mode support switch */
#define RFAL_SUPPORT_MODE_POLL_ACTIVE_P2P true /*!< RFAL Poll AP2P mode support switch */
#define RFAL_SUPPORT_MODE_LISTEN_NFCA true /*!< RFAL Listen NFCA mode support switch */
#define RFAL_SUPPORT_MODE_LISTEN_NFCB false /*!< RFAL Listen NFCB mode support switch */
#define RFAL_SUPPORT_MODE_LISTEN_NFCF true /*!< RFAL Listen NFCF mode support switch */
#define RFAL_SUPPORT_MODE_LISTEN_ACTIVE_P2P true /*!< RFAL Listen AP2P mode support switch */
#define RFAL_SUPPORT_MODE_POLL_NFCA true /*!< RFAL Poll NFCA mode support switch */
#define RFAL_SUPPORT_MODE_POLL_NFCB true /*!< RFAL Poll NFCB mode support switch */
#define RFAL_SUPPORT_MODE_POLL_NFCF true /*!< RFAL Poll NFCF mode support switch */
#define RFAL_SUPPORT_MODE_POLL_NFCV true /*!< RFAL Poll NFCV mode support switch */
#define RFAL_SUPPORT_MODE_POLL_ACTIVE_P2P true /*!< RFAL Poll AP2P mode support switch */
#define RFAL_SUPPORT_MODE_LISTEN_NFCA true /*!< RFAL Listen NFCA mode support switch */
#define RFAL_SUPPORT_MODE_LISTEN_NFCB false /*!< RFAL Listen NFCB mode support switch */
#define RFAL_SUPPORT_MODE_LISTEN_NFCF true /*!< RFAL Listen NFCF mode support switch */
#define RFAL_SUPPORT_MODE_LISTEN_ACTIVE_P2P true /*!< RFAL Listen AP2P mode support switch */
/*******************************************************************************/
/*! RFAL supported Card Emulation (CE) */
#define RFAL_SUPPORT_CE ( RFAL_SUPPORT_MODE_LISTEN_NFCA || RFAL_SUPPORT_MODE_LISTEN_NFCB || RFAL_SUPPORT_MODE_LISTEN_NFCF )
#define RFAL_SUPPORT_CE \
(RFAL_SUPPORT_MODE_LISTEN_NFCA || RFAL_SUPPORT_MODE_LISTEN_NFCB || \
RFAL_SUPPORT_MODE_LISTEN_NFCF)
/*! RFAL supported Reader/Writer (RW) */
#define RFAL_SUPPORT_RW ( RFAL_SUPPORT_MODE_POLL_NFCA || RFAL_SUPPORT_MODE_POLL_NFCB || RFAL_SUPPORT_MODE_POLL_NFCF || RFAL_SUPPORT_MODE_POLL_NFCV )
#define RFAL_SUPPORT_RW \
(RFAL_SUPPORT_MODE_POLL_NFCA || RFAL_SUPPORT_MODE_POLL_NFCB || RFAL_SUPPORT_MODE_POLL_NFCF || \
RFAL_SUPPORT_MODE_POLL_NFCV)
/*! RFAL support for Active P2P (AP2P) */
#define RFAL_SUPPORT_AP2P ( RFAL_SUPPORT_MODE_POLL_ACTIVE_P2P || RFAL_SUPPORT_MODE_LISTEN_ACTIVE_P2P )
#define RFAL_SUPPORT_AP2P \
(RFAL_SUPPORT_MODE_POLL_ACTIVE_P2P || RFAL_SUPPORT_MODE_LISTEN_ACTIVE_P2P)
/*******************************************************************************/
#define RFAL_SUPPORT_BR_RW_106 true /*!< RFAL RW 106 Bit Rate support switch */
#define RFAL_SUPPORT_BR_RW_212 true /*!< RFAL RW 212 Bit Rate support switch */
#define RFAL_SUPPORT_BR_RW_424 true /*!< RFAL RW 424 Bit Rate support switch */
#define RFAL_SUPPORT_BR_RW_848 true /*!< RFAL RW 848 Bit Rate support switch */
#define RFAL_SUPPORT_BR_RW_1695 false /*!< RFAL RW 1695 Bit Rate support switch */
#define RFAL_SUPPORT_BR_RW_3390 false /*!< RFAL RW 3390 Bit Rate support switch */
#define RFAL_SUPPORT_BR_RW_6780 false /*!< RFAL RW 6780 Bit Rate support switch */
#define RFAL_SUPPORT_BR_RW_13560 false /*!< RFAL RW 6780 Bit Rate support switch */
#define RFAL_SUPPORT_BR_RW_106 true /*!< RFAL RW 106 Bit Rate support switch */
#define RFAL_SUPPORT_BR_RW_212 true /*!< RFAL RW 212 Bit Rate support switch */
#define RFAL_SUPPORT_BR_RW_424 true /*!< RFAL RW 424 Bit Rate support switch */
#define RFAL_SUPPORT_BR_RW_848 true /*!< RFAL RW 848 Bit Rate support switch */
#define RFAL_SUPPORT_BR_RW_1695 false /*!< RFAL RW 1695 Bit Rate support switch */
#define RFAL_SUPPORT_BR_RW_3390 false /*!< RFAL RW 3390 Bit Rate support switch */
#define RFAL_SUPPORT_BR_RW_6780 false /*!< RFAL RW 6780 Bit Rate support switch */
#define RFAL_SUPPORT_BR_RW_13560 false /*!< RFAL RW 6780 Bit Rate support switch */
/*******************************************************************************/
#define RFAL_SUPPORT_BR_AP2P_106 true /*!< RFAL AP2P 106 Bit Rate support switch */
#define RFAL_SUPPORT_BR_AP2P_212 true /*!< RFAL AP2P 212 Bit Rate support switch */
#define RFAL_SUPPORT_BR_AP2P_424 true /*!< RFAL AP2P 424 Bit Rate support switch */
#define RFAL_SUPPORT_BR_AP2P_848 false /*!< RFAL AP2P 848 Bit Rate support switch */
#define RFAL_SUPPORT_BR_AP2P_106 true /*!< RFAL AP2P 106 Bit Rate support switch */
#define RFAL_SUPPORT_BR_AP2P_212 true /*!< RFAL AP2P 212 Bit Rate support switch */
#define RFAL_SUPPORT_BR_AP2P_424 true /*!< RFAL AP2P 424 Bit Rate support switch */
#define RFAL_SUPPORT_BR_AP2P_848 false /*!< RFAL AP2P 848 Bit Rate support switch */
/*******************************************************************************/
#define RFAL_SUPPORT_BR_CE_A_106 true /*!< RFAL CE A 106 Bit Rate support switch */
#define RFAL_SUPPORT_BR_CE_A_212 false /*!< RFAL CE A 212 Bit Rate support switch */
#define RFAL_SUPPORT_BR_CE_A_424 false /*!< RFAL CE A 424 Bit Rate support switch */
#define RFAL_SUPPORT_BR_CE_A_848 false /*!< RFAL CE A 848 Bit Rate support switch */
#define RFAL_SUPPORT_BR_CE_A_106 true /*!< RFAL CE A 106 Bit Rate support switch */
#define RFAL_SUPPORT_BR_CE_A_212 false /*!< RFAL CE A 212 Bit Rate support switch */
#define RFAL_SUPPORT_BR_CE_A_424 false /*!< RFAL CE A 424 Bit Rate support switch */
#define RFAL_SUPPORT_BR_CE_A_848 false /*!< RFAL CE A 848 Bit Rate support switch */
/*******************************************************************************/
#define RFAL_SUPPORT_BR_CE_B_106 false /*!< RFAL CE B 106 Bit Rate support switch */
#define RFAL_SUPPORT_BR_CE_B_212 false /*!< RFAL CE B 212 Bit Rate support switch */
#define RFAL_SUPPORT_BR_CE_B_424 false /*!< RFAL CE B 424 Bit Rate support switch */
#define RFAL_SUPPORT_BR_CE_B_848 false /*!< RFAL CE B 848 Bit Rate support switch */
#define RFAL_SUPPORT_BR_CE_B_106 false /*!< RFAL CE B 106 Bit Rate support switch */
#define RFAL_SUPPORT_BR_CE_B_212 false /*!< RFAL CE B 212 Bit Rate support switch */
#define RFAL_SUPPORT_BR_CE_B_424 false /*!< RFAL CE B 424 Bit Rate support switch */
#define RFAL_SUPPORT_BR_CE_B_848 false /*!< RFAL CE B 848 Bit Rate support switch */
/*******************************************************************************/
#define RFAL_SUPPORT_BR_CE_F_212 true /*!< RFAL CE F 212 Bit Rate support switch */
#define RFAL_SUPPORT_BR_CE_F_424 true /*!< RFAL CE F 424 Bit Rate support switch */
#define RFAL_SUPPORT_BR_CE_F_212 true /*!< RFAL CE F 212 Bit Rate support switch */
#define RFAL_SUPPORT_BR_CE_F_424 true /*!< RFAL CE F 424 Bit Rate support switch */
#endif /* RFAL_FEATURES_H */
+3293 -3291
View File
File diff suppressed because it is too large Load Diff
+367 -369
View File
File diff suppressed because it is too large Load Diff
+152 -92
View File
@@ -20,7 +20,6 @@
*
******************************************************************************/
/*
* PROJECT: ST25R3916 firmware
* Revision:
@@ -51,7 +50,6 @@
*
*/
#ifndef ST25R3916_H
#define ST25R3916_H
@@ -71,20 +69,21 @@
*/
/*! Struct to represent all regs on ST25R3916 */
typedef struct{
uint8_t RsA[(ST25R3916_REG_IC_IDENTITY+1U)]; /*!< Registers contained on ST25R3916 space A (Rs-A) */
uint8_t RsB[ST25R3916_SPACE_B_REG_LEN]; /*!< Registers contained on ST25R3916 space B (Rs-B) */
}t_st25r3916Regs;
typedef struct {
uint8_t RsA[(
ST25R3916_REG_IC_IDENTITY + 1U)]; /*!< Registers contained on ST25R3916 space A (Rs-A) */
uint8_t
RsB[ST25R3916_SPACE_B_REG_LEN]; /*!< Registers contained on ST25R3916 space B (Rs-B) */
} t_st25r3916Regs;
/*! Parameters how the stream mode should work */
struct st25r3916StreamConfig {
uint8_t useBPSK; /*!< 0: subcarrier, 1:BPSK */
uint8_t din; /*!< Divider for the in subcarrier frequency: fc/2^din */
uint8_t dout; /*!< Divider for the in subcarrier frequency fc/2^dout */
uint8_t report_period_length; /*!< Length of the reporting period 2^report_period_length*/
uint8_t useBPSK; /*!< 0: subcarrier, 1:BPSK */
uint8_t din; /*!< Divider for the in subcarrier frequency: fc/2^din */
uint8_t dout; /*!< Divider for the in subcarrier frequency fc/2^dout */
uint8_t report_period_length; /*!< Length of the reporting period 2^report_period_length*/
};
/*
******************************************************************************
* GLOBAL DEFINES
@@ -92,53 +91,86 @@ struct st25r3916StreamConfig {
*/
/* ST25R3916 direct commands */
#define ST25R3916_CMD_SET_DEFAULT 0xC1U /*!< Puts the chip in default state (same as after power-up) */
#define ST25R3916_CMD_STOP 0xC2U /*!< Stops all activities and clears FIFO */
#define ST25R3916_CMD_TRANSMIT_WITH_CRC 0xC4U /*!< Transmit with CRC */
#define ST25R3916_CMD_TRANSMIT_WITHOUT_CRC 0xC5U /*!< Transmit without CRC */
#define ST25R3916_CMD_TRANSMIT_REQA 0xC6U /*!< Transmit REQA */
#define ST25R3916_CMD_TRANSMIT_WUPA 0xC7U /*!< Transmit WUPA */
#define ST25R3916_CMD_INITIAL_RF_COLLISION 0xC8U /*!< NFC transmit with Initial RF Collision Avoidance */
#define ST25R3916_CMD_RESPONSE_RF_COLLISION_N 0xC9U /*!< NFC transmit with Response RF Collision Avoidance */
#define ST25R3916_CMD_GOTO_SENSE 0xCDU /*!< Passive target logic to Sense/Idle state */
#define ST25R3916_CMD_GOTO_SLEEP 0xCEU /*!< Passive target logic to Sleep/Halt state */
#define ST25R3916_CMD_MASK_RECEIVE_DATA 0xD0U /*!< Mask receive data */
#define ST25R3916_CMD_UNMASK_RECEIVE_DATA 0xD1U /*!< Unmask receive data */
#define ST25R3916_CMD_AM_MOD_STATE_CHANGE 0xD2U /*!< AM Modulation state change */
#define ST25R3916_CMD_MEASURE_AMPLITUDE 0xD3U /*!< Measure singal amplitude on RFI inputs */
#define ST25R3916_CMD_RESET_RXGAIN 0xD5U /*!< Reset RX Gain */
#define ST25R3916_CMD_ADJUST_REGULATORS 0xD6U /*!< Adjust regulators */
#define ST25R3916_CMD_CALIBRATE_DRIVER_TIMING 0xD8U /*!< Starts the sequence to adjust the driver timing */
#define ST25R3916_CMD_MEASURE_PHASE 0xD9U /*!< Measure phase between RFO and RFI signal */
#define ST25R3916_CMD_CLEAR_RSSI 0xDAU /*!< Clear RSSI bits and restart the measurement */
#define ST25R3916_CMD_CLEAR_FIFO 0xDBU /*!< Clears FIFO, Collision and IRQ status */
#define ST25R3916_CMD_TRANSPARENT_MODE 0xDCU /*!< Transparent mode */
#define ST25R3916_CMD_CALIBRATE_C_SENSOR 0xDDU /*!< Calibrate the capacitive sensor */
#define ST25R3916_CMD_MEASURE_CAPACITANCE 0xDEU /*!< Measure capacitance */
#define ST25R3916_CMD_MEASURE_VDD 0xDFU /*!< Measure power supply voltage */
#define ST25R3916_CMD_START_GP_TIMER 0xE0U /*!< Start the general purpose timer */
#define ST25R3916_CMD_START_WUP_TIMER 0xE1U /*!< Start the wake-up timer */
#define ST25R3916_CMD_START_MASK_RECEIVE_TIMER 0xE2U /*!< Start the mask-receive timer */
#define ST25R3916_CMD_START_NO_RESPONSE_TIMER 0xE3U /*!< Start the no-response timer */
#define ST25R3916_CMD_START_PPON2_TIMER 0xE4U /*!< Start PPon2 timer */
#define ST25R3916_CMD_STOP_NRT 0xE8U /*!< Stop No Response Timer */
#define ST25R3916_CMD_SPACE_B_ACCESS 0xFBU /*!< Enable R/W access to the test registers */
#define ST25R3916_CMD_TEST_ACCESS 0xFCU /*!< Enable R/W access to the test registers */
#define ST25R3916_CMD_SET_DEFAULT \
0xC1U /*!< Puts the chip in default state (same as after power-up) */
#define ST25R3916_CMD_STOP 0xC2U /*!< Stops all activities and clears FIFO */
#define ST25R3916_CMD_TRANSMIT_WITH_CRC \
0xC4U /*!< Transmit with CRC */
#define ST25R3916_CMD_TRANSMIT_WITHOUT_CRC \
0xC5U /*!< Transmit without CRC */
#define ST25R3916_CMD_TRANSMIT_REQA \
0xC6U /*!< Transmit REQA */
#define ST25R3916_CMD_TRANSMIT_WUPA \
0xC7U /*!< Transmit WUPA */
#define ST25R3916_CMD_INITIAL_RF_COLLISION \
0xC8U /*!< NFC transmit with Initial RF Collision Avoidance */
#define ST25R3916_CMD_RESPONSE_RF_COLLISION_N \
0xC9U /*!< NFC transmit with Response RF Collision Avoidance */
#define ST25R3916_CMD_GOTO_SENSE \
0xCDU /*!< Passive target logic to Sense/Idle state */
#define ST25R3916_CMD_GOTO_SLEEP \
0xCEU /*!< Passive target logic to Sleep/Halt state */
#define ST25R3916_CMD_MASK_RECEIVE_DATA \
0xD0U /*!< Mask receive data */
#define ST25R3916_CMD_UNMASK_RECEIVE_DATA \
0xD1U /*!< Unmask receive data */
#define ST25R3916_CMD_AM_MOD_STATE_CHANGE \
0xD2U /*!< AM Modulation state change */
#define ST25R3916_CMD_MEASURE_AMPLITUDE \
0xD3U /*!< Measure singal amplitude on RFI inputs */
#define ST25R3916_CMD_RESET_RXGAIN \
0xD5U /*!< Reset RX Gain */
#define ST25R3916_CMD_ADJUST_REGULATORS \
0xD6U /*!< Adjust regulators */
#define ST25R3916_CMD_CALIBRATE_DRIVER_TIMING \
0xD8U /*!< Starts the sequence to adjust the driver timing */
#define ST25R3916_CMD_MEASURE_PHASE \
0xD9U /*!< Measure phase between RFO and RFI signal */
#define ST25R3916_CMD_CLEAR_RSSI \
0xDAU /*!< Clear RSSI bits and restart the measurement */
#define ST25R3916_CMD_CLEAR_FIFO \
0xDBU /*!< Clears FIFO, Collision and IRQ status */
#define ST25R3916_CMD_TRANSPARENT_MODE \
0xDCU /*!< Transparent mode */
#define ST25R3916_CMD_CALIBRATE_C_SENSOR \
0xDDU /*!< Calibrate the capacitive sensor */
#define ST25R3916_CMD_MEASURE_CAPACITANCE \
0xDEU /*!< Measure capacitance */
#define ST25R3916_CMD_MEASURE_VDD \
0xDFU /*!< Measure power supply voltage */
#define ST25R3916_CMD_START_GP_TIMER \
0xE0U /*!< Start the general purpose timer */
#define ST25R3916_CMD_START_WUP_TIMER \
0xE1U /*!< Start the wake-up timer */
#define ST25R3916_CMD_START_MASK_RECEIVE_TIMER \
0xE2U /*!< Start the mask-receive timer */
#define ST25R3916_CMD_START_NO_RESPONSE_TIMER \
0xE3U /*!< Start the no-response timer */
#define ST25R3916_CMD_START_PPON2_TIMER \
0xE4U /*!< Start PPon2 timer */
#define ST25R3916_CMD_STOP_NRT \
0xE8U /*!< Stop No Response Timer */
#define ST25R3916_CMD_SPACE_B_ACCESS \
0xFBU /*!< Enable R/W access to the test registers */
#define ST25R3916_CMD_TEST_ACCESS \
0xFCU /*!< Enable R/W access to the test registers */
#define ST25R3916_THRESHOLD_DO_NOT_SET \
0xFFU /*!< Indicates not to change this Threshold */
#define ST25R3916_THRESHOLD_DO_NOT_SET 0xFFU /*!< Indicates not to change this Threshold */
#define ST25R3916_BR_DO_NOT_SET 0xFFU /*!< Indicates not to change this Bit Rate */
#define ST25R3916_BR_106 0x00U /*!< ST25R3916 Bit Rate 106 kbit/s (fc/128) */
#define ST25R3916_BR_212 0x01U /*!< ST25R3916 Bit Rate 212 kbit/s (fc/64) */
#define ST25R3916_BR_424 0x02U /*!< ST25R3916 Bit Rate 424 kbit/s (fc/32) */
#define ST25R3916_BR_848 0x03U /*!< ST25R3916 Bit Rate 848 kbit/s (fc/16) */
#define ST25R3916_BR_1695 0x04U /*!< ST25R3916 Bit Rate 1696 kbit/s (fc/8) */
#define ST25R3916_BR_3390 0x05U /*!< ST25R3916 Bit Rate 3390 kbit/s (fc/4) */
#define ST25R3916_BR_6780 0x07U /*!< ST25R3916 Bit Rate 6780 kbit/s (fc/2) */
#define ST25R3916_FIFO_DEPTH 512U /*!< Depth of FIFO */
#define ST25R3916_TOUT_OSC_STABLE 10U /*!< Max timeout for Oscillator to get stable DS: 700us */
#define ST25R3916_BR_DO_NOT_SET \
0xFFU /*!< Indicates not to change this Bit Rate */
#define ST25R3916_BR_106 0x00U /*!< ST25R3916 Bit Rate 106 kbit/s (fc/128) */
#define ST25R3916_BR_212 0x01U /*!< ST25R3916 Bit Rate 212 kbit/s (fc/64) */
#define ST25R3916_BR_424 0x02U /*!< ST25R3916 Bit Rate 424 kbit/s (fc/32) */
#define ST25R3916_BR_848 0x03U /*!< ST25R3916 Bit Rate 848 kbit/s (fc/16) */
#define ST25R3916_BR_1695 0x04U /*!< ST25R3916 Bit Rate 1696 kbit/s (fc/8) */
#define ST25R3916_BR_3390 0x05U /*!< ST25R3916 Bit Rate 3390 kbit/s (fc/4) */
#define ST25R3916_BR_6780 0x07U /*!< ST25R3916 Bit Rate 6780 kbit/s (fc/2) */
#define ST25R3916_FIFO_DEPTH 512U /*!< Depth of FIFO */
#define ST25R3916_TOUT_OSC_STABLE \
10U /*!< Max timeout for Oscillator to get stable DS: 700us */
/*
******************************************************************************
@@ -147,31 +179,55 @@ struct st25r3916StreamConfig {
*/
/*! Enables the Transmitter (Field On) and Receiver */
#define st25r3916TxRxOn() st25r3916SetRegisterBits( ST25R3916_REG_OP_CONTROL, (ST25R3916_REG_OP_CONTROL_rx_en | ST25R3916_REG_OP_CONTROL_tx_en ) )
#define st25r3916TxRxOn() \
st25r3916SetRegisterBits( \
ST25R3916_REG_OP_CONTROL, \
(ST25R3916_REG_OP_CONTROL_rx_en | ST25R3916_REG_OP_CONTROL_tx_en))
/*! Disables the Transmitter (Field Off) and Receiver */
#define st25r3916TxRxOff() st25r3916ClrRegisterBits( ST25R3916_REG_OP_CONTROL, (ST25R3916_REG_OP_CONTROL_rx_en | ST25R3916_REG_OP_CONTROL_tx_en ) )
#define st25r3916TxRxOff() \
st25r3916ClrRegisterBits( \
ST25R3916_REG_OP_CONTROL, \
(ST25R3916_REG_OP_CONTROL_rx_en | ST25R3916_REG_OP_CONTROL_tx_en))
/*! Disables the Transmitter (Field Off) */
#define st25r3916TxOff() st25r3916ClrRegisterBits( ST25R3916_REG_OP_CONTROL, ST25R3916_REG_OP_CONTROL_tx_en )
#define st25r3916TxOff() \
st25r3916ClrRegisterBits(ST25R3916_REG_OP_CONTROL, ST25R3916_REG_OP_CONTROL_tx_en)
/*! Checks if General Purpose Timer is still running by reading gpt_on flag */
#define st25r3916IsGPTRunning( ) st25r3916CheckReg( ST25R3916_REG_NFCIP1_BIT_RATE, ST25R3916_REG_NFCIP1_BIT_RATE_gpt_on, ST25R3916_REG_NFCIP1_BIT_RATE_gpt_on )
#define st25r3916IsGPTRunning() \
st25r3916CheckReg( \
ST25R3916_REG_NFCIP1_BIT_RATE, \
ST25R3916_REG_NFCIP1_BIT_RATE_gpt_on, \
ST25R3916_REG_NFCIP1_BIT_RATE_gpt_on)
/*! Checks if External Filed is detected by reading ST25R3916 External Field Detector output */
#define st25r3916IsExtFieldOn() st25r3916CheckReg( ST25R3916_REG_AUX_DISPLAY, ST25R3916_REG_AUX_DISPLAY_efd_o, ST25R3916_REG_AUX_DISPLAY_efd_o )
#define st25r3916IsExtFieldOn() \
st25r3916CheckReg( \
ST25R3916_REG_AUX_DISPLAY, \
ST25R3916_REG_AUX_DISPLAY_efd_o, \
ST25R3916_REG_AUX_DISPLAY_efd_o)
/*! Checks if Transmitter is enabled (Field On) */
#define st25r3916IsTxEnabled() st25r3916CheckReg( ST25R3916_REG_OP_CONTROL, ST25R3916_REG_OP_CONTROL_tx_en, ST25R3916_REG_OP_CONTROL_tx_en )
#define st25r3916IsTxEnabled() \
st25r3916CheckReg( \
ST25R3916_REG_OP_CONTROL, ST25R3916_REG_OP_CONTROL_tx_en, ST25R3916_REG_OP_CONTROL_tx_en)
/*! Checks if NRT is in EMV mode */
#define st25r3916IsNRTinEMV() st25r3916CheckReg( ST25R3916_REG_TIMER_EMV_CONTROL, ST25R3916_REG_TIMER_EMV_CONTROL_nrt_emv, ST25R3916_REG_TIMER_EMV_CONTROL_nrt_emv_on )
#define st25r3916IsNRTinEMV() \
st25r3916CheckReg( \
ST25R3916_REG_TIMER_EMV_CONTROL, \
ST25R3916_REG_TIMER_EMV_CONTROL_nrt_emv, \
ST25R3916_REG_TIMER_EMV_CONTROL_nrt_emv_on)
/*! Checks if last FIFO byte is complete */
#define st25r3916IsLastFIFOComplete() st25r3916CheckReg( ST25R3916_REG_FIFO_STATUS2, ST25R3916_REG_FIFO_STATUS2_fifo_lb_mask, 0 )
#define st25r3916IsLastFIFOComplete() \
st25r3916CheckReg(ST25R3916_REG_FIFO_STATUS2, ST25R3916_REG_FIFO_STATUS2_fifo_lb_mask, 0)
/*! Checks if the Oscillator is enabled */
#define st25r3916IsOscOn() st25r3916CheckReg( ST25R3916_REG_OP_CONTROL, ST25R3916_REG_OP_CONTROL_en, ST25R3916_REG_OP_CONTROL_en )
#define st25r3916IsOscOn() \
st25r3916CheckReg( \
ST25R3916_REG_OP_CONTROL, ST25R3916_REG_OP_CONTROL_en, ST25R3916_REG_OP_CONTROL_en)
/*
******************************************************************************
@@ -193,7 +249,7 @@ struct st25r3916StreamConfig {
*
*****************************************************************************
*/
ReturnCode st25r3916Initialize( void );
ReturnCode st25r3916Initialize(void);
/*!
*****************************************************************************
@@ -203,7 +259,7 @@ ReturnCode st25r3916Initialize( void );
*
*****************************************************************************
*/
void st25r3916Deinitialize( void );
void st25r3916Deinitialize(void);
/*!
*****************************************************************************
@@ -217,7 +273,7 @@ void st25r3916Deinitialize( void );
*
*****************************************************************************
*/
ReturnCode st25r3916OscOn( void );
ReturnCode st25r3916OscOn(void);
/*!
*****************************************************************************
@@ -235,7 +291,7 @@ ReturnCode st25r3916OscOn( void );
*
*****************************************************************************
*/
ReturnCode st25r3916SetBitrate( uint8_t txrate, uint8_t rxrate );
ReturnCode st25r3916SetBitrate(uint8_t txrate, uint8_t rxrate);
/*!
*****************************************************************************
@@ -254,7 +310,7 @@ ReturnCode st25r3916SetBitrate( uint8_t txrate, uint8_t rxrate );
*
*****************************************************************************
*/
ReturnCode st25r3916AdjustRegulators( uint16_t* result_mV );
ReturnCode st25r3916AdjustRegulators(uint16_t* result_mV);
/*!
*****************************************************************************
@@ -270,7 +326,7 @@ ReturnCode st25r3916AdjustRegulators( uint16_t* result_mV );
*
*****************************************************************************
*/
ReturnCode st25r3916MeasureAmplitude( uint8_t* result );
ReturnCode st25r3916MeasureAmplitude(uint8_t* result);
/*!
*****************************************************************************
@@ -288,7 +344,7 @@ ReturnCode st25r3916MeasureAmplitude( uint8_t* result );
*
*****************************************************************************
*/
uint8_t st25r3916MeasurePowerSupply( uint8_t mpsv );
uint8_t st25r3916MeasurePowerSupply(uint8_t mpsv);
/*!
*****************************************************************************
@@ -307,7 +363,7 @@ uint8_t st25r3916MeasurePowerSupply( uint8_t mpsv );
*
*****************************************************************************
*/
uint16_t st25r3916MeasureVoltage( uint8_t mpsv );
uint16_t st25r3916MeasureVoltage(uint8_t mpsv);
/*!
*****************************************************************************
@@ -323,8 +379,7 @@ uint16_t st25r3916MeasureVoltage( uint8_t mpsv );
*
*****************************************************************************
*/
ReturnCode st25r3916MeasurePhase( uint8_t* result );
ReturnCode st25r3916MeasurePhase(uint8_t* result);
/*!
*****************************************************************************
@@ -340,7 +395,7 @@ ReturnCode st25r3916MeasurePhase( uint8_t* result );
*
*****************************************************************************
*/
ReturnCode st25r3916MeasureCapacitance( uint8_t* result );
ReturnCode st25r3916MeasureCapacitance(uint8_t* result);
/*!
*****************************************************************************
@@ -364,7 +419,7 @@ ReturnCode st25r3916MeasureCapacitance( uint8_t* result );
*
*****************************************************************************
*/
ReturnCode st25r3916CalibrateCapacitiveSensor( uint8_t* result );
ReturnCode st25r3916CalibrateCapacitiveSensor(uint8_t* result);
/*!
*****************************************************************************
@@ -377,7 +432,7 @@ ReturnCode st25r3916CalibrateCapacitiveSensor( uint8_t* result );
*
* \return the value of the NRT in 64/fc
*/
uint32_t st25r3916GetNoResponseTime( void );
uint32_t st25r3916GetNoResponseTime(void);
/*!
*****************************************************************************
@@ -392,7 +447,7 @@ uint32_t st25r3916GetNoResponseTime( void );
*
*****************************************************************************
*/
ReturnCode st25r3916SetNoResponseTime( uint32_t nrt_64fcs );
ReturnCode st25r3916SetNoResponseTime(uint32_t nrt_64fcs);
/*!
*****************************************************************************
@@ -409,7 +464,7 @@ ReturnCode st25r3916SetNoResponseTime( uint32_t nrt_64fcs );
*
*****************************************************************************
*/
ReturnCode st25r3916SetStartNoResponseTimer( uint32_t nrt_64fcs );
ReturnCode st25r3916SetStartNoResponseTimer(uint32_t nrt_64fcs);
/*!
*****************************************************************************
@@ -421,7 +476,7 @@ ReturnCode st25r3916SetStartNoResponseTimer( uint32_t nrt_64fcs );
*
*****************************************************************************
*/
void st25r3916SetGPTime( uint16_t gpt_8fcs );
void st25r3916SetGPTime(uint16_t gpt_8fcs);
/*!
*****************************************************************************
@@ -438,7 +493,7 @@ void st25r3916SetGPTime( uint16_t gpt_8fcs );
*
*****************************************************************************
*/
ReturnCode st25r3916SetStartGPTimer( uint16_t gpt_8fcs, uint8_t trigger_source );
ReturnCode st25r3916SetStartGPTimer(uint16_t gpt_8fcs, uint8_t trigger_source);
/*!
*****************************************************************************
@@ -451,7 +506,7 @@ ReturnCode st25r3916SetStartGPTimer( uint16_t gpt_8fcs, uint8_t trigger_source )
*
*****************************************************************************
*/
void st25r3916SetNumTxBits( uint16_t nBits );
void st25r3916SetNumTxBits(uint16_t nBits);
/*!
*****************************************************************************
@@ -463,7 +518,7 @@ void st25r3916SetNumTxBits( uint16_t nBits );
*
*****************************************************************************
*/
uint16_t st25r3916GetNumFIFOBytes( void );
uint16_t st25r3916GetNumFIFOBytes(void);
/*!
*****************************************************************************
@@ -476,7 +531,7 @@ uint16_t st25r3916GetNumFIFOBytes( void );
*
*****************************************************************************
*/
uint8_t st25r3916GetNumFIFOLastBits( void );
uint8_t st25r3916GetNumFIFOLastBits(void);
/*!
*****************************************************************************
@@ -499,7 +554,11 @@ uint8_t st25r3916GetNumFIFOLastBits( void );
*
*****************************************************************************
*/
ReturnCode st25r3916PerformCollisionAvoidance( uint8_t FieldONCmd, uint8_t pdThreshold, uint8_t caThreshold, uint8_t nTRFW );
ReturnCode st25r3916PerformCollisionAvoidance(
uint8_t FieldONCmd,
uint8_t pdThreshold,
uint8_t caThreshold,
uint8_t nTRFW);
/*!
*****************************************************************************
@@ -515,7 +574,7 @@ ReturnCode st25r3916PerformCollisionAvoidance( uint8_t FieldONCmd, uint8_t pdThr
* \return true when IC type is as expected
* \return false otherwise
*/
bool st25r3916CheckChipID( uint8_t *rev );
bool st25r3916CheckChipID(uint8_t* rev);
/*!
*****************************************************************************
@@ -528,7 +587,7 @@ bool st25r3916CheckChipID( uint8_t *rev );
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode st25r3916GetRegsDump( t_st25r3916Regs* regDump );
ReturnCode st25r3916GetRegsDump(t_st25r3916Regs* regDump);
/*!
*****************************************************************************
@@ -543,7 +602,7 @@ ReturnCode st25r3916GetRegsDump( t_st25r3916Regs* regDump );
*
*****************************************************************************
*/
bool st25r3916IsCmdValid( uint8_t cmd );
bool st25r3916IsCmdValid(uint8_t cmd);
/*!
*****************************************************************************
@@ -558,7 +617,7 @@ bool st25r3916IsCmdValid( uint8_t cmd );
*
*****************************************************************************
*/
ReturnCode st25r3916StreamConfigure( const struct st25r3916StreamConfig *config );
ReturnCode st25r3916StreamConfigure(const struct st25r3916StreamConfig* config);
/*!
*****************************************************************************
@@ -577,7 +636,8 @@ ReturnCode st25r3916StreamConfigure( const struct st25r3916StreamConfig *config
*
*****************************************************************************
*/
ReturnCode st25r3916ExecuteCommandAndGetResult( uint8_t cmd, uint8_t resReg, uint8_t tout, uint8_t* result );
ReturnCode
st25r3916ExecuteCommandAndGetResult(uint8_t cmd, uint8_t resReg, uint8_t tout, uint8_t* result);
/*!
*****************************************************************************
@@ -595,7 +655,7 @@ ReturnCode st25r3916ExecuteCommandAndGetResult( uint8_t cmd, uint8_t resReg, uin
*
*****************************************************************************
*/
ReturnCode st25r3916GetRSSI( uint16_t *amRssi, uint16_t *pmRssi );
ReturnCode st25r3916GetRSSI(uint16_t* amRssi, uint16_t* pmRssi);
#endif /* ST25R3916_H */
/**
+167 -130
View File
@@ -19,7 +19,6 @@
*
******************************************************************************/
/*
* PROJECT: ST25R3916 firmware
* Revision:
@@ -37,8 +36,7 @@
* to tune the antenna matching.
*
*/
/*
******************************************************************************
* INCLUDES
@@ -52,207 +50,229 @@
#include "platform.h"
#include "rfal_chip.h"
/*
******************************************************************************
* GLOBAL DEFINES
******************************************************************************
*/
#define ST25R3916_AAT_CAP_DELAY_MAX 10 /*!< Max Variable Capacitor settle delay */
#define ST25R3916_AAT_CAP_DELAY_MAX 10 /*!< Max Variable Capacitor settle delay */
/*
******************************************************************************
* GLOBAL MACROS
******************************************************************************
*/
#define st25r3916AatLog(...) /* platformLog(__VA_ARGS__) */ /*!< Logging macro */
#define st25r3916AatLog(...) /* platformLog(__VA_ARGS__) */ /*!< Logging macro */
/*
******************************************************************************
* LOCAL FUNCTION PROTOTYPES
******************************************************************************
*/
static ReturnCode aatHillClimb(const struct st25r3916AatTuneParams *tuningParams, struct st25r3916AatTuneResult *tuningStatus);
static int32_t aatGreedyDescent(uint32_t *f_min, const struct st25r3916AatTuneParams *tuningParams, struct st25r3916AatTuneResult *tuningStatus, int32_t previousDir);
static int32_t aatSteepestDescent(uint32_t *f_min, const struct st25r3916AatTuneParams *tuningParams, struct st25r3916AatTuneResult *tuningStatus, int32_t previousDir, int32_t previousDir2);
static ReturnCode aatHillClimb(
const struct st25r3916AatTuneParams* tuningParams,
struct st25r3916AatTuneResult* tuningStatus);
static int32_t aatGreedyDescent(
uint32_t* f_min,
const struct st25r3916AatTuneParams* tuningParams,
struct st25r3916AatTuneResult* tuningStatus,
int32_t previousDir);
static int32_t aatSteepestDescent(
uint32_t* f_min,
const struct st25r3916AatTuneParams* tuningParams,
struct st25r3916AatTuneResult* tuningStatus,
int32_t previousDir,
int32_t previousDir2);
static ReturnCode aatMeasure(uint8_t serCap, uint8_t parCap, uint8_t *amplitude, uint8_t *phase, uint16_t *measureCnt);
static uint32_t aatCalcF(const struct st25r3916AatTuneParams *tuningParams, uint8_t amplitude, uint8_t phase);
static ReturnCode aatStepDacVals(const struct st25r3916AatTuneParams *tuningParams,uint8_t *a, uint8_t *b, int32_t dir);
static ReturnCode aatMeasure(
uint8_t serCap,
uint8_t parCap,
uint8_t* amplitude,
uint8_t* phase,
uint16_t* measureCnt);
static uint32_t
aatCalcF(const struct st25r3916AatTuneParams* tuningParams, uint8_t amplitude, uint8_t phase);
static ReturnCode aatStepDacVals(
const struct st25r3916AatTuneParams* tuningParams,
uint8_t* a,
uint8_t* b,
int32_t dir);
/*******************************************************************************/
ReturnCode st25r3916AatTune(const struct st25r3916AatTuneParams *tuningParams, struct st25r3916AatTuneResult *tuningStatus)
{
ReturnCode st25r3916AatTune(
const struct st25r3916AatTuneParams* tuningParams,
struct st25r3916AatTuneResult* tuningStatus) {
ReturnCode err;
const struct st25r3916AatTuneParams *tp = tuningParams;
struct st25r3916AatTuneResult *ts = tuningStatus;
struct st25r3916AatTuneParams defaultTuningParams =
{
.aat_a_min=0,
.aat_a_max=255,
.aat_a_start=127,
.aat_a_stepWidth=32,
.aat_b_min=0,
.aat_b_max=255,
.aat_b_start=127,
.aat_b_stepWidth=32,
const struct st25r3916AatTuneParams* tp = tuningParams;
struct st25r3916AatTuneResult* ts = tuningStatus;
struct st25r3916AatTuneParams defaultTuningParams = {
.aat_a_min = 0,
.aat_a_max = 255,
.aat_a_start = 127,
.aat_a_stepWidth = 32,
.aat_b_min = 0,
.aat_b_max = 255,
.aat_b_start = 127,
.aat_b_stepWidth = 32,
.phaTarget=128,
.phaWeight=2,
.ampTarget=196,
.ampWeight=1,
.phaTarget = 128,
.phaWeight = 2,
.ampTarget = 196,
.ampWeight = 1,
.doDynamicSteps=true,
.measureLimit=50,
.doDynamicSteps = true,
.measureLimit = 50,
};
struct st25r3916AatTuneResult defaultTuneResult;
if ((NULL != tp) && (
(tp->aat_a_min > tp->aat_a_max )
|| (tp->aat_a_start < tp->aat_a_min )
|| (tp->aat_a_start > tp->aat_a_max )
|| (tp->aat_b_min > tp->aat_b_max )
|| (tp->aat_b_start < tp->aat_b_min )
|| (tp->aat_b_start > tp->aat_b_max )
))
{
if((NULL != tp) && ((tp->aat_a_min > tp->aat_a_max) || (tp->aat_a_start < tp->aat_a_min) ||
(tp->aat_a_start > tp->aat_a_max) || (tp->aat_b_min > tp->aat_b_max) ||
(tp->aat_b_start < tp->aat_b_min) || (tp->aat_b_start > tp->aat_b_max))) {
return ERR_PARAM;
}
if (NULL == tp)
{ /* Start from current caps with default params */
if(NULL == tp) { /* Start from current caps with default params */
st25r3916ReadRegister(ST25R3916_REG_ANT_TUNE_A, &defaultTuningParams.aat_a_start);
st25r3916ReadRegister(ST25R3916_REG_ANT_TUNE_B, &defaultTuningParams.aat_b_start);
tp = &defaultTuningParams;
}
if (NULL == ts){ts = &defaultTuneResult;}
if(NULL == ts) {
ts = &defaultTuneResult;
}
ts->measureCnt = 0; /* Clear current measure count */
err = aatHillClimb(tp, ts);
return err;
}
/*******************************************************************************/
static ReturnCode aatHillClimb(const struct st25r3916AatTuneParams *tuningParams, struct st25r3916AatTuneResult *tuningStatus)
{
ReturnCode err = ERR_NONE;
static ReturnCode aatHillClimb(
const struct st25r3916AatTuneParams* tuningParams,
struct st25r3916AatTuneResult* tuningStatus) {
ReturnCode err = ERR_NONE;
uint32_t f_min;
int32_t direction, gdirection;
uint8_t amp,phs;
uint8_t amp, phs;
struct st25r3916AatTuneParams tp = *tuningParams; // local copy to obey const
tuningStatus->aat_a = tuningParams->aat_a_start;
tuningStatus->aat_b = tuningParams->aat_b_start;
/* Get a proper start value */
aatMeasure(tuningStatus->aat_a,tuningStatus->aat_b,&amp,&phs,&tuningStatus->measureCnt);
aatMeasure(tuningStatus->aat_a, tuningStatus->aat_b, &amp, &phs, &tuningStatus->measureCnt);
f_min = aatCalcF(&tp, amp, phs);
direction = 0;
st25r3916AatLog("%d %d: %d***\n",tuningStatus->aat_a,tuningStatus->aat_b,f_min);
st25r3916AatLog("%d %d: %d***\n", tuningStatus->aat_a, tuningStatus->aat_b, f_min);
do {
direction = 0; /* Initially and after reducing step sizes we don't have a previous direction */
direction =
0; /* Initially and after reducing step sizes we don't have a previous direction */
do {
/* With the greedy step below always executed aftwards the -direction does never need to be investigated */
direction = aatSteepestDescent(&f_min, &tp, tuningStatus, direction, -direction);
if (tuningStatus->measureCnt > tp.measureLimit)
{
if(tuningStatus->measureCnt > tp.measureLimit) {
err = ERR_OVERRUN;
break;
}
do
{
do {
gdirection = aatGreedyDescent(&f_min, &tp, tuningStatus, direction);
if (tuningStatus->measureCnt > tp.measureLimit) {
if(tuningStatus->measureCnt > tp.measureLimit) {
err = ERR_OVERRUN;
break;
}
} while (0 != gdirection);
} while (0 != direction);
} while(0 != gdirection);
} while(0 != direction);
tp.aat_a_stepWidth /= 2U; /* Reduce step sizes */
tp.aat_b_stepWidth /= 2U;
} while (tp.doDynamicSteps && ((tp.aat_a_stepWidth>0U) || (tp.aat_b_stepWidth>0U)));
} while(tp.doDynamicSteps && ((tp.aat_a_stepWidth > 0U) || (tp.aat_b_stepWidth > 0U)));
return err;
}
/*******************************************************************************/
static int32_t aatSteepestDescent(uint32_t *f_min, const struct st25r3916AatTuneParams *tuningParams, struct st25r3916AatTuneResult *tuningStatus, int32_t previousDir, int32_t previousDir2)
{
static int32_t aatSteepestDescent(
uint32_t* f_min,
const struct st25r3916AatTuneParams* tuningParams,
struct st25r3916AatTuneResult* tuningStatus,
int32_t previousDir,
int32_t previousDir2) {
int32_t i;
uint8_t amp,phs;
uint8_t amp, phs;
uint32_t f;
int32_t bestdir = 0; /* Negative direction: decrease, Positive: increase. (-)1: aat_a, (-)2: aat_b */
int32_t bestdir =
0; /* Negative direction: decrease, Positive: increase. (-)1: aat_a, (-)2: aat_b */
for (i = -2; i <= 2; i++)
{
uint8_t a = tuningStatus->aat_a , b = tuningStatus->aat_b;
for(i = -2; i <= 2; i++) {
uint8_t a = tuningStatus->aat_a, b = tuningStatus->aat_b;
if ((0==i) || (i==-previousDir) || (i==-previousDir2))
{ /* Skip no direction and avoid going backwards */
if((0 == i) || (i == -previousDir) ||
(i == -previousDir2)) { /* Skip no direction and avoid going backwards */
continue;
}
if (0U!=aatStepDacVals(tuningParams, &a, &b, i))
{ /* If stepping did not change the value, omit this direction */
if(0U != aatStepDacVals(
tuningParams,
&a,
&b,
i)) { /* If stepping did not change the value, omit this direction */
continue;
}
aatMeasure(a,b,&amp,&phs,&tuningStatus->measureCnt);
aatMeasure(a, b, &amp, &phs, &tuningStatus->measureCnt);
f = aatCalcF(tuningParams, amp, phs);
st25r3916AatLog("%d : %d %d: %d",i,a, b, f);
if (f < *f_min)
{ /* Value is better than all previous ones */
st25r3916AatLog("%d : %d %d: %d", i, a, b, f);
if(f < *f_min) { /* Value is better than all previous ones */
st25r3916AatLog("*");
*f_min = f;
bestdir = i;
}
st25r3916AatLog("\n");
}
if (0!=bestdir)
{ /* Walk into the best direction */
if(0 != bestdir) { /* Walk into the best direction */
aatStepDacVals(tuningParams, &tuningStatus->aat_a, &tuningStatus->aat_b, bestdir);
}
return bestdir;
}
/*******************************************************************************/
static int32_t aatGreedyDescent(uint32_t *f_min, const struct st25r3916AatTuneParams *tuningParams, struct st25r3916AatTuneResult *tuningStatus, int32_t previousDir)
{
uint8_t amp,phs;
static int32_t aatGreedyDescent(
uint32_t* f_min,
const struct st25r3916AatTuneParams* tuningParams,
struct st25r3916AatTuneResult* tuningStatus,
int32_t previousDir) {
uint8_t amp, phs;
uint32_t f;
uint8_t a = tuningStatus->aat_a , b = tuningStatus->aat_b;
uint8_t a = tuningStatus->aat_a, b = tuningStatus->aat_b;
if (0U != aatStepDacVals(tuningParams, &a, &b, previousDir))
{ /* If stepping did not change the value, omit this direction */
if(0U != aatStepDacVals(
tuningParams,
&a,
&b,
previousDir)) { /* If stepping did not change the value, omit this direction */
return 0;
}
aatMeasure(a,b,&amp,&phs,&tuningStatus->measureCnt);
aatMeasure(a, b, &amp, &phs, &tuningStatus->measureCnt);
f = aatCalcF(tuningParams, amp, phs);
st25r3916AatLog("g : %d %d: %d",a, b, f);
if (f < *f_min)
{ /* Value is better than previous one */
st25r3916AatLog("g : %d %d: %d", a, b, f);
if(f < *f_min) { /* Value is better than previous one */
st25r3916AatLog("*\n");
tuningStatus->aat_a = a;
tuningStatus->aat_b = b;
*f_min = f;
return previousDir;
}
st25r3916AatLog("\n");
return 0;
}
/*******************************************************************************/
static uint32_t aatCalcF(const struct st25r3916AatTuneParams *tuningParams, uint8_t amplitude, uint8_t phase)
{
static uint32_t
aatCalcF(const struct st25r3916AatTuneParams* tuningParams, uint8_t amplitude, uint8_t phase) {
/* f(amp, pha) = (ampWeight * |amp - ampTarget|) + (phaWeight * |pha - phaTarget|) */
uint8_t ampTarget = tuningParams->ampTarget;
uint8_t phaTarget = tuningParams->phaTarget;
@@ -261,8 +281,8 @@ static uint32_t aatCalcF(const struct st25r3916AatTuneParams *tuningParams, uint
uint32_t phaWeight = tuningParams->phaWeight;
/* Temp variables to avoid MISRA R10.8 (cast on composite expression) */
uint8_t ad = ((amplitude > ampTarget) ? (amplitude - ampTarget) : (ampTarget - amplitude));
uint8_t pd = ((phase > phaTarget) ? (phase - phaTarget) : (phaTarget - phase));
uint8_t ad = ((amplitude > ampTarget) ? (amplitude - ampTarget) : (ampTarget - amplitude));
uint8_t pd = ((phase > phaTarget) ? (phase - phaTarget) : (phaTarget - phase));
uint32_t ampDelta = (uint32_t)ad;
uint32_t phaDelta = (uint32_t)pd;
@@ -271,58 +291,75 @@ static uint32_t aatCalcF(const struct st25r3916AatTuneParams *tuningParams, uint
}
/*******************************************************************************/
static ReturnCode aatStepDacVals(const struct st25r3916AatTuneParams *tuningParams,uint8_t *a, uint8_t *b, int32_t dir)
{
static ReturnCode aatStepDacVals(
const struct st25r3916AatTuneParams* tuningParams,
uint8_t* a,
uint8_t* b,
int32_t dir) {
int16_t aat_a = (int16_t)*a, aat_b = (int16_t)*b;
switch (abs(dir))
{ /* Advance by steps size in requested direction */
case 1:
aat_a = (dir<0)?(aat_a - (int16_t)tuningParams->aat_a_stepWidth):(aat_a + (int16_t)tuningParams->aat_a_stepWidth);
if(aat_a < (int16_t)tuningParams->aat_a_min){ aat_a = (int16_t)tuningParams->aat_a_min; }
if(aat_a > (int16_t)tuningParams->aat_a_max){ aat_a = (int16_t)tuningParams->aat_a_max; }
if ((int16_t)*a == aat_a) {return ERR_PARAM;}
break;
case 2:
aat_b = (dir<0)?(aat_b - (int16_t)tuningParams->aat_b_stepWidth):(aat_b + (int16_t)tuningParams->aat_b_stepWidth);
if(aat_b < (int16_t)tuningParams->aat_b_min){ aat_b = (int16_t)tuningParams->aat_b_min; }
if(aat_b > (int16_t)tuningParams->aat_b_max){ aat_b = (int16_t)tuningParams->aat_b_max; }
if ((int16_t)*b == aat_b) {return ERR_PARAM;}
break;
default:
return ERR_REQUEST;
switch(abs(dir)) { /* Advance by steps size in requested direction */
case 1:
aat_a = (dir < 0) ? (aat_a - (int16_t)tuningParams->aat_a_stepWidth) :
(aat_a + (int16_t)tuningParams->aat_a_stepWidth);
if(aat_a < (int16_t)tuningParams->aat_a_min) {
aat_a = (int16_t)tuningParams->aat_a_min;
}
if(aat_a > (int16_t)tuningParams->aat_a_max) {
aat_a = (int16_t)tuningParams->aat_a_max;
}
if((int16_t)*a == aat_a) {
return ERR_PARAM;
}
break;
case 2:
aat_b = (dir < 0) ? (aat_b - (int16_t)tuningParams->aat_b_stepWidth) :
(aat_b + (int16_t)tuningParams->aat_b_stepWidth);
if(aat_b < (int16_t)tuningParams->aat_b_min) {
aat_b = (int16_t)tuningParams->aat_b_min;
}
if(aat_b > (int16_t)tuningParams->aat_b_max) {
aat_b = (int16_t)tuningParams->aat_b_max;
}
if((int16_t)*b == aat_b) {
return ERR_PARAM;
}
break;
default:
return ERR_REQUEST;
}
/* We only get here if actual values have changed. In all other cases an error is returned */
*a = (uint8_t)aat_a;
*a = (uint8_t)aat_a;
*b = (uint8_t)aat_b;
return ERR_NONE;
return ERR_NONE;
}
/*******************************************************************************/
static ReturnCode aatMeasure(uint8_t serCap, uint8_t parCap, uint8_t *amplitude, uint8_t *phase, uint16_t *measureCnt)
{
static ReturnCode aatMeasure(
uint8_t serCap,
uint8_t parCap,
uint8_t* amplitude,
uint8_t* phase,
uint16_t* measureCnt) {
ReturnCode err;
*amplitude = 0;
*phase = 0;
*amplitude = 0;
*phase = 0;
st25r3916WriteRegister(ST25R3916_REG_ANT_TUNE_A, serCap);
st25r3916WriteRegister(ST25R3916_REG_ANT_TUNE_B, parCap);
/* Wait till caps have settled.. */
platformDelay( ST25R3916_AAT_CAP_DELAY_MAX );
platformDelay(ST25R3916_AAT_CAP_DELAY_MAX);
/* Get amplitude and phase .. */
err = rfalChipMeasureAmplitude(amplitude);
if (ERR_NONE == err)
{
if(ERR_NONE == err) {
err = rfalChipMeasurePhase(phase);
}
if( measureCnt != NULL )
{
if(measureCnt != NULL) {
(*measureCnt)++;
}
return err;
+24 -28
View File
@@ -19,7 +19,6 @@
*
******************************************************************************/
/*
* PROJECT: ST25R3916 firmware
* Revision:
@@ -38,7 +37,6 @@
*
*/
#ifndef ST25R3916_AAT_H
#define ST25R3916_AAT_H
@@ -54,40 +52,36 @@
/*!
* struct representing input parameters for the antenna tuning
*/
struct st25r3916AatTuneParams{
uint8_t aat_a_min; /*!< min value of A cap */
uint8_t aat_a_max; /*!< max value of A cap */
uint8_t aat_a_start; /*!< start value of A cap */
uint8_t aat_a_stepWidth; /*!< increment stepWidth for A cap */
uint8_t aat_b_min; /*!< min value of B cap */
uint8_t aat_b_max; /*!< max value of B cap */
uint8_t aat_b_start; /*!< start value of B cap */
uint8_t aat_b_stepWidth; /*!< increment stepWidth for B cap */
struct st25r3916AatTuneParams {
uint8_t aat_a_min; /*!< min value of A cap */
uint8_t aat_a_max; /*!< max value of A cap */
uint8_t aat_a_start; /*!< start value of A cap */
uint8_t aat_a_stepWidth; /*!< increment stepWidth for A cap */
uint8_t aat_b_min; /*!< min value of B cap */
uint8_t aat_b_max; /*!< max value of B cap */
uint8_t aat_b_start; /*!< start value of B cap */
uint8_t aat_b_stepWidth; /*!< increment stepWidth for B cap */
uint8_t phaTarget; /*!< target phase */
uint8_t phaWeight; /*!< weight of target phase */
uint8_t ampTarget; /*!< target amplitude */
uint8_t ampWeight; /*!< weight of target amplitude */
uint8_t phaTarget; /*!< target phase */
uint8_t phaWeight; /*!< weight of target phase */
uint8_t ampTarget; /*!< target amplitude */
uint8_t ampWeight; /*!< weight of target amplitude */
bool doDynamicSteps; /*!< dynamically reduce step size in algo */
uint8_t measureLimit; /*!< max number of allowed steps/measurements */
bool doDynamicSteps; /*!< dynamically reduce step size in algo */
uint8_t measureLimit; /*!< max number of allowed steps/measurements */
};
/*!
* struct representing out parameters for the antenna tuning
*/
struct st25r3916AatTuneResult{
uint8_t aat_a; /*!< serial cap after tuning */
uint8_t aat_b; /*!< parallel cap after tuning */
uint8_t pha; /*!< phase after tuning */
uint8_t amp; /*!< amplitude after tuning */
uint16_t measureCnt; /*!< number of measures performed */
struct st25r3916AatTuneResult {
uint8_t aat_a; /*!< serial cap after tuning */
uint8_t aat_b; /*!< parallel cap after tuning */
uint8_t pha; /*!< phase after tuning */
uint8_t amp; /*!< amplitude after tuning */
uint16_t measureCnt; /*!< number of measures performed */
};
/*!
*****************************************************************************
* \brief Perform antenna tuning
@@ -108,6 +102,8 @@ struct st25r3916AatTuneResult{
*
*****************************************************************************
*/
extern ReturnCode st25r3916AatTune(const struct st25r3916AatTuneParams *tuningParams, struct st25r3916AatTuneResult *tuningStatus);
extern ReturnCode st25r3916AatTune(
const struct st25r3916AatTuneParams* tuningParams,
struct st25r3916AatTuneResult* tuningStatus);
#endif /* ST25R3916_AAT_H */
+256 -288
View File
@@ -20,7 +20,6 @@
*
******************************************************************************/
/*
* PROJECT: ST25R3916 firmware
* Revision:
@@ -48,29 +47,42 @@
#include "platform.h"
#include "utils.h"
/*
******************************************************************************
* LOCAL DEFINES
******************************************************************************
*/
#define ST25R3916_OPTIMIZE true /*!< Optimization switch: false always write value to register */
#define ST25R3916_I2C_ADDR (0xA0U >> 1) /*!< ST25R3916's default I2C address */
#define ST25R3916_REG_LEN 1U /*!< Byte length of a ST25R3916 register */
#define ST25R3916_OPTIMIZE \
true /*!< Optimization switch: false always write value to register */
#define ST25R3916_I2C_ADDR \
(0xA0U >> 1) /*!< ST25R3916's default I2C address */
#define ST25R3916_REG_LEN 1U /*!< Byte length of a ST25R3916 register */
#define ST25R3916_WRITE_MODE (0U << 6) /*!< ST25R3916 Operation Mode: Write */
#define ST25R3916_READ_MODE (1U << 6) /*!< ST25R3916 Operation Mode: Read */
#define ST25R3916_CMD_MODE (3U << 6) /*!< ST25R3916 Operation Mode: Direct Command */
#define ST25R3916_FIFO_LOAD (0x80U) /*!< ST25R3916 Operation Mode: FIFO Load */
#define ST25R3916_FIFO_READ (0x9FU) /*!< ST25R3916 Operation Mode: FIFO Read */
#define ST25R3916_PT_A_CONFIG_LOAD (0xA0U) /*!< ST25R3916 Operation Mode: Passive Target Memory A-Config Load */
#define ST25R3916_PT_F_CONFIG_LOAD (0xA8U) /*!< ST25R3916 Operation Mode: Passive Target Memory F-Config Load */
#define ST25R3916_PT_TSN_DATA_LOAD (0xACU) /*!< ST25R3916 Operation Mode: Passive Target Memory TSN Load */
#define ST25R3916_PT_MEM_READ (0xBFU) /*!< ST25R3916 Operation Mode: Passive Target Memory Read */
#define ST25R3916_WRITE_MODE \
(0U << 6) /*!< ST25R3916 Operation Mode: Write */
#define ST25R3916_READ_MODE \
(1U << 6) /*!< ST25R3916 Operation Mode: Read */
#define ST25R3916_CMD_MODE \
(3U << 6) /*!< ST25R3916 Operation Mode: Direct Command */
#define ST25R3916_FIFO_LOAD \
(0x80U) /*!< ST25R3916 Operation Mode: FIFO Load */
#define ST25R3916_FIFO_READ \
(0x9FU) /*!< ST25R3916 Operation Mode: FIFO Read */
#define ST25R3916_PT_A_CONFIG_LOAD \
(0xA0U) /*!< ST25R3916 Operation Mode: Passive Target Memory A-Config Load */
#define ST25R3916_PT_F_CONFIG_LOAD \
(0xA8U) /*!< ST25R3916 Operation Mode: Passive Target Memory F-Config Load */
#define ST25R3916_PT_TSN_DATA_LOAD \
(0xACU) /*!< ST25R3916 Operation Mode: Passive Target Memory TSN Load */
#define ST25R3916_PT_MEM_READ \
(0xBFU) /*!< ST25R3916 Operation Mode: Passive Target Memory Read */
#define ST25R3916_CMD_LEN (1U) /*!< ST25R3916 CMD length */
#define ST25R3916_BUF_LEN (ST25R3916_CMD_LEN+ST25R3916_FIFO_DEPTH) /*!< ST25R3916 communication buffer: CMD + FIFO length */
#define ST25R3916_CMD_LEN \
(1U) /*!< ST25R3916 CMD length */
#define ST25R3916_BUF_LEN \
(ST25R3916_CMD_LEN + \
ST25R3916_FIFO_DEPTH) /*!< ST25R3916 communication buffer: CMD + FIFO length */
/*
******************************************************************************
@@ -78,19 +90,26 @@
******************************************************************************
*/
#ifdef RFAL_USE_I2C
#define st25r3916I2CStart() platformI2CStart() /*!< ST25R3916 HAL I2C driver macro to start a I2C transfer */
#define st25r3916I2CStop() platformI2CStop() /*!< ST25R3916 HAL I2C driver macro to stop a I2C transfer */
#define st25r3916I2CRepeatStart() platformI2CRepeatStart() /*!< ST25R3916 HAL I2C driver macro to repeat Start */
#define st25r3916I2CSlaveAddrWR( sA ) platformI2CSlaveAddrWR( sA ) /*!< ST25R3916 HAL I2C driver macro to repeat Start */
#define st25r3916I2CSlaveAddrRD( sA ) platformI2CSlaveAddrRD( sA ) /*!< ST25R3916 HAL I2C driver macro to repeat Start */
#define st25r3916I2CStart() \
platformI2CStart() /*!< ST25R3916 HAL I2C driver macro to start a I2C transfer */
#define st25r3916I2CStop() \
platformI2CStop() /*!< ST25R3916 HAL I2C driver macro to stop a I2C transfer */
#define st25r3916I2CRepeatStart() \
platformI2CRepeatStart() /*!< ST25R3916 HAL I2C driver macro to repeat Start */
#define st25r3916I2CSlaveAddrWR(sA) \
platformI2CSlaveAddrWR( \
sA) /*!< ST25R3916 HAL I2C driver macro to repeat Start */
#define st25r3916I2CSlaveAddrRD(sA) \
platformI2CSlaveAddrRD( \
sA) /*!< ST25R3916 HAL I2C driver macro to repeat Start */
#endif /* RFAL_USE_I2C */
#if defined(ST25R_COM_SINGLETXRX) && !defined(RFAL_USE_I2C)
static uint8_t comBuf[ST25R3916_BUF_LEN]; /*!< ST25R3916 communication buffer */
static uint16_t comBufIt; /*!< ST25R3916 communication buffer iterator */
static uint8_t
comBuf[ST25R3916_BUF_LEN]; /*!< ST25R3916 communication buffer */
static uint16_t comBufIt; /*!< ST25R3916 communication buffer iterator */
#endif /* ST25R_COM_SINGLETXRX */
/*
******************************************************************************
* LOCAL FUNCTION PROTOTYPES
@@ -105,7 +124,7 @@ static uint16_t comBufIt; /*!< ST25
* ST25R3916, either by SPI or I2C
******************************************************************************
*/
static void st25r3916comStart( void );
static void st25r3916comStart(void);
/*!
******************************************************************************
@@ -115,7 +134,7 @@ static void st25r3916comStart( void );
* ST25R3916, either by SPI or I2C
******************************************************************************
*/
static void st25r3916comStop( void );
static void st25r3916comStop(void);
/*!
******************************************************************************
@@ -126,9 +145,9 @@ static void st25r3916comStop( void );
******************************************************************************
*/
#ifdef RFAL_USE_I2C
static void st25r3916comRepeatStart( void );
static void st25r3916comRepeatStart(void);
#else
#define st25r3916comRepeatStart()
#define st25r3916comRepeatStart()
#endif /* RFAL_USE_I2C */
/*!
@@ -145,8 +164,7 @@ static void st25r3916comRepeatStart( void );
*
******************************************************************************
*/
static void st25r3916comTx( const uint8_t* txBuf, uint16_t txLen, bool last, bool txOnly );
static void st25r3916comTx(const uint8_t* txBuf, uint16_t txLen, bool last, bool txOnly);
/*!
******************************************************************************
@@ -160,7 +178,7 @@ static void st25r3916comTx( const uint8_t* txBuf, uint16_t txLen, bool last, boo
*
******************************************************************************
*/
static void st25r3916comRx( uint8_t* rxBuf, uint16_t rxLen );
static void st25r3916comRx(uint8_t* rxBuf, uint16_t rxLen);
/*!
******************************************************************************
@@ -174,39 +192,34 @@ static void st25r3916comRx( uint8_t* rxBuf, uint16_t rxLen );
*
******************************************************************************
*/
static void st25r3916comTxByte( uint8_t txByte, bool last, bool txOnly );
static void st25r3916comTxByte(uint8_t txByte, bool last, bool txOnly);
/*
******************************************************************************
* LOCAL FUNCTION
******************************************************************************
*/
static void st25r3916comStart( void )
{
static void st25r3916comStart(void) {
/* Make this operation atomic, disabling ST25R3916 interrupt during communications*/
platformProtectST25RComm();
#ifdef RFAL_USE_I2C
/* I2C Start and send Slave Address */
st25r3916I2CStart();
st25r3916I2CSlaveAddrWR( ST25R3916_I2C_ADDR );
st25r3916I2CSlaveAddrWR(ST25R3916_I2C_ADDR);
#else
/* Perform the chip select */
platformSpiSelect();
#if defined(ST25R_COM_SINGLETXRX)
comBufIt = 0; /* reset local buffer position */
#endif /* ST25R_COM_SINGLETXRX */
#if defined(ST25R_COM_SINGLETXRX)
comBufIt = 0; /* reset local buffer position */
#endif /* ST25R_COM_SINGLETXRX */
#endif /* RFAL_USE_I2C */
}
/*******************************************************************************/
static void st25r3916comStop( void )
{
static void st25r3916comStop(void) {
#ifdef RFAL_USE_I2C
/* Generate Stop signal */
st25r3916I2CStop();
@@ -214,83 +227,95 @@ static void st25r3916comStop( void )
/* Release the chip select */
platformSpiDeselect();
#endif /* RFAL_USE_I2C */
/* reEnable the ST25R3916 interrupt */
platformUnprotectST25RComm();
}
/*******************************************************************************/
#ifdef RFAL_USE_I2C
static void st25r3916comRepeatStart( void )
{
static void st25r3916comRepeatStart(void) {
st25r3916I2CRepeatStart();
st25r3916I2CSlaveAddrRD( ST25R3916_I2C_ADDR );
st25r3916I2CSlaveAddrRD(ST25R3916_I2C_ADDR);
}
#endif /* RFAL_USE_I2C */
/*******************************************************************************/
static void st25r3916comTx( const uint8_t* txBuf, uint16_t txLen, bool last, bool txOnly )
{
static void st25r3916comTx(const uint8_t* txBuf, uint16_t txLen, bool last, bool txOnly) {
NO_WARNING(last);
NO_WARNING(txOnly);
if( txLen > 0U )
{
#ifdef RFAL_USE_I2C
platformI2CTx( txBuf, txLen, last, txOnly );
#else /* RFAL_USE_I2C */
#ifdef ST25R_COM_SINGLETXRX
ST_MEMCPY( &comBuf[comBufIt], txBuf, MIN( txLen, (ST25R3916_BUF_LEN - comBufIt) ) ); /* copy tx data to local buffer */
comBufIt += MIN( txLen, (ST25R3916_BUF_LEN - comBufIt) ); /* store position on local buffer */
if( last && txOnly ) /* only perform SPI transaction if no Rx will follow */
{
platformSpiTxRx( comBuf, NULL, comBufIt );
}
#else
platformSpiTxRx( txBuf, NULL, txLen );
#endif /* ST25R_COM_SINGLETXRX */
#endif /* RFAL_USE_I2C */
}
}
/*******************************************************************************/
static void st25r3916comRx( uint8_t* rxBuf, uint16_t rxLen )
{
if( rxLen > 0U )
{
if(txLen > 0U) {
#ifdef RFAL_USE_I2C
platformI2CRx( rxBuf, rxLen );
platformI2CTx(txBuf, txLen, last, txOnly);
#else /* RFAL_USE_I2C */
#ifdef ST25R_COM_SINGLETXRX
ST_MEMSET( &comBuf[comBufIt], 0x00, MIN( rxLen, (ST25R3916_BUF_LEN - comBufIt) ) ); /* clear outgoing buffer */
platformSpiTxRx( comBuf, comBuf, MIN( (comBufIt + rxLen), ST25R3916_BUF_LEN ) ); /* transceive as a single SPI call */
ST_MEMCPY( rxBuf, &comBuf[comBufIt], MIN( rxLen, (ST25R3916_BUF_LEN - comBufIt) ) ); /* copy from local buf to output buffer and skip cmd byte */
#else
if( rxBuf != NULL)
#ifdef ST25R_COM_SINGLETXRX
ST_MEMCPY(
&comBuf[comBufIt],
txBuf,
MIN(txLen,
(ST25R3916_BUF_LEN -
comBufIt))); /* copy tx data to local buffer */
comBufIt +=
MIN(txLen,
(ST25R3916_BUF_LEN -
comBufIt)); /* store position on local buffer */
if(last && txOnly) /* only perform SPI transaction if no Rx will follow */
{
ST_MEMSET( rxBuf, 0x00, rxLen ); /* clear outgoing buffer */
platformSpiTxRx(comBuf, NULL, comBufIt);
}
platformSpiTxRx( NULL, rxBuf, rxLen );
#endif /* ST25R_COM_SINGLETXRX */
#else
platformSpiTxRx(txBuf, NULL, txLen);
#endif /* ST25R_COM_SINGLETXRX */
#endif /* RFAL_USE_I2C */
}
}
/*******************************************************************************/
static void st25r3916comRx(uint8_t* rxBuf, uint16_t rxLen) {
if(rxLen > 0U) {
#ifdef RFAL_USE_I2C
platformI2CRx(rxBuf, rxLen);
#else /* RFAL_USE_I2C */
#ifdef ST25R_COM_SINGLETXRX
ST_MEMSET(
&comBuf[comBufIt],
0x00,
MIN(rxLen,
(ST25R3916_BUF_LEN -
comBufIt))); /* clear outgoing buffer */
platformSpiTxRx(
comBuf,
comBuf,
MIN((comBufIt + rxLen),
ST25R3916_BUF_LEN)); /* transceive as a single SPI call */
ST_MEMCPY(
rxBuf,
&comBuf[comBufIt],
MIN(rxLen,
(ST25R3916_BUF_LEN -
comBufIt))); /* copy from local buf to output buffer and skip cmd byte */
#else
if(rxBuf != NULL) {
ST_MEMSET(
rxBuf, 0x00, rxLen); /* clear outgoing buffer */
}
platformSpiTxRx(NULL, rxBuf, rxLen);
#endif /* ST25R_COM_SINGLETXRX */
#endif /* RFAL_USE_I2C */
}
}
/*******************************************************************************/
static void st25r3916comTxByte( uint8_t txByte, bool last, bool txOnly )
{
uint8_t val = txByte; /* MISRA 17.8: use intermediate variable */
st25r3916comTx( &val, ST25R3916_REG_LEN, last, txOnly );
static void st25r3916comTxByte(uint8_t txByte, bool last, bool txOnly) {
uint8_t val = txByte; /* MISRA 17.8: use intermediate variable */
st25r3916comTx(&val, ST25R3916_REG_LEN, last, txOnly);
}
/*
@@ -300,350 +325,293 @@ static void st25r3916comTxByte( uint8_t txByte, bool last, bool txOnly )
*/
/*******************************************************************************/
ReturnCode st25r3916ReadRegister( uint8_t reg, uint8_t* val )
{
return st25r3916ReadMultipleRegisters( reg, val, ST25R3916_REG_LEN );
ReturnCode st25r3916ReadRegister(uint8_t reg, uint8_t* val) {
return st25r3916ReadMultipleRegisters(reg, val, ST25R3916_REG_LEN);
}
/*******************************************************************************/
ReturnCode st25r3916ReadMultipleRegisters( uint8_t reg, uint8_t* values, uint8_t length )
{
if( length > 0U )
{
ReturnCode st25r3916ReadMultipleRegisters(uint8_t reg, uint8_t* values, uint8_t length) {
if(length > 0U) {
st25r3916comStart();
/* If is a space-B register send a direct command first */
if( (reg & ST25R3916_SPACE_B) != 0U )
{
st25r3916comTxByte( ST25R3916_CMD_SPACE_B_ACCESS, false, false );
if((reg & ST25R3916_SPACE_B) != 0U) {
st25r3916comTxByte(ST25R3916_CMD_SPACE_B_ACCESS, false, false);
}
st25r3916comTxByte( ((reg & ~ST25R3916_SPACE_B) | ST25R3916_READ_MODE), true, false );
st25r3916comTxByte(((reg & ~ST25R3916_SPACE_B) | ST25R3916_READ_MODE), true, false);
st25r3916comRepeatStart();
st25r3916comRx( values, length );
st25r3916comRx(values, length);
st25r3916comStop();
}
return ERR_NONE;
}
/*******************************************************************************/
ReturnCode st25r3916WriteRegister( uint8_t reg, uint8_t val )
{
uint8_t value = val; /* MISRA 17.8: use intermediate variable */
return st25r3916WriteMultipleRegisters( reg, &value, ST25R3916_REG_LEN );
ReturnCode st25r3916WriteRegister(uint8_t reg, uint8_t val) {
uint8_t value = val; /* MISRA 17.8: use intermediate variable */
return st25r3916WriteMultipleRegisters(reg, &value, ST25R3916_REG_LEN);
}
/*******************************************************************************/
ReturnCode st25r3916WriteMultipleRegisters( uint8_t reg, const uint8_t* values, uint8_t length )
{
if( length > 0U )
{
ReturnCode st25r3916WriteMultipleRegisters(uint8_t reg, const uint8_t* values, uint8_t length) {
if(length > 0U) {
st25r3916comStart();
if( (reg & ST25R3916_SPACE_B) != 0U )
{
st25r3916comTxByte( ST25R3916_CMD_SPACE_B_ACCESS, false, true );
if((reg & ST25R3916_SPACE_B) != 0U) {
st25r3916comTxByte(ST25R3916_CMD_SPACE_B_ACCESS, false, true);
}
st25r3916comTxByte( ((reg & ~ST25R3916_SPACE_B) | ST25R3916_WRITE_MODE), false, true );
st25r3916comTx( values, length, true, true );
st25r3916comTxByte(((reg & ~ST25R3916_SPACE_B) | ST25R3916_WRITE_MODE), false, true);
st25r3916comTx(values, length, true, true);
st25r3916comStop();
/* Send a WriteMultiReg event to LED handling */
st25r3916ledEvtWrMultiReg( reg, values, length);
st25r3916ledEvtWrMultiReg(reg, values, length);
}
return ERR_NONE;
}
/*******************************************************************************/
ReturnCode st25r3916WriteFifo( const uint8_t* values, uint16_t length )
{
if( length > ST25R3916_FIFO_DEPTH )
{
ReturnCode st25r3916WriteFifo(const uint8_t* values, uint16_t length) {
if(length > ST25R3916_FIFO_DEPTH) {
return ERR_PARAM;
}
if( length > 0U )
{
if(length > 0U) {
st25r3916comStart();
st25r3916comTxByte( ST25R3916_FIFO_LOAD, false, true );
st25r3916comTx( values, length, true, true );
st25r3916comTxByte(ST25R3916_FIFO_LOAD, false, true);
st25r3916comTx(values, length, true, true);
st25r3916comStop();
}
return ERR_NONE;
}
/*******************************************************************************/
ReturnCode st25r3916ReadFifo( uint8_t* buf, uint16_t length )
{
if( length > 0U )
{
ReturnCode st25r3916ReadFifo(uint8_t* buf, uint16_t length) {
if(length > 0U) {
st25r3916comStart();
st25r3916comTxByte( ST25R3916_FIFO_READ, true, false );
st25r3916comTxByte(ST25R3916_FIFO_READ, true, false);
st25r3916comRepeatStart();
st25r3916comRx( buf, length );
st25r3916comRx(buf, length);
st25r3916comStop();
}
return ERR_NONE;
}
/*******************************************************************************/
ReturnCode st25r3916WritePTMem( const uint8_t* values, uint16_t length )
{
if( length > ST25R3916_PTM_LEN )
{
ReturnCode st25r3916WritePTMem(const uint8_t* values, uint16_t length) {
if(length > ST25R3916_PTM_LEN) {
return ERR_PARAM;
}
if( length > 0U )
{
if(length > 0U) {
st25r3916comStart();
st25r3916comTxByte( ST25R3916_PT_A_CONFIG_LOAD, false, true );
st25r3916comTx( values, length, true, true );
st25r3916comTxByte(ST25R3916_PT_A_CONFIG_LOAD, false, true);
st25r3916comTx(values, length, true, true);
st25r3916comStop();
}
return ERR_NONE;
}
/*******************************************************************************/
ReturnCode st25r3916ReadPTMem( uint8_t* values, uint16_t length )
{
uint8_t tmp[ST25R3916_REG_LEN + ST25R3916_PTM_LEN]; /* local buffer to handle prepended byte on I2C and SPI */
if( length > 0U )
{
if( length > ST25R3916_PTM_LEN )
{
ReturnCode st25r3916ReadPTMem(uint8_t* values, uint16_t length) {
uint8_t
tmp[ST25R3916_REG_LEN +
ST25R3916_PTM_LEN]; /* local buffer to handle prepended byte on I2C and SPI */
if(length > 0U) {
if(length > ST25R3916_PTM_LEN) {
return ERR_PARAM;
}
st25r3916comStart();
st25r3916comTxByte( ST25R3916_PT_MEM_READ, true, false );
st25r3916comTxByte(ST25R3916_PT_MEM_READ, true, false);
st25r3916comRepeatStart();
st25r3916comRx( tmp, (ST25R3916_REG_LEN + length) ); /* skip prepended byte */
st25r3916comRx(tmp, (ST25R3916_REG_LEN + length)); /* skip prepended byte */
st25r3916comStop();
/* Copy PTMem content without prepended byte */
ST_MEMCPY( values, (tmp+ST25R3916_REG_LEN), length );
ST_MEMCPY(values, (tmp + ST25R3916_REG_LEN), length);
}
return ERR_NONE;
}
/*******************************************************************************/
ReturnCode st25r3916WritePTMemF( const uint8_t* values, uint16_t length )
{
if( length > (ST25R3916_PTM_F_LEN + ST25R3916_PTM_TSN_LEN) )
{
ReturnCode st25r3916WritePTMemF(const uint8_t* values, uint16_t length) {
if(length > (ST25R3916_PTM_F_LEN + ST25R3916_PTM_TSN_LEN)) {
return ERR_PARAM;
}
if( length > 0U )
{
if(length > 0U) {
st25r3916comStart();
st25r3916comTxByte( ST25R3916_PT_F_CONFIG_LOAD, false, true );
st25r3916comTx( values, length, true, true );
st25r3916comTxByte(ST25R3916_PT_F_CONFIG_LOAD, false, true);
st25r3916comTx(values, length, true, true);
st25r3916comStop();
}
return ERR_NONE;
}
/*******************************************************************************/
ReturnCode st25r3916WritePTMemTSN( const uint8_t* values, uint16_t length )
{
if( length > ST25R3916_PTM_TSN_LEN )
{
ReturnCode st25r3916WritePTMemTSN(const uint8_t* values, uint16_t length) {
if(length > ST25R3916_PTM_TSN_LEN) {
return ERR_PARAM;
}
if(length > 0U)
{
if(length > 0U) {
st25r3916comStart();
st25r3916comTxByte( ST25R3916_PT_TSN_DATA_LOAD, false, true );
st25r3916comTx( values, length, true, true );
st25r3916comTxByte(ST25R3916_PT_TSN_DATA_LOAD, false, true);
st25r3916comTx(values, length, true, true);
st25r3916comStop();
}
return ERR_NONE;
}
/*******************************************************************************/
ReturnCode st25r3916ExecuteCommand( uint8_t cmd )
{
ReturnCode st25r3916ExecuteCommand(uint8_t cmd) {
st25r3916comStart();
st25r3916comTxByte( (cmd | ST25R3916_CMD_MODE ), true, true );
st25r3916comTxByte((cmd | ST25R3916_CMD_MODE), true, true);
st25r3916comStop();
/* Send a cmd event to LED handling */
st25r3916ledEvtCmd(cmd);
return ERR_NONE;
}
/*******************************************************************************/
ReturnCode st25r3916ReadTestRegister( uint8_t reg, uint8_t* val )
{
ReturnCode st25r3916ReadTestRegister(uint8_t reg, uint8_t* val) {
st25r3916comStart();
st25r3916comTxByte( ST25R3916_CMD_TEST_ACCESS, false, false );
st25r3916comTxByte( (reg | ST25R3916_READ_MODE), true, false );
st25r3916comTxByte(ST25R3916_CMD_TEST_ACCESS, false, false);
st25r3916comTxByte((reg | ST25R3916_READ_MODE), true, false);
st25r3916comRepeatStart();
st25r3916comRx( val, ST25R3916_REG_LEN );
st25r3916comRx(val, ST25R3916_REG_LEN);
st25r3916comStop();
return ERR_NONE;
}
/*******************************************************************************/
ReturnCode st25r3916WriteTestRegister( uint8_t reg, uint8_t val )
{
uint8_t value = val; /* MISRA 17.8: use intermediate variable */
ReturnCode st25r3916WriteTestRegister(uint8_t reg, uint8_t val) {
uint8_t value = val; /* MISRA 17.8: use intermediate variable */
st25r3916comStart();
st25r3916comTxByte( ST25R3916_CMD_TEST_ACCESS, false, true );
st25r3916comTxByte( (reg | ST25R3916_WRITE_MODE), false, true );
st25r3916comTx( &value, ST25R3916_REG_LEN, true, true );
st25r3916comTxByte(ST25R3916_CMD_TEST_ACCESS, false, true);
st25r3916comTxByte((reg | ST25R3916_WRITE_MODE), false, true);
st25r3916comTx(&value, ST25R3916_REG_LEN, true, true);
st25r3916comStop();
return ERR_NONE;
}
/*******************************************************************************/
ReturnCode st25r3916ClrRegisterBits( uint8_t reg, uint8_t clr_mask )
{
ReturnCode st25r3916ClrRegisterBits(uint8_t reg, uint8_t clr_mask) {
ReturnCode ret;
uint8_t rdVal;
uint8_t rdVal;
/* Read current reg value */
EXIT_ON_ERR( ret, st25r3916ReadRegister(reg, &rdVal) );
EXIT_ON_ERR(ret, st25r3916ReadRegister(reg, &rdVal));
/* Only perform a Write if value to be written is different */
if( ST25R3916_OPTIMIZE && (rdVal == (uint8_t)(rdVal & ~clr_mask)) )
{
if(ST25R3916_OPTIMIZE && (rdVal == (uint8_t)(rdVal & ~clr_mask))) {
return ERR_NONE;
}
/* Write new reg value */
return st25r3916WriteRegister(reg, (uint8_t)(rdVal & ~clr_mask) );
return st25r3916WriteRegister(reg, (uint8_t)(rdVal & ~clr_mask));
}
/*******************************************************************************/
ReturnCode st25r3916SetRegisterBits( uint8_t reg, uint8_t set_mask )
{
ReturnCode st25r3916SetRegisterBits(uint8_t reg, uint8_t set_mask) {
ReturnCode ret;
uint8_t rdVal;
uint8_t rdVal;
/* Read current reg value */
EXIT_ON_ERR( ret, st25r3916ReadRegister(reg, &rdVal) );
EXIT_ON_ERR(ret, st25r3916ReadRegister(reg, &rdVal));
/* Only perform a Write if the value to be written is different */
if( ST25R3916_OPTIMIZE && (rdVal == (rdVal | set_mask)) )
{
if(ST25R3916_OPTIMIZE && (rdVal == (rdVal | set_mask))) {
return ERR_NONE;
}
/* Write new reg value */
return st25r3916WriteRegister(reg, (rdVal | set_mask) );
return st25r3916WriteRegister(reg, (rdVal | set_mask));
}
/*******************************************************************************/
ReturnCode st25r3916ChangeRegisterBits( uint8_t reg, uint8_t valueMask, uint8_t value )
{
return st25r3916ModifyRegister(reg, valueMask, (valueMask & value) );
ReturnCode st25r3916ChangeRegisterBits(uint8_t reg, uint8_t valueMask, uint8_t value) {
return st25r3916ModifyRegister(reg, valueMask, (valueMask & value));
}
/*******************************************************************************/
ReturnCode st25r3916ModifyRegister( uint8_t reg, uint8_t clr_mask, uint8_t set_mask )
{
ReturnCode st25r3916ModifyRegister(uint8_t reg, uint8_t clr_mask, uint8_t set_mask) {
ReturnCode ret;
uint8_t rdVal;
uint8_t wrVal;
uint8_t rdVal;
uint8_t wrVal;
/* Read current reg value */
EXIT_ON_ERR( ret, st25r3916ReadRegister(reg, &rdVal) );
EXIT_ON_ERR(ret, st25r3916ReadRegister(reg, &rdVal));
/* Compute new value */
wrVal = (uint8_t)(rdVal & ~clr_mask);
wrVal = (uint8_t)(rdVal & ~clr_mask);
wrVal |= set_mask;
/* Only perform a Write if the value to be written is different */
if( ST25R3916_OPTIMIZE && (rdVal == wrVal) )
{
if(ST25R3916_OPTIMIZE && (rdVal == wrVal)) {
return ERR_NONE;
}
/* Write new reg value */
return st25r3916WriteRegister(reg, wrVal );
return st25r3916WriteRegister(reg, wrVal);
}
/*******************************************************************************/
ReturnCode st25r3916ChangeTestRegisterBits( uint8_t reg, uint8_t valueMask, uint8_t value )
{
ReturnCode st25r3916ChangeTestRegisterBits(uint8_t reg, uint8_t valueMask, uint8_t value) {
ReturnCode ret;
uint8_t rdVal;
uint8_t wrVal;
uint8_t rdVal;
uint8_t wrVal;
/* Read current reg value */
EXIT_ON_ERR( ret, st25r3916ReadTestRegister(reg, &rdVal) );
EXIT_ON_ERR(ret, st25r3916ReadTestRegister(reg, &rdVal));
/* Compute new value */
wrVal = (uint8_t)(rdVal & ~valueMask);
wrVal = (uint8_t)(rdVal & ~valueMask);
wrVal |= (uint8_t)(value & valueMask);
/* Only perform a Write if the value to be written is different */
if( ST25R3916_OPTIMIZE && (rdVal == wrVal) )
{
if(ST25R3916_OPTIMIZE && (rdVal == wrVal)) {
return ERR_NONE;
}
/* Write new reg value */
return st25r3916WriteTestRegister(reg, wrVal );
return st25r3916WriteTestRegister(reg, wrVal);
}
/*******************************************************************************/
bool st25r3916CheckReg( uint8_t reg, uint8_t mask, uint8_t val )
{
bool st25r3916CheckReg(uint8_t reg, uint8_t mask, uint8_t val) {
uint8_t regVal;
regVal = 0;
st25r3916ReadRegister( reg, &regVal );
return ( (regVal & mask) == val );
st25r3916ReadRegister(reg, &regVal);
return ((regVal & mask) == val);
}
/*******************************************************************************/
bool st25r3916IsRegValid( uint8_t reg )
{
if( !(( (int16_t)reg >= (int16_t)ST25R3916_REG_IO_CONF1) && (reg <= (ST25R3916_SPACE_B | ST25R3916_REG_IC_IDENTITY)) ))
{
bool st25r3916IsRegValid(uint8_t reg) {
if(!(((int16_t)reg >= (int16_t)ST25R3916_REG_IO_CONF1) &&
(reg <= (ST25R3916_SPACE_B | ST25R3916_REG_IC_IDENTITY)))) {
return false;
}
}
return true;
}
+915 -861
View File
File diff suppressed because it is too large Load Diff
+68 -99
View File
@@ -20,7 +20,6 @@
*
******************************************************************************/
/*
* PROJECT: ST25R3916 firmware
* Revision:
@@ -54,15 +53,13 @@
*/
/*! Holds current and previous interrupt callback pointer as well as current Interrupt status and mask */
typedef struct
{
void (*prevCallback)(void); /*!< call back function for ST25R3916 interrupt */
void (*callback)(void); /*!< call back function for ST25R3916 interrupt */
uint32_t status; /*!< latest interrupt status */
uint32_t mask; /*!< Interrupt mask. Negative mask = ST25R3916 mask regs */
typedef struct {
void (*prevCallback)(void); /*!< call back function for ST25R3916 interrupt */
void (*callback)(void); /*!< call back function for ST25R3916 interrupt */
uint32_t status; /*!< latest interrupt status */
uint32_t mask; /*!< Interrupt mask. Negative mask = ST25R3916 mask regs */
} st25r3916Interrupt;
/*
******************************************************************************
* GLOBAL DEFINES
@@ -70,7 +67,7 @@ typedef struct
*/
/*! Length of the interrupt registers */
#define ST25R3916_INT_REGS_LEN ( (ST25R3916_REG_IRQ_TARGET - ST25R3916_REG_IRQ_MAIN) + 1U )
#define ST25R3916_INT_REGS_LEN ((ST25R3916_REG_IRQ_TARGET - ST25R3916_REG_IRQ_MAIN) + 1U)
/*
******************************************************************************
@@ -78,131 +75,113 @@ typedef struct
******************************************************************************
*/
static volatile st25r3916Interrupt st25r3916interrupt; /*!< Instance of ST25R3916 interrupt */
static volatile st25r3916Interrupt st25r3916interrupt; /*!< Instance of ST25R3916 interrupt */
/*
******************************************************************************
* GLOBAL FUNCTIONS
******************************************************************************
*/
void st25r3916InitInterrupts( void )
{
void st25r3916InitInterrupts(void) {
platformIrqST25RPinInitialize();
platformIrqST25RSetCallback( st25r3916Isr );
st25r3916interrupt.callback = NULL;
platformIrqST25RSetCallback(st25r3916Isr);
st25r3916interrupt.callback = NULL;
st25r3916interrupt.prevCallback = NULL;
st25r3916interrupt.status = ST25R3916_IRQ_MASK_NONE;
st25r3916interrupt.mask = ST25R3916_IRQ_MASK_NONE;
st25r3916interrupt.status = ST25R3916_IRQ_MASK_NONE;
st25r3916interrupt.mask = ST25R3916_IRQ_MASK_NONE;
}
/*******************************************************************************/
void st25r3916Isr( void )
{
void st25r3916Isr(void) {
st25r3916CheckForReceivedInterrupts();
// Check if callback is set and run it
if( NULL != st25r3916interrupt.callback )
{
if(NULL != st25r3916interrupt.callback) {
st25r3916interrupt.callback();
}
}
/*******************************************************************************/
void st25r3916CheckForReceivedInterrupts( void )
{
uint8_t iregs[ST25R3916_INT_REGS_LEN];
void st25r3916CheckForReceivedInterrupts(void) {
uint8_t iregs[ST25R3916_INT_REGS_LEN];
uint32_t irqStatus;
/* Initialize iregs */
irqStatus = ST25R3916_IRQ_MASK_NONE;
ST_MEMSET( iregs, (int32_t)(ST25R3916_IRQ_MASK_ALL & 0xFFU), ST25R3916_INT_REGS_LEN );
ST_MEMSET(iregs, (int32_t)(ST25R3916_IRQ_MASK_ALL & 0xFFU), ST25R3916_INT_REGS_LEN);
/* In case the IRQ is Edge (not Level) triggered read IRQs until done */
while( platformGpioIsHigh( ST25R_INT_PORT, ST25R_INT_PIN ) )
{
st25r3916ReadMultipleRegisters( ST25R3916_REG_IRQ_MAIN, iregs, ST25R3916_INT_REGS_LEN );
irqStatus |= (uint32_t)iregs[0];
irqStatus |= (uint32_t)iregs[1]<<8;
irqStatus |= (uint32_t)iregs[2]<<16;
irqStatus |= (uint32_t)iregs[3]<<24;
}
/* Forward all interrupts, even masked ones to application */
platformProtectST25RIrqStatus();
st25r3916interrupt.status |= irqStatus;
platformUnprotectST25RIrqStatus();
/* Send an IRQ event to LED handling */
st25r3916ledEvtIrq( st25r3916interrupt.status );
while(platformGpioIsHigh(ST25R_INT_PORT, ST25R_INT_PIN)) {
st25r3916ReadMultipleRegisters(ST25R3916_REG_IRQ_MAIN, iregs, ST25R3916_INT_REGS_LEN);
irqStatus |= (uint32_t)iregs[0];
irqStatus |= (uint32_t)iregs[1] << 8;
irqStatus |= (uint32_t)iregs[2] << 16;
irqStatus |= (uint32_t)iregs[3] << 24;
}
/* Forward all interrupts, even masked ones to application */
platformProtectST25RIrqStatus();
st25r3916interrupt.status |= irqStatus;
platformUnprotectST25RIrqStatus();
/* Send an IRQ event to LED handling */
st25r3916ledEvtIrq(st25r3916interrupt.status);
}
/*******************************************************************************/
void st25r3916ModifyInterrupts(uint32_t clr_mask, uint32_t set_mask)
{
uint8_t i;
void st25r3916ModifyInterrupts(uint32_t clr_mask, uint32_t set_mask) {
uint8_t i;
uint32_t old_mask;
uint32_t new_mask;
old_mask = st25r3916interrupt.mask;
new_mask = ((~old_mask & set_mask) | (old_mask & clr_mask));
st25r3916interrupt.mask &= ~clr_mask;
st25r3916interrupt.mask |= set_mask;
for(i=0; i<ST25R3916_INT_REGS_LEN; i++)
{
if( ((new_mask >> (8U*i)) & 0xFFU) == 0U )
{
for(i = 0; i < ST25R3916_INT_REGS_LEN; i++) {
if(((new_mask >> (8U * i)) & 0xFFU) == 0U) {
continue;
}
st25r3916WriteRegister(ST25R3916_REG_IRQ_MASK_MAIN + i, (uint8_t)((st25r3916interrupt.mask>>(8U*i)) & 0xFFU) );
st25r3916WriteRegister(
ST25R3916_REG_IRQ_MASK_MAIN + i,
(uint8_t)((st25r3916interrupt.mask >> (8U * i)) & 0xFFU));
}
return;
}
/*******************************************************************************/
uint32_t st25r3916WaitForInterruptsTimed( uint32_t mask, uint16_t tmo )
{
uint32_t st25r3916WaitForInterruptsTimed(uint32_t mask, uint16_t tmo) {
uint32_t tmrDelay;
uint32_t status;
tmrDelay = platformTimerCreate( tmo );
tmrDelay = platformTimerCreate(tmo);
/* Run until specific interrupt has happen or the timer has expired */
do
{
do {
status = (st25r3916interrupt.status & mask);
} while( ( !platformTimerIsExpired( tmrDelay ) || (tmo == 0U)) && (status == 0U) );
platformTimerDestroy( tmrDelay );
} while((!platformTimerIsExpired(tmrDelay) || (tmo == 0U)) && (status == 0U));
platformTimerDestroy(tmrDelay);
status = st25r3916interrupt.status & mask;
platformProtectST25RIrqStatus();
st25r3916interrupt.status &= ~status;
platformUnprotectST25RIrqStatus();
return status;
}
/*******************************************************************************/
uint32_t st25r3916GetInterrupt( uint32_t mask )
{
uint32_t st25r3916GetInterrupt(uint32_t mask) {
uint32_t irqs;
irqs = (st25r3916interrupt.status & mask);
if(irqs != ST25R3916_IRQ_MASK_NONE)
{
if(irqs != ST25R3916_IRQ_MASK_NONE) {
platformProtectST25RIrqStatus();
st25r3916interrupt.status &= ~irqs;
platformUnprotectST25RIrqStatus();
@@ -211,31 +190,24 @@ uint32_t st25r3916GetInterrupt( uint32_t mask )
return irqs;
}
/*******************************************************************************/
void st25r3916ClearAndEnableInterrupts( uint32_t mask )
{
st25r3916GetInterrupt( mask );
st25r3916EnableInterrupts( mask );
void st25r3916ClearAndEnableInterrupts(uint32_t mask) {
st25r3916GetInterrupt(mask);
st25r3916EnableInterrupts(mask);
}
/*******************************************************************************/
void st25r3916EnableInterrupts(uint32_t mask)
{
void st25r3916EnableInterrupts(uint32_t mask) {
st25r3916ModifyInterrupts(mask, 0);
}
/*******************************************************************************/
void st25r3916DisableInterrupts(uint32_t mask)
{
void st25r3916DisableInterrupts(uint32_t mask) {
st25r3916ModifyInterrupts(0, mask);
}
/*******************************************************************************/
void st25r3916ClearInterrupts( void )
{
void st25r3916ClearInterrupts(void) {
uint8_t iregs[ST25R3916_INT_REGS_LEN];
st25r3916ReadMultipleRegisters(ST25R3916_REG_IRQ_MAIN, iregs, ST25R3916_INT_REGS_LEN);
@@ -247,16 +219,13 @@ void st25r3916ClearInterrupts( void )
}
/*******************************************************************************/
void st25r3916IRQCallbackSet( void (*cb)(void) )
{
void st25r3916IRQCallbackSet(void (*cb)(void)) {
st25r3916interrupt.prevCallback = st25r3916interrupt.callback;
st25r3916interrupt.callback = cb;
st25r3916interrupt.callback = cb;
}
/*******************************************************************************/
void st25r3916IRQCallbackRestore( void )
{
st25r3916interrupt.callback = st25r3916interrupt.prevCallback;
void st25r3916IRQCallbackRestore(void) {
st25r3916interrupt.callback = st25r3916interrupt.prevCallback;
st25r3916interrupt.prevCallback = NULL;
}
+80 -48
View File
@@ -20,7 +20,6 @@
*
******************************************************************************/
/*
* PROJECT: ST25R3916 firmware
* Revision:
@@ -67,48 +66,82 @@
******************************************************************************
*/
#define ST25R3916_IRQ_MASK_ALL (uint32_t)(0xFFFFFFFFUL) /*!< All ST25R3916 interrupt sources */
#define ST25R3916_IRQ_MASK_NONE (uint32_t)(0x00000000UL) /*!< No ST25R3916 interrupt source */
#define ST25R3916_IRQ_MASK_ALL \
(uint32_t)(0xFFFFFFFFUL) /*!< All ST25R3916 interrupt sources */
#define ST25R3916_IRQ_MASK_NONE \
(uint32_t)(0x00000000UL) /*!< No ST25R3916 interrupt source */
/* Main interrupt register */
#define ST25R3916_IRQ_MASK_OSC (uint32_t)(0x00000080U) /*!< ST25R3916 oscillator stable interrupt */
#define ST25R3916_IRQ_MASK_FWL (uint32_t)(0x00000040U) /*!< ST25R3916 FIFO water level interrupt */
#define ST25R3916_IRQ_MASK_RXS (uint32_t)(0x00000020U) /*!< ST25R3916 start of receive interrupt */
#define ST25R3916_IRQ_MASK_RXE (uint32_t)(0x00000010U) /*!< ST25R3916 end of receive interrupt */
#define ST25R3916_IRQ_MASK_TXE (uint32_t)(0x00000008U) /*!< ST25R3916 end of transmission interrupt */
#define ST25R3916_IRQ_MASK_COL (uint32_t)(0x00000004U) /*!< ST25R3916 bit collision interrupt */
#define ST25R3916_IRQ_MASK_RX_REST (uint32_t)(0x00000002U) /*!< ST25R3916 automatic reception restart interrupt */
#define ST25R3916_IRQ_MASK_RFU (uint32_t)(0x00000001U) /*!< ST25R3916 RFU interrupt */
#define ST25R3916_IRQ_MASK_OSC \
(uint32_t)(0x00000080U) /*!< ST25R3916 oscillator stable interrupt */
#define ST25R3916_IRQ_MASK_FWL \
(uint32_t)(0x00000040U) /*!< ST25R3916 FIFO water level interrupt */
#define ST25R3916_IRQ_MASK_RXS \
(uint32_t)(0x00000020U) /*!< ST25R3916 start of receive interrupt */
#define ST25R3916_IRQ_MASK_RXE \
(uint32_t)(0x00000010U) /*!< ST25R3916 end of receive interrupt */
#define ST25R3916_IRQ_MASK_TXE \
(uint32_t)(0x00000008U) /*!< ST25R3916 end of transmission interrupt */
#define ST25R3916_IRQ_MASK_COL \
(uint32_t)(0x00000004U) /*!< ST25R3916 bit collision interrupt */
#define ST25R3916_IRQ_MASK_RX_REST \
(uint32_t)(0x00000002U) /*!< ST25R3916 automatic reception restart interrupt */
#define ST25R3916_IRQ_MASK_RFU \
(uint32_t)(0x00000001U) /*!< ST25R3916 RFU interrupt */
/* Timer and NFC interrupt register */
#define ST25R3916_IRQ_MASK_DCT (uint32_t)(0x00008000U) /*!< ST25R3916 termination of direct command interrupt. */
#define ST25R3916_IRQ_MASK_NRE (uint32_t)(0x00004000U) /*!< ST25R3916 no-response timer expired interrupt */
#define ST25R3916_IRQ_MASK_GPE (uint32_t)(0x00002000U) /*!< ST25R3916 general purpose timer expired interrupt */
#define ST25R3916_IRQ_MASK_EON (uint32_t)(0x00001000U) /*!< ST25R3916 external field on interrupt */
#define ST25R3916_IRQ_MASK_EOF (uint32_t)(0x00000800U) /*!< ST25R3916 external field off interrupt */
#define ST25R3916_IRQ_MASK_CAC (uint32_t)(0x00000400U) /*!< ST25R3916 collision during RF collision avoidance interrupt */
#define ST25R3916_IRQ_MASK_CAT (uint32_t)(0x00000200U) /*!< ST25R3916 minimum guard time expired interrupt */
#define ST25R3916_IRQ_MASK_NFCT (uint32_t)(0x00000100U) /*!< ST25R3916 initiator bit rate recognised interrupt */
#define ST25R3916_IRQ_MASK_DCT \
(uint32_t)(0x00008000U) /*!< ST25R3916 termination of direct command interrupt. */
#define ST25R3916_IRQ_MASK_NRE \
(uint32_t)(0x00004000U) /*!< ST25R3916 no-response timer expired interrupt */
#define ST25R3916_IRQ_MASK_GPE \
(uint32_t)(0x00002000U) /*!< ST25R3916 general purpose timer expired interrupt */
#define ST25R3916_IRQ_MASK_EON \
(uint32_t)(0x00001000U) /*!< ST25R3916 external field on interrupt */
#define ST25R3916_IRQ_MASK_EOF \
(uint32_t)(0x00000800U) /*!< ST25R3916 external field off interrupt */
#define ST25R3916_IRQ_MASK_CAC \
(uint32_t)(0x00000400U) /*!< ST25R3916 collision during RF collision avoidance interrupt */
#define ST25R3916_IRQ_MASK_CAT \
(uint32_t)(0x00000200U) /*!< ST25R3916 minimum guard time expired interrupt */
#define ST25R3916_IRQ_MASK_NFCT \
(uint32_t)(0x00000100U) /*!< ST25R3916 initiator bit rate recognised interrupt */
/* Error and wake-up interrupt register */
#define ST25R3916_IRQ_MASK_CRC (uint32_t)(0x00800000U) /*!< ST25R3916 CRC error interrupt */
#define ST25R3916_IRQ_MASK_PAR (uint32_t)(0x00400000U) /*!< ST25R3916 parity error interrupt */
#define ST25R3916_IRQ_MASK_ERR2 (uint32_t)(0x00200000U) /*!< ST25R3916 soft framing error interrupt */
#define ST25R3916_IRQ_MASK_ERR1 (uint32_t)(0x00100000U) /*!< ST25R3916 hard framing error interrupt */
#define ST25R3916_IRQ_MASK_WT (uint32_t)(0x00080000U) /*!< ST25R3916 wake-up interrupt */
#define ST25R3916_IRQ_MASK_WAM (uint32_t)(0x00040000U) /*!< ST25R3916 wake-up due to amplitude interrupt */
#define ST25R3916_IRQ_MASK_WPH (uint32_t)(0x00020000U) /*!< ST25R3916 wake-up due to phase interrupt */
#define ST25R3916_IRQ_MASK_WCAP (uint32_t)(0x00010000U) /*!< ST25R3916 wake-up due to capacitance measurement */
#define ST25R3916_IRQ_MASK_CRC \
(uint32_t)(0x00800000U) /*!< ST25R3916 CRC error interrupt */
#define ST25R3916_IRQ_MASK_PAR \
(uint32_t)(0x00400000U) /*!< ST25R3916 parity error interrupt */
#define ST25R3916_IRQ_MASK_ERR2 \
(uint32_t)(0x00200000U) /*!< ST25R3916 soft framing error interrupt */
#define ST25R3916_IRQ_MASK_ERR1 \
(uint32_t)(0x00100000U) /*!< ST25R3916 hard framing error interrupt */
#define ST25R3916_IRQ_MASK_WT \
(uint32_t)(0x00080000U) /*!< ST25R3916 wake-up interrupt */
#define ST25R3916_IRQ_MASK_WAM \
(uint32_t)(0x00040000U) /*!< ST25R3916 wake-up due to amplitude interrupt */
#define ST25R3916_IRQ_MASK_WPH \
(uint32_t)(0x00020000U) /*!< ST25R3916 wake-up due to phase interrupt */
#define ST25R3916_IRQ_MASK_WCAP \
(uint32_t)(0x00010000U) /*!< ST25R3916 wake-up due to capacitance measurement */
/* Passive Target Interrupt Register */
#define ST25R3916_IRQ_MASK_PPON2 (uint32_t)(0x80000000U) /*!< ST25R3916 PPON2 Field on waiting Timer interrupt */
#define ST25R3916_IRQ_MASK_SL_WL (uint32_t)(0x40000000U) /*!< ST25R3916 Passive target slot number water level interrupt */
#define ST25R3916_IRQ_MASK_APON (uint32_t)(0x20000000U) /*!< ST25R3916 Anticollision done and Field On interrupt */
#define ST25R3916_IRQ_MASK_RXE_PTA (uint32_t)(0x10000000U) /*!< ST25R3916 RXE with an automatic response interrupt */
#define ST25R3916_IRQ_MASK_WU_F (uint32_t)(0x08000000U) /*!< ST25R3916 212/424b/s Passive target interrupt: Active */
#define ST25R3916_IRQ_MASK_RFU2 (uint32_t)(0x04000000U) /*!< ST25R3916 RFU2 interrupt */
#define ST25R3916_IRQ_MASK_WU_A_X (uint32_t)(0x02000000U) /*!< ST25R3916 106kb/s Passive target state interrupt: Active* */
#define ST25R3916_IRQ_MASK_WU_A (uint32_t)(0x01000000U) /*!< ST25R3916 106kb/s Passive target state interrupt: Active */
#define ST25R3916_IRQ_MASK_PPON2 \
(uint32_t)(0x80000000U) /*!< ST25R3916 PPON2 Field on waiting Timer interrupt */
#define ST25R3916_IRQ_MASK_SL_WL \
(uint32_t)(0x40000000U) /*!< ST25R3916 Passive target slot number water level interrupt */
#define ST25R3916_IRQ_MASK_APON \
(uint32_t)(0x20000000U) /*!< ST25R3916 Anticollision done and Field On interrupt */
#define ST25R3916_IRQ_MASK_RXE_PTA \
(uint32_t)(0x10000000U) /*!< ST25R3916 RXE with an automatic response interrupt */
#define ST25R3916_IRQ_MASK_WU_F \
(uint32_t)(0x08000000U) /*!< ST25R3916 212/424b/s Passive target interrupt: Active */
#define ST25R3916_IRQ_MASK_RFU2 \
(uint32_t)(0x04000000U) /*!< ST25R3916 RFU2 interrupt */
#define ST25R3916_IRQ_MASK_WU_A_X \
(uint32_t)(0x02000000U) /*!< ST25R3916 106kb/s Passive target state interrupt: Active* */
#define ST25R3916_IRQ_MASK_WU_A \
(uint32_t)(0x01000000U) /*!< ST25R3916 106kb/s Passive target state interrupt: Active */
/*
******************************************************************************
@@ -116,7 +149,6 @@
******************************************************************************
*/
/*!
*****************************************************************************
* \brief Wait until an ST25R3916 interrupt occurs
@@ -134,7 +166,7 @@
*
*****************************************************************************
*/
uint32_t st25r3916WaitForInterruptsTimed( uint32_t mask, uint16_t tmo );
uint32_t st25r3916WaitForInterruptsTimed(uint32_t mask, uint16_t tmo);
/*!
*****************************************************************************
@@ -150,7 +182,7 @@ uint32_t st25r3916WaitForInterruptsTimed( uint32_t mask, uint16_t tmo );
*
*****************************************************************************
*/
uint32_t st25r3916GetInterrupt( uint32_t mask );
uint32_t st25r3916GetInterrupt(uint32_t mask);
/*!
*****************************************************************************
@@ -161,7 +193,7 @@ uint32_t st25r3916GetInterrupt( uint32_t mask );
*
*****************************************************************************
*/
void st25r3916InitInterrupts( void );
void st25r3916InitInterrupts(void);
/*!
*****************************************************************************
@@ -173,7 +205,7 @@ void st25r3916InitInterrupts( void );
* \param[in] set_mask : bit mask to be set on the interrupt mask
*****************************************************************************
*/
void st25r3916ModifyInterrupts( uint32_t clr_mask, uint32_t set_mask );
void st25r3916ModifyInterrupts(uint32_t clr_mask, uint32_t set_mask);
/*!
*****************************************************************************
@@ -182,7 +214,7 @@ void st25r3916ModifyInterrupts( uint32_t clr_mask, uint32_t set_mask );
* Checks received interrupts and saves the result into global params
*****************************************************************************
*/
void st25r3916CheckForReceivedInterrupts( void );
void st25r3916CheckForReceivedInterrupts(void);
/*!
*****************************************************************************
@@ -191,7 +223,7 @@ void st25r3916CheckForReceivedInterrupts( void );
* This function modiefies the interupt
*****************************************************************************
*/
void st25r3916Isr( void );
void st25r3916Isr(void);
/*!
*****************************************************************************
@@ -204,7 +236,7 @@ void st25r3916Isr( void );
*
*****************************************************************************
*/
void st25r3916EnableInterrupts( uint32_t mask );
void st25r3916EnableInterrupts(uint32_t mask);
/*!
*****************************************************************************
@@ -216,7 +248,7 @@ void st25r3916EnableInterrupts( uint32_t mask );
*
*****************************************************************************
*/
void st25r3916DisableInterrupts( uint32_t mask );
void st25r3916DisableInterrupts(uint32_t mask);
/*!
*****************************************************************************
@@ -224,7 +256,7 @@ void st25r3916DisableInterrupts( uint32_t mask );
*
*****************************************************************************
*/
void st25r3916ClearInterrupts( void );
void st25r3916ClearInterrupts(void);
/*!
*****************************************************************************
@@ -233,7 +265,7 @@ void st25r3916ClearInterrupts( void );
* \param[in] mask: mask indicating the interrupts to be cleared and enabled
*****************************************************************************
*/
void st25r3916ClearAndEnableInterrupts( uint32_t mask );
void st25r3916ClearAndEnableInterrupts(uint32_t mask);
/*!
*****************************************************************************
@@ -241,7 +273,7 @@ void st25r3916ClearAndEnableInterrupts( uint32_t mask );
*
*****************************************************************************
*/
void st25r3916IRQCallbackSet( void (*cb)( void ) );
void st25r3916IRQCallbackSet(void (*cb)(void));
/*!
*****************************************************************************
@@ -249,7 +281,7 @@ void st25r3916IRQCallbackSet( void (*cb)( void ) );
*
*****************************************************************************
*/
void st25r3916IRQCallbackRestore( void );
void st25r3916IRQCallbackRestore(void);
#endif /* ST25R3916_IRQ_H */
+45 -54
View File
@@ -20,7 +20,6 @@
*
******************************************************************************/
/*
* PROJECT: ST25R3916 firmware
* Revision:
@@ -46,7 +45,6 @@
#include "st25r3916_com.h"
#include "st25r3916.h"
/*
******************************************************************************
* MACROS
@@ -54,20 +52,31 @@
*/
#ifdef PLATFORM_LED_RX_PIN
#define st25r3916ledRxOn() platformLedOn( PLATFORM_LED_RX_PORT, PLATFORM_LED_RX_PIN ); /*!< LED Rx Pin On from system HAL */
#define st25r3916ledRxOff() platformLedOff( PLATFORM_LED_RX_PORT, PLATFORM_LED_RX_PIN ); /*!< LED Rx Pin Off from system HAL */
#define st25r3916ledRxOn() \
platformLedOn( \
PLATFORM_LED_RX_PORT, \
PLATFORM_LED_RX_PIN); /*!< LED Rx Pin On from system HAL */
#define st25r3916ledRxOff() \
platformLedOff( \
PLATFORM_LED_RX_PORT, \
PLATFORM_LED_RX_PIN); /*!< LED Rx Pin Off from system HAL */
#else /* PLATFORM_LED_RX_PIN */
#define st25r3916ledRxOn()
#define st25r3916ledRxOff()
#define st25r3916ledRxOn()
#define st25r3916ledRxOff()
#endif /* PLATFORM_LED_RX_PIN */
#ifdef PLATFORM_LED_FIELD_PIN
#define st25r3916ledFieldOn() platformLedOn( PLATFORM_LED_FIELD_PORT, PLATFORM_LED_FIELD_PIN ); /*!< LED Field Pin On from system HAL */
#define st25r3916ledFieldOff() platformLedOff( PLATFORM_LED_FIELD_PORT, PLATFORM_LED_FIELD_PIN ); /*!< LED Field Pin Off from system HAL */
#define st25r3916ledFieldOn() \
platformLedOn( \
PLATFORM_LED_FIELD_PORT, \
PLATFORM_LED_FIELD_PIN); /*!< LED Field Pin On from system HAL */
#define st25r3916ledFieldOff() \
platformLedOff( \
PLATFORM_LED_FIELD_PORT, \
PLATFORM_LED_FIELD_PIN); /*!< LED Field Pin Off from system HAL */
#else /* PLATFORM_LED_FIELD_PIN */
#define st25r3916ledFieldOn()
#define st25r3916ledFieldOff()
#define st25r3916ledFieldOn()
#define st25r3916ledFieldOff()
#endif /* PLATFORM_LED_FIELD_PIN */
/*
@@ -76,81 +85,63 @@
******************************************************************************
*/
void st25r3916ledInit( void )
{
void st25r3916ledInit(void) {
/* Initialize LEDs if existing and defined */
platformLedsInitialize();
st25r3916ledRxOff();
st25r3916ledFieldOff();
}
/*******************************************************************************/
void st25r3916ledEvtIrq( uint32_t irqs )
{
if( (irqs & (ST25R3916_IRQ_MASK_TXE | ST25R3916_IRQ_MASK_CAT) ) != 0U )
{
void st25r3916ledEvtIrq(uint32_t irqs) {
if((irqs & (ST25R3916_IRQ_MASK_TXE | ST25R3916_IRQ_MASK_CAT)) != 0U) {
st25r3916ledFieldOn();
}
if( (irqs & (ST25R3916_IRQ_MASK_RXS | ST25R3916_IRQ_MASK_NFCT) ) != 0U )
{
if((irqs & (ST25R3916_IRQ_MASK_RXS | ST25R3916_IRQ_MASK_NFCT)) != 0U) {
st25r3916ledRxOn();
}
if( (irqs & (ST25R3916_IRQ_MASK_RXE | ST25R3916_IRQ_MASK_NRE | ST25R3916_IRQ_MASK_RX_REST | ST25R3916_IRQ_MASK_RXE_PTA |
ST25R3916_IRQ_MASK_WU_A | ST25R3916_IRQ_MASK_WU_A_X | ST25R3916_IRQ_MASK_WU_F | ST25R3916_IRQ_MASK_RFU2) ) != 0U )
{
if((irqs & (ST25R3916_IRQ_MASK_RXE | ST25R3916_IRQ_MASK_NRE | ST25R3916_IRQ_MASK_RX_REST |
ST25R3916_IRQ_MASK_RXE_PTA | ST25R3916_IRQ_MASK_WU_A | ST25R3916_IRQ_MASK_WU_A_X |
ST25R3916_IRQ_MASK_WU_F | ST25R3916_IRQ_MASK_RFU2)) != 0U) {
st25r3916ledRxOff();
}
}
/*******************************************************************************/
void st25r3916ledEvtWrReg( uint8_t reg, uint8_t val )
{
if( reg == ST25R3916_REG_OP_CONTROL )
{
if( (ST25R3916_REG_OP_CONTROL_tx_en & val) != 0U )
{
void st25r3916ledEvtWrReg(uint8_t reg, uint8_t val) {
if(reg == ST25R3916_REG_OP_CONTROL) {
if((ST25R3916_REG_OP_CONTROL_tx_en & val) != 0U) {
st25r3916ledFieldOn();
}
else
{
} else {
st25r3916ledFieldOff();
}
}
}
/*******************************************************************************/
void st25r3916ledEvtWrMultiReg( uint8_t reg, const uint8_t* vals, uint8_t len )
{
void st25r3916ledEvtWrMultiReg(uint8_t reg, const uint8_t* vals, uint8_t len) {
uint8_t i;
for(i=0; i<(len); i++)
{
st25r3916ledEvtWrReg( (reg+i), vals[i] );
for(i = 0; i < (len); i++) {
st25r3916ledEvtWrReg((reg + i), vals[i]);
}
}
/*******************************************************************************/
void st25r3916ledEvtCmd( uint8_t cmd )
{
if( (cmd >= ST25R3916_CMD_TRANSMIT_WITH_CRC) && (cmd <= ST25R3916_CMD_RESPONSE_RF_COLLISION_N) )
{
void st25r3916ledEvtCmd(uint8_t cmd) {
if((cmd >= ST25R3916_CMD_TRANSMIT_WITH_CRC) &&
(cmd <= ST25R3916_CMD_RESPONSE_RF_COLLISION_N)) {
st25r3916ledFieldOff();
}
if( cmd == ST25R3916_CMD_UNMASK_RECEIVE_DATA )
{
if(cmd == ST25R3916_CMD_UNMASK_RECEIVE_DATA) {
st25r3916ledRxOff();
}
if( cmd == ST25R3916_CMD_SET_DEFAULT )
{
if(cmd == ST25R3916_CMD_SET_DEFAULT) {
st25r3916ledFieldOff();
st25r3916ledRxOff();
}
+5 -7
View File
@@ -20,7 +20,6 @@
*
******************************************************************************/
/*
* PROJECT: ST25R3916 firmware
* Revision:
@@ -74,7 +73,6 @@
******************************************************************************
*/
/*!
*****************************************************************************
* \brief ST25R3916 LED Initialize
@@ -83,7 +81,7 @@
*
*****************************************************************************
*/
void st25r3916ledInit( void );
void st25r3916ledInit(void);
/*!
*****************************************************************************
@@ -96,7 +94,7 @@ void st25r3916ledInit( void );
*
*****************************************************************************
*/
void st25r3916ledEvtIrq( uint32_t irqs );
void st25r3916ledEvtIrq(uint32_t irqs);
/*!
*****************************************************************************
@@ -110,7 +108,7 @@ void st25r3916ledEvtIrq( uint32_t irqs );
*
*****************************************************************************
*/
void st25r3916ledEvtWrReg( uint8_t reg, uint8_t val );
void st25r3916ledEvtWrReg(uint8_t reg, uint8_t val);
/*!
*****************************************************************************
@@ -125,7 +123,7 @@ void st25r3916ledEvtWrReg( uint8_t reg, uint8_t val );
*
*****************************************************************************
*/
void st25r3916ledEvtWrMultiReg( uint8_t reg, const uint8_t* vals, uint8_t len );
void st25r3916ledEvtWrMultiReg(uint8_t reg, const uint8_t* vals, uint8_t len);
/*!
*****************************************************************************
@@ -138,7 +136,7 @@ void st25r3916ledEvtWrMultiReg( uint8_t reg, const uint8_t* vals, uint8_t len );
*
*****************************************************************************
*/
void st25r3916ledEvtCmd( uint8_t cmd );
void st25r3916ledEvtCmd(uint8_t cmd);
#endif /* ST25R3916_LED_H */
+75 -82
View File
@@ -20,7 +20,6 @@
*
******************************************************************************/
/*
* PROJECT: STxxxx firmware
* LANGUAGE: ISO C99
@@ -45,14 +44,13 @@
#include <stdint.h>
/*
******************************************************************************
* GLOBAL DATA TYPES
******************************************************************************
*/
typedef uint16_t ReturnCode; /*!< Standard Return Code type from function. */
typedef uint16_t ReturnCode; /*!< Standard Return Code type from function. */
/*
******************************************************************************
@@ -60,89 +58,88 @@ typedef uint16_t ReturnCode; /*!< Standard Return Code type from function.
******************************************************************************
*/
/*
* Error codes to be used within the application.
* They are represented by an uint8_t
*/
enum {
ERR_NONE = 0, /*!< no error occurred */
ERR_NOMEM = 1, /*!< not enough memory to perform the requested operation */
ERR_BUSY = 2, /*!< device or resource busy */
ERR_IO = 3, /*!< generic IO error */
ERR_TIMEOUT = 4, /*!< error due to timeout */
ERR_REQUEST = 5, /*!< invalid request or requested function can't be executed at the moment */
ERR_NOMSG = 6, /*!< No message of desired type */
ERR_PARAM = 7, /*!< Parameter error */
ERR_SYSTEM = 8, /*!< System error */
ERR_FRAMING = 9, /*!< Framing error */
ERR_OVERRUN = 10, /*!< lost one or more received bytes */
ERR_PROTO = 11, /*!< protocol error */
ERR_INTERNAL = 12, /*!< Internal Error */
ERR_AGAIN = 13, /*!< Call again */
ERR_MEM_CORRUPT = 14, /*!< memory corruption */
ERR_NOT_IMPLEMENTED = 15, /*!< not implemented */
ERR_PC_CORRUPT = 16, /*!< Program Counter has been manipulated or spike/noise trigger illegal operation */
ERR_SEND = 17, /*!< error sending*/
ERR_IGNORE = 18, /*!< indicates error detected but to be ignored */
ERR_SEMANTIC = 19, /*!< indicates error in state machine (unexpected cmd) */
ERR_SYNTAX = 20, /*!< indicates error in state machine (unknown cmd) */
ERR_CRC = 21, /*!< crc error */
ERR_NOTFOUND = 22, /*!< transponder not found */
ERR_NOTUNIQUE = 23, /*!< transponder not unique - more than one transponder in field */
ERR_NOTSUPP = 24, /*!< requested operation not supported */
ERR_WRITE = 25, /*!< write error */
ERR_FIFO = 26, /*!< fifo over or underflow error */
ERR_PAR = 27, /*!< parity error */
ERR_DONE = 28, /*!< transfer has already finished */
ERR_RF_COLLISION = 29, /*!< collision error (Bit Collision or during RF Collision avoidance ) */
ERR_HW_OVERRUN = 30, /*!< lost one or more received bytes */
ERR_RELEASE_REQ = 31, /*!< device requested release */
ERR_SLEEP_REQ = 32, /*!< device requested sleep */
ERR_WRONG_STATE = 33, /*!< incorrent state for requested operation */
ERR_MAX_RERUNS = 34, /*!< blocking procedure reached maximum runs */
ERR_DISABLED = 35, /*!< operation aborted due to disabled configuration */
ERR_HW_MISMATCH = 36, /*!< expected hw do not match */
ERR_LINK_LOSS = 37, /*!< Other device's field didn't behave as expected: turned off by Initiator in Passive mode, or AP2P did not turn on field */
ERR_INVALID_HANDLE = 38, /*!< invalid or not initalized device handle */
ERR_NONE = 0, /*!< no error occurred */
ERR_NOMEM = 1, /*!< not enough memory to perform the requested operation */
ERR_BUSY = 2, /*!< device or resource busy */
ERR_IO = 3, /*!< generic IO error */
ERR_TIMEOUT = 4, /*!< error due to timeout */
ERR_REQUEST = 5, /*!< invalid request or requested function can't be executed at the moment */
ERR_NOMSG = 6, /*!< No message of desired type */
ERR_PARAM = 7, /*!< Parameter error */
ERR_SYSTEM = 8, /*!< System error */
ERR_FRAMING = 9, /*!< Framing error */
ERR_OVERRUN = 10, /*!< lost one or more received bytes */
ERR_PROTO = 11, /*!< protocol error */
ERR_INTERNAL = 12, /*!< Internal Error */
ERR_AGAIN = 13, /*!< Call again */
ERR_MEM_CORRUPT = 14, /*!< memory corruption */
ERR_NOT_IMPLEMENTED = 15, /*!< not implemented */
ERR_PC_CORRUPT =
16, /*!< Program Counter has been manipulated or spike/noise trigger illegal operation */
ERR_SEND = 17, /*!< error sending*/
ERR_IGNORE = 18, /*!< indicates error detected but to be ignored */
ERR_SEMANTIC = 19, /*!< indicates error in state machine (unexpected cmd) */
ERR_SYNTAX = 20, /*!< indicates error in state machine (unknown cmd) */
ERR_CRC = 21, /*!< crc error */
ERR_NOTFOUND = 22, /*!< transponder not found */
ERR_NOTUNIQUE = 23, /*!< transponder not unique - more than one transponder in field */
ERR_NOTSUPP = 24, /*!< requested operation not supported */
ERR_WRITE = 25, /*!< write error */
ERR_FIFO = 26, /*!< fifo over or underflow error */
ERR_PAR = 27, /*!< parity error */
ERR_DONE = 28, /*!< transfer has already finished */
ERR_RF_COLLISION =
29, /*!< collision error (Bit Collision or during RF Collision avoidance ) */
ERR_HW_OVERRUN = 30, /*!< lost one or more received bytes */
ERR_RELEASE_REQ = 31, /*!< device requested release */
ERR_SLEEP_REQ = 32, /*!< device requested sleep */
ERR_WRONG_STATE = 33, /*!< incorrent state for requested operation */
ERR_MAX_RERUNS = 34, /*!< blocking procedure reached maximum runs */
ERR_DISABLED = 35, /*!< operation aborted due to disabled configuration */
ERR_HW_MISMATCH = 36, /*!< expected hw do not match */
ERR_LINK_LOSS =
37, /*!< Other device's field didn't behave as expected: turned off by Initiator in Passive mode, or AP2P did not turn on field */
ERR_INVALID_HANDLE = 38, /*!< invalid or not initalized device handle */
ERR_INCOMPLETE_BYTE = 40, /*!< Incomplete byte rcvd */
ERR_INCOMPLETE_BYTE_01 = 41, /*!< Incomplete byte rcvd - 1 bit */
ERR_INCOMPLETE_BYTE_02 = 42, /*!< Incomplete byte rcvd - 2 bit */
ERR_INCOMPLETE_BYTE_03 = 43, /*!< Incomplete byte rcvd - 3 bit */
ERR_INCOMPLETE_BYTE_04 = 44, /*!< Incomplete byte rcvd - 4 bit */
ERR_INCOMPLETE_BYTE_05 = 45, /*!< Incomplete byte rcvd - 5 bit */
ERR_INCOMPLETE_BYTE_06 = 46, /*!< Incomplete byte rcvd - 6 bit */
ERR_INCOMPLETE_BYTE_07 = 47, /*!< Incomplete byte rcvd - 7 bit */
ERR_INCOMPLETE_BYTE = 40, /*!< Incomplete byte rcvd */
ERR_INCOMPLETE_BYTE_01 = 41, /*!< Incomplete byte rcvd - 1 bit */
ERR_INCOMPLETE_BYTE_02 = 42, /*!< Incomplete byte rcvd - 2 bit */
ERR_INCOMPLETE_BYTE_03 = 43, /*!< Incomplete byte rcvd - 3 bit */
ERR_INCOMPLETE_BYTE_04 = 44, /*!< Incomplete byte rcvd - 4 bit */
ERR_INCOMPLETE_BYTE_05 = 45, /*!< Incomplete byte rcvd - 5 bit */
ERR_INCOMPLETE_BYTE_06 = 46, /*!< Incomplete byte rcvd - 6 bit */
ERR_INCOMPLETE_BYTE_07 = 47, /*!< Incomplete byte rcvd - 7 bit */
};
/* General Sub-category number */
#define ERR_GENERIC_GRP (0x0000) /*!< Reserved value for generic error no */
#define ERR_WARN_GRP (0x0100) /*!< Errors which are not expected in normal operation */
#define ERR_PROCESS_GRP (0x0200) /*!< Processes management errors */
#define ERR_SIO_GRP (0x0800) /*!< SIO errors due to logging */
#define ERR_RINGBUF_GRP (0x0900) /*!< Ring Buffer errors */
#define ERR_MQ_GRP (0x0A00) /*!< MQ errors */
#define ERR_TIMER_GRP (0x0B00) /*!< Timer errors */
#define ERR_RFAL_GRP (0x0C00) /*!< RFAL errors */
#define ERR_UART_GRP (0x0D00) /*!< UART errors */
#define ERR_SPI_GRP (0x0E00) /*!< SPI errors */
#define ERR_I2C_GRP (0x0F00) /*!< I2c errors */
#define ERR_INSERT_SIO_GRP(x) (ERR_SIO_GRP | x) /*!< Insert the SIO grp */
#define ERR_INSERT_RINGBUF_GRP(x) (ERR_RINGBUF_GRP | x) /*!< Insert the Ring Buffer grp */
#define ERR_INSERT_RFAL_GRP(x) (ERR_RFAL_GRP | x) /*!< Insert the RFAL grp */
#define ERR_INSERT_SPI_GRP(x) (ERR_SPI_GRP | x) /*!< Insert the spi grp */
#define ERR_INSERT_I2C_GRP(x) (ERR_I2C_GRP | x) /*!< Insert the i2c grp */
#define ERR_INSERT_UART_GRP(x) (ERR_UART_GRP | x) /*!< Insert the uart grp */
#define ERR_INSERT_TIMER_GRP(x) (ERR_TIMER_GRP | x) /*!< Insert the timer grp */
#define ERR_INSERT_MQ_GRP(x) (ERR_MQ_GRP | x) /*!< Insert the mq grp */
#define ERR_INSERT_PROCESS_GRP(x) (ERR_PROCESS_GRP | x) /*!< Insert the process grp */
#define ERR_INSERT_WARN_GRP(x) (ERR_WARN_GRP | x) /*!< Insert the i2c grp */
#define ERR_INSERT_GENERIC_GRP(x) (ERR_GENERIC_GRP | x) /*!< Insert the generic grp */
#define ERR_GENERIC_GRP (0x0000) /*!< Reserved value for generic error no */
#define ERR_WARN_GRP (0x0100) /*!< Errors which are not expected in normal operation */
#define ERR_PROCESS_GRP (0x0200) /*!< Processes management errors */
#define ERR_SIO_GRP (0x0800) /*!< SIO errors due to logging */
#define ERR_RINGBUF_GRP (0x0900) /*!< Ring Buffer errors */
#define ERR_MQ_GRP (0x0A00) /*!< MQ errors */
#define ERR_TIMER_GRP (0x0B00) /*!< Timer errors */
#define ERR_RFAL_GRP (0x0C00) /*!< RFAL errors */
#define ERR_UART_GRP (0x0D00) /*!< UART errors */
#define ERR_SPI_GRP (0x0E00) /*!< SPI errors */
#define ERR_I2C_GRP (0x0F00) /*!< I2c errors */
#define ERR_INSERT_SIO_GRP(x) (ERR_SIO_GRP | x) /*!< Insert the SIO grp */
#define ERR_INSERT_RINGBUF_GRP(x) (ERR_RINGBUF_GRP | x) /*!< Insert the Ring Buffer grp */
#define ERR_INSERT_RFAL_GRP(x) (ERR_RFAL_GRP | x) /*!< Insert the RFAL grp */
#define ERR_INSERT_SPI_GRP(x) (ERR_SPI_GRP | x) /*!< Insert the spi grp */
#define ERR_INSERT_I2C_GRP(x) (ERR_I2C_GRP | x) /*!< Insert the i2c grp */
#define ERR_INSERT_UART_GRP(x) (ERR_UART_GRP | x) /*!< Insert the uart grp */
#define ERR_INSERT_TIMER_GRP(x) (ERR_TIMER_GRP | x) /*!< Insert the timer grp */
#define ERR_INSERT_MQ_GRP(x) (ERR_MQ_GRP | x) /*!< Insert the mq grp */
#define ERR_INSERT_PROCESS_GRP(x) (ERR_PROCESS_GRP | x) /*!< Insert the process grp */
#define ERR_INSERT_WARN_GRP(x) (ERR_WARN_GRP | x) /*!< Insert the i2c grp */
#define ERR_INSERT_GENERIC_GRP(x) (ERR_GENERIC_GRP | x) /*!< Insert the generic grp */
/*
******************************************************************************
@@ -150,16 +147,12 @@ enum {
******************************************************************************
*/
#define ERR_NO_MASK(x) (x & 0x00FF) /*!< Mask the error number */
#define ERR_NO_MASK(x) (x & 0x00FF) /*!< Mask the error number */
/*! Common code to exit a function with the error if function f return error */
#define EXIT_ON_ERR(r, f) \
if (ERR_NONE != (r = f)) \
{ \
if(ERR_NONE != (r = f)) { \
return r; \
}
#endif /* ST_ERRNO_H */
+26 -38
View File
@@ -42,7 +42,6 @@
*/
#include "timer.h"
/*
******************************************************************************
* LOCAL DEFINES
@@ -63,54 +62,43 @@ static uint32_t timerStopwatchTick;
******************************************************************************
*/
/*******************************************************************************/
uint32_t timerCalculateTimer( uint16_t time )
{
return (HAL_GetTick() + time);
uint32_t timerCalculateTimer(uint16_t time) {
return (HAL_GetTick() + time);
}
/*******************************************************************************/
bool timerIsExpired( uint32_t timer )
{
uint32_t uDiff;
int32_t sDiff;
uDiff = (timer - HAL_GetTick()); /* Calculate the diff between the timers */
sDiff = uDiff; /* Convert the diff to a signed var */
/* Check if the given timer has expired already */
if( sDiff < 0 )
{
return true;
}
return false;
bool timerIsExpired(uint32_t timer) {
uint32_t uDiff;
int32_t sDiff;
uDiff = (timer - HAL_GetTick()); /* Calculate the diff between the timers */
sDiff = uDiff; /* Convert the diff to a signed var */
/* Check if the given timer has expired already */
if(sDiff < 0) {
return true;
}
return false;
}
/*******************************************************************************/
void timerDelay( uint16_t tOut )
{
uint32_t t;
/* Calculate the timer and wait blocking until is running */
t = timerCalculateTimer( tOut );
while( timerIsRunning(t) );
void timerDelay(uint16_t tOut) {
uint32_t t;
/* Calculate the timer and wait blocking until is running */
t = timerCalculateTimer(tOut);
while(timerIsRunning(t))
;
}
/*******************************************************************************/
void timerStopwatchStart( void )
{
timerStopwatchTick = HAL_GetTick();
void timerStopwatchStart(void) {
timerStopwatchTick = HAL_GetTick();
}
/*******************************************************************************/
uint32_t timerStopwatchMeasure( void )
{
return (uint32_t)(HAL_GetTick() - timerStopwatchTick);
uint32_t timerStopwatchMeasure(void) {
return (uint32_t)(HAL_GetTick() - timerStopwatchTick);
}
+11 -16
View File
@@ -32,9 +32,8 @@
* an abstraction for SW timers
*
*/
/*
/*
******************************************************************************
* INCLUDES
******************************************************************************
@@ -46,15 +45,15 @@
* GLOBAL MACROS
******************************************************************************
*/
#define timerIsRunning(t) (!timerIsExpired(t))
#define timerIsRunning(t) (!timerIsExpired(t))
/*
******************************************************************************
* GLOBAL DEFINES
******************************************************************************
*/
/*!
/*!
*****************************************************************************
* \brief Calculate Timer
*
@@ -70,8 +69,7 @@
* \return u32 : The new timer calculated based on the given time
*****************************************************************************
*/
uint32_t timerCalculateTimer( uint16_t time );
uint32_t timerCalculateTimer(uint16_t time);
/*!
*****************************************************************************
@@ -89,10 +87,9 @@ uint32_t timerCalculateTimer( uint16_t time );
* \return false : timer is still running
*****************************************************************************
*/
bool timerIsExpired( uint32_t timer );
bool timerIsExpired(uint32_t timer);
/*!
/*!
*****************************************************************************
* \brief Performs a Delay
*
@@ -102,8 +99,7 @@ bool timerIsExpired( uint32_t timer );
*
*****************************************************************************
*/
void timerDelay( uint16_t time );
void timerDelay(uint16_t time);
/*!
*****************************************************************************
@@ -113,8 +109,7 @@ void timerDelay( uint16_t time );
*
*****************************************************************************
*/
void timerStopwatchStart( void );
void timerStopwatchStart(void);
/*!
*****************************************************************************
@@ -125,4 +120,4 @@ void timerStopwatchStart( void );
* \return The time in ms since the stopwatch was started
*****************************************************************************
*/
uint32_t timerStopwatchMeasure( void );
uint32_t timerStopwatchMeasure(void);
+25 -23
View File
@@ -20,7 +20,6 @@
*
******************************************************************************/
/*
* PROJECT: NFCC firmware
* $Revision: $
@@ -55,38 +54,41 @@
* this macro evaluates an error variable \a ERR against an error code \a EC.
* in case it is not equal it jumps to the given label \a LABEL.
*/
#define EVAL_ERR_NE_GOTO(EC, ERR, LABEL) \
if (EC != ERR) goto LABEL;
#define EVAL_ERR_NE_GOTO(EC, ERR, LABEL) \
if(EC != ERR) goto LABEL;
/*!
* this macro evaluates an error variable \a ERR against an error code \a EC.
* in case it is equal it jumps to the given label \a LABEL.
*/
#define EVAL_ERR_EQ_GOTO(EC, ERR, LABEL) \
if (EC == ERR) goto LABEL;
#define BITMASK_1 (0x01) /*!< Bit mask for lsb bit */
#define BITMASK_2 (0x03) /*!< Bit mask for two lsb bits */
#define BITMASK_3 (0x07) /*!< Bit mask for three lsb bits */
#define BITMASK_4 (0x0F) /*!< Bit mask for four lsb bits */
#define U16TOU8(a) ((a) & 0x00FF) /*!< Cast 16-bit unsigned to 8-bit unsigned */
#define GETU16(a) (uint16_t)((a[0] << 8) | a[1])/*!< Cast two Big Endian 8-bits byte array to 16-bits unsigned */
#define EVAL_ERR_EQ_GOTO(EC, ERR, LABEL) \
if(EC == ERR) goto LABEL;
#define BITMASK_1 (0x01) /*!< Bit mask for lsb bit */
#define BITMASK_2 (0x03) /*!< Bit mask for two lsb bits */
#define BITMASK_3 (0x07) /*!< Bit mask for three lsb bits */
#define BITMASK_4 (0x0F) /*!< Bit mask for four lsb bits */
#define U16TOU8(a) ((a)&0x00FF) /*!< Cast 16-bit unsigned to 8-bit unsigned */
#define GETU16(a) \
(uint16_t)( \
(a[0] << 8) | a[1]) /*!< Cast two Big Endian 8-bits byte array to 16-bits unsigned */
#define REVERSE_BYTES(pData, nDataSize) \
unsigned char swap, *lo = pData, *hi = pData + nDataSize - 1; \
while(lo < hi) { \
swap = *lo; \
*lo++ = *hi; \
*hi-- = swap; \
}
#define REVERSE_BYTES(pData, nDataSize) \
unsigned char swap, *lo = pData, *hi = pData + nDataSize - 1; \
while (lo < hi) { swap = *lo; *lo++ = *hi; *hi-- = swap; }
#define ST_MEMMOVE memmove /*!< map memmove to string library code */
#define ST_MEMCPY memcpy /*!< map memcpy to string library code */
#define ST_MEMSET memset /*!< map memset to string library code */
#define ST_BYTECMP memcmp /*!< map bytecmp to string library code */
#define NO_WARNING(v) ((void) (v)) /*!< Macro to suppress compiler warning */
#define ST_MEMMOVE memmove /*!< map memmove to string library code */
#define ST_MEMCPY memcpy /*!< map memcpy to string library code */
#define ST_MEMSET memset /*!< map memset to string library code */
#define ST_BYTECMP memcmp /*!< map bytecmp to string library code */
#define NO_WARNING(v) ((void)(v)) /*!< Macro to suppress compiler warning */
#ifndef NULL
#define NULL (void*)0 /*!< represents a NULL pointer */
#define NULL (void*)0 /*!< represents a NULL pointer */
#endif /* !NULL */
/*