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

* Makefile, Scripts: new linter
* About: remove ID from IC
* Firmware: remove double define for DIVC/DIVR
* Scripts: check folder names too. Docker: replace syntax check with make lint.
* Reformat Sources and Migrate to new file naming convention
* Docker: symlink clang-format-12 to clang-format
* Add coding style guide
This commit is contained in:
あく
2022-01-05 19:10:18 +03:00
committed by GitHub
parent c98e54da10
commit 389ff92cc1
899 changed files with 379245 additions and 373421 deletions

1739
lib/ST25RFAL002/source/st25r3916/rfal_analogConfigTbl.h Executable file → Normal file

File diff suppressed because it is too large Load Diff

23
lib/ST25RFAL002/source/st25r3916/rfal_dpoTbl.h Executable file → Normal file
View File

@@ -20,7 +20,6 @@
*
******************************************************************************/
/*
* PROJECT: ST25R391x firmware
* $Revision: $
@@ -34,7 +33,6 @@
* \brief RF Dynamic Power Table default values
*/
#ifndef ST25R3916_DPO_H
#define ST25R3916_DPO_H
@@ -45,19 +43,26 @@
*/
#include "rfal_dpo.h"
/*
******************************************************************************
* GLOBAL DATA TYPES
******************************************************************************
*/
/*! Default DPO table */
const uint8_t rfalDpoDefaultSettings [] = {
0x00, 255, 200,
0x01, 210, 150,
0x02, 160, 100,
0x03, 110, 50,
const uint8_t rfalDpoDefaultSettings[] = {
0x00,
255,
200,
0x01,
210,
150,
0x02,
160,
100,
0x03,
110,
50,
};
#endif /* ST25R3916_DPO_H */

82
lib/ST25RFAL002/source/st25r3916/rfal_features.h Executable file → Normal file
View File

@@ -20,7 +20,6 @@
*
******************************************************************************/
/*
* PROJECT: ST25R391x firmware
* Revision:
@@ -34,7 +33,6 @@
* \brief RFAL Features/Capabilities Definition for ST25R3916
*/
#ifndef RFAL_FEATURES_H
#define RFAL_FEATURES_H
@@ -51,63 +49,61 @@
******************************************************************************
*/
#define RFAL_SUPPORT_MODE_POLL_NFCA true /*!< RFAL Poll NFCA mode support switch */
#define RFAL_SUPPORT_MODE_POLL_NFCB true /*!< RFAL Poll NFCB mode support switch */
#define RFAL_SUPPORT_MODE_POLL_NFCF true /*!< RFAL Poll NFCF mode support switch */
#define RFAL_SUPPORT_MODE_POLL_NFCV true /*!< RFAL Poll NFCV mode support switch */
#define RFAL_SUPPORT_MODE_POLL_ACTIVE_P2P true /*!< RFAL Poll AP2P mode support switch */
#define RFAL_SUPPORT_MODE_LISTEN_NFCA true /*!< RFAL Listen NFCA mode support switch */
#define RFAL_SUPPORT_MODE_LISTEN_NFCB false /*!< RFAL Listen NFCB mode support switch */
#define RFAL_SUPPORT_MODE_LISTEN_NFCF true /*!< RFAL Listen NFCF mode support switch */
#define RFAL_SUPPORT_MODE_LISTEN_ACTIVE_P2P true /*!< RFAL Listen AP2P mode support switch */
#define RFAL_SUPPORT_MODE_POLL_NFCA true /*!< RFAL Poll NFCA mode support switch */
#define RFAL_SUPPORT_MODE_POLL_NFCB true /*!< RFAL Poll NFCB mode support switch */
#define RFAL_SUPPORT_MODE_POLL_NFCF true /*!< RFAL Poll NFCF mode support switch */
#define RFAL_SUPPORT_MODE_POLL_NFCV true /*!< RFAL Poll NFCV mode support switch */
#define RFAL_SUPPORT_MODE_POLL_ACTIVE_P2P true /*!< RFAL Poll AP2P mode support switch */
#define RFAL_SUPPORT_MODE_LISTEN_NFCA true /*!< RFAL Listen NFCA mode support switch */
#define RFAL_SUPPORT_MODE_LISTEN_NFCB false /*!< RFAL Listen NFCB mode support switch */
#define RFAL_SUPPORT_MODE_LISTEN_NFCF true /*!< RFAL Listen NFCF mode support switch */
#define RFAL_SUPPORT_MODE_LISTEN_ACTIVE_P2P true /*!< RFAL Listen AP2P mode support switch */
/*******************************************************************************/
/*! RFAL supported Card Emulation (CE) */
#define RFAL_SUPPORT_CE ( RFAL_SUPPORT_MODE_LISTEN_NFCA || RFAL_SUPPORT_MODE_LISTEN_NFCB || RFAL_SUPPORT_MODE_LISTEN_NFCF )
#define RFAL_SUPPORT_CE \
(RFAL_SUPPORT_MODE_LISTEN_NFCA || RFAL_SUPPORT_MODE_LISTEN_NFCB || \
RFAL_SUPPORT_MODE_LISTEN_NFCF)
/*! RFAL supported Reader/Writer (RW) */
#define RFAL_SUPPORT_RW ( RFAL_SUPPORT_MODE_POLL_NFCA || RFAL_SUPPORT_MODE_POLL_NFCB || RFAL_SUPPORT_MODE_POLL_NFCF || RFAL_SUPPORT_MODE_POLL_NFCV )
#define RFAL_SUPPORT_RW \
(RFAL_SUPPORT_MODE_POLL_NFCA || RFAL_SUPPORT_MODE_POLL_NFCB || RFAL_SUPPORT_MODE_POLL_NFCF || \
RFAL_SUPPORT_MODE_POLL_NFCV)
/*! RFAL support for Active P2P (AP2P) */
#define RFAL_SUPPORT_AP2P ( RFAL_SUPPORT_MODE_POLL_ACTIVE_P2P || RFAL_SUPPORT_MODE_LISTEN_ACTIVE_P2P )
#define RFAL_SUPPORT_AP2P \
(RFAL_SUPPORT_MODE_POLL_ACTIVE_P2P || RFAL_SUPPORT_MODE_LISTEN_ACTIVE_P2P)
/*******************************************************************************/
#define RFAL_SUPPORT_BR_RW_106 true /*!< RFAL RW 106 Bit Rate support switch */
#define RFAL_SUPPORT_BR_RW_212 true /*!< RFAL RW 212 Bit Rate support switch */
#define RFAL_SUPPORT_BR_RW_424 true /*!< RFAL RW 424 Bit Rate support switch */
#define RFAL_SUPPORT_BR_RW_848 true /*!< RFAL RW 848 Bit Rate support switch */
#define RFAL_SUPPORT_BR_RW_1695 false /*!< RFAL RW 1695 Bit Rate support switch */
#define RFAL_SUPPORT_BR_RW_3390 false /*!< RFAL RW 3390 Bit Rate support switch */
#define RFAL_SUPPORT_BR_RW_6780 false /*!< RFAL RW 6780 Bit Rate support switch */
#define RFAL_SUPPORT_BR_RW_13560 false /*!< RFAL RW 6780 Bit Rate support switch */
#define RFAL_SUPPORT_BR_RW_106 true /*!< RFAL RW 106 Bit Rate support switch */
#define RFAL_SUPPORT_BR_RW_212 true /*!< RFAL RW 212 Bit Rate support switch */
#define RFAL_SUPPORT_BR_RW_424 true /*!< RFAL RW 424 Bit Rate support switch */
#define RFAL_SUPPORT_BR_RW_848 true /*!< RFAL RW 848 Bit Rate support switch */
#define RFAL_SUPPORT_BR_RW_1695 false /*!< RFAL RW 1695 Bit Rate support switch */
#define RFAL_SUPPORT_BR_RW_3390 false /*!< RFAL RW 3390 Bit Rate support switch */
#define RFAL_SUPPORT_BR_RW_6780 false /*!< RFAL RW 6780 Bit Rate support switch */
#define RFAL_SUPPORT_BR_RW_13560 false /*!< RFAL RW 6780 Bit Rate support switch */
/*******************************************************************************/
#define RFAL_SUPPORT_BR_AP2P_106 true /*!< RFAL AP2P 106 Bit Rate support switch */
#define RFAL_SUPPORT_BR_AP2P_212 true /*!< RFAL AP2P 212 Bit Rate support switch */
#define RFAL_SUPPORT_BR_AP2P_424 true /*!< RFAL AP2P 424 Bit Rate support switch */
#define RFAL_SUPPORT_BR_AP2P_848 false /*!< RFAL AP2P 848 Bit Rate support switch */
#define RFAL_SUPPORT_BR_AP2P_106 true /*!< RFAL AP2P 106 Bit Rate support switch */
#define RFAL_SUPPORT_BR_AP2P_212 true /*!< RFAL AP2P 212 Bit Rate support switch */
#define RFAL_SUPPORT_BR_AP2P_424 true /*!< RFAL AP2P 424 Bit Rate support switch */
#define RFAL_SUPPORT_BR_AP2P_848 false /*!< RFAL AP2P 848 Bit Rate support switch */
/*******************************************************************************/
#define RFAL_SUPPORT_BR_CE_A_106 true /*!< RFAL CE A 106 Bit Rate support switch */
#define RFAL_SUPPORT_BR_CE_A_212 false /*!< RFAL CE A 212 Bit Rate support switch */
#define RFAL_SUPPORT_BR_CE_A_424 false /*!< RFAL CE A 424 Bit Rate support switch */
#define RFAL_SUPPORT_BR_CE_A_848 false /*!< RFAL CE A 848 Bit Rate support switch */
#define RFAL_SUPPORT_BR_CE_A_106 true /*!< RFAL CE A 106 Bit Rate support switch */
#define RFAL_SUPPORT_BR_CE_A_212 false /*!< RFAL CE A 212 Bit Rate support switch */
#define RFAL_SUPPORT_BR_CE_A_424 false /*!< RFAL CE A 424 Bit Rate support switch */
#define RFAL_SUPPORT_BR_CE_A_848 false /*!< RFAL CE A 848 Bit Rate support switch */
/*******************************************************************************/
#define RFAL_SUPPORT_BR_CE_B_106 false /*!< RFAL CE B 106 Bit Rate support switch */
#define RFAL_SUPPORT_BR_CE_B_212 false /*!< RFAL CE B 212 Bit Rate support switch */
#define RFAL_SUPPORT_BR_CE_B_424 false /*!< RFAL CE B 424 Bit Rate support switch */
#define RFAL_SUPPORT_BR_CE_B_848 false /*!< RFAL CE B 848 Bit Rate support switch */
#define RFAL_SUPPORT_BR_CE_B_106 false /*!< RFAL CE B 106 Bit Rate support switch */
#define RFAL_SUPPORT_BR_CE_B_212 false /*!< RFAL CE B 212 Bit Rate support switch */
#define RFAL_SUPPORT_BR_CE_B_424 false /*!< RFAL CE B 424 Bit Rate support switch */
#define RFAL_SUPPORT_BR_CE_B_848 false /*!< RFAL CE B 848 Bit Rate support switch */
/*******************************************************************************/
#define RFAL_SUPPORT_BR_CE_F_212 true /*!< RFAL CE F 212 Bit Rate support switch */
#define RFAL_SUPPORT_BR_CE_F_424 true /*!< RFAL CE F 424 Bit Rate support switch */
#define RFAL_SUPPORT_BR_CE_F_212 true /*!< RFAL CE F 212 Bit Rate support switch */
#define RFAL_SUPPORT_BR_CE_F_424 true /*!< RFAL CE F 424 Bit Rate support switch */
#endif /* RFAL_FEATURES_H */

6584
lib/ST25RFAL002/source/st25r3916/rfal_rfst25r3916.c Executable file → Normal file

File diff suppressed because it is too large Load Diff

736
lib/ST25RFAL002/source/st25r3916/st25r3916.c Executable file → Normal file

File diff suppressed because it is too large Load Diff

244
lib/ST25RFAL002/source/st25r3916/st25r3916.h Executable file → Normal file
View File

@@ -20,7 +20,6 @@
*
******************************************************************************/
/*
* PROJECT: ST25R3916 firmware
* Revision:
@@ -51,7 +50,6 @@
*
*/
#ifndef ST25R3916_H
#define ST25R3916_H
@@ -71,20 +69,21 @@
*/
/*! Struct to represent all regs on ST25R3916 */
typedef struct{
uint8_t RsA[(ST25R3916_REG_IC_IDENTITY+1U)]; /*!< Registers contained on ST25R3916 space A (Rs-A) */
uint8_t RsB[ST25R3916_SPACE_B_REG_LEN]; /*!< Registers contained on ST25R3916 space B (Rs-B) */
}t_st25r3916Regs;
typedef struct {
uint8_t RsA[(
ST25R3916_REG_IC_IDENTITY + 1U)]; /*!< Registers contained on ST25R3916 space A (Rs-A) */
uint8_t
RsB[ST25R3916_SPACE_B_REG_LEN]; /*!< Registers contained on ST25R3916 space B (Rs-B) */
} t_st25r3916Regs;
/*! Parameters how the stream mode should work */
struct st25r3916StreamConfig {
uint8_t useBPSK; /*!< 0: subcarrier, 1:BPSK */
uint8_t din; /*!< Divider for the in subcarrier frequency: fc/2^din */
uint8_t dout; /*!< Divider for the in subcarrier frequency fc/2^dout */
uint8_t report_period_length; /*!< Length of the reporting period 2^report_period_length*/
uint8_t useBPSK; /*!< 0: subcarrier, 1:BPSK */
uint8_t din; /*!< Divider for the in subcarrier frequency: fc/2^din */
uint8_t dout; /*!< Divider for the in subcarrier frequency fc/2^dout */
uint8_t report_period_length; /*!< Length of the reporting period 2^report_period_length*/
};
/*
******************************************************************************
* GLOBAL DEFINES
@@ -92,53 +91,86 @@ struct st25r3916StreamConfig {
*/
/* ST25R3916 direct commands */
#define ST25R3916_CMD_SET_DEFAULT 0xC1U /*!< Puts the chip in default state (same as after power-up) */
#define ST25R3916_CMD_STOP 0xC2U /*!< Stops all activities and clears FIFO */
#define ST25R3916_CMD_TRANSMIT_WITH_CRC 0xC4U /*!< Transmit with CRC */
#define ST25R3916_CMD_TRANSMIT_WITHOUT_CRC 0xC5U /*!< Transmit without CRC */
#define ST25R3916_CMD_TRANSMIT_REQA 0xC6U /*!< Transmit REQA */
#define ST25R3916_CMD_TRANSMIT_WUPA 0xC7U /*!< Transmit WUPA */
#define ST25R3916_CMD_INITIAL_RF_COLLISION 0xC8U /*!< NFC transmit with Initial RF Collision Avoidance */
#define ST25R3916_CMD_RESPONSE_RF_COLLISION_N 0xC9U /*!< NFC transmit with Response RF Collision Avoidance */
#define ST25R3916_CMD_GOTO_SENSE 0xCDU /*!< Passive target logic to Sense/Idle state */
#define ST25R3916_CMD_GOTO_SLEEP 0xCEU /*!< Passive target logic to Sleep/Halt state */
#define ST25R3916_CMD_MASK_RECEIVE_DATA 0xD0U /*!< Mask receive data */
#define ST25R3916_CMD_UNMASK_RECEIVE_DATA 0xD1U /*!< Unmask receive data */
#define ST25R3916_CMD_AM_MOD_STATE_CHANGE 0xD2U /*!< AM Modulation state change */
#define ST25R3916_CMD_MEASURE_AMPLITUDE 0xD3U /*!< Measure singal amplitude on RFI inputs */
#define ST25R3916_CMD_RESET_RXGAIN 0xD5U /*!< Reset RX Gain */
#define ST25R3916_CMD_ADJUST_REGULATORS 0xD6U /*!< Adjust regulators */
#define ST25R3916_CMD_CALIBRATE_DRIVER_TIMING 0xD8U /*!< Starts the sequence to adjust the driver timing */
#define ST25R3916_CMD_MEASURE_PHASE 0xD9U /*!< Measure phase between RFO and RFI signal */
#define ST25R3916_CMD_CLEAR_RSSI 0xDAU /*!< Clear RSSI bits and restart the measurement */
#define ST25R3916_CMD_CLEAR_FIFO 0xDBU /*!< Clears FIFO, Collision and IRQ status */
#define ST25R3916_CMD_TRANSPARENT_MODE 0xDCU /*!< Transparent mode */
#define ST25R3916_CMD_CALIBRATE_C_SENSOR 0xDDU /*!< Calibrate the capacitive sensor */
#define ST25R3916_CMD_MEASURE_CAPACITANCE 0xDEU /*!< Measure capacitance */
#define ST25R3916_CMD_MEASURE_VDD 0xDFU /*!< Measure power supply voltage */
#define ST25R3916_CMD_START_GP_TIMER 0xE0U /*!< Start the general purpose timer */
#define ST25R3916_CMD_START_WUP_TIMER 0xE1U /*!< Start the wake-up timer */
#define ST25R3916_CMD_START_MASK_RECEIVE_TIMER 0xE2U /*!< Start the mask-receive timer */
#define ST25R3916_CMD_START_NO_RESPONSE_TIMER 0xE3U /*!< Start the no-response timer */
#define ST25R3916_CMD_START_PPON2_TIMER 0xE4U /*!< Start PPon2 timer */
#define ST25R3916_CMD_STOP_NRT 0xE8U /*!< Stop No Response Timer */
#define ST25R3916_CMD_SPACE_B_ACCESS 0xFBU /*!< Enable R/W access to the test registers */
#define ST25R3916_CMD_TEST_ACCESS 0xFCU /*!< Enable R/W access to the test registers */
#define ST25R3916_CMD_SET_DEFAULT \
0xC1U /*!< Puts the chip in default state (same as after power-up) */
#define ST25R3916_CMD_STOP 0xC2U /*!< Stops all activities and clears FIFO */
#define ST25R3916_CMD_TRANSMIT_WITH_CRC \
0xC4U /*!< Transmit with CRC */
#define ST25R3916_CMD_TRANSMIT_WITHOUT_CRC \
0xC5U /*!< Transmit without CRC */
#define ST25R3916_CMD_TRANSMIT_REQA \
0xC6U /*!< Transmit REQA */
#define ST25R3916_CMD_TRANSMIT_WUPA \
0xC7U /*!< Transmit WUPA */
#define ST25R3916_CMD_INITIAL_RF_COLLISION \
0xC8U /*!< NFC transmit with Initial RF Collision Avoidance */
#define ST25R3916_CMD_RESPONSE_RF_COLLISION_N \
0xC9U /*!< NFC transmit with Response RF Collision Avoidance */
#define ST25R3916_CMD_GOTO_SENSE \
0xCDU /*!< Passive target logic to Sense/Idle state */
#define ST25R3916_CMD_GOTO_SLEEP \
0xCEU /*!< Passive target logic to Sleep/Halt state */
#define ST25R3916_CMD_MASK_RECEIVE_DATA \
0xD0U /*!< Mask receive data */
#define ST25R3916_CMD_UNMASK_RECEIVE_DATA \
0xD1U /*!< Unmask receive data */
#define ST25R3916_CMD_AM_MOD_STATE_CHANGE \
0xD2U /*!< AM Modulation state change */
#define ST25R3916_CMD_MEASURE_AMPLITUDE \
0xD3U /*!< Measure singal amplitude on RFI inputs */
#define ST25R3916_CMD_RESET_RXGAIN \
0xD5U /*!< Reset RX Gain */
#define ST25R3916_CMD_ADJUST_REGULATORS \
0xD6U /*!< Adjust regulators */
#define ST25R3916_CMD_CALIBRATE_DRIVER_TIMING \
0xD8U /*!< Starts the sequence to adjust the driver timing */
#define ST25R3916_CMD_MEASURE_PHASE \
0xD9U /*!< Measure phase between RFO and RFI signal */
#define ST25R3916_CMD_CLEAR_RSSI \
0xDAU /*!< Clear RSSI bits and restart the measurement */
#define ST25R3916_CMD_CLEAR_FIFO \
0xDBU /*!< Clears FIFO, Collision and IRQ status */
#define ST25R3916_CMD_TRANSPARENT_MODE \
0xDCU /*!< Transparent mode */
#define ST25R3916_CMD_CALIBRATE_C_SENSOR \
0xDDU /*!< Calibrate the capacitive sensor */
#define ST25R3916_CMD_MEASURE_CAPACITANCE \
0xDEU /*!< Measure capacitance */
#define ST25R3916_CMD_MEASURE_VDD \
0xDFU /*!< Measure power supply voltage */
#define ST25R3916_CMD_START_GP_TIMER \
0xE0U /*!< Start the general purpose timer */
#define ST25R3916_CMD_START_WUP_TIMER \
0xE1U /*!< Start the wake-up timer */
#define ST25R3916_CMD_START_MASK_RECEIVE_TIMER \
0xE2U /*!< Start the mask-receive timer */
#define ST25R3916_CMD_START_NO_RESPONSE_TIMER \
0xE3U /*!< Start the no-response timer */
#define ST25R3916_CMD_START_PPON2_TIMER \
0xE4U /*!< Start PPon2 timer */
#define ST25R3916_CMD_STOP_NRT \
0xE8U /*!< Stop No Response Timer */
#define ST25R3916_CMD_SPACE_B_ACCESS \
0xFBU /*!< Enable R/W access to the test registers */
#define ST25R3916_CMD_TEST_ACCESS \
0xFCU /*!< Enable R/W access to the test registers */
#define ST25R3916_THRESHOLD_DO_NOT_SET \
0xFFU /*!< Indicates not to change this Threshold */
#define ST25R3916_THRESHOLD_DO_NOT_SET 0xFFU /*!< Indicates not to change this Threshold */
#define ST25R3916_BR_DO_NOT_SET 0xFFU /*!< Indicates not to change this Bit Rate */
#define ST25R3916_BR_106 0x00U /*!< ST25R3916 Bit Rate 106 kbit/s (fc/128) */
#define ST25R3916_BR_212 0x01U /*!< ST25R3916 Bit Rate 212 kbit/s (fc/64) */
#define ST25R3916_BR_424 0x02U /*!< ST25R3916 Bit Rate 424 kbit/s (fc/32) */
#define ST25R3916_BR_848 0x03U /*!< ST25R3916 Bit Rate 848 kbit/s (fc/16) */
#define ST25R3916_BR_1695 0x04U /*!< ST25R3916 Bit Rate 1696 kbit/s (fc/8) */
#define ST25R3916_BR_3390 0x05U /*!< ST25R3916 Bit Rate 3390 kbit/s (fc/4) */
#define ST25R3916_BR_6780 0x07U /*!< ST25R3916 Bit Rate 6780 kbit/s (fc/2) */
#define ST25R3916_FIFO_DEPTH 512U /*!< Depth of FIFO */
#define ST25R3916_TOUT_OSC_STABLE 10U /*!< Max timeout for Oscillator to get stable DS: 700us */
#define ST25R3916_BR_DO_NOT_SET \
0xFFU /*!< Indicates not to change this Bit Rate */
#define ST25R3916_BR_106 0x00U /*!< ST25R3916 Bit Rate 106 kbit/s (fc/128) */
#define ST25R3916_BR_212 0x01U /*!< ST25R3916 Bit Rate 212 kbit/s (fc/64) */
#define ST25R3916_BR_424 0x02U /*!< ST25R3916 Bit Rate 424 kbit/s (fc/32) */
#define ST25R3916_BR_848 0x03U /*!< ST25R3916 Bit Rate 848 kbit/s (fc/16) */
#define ST25R3916_BR_1695 0x04U /*!< ST25R3916 Bit Rate 1696 kbit/s (fc/8) */
#define ST25R3916_BR_3390 0x05U /*!< ST25R3916 Bit Rate 3390 kbit/s (fc/4) */
#define ST25R3916_BR_6780 0x07U /*!< ST25R3916 Bit Rate 6780 kbit/s (fc/2) */
#define ST25R3916_FIFO_DEPTH 512U /*!< Depth of FIFO */
#define ST25R3916_TOUT_OSC_STABLE \
10U /*!< Max timeout for Oscillator to get stable DS: 700us */
/*
******************************************************************************
@@ -147,31 +179,55 @@ struct st25r3916StreamConfig {
*/
/*! Enables the Transmitter (Field On) and Receiver */
#define st25r3916TxRxOn() st25r3916SetRegisterBits( ST25R3916_REG_OP_CONTROL, (ST25R3916_REG_OP_CONTROL_rx_en | ST25R3916_REG_OP_CONTROL_tx_en ) )
#define st25r3916TxRxOn() \
st25r3916SetRegisterBits( \
ST25R3916_REG_OP_CONTROL, \
(ST25R3916_REG_OP_CONTROL_rx_en | ST25R3916_REG_OP_CONTROL_tx_en))
/*! Disables the Transmitter (Field Off) and Receiver */
#define st25r3916TxRxOff() st25r3916ClrRegisterBits( ST25R3916_REG_OP_CONTROL, (ST25R3916_REG_OP_CONTROL_rx_en | ST25R3916_REG_OP_CONTROL_tx_en ) )
#define st25r3916TxRxOff() \
st25r3916ClrRegisterBits( \
ST25R3916_REG_OP_CONTROL, \
(ST25R3916_REG_OP_CONTROL_rx_en | ST25R3916_REG_OP_CONTROL_tx_en))
/*! Disables the Transmitter (Field Off) */
#define st25r3916TxOff() st25r3916ClrRegisterBits( ST25R3916_REG_OP_CONTROL, ST25R3916_REG_OP_CONTROL_tx_en )
#define st25r3916TxOff() \
st25r3916ClrRegisterBits(ST25R3916_REG_OP_CONTROL, ST25R3916_REG_OP_CONTROL_tx_en)
/*! Checks if General Purpose Timer is still running by reading gpt_on flag */
#define st25r3916IsGPTRunning( ) st25r3916CheckReg( ST25R3916_REG_NFCIP1_BIT_RATE, ST25R3916_REG_NFCIP1_BIT_RATE_gpt_on, ST25R3916_REG_NFCIP1_BIT_RATE_gpt_on )
#define st25r3916IsGPTRunning() \
st25r3916CheckReg( \
ST25R3916_REG_NFCIP1_BIT_RATE, \
ST25R3916_REG_NFCIP1_BIT_RATE_gpt_on, \
ST25R3916_REG_NFCIP1_BIT_RATE_gpt_on)
/*! Checks if External Filed is detected by reading ST25R3916 External Field Detector output */
#define st25r3916IsExtFieldOn() st25r3916CheckReg( ST25R3916_REG_AUX_DISPLAY, ST25R3916_REG_AUX_DISPLAY_efd_o, ST25R3916_REG_AUX_DISPLAY_efd_o )
#define st25r3916IsExtFieldOn() \
st25r3916CheckReg( \
ST25R3916_REG_AUX_DISPLAY, \
ST25R3916_REG_AUX_DISPLAY_efd_o, \
ST25R3916_REG_AUX_DISPLAY_efd_o)
/*! Checks if Transmitter is enabled (Field On) */
#define st25r3916IsTxEnabled() st25r3916CheckReg( ST25R3916_REG_OP_CONTROL, ST25R3916_REG_OP_CONTROL_tx_en, ST25R3916_REG_OP_CONTROL_tx_en )
#define st25r3916IsTxEnabled() \
st25r3916CheckReg( \
ST25R3916_REG_OP_CONTROL, ST25R3916_REG_OP_CONTROL_tx_en, ST25R3916_REG_OP_CONTROL_tx_en)
/*! Checks if NRT is in EMV mode */
#define st25r3916IsNRTinEMV() st25r3916CheckReg( ST25R3916_REG_TIMER_EMV_CONTROL, ST25R3916_REG_TIMER_EMV_CONTROL_nrt_emv, ST25R3916_REG_TIMER_EMV_CONTROL_nrt_emv_on )
#define st25r3916IsNRTinEMV() \
st25r3916CheckReg( \
ST25R3916_REG_TIMER_EMV_CONTROL, \
ST25R3916_REG_TIMER_EMV_CONTROL_nrt_emv, \
ST25R3916_REG_TIMER_EMV_CONTROL_nrt_emv_on)
/*! Checks if last FIFO byte is complete */
#define st25r3916IsLastFIFOComplete() st25r3916CheckReg( ST25R3916_REG_FIFO_STATUS2, ST25R3916_REG_FIFO_STATUS2_fifo_lb_mask, 0 )
#define st25r3916IsLastFIFOComplete() \
st25r3916CheckReg(ST25R3916_REG_FIFO_STATUS2, ST25R3916_REG_FIFO_STATUS2_fifo_lb_mask, 0)
/*! Checks if the Oscillator is enabled */
#define st25r3916IsOscOn() st25r3916CheckReg( ST25R3916_REG_OP_CONTROL, ST25R3916_REG_OP_CONTROL_en, ST25R3916_REG_OP_CONTROL_en )
#define st25r3916IsOscOn() \
st25r3916CheckReg( \
ST25R3916_REG_OP_CONTROL, ST25R3916_REG_OP_CONTROL_en, ST25R3916_REG_OP_CONTROL_en)
/*
******************************************************************************
@@ -193,7 +249,7 @@ struct st25r3916StreamConfig {
*
*****************************************************************************
*/
ReturnCode st25r3916Initialize( void );
ReturnCode st25r3916Initialize(void);
/*!
*****************************************************************************
@@ -203,7 +259,7 @@ ReturnCode st25r3916Initialize( void );
*
*****************************************************************************
*/
void st25r3916Deinitialize( void );
void st25r3916Deinitialize(void);
/*!
*****************************************************************************
@@ -217,7 +273,7 @@ void st25r3916Deinitialize( void );
*
*****************************************************************************
*/
ReturnCode st25r3916OscOn( void );
ReturnCode st25r3916OscOn(void);
/*!
*****************************************************************************
@@ -235,7 +291,7 @@ ReturnCode st25r3916OscOn( void );
*
*****************************************************************************
*/
ReturnCode st25r3916SetBitrate( uint8_t txrate, uint8_t rxrate );
ReturnCode st25r3916SetBitrate(uint8_t txrate, uint8_t rxrate);
/*!
*****************************************************************************
@@ -254,7 +310,7 @@ ReturnCode st25r3916SetBitrate( uint8_t txrate, uint8_t rxrate );
*
*****************************************************************************
*/
ReturnCode st25r3916AdjustRegulators( uint16_t* result_mV );
ReturnCode st25r3916AdjustRegulators(uint16_t* result_mV);
/*!
*****************************************************************************
@@ -270,7 +326,7 @@ ReturnCode st25r3916AdjustRegulators( uint16_t* result_mV );
*
*****************************************************************************
*/
ReturnCode st25r3916MeasureAmplitude( uint8_t* result );
ReturnCode st25r3916MeasureAmplitude(uint8_t* result);
/*!
*****************************************************************************
@@ -288,7 +344,7 @@ ReturnCode st25r3916MeasureAmplitude( uint8_t* result );
*
*****************************************************************************
*/
uint8_t st25r3916MeasurePowerSupply( uint8_t mpsv );
uint8_t st25r3916MeasurePowerSupply(uint8_t mpsv);
/*!
*****************************************************************************
@@ -307,7 +363,7 @@ uint8_t st25r3916MeasurePowerSupply( uint8_t mpsv );
*
*****************************************************************************
*/
uint16_t st25r3916MeasureVoltage( uint8_t mpsv );
uint16_t st25r3916MeasureVoltage(uint8_t mpsv);
/*!
*****************************************************************************
@@ -323,8 +379,7 @@ uint16_t st25r3916MeasureVoltage( uint8_t mpsv );
*
*****************************************************************************
*/
ReturnCode st25r3916MeasurePhase( uint8_t* result );
ReturnCode st25r3916MeasurePhase(uint8_t* result);
/*!
*****************************************************************************
@@ -340,7 +395,7 @@ ReturnCode st25r3916MeasurePhase( uint8_t* result );
*
*****************************************************************************
*/
ReturnCode st25r3916MeasureCapacitance( uint8_t* result );
ReturnCode st25r3916MeasureCapacitance(uint8_t* result);
/*!
*****************************************************************************
@@ -364,7 +419,7 @@ ReturnCode st25r3916MeasureCapacitance( uint8_t* result );
*
*****************************************************************************
*/
ReturnCode st25r3916CalibrateCapacitiveSensor( uint8_t* result );
ReturnCode st25r3916CalibrateCapacitiveSensor(uint8_t* result);
/*!
*****************************************************************************
@@ -377,7 +432,7 @@ ReturnCode st25r3916CalibrateCapacitiveSensor( uint8_t* result );
*
* \return the value of the NRT in 64/fc
*/
uint32_t st25r3916GetNoResponseTime( void );
uint32_t st25r3916GetNoResponseTime(void);
/*!
*****************************************************************************
@@ -392,7 +447,7 @@ uint32_t st25r3916GetNoResponseTime( void );
*
*****************************************************************************
*/
ReturnCode st25r3916SetNoResponseTime( uint32_t nrt_64fcs );
ReturnCode st25r3916SetNoResponseTime(uint32_t nrt_64fcs);
/*!
*****************************************************************************
@@ -409,7 +464,7 @@ ReturnCode st25r3916SetNoResponseTime( uint32_t nrt_64fcs );
*
*****************************************************************************
*/
ReturnCode st25r3916SetStartNoResponseTimer( uint32_t nrt_64fcs );
ReturnCode st25r3916SetStartNoResponseTimer(uint32_t nrt_64fcs);
/*!
*****************************************************************************
@@ -421,7 +476,7 @@ ReturnCode st25r3916SetStartNoResponseTimer( uint32_t nrt_64fcs );
*
*****************************************************************************
*/
void st25r3916SetGPTime( uint16_t gpt_8fcs );
void st25r3916SetGPTime(uint16_t gpt_8fcs);
/*!
*****************************************************************************
@@ -438,7 +493,7 @@ void st25r3916SetGPTime( uint16_t gpt_8fcs );
*
*****************************************************************************
*/
ReturnCode st25r3916SetStartGPTimer( uint16_t gpt_8fcs, uint8_t trigger_source );
ReturnCode st25r3916SetStartGPTimer(uint16_t gpt_8fcs, uint8_t trigger_source);
/*!
*****************************************************************************
@@ -451,7 +506,7 @@ ReturnCode st25r3916SetStartGPTimer( uint16_t gpt_8fcs, uint8_t trigger_source )
*
*****************************************************************************
*/
void st25r3916SetNumTxBits( uint16_t nBits );
void st25r3916SetNumTxBits(uint16_t nBits);
/*!
*****************************************************************************
@@ -463,7 +518,7 @@ void st25r3916SetNumTxBits( uint16_t nBits );
*
*****************************************************************************
*/
uint16_t st25r3916GetNumFIFOBytes( void );
uint16_t st25r3916GetNumFIFOBytes(void);
/*!
*****************************************************************************
@@ -476,7 +531,7 @@ uint16_t st25r3916GetNumFIFOBytes( void );
*
*****************************************************************************
*/
uint8_t st25r3916GetNumFIFOLastBits( void );
uint8_t st25r3916GetNumFIFOLastBits(void);
/*!
*****************************************************************************
@@ -499,7 +554,11 @@ uint8_t st25r3916GetNumFIFOLastBits( void );
*
*****************************************************************************
*/
ReturnCode st25r3916PerformCollisionAvoidance( uint8_t FieldONCmd, uint8_t pdThreshold, uint8_t caThreshold, uint8_t nTRFW );
ReturnCode st25r3916PerformCollisionAvoidance(
uint8_t FieldONCmd,
uint8_t pdThreshold,
uint8_t caThreshold,
uint8_t nTRFW);
/*!
*****************************************************************************
@@ -515,7 +574,7 @@ ReturnCode st25r3916PerformCollisionAvoidance( uint8_t FieldONCmd, uint8_t pdThr
* \return true when IC type is as expected
* \return false otherwise
*/
bool st25r3916CheckChipID( uint8_t *rev );
bool st25r3916CheckChipID(uint8_t* rev);
/*!
*****************************************************************************
@@ -528,7 +587,7 @@ bool st25r3916CheckChipID( uint8_t *rev );
* \return ERR_NONE : No error
*****************************************************************************
*/
ReturnCode st25r3916GetRegsDump( t_st25r3916Regs* regDump );
ReturnCode st25r3916GetRegsDump(t_st25r3916Regs* regDump);
/*!
*****************************************************************************
@@ -543,7 +602,7 @@ ReturnCode st25r3916GetRegsDump( t_st25r3916Regs* regDump );
*
*****************************************************************************
*/
bool st25r3916IsCmdValid( uint8_t cmd );
bool st25r3916IsCmdValid(uint8_t cmd);
/*!
*****************************************************************************
@@ -558,7 +617,7 @@ bool st25r3916IsCmdValid( uint8_t cmd );
*
*****************************************************************************
*/
ReturnCode st25r3916StreamConfigure( const struct st25r3916StreamConfig *config );
ReturnCode st25r3916StreamConfigure(const struct st25r3916StreamConfig* config);
/*!
*****************************************************************************
@@ -577,7 +636,8 @@ ReturnCode st25r3916StreamConfigure( const struct st25r3916StreamConfig *config
*
*****************************************************************************
*/
ReturnCode st25r3916ExecuteCommandAndGetResult( uint8_t cmd, uint8_t resReg, uint8_t tout, uint8_t* result );
ReturnCode
st25r3916ExecuteCommandAndGetResult(uint8_t cmd, uint8_t resReg, uint8_t tout, uint8_t* result);
/*!
*****************************************************************************
@@ -595,7 +655,7 @@ ReturnCode st25r3916ExecuteCommandAndGetResult( uint8_t cmd, uint8_t resReg, uin
*
*****************************************************************************
*/
ReturnCode st25r3916GetRSSI( uint16_t *amRssi, uint16_t *pmRssi );
ReturnCode st25r3916GetRSSI(uint16_t* amRssi, uint16_t* pmRssi);
#endif /* ST25R3916_H */
/**

297
lib/ST25RFAL002/source/st25r3916/st25r3916_aat.c Executable file → Normal file
View File

@@ -19,7 +19,6 @@
*
******************************************************************************/
/*
* PROJECT: ST25R3916 firmware
* Revision:
@@ -37,8 +36,7 @@
* to tune the antenna matching.
*
*/
/*
******************************************************************************
* INCLUDES
@@ -52,207 +50,229 @@
#include "platform.h"
#include "rfal_chip.h"
/*
******************************************************************************
* GLOBAL DEFINES
******************************************************************************
*/
#define ST25R3916_AAT_CAP_DELAY_MAX 10 /*!< Max Variable Capacitor settle delay */
#define ST25R3916_AAT_CAP_DELAY_MAX 10 /*!< Max Variable Capacitor settle delay */
/*
******************************************************************************
* GLOBAL MACROS
******************************************************************************
*/
#define st25r3916AatLog(...) /* platformLog(__VA_ARGS__) */ /*!< Logging macro */
#define st25r3916AatLog(...) /* platformLog(__VA_ARGS__) */ /*!< Logging macro */
/*
******************************************************************************
* LOCAL FUNCTION PROTOTYPES
******************************************************************************
*/
static ReturnCode aatHillClimb(const struct st25r3916AatTuneParams *tuningParams, struct st25r3916AatTuneResult *tuningStatus);
static int32_t aatGreedyDescent(uint32_t *f_min, const struct st25r3916AatTuneParams *tuningParams, struct st25r3916AatTuneResult *tuningStatus, int32_t previousDir);
static int32_t aatSteepestDescent(uint32_t *f_min, const struct st25r3916AatTuneParams *tuningParams, struct st25r3916AatTuneResult *tuningStatus, int32_t previousDir, int32_t previousDir2);
static ReturnCode aatHillClimb(
const struct st25r3916AatTuneParams* tuningParams,
struct st25r3916AatTuneResult* tuningStatus);
static int32_t aatGreedyDescent(
uint32_t* f_min,
const struct st25r3916AatTuneParams* tuningParams,
struct st25r3916AatTuneResult* tuningStatus,
int32_t previousDir);
static int32_t aatSteepestDescent(
uint32_t* f_min,
const struct st25r3916AatTuneParams* tuningParams,
struct st25r3916AatTuneResult* tuningStatus,
int32_t previousDir,
int32_t previousDir2);
static ReturnCode aatMeasure(uint8_t serCap, uint8_t parCap, uint8_t *amplitude, uint8_t *phase, uint16_t *measureCnt);
static uint32_t aatCalcF(const struct st25r3916AatTuneParams *tuningParams, uint8_t amplitude, uint8_t phase);
static ReturnCode aatStepDacVals(const struct st25r3916AatTuneParams *tuningParams,uint8_t *a, uint8_t *b, int32_t dir);
static ReturnCode aatMeasure(
uint8_t serCap,
uint8_t parCap,
uint8_t* amplitude,
uint8_t* phase,
uint16_t* measureCnt);
static uint32_t
aatCalcF(const struct st25r3916AatTuneParams* tuningParams, uint8_t amplitude, uint8_t phase);
static ReturnCode aatStepDacVals(
const struct st25r3916AatTuneParams* tuningParams,
uint8_t* a,
uint8_t* b,
int32_t dir);
/*******************************************************************************/
ReturnCode st25r3916AatTune(const struct st25r3916AatTuneParams *tuningParams, struct st25r3916AatTuneResult *tuningStatus)
{
ReturnCode st25r3916AatTune(
const struct st25r3916AatTuneParams* tuningParams,
struct st25r3916AatTuneResult* tuningStatus) {
ReturnCode err;
const struct st25r3916AatTuneParams *tp = tuningParams;
struct st25r3916AatTuneResult *ts = tuningStatus;
struct st25r3916AatTuneParams defaultTuningParams =
{
.aat_a_min=0,
.aat_a_max=255,
.aat_a_start=127,
.aat_a_stepWidth=32,
.aat_b_min=0,
.aat_b_max=255,
.aat_b_start=127,
.aat_b_stepWidth=32,
const struct st25r3916AatTuneParams* tp = tuningParams;
struct st25r3916AatTuneResult* ts = tuningStatus;
struct st25r3916AatTuneParams defaultTuningParams = {
.aat_a_min = 0,
.aat_a_max = 255,
.aat_a_start = 127,
.aat_a_stepWidth = 32,
.aat_b_min = 0,
.aat_b_max = 255,
.aat_b_start = 127,
.aat_b_stepWidth = 32,
.phaTarget=128,
.phaWeight=2,
.ampTarget=196,
.ampWeight=1,
.phaTarget = 128,
.phaWeight = 2,
.ampTarget = 196,
.ampWeight = 1,
.doDynamicSteps=true,
.measureLimit=50,
.doDynamicSteps = true,
.measureLimit = 50,
};
struct st25r3916AatTuneResult defaultTuneResult;
if ((NULL != tp) && (
(tp->aat_a_min > tp->aat_a_max )
|| (tp->aat_a_start < tp->aat_a_min )
|| (tp->aat_a_start > tp->aat_a_max )
|| (tp->aat_b_min > tp->aat_b_max )
|| (tp->aat_b_start < tp->aat_b_min )
|| (tp->aat_b_start > tp->aat_b_max )
))
{
if((NULL != tp) && ((tp->aat_a_min > tp->aat_a_max) || (tp->aat_a_start < tp->aat_a_min) ||
(tp->aat_a_start > tp->aat_a_max) || (tp->aat_b_min > tp->aat_b_max) ||
(tp->aat_b_start < tp->aat_b_min) || (tp->aat_b_start > tp->aat_b_max))) {
return ERR_PARAM;
}
if (NULL == tp)
{ /* Start from current caps with default params */
if(NULL == tp) { /* Start from current caps with default params */
st25r3916ReadRegister(ST25R3916_REG_ANT_TUNE_A, &defaultTuningParams.aat_a_start);
st25r3916ReadRegister(ST25R3916_REG_ANT_TUNE_B, &defaultTuningParams.aat_b_start);
tp = &defaultTuningParams;
}
if (NULL == ts){ts = &defaultTuneResult;}
if(NULL == ts) {
ts = &defaultTuneResult;
}
ts->measureCnt = 0; /* Clear current measure count */
err = aatHillClimb(tp, ts);
return err;
}
/*******************************************************************************/
static ReturnCode aatHillClimb(const struct st25r3916AatTuneParams *tuningParams, struct st25r3916AatTuneResult *tuningStatus)
{
ReturnCode err = ERR_NONE;
static ReturnCode aatHillClimb(
const struct st25r3916AatTuneParams* tuningParams,
struct st25r3916AatTuneResult* tuningStatus) {
ReturnCode err = ERR_NONE;
uint32_t f_min;
int32_t direction, gdirection;
uint8_t amp,phs;
uint8_t amp, phs;
struct st25r3916AatTuneParams tp = *tuningParams; // local copy to obey const
tuningStatus->aat_a = tuningParams->aat_a_start;
tuningStatus->aat_b = tuningParams->aat_b_start;
/* Get a proper start value */
aatMeasure(tuningStatus->aat_a,tuningStatus->aat_b,&amp,&phs,&tuningStatus->measureCnt);
aatMeasure(tuningStatus->aat_a, tuningStatus->aat_b, &amp, &phs, &tuningStatus->measureCnt);
f_min = aatCalcF(&tp, amp, phs);
direction = 0;
st25r3916AatLog("%d %d: %d***\n",tuningStatus->aat_a,tuningStatus->aat_b,f_min);
st25r3916AatLog("%d %d: %d***\n", tuningStatus->aat_a, tuningStatus->aat_b, f_min);
do {
direction = 0; /* Initially and after reducing step sizes we don't have a previous direction */
direction =
0; /* Initially and after reducing step sizes we don't have a previous direction */
do {
/* With the greedy step below always executed aftwards the -direction does never need to be investigated */
direction = aatSteepestDescent(&f_min, &tp, tuningStatus, direction, -direction);
if (tuningStatus->measureCnt > tp.measureLimit)
{
if(tuningStatus->measureCnt > tp.measureLimit) {
err = ERR_OVERRUN;
break;
}
do
{
do {
gdirection = aatGreedyDescent(&f_min, &tp, tuningStatus, direction);
if (tuningStatus->measureCnt > tp.measureLimit) {
if(tuningStatus->measureCnt > tp.measureLimit) {
err = ERR_OVERRUN;
break;
}
} while (0 != gdirection);
} while (0 != direction);
} while(0 != gdirection);
} while(0 != direction);
tp.aat_a_stepWidth /= 2U; /* Reduce step sizes */
tp.aat_b_stepWidth /= 2U;
} while (tp.doDynamicSteps && ((tp.aat_a_stepWidth>0U) || (tp.aat_b_stepWidth>0U)));
} while(tp.doDynamicSteps && ((tp.aat_a_stepWidth > 0U) || (tp.aat_b_stepWidth > 0U)));
return err;
}
/*******************************************************************************/
static int32_t aatSteepestDescent(uint32_t *f_min, const struct st25r3916AatTuneParams *tuningParams, struct st25r3916AatTuneResult *tuningStatus, int32_t previousDir, int32_t previousDir2)
{
static int32_t aatSteepestDescent(
uint32_t* f_min,
const struct st25r3916AatTuneParams* tuningParams,
struct st25r3916AatTuneResult* tuningStatus,
int32_t previousDir,
int32_t previousDir2) {
int32_t i;
uint8_t amp,phs;
uint8_t amp, phs;
uint32_t f;
int32_t bestdir = 0; /* Negative direction: decrease, Positive: increase. (-)1: aat_a, (-)2: aat_b */
int32_t bestdir =
0; /* Negative direction: decrease, Positive: increase. (-)1: aat_a, (-)2: aat_b */
for (i = -2; i <= 2; i++)
{
uint8_t a = tuningStatus->aat_a , b = tuningStatus->aat_b;
for(i = -2; i <= 2; i++) {
uint8_t a = tuningStatus->aat_a, b = tuningStatus->aat_b;
if ((0==i) || (i==-previousDir) || (i==-previousDir2))
{ /* Skip no direction and avoid going backwards */
if((0 == i) || (i == -previousDir) ||
(i == -previousDir2)) { /* Skip no direction and avoid going backwards */
continue;
}
if (0U!=aatStepDacVals(tuningParams, &a, &b, i))
{ /* If stepping did not change the value, omit this direction */
if(0U != aatStepDacVals(
tuningParams,
&a,
&b,
i)) { /* If stepping did not change the value, omit this direction */
continue;
}
aatMeasure(a,b,&amp,&phs,&tuningStatus->measureCnt);
aatMeasure(a, b, &amp, &phs, &tuningStatus->measureCnt);
f = aatCalcF(tuningParams, amp, phs);
st25r3916AatLog("%d : %d %d: %d",i,a, b, f);
if (f < *f_min)
{ /* Value is better than all previous ones */
st25r3916AatLog("%d : %d %d: %d", i, a, b, f);
if(f < *f_min) { /* Value is better than all previous ones */
st25r3916AatLog("*");
*f_min = f;
bestdir = i;
}
st25r3916AatLog("\n");
}
if (0!=bestdir)
{ /* Walk into the best direction */
if(0 != bestdir) { /* Walk into the best direction */
aatStepDacVals(tuningParams, &tuningStatus->aat_a, &tuningStatus->aat_b, bestdir);
}
return bestdir;
}
/*******************************************************************************/
static int32_t aatGreedyDescent(uint32_t *f_min, const struct st25r3916AatTuneParams *tuningParams, struct st25r3916AatTuneResult *tuningStatus, int32_t previousDir)
{
uint8_t amp,phs;
static int32_t aatGreedyDescent(
uint32_t* f_min,
const struct st25r3916AatTuneParams* tuningParams,
struct st25r3916AatTuneResult* tuningStatus,
int32_t previousDir) {
uint8_t amp, phs;
uint32_t f;
uint8_t a = tuningStatus->aat_a , b = tuningStatus->aat_b;
uint8_t a = tuningStatus->aat_a, b = tuningStatus->aat_b;
if (0U != aatStepDacVals(tuningParams, &a, &b, previousDir))
{ /* If stepping did not change the value, omit this direction */
if(0U != aatStepDacVals(
tuningParams,
&a,
&b,
previousDir)) { /* If stepping did not change the value, omit this direction */
return 0;
}
aatMeasure(a,b,&amp,&phs,&tuningStatus->measureCnt);
aatMeasure(a, b, &amp, &phs, &tuningStatus->measureCnt);
f = aatCalcF(tuningParams, amp, phs);
st25r3916AatLog("g : %d %d: %d",a, b, f);
if (f < *f_min)
{ /* Value is better than previous one */
st25r3916AatLog("g : %d %d: %d", a, b, f);
if(f < *f_min) { /* Value is better than previous one */
st25r3916AatLog("*\n");
tuningStatus->aat_a = a;
tuningStatus->aat_b = b;
*f_min = f;
return previousDir;
}
st25r3916AatLog("\n");
return 0;
}
/*******************************************************************************/
static uint32_t aatCalcF(const struct st25r3916AatTuneParams *tuningParams, uint8_t amplitude, uint8_t phase)
{
static uint32_t
aatCalcF(const struct st25r3916AatTuneParams* tuningParams, uint8_t amplitude, uint8_t phase) {
/* f(amp, pha) = (ampWeight * |amp - ampTarget|) + (phaWeight * |pha - phaTarget|) */
uint8_t ampTarget = tuningParams->ampTarget;
uint8_t phaTarget = tuningParams->phaTarget;
@@ -261,8 +281,8 @@ static uint32_t aatCalcF(const struct st25r3916AatTuneParams *tuningParams, uint
uint32_t phaWeight = tuningParams->phaWeight;
/* Temp variables to avoid MISRA R10.8 (cast on composite expression) */
uint8_t ad = ((amplitude > ampTarget) ? (amplitude - ampTarget) : (ampTarget - amplitude));
uint8_t pd = ((phase > phaTarget) ? (phase - phaTarget) : (phaTarget - phase));
uint8_t ad = ((amplitude > ampTarget) ? (amplitude - ampTarget) : (ampTarget - amplitude));
uint8_t pd = ((phase > phaTarget) ? (phase - phaTarget) : (phaTarget - phase));
uint32_t ampDelta = (uint32_t)ad;
uint32_t phaDelta = (uint32_t)pd;
@@ -271,58 +291,75 @@ static uint32_t aatCalcF(const struct st25r3916AatTuneParams *tuningParams, uint
}
/*******************************************************************************/
static ReturnCode aatStepDacVals(const struct st25r3916AatTuneParams *tuningParams,uint8_t *a, uint8_t *b, int32_t dir)
{
static ReturnCode aatStepDacVals(
const struct st25r3916AatTuneParams* tuningParams,
uint8_t* a,
uint8_t* b,
int32_t dir) {
int16_t aat_a = (int16_t)*a, aat_b = (int16_t)*b;
switch (abs(dir))
{ /* Advance by steps size in requested direction */
case 1:
aat_a = (dir<0)?(aat_a - (int16_t)tuningParams->aat_a_stepWidth):(aat_a + (int16_t)tuningParams->aat_a_stepWidth);
if(aat_a < (int16_t)tuningParams->aat_a_min){ aat_a = (int16_t)tuningParams->aat_a_min; }
if(aat_a > (int16_t)tuningParams->aat_a_max){ aat_a = (int16_t)tuningParams->aat_a_max; }
if ((int16_t)*a == aat_a) {return ERR_PARAM;}
break;
case 2:
aat_b = (dir<0)?(aat_b - (int16_t)tuningParams->aat_b_stepWidth):(aat_b + (int16_t)tuningParams->aat_b_stepWidth);
if(aat_b < (int16_t)tuningParams->aat_b_min){ aat_b = (int16_t)tuningParams->aat_b_min; }
if(aat_b > (int16_t)tuningParams->aat_b_max){ aat_b = (int16_t)tuningParams->aat_b_max; }
if ((int16_t)*b == aat_b) {return ERR_PARAM;}
break;
default:
return ERR_REQUEST;
switch(abs(dir)) { /* Advance by steps size in requested direction */
case 1:
aat_a = (dir < 0) ? (aat_a - (int16_t)tuningParams->aat_a_stepWidth) :
(aat_a + (int16_t)tuningParams->aat_a_stepWidth);
if(aat_a < (int16_t)tuningParams->aat_a_min) {
aat_a = (int16_t)tuningParams->aat_a_min;
}
if(aat_a > (int16_t)tuningParams->aat_a_max) {
aat_a = (int16_t)tuningParams->aat_a_max;
}
if((int16_t)*a == aat_a) {
return ERR_PARAM;
}
break;
case 2:
aat_b = (dir < 0) ? (aat_b - (int16_t)tuningParams->aat_b_stepWidth) :
(aat_b + (int16_t)tuningParams->aat_b_stepWidth);
if(aat_b < (int16_t)tuningParams->aat_b_min) {
aat_b = (int16_t)tuningParams->aat_b_min;
}
if(aat_b > (int16_t)tuningParams->aat_b_max) {
aat_b = (int16_t)tuningParams->aat_b_max;
}
if((int16_t)*b == aat_b) {
return ERR_PARAM;
}
break;
default:
return ERR_REQUEST;
}
/* We only get here if actual values have changed. In all other cases an error is returned */
*a = (uint8_t)aat_a;
*a = (uint8_t)aat_a;
*b = (uint8_t)aat_b;
return ERR_NONE;
return ERR_NONE;
}
/*******************************************************************************/
static ReturnCode aatMeasure(uint8_t serCap, uint8_t parCap, uint8_t *amplitude, uint8_t *phase, uint16_t *measureCnt)
{
static ReturnCode aatMeasure(
uint8_t serCap,
uint8_t parCap,
uint8_t* amplitude,
uint8_t* phase,
uint16_t* measureCnt) {
ReturnCode err;
*amplitude = 0;
*phase = 0;
*amplitude = 0;
*phase = 0;
st25r3916WriteRegister(ST25R3916_REG_ANT_TUNE_A, serCap);
st25r3916WriteRegister(ST25R3916_REG_ANT_TUNE_B, parCap);
/* Wait till caps have settled.. */
platformDelay( ST25R3916_AAT_CAP_DELAY_MAX );
platformDelay(ST25R3916_AAT_CAP_DELAY_MAX);
/* Get amplitude and phase .. */
err = rfalChipMeasureAmplitude(amplitude);
if (ERR_NONE == err)
{
if(ERR_NONE == err) {
err = rfalChipMeasurePhase(phase);
}
if( measureCnt != NULL )
{
if(measureCnt != NULL) {
(*measureCnt)++;
}
return err;

52
lib/ST25RFAL002/source/st25r3916/st25r3916_aat.h Executable file → Normal file
View File

@@ -19,7 +19,6 @@
*
******************************************************************************/
/*
* PROJECT: ST25R3916 firmware
* Revision:
@@ -38,7 +37,6 @@
*
*/
#ifndef ST25R3916_AAT_H
#define ST25R3916_AAT_H
@@ -54,40 +52,36 @@
/*!
* struct representing input parameters for the antenna tuning
*/
struct st25r3916AatTuneParams{
uint8_t aat_a_min; /*!< min value of A cap */
uint8_t aat_a_max; /*!< max value of A cap */
uint8_t aat_a_start; /*!< start value of A cap */
uint8_t aat_a_stepWidth; /*!< increment stepWidth for A cap */
uint8_t aat_b_min; /*!< min value of B cap */
uint8_t aat_b_max; /*!< max value of B cap */
uint8_t aat_b_start; /*!< start value of B cap */
uint8_t aat_b_stepWidth; /*!< increment stepWidth for B cap */
struct st25r3916AatTuneParams {
uint8_t aat_a_min; /*!< min value of A cap */
uint8_t aat_a_max; /*!< max value of A cap */
uint8_t aat_a_start; /*!< start value of A cap */
uint8_t aat_a_stepWidth; /*!< increment stepWidth for A cap */
uint8_t aat_b_min; /*!< min value of B cap */
uint8_t aat_b_max; /*!< max value of B cap */
uint8_t aat_b_start; /*!< start value of B cap */
uint8_t aat_b_stepWidth; /*!< increment stepWidth for B cap */
uint8_t phaTarget; /*!< target phase */
uint8_t phaWeight; /*!< weight of target phase */
uint8_t ampTarget; /*!< target amplitude */
uint8_t ampWeight; /*!< weight of target amplitude */
uint8_t phaTarget; /*!< target phase */
uint8_t phaWeight; /*!< weight of target phase */
uint8_t ampTarget; /*!< target amplitude */
uint8_t ampWeight; /*!< weight of target amplitude */
bool doDynamicSteps; /*!< dynamically reduce step size in algo */
uint8_t measureLimit; /*!< max number of allowed steps/measurements */
bool doDynamicSteps; /*!< dynamically reduce step size in algo */
uint8_t measureLimit; /*!< max number of allowed steps/measurements */
};
/*!
* struct representing out parameters for the antenna tuning
*/
struct st25r3916AatTuneResult{
uint8_t aat_a; /*!< serial cap after tuning */
uint8_t aat_b; /*!< parallel cap after tuning */
uint8_t pha; /*!< phase after tuning */
uint8_t amp; /*!< amplitude after tuning */
uint16_t measureCnt; /*!< number of measures performed */
struct st25r3916AatTuneResult {
uint8_t aat_a; /*!< serial cap after tuning */
uint8_t aat_b; /*!< parallel cap after tuning */
uint8_t pha; /*!< phase after tuning */
uint8_t amp; /*!< amplitude after tuning */
uint16_t measureCnt; /*!< number of measures performed */
};
/*!
*****************************************************************************
* \brief Perform antenna tuning
@@ -108,6 +102,8 @@ struct st25r3916AatTuneResult{
*
*****************************************************************************
*/
extern ReturnCode st25r3916AatTune(const struct st25r3916AatTuneParams *tuningParams, struct st25r3916AatTuneResult *tuningStatus);
extern ReturnCode st25r3916AatTune(
const struct st25r3916AatTuneParams* tuningParams,
struct st25r3916AatTuneResult* tuningStatus);
#endif /* ST25R3916_AAT_H */

544
lib/ST25RFAL002/source/st25r3916/st25r3916_com.c Executable file → Normal file
View File

@@ -20,7 +20,6 @@
*
******************************************************************************/
/*
* PROJECT: ST25R3916 firmware
* Revision:
@@ -48,29 +47,42 @@
#include "platform.h"
#include "utils.h"
/*
******************************************************************************
* LOCAL DEFINES
******************************************************************************
*/
#define ST25R3916_OPTIMIZE true /*!< Optimization switch: false always write value to register */
#define ST25R3916_I2C_ADDR (0xA0U >> 1) /*!< ST25R3916's default I2C address */
#define ST25R3916_REG_LEN 1U /*!< Byte length of a ST25R3916 register */
#define ST25R3916_OPTIMIZE \
true /*!< Optimization switch: false always write value to register */
#define ST25R3916_I2C_ADDR \
(0xA0U >> 1) /*!< ST25R3916's default I2C address */
#define ST25R3916_REG_LEN 1U /*!< Byte length of a ST25R3916 register */
#define ST25R3916_WRITE_MODE (0U << 6) /*!< ST25R3916 Operation Mode: Write */
#define ST25R3916_READ_MODE (1U << 6) /*!< ST25R3916 Operation Mode: Read */
#define ST25R3916_CMD_MODE (3U << 6) /*!< ST25R3916 Operation Mode: Direct Command */
#define ST25R3916_FIFO_LOAD (0x80U) /*!< ST25R3916 Operation Mode: FIFO Load */
#define ST25R3916_FIFO_READ (0x9FU) /*!< ST25R3916 Operation Mode: FIFO Read */
#define ST25R3916_PT_A_CONFIG_LOAD (0xA0U) /*!< ST25R3916 Operation Mode: Passive Target Memory A-Config Load */
#define ST25R3916_PT_F_CONFIG_LOAD (0xA8U) /*!< ST25R3916 Operation Mode: Passive Target Memory F-Config Load */
#define ST25R3916_PT_TSN_DATA_LOAD (0xACU) /*!< ST25R3916 Operation Mode: Passive Target Memory TSN Load */
#define ST25R3916_PT_MEM_READ (0xBFU) /*!< ST25R3916 Operation Mode: Passive Target Memory Read */
#define ST25R3916_WRITE_MODE \
(0U << 6) /*!< ST25R3916 Operation Mode: Write */
#define ST25R3916_READ_MODE \
(1U << 6) /*!< ST25R3916 Operation Mode: Read */
#define ST25R3916_CMD_MODE \
(3U << 6) /*!< ST25R3916 Operation Mode: Direct Command */
#define ST25R3916_FIFO_LOAD \
(0x80U) /*!< ST25R3916 Operation Mode: FIFO Load */
#define ST25R3916_FIFO_READ \
(0x9FU) /*!< ST25R3916 Operation Mode: FIFO Read */
#define ST25R3916_PT_A_CONFIG_LOAD \
(0xA0U) /*!< ST25R3916 Operation Mode: Passive Target Memory A-Config Load */
#define ST25R3916_PT_F_CONFIG_LOAD \
(0xA8U) /*!< ST25R3916 Operation Mode: Passive Target Memory F-Config Load */
#define ST25R3916_PT_TSN_DATA_LOAD \
(0xACU) /*!< ST25R3916 Operation Mode: Passive Target Memory TSN Load */
#define ST25R3916_PT_MEM_READ \
(0xBFU) /*!< ST25R3916 Operation Mode: Passive Target Memory Read */
#define ST25R3916_CMD_LEN (1U) /*!< ST25R3916 CMD length */
#define ST25R3916_BUF_LEN (ST25R3916_CMD_LEN+ST25R3916_FIFO_DEPTH) /*!< ST25R3916 communication buffer: CMD + FIFO length */
#define ST25R3916_CMD_LEN \
(1U) /*!< ST25R3916 CMD length */
#define ST25R3916_BUF_LEN \
(ST25R3916_CMD_LEN + \
ST25R3916_FIFO_DEPTH) /*!< ST25R3916 communication buffer: CMD + FIFO length */
/*
******************************************************************************
@@ -78,19 +90,26 @@
******************************************************************************
*/
#ifdef RFAL_USE_I2C
#define st25r3916I2CStart() platformI2CStart() /*!< ST25R3916 HAL I2C driver macro to start a I2C transfer */
#define st25r3916I2CStop() platformI2CStop() /*!< ST25R3916 HAL I2C driver macro to stop a I2C transfer */
#define st25r3916I2CRepeatStart() platformI2CRepeatStart() /*!< ST25R3916 HAL I2C driver macro to repeat Start */
#define st25r3916I2CSlaveAddrWR( sA ) platformI2CSlaveAddrWR( sA ) /*!< ST25R3916 HAL I2C driver macro to repeat Start */
#define st25r3916I2CSlaveAddrRD( sA ) platformI2CSlaveAddrRD( sA ) /*!< ST25R3916 HAL I2C driver macro to repeat Start */
#define st25r3916I2CStart() \
platformI2CStart() /*!< ST25R3916 HAL I2C driver macro to start a I2C transfer */
#define st25r3916I2CStop() \
platformI2CStop() /*!< ST25R3916 HAL I2C driver macro to stop a I2C transfer */
#define st25r3916I2CRepeatStart() \
platformI2CRepeatStart() /*!< ST25R3916 HAL I2C driver macro to repeat Start */
#define st25r3916I2CSlaveAddrWR(sA) \
platformI2CSlaveAddrWR( \
sA) /*!< ST25R3916 HAL I2C driver macro to repeat Start */
#define st25r3916I2CSlaveAddrRD(sA) \
platformI2CSlaveAddrRD( \
sA) /*!< ST25R3916 HAL I2C driver macro to repeat Start */
#endif /* RFAL_USE_I2C */
#if defined(ST25R_COM_SINGLETXRX) && !defined(RFAL_USE_I2C)
static uint8_t comBuf[ST25R3916_BUF_LEN]; /*!< ST25R3916 communication buffer */
static uint16_t comBufIt; /*!< ST25R3916 communication buffer iterator */
static uint8_t
comBuf[ST25R3916_BUF_LEN]; /*!< ST25R3916 communication buffer */
static uint16_t comBufIt; /*!< ST25R3916 communication buffer iterator */
#endif /* ST25R_COM_SINGLETXRX */
/*
******************************************************************************
* LOCAL FUNCTION PROTOTYPES
@@ -105,7 +124,7 @@ static uint16_t comBufIt; /*!< ST25
* ST25R3916, either by SPI or I2C
******************************************************************************
*/
static void st25r3916comStart( void );
static void st25r3916comStart(void);
/*!
******************************************************************************
@@ -115,7 +134,7 @@ static void st25r3916comStart( void );
* ST25R3916, either by SPI or I2C
******************************************************************************
*/
static void st25r3916comStop( void );
static void st25r3916comStop(void);
/*!
******************************************************************************
@@ -126,9 +145,9 @@ static void st25r3916comStop( void );
******************************************************************************
*/
#ifdef RFAL_USE_I2C
static void st25r3916comRepeatStart( void );
static void st25r3916comRepeatStart(void);
#else
#define st25r3916comRepeatStart()
#define st25r3916comRepeatStart()
#endif /* RFAL_USE_I2C */
/*!
@@ -145,8 +164,7 @@ static void st25r3916comRepeatStart( void );
*
******************************************************************************
*/
static void st25r3916comTx( const uint8_t* txBuf, uint16_t txLen, bool last, bool txOnly );
static void st25r3916comTx(const uint8_t* txBuf, uint16_t txLen, bool last, bool txOnly);
/*!
******************************************************************************
@@ -160,7 +178,7 @@ static void st25r3916comTx( const uint8_t* txBuf, uint16_t txLen, bool last, boo
*
******************************************************************************
*/
static void st25r3916comRx( uint8_t* rxBuf, uint16_t rxLen );
static void st25r3916comRx(uint8_t* rxBuf, uint16_t rxLen);
/*!
******************************************************************************
@@ -174,39 +192,34 @@ static void st25r3916comRx( uint8_t* rxBuf, uint16_t rxLen );
*
******************************************************************************
*/
static void st25r3916comTxByte( uint8_t txByte, bool last, bool txOnly );
static void st25r3916comTxByte(uint8_t txByte, bool last, bool txOnly);
/*
******************************************************************************
* LOCAL FUNCTION
******************************************************************************
*/
static void st25r3916comStart( void )
{
static void st25r3916comStart(void) {
/* Make this operation atomic, disabling ST25R3916 interrupt during communications*/
platformProtectST25RComm();
#ifdef RFAL_USE_I2C
/* I2C Start and send Slave Address */
st25r3916I2CStart();
st25r3916I2CSlaveAddrWR( ST25R3916_I2C_ADDR );
st25r3916I2CSlaveAddrWR(ST25R3916_I2C_ADDR);
#else
/* Perform the chip select */
platformSpiSelect();
#if defined(ST25R_COM_SINGLETXRX)
comBufIt = 0; /* reset local buffer position */
#endif /* ST25R_COM_SINGLETXRX */
#if defined(ST25R_COM_SINGLETXRX)
comBufIt = 0; /* reset local buffer position */
#endif /* ST25R_COM_SINGLETXRX */
#endif /* RFAL_USE_I2C */
}
/*******************************************************************************/
static void st25r3916comStop( void )
{
static void st25r3916comStop(void) {
#ifdef RFAL_USE_I2C
/* Generate Stop signal */
st25r3916I2CStop();
@@ -214,83 +227,95 @@ static void st25r3916comStop( void )
/* Release the chip select */
platformSpiDeselect();
#endif /* RFAL_USE_I2C */
/* reEnable the ST25R3916 interrupt */
platformUnprotectST25RComm();
}
/*******************************************************************************/
#ifdef RFAL_USE_I2C
static void st25r3916comRepeatStart( void )
{
static void st25r3916comRepeatStart(void) {
st25r3916I2CRepeatStart();
st25r3916I2CSlaveAddrRD( ST25R3916_I2C_ADDR );
st25r3916I2CSlaveAddrRD(ST25R3916_I2C_ADDR);
}
#endif /* RFAL_USE_I2C */
/*******************************************************************************/
static void st25r3916comTx( const uint8_t* txBuf, uint16_t txLen, bool last, bool txOnly )
{
static void st25r3916comTx(const uint8_t* txBuf, uint16_t txLen, bool last, bool txOnly) {
NO_WARNING(last);
NO_WARNING(txOnly);
if( txLen > 0U )
{
#ifdef RFAL_USE_I2C
platformI2CTx( txBuf, txLen, last, txOnly );
#else /* RFAL_USE_I2C */
#ifdef ST25R_COM_SINGLETXRX
ST_MEMCPY( &comBuf[comBufIt], txBuf, MIN( txLen, (ST25R3916_BUF_LEN - comBufIt) ) ); /* copy tx data to local buffer */
comBufIt += MIN( txLen, (ST25R3916_BUF_LEN - comBufIt) ); /* store position on local buffer */
if( last && txOnly ) /* only perform SPI transaction if no Rx will follow */
{
platformSpiTxRx( comBuf, NULL, comBufIt );
}
#else
platformSpiTxRx( txBuf, NULL, txLen );
#endif /* ST25R_COM_SINGLETXRX */
#endif /* RFAL_USE_I2C */
}
}
/*******************************************************************************/
static void st25r3916comRx( uint8_t* rxBuf, uint16_t rxLen )
{
if( rxLen > 0U )
{
if(txLen > 0U) {
#ifdef RFAL_USE_I2C
platformI2CRx( rxBuf, rxLen );
platformI2CTx(txBuf, txLen, last, txOnly);
#else /* RFAL_USE_I2C */
#ifdef ST25R_COM_SINGLETXRX
ST_MEMSET( &comBuf[comBufIt], 0x00, MIN( rxLen, (ST25R3916_BUF_LEN - comBufIt) ) ); /* clear outgoing buffer */
platformSpiTxRx( comBuf, comBuf, MIN( (comBufIt + rxLen), ST25R3916_BUF_LEN ) ); /* transceive as a single SPI call */
ST_MEMCPY( rxBuf, &comBuf[comBufIt], MIN( rxLen, (ST25R3916_BUF_LEN - comBufIt) ) ); /* copy from local buf to output buffer and skip cmd byte */
#else
if( rxBuf != NULL)
#ifdef ST25R_COM_SINGLETXRX
ST_MEMCPY(
&comBuf[comBufIt],
txBuf,
MIN(txLen,
(ST25R3916_BUF_LEN -
comBufIt))); /* copy tx data to local buffer */
comBufIt +=
MIN(txLen,
(ST25R3916_BUF_LEN -
comBufIt)); /* store position on local buffer */
if(last && txOnly) /* only perform SPI transaction if no Rx will follow */
{
ST_MEMSET( rxBuf, 0x00, rxLen ); /* clear outgoing buffer */
platformSpiTxRx(comBuf, NULL, comBufIt);
}
platformSpiTxRx( NULL, rxBuf, rxLen );
#endif /* ST25R_COM_SINGLETXRX */
#else
platformSpiTxRx(txBuf, NULL, txLen);
#endif /* ST25R_COM_SINGLETXRX */
#endif /* RFAL_USE_I2C */
}
}
/*******************************************************************************/
static void st25r3916comRx(uint8_t* rxBuf, uint16_t rxLen) {
if(rxLen > 0U) {
#ifdef RFAL_USE_I2C
platformI2CRx(rxBuf, rxLen);
#else /* RFAL_USE_I2C */
#ifdef ST25R_COM_SINGLETXRX
ST_MEMSET(
&comBuf[comBufIt],
0x00,
MIN(rxLen,
(ST25R3916_BUF_LEN -
comBufIt))); /* clear outgoing buffer */
platformSpiTxRx(
comBuf,
comBuf,
MIN((comBufIt + rxLen),
ST25R3916_BUF_LEN)); /* transceive as a single SPI call */
ST_MEMCPY(
rxBuf,
&comBuf[comBufIt],
MIN(rxLen,
(ST25R3916_BUF_LEN -
comBufIt))); /* copy from local buf to output buffer and skip cmd byte */
#else
if(rxBuf != NULL) {
ST_MEMSET(
rxBuf, 0x00, rxLen); /* clear outgoing buffer */
}
platformSpiTxRx(NULL, rxBuf, rxLen);
#endif /* ST25R_COM_SINGLETXRX */
#endif /* RFAL_USE_I2C */
}
}
/*******************************************************************************/
static void st25r3916comTxByte( uint8_t txByte, bool last, bool txOnly )
{
uint8_t val = txByte; /* MISRA 17.8: use intermediate variable */
st25r3916comTx( &val, ST25R3916_REG_LEN, last, txOnly );
static void st25r3916comTxByte(uint8_t txByte, bool last, bool txOnly) {
uint8_t val = txByte; /* MISRA 17.8: use intermediate variable */
st25r3916comTx(&val, ST25R3916_REG_LEN, last, txOnly);
}
/*
@@ -300,350 +325,293 @@ static void st25r3916comTxByte( uint8_t txByte, bool last, bool txOnly )
*/
/*******************************************************************************/
ReturnCode st25r3916ReadRegister( uint8_t reg, uint8_t* val )
{
return st25r3916ReadMultipleRegisters( reg, val, ST25R3916_REG_LEN );
ReturnCode st25r3916ReadRegister(uint8_t reg, uint8_t* val) {
return st25r3916ReadMultipleRegisters(reg, val, ST25R3916_REG_LEN);
}
/*******************************************************************************/
ReturnCode st25r3916ReadMultipleRegisters( uint8_t reg, uint8_t* values, uint8_t length )
{
if( length > 0U )
{
ReturnCode st25r3916ReadMultipleRegisters(uint8_t reg, uint8_t* values, uint8_t length) {
if(length > 0U) {
st25r3916comStart();
/* If is a space-B register send a direct command first */
if( (reg & ST25R3916_SPACE_B) != 0U )
{
st25r3916comTxByte( ST25R3916_CMD_SPACE_B_ACCESS, false, false );
if((reg & ST25R3916_SPACE_B) != 0U) {
st25r3916comTxByte(ST25R3916_CMD_SPACE_B_ACCESS, false, false);
}
st25r3916comTxByte( ((reg & ~ST25R3916_SPACE_B) | ST25R3916_READ_MODE), true, false );
st25r3916comTxByte(((reg & ~ST25R3916_SPACE_B) | ST25R3916_READ_MODE), true, false);
st25r3916comRepeatStart();
st25r3916comRx( values, length );
st25r3916comRx(values, length);
st25r3916comStop();
}
return ERR_NONE;
}
/*******************************************************************************/
ReturnCode st25r3916WriteRegister( uint8_t reg, uint8_t val )
{
uint8_t value = val; /* MISRA 17.8: use intermediate variable */
return st25r3916WriteMultipleRegisters( reg, &value, ST25R3916_REG_LEN );
ReturnCode st25r3916WriteRegister(uint8_t reg, uint8_t val) {
uint8_t value = val; /* MISRA 17.8: use intermediate variable */
return st25r3916WriteMultipleRegisters(reg, &value, ST25R3916_REG_LEN);
}
/*******************************************************************************/
ReturnCode st25r3916WriteMultipleRegisters( uint8_t reg, const uint8_t* values, uint8_t length )
{
if( length > 0U )
{
ReturnCode st25r3916WriteMultipleRegisters(uint8_t reg, const uint8_t* values, uint8_t length) {
if(length > 0U) {
st25r3916comStart();
if( (reg & ST25R3916_SPACE_B) != 0U )
{
st25r3916comTxByte( ST25R3916_CMD_SPACE_B_ACCESS, false, true );
if((reg & ST25R3916_SPACE_B) != 0U) {
st25r3916comTxByte(ST25R3916_CMD_SPACE_B_ACCESS, false, true);
}
st25r3916comTxByte( ((reg & ~ST25R3916_SPACE_B) | ST25R3916_WRITE_MODE), false, true );
st25r3916comTx( values, length, true, true );
st25r3916comTxByte(((reg & ~ST25R3916_SPACE_B) | ST25R3916_WRITE_MODE), false, true);
st25r3916comTx(values, length, true, true);
st25r3916comStop();
/* Send a WriteMultiReg event to LED handling */
st25r3916ledEvtWrMultiReg( reg, values, length);
st25r3916ledEvtWrMultiReg(reg, values, length);
}
return ERR_NONE;
}
/*******************************************************************************/
ReturnCode st25r3916WriteFifo( const uint8_t* values, uint16_t length )
{
if( length > ST25R3916_FIFO_DEPTH )
{
ReturnCode st25r3916WriteFifo(const uint8_t* values, uint16_t length) {
if(length > ST25R3916_FIFO_DEPTH) {
return ERR_PARAM;
}
if( length > 0U )
{
if(length > 0U) {
st25r3916comStart();
st25r3916comTxByte( ST25R3916_FIFO_LOAD, false, true );
st25r3916comTx( values, length, true, true );
st25r3916comTxByte(ST25R3916_FIFO_LOAD, false, true);
st25r3916comTx(values, length, true, true);
st25r3916comStop();
}
return ERR_NONE;
}
/*******************************************************************************/
ReturnCode st25r3916ReadFifo( uint8_t* buf, uint16_t length )
{
if( length > 0U )
{
ReturnCode st25r3916ReadFifo(uint8_t* buf, uint16_t length) {
if(length > 0U) {
st25r3916comStart();
st25r3916comTxByte( ST25R3916_FIFO_READ, true, false );
st25r3916comTxByte(ST25R3916_FIFO_READ, true, false);
st25r3916comRepeatStart();
st25r3916comRx( buf, length );
st25r3916comRx(buf, length);
st25r3916comStop();
}
return ERR_NONE;
}
/*******************************************************************************/
ReturnCode st25r3916WritePTMem( const uint8_t* values, uint16_t length )
{
if( length > ST25R3916_PTM_LEN )
{
ReturnCode st25r3916WritePTMem(const uint8_t* values, uint16_t length) {
if(length > ST25R3916_PTM_LEN) {
return ERR_PARAM;
}
if( length > 0U )
{
if(length > 0U) {
st25r3916comStart();
st25r3916comTxByte( ST25R3916_PT_A_CONFIG_LOAD, false, true );
st25r3916comTx( values, length, true, true );
st25r3916comTxByte(ST25R3916_PT_A_CONFIG_LOAD, false, true);
st25r3916comTx(values, length, true, true);
st25r3916comStop();
}
return ERR_NONE;
}
/*******************************************************************************/
ReturnCode st25r3916ReadPTMem( uint8_t* values, uint16_t length )
{
uint8_t tmp[ST25R3916_REG_LEN + ST25R3916_PTM_LEN]; /* local buffer to handle prepended byte on I2C and SPI */
if( length > 0U )
{
if( length > ST25R3916_PTM_LEN )
{
ReturnCode st25r3916ReadPTMem(uint8_t* values, uint16_t length) {
uint8_t
tmp[ST25R3916_REG_LEN +
ST25R3916_PTM_LEN]; /* local buffer to handle prepended byte on I2C and SPI */
if(length > 0U) {
if(length > ST25R3916_PTM_LEN) {
return ERR_PARAM;
}
st25r3916comStart();
st25r3916comTxByte( ST25R3916_PT_MEM_READ, true, false );
st25r3916comTxByte(ST25R3916_PT_MEM_READ, true, false);
st25r3916comRepeatStart();
st25r3916comRx( tmp, (ST25R3916_REG_LEN + length) ); /* skip prepended byte */
st25r3916comRx(tmp, (ST25R3916_REG_LEN + length)); /* skip prepended byte */
st25r3916comStop();
/* Copy PTMem content without prepended byte */
ST_MEMCPY( values, (tmp+ST25R3916_REG_LEN), length );
ST_MEMCPY(values, (tmp + ST25R3916_REG_LEN), length);
}
return ERR_NONE;
}
/*******************************************************************************/
ReturnCode st25r3916WritePTMemF( const uint8_t* values, uint16_t length )
{
if( length > (ST25R3916_PTM_F_LEN + ST25R3916_PTM_TSN_LEN) )
{
ReturnCode st25r3916WritePTMemF(const uint8_t* values, uint16_t length) {
if(length > (ST25R3916_PTM_F_LEN + ST25R3916_PTM_TSN_LEN)) {
return ERR_PARAM;
}
if( length > 0U )
{
if(length > 0U) {
st25r3916comStart();
st25r3916comTxByte( ST25R3916_PT_F_CONFIG_LOAD, false, true );
st25r3916comTx( values, length, true, true );
st25r3916comTxByte(ST25R3916_PT_F_CONFIG_LOAD, false, true);
st25r3916comTx(values, length, true, true);
st25r3916comStop();
}
return ERR_NONE;
}
/*******************************************************************************/
ReturnCode st25r3916WritePTMemTSN( const uint8_t* values, uint16_t length )
{
if( length > ST25R3916_PTM_TSN_LEN )
{
ReturnCode st25r3916WritePTMemTSN(const uint8_t* values, uint16_t length) {
if(length > ST25R3916_PTM_TSN_LEN) {
return ERR_PARAM;
}
if(length > 0U)
{
if(length > 0U) {
st25r3916comStart();
st25r3916comTxByte( ST25R3916_PT_TSN_DATA_LOAD, false, true );
st25r3916comTx( values, length, true, true );
st25r3916comTxByte(ST25R3916_PT_TSN_DATA_LOAD, false, true);
st25r3916comTx(values, length, true, true);
st25r3916comStop();
}
return ERR_NONE;
}
/*******************************************************************************/
ReturnCode st25r3916ExecuteCommand( uint8_t cmd )
{
ReturnCode st25r3916ExecuteCommand(uint8_t cmd) {
st25r3916comStart();
st25r3916comTxByte( (cmd | ST25R3916_CMD_MODE ), true, true );
st25r3916comTxByte((cmd | ST25R3916_CMD_MODE), true, true);
st25r3916comStop();
/* Send a cmd event to LED handling */
st25r3916ledEvtCmd(cmd);
return ERR_NONE;
}
/*******************************************************************************/
ReturnCode st25r3916ReadTestRegister( uint8_t reg, uint8_t* val )
{
ReturnCode st25r3916ReadTestRegister(uint8_t reg, uint8_t* val) {
st25r3916comStart();
st25r3916comTxByte( ST25R3916_CMD_TEST_ACCESS, false, false );
st25r3916comTxByte( (reg | ST25R3916_READ_MODE), true, false );
st25r3916comTxByte(ST25R3916_CMD_TEST_ACCESS, false, false);
st25r3916comTxByte((reg | ST25R3916_READ_MODE), true, false);
st25r3916comRepeatStart();
st25r3916comRx( val, ST25R3916_REG_LEN );
st25r3916comRx(val, ST25R3916_REG_LEN);
st25r3916comStop();
return ERR_NONE;
}
/*******************************************************************************/
ReturnCode st25r3916WriteTestRegister( uint8_t reg, uint8_t val )
{
uint8_t value = val; /* MISRA 17.8: use intermediate variable */
ReturnCode st25r3916WriteTestRegister(uint8_t reg, uint8_t val) {
uint8_t value = val; /* MISRA 17.8: use intermediate variable */
st25r3916comStart();
st25r3916comTxByte( ST25R3916_CMD_TEST_ACCESS, false, true );
st25r3916comTxByte( (reg | ST25R3916_WRITE_MODE), false, true );
st25r3916comTx( &value, ST25R3916_REG_LEN, true, true );
st25r3916comTxByte(ST25R3916_CMD_TEST_ACCESS, false, true);
st25r3916comTxByte((reg | ST25R3916_WRITE_MODE), false, true);
st25r3916comTx(&value, ST25R3916_REG_LEN, true, true);
st25r3916comStop();
return ERR_NONE;
}
/*******************************************************************************/
ReturnCode st25r3916ClrRegisterBits( uint8_t reg, uint8_t clr_mask )
{
ReturnCode st25r3916ClrRegisterBits(uint8_t reg, uint8_t clr_mask) {
ReturnCode ret;
uint8_t rdVal;
uint8_t rdVal;
/* Read current reg value */
EXIT_ON_ERR( ret, st25r3916ReadRegister(reg, &rdVal) );
EXIT_ON_ERR(ret, st25r3916ReadRegister(reg, &rdVal));
/* Only perform a Write if value to be written is different */
if( ST25R3916_OPTIMIZE && (rdVal == (uint8_t)(rdVal & ~clr_mask)) )
{
if(ST25R3916_OPTIMIZE && (rdVal == (uint8_t)(rdVal & ~clr_mask))) {
return ERR_NONE;
}
/* Write new reg value */
return st25r3916WriteRegister(reg, (uint8_t)(rdVal & ~clr_mask) );
return st25r3916WriteRegister(reg, (uint8_t)(rdVal & ~clr_mask));
}
/*******************************************************************************/
ReturnCode st25r3916SetRegisterBits( uint8_t reg, uint8_t set_mask )
{
ReturnCode st25r3916SetRegisterBits(uint8_t reg, uint8_t set_mask) {
ReturnCode ret;
uint8_t rdVal;
uint8_t rdVal;
/* Read current reg value */
EXIT_ON_ERR( ret, st25r3916ReadRegister(reg, &rdVal) );
EXIT_ON_ERR(ret, st25r3916ReadRegister(reg, &rdVal));
/* Only perform a Write if the value to be written is different */
if( ST25R3916_OPTIMIZE && (rdVal == (rdVal | set_mask)) )
{
if(ST25R3916_OPTIMIZE && (rdVal == (rdVal | set_mask))) {
return ERR_NONE;
}
/* Write new reg value */
return st25r3916WriteRegister(reg, (rdVal | set_mask) );
return st25r3916WriteRegister(reg, (rdVal | set_mask));
}
/*******************************************************************************/
ReturnCode st25r3916ChangeRegisterBits( uint8_t reg, uint8_t valueMask, uint8_t value )
{
return st25r3916ModifyRegister(reg, valueMask, (valueMask & value) );
ReturnCode st25r3916ChangeRegisterBits(uint8_t reg, uint8_t valueMask, uint8_t value) {
return st25r3916ModifyRegister(reg, valueMask, (valueMask & value));
}
/*******************************************************************************/
ReturnCode st25r3916ModifyRegister( uint8_t reg, uint8_t clr_mask, uint8_t set_mask )
{
ReturnCode st25r3916ModifyRegister(uint8_t reg, uint8_t clr_mask, uint8_t set_mask) {
ReturnCode ret;
uint8_t rdVal;
uint8_t wrVal;
uint8_t rdVal;
uint8_t wrVal;
/* Read current reg value */
EXIT_ON_ERR( ret, st25r3916ReadRegister(reg, &rdVal) );
EXIT_ON_ERR(ret, st25r3916ReadRegister(reg, &rdVal));
/* Compute new value */
wrVal = (uint8_t)(rdVal & ~clr_mask);
wrVal = (uint8_t)(rdVal & ~clr_mask);
wrVal |= set_mask;
/* Only perform a Write if the value to be written is different */
if( ST25R3916_OPTIMIZE && (rdVal == wrVal) )
{
if(ST25R3916_OPTIMIZE && (rdVal == wrVal)) {
return ERR_NONE;
}
/* Write new reg value */
return st25r3916WriteRegister(reg, wrVal );
return st25r3916WriteRegister(reg, wrVal);
}
/*******************************************************************************/
ReturnCode st25r3916ChangeTestRegisterBits( uint8_t reg, uint8_t valueMask, uint8_t value )
{
ReturnCode st25r3916ChangeTestRegisterBits(uint8_t reg, uint8_t valueMask, uint8_t value) {
ReturnCode ret;
uint8_t rdVal;
uint8_t wrVal;
uint8_t rdVal;
uint8_t wrVal;
/* Read current reg value */
EXIT_ON_ERR( ret, st25r3916ReadTestRegister(reg, &rdVal) );
EXIT_ON_ERR(ret, st25r3916ReadTestRegister(reg, &rdVal));
/* Compute new value */
wrVal = (uint8_t)(rdVal & ~valueMask);
wrVal = (uint8_t)(rdVal & ~valueMask);
wrVal |= (uint8_t)(value & valueMask);
/* Only perform a Write if the value to be written is different */
if( ST25R3916_OPTIMIZE && (rdVal == wrVal) )
{
if(ST25R3916_OPTIMIZE && (rdVal == wrVal)) {
return ERR_NONE;
}
/* Write new reg value */
return st25r3916WriteTestRegister(reg, wrVal );
return st25r3916WriteTestRegister(reg, wrVal);
}
/*******************************************************************************/
bool st25r3916CheckReg( uint8_t reg, uint8_t mask, uint8_t val )
{
bool st25r3916CheckReg(uint8_t reg, uint8_t mask, uint8_t val) {
uint8_t regVal;
regVal = 0;
st25r3916ReadRegister( reg, &regVal );
return ( (regVal & mask) == val );
st25r3916ReadRegister(reg, &regVal);
return ((regVal & mask) == val);
}
/*******************************************************************************/
bool st25r3916IsRegValid( uint8_t reg )
{
if( !(( (int16_t)reg >= (int16_t)ST25R3916_REG_IO_CONF1) && (reg <= (ST25R3916_SPACE_B | ST25R3916_REG_IC_IDENTITY)) ))
{
bool st25r3916IsRegValid(uint8_t reg) {
if(!(((int16_t)reg >= (int16_t)ST25R3916_REG_IO_CONF1) &&
(reg <= (ST25R3916_SPACE_B | ST25R3916_REG_IC_IDENTITY)))) {
return false;
}
}
return true;
}

1776
lib/ST25RFAL002/source/st25r3916/st25r3916_com.h Executable file → Normal file

File diff suppressed because it is too large Load Diff

167
lib/ST25RFAL002/source/st25r3916/st25r3916_irq.c Executable file → Normal file
View File

@@ -20,7 +20,6 @@
*
******************************************************************************/
/*
* PROJECT: ST25R3916 firmware
* Revision:
@@ -54,15 +53,13 @@
*/
/*! Holds current and previous interrupt callback pointer as well as current Interrupt status and mask */
typedef struct
{
void (*prevCallback)(void); /*!< call back function for ST25R3916 interrupt */
void (*callback)(void); /*!< call back function for ST25R3916 interrupt */
uint32_t status; /*!< latest interrupt status */
uint32_t mask; /*!< Interrupt mask. Negative mask = ST25R3916 mask regs */
typedef struct {
void (*prevCallback)(void); /*!< call back function for ST25R3916 interrupt */
void (*callback)(void); /*!< call back function for ST25R3916 interrupt */
uint32_t status; /*!< latest interrupt status */
uint32_t mask; /*!< Interrupt mask. Negative mask = ST25R3916 mask regs */
} st25r3916Interrupt;
/*
******************************************************************************
* GLOBAL DEFINES
@@ -70,7 +67,7 @@ typedef struct
*/
/*! Length of the interrupt registers */
#define ST25R3916_INT_REGS_LEN ( (ST25R3916_REG_IRQ_TARGET - ST25R3916_REG_IRQ_MAIN) + 1U )
#define ST25R3916_INT_REGS_LEN ((ST25R3916_REG_IRQ_TARGET - ST25R3916_REG_IRQ_MAIN) + 1U)
/*
******************************************************************************
@@ -78,131 +75,113 @@ typedef struct
******************************************************************************
*/
static volatile st25r3916Interrupt st25r3916interrupt; /*!< Instance of ST25R3916 interrupt */
static volatile st25r3916Interrupt st25r3916interrupt; /*!< Instance of ST25R3916 interrupt */
/*
******************************************************************************
* GLOBAL FUNCTIONS
******************************************************************************
*/
void st25r3916InitInterrupts( void )
{
void st25r3916InitInterrupts(void) {
platformIrqST25RPinInitialize();
platformIrqST25RSetCallback( st25r3916Isr );
st25r3916interrupt.callback = NULL;
platformIrqST25RSetCallback(st25r3916Isr);
st25r3916interrupt.callback = NULL;
st25r3916interrupt.prevCallback = NULL;
st25r3916interrupt.status = ST25R3916_IRQ_MASK_NONE;
st25r3916interrupt.mask = ST25R3916_IRQ_MASK_NONE;
st25r3916interrupt.status = ST25R3916_IRQ_MASK_NONE;
st25r3916interrupt.mask = ST25R3916_IRQ_MASK_NONE;
}
/*******************************************************************************/
void st25r3916Isr( void )
{
void st25r3916Isr(void) {
st25r3916CheckForReceivedInterrupts();
// Check if callback is set and run it
if( NULL != st25r3916interrupt.callback )
{
if(NULL != st25r3916interrupt.callback) {
st25r3916interrupt.callback();
}
}
/*******************************************************************************/
void st25r3916CheckForReceivedInterrupts( void )
{
uint8_t iregs[ST25R3916_INT_REGS_LEN];
void st25r3916CheckForReceivedInterrupts(void) {
uint8_t iregs[ST25R3916_INT_REGS_LEN];
uint32_t irqStatus;
/* Initialize iregs */
irqStatus = ST25R3916_IRQ_MASK_NONE;
ST_MEMSET( iregs, (int32_t)(ST25R3916_IRQ_MASK_ALL & 0xFFU), ST25R3916_INT_REGS_LEN );
ST_MEMSET(iregs, (int32_t)(ST25R3916_IRQ_MASK_ALL & 0xFFU), ST25R3916_INT_REGS_LEN);
/* In case the IRQ is Edge (not Level) triggered read IRQs until done */
while( platformGpioIsHigh( ST25R_INT_PORT, ST25R_INT_PIN ) )
{
st25r3916ReadMultipleRegisters( ST25R3916_REG_IRQ_MAIN, iregs, ST25R3916_INT_REGS_LEN );
irqStatus |= (uint32_t)iregs[0];
irqStatus |= (uint32_t)iregs[1]<<8;
irqStatus |= (uint32_t)iregs[2]<<16;
irqStatus |= (uint32_t)iregs[3]<<24;
}
/* Forward all interrupts, even masked ones to application */
platformProtectST25RIrqStatus();
st25r3916interrupt.status |= irqStatus;
platformUnprotectST25RIrqStatus();
/* Send an IRQ event to LED handling */
st25r3916ledEvtIrq( st25r3916interrupt.status );
while(platformGpioIsHigh(ST25R_INT_PORT, ST25R_INT_PIN)) {
st25r3916ReadMultipleRegisters(ST25R3916_REG_IRQ_MAIN, iregs, ST25R3916_INT_REGS_LEN);
irqStatus |= (uint32_t)iregs[0];
irqStatus |= (uint32_t)iregs[1] << 8;
irqStatus |= (uint32_t)iregs[2] << 16;
irqStatus |= (uint32_t)iregs[3] << 24;
}
/* Forward all interrupts, even masked ones to application */
platformProtectST25RIrqStatus();
st25r3916interrupt.status |= irqStatus;
platformUnprotectST25RIrqStatus();
/* Send an IRQ event to LED handling */
st25r3916ledEvtIrq(st25r3916interrupt.status);
}
/*******************************************************************************/
void st25r3916ModifyInterrupts(uint32_t clr_mask, uint32_t set_mask)
{
uint8_t i;
void st25r3916ModifyInterrupts(uint32_t clr_mask, uint32_t set_mask) {
uint8_t i;
uint32_t old_mask;
uint32_t new_mask;
old_mask = st25r3916interrupt.mask;
new_mask = ((~old_mask & set_mask) | (old_mask & clr_mask));
st25r3916interrupt.mask &= ~clr_mask;
st25r3916interrupt.mask |= set_mask;
for(i=0; i<ST25R3916_INT_REGS_LEN; i++)
{
if( ((new_mask >> (8U*i)) & 0xFFU) == 0U )
{
for(i = 0; i < ST25R3916_INT_REGS_LEN; i++) {
if(((new_mask >> (8U * i)) & 0xFFU) == 0U) {
continue;
}
st25r3916WriteRegister(ST25R3916_REG_IRQ_MASK_MAIN + i, (uint8_t)((st25r3916interrupt.mask>>(8U*i)) & 0xFFU) );
st25r3916WriteRegister(
ST25R3916_REG_IRQ_MASK_MAIN + i,
(uint8_t)((st25r3916interrupt.mask >> (8U * i)) & 0xFFU));
}
return;
}
/*******************************************************************************/
uint32_t st25r3916WaitForInterruptsTimed( uint32_t mask, uint16_t tmo )
{
uint32_t st25r3916WaitForInterruptsTimed(uint32_t mask, uint16_t tmo) {
uint32_t tmrDelay;
uint32_t status;
tmrDelay = platformTimerCreate( tmo );
tmrDelay = platformTimerCreate(tmo);
/* Run until specific interrupt has happen or the timer has expired */
do
{
do {
status = (st25r3916interrupt.status & mask);
} while( ( !platformTimerIsExpired( tmrDelay ) || (tmo == 0U)) && (status == 0U) );
platformTimerDestroy( tmrDelay );
} while((!platformTimerIsExpired(tmrDelay) || (tmo == 0U)) && (status == 0U));
platformTimerDestroy(tmrDelay);
status = st25r3916interrupt.status & mask;
platformProtectST25RIrqStatus();
st25r3916interrupt.status &= ~status;
platformUnprotectST25RIrqStatus();
return status;
}
/*******************************************************************************/
uint32_t st25r3916GetInterrupt( uint32_t mask )
{
uint32_t st25r3916GetInterrupt(uint32_t mask) {
uint32_t irqs;
irqs = (st25r3916interrupt.status & mask);
if(irqs != ST25R3916_IRQ_MASK_NONE)
{
if(irqs != ST25R3916_IRQ_MASK_NONE) {
platformProtectST25RIrqStatus();
st25r3916interrupt.status &= ~irqs;
platformUnprotectST25RIrqStatus();
@@ -211,31 +190,24 @@ uint32_t st25r3916GetInterrupt( uint32_t mask )
return irqs;
}
/*******************************************************************************/
void st25r3916ClearAndEnableInterrupts( uint32_t mask )
{
st25r3916GetInterrupt( mask );
st25r3916EnableInterrupts( mask );
void st25r3916ClearAndEnableInterrupts(uint32_t mask) {
st25r3916GetInterrupt(mask);
st25r3916EnableInterrupts(mask);
}
/*******************************************************************************/
void st25r3916EnableInterrupts(uint32_t mask)
{
void st25r3916EnableInterrupts(uint32_t mask) {
st25r3916ModifyInterrupts(mask, 0);
}
/*******************************************************************************/
void st25r3916DisableInterrupts(uint32_t mask)
{
void st25r3916DisableInterrupts(uint32_t mask) {
st25r3916ModifyInterrupts(0, mask);
}
/*******************************************************************************/
void st25r3916ClearInterrupts( void )
{
void st25r3916ClearInterrupts(void) {
uint8_t iregs[ST25R3916_INT_REGS_LEN];
st25r3916ReadMultipleRegisters(ST25R3916_REG_IRQ_MAIN, iregs, ST25R3916_INT_REGS_LEN);
@@ -247,16 +219,13 @@ void st25r3916ClearInterrupts( void )
}
/*******************************************************************************/
void st25r3916IRQCallbackSet( void (*cb)(void) )
{
void st25r3916IRQCallbackSet(void (*cb)(void)) {
st25r3916interrupt.prevCallback = st25r3916interrupt.callback;
st25r3916interrupt.callback = cb;
st25r3916interrupt.callback = cb;
}
/*******************************************************************************/
void st25r3916IRQCallbackRestore( void )
{
st25r3916interrupt.callback = st25r3916interrupt.prevCallback;
void st25r3916IRQCallbackRestore(void) {
st25r3916interrupt.callback = st25r3916interrupt.prevCallback;
st25r3916interrupt.prevCallback = NULL;
}

128
lib/ST25RFAL002/source/st25r3916/st25r3916_irq.h Executable file → Normal file
View File

@@ -20,7 +20,6 @@
*
******************************************************************************/
/*
* PROJECT: ST25R3916 firmware
* Revision:
@@ -67,48 +66,82 @@
******************************************************************************
*/
#define ST25R3916_IRQ_MASK_ALL (uint32_t)(0xFFFFFFFFUL) /*!< All ST25R3916 interrupt sources */
#define ST25R3916_IRQ_MASK_NONE (uint32_t)(0x00000000UL) /*!< No ST25R3916 interrupt source */
#define ST25R3916_IRQ_MASK_ALL \
(uint32_t)(0xFFFFFFFFUL) /*!< All ST25R3916 interrupt sources */
#define ST25R3916_IRQ_MASK_NONE \
(uint32_t)(0x00000000UL) /*!< No ST25R3916 interrupt source */
/* Main interrupt register */
#define ST25R3916_IRQ_MASK_OSC (uint32_t)(0x00000080U) /*!< ST25R3916 oscillator stable interrupt */
#define ST25R3916_IRQ_MASK_FWL (uint32_t)(0x00000040U) /*!< ST25R3916 FIFO water level interrupt */
#define ST25R3916_IRQ_MASK_RXS (uint32_t)(0x00000020U) /*!< ST25R3916 start of receive interrupt */
#define ST25R3916_IRQ_MASK_RXE (uint32_t)(0x00000010U) /*!< ST25R3916 end of receive interrupt */
#define ST25R3916_IRQ_MASK_TXE (uint32_t)(0x00000008U) /*!< ST25R3916 end of transmission interrupt */
#define ST25R3916_IRQ_MASK_COL (uint32_t)(0x00000004U) /*!< ST25R3916 bit collision interrupt */
#define ST25R3916_IRQ_MASK_RX_REST (uint32_t)(0x00000002U) /*!< ST25R3916 automatic reception restart interrupt */
#define ST25R3916_IRQ_MASK_RFU (uint32_t)(0x00000001U) /*!< ST25R3916 RFU interrupt */
#define ST25R3916_IRQ_MASK_OSC \
(uint32_t)(0x00000080U) /*!< ST25R3916 oscillator stable interrupt */
#define ST25R3916_IRQ_MASK_FWL \
(uint32_t)(0x00000040U) /*!< ST25R3916 FIFO water level interrupt */
#define ST25R3916_IRQ_MASK_RXS \
(uint32_t)(0x00000020U) /*!< ST25R3916 start of receive interrupt */
#define ST25R3916_IRQ_MASK_RXE \
(uint32_t)(0x00000010U) /*!< ST25R3916 end of receive interrupt */
#define ST25R3916_IRQ_MASK_TXE \
(uint32_t)(0x00000008U) /*!< ST25R3916 end of transmission interrupt */
#define ST25R3916_IRQ_MASK_COL \
(uint32_t)(0x00000004U) /*!< ST25R3916 bit collision interrupt */
#define ST25R3916_IRQ_MASK_RX_REST \
(uint32_t)(0x00000002U) /*!< ST25R3916 automatic reception restart interrupt */
#define ST25R3916_IRQ_MASK_RFU \
(uint32_t)(0x00000001U) /*!< ST25R3916 RFU interrupt */
/* Timer and NFC interrupt register */
#define ST25R3916_IRQ_MASK_DCT (uint32_t)(0x00008000U) /*!< ST25R3916 termination of direct command interrupt. */
#define ST25R3916_IRQ_MASK_NRE (uint32_t)(0x00004000U) /*!< ST25R3916 no-response timer expired interrupt */
#define ST25R3916_IRQ_MASK_GPE (uint32_t)(0x00002000U) /*!< ST25R3916 general purpose timer expired interrupt */
#define ST25R3916_IRQ_MASK_EON (uint32_t)(0x00001000U) /*!< ST25R3916 external field on interrupt */
#define ST25R3916_IRQ_MASK_EOF (uint32_t)(0x00000800U) /*!< ST25R3916 external field off interrupt */
#define ST25R3916_IRQ_MASK_CAC (uint32_t)(0x00000400U) /*!< ST25R3916 collision during RF collision avoidance interrupt */
#define ST25R3916_IRQ_MASK_CAT (uint32_t)(0x00000200U) /*!< ST25R3916 minimum guard time expired interrupt */
#define ST25R3916_IRQ_MASK_NFCT (uint32_t)(0x00000100U) /*!< ST25R3916 initiator bit rate recognised interrupt */
#define ST25R3916_IRQ_MASK_DCT \
(uint32_t)(0x00008000U) /*!< ST25R3916 termination of direct command interrupt. */
#define ST25R3916_IRQ_MASK_NRE \
(uint32_t)(0x00004000U) /*!< ST25R3916 no-response timer expired interrupt */
#define ST25R3916_IRQ_MASK_GPE \
(uint32_t)(0x00002000U) /*!< ST25R3916 general purpose timer expired interrupt */
#define ST25R3916_IRQ_MASK_EON \
(uint32_t)(0x00001000U) /*!< ST25R3916 external field on interrupt */
#define ST25R3916_IRQ_MASK_EOF \
(uint32_t)(0x00000800U) /*!< ST25R3916 external field off interrupt */
#define ST25R3916_IRQ_MASK_CAC \
(uint32_t)(0x00000400U) /*!< ST25R3916 collision during RF collision avoidance interrupt */
#define ST25R3916_IRQ_MASK_CAT \
(uint32_t)(0x00000200U) /*!< ST25R3916 minimum guard time expired interrupt */
#define ST25R3916_IRQ_MASK_NFCT \
(uint32_t)(0x00000100U) /*!< ST25R3916 initiator bit rate recognised interrupt */
/* Error and wake-up interrupt register */
#define ST25R3916_IRQ_MASK_CRC (uint32_t)(0x00800000U) /*!< ST25R3916 CRC error interrupt */
#define ST25R3916_IRQ_MASK_PAR (uint32_t)(0x00400000U) /*!< ST25R3916 parity error interrupt */
#define ST25R3916_IRQ_MASK_ERR2 (uint32_t)(0x00200000U) /*!< ST25R3916 soft framing error interrupt */
#define ST25R3916_IRQ_MASK_ERR1 (uint32_t)(0x00100000U) /*!< ST25R3916 hard framing error interrupt */
#define ST25R3916_IRQ_MASK_WT (uint32_t)(0x00080000U) /*!< ST25R3916 wake-up interrupt */
#define ST25R3916_IRQ_MASK_WAM (uint32_t)(0x00040000U) /*!< ST25R3916 wake-up due to amplitude interrupt */
#define ST25R3916_IRQ_MASK_WPH (uint32_t)(0x00020000U) /*!< ST25R3916 wake-up due to phase interrupt */
#define ST25R3916_IRQ_MASK_WCAP (uint32_t)(0x00010000U) /*!< ST25R3916 wake-up due to capacitance measurement */
#define ST25R3916_IRQ_MASK_CRC \
(uint32_t)(0x00800000U) /*!< ST25R3916 CRC error interrupt */
#define ST25R3916_IRQ_MASK_PAR \
(uint32_t)(0x00400000U) /*!< ST25R3916 parity error interrupt */
#define ST25R3916_IRQ_MASK_ERR2 \
(uint32_t)(0x00200000U) /*!< ST25R3916 soft framing error interrupt */
#define ST25R3916_IRQ_MASK_ERR1 \
(uint32_t)(0x00100000U) /*!< ST25R3916 hard framing error interrupt */
#define ST25R3916_IRQ_MASK_WT \
(uint32_t)(0x00080000U) /*!< ST25R3916 wake-up interrupt */
#define ST25R3916_IRQ_MASK_WAM \
(uint32_t)(0x00040000U) /*!< ST25R3916 wake-up due to amplitude interrupt */
#define ST25R3916_IRQ_MASK_WPH \
(uint32_t)(0x00020000U) /*!< ST25R3916 wake-up due to phase interrupt */
#define ST25R3916_IRQ_MASK_WCAP \
(uint32_t)(0x00010000U) /*!< ST25R3916 wake-up due to capacitance measurement */
/* Passive Target Interrupt Register */
#define ST25R3916_IRQ_MASK_PPON2 (uint32_t)(0x80000000U) /*!< ST25R3916 PPON2 Field on waiting Timer interrupt */
#define ST25R3916_IRQ_MASK_SL_WL (uint32_t)(0x40000000U) /*!< ST25R3916 Passive target slot number water level interrupt */
#define ST25R3916_IRQ_MASK_APON (uint32_t)(0x20000000U) /*!< ST25R3916 Anticollision done and Field On interrupt */
#define ST25R3916_IRQ_MASK_RXE_PTA (uint32_t)(0x10000000U) /*!< ST25R3916 RXE with an automatic response interrupt */
#define ST25R3916_IRQ_MASK_WU_F (uint32_t)(0x08000000U) /*!< ST25R3916 212/424b/s Passive target interrupt: Active */
#define ST25R3916_IRQ_MASK_RFU2 (uint32_t)(0x04000000U) /*!< ST25R3916 RFU2 interrupt */
#define ST25R3916_IRQ_MASK_WU_A_X (uint32_t)(0x02000000U) /*!< ST25R3916 106kb/s Passive target state interrupt: Active* */
#define ST25R3916_IRQ_MASK_WU_A (uint32_t)(0x01000000U) /*!< ST25R3916 106kb/s Passive target state interrupt: Active */
#define ST25R3916_IRQ_MASK_PPON2 \
(uint32_t)(0x80000000U) /*!< ST25R3916 PPON2 Field on waiting Timer interrupt */
#define ST25R3916_IRQ_MASK_SL_WL \
(uint32_t)(0x40000000U) /*!< ST25R3916 Passive target slot number water level interrupt */
#define ST25R3916_IRQ_MASK_APON \
(uint32_t)(0x20000000U) /*!< ST25R3916 Anticollision done and Field On interrupt */
#define ST25R3916_IRQ_MASK_RXE_PTA \
(uint32_t)(0x10000000U) /*!< ST25R3916 RXE with an automatic response interrupt */
#define ST25R3916_IRQ_MASK_WU_F \
(uint32_t)(0x08000000U) /*!< ST25R3916 212/424b/s Passive target interrupt: Active */
#define ST25R3916_IRQ_MASK_RFU2 \
(uint32_t)(0x04000000U) /*!< ST25R3916 RFU2 interrupt */
#define ST25R3916_IRQ_MASK_WU_A_X \
(uint32_t)(0x02000000U) /*!< ST25R3916 106kb/s Passive target state interrupt: Active* */
#define ST25R3916_IRQ_MASK_WU_A \
(uint32_t)(0x01000000U) /*!< ST25R3916 106kb/s Passive target state interrupt: Active */
/*
******************************************************************************
@@ -116,7 +149,6 @@
******************************************************************************
*/
/*!
*****************************************************************************
* \brief Wait until an ST25R3916 interrupt occurs
@@ -134,7 +166,7 @@
*
*****************************************************************************
*/
uint32_t st25r3916WaitForInterruptsTimed( uint32_t mask, uint16_t tmo );
uint32_t st25r3916WaitForInterruptsTimed(uint32_t mask, uint16_t tmo);
/*!
*****************************************************************************
@@ -150,7 +182,7 @@ uint32_t st25r3916WaitForInterruptsTimed( uint32_t mask, uint16_t tmo );
*
*****************************************************************************
*/
uint32_t st25r3916GetInterrupt( uint32_t mask );
uint32_t st25r3916GetInterrupt(uint32_t mask);
/*!
*****************************************************************************
@@ -161,7 +193,7 @@ uint32_t st25r3916GetInterrupt( uint32_t mask );
*
*****************************************************************************
*/
void st25r3916InitInterrupts( void );
void st25r3916InitInterrupts(void);
/*!
*****************************************************************************
@@ -173,7 +205,7 @@ void st25r3916InitInterrupts( void );
* \param[in] set_mask : bit mask to be set on the interrupt mask
*****************************************************************************
*/
void st25r3916ModifyInterrupts( uint32_t clr_mask, uint32_t set_mask );
void st25r3916ModifyInterrupts(uint32_t clr_mask, uint32_t set_mask);
/*!
*****************************************************************************
@@ -182,7 +214,7 @@ void st25r3916ModifyInterrupts( uint32_t clr_mask, uint32_t set_mask );
* Checks received interrupts and saves the result into global params
*****************************************************************************
*/
void st25r3916CheckForReceivedInterrupts( void );
void st25r3916CheckForReceivedInterrupts(void);
/*!
*****************************************************************************
@@ -191,7 +223,7 @@ void st25r3916CheckForReceivedInterrupts( void );
* This function modiefies the interupt
*****************************************************************************
*/
void st25r3916Isr( void );
void st25r3916Isr(void);
/*!
*****************************************************************************
@@ -204,7 +236,7 @@ void st25r3916Isr( void );
*
*****************************************************************************
*/
void st25r3916EnableInterrupts( uint32_t mask );
void st25r3916EnableInterrupts(uint32_t mask);
/*!
*****************************************************************************
@@ -216,7 +248,7 @@ void st25r3916EnableInterrupts( uint32_t mask );
*
*****************************************************************************
*/
void st25r3916DisableInterrupts( uint32_t mask );
void st25r3916DisableInterrupts(uint32_t mask);
/*!
*****************************************************************************
@@ -224,7 +256,7 @@ void st25r3916DisableInterrupts( uint32_t mask );
*
*****************************************************************************
*/
void st25r3916ClearInterrupts( void );
void st25r3916ClearInterrupts(void);
/*!
*****************************************************************************
@@ -233,7 +265,7 @@ void st25r3916ClearInterrupts( void );
* \param[in] mask: mask indicating the interrupts to be cleared and enabled
*****************************************************************************
*/
void st25r3916ClearAndEnableInterrupts( uint32_t mask );
void st25r3916ClearAndEnableInterrupts(uint32_t mask);
/*!
*****************************************************************************
@@ -241,7 +273,7 @@ void st25r3916ClearAndEnableInterrupts( uint32_t mask );
*
*****************************************************************************
*/
void st25r3916IRQCallbackSet( void (*cb)( void ) );
void st25r3916IRQCallbackSet(void (*cb)(void));
/*!
*****************************************************************************
@@ -249,7 +281,7 @@ void st25r3916IRQCallbackSet( void (*cb)( void ) );
*
*****************************************************************************
*/
void st25r3916IRQCallbackRestore( void );
void st25r3916IRQCallbackRestore(void);
#endif /* ST25R3916_IRQ_H */

99
lib/ST25RFAL002/source/st25r3916/st25r3916_led.c Executable file → Normal file
View File

@@ -20,7 +20,6 @@
*
******************************************************************************/
/*
* PROJECT: ST25R3916 firmware
* Revision:
@@ -46,7 +45,6 @@
#include "st25r3916_com.h"
#include "st25r3916.h"
/*
******************************************************************************
* MACROS
@@ -54,20 +52,31 @@
*/
#ifdef PLATFORM_LED_RX_PIN
#define st25r3916ledRxOn() platformLedOn( PLATFORM_LED_RX_PORT, PLATFORM_LED_RX_PIN ); /*!< LED Rx Pin On from system HAL */
#define st25r3916ledRxOff() platformLedOff( PLATFORM_LED_RX_PORT, PLATFORM_LED_RX_PIN ); /*!< LED Rx Pin Off from system HAL */
#define st25r3916ledRxOn() \
platformLedOn( \
PLATFORM_LED_RX_PORT, \
PLATFORM_LED_RX_PIN); /*!< LED Rx Pin On from system HAL */
#define st25r3916ledRxOff() \
platformLedOff( \
PLATFORM_LED_RX_PORT, \
PLATFORM_LED_RX_PIN); /*!< LED Rx Pin Off from system HAL */
#else /* PLATFORM_LED_RX_PIN */
#define st25r3916ledRxOn()
#define st25r3916ledRxOff()
#define st25r3916ledRxOn()
#define st25r3916ledRxOff()
#endif /* PLATFORM_LED_RX_PIN */
#ifdef PLATFORM_LED_FIELD_PIN
#define st25r3916ledFieldOn() platformLedOn( PLATFORM_LED_FIELD_PORT, PLATFORM_LED_FIELD_PIN ); /*!< LED Field Pin On from system HAL */
#define st25r3916ledFieldOff() platformLedOff( PLATFORM_LED_FIELD_PORT, PLATFORM_LED_FIELD_PIN ); /*!< LED Field Pin Off from system HAL */
#define st25r3916ledFieldOn() \
platformLedOn( \
PLATFORM_LED_FIELD_PORT, \
PLATFORM_LED_FIELD_PIN); /*!< LED Field Pin On from system HAL */
#define st25r3916ledFieldOff() \
platformLedOff( \
PLATFORM_LED_FIELD_PORT, \
PLATFORM_LED_FIELD_PIN); /*!< LED Field Pin Off from system HAL */
#else /* PLATFORM_LED_FIELD_PIN */
#define st25r3916ledFieldOn()
#define st25r3916ledFieldOff()
#define st25r3916ledFieldOn()
#define st25r3916ledFieldOff()
#endif /* PLATFORM_LED_FIELD_PIN */
/*
@@ -76,81 +85,63 @@
******************************************************************************
*/
void st25r3916ledInit( void )
{
void st25r3916ledInit(void) {
/* Initialize LEDs if existing and defined */
platformLedsInitialize();
st25r3916ledRxOff();
st25r3916ledFieldOff();
}
/*******************************************************************************/
void st25r3916ledEvtIrq( uint32_t irqs )
{
if( (irqs & (ST25R3916_IRQ_MASK_TXE | ST25R3916_IRQ_MASK_CAT) ) != 0U )
{
void st25r3916ledEvtIrq(uint32_t irqs) {
if((irqs & (ST25R3916_IRQ_MASK_TXE | ST25R3916_IRQ_MASK_CAT)) != 0U) {
st25r3916ledFieldOn();
}
if( (irqs & (ST25R3916_IRQ_MASK_RXS | ST25R3916_IRQ_MASK_NFCT) ) != 0U )
{
if((irqs & (ST25R3916_IRQ_MASK_RXS | ST25R3916_IRQ_MASK_NFCT)) != 0U) {
st25r3916ledRxOn();
}
if( (irqs & (ST25R3916_IRQ_MASK_RXE | ST25R3916_IRQ_MASK_NRE | ST25R3916_IRQ_MASK_RX_REST | ST25R3916_IRQ_MASK_RXE_PTA |
ST25R3916_IRQ_MASK_WU_A | ST25R3916_IRQ_MASK_WU_A_X | ST25R3916_IRQ_MASK_WU_F | ST25R3916_IRQ_MASK_RFU2) ) != 0U )
{
if((irqs & (ST25R3916_IRQ_MASK_RXE | ST25R3916_IRQ_MASK_NRE | ST25R3916_IRQ_MASK_RX_REST |
ST25R3916_IRQ_MASK_RXE_PTA | ST25R3916_IRQ_MASK_WU_A | ST25R3916_IRQ_MASK_WU_A_X |
ST25R3916_IRQ_MASK_WU_F | ST25R3916_IRQ_MASK_RFU2)) != 0U) {
st25r3916ledRxOff();
}
}
/*******************************************************************************/
void st25r3916ledEvtWrReg( uint8_t reg, uint8_t val )
{
if( reg == ST25R3916_REG_OP_CONTROL )
{
if( (ST25R3916_REG_OP_CONTROL_tx_en & val) != 0U )
{
void st25r3916ledEvtWrReg(uint8_t reg, uint8_t val) {
if(reg == ST25R3916_REG_OP_CONTROL) {
if((ST25R3916_REG_OP_CONTROL_tx_en & val) != 0U) {
st25r3916ledFieldOn();
}
else
{
} else {
st25r3916ledFieldOff();
}
}
}
/*******************************************************************************/
void st25r3916ledEvtWrMultiReg( uint8_t reg, const uint8_t* vals, uint8_t len )
{
void st25r3916ledEvtWrMultiReg(uint8_t reg, const uint8_t* vals, uint8_t len) {
uint8_t i;
for(i=0; i<(len); i++)
{
st25r3916ledEvtWrReg( (reg+i), vals[i] );
for(i = 0; i < (len); i++) {
st25r3916ledEvtWrReg((reg + i), vals[i]);
}
}
/*******************************************************************************/
void st25r3916ledEvtCmd( uint8_t cmd )
{
if( (cmd >= ST25R3916_CMD_TRANSMIT_WITH_CRC) && (cmd <= ST25R3916_CMD_RESPONSE_RF_COLLISION_N) )
{
void st25r3916ledEvtCmd(uint8_t cmd) {
if((cmd >= ST25R3916_CMD_TRANSMIT_WITH_CRC) &&
(cmd <= ST25R3916_CMD_RESPONSE_RF_COLLISION_N)) {
st25r3916ledFieldOff();
}
if( cmd == ST25R3916_CMD_UNMASK_RECEIVE_DATA )
{
if(cmd == ST25R3916_CMD_UNMASK_RECEIVE_DATA) {
st25r3916ledRxOff();
}
if( cmd == ST25R3916_CMD_SET_DEFAULT )
{
if(cmd == ST25R3916_CMD_SET_DEFAULT) {
st25r3916ledFieldOff();
st25r3916ledRxOff();
}

12
lib/ST25RFAL002/source/st25r3916/st25r3916_led.h Executable file → Normal file
View File

@@ -20,7 +20,6 @@
*
******************************************************************************/
/*
* PROJECT: ST25R3916 firmware
* Revision:
@@ -74,7 +73,6 @@
******************************************************************************
*/
/*!
*****************************************************************************
* \brief ST25R3916 LED Initialize
@@ -83,7 +81,7 @@
*
*****************************************************************************
*/
void st25r3916ledInit( void );
void st25r3916ledInit(void);
/*!
*****************************************************************************
@@ -96,7 +94,7 @@ void st25r3916ledInit( void );
*
*****************************************************************************
*/
void st25r3916ledEvtIrq( uint32_t irqs );
void st25r3916ledEvtIrq(uint32_t irqs);
/*!
*****************************************************************************
@@ -110,7 +108,7 @@ void st25r3916ledEvtIrq( uint32_t irqs );
*
*****************************************************************************
*/
void st25r3916ledEvtWrReg( uint8_t reg, uint8_t val );
void st25r3916ledEvtWrReg(uint8_t reg, uint8_t val);
/*!
*****************************************************************************
@@ -125,7 +123,7 @@ void st25r3916ledEvtWrReg( uint8_t reg, uint8_t val );
*
*****************************************************************************
*/
void st25r3916ledEvtWrMultiReg( uint8_t reg, const uint8_t* vals, uint8_t len );
void st25r3916ledEvtWrMultiReg(uint8_t reg, const uint8_t* vals, uint8_t len);
/*!
*****************************************************************************
@@ -138,7 +136,7 @@ void st25r3916ledEvtWrMultiReg( uint8_t reg, const uint8_t* vals, uint8_t len );
*
*****************************************************************************
*/
void st25r3916ledEvtCmd( uint8_t cmd );
void st25r3916ledEvtCmd(uint8_t cmd);
#endif /* ST25R3916_LED_H */