1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-03-13 14:46:06 +00:00

refactor(core): revert style checks in RFAL drivers

This commit is contained in:
kopecdav 2025-02-06 09:38:51 +01:00
parent b241955075
commit 3a147fab02
50 changed files with 24903 additions and 27528 deletions

View File

@ -1,18 +1,18 @@
/******************************************************************************
* @attention
*
* COPYRIGHT 2020 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
* @attention
*
* COPYRIGHT 2020 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/*
* PROJECT: ST25R391x firmware
@ -25,8 +25,8 @@
* \author bkam
*
* \brief RF Chip Analog Configuration Settings
*
*
*
*
* \addtogroup RFAL
* @{
*
@ -37,7 +37,7 @@
* \addtogroup AnalogConfig
* \brief RFAL Analog Config Module
* @{
*
*
*/
#ifndef RFAL_ANALOG_CONFIG_H
@ -49,8 +49,8 @@
******************************************************************************
*/
#include "rfal_platform.h"
#include "rfal_rf.h"
#include "rfal_utils.h"
#include "rfal_rf.h"
/*
******************************************************************************
@ -58,13 +58,10 @@
******************************************************************************
*/
#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 */
/*
******************************************************************************
@ -75,21 +72,21 @@
* +---------+-----------------------+-----------------------------+
*
* The Mode ID coding for different use cases is described below
*
*
* 1. ModeID coding for NFC technologies (not chip specific)
* +----------------------------------------------------------------------+
* | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
* +----------------------------------------------------------------------+
* | P/L | TECH != CHIP | BR | DIR |
* +----------------------------------------------------------------------+
*
*
* 2. ModeID coding for chip specific modes and events
* +----------------------------------------------------------------------+
* | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
* +----------------------------------------------------------------------+
* | P/L | TECH == CHIP | CHIP_SPECIFIC |
* +----------------------------------------------------------------------+
*
*
* 3. Special ModeID coding for Direction == DPO
* +----------------------------------------------------------------------+
* | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
@ -97,264 +94,149 @@
* | P/L | DPO_LVL | TECH* | BR | DIR == DPO |
* +----------------------------------------------------------------------+
* ^
* |
* |
* +----- reuse of TECH_RFU bits as DPO level indicator
******************************************************************************
*/
/* Mask bit */
#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 */
/* Mask bit */
#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 */
/* Shift values */
#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 */
/* P/L: bit 15 */
#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 */
/* TECH: bit 14-8 */
#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_RFU2 (0x4000U) /*!< 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_TECH_RFU2 (0x4000U) /*!< RFU for Technology bits */
/* BR: bit 7-4 */
#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_211p88 \
(0x0090U) /*!< 211.88kbits/s (ISO15693 x8) in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_BITRATE_105p94 \
(0x00A0U) /*!< 105.94kbits/s (ISO15693 x4) in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_BITRATE_53 \
(0x00B0U) /*!< 53kbits/s (ISO15693 x2) setting in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_BITRATE_26 \
(0x00C0U) /*!< 26kbit/s (1 out of 4) NFC-V setting Analog Configuration ID \
*/
#define RFAL_ANALOG_CONFIG_BITRATE_1p6 \
(0x00D0U) /*!< 1.6kbit/s (1 out of 256) NFC-V setting Analog Config ID */
#define RFAL_ANALOG_CONFIG_BITRATE_RFU (0x00E0U) /*!< RFU for Bitrate bits */
#define RFAL_ANALOG_CONFIG_BITRATE_RFU2 (0x00F0U) /*!< RFU for Bitrate 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_211p88 (0x0090U) /*!< 211.88kbits/s (ISO15693 x8) in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_BITRATE_105p94 (0x00A0U) /*!< 105.94kbits/s (ISO15693 x4) in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_BITRATE_53 (0x00B0U) /*!< 53kbits/s (ISO15693 x2) setting in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_BITRATE_26 (0x00C0U) /*!< 26kbit/s (1 out of 4) NFC-V setting Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_BITRATE_1p6 (0x00D0U) /*!< 1.6kbit/s (1 out of 256) NFC-V setting Analog Config ID */
#define RFAL_ANALOG_CONFIG_BITRATE_RFU (0x00E0U) /*!< RFU for Bitrate bits */
#define RFAL_ANALOG_CONFIG_BITRATE_RFU2 (0x00F0U) /*!< RFU for Bitrate bits */
/* DIR: bit 3-0 */
#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_DLMA \
(0x0005U) /*!< DLMA setting in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_DIRECTION_RFU2 \
(0x0006U) /*!< RFU for Direction bits */
#define RFAL_ANALOG_CONFIG_DIRECTION_RFU3 \
(0x0007U) /*!< RFU for Direction bits */
#define RFAL_ANALOG_CONFIG_DIRECTION_RFU4 \
(0x0008U) /*!< RFU for Direction bits */
#define RFAL_ANALOG_CONFIG_DIRECTION_RFU5 \
(0x0009U) /*!< RFU for Direction bits */
#define RFAL_ANALOG_CONFIG_DIRECTION_RFU6 \
(0x000AU) /*!< RFU for Direction bits */
#define RFAL_ANALOG_CONFIG_DIRECTION_RFU7 \
(0x000BU) /*!< RFU for Direction bits */
#define RFAL_ANALOG_CONFIG_DIRECTION_RFU8 \
(0x000CU) /*!< RFU for Direction bits */
#define RFAL_ANALOG_CONFIG_DIRECTION_RFU9 \
(0x000DU) /*!< RFU for Direction bits */
#define RFAL_ANALOG_CONFIG_DIRECTION_RFU10 \
(0x000EU) /*!< RFU for Direction bits */
#define RFAL_ANALOG_CONFIG_DIRECTION_RFU11 \
(0x000FU) /*!< RFU for Direction bits */
#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_DLMA (0x0005U) /*!< DLMA setting in Analog Configuration ID */
#define RFAL_ANALOG_CONFIG_DIRECTION_RFU2 (0x0006U) /*!< RFU for Direction bits */
#define RFAL_ANALOG_CONFIG_DIRECTION_RFU3 (0x0007U) /*!< RFU for Direction bits */
#define RFAL_ANALOG_CONFIG_DIRECTION_RFU4 (0x0008U) /*!< RFU for Direction bits */
#define RFAL_ANALOG_CONFIG_DIRECTION_RFU5 (0x0009U) /*!< RFU for Direction bits */
#define RFAL_ANALOG_CONFIG_DIRECTION_RFU6 (0x000AU) /*!< RFU for Direction bits */
#define RFAL_ANALOG_CONFIG_DIRECTION_RFU7 (0x000BU) /*!< RFU for Direction bits */
#define RFAL_ANALOG_CONFIG_DIRECTION_RFU8 (0x000CU) /*!< RFU for Direction bits */
#define RFAL_ANALOG_CONFIG_DIRECTION_RFU9 (0x000DU) /*!< RFU for Direction bits */
#define RFAL_ANALOG_CONFIG_DIRECTION_RFU10 (0x000EU) /*!< RFU for Direction bits */
#define RFAL_ANALOG_CONFIG_DIRECTION_RFU11 (0x000FU) /*!< RFU for Direction bits */
/* bit 7-0 */
#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_CHIP_POWER_LVL_00 \
(0x0010U) /*!< Chip-Specific event: Power Level 00 (e.g DPO, WLC) */
#define RFAL_ANALOG_CONFIG_CHIP_POWER_LVL_01 \
(0x0011U) /*!< Chip-Specific event: Power Level 01 (e.g DPO, WLC) */
#define RFAL_ANALOG_CONFIG_CHIP_POWER_LVL_02 \
(0x0012U) /*!< Chip-Specific event: Power Level 02 (e.g DPO, WLC) */
#define RFAL_ANALOG_CONFIG_CHIP_POWER_LVL_03 \
(0x0013U) /*!< Chip-Specific event: Power Level 03 (e.g DPO, WLC) */
#define RFAL_ANALOG_CONFIG_CHIP_POWER_LVL_04 \
(0x0014U) /*!< Chip-Specific event: Power Level 04 (e.g DPO, WLC) */
#define RFAL_ANALOG_CONFIG_CHIP_POWER_LVL_05 \
(0x0015U) /*!< Chip-Specific event: Power Level 05 (e.g DPO, WLC) */
#define RFAL_ANALOG_CONFIG_CHIP_POWER_LVL_06 \
(0x0016U) /*!< Chip-Specific event: Power Level 06 (e.g DPO, WLC) */
#define RFAL_ANALOG_CONFIG_CHIP_POWER_LVL_07 \
(0x0017U) /*!< Chip-Specific event: Power Level 07 (e.g DPO, WLC) */
#define RFAL_ANALOG_CONFIG_CHIP_POWER_LVL_08 \
(0x0018U) /*!< Chip-Specific event: Power Level 08 (e.g DPO, WLC) */
#define RFAL_ANALOG_CONFIG_CHIP_POWER_LVL_09 \
(0x0019U) /*!< Chip-Specific event: Power Level 09 (e.g DPO, WLC) */
#define RFAL_ANALOG_CONFIG_CHIP_POWER_LVL_10 \
(0x001AU) /*!< Chip-Specific event: Power Level 10 (e.g DPO, WLC) */
#define RFAL_ANALOG_CONFIG_CHIP_POWER_LVL_11 \
(0x001BU) /*!< Chip-Specific event: Power Level 11 (e.g DPO, WLC) */
#define RFAL_ANALOG_CONFIG_CHIP_POWER_LVL_12 \
(0x001CU) /*!< Chip-Specific event: Power Level 12 (e.g DPO, WLC) */
#define RFAL_ANALOG_CONFIG_CHIP_POWER_LVL_13 \
(0x001DU) /*!< Chip-Specific event: Power Level 13 (e.g DPO, WLC) */
#define RFAL_ANALOG_CONFIG_CHIP_POWER_LVL_14 \
(0x001EU) /*!< Chip-Specific event: Power Level 14 (e.g DPO, WLC) */
#define RFAL_ANALOG_CONFIG_CHIP_POWER_LVL_15 \
(0x001FU) /*!< Chip-Specific event: Power Level 15 (e.g DPO, WLC) */
#define RFAL_ANALOG_CONFIG_CHIP_POWER_LVL_00 (0x0010U) /*!< Chip-Specific event: Power Level 00 (e.g DPO, WLC) */
#define RFAL_ANALOG_CONFIG_CHIP_POWER_LVL_01 (0x0011U) /*!< Chip-Specific event: Power Level 01 (e.g DPO, WLC) */
#define RFAL_ANALOG_CONFIG_CHIP_POWER_LVL_02 (0x0012U) /*!< Chip-Specific event: Power Level 02 (e.g DPO, WLC) */
#define RFAL_ANALOG_CONFIG_CHIP_POWER_LVL_03 (0x0013U) /*!< Chip-Specific event: Power Level 03 (e.g DPO, WLC) */
#define RFAL_ANALOG_CONFIG_CHIP_POWER_LVL_04 (0x0014U) /*!< Chip-Specific event: Power Level 04 (e.g DPO, WLC) */
#define RFAL_ANALOG_CONFIG_CHIP_POWER_LVL_05 (0x0015U) /*!< Chip-Specific event: Power Level 05 (e.g DPO, WLC) */
#define RFAL_ANALOG_CONFIG_CHIP_POWER_LVL_06 (0x0016U) /*!< Chip-Specific event: Power Level 06 (e.g DPO, WLC) */
#define RFAL_ANALOG_CONFIG_CHIP_POWER_LVL_07 (0x0017U) /*!< Chip-Specific event: Power Level 07 (e.g DPO, WLC) */
#define RFAL_ANALOG_CONFIG_CHIP_POWER_LVL_08 (0x0018U) /*!< Chip-Specific event: Power Level 08 (e.g DPO, WLC) */
#define RFAL_ANALOG_CONFIG_CHIP_POWER_LVL_09 (0x0019U) /*!< Chip-Specific event: Power Level 09 (e.g DPO, WLC) */
#define RFAL_ANALOG_CONFIG_CHIP_POWER_LVL_10 (0x001AU) /*!< Chip-Specific event: Power Level 10 (e.g DPO, WLC) */
#define RFAL_ANALOG_CONFIG_CHIP_POWER_LVL_11 (0x001BU) /*!< Chip-Specific event: Power Level 11 (e.g DPO, WLC) */
#define RFAL_ANALOG_CONFIG_CHIP_POWER_LVL_12 (0x001CU) /*!< Chip-Specific event: Power Level 12 (e.g DPO, WLC) */
#define RFAL_ANALOG_CONFIG_CHIP_POWER_LVL_13 (0x001DU) /*!< Chip-Specific event: Power Level 13 (e.g DPO, WLC) */
#define RFAL_ANALOG_CONFIG_CHIP_POWER_LVL_14 (0x001EU) /*!< Chip-Specific event: Power Level 14 (e.g DPO, WLC) */
#define RFAL_ANALOG_CONFIG_CHIP_POWER_LVL_15 (0x001FU) /*!< Chip-Specific event: Power Level 15 (e.g DPO, WLC) */
#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 */
/*
******************************************************************************
* GLOBAL MACROS
******************************************************************************
*/
#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_26(id) \
(RFAL_ANALOG_CONFIG_BITRATE_26 & \
(id)) /*!< Check if ID indicates 1 out of 4 bitrate */
#define RFAL_ANALOG_CONFIG_ID_IS_1p6(id) \
(RFAL_ANALOG_CONFIG_BITRATE_1p6 & \
(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_26(id) (RFAL_ANALOG_CONFIG_BITRATE_26 & (id)) /*!< Check if ID indicates 1 out of 4 bitrate */
#define RFAL_ANALOG_CONFIG_ID_IS_1p6(id) (RFAL_ANALOG_CONFIG_BITRATE_1p6 & (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))
/*! 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) \
)
/*
******************************************************************************
@ -362,44 +244,36 @@
******************************************************************************
*/
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 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 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! */
/*! 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
@ -409,36 +283,37 @@ typedef struct {
/*!
*****************************************************************************
* \brief Initialize the Analog Configuration
*
*
* Reset the Analog Configuration LUT pointer to reference to default settings.
*
*
*****************************************************************************
*/
void rfalAnalogConfigInitialize(void);
void rfalAnalogConfigInitialize( void );
/*!
*****************************************************************************
* \brief Indicate if the current Analog Configuration Table is complete and
*ready to be used.
*
* \return true if current Analog Configuration Table is complete and ready to
*be used. \return false if current Analog Configuration Table is incomplete
*
* \brief Indicate if the current Analog Configuration Table is complete and ready to be used.
*
* \return true if current Analog Configuration Table is complete and ready to be used.
* \return false if current Analog Configuration Table is incomplete
*
*****************************************************************************
*/
bool rfalAnalogConfigIsReady(void);
bool rfalAnalogConfigIsReady( void );
/*!
*****************************************************************************
* \brief Write the whole Analog Configuration table in raw format
*
* \brief Write the whole Analog Configuration table in raw format
*
* Writes the Analog Configuration and Look Up Table with the given raw table
*
*
* NOTE: Function does not check the validity of the given Table contents
*
*
* \param[in] configTbl : location of config Table to be loaded
* \param[in] configTblSize : size of the config Table to be loaded
*
*
* \return RFAL_ERR_NONE : if setting is updated
* \return RFAL_ERR_PARAM : if configTbl is invalid
* \return RFAL_ERR_NOMEM : if the given Table is bigger exceeds the max size
@ -446,115 +321,113 @@ bool rfalAnalogConfigIsReady(void);
*
*****************************************************************************
*/
ReturnCode rfalAnalogConfigListWriteRaw(const uint8_t *configTbl,
uint16_t configTblSize);
ReturnCode rfalAnalogConfigListWriteRaw( const uint8_t *configTbl, uint16_t configTblSize );
/*!
*****************************************************************************
* \brief Write the Analog Configuration table with new analog settings.
*
* Writes the Analog Configuration and Look Up Table with the new list of
*register-mask-value and Configuration ID respectively.
*
*
* Writes the Analog Configuration and Look Up Table with the new list of register-mask-value
* and Configuration ID respectively.
*
* NOTE: Function does not check for the validity of the Register Address.
*
* \param[in] more : 0x00 indicates it is last Configuration ID settings;
* 0x01 indicates more Configuration ID setting(s) are
*coming. \param[in] *config : reference to the configuration list of current
*Configuraiton ID.
*
*
* \param[in] more : 0x00 indicates it is last Configuration ID settings;
* 0x01 indicates more Configuration ID setting(s) are coming.
* \param[in] *config : reference to the configuration list of current Configuraiton ID.
*
* \return RFAL_ERR_PARAM : if Configuration ID or parameter is invalid
* \return RFAL_ERR_NOMEM : if LUT is full
* \return RFAL_ERR_REQUEST : if the update Configuration Id is disabled
* \return RFAL_ERR_NOMEM : if LUT is full
* \return RFAL_ERR_REQUEST : if the update Configuration Id is disabled
* \return RFAL_ERR_NONE : if setting is updated
*
*****************************************************************************
*/
ReturnCode rfalAnalogConfigListWrite(uint8_t more,
const rfalAnalogConfig *config);
ReturnCode rfalAnalogConfigListWrite( uint8_t more, const rfalAnalogConfig *config );
/*!
*****************************************************************************
* \brief Read the whole Analog Configuration table in raw format
*
*
* Reads the whole Analog Configuration Table in raw format
*
* \param[out] tblBuf : location to the buffer to place the Config
*Table \param[in] tblBufLen : length of the buffer to place the Config
*Table \param[out] configTblSize : Config Table size
*
*
* \param[out] tblBuf : location to the buffer to place the Config Table
* \param[in] tblBufLen : length of the buffer to place the Config Table
* \param[out] configTblSize : Config Table size
*
* \return RFAL_ERR_PARAM : if configTbl or configTblSize is invalid
* \return RFAL_ERR_NOMEM : if configTblSize is not enough for the whole table
* \return RFAL_ERR_NOMEM : if configTblSize is not enough for the whole table
* \return RFAL_ERR_NONE : if read is successful
*
*
*****************************************************************************
*/
ReturnCode rfalAnalogConfigListReadRaw(uint8_t *tblBuf, uint16_t tblBufLen,
uint16_t *configTblSize);
ReturnCode rfalAnalogConfigListReadRaw( uint8_t *tblBuf, uint16_t tblBufLen, uint16_t *configTblSize );
/*!
*****************************************************************************
* \brief Read the Analog Configuration table.
*
*
* Read the Analog Configuration Table
*
* \param[in] configOffset : offset to the next Configuration ID in the List
*Table to be read. \param[out] more : 0x00 indicates it is last
*Configuration ID settings; 0x01 indicates more Configuration ID setting(s) are
*coming. \param[out] config : configuration id, number of configuration
*sets and register-mask-value sets \param[in] numConfig : the remaining
*configuration settings space available;
*
* \return RFAL_ERR_NOMEM : if number of Configuration for respective
*Configuration ID is greater the the remaining configuration setting space
*available \return RFAL_ERR_NONE : if read is successful
*
*
* \param[in] configOffset : offset to the next Configuration ID in the List Table to be read.
* \param[out] more : 0x00 indicates it is last Configuration ID settings;
* 0x01 indicates more Configuration ID setting(s) are coming.
* \param[out] config : configuration id, number of configuration sets and register-mask-value sets
* \param[in] numConfig : the remaining configuration settings space available;
*
* \return RFAL_ERR_NOMEM : if number of Configuration for respective Configuration ID is greater the the remaining configuration setting space available
* \return RFAL_ERR_NONE : if read is successful
*
*****************************************************************************
*/
ReturnCode rfalAnalogConfigListRead(rfalAnalogConfigOffset *configOffset,
uint8_t *more, rfalAnalogConfig *config,
rfalAnalogConfigNum numConfig);
ReturnCode rfalAnalogConfigListRead( rfalAnalogConfigOffset *configOffset, uint8_t *more, rfalAnalogConfig *config, rfalAnalogConfigNum numConfig );
/*!
*****************************************************************************
* \brief Set the Analog settings of indicated Configuration ID.
*
*
* Update the chip with indicated analog settings of indicated Configuration ID.
*
* \param[in] configId : configuration ID
*
*
* \return RFAL_ERR_PARAM : if Configuration ID is invalid
* \return RFAL_ERR_INTERNAL : if error updating setting to chip
* \return RFAL_ERR_INTERNAL : if error updating setting to chip
* \return RFAL_ERR_NONE : if new settings is applied to chip
*
*****************************************************************************
*/
ReturnCode rfalSetAnalogConfig(rfalAnalogConfigId configId);
ReturnCode rfalSetAnalogConfig( rfalAnalogConfigId configId );
/*!
*****************************************************************************
* \brief Generates Analog Config mode ID
* \brief Generates Analog Config mode ID
*
* Converts RFAL mode and bitrate into Analog Config Mode ID.
*
*
* Update the chip with indicated analog settings of indicated Configuration ID.
*
* \param[in] md : RFAL mode format
* \param[in] br : RFAL bit rate format
* \param[in] dir : Analog Config communication direction
*
*
* \return Analog Config Mode ID
*
*****************************************************************************
*/
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 */
/**
* @}
*
* @}
*
* @}
*/
* @}
*
* @}
*
* @}
*/

View File

@ -1,18 +1,20 @@
/******************************************************************************
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/*
* PROJECT: ST25R391x firmware
@ -22,11 +24,11 @@
/*! \file rfal_chip.h
*
* \author Gustavo Patricio
* \author Gustavo Patricio
*
* \brief RF Chip specific Layer
*
* \warning This layer, which provides direct access to RF chip, should
*
* \warning This layer, which provides direct access to RF chip, should
* only be used for debug purposes and/or advanced features
*
*
@ -40,9 +42,10 @@
* \addtogroup Chip
* \brief RFAL RF Chip Module
* @{
*
*
*/
#ifndef RFAL_CHIP_H
#define RFAL_CHIP_H
@ -52,11 +55,12 @@
******************************************************************************
*/
#include "rfal_platform.h"
#include "rfal_rf.h"
#include "rfal_utils.h"
#include "rfal_rf.h"
/*****************************************************************************
* RF Chip *
* RF Chip *
*****************************************************************************/
/*!
@ -65,18 +69,18 @@
*
* Checks if the given register is valid and if so, writes the value(s)
* on the RF Chip register
*
*
* \param[in] reg : register address to be written, or the first if len > 1
* \param[in] values : pointer with content to be written on the register(s)
* \param[in] len : number of consecutive registers to be written
*
*
*
*
* \return RFAL_ERR_PARAM : Invalid register or bad request
* \return RFAL_ERR_NOTSUPP : Feature not supported
* \return RFAL_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 );
/*!
*****************************************************************************
@ -84,112 +88,108 @@ ReturnCode rfalChipWriteReg(uint16_t reg, const uint8_t* values, uint8_t len);
*
* Checks if the given register is valid and if so, reads the value(s)
* of the RF Chip register(s)
*
*
* \param[in] reg : register address to be read, or the first if len > 1
* \param[out] values : pointer where the register(s) read content will be
*placed \param[in] len : number of consecutive registers to be read
*
* \param[out] values : pointer where the register(s) read content will be placed
* \param[in] len : number of consecutive registers to be read
*
* \return RFAL_ERR_PARAM : Invalid register or bad request
* \return RFAL_ERR_NOTSUPP : Feature not supported
* \return RFAL_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 );
/*!
*****************************************************************************
* \brief Change a register on the RF Chip
*
* Change the value of the register bits on the RF Chip Test set in the
*valueMask.
*
* Change the value of the register bits on the RF Chip Test set in the valueMask.
*
* \param[in] reg : register address to be modified
* \param[in] valueMask : mask value of the register bits to be changed
* \param[in] value : register value to be set
*
*
* \return RFAL_ERR_PARAM : Invalid register or bad request
* \return RFAL_ERR_NOTSUPP : Feature not supported
* \return RFAL_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 );
/*!
*****************************************************************************
* \brief Writes a Test register on the RF Chip
*
* Writes the value on the RF Chip Test register
*
*
* \param[in] reg : register address to be written
* \param[in] value : value to be written on the register
*
*
*
*
* \return RFAL_ERR_PARAM : Invalid register or bad request
* \return RFAL_ERR_NOTSUPP : Feature not supported
* \return RFAL_ERR_NONE : Write done with no error
*****************************************************************************
*/
ReturnCode rfalChipWriteTestReg(uint16_t reg, uint8_t value);
ReturnCode rfalChipWriteTestReg( uint16_t reg, uint8_t value );
/*!
*****************************************************************************
* \brief Reads a Test register on the RF Chip
*
* Reads the value of the RF Chip Test register
*
*
* \param[in] reg : register address to be read
* \param[out] value : pointer where the register content will be placed
*
* \param[out] value : pointer where the register content will be placed
*
* \return RFAL_ERR_PARAM :Invalid register or bad request
* \return RFAL_ERR_NOTSUPP : Feature not supported
* \return RFAL_ERR_NONE : Read done with no error
*****************************************************************************
*/
ReturnCode rfalChipReadTestReg(uint16_t reg, uint8_t* value);
ReturnCode rfalChipReadTestReg( uint16_t reg, uint8_t* value );
/*!
*****************************************************************************
* \brief Change a Test register on the RF Chip
*
* Change the value of the register bits on the RF Chip Test set in the
*valueMask.
*
* Change the value of the register bits on the RF Chip Test set in the valueMask.
*
* \param[in] reg : test register address to be modified
* \param[in] valueMask : mask value of the register bits to be changed
* \param[in] value : register value to be set
*
*
* \return RFAL_ERR_PARAM : Invalid register or bad request
* \return RFAL_ERR_NOTSUPP : Feature not supported
* \return RFAL_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 );
/*!
*****************************************************************************
* \brief Execute command on the RF Chip
*
* Checks if the given command is valid and if so, executes it on
* Checks if the given command is valid and if so, executes it on
* the RF Chip
*
*
* \param[in] cmd : direct command to be executed
*
*
* \return RFAL_ERR_PARAM : Invalid command or bad request
* \return RFAL_ERR_NOTSUPP : Feature not supported
* \return RFAL_ERR_NONE : Direct command executed with no error
*****************************************************************************
*/
ReturnCode rfalChipExecCmd(uint16_t cmd);
ReturnCode rfalChipExecCmd( uint16_t cmd );
/*!
/*!
*****************************************************************************
* \brief Set RFO
*
* Sets the RFO driver resistance value used when the
* Sets the RFO driver resistance value used when the
* field is on (unmodulated/active)
*
*
* \param[in] rfo : the RFO value to be used
*
* \return RFAL_ERR_IO : Internal error
@ -197,31 +197,33 @@ ReturnCode rfalChipExecCmd(uint16_t cmd);
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalChipSetRFO(uint8_t rfo);
ReturnCode rfalChipSetRFO( uint8_t rfo );
/*!
/*!
*****************************************************************************
* \brief Get RFO
*
* Gets the RFO driver resistance value used when the
* Gets the RFO driver resistance value used when the
* field is on (unmodulated/active)
*
* \param[out] result : the current RFO value
* \param[out] result : the current RFO value
*
* \return RFAL_ERR_IO : Internal error
* \return RFAL_ERR_NOTSUPP : Feature not supported
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalChipGetRFO(uint8_t* result);
ReturnCode rfalChipGetRFO( uint8_t* result );
/*!
/*!
*****************************************************************************
* \brief Get LM Field Indicator
*
* Gets an indicator of the signal on RFI while in Passive Listen Mode
*
* \param[out] result : the current RFI value
* \param[out] result : the current RFI value
*
* \return RFAL_ERR_IO : Internal error
* \return RFAL_ERR_NOTSUPP : Feature not supported
@ -229,13 +231,13 @@ ReturnCode rfalChipGetRFO(uint8_t* result);
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalChipGetLmFieldInd(uint8_t* result);
ReturnCode rfalChipGetLmFieldInd( uint8_t* result );
/*!
/*!
*****************************************************************************
* \brief Set Listen Mode Modulation
*
* Sets the modulation (modulated and unmodulated state) when Passive Listen
* Sets the modulation (modulated and unmodulated state) when Passive Listen
* Mode is used
*
* \param[in] mod : modulation to be used in modulated state
@ -246,13 +248,14 @@ ReturnCode rfalChipGetLmFieldInd(uint8_t* result);
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalChipSetLMMod(uint8_t mod, uint8_t unmod);
ReturnCode rfalChipSetLMMod( uint8_t mod, uint8_t unmod );
/*!
/*!
*****************************************************************************
* \brief Get Listen Mode Modulation
*
* Gets the modulation (modulated and unmodulated state) when Passive Listen
* Gets the modulation (modulated and unmodulated state) when Passive Listen
* Mode is used
*
* \param[out] mod : modulation set in modulated state
@ -263,9 +266,10 @@ ReturnCode rfalChipSetLMMod(uint8_t mod, uint8_t unmod);
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalChipGetLMMod(uint8_t* mod, uint8_t* unmod);
ReturnCode rfalChipGetLMMod( uint8_t* mod, uint8_t* unmod );
/*!
/*!
*****************************************************************************
* \brief Measure Amplitude
*
@ -278,9 +282,10 @@ ReturnCode rfalChipGetLMMod(uint8_t* mod, uint8_t* unmod);
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalChipMeasureAmplitude(uint8_t* result);
ReturnCode rfalChipMeasureAmplitude( uint8_t* result );
/*!
/*!
*****************************************************************************
* \brief Measure Phase
*
@ -293,9 +298,10 @@ ReturnCode rfalChipMeasureAmplitude(uint8_t* result);
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalChipMeasurePhase(uint8_t* result);
ReturnCode rfalChipMeasurePhase( uint8_t* result );
/*!
/*!
*****************************************************************************
* \brief Measure Capacitance
*
@ -308,9 +314,10 @@ ReturnCode rfalChipMeasurePhase(uint8_t* result);
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalChipMeasureCapacitance(uint8_t* result);
ReturnCode rfalChipMeasureCapacitance( uint8_t* result );
/*!
/*!
*****************************************************************************
* \brief Measure Power Supply
*
@ -324,9 +331,10 @@ ReturnCode rfalChipMeasureCapacitance(uint8_t* result);
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalChipMeasurePowerSupply(uint8_t param, uint8_t* result);
ReturnCode rfalChipMeasurePowerSupply( uint8_t param, uint8_t* result );
/*!
/*!
*****************************************************************************
* \brief Measure I and Q
*
@ -340,9 +348,10 @@ ReturnCode rfalChipMeasurePowerSupply(uint8_t param, uint8_t* result);
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalChipMeasureIQ(int8_t* resI, int8_t* resQ);
ReturnCode rfalChipMeasureIQ( int8_t* resI, int8_t* resQ );
/*!
/*!
*****************************************************************************
* \brief Measure combined I and Q
*
@ -355,13 +364,14 @@ ReturnCode rfalChipMeasureIQ(int8_t* resI, int8_t* resQ);
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalChipMeasureCombinedIQ(uint8_t* result);
ReturnCode rfalChipMeasureCombinedIQ( uint8_t* result );
/*!
/*!
*****************************************************************************
* \brief Set Antenna mode
*
* Sets the antenna mode.
* Sets the antenna mode.
* Differential or single ended antenna mode (RFO1 or RFO2)
*
* \param[in] single : FALSE differential ; single ended mode
@ -372,14 +382,14 @@ ReturnCode rfalChipMeasureCombinedIQ(uint8_t* result);
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalChipSetAntennaMode(bool single, bool rfiox);
ReturnCode rfalChipSetAntennaMode( bool single, bool rfiox );
#endif /* RFAL_CHIP_H */
/**
* @}
*
* @}
*
* @}
*/
* @}
*
* @}
*
* @}
*/

View File

@ -1,39 +1,41 @@
/******************************************************************************
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/*
* PROJECT: ST25R
* PROJECT: ST25R
* Revision:
* LANGUAGE: ISO C99
*/
/*! \file rfal_defConfig.h
*
* \author Gustavo Patricio
* \author Gustavo Patricio
*
* \brief RF Abstraction Layer (RFAL) default Config file
*
*
* This file contains a base/default configuration for the
* RFAL library.
* Users can and shall define their on configuration acording
* RFAL library.
* Users can and shall define their on configuration acording
* to their speficic system needs on rfal_platform.h.
*
* \addtogroup RFAL
* @{
*
*
*/
#ifndef RFAL_CONFIG_H
@ -46,295 +48,283 @@
*/
#include "rfal_features.h"
/*
******************************************************************************
* GLOBAL DEFINES
******************************************************************************
*/
/*
******************************************************************************
* RFAL FEATURES DEFAULT CONFIGURATION
******************************************************************************
*/
#ifndef RFAL_FEATURE_LISTEN_MODE
#if RFAL_SUPPORT_CE || RFAL_SUPPORT_MODE_LISTEN_ACTIVE_P2P
#define RFAL_FEATURE_LISTEN_MODE \
true /*!< Enable RFAL support for Listen Mode */
#endif /* SUPPORT LISTEN_MODE */
#if RFAL_SUPPORT_CE || RFAL_SUPPORT_MODE_LISTEN_ACTIVE_P2P
#define RFAL_FEATURE_LISTEN_MODE true /*!< Enable RFAL support for Listen Mode */
#endif /* SUPPORT LISTEN_MODE */
#endif /* RFAL_FEATURE_LISTEN_MODE */
#ifndef RFAL_FEATURE_WAKEUP_MODE
#define RFAL_FEATURE_WAKEUP_MODE \
true /*!< Enable RFAL support for the Wake-Up mode */
#define RFAL_FEATURE_WAKEUP_MODE true /*!< Enable RFAL support for the Wake-Up mode */
#endif /* RFAL_FEATURE_WAKEUP_MODE */
#ifndef RFAL_FEATURE_LOWPOWER_MODE
#define RFAL_FEATURE_LOWPOWER_MODE \
false /*!< RFAL support for the Low Power mode, Disabled by default */
#endif /* RFAL_FEATURE_LOWPOWER_MODE */
#define RFAL_FEATURE_LOWPOWER_MODE false /*!< RFAL support for the Low Power mode, Disabled by default */
#endif /* RFAL_FEATURE_LOWPOWER_MODE */
#ifndef RFAL_FEATURE_NFCA
#if RFAL_SUPPORT_MODE_POLL_NFCA
#define RFAL_FEATURE_NFCA \
true /*!< Enable RFAL support for NFC-A (ISO14443A) \
*/
#endif /* RFAL_SUPPORT_MODE_POLL_NFCA */
#if RFAL_SUPPORT_MODE_POLL_NFCA
#define RFAL_FEATURE_NFCA true /*!< Enable RFAL support for NFC-A (ISO14443A) */
#endif /* RFAL_SUPPORT_MODE_POLL_NFCA */
#endif /* RFAL_FEATURE_NFCA */
#ifndef RFAL_FEATURE_T1T
#if RFAL_SUPPORT_MODE_POLL_NFCA
#define RFAL_FEATURE_T1T true /*!< Enable RFAL support for T1T (Topaz) */
#endif /* RFAL_SUPPORT_MODE_POLL_NFCA */
#endif /* RFAL_FEATURE_T1T */
#if RFAL_SUPPORT_MODE_POLL_NFCA
#define RFAL_FEATURE_T1T true /*!< Enable RFAL support for T1T (Topaz) */
#endif /* RFAL_SUPPORT_MODE_POLL_NFCA */
#endif /* RFAL_FEATURE_T1T */
#ifndef RFAL_FEATURE_T2T
#if RFAL_SUPPORT_MODE_POLL_NFCA
#define RFAL_FEATURE_T2T true /*!< Enable RFAL support for T2T */
#endif /* RFAL_SUPPORT_MODE_POLL_NFCA */
#endif /* RFAL_FEATURE_T2T */
#if RFAL_SUPPORT_MODE_POLL_NFCA
#define RFAL_FEATURE_T2T true /*!< Enable RFAL support for T2T */
#endif /* RFAL_SUPPORT_MODE_POLL_NFCA */
#endif /* RFAL_FEATURE_T2T */
#ifndef RFAL_FEATURE_T4T
#if RFAL_SUPPORT_MODE_POLL_NFCA
#define RFAL_FEATURE_T4T true /*!< Enable RFAL support for T4T */
#endif /* RFAL_SUPPORT_MODE_POLL_NFCA */
#endif /* RFAL_FEATURE_T2T */
#if RFAL_SUPPORT_MODE_POLL_NFCA
#define RFAL_FEATURE_T4T true /*!< Enable RFAL support for T4T */
#endif /* RFAL_SUPPORT_MODE_POLL_NFCA */
#endif /* RFAL_FEATURE_T2T */
#ifndef RFAL_FEATURE_NFCB
#if RFAL_SUPPORT_MODE_POLL_NFCB
#define RFAL_FEATURE_NFCB \
true /*!< Enable RFAL support for NFC-B (ISO14443B) \
*/
#endif /* RFAL_SUPPORT_MODE_POLL_NFCB */
#if RFAL_SUPPORT_MODE_POLL_NFCB
#define RFAL_FEATURE_NFCB true /*!< Enable RFAL support for NFC-B (ISO14443B) */
#endif /* RFAL_SUPPORT_MODE_POLL_NFCB */
#endif /* RFAL_FEATURE_NFCB */
#ifndef RFAL_FEATURE_ST25TB
#if RFAL_SUPPORT_MODE_POLL_NFCB
#define RFAL_FEATURE_ST25TB true /*!< Enable RFAL support for ST25TB */
#endif /* RFAL_SUPPORT_MODE_POLL_NFCB */
#endif /* RFAL_FEATURE_ST25TB */
#if RFAL_SUPPORT_MODE_POLL_NFCB
#define RFAL_FEATURE_ST25TB true /*!< Enable RFAL support for ST25TB */
#endif /* RFAL_SUPPORT_MODE_POLL_NFCB */
#endif /* RFAL_FEATURE_ST25TB */
#ifndef RFAL_FEATURE_NFCF
#if RFAL_SUPPORT_MODE_POLL_NFCF
#define RFAL_FEATURE_NFCF true /*!< Enable RFAL support for NFC-F (FeliCa) */
#endif /* RFAL_SUPPORT_MODE_POLL_NFCF */
#endif /* RFAL_FEATURE_NFCF */
#if RFAL_SUPPORT_MODE_POLL_NFCF
#define RFAL_FEATURE_NFCF true /*!< Enable RFAL support for NFC-F (FeliCa) */
#endif /* RFAL_SUPPORT_MODE_POLL_NFCF */
#endif /* RFAL_FEATURE_NFCF */
#ifndef RFAL_FEATURE_NFCV
#if RFAL_SUPPORT_MODE_POLL_NFCV
#define RFAL_FEATURE_NFCV \
true /*!< Enable RFAL support for NFC-V (ISO15693) \
*/
#endif /* RFAL_SUPPORT_MODE_POLL_NFCV */
#if RFAL_SUPPORT_MODE_POLL_NFCV
#define RFAL_FEATURE_NFCV true /*!< Enable RFAL support for NFC-V (ISO15693) */
#endif /* RFAL_SUPPORT_MODE_POLL_NFCV */
#endif /* RFAL_FEATURE_NFCV */
#ifndef RFAL_FEATURE_ISO_DEP
#if RFAL_SUPPORT_MODE_POLL_NFCA || RFAL_SUPPORT_MODE_POLL_NFCB || \
RFAL_SUPPORT_CE
#define RFAL_FEATURE_ISO_DEP \
true /*!< Enable RFAL support for ISO-DEP (ISO14443-4) */
#endif /* RFAL_SUPPORT_MODE_ */
#if RFAL_SUPPORT_MODE_POLL_NFCA || RFAL_SUPPORT_MODE_POLL_NFCB || RFAL_SUPPORT_CE
#define RFAL_FEATURE_ISO_DEP true /*!< Enable RFAL support for ISO-DEP (ISO14443-4) */
#endif /* RFAL_SUPPORT_MODE_ */
#endif /* RFAL_FEATURE_ISO_DEP */
#ifndef RFAL_FEATURE_ISO_DEP_POLL
#if RFAL_SUPPORT_MODE_POLL_NFCA || RFAL_SUPPORT_MODE_POLL_NFCB
#define RFAL_FEATURE_ISO_DEP_POLL \
true /*!< Enable RFAL support for Poller mode (PCD) ISO-DEP (ISO14443-4) */
#endif /* RFAL_SUPPORT_MODE_ */
#if RFAL_SUPPORT_MODE_POLL_NFCA || RFAL_SUPPORT_MODE_POLL_NFCB
#define RFAL_FEATURE_ISO_DEP_POLL true /*!< Enable RFAL support for Poller mode (PCD) ISO-DEP (ISO14443-4) */
#endif /* RFAL_SUPPORT_MODE_ */
#endif /* RFAL_FEATURE_ISO_DEP */
#ifndef RFAL_FEATURE_ISO_DEP_LISTEN
#if RFAL_SUPPORT_CE
#define RFAL_FEATURE_ISO_DEP_LISTEN \
true /*!< Enable RFAL support for Listen mode (PICC) ISO-DEP (ISO14443-4) */
#endif /* RFAL_SUPPORT_MODE_ */
#if RFAL_SUPPORT_CE
#define RFAL_FEATURE_ISO_DEP_LISTEN true /*!< Enable RFAL support for Listen mode (PICC) ISO-DEP (ISO14443-4) */
#endif /* RFAL_SUPPORT_MODE_ */
#endif /* RFAL_FEATURE_ISO_DEP */
#ifndef RFAL_FEATURE_ISO_DEP_IBLOCK_MAX_LEN
#if RFAL_FEATURE_ISO_DEP
#define RFAL_FEATURE_ISO_DEP_IBLOCK_MAX_LEN \
256U /*!< ISO-DEP I-Block max length. Please use values as defined by \
rfalIsoDepFSx */
#endif /* RFAL_FEATURE_ISO_DEP */
#if RFAL_FEATURE_ISO_DEP
#define RFAL_FEATURE_ISO_DEP_IBLOCK_MAX_LEN 256U /*!< ISO-DEP I-Block max length. Please use values as defined by rfalIsoDepFSx */
#endif /* RFAL_FEATURE_ISO_DEP */
#endif /* RFAL_FEATURE_ISO_DEP_IBLOCK_MAX_LEN */
#ifndef RFAL_FEATURE_ISO_DEP_APDU_MAX_LEN
#if RFAL_FEATURE_ISO_DEP
#define RFAL_FEATURE_ISO_DEP_APDU_MAX_LEN \
512U /*!< ISO-DEP APDU max length. \
*/
#endif /* RFAL_FEATURE_ISO_DEP */
#if RFAL_FEATURE_ISO_DEP
#define RFAL_FEATURE_ISO_DEP_APDU_MAX_LEN 512U /*!< ISO-DEP APDU max length. */
#endif /* RFAL_FEATURE_ISO_DEP */
#endif /* RFAL_FEATURE_ISO_DEP_APDU_MAX_LEN */
#ifndef RFAL_FEATURE_NFC_DEP
#if RFAL_SUPPORT_MODE_POLL_NFCA && RFAL_SUPPORT_MODE_POLL_NFCF
#define RFAL_FEATURE_NFC_DEP \
true /*!< Enable RFAL support for NFC-DEP (NFCIP1/P2P) */
#endif /* RFAL_SUPPORT_MODE_POLL_NFCA/F */
#if RFAL_SUPPORT_MODE_POLL_NFCA && RFAL_SUPPORT_MODE_POLL_NFCF
#define RFAL_FEATURE_NFC_DEP true /*!< Enable RFAL support for NFC-DEP (NFCIP1/P2P) */
#endif /* RFAL_SUPPORT_MODE_POLL_NFCA/F */
#endif /* RFAL_FEATURE_NFC_DEP */
#ifndef RFAL_FEATURE_NFC_DEP_BLOCK_MAX_LEN
#if RFAL_FEATURE_NFC_DEP
#define RFAL_FEATURE_NFC_DEP_BLOCK_MAX_LEN \
254U /*!< NFC-DEP Block/Payload length. Allowed values: 64, 128, 192, 254 */
#endif /* RFAL_FEATURE_NFC_DEP */
#if RFAL_FEATURE_NFC_DEP
#define RFAL_FEATURE_NFC_DEP_BLOCK_MAX_LEN 254U /*!< NFC-DEP Block/Payload length. Allowed values: 64, 128, 192, 254 */
#endif /* RFAL_FEATURE_NFC_DEP */
#endif /* RFAL_FEATURE_NFC_DEP_BLOCK_MAX_LEN */
#ifndef RFAL_FEATURE_NFC_DEP_PDU_MAX_LEN
#if RFAL_FEATURE_NFC_DEP
#define RFAL_FEATURE_NFC_DEP_PDU_MAX_LEN 512U /*!< NFC-DEP PDU max length. */
#endif /* RFAL_FEATURE_NFC_DEP */
#if RFAL_FEATURE_NFC_DEP
#define RFAL_FEATURE_NFC_DEP_PDU_MAX_LEN 512U /*!< NFC-DEP PDU max length. */
#endif /* RFAL_FEATURE_NFC_DEP */
#endif /* RFAL_FEATURE_NFC_DEP_PDU_MAX_LEN */
#ifndef RFAL_FEATURE_NFC_RF_BUF_LEN
#define RFAL_FEATURE_NFC_RF_BUF_LEN \
258U /*!< RF buffer length used by RFAL NFC layer */
#define RFAL_FEATURE_NFC_RF_BUF_LEN 258U /*!< RF buffer length used by RFAL NFC layer */
#endif /* RFAL_FEATURE_NFC_RF_BUF_LEN */
#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
#ifndef RFAL_FEATURE_DYNAMIC_ANALOG_CONFIG
#define RFAL_FEATURE_DYNAMIC_ANALOG_CONFIG false /*!< Dynamic Analog Configs configuration missing. Disabled by default */
#endif
#ifndef RFAL_FEATURE_DPO
#define RFAL_FEATURE_DPO false /*!< Dynamic Power Module configuration missing. Disabled by default */
#endif
#ifndef RFAL_FEATURE_DLMA
#define RFAL_FEATURE_DLMA false /*!< Dynamic LMA Module configuration missing. Disabled by default */
#endif
#ifndef RFAL_FEATURE_DYNAMIC_ANALOG_CONFIG
#define RFAL_FEATURE_DYNAMIC_ANALOG_CONFIG \
false /*!< Dynamic Analog Configs configuration missing. Disabled by default \
*/
#endif
#ifndef RFAL_FEATURE_DPO
#define RFAL_FEATURE_DPO \
false /*!< Dynamic Power Module configuration missing. Disabled by default \
*/
#endif
#ifndef RFAL_FEATURE_DLMA
#define RFAL_FEATURE_DLMA \
false /*!< Dynamic LMA Module configuration missing. Disabled by default */
#endif
/*
******************************************************************************
* RFAL OPTIONAL MACROS
******************************************************************************
*/
/*
******************************************************************************
* RFAL OPTIONAL MACROS
******************************************************************************
*/
#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 \
*/
#endif /* platformProtectST25RIrqStatus */
#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 */
#endif /* platformUnprotectST25RIrqStatus */
#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 */
#endif /* platformProtectWorker */
#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 */
#endif /* platformUnprotectWorker */
#define platformUnprotectWorker() /*!< Unprotect RFAL Worker/Task/Process from concurrent execution on multi thread platforms */
#endif /* platformUnprotectWorker */
#ifndef platformIrqST25RPinInitialize
#define platformIrqST25RPinInitialize() /*!< Initializes ST25R IRQ pin */
#endif /* platformIrqST25RPinInitialize */
#define platformIrqST25RPinInitialize() /*!< Initializes ST25R IRQ pin */
#endif /* platformIrqST25RPinInitialize */
#ifndef platformIrqST25RSetCallback
#define platformIrqST25RSetCallback(cb) /*!< Sets ST25R ISR callback */
#endif /* platformIrqST25RSetCallback */
#ifndef platformIrqST25RSetCallback
#define platformIrqST25RSetCallback( cb ) /*!< Sets ST25R ISR callback */
#endif /* platformIrqST25RSetCallback */
#ifndef platformLedsInitialize
#define platformLedsInitialize() /*!< Initializes the pins used as LEDs to \
outputs */
#endif /* platformLedsInitialize */
#ifndef platformLedsInitialize
#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 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 platformLedOn
#define platformLedOn( port, pin ) /*!< Turns the given LED On */
#endif /* platformLedOn */
#ifndef platformLedToggle
#define platformLedToggle( port, pin ) /*!< Toggles the given LED */
#endif /* platformLedToggle */
#ifndef platformLedToggle
#define platformLedToggle(port, pin) /*!< Toggles the given LED */
#endif /* platformLedToggle */
#ifndef platformGetSysTick
#define platformGetSysTick() /*!< Get System Tick ( 1 tick = 1 ms) */
#endif /* platformGetSysTick */
#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 platformTimerDestroy
#define platformTimerDestroy( timer ) /*!< Stops and released the given timer */
#endif /* platformTimerDestroy */
#ifndef platformLog
#define platformLog(...) /*!< Log method */
#endif /* platformLog */
#ifndef platformLog
#define platformLog(...) /*!< Log method */
#endif /* platformLog */
#ifndef platformAssert
#define platformAssert(exp) /*!< Asserts whether the given expression is true \
*/
#endif /* platformAssert */
#ifndef platformAssert
#define platformAssert( exp ) /*!< Asserts whether the given expression is true */
#endif /* platformAssert */
#ifndef platformErrorHandle
#define platformErrorHandle() /*!< Global error handler or trap */
#endif /* platformErrorHandle */
#ifndef platformErrorHandle
#define platformErrorHandle() /*!< Global error handler or trap */
#endif /* platformErrorHandle */
#ifdef RFAL_USE_I2C
#ifndef platformSpiTxRx
#define platformSpiTxRx(txBuf, rxBuf, len) /*!< SPI transceive */
#endif /* platformSpiTxRx */
#else /* RFAL_USE_I2C */
#ifndef platformI2CTx
#define platformI2CTx(txBuf, len, last, txOnly) /*!< I2C Transmit */
#endif /* platformI2CTx */
#ifndef platformI2CRx
#define platformI2CRx(txBuf, len) /*!< I2C Receive */
#endif /* platformI2CRx */
#ifndef platformI2CStart
#define platformI2CStart() /*!< I2C Start condition */
#endif /* platformI2CStart */
#ifndef platformI2CStop
#define platformI2CStop() /*!< I2C Stop condition */
#endif /* platformI2CStop */
#ifndef platformI2CRepeatStart
#define platformI2CRepeatStart() /*!< I2C Repeat Start */
#endif /* platformI2CRepeatStart */
#ifndef platformI2CSlaveAddrWR
#define platformI2CSlaveAddrWR( \
add) /*!< I2C Slave address for Write operation */
#endif /* platformI2CSlaveAddrWR */
#ifndef platformI2CSlaveAddrRD
#define platformI2CSlaveAddrRD( \
add) /*!< I2C Slave address for Read operation */
#endif /* platformI2CSlaveAddrRD */
#ifndef platformSpiTxRx
#define platformSpiTxRx( txBuf, rxBuf, len ) /*!< SPI transceive */
#endif /* platformSpiTxRx */
#else /* RFAL_USE_I2C */
#ifndef platformI2CTx
#define platformI2CTx( txBuf, len, last, txOnly ) /*!< I2C Transmit */
#endif /* platformI2CTx */
#ifndef platformI2CRx
#define platformI2CRx( txBuf, len ) /*!< I2C Receive */
#endif /* platformI2CRx */
#ifndef platformI2CStart
#define platformI2CStart() /*!< I2C Start condition */
#endif /* platformI2CStart */
#ifndef platformI2CStop
#define platformI2CStop() /*!< I2C Stop condition */
#endif /* platformI2CStop */
#ifndef platformI2CRepeatStart
#define platformI2CRepeatStart() /*!< I2C Repeat Start */
#endif /* platformI2CRepeatStart */
#ifndef platformI2CSlaveAddrWR
#define platformI2CSlaveAddrWR(add) /*!< I2C Slave address for Write operation */
#endif /* platformI2CSlaveAddrWR */
#ifndef platformI2CSlaveAddrRD
#define platformI2CSlaveAddrRD(add) /*!< I2C Slave address for Read operation */
#endif /* platformI2CSlaveAddrRD */
#endif /* RFAL_USE_I2C */
#endif /* RFAL_CONFIG_H */
#endif /* RFAL_CONFIG_H */
/**
* @}
*
*/
* @}
*
*/

View File

@ -1,18 +1,19 @@
/******************************************************************************
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/*
* PROJECT: ST25R391x firmware
@ -25,11 +26,10 @@
* \author Martin Zechleitner
*
* \brief Dynamic Power adjustment
*
* This module provides an interface to perform the power adjustment
* dynamically
*
*
*
* This module provides an interface to perform the power adjustment dynamically
*
*
* \addtogroup RFAL
* @{
*
@ -40,9 +40,10 @@
* \addtogroup DPO
* \brief RFAL Dynamic Power Module
* @{
*
*
*/
#ifndef RFAL_DPO_H
#define RFAL_DPO_H
@ -60,12 +61,9 @@
******************************************************************************
*/
#define RFAL_DPO_TABLE_MAX_ENTRIES 4U /*!< Max DPO table entries */
#define RFAL_DPO_TABLE_PARAM_LEN \
sizeof(rfalDpoEntry) /*!< DPO Parameter length */
#define RFAL_DPO_TABLE_SIZE_MAX \
(RFAL_DPO_TABLE_MAX_ENTRIES * \
RFAL_DPO_TABLE_PARAM_LEN) /*!< Max DPO table size */
#define RFAL_DPO_TABLE_MAX_ENTRIES 4U /*!< Max DPO table entries */
#define RFAL_DPO_TABLE_PARAM_LEN sizeof(rfalDpoEntry) /*!< DPO Parameter length */
#define RFAL_DPO_TABLE_SIZE_MAX (RFAL_DPO_TABLE_MAX_ENTRIES * RFAL_DPO_TABLE_PARAM_LEN) /*!< Max DPO table size */
/*
******************************************************************************
@ -75,10 +73,10 @@
/*! 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 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;
/*! Function pointer to methode doing the reference measurement */
typedef ReturnCode (*rfalDpoMeasureFunc)(uint8_t* res);
@ -89,135 +87,138 @@ typedef ReturnCode (*rfalDpoMeasureFunc)(uint8_t* res);
******************************************************************************
*/
/*!
/*!
*****************************************************************************
* \brief Initialize dynamic power table
*
* This function sets the internal dynamic power table to the default
*
* This function sets the internal dynamic power table to the default
* values stored in rfal_DpoTbl.h
*
*
*****************************************************************************
*/
void rfalDpoInitialize(void);
void rfalDpoInitialize( void );
/*!
/*!
*****************************************************************************
* \brief Set the measurement methode
*
*
* This function sets the measurement method used for reference measurement.
* Based on the measurement the power will then be adjusted
*
*
* \param[in] pFunc: callback of measurement function
*
*****************************************************************************
*/
void rfalDpoSetMeasureCallback(rfalDpoMeasureFunc pFunc);
void rfalDpoSetMeasureCallback( rfalDpoMeasureFunc pFunc );
/*!
/*!
*****************************************************************************
* \brief Write dynamic power table
*
* Load the dynamic power table
*
* Load the dynamic power table
*
* \param[in] powerTbl : location of power Table to be loaded
* \param[in] powerTblEntries : number of entries of the power Table to be
*loaded
*
* \param[in] powerTblEntries : number of entries of the power Table to be loaded
*
* \return RFAL_ERR_NONE : No error
* \return RFAL_ERR_PARAM : if configTbl is invalid
* \return RFAL_ERR_NOMEM : if the given Table is bigger exceeds the max size
*****************************************************************************
*/
ReturnCode rfalDpoTableWrite(const rfalDpoEntry* powerTbl,
uint8_t powerTblEntries);
ReturnCode rfalDpoTableWrite( const rfalDpoEntry* powerTbl, uint8_t powerTblEntries );
/*!
/*!
*****************************************************************************
* \brief Dynamic power table Read
*
* Read the dynamic power table
*
* Read the dynamic power table
*
* \param[out] tblBuf : location to the rfalDpoEntry[] to place the
*Table \param[in] tblBufEntries : number of entries available in tblBuf to
*place the power Table \param[out] tableEntries : returned number of entries
*actually written into tblBuf
*
* \param[out] tblBuf : location to the rfalDpoEntry[] to place the Table
* \param[in] tblBufEntries : number of entries available in tblBuf to place the power Table
* \param[out] tableEntries : returned number of entries actually written into tblBuf
*
* \return RFAL_ERR_NONE : No error
* \return RFAL_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 );
/*!
/*!
*****************************************************************************
* \brief Dynamic power adjust
*
* It measures the current output and adjusts the power accordingly to
*
* It measures the current output and adjusts the power accordingly to
* the dynamic power table.
* This method | The adjustment shall be performed when the device
* This method | The adjustment shall be performed when the device
* is already emiting RF field
*
*
* \return RFAL_ERR_NONE : No error
* \return RFAL_ERR_PARAM : if configTbl is invalid or parameters are
*invalid \return RFAL_ERR_WRONG_STATE : if the current state is valid for DPO
*Adjustment
* \return RFAL_ERR_PARAM : if configTbl is invalid or parameters are invalid
* \return RFAL_ERR_WRONG_STATE : if the current state is valid for DPO Adjustment
*****************************************************************************
*/
ReturnCode rfalDpoAdjust(void);
ReturnCode rfalDpoAdjust( void );
/*!
/*!
*****************************************************************************
* \brief Get Current Dynamic power table entry
*
*
* Return current used DPO power table entry settings
*
* \return RFAL_ERR_NONE : Current DpoEntry. This includes d_res, inc and dec
*
*
*****************************************************************************
*/
const rfalDpoEntry* rfalDpoGetCurrentTableEntry(void);
const rfalDpoEntry* rfalDpoGetCurrentTableEntry( void );
/*!
/*!
*****************************************************************************
* \brief Get Current Dynamic power table index
*
* \return the index currently used DPO table entry
* \return the index currently used DPO table entry
*
*****************************************************************************
*/
uint8_t rfalDpoGetCurrentTableIndex(void);
uint8_t rfalDpoGetCurrentTableIndex( void );
/*!
/*!
*****************************************************************************
* \brief Dynamic power set enabled state
*
*
* \param[in] enable : new active state
*
* Set state to enable or disable the Dynamic power adjustment
*
* Set state to enable or disable the Dynamic power adjustment
*
*****************************************************************************
*/
void rfalDpoSetEnabled(bool enable);
void rfalDpoSetEnabled( bool enable );
/*!
/*!
*****************************************************************************
* \brief Get the Dynamic power enabled state
*
* Get state of the Dynamic power adjustment
*
*
* Get state of the Dynamic power adjustment
*
* \return true : DPO is enabled
* \return false : DPO is disabled
*****************************************************************************
*/
bool rfalDpoIsEnabled(void);
bool rfalDpoIsEnabled( void );
#endif /* RFAL_DPO_H */
/**
* @}
*
* @}
*
* @}
*/
* @}
*
* @}
*
* @}
*/

File diff suppressed because it is too large Load Diff

View File

@ -1,18 +1,20 @@
/******************************************************************************
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/*
* PROJECT: ST25R391x firmware
@ -23,28 +25,28 @@
/*! \file rfal_nfc.h
*
* \brief RFAL NFC device
*
* This module provides the required features to behave as an NFC Poller
*
* This module provides the required features to behave as an NFC Poller
* or Listener device. It grants an easy to use interface for the following
* activities: Technology Detection, Collision Resolution, Activation,
* Data Exchange, and Deactivation
*
* This layer is influenced by (but not fully aligned with) the NFC Forum
*
* This layer is influenced by (but not fully aligned with) the NFC Forum
* specifications, in particular: Activity 2.0 and NCI 2.0
*
*
*
*
*
* \addtogroup RFAL
* @{
*
*
* \addtogroup RFAL-HL
* \brief RFAL Higher Layer
* @{
*
*
* \addtogroup NFC
* \brief RFAL NFC Device
* @{
*
*
*/
#ifndef RFAL_NFC_H
@ -55,16 +57,17 @@
* INCLUDES
******************************************************************************
*/
#include "rfal_isoDep.h"
#include "rfal_nfcDep.h"
#include "rfal_platform.h"
#include "rfal_utils.h"
#include "rfal_rf.h"
#include "rfal_nfca.h"
#include "rfal_nfcb.h"
#include "rfal_nfcf.h"
#include "rfal_nfcv.h"
#include "rfal_platform.h"
#include "rfal_rf.h"
#include "rfal_st25tb.h"
#include "rfal_utils.h"
#include "rfal_nfcDep.h"
#include "rfal_isoDep.h"
/*
******************************************************************************
@ -72,22 +75,19 @@
******************************************************************************
*/
#define RFAL_NFC_TECH_NONE 0x0000U /*!< No technology */
#define RFAL_NFC_POLL_TECH_A 0x0001U /*!< Poll NFC-A technology Flag */
#define RFAL_NFC_POLL_TECH_B 0x0002U /*!< Poll NFC-B technology Flag */
#define RFAL_NFC_POLL_TECH_F 0x0004U /*!< Poll NFC-F technology Flag */
#define RFAL_NFC_POLL_TECH_V 0x0008U /*!< Poll NFC-V technology Flag */
#define RFAL_NFC_POLL_TECH_AP2P \
0x0010U /*!< Poll AP2P technology Flag */
#define RFAL_NFC_POLL_TECH_ST25TB \
0x0020U /*!< Poll ST25TB technology Flag */
#define RFAL_NFC_POLL_TECH_PROP \
0x0040U /*!< Poll Proprietary technology Flag */
#define RFAL_NFC_LISTEN_TECH_A 0x1000U /*!< Listen NFC-A technology Flag */
#define RFAL_NFC_LISTEN_TECH_B 0x2000U /*!< Listen NFC-B technology Flag */
#define RFAL_NFC_LISTEN_TECH_F 0x4000U /*!< Listen NFC-F technology Flag */
#define RFAL_NFC_LISTEN_TECH_AP2P \
0x8000U /*!< Listen AP2P technology Flag */
#define RFAL_NFC_TECH_NONE 0x0000U /*!< No technology */
#define RFAL_NFC_POLL_TECH_A 0x0001U /*!< Poll NFC-A technology Flag */
#define RFAL_NFC_POLL_TECH_B 0x0002U /*!< Poll NFC-B technology Flag */
#define RFAL_NFC_POLL_TECH_F 0x0004U /*!< Poll NFC-F technology Flag */
#define RFAL_NFC_POLL_TECH_V 0x0008U /*!< Poll NFC-V technology Flag */
#define RFAL_NFC_POLL_TECH_AP2P 0x0010U /*!< Poll AP2P technology Flag */
#define RFAL_NFC_POLL_TECH_ST25TB 0x0020U /*!< Poll ST25TB technology Flag */
#define RFAL_NFC_POLL_TECH_PROP 0x0040U /*!< Poll Proprietary technology Flag */
#define RFAL_NFC_LISTEN_TECH_A 0x1000U /*!< Listen NFC-A technology Flag */
#define RFAL_NFC_LISTEN_TECH_B 0x2000U /*!< Listen NFC-B technology Flag */
#define RFAL_NFC_LISTEN_TECH_F 0x4000U /*!< Listen NFC-F technology Flag */
#define RFAL_NFC_LISTEN_TECH_AP2P 0x8000U /*!< Listen AP2P technology Flag */
/*
******************************************************************************
@ -96,44 +96,37 @@
*/
/*! 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) )
/*! Sets the discover parameters to its default values */
#define rfalNfcDefaultDiscParams(dp) \
if ((dp) != NULL) { \
RFAL_MEMSET((dp), 0x00, sizeof(rfalNfcDiscoverParam)); \
((dp))->compMode = RFAL_COMPLIANCE_MODE_NFC; \
((dp))->devLimit = 1U; \
((dp))->nfcfBR = RFAL_BR_212; \
((dp))->ap2pBR = RFAL_BR_424; \
((dp))->maxBR = RFAL_BR_KEEP; \
((dp))->isoDepFS = RFAL_ISODEP_FSXI_256; \
((dp))->nfcDepLR = RFAL_NFCDEP_LR_254; \
((dp))->GBLen = 0U; \
((dp))->p2pNfcaPrio = false; \
((dp))->wakeupEnabled = false; \
((dp))->wakeupConfigDefault = true; \
((dp))->wakeupPollBefore = false; \
((dp))->wakeupNPolls = 1U; \
((dp))->totalDuration = 1000U; \
((dp))->techs2Find = RFAL_NFC_TECH_NONE; \
((dp))->techs2Bail = RFAL_NFC_TECH_NONE; \
}
#define rfalNfcDefaultDiscParams( dp ) if( (dp) != NULL) { \
RFAL_MEMSET( (dp), 0x00, sizeof(rfalNfcDiscoverParam) ); \
((dp))->compMode = RFAL_COMPLIANCE_MODE_NFC; \
((dp))->devLimit = 1U; \
((dp))->nfcfBR = RFAL_BR_212; \
((dp))->ap2pBR = RFAL_BR_424; \
((dp))->maxBR = RFAL_BR_KEEP; \
((dp))->isoDepFS = RFAL_ISODEP_FSXI_256; \
((dp))->nfcDepLR = RFAL_NFCDEP_LR_254; \
((dp))->GBLen = 0U; \
((dp))->p2pNfcaPrio = false; \
((dp))->wakeupEnabled = false; \
((dp))->wakeupConfigDefault = true; \
((dp))->wakeupPollBefore = false; \
((dp))->wakeupNPolls = 1U; \
((dp))->totalDuration = 1000U; \
((dp))->techs2Find = RFAL_NFC_TECH_NONE; \
((dp))->techs2Bail = RFAL_NFC_TECH_NONE; \
}
/*
******************************************************************************
@ -147,156 +140,137 @@
******************************************************************************
*/
/*! 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;
/*! 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;
/*! 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_LISTEN_TYPE_PROP = 6, /*!< Proprietary Listen dev 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;
/*! 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_LISTEN_TYPE_PROP = 6, /*!< Proprietary Listen dev 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;
/*! Deactivation type */
typedef enum {
RFAL_NFC_DEACTIVATE_IDLE = 0, /*!< Deactivate and go to IDLE */
RFAL_NFC_DEACTIVATE_SLEEP = 1, /*!< Deactivate and go to SELECT */
RFAL_NFC_DEACTIVATE_DISCOVERY = 2 /*!< Deactivate and restart DISCOVERY */
} rfalNfcDeactivateType;
/*! 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 */
/*! 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;
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;
/*! Deactivation type */
typedef enum{
RFAL_NFC_DEACTIVATE_IDLE = 0, /*!< Deactivate and go to IDLE */
RFAL_NFC_DEACTIVATE_SLEEP = 1, /*!< Deactivate and go to SELECT */
RFAL_NFC_DEACTIVATE_DISCOVERY = 2 /*!< Deactivate and restart DISCOVERY */
}rfalNfcDeactivateType;
/*! Callbacks for Proprietary|Other Technology Activity 2.1 &
* EMVCo 3.0 9.2 */
typedef ReturnCode (*rfalNfcPropCallback)(void);
/*! Struct that holds the Proprietary NFC callbacks */
typedef struct {
rfalNfcPropCallback
rfalNfcpPollerInitialize; /*!< Prorietary NFC Initialization callback */
rfalNfcPropCallback
rfalNfcpPollerTechnologyDetection; /*!< Prorietary NFC Technoly Detection
callback */
rfalNfcPropCallback
rfalNfcpPollerStartCollisionResolution; /*!< Prorietary NFC Start
Collision Resolution callback
*/
rfalNfcPropCallback
rfalNfcpPollerGetCollisionResolutionStatus; /*!< Prorietary NFC Get
Collision Resolution status
callback */
rfalNfcPropCallback
rfalNfcpStartActivation; /*!< Prorietary NFC Start Activation callback */
rfalNfcPropCallback
rfalNfcpGetActivationStatus; /*!< Prorietary NFC Get Activation status
callback */
/*! 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;
/*! Callbacks for Proprietary|Other Technology Activity 2.1 & EMVCo 3.0 9.2 */
typedef ReturnCode (* rfalNfcPropCallback)(void);
/*! Struct that holds the Proprietary NFC callbacks */
typedef struct{
rfalNfcPropCallback rfalNfcpPollerInitialize; /*!< Prorietary NFC Initialization callback */
rfalNfcPropCallback rfalNfcpPollerTechnologyDetection; /*!< Prorietary NFC Technoly Detection callback */
rfalNfcPropCallback rfalNfcpPollerStartCollisionResolution; /*!< Prorietary NFC Start Collision Resolution callback */
rfalNfcPropCallback rfalNfcpPollerGetCollisionResolutionStatus; /*!< Prorietary NFC Get Collision Resolution status callback */
rfalNfcPropCallback rfalNfcpStartActivation; /*!< Prorietary NFC Start Activation callback */
rfalNfcPropCallback rfalNfcpGetActivationStatus; /*!< Prorietary NFC Get Activation status callback */
} rfalNfcPropCallbacks;
/*! Discovery parameters */
typedef struct {
rfalComplianceMode compMode; /*!< Compliancy mode to be used */
uint16_t techs2Find; /*!< Technologies to search for */
uint16_t techs2Bail; /*!< Bail-out after certain NFC technologies */
uint16_t totalDuration; /*!< Duration of a whole Poll + Listen cycle NCI 2.1
Table 46 */
uint8_t devLimit; /*!< Max number of devices Activity 2.1
Table 11 */
rfalBitRate maxBR; /*!< Max Bit rate to be used NCI 2.1
Table 28 */
rfalBitRate nfcfBR; /*!< Bit rate to poll for NFC-F NCI 2.1 Table 27 */
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 NCI 2.1 Table 29 */
uint8_t GBLen; /*!< Length of the General Bytes NCI 2.1
Table 29 */
rfalBitRate ap2pBR; /*!< Bit rate to poll for AP2P NCI 2.1 Table 31 */
bool p2pNfcaPrio; /*!< NFC-A P2P (true) or ISO14443-4/T4T (false) priority */
rfalNfcPropCallbacks propNfc; /*!< Proprietary Technlogy callbacks */
/*! Discovery parameters */
typedef struct{
rfalComplianceMode compMode; /*!< Compliancy mode to be used */
uint16_t techs2Find; /*!< Technologies to search for */
uint16_t techs2Bail; /*!< Bail-out after certain NFC technologies */
uint16_t totalDuration; /*!< Duration of a whole Poll + Listen cycle NCI 2.1 Table 46 */
uint8_t devLimit; /*!< Max number of devices Activity 2.1 Table 11 */
rfalBitRate maxBR; /*!< Max Bit rate to be used NCI 2.1 Table 28 */
rfalBitRate nfcfBR; /*!< Bit rate to poll for NFC-F NCI 2.1 Table 27 */
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 NCI 2.1 Table 29 */
uint8_t GBLen; /*!< Length of the General Bytes NCI 2.1 Table 29 */
rfalBitRate ap2pBR; /*!< Bit rate to poll for AP2P NCI 2.1 Table 31 */
bool p2pNfcaPrio; /*!< NFC-A P2P (true) or ISO14443-4/T4T (false) priority */
rfalNfcPropCallbacks propNfc; /*!< Proprietary Technlogy callbacks */
rfalIsoDepFSxI isoDepFS; /*!< ISO-DEP Poller announced maximum frame size Digital 2.2 Table 60 */
uint8_t nfcDepLR; /*!< NFC-DEP Poller & Listener maximum frame size Digital 2.2 Table 90 */
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 wakeupPollBefore; /*!< Flag to Poll wakeupNPolls times before entering Wake-up */
uint16_t wakeupNPolls; /*!< Number of polling cycles before|after entering Wake-up */
}rfalNfcDiscoverParam;
rfalIsoDepFSxI isoDepFS; /*!< ISO-DEP Poller announced maximum frame size
Digital 2.2 Table 60 */
uint8_t nfcDepLR; /*!< NFC-DEP Poller & Listener maximum frame size
Digital 2.2 Table 90 */
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 wakeupPollBefore; /*!< Flag to Poll wakeupNPolls times before entering
Wake-up */
uint16_t wakeupNPolls; /*!< Number of polling cycles before|after entering
Wake-up */
} 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;
/*! 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;
/*******************************************************************************/
@ -306,19 +280,20 @@ typedef union { /* PRQA S 0750 # MISRA 19.2 - Members of the union will not be
******************************************************************************
*/
/*!
/*!
*****************************************************************************
* \brief RFAL NFC Worker
*
*
* It runs the internal state machine and runs the RFAL RF worker.
*****************************************************************************
*/
void rfalNfcWorker(void);
void rfalNfcWorker( void );
/*!
/*!
*****************************************************************************
* \brief RFAL NFC Initialize
*
*
* It initializes this module and its dependencies
*
* \return RFAL_ERR_WRONG_STATE : Incorrect state for this operation
@ -326,14 +301,15 @@ void rfalNfcWorker(void);
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcInitialize(void);
ReturnCode rfalNfcInitialize( void );
/*!
*****************************************************************************
* \brief RFAL NFC Discovery
*
*
* It set the device in Discovery state.
* In discovery it will Poll and/or Listen for the technologies configured,
* In discovery it will Poll and/or Listen for the technologies configured,
* and perform Wake-up mode if configured to do so.
*
* The device list passed on disParams must not be empty.
@ -347,24 +323,26 @@ ReturnCode rfalNfcInitialize(void);
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcDiscover(const rfalNfcDiscoverParam *disParams);
ReturnCode rfalNfcDiscover( const rfalNfcDiscoverParam *disParams );
/*!
*****************************************************************************
* \brief RFAL NFC Get State
*
*
* It returns the current state
*
* \return rfalNfcState : the current state
*****************************************************************************
*/
rfalNfcState rfalNfcGetState(void);
rfalNfcState rfalNfcGetState( void );
/*!
*****************************************************************************
* \brief RFAL NFC Get Devices Found
*
* It returns the location of the device list and the number of
*
* It returns the location of the device list and the number of
* devices found.
*
* \param[out] devList : device list location
@ -376,12 +354,13 @@ rfalNfcState rfalNfcGetState(void);
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcGetDevicesFound(rfalNfcDevice **devList, uint8_t *devCnt);
ReturnCode rfalNfcGetDevicesFound( rfalNfcDevice **devList, uint8_t *devCnt );
/*!
*****************************************************************************
* \brief RFAL NFC Get Active Device
*
*
* It returns the location of the device current Active device
*
* \param[out] dev : device info location
@ -392,16 +371,17 @@ ReturnCode rfalNfcGetDevicesFound(rfalNfcDevice **devList, uint8_t *devCnt);
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcGetActiveDevice(rfalNfcDevice **dev);
ReturnCode rfalNfcGetActiveDevice( rfalNfcDevice **dev );
/*!
*****************************************************************************
* \brief RFAL NFC Select Device
*
*
* It selects the device to be activated.
* It shall be called when more than one device has been identified to
* It shall be called when more than one device has been identified to
* indicate which device shall be actived
*
*
* \param[in] devIdx : device index to be activated
*
* \return RFAL_ERR_WRONG_STATE : Incorrect state for this operation
@ -410,33 +390,31 @@ ReturnCode rfalNfcGetActiveDevice(rfalNfcDevice **dev);
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcSelect(uint8_t devIdx);
ReturnCode rfalNfcSelect( uint8_t devIdx );
/*!
*****************************************************************************
* \brief RFAL NFC Start Data Exchange
*
*
* After a device has been activated, it starts a data exchange.
* It handles automatically which interface/protocol to be used and acts
*accordingly.
* It handles automatically which interface/protocol to be used and acts accordingly.
*
* In Listen mode the first frame/data shall be sent by the Reader/Initiator
* therefore this method must be called first with txDataLen set to zero
* therefore this method must be called first with txDataLen set to zero
* to retrieve the rxData and rcvLen locations.
*
*
* \param[in] txData : data to be transmitted
* \param[in] txDataLen : size of the data to be transmitted (in bits or
*bytes - see below) \param[out] rxData : location of the received data
*after operation is completed \param[out] rvdLen : location of the length
*of the received data (in bits or bytes - see below) \param[in] fwt :
*FWT to be used in case of RF interface. If ISO-DEP or NFC-DEP interface is
*used, this will be ignored
* \param[in] txDataLen : size of the data to be transmitted (in bits or bytes - see below)
* \param[out] rxData : location of the received data after operation is completed
* \param[out] rvdLen : location of the length of the received data (in bits or bytes - see below)
* \param[in] fwt : FWT to be used in case of RF interface.
* If ISO-DEP or NFC-DEP interface is used, this will be ignored
*
* \warning In order to support a wider range of protocols, when RF interface is
*used the lengths are in number of bits (not bytes). Therefore both input
*txDataLen and output rvdLen refer to bits. If ISO-DEP or NFC-DEP interface is
*used those are expressed in number of bytes.
* \warning In order to support a wider range of protocols, when RF interface is used the lengths
* are in number of bits (not bytes). Therefore both input txDataLen and output rvdLen refer to
* bits. If ISO-DEP or NFC-DEP interface is used those are expressed in number of bytes.
*
*
* \return RFAL_ERR_WRONG_STATE : Incorrect state for this operation
@ -444,41 +422,44 @@ ReturnCode rfalNfcSelect(uint8_t devIdx);
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcDataExchangeStart(uint8_t *txData, uint16_t txDataLen,
uint8_t **rxData, uint16_t **rvdLen,
uint32_t fwt);
ReturnCode rfalNfcDataExchangeStart( uint8_t *txData, uint16_t txDataLen, uint8_t **rxData, uint16_t **rvdLen, uint32_t fwt );
/*!
/*!
*****************************************************************************
* \brief RFAL NFC Get Data Exchange Status
*
*
* Gets current Data Exchange status
*
* \return RFAL_ERR_NONE : Transceive done with no error
* \return RFAL_ERR_BUSY : Transceive ongoing
* \return RFAL_ERR_AGAIN : received one chaining block, copy received
*data and continue to call this method to retrieve the remaining blocks \return
*RFAL_ERR_XXXX : Error occurred \return RFAL_ERR_TIMEOUT : No
*response \return RFAL_ERR_FRAMING : Framing error detected \return
*RFAL_ERR_PAR : Parity error detected \return RFAL_ERR_CRC :
*CRC error detected \return RFAL_ERR_LINK_LOSS : Link Loss - External Field
*is Off \return RFAL_ERR_RF_COLLISION : Collision detected \return RFAL_ERR_IO
*: Internal error
* \return RFAL_ERR_AGAIN : received one chaining block, copy received data
* and continue to call this method to retrieve the
* remaining blocks
* \return RFAL_ERR_XXXX : Error occurred
* \return RFAL_ERR_TIMEOUT : No response
* \return RFAL_ERR_FRAMING : Framing error detected
* \return RFAL_ERR_PAR : Parity error detected
* \return RFAL_ERR_CRC : CRC error detected
* \return RFAL_ERR_LINK_LOSS : Link Loss - External Field is Off
* \return RFAL_ERR_RF_COLLISION : Collision detected
* \return RFAL_ERR_IO : Internal error
*****************************************************************************
*/
ReturnCode rfalNfcDataExchangeGetStatus(void);
ReturnCode rfalNfcDataExchangeGetStatus( void );
/*!
/*!
*****************************************************************************
* \brief RFAL NFC Deactivate
*
* It triggers the deactivation procedure to terminate communications with
* remote device.
*
* It triggers the deactivation procedure to terminate communications with
* remote device.
* In case the deactivation type is RFAL_NFC_DEACTIVATE_SLEEP the field is
* kept On and device selection shall follow. Otherwise the field will
* kept On and device selection shall follow. Otherwise the field will
* be turned Off.
*
* \warning In case the deactivation type is RFAL_NFC_DEACTIVATE_IDLE the
* \warning In case the deactivation type is RFAL_NFC_DEACTIVATE_IDLE the
* deactivation procedure is executed immediately and in a blocking manner
*
* \param[in] deactType : Type of deactivation to be performed
@ -487,14 +468,15 @@ ReturnCode rfalNfcDataExchangeGetStatus(void);
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcDeactivate(rfalNfcDeactivateType deactType);
ReturnCode rfalNfcDeactivate( rfalNfcDeactivateType deactType );
#endif /* RFAL_NFC_H */
/**
* @}
*
* @}
*
* @}
*/
* @}
*
* @}
*
* @}
*/

File diff suppressed because it is too large Load Diff

View File

@ -1,18 +1,19 @@
/******************************************************************************
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/*
* PROJECT: ST25R391x firmware
@ -25,18 +26,18 @@
* \author Gustavo Patricio
*
* \brief Provides several NFC-A convenience methods and definitions
*
* It provides a Poller (ISO14443A PCD) interface as well as
*
* It provides a Poller (ISO14443A PCD) interface as well as
* some NFC-A Listener (ISO14443A PICC) helpers.
*
* The definitions and helper methods provided by this module are only
* up to ISO14443-3 layer
*
*
*
*
* An usage example is provided here: \ref exampleRfalNfca.c
* \example exampleRfalNfca.c
*
*
*
*
* \addtogroup RFAL
* @{
*
@ -47,9 +48,10 @@
* \addtogroup NFC-A
* \brief RFAL NFC-A Module
* @{
*
*
*/
#ifndef RFAL_NFCA_H
#define RFAL_NFCA_H
@ -59,9 +61,9 @@
******************************************************************************
*/
#include "rfal_platform.h"
#include "rfal_utils.h"
#include "rfal_rf.h"
#include "rfal_t1t.h"
#include "rfal_utils.h"
/*
******************************************************************************
@ -69,38 +71,25 @@
******************************************************************************
*/
#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_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_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
/*! 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
/*
******************************************************************************
* GLOBAL MACROS
@ -108,34 +97,22 @@
*/
/*! 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)
/*! 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 )
/*
******************************************************************************
@ -145,61 +122,67 @@
/*! 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 */
#endif /* RFAL_FEATURE_T1T */
bool isSleep; /*!< Device sleeping flag */
rfalT1TRidRes ridRes; /*!< RID_RES */
#endif /* RFAL_FEATURE_T1T */
bool isSleep; /*!< Device sleeping flag */
} rfalNfcaListenDevice;
/*
@ -208,55 +191,55 @@ typedef struct {
******************************************************************************
*/
/*!
/*!
*****************************************************************************
* \brief Initialize NFC-A Poller mode
*
* This methods configures RFAL RF layer to perform as a
*
* This methods configures RFAL RF layer to perform as a
* NFC-A Poller/RW (ISO14443A PCD) including all default timings and bit rate
* to 106 kbps
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or mode not set
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcaPollerInitialize(void);
ReturnCode rfalNfcaPollerInitialize( void );
/*!
/*!
*****************************************************************************
* \brief NFC-A Poller Check Presence
*
*
* This method checks if a NFC-A Listen device (PICC) is present on the field
* by sending an ALL_REQ (WUPA) or SENS_REQ (REQA)
*
*
* \param[in] cmd : Indicate if to send an ALL_REQ or a SENS_REQ
* \param[out] sensRes : If received, the SENS_RES
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_RF_COLLISION : Collision detected one or more device in the
*field \return RFAL_ERR_PAR : Parity error detected, one or more
*device in the field \return RFAL_ERR_CRC : CRC error detected, one or
*more device in the field \return RFAL_ERR_FRAMING : Framing error
*detected, one or more device in the field \return RFAL_ERR_PROTO :
*Protocol error detected, one or more device in the field \return
*RFAL_ERR_TIMEOUT : Timeout error, no listener device detected \return
*RFAL_ERR_NONE : No error, one or more device in the field
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_RF_COLLISION : Collision detected one or more device in the field
* \return RFAL_ERR_PAR : Parity error detected, one or more device in the field
* \return RFAL_ERR_CRC : CRC error detected, one or more device in the field
* \return RFAL_ERR_FRAMING : Framing error detected, one or more device in the field
* \return RFAL_ERR_PROTO : Protocol error detected, one or more device in the field
* \return RFAL_ERR_TIMEOUT : Timeout error, no listener device detected
* \return RFAL_ERR_NONE : No error, one or more device in the field
*****************************************************************************
*/
ReturnCode rfalNfcaPollerCheckPresence(rfal14443AShortFrameCmd cmd,
rfalNfcaSensRes *sensRes);
ReturnCode rfalNfcaPollerCheckPresence( rfal14443AShortFrameCmd cmd, rfalNfcaSensRes *sensRes );
/*!
/*!
*****************************************************************************
* \brief NFC-A Poller Select
*
* This method selects a NFC-A Listener device (PICC)
*
*
* This method selects a NFC-A Listener device (PICC)
*
* \param[in] nfcid1 : Listener device NFCID1 to be selected
* \param[in] nfcidLen : Length of the NFCID1 to be selected
* \param[in] nfcidLen : Length of the NFCID1 to be selected
* \param[out] selRes : pointer to place the SEL_RES
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
@ -270,17 +253,17 @@ ReturnCode rfalNfcaPollerCheckPresence(rfal14443AShortFrameCmd cmd,
* \return RFAL_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 );
/*!
/*!
*****************************************************************************
* \brief NFC-A Poller Start Select
*
* This method starts the selection of a NFC-A Listener device (PICC)
*
*
* This method starts the selection of a NFC-A Listener device (PICC)
*
* \param[in] nfcid1 : Listener device NFCID1 to be selected
* \param[in] nfcidLen : Length of the NFCID1 to be selected
* \param[in] nfcidLen : Length of the NFCID1 to be selected
* \param[out] selRes : pointer to place the SEL_RES
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
@ -294,15 +277,15 @@ ReturnCode rfalNfcaPollerSelect(const uint8_t *nfcid1, uint8_t nfcidLen,
* \return RFAL_ERR_NONE : No error, SEL_RES received
*****************************************************************************
*/
ReturnCode rfalNfcaPollerStartSelect(const uint8_t *nfcid1, uint8_t nfcidLen,
rfalNfcaSelRes *selRes);
ReturnCode rfalNfcaPollerStartSelect( const uint8_t *nfcid1, uint8_t nfcidLen, rfalNfcaSelRes *selRes );
/*!
/*!
*****************************************************************************
* \brief NFC-A Poller Get Select Status
*
*
* This method gets the selection status
*
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
@ -315,97 +298,101 @@ ReturnCode rfalNfcaPollerStartSelect(const uint8_t *nfcid1, uint8_t nfcidLen,
* \return RFAL_ERR_NONE : No error, SEL_RES received
*****************************************************************************
*/
ReturnCode rfalNfcaPollerGetSelectStatus(void);
ReturnCode rfalNfcaPollerGetSelectStatus( void );
/*!
/*!
*****************************************************************************
* \brief NFC-A Poller Sleep
*
*
* This method sends a SLP_REQ (HLTA)
* No response is expected afterwards Digital 1.1 6.9.2.1
*
* No response is expected afterwards Digital 1.1 6.9.2.1
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcaPollerSleep(void);
ReturnCode rfalNfcaPollerSleep( void );
/*!
*****************************************************************************
* \brief NFC-A Poller Start Sleep
*
*
* This method sends a SLP_REQ (HLTA)
* No response is expected afterwards Digital 1.1 6.9.2.1
*
* No response is expected afterwards Digital 1.1 6.9.2.1
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcaPollerStartSleep(void);
ReturnCode rfalNfcaPollerStartSleep( void );
/*!
/*!
*****************************************************************************
* \brief NFC-A Poller Get Sleep Status
*
*
* Returns the Sleep status
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcaPollerGetSleepStatus(void);
ReturnCode rfalNfcaPollerGetSleepStatus( void );
/*!
*****************************************************************************
* \brief NFC-A Technology Detection
*
*
* This method performs NFC-A Technology Detection as defined in the spec
* given in the compliance mode
*
*
* \param[in] compMode : compliance mode to be performed
* \param[out] sensRes : location to store the SENS_RES, if received
*
* When compMode is set to ISO compliance a SLP_REQ (HLTA) is not sent
* after detection. When set to EMV a ALL_REQ (WUPA) is sent instead of
*
* When compMode is set to ISO compliance a SLP_REQ (HLTA) is not sent
* after detection. When set to EMV a ALL_REQ (WUPA) is sent instead of
* a SENS_REQ (REQA)
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_NONE : No error, one or more device in the field
*****************************************************************************
*/
ReturnCode rfalNfcaPollerTechnologyDetection(rfalComplianceMode compMode,
rfalNfcaSensRes *sensRes);
ReturnCode rfalNfcaPollerTechnologyDetection( rfalComplianceMode compMode, rfalNfcaSensRes *sensRes );
/*!
/*!
*****************************************************************************
* \brief NFC-A Start Technology Detection
*
*
* This method starts NFC-A Technology Detection as defined in the spec
* given in the compliance mode
*
*
* \param[in] compMode : compliance mode to be performed
* \param[out] sensRes : location to store the SENS_RES, if received
*
* When compMode is set to ISO compliance a SLP_REQ (HLTA) is not sent
* after detection. When set to EMV a ALL_REQ (WUPA) is sent instead of
*
* When compMode is set to ISO compliance a SLP_REQ (HLTA) is not sent
* after detection. When set to EMV a ALL_REQ (WUPA) is sent instead of
* a SENS_REQ (REQA)
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_NONE : No error, one or more device in the field
*****************************************************************************
*/
ReturnCode rfalNfcaPollerStartTechnologyDetection(rfalComplianceMode compMode,
rfalNfcaSensRes *sensRes);
ReturnCode rfalNfcaPollerStartTechnologyDetection( rfalComplianceMode compMode, rfalNfcaSensRes *sensRes );
/*!
*****************************************************************************
@ -419,28 +406,27 @@ ReturnCode rfalNfcaPollerStartTechnologyDetection(rfalComplianceMode compMode,
* \return RFAL_ERR_NONE : No error, one or more device in the field
*****************************************************************************
*/
ReturnCode rfalNfcaPollerGetTechnologyDetectionStatus(void);
ReturnCode rfalNfcaPollerGetTechnologyDetectionStatus( void );
/*!
/*!
*****************************************************************************
* \brief NFC-A Poller Collision Resolution
*
* Collision resolution for one NFC-A Listener device/card (PICC) as
*
* Collision resolution for one NFC-A Listener device/card (PICC) as
* defined in Activity 2.1 9.3.4
*
* This method executes anti collision loop and select the device with higher
*NFCID1
*
* When devLimit = 0 it is configured to perform collision detection only. Once
*a collision is detected the collision resolution is aborted immidiatly. If
*only one device is found with no collisions, it will properly resolved.
*
* This method executes anti collision loop and select the device with higher NFCID1
*
* When devLimit = 0 it is configured to perform collision detection only. Once a collision
* is detected the collision resolution is aborted immidiatly. If only one device is found
* with no collisions, it will properly resolved.
*
* \param[in] devLimit : device limit value (CON_DEVICES_LIMIT)
* \param[out] collPending : pointer to collision pending flag (INT_COLL_PEND)
* \param[out] selRes : location to store the last Select Response from
*listener device (PICC) \param[out] nfcId1 : location to store the NFCID1
*(UID), ensure RFAL_NFCA_CASCADE_3_UID_LEN \param[out] nfcId1Len : pointer to
*length of NFCID1 (UID)
* \param[out] selRes : location to store the last Select Response from listener device (PICC)
* \param[out] nfcId1 : location to store the NFCID1 (UID), ensure RFAL_NFCA_CASCADE_3_UID_LEN
* \param[out] nfcId1Len : pointer to length of NFCID1 (UID)
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or mode not set
* \return RFAL_ERR_PARAM : Invalid parameters
@ -450,16 +436,13 @@ ReturnCode rfalNfcaPollerGetTechnologyDetectionStatus(void);
* \return RFAL_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 );
/*!
/*!
*****************************************************************************
* \brief NFC-A Poller Full Collision Resolution
*
*
* Performs a full Collision resolution as defined in Activity 2.1 9.3.4
*
* \param[in] compMode : compliance mode to be performed
@ -469,13 +452,13 @@ ReturnCode rfalNfcaPollerSingleCollisionResolution(uint8_t devLimit,
*
* When compMode is set to ISO compliance it assumes that the device is
* not sleeping and therefore no ALL_REQ (WUPA) is sent at the beginning.
* When compMode is set to NFC compliance an additional ALL_REQ (WUPA) is sent
* When compMode is set to NFC compliance an additional ALL_REQ (WUPA) is sent
* at the beginning.
*
*
* When devLimit = 0 it is configured to perform collision detection only. Once
*a collision is detected the collision resolution is aborted immidiatly. If
*only one device is found with no collisions, it will properly resolved.
*
*
* When devLimit = 0 it is configured to perform collision detection only. Once a collision
* is detected the collision resolution is aborted immidiatly. If only one device is found
* with no collisions, it will properly resolved.
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or mode not set
@ -484,25 +467,24 @@ ReturnCode rfalNfcaPollerSingleCollisionResolution(uint8_t devLimit,
* \return RFAL_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 );
/*!
/*!
*****************************************************************************
* \brief NFC-A Poller Full Collision Resolution with Sleep
*
* Performs a full Collision resolution similar to
*rfalNfcaPollerFullCollisionResolution but an additional SLP_REQ (HLTA) ->
*SENS_RES (REQA) is sent regardless if there was a collision. This proprietary
*behaviour ensures proper activation of certain devices that suffer from
*influence of Type B commands as foreseen in ISO14443-3 5.2.3 or were somehow
*
* Performs a full Collision resolution similar to rfalNfcaPollerFullCollisionResolution
* but an additional SLP_REQ (HLTA) -> SENS_RES (REQA) is sent regardless if there
* was a collision.
* This proprietary behaviour ensures proper activation of certain devices that suffer
* from influence of Type B commands as foreseen in ISO14443-3 5.2.3 or were somehow
* not detected by the first round of collision resolution
*
* \param[in] devLimit : device limit value, and size nfcaDevList
* \param[out] nfcaDevList : NFC-A listener device info
* \param[out] devCnt : Devices found counter
*
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or mode not set
* \return RFAL_ERR_PARAM : Invalid parameters
@ -510,15 +492,15 @@ ReturnCode rfalNfcaPollerFullCollisionResolution(
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcaPollerSleepFullCollisionResolution(
uint8_t devLimit, rfalNfcaListenDevice *nfcaDevList, uint8_t *devCnt);
ReturnCode rfalNfcaPollerSleepFullCollisionResolution( uint8_t devLimit, rfalNfcaListenDevice *nfcaDevList, uint8_t *devCnt );
/*!
*****************************************************************************
* \brief NFC-A Poller Start Full Collision Resolution
*
* This method starts the full Collision resolution as defined
* in Activity 1.0 or 1.1 9.3.4
*
* This method starts the full Collision resolution as defined
* in Activity 1.0 or 1.1 9.3.4
*
* \param[in] compMode : compliance mode to be performed
* \param[in] devLimit : device limit value, and size nfcaDevList
@ -527,13 +509,13 @@ ReturnCode rfalNfcaPollerSleepFullCollisionResolution(
*
* When compMode is set to ISO compliance it assumes that the device is
* not sleeping and therefore no ALL_REQ (WUPA) is sent at the beginning.
* When compMode is set to NFC compliance an additional ALL_REQ (WUPA) is sent
*at the beginning.
*
*
* When devLimit = 0 it is configured to perform collision detection only. Once
*a collision is detected the collision resolution is aborted immidiatly. If
*only one device is found with no collisions, it will properly resolved.
* When compMode is set to NFC compliance an additional ALL_REQ (WUPA) is sent at
* the beginning.
*
*
* When devLimit = 0 it is configured to perform collision detection only. Once a collision
* is detected the collision resolution is aborted immidiatly. If only one device is found
* with no collisions, it will properly resolved.
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or mode not set
@ -542,9 +524,8 @@ ReturnCode rfalNfcaPollerSleepFullCollisionResolution(
* \return RFAL_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 );
/*!
*****************************************************************************
@ -564,28 +545,30 @@ ReturnCode rfalNfcaPollerStartFullCollisionResolution(
* \return RFAL_ERR_NONE : No error, activation successful
*****************************************************************************
*/
ReturnCode rfalNfcaPollerGetFullCollisionResolutionStatus(void);
ReturnCode rfalNfcaPollerGetFullCollisionResolutionStatus( void );
/*!
*****************************************************************************
* \brief NFC-A Listener is SLP_REQ
*
* \brief NFC-A Listener is SLP_REQ
*
* Checks if the given buffer contains valid NFC-A SLP_REQ (HALT)
*
*
* \param[in] buf: buffer containing data
* \param[in] bufLen: length of the data in buffer to be checked
*
*
* \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 */
/**
* @}
*
* @}
*
* @}
*/
* @}
*
* @}
*
* @}
*/

View File

@ -1,18 +1,19 @@
/******************************************************************************
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/*
* PROJECT: ST25R391x firmware
@ -24,15 +25,15 @@
*
* \author Gustavo Patricio
*
* \brief Implementation of NFC-B (ISO14443B) helpers
*
* It provides a NFC-B Poller (ISO14443B PCD) interface and
* \brief Implementation of NFC-B (ISO14443B) helpers
*
* It provides a NFC-B Poller (ISO14443B PCD) interface and
* also provides some NFC-B Listener (ISO14443B PICC) helpers
*
* The definitions and helpers methods provided by this module are only
* up to ISO14443-3 layer (excluding ATTRIB)
*
*
*
*
* \addtogroup RFAL
* @{
*
@ -43,9 +44,10 @@
* \addtogroup NFC-B
* \brief RFAL NFC-B Module
* @{
*
*
*/
#ifndef RFAL_NFCB_H
#define RFAL_NFCB_H
@ -55,8 +57,8 @@
******************************************************************************
*/
#include "rfal_platform.h"
#include "rfal_rf.h"
#include "rfal_utils.h"
#include "rfal_rf.h"
/*
******************************************************************************
@ -64,64 +66,37 @@
******************************************************************************
*/
#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 */
/*
******************************************************************************
@ -130,15 +105,10 @@
*/
/*! 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 )
/*
******************************************************************************
@ -147,53 +117,60 @@
*/
/*! 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;
/*! 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;
/*! 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;
/*
******************************************************************************
@ -201,83 +178,83 @@ typedef struct {
******************************************************************************
*/
/*!
/*!
*****************************************************************************
* \brief Initialize NFC-B Poller mode
*
* This methods configures RFAL RF layer to perform as a
*
* This methods configures RFAL RF layer to perform as a
* NFC-B Poller/RW (ISO14443B PCD) including all default timings
*
*
* It sets NFC-B parameters (AFI, PARAM) to default values
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or mode not set
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcbPollerInitialize(void);
ReturnCode rfalNfcbPollerInitialize( void );
/*!
/*!
*****************************************************************************
* \brief Set NFC-B Poller parameters
*
* This methods configures RFAL RF layer to perform as a
*
* This methods configures RFAL RF layer to perform as a
* NFCA Poller/RW (ISO14443A PCD) including all default timings
*
* Additionally configures NFC-B specific parameters to be used on the
*
* Additionally configures NFC-B specific parameters to be used on the
* following communications
*
*
* \param[in] AFI : Application Family Identifier to be used
* \param[in] PARAM : PARAM to be used, it announces whether Advanced
* Features or Extended SENSB_RES is supported
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or mode not set
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcbPollerInitializeWithParams(uint8_t AFI, uint8_t PARAM);
ReturnCode rfalNfcbPollerInitializeWithParams( uint8_t AFI, uint8_t PARAM );
/*!
/*!
*****************************************************************************
* \brief NFC-B Poller Check Presence
*
*
* This method checks if a NFC-B Listen device (PICC) is present on the field
* by sending an ALLB_REQ (WUPB) or SENSB_REQ (REQB)
*
*
* \param[in] cmd : Indicate if to send an ALLB_REQ or a SENSB_REQ
* \param[in] slots : The number of slots to be announced
* \param[out] sensbRes : If received, the SENSB_RES
* \param[out] sensbResLen : If received, the SENSB_RES length
*
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_TIMEOUT : Timeout error, no listener device detected
* \return RFAL_ERR_RF_COLLISION : Collision detected one or more device in the
*field \return RFAL_ERR_PAR : Parity error detected, one or more
*device in the field \return RFAL_ERR_CRC : CRC error detected, one or
*more device in the field \return RFAL_ERR_FRAMING : Framing error
*detected, one or more device in the field \return RFAL_ERR_PROTO :
*Protocol error detected, invalid SENSB_RES received \return RFAL_ERR_NONE : No
*error, SENSB_RES received
* \return RFAL_ERR_RF_COLLISION : Collision detected one or more device in the field
* \return RFAL_ERR_PAR : Parity error detected, one or more device in the field
* \return RFAL_ERR_CRC : CRC error detected, one or more device in the field
* \return RFAL_ERR_FRAMING : Framing error detected, one or more device in the field
* \return RFAL_ERR_PROTO : Protocol error detected, invalid SENSB_RES received
* \return RFAL_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 );
/*!
/*!
*****************************************************************************
* \brief NFC-B Poller Start Check Presence
*
* This method starts check for a NFC-B Listen device (PICC) presence on the
*field by sending an ALLB_REQ (WUPB) or SENSB_REQ (REQB)
*
*
* This method starts check for a NFC-B Listen device (PICC) presence on the field
* by sending an ALLB_REQ (WUPB) or SENSB_REQ (REQB)
*
* \param[in] cmd : Indicate if to send an ALL_REQ or a SENS_REQ
* \param[in] slots : The number of slots to be announced
* \param[out] sensbRes : If received, the SENSB_RES
* \param[out] sensbResLen : If received, the SENSB_RES length
*
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
@ -285,57 +262,56 @@ ReturnCode rfalNfcbPollerCheckPresence(rfalNfcbSensCmd cmd, rfalNfcbSlots slots,
* \return RFAL_ERR_NONE : No error, SENSB_RES received
*****************************************************************************
*/
ReturnCode rfalNfcbPollerStartCheckPresence(rfalNfcbSensCmd cmd,
rfalNfcbSlots slots,
rfalNfcbSensbRes *sensbRes,
uint8_t *sensbResLen);
ReturnCode rfalNfcbPollerStartCheckPresence( rfalNfcbSensCmd cmd, rfalNfcbSlots slots, rfalNfcbSensbRes *sensbRes, uint8_t *sensbResLen );
/*!
/*!
*****************************************************************************
* \brief NFC-B Poller Get Check Presence Status
*
*
* This method get the presence check status
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_TIMEOUT : Timeout error, no listener device detected
* \return RFAL_ERR_RF_COLLISION : Collision detected one or more device in the
*field \return RFAL_ERR_PAR : Parity error detected, one or more
*device in the field \return RFAL_ERR_CRC : CRC error detected, one or
*more device in the field \return RFAL_ERR_FRAMING : Framing error
*detected, one or more device in the field \return RFAL_ERR_PROTO :
*Protocol error detected, invalid SENSB_RES received \return RFAL_ERR_NONE : No
*error, SENSB_RES received
* \return RFAL_ERR_RF_COLLISION : Collision detected one or more device in the field
* \return RFAL_ERR_PAR : Parity error detected, one or more device in the field
* \return RFAL_ERR_CRC : CRC error detected, one or more device in the field
* \return RFAL_ERR_FRAMING : Framing error detected, one or more device in the field
* \return RFAL_ERR_PROTO : Protocol error detected, invalid SENSB_RES received
* \return RFAL_ERR_NONE : No error, SENSB_RES received
*****************************************************************************
*/
ReturnCode rfalNfcbPollerGetCheckPresenceStatus(void);
ReturnCode rfalNfcbPollerGetCheckPresenceStatus( void );
/*!
/*!
*****************************************************************************
* \brief NFC-B Poller Sleep
*
* This function is used to send the SLPB_REQ (HLTB) command to put the PICC
*with the given NFCID0 to state HALT so that they do not reply to further
*SENSB_REQ commands (only to ALLB_REQ)
*
*
* This function is used to send the SLPB_REQ (HLTB) command to put the PICC with
* the given NFCID0 to state HALT so that they do not reply to further SENSB_REQ
* commands (only to ALLB_REQ)
*
* \param[in] nfcid0 : NFCID of the device to be put to Sleep
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcbPollerSleep(const uint8_t *nfcid0);
ReturnCode rfalNfcbPollerSleep( const uint8_t* nfcid0 );
/*!
/*!
*****************************************************************************
* \brief NFC-B Poller Slot Marker
*
* This method sends a NFC-B Slot marker frame
*
* \param[in] slotCode : Slot Code [1-15]
*
* This method sends a NFC-B Slot marker frame
*
* \param[in] slotCode : Slot Code [1-15]
* \param[out] sensbRes : If received, the SENSB_RES
* \param[out] sensbResLen : If received, the SENSB_RES length
*
@ -350,17 +326,16 @@ ReturnCode rfalNfcbPollerSleep(const uint8_t *nfcid0);
* \return RFAL_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 );
/*!
/*!
*****************************************************************************
* \brief NFC-B Poller Start Slot Marker
*
* This method starts a NFC-B Slot marker
*
* \param[in] slotCode : Slot Code [1-15]
*
* This method starts a NFC-B Slot marker
*
* \param[in] slotCode : Slot Code [1-15]
* \param[out] sensbRes : If received, the SENSB_RES
* \param[out] sensbResLen : If received, the SENSB_RES length
*
@ -370,16 +345,15 @@ ReturnCode rfalNfcbPollerSlotMarker(uint8_t slotCode,
* \return RFAL_ERR_NONE : No error, SEL_RES received
*****************************************************************************
*/
ReturnCode rfalNfcbPollerStartSlotMarker(uint8_t slotCode,
rfalNfcbSensbRes *sensbRes,
uint8_t *sensbResLen);
ReturnCode rfalNfcbPollerStartSlotMarker( uint8_t slotCode, rfalNfcbSensbRes *sensbRes, uint8_t *sensbResLen );
/*!
/*!
*****************************************************************************
* \brief NFC-B Poller Get Slot Marker Status
*
* This method gets the status of the NFC-B Slot marker
*
*
* This method gets the status of the NFC-B Slot marker
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
@ -392,75 +366,73 @@ ReturnCode rfalNfcbPollerStartSlotMarker(uint8_t slotCode,
* \return RFAL_ERR_NONE : No error, SEL_RES received
*****************************************************************************
*/
ReturnCode rfalNfcbPollerGetSlotMarkerStatus(void);
ReturnCode rfalNfcbPollerGetSlotMarkerStatus( void );
/*!
/*!
*****************************************************************************
* \brief NFC-B Technology Detection
*
*
* This method performs NFC-B Technology Detection as defined in the spec
* given in the compliance mode
*
*
* \param[in] compMode : compliance mode to be performed
* \param[out] sensbRes : location to store the SENSB_RES, if received
* \param[out] sensbResLen : length of the SENSB_RES, if received
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_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 );
/*!
/*!
*****************************************************************************
* \brief NFC-B Start Technology Detection
*
*
* This method starts the NFC-B Technology Detection as defined in the spec
* given in the compliance mode
*
*
* \param[in] compMode : compliance mode to be performed
* \param[out] sensbRes : location to store the SENSB_RES, if received
* \param[out] sensbResLen : length of the SENSB_RES, if received
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_NONE : No error, one or more device in the field
*****************************************************************************
*/
ReturnCode rfalNfcbPollerStartTechnologyDetection(rfalComplianceMode compMode,
rfalNfcbSensbRes *sensbRes,
uint8_t *sensbResLen);
ReturnCode rfalNfcbPollerStartTechnologyDetection( rfalComplianceMode compMode, rfalNfcbSensbRes *sensbRes, uint8_t *sensbResLen );
/*!
/*!
*****************************************************************************
* \brief NFC-B Get Technology Detection Status
*
*
* This method gets the NFC-B Technology Detection status
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_NONE : No error, one or more device in the field
*****************************************************************************
*/
ReturnCode rfalNfcbPollerGetTechnologyDetectionStatus(void);
ReturnCode rfalNfcbPollerGetTechnologyDetectionStatus( void );
/*!
/*!
*****************************************************************************
* \brief NFC-B Poller Collision Resolution
*
* NFC-B Collision resolution Listener device/card (PICC) as
*
* NFC-B Collision resolution Listener device/card (PICC) as
* defined in Activity 1.1 9.3.5
*
* This function is used to perform collision resolution for detection in case
* of multiple NFC Forum Devices with Technology B detected.
* Target with valid SENSB_RES will be stored in nfcbDevList and devCnt
*incremented.
*
* This function is used to perform collision resolution for detection in case
* of multiple NFC Forum Devices with Technology B detected.
* Target with valid SENSB_RES will be stored in nfcbDevList and devCnt incremented.
*
* \param[in] compMode : compliance mode to be performed
* \param[in] devLimit : device limit value, and size nfcbDevList
@ -474,38 +446,33 @@ ReturnCode rfalNfcbPollerGetTechnologyDetectionStatus(void);
* \return RFAL_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 );
/*!
/*!
*****************************************************************************
* \brief NFC-B Poller Collision Resolution Slotted
*
* NFC-B Collision resolution Listener device/card (PICC). The sequence can
*
* NFC-B Collision resolution Listener device/card (PICC). The sequence can
* be configured to be according to NFC Forum Activity 1.1 9.3.5, ISO10373
* or EMVCo
*
* This function is used to perform collision resolution for detection in case
* of multiple NFC Forum Devices with Technology B are detected.
* Target with valid SENSB_RES will be stored in nfcbDevList and devCnt
*incremented.
*
* This method provides the means to perform a collision resolution loop with
*specific initial and end number of slots. This allows to user to start the
*loop already with greater number of slots, and or limit the end number of
*slots. At the end a flag indicating whether there were collisions pending is
*returned.
*
* If RFAL_COMPLIANCE_MODE_ISO is used \a initSlots must be set to
*RFAL_NFCB_SLOT_NUM_1
*
* or EMVCo
*
* This function is used to perform collision resolution for detection in case
* of multiple NFC Forum Devices with Technology B are detected.
* Target with valid SENSB_RES will be stored in nfcbDevList and devCnt incremented.
*
* This method provides the means to perform a collision resolution loop with specific
* initial and end number of slots. This allows to user to start the loop already with
* greater number of slots, and or limit the end number of slots. At the end a flag
* indicating whether there were collisions pending is returned.
*
* If RFAL_COMPLIANCE_MODE_ISO is used \a initSlots must be set to RFAL_NFCB_SLOT_NUM_1
*
*
* \param[in] compMode : compliance mode to be performed
* \param[in] devLimit : device limit value, and size nfcbDevList
* \param[in] initSlots : number of slots to open initially
* \param[in] endSlots : number of slots when to stop collision resolution
* \param[in] initSlots : number of slots to open initially
* \param[in] endSlots : number of slots when to stop collision resolution
* \param[out] nfcbDevList : NFC-B listener device info
* \param[out] devCnt : devices found counter
* \param[out] colPending : flag indicating whether collision are still pending
@ -517,21 +484,19 @@ ReturnCode rfalNfcbPollerCollisionResolution(rfalComplianceMode compMode,
* \return RFAL_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 );
/*!
*****************************************************************************
* \brief NFC-B Poller Start Collision Resolution
*
* It starts the NFC-B Collision resolution Listener device/card (PICC) as
*
* It starts the NFC-B Collision resolution Listener device/card (PICC) as
* defined in Activity 1.1 9.3.5
*
* This function is used to trigger the collision resolution for detection in
*case of multiple NFC Forum Devices with Technology B detected. Target with
*valid SENSB_RES will be stored in nfcbDevList and devCnt incremented.
*
* This function is used to trigger the collision resolution for detection in case
* of multiple NFC Forum Devices with Technology B detected.
* Target with valid SENSB_RES will be stored in nfcbDevList and devCnt incremented.
*
* \param[in] compMode : compliance mode to be performed
* \param[in] devLimit : device limit value, and size nfcbDevList
@ -545,36 +510,33 @@ ReturnCode rfalNfcbPollerSlottedCollisionResolution(
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcbPollerStartCollisionResolution(
rfalComplianceMode compMode, uint8_t devLimit,
rfalNfcbListenDevice *nfcbDevList, uint8_t *devCnt);
ReturnCode rfalNfcbPollerStartCollisionResolution( rfalComplianceMode compMode, uint8_t devLimit, rfalNfcbListenDevice *nfcbDevList, uint8_t *devCnt );
/*!
/*!
*****************************************************************************
* \brief NFC-B Poller Start Collision Resolution Slotted
*
* Starts NFC-B Collision resolution Listener device/card (PICC). The sequence
*can be configured to be according to NFC Forum Activity 1.1 9.3.5, ISO10373
* or EMVCo
*
* This function is used to trigger the collision resolution for detection in
*case of multiple NFC Forum Devices with Technology B are detected. Target with
*valid SENSB_RES will be stored in nfcbDevList and devCnt incremented.
*
* This method provides the means to perform a collision resolution loop with
*specific initial and end number of slots. This allows to user to start the
*loop already with greater number of slots, and or limit the end number of
*slots. At the end a flag indicating whether there were collisions pending is
*returned.
*
* If RFAL_COMPLIANCE_MODE_ISO is used \a initSlots must be set to
*RFAL_NFCB_SLOT_NUM_1
*
*
* Starts NFC-B Collision resolution Listener device/card (PICC). The sequence can
* be configured to be according to NFC Forum Activity 1.1 9.3.5, ISO10373
* or EMVCo
*
* This function is used to trigger the collision resolution for detection in case
* of multiple NFC Forum Devices with Technology B are detected.
* Target with valid SENSB_RES will be stored in nfcbDevList and devCnt incremented.
*
* This method provides the means to perform a collision resolution loop with specific
* initial and end number of slots. This allows to user to start the loop already with
* greater number of slots, and or limit the end number of slots. At the end a flag
* indicating whether there were collisions pending is returned.
*
* If RFAL_COMPLIANCE_MODE_ISO is used \a initSlots must be set to RFAL_NFCB_SLOT_NUM_1
*
*
* \param[in] compMode : compliance mode to be performed
* \param[in] devLimit : device limit value, and size nfcbDevList
* \param[in] initSlots : number of slots to open initially
* \param[in] endSlots : number of slots when to stop collision resolution
* \param[in] initSlots : number of slots to open initially
* \param[in] endSlots : number of slots when to stop collision resolution
* \param[out] nfcbDevList : NFC-B listener device info
* \param[out] devCnt : devices found counter
* \param[out] colPending : flag indicating whether collision are still pending
@ -586,10 +548,8 @@ ReturnCode rfalNfcbPollerStartCollisionResolution(
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcbPollerStartSlottedCollisionResolution(
rfalComplianceMode compMode, uint8_t devLimit, rfalNfcbSlots initSlots,
rfalNfcbSlots endSlots, rfalNfcbListenDevice *nfcbDevList, uint8_t *devCnt,
bool *colPending);
ReturnCode rfalNfcbPollerStartSlottedCollisionResolution( rfalComplianceMode compMode, uint8_t devLimit, rfalNfcbSlots initSlots, rfalNfcbSlots endSlots, rfalNfcbListenDevice *nfcbDevList, uint8_t *devCnt, bool *colPending );
/*!
*****************************************************************************
@ -609,28 +569,29 @@ ReturnCode rfalNfcbPollerStartSlottedCollisionResolution(
* \return RFAL_ERR_NONE : No error, activation successful
*****************************************************************************
*/
ReturnCode rfalNfcbPollerGetCollisionResolutionStatus(void);
ReturnCode rfalNfcbPollerGetCollisionResolutionStatus( void );
/*!
/*!
*****************************************************************************
* \brief NFC-B TR2 code to FDT
*
* Converts the TR2 code as defined in Digital 1.1 Table 33 Minimum
*
* Converts the TR2 code as defined in Digital 1.1 Table 33 Minimum
* TR2 Coding to Frame Delay Time (FDT) in 1/Fc
*
* \param[in] tr2Code : TR2 code as defined in Digital 1.1 Table 33
*
*
* \return FDT in 1/Fc
*****************************************************************************
*/
uint32_t rfalNfcbTR2ToFDT(uint8_t tr2Code);
uint32_t rfalNfcbTR2ToFDT( uint8_t tr2Code );
#endif /* RFAL_NFCB_H */
/**
* @}
*
* @}
*
* @}
*/
* @}
*
* @}
*
* @}
*/

View File

@ -1,18 +1,19 @@
/******************************************************************************
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/*
* PROJECT: ST25R391x firmware
@ -26,10 +27,10 @@
*
* \brief Implementation of NFC-F Poller (FeliCa PCD) device
*
* The definitions and helpers methods provided by this module are
* The definitions and helpers methods provided by this module are
* aligned with NFC-F (FeliCa - JIS X6319-4)
*
*
*
*
* \addtogroup RFAL
* @{
*
@ -39,10 +40,11 @@
*
* \addtogroup NFC-F
* \brief RFAL NFC-F Module
* @{
*
* @{
*
*/
#ifndef RFAL_NFCF_H
#define RFAL_NFCF_H
@ -52,8 +54,8 @@
******************************************************************************
*/
#include "rfal_platform.h"
#include "rfal_rf.h"
#include "rfal_utils.h"
#include "rfal_rf.h"
/*
******************************************************************************
@ -61,124 +63,74 @@
******************************************************************************
*/
#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 \
3U /*!< 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 3U /*!< 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_NOS_LEN \
1U /*!< Number of Services length */
#define RFAL_NFCF_NOB_LEN \
1U /*!< Number of Blocks 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_NOS_LEN 1U /*!< Number of Services length */
#define RFAL_NFCF_NOB_LEN 1U /*!< Number of Blocks length */
#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_SYSTEMCODE \
0xFFFFU /*!< SENSF_RES Default System Code Digital 2.3 8.6.1.5 */
#define RFAL_NFCF_SYSTEMCODE_LEN \
2U /*!< SENSF_RES System Code length Digital 2.3 8.6.1 */
#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_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_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_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_SYSTEMCODE 0xFFFFU /*!< SENSF_RES Default System Code Digital 2.3 8.6.1.5 */
#define RFAL_NFCF_SYSTEMCODE_LEN 2U /*!< SENSF_RES System Code length Digital 2.3 8.6.1 */
#define RFAL_NFCF_BLOCKLISTELEM_MAX_LEN \
3U /*!< Block List Element max Length (3 bytes) T3T 1.0 5.6.1 */
#define RFAL_NFCF_BLOCKLISTELEM_LEN_BIT \
0x80U /*!< Block List Element Length bit (2|3 bytes) T3T 1.0 5.6.1 */
#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_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_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_MAX_LEN 3U /*!< Block List Element max Length (3 bytes) T3T 1.0 5.6.1 */
#define RFAL_NFCF_BLOCKLISTELEM_LEN_BIT 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_TEST_LB_CMD0 0xD8U /*!< T3T loopback CMD0 ETSI TS 102 695-1 5.6.4.4.2 */
#define RFAL_NFCF_TEST_LB_CMD1 0x00U /*!< T3T loopback CMD1 ETSI TS 102 695-1 5.6.4.4.2 */
#define RFAL_NFCF_TEST_LB_CMD0 \
0xD8U /*!< T3T loopback CMD0 ETSI TS 102 695-1 5.6.4.4.2 */
#define RFAL_NFCF_TEST_LB_CMD1 \
0x00U /*!< T3T loopback CMD1 ETSI TS 102 695-1 5.6.4.4.2 */
/*! 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 */
};
/*
@ -188,13 +140,9 @@ 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) )
/*
******************************************************************************
@ -202,44 +150,52 @@ 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 */
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 */
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 */
} 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;
/*
******************************************************************************
@ -247,13 +203,13 @@ typedef struct {
******************************************************************************
*/
/*!
/*!
*****************************************************************************
* \brief Initialize NFC-F Poller mode
*
* This methods configures RFAL RF layer to perform as a
*
* This methods configures RFAL RF layer to perform as a
* NFC-F Poller/RW (FeliCa PCD) including all default timings
*
*
* \param[in] bitRate : NFC-F bitrate to be initialize (212 or 424)
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or mode not set
@ -261,18 +217,19 @@ typedef struct {
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcfPollerInitialize(rfalBitRate bitRate);
ReturnCode rfalNfcfPollerInitialize( rfalBitRate bitRate );
/*!
/*!
*****************************************************************************
* \brief NFC-F Poller Check Presence
*
*
* This function sends a Poll/SENSF command according to NFC Activity spec
* It detects if a NCF-F device is within range
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_CRC : CRC error detected
* \return RFAL_ERR_FRAMING : Framing error detected
* \return RFAL_ERR_PROTO : Protocol error detected
@ -281,31 +238,33 @@ ReturnCode rfalNfcfPollerInitialize(rfalBitRate bitRate);
*
*****************************************************************************
*/
ReturnCode rfalNfcfPollerCheckPresence(void);
ReturnCode rfalNfcfPollerCheckPresence( void );
/*!
/*!
*****************************************************************************
* \brief NFC-F Poller Start Check Presence
*
*
* This function triggers a Poll/SENSF command according to NFC Activity spec
* It detects if a NCF-F device is within range
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_NONE : No error and some NFC-F device was detected
*
*****************************************************************************
*/
ReturnCode rfalNfcfPollerStartCheckPresence(void);
ReturnCode rfalNfcfPollerStartCheckPresence( void );
/*!
/*!
*****************************************************************************
* \brief NFC-F Poller Get Check Presence Status
*
*
* This function gets the status of the Check Presense operation
* triggered by rfalNfcfPollerStartCheckPresence()
*
* \return RFAL_ERR_IO : Generic internal error
*
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_CRC : CRC error detected
* \return RFAL_ERR_FRAMING : Framing error detected
* \return RFAL_ERR_PROTO : Protocol error detected
@ -314,28 +273,28 @@ ReturnCode rfalNfcfPollerStartCheckPresence(void);
*
*****************************************************************************
*/
ReturnCode rfalNfcfPollerGetCheckPresenceStatus(void);
ReturnCode rfalNfcfPollerGetCheckPresenceStatus( void );
/*!
/*!
*****************************************************************************
* \brief NFC-F Poller Poll
*
*
* This function sends to all PICCs in field the POLL command with the given
* number of slots.
*
* \param[in] slots : the number of slots to be performed
* \param[in] sysCode : as given in FeliCa poll command
* \param[in] sysCode : as given in FeliCa poll command
* \param[in] reqCode : FeliCa communication parameters
* \param[out] cardList : Parameter of type rfalFeliCaPollRes which will hold
*the cards found \param[out] devCnt : actual number of cards found
* \param[out] cardList : Parameter of type rfalFeliCaPollRes which will hold the cards found
* \param[out] devCnt : actual number of cards found
* \param[out] collisions : number of collisions encountered
*
* \warning the list cardList has to be as big as the number of slots for the
*Poll
* \warning the list cardList has to be as big as the number of slots for the Poll
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_CRC : CRC error detected
* \return RFAL_ERR_FRAMING : Framing error detected
* \return RFAL_ERR_PROTO : Protocol error detected
@ -344,25 +303,23 @@ ReturnCode rfalNfcfPollerGetCheckPresenceStatus(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 );
/*!
/*!
*****************************************************************************
* \brief NFC-F Poller Full Collision Resolution
*
*
* Performs a full Collision resolution as defined in Activity 1.1 9.3.4
*
* \param[in] compMode : compliance mode to be performed
* \param[in] devLimit : device limit value, and size nfcaDevList
* \param[out] nfcfDevList : NFC-F listener devices list
* \param[out] devCnt : Devices found counter
*
* NFC-F Collision Resolution uses information collected at Technlology
*dectection (if provided on nfcfDevList). Technology Detection shall be
*performed using 4 slots, therefore at least 4 slots/devLimit shall be
*allocated on nfcfDevList.
*
* NFC-F Collision Resolution uses information collected at Technlology dectection (if
* provided on nfcfDevList). Technology Detection shall be performed using 4 slots, therefore
* at least 4 slots/devLimit shall be allocated on nfcfDevList.
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or mode not set
* \return RFAL_ERR_PARAM : Invalid parameters
@ -370,21 +327,18 @@ ReturnCode rfalNfcfPollerPoll(rfalFeliCaPollSlots slots, uint16_t sysCode,
* \return RFAL_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 );
/*!
/*!
*****************************************************************************
* \brief NFC-F Start Poller Collision Resolution
*
*
* Triggers a Collision Resolution as defined in Activity 2.1 9.3.6
*
* NFC-F Collision Resolution uses information collected at Technlology
*dectection (if provided on nfcfDevList). Technology Detection shall be
*performed using 4 slots, therefore at least 4 slots/devLimit shall be
*allocated on nfcfDevList.
*
* NFC-F Collision Resolution uses information collected at Technlology dectection (if
* provided on nfcfDevList). Technology Detection shall be performed using 4 slots, therefore
* at least 4 slots/devLimit shall be allocated on nfcfDevList.
*
* \param[in] compMode : compliance mode to be performed
* \param[in] devLimit : device limit value, and size nfcaDevList
@ -397,18 +351,17 @@ ReturnCode rfalNfcfPollerCollisionResolution(rfalComplianceMode compMode,
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalNfcfPollerStartCollisionResolution(
rfalComplianceMode compMode, uint8_t devLimit,
rfalNfcfListenDevice *nfcfDevList, uint8_t *devCnt);
ReturnCode rfalNfcfPollerStartCollisionResolution( rfalComplianceMode compMode, uint8_t devLimit, rfalNfcfListenDevice *nfcfDevList, uint8_t *devCnt );
/*!
/*!
*****************************************************************************
* \brief NFC-F Poller Get Collision Resolution Status
*
*
* This function gets the status of the Collision Resolution operation
* triggered by rfalNfcfPollerStartCollisionResolution()
*
* \return RFAL_ERR_IO : Generic internal error
*
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_CRC : CRC error detected
* \return RFAL_ERR_FRAMING : Framing error detected
* \return RFAL_ERR_PROTO : Protocol error detected
@ -417,20 +370,21 @@ ReturnCode rfalNfcfPollerStartCollisionResolution(
*
*****************************************************************************
*/
ReturnCode rfalNfcfPollerGetCollisionResolutionStatus(void);
ReturnCode rfalNfcfPollerGetCollisionResolutionStatus( void );
/*!
/*!
*****************************************************************************
* \brief NFC-F Poller Check/Read
*
* It computes a Check / Read command accoring to T3T 1.0 and JIS X6319-4 and
* sends it to PICC. If sucessfully, the rxBuf will contain the the number of
*
* It computes a Check / Read command accoring to T3T 1.0 and JIS X6319-4 and
* sends it to PICC. If sucessfully, the rxBuf will contain the the number of
* blocks in the first byte followed by the blocks data.
*
* \param[in] nfcid2 : nfcid2 of the device
* \param[in] servBlock : parameter containing the list of Services and
* Blocks to be addressed by this command
* \param[out] rxBuf : buffer to place check/read data
* \param[out] rxBuf : buffer to place check/read data
* \param[in] rxBufLen : size of the rxBuf
* \param[out] rcvdLen : length of data placed in rxBuf
*
@ -441,16 +395,14 @@ ReturnCode rfalNfcfPollerGetCollisionResolutionStatus(void);
* \return RFAL_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 );
/*!
/*!
*****************************************************************************
* \brief NFC-F Poller Update/Write
*
* It computes a Update / Write command accoring to T3T 1.0 and JIS X6319-4 and
*
* It computes a Update / Write command accoring to T3T 1.0 and JIS X6319-4 and
* sends it to PICC.
*
* \param[in] nfcid2 : nfcid2 of the device
@ -459,7 +411,7 @@ ReturnCode rfalNfcfPollerCheck(const uint8_t *nfcid2,
* \param[in] txBuf : buffer where the request will be composed
* \param[in] txBufLen : size of txBuf
* \param[in] blockData : data to written on the given block(s)
* \param[out] rxBuf : buffer to place check/read data
* \param[out] rxBuf : buffer to place check/read data
* \param[in] rxBufLen : size of the rxBuf
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or mode not set
@ -469,40 +421,35 @@ ReturnCode rfalNfcfPollerCheck(const uint8_t *nfcid2,
* \return RFAL_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);
/*!
*****************************************************************************
* \brief NFC-F Listener is T3T Request
*
* This method checks if the given data is a valid T3T command (Read or Write)
* and in case a valid request has been received it may output the request's
*NFCID2
*
* \brief NFC-F Listener is T3T Request
*
* This method checks if the given data is a valid T3T command (Read or Write)
* and in case a valid request has been received it may output the request's NFCID2
*
* \param[in] buf : buffer holding Initiator's received command
* \param[in] bufLen : length of received command in bytes
* \param[out] nfcid2 : pointer to where the NFCID2 may be outputed,
* \param[out] nfcid2 : pointer to where the NFCID2 may be outputed,
* nfcid2 has NFCF_SENSF_NFCID2_LEN as length
* Pass NULL if output parameter not desired
*
* Pass NULL if output parameter not desired
*
* \return true : Valid T3T command (Read or Write) received
* \return false : Invalid protocol request
*
*
*****************************************************************************
*/
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 */
/**
* @}
*
* @}
*
* @}
*/
* @}
*
* @}
*
* @}
*/

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,18 +1,19 @@
/******************************************************************************
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/*
* PROJECT: ST25R391x firmware
@ -24,7 +25,7 @@
*
* \author Gustavo Patricio
*
* \brief Implementation of ST25TB interface
* \brief Implementation of ST25TB interface
*
*
* \addtogroup RFAL
@ -37,9 +38,10 @@
* \addtogroup ST25TB
* \brief RFAL ST25TB Module
* @{
*
*
*/
#ifndef RFAL_ST25TB_H
#define RFAL_ST25TB_H
@ -48,10 +50,10 @@
* INCLUDES
******************************************************************************
*/
#include "rfal_nfcb.h"
#include "rfal_platform.h"
#include "rfal_rf.h"
#include "rfal_utils.h"
#include "rfal_rf.h"
#include "rfal_nfcb.h"
/*
******************************************************************************
@ -59,10 +61,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 */
/*
******************************************************************************
@ -70,21 +72,25 @@
******************************************************************************
*/
/*
******************************************************************************
* 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;
/*
******************************************************************************
@ -92,74 +98,75 @@ typedef struct {
******************************************************************************
*/
/*!
/*!
*****************************************************************************
* \brief Initialize ST25TB Poller mode
*
* This methods configures RFAL RF layer to perform as a
*
* This methods configures RFAL RF layer to perform as a
* ST25TB Poller/RW including all default timings
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or mode not set
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalSt25tbPollerInitialize(void);
ReturnCode rfalSt25tbPollerInitialize( void );
/*!
/*!
*****************************************************************************
* \brief ST25TB Poller Check Presence
*
*
* This method checks if a ST25TB Listen device (PICC) is present on the field
* by sending an Initiate command
*
*
* \param[out] chipId : if successfully retrieved, the device's chip ID
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_TIMEOUT : Timeout error, no listener device detected
* \return RFAL_ERR_RF_COLLISION : Collision detected one or more device in the
*field \return RFAL_ERR_PROTO : Protocol error detected \return
*RFAL_ERR_NONE : No error
* \return RFAL_ERR_RF_COLLISION : Collision detected one or more device in the field
* \return RFAL_ERR_PROTO : Protocol error detected
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalSt25tbPollerCheckPresence(uint8_t *chipId);
ReturnCode rfalSt25tbPollerCheckPresence( uint8_t *chipId );
/*!
/*!
*****************************************************************************
* \brief ST25TB Poller Collision Resolution
*
*
* This method performs ST25TB Collision resolution, selects the each device,
* retrieves its UID and then deselects.
* In case only one device is identified the ST25TB device is left in select
* state.
*
*
* \param[in] devLimit : device limit value, and size st25tbDevList
* \param[out] st25tbDevList : ST35TB listener device info
* \param[out] devCnt : Devices found counter
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_TIMEOUT : Timeout error, no listener device detected
* \return RFAL_ERR_RF_COLLISION : Collision detected one or more device in the
*field \return RFAL_ERR_PROTO : Protocol error detected \return
*RFAL_ERR_NONE : No error
* \return RFAL_ERR_RF_COLLISION : Collision detected one or more device in the field
* \return RFAL_ERR_PROTO : Protocol error detected
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalSt25tbPollerCollisionResolution(
uint8_t devLimit, rfalSt25tbListenDevice *st25tbDevList, uint8_t *devCnt);
ReturnCode rfalSt25tbPollerCollisionResolution( uint8_t devLimit, rfalSt25tbListenDevice *st25tbDevList, uint8_t *devCnt );
/*!
/*!
*****************************************************************************
* \brief ST25TB Poller Initiate
*
* This method sends an Initiate command
*
*
* This method sends an Initiate command
*
* If a single device responds the chip ID will be retrieved
*
* \param[out] chipId : chip ID of the device
*
*
* \param[out] chipId : chip ID of the device
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
@ -168,17 +175,18 @@ ReturnCode rfalSt25tbPollerCollisionResolution(
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalSt25tbPollerInitiate(uint8_t *chipId);
ReturnCode rfalSt25tbPollerInitiate( uint8_t *chipId );
/*!
/*!
*****************************************************************************
* \brief ST25TB Poller Pcall
*
* This method sends a Pcall command
*
* This method sends a Pcall command
* If successful the device's chip ID will be retrieved
*
* \param[out] chipId : Chip ID of the device
*
*
* \param[out] chipId : Chip ID of the device
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
@ -187,19 +195,20 @@ ReturnCode rfalSt25tbPollerInitiate(uint8_t *chipId);
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalSt25tbPollerPcall(uint8_t *chipId);
ReturnCode rfalSt25tbPollerPcall( uint8_t *chipId );
/*!
/*!
*****************************************************************************
* \brief ST25TB Poller Slot Marker
*
*
* This method sends a Slot Marker
*
*
* If a single device responds the chip ID will be retrieved
*
* \param[in] slotNum : Slot Number
* \param[out] chipIdRes : Chip ID of the device
*
* \param[in] slotNum : Slot Number
* \param[out] chipIdRes : Chip ID of the device
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
@ -208,19 +217,20 @@ ReturnCode rfalSt25tbPollerPcall(uint8_t *chipId);
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalSt25tbPollerSlotMarker(uint8_t slotNum, uint8_t *chipIdRes);
ReturnCode rfalSt25tbPollerSlotMarker( uint8_t slotNum, uint8_t *chipIdRes );
/*!
/*!
*****************************************************************************
* \brief ST25TB Poller Select
*
*
* This method sends a ST25TB Select command with the given chip ID.
*
* If the device is already in Selected state and receives an incorrect chip
*
* If the device is already in Selected state and receives an incorrect chip
* ID, it goes into Deselected state
*
*
* \param[in] chipId : chip ID of the device to be selected
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
@ -229,18 +239,19 @@ ReturnCode rfalSt25tbPollerSlotMarker(uint8_t slotNum, uint8_t *chipIdRes);
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalSt25tbPollerSelect(uint8_t chipId);
ReturnCode rfalSt25tbPollerSelect( uint8_t chipId );
/*!
/*!
*****************************************************************************
* \brief ST25TB Get UID
*
*
* This method sends a Get_UID command
*
*
* If a single device responds the chip UID will be retrieved
*
* \param[out] UID : UID of the found device
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
@ -249,17 +260,18 @@ ReturnCode rfalSt25tbPollerSelect(uint8_t chipId);
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalSt25tbPollerGetUID(rfalSt25tbUID *UID);
ReturnCode rfalSt25tbPollerGetUID( rfalSt25tbUID *UID );
/*!
/*!
*****************************************************************************
* \brief ST25TB Poller Read Block
*
*
* This method reads a block of the ST25TB
*
*
* \param[in] blockAddress : address of the block to be read
* \param[out] blockData : location to place the data read from block
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
@ -268,18 +280,18 @@ ReturnCode rfalSt25tbPollerGetUID(rfalSt25tbUID *UID);
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalSt25tbPollerReadBlock(uint8_t blockAddress,
rfalSt25tbBlock *blockData);
ReturnCode rfalSt25tbPollerReadBlock( uint8_t blockAddress, rfalSt25tbBlock *blockData );
/*!
/*!
*****************************************************************************
* \brief ST25TB Poller Write Block
*
*
* This method writes a block of the ST25TB
*
*
* \param[in] blockAddress : address of the block to be written
* \param[in] blockData : data to be written on the block
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
@ -288,48 +300,51 @@ ReturnCode rfalSt25tbPollerReadBlock(uint8_t blockAddress,
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalSt25tbPollerWriteBlock(uint8_t blockAddress,
const rfalSt25tbBlock *blockData);
ReturnCode rfalSt25tbPollerWriteBlock( uint8_t blockAddress, const rfalSt25tbBlock *blockData );
/*!
/*!
*****************************************************************************
* \brief ST25TB Poller Completion
*
* This method sends a completion command to the ST25TB. After the
* \brief ST25TB Poller Completion
*
* This method sends a completion command to the ST25TB. After the
* completion the card no longer will reply to any command.
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_TIMEOUT : Timeout error, no listener device detected
* \return RFAL_ERR_PROTO : Protocol error detected, invalid SENSB_RES
*received \return RFAL_ERR_NONE : No error
* \return RFAL_ERR_PROTO : Protocol error detected, invalid SENSB_RES received
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalSt25tbPollerCompletion(void);
ReturnCode rfalSt25tbPollerCompletion( void );
/*!
/*!
*****************************************************************************
* \brief ST25TB Poller Reset to Inventory
*
*
* This method sends a Reset to Inventory command to the ST25TB.
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_TIMEOUT : Timeout error, no listener device detected
* \return RFAL_ERR_PROTO : Protocol error detected, invalid SENSB_RES
*received \return RFAL_ERR_NONE : No error
* \return RFAL_ERR_PROTO : Protocol error detected, invalid SENSB_RES received
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalSt25tbPollerResetToInventory(void);
ReturnCode rfalSt25tbPollerResetToInventory( void );
#endif /* RFAL_ST25TB_H */
/**
* @}
*
* @}
*
* @}
*/
* @}
*
* @}
*
* @}
*/

View File

@ -1,18 +1,19 @@
/******************************************************************************
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/*
* PROJECT: ST25R391x firmware
@ -40,7 +41,7 @@
* \addtogroup ST25xV
* \brief RFAL ST25xV Module
* @{
*
*
*/
#ifndef RFAL_ST25xV_H
@ -52,8 +53,8 @@
******************************************************************************
*/
#include "rfal_platform.h"
#include "rfal_rf.h"
#include "rfal_utils.h"
#include "rfal_rf.h"
/*
******************************************************************************
@ -61,28 +62,28 @@
******************************************************************************
*/
#define RFAL_NFCV_BLOCKNUM_M24LR_LEN \
2U /*!< Block Number length of MR24LR tags: 16 bits */
#define RFAL_NFCV_BLOCKNUM_M24LR_LEN 2U /*!< Block Number length of MR24LR tags: 16 bits */
/*!
/*!
*****************************************************************************
* \brief NFC-V Poller Read Single Block (M24LR)
*
* Reads a Single Block from a M24LR tag which has the number of blocks
*
* Reads a Single Block from a M24LR tag which has the number of blocks
* bigger than 256 (M24LR16 ; M24LR64)
*
* \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
* default: RFAL_NFCV_REQ_FLAG_DEFAULT
* \param[in] uid : UID of the device to be put to be read
* if not provided Select mode will be used
* if not provided Select mode will be used
* \param[in] blockNum : Number of the block to read (16 bits)
* \param[out] rxBuf : buffer to store response (also with RES_FLAGS)
* \param[in] rxBufLen : length of rxBuf
* \param[out] rcvLen : number of bytes received
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_CRC : CRC error detected
* \return RFAL_ERR_FRAMING : Framing error detected
* \return RFAL_ERR_PROTO : Protocol error detected
@ -90,29 +91,27 @@
* \return RFAL_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 );
/*!
/*!
*****************************************************************************
* \brief NFC-V Poller Fast Read Single Block (M24LR)
*
* Reads a Single Block from a M24LR tag which has the number of blocks
*
* Reads a Single Block from a M24LR tag which has the number of blocks
* bigger than 256 (M24LR16 ; M24LR64) using ST Fast mode
*
* \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
* default: RFAL_NFCV_REQ_FLAG_DEFAULT
* \param[in] uid : UID of the device to be put to be read
* if not provided Select mode will be used
* if not provided Select mode will be used
* \param[in] blockNum : Number of the block to read (16 bits)
* \param[out] rxBuf : buffer to store response (also with RES_FLAGS)
* \param[in] rxBufLen : length of rxBuf
* \param[out] rcvLen : number of bytes received
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_CRC : CRC error detected
* \return RFAL_ERR_FRAMING : Framing error detected
* \return RFAL_ERR_PROTO : Protocol error detected
@ -120,28 +119,26 @@ ReturnCode rfalST25xVPollerM24LRReadSingleBlock(
* \return RFAL_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 );
/*!
/*!
*****************************************************************************
* \brief NFC-V Poller Write Single Block (M24LR)
*
* Writes a Single Block from a M24LR tag which has the number of blocks
*
* Writes a Single Block from a M24LR tag which has the number of blocks
* bigger than 256 (M24LR16 ; M24LR64)
*
* \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
* for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
* \param[in] uid : UID of the device to be put to be written
* if not provided Select mode will be used
* if not provided Select mode will be used
* \param[in] blockNum : Number of the block to write (16 bits)
* \param[in] wrData : data to be written on the given block
* \param[in] blockLen : number of bytes of a block
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_CRC : CRC error detected
* \return RFAL_ERR_FRAMING : Framing error detected
* \return RFAL_ERR_PROTO : Protocol error detected
@ -149,32 +146,28 @@ ReturnCode rfalST25xVPollerM24LRFastReadSingleBlock(
* \return RFAL_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 );
/*!
/*!
*****************************************************************************
* \brief NFC-V Poller Read Multiple Blocks (M24LR)
*
* Reads Multiple Blocks from a device from a M24LR tag which has the number of
*blocks bigger than 256 (M24LR16 ; M24LR64)
*
* Reads Multiple Blocks from a device from a M24LR tag which has the number of blocks
* bigger than 256 (M24LR16 ; M24LR64)
*
* \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
* for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
* \param[in] uid : UID of the device to be put to be read
* if not provided Select mode will be used
* if not provided Select mode will be used
* \param[in] firstBlockNum : first block to be read (16 bits)
* \param[in] numOfBlocks : number of block to read
* \param[out] rxBuf : buffer to store response (also with RES_FLAGS)
* \param[in] rxBufLen : length of rxBuf
* \param[out] rcvLen : number of bytes received
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_CRC : CRC error detected
* \return RFAL_ERR_FRAMING : Framing error detected
* \return RFAL_ERR_PROTO : Protocol error detected
@ -182,30 +175,29 @@ ReturnCode rfalST25xVPollerM24LRWriteSingleBlock(uint8_t flags,
* \return RFAL_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 );
/*!
/*!
*****************************************************************************
* \brief NFC-V Poller Fast Read Multiple Blocks (M24LR)
*
* Reads Multiple Blocks from a device from a M24LR tag which has the number of
*blocks bigger than 256 (M24LR16 ; M24LR64) using ST Fast mode
*
* Reads Multiple Blocks from a device from a M24LR tag which has the number of blocks
* bigger than 256 (M24LR16 ; M24LR64) using ST Fast mode
*
* \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
* for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
* \param[in] uid : UID of the device to be put to be read
* if not provided Select mode will be used
* if not provided Select mode will be used
* \param[in] firstBlockNum : first block to be read (16 bits)
* \param[in] numOfBlocks : number of block to read
* \param[out] rxBuf : buffer to store response (also with RES_FLAGS)
* \param[in] rxBufLen : length of rxBuf
* \param[out] rcvLen : number of bytes received
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_CRC : CRC error detected
* \return RFAL_ERR_FRAMING : Framing error detected
* \return RFAL_ERR_PROTO : Protocol error detected
@ -213,28 +205,26 @@ ReturnCode rfalST25xVPollerM24LRReadMultipleBlocks(
* \return RFAL_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 );
/*!
/*!
*****************************************************************************
* \brief NFC-V Poller Fast Read Single Block
*
*
* Reads a Single Block from a device (VICC) using ST Fast mode
*
* \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
* for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
* \param[in] uid : UID of the device to be put to be read
* if not provided Select mode will be used
* if not provided Select mode will be used
* \param[in] blockNum : Number of the block to read
* \param[out] rxBuf : buffer to store response (also with RES_FLAGS)
* \param[in] rxBufLen : length of rxBuf
* \param[out] rcvLen : number of bytes received
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_CRC : CRC error detected
* \return RFAL_ERR_FRAMING : Framing error detected
* \return RFAL_ERR_PROTO : Protocol error detected
@ -242,31 +232,27 @@ ReturnCode rfalST25xVPollerM24LRFastReadMultipleBlocks(
* \return RFAL_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 );
/*!
/*!
*****************************************************************************
* \brief NFC-V Poller Fast Read Multiple Blocks
*
*
* Reads Multiple Blocks from a device (VICC) using ST Fast mode
*
* \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
* for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
* \param[in] uid : UID of the device to be put to be read
* if not provided Select mode will be used
* if not provided Select mode will be used
* \param[in] firstBlockNum : first block to be read
* \param[in] numOfBlocks : number of block to read
* \param[out] rxBuf : buffer to store response (also with RES_FLAGS)
* \param[in] rxBufLen : length of rxBuf
* \param[out] rcvLen : number of bytes received
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_CRC : CRC error detected
* \return RFAL_ERR_FRAMING : Framing error detected
* \return RFAL_ERR_PROTO : Protocol error detected
@ -274,29 +260,26 @@ ReturnCode rfalST25xVPollerFastReadSingleBlock(uint8_t flags,
* \return RFAL_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 );
/*!
/*!
*****************************************************************************
* \brief NFC-V Poller Fast Extended Read Single Block
*
* Reads a Single Block from a device (VICC) supporting extended commands using
*ST Fast mode
*
* Reads a Single Block from a device (VICC) supporting extended commands using ST Fast mode
*
* \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
* for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
* \param[in] uid : UID of the device to be put to be read
* if not provided Select mode will be used
* if not provided Select mode will be used
* \param[in] blockNum : Number of the block to read (16 bits)
* \param[out] rxBuf : buffer to store response (also with RES_FLAGS)
* \param[in] rxBufLen : length of rxBuf
* \param[out] rcvLen : number of bytes received
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_CRC : CRC error detected
* \return RFAL_ERR_FRAMING : Framing error detected
* \return RFAL_ERR_PROTO : Protocol error detected
@ -304,30 +287,27 @@ ReturnCode rfalST25xVPollerFastReadMultipleBlocks(
* \return RFAL_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 );
/*!
/*!
*****************************************************************************
* \brief NFC-V Poller Fast Extended Read Multiple Blocks
*
* Reads Multiple Blocks from a device (VICC) supporting extended commands using
*ST Fast mode
*
* Reads Multiple Blocks from a device (VICC) supporting extended commands using ST Fast mode
*
* \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
* for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
* \param[in] uid : UID of the device to be put to be read
* if not provided Select mode will be used
* if not provided Select mode will be used
* \param[in] firstBlockNum : first block to be read (16 bits)
* \param[in] numOfBlocks : number of consecutive blocks to read (16 bits)
* \param[out] rxBuf : buffer to store response (also with RES_FLAGS)
* \param[in] rxBufLen : length of rxBuf
* \param[out] rcvLen : number of bytes received
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_CRC : CRC error detected
* \return RFAL_ERR_FRAMING : Framing error detected
* \return RFAL_ERR_PROTO : Protocol error detected
@ -335,26 +315,24 @@ ReturnCode rfalST25xVPollerFastExtendedReadSingleBlock(
* \return RFAL_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 );
/*!
/*!
*****************************************************************************
* \brief NFC-V Poller Read Configuration
*
*
* Reads static configuration registers at the Pointer address
*
* \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
* for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
* \param[in] uid : UID of the device to be put to be read
* if not provided Select mode will be used
* if not provided Select mode will be used
* \param[in] pointer : Pointer address
* \param[out] regValue : Register value
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_CRC : CRC error detected
* \return RFAL_ERR_FRAMING : Framing error detected
* \return RFAL_ERR_PROTO : Protocol error detected
@ -362,26 +340,24 @@ ReturnCode rfalST25xVPollerFastExtReadMultipleBlocks(
* \return RFAL_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 );
/*!
/*!
*****************************************************************************
* \brief NFC-V Poller Write Configuration
*
*
* Writes static configuration registers at the Pointer address
*
* \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
* for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
* \param[in] uid : UID of the device to be put to be read
* if not provided Select mode will be used
* if not provided Select mode will be used
* \param[in] pointer : Pointer address
* \param[in] regValue : Register value
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_CRC : CRC error detected
* \return RFAL_ERR_FRAMING : Framing error detected
* \return RFAL_ERR_PROTO : Protocol error detected
@ -389,26 +365,25 @@ ReturnCode rfalST25xVPollerReadConfiguration(uint8_t flags, const uint8_t* uid,
* \return RFAL_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 );
/*!
/*!
*****************************************************************************
* \brief NFC-V Poller Read Dynamic Configuration
*
*
* Reads dynamic registers at the Pointer address
*
* \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
* for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
* \param[in] uid : UID of the device to be put to be read
* if not provided Select mode will be used
* if not provided Select mode will be used
* \param[in] pointer : Pointer address
* \param[out] regValue : Register value
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_CRC : CRC error detected
* \return RFAL_ERR_FRAMING : Framing error detected
* \return RFAL_ERR_PROTO : Protocol error detected
@ -416,27 +391,24 @@ ReturnCode rfalST25xVPollerWriteConfiguration(uint8_t flags, const uint8_t* uid,
* \return RFAL_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 );
/*!
/*!
*****************************************************************************
* \brief NFC-V Poller Write Dynamic Configuration
*
*
* Writes dynamic registers at the Pointer address
*
* \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
* for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
* \param[in] uid : UID of the device to be put to be read
* if not provided Select mode will be used
* if not provided Select mode will be used
* \param[in] pointer : Pointer address
* \param[in] regValue : Register value
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_CRC : CRC error detected
* \return RFAL_ERR_FRAMING : Framing error detected
* \return RFAL_ERR_PROTO : Protocol error detected
@ -444,27 +416,24 @@ ReturnCode rfalST25xVPollerReadDynamicConfiguration(uint8_t flags,
* \return RFAL_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 );
/*!
/*!
*****************************************************************************
* \brief NFC-V Poller Fast Read Dynamic Configuration
*
*
* Reads dynamic registers at the Pointer address using ST Fast mode
*
* \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
* for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
* \param[in] uid : UID of the device to be put to be read
* if not provided Select mode will be used
* if not provided Select mode will be used
* \param[in] pointer : Pointer address
* \param[out] regValue : Register value
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_CRC : CRC error detected
* \return RFAL_ERR_FRAMING : Framing error detected
* \return RFAL_ERR_PROTO : Protocol error detected
@ -472,27 +441,24 @@ ReturnCode rfalST25xVPollerWriteDynamicConfiguration(uint8_t flags,
* \return RFAL_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 );
/*!
/*!
*****************************************************************************
* \brief NFC-V Poller Fast Write Dynamic Configuration
*
*
* Writes dynamic registers at the Pointer address using ST Fast mode
*
* \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
* for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
* \param[in] uid : UID of the device to be put to be read
* if not provided Select mode will be used
* if not provided Select mode will be used
* \param[in] pointer : Pointer address
* \param[in] regValue : Register value
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_CRC : CRC error detected
* \return RFAL_ERR_FRAMING : Framing error detected
* \return RFAL_ERR_PROTO : Protocol error detected
@ -500,28 +466,25 @@ ReturnCode rfalST25xVPollerFastReadDynamicConfiguration(uint8_t flags,
* \return RFAL_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 );
/*!
/*!
*****************************************************************************
* \brief NFC-V Poller Present Password
*
*
* Sends the Present Password command
*
* \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
* for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
* \param[in] uid : UID of the device to be put to be read
* if not provided Select mode will be used
* if not provided Select mode will be used
* \param[in] pwdNum : Password number
* \param[in] pwd : Password
* \param[in] pwdLen : Password length
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_CRC : CRC error detected
* \return RFAL_ERR_FRAMING : Framing error detected
* \return RFAL_ERR_PROTO : Protocol error detected
@ -529,27 +492,25 @@ ReturnCode rfalST25xVPollerFastWriteDynamicConfiguration(uint8_t flags,
* \return RFAL_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 );
/*!
/*!
*****************************************************************************
* \brief NFC-V Poller Write Password
*
*
* Sends the Write Password command
*
* \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
* for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
* \param[in] uid : UID of the device to be put to be read
* if not provided Select mode will be used
* if not provided Select mode will be used
* \param[in] pwdNum : Password number
* \param[in] pwd : Password
* \param[in] pwdLen : Password length
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_CRC : CRC error detected
* \return RFAL_ERR_FRAMING : Framing error detected
* \return RFAL_ERR_PROTO : Protocol error detected
@ -557,27 +518,25 @@ ReturnCode rfalST25xVPollerPresentPassword(uint8_t flags, const uint8_t* uid,
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalST25xVPollerWritePassword(uint8_t flags, const uint8_t* uid,
uint8_t pwdNum, const uint8_t* pwd,
uint8_t pwdLen);
ReturnCode rfalST25xVPollerWritePassword( uint8_t flags, const uint8_t* uid, uint8_t pwdNum, const uint8_t *pwd, uint8_t pwdLen);
/*!
/*!
*****************************************************************************
* \brief NFC-V Poller Get Random Number
*
*
* Returns a 16 bit random number
*
* \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
* for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
* \param[in] uid : UID of the device to be put to be read
* if not provided Select mode will be used
* if not provided Select mode will be used
* \param[out] rxBuf : buffer to store response (also with RES_FLAGS)
* \param[in] rxBufLen : length of rxBuf
* \param[out] rcvLen : number of bytes received
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_CRC : CRC error detected
* \return RFAL_ERR_FRAMING : Framing error detected
* \return RFAL_ERR_PROTO : Protocol error detected
@ -585,25 +544,23 @@ ReturnCode rfalST25xVPollerWritePassword(uint8_t flags, const uint8_t* uid,
* \return RFAL_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 );
/*!
/*!
*****************************************************************************
* \brief NFC-V Poller Read Message length
*
* Sends a Read Message Length message to retrieve the value of MB_LEN_Dyn
*
* Sends a Read Message Length message to retrieve the value of MB_LEN_Dyn
*
* \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
* for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
* \param[in] uid : UID of the device to be put to be read
* if not provided Select mode will be used
* if not provided Select mode will be used
* \param[out] msgLen : Message Length
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_CRC : CRC error detected
* \return RFAL_ERR_FRAMING : Framing error detected
* \return RFAL_ERR_PROTO : Protocol error detected
@ -611,25 +568,23 @@ ReturnCode rfalST25xVPollerGetRandomNumber(uint8_t flags, const uint8_t* uid,
* \return RFAL_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 );
/*!
/*!
*****************************************************************************
* \brief NFC-V Poller Fast Read Message length
*
* Sends a Fast Read Message Length message to retrieve the value of MB_LEN_Dyn
*using ST Fast mode.
*
* Sends a Fast Read Message Length message to retrieve the value of MB_LEN_Dyn using ST Fast mode.
*
* \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
* for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
* \param[in] uid : UID of the device to be put to be read
* if not provided Select mode will be used
* if not provided Select mode will be used
* \param[out] msgLen : Message Length
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_CRC : CRC error detected
* \return RFAL_ERR_FRAMING : Framing error detected
* \return RFAL_ERR_PROTO : Protocol error detected
@ -637,36 +592,35 @@ ReturnCode rfalST25xVPollerReadMessageLength(uint8_t flags, const uint8_t* uid,
* \return RFAL_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 );
/*!
/*!
*****************************************************************************
* \brief NFC-V Poller Read Message
*
*
* Reads up to 256 bytes in the Mailbox from the location
* specified by MBpointer and sends back their value in the rxBuf response.
* First MailBox location is '00'. When Number of bytes is set to 00h
* and MBPointer is equals to 00h, the MB_LEN bytes of the full message
* are returned. Otherwise, Read Message command returns (Number of Bytes + 1)
*bytes (i.e. 01h returns 2 bytes, FFh returns 256 bytes). An error is reported
*if (Pointer + Nb of bytes + 1) is greater than the message length. RF Reading
*of the last byte of the mailbox message automatically clears b1 of MB_CTRL_Dyn
*HOST_PUT_MSG, and allows RF to put a new message.
* First MailBox location is '00'. When Number of bytes is set to 00h
* and MBPointer is equals to 00h, the MB_LEN bytes of the full message
* are returned. Otherwise, Read Message command returns (Number of Bytes + 1) bytes
* (i.e. 01h returns 2 bytes, FFh returns 256 bytes).
* An error is reported if (Pointer + Nb of bytes + 1) is greater than the message length.
* RF Reading of the last byte of the mailbox message automatically clears b1
* of MB_CTRL_Dyn HOST_PUT_MSG, and allows RF to put a new message.
*
* \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
* for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
* \param[in] uid : UID of the device to be put to be read
* if not provided Select mode will be used
* if not provided Select mode will be used
* \param[in] mbPointer : MPpointer
* \param[in] numBytes : number of bytes
* \param[out] rxBuf : buffer to store response (also with RES_FLAGS)
* \param[in] rxBufLen : length of rxBuf
* \param[out] rcvLen : number of bytes received
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_CRC : CRC error detected
* \return RFAL_ERR_FRAMING : Framing error detected
* \return RFAL_ERR_PROTO : Protocol error detected
@ -674,39 +628,35 @@ ReturnCode rfalST25xVPollerFastReadMsgLength(uint8_t flags, const uint8_t* uid,
* \return RFAL_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 );
/*!
/*!
*****************************************************************************
* \brief NFC-V Poller Fast Read Message
*
*
* Reads up to 256 bytes in the Mailbox from the location
* specified by MBpointer and sends back their value in the rxBuf response using
*ST Fast mode. First MailBox location is '00'. When Number of bytes is set to
*00h and MBPointer is equals to 00h, the MB_LEN bytes of the full message are
*returned. Otherwise, Read Message command returns (Number of Bytes + 1) bytes
* specified by MBpointer and sends back their value in the rxBuf response using ST Fast mode.
* First MailBox location is '00'. When Number of bytes is set to 00h
* and MBPointer is equals to 00h, the MB_LEN bytes of the full message
* are returned. Otherwise, Read Message command returns (Number of Bytes + 1) bytes
* (i.e. 01h returns 2 bytes, FFh returns 256 bytes).
* An error is reported if (Pointer + Nb of bytes + 1) is greater than the
*message length. RF Reading of the last byte of the mailbox message
*automatically clears b1 of MB_CTRL_Dyn HOST_PUT_MSG, and allows RF to put a
*new message.
* An error is reported if (Pointer + Nb of bytes + 1) is greater than the message length.
* RF Reading of the last byte of the mailbox message automatically clears b1
* of MB_CTRL_Dyn HOST_PUT_MSG, and allows RF to put a new message.
*
* \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
* for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
* \param[in] uid : UID of the device to be put to be read
* if not provided Select mode will be used
* if not provided Select mode will be used
* \param[in] mbPointer : MPpointer
* \param[in] numBytes : number of bytes
* \param[out] rxBuf : buffer to store response (also with RES_FLAGS)
* \param[in] rxBufLen : length of rxBuf
* \param[out] rcvLen : number of bytes received
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_CRC : CRC error detected
* \return RFAL_ERR_FRAMING : Framing error detected
* \return RFAL_ERR_PROTO : Protocol error detected
@ -714,38 +664,34 @@ ReturnCode rfalST25xVPollerReadMessage(uint8_t flags, const uint8_t* uid,
* \return RFAL_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 );
/*!
/*!
*****************************************************************************
* \brief NFC-V Poller Write Message
*
*
* Sends Write message Command
*
* On receiving the Write Message command, the ST25DVxxx puts the data contained
* in the request into the Mailbox buffer, update the MB_LEN_Dyn register, and
* set bit RF_PUT_MSG in MB_CTRL_Dyn register. It then reports if the write
*operation was successful in the response. The ST25DVxxx Mailbox contains up to
*256 data bytes which are filled from the first location '00'. 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). Write Message could be executed only when
*Mailbox is accessible by RF.
* On receiving the Write Message command, the ST25DVxxx puts the data contained
* in the request into the Mailbox buffer, update the MB_LEN_Dyn register, and
* set bit RF_PUT_MSG in MB_CTRL_Dyn register. It then reports if the write operation was successful
* in the response. The ST25DVxxx Mailbox contains up to 256 data bytes which are filled from the
* first location '00'. 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).
* Write Message could be executed only when Mailbox is accessible by RF.
*
* \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
* for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
* \param[in] uid : UID of the device to be put to be read
* if not provided Select mode will be used
* if not provided Select mode will be used
* \param[in] msgLen : MSGLen number of Data bytes minus 1
* \param[in] msgData : Message Data
* \param[out] txBuf : buffer to used to build the Write Message
*command \param[in] txBufLen : length of txBuf
*
* \param[out] txBuf : buffer to used to build the Write Message command
* \param[in] txBufLen : length of txBuf
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_CRC : CRC error detected
* \return RFAL_ERR_FRAMING : Framing error detected
* \return RFAL_ERR_PROTO : Protocol error detected
@ -753,37 +699,34 @@ ReturnCode rfalST25xVPollerFastReadMessage(uint8_t flags, const uint8_t* uid,
* \return RFAL_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 );
/*!
/*!
*****************************************************************************
* \brief NFC-V Poller Fast Write Message
*
*
* Sends Fast Write message Command using ST Fast mode
*
* On receiving the Write Message command, the ST25DVxxx puts the data contained
* in the request into the Mailbox buffer, update the MB_LEN_Dyn register, and
* set bit RF_PUT_MSG in MB_CTRL_Dyn register. It then reports if the write
*operation was successful in the response. The ST25DVxxx Mailbox contains up to
*256 data bytes which are filled from the first location '00'. 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). Write Message could be executed only when
*Mailbox is accessible by RF.
*
* On receiving the Write Message command, the ST25DVxxx puts the data contained
* in the request into the Mailbox buffer, update the MB_LEN_Dyn register, and
* set bit RF_PUT_MSG in MB_CTRL_Dyn register. It then reports if the write operation was successful
* in the response. The ST25DVxxx Mailbox contains up to 256 data bytes which are filled from the
* first location '00'. 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).
* Write Message could be executed only when Mailbox is accessible by RF.
*
* \param[in] flags : Flags to be used: Sub-carrier; Data_rate; Option
* for NFC-Forum use: RFAL_NFCV_REQ_FLAG_DEFAULT
* \param[in] uid : UID of the device to be put to be read
* if not provided Select mode will be used
* if not provided Select mode will be used
* \param[in] msgLen : MSGLen number of Data bytes minus 1
* \param[in] msgData : Message Data
* \param[out] txBuf : buffer to used to build the Write Message
*command \param[in] txBufLen : length of txBuf
*
* \param[out] txBuf : buffer to used to build the Write Message command
* \param[in] txBufLen : length of txBuf
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or incorrect mode
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_IO : Generic internal error
* \return RFAL_ERR_CRC : CRC error detected
* \return RFAL_ERR_FRAMING : Framing error detected
* \return RFAL_ERR_PROTO : Protocol error detected
@ -791,17 +734,15 @@ ReturnCode rfalST25xVPollerWriteMessage(uint8_t flags, const uint8_t* uid,
* \return RFAL_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 */
/**
* @}
*
* @}
*
* @}
*/
* @}
*
* @}
*
* @}
*/

View File

@ -1,18 +1,19 @@
/******************************************************************************
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/*
* PROJECT: ST25R391x firmware
@ -25,11 +26,11 @@
* \author Gustavo Patricio
*
* \brief Provides NFC-A T1T convenience methods and definitions
*
*
* This module provides an interface to perform as a NFC-A Reader/Writer
* to handle a Type 1 Tag T1T (Topaz)
*
*
*
*
* \addtogroup RFAL
* @{
*
@ -40,9 +41,10 @@
* \addtogroup T1T
* \brief RFAL T1T Module
* @{
*
*
*/
#ifndef RFAL_T1T_H
#define RFAL_T1T_H
@ -52,42 +54,45 @@
******************************************************************************
*/
#include "rfal_platform.h"
#include "rfal_rf.h"
#include "rfal_utils.h"
#include "rfal_rf.h"
/*
******************************************************************************
* 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_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_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;
/*
@ -96,81 +101,82 @@ typedef struct {
******************************************************************************
*/
/*!
/*!
*****************************************************************************
* \brief Initialize NFC-A T1T Poller mode
*
* This methods configures RFAL RF layer to perform as a
* NFC-A T1T Poller/RW (Topaz) including all default timings
*
* This methods configures RFAL RF layer to perform as a
* NFC-A T1T Poller/RW (Topaz) including all default timings
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or mode not set
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalT1TPollerInitialize(void);
ReturnCode rfalT1TPollerInitialize( void );
/*!
/*!
*****************************************************************************
* \brief NFC-A T1T Poller RID
*
* This method reads the UID of a NFC-A T1T Listener device
*
* This method reads the UID of a NFC-A T1T Listener device
*
*
* \param[out] ridRes : pointer to place the RID_RES
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or mode not set
* \return RFAL_ERR_PARAM : Invalid parameter
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalT1TPollerRid(rfalT1TRidRes* ridRes);
ReturnCode rfalT1TPollerRid( rfalT1TRidRes *ridRes );
/*!
/*!
*****************************************************************************
* \brief NFC-A T1T Poller RALL
*
* This method send a Read All command to a NFC-A T1T Listener device
*
* This method send a Read All command to a NFC-A T1T Listener device
*
*
* \param[in] uid : the UID of the device to read data
* \param[out] rxBuf : pointer to place the read data
* \param[in] rxBufLen : size of rxBuf
* \param[out] rxRcvdLen : actual received data
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or mode not set
* \return RFAL_ERR_PARAM : Invalid parameter
* \return RFAL_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 );
/*!
/*!
*****************************************************************************
* \brief NFC-A T1T Poller Write
*
* This method writes the given data on the address of a NFC-A T1T Listener
*device
*
* This method writes the given data on the address of a NFC-A T1T Listener device
*
*
* \param[in] uid : the UID of the device to read data
* \param[in] address : address to write the data
* \param[in] data : the data to be written
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or mode not set
* \return RFAL_ERR_PARAM : Invalid parameter
* \return RFAL_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 */
/**
* @}
*
* @}
*
* @}
*/
* @}
*
* @}
*
* @}
*/

View File

@ -1,18 +1,19 @@
/******************************************************************************
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/*
* PROJECT: ST25R391x firmware
@ -25,11 +26,11 @@
* \author Gustavo Patricio
*
* \brief Provides NFC-A T2T convenience methods and definitions
*
*
* This module provides an interface to perform as a NFC-A Reader/Writer
* to handle a Type 2 Tag T2T
*
*
*
*
* \addtogroup RFAL
* @{
*
@ -40,9 +41,10 @@
* \addtogroup T2T
* \brief RFAL T2T Module
* @{
*
*
*/
#ifndef RFAL_T2T_H
#define RFAL_T2T_H
@ -52,8 +54,8 @@
******************************************************************************
*/
#include "rfal_platform.h"
#include "rfal_rf.h"
#include "rfal_utils.h"
#include "rfal_rf.h"
/*
******************************************************************************
@ -61,11 +63,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 */
/*
******************************************************************************
@ -73,74 +73,76 @@
******************************************************************************
*/
/*
******************************************************************************
* GLOBAL FUNCTION PROTOTYPES
******************************************************************************
*/
/*!
/*!
*****************************************************************************
* \brief NFC-A T2T Poller Read
*
* This method sends a Read command to a NFC-A T2T Listener device
*
* This method sends a Read command to a NFC-A T2T Listener device
*
*
* \param[in] blockNum : Number of the block to read
* \param[out] rxBuf : pointer to place the read data
* \param[in] rxBufLen : size of rxBuf (RFAL_T2T_READ_DATA_LEN)
* \param[out] rcvLen : actual received data
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or mode not set
* \return RFAL_ERR_PARAM : Invalid parameter
* \return RFAL_ERR_PROTO : Protocol error
* \return RFAL_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 );
/*!
/*!
*****************************************************************************
* \brief NFC-A T2T Poller Write
*
* This method sends a Write command to a NFC-A T2T Listener device
*
* This method sends a Write command to a NFC-A T2T Listener device
*
*
* \param[in] blockNum : Number of the block to write
* \param[in] wrData : data to be written on the given block
* size must be of RFAL_T2T_WRITE_DATA_LEN
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or mode not set
* \return RFAL_ERR_PARAM : Invalid parameter
* \return RFAL_ERR_PROTO : Protocol error
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalT2TPollerWrite(uint8_t blockNum, const uint8_t* wrData);
ReturnCode rfalT2TPollerWrite( uint8_t blockNum, const uint8_t* wrData );
/*!
/*!
*****************************************************************************
* \brief NFC-A T2T Poller Sector Select
*
* This method sends a Sector Select commands to a NFC-A T2T Listener device
* \brief NFC-A T2T Poller Sector Select
*
* This method sends a Sector Select commands to a NFC-A T2T Listener device
*
* \param[in] sectorNum : Sector Number
*
*
* \return RFAL_ERR_WRONG_STATE : RFAL not initialized or mode not set
* \return RFAL_ERR_PARAM : Invalid parameter
* \return RFAL_ERR_PROTO : Protocol error
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalT2TPollerSectorSelect(uint8_t sectorNum);
ReturnCode rfalT2TPollerSectorSelect( uint8_t sectorNum );
#endif /* RFAL_T2T_H */
/**
* @}
*
* @}
*
* @}
*/
* @}
*
* @}
*
* @}
*/

View File

@ -1,18 +1,18 @@
/******************************************************************************
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/*
* PROJECT: ST25R391x firmware
@ -25,14 +25,14 @@
* \author Gustavo Patricio
*
* \brief Provides convenience methods and definitions for T4T (ISO7816-4)
*
* This module provides an interface to exchange T4T APDUs according to
*
* This module provides an interface to exchange T4T APDUs according to
* NFC Forum T4T and ISO7816-4
*
*
* This implementation was based on the following specs:
* - ISO/IEC 7816-4 3rd Edition 2013-04-15
* - NFC Forum T4T Technical Specification 1.0 2017-08-28
*
*
* \addtogroup RFAL
* @{
*
@ -43,9 +43,10 @@
* \addtogroup T4T
* \brief RFAL T4T Module
* @{
*
*
*/
#ifndef RFAL_T4T_H
#define RFAL_T4T_H
@ -54,10 +55,10 @@
* INCLUDES
******************************************************************************
*/
#include "rfal_isoDep.h"
#include "rfal_platform.h"
#include "rfal_rf.h"
#include "rfal_utils.h"
#include "rfal_rf.h"
#include "rfal_isoDep.h"
/*
******************************************************************************
@ -65,31 +66,20 @@
******************************************************************************
*/
#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_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_STATUS_COMPLETE \
0x9000U /*!< Command completed \ Normal processing - No further \
qualification*/
/*
******************************************************************************
@ -97,41 +87,47 @@
******************************************************************************
*/
/*
******************************************************************************
* 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;
/*
@ -140,12 +136,12 @@ typedef enum {
******************************************************************************
*/
/*!
/*!
*****************************************************************************
* \brief T4T Compose APDU
*
*
* This method computes a C-APDU according to NFC Forum T4T and ISO7816-4.
*
*
* If C-APDU contains data to be sent, it must be placed inside the buffer
* rfalT4tTxRxApduParam.txRx.cApduBuf.apdu and signaled by Lc
*
@ -155,224 +151,209 @@ typedef enum {
* \see rfalIsoDepGetApduTransceiveStatus()
* \see rfalT4TPollerParseRAPDU()
*
* \warning The ISO-DEP module is used to perform the tranceive. Usually
* \warning The ISO-DEP module is used to perform the tranceive. Usually
* activation has been done via ISO-DEP activatiavtion. If not
* please call rfalIsoDepInitialize() before.
*
*
* \param[in,out] apduParam : APDU parameters
* apduParam.cApduLen will contain the APDU length
*
* apduParam.cApduLen will contain the APDU length
*
* \return RFAL_ERR_PARAM : Invalid parameter
* \return RFAL_ERR_PROTO : Protocol error
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalT4TPollerComposeCAPDU(const rfalT4tCApduParam *apduParam);
ReturnCode rfalT4TPollerComposeCAPDU( const rfalT4tCApduParam *apduParam );
/*!
/*!
*****************************************************************************
* \brief T4T Parse R-APDU
*
*
* This method parses a R-APDU according to NFC Forum T4T and ISO7816-4.
* It will extract the data length and check if the Satus word is expected.
*
* \param[in,out] apduParam : APDU parameters
* apduParam.rApduBodyLen will contain the data
*length apduParam.statusWord will contain the SW1 and SW2
*
* apduParam.rApduBodyLen will contain the data length
* apduParam.statusWord will contain the SW1 and SW2
*
* \return RFAL_ERR_REQUEST : Status word (SW1 SW2) different from 9000
* \return RFAL_ERR_PARAM : Invalid parameter
* \return RFAL_ERR_PROTO : Protocol error
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode rfalT4TPollerParseRAPDU(rfalT4tRApduParam *apduParam);
ReturnCode rfalT4TPollerParseRAPDU( rfalT4tRApduParam *apduParam );
/*!
/*!
*****************************************************************************
* \brief T4T Compose Select Application APDU
*
*
* This method computes a Select Application APDU according to NFC Forum T4T
*
* To transceive the formed APDU the ISO-DEP layer shall be used
*
* \see rfalIsoDepStartApduTransceive()
* \see rfalIsoDepGetApduTransceiveStatus()
*
*
* \param[out] cApduBuf : buffer where the C-APDU will be placed
* \param[in] aid : Application ID to be used
* \param[in] aidLen : Application ID length
* \param[out] cApduLen : Composed C-APDU length
*
*
* \return RFAL_ERR_PARAM : Invalid parameter
* \return RFAL_ERR_PROTO : Protocol error
* \return RFAL_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 );
/*!
/*!
*****************************************************************************
* \brief T4T Compose Select File APDU
*
*
* This method computes a Select File APDU according to NFC Forum T4T
*
* To transceive the formed APDU the ISO-DEP layer shall be used
*
* \see rfalIsoDepStartApduTransceive()
* \see rfalIsoDepGetApduTransceiveStatus()
*
*
* \param[out] cApduBuf : buffer where the C-APDU will be placed
* \param[in] fid : File ID to be used
* \param[in] fidLen : File ID length
* \param[out] cApduLen : Composed C-APDU length
*
*
* \return RFAL_ERR_PARAM : Invalid parameter
* \return RFAL_ERR_PROTO : Protocol error
* \return RFAL_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 );
/*!
/*!
*****************************************************************************
* \brief T4T Compose Select File APDU for Mapping Version 1
*
*
* This method computes a Select File APDU according to NFC Forum T4TOP_v1.0
*
* To transceive the formed APDU the ISO-DEP layer shall be used
*
* \see rfalIsoDepStartApduTransceive()
* \see rfalIsoDepGetApduTransceiveStatus()
*
*
* \param[out] cApduBuf : buffer where the C-APDU will be placed
* \param[in] fid : File ID to be used
* \param[in] fidLen : File ID length
* \param[out] cApduLen : Composed C-APDU length
*
*
* \return RFAL_ERR_PARAM : Invalid parameter
* \return RFAL_ERR_PROTO : Protocol error
* \return RFAL_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 );
/*!
/*!
*****************************************************************************
* \brief T4T Compose Read Data APDU
*
*
* This method computes a Read Data APDU according to NFC Forum T4T
*
* To transceive the formed APDU the ISO-DEP layer shall be used
*
* \see rfalIsoDepStartApduTransceive()
* \see rfalIsoDepGetApduTransceiveStatus()
*
*
* \param[out] cApduBuf : buffer where the C-APDU will be placed
* \param[in] offset : File offset
* \param[in] expLen : Expected length (Le)
* \param[out] cApduLen : Composed C-APDU length
*
*
* \return RFAL_ERR_PARAM : Invalid parameter
* \return RFAL_ERR_PROTO : Protocol error
* \return RFAL_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 );
/*!
/*!
*****************************************************************************
* \brief T4T Compose Read Data ODO APDU
*
*
* This method computes a Read Data ODO APDU according to NFC Forum T4T
*
* To transceive the formed APDU the ISO-DEP layer shall be used
*
* \see rfalIsoDepStartApduTransceive()
* \see rfalIsoDepGetApduTransceiveStatus()
*
*
* \param[out] cApduBuf : buffer where the C-APDU will be placed
* \param[in] offset : File offset
* \param[in] expLen : Expected length (Le)
* \param[out] cApduLen : Composed C-APDU length
*
*
* \return RFAL_ERR_PARAM : Invalid parameter
* \return RFAL_ERR_PROTO : Protocol error
* \return RFAL_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 );
/*!
/*!
*****************************************************************************
* \brief T4T Compose Write Data APDU
*
*
* This method computes a Write Data APDU according to NFC Forum T4T
*
* To transceive the formed APDU the ISO-DEP layer shall be used
*
* \see rfalIsoDepStartApduTransceive()
* \see rfalIsoDepGetApduTransceiveStatus()
*
*
* \param[out] cApduBuf : buffer where the C-APDU will be placed
* \param[in] offset : File offset
* \param[in] data : Data to be written
* \param[in] dataLen : Data length to be written (Lc)
* \param[out] cApduLen : Composed C-APDU length
*
*
* \return RFAL_ERR_PARAM : Invalid parameter
* \return RFAL_ERR_PROTO : Protocol error
* \return RFAL_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 );
/*!
/*!
*****************************************************************************
* \brief T4T Compose Write Data ODO APDU
*
*
* This method computes a Write Data ODO sAPDU according to NFC Forum T4T
*
* To transceive the formed APDU the ISO-DEP layer shall be used
*
* \see rfalIsoDepStartApduTransceive()
* \see rfalIsoDepGetApduTransceiveStatus()
*
*
* \param[out] cApduBuf : buffer where the C-APDU will be placed
* \param[in] offset : File offset
* \param[in] data : Data to be written
* \param[in] dataLen : Data length to be written (Lc)
* \param[out] cApduLen : Composed C-APDU length
*
*
* \return RFAL_ERR_PARAM : Invalid parameter
* \return RFAL_ERR_PROTO : Protocol error
* \return RFAL_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 */
/**
* @}
*
* @}
*
* @}
*/
* @}
*
* @}
*
* @}
*/

View File

@ -1,34 +1,36 @@
/******************************************************************************
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/*
* PROJECT: ST25R
* PROJECT: ST25R
* Revision:
* LANGUAGE: ISO C99
*/
/*! \file rfal_utils.h
*
* \author Gustavo Patricio
* \author Gustavo Patricio
*
* \brief RF Abstraction Layer (RFAL) Utils
*
*
* \addtogroup RFAL
* @{
*
*
*/
#ifndef RFAL_UTILS_H
@ -42,13 +44,14 @@
#include <stdint.h>
#include <string.h>
/*
******************************************************************************
* GLOBAL DATA TYPES
******************************************************************************
*/
typedef uint16_t ReturnCode; /*!< Standard Return Code type from function. */
typedef uint16_t ReturnCode; /*!< Standard Return Code type from function. */
/*
******************************************************************************
@ -61,89 +64,54 @@ typedef uint16_t ReturnCode; /*!< Standard Return Code type from function. */
* They are represented by an uint8_t
*/
#define RFAL_ERR_NONE ((ReturnCode)0U) /*!< no error occurred */
#define RFAL_ERR_NOMEM \
((ReturnCode)1U) /*!< not enough memory to perform the requested operation \
*/
#define RFAL_ERR_BUSY ((ReturnCode)2U) /*!< device or resource busy */
#define RFAL_ERR_IO ((ReturnCode)3U) /*!< generic IO error */
#define RFAL_ERR_TIMEOUT ((ReturnCode)4U) /*!< error due to timeout */
#define RFAL_ERR_REQUEST \
((ReturnCode)5U) /*!< invalid request or requested function can't be \
executed at the moment */
#define RFAL_ERR_NOMSG ((ReturnCode)6U) /*!< No message of desired type */
#define RFAL_ERR_PARAM ((ReturnCode)7U) /*!< Parameter error */
#define RFAL_ERR_SYSTEM ((ReturnCode)8U) /*!< System error */
#define RFAL_ERR_FRAMING ((ReturnCode)9U) /*!< Framing error */
#define RFAL_ERR_OVERRUN \
((ReturnCode)10U) /*!< lost one or more received bytes */
#define RFAL_ERR_PROTO ((ReturnCode)11U) /*!< protocol error */
#define RFAL_ERR_INTERNAL ((ReturnCode)12U) /*!< Internal Error */
#define RFAL_ERR_AGAIN ((ReturnCode)13U) /*!< Call again */
#define RFAL_ERR_MEM_CORRUPT ((ReturnCode)14U) /*!< memory corruption */
#define RFAL_ERR_NOT_IMPLEMENTED ((ReturnCode)15U) /*!< not implemented */
#define RFAL_ERR_PC_CORRUPT \
((ReturnCode)16U) /*!< Program Counter has been manipulated or spike/noise \
trigger illegal operation */
#define RFAL_ERR_SEND ((ReturnCode)17U) /*!< error sending*/
#define RFAL_ERR_IGNORE \
((ReturnCode)18U) /*!< indicates error detected but to be ignored */
#define RFAL_ERR_SEMANTIC \
((ReturnCode)19U) /*!< indicates error in state machine (unexpected cmd) */
#define RFAL_ERR_SYNTAX \
((ReturnCode)20U) /*!< indicates error in state machine (unknown cmd) */
#define RFAL_ERR_CRC ((ReturnCode)21U) /*!< crc error */
#define RFAL_ERR_NOTFOUND ((ReturnCode)22U) /*!< transponder not found */
#define RFAL_ERR_NOTUNIQUE \
((ReturnCode)23U) /*!< transponder not unique - more than one transponder in \
field */
#define RFAL_ERR_NOTSUPP \
((ReturnCode)24U) /*!< requested operation not supported */
#define RFAL_ERR_WRITE ((ReturnCode)25U) /*!< write error */
#define RFAL_ERR_FIFO ((ReturnCode)26U) /*!< fifo over or underflow error */
#define RFAL_ERR_PAR ((ReturnCode)27U) /*!< parity error */
#define RFAL_ERR_DONE ((ReturnCode)28U) /*!< transfer has already finished */
#define RFAL_ERR_RF_COLLISION \
((ReturnCode)29U) /*!< collision error (Bit Collision or during RF Collision \
avoidance ) */
#define RFAL_ERR_HW_OVERRUN \
((ReturnCode)30U) /*!< lost one or more received bytes */
#define RFAL_ERR_RELEASE_REQ \
((ReturnCode)31U) /*!< device requested release \
*/
#define RFAL_ERR_SLEEP_REQ ((ReturnCode)32U) /*!< device requested sleep */
#define RFAL_ERR_WRONG_STATE \
((ReturnCode)33U) /*!< incorrent state for requested operation */
#define RFAL_ERR_MAX_RERUNS \
((ReturnCode)34U) /*!< blocking procedure reached maximum runs */
#define RFAL_ERR_DISABLED \
((ReturnCode)35U) /*!< operation aborted due to disabled configuration */
#define RFAL_ERR_HW_MISMATCH \
((ReturnCode)36U) /*!< expected hw do not match \
*/
#define RFAL_ERR_LINK_LOSS \
((ReturnCode)37U) /*!< Other device's field didn't behave as expected: \
turned off by Initiator in Passive mode, or AP2P did \
not turn on field */
#define RFAL_ERR_INVALID_HANDLE \
((ReturnCode)38U) /*!< invalid or not initialized device handle */
#define RFAL_ERR_NONE ((ReturnCode)0U) /*!< no error occurred */
#define RFAL_ERR_NOMEM ((ReturnCode)1U) /*!< not enough memory to perform the requested operation */
#define RFAL_ERR_BUSY ((ReturnCode)2U) /*!< device or resource busy */
#define RFAL_ERR_IO ((ReturnCode)3U) /*!< generic IO error */
#define RFAL_ERR_TIMEOUT ((ReturnCode)4U) /*!< error due to timeout */
#define RFAL_ERR_REQUEST ((ReturnCode)5U) /*!< invalid request or requested function can't be executed at the moment */
#define RFAL_ERR_NOMSG ((ReturnCode)6U) /*!< No message of desired type */
#define RFAL_ERR_PARAM ((ReturnCode)7U) /*!< Parameter error */
#define RFAL_ERR_SYSTEM ((ReturnCode)8U) /*!< System error */
#define RFAL_ERR_FRAMING ((ReturnCode)9U) /*!< Framing error */
#define RFAL_ERR_OVERRUN ((ReturnCode)10U) /*!< lost one or more received bytes */
#define RFAL_ERR_PROTO ((ReturnCode)11U) /*!< protocol error */
#define RFAL_ERR_INTERNAL ((ReturnCode)12U) /*!< Internal Error */
#define RFAL_ERR_AGAIN ((ReturnCode)13U) /*!< Call again */
#define RFAL_ERR_MEM_CORRUPT ((ReturnCode)14U) /*!< memory corruption */
#define RFAL_ERR_NOT_IMPLEMENTED ((ReturnCode)15U) /*!< not implemented */
#define RFAL_ERR_PC_CORRUPT ((ReturnCode)16U) /*!< Program Counter has been manipulated or spike/noise trigger illegal operation */
#define RFAL_ERR_SEND ((ReturnCode)17U) /*!< error sending*/
#define RFAL_ERR_IGNORE ((ReturnCode)18U) /*!< indicates error detected but to be ignored */
#define RFAL_ERR_SEMANTIC ((ReturnCode)19U) /*!< indicates error in state machine (unexpected cmd) */
#define RFAL_ERR_SYNTAX ((ReturnCode)20U) /*!< indicates error in state machine (unknown cmd) */
#define RFAL_ERR_CRC ((ReturnCode)21U) /*!< crc error */
#define RFAL_ERR_NOTFOUND ((ReturnCode)22U) /*!< transponder not found */
#define RFAL_ERR_NOTUNIQUE ((ReturnCode)23U) /*!< transponder not unique - more than one transponder in field */
#define RFAL_ERR_NOTSUPP ((ReturnCode)24U) /*!< requested operation not supported */
#define RFAL_ERR_WRITE ((ReturnCode)25U) /*!< write error */
#define RFAL_ERR_FIFO ((ReturnCode)26U) /*!< fifo over or underflow error */
#define RFAL_ERR_PAR ((ReturnCode)27U) /*!< parity error */
#define RFAL_ERR_DONE ((ReturnCode)28U) /*!< transfer has already finished */
#define RFAL_ERR_RF_COLLISION ((ReturnCode)29U) /*!< collision error (Bit Collision or during RF Collision avoidance ) */
#define RFAL_ERR_HW_OVERRUN ((ReturnCode)30U) /*!< lost one or more received bytes */
#define RFAL_ERR_RELEASE_REQ ((ReturnCode)31U) /*!< device requested release */
#define RFAL_ERR_SLEEP_REQ ((ReturnCode)32U) /*!< device requested sleep */
#define RFAL_ERR_WRONG_STATE ((ReturnCode)33U) /*!< incorrent state for requested operation */
#define RFAL_ERR_MAX_RERUNS ((ReturnCode)34U) /*!< blocking procedure reached maximum runs */
#define RFAL_ERR_DISABLED ((ReturnCode)35U) /*!< operation aborted due to disabled configuration */
#define RFAL_ERR_HW_MISMATCH ((ReturnCode)36U) /*!< expected hw do not match */
#define RFAL_ERR_LINK_LOSS ((ReturnCode)37U) /*!< Other device's field didn't behave as expected: turned off by Initiator in Passive mode, or AP2P did not turn on field */
#define RFAL_ERR_INVALID_HANDLE ((ReturnCode)38U) /*!< invalid or not initialized device handle */
#define RFAL_ERR_INCOMPLETE_BYTE \
((ReturnCode)40U) /*!< Incomplete byte rcvd */
#define RFAL_ERR_INCOMPLETE_BYTE_01 \
((ReturnCode)41U) /*!< Incomplete byte rcvd - 1 bit */
#define RFAL_ERR_INCOMPLETE_BYTE_02 \
((ReturnCode)42U) /*!< Incomplete byte rcvd - 2 bit */
#define RFAL_ERR_INCOMPLETE_BYTE_03 \
((ReturnCode)43U) /*!< Incomplete byte rcvd - 3 bit */
#define RFAL_ERR_INCOMPLETE_BYTE_04 \
((ReturnCode)44U) /*!< Incomplete byte rcvd - 4 bit */
#define RFAL_ERR_INCOMPLETE_BYTE_05 \
((ReturnCode)45U) /*!< Incomplete byte rcvd - 5 bit */
#define RFAL_ERR_INCOMPLETE_BYTE_06 \
((ReturnCode)46U) /*!< Incomplete byte rcvd - 6 bit */
#define RFAL_ERR_INCOMPLETE_BYTE_07 \
((ReturnCode)47U) /*!< Incomplete byte rcvd - 7 bit */
#define RFAL_ERR_INCOMPLETE_BYTE ((ReturnCode)40U) /*!< Incomplete byte rcvd */
#define RFAL_ERR_INCOMPLETE_BYTE_01 ((ReturnCode)41U) /*!< Incomplete byte rcvd - 1 bit */
#define RFAL_ERR_INCOMPLETE_BYTE_02 ((ReturnCode)42U) /*!< Incomplete byte rcvd - 2 bit */
#define RFAL_ERR_INCOMPLETE_BYTE_03 ((ReturnCode)43U) /*!< Incomplete byte rcvd - 3 bit */
#define RFAL_ERR_INCOMPLETE_BYTE_04 ((ReturnCode)44U) /*!< Incomplete byte rcvd - 4 bit */
#define RFAL_ERR_INCOMPLETE_BYTE_05 ((ReturnCode)45U) /*!< Incomplete byte rcvd - 5 bit */
#define RFAL_ERR_INCOMPLETE_BYTE_06 ((ReturnCode)46U) /*!< Incomplete byte rcvd - 6 bit */
#define RFAL_ERR_INCOMPLETE_BYTE_07 ((ReturnCode)47U) /*!< Incomplete byte rcvd - 7 bit */
/*
******************************************************************************
@ -152,67 +120,57 @@ typedef uint16_t ReturnCode; /*!< Standard Return Code type from function. */
*/
/*! Common code to exit a function with the error if function f return error */
#define RFAL_EXIT_ON_ERR(r, f) \
(r) = (f); \
if (RFAL_ERR_NONE != (r)) { \
return (r); \
}
(r) = (f); \
if (RFAL_ERR_NONE != (r)) \
{ \
return (r); \
}
/*! Common code to exit a function if process/function f has not concluded */
#define RFAL_EXIT_ON_BUSY(r, f) \
(r) = (f); \
if (RFAL_ERR_BUSY == (r)) { \
return (r); \
}
(r) = (f); \
if (RFAL_ERR_BUSY == (r)) \
{ \
return (r); \
}
#define RFAL_SIZEOF_ARRAY(a) (sizeof(a) / sizeof((a)[0])) /*!< Compute the size of an array */
#define RFAL_MAX(a, b) (((a) > (b)) ? (a) : (b)) /*!< Return the maximum of the 2 values */
#define RFAL_MIN(a, b) (((a) < (b)) ? (a) : (b)) /*!< Return the minimum of the 2 values */
#define RFAL_GETU16(a) (((uint16_t)(a)[0] << 8) | (uint16_t)(a)[1])/*!< Cast two Big Endian 8-bits byte array to 16-bits unsigned */
#define RFAL_GETU32(a) (((uint32_t)(a)[0] << 24) | ((uint32_t)(a)[1] << 16) | ((uint32_t)(a)[2] << 8) | ((uint32_t)(a)[3])) /*!< Cast four Big Endian 8-bit byte array to 32-bit unsigned */
#define RFAL_SIZEOF_ARRAY(a) \
(sizeof(a) / sizeof((a)[0])) /*!< Compute the size of an array */
#define RFAL_MAX(a, b) \
(((a) > (b)) ? (a) : (b)) /*!< Return the maximum of the 2 values */
#define RFAL_MIN(a, b) \
(((a) < (b)) ? (a) : (b)) /*!< Return the minimum of the 2 values */
#define RFAL_GETU16(a) \
(((uint16_t)(a)[0] << 8) | \
(uint16_t)(a)[1]) /*!< Cast two Big Endian 8-bits byte array to 16-bits \
unsigned */
#define RFAL_GETU32(a) \
(((uint32_t)(a)[0] << 24) | ((uint32_t)(a)[1] << 16) | \
((uint32_t)(a)[2] << 8) | \
((uint32_t)(a)[3])) /*!< Cast four Big Endian 8-bit byte array to 32-bit \
unsigned */
#ifdef __CSMC__
/* STM8 COSMIC */
#define RFAL_MEMMOVE(s1, s2, n) \
memmove(s1,s2,n) /* PRQA S 5003 # CERT C 9 - string.h from Cosmic only provides functions with low qualified parameters */ /*!< map memmove to string library code */
static inline void *RFAL_MEMCPY(void *s1, const void *s2, uint32_t n) {
return memcpy(s1, s2, (uint16_t)n);
} /* PRQA S 0431 # MISRA 1.1 - string.h from Cosmic only provides functions
with low qualified parameters */
#define RFAL_MEMSET(s1, c, n) \
memset(s1, (char)(c), n) /*!< map memset to string library code */
static inline int32_t RFAL_BYTECMP(void *s1, const void *s2, uint32_t n) {
return (int32_t)memcmp(s1, s2, (uint16_t)n);
} /* PRQA S 0431 # MISRA 1.1 - string.h from Cosmic only provides functions
with low qualified parameters */
#define RFAL_MEMMOVE(s1,s2,n) memmove(s1,s2,n) /* PRQA S 5003 # CERT C 9 - string.h from Cosmic only provides functions with low qualified parameters */ /*!< map memmove to string library code */
static inline void * RFAL_MEMCPY(void *s1, const void *s2, uint32_t n) { return memcpy(s1,s2,(uint16_t)n); } /* PRQA S 0431 # MISRA 1.1 - string.h from Cosmic only provides functions with low qualified parameters */
#define RFAL_MEMSET(s1,c,n) memset(s1,(char)(c),n) /*!< map memset to string library code */
static inline int32_t RFAL_BYTECMP(void *s1, const void *s2, uint32_t n) { return (int32_t)memcmp(s1,s2,(uint16_t)n); } /* PRQA S 0431 # MISRA 1.1 - string.h from Cosmic only provides functions with low qualified parameters */
#else /* __CSMC__ */
#else /* __CSMC__ */
#define RFAL_MEMMOVE memmove /*!< map memmove to string library code */
#define RFAL_MEMCPY memcpy /*!< map memcpy to string library code */
#define RFAL_MEMSET memset /*!< map memset to string library code */
#define RFAL_BYTECMP memcmp /*!< map bytecmp to string library code */
#endif /* __CSMC__ */
#define RFAL_MEMMOVE memmove /*!< map memmove to string library code */
#define RFAL_MEMCPY memcpy /*!< map memcpy to string library code */
#define RFAL_MEMSET memset /*!< map memset to string library code */
#define RFAL_BYTECMP memcmp /*!< map bytecmp to string library code */
#endif /* __CSMC__ */
#define RFAL_NO_WARNING(v) ((void) (v)) /*!< Macro to suppress compiler warning */
#define RFAL_NO_WARNING(v) \
((void)(v)) /*!< Macro to suppress compiler warning */
#ifndef NULL
#define NULL (void *)0 /*!< represents a NULL pointer */
#endif /* !NULL */
#define NULL (void*)0 /*!< represents a NULL pointer */
#endif /* !NULL */
#endif /* RFAL_UTILS_H */
#endif /* RFAL_UTILS_H */
/**
* @}
*
*/
* @}
*
*/

View File

@ -1,25 +1,26 @@
/******************************************************************************
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/*
* PROJECT: ST25R391x firmware
* Revision:
* LANGUAGE: ISO C99
*/
/*! \file rfal_analogConfig.c
*
* \author bkam
@ -35,15 +36,18 @@
*/
#include "rfal_analogConfig.h"
#include "rfal_chip.h"
#include "rfal_platform.h"
#include "rfal_utils.h"
#include "rfal_platform.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
/*
@ -52,7 +56,8 @@ extern const uint16_t rfalAnalogConfigCustomSettingsLength;
******************************************************************************
*/
#define RFAL_TEST_REG 0x0080U /*!< Test Register indicator */
#define RFAL_TEST_REG 0x0080U /*!< Test Register indicator */
/*
******************************************************************************
@ -67,21 +72,18 @@ extern const uint16_t rfalAnalogConfigCustomSettingsLength;
*/
#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 */
/*
******************************************************************************
@ -94,11 +96,10 @@ static rfalAnalogConfigMgmt
* 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 */
/*
@ -113,307 +114,297 @@ static void rfalAnalogConfigPtrUpdate(const uint8_t *analogConfigTbl);
******************************************************************************
*/
/*******************************************************************************/
void rfalAnalogConfigInitialize(void) {
/* Use default Analog configuration settings in Flash by default. */
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 = rfalAnalogConfigCustomSettings;
gRfalAnalogConfigMgmt.configTblSize = rfalAnalogConfigCustomSettingsLength;
#else
gRfalAnalogConfigMgmt.currentAnalogConfigTbl =
rfalAnalogConfigDefaultSettings;
gRfalAnalogConfigMgmt.configTblSize = sizeof(rfalAnalogConfigDefaultSettings);
gRfalAnalogConfigMgmt.currentAnalogConfigTbl = rfalAnalogConfigCustomSettings;
gRfalAnalogConfigMgmt.configTblSize = rfalAnalogConfigCustomSettingsLength;
#else
gRfalAnalogConfigMgmt.currentAnalogConfigTbl = rfalAnalogConfigDefaultSettings;
gRfalAnalogConfigMgmt.configTblSize = sizeof(rfalAnalogConfigDefaultSettings);
#endif
gRfalAnalogConfigMgmt.ready = true;
}
/*******************************************************************************/
bool rfalAnalogConfigIsReady(void) { return gRfalAnalogConfigMgmt.ready; }
/*******************************************************************************/
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) {
return RFAL_ERR_NOMEM;
}
/* Check for invalid parameters */
if ((configTbl == NULL) || (configTblSize == 0U)) {
return RFAL_ERR_PARAM;
}
/* NOTE: On this API (rfalAnalogConfigListWriteRaw) the current AC Table is
* not reset upon error, as on rfalAnalogConfigListWrite. */
/* On rfalAnalogConfigListWrite the AC table is written in mutiple
* chunks of data which may lead to an invalid|incomplte AC */
/* table if an error arises, where here the whole AC Table is written
* all together. */
/* NOTE: Function does not check for the validity of the Table contents (conf
* IDs, conf sets, register address) */
RFAL_MEMCPY(gRfalAnalogConfig, configTbl, configTblSize);
/* Update the total size of configuration settings */
gRfalAnalogConfigMgmt.configTblSize = configTblSize;
rfalAnalogConfigPtrUpdate(gRfalAnalogConfig);
return RFAL_ERR_NONE;
#else
// If Analog Configuration Update is to be disabled
RFAL_NO_WARNING(configTbl);
RFAL_NO_WARNING(configTblSize);
return RFAL_ERR_REQUEST;
#endif /* RFAL_FEATURE_DYNAMIC_ANALOG_CONFIG */
bool rfalAnalogConfigIsReady( void )
{
return gRfalAnalogConfigMgmt.ready;
}
/*******************************************************************************/
ReturnCode rfalAnalogConfigListWrite(uint8_t more,
const rfalAnalogConfig *config) {
ReturnCode rfalAnalogConfigListWriteRaw( const uint8_t *configTbl, uint16_t configTblSize )
{
#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
gRfalAnalogConfigMgmt.configTblSize = 0; // Clear the config List
}
configId = RFAL_GETU16(config->id);
/* Check validity of the Configuration ID. */
/* NOTE: Direction DPO uses 2msb of the Technology field as level indicator */
if (((RFAL_ANALOG_CONFIG_TECH_RFU <=
RFAL_ANALOG_CONFIG_ID_GET_TECH(configId)) &&
((RFAL_ANALOG_CONFIG_ID_GET_DIRECTION(configId) !=
RFAL_ANALOG_CONFIG_DPO) &&
(RFAL_ANALOG_CONFIG_ID_GET_DIRECTION(configId) !=
RFAL_ANALOG_CONFIG_DLMA))) ||
((RFAL_ANALOG_CONFIG_BITRATE_6780 <
RFAL_ANALOG_CONFIG_ID_GET_BITRATE(configId)) &&
(RFAL_ANALOG_CONFIG_BITRATE_211p88 >
RFAL_ANALOG_CONFIG_ID_GET_BITRATE(configId))) ||
(RFAL_ANALOG_CONFIG_BITRATE_1p6 <
RFAL_ANALOG_CONFIG_ID_GET_BITRATE(configId))) {
rfalAnalogConfigInitialize(); /* Revert to default Analog Configuration */
return RFAL_ERR_PARAM;
}
numConfig = config->num;
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)) {
rfalAnalogConfigInitialize(); /* Revert to default Analog Configuration */
return RFAL_ERR_NOMEM;
}
/* NOTE: Function does not check for the validity of the Register Address. */
RFAL_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. */
/* Check if the Configuration Table exceed the Table size */
if ( configTblSize >= RFAL_ANALOG_CONFIG_TBL_SIZE )
{
return RFAL_ERR_NOMEM;
}
/* Check for invalid parameters */
if( (configTbl == NULL) || (configTblSize == 0U) )
{
return RFAL_ERR_PARAM;
}
/* NOTE: On this API (rfalAnalogConfigListWriteRaw) the current AC Table is not reset upon error, as on rfalAnalogConfigListWrite. */
/* On rfalAnalogConfigListWrite the AC table is written in mutiple chunks of data which may lead to an invalid|incomplte AC */
/* table if an error arises, where here the whole AC Table is written all together. */
/* NOTE: Function does not check for the validity of the Table contents (conf IDs, conf sets, register address) */
RFAL_MEMCPY( gRfalAnalogConfig, configTbl, configTblSize );
/* Update the total size of configuration settings */
gRfalAnalogConfigMgmt.configTblSize = configTblSize;
rfalAnalogConfigPtrUpdate(gRfalAnalogConfig);
}
return RFAL_ERR_NONE;
return RFAL_ERR_NONE;
#else
// If Analog Configuration Update is to be disabled
RFAL_NO_WARNING(config);
RFAL_NO_WARNING(more);
return RFAL_ERR_DISABLED;
// If Analog Configuration Update is to be disabled
RFAL_NO_WARNING(configTbl);
RFAL_NO_WARNING(configTblSize);
return RFAL_ERR_REQUEST;
#endif /* RFAL_FEATURE_DYNAMIC_ANALOG_CONFIG */
}
/*******************************************************************************/
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) {
return RFAL_ERR_NOMEM;
}
/* Check for invalid parameters */
if ((configTblSize == NULL) || (tblBuf == NULL)) {
return RFAL_ERR_PARAM;
}
/* Copy the whole Table to the given buffer */
if (gRfalAnalogConfigMgmt.configTblSize > 0U) /* MISRA 21.18 */
{
RFAL_MEMCPY(tblBuf, gRfalAnalogConfigMgmt.currentAnalogConfigTbl,
gRfalAnalogConfigMgmt.configTblSize);
}
*configTblSize = gRfalAnalogConfigMgmt.configTblSize;
return RFAL_ERR_NONE;
}
/*******************************************************************************/
ReturnCode rfalAnalogConfigListRead(rfalAnalogConfigOffset *configOffset,
uint8_t *more, rfalAnalogConfig *config,
rfalAnalogConfigNum numConfig) {
uint16_t configSize;
const rfalAnalogConfigOffset offset = *configOffset;
rfalAnalogConfigNum numConfigSet;
ReturnCode rfalAnalogConfigListWrite( uint8_t more, const rfalAnalogConfig *config )
{
#if RFAL_FEATURE_DYNAMIC_ANALOG_CONFIG
rfalAnalogConfigId configId;
rfalAnalogConfigNum numConfig;
uint8_t configSize;
/* 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) {
return RFAL_ERR_NOMEM;
}
/* Get the number of Configuration set */
numConfigSet =
gRfalAnalogConfigMgmt
.currentAnalogConfigTbl[offset + sizeof(rfalAnalogConfigId)];
/* Pass Configuration Register-Mask-Value sets */
configSize =
(sizeof(rfalAnalogConfigId) + sizeof(rfalAnalogConfigNum) +
(uint16_t)(numConfigSet * sizeof(rfalAnalogConfigRegAddrMaskVal)));
RFAL_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);
return RFAL_ERR_NONE;
}
/*******************************************************************************/
ReturnCode rfalSetAnalogConfig(rfalAnalogConfigId configId) {
rfalAnalogConfigOffset configOffset = 0;
rfalAnalogConfigNum numConfigSet;
const rfalAnalogConfigRegAddrMaskVal *configTbl;
ReturnCode retCode = RFAL_ERR_NONE;
rfalAnalogConfigNum i;
if (true != gRfalAnalogConfigMgmt.ready) {
return RFAL_ERR_REQUEST;
}
/* Search LUT for the specific Configuration ID */
while (true) {
numConfigSet = rfalAnalogConfigSearch(configId, &configOffset);
if (RFAL_ANALOG_CONFIG_LUT_NOT_FOUND == numConfigSet) {
break;
if( true == gRfalAnalogConfigMgmt.ready )
{ /* First Update to the Configuration list. */
gRfalAnalogConfigMgmt.ready = false; // invalidate the config List
gRfalAnalogConfigMgmt.configTblSize = 0; // Clear the config List
}
configTbl =
(rfalAnalogConfigRegAddrMaskVal *)((uintptr_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 */
return RFAL_ERR_NOMEM;
configId = RFAL_GETU16(config->id);
/* Check validity of the Configuration ID. */
/* NOTE: Direction DPO uses 2msb of the Technology field as level indicator */
if( ((RFAL_ANALOG_CONFIG_TECH_RFU <= RFAL_ANALOG_CONFIG_ID_GET_TECH(configId)) && ((RFAL_ANALOG_CONFIG_ID_GET_DIRECTION(configId) != RFAL_ANALOG_CONFIG_DPO) && (RFAL_ANALOG_CONFIG_ID_GET_DIRECTION(configId) != RFAL_ANALOG_CONFIG_DLMA)) )
||((RFAL_ANALOG_CONFIG_BITRATE_6780 < RFAL_ANALOG_CONFIG_ID_GET_BITRATE(configId)) && (RFAL_ANALOG_CONFIG_BITRATE_211p88 > RFAL_ANALOG_CONFIG_ID_GET_BITRATE(configId)))
||(RFAL_ANALOG_CONFIG_BITRATE_1p6 < RFAL_ANALOG_CONFIG_ID_GET_BITRATE(configId))
)
{
rfalAnalogConfigInitialize(); /* Revert to default Analog Configuration */
return RFAL_ERR_PARAM;
}
for (i = 0; i < numConfigSet; i++) {
if ((RFAL_GETU16(configTbl[i].addr) & RFAL_TEST_REG) != 0U) {
RFAL_EXIT_ON_ERR(retCode,
rfalChipChangeTestRegBits(
(RFAL_GETU16(configTbl[i].addr) & ~RFAL_TEST_REG),
configTbl[i].mask, configTbl[i].val));
} else {
RFAL_EXIT_ON_ERR(retCode, rfalChipChangeRegBits(
RFAL_GETU16(configTbl[i].addr),
configTbl[i].mask, configTbl[i].val));
}
numConfig = config->num;
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) )
{
rfalAnalogConfigInitialize(); /* Revert to default Analog Configuration */
return RFAL_ERR_NOMEM;
}
/* NOTE: Function does not check for the validity of the Register Address. */
RFAL_MEMCPY(&gRfalAnalogConfig[gRfalAnalogConfigMgmt.configTblSize], (const uint8_t*)config, configSize);
/* Increment the total size of configuration settings. */
gRfalAnalogConfigMgmt.configTblSize += configSize;
} /* while(found Analog Config Id) */
return retCode;
/* 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. */
rfalAnalogConfigPtrUpdate(gRfalAnalogConfig);
}
return RFAL_ERR_NONE;
#else
// If Analog Configuration Update is to be disabled
RFAL_NO_WARNING(config);
RFAL_NO_WARNING(more);
return RFAL_ERR_DISABLED;
#endif /* RFAL_FEATURE_DYNAMIC_ANALOG_CONFIG */
}
/*******************************************************************************/
uint16_t rfalAnalogConfigGenModeID(rfalMode md, rfalBitRate br, uint16_t dir) {
uint16_t id;
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 )
{
return RFAL_ERR_NOMEM;
}
/* Check for invalid parameters */
if( (configTblSize == NULL) || (tblBuf == NULL) )
{
return RFAL_ERR_PARAM;
}
/* Copy the whole Table to the given buffer */
if( gRfalAnalogConfigMgmt.configTblSize > 0U ) /* MISRA 21.18 */
{
RFAL_MEMCPY( tblBuf, gRfalAnalogConfigMgmt.currentAnalogConfigTbl, gRfalAnalogConfigMgmt.configTblSize );
}
*configTblSize = gRfalAnalogConfigMgmt.configTblSize;
return RFAL_ERR_NONE;
}
/* 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;
/*******************************************************************************/
ReturnCode rfalAnalogConfigListRead( rfalAnalogConfigOffset *configOffset, uint8_t *more, rfalAnalogConfig *config, rfalAnalogConfigNum numConfig )
{
uint16_t configSize;
const 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 )
{
return RFAL_ERR_NOMEM;
}
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;
/* Get the number of Configuration set */
numConfigSet = gRfalAnalogConfigMgmt.currentAnalogConfigTbl[offset + sizeof(rfalAnalogConfigId)];
/* Pass Configuration Register-Mask-Value sets */
configSize = (sizeof(rfalAnalogConfigId) + sizeof(rfalAnalogConfigNum) + (uint16_t)(numConfigSet * sizeof(rfalAnalogConfigRegAddrMaskVal)));
RFAL_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);
case RFAL_MODE_POLL_NFCF:
case RFAL_MODE_LISTEN_NFCF:
id |= RFAL_ANALOG_CONFIG_TECH_NFCF;
break;
return RFAL_ERR_NONE;
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;
}
/*******************************************************************************/
ReturnCode rfalSetAnalogConfig( rfalAnalogConfigId configId )
{
rfalAnalogConfigOffset configOffset = 0;
rfalAnalogConfigNum numConfigSet;
const rfalAnalogConfigRegAddrMaskVal *configTbl;
ReturnCode retCode = RFAL_ERR_NONE;
rfalAnalogConfigNum i;
if( true != gRfalAnalogConfigMgmt.ready )
{
return RFAL_ERR_REQUEST;
}
/* Search LUT for the specific Configuration ID */
while( true )
{
numConfigSet = rfalAnalogConfigSearch(configId, &configOffset);
if( RFAL_ANALOG_CONFIG_LUT_NOT_FOUND == numConfigSet )
{
break;
}
configTbl = (rfalAnalogConfigRegAddrMaskVal *)( (uintptr_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 */
return RFAL_ERR_NOMEM;
}
for ( i = 0; i < numConfigSet; i++)
{
if( (RFAL_GETU16(configTbl[i].addr) & RFAL_TEST_REG) != 0U )
{
RFAL_EXIT_ON_ERR(retCode, rfalChipChangeTestRegBits( (RFAL_GETU16(configTbl[i].addr) & ~RFAL_TEST_REG), configTbl[i].mask, configTbl[i].val) );
}
else
{
RFAL_EXIT_ON_ERR(retCode, rfalChipChangeRegBits( RFAL_GETU16(configTbl[i].addr), configTbl[i].mask, configTbl[i].val) );
}
}
} /* while(found Analog Config Id) */
return retCode;
}
/* 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);
/* Assign Direction */
id |= ((dir << RFAL_ANALOG_CONFIG_DIRECTION_SHIFT) &
RFAL_ANALOG_CONFIG_DIRECTION_MASK);
return id;
/*******************************************************************************/
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;
}
/* 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);
/* Assign Direction */
id |= ((dir<<RFAL_ANALOG_CONFIG_DIRECTION_SHIFT) & RFAL_ANALOG_CONFIG_DIRECTION_MASK);
return id;
}
/*
@ -422,86 +413,76 @@ uint16_t rfalAnalogConfigGenModeID(rfalMode md, rfalBitRate br, uint16_t dir) {
******************************************************************************
*/
/*!
/*!
*****************************************************************************
* \brief Update the link to Analog Configuration LUT
*
* Update the link to the Analog Configuration LUT for the subsequent search
*
* Update the link to the Analog Configuration LUT for the subsequent search
* of Analog Settings.
*
* \param[in] analogConfigTbl: reference to the start of the new Analog
*Configuration Table
*
* \param[in] analogConfigTbl: reference to the start of the new Analog Configuration Table
*
*****************************************************************************
*/
#if RFAL_FEATURE_DYNAMIC_ANALOG_CONFIG
static void rfalAnalogConfigPtrUpdate(const uint8_t *analogConfigTbl) {
gRfalAnalogConfigMgmt.currentAnalogConfigTbl = analogConfigTbl;
gRfalAnalogConfigMgmt.ready = true;
static void rfalAnalogConfigPtrUpdate( const uint8_t* analogConfigTbl )
{
gRfalAnalogConfigMgmt.currentAnalogConfigTbl = analogConfigTbl;
gRfalAnalogConfigMgmt.ready = true;
}
#endif /* RFAL_FEATURE_DYNAMIC_ANALOG_CONFIG */
/*!
/*!
*****************************************************************************
* \brief Search the Analog Configuration LUT for a specific Configuration ID.
*
*
* Search the Analog Configuration LUT for the Configuration ID.
*
*
* \param[in] configId: Configuration ID to search for.
* \param[in] configOffset: Configuration Offset in Table
*
*
* \return number of Configuration Sets
* \return #RFAL_ANALOG_CONFIG_LUT_NOT_FOUND in case Configuration ID is not
*found.
* \return #RFAL_ANALOG_CONFIG_LUT_NOT_FOUND in case Configuration ID is not found.
*****************************************************************************
*/
static rfalAnalogConfigNum rfalAnalogConfigSearch(rfalAnalogConfigId configId,
uint16_t *configOffset) {
rfalAnalogConfigId foundConfigId;
rfalAnalogConfigId configIdMaskVal;
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));
/* When specific ConfigIDs are to be used, override search mask */
if ((RFAL_ANALOG_CONFIG_ID_GET_DIRECTION(configId) ==
RFAL_ANALOG_CONFIG_DPO) ||
(RFAL_ANALOG_CONFIG_ID_GET_DIRECTION(configId) ==
RFAL_ANALOG_CONFIG_DLMA)) {
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) {
configTbl = &currentConfigTbl[i];
foundConfigId = RFAL_GETU16(configTbl);
if (configId == (foundConfigId & configIdMaskVal)) {
*configOffset = (uint16_t)(i + sizeof(rfalAnalogConfigId) +
sizeof(rfalAnalogConfigNum));
return configTbl[sizeof(rfalAnalogConfigId)];
static rfalAnalogConfigNum rfalAnalogConfigSearch( rfalAnalogConfigId configId, uint16_t *configOffset )
{
rfalAnalogConfigId foundConfigId;
rfalAnalogConfigId configIdMaskVal;
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)
);
/* When specific ConfigIDs are to be used, override search mask */
if( (RFAL_ANALOG_CONFIG_ID_GET_DIRECTION(configId) == RFAL_ANALOG_CONFIG_DPO) || (RFAL_ANALOG_CONFIG_ID_GET_DIRECTION(configId) == RFAL_ANALOG_CONFIG_DLMA) )
{
configIdMaskVal = (RFAL_ANALOG_CONFIG_POLL_LISTEN_MODE_MASK | RFAL_ANALOG_CONFIG_TECH_MASK | RFAL_ANALOG_CONFIG_BITRATE_MASK | RFAL_ANALOG_CONFIG_DIRECTION_MASK);
}
/* If Config Id does not match, increment to next Configuration Id */
i += (uint16_t)(sizeof(rfalAnalogConfigId) + sizeof(rfalAnalogConfigNum) +
(configTbl[sizeof(rfalAnalogConfigId)] *
sizeof(rfalAnalogConfigRegAddrMaskVal)));
} /* for */
return RFAL_ANALOG_CONFIG_LUT_NOT_FOUND;
i = (*configOffset);
while( i < gRfalAnalogConfigMgmt.configTblSize )
{
configTbl = &currentConfigTbl[i];
foundConfigId = RFAL_GETU16(configTbl);
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) )
);
} /* for */
return RFAL_ANALOG_CONFIG_LUT_NOT_FOUND;
}

View File

@ -1,18 +1,19 @@
/******************************************************************************
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/*
* PROJECT: ST25R391x firmware
@ -47,16 +48,17 @@ 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 crc = preloadValue;
uint16_t index;
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++) {
crc = rfalCrcUpdateCcitt(crc, buf[index]);
}
for (index = 0; index < length; index++)
{
crc = rfalCrcUpdateCcitt(crc, buf[index]);
}
return crc;
return crc;
}
/*
@ -64,15 +66,16 @@ uint16_t rfalCrcCalculateCcitt(uint16_t preloadValue, const uint8_t* buf,
* LOCAL FUNCTIONS
******************************************************************************
*/
static uint16_t rfalCrcUpdateCcitt(uint16_t crcSeed, uint8_t dataByte) {
uint16_t crc = crcSeed;
uint8_t dat = dataByte;
static uint16_t rfalCrcUpdateCcitt(uint16_t crcSeed, uint8_t dataByte)
{
uint16_t crc = crcSeed;
uint8_t dat = dataByte;
dat ^= (uint8_t)(crc & 0xFFU);
dat ^= (dat << 4);
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;
return crc;
}

View File

@ -1,18 +1,19 @@
/******************************************************************************
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/*
* PROJECT: ST25R391x firmware
@ -28,7 +29,7 @@
*
*/
/*!
*
*
*/
#ifndef RFAL_CRC_H_
@ -46,7 +47,7 @@
* GLOBAL FUNCTION PROTOTYPES
******************************************************************************
*/
/*!
/*!
*****************************************************************************
* \brief Calculate CRC according to CCITT standard.
*
@ -63,7 +64,7 @@
*
*****************************************************************************
*/
extern uint16_t rfalCrcCalculateCcitt(uint16_t preloadValue, const uint8_t* buf,
uint16_t length);
extern uint16_t rfalCrcCalculateCcitt(uint16_t preloadValue, const uint8_t* buf, uint16_t length);
#endif /* RFAL_CRC_H_ */

View File

@ -1,31 +1,31 @@
/******************************************************************************
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/*
* PROJECT: ST25R391x firmware
* $Revision: $
* LANGUAGE: ISO C99
*/
/*! \file rfal_dpo.c
*
* \author Martin Zechleitner
*
* \brief Functions to manage and set dynamic power settings
*
*
*/
/*
@ -33,53 +33,56 @@
* INCLUDES
******************************************************************************
*/
#include "rfal_dpo.h"
#include "rfal_analogConfig.h"
#include "rfal_chip.h"
#include "rfal_dpoTbl.h"
#include "rfal_dpo.h"
#include "rfal_platform.h"
#include "rfal_rf.h"
#include "rfal_chip.h"
#include "rfal_analogConfig.h"
#include "rfal_utils.h"
/*
******************************************************************************
* ENABLE SWITCH
******************************************************************************
*/
/* Feature switch may be enabled or disabled by user at rfal_platform.h
/* Feature switch may be enabled or disabled by user at rfal_platform.h
* Default configuration (ST25R dependant) also provided at rfal_defConfig.h
*
*
* RFAL_FEATURE_DPO
*/
#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
******************************************************************************
*/
/*! RFAL DPO instance */
typedef struct {
bool enabled;
const rfalDpoEntry* currentDpo;
uint8_t tableEntries;
rfalDpoEntry table[RFAL_DPO_TABLE_MAX_ENTRIES];
uint8_t tableEntry;
rfalDpoMeasureFunc measureCallback;
rfalMode curMode;
rfalBitRate curBR;
} rfalDpo;
/*! RFAL DPO instance */
typedef struct{
bool enabled;
const rfalDpoEntry* currentDpo;
uint8_t tableEntries;
rfalDpoEntry table[RFAL_DPO_TABLE_MAX_ENTRIES];
uint8_t tableEntry;
rfalDpoMeasureFunc measureCallback;
rfalMode curMode;
rfalBitRate curBR;
}rfalDpo;
/*
******************************************************************************
@ -94,197 +97,224 @@ static rfalDpo gRfalDpo;
* GLOBAL FUNCTIONS
******************************************************************************
*/
void rfalDpoInitialize(void) {
/* By default DPO is disabled */
rfalDpoSetEnabled(false);
/* Set default measurement */
#if defined(ST25R3911) || defined(ST25R3916) || defined(ST25R3916B)
gRfalDpo.measureCallback = rfalChipMeasureAmplitude;
#else
gRfalDpo.measureCallback = rfalChipMeasureCombinedIQ;
#endif /* ST25R */
/* Use the default Dynamic Power values */
gRfalDpo.currentDpo = rfalDpoDefaultSettings;
gRfalDpo.tableEntries =
(sizeof(rfalDpoDefaultSettings) / RFAL_DPO_TABLE_PARAM_LEN);
RFAL_MEMCPY(gRfalDpo.table, gRfalDpo.currentDpo,
sizeof(rfalDpoDefaultSettings));
void rfalDpoInitialize( void )
{
/* By default DPO is disabled */
rfalDpoSetEnabled( false );
/* Set default measurement */
#if defined(ST25R3911) || defined(ST25R3916) || defined(ST25R3916B)
gRfalDpo.measureCallback = rfalChipMeasureAmplitude;
#else
gRfalDpo.measureCallback = rfalChipMeasureCombinedIQ;
#endif /* ST25R */
/* Use the default Dynamic Power values */
gRfalDpo.currentDpo = rfalDpoDefaultSettings;
gRfalDpo.tableEntries = (sizeof(rfalDpoDefaultSettings) / RFAL_DPO_TABLE_PARAM_LEN);
RFAL_MEMCPY( gRfalDpo.table, gRfalDpo.currentDpo, sizeof(rfalDpoDefaultSettings) );
}
/*******************************************************************************/
void rfalDpoSetMeasureCallback(rfalDpoMeasureFunc pFunc) {
gRfalDpo.measureCallback = pFunc;
void rfalDpoSetMeasureCallback( rfalDpoMeasureFunc pFunc )
{
gRfalDpo.measureCallback = pFunc;
}
/*******************************************************************************/
ReturnCode rfalDpoTableWrite(const rfalDpoEntry* powerTbl,
uint8_t powerTblEntries) {
uint8_t entry;
/* Check if the table size parameter is too big */
if ((powerTblEntries * RFAL_DPO_TABLE_PARAM_LEN) > RFAL_DPO_TABLE_SIZE_MAX) {
return RFAL_ERR_NOMEM;
}
/* Check if the first increase entry is 0xFF */
if ((powerTblEntries == 0U) || (powerTbl == NULL)) {
return RFAL_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) {
return RFAL_ERR_PARAM;
ReturnCode rfalDpoTableWrite( const rfalDpoEntry* powerTbl, uint8_t powerTblEntries )
{
uint8_t entry;
/* Check if the table size parameter is too big */
if( (powerTblEntries * RFAL_DPO_TABLE_PARAM_LEN) > RFAL_DPO_TABLE_SIZE_MAX)
{
return RFAL_ERR_NOMEM;
}
}
/* Copy the data set */
RFAL_MEMCPY(gRfalDpo.table, powerTbl,
(powerTblEntries * RFAL_DPO_TABLE_PARAM_LEN));
gRfalDpo.currentDpo = gRfalDpo.table;
gRfalDpo.tableEntries = powerTblEntries;
if (gRfalDpo.tableEntry > powerTblEntries) {
/* powerTblEntries is always greater then zero, verified at parameter check
*/
gRfalDpo.tableEntry = (powerTblEntries - 1U);
}
return RFAL_ERR_NONE;
}
/*******************************************************************************/
ReturnCode rfalDpoTableRead(rfalDpoEntry* tblBuf, uint8_t tblBufEntries,
uint8_t* tableEntries) {
/* Wrong request */
if ((tblBuf == NULL) || (tblBufEntries < gRfalDpo.tableEntries) ||
(tableEntries == NULL)) {
return RFAL_ERR_PARAM;
}
/* Not properly initialized */
if (gRfalDpo.currentDpo == NULL) {
return RFAL_ERR_WRONG_STATE;
}
/* Copy the whole Table to the given buffer */
RFAL_MEMCPY(tblBuf, gRfalDpo.currentDpo,
(tblBufEntries * RFAL_DPO_TABLE_PARAM_LEN));
*tableEntries = gRfalDpo.tableEntries;
return RFAL_ERR_NONE;
}
/*******************************************************************************/
ReturnCode rfalDpoAdjust(void) {
uint8_t refValue;
uint16_t modeID;
rfalBitRate br;
rfalMode mode;
uint8_t tableEntry;
const rfalDpoEntry* dpoTable;
/* Initialize local vars */
tableEntry = gRfalDpo.tableEntry;
dpoTable = (const rfalDpoEntry*)gRfalDpo.currentDpo;
refValue = 0;
mode = RFAL_MODE_NONE;
br = RFAL_BR_KEEP;
/* Obtain RFAL's current mode and bit rate */
mode = rfalGetMode();
rfalGetBitRate(&br, NULL);
/* Check if the Power Adjustment is disabled and *
* if the callback to the measurement method is properly set */
if ((!gRfalDpo.enabled) || (gRfalDpo.measureCallback == NULL)) {
return RFAL_ERR_PARAM;
}
/* Ensure that the current mode is Passive Poller and table is initialized*/
if ((!rfalIsModePassivePoll(mode)) || (gRfalDpo.currentDpo == NULL)) {
return RFAL_ERR_WRONG_STATE;
}
/* Ensure a proper measure reference value */
if (RFAL_ERR_NONE != gRfalDpo.measureCallback(&refValue)) {
return RFAL_ERR_IO;
}
if (refValue >=
dpoTable[gRfalDpo.tableEntry].inc) { /* Increase the output power */
/* the top of the table represents the highest amplitude value*/
if (gRfalDpo.tableEntry == 0U) {
/* Maximum driver value has been reached */
} else {
/* Go up in the table to decrease the driver resistance */
tableEntry--;
/* Check if the first increase entry is 0xFF */
if( (powerTblEntries == 0U) || (powerTbl == NULL) )
{
return RFAL_ERR_PARAM;
}
} else if (refValue <= dpoTable[gRfalDpo.tableEntry]
.dec) { /* Decrease the output power */
/* The bottom is the highest possible value */
if ((gRfalDpo.tableEntry + 1U) >= gRfalDpo.tableEntries) {
/* minimum driver value has been reached */
} else {
/* Go down in the table to increase the driver resistance */
tableEntry++;
/* Check if the entries of the dynamic power table are valid */
for( entry = 0; entry < powerTblEntries; entry++ )
{
if(powerTbl[entry].inc < powerTbl[entry].dec)
{
return RFAL_ERR_PARAM;
}
}
} else {
/* Fall through to evaluate whether to write dpo and its associated analog
* configs */
}
/* Apply new configs if there was a change on DPO level or RFAL mode|bitrate
*/
/* Also adjust power in case mode is not yet set and a different table
* entry|setting is applicbale */
if ((mode != gRfalDpo.curMode) || (br != gRfalDpo.curBR) ||
(tableEntry != gRfalDpo.tableEntry) ||
((mode == RFAL_MODE_NONE) && (tableEntry != gRfalDpo.tableEntry))) {
/* Update local context */
gRfalDpo.curMode = mode;
gRfalDpo.curBR = br;
gRfalDpo.tableEntry = tableEntry;
/* Get the new value for RFO resistance form the table and apply the new RFO
* resistance setting */
rfalChipSetRFO(dpoTable[gRfalDpo.tableEntry].rfoRes);
/* Apply the DPO Analog Config according to this threshold */
/* Technology field is being extended for DPO: 2msb are used for threshold
* step (only 4 allowed) */
modeID = rfalAnalogConfigGenModeID(
gRfalDpo.curMode, gRfalDpo.curBR,
RFAL_ANALOG_CONFIG_DPO); /* Generate Analog Config mode ID */
modeID |= (((uint16_t)gRfalDpo.tableEntry << RFAL_DPO_ANALOGCONFIG_SHIFT) &
RFAL_DPO_ANALOGCONFIG_MASK); /* Add DPO threshold step|level */
rfalSetAnalogConfig(modeID); /* Apply DPO Analog Config */
}
return RFAL_ERR_NONE;
/* Copy the data set */
RFAL_MEMCPY( gRfalDpo.table, powerTbl, (powerTblEntries * RFAL_DPO_TABLE_PARAM_LEN) );
gRfalDpo.currentDpo = gRfalDpo.table;
gRfalDpo.tableEntries = powerTblEntries;
if( gRfalDpo.tableEntry > powerTblEntries )
{
/* powerTblEntries is always greater then zero, verified at parameter check */
gRfalDpo.tableEntry = (powerTblEntries - 1U);
}
return RFAL_ERR_NONE;
}
/*******************************************************************************/
const rfalDpoEntry* rfalDpoGetCurrentTableEntry(void) {
return &gRfalDpo.currentDpo[gRfalDpo.tableEntry];
ReturnCode rfalDpoTableRead( rfalDpoEntry* tblBuf, uint8_t tblBufEntries, uint8_t* tableEntries )
{
/* Wrong request */
if( (tblBuf == NULL) || (tblBufEntries < gRfalDpo.tableEntries) || (tableEntries == NULL) )
{
return RFAL_ERR_PARAM;
}
/* Not properly initialized */
if( gRfalDpo.currentDpo == NULL )
{
return RFAL_ERR_WRONG_STATE;
}
/* Copy the whole Table to the given buffer */
RFAL_MEMCPY( tblBuf, gRfalDpo.currentDpo, (tblBufEntries * RFAL_DPO_TABLE_PARAM_LEN) );
*tableEntries = gRfalDpo.tableEntries;
return RFAL_ERR_NONE;
}
/*******************************************************************************/
uint8_t rfalDpoGetCurrentTableIndex(void) { return gRfalDpo.tableEntry; }
/*******************************************************************************/
void rfalDpoSetEnabled(bool enable) {
gRfalDpo.enabled = enable;
gRfalDpo.curMode = RFAL_MODE_NONE;
gRfalDpo.curBR = RFAL_BR_KEEP;
gRfalDpo.tableEntry = 0;
ReturnCode rfalDpoAdjust( void )
{
uint8_t refValue;
uint16_t modeID;
rfalBitRate br;
rfalMode mode;
uint8_t tableEntry;
const rfalDpoEntry* dpoTable;
/* Initialize local vars */
tableEntry = gRfalDpo.tableEntry;
dpoTable = (const rfalDpoEntry*) gRfalDpo.currentDpo;
refValue = 0;
mode = RFAL_MODE_NONE;
br = RFAL_BR_KEEP;
/* Obtain RFAL's current mode and bit rate */
mode = rfalGetMode();
rfalGetBitRate( &br, NULL );
/* Check if the Power Adjustment is disabled and *
* if the callback to the measurement method is properly set */
if( (!gRfalDpo.enabled) || (gRfalDpo.measureCallback == NULL) )
{
return RFAL_ERR_PARAM;
}
/* Ensure that the current mode is Passive Poller and table is initialized*/
if( (!rfalIsModePassivePoll( mode )) || (gRfalDpo.currentDpo == NULL) )
{
return RFAL_ERR_WRONG_STATE;
}
/* Ensure a proper measure reference value */
if( RFAL_ERR_NONE != gRfalDpo.measureCallback( &refValue ) )
{
return RFAL_ERR_IO;
}
if( refValue >= dpoTable[gRfalDpo.tableEntry].inc )
{ /* Increase the output power */
/* the top of the table represents the highest amplitude value*/
if( gRfalDpo.tableEntry == 0U )
{
/* Maximum driver value has been reached */
}
else
{
/* Go up in the table to decrease the driver resistance */
tableEntry--;
}
}
else if( refValue <= dpoTable[gRfalDpo.tableEntry].dec )
{ /* Decrease the output power */
/* The bottom is the highest possible value */
if( (gRfalDpo.tableEntry + 1U) >= gRfalDpo.tableEntries )
{
/* minimum driver value has been reached */
}
else
{
/* Go down in the table to increase the driver resistance */
tableEntry++;
}
}
else
{
/* Fall through to evaluate whether to write dpo and its associated analog configs */
}
/* Apply new configs if there was a change on DPO level or RFAL mode|bitrate */
/* Also adjust power in case mode is not yet set and a different table entry|setting is applicbale */
if( (mode != gRfalDpo.curMode) || (br != gRfalDpo.curBR) || (tableEntry != gRfalDpo.tableEntry) || ((mode == RFAL_MODE_NONE) && (tableEntry != gRfalDpo.tableEntry)) )
{
/* Update local context */
gRfalDpo.curMode = mode;
gRfalDpo.curBR = br;
gRfalDpo.tableEntry = tableEntry;
/* Get the new value for RFO resistance form the table and apply the new RFO resistance setting */
rfalChipSetRFO( dpoTable[gRfalDpo.tableEntry].rfoRes );
/* Apply the DPO Analog Config according to this threshold */
/* Technology field is being extended for DPO: 2msb are used for threshold step (only 4 allowed) */
modeID = rfalAnalogConfigGenModeID( gRfalDpo.curMode, gRfalDpo.curBR, RFAL_ANALOG_CONFIG_DPO ); /* Generate Analog Config mode ID */
modeID |= (((uint16_t)gRfalDpo.tableEntry << RFAL_DPO_ANALOGCONFIG_SHIFT) & RFAL_DPO_ANALOGCONFIG_MASK); /* Add DPO threshold step|level */
rfalSetAnalogConfig( modeID ); /* Apply DPO Analog Config */
}
return RFAL_ERR_NONE;
}
/*******************************************************************************/
bool rfalDpoIsEnabled(void) { return gRfalDpo.enabled; }
const rfalDpoEntry* rfalDpoGetCurrentTableEntry( void )
{
return &gRfalDpo.currentDpo[gRfalDpo.tableEntry];
}
/*******************************************************************************/
uint8_t rfalDpoGetCurrentTableIndex( void )
{
return gRfalDpo.tableEntry;
}
/*******************************************************************************/
void rfalDpoSetEnabled( bool enable )
{
gRfalDpo.enabled = enable;
gRfalDpo.curMode = RFAL_MODE_NONE;
gRfalDpo.curBR = RFAL_BR_KEEP;
gRfalDpo.tableEntry = 0;
}
/*******************************************************************************/
bool rfalDpoIsEnabled( void )
{
return gRfalDpo.enabled;
}
#endif /* RFAL_FEATURE_DPO */

View File

@ -1,18 +1,19 @@
/******************************************************************************
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/*
* PROJECT: ST25R391x firmware
@ -43,9 +44,9 @@
******************************************************************************
*/
/* Feature switch may be enabled or disabled by user at rfal_platform.h
/* Feature switch may be enabled or disabled by user at rfal_platform.h
* Default configuration (ST25R dependant) also provided at rfal_defConfig.h
*
*
* RFAL_FEATURE_NFCV
*/
@ -57,22 +58,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
@ -80,317 +81,329 @@
#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. */
/*
******************************************************************************
* LOCAL VARIABLES
******************************************************************************
*/
static rfalIso15693PhyConfig_t
gIso15693PhyConfig; /*!< current phy configuration */
static rfalIso15693PhyConfig_t gIso15693PhyConfig; /*!< current phy configuration */
/*
******************************************************************************
* LOCAL FUNCTION PROTOTYPES
******************************************************************************
*/
static ReturnCode rfalIso15693PhyVCDCode1Of4(const uint8_t data,
uint8_t* outbuffer,
uint16_t maxOutBufLen,
uint16_t* outBufLen);
static ReturnCode rfalIso15693PhyVCDCode1Of256(const uint8_t data,
uint8_t* outbuffer,
uint16_t maxOutBufLen,
uint16_t* outBufLen);
static ReturnCode rfalIso15693PhyVCDCode1Of4(const uint8_t data, uint8_t* outbuffer, uint16_t maxOutBufLen, uint16_t* outBufLen);
static ReturnCode rfalIso15693PhyVCDCode1Of256(const uint8_t data, uint8_t* outbuffer, uint16_t maxOutBufLen, uint16_t* outBufLen);
/*
******************************************************************************
* GLOBAL FUNCTIONS
******************************************************************************
*/
ReturnCode rfalIso15693PhyConfigure(
const rfalIso15693PhyConfig_t* config,
const struct iso15693StreamConfig** needed_stream_config) {
static struct iso15693StreamConfig auxConfig = {
/* 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 */
RFAL_MEMCPY((uint8_t*)&gIso15693PhyConfig, (const uint8_t*)config,
sizeof(rfalIso15693PhyConfig_t));
if (config->speedMode <=
3U) { /* If valid speed mode adjust report period accordingly */
auxConfig.report_period_length = (3U - (uint8_t)config->speedMode);
} else { /* If invalid default to normal (high) speed */
auxConfig.report_period_length = 3;
}
*needed_stream_config = &auxConfig;
return RFAL_ERR_NONE;
}
ReturnCode rfalIso15693PhyGetConfiguration(rfalIso15693PhyConfig_t* config) {
RFAL_MEMCPY(config, &gIso15693PhyConfig, sizeof(rfalIso15693PhyConfig_t));
return RFAL_ERR_NONE;
}
ReturnCode rfalIso15693VCDCode(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 = RFAL_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);
uint8_t crc_len;
uint8_t* outputBuf;
uint16_t outputBufSize;
crc_len = (uint8_t)((sendCrc) ? 2 : 0);
*actOutBufSize = 0;
if (ISO15693_VCD_CODING_1_4 == gIso15693PhyConfig.coding) {
sof = ISO15693_DAT_SOF_1_4;
eof = ISO15693_DAT_EOF_1_4;
txFunc = rfalIso15693PhyVCDCode1Of4;
*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 RFAL_ERR_NOMEM;
ReturnCode rfalIso15693PhyConfigure(const rfalIso15693PhyConfig_t* config, const struct iso15693StreamConfig ** needed_stream_config )
{
static struct iso15693StreamConfig auxConfig = { /* 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 */
RFAL_MEMCPY( (uint8_t*)&gIso15693PhyConfig, (const uint8_t*)config, sizeof(rfalIso15693PhyConfig_t));
if ( config->speedMode <= 3U)
{ /* If valid speed mode adjust report period accordingly */
auxConfig.report_period_length = (3U - (uint8_t)config->speedMode);
}
} else {
sof = ISO15693_DAT_SOF_1_256;
eof = ISO15693_DAT_EOF_1_256;
txFunc = rfalIso15693PhyVCDCode1Of256;
*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 */
return RFAL_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 */
return RFAL_ERR_NOMEM;
}
else
{ /* If invalid default to normal (high) speed */
auxConfig.report_period_length = 3;
}
}
if (length == 0U) {
*subbit_total_length = 1;
}
*needed_stream_config = &auxConfig;
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 */
}
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;
(*actOutBufSize)++;
outputBufSize--;
outputBuf++;
}
while ((*offset < length) && (err == RFAL_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 */
outputBufSize -= filled_size;
if (err == RFAL_ERR_NONE) {
(*offset)++;
}
}
if (err != RFAL_ERR_NONE) {
return RFAL_ERR_AGAIN;
}
while ((err == RFAL_ERR_NONE) && sendCrc && (*offset < (length + 2U))) {
uint16_t filled_size;
if ((0U == crc) && (length != 0U)) {
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 */
transbuf[0] = (uint8_t)(crc & 0xffU);
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 */
outputBufSize -= filled_size;
if (err == RFAL_ERR_NONE) {
(*offset)++;
}
}
if (err != RFAL_ERR_NONE) {
return RFAL_ERR_AGAIN;
}
if (((!sendCrc) && (*offset == length)) ||
(sendCrc && (*offset == (length + 2U)))) {
*outputBuf = eof;
(*actOutBufSize)++;
outputBufSize--;
outputBuf++;
} else {
return RFAL_ERR_AGAIN;
}
return err;
}
ReturnCode rfalIso15693VICCDecode(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 = RFAL_ERR_NONE;
uint16_t crc;
uint16_t mp; /* Current bit position in manchester bit inBuf*/
uint16_t bp; /* Current bit position in outBuf */
*bitsBeforeCol = 0;
*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 RFAL_ERR_FRAMING;
}
ISO_15693_DEBUG("SOF\n");
if (outBufLen == 0U) {
return RFAL_ERR_NONE;
}
}
mp = 5; /* 5 bits were SOF, now manchester starts: 2 bits per payload bit */
bp = 0;
ReturnCode rfalIso15693PhyGetConfiguration(rfalIso15693PhyConfig_t* config)
{
RFAL_MEMCPY(config, &gIso15693PhyConfig, sizeof(rfalIso15693PhyConfig_t));
RFAL_MEMSET(outBuf, 0, outBufLen);
return RFAL_ERR_NONE;
}
if (inBufLen == 0U) {
return RFAL_ERR_CRC;
}
ReturnCode rfalIso15693VCDCode(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 = RFAL_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);
uint8_t crc_len;
uint8_t* outputBuf;
uint16_t outputBufSize;
for (; mp < ((inBufLen * 8U) - 2U); mp += 2U) {
bool isEOF = false;
crc_len = (uint8_t)((sendCrc)?2:0);
uint8_t man;
man = (inBuf[mp / 8U] >> (mp % 8U)) & 0x1U;
man |= ((inBuf[(mp + 1U) / 8U] >> ((mp + 1U) % 8U)) & 0x1U) << 1;
if (1U == man) {
bp++;
*actOutBufSize = 0;
if (ISO15693_VCD_CODING_1_4 == gIso15693PhyConfig.coding)
{
sof = ISO15693_DAT_SOF_1_4;
eof = ISO15693_DAT_EOF_1_4;
txFunc = rfalIso15693PhyVCDCode1Of4;
*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 RFAL_ERR_NOMEM;
}
}
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 */
ISO_15693_DEBUG("EOF\n");
isEOF = true;
}
}
if (((0U == man) || (3U == man)) && (!isEOF)) {
if (bp >= ignoreBits) {
err = RFAL_ERR_RF_COLLISION;
} else {
/* ignored collision: leave as 0 */
bp++;
}
}
if ((bp >= (outBufLen * 8U)) || (err == RFAL_ERR_RF_COLLISION) ||
isEOF) { /* Don't write beyond the end */
break;
}
}
else
{
sof = ISO15693_DAT_SOF_1_256;
eof = ISO15693_DAT_EOF_1_256;
txFunc = rfalIso15693PhyVCDCode1Of256;
*subbit_total_length = (
( 1U /* SOF */
+ ((length + (uint16_t)crc_len) * 64U)
+ 1U) /* EOF */
);
*outBufPos = (bp / 8U);
*bitsBeforeCol = bp;
if (*offset != 0U)
{
if (outBufSize < 64U) { /* 64 should be safe: enough a single byte data in 1of256 */
return RFAL_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 */
return RFAL_ERR_NOMEM;
}
}
}
if (length == 0U)
{
*subbit_total_length = 1;
}
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 */
}
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;
(*actOutBufSize)++;
outputBufSize--;
outputBuf++;
}
while ((*offset < length) && (err == RFAL_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 */
outputBufSize -= filled_size;
if (err == RFAL_ERR_NONE) {
(*offset)++;
}
}
if (err != RFAL_ERR_NONE) {
return RFAL_ERR_AGAIN;
}
while ((err == RFAL_ERR_NONE) && sendCrc && (*offset < (length + 2U)))
{
uint16_t filled_size;
if ((0U==crc) && (length != 0U))
{
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 */
transbuf[0] = (uint8_t)(crc & 0xffU);
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 */
outputBufSize -= filled_size;
if (err == RFAL_ERR_NONE) {
(*offset)++;
}
}
if (err != RFAL_ERR_NONE) {
return RFAL_ERR_AGAIN;
}
if (((!sendCrc) && (*offset == length))
|| (sendCrc && (*offset == (length + 2U))))
{
*outputBuf = eof;
(*actOutBufSize)++;
outputBufSize--;
outputBuf++;
}
else
{
return RFAL_ERR_AGAIN;
}
if (err != RFAL_ERR_NONE) {
return err;
}
}
if ((bp % 8U) != 0U) {
return RFAL_ERR_CRC;
}
ReturnCode rfalIso15693VICCDecode(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 = RFAL_ERR_NONE;
uint16_t crc;
uint16_t mp; /* Current bit position in manchester bit inBuf*/
uint16_t bp; /* Current bit position in outBuf */
if (*outBufPos > 2U) {
/* finally, check crc */
ISO_15693_DEBUG("Calculate CRC, val: 0x%x, outBufLen: ", *outBuf);
ISO_15693_DEBUG("0x%x ", *outBufPos - 2);
*bitsBeforeCol = 0;
*outBufPos = 0;
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])) {
err = RFAL_ERR_NONE;
ISO_15693_DEBUG("OK\n");
} else {
ISO_15693_DEBUG("error! Expected: 0x%x, got ", crc);
ISO_15693_DEBUG("0x%hhx 0x%hhx\n", outBuf[*outBufPos - 2],
outBuf[*outBufPos - 1]);
err = RFAL_ERR_CRC;
/* 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 RFAL_ERR_FRAMING;
}
} else {
err = RFAL_ERR_CRC;
}
ISO_15693_DEBUG("SOF\n");
return err;
if (outBufLen == 0U)
{
return RFAL_ERR_NONE;
}
mp = 5; /* 5 bits were SOF, now manchester starts: 2 bits per payload bit */
bp = 0;
RFAL_MEMSET(outBuf,0,outBufLen);
if (inBufLen == 0U)
{
return RFAL_ERR_CRC;
}
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)
{
bp++;
}
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 */
ISO_15693_DEBUG("EOF\n");
isEOF = true;
}
}
if ( ((0U == man) || (3U == man)) && (!isEOF) )
{
if (bp >= ignoreBits)
{
err = RFAL_ERR_RF_COLLISION;
}
else
{
/* ignored collision: leave as 0 */
bp++;
}
}
if ( (bp >= (outBufLen * 8U)) || (err == RFAL_ERR_RF_COLLISION) || isEOF )
{ /* Don't write beyond the end */
break;
}
}
*outBufPos = (bp / 8U);
*bitsBeforeCol = bp;
if (err != RFAL_ERR_NONE)
{
return err;
}
if ((bp%8U) != 0U)
{
return RFAL_ERR_CRC;
}
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]))
{
err = RFAL_ERR_NONE;
ISO_15693_DEBUG("OK\n");
}
else
{
ISO_15693_DEBUG("error! Expected: 0x%x, got ", crc);
ISO_15693_DEBUG("0x%hhx 0x%hhx\n", outBuf[*outBufPos-2], outBuf[*outBufPos-1]);
err = RFAL_ERR_CRC;
}
}
else
{
err = RFAL_ERR_CRC;
}
return err;
}
/*
@ -398,7 +411,7 @@ ReturnCode rfalIso15693VICCDecode(const uint8_t* inBuf, uint16_t inBufLen,
* LOCAL FUNCTIONS
******************************************************************************
*/
/*!
/*!
*****************************************************************************
* \brief Perform 1 of 4 coding and send coded data
*
@ -414,48 +427,48 @@ ReturnCode rfalIso15693VICCDecode(const uint8_t* inBuf, uint16_t inBufLen,
*
*****************************************************************************
*/
static ReturnCode rfalIso15693PhyVCDCode1Of4(const uint8_t data,
uint8_t* outbuffer,
uint16_t maxOutBufLen,
uint16_t* outBufLen) {
uint8_t tmp;
ReturnCode err = RFAL_ERR_NONE;
uint16_t a;
uint8_t* outbuf = outbuffer;
static ReturnCode rfalIso15693PhyVCDCode1Of4(const uint8_t data, uint8_t* outbuffer, uint16_t maxOutBufLen, uint16_t* outBufLen)
{
uint8_t tmp;
ReturnCode err = RFAL_ERR_NONE;
uint16_t a;
uint8_t* outbuf = outbuffer;
*outBufLen = 0;
*outBufLen = 0;
if (maxOutBufLen < 4U) {
return RFAL_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;
if (maxOutBufLen < 4U) {
return RFAL_ERR_NOMEM;
}
outbuf++;
(*outBufLen)++;
tmp >>= 2;
}
return err;
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;
}
outbuf++;
(*outBufLen)++;
tmp >>= 2;
}
return err;
}
/*!
/*!
*****************************************************************************
* \brief Perform 1 of 256 coding and send coded data
*
@ -472,47 +485,46 @@ static ReturnCode rfalIso15693PhyVCDCode1Of4(const uint8_t data,
*
*****************************************************************************
*/
static ReturnCode rfalIso15693PhyVCDCode1Of256(const uint8_t data,
uint8_t* outbuffer,
uint16_t maxOutBufLen,
uint16_t* outBufLen) {
uint8_t tmp;
ReturnCode err = RFAL_ERR_NONE;
uint16_t a;
uint8_t* outbuf = outbuffer;
static ReturnCode rfalIso15693PhyVCDCode1Of256(const uint8_t data, uint8_t* outbuffer, uint16_t maxOutBufLen, uint16_t* outBufLen)
{
uint8_t tmp;
ReturnCode err = RFAL_ERR_NONE;
uint16_t a;
uint8_t* outbuf = outbuffer;
*outBufLen = 0;
*outBufLen = 0;
if (maxOutBufLen < 64U) {
return RFAL_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;
if (maxOutBufLen < 64U) {
return RFAL_ERR_NOMEM;
}
outbuf++;
(*outBufLen)++;
tmp -= 4U; /* PRQA S 2911 # CERT INT30 - Intentional underflow, part of the
coding */
}
return err;
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;
}
outbuf++;
(*outBufLen)++;
tmp -= 4U; /* PRQA S 2911 # CERT INT30 - Intentional underflow, part of the coding */
}
return err;
}
#endif /* RFAL_FEATURE_NFCV */

View File

@ -1,18 +1,19 @@
/******************************************************************************
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/*
* PROJECT: ST25R391x firmware
@ -28,7 +29,7 @@
*
*/
/*!
*
*
*/
#ifndef RFAL_ISO_15693_2_H
@ -48,28 +49,27 @@
******************************************************************************
*/
/*! Enum holding possible VCD codings */
typedef enum {
ISO15693_VCD_CODING_1_4,
ISO15693_VCD_CODING_1_256
} rfalIso15693VcdCoding_t;
typedef enum
{
ISO15693_VCD_CODING_1_4,
ISO15693_VCD_CODING_1_256
}rfalIso15693VcdCoding_t;
/*! Enum holding possible VICC datarates */
/*! Configuration parameter used by rfalIso15693PhyConfigure */
typedef struct {
rfalIso15693VcdCoding_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 */
} rfalIso15693PhyConfig_t;
typedef struct
{
rfalIso15693VcdCoding_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 */
}rfalIso15693PhyConfig_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 report_period_length; /*!< the length of the reporting period
2^report_period_length*/
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*/
};
/*
******************************************************************************
@ -77,41 +77,38 @@ 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
******************************************************************************
*/
/*!
/*!
*****************************************************************************
* \brief Initialize the ISO15693 phy
*
* \param[in] config : ISO15693 phy related configuration (See
*rfalIso15693PhyConfig_t) \param[out] needed_stream_config : return a pointer
*to the stream config needed for this iso15693 config. To be used for configure
*RF chip.
* \param[in] config : ISO15693 phy related configuration (See rfalIso15693PhyConfig_t)
* \param[out] needed_stream_config : return a pointer to the stream config
* needed for this iso15693 config. To be used for configure RF chip.
*
* \return RFAL_ERR_IO : Error during communication.
* \return RFAL_ERR_NONE : No error.
*
*****************************************************************************
*/
extern ReturnCode rfalIso15693PhyConfigure(
const rfalIso15693PhyConfig_t* config,
const struct iso15693StreamConfig** needed_stream_config);
extern ReturnCode rfalIso15693PhyConfigure(const rfalIso15693PhyConfig_t* config, const struct iso15693StreamConfig ** needed_stream_config );
/*!
/*!
*****************************************************************************
* \brief Return current phy configuration
*
@ -124,10 +121,9 @@ extern ReturnCode rfalIso15693PhyConfigure(
*
*****************************************************************************
*/
extern ReturnCode rfalIso15693PhyGetConfiguration(
rfalIso15693PhyConfig_t* config);
extern ReturnCode rfalIso15693PhyGetConfiguration(rfalIso15693PhyConfig_t* config);
/*!
/*!
*****************************************************************************
* \brief Code an ISO15693 compatible frame
*
@ -139,51 +135,46 @@ extern ReturnCode rfalIso15693PhyGetConfiguration(
* \param[in] sendCrc : If set to true, CRC is appended to the frame
* \param[in] sendFlags : If set to true, flag field is sent according to
* ISO15693.
* \param[in] picopassMode : If set to true, the coding will be according to
Picopass
* \param[out] subbit_total_length : Return the complete bytes which need to
* \param[in] picopassMode : If set to true, the coding will be according to Picopass
* \param[out] subbit_total_length : Return the complete bytes which need to
* be send for the current coding
* \param[in,out] offset : Set to 0 for first transfer, function will
update it to point to next byte to be coded
* \param[out] outbuf : buffer where the function will store the coded
subbit stream
* \param[in,out] offset : Set to 0 for first transfer, function will update it to
point to next byte to be coded
* \param[out] outbuf : buffer where the function will store the coded subbit stream
* \param[out] outBufSize : the size of the output buffer
* \param[out] actOutBufSize : the amount of data stored into the buffer at
this call
* \param[out] actOutBufSize : the amount of data stored into the buffer at this call
*
* \return RFAL_ERR_IO : Error during communication.
* \return RFAL_ERR_AGAIN : Data was not coded all the way. Call function
again with a new/emptied buffer
* \return RFAL_ERR_NO_MEM : In case outBuf is not big enough. Needs to have at
least 5 bytes for 1of4 coding and 65 bytes for
1of256 coding
* \return RFAL_ERR_AGAIN : Data was not coded all the way. Call function again with a new/emptied buffer
* \return RFAL_ERR_NO_MEM : In case outBuf is not big enough. Needs to have at
least 5 bytes for 1of4 coding and 65 bytes for 1of256 coding
* \return RFAL_ERR_NONE : No error
*
*****************************************************************************
*/
extern ReturnCode rfalIso15693VCDCode(
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 rfalIso15693VCDCode(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);
/*!
/*!
*****************************************************************************
* \brief Receive an ISO15693 compatible frame
*
* This function receives an ISO15693 frame from the ST25R391x, decodes the
*frame and writes the raw data to \a buffer. \note Buffer needs to be big
*enough to hold CRC also (+2 bytes)
* This function receives an ISO15693 frame from the ST25R391x, decodes the frame
* and writes the raw data to \a buffer.
* \note Buffer needs to be big enough to hold CRC also (+2 bytes)
*
* \param[in] inBuf : buffer with the hamming coded stream to be decoded
* \param[in] inBufLen : number of bytes to decode (=length of buffer).
* \param[out] outBuf : buffer where received data shall be written to.
* \param[in] outBufLen : Length of output buffer, should be approx twice
*the size of inBuf \param[out] outBufPos : The number of decoded bytes. Could
*be used in extended implementation to allow multiple calls \param[out]
*bitsBeforeCol : in case of RFAL_ERR_RF_COLLISION this value holds the number
*of bits in the current byte where the collision happened \param[in] ignoreBits
*: number of bits in the beginning where collisions will be ignored \param[in]
*picopassMode : if set to true, the decoding will be according to Picopass
* \param[in] outBufLen : Length of output buffer, should be approx twice the size of inBuf
* \param[out] outBufPos : The number of decoded bytes. Could be used in
* extended implementation to allow multiple calls
* \param[out] bitsBeforeCol : in case of RFAL_ERR_RF_COLLISION this value holds the
* number of bits in the current byte where the collision happened
* \param[in] ignoreBits : number of bits in the beginning where collisions will be ignored
* \param[in] picopassMode : if set to true, the decoding will be according to Picopass
*
* \return RFAL_ERR_RF_COLLISION : collision occured, data uncorrect
* \return RFAL_ERR_CRC : CRC error, data uncorrect
@ -192,9 +183,14 @@ extern ReturnCode rfalIso15693VCDCode(
*
*****************************************************************************
*/
extern ReturnCode rfalIso15693VICCDecode(
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 rfalIso15693VICCDecode(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 */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -242,7 +242,7 @@ ReturnCode rfalNfcvPollerInventory(rfalNfcvNumSlots nSlots, uint8_t maskLen,
ReturnCode ret;
rfalNfcvInventoryReq invReq;
uint16_t rxLen;
`
if (((maskVal == NULL) && (maskLen != 0U)) || (invRes == NULL)) {
return RFAL_ERR_PARAM;
}

View File

@ -1,18 +1,19 @@
/******************************************************************************
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/*
* PROJECT: ST25R391x firmware
@ -24,7 +25,7 @@
*
* \author Gustavo Patricio
*
* \brief Implementation of ST25TB interface
* \brief Implementation of ST25TB interface
*
*/
@ -41,10 +42,10 @@
* ENABLE SWITCH
******************************************************************************
*/
/* Feature switch may be enabled or disabled by user at rfal_platform.h
/* Feature switch may be enabled or disabled by user at rfal_platform.h
* Default configuration (ST25R dependant) also provided at rfal_defConfig.h
*
*
* RFAL_FEATURE_ST25TB
*/
@ -56,45 +57,29 @@
******************************************************************************
*/
#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_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_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 */
/*
******************************************************************************
@ -109,56 +94,62 @@
*/
/*! 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
******************************************************************************
*/
/*!
/*!
*****************************************************************************
* \brief ST25TB Poller Do Collision Resolution
*
*
* This method performs ST25TB Collision resolution loop for each slot
*
*
* \param[in] devLimit : device limit value, and size st25tbDevList
* \param[out] st25tbDevList : ST35TB listener device info
* \param[out] devCnt : Devices found counter
*
*
* \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 );
/*
******************************************************************************
@ -166,59 +157,74 @@ static bool rfalSt25tbPollerDoCollisionResolution(
******************************************************************************
*/
static bool rfalSt25tbPollerDoCollisionResolution(
uint8_t devLimit, rfalSt25tbListenDevice *st25tbDevList, uint8_t *devCnt) {
uint8_t i;
uint8_t chipId;
ReturnCode ret;
bool col;
col = false;
static bool rfalSt25tbPollerDoCollisionResolution( uint8_t devLimit, rfalSt25tbListenDevice *st25tbDevList, uint8_t *devCnt )
{
uint8_t i;
uint8_t chipId;
ReturnCode ret;
bool col;
for (i = 0; i < RFAL_ST25TB_SLOTS; i++) {
platformDelay(1); /* Wait t2: Answer to new request delay */
col = false;
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
{
/* Step 3-17: Send Pcall16 */
ret = rfalSt25tbPollerSlotMarker( i, &chipId );
}
if( ret == RFAL_ERR_NONE )
{
/* Found another device */
st25tbDevList[*devCnt].chipID = chipId;
st25tbDevList[*devCnt].isDeselected = false;
/* Select Device, retrieve its UID */
ret = rfalSt25tbPollerSelect( chipId );
if (i == 0U) {
/* Step 2: Send Pcall16 */
ret = rfalSt25tbPollerPcall(&chipId);
} else {
/* Step 3-17: Send Pcall16 */
ret = rfalSt25tbPollerSlotMarker(i, &chipId);
/* By Selecting this device, the previous gets Deselected */
if( (*devCnt) > 0U )
{
st25tbDevList[(*devCnt)-1U].isDeselected = true;
}
if( RFAL_ERR_NONE == ret )
{
ret = rfalSt25tbPollerGetUID( &st25tbDevList[*devCnt].UID );
}
if( RFAL_ERR_NONE == ret )
{
(*devCnt)++;
}
}
else if( (ret == RFAL_ERR_CRC) || (ret == RFAL_ERR_FRAMING) )
{
col = true;
}
else
{
/* MISRA 15.7 - Empty else */
}
if( *devCnt >= devLimit )
{
break;
}
}
if (ret == RFAL_ERR_NONE) {
/* Found another device */
st25tbDevList[*devCnt].chipID = chipId;
st25tbDevList[*devCnt].isDeselected = false;
/* Select Device, retrieve its UID */
ret = rfalSt25tbPollerSelect(chipId);
/* By Selecting this device, the previous gets Deselected */
if ((*devCnt) > 0U) {
st25tbDevList[(*devCnt) - 1U].isDeselected = true;
}
if (RFAL_ERR_NONE == ret) {
ret = rfalSt25tbPollerGetUID(&st25tbDevList[*devCnt].UID);
}
if (RFAL_ERR_NONE == ret) {
(*devCnt)++;
}
} else if ((ret == RFAL_ERR_CRC) || (ret == RFAL_ERR_FRAMING)) {
col = true;
} else {
/* MISRA 15.7 - Empty else */
}
if (*devCnt >= devLimit) {
break;
}
}
return col;
return col;
}
/*
******************************************************************************
* LOCAL VARIABLES
@ -232,307 +238,322 @@ static bool rfalSt25tbPollerDoCollisionResolution(
*/
/*******************************************************************************/
ReturnCode rfalSt25tbPollerInitialize(void) {
return rfalNfcbPollerInitialize();
ReturnCode rfalSt25tbPollerInitialize( void )
{
return rfalNfcbPollerInitialize();
}
/*******************************************************************************/
ReturnCode rfalSt25tbPollerCheckPresence(uint8_t *chipId) {
ReturnCode ret;
uint8_t chipIdRes;
ReturnCode rfalSt25tbPollerCheckPresence( uint8_t *chipId )
{
ReturnCode ret;
uint8_t chipIdRes;
chipIdRes = 0x00;
chipIdRes = 0x00;
/* Send Initiate Request */
ret = rfalSt25tbPollerInitiate( &chipIdRes );
/* Check if a transmission error was detected */
if( (ret == RFAL_ERR_CRC) || (ret == RFAL_ERR_FRAMING) )
{
return RFAL_ERR_NONE;
}
/* Copy chip ID if requested */
if( chipId != NULL )
{
*chipId = chipIdRes;
}
return ret;
}
/* Send Initiate Request */
ret = rfalSt25tbPollerInitiate(&chipIdRes);
/* Check if a transmission error was detected */
if ((ret == RFAL_ERR_CRC) || (ret == RFAL_ERR_FRAMING)) {
/*******************************************************************************/
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 */
/* Compute Initiate Request */
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 );
/* Check for valid Select Response */
if( (ret == RFAL_ERR_NONE) && (rxLen != RFAL_ST25TB_CHIP_ID_LEN) )
{
return RFAL_ERR_PROTO;
}
/* Copy chip ID if requested */
if( chipId != NULL )
{
*chipId = *rxBuf;
}
return ret;
}
/*******************************************************************************/
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;
/* 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 );
/* Check for valid Select Response */
if( (ret == RFAL_ERR_NONE) && (rxLen != RFAL_ST25TB_CHIP_ID_LEN) )
{
return RFAL_ERR_PROTO;
}
return ret;
}
/*******************************************************************************/
ReturnCode rfalSt25tbPollerSlotMarker( uint8_t slotNum, uint8_t *chipIdRes )
{
ReturnCode ret;
uint16_t rxLen;
uint8_t slotMarker;
if( (slotNum == 0U) || (slotNum > 15U) )
{
return RFAL_ERR_PARAM;
}
/* Compute SlotMarker */
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 );
/* Check for valid ChipID Response */
if( (ret == RFAL_ERR_NONE) && (rxLen != RFAL_ST25TB_CHIP_ID_LEN) )
{
return RFAL_ERR_PROTO;
}
return ret;
}
/*******************************************************************************/
ReturnCode rfalSt25tbPollerSelect( uint8_t chipId )
{
ReturnCode ret;
uint16_t rxLen;
rfalSt25tbSelectReq selectReq;
uint8_t chipIdRes;
/* Compute Select Request */
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 );
/* Check for valid Select Response */
if( (ret == RFAL_ERR_NONE) && ((rxLen != RFAL_ST25TB_CHIP_ID_LEN) || (chipIdRes != chipId)) )
{
return RFAL_ERR_PROTO;
}
return ret;
}
/*******************************************************************************/
ReturnCode rfalSt25tbPollerGetUID( rfalSt25tbUID *UID )
{
ReturnCode ret;
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 );
/* Check for valid UID Response */
if( (ret == RFAL_ERR_NONE) && (rxLen != RFAL_ST25TB_UID_LEN) )
{
return RFAL_ERR_PROTO;
}
return ret;
}
/*******************************************************************************/
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) )
{
return RFAL_ERR_PARAM;
}
*devCnt = 0;
/* Step 1: Send Initiate */
ret = rfalSt25tbPollerInitiate( &chipId );
if( ret == RFAL_ERR_NONE )
{
/* If only 1 answer is detected */
st25tbDevList[*devCnt].chipID = chipId;
st25tbDevList[*devCnt].isDeselected = false;
/* Retrieve its UID and keep it Selected*/
ret = rfalSt25tbPollerSelect( chipId );
if( RFAL_ERR_NONE == ret )
{
ret = rfalSt25tbPollerGetUID( &st25tbDevList[*devCnt].UID );
}
if( RFAL_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 )
{
/* Multiple device responses */
do
{
detected = rfalSt25tbPollerDoCollisionResolution( devLimit, st25tbDevList, devCnt );
}
while( (detected == true) && (*devCnt < devLimit) );
}
return RFAL_ERR_NONE;
}
/* Copy chip ID if requested */
if (chipId != NULL) {
*chipId = chipIdRes;
}
return ret;
}
/*******************************************************************************/
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 */
/* Compute Initiate Request */
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);
/* Check for valid Select Response */
if ((ret == RFAL_ERR_NONE) && (rxLen != RFAL_ST25TB_CHIP_ID_LEN)) {
return RFAL_ERR_PROTO;
}
/* Copy chip ID if requested */
if (chipId != NULL) {
*chipId = *rxBuf;
}
return ret;
}
/*******************************************************************************/
ReturnCode rfalSt25tbPollerPcall(uint8_t *chipId) {
ReturnCode ret;
uint16_t rxLen;
rfalSt25tbPcallReq pcallReq;
ReturnCode rfalSt25tbPollerReadBlock( uint8_t blockAddress, rfalSt25tbBlock *blockData )
{
ReturnCode ret;
uint16_t rxLen;
rfalSt25tbReadBlockReq readBlockReq;
/* Compute Pcal16 Request */
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);
/* Check for valid Select Response */
if ((ret == RFAL_ERR_NONE) && (rxLen != RFAL_ST25TB_CHIP_ID_LEN)) {
return RFAL_ERR_PROTO;
}
return ret;
}
/*******************************************************************************/
ReturnCode rfalSt25tbPollerSlotMarker(uint8_t slotNum, uint8_t *chipIdRes) {
ReturnCode ret;
uint16_t rxLen;
uint8_t slotMarker;
if ((slotNum == 0U) || (slotNum > 15U)) {
return RFAL_ERR_PARAM;
}
/* Compute SlotMarker */
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);
/* Check for valid ChipID Response */
if ((ret == RFAL_ERR_NONE) && (rxLen != RFAL_ST25TB_CHIP_ID_LEN)) {
return RFAL_ERR_PROTO;
}
return ret;
}
/*******************************************************************************/
ReturnCode rfalSt25tbPollerSelect(uint8_t chipId) {
ReturnCode ret;
uint16_t rxLen;
rfalSt25tbSelectReq selectReq;
uint8_t chipIdRes;
/* Compute Select Request */
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);
/* Check for valid Select Response */
if ((ret == RFAL_ERR_NONE) &&
((rxLen != RFAL_ST25TB_CHIP_ID_LEN) || (chipIdRes != chipId))) {
return RFAL_ERR_PROTO;
}
return ret;
}
/*******************************************************************************/
ReturnCode rfalSt25tbPollerGetUID(rfalSt25tbUID *UID) {
ReturnCode ret;
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);
/* Check for valid UID Response */
if ((ret == RFAL_ERR_NONE) && (rxLen != RFAL_ST25TB_UID_LEN)) {
return RFAL_ERR_PROTO;
}
return ret;
}
/*******************************************************************************/
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)) {
return RFAL_ERR_PARAM;
}
*devCnt = 0;
/* Step 1: Send Initiate */
ret = rfalSt25tbPollerInitiate(&chipId);
if (ret == RFAL_ERR_NONE) {
/* If only 1 answer is detected */
st25tbDevList[*devCnt].chipID = chipId;
st25tbDevList[*devCnt].isDeselected = false;
/* Retrieve its UID and keep it Selected*/
ret = rfalSt25tbPollerSelect(chipId);
if (RFAL_ERR_NONE == ret) {
ret = rfalSt25tbPollerGetUID(&st25tbDevList[*devCnt].UID);
/* Compute Read Block Request */
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 );
/* Check for valid UID Response */
if( (ret == RFAL_ERR_NONE) && (rxLen != RFAL_ST25TB_BLOCK_LEN) )
{
return RFAL_ERR_PROTO;
}
if (RFAL_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) {
/* Multiple device responses */
do {
detected = rfalSt25tbPollerDoCollisionResolution(devLimit, st25tbDevList,
devCnt);
} while ((detected == true) && (*devCnt < devLimit));
}
return RFAL_ERR_NONE;
return ret;
}
/*******************************************************************************/
ReturnCode rfalSt25tbPollerReadBlock(uint8_t blockAddress,
rfalSt25tbBlock *blockData) {
ReturnCode ret;
uint16_t rxLen;
rfalSt25tbReadBlockReq readBlockReq;
ReturnCode rfalSt25tbPollerWriteBlock( uint8_t blockAddress, const rfalSt25tbBlock *blockData )
{
ReturnCode ret;
uint16_t rxLen;
rfalSt25tbWriteBlockReq writeBlockReq;
rfalSt25tbBlock tmpBlockData;
/* Compute Read Block Request */
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);
/* Check for valid UID Response */
if ((ret == RFAL_ERR_NONE) && (rxLen != RFAL_ST25TB_BLOCK_LEN)) {
return RFAL_ERR_PROTO;
}
return ret;
/* Compute Write Block Request */
writeBlockReq.cmd = RFAL_ST25TB_WRITE_BLOCK_CMD;
writeBlockReq.address = blockAddress;
RFAL_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) );
/* Check if there was any error besides timeout */
if( ret != RFAL_ERR_TIMEOUT )
{
/* Check if an unexpected answer was received */
if( ret == RFAL_ERR_NONE )
{
return RFAL_ERR_PROTO;
}
/* Check whether a transmission error occurred */
if( (ret != RFAL_ERR_CRC) && (ret != RFAL_ERR_FRAMING) && (ret != RFAL_ERR_NOMEM) && (ret != RFAL_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) );
rfalFieldOnAndStartGT();
}
ret = rfalSt25tbPollerReadBlock(blockAddress, &tmpBlockData);
if( ret == RFAL_ERR_NONE )
{
if( RFAL_BYTECMP( &tmpBlockData, blockData, RFAL_ST25TB_BLOCK_LEN ) == 0 )
{
return RFAL_ERR_NONE;
}
return RFAL_ERR_PROTO;
}
return ret;
}
/*******************************************************************************/
ReturnCode rfalSt25tbPollerWriteBlock(uint8_t blockAddress,
const rfalSt25tbBlock *blockData) {
ReturnCode ret;
uint16_t rxLen;
rfalSt25tbWriteBlockReq writeBlockReq;
rfalSt25tbBlock tmpBlockData;
ReturnCode rfalSt25tbPollerCompletion( void )
{
uint8_t completionReq;
/* Compute Write Block Request */
writeBlockReq.cmd = RFAL_ST25TB_WRITE_BLOCK_CMD;
writeBlockReq.address = blockAddress;
RFAL_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));
/* Check if there was any error besides timeout */
if (ret != RFAL_ERR_TIMEOUT) {
/* Check if an unexpected answer was received */
if (ret == RFAL_ERR_NONE) {
return RFAL_ERR_PROTO;
}
/* Check whether a transmission error occurred */
if ((ret != RFAL_ERR_CRC) && (ret != RFAL_ERR_FRAMING) &&
(ret != RFAL_ERR_NOMEM) && (ret != RFAL_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));
rfalFieldOnAndStartGT();
}
ret = rfalSt25tbPollerReadBlock(blockAddress, &tmpBlockData);
if (ret == RFAL_ERR_NONE) {
if (RFAL_BYTECMP(&tmpBlockData, blockData, RFAL_ST25TB_BLOCK_LEN) == 0) {
return RFAL_ERR_NONE;
}
return RFAL_ERR_PROTO;
}
return ret;
/* 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 );
}
/*******************************************************************************/
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);
}
/*******************************************************************************/
ReturnCode rfalSt25tbPollerResetToInventory(void) {
uint8_t resetInvReq;
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);
/* 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 );
}
#endif /* RFAL_FEATURE_ST25TB */

File diff suppressed because it is too large Load Diff

View File

@ -1,18 +1,19 @@
/******************************************************************************
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/*
* PROJECT: ST25R391x firmware
@ -25,10 +26,10 @@
* \author Gustavo Patricio
*
* \brief Provides NFC-A T1T convenience methods and definitions
*
*
* This module provides an interface to perform as a NFC-A Reader/Writer
* to handle a Type 1 Tag T1T (Topaz)
*
* to handle a Type 1 Tag T1T (Topaz)
*
*/
/*
@ -45,9 +46,9 @@
******************************************************************************
*/
/* Feature switch may be enabled or disabled by user at rfal_platform.h
/* Feature switch may be enabled or disabled by user at rfal_platform.h
* Default configuration (ST25R dependant) also provided at rfal_defConfig.h
*
*
* RFAL_FEATURE_T1T
*/
@ -59,21 +60,12 @@
******************************************************************************
*/
#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 */
/*
******************************************************************************
@ -82,33 +74,40 @@
*/
/*! 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;
/*
@ -123,101 +122,96 @@ typedef struct {
******************************************************************************
*/
ReturnCode rfalT1TPollerInitialize(void) {
ReturnCode ret;
RFAL_EXIT_ON_ERR(
ret, rfalSetMode(RFAL_MODE_POLL_NFCA_T1T, RFAL_BR_106, RFAL_BR_106));
rfalSetErrorHandling(RFAL_ERRORHANDLING_NONE);
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 RFAL_ERR_NONE;
ReturnCode rfalT1TPollerInitialize( void )
{
ReturnCode ret;
RFAL_EXIT_ON_ERR(ret, rfalSetMode( RFAL_MODE_POLL_NFCA_T1T, RFAL_BR_106, RFAL_BR_106 ) );
rfalSetErrorHandling( RFAL_ERRORHANDLING_NONE );
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 RFAL_ERR_NONE;
}
/*******************************************************************************/
ReturnCode rfalT1TPollerRid(rfalT1TRidRes* ridRes) {
ReturnCode ret;
rfalT1TRidReq ridReq;
uint16_t rcvdLen;
if (ridRes == NULL) {
return RFAL_ERR_PARAM;
}
/* Compute RID command and set Undefined Values to 0x00 Digital 1.1 10.6.1
*/
RFAL_MEMSET(&ridReq, 0x00, sizeof(rfalT1TRidReq));
ridReq.cmd = (uint8_t)RFAL_T1T_CMD_RID;
RFAL_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)) {
return RFAL_ERR_PROTO;
}
return RFAL_ERR_NONE;
}
/*******************************************************************************/
ReturnCode rfalT1TPollerRall(const uint8_t* uid, uint8_t* rxBuf,
uint16_t rxBufLen, uint16_t* rxRcvdLen) {
rfalT1TRallReq rallReq;
if ((rxBuf == NULL) || (uid == NULL) || (rxRcvdLen == NULL)) {
return RFAL_ERR_PARAM;
}
/* Compute RALL command and set Add to 0x00 */
RFAL_MEMSET(&rallReq, 0x00, sizeof(rfalT1TRallReq));
rallReq.cmd = (uint8_t)RFAL_T1T_CMD_RALL;
RFAL_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);
}
/*******************************************************************************/
ReturnCode rfalT1TPollerWrite(const uint8_t* uid, uint8_t address,
uint8_t data) {
rfalT1TWriteReq writeReq;
rfalT1TWriteRes writeRes;
uint16_t rxRcvdLen;
ReturnCode err;
if (uid == NULL) {
return RFAL_ERR_PARAM;
}
writeReq.cmd = (uint8_t)RFAL_T1T_CMD_WRITE_E;
writeReq.add = address;
writeReq.data = data;
RFAL_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 == RFAL_ERR_NONE) {
if ((writeReq.add != writeRes.add) || (writeReq.data != writeRes.data) ||
(rxRcvdLen != sizeof(rfalT1TWriteRes))) {
return RFAL_ERR_PROTO;
ReturnCode rfalT1TPollerRid( rfalT1TRidRes *ridRes )
{
ReturnCode ret;
rfalT1TRidReq ridReq;
uint16_t rcvdLen;
if( ridRes == NULL )
{
return RFAL_ERR_PARAM;
}
}
return err;
/* Compute RID command and set Undefined Values to 0x00 Digital 1.1 10.6.1 */
RFAL_MEMSET( &ridReq, 0x00, sizeof(rfalT1TRidReq) );
ridReq.cmd = (uint8_t)RFAL_T1T_CMD_RID;
RFAL_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) )
{
return RFAL_ERR_PROTO;
}
return RFAL_ERR_NONE;
}
/*******************************************************************************/
ReturnCode rfalT1TPollerRall( const uint8_t* uid, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rxRcvdLen )
{
rfalT1TRallReq rallReq;
if( (rxBuf == NULL) || (uid == NULL) || (rxRcvdLen == NULL) )
{
return RFAL_ERR_PARAM;
}
/* Compute RALL command and set Add to 0x00 */
RFAL_MEMSET( &rallReq, 0x00, sizeof(rfalT1TRallReq) );
rallReq.cmd = (uint8_t)RFAL_T1T_CMD_RALL;
RFAL_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 );
}
/*******************************************************************************/
ReturnCode rfalT1TPollerWrite( const uint8_t* uid, uint8_t address, uint8_t data )
{
rfalT1TWriteReq writeReq;
rfalT1TWriteRes writeRes;
uint16_t rxRcvdLen;
ReturnCode err;
if( uid == NULL )
{
return RFAL_ERR_PARAM;
}
writeReq.cmd = (uint8_t)RFAL_T1T_CMD_WRITE_E;
writeReq.add = address;
writeReq.data = data;
RFAL_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 == RFAL_ERR_NONE )
{
if( (writeReq.add != writeRes.add) || (writeReq.data != writeRes.data) || (rxRcvdLen != sizeof(rfalT1TWriteRes)) )
{
return RFAL_ERR_PROTO;
}
}
return err;
}
#endif /* RFAL_FEATURE_T1T */

View File

@ -1,18 +1,18 @@
/******************************************************************************
* @attention
*
* COPYRIGHT 2018 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
* @attention
*
* COPYRIGHT 2018 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/*
* PROJECT: ST25R391x firmware
@ -22,13 +22,13 @@
/*! \file rfal_t2t.c
*
* \author
* \author
*
* \brief Provides NFC-A T2T convenience methods and definitions
*
*
* This module provides an interface to perform as a NFC-A Reader/Writer
* to handle a Type 2 Tag T2T
*
* to handle a Type 2 Tag T2T
*
*/
/*
@ -39,193 +39,200 @@
#include "rfal_t2t.h"
#include "rfal_utils.h"
/*
******************************************************************************
* ENABLE SWITCH
******************************************************************************
*/
/* Feature switch may be enabled or disabled by user at rfal_platform.h
/*
******************************************************************************
* ENABLE SWITCH
******************************************************************************
*/
/* Feature switch may be enabled or disabled by user at rfal_platform.h
* Default configuration (ST25R dependant) also provided at rfal_defConfig.h
*
*
* RFAL_FEATURE_T2T
*/
#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 */
/*
/*
******************************************************************************
* GLOBAL TYPES
* 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 */
/*
******************************************************************************
* 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)) {
return RFAL_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);
/* 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 == RFAL_ERR_INCOMPLETE_BYTE) && (*rcvLen == RFAL_T2T_ACK_NACK_LEN) &&
((*rxBuf & RFAL_T2T_ACK_MASK) != RFAL_T2T_ACK)) {
return RFAL_ERR_PROTO;
}
return ret;
}
/*******************************************************************************/
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;
RFAL_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_WRITE_MAX);
/* Check for a valid ACK */
if ((ret == RFAL_ERR_INCOMPLETE_BYTE) || (ret == RFAL_ERR_NONE)) {
ret = RFAL_ERR_PROTO;
if ((rxLen == RFAL_T2T_ACK_NACK_LEN) &&
((res & RFAL_T2T_ACK_MASK) == RFAL_T2T_ACK)) {
ret = RFAL_ERR_NONE;
ReturnCode rfalT2TPollerRead( uint8_t blockNum, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t *rcvLen )
{
ReturnCode ret;
rfalT2TReadReq req;
if( (rxBuf == NULL) || (rcvLen == NULL) )
{
return RFAL_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 );
/* 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 == RFAL_ERR_INCOMPLETE_BYTE) && (*rcvLen == RFAL_T2T_ACK_NACK_LEN) && ((*rxBuf & RFAL_T2T_ACK_MASK) != RFAL_T2T_ACK) )
{
return RFAL_ERR_PROTO;
}
}
return ret;
}
/*******************************************************************************/
ReturnCode rfalT2TPollerSectorSelect(uint8_t sectorNum) {
rfalT2TSectorSelectP1Req p1Req;
rfalT2TSectorSelectP2Req p2Req;
ReturnCode ret;
uint8_t res;
uint16_t rxLen;
/* Compute SECTOR SELECT Packet 1 */
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);
/* Check and report any transmission error */
if ((ret != RFAL_ERR_INCOMPLETE_BYTE) && (ret != RFAL_ERR_NONE)) {
return ret;
}
}
/*******************************************************************************/
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;
RFAL_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_WRITE_MAX );
/* Check for a valid ACK */
if( (ret == RFAL_ERR_INCOMPLETE_BYTE) || (ret == RFAL_ERR_NONE) )
{
ret = RFAL_ERR_PROTO;
if( (rxLen == RFAL_T2T_ACK_NACK_LEN) && ((res & RFAL_T2T_ACK_MASK) == RFAL_T2T_ACK) )
{
ret = RFAL_ERR_NONE;
}
}
return ret;
}
/* Ensure that an ACK was received */
if ((ret != RFAL_ERR_INCOMPLETE_BYTE) || (rxLen != RFAL_T2T_ACK_NACK_LEN) ||
((res & RFAL_T2T_ACK_MASK) != RFAL_T2T_ACK)) {
return RFAL_ERR_PROTO;
}
/* Compute SECTOR SELECT Packet 2 */
p2Req.secNo = sectorNum;
RFAL_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);
/* 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 == RFAL_ERR_NONE) || (ret == RFAL_ERR_INCOMPLETE_BYTE)) {
return RFAL_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 == RFAL_ERR_TIMEOUT) {
return RFAL_ERR_NONE;
}
return ret;
}
/*******************************************************************************/
ReturnCode rfalT2TPollerSectorSelect( uint8_t sectorNum )
{
rfalT2TSectorSelectP1Req p1Req;
rfalT2TSectorSelectP2Req p2Req;
ReturnCode ret;
uint8_t res;
uint16_t rxLen;
/* Compute SECTOR SELECT Packet 1 */
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 );
/* Check and report any transmission error */
if( (ret != RFAL_ERR_INCOMPLETE_BYTE) && (ret != RFAL_ERR_NONE) )
{
return ret;
}
/* Ensure that an ACK was received */
if( (ret != RFAL_ERR_INCOMPLETE_BYTE) || (rxLen != RFAL_T2T_ACK_NACK_LEN) || ((res & RFAL_T2T_ACK_MASK) != RFAL_T2T_ACK) )
{
return RFAL_ERR_PROTO;
}
/* Compute SECTOR SELECT Packet 2 */
p2Req.secNo = sectorNum;
RFAL_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 );
/* 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 == RFAL_ERR_NONE) || (ret == RFAL_ERR_INCOMPLETE_BYTE) )
{
return RFAL_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 == RFAL_ERR_TIMEOUT )
{
return RFAL_ERR_NONE;
}
return ret;
}
#endif /* RFAL_FEATURE_T2T */

View File

@ -1,18 +1,19 @@
/******************************************************************************
* @attention
*
* COPYRIGHT 2018 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
* @attention
*
* COPYRIGHT 2018 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/*
* PROJECT: ST25R391x firmware
@ -25,14 +26,14 @@
* \author Gustavo Patricio
*
* \brief Provides convenience methods and definitions for T4T (ISO7816-4)
*
* This module provides an interface to exchange T4T APDUs according to
*
* This module provides an interface to exchange T4T APDUs according to
* NFC Forum T4T and ISO7816-4
*
*
* This implementation was based on the following specs:
* - ISO/IEC 7816-4 3rd Edition 2013-04-15
* - NFC Forum T4T Technical Specification 1.0 2017-08-28
*
*
*/
/*
@ -40,42 +41,39 @@
* INCLUDES
******************************************************************************
*/
#include "rfal_t4t.h"
#include "rfal_utils.h"
#include "rfal_t4t.h"
#include "rfal_utils.h"
/*
******************************************************************************
* ENABLE SWITCH
******************************************************************************
*/
/*
******************************************************************************
* ENABLE SWITCH
******************************************************************************
*/
/* Feature switch may be enabled or disabled by user at rfal_platform.h
/* Feature switch may be enabled or disabled by user at rfal_platform.h
* Default configuration (ST25R dependant) also provided at rfal_defConfig.h
*
*
* RFAL_FEATURE_T4T
*/
#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_MAX_LC 255U /*!< Maximum Lc value for short Lc coding */
/*
******************************************************************************
* GLOBAL DEFINES
* GLOBAL TYPES
******************************************************************************
*/
#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 */
/*
******************************************************************************
* GLOBAL TYPES
******************************************************************************
*/
/*
******************************************************************************
@ -83,335 +81,345 @@
******************************************************************************
*/
/*
******************************************************************************
* LOCAL VARIABLES
******************************************************************************
*/
/*
******************************************************************************
* GLOBAL FUNCTIONS
******************************************************************************
*/
/*******************************************************************************/
ReturnCode rfalT4TPollerComposeCAPDU(const rfalT4tCApduParam *apduParam) {
uint8_t hdrLen;
uint16_t msgIt;
if ((apduParam == NULL) || (apduParam->cApduBuf == NULL) ||
(apduParam->cApduLen == NULL)) {
return RFAL_ERR_PARAM;
}
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) {
/* Extented field coding not supported */
return RFAL_ERR_PARAM;
/*******************************************************************************/
ReturnCode rfalT4TPollerComposeCAPDU( const rfalT4tCApduParam *apduParam )
{
uint8_t hdrLen;
uint16_t msgIt;
if( (apduParam == NULL) || (apduParam->cApduBuf == NULL) || (apduParam->cApduLen == NULL) )
{
return RFAL_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 RFAL_ERR_PARAM; /* PRQA S 2880 # MISRA 2.1 - Unreachable code due
to configuration option being set/unset */
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 )
{
/* Extented field coding not supported */
return RFAL_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 RFAL_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 RFAL_ERR_NOMEM; /* PRQA S 2880 # MISRA 2.1 - Unreachable code due to configuration option being set/unset */
}
RFAL_MEMMOVE( &apduParam->cApduBuf->apdu[hdrLen], apduParam->cApduBuf->apdu, apduParam->Lc );
}
/* 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 RFAL_ERR_NOMEM; /* PRQA S 2880 # MISRA 2.1 - Unreachable code due
to configuration option being set/unset */
/* 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 )
{
apduParam->cApduBuf->apdu[msgIt++] = apduParam->Lc;
msgIt += apduParam->Lc;
}
RFAL_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) {
apduParam->cApduBuf->apdu[msgIt++] = apduParam->Lc;
msgIt += apduParam->Lc;
}
/* Check if Expected Response Length is to be added */
if (apduParam->LeFlag) {
apduParam->cApduBuf->apdu[msgIt++] = apduParam->Le;
}
*(apduParam->cApduLen) = msgIt;
return RFAL_ERR_NONE;
}
/*******************************************************************************/
ReturnCode rfalT4TPollerParseRAPDU(rfalT4tRApduParam *apduParam) {
if ((apduParam == NULL) || (apduParam->rApduBuf == NULL)) {
return RFAL_ERR_PARAM;
}
if (apduParam->rcvdLen < RFAL_T4T_MAX_RAPDU_SW1SW2_LEN) {
return RFAL_ERR_PROTO;
}
apduParam->rApduBodyLen =
(apduParam->rcvdLen - (uint16_t)RFAL_T4T_MAX_RAPDU_SW1SW2_LEN);
apduParam->statusWord =
RFAL_GETU16(&apduParam->rApduBuf->apdu[apduParam->rApduBodyLen]);
/* Check SW1 SW2 T4T 1.0 5.1.3 NOTE */
if (apduParam->statusWord == RFAL_T4T_ISO7816_STATUS_COMPLETE) {
/* Check if Expected Response Length is to be added */
if( apduParam->LeFlag )
{
apduParam->cApduBuf->apdu[msgIt++] = apduParam->Le;
}
*(apduParam->cApduLen) = msgIt;
return RFAL_ERR_NONE;
}
return RFAL_ERR_REQUEST;
}
/*******************************************************************************/
ReturnCode rfalT4TPollerComposeSelectAppl(rfalIsoDepApduBufFormat *cApduBuf,
const uint8_t *aid, uint8_t aidLen,
uint16_t *cApduLen) {
rfalT4tCApduParam cAPDU;
ReturnCode rfalT4TPollerParseRAPDU( rfalT4tRApduParam *apduParam )
{
if( (apduParam == NULL) || (apduParam->rApduBuf == NULL) )
{
return RFAL_ERR_PARAM;
}
if( apduParam->rcvdLen < RFAL_T4T_MAX_RAPDU_SW1SW2_LEN )
{
return RFAL_ERR_PROTO;
}
if (cApduBuf == NULL) {
return RFAL_ERR_PARAM;
}
apduParam->rApduBodyLen = (apduParam->rcvdLen - (uint16_t)RFAL_T4T_MAX_RAPDU_SW1SW2_LEN);
apduParam->statusWord = RFAL_GETU16( &apduParam->rApduBuf->apdu[ apduParam->rApduBodyLen ] );
/* 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.cApduBuf = cApduBuf;
cAPDU.cApduLen = cApduLen;
/* Check SW1 SW2 T4T 1.0 5.1.3 NOTE */
if( apduParam->statusWord == RFAL_T4T_ISO7816_STATUS_COMPLETE )
{
return RFAL_ERR_NONE;
}
if ((aid != NULL) && (aidLen > 0U)) {
RFAL_MEMCPY(cAPDU.cApduBuf->apdu, aid, aidLen);
}
return rfalT4TPollerComposeCAPDU(&cAPDU);
return RFAL_ERR_REQUEST;
}
/*******************************************************************************/
ReturnCode rfalT4TPollerComposeSelectFile(rfalIsoDepApduBufFormat *cApduBuf,
const uint8_t *fid, uint8_t fidLen,
uint16_t *cApduLen) {
rfalT4tCApduParam cAPDU;
if (cApduBuf == NULL) {
return RFAL_ERR_PARAM;
}
/*******************************************************************************/
ReturnCode rfalT4TPollerComposeSelectAppl( rfalIsoDepApduBufFormat *cApduBuf, const uint8_t* aid, uint8_t aidLen, uint16_t *cApduLen )
{
rfalT4tCApduParam cAPDU;
if( cApduBuf == NULL )
{
return RFAL_ERR_PARAM;
}
/* 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;
cAPDU.cApduBuf = cApduBuf;
cAPDU.cApduLen = cApduLen;
if ((fid != NULL) && (fidLen > 0U)) {
RFAL_MEMCPY(cAPDU.cApduBuf->apdu, fid, fidLen);
}
return rfalT4TPollerComposeCAPDU(&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.cApduBuf = cApduBuf;
cAPDU.cApduLen = cApduLen;
if( (aid != NULL) && (aidLen > 0U) )
{
RFAL_MEMCPY( cAPDU.cApduBuf->apdu, aid, aidLen );
}
return rfalT4TPollerComposeCAPDU( &cAPDU );
}
/*******************************************************************************/
ReturnCode rfalT4TPollerComposeSelectFileV1Mapping(
rfalIsoDepApduBufFormat *cApduBuf, const uint8_t *fid, uint8_t fidLen,
uint16_t *cApduLen) {
rfalT4tCApduParam cAPDU;
if (cApduBuf == NULL) {
return RFAL_ERR_PARAM;
}
/*******************************************************************************/
ReturnCode rfalT4TPollerComposeSelectFile( rfalIsoDepApduBufFormat *cApduBuf, const uint8_t* fid, uint8_t fidLen, uint16_t *cApduLen )
{
rfalT4tCApduParam cAPDU;
if( cApduBuf == NULL )
{
return RFAL_ERR_PARAM;
}
/* 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;
cAPDU.cApduBuf = cApduBuf;
cAPDU.cApduLen = cApduLen;
if ((fid != NULL) && (fidLen > 0U)) {
RFAL_MEMCPY(cAPDU.cApduBuf->apdu, fid, fidLen);
}
return rfalT4TPollerComposeCAPDU(&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;
cAPDU.cApduBuf = cApduBuf;
cAPDU.cApduLen = cApduLen;
if( (fid != NULL) && (fidLen > 0U) )
{
RFAL_MEMCPY( cAPDU.cApduBuf->apdu, fid, fidLen );
}
return rfalT4TPollerComposeCAPDU( &cAPDU );
}
/*******************************************************************************/
ReturnCode rfalT4TPollerComposeReadData(rfalIsoDepApduBufFormat *cApduBuf,
uint16_t offset, uint8_t expLen,
uint16_t *cApduLen) {
rfalT4tCApduParam cAPDU;
RFAL_MEMSET(&cAPDU, 0x00, sizeof(rfalT4tCApduParam));
/* 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;
cAPDU.cApduBuf = cApduBuf;
cAPDU.cApduLen = cApduLen;
return rfalT4TPollerComposeCAPDU(&cAPDU);
/*******************************************************************************/
ReturnCode rfalT4TPollerComposeSelectFileV1Mapping( rfalIsoDepApduBufFormat *cApduBuf, const uint8_t* fid, uint8_t fidLen, uint16_t *cApduLen )
{
rfalT4tCApduParam cAPDU;
if( cApduBuf == NULL )
{
return RFAL_ERR_PARAM;
}
/* 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;
cAPDU.cApduBuf = cApduBuf;
cAPDU.cApduLen = cApduLen;
if( (fid != NULL) && (fidLen > 0U) )
{
RFAL_MEMCPY( cAPDU.cApduBuf->apdu, fid, fidLen );
}
return rfalT4TPollerComposeCAPDU( &cAPDU );
}
/*******************************************************************************/
ReturnCode rfalT4TPollerComposeReadDataODO(rfalIsoDepApduBufFormat *cApduBuf,
uint32_t offset, uint8_t expLen,
uint16_t *cApduLen) {
rfalT4tCApduParam cAPDU;
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;
cAPDU.cApduBuf = cApduBuf;
cAPDU.cApduLen = cApduLen;
/*******************************************************************************/
ReturnCode rfalT4TPollerComposeReadData( rfalIsoDepApduBufFormat *cApduBuf, uint16_t offset, uint8_t expLen, uint16_t *cApduLen )
{
rfalT4tCApduParam cAPDU;
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);
RFAL_MEMSET( &cAPDU, 0x00, sizeof(rfalT4tCApduParam) );
/* 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;
cAPDU.cApduBuf = cApduBuf;
cAPDU.cApduLen = cApduLen;
return rfalT4TPollerComposeCAPDU( &cAPDU );
}
/*******************************************************************************/
ReturnCode rfalT4TPollerComposeWriteData(rfalIsoDepApduBufFormat *cApduBuf,
uint16_t offset, const uint8_t *data,
uint8_t dataLen, uint16_t *cApduLen) {
rfalT4tCApduParam cAPDU;
if (cApduBuf == NULL) {
return RFAL_ERR_PARAM;
}
/*******************************************************************************/
ReturnCode rfalT4TPollerComposeReadDataODO( rfalIsoDepApduBufFormat *cApduBuf, uint32_t offset, uint8_t expLen, uint16_t *cApduLen )
{
rfalT4tCApduParam cAPDU;
uint8_t dataIt;
RFAL_MEMSET(&cAPDU, 0x00, sizeof(rfalT4tCApduParam));
/* 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;
cAPDU.cApduBuf = cApduBuf;
cAPDU.cApduLen = cApduLen;
if ((data != NULL) && (dataLen > 0U)) {
RFAL_MEMCPY(cAPDU.cApduBuf->apdu, data, dataLen);
}
return rfalT4TPollerComposeCAPDU(&cAPDU);
/* 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;
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 );
}
/*******************************************************************************/
ReturnCode rfalT4TPollerComposeWriteDataODO(rfalIsoDepApduBufFormat *cApduBuf,
uint32_t offset,
const uint8_t *data,
uint8_t dataLen,
uint16_t *cApduLen) {
rfalT4tCApduParam cAPDU;
uint8_t dataIt;
if (cApduBuf == NULL) {
return RFAL_ERR_PARAM;
}
/*******************************************************************************/
ReturnCode rfalT4TPollerComposeWriteData( rfalIsoDepApduBufFormat *cApduBuf, uint16_t offset, const uint8_t* data, uint8_t dataLen, uint16_t *cApduLen )
{
rfalT4tCApduParam cAPDU;
if( cApduBuf == NULL )
{
return RFAL_ERR_PARAM;
}
RFAL_MEMSET(&cAPDU, 0x00, sizeof(rfalT4tCApduParam));
RFAL_MEMSET( &cAPDU, 0x00, sizeof(rfalT4tCApduParam) );
/* 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.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);
cApduBuf->apdu[dataIt++] = RFAL_T4T_DATA_DO;
cApduBuf->apdu[dataIt++] = dataLen;
/* 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;
cAPDU.cApduBuf = cApduBuf;
cAPDU.cApduLen = cApduLen;
if( (data != NULL) && (dataLen > 0U) )
{
RFAL_MEMCPY( cAPDU.cApduBuf->apdu, data, dataLen );
}
return rfalT4TPollerComposeCAPDU( &cAPDU );
}
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 (RFAL_ERR_NOMEM);
}
/*******************************************************************************/
ReturnCode rfalT4TPollerComposeWriteDataODO( rfalIsoDepApduBufFormat *cApduBuf, uint32_t offset, const uint8_t* data, uint8_t dataLen, uint16_t *cApduLen )
{
rfalT4tCApduParam cAPDU;
uint8_t dataIt;
if( cApduBuf == NULL )
{
return RFAL_ERR_PARAM;
}
if ((data != NULL) && (dataLen > 0U)) {
RFAL_MEMCPY(&cAPDU.cApduBuf->apdu[dataIt], data, dataLen);
}
dataIt += dataLen;
cAPDU.Lc = dataIt;
return rfalT4TPollerComposeCAPDU(&cAPDU);
RFAL_MEMSET( &cAPDU, 0x00, sizeof(rfalT4tCApduParam) );
/* 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.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);
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) )
{
return (RFAL_ERR_NOMEM);
}
if( (data != NULL) && (dataLen > 0U) )
{
RFAL_MEMCPY( &cAPDU.cApduBuf->apdu[dataIt], data, dataLen );
}
dataIt += dataLen;
cAPDU.Lc = dataIt;
return rfalT4TPollerComposeCAPDU( &cAPDU );
}
#endif /* RFAL_FEATURE_T4T */

File diff suppressed because it is too large Load Diff

View File

@ -1,18 +1,20 @@
/******************************************************************************
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/*
* PROJECT: ST25R391x firmware
@ -22,11 +24,12 @@
/*! \file
*
* \author Martin Zechleitner
* \author Martin Zechleitner
*
* \brief RF Dynamic Power Table default values
*/
#ifndef ST25R3916_DPO_H
#define ST25R3916_DPO_H
@ -37,33 +40,39 @@
*/
#include "rfal_dpo.h"
/*
******************************************************************************
* GLOBAL DATA TYPES
******************************************************************************
*/
#if defined(ST25R3916)
/*! ST25R3916 Default DPO table */
/* PRQA S 3674 2 # CERT ARR02 - Flexible array will be used with sizeof, on
* adding elements error-prone manual update of size would be required */
/* PRQA S 3406 1 # MISRA 8.6 - Externally generated table included by the
* library */ /* PRQA S 1514 1 # MISRA 8.9 - Externally generated table included by the library */
const rfalDpoEntry rfalDpoDefaultSettings[] = {
{0x00, 255, 200}, {0x01, 210, 150}, {0x02, 160, 100}, {0x03, 110, 50}};
#elif defined(ST25R3916B) /* ST25R3916B has an increased resolution on the \
driver resistance (d_res) */
/*! ST25R3916B Default DPO table */
/* PRQA S 3674 2 # CERT ARR02 - Flexible array will be used with sizeof, on
* adding elements error-prone manual update of size would be required */
/* PRQA S 3406 1 # MISRA 8.6 - Externally generated table included by the
* library */ /* PRQA S 1514 1 # MISRA 8.9 - Externally generated table included by the library */
const rfalDpoEntry rfalDpoDefaultSettings[] = {
{0x00, 255, 200}, {0x05, 210, 150}, {0x09, 160, 100}, {0x0B, 110, 50}};
/*! ST25R3916 Default DPO table */
/* PRQA S 3674 2 # CERT ARR02 - Flexible array will be used with sizeof, on adding elements error-prone manual update of size would be required */
/* PRQA S 3406 1 # MISRA 8.6 - Externally generated table included by the library */ /* PRQA S 1514 1 # MISRA 8.9 - Externally generated table included by the library */
const rfalDpoEntry rfalDpoDefaultSettings [] = {
{ 0x00, 255, 200 },
{ 0x01, 210, 150 },
{ 0x02, 160, 100 },
{ 0x03, 110, 50 }
};
#elif defined(ST25R3916B) /* ST25R3916B has an increased resolution on the driver resistance (d_res) */
/*! ST25R3916B Default DPO table */
/* PRQA S 3674 2 # CERT ARR02 - Flexible array will be used with sizeof, on adding elements error-prone manual update of size would be required */
/* PRQA S 3406 1 # MISRA 8.6 - Externally generated table included by the library */ /* PRQA S 1514 1 # MISRA 8.9 - Externally generated table included by the library */
const rfalDpoEntry rfalDpoDefaultSettings [] = {
{ 0x00, 255, 200 },
{ 0x05, 210, 150 },
{ 0x09, 160, 100 },
{ 0x0B, 110, 50 }
};
#endif /* ST25R3916 */
#endif /* ST25R3916_DPO_H */

View File

@ -1,32 +1,35 @@
/******************************************************************************
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/*
* PROJECT: ST25R391x firmware
* Revision:
* Revision:
* LANGUAGE: ISO C99
*/
/*! \file
*
* \author Gustavo Patricio
* \author Gustavo Patricio
*
* \brief RFAL Features/Capabilities Definition for ST25R3916
*/
#ifndef RFAL_FEATURES_H
#define RFAL_FEATURES_H
@ -43,93 +46,65 @@
******************************************************************************
*/
#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 */
/*
******************************************************************************
@ -138,104 +113,97 @@
*/
/*! RFAL Wake-Up Period/Timer */
typedef enum {
RFAL_WUM_PERIOD_10MS = 0x00, /*!< Wake-Up timer 10ms */
RFAL_WUM_PERIOD_20MS = 0x01, /*!< Wake-Up timer 20ms */
RFAL_WUM_PERIOD_30MS = 0x02, /*!< Wake-Up timer 30ms */
RFAL_WUM_PERIOD_40MS = 0x03, /*!< Wake-Up timer 40ms */
RFAL_WUM_PERIOD_50MS = 0x04, /*!< Wake-Up timer 50ms */
RFAL_WUM_PERIOD_60MS = 0x05, /*!< Wake-Up timer 60ms */
RFAL_WUM_PERIOD_70MS = 0x06, /*!< Wake-Up timer 70ms */
RFAL_WUM_PERIOD_80MS = 0x07, /*!< Wake-Up timer 80ms */
RFAL_WUM_PERIOD_100MS = 0x10, /*!< Wake-Up timer 100ms */
RFAL_WUM_PERIOD_200MS = 0x11, /*!< Wake-Up timer 200ms */
RFAL_WUM_PERIOD_300MS = 0x12, /*!< Wake-Up timer 300ms */
RFAL_WUM_PERIOD_400MS = 0x13, /*!< Wake-Up timer 400ms */
RFAL_WUM_PERIOD_500MS = 0x14, /*!< Wake-Up timer 500ms */
RFAL_WUM_PERIOD_600MS = 0x15, /*!< Wake-Up timer 600ms */
RFAL_WUM_PERIOD_700MS = 0x16, /*!< Wake-Up timer 700ms */
RFAL_WUM_PERIOD_800MS = 0x17, /*!< Wake-Up timer 800ms */
} rfalWumPeriod;
/*! RFAL Wake-Up Period/Timer */
typedef enum {
RFAL_WUM_AA_WEIGHT_4 = 0x00, /*!< Wake-Up Auto Average Weight 4 */
RFAL_WUM_AA_WEIGHT_8 = 0x01, /*!< Wake-Up Auto Average Weight 8 */
RFAL_WUM_AA_WEIGHT_16 = 0x02, /*!< Wake-Up Auto Average Weight 16 */
RFAL_WUM_AA_WEIGHT_32 = 0x03, /*!< Wake-Up Auto Average Weight 32 */
typedef enum
{
RFAL_WUM_PERIOD_10MS = 0x00, /*!< Wake-Up timer 10ms */
RFAL_WUM_PERIOD_20MS = 0x01, /*!< Wake-Up timer 20ms */
RFAL_WUM_PERIOD_30MS = 0x02, /*!< Wake-Up timer 30ms */
RFAL_WUM_PERIOD_40MS = 0x03, /*!< Wake-Up timer 40ms */
RFAL_WUM_PERIOD_50MS = 0x04, /*!< Wake-Up timer 50ms */
RFAL_WUM_PERIOD_60MS = 0x05, /*!< Wake-Up timer 60ms */
RFAL_WUM_PERIOD_70MS = 0x06, /*!< Wake-Up timer 70ms */
RFAL_WUM_PERIOD_80MS = 0x07, /*!< Wake-Up timer 80ms */
RFAL_WUM_PERIOD_100MS = 0x10, /*!< Wake-Up timer 100ms */
RFAL_WUM_PERIOD_200MS = 0x11, /*!< Wake-Up timer 200ms */
RFAL_WUM_PERIOD_300MS = 0x12, /*!< Wake-Up timer 300ms */
RFAL_WUM_PERIOD_400MS = 0x13, /*!< Wake-Up timer 400ms */
RFAL_WUM_PERIOD_500MS = 0x14, /*!< Wake-Up timer 500ms */
RFAL_WUM_PERIOD_600MS = 0x15, /*!< Wake-Up timer 600ms */
RFAL_WUM_PERIOD_700MS = 0x16, /*!< Wake-Up timer 700ms */
RFAL_WUM_PERIOD_800MS = 0x17, /*!< Wake-Up timer 800ms */
} rfalWumPeriod;
/*! RFAL Wake-Up Period/Timer */
typedef enum
{
RFAL_WUM_AA_WEIGHT_4 = 0x00, /*!< Wake-Up Auto Average Weight 4 */
RFAL_WUM_AA_WEIGHT_8 = 0x01, /*!< Wake-Up Auto Average Weight 8 */
RFAL_WUM_AA_WEIGHT_16 = 0x02, /*!< Wake-Up Auto Average Weight 16 */
RFAL_WUM_AA_WEIGHT_32 = 0x03, /*!< Wake-Up Auto Average Weight 32 */
} rfalWumAAWeight;
/*! RFAL Wake-Up Mode configuration */
typedef struct {
rfalWumPeriod
period; /*!< Wake-Up Timer period;how often measurement(s) is performed */
bool irqTout; /*!< IRQ at every timeout will refresh the measurement(s) */
bool swTagDetect; /*!< Use SW Tag Detection instead of HW Wake-Up mode */
struct {
bool enabled; /*!< Reference from WU mode enabled */
rfalWumPeriod refDelay; /*!< Obtain reference from WU after delay time */
} refWU; /*!< Reference obtained from PD|WU mode */
struct {
bool enabled; /*!< Inductive Amplitude measurement enabled */
uint8_t
delta; /*!< Delta between the reference and measurement to wake-up */
uint8_t fracDelta; /*!< Fractional part of the delta [0;3] 0.25 steps (SW TD
only) */
uint16_t reference; /*!< Reference to be used;RFAL_WUM_REFERENCE_AUTO sets
it auto */
bool autoAvg; /*!< Use the HW Auto Averaging feature */
bool aaInclMeas; /*!< When AutoAvg is enabled, include IRQ measurement */
rfalWumAAWeight
aaWeight; /*!< When AutoAvg is enabled, last measure weight */
} indAmp; /*!< Inductive Amplitude Configuration */
struct {
bool enabled; /*!< Inductive Phase measurement enabled */
uint8_t
delta; /*!< Delta between the reference and measurement to wake-up */
uint8_t fracDelta; /*!< Fractional part of the delta [0;3] 0.25 steps (SW TD
only) */
uint16_t reference; /*!< Reference to be used;RFAL_WUM_REFERENCE_AUTO sets
it auto */
bool autoAvg; /*!< Use the HW Auto Averaging feature */
bool aaInclMeas; /*!< When AutoAvg is enabled, include IRQ measurement */
rfalWumAAWeight
aaWeight; /*!< When AutoAvg is enabled, last measure weight */
} indPha; /*!< Inductive Phase Configuration */
struct {
bool enabled; /*!< Capacitive measurement enabled */
uint8_t
delta; /*!< Delta between the reference and measurement to wake-up */
uint16_t reference; /*!< Reference to be used;RFAL_WUM_REFERENCE_AUTO sets
it auto */
bool autoAvg; /*!< Use the HW Auto Averaging feature */
bool aaInclMeas; /*!< When AutoAvg is enabled, include IRQ measurement */
rfalWumAAWeight
aaWeight; /*!< When AutoAvg is enabled, last measure weight */
} cap; /*!< Capacitive Configuration */
typedef struct
{
rfalWumPeriod period; /*!< Wake-Up Timer period;how often measurement(s) is performed */
bool irqTout; /*!< IRQ at every timeout will refresh the measurement(s) */
bool swTagDetect; /*!< Use SW Tag Detection instead of HW Wake-Up mode */
struct{
bool enabled; /*!< Reference from WU mode enabled */
rfalWumPeriod refDelay; /*!< Obtain reference from WU after delay time */
}refWU; /*!< Reference obtained from PD|WU mode */
struct{
bool enabled; /*!< Inductive Amplitude measurement enabled */
uint8_t delta; /*!< Delta between the reference and measurement to wake-up */
uint8_t fracDelta; /*!< Fractional part of the delta [0;3] 0.25 steps (SW TD only) */
uint16_t reference; /*!< Reference to be used;RFAL_WUM_REFERENCE_AUTO sets it auto */
bool autoAvg; /*!< Use the HW Auto Averaging feature */
bool aaInclMeas; /*!< When AutoAvg is enabled, include IRQ measurement */
rfalWumAAWeight aaWeight; /*!< When AutoAvg is enabled, last measure weight */
}indAmp; /*!< Inductive Amplitude Configuration */
struct{
bool enabled; /*!< Inductive Phase measurement enabled */
uint8_t delta; /*!< Delta between the reference and measurement to wake-up */
uint8_t fracDelta; /*!< Fractional part of the delta [0;3] 0.25 steps (SW TD only) */
uint16_t reference; /*!< Reference to be used;RFAL_WUM_REFERENCE_AUTO sets it auto */
bool autoAvg; /*!< Use the HW Auto Averaging feature */
bool aaInclMeas; /*!< When AutoAvg is enabled, include IRQ measurement */
rfalWumAAWeight aaWeight; /*!< When AutoAvg is enabled, last measure weight */
}indPha; /*!< Inductive Phase Configuration */
struct{
bool enabled; /*!< Capacitive measurement enabled */
uint8_t delta; /*!< Delta between the reference and measurement to wake-up */
uint16_t reference; /*!< Reference to be used;RFAL_WUM_REFERENCE_AUTO sets it auto */
bool autoAvg; /*!< Use the HW Auto Averaging feature */
bool aaInclMeas; /*!< When AutoAvg is enabled, include IRQ measurement */
rfalWumAAWeight aaWeight; /*!< When AutoAvg is enabled, last measure weight */
}cap; /*!< Capacitive Configuration */
} rfalWakeUpConfig;
/*! RFAL Wake-Up Mode information */
typedef struct {
bool irqWut; /*!< Wake-Up Timer IRQ received (cleared upon read) */
struct {
uint8_t lastMeas; /*!< Value of the latest measurement */
uint16_t
reference; /*!< Current reference value (TD format if SW TD enabled) */
bool irqWu; /*!< Amplitude WU IRQ received (cleared upon read) */
} indAmp; /*!< Inductive Amplitude */
struct {
uint8_t lastMeas; /*!< Value of the latest measurement */
uint16_t
reference; /*!< Current reference value (TD format if SW TD enabled) */
bool irqWu; /*!< Phase WU IRQ received (cleared upon read) */
} indPha; /*!< Inductive Phase */
struct {
uint8_t lastMeas; /*!< Value of the latest measurement */
uint16_t reference; /*!< Current reference value */
bool irqWu; /*!< Capacitive WU IRQ received (cleared upon read) */
} cap; /*!< Capacitive */
typedef struct
{
bool irqWut; /*!< Wake-Up Timer IRQ received (cleared upon read) */
struct{
uint8_t lastMeas; /*!< Value of the latest measurement */
uint16_t reference; /*!< Current reference value (TD format if SW TD enabled) */
bool irqWu; /*!< Amplitude WU IRQ received (cleared upon read) */
}indAmp; /*!< Inductive Amplitude */
struct{
uint8_t lastMeas; /*!< Value of the latest measurement */
uint16_t reference; /*!< Current reference value (TD format if SW TD enabled) */
bool irqWu; /*!< Phase WU IRQ received (cleared upon read) */
}indPha; /*!< Inductive Phase */
struct{
uint8_t lastMeas; /*!< Value of the latest measurement */
uint16_t reference; /*!< Current reference value */
bool irqWu; /*!< Capacitive WU IRQ received (cleared upon read) */
}cap; /*!< Capacitive */
} rfalWakeUpInfo;
#endif /* RFAL_FEATURES_H */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,22 +1,24 @@
/******************************************************************************
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/*
* PROJECT: ST25R3916 firmware
* Revision:
* Revision:
* LANGUAGE: ISO C99
*/
@ -37,13 +39,14 @@
* \addtogroup ST25R3916
* \brief RFAL ST25R3916 Driver
* @{
*
*
* \addtogroup ST25R3916_Driver
* \brief RFAL ST25R3916 Driver
* @{
*
*
*/
#ifndef ST25R3916_H
#define ST25R3916_H
@ -62,23 +65,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;
/*! 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;
/*! Parameters how the stream mode should work */
/*! 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
@ -86,101 +87,58 @@ 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_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 */
#ifdef ST25R3916
#define ST25R3916_CMD_CALIBRATE_C_SENSOR \
0xDDU /*!< Calibrate the capacitive sensor */
#define ST25R3916_CMD_MEASURE_CAPACITANCE \
0xDEU /*!< Measure capacitance */
#endif /* ST25R3916 */
#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_CALIBRATE_C_SENSOR 0xDDU /*!< Calibrate the capacitive sensor */
#define ST25R3916_CMD_MEASURE_CAPACITANCE 0xDEU /*!< Measure capacitance */
#endif /* ST25R3916 */
#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 */
#ifdef ST25R3916B
#define ST25R3916_CMD_RC_CAL \
0xEAU /*!< Trigger RC calibration */
#endif /* ST25R3916B */
#define ST25R3916_CMD_SPACE_B_ACCESS \
0xFBU /*!< Enable R/W access to the space B registers */
#define ST25R3916_CMD_TEST_ACCESS \
0xFCU /*!< Enable R/W access to the test registers */
#define ST25R3916_CMD_RC_CAL 0xEAU /*!< Trigger RC calibration */
#endif /* ST25R3916B */
#define ST25R3916_CMD_SPACE_B_ACCESS 0xFBU /*!< Enable R/W access to the space B 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_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_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 */
/*
******************************************************************************
@ -188,61 +146,35 @@ 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))
/*! 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 ) )
/*! 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))
/*! 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 ) )
/*! Disables the Transmitter (Field Off) */
#define st25r3916TxOff() \
st25r3916ClrRegisterBits(ST25R3916_REG_OP_CONTROL, \
ST25R3916_REG_OP_CONTROL_tx_en)
/*! Disables the Transmitter (Field Off) */
#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)
/*! 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 )
/*! 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)
/*! 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 )
/*! 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 )
/*! Checks if the AAT is enabled */
#define st25r3916IsAATOn() \
st25r3916CheckReg(ST25R3916_REG_IO_CONF2, ST25R3916_REG_IO_CONF2_aat_en, \
ST25R3916_REG_IO_CONF2_aat_en)
#define st25r3916IsAATOn() st25r3916CheckReg( ST25R3916_REG_IO_CONF2, ST25R3916_REG_IO_CONF2_aat_en, ST25R3916_REG_IO_CONF2_aat_en )
/*
******************************************************************************
@ -250,24 +182,23 @@ struct st25r3916StreamConfig {
******************************************************************************
*/
/*!
/*!
*****************************************************************************
* \brief Initialise ST25R3916 driver
*
* This function initialises the ST25R3916 driver.
*
* \return RFAL_ERR_NONE : Operation successful
* \return RFAL_ERR_HW_MISMATCH : Expected HW do not match or communication
*error \return RFAL_ERR_IO : Error during communication selftest.
*Check communication interface \return RFAL_ERR_TIMEOUT : Timeout during
*IRQ selftest. Check IRQ handling \return RFAL_ERR_SYSTEM : Failure
*during oscillator activation or timer error
* \return RFAL_ERR_HW_MISMATCH : Expected HW do not match or communication error
* \return RFAL_ERR_IO : Error during communication selftest. Check communication interface
* \return RFAL_ERR_TIMEOUT : Timeout during IRQ selftest. Check IRQ handling
* \return RFAL_ERR_SYSTEM : Failure during oscillator activation or timer error
*
*****************************************************************************
*/
ReturnCode st25r3916Initialize(void);
ReturnCode st25r3916Initialize( void );
/*!
/*!
*****************************************************************************
* \brief Deinitialize ST25R3916 driver
*
@ -275,24 +206,23 @@ ReturnCode st25r3916Initialize(void);
*
*****************************************************************************
*/
void st25r3916Deinitialize(void);
void st25r3916Deinitialize( void );
/*!
/*!
*****************************************************************************
* \brief Turn on Oscillator and Regulator
*
* This function turn on oscillator and regulator and waits for the
*
* This function turn on oscillator and regulator and waits for the
* oscillator to become stable
*
*
* \return RFAL_ERR_SYSTEM : Failure dusring Oscillator activation
* \return RFAL_ERR_NONE : No error, Oscillator is active and stable,
*Regulator is on
* \return RFAL_ERR_NONE : No error, Oscillator is active and stable, Regulator is on
*
*****************************************************************************
*/
ReturnCode st25r3916OscOn(void);
ReturnCode st25r3916OscOn( void );
/*!
/*!
*****************************************************************************
* \brief Sets the bitrate
*
@ -308,18 +238,18 @@ ReturnCode st25r3916OscOn(void);
*
*****************************************************************************
*/
ReturnCode st25r3916SetBitrate(uint8_t txrate, uint8_t rxrate);
ReturnCode st25r3916SetBitrate( uint8_t txrate, uint8_t rxrate );
/*!
/*!
*****************************************************************************
* \brief Adjusts supply regulators according to the current supply voltage
*
* This function the power level is measured in maximum load conditions and
* the regulated voltage reference is set to 250mV below this level.
* Execution of this function lasts arround 5ms.
* Execution of this function lasts arround 5ms.
*
* The regulated voltages will be set to the result of Adjust Regulators
*
*
* \param [out] result_mV : Result of calibration in milliVolts
*
* \return RFAL_ERR_IO : Error during communication with ST25R3916
@ -327,9 +257,9 @@ ReturnCode st25r3916SetBitrate(uint8_t txrate, uint8_t rxrate);
*
*****************************************************************************
*/
ReturnCode st25r3916AdjustRegulators(uint16_t* result_mV);
ReturnCode st25r3916AdjustRegulators( uint16_t* result_mV );
/*!
/*!
*****************************************************************************
* \brief Measure Amplitude
*
@ -340,12 +270,12 @@ ReturnCode st25r3916AdjustRegulators(uint16_t* result_mV);
*
* \return RFAL_ERR_PARAM : Invalid parameter
* \return RFAL_ERR_NONE : No error
*
*
*****************************************************************************
*/
ReturnCode st25r3916MeasureAmplitude(uint8_t* result);
ReturnCode st25r3916MeasureAmplitude( uint8_t* result );
/*!
/*!
*****************************************************************************
* \brief Measure Power Supply
*
@ -361,13 +291,13 @@ ReturnCode st25r3916MeasureAmplitude(uint8_t* result);
*
*****************************************************************************
*/
uint8_t st25r3916MeasurePowerSupply(uint8_t mpsv);
uint8_t st25r3916MeasurePowerSupply( uint8_t mpsv );
/*!
/*!
*****************************************************************************
* \brief Measure Voltage
*
* This function measures the voltage on one of VDD and VDD_* and returns
* This function measures the voltage on one of VDD and VDD_* and returns
* the result in mV
*
* \param[in] mpsv : one of ST25R3916_REG_REGULATOR_CONTROL_mpsv_vdd
@ -380,9 +310,9 @@ uint8_t st25r3916MeasurePowerSupply(uint8_t mpsv);
*
*****************************************************************************
*/
uint16_t st25r3916MeasureVoltage(uint8_t mpsv);
uint16_t st25r3916MeasureVoltage( uint8_t mpsv );
/*!
/*!
*****************************************************************************
* \brief Measure Phase
*
@ -393,12 +323,13 @@ uint16_t st25r3916MeasureVoltage(uint8_t mpsv);
*
* \return RFAL_ERR_PARAM : Invalid parameter
* \return RFAL_ERR_NONE : No error
*
*
*****************************************************************************
*/
ReturnCode st25r3916MeasurePhase(uint8_t* result);
ReturnCode st25r3916MeasurePhase( uint8_t* result );
/*!
/*!
*****************************************************************************
* \brief Measure Capacitance
*
@ -409,49 +340,49 @@ ReturnCode st25r3916MeasurePhase(uint8_t* result);
*
* \return RFAL_ERR_PARAM : Invalid parameter
* \return RFAL_ERR_NONE : No error
*
*
*****************************************************************************
*/
ReturnCode st25r3916MeasureCapacitance(uint8_t* result);
ReturnCode st25r3916MeasureCapacitance( uint8_t* result );
/*!
/*!
*****************************************************************************
* \brief Calibrates Capacitive Sensor
*
* This function performs automatic calibration of the capacitive sensor
* This function performs automatic calibration of the capacitive sensor
* and stores the result in parameter \a result.
*
* \warning To avoid interference with Xtal oscillator and reader magnetic
* \warning To avoid interference with Xtal oscillator and reader magnetic
* field, it is strongly recommended to perform calibration
* in Power-down mode only.
* This method does not modify the Oscillator nor transmitter state,
* This method does not modify the Oscillator nor transmitter state,
* these should be configured before by user.
*
* \param[out] result: 5 bit long result of the calibration.
* Binary weighted, step 0.1 pF, max 3.1 pF
*
* \return RFAL_ERR_PARAM : Invalid parameter
* \return RFAL_ERR_IO : The calibration was not successful
* \return RFAL_ERR_IO : The calibration was not successful
* \return RFAL_ERR_NONE : No error
*
*
*****************************************************************************
*/
ReturnCode st25r3916CalibrateCapacitiveSensor(uint8_t* result);
ReturnCode st25r3916CalibrateCapacitiveSensor( uint8_t* result );
/*!
/*!
*****************************************************************************
* \brief Get NRT time
*
* This returns the last value set on the NRT
*
* \warning it does not read chip register, just the sw var that contains the
*
* \warning it does not read chip register, just the sw var that contains the
* last value set before
*
* \return the value of the NRT in 64/fc
* \return the value of the NRT in 64/fc
*/
uint32_t st25r3916GetNoResponseTime(void);
uint32_t st25r3916GetNoResponseTime( void );
/*!
/*!
*****************************************************************************
* \brief Set NRT time
*
@ -462,15 +393,15 @@ uint32_t st25r3916GetNoResponseTime(void);
* \return RFAL_ERR_PARAM : Invalid parameter (time is too large)
* \return RFAL_ERR_NONE : No error
*
*****************************************************************************
*****************************************************************************
*/
ReturnCode st25r3916SetNoResponseTime(uint32_t nrt_64fcs);
ReturnCode st25r3916SetNoResponseTime( uint32_t nrt_64fcs );
/*!
/*!
*****************************************************************************
* \brief Set and Start NRT
*
* This function sets the No Response Time with the given value and
* This function sets the No Response Time with the given value and
* immediately starts it
* Used when needs to add more time before timeout without performing Tx
*
@ -479,150 +410,145 @@ ReturnCode st25r3916SetNoResponseTime(uint32_t nrt_64fcs);
* \return RFAL_ERR_PARAM : Invalid parameter
* \return RFAL_ERR_NONE : No error
*
*****************************************************************************
*****************************************************************************
*/
ReturnCode st25r3916SetStartNoResponseTimer(uint32_t nrt_64fcs);
ReturnCode st25r3916SetStartNoResponseTimer( uint32_t nrt_64fcs );
/*!
/*!
*****************************************************************************
* \brief Set GPT time
*
* This function sets the General Purpose Timer time registers
*
* \param [in] gpt_8fcs : general purpose timer timeout in steps of 8/fc
*(590ns)
* \param [in] gpt_8fcs : general purpose timer timeout in steps of 8/fc (590ns)
*
*****************************************************************************
*/
void st25r3916SetGPTime(uint16_t gpt_8fcs);
void st25r3916SetGPTime( uint16_t gpt_8fcs );
/*!
/*!
*****************************************************************************
* \brief Set and Start GPT
*
* This function sets the General Purpose Timer with the given timeout and
* This function sets the General Purpose Timer with the given timeout and
* immediately starts it ONLY if the trigger source is not set to none.
*
* \param [in] gpt_8fcs : general purpose timer timeout in steps of8/fc
*(590ns) \param [in] trigger_source : no trigger, start of Rx, end of Rx, end
*of Tx in NFC mode
*
* \param [in] gpt_8fcs : general purpose timer timeout in steps of8/fc (590ns)
* \param [in] trigger_source : no trigger, start of Rx, end of Rx, end of Tx in NFC mode
*
* \return RFAL_ERR_PARAM : Invalid parameter
* \return RFAL_ERR_NONE : No error
*
* \return RFAL_ERR_NONE : No error
*
*****************************************************************************
*/
ReturnCode st25r3916SetStartGPTimer(uint16_t gpt_8fcs, uint8_t trigger_source);
ReturnCode st25r3916SetStartGPTimer( uint16_t gpt_8fcs, uint8_t trigger_source );
/*!
/*!
*****************************************************************************
* \brief Sets the number Tx Bits
*
*
* Sets ST25R3916 internal registers with correct number of complete bytes and
* bits to be sent
*
*
* \param [in] nBits : number of bits to be set/transmitted
*
*
*****************************************************************************
*/
void st25r3916SetNumTxBits(uint16_t nBits);
void st25r3916SetNumTxBits( uint16_t nBits );
/*!
/*!
*****************************************************************************
* \brief Get amount of bytes in FIFO
*
*
* Gets the number of bytes currently in the FIFO
*
*
* \return the number of bytes currently in the FIFO
*
*
*****************************************************************************
*/
uint16_t st25r3916GetNumFIFOBytes(void);
uint16_t st25r3916GetNumFIFOBytes( void );
/*!
/*!
*****************************************************************************
* \brief Get amount of bits of the last FIFO byte if incomplete
*
*
* Gets the number of bits of the last FIFO byte if incomplete
*
* \return the number of bits of the last FIFO byte if incomplete, 0 if
*
* \return the number of bits of the last FIFO byte if incomplete, 0 if
* the last byte is complete
*
*
*****************************************************************************
*/
uint8_t st25r3916GetNumFIFOLastBits(void);
uint8_t st25r3916GetNumFIFOLastBits( void );
/*!
/*!
*****************************************************************************
* \brief Perform Collision Avoidance
*
* Performs Collision Avoidance with the given threshold and with the
* n number of TRFW
* Performs Collision Avoidance with the given threshold and with the
* n number of TRFW
*
* \param[in] FieldONCmd : Field ON command to be executed ST25R3916_CMD_INITIAL_RF_COLLISION
* or ST25R3916_CMD_RESPONSE_RF_COLLISION_N
* \param[in] pdThreshold : Peer Detection Threshold (ST25R3916_REG_FIELD_THRESHOLD_trg_xx)
* 0xff : don't set Threshold (ST25R3916_THRESHOLD_DO_NOT_SET)
* \param[in] caThreshold : Collision Avoidance Threshold (ST25R3916_REG_FIELD_THRESHOLD_rfe_xx)
* 0xff : don't set Threshold (ST25R3916_THRESHOLD_DO_NOT_SET)
* \param[in] nTRFW : Number of TRFW
*
* \param[in] FieldONCmd : Field ON command to be executed
*ST25R3916_CMD_INITIAL_RF_COLLISION or ST25R3916_CMD_RESPONSE_RF_COLLISION_N
* \param[in] pdThreshold : Peer Detection Threshold
*(ST25R3916_REG_FIELD_THRESHOLD_trg_xx) 0xff : don't set Threshold
*(ST25R3916_THRESHOLD_DO_NOT_SET) \param[in] caThreshold : Collision Avoidance
*Threshold (ST25R3916_REG_FIELD_THRESHOLD_rfe_xx) 0xff : don't set Threshold
*(ST25R3916_THRESHOLD_DO_NOT_SET) \param[in] nTRFW : Number of TRFW
*
* \return RFAL_ERR_PARAM : Invalid parameter
* \return RFAL_ERR_PARAM : Invalid parameter
* \return RFAL_ERR_RF_COLLISION : Collision detected
* \return RFAL_ERR_NONE : No collision detected
*
*
*****************************************************************************
*/
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 );
/*!
/*!
*****************************************************************************
* \brief Check Identity
*
* Checks if the chip ID is as expected.
*
*
* 5 bit IC type code for ST25R3916: 00101
* The 3 lsb contain the IC revision code
*
*
* \param[out] rev : the IC revision code
*
*
* \return true when IC type is as expected
* \return false otherwise
*/
bool st25r3916CheckChipID(uint8_t* rev);
bool st25r3916CheckChipID( uint8_t *rev );
/*!
/*!
*****************************************************************************
* \brief Retrieves all internal registers from ST25R3916
*
*
* \param[out] regDump : pointer to the struct/buffer where the reg dump
* will be written
*
*
* \return RFAL_ERR_PARAM : Invalid parameter
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode st25r3916GetRegsDump(t_st25r3916Regs* regDump);
ReturnCode st25r3916GetRegsDump( t_st25r3916Regs* regDump );
/*!
/*!
*****************************************************************************
* \brief Check if command is valid
*
* Checks if the given command is a valid ST25R3916 command
*
* \param[in] cmd: Command to check
*
*
* \return true if is a valid command
* \return false otherwise
*
*****************************************************************************
*/
bool st25r3916IsCmdValid(uint8_t cmd);
bool st25r3916IsCmdValid( uint8_t cmd );
/*!
/*!
*****************************************************************************
* \brief Configure the stream mode of ST25R3916
*
@ -635,9 +561,9 @@ bool st25r3916IsCmdValid(uint8_t cmd);
*
*****************************************************************************
*/
ReturnCode st25r3916StreamConfigure(const struct st25r3916StreamConfig* config);
ReturnCode st25r3916StreamConfigure( const struct st25r3916StreamConfig *config );
/*!
/*!
*****************************************************************************
* \brief Executes a direct command and returns the result
*
@ -651,35 +577,35 @@ ReturnCode st25r3916StreamConfigure(const struct st25r3916StreamConfig* config);
* \param[out] result: result
*
* \return RFAL_ERR_NONE : No error
*
*
*****************************************************************************
*/
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 );
/*!
/*!
*****************************************************************************
* \brief Gets the RSSI values
*
* This function gets the RSSI value of the previous reception taking into
* account the gain reductions that were used.
* This function gets the RSSI value of the previous reception taking into
* account the gain reductions that were used.
* RSSI value for both AM and PM channel can be retrieved.
*
* \param[out] amRssi: the RSSI on the AM channel expressed in mV
* \param[out] pmRssi: the RSSI on the PM channel expressed in mV
*
* \param[out] amRssi: the RSSI on the AM channel expressed in mV
* \param[out] pmRssi: the RSSI on the PM channel expressed in mV
*
* \return RFAL_ERR_PARAM : Invalid parameter
* \return RFAL_ERR_NONE : No error
*
*
*****************************************************************************
*/
ReturnCode st25r3916GetRSSI(uint16_t* amRssi, uint16_t* pmRssi);
ReturnCode st25r3916GetRSSI( uint16_t *amRssi, uint16_t *pmRssi );
/*!
/*!
*****************************************************************************
* \brief Set Antenna mode
*
* Sets the antenna mode.
* Sets the antenna mode.
* Differential or single ended antenna mode (RFO1 or RFO2)
*
* \param[in] single: FALSE differential ; single ended mode
@ -690,16 +616,16 @@ ReturnCode st25r3916GetRSSI(uint16_t* amRssi, uint16_t* pmRssi);
* \return RFAL_ERR_NONE : No error
*****************************************************************************
*/
ReturnCode st25r3916SetAntennaMode(bool single, bool rfiox);
ReturnCode st25r3916SetAntennaMode( bool single, bool rfiox );
#endif /* ST25R3916_H */
/**
* @}
*
* @}
*
* @}
*
* @}
*/
* @}
*
* @}
*
* @}
*
* @}
*/

View File

@ -1,351 +1,322 @@
/******************************************************************************
* @attention
*
* COPYRIGHT 2019 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
* @attention
*
* COPYRIGHT 2019 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/*
* PROJECT: ST25R3916 firmware
* Revision:
* Revision:
* LANGUAGE: ISO C99
*/
/*! \file st25r3916_aat.c
*
* \author
* \author
*
* \brief ST25R3916 Antenna Tuning
* \brief ST25R3916 Antenna Tuning
*
* The antenna tuning algorithm tries to find the optimal settings for
* the AAT_A and AAT_B registers, which are connected to variable capacitors
* The antenna tuning algorithm tries to find the optimal settings for
* the AAT_A and AAT_B registers, which are connected to variable capacitors
* to tune the antenna matching.
*
*/
/*
******************************************************************************
* INCLUDES
******************************************************************************
*/
#include "st25r3916_aat.h"
#include "rfal_chip.h"
#include "rfal_platform.h"
#include "rfal_utils.h"
#include "st25r3916.h"
#include "st25r3916_com.h"
#include "rfal_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 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,
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,
.phaTarget = 128,
.phaWeight = 2,
.ampTarget = 196,
.ampWeight = 1,
.phaTarget=128,
.phaWeight=2,
.ampTarget=196,
.ampWeight=1,
.doDynamicSteps = true,
.measureLimit = 50,
};
struct st25r3916AatTuneResult defaultTuneResult;
.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 )
))
{
return RFAL_ERR_PARAM;
}
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 RFAL_ERR_PARAM;
}
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 == 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);
ts->measureCnt = 0; /* Clear current measure count */
err = aatHillClimb(tp, ts);
return err;
return err;
}
/*******************************************************************************/
static ReturnCode aatHillClimb(
const struct st25r3916AatTuneParams *tuningParams,
struct st25r3916AatTuneResult *tuningStatus) {
ReturnCode err = RFAL_ERR_NONE;
uint32_t f_min;
int32_t direction, gdirection;
uint8_t amp, phs;
struct st25r3916AatTuneParams tp = *tuningParams; // local copy to obey const
static ReturnCode aatHillClimb(const struct st25r3916AatTuneParams *tuningParams, struct st25r3916AatTuneResult *tuningStatus)
{
ReturnCode err = RFAL_ERR_NONE;
uint32_t f_min;
int32_t direction, gdirection;
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;
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);
f_min = aatCalcF(&tp, amp, phs);
direction = 0;
/* Get a proper start value */
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 */
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) {
err = RFAL_ERR_OVERRUN;
break;
}
do {
gdirection = aatGreedyDescent(&f_min, &tp, tuningStatus, direction);
if (tuningStatus->measureCnt > tp.measureLimit) {
err = RFAL_ERR_OVERRUN;
break;
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)
{
err = RFAL_ERR_OVERRUN;
break;
}
do
{
gdirection = aatGreedyDescent(&f_min, &tp, tuningStatus, direction);
if (tuningStatus->measureCnt > tp.measureLimit) {
err = RFAL_ERR_OVERRUN;
break;
}
} 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)));
return err;
}
/*******************************************************************************/
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;
uint32_t f;
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;
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 */
continue;
}
} 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)));
return err;
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("*");
*f_min = f;
bestdir = i;
}
st25r3916AatLog("\n");
}
if (0!=bestdir)
{ /* Walk into the best direction */
aatStepDacVals(tuningParams, &tuningStatus->aat_a, &tuningStatus->aat_b, bestdir);
}
return bestdir;
}
/*******************************************************************************/
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;
uint32_t f;
int32_t bestdir = 0; /* Negative direction: decrease, Positive: increase.
(-)1: aat_a, (-)2: aat_b */
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;
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 */
continue;
}
if (0U != aatStepDacVals(tuningParams, &a, &b,
i)) { /* If stepping did not change the value, omit
this direction */
continue;
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("%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("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");
}
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;
uint32_t f;
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 */
return 0;
}
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("*\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) {
/* f(amp, pha) = (ampWeight * |amp - ampTarget|) + (phaWeight * |pha -
* phaTarget|) */
uint8_t ampTarget = tuningParams->ampTarget;
uint8_t phaTarget = tuningParams->phaTarget;
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;
uint32_t ampWeight = tuningParams->ampWeight;
uint32_t phaWeight = tuningParams->phaWeight;
uint32_t ampWeight = tuningParams->ampWeight;
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));
/* 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));
uint32_t ampDelta = (uint32_t)ad;
uint32_t phaDelta = (uint32_t)pd;
uint32_t ampDelta = (uint32_t)ad;
uint32_t phaDelta = (uint32_t)pd;
return ((ampWeight * ampDelta) + (phaWeight * phaDelta));
return ((ampWeight * ampDelta) + (phaWeight * phaDelta));
}
/*******************************************************************************/
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;
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 RFAL_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 RFAL_ERR_PARAM;}
break;
default:
return RFAL_ERR_REQUEST;
}
/* We only get here if actual values have changed. In all other cases an error is returned */
*a = (uint8_t)aat_a;
*b = (uint8_t)aat_b;
return RFAL_ERR_NONE;
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 RFAL_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 RFAL_ERR_PARAM;
}
break;
default:
return RFAL_ERR_REQUEST;
}
/* We only get here if actual values have changed. In all other cases an error
* is returned */
*a = (uint8_t)aat_a;
*b = (uint8_t)aat_b;
return RFAL_ERR_NONE;
}
/*******************************************************************************/
static ReturnCode aatMeasure(uint8_t serCap, uint8_t parCap, uint8_t *amplitude,
uint8_t *phase, uint16_t *measureCnt) {
ReturnCode err;
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);
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);
/* Get amplitude and phase .. */
err = rfalChipMeasureAmplitude(amplitude);
if (RFAL_ERR_NONE == err) {
err = rfalChipMeasurePhase(phase);
}
if (measureCnt != NULL) {
(*measureCnt)++;
}
return err;
/* Wait till caps have settled.. */
platformDelay( ST25R3916_AAT_CAP_DELAY_MAX );
/* Get amplitude and phase .. */
err = rfalChipMeasureAmplitude(amplitude);
if (RFAL_ERR_NONE == err)
{
err = rfalChipMeasurePhase(phase);
}
if( measureCnt != NULL )
{
(*measureCnt)++;
}
return err;
}

View File

@ -1,21 +1,22 @@
/******************************************************************************
* @attention
*
* COPYRIGHT 2019 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
* @attention
*
* COPYRIGHT 2019 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/*
* PROJECT: ST25R3916 firmware
* Revision:
* Revision:
* LANGUAGE: ISO C99
*/
@ -23,14 +24,15 @@
*
* \author
*
* \brief ST25R3916 Antenna Tuning
* \brief ST25R3916 Antenna Tuning
*
* The antenna tuning algorithm tries to find the optimal settings for
* the AAT_A and AAT_B registers, which are connected to variable capacitors
* The antenna tuning algorithm tries to find the optimal settings for
* the AAT_A and AAT_B registers, which are connected to variable capacitors
* to tune the antenna matching.
*
*/
#ifndef ST25R3916_AAT_H
#define ST25R3916_AAT_H
@ -46,52 +48,56 @@
/*!
* 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
*
* This function starts an antenna tuning procedure by modifying the serial
* This function starts an antenna tuning procedure by modifying the serial
* and parallel capacitors of the antenna matching circuit via the AAT_A
* and AAT_B registers.
* and AAT_B registers.
* This function is best run if the field is already turned on.
* When used on ST25R3916B with new rgs_am=1 it is necessary to turn on the
* field before running this procedure or to set rgs_txonoff=0.
*
*
* \param[in] tuningParams : Input parameters for the tuning algorithm. If NULL
* default values will be used.
* \param[out] tuningStatus : Result information of performed tuning. If NULL
* no further information is returned, only
*registers ST25R3916 (AAT_A,B) will be adapted.
* no further information is returned, only registers
* ST25R3916 (AAT_A,B) will be adapted.
*
* \return RFAL_ERR_IO : Error during communication.
* \return RFAL_ERR_PARAM : Invalid input parameters
@ -99,8 +105,6 @@ 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 */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,22 +1,23 @@
/******************************************************************************
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/*
* PROJECT: ST25R3916 firmware
* Revision:
* Revision:
* LANGUAGE: ISO C99
*/
@ -35,10 +36,10 @@
*/
#include "st25r3916_irq.h"
#include "rfal_utils.h"
#include "st25r3916.h"
#include "st25r3916_com.h"
#include "st25r3916_led.h"
#include "st25r3916.h"
#include "rfal_utils.h"
/*
******************************************************************************
@ -46,15 +47,16 @@
******************************************************************************
*/
/*! 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 */
/*! 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 */
} st25r3916Interrupt;
/*
******************************************************************************
* GLOBAL DEFINES
@ -62,8 +64,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 )
/*
******************************************************************************
@ -71,162 +72,185 @@ typedef struct {
******************************************************************************
*/
static volatile st25r3916Interrupt
st25r3916interrupt; /*!< Instance of ST25R3916 interrupt */
static volatile st25r3916Interrupt st25r3916interrupt; /*!< Instance of ST25R3916 interrupt */
/*
******************************************************************************
* GLOBAL FUNCTIONS
******************************************************************************
*/
void st25r3916InitInterrupts(void) {
platformIrqST25RPinInitialize();
platformIrqST25RSetCallback(st25r3916Isr);
st25r3916interrupt.callback = NULL;
st25r3916interrupt.prevCallback = NULL;
st25r3916interrupt.status = ST25R3916_IRQ_MASK_NONE;
st25r3916interrupt.mask = ST25R3916_IRQ_MASK_NONE;
void st25r3916InitInterrupts( void )
{
platformIrqST25RPinInitialize();
platformIrqST25RSetCallback( st25r3916Isr );
st25r3916interrupt.callback = NULL;
st25r3916interrupt.prevCallback = NULL;
st25r3916interrupt.status = ST25R3916_IRQ_MASK_NONE;
st25r3916interrupt.mask = ST25R3916_IRQ_MASK_NONE;
}
/*******************************************************************************/
void st25r3916Isr(void) {
st25r3916CheckForReceivedInterrupts();
// Check if callback is set and run it
if (NULL != st25r3916interrupt.callback) {
st25r3916interrupt.callback();
}
/*******************************************************************************/
void st25r3916Isr( void )
{
st25r3916CheckForReceivedInterrupts();
// Check if callback is set and run it
if( NULL != st25r3916interrupt.callback )
{
st25r3916interrupt.callback();
}
}
/*******************************************************************************/
void st25r3916CheckForReceivedInterrupts(void) {
uint8_t iregs[ST25R3916_INT_REGS_LEN];
uint32_t irqStatus;
/* Initialize iregs */
irqStatus = ST25R3916_IRQ_MASK_NONE;
RFAL_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);
void st25r3916CheckForReceivedInterrupts( void )
{
uint8_t iregs[ST25R3916_INT_REGS_LEN];
uint32_t irqStatus;
/* Initialize iregs */
irqStatus = ST25R3916_IRQ_MASK_NONE;
RFAL_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 );
}
/*******************************************************************************/
void st25r3916ModifyInterrupts(uint32_t clr_mask, uint32_t set_mask) {
uint8_t i;
uint32_t old_mask;
uint32_t new_mask;
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;
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 )
{
continue;
}
st25r3916WriteRegister(ST25R3916_REG_IRQ_MASK_MAIN + i, (uint8_t)((st25r3916interrupt.mask>>(8U*i)) & 0xFFU) );
}
return;
}
for (i = 0; i < ST25R3916_INT_REGS_LEN; i++) {
if (((new_mask >> (8U * i)) & 0xFFU) == 0U) {
continue;
/*******************************************************************************/
uint32_t st25r3916WaitForInterruptsTimed( uint32_t mask, uint16_t tmo )
{
uint32_t tmrDelay;
uint32_t status;
tmrDelay = platformTimerCreate( tmo );
/* Run until specific interrupt has happen or the timer has expired */
do
{
status = (st25r3916interrupt.status & mask);
} 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 irqs;
irqs = (st25r3916interrupt.status & mask);
if(irqs != ST25R3916_IRQ_MASK_NONE)
{
platformProtectST25RIrqStatus();
st25r3916interrupt.status &= ~irqs;
platformUnprotectST25RIrqStatus();
}
st25r3916WriteRegister(
ST25R3916_REG_IRQ_MASK_MAIN + i,
(uint8_t)((st25r3916interrupt.mask >> (8U * i)) & 0xFFU));
}
return;
return irqs;
}
/*******************************************************************************/
void st25r3916ClearAndEnableInterrupts( uint32_t mask )
{
st25r3916GetInterrupt( mask );
st25r3916EnableInterrupts( mask );
}
/*******************************************************************************/
void st25r3916EnableInterrupts(uint32_t mask)
{
st25r3916ModifyInterrupts(mask, 0);
}
/*******************************************************************************/
void st25r3916DisableInterrupts(uint32_t mask)
{
st25r3916ModifyInterrupts(0, mask);
}
/*******************************************************************************/
uint32_t st25r3916WaitForInterruptsTimed(uint32_t mask, uint16_t tmo) {
uint32_t tmrDelay;
uint32_t status;
void st25r3916ClearInterrupts( void )
{
uint8_t iregs[ST25R3916_INT_REGS_LEN];
tmrDelay = platformTimerCreate(tmo);
st25r3916ReadMultipleRegisters(ST25R3916_REG_IRQ_MAIN, iregs, ST25R3916_INT_REGS_LEN);
/* Run until specific interrupt has happen or the timer has expired */
do {
status = (st25r3916interrupt.status & mask);
} 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 irqs;
irqs = (st25r3916interrupt.status & mask);
if (irqs != ST25R3916_IRQ_MASK_NONE) {
platformProtectST25RIrqStatus();
st25r3916interrupt.status &= ~irqs;
st25r3916interrupt.status = ST25R3916_IRQ_MASK_NONE;
platformUnprotectST25RIrqStatus();
}
return irqs;
return;
}
/*******************************************************************************/
void st25r3916ClearAndEnableInterrupts(uint32_t mask) {
st25r3916GetInterrupt(mask);
st25r3916EnableInterrupts(mask);
void st25r3916IRQCallbackSet( void (*cb)(void) )
{
st25r3916interrupt.prevCallback = st25r3916interrupt.callback;
st25r3916interrupt.callback = cb;
}
/*******************************************************************************/
void st25r3916EnableInterrupts(uint32_t mask) {
st25r3916ModifyInterrupts(mask, 0);
void st25r3916IRQCallbackRestore( void )
{
st25r3916interrupt.callback = st25r3916interrupt.prevCallback;
st25r3916interrupt.prevCallback = NULL;
}
/*******************************************************************************/
void st25r3916DisableInterrupts(uint32_t mask) {
st25r3916ModifyInterrupts(0, mask);
}
/*******************************************************************************/
void st25r3916ClearInterrupts(void) {
uint8_t iregs[ST25R3916_INT_REGS_LEN];
st25r3916ReadMultipleRegisters(ST25R3916_REG_IRQ_MAIN, iregs,
ST25R3916_INT_REGS_LEN);
platformProtectST25RIrqStatus();
st25r3916interrupt.status = ST25R3916_IRQ_MASK_NONE;
platformUnprotectST25RIrqStatus();
return;
}
/*******************************************************************************/
void st25r3916IRQCallbackSet(void (*cb)(void)) {
st25r3916interrupt.prevCallback = st25r3916interrupt.callback;
st25r3916interrupt.callback = cb;
}
/*******************************************************************************/
void st25r3916IRQCallbackRestore(void) {
st25r3916interrupt.callback = st25r3916interrupt.prevCallback;
st25r3916interrupt.prevCallback = NULL;
}

View File

@ -1,22 +1,24 @@
/******************************************************************************
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/*
* PROJECT: ST25R3916 firmware
* Revision:
* Revision:
* LANGUAGE: ISO C99
*/
@ -36,11 +38,11 @@
* \addtogroup ST25R3916
* \brief RFAL ST25R3916 Driver
* @{
*
*
* \addtogroup ST25R3916_IRQ
* \brief RFAL ST25R3916 IRQ
* @{
*
*
*/
#ifndef ST25R3916_IRQ_H
@ -60,102 +62,52 @@
******************************************************************************
*/
#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_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 */
#if defined(ST25R3916)
#define ST25R3916_IRQ_MASK_WCAP \
(uint32_t)( \
0x00010000U) /*!< ST25R3916 wake-up due to capacitance measurement */
#define ST25R3916_IRQ_MASK_WCAP (uint32_t)(0x00010000U) /*!< ST25R3916 wake-up due to capacitance measurement */
#elif defined(ST25R3916B)
#define ST25R3916_IRQ_MASK_WCAP \
ST25R3916_IRQ_MASK_NONE /*!< ST25R3916B disable capacitive WU */
#endif /* ST25R3916 */
#define ST25R3916_IRQ_MASK_WCAP ST25R3916_IRQ_MASK_NONE /*!< ST25R3916B disable capacitive WU */
#endif /* ST25R3916 */
/* 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 */
/*
******************************************************************************
@ -163,7 +115,8 @@
******************************************************************************
*/
/*!
/*!
*****************************************************************************
* \brief Wait until an ST25R3916 interrupt occurs
*
@ -180,9 +133,9 @@
*
*****************************************************************************
*/
uint32_t st25r3916WaitForInterruptsTimed(uint32_t mask, uint16_t tmo);
uint32_t st25r3916WaitForInterruptsTimed( uint32_t mask, uint16_t tmo );
/*!
/*!
*****************************************************************************
* \brief Get status for the given interrupt
*
@ -196,63 +149,63 @@ uint32_t st25r3916WaitForInterruptsTimed(uint32_t mask, uint16_t tmo);
*
*****************************************************************************
*/
uint32_t st25r3916GetInterrupt(uint32_t mask);
uint32_t st25r3916GetInterrupt( uint32_t mask );
/*!
/*!
*****************************************************************************
* \brief Init the 3916 interrupt
*
* This function is used to check whether the interrupt given by \a mask
* has occured.
* has occured.
*
*****************************************************************************
*/
void st25r3916InitInterrupts(void);
void st25r3916InitInterrupts( void );
/*!
/*!
*****************************************************************************
* \brief Modifies the Interrupt
*
* This function modifies the interrupt
*
* \param[in] clr_mask : bit mask to be cleared on the interrupt mask
* \param[in] set_mask : bit mask to be set on the interrupt mask
*
* \param[in] clr_mask : bit mask to be cleared on the interrupt mask
* \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 );
/*!
/*!
*****************************************************************************
* \brief Checks received interrupts
*
* Checks received interrupts and saves the result into global params
*****************************************************************************
*/
void st25r3916CheckForReceivedInterrupts(void);
void st25r3916CheckForReceivedInterrupts( void );
/*!
/*!
*****************************************************************************
* \brief ISR Service routine
*
* This function modiefies the interupt
*****************************************************************************
*/
void st25r3916Isr(void);
void st25r3916Isr( void );
/*!
/*!
*****************************************************************************
* \brief Enable a given ST25R3916 Interrupt source
*
* This function enables all interrupts given by \a mask,
* This function enables all interrupts given by \a mask,
* ST25R3916_IRQ_MASK_ALL enables all interrupts.
*
* \param[in] mask: mask indicating the interrupts to be enabled
*
*****************************************************************************
*/
void st25r3916EnableInterrupts(uint32_t mask);
void st25r3916EnableInterrupts( uint32_t mask );
/*!
/*!
*****************************************************************************
* \brief Disable one or more a given ST25R3916 Interrupt sources
*
@ -262,26 +215,26 @@ void st25r3916EnableInterrupts(uint32_t mask);
*
*****************************************************************************
*/
void st25r3916DisableInterrupts(uint32_t mask);
void st25r3916DisableInterrupts( uint32_t mask );
/*!
/*!
*****************************************************************************
* \brief Clear all ST25R3916 irq flags
*
*****************************************************************************
*/
void st25r3916ClearInterrupts(void);
void st25r3916ClearInterrupts( void );
/*!
/*!
*****************************************************************************
* \brief Clears and then enables the given ST25R3916 Interrupt sources
*
* \param[in] mask: mask indicating the interrupts to be cleared and enabled
*****************************************************************************
*/
void st25r3916ClearAndEnableInterrupts(uint32_t mask);
void st25r3916ClearAndEnableInterrupts( uint32_t mask );
/*!
/*!
*****************************************************************************
* \brief Sets IRQ callback for the ST25R3916 interrupt
*
@ -289,24 +242,24 @@ void st25r3916ClearAndEnableInterrupts(uint32_t mask);
*
*****************************************************************************
*/
void st25r3916IRQCallbackSet(void (*cb)(void));
void st25r3916IRQCallbackSet( void (*cb)( void ) );
/*!
/*!
*****************************************************************************
* \brief Sets IRQ callback for the ST25R3916 interrupt
*
*****************************************************************************
*/
void st25r3916IRQCallbackRestore(void);
void st25r3916IRQCallbackRestore( void );
#endif /* ST25R3916_IRQ_H */
/**
* @}
*
* @}
*
* @}
*
* @}
*/
* @}
*
* @}
*
* @}
*
* @}
*/

View File

@ -1,22 +1,24 @@
/******************************************************************************
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/*
* PROJECT: ST25R3916 firmware
* Revision:
* Revision:
* LANGUAGE: ISO C99
*/
@ -35,9 +37,10 @@
*/
#include "st25r3916_led.h"
#include "st25r3916.h"
#include "st25r3916_com.h"
#include "st25r3916_irq.h"
#include "st25r3916_com.h"
#include "st25r3916.h"
/*
******************************************************************************
@ -46,43 +49,28 @@
*/
#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 */
#else /* PLATFORM_LED_RX_PIN */
#define st25r3916ledRxOn()
#define st25r3916ledRxOff()
#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()
#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 */
#else /* PLATFORM_LED_FIELD_PIN */
#define st25r3916ledFieldOn()
#define st25r3916ledFieldOff()
#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()
#endif /* PLATFORM_LED_FIELD_PIN */
#ifdef PLATFORM_LED_ERR_PIN
#define st25r3916ledErrOn() \
platformLedOn( \
PLATFORM_LED_ERR_PORT, \
PLATFORM_LED_ERR_PIN); /*!< LED Field Pin On from system HAL */
#define st25r3916ledErrOff() \
platformLedOff( \
PLATFORM_LED_ERR_PORT, \
PLATFORM_LED_ERR_PIN); /*!< LED Field Pin Off from system HAL */
#else /* PLATFORM_LED_ERR_PIN */
#define st25r3916ledErrOn()
#define st25r3916ledErrOff()
#define st25r3916ledErrOn() platformLedOn( PLATFORM_LED_ERR_PORT, PLATFORM_LED_ERR_PIN ); /*!< LED Field Pin On from system HAL */
#define st25r3916ledErrOff() platformLedOff( PLATFORM_LED_ERR_PORT, PLATFORM_LED_ERR_PIN ); /*!< LED Field Pin Off from system HAL */
#else /* PLATFORM_LED_ERR_PIN */
#define st25r3916ledErrOn()
#define st25r3916ledErrOff()
#endif /* PLATFORM_LED_ERR_PIN */
/*
@ -91,72 +79,89 @@
******************************************************************************
*/
void st25r3916ledInit(void) {
/* Initialize LEDs if existing and defined */
platformLedsInitialize();
st25r3916ledRxOff();
st25r3916ledFieldOff();
st25r3916ledErrOff();
}
/*******************************************************************************/
void st25r3916ledEvtIrq(uint32_t irqs) {
if ((irqs & (ST25R3916_IRQ_MASK_TXE | ST25R3916_IRQ_MASK_CAT)) != 0U) {
st25r3916ledFieldOn();
void st25r3916ledInit( void )
{
/* Initialize LEDs if existing and defined */
platformLedsInitialize();
st25r3916ledRxOff();
st25r3916ledFieldOff();
st25r3916ledErrOff();
}
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) {
st25r3916ledRxOff();
}
if (((irqs & (ST25R3916_IRQ_MASK_CRC | ST25R3916_IRQ_MASK_PAR |
ST25R3916_IRQ_MASK_ERR1 | ST25R3916_IRQ_MASK_ERR2)) != 0U)) {
st25r3916ledErrOn();
}
}
/*******************************************************************************/
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 {
st25r3916ledFieldOff();
void st25r3916ledEvtIrq( uint32_t irqs )
{
if( (irqs & (ST25R3916_IRQ_MASK_TXE | ST25R3916_IRQ_MASK_CAT) ) != 0U )
{
st25r3916ledFieldOn();
st25r3916ledErrOff();
}
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 )
{
st25r3916ledRxOff();
}
if( ((irqs & (ST25R3916_IRQ_MASK_CRC | ST25R3916_IRQ_MASK_PAR | ST25R3916_IRQ_MASK_ERR1 | ST25R3916_IRQ_MASK_ERR2)) != 0U) )
{
st25r3916ledErrOn();
}
}
}
/*******************************************************************************/
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]);
}
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
{
st25r3916ledFieldOff();
}
}
}
/*******************************************************************************/
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) {
st25r3916ledRxOff();
}
if (cmd == ST25R3916_CMD_SET_DEFAULT) {
st25r3916ledFieldOff();
st25r3916ledRxOff();
}
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] );
}
}
/*******************************************************************************/
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 )
{
st25r3916ledRxOff();
}
if( cmd == ST25R3916_CMD_SET_DEFAULT )
{
st25r3916ledFieldOff();
st25r3916ledRxOff();
}
}

View File

@ -1,22 +1,24 @@
/******************************************************************************
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
* @attention
*
* COPYRIGHT 2016 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/*
* PROJECT: ST25R3916 firmware
* Revision:
* Revision:
* LANGUAGE: ISO C99
*/
@ -37,11 +39,11 @@
* \addtogroup ST25R3916
* \brief RFAL ST25R3916 Driver
* @{
*
*
* \addtogroup ST25R3916_LED
* \brief RFAL ST25R3916 LED
* @{
*
*
*/
#ifndef ST25R3916_LED_H
@ -67,49 +69,50 @@
******************************************************************************
*/
/*!
/*!
*****************************************************************************
* \brief ST25R3916 LED Initialize
*
* This function initializes the LEDs that represent ST25R3916 activity
* This function initializes the LEDs that represent ST25R3916 activity
*
*****************************************************************************
*/
void st25r3916ledInit(void);
void st25r3916ledInit( void );
/*!
/*!
*****************************************************************************
* \brief ST25R3916 LED Event Interrupt
*
* This function should be called upon a ST25R3916 Interrupt, providing
* the interrupt event with ST25R3916 irq flags to update LEDs
* This function should be called upon a ST25R3916 Interrupt, providing
* the interrupt event with ST25R3916 irq flags to update LEDs
*
* \param[in] irqs: ST25R3916 irqs mask
*
*****************************************************************************
*/
void st25r3916ledEvtIrq(uint32_t irqs);
void st25r3916ledEvtIrq( uint32_t irqs );
/*!
/*!
*****************************************************************************
* \brief ST25R3916 LED Event Write Register
*
* This function should be called on a ST25R3916 Write Register operation
* providing the event with the register and value to update LEDs
* providing the event with the register and value to update LEDs
*
* \param[in] reg: ST25R3916 register to be written
* \param[in] val: value to be written on the register
*
*****************************************************************************
*/
void st25r3916ledEvtWrReg(uint8_t reg, uint8_t val);
void st25r3916ledEvtWrReg( uint8_t reg, uint8_t val );
/*!
/*!
*****************************************************************************
* \brief ST25R3916 LED Event Write Multiple Register
*
* This function should be called upon a ST25R3916 Write Multiple Registers,
* providing the event with the registers and values to update LEDs
* This function should be called upon a ST25R3916 Write Multiple Registers,
* providing the event with the registers and values to update LEDs
*
* \param[in] reg : ST25R3916 first register written
* \param[in] vals: pointer to the values written
@ -117,29 +120,29 @@ 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 );
/*!
/*!
*****************************************************************************
* \brief ST25R3916 LED Event Direct Command
*
* This function should be called upon a ST25R3916 direct command, providing
* This function should be called upon a ST25R3916 direct command, providing
* the event with the command executed
*
* \param[in] cmd: ST25R3916 cmd executed
*
*****************************************************************************
*/
void st25r3916ledEvtCmd(uint8_t cmd);
void st25r3916ledEvtCmd( uint8_t cmd );
#endif /* ST25R3916_LED_H */
/**
* @}
*
* @}
*
* @}
*
* @}
*/
* @}
*
* @}
*
* @}
*
* @}
*/