Skip to content

Commit

Permalink
chore(core): Align RFAL library with most relevant public version 3.0.1.
Browse files Browse the repository at this point in the history
  • Loading branch information
kopecdav committed Feb 11, 2025
1 parent 9a41feb commit 073bd6c
Show file tree
Hide file tree
Showing 4 changed files with 1,401 additions and 1,484 deletions.
2 changes: 1 addition & 1 deletion core/embed/io/nfc/rfal/LOCAL_CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

RFAL middleware was imported into trezor-firmware to support a low level NFC operations of st25r3916b from
https://www.st.com/en/embedded-software/stsw-st25r-lib.html#overview (version 1.7.0)
https://www.st.com/en/embedded-software/stsw-st25rfal002.html (version 3.0.1)

# Local changes

Expand Down
122 changes: 64 additions & 58 deletions core/embed/io/nfc/rfal/include/rfal_cd.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@

/******************************************************************************
* @attention
*
* COPYRIGHT 2019 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
* @attention
*
* COPYRIGHT 2019 STMicroelectronics, all rights reserved
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/

/*
* PROJECT: ST25R firmware
Expand Down Expand Up @@ -70,39 +70,42 @@
******************************************************************************
*/

/*! Card Detection NFC technology type */
typedef enum {
RFAL_CD_TECH_NONE = 0x00, /*!< No NFC Technology */
RFAL_CD_TECH_NFCA = 0x01, /*!< NFC Technology NFCB */
RFAL_CD_TECH_NFCB = 0x02, /*!< NFC Technology NFCB */
RFAL_CD_TECH_NFCF = 0x04, /*!< NFC Technology NFCF */
RFAL_CD_TECH_NFCV = 0x08, /*!< NFC Technology NFCV */
RFAL_CD_TECH_OTHER = 0x10 /*!< NFC Technology OTHER */
} rfalCdTech;

/*! Card Detection result|outcome type */
typedef enum {
RFAL_CD_NOT_FOUND = 0, /*<! No NFC device found */
RFAL_CD_SINGLE_DEV = 1, /*<! An NFC card was found */
RFAL_CD_MULTIPLE_DEV = 2, /*<! Multiple NFC devices found */
RFAL_CD_MULTIPLE_TECH =
3, /*<! Multiple NFC technologies observed in a single RF carrier */
RFAL_CD_CARD_TECH = 4, /*<! A card-exclusive NFC technology found */
RFAL_CD_SINGLE_MULTI_TECH =
5, /*<! A single NFC device which supports multiple technologies found */
RFAL_CD_SINGLE_P2P =
6, /*<! A single NFC device which supports NFC-DEP|P2P found */
RFAL_CD_SINGLE_HB =
7, /*<! A single NFC device where heartbeat was detected */
RFAL_CD_UNKOWN = 8 /*<! Unable to complete the Card Detection due to
unknow|unexpected event */
} rfalCdDetType;

/*! Card Detection result|outcome */
typedef struct {
bool detected; /*!< Card detected flag */
rfalCdDetType detType; /*!< Card detection type */
} rfalCdRes;
/*! Card Detection NFC technology type */
typedef enum
{
RFAL_CD_TECH_NONE = 0x00, /*!< No NFC Technology */
RFAL_CD_TECH_NFCA = 0x01, /*!< NFC Technology NFCB */
RFAL_CD_TECH_NFCB = 0x02, /*!< NFC Technology NFCB */
RFAL_CD_TECH_NFCF = 0x04, /*!< NFC Technology NFCF */
RFAL_CD_TECH_NFCV = 0x08, /*!< NFC Technology NFCV */
RFAL_CD_TECH_OTHER = 0x10 /*!< NFC Technology OTHER */
}rfalCdTech;


/*! Card Detection result|outcome type */
typedef enum
{
RFAL_CD_NOT_FOUND = 0, /*<! No NFC device found */
RFAL_CD_SINGLE_DEV = 1, /*<! An NFC card was found */
RFAL_CD_MULTIPLE_DEV = 2, /*<! Multiple NFC devices found */
RFAL_CD_MULTIPLE_TECH = 3, /*<! Multiple NFC technologies observed in a single RF carrier */
RFAL_CD_CARD_TECH = 4, /*<! A card-exclusive NFC technology found */
RFAL_CD_SINGLE_MULTI_TECH = 5, /*<! A single NFC device which supports multiple technologies found */
RFAL_CD_SINGLE_P2P = 6, /*<! A single NFC device which supports NFC-DEP|P2P found */
RFAL_CD_SINGLE_HB = 7, /*<! A single NFC device where heartbeat was detected */
RFAL_CD_UNKOWN = 8 /*<! Unable to complete the Card Detection due to unknow|unexpected event */
}
rfalCdDetType;


/*! Card Detection result|outcome */
typedef struct
{
bool detected; /*!< Card detected flag */
rfalCdDetType detType; /*!< Card detection type */
}
rfalCdRes;


/*
******************************************************************************
Expand All @@ -117,23 +120,24 @@ typedef struct {
* This function checks if a passive NFC card is present in the vicinity
*
* \param[out] result : Pointer to detection result|outcome
*
*
* \return RFAL_ERR_PARAM : Invalid parameters
* \return RFAL_ERR_WRONG_STATE : Incorrect state for this operation
* \return RFAL_ERR_NONE : Detection excuted with no error
* \return RFAL_ERR_RF_COLLISION : RF carrier collision detected
* \return RFAL_ERR_XXXX : Error occurred
*
*****************************************************************************
*/
ReturnCode rfalCdDetectCard(rfalCdRes *result);
ReturnCode rfalCdDetectCard( rfalCdRes *result );


/*!
*****************************************************************************
* \brief Start Card Detection
*
* This function starts the detection for a passive NFC card is present
* This function starts the detection for a passive NFC card is present
* in the vicinity
*
* \param[out] result : Pointer to detection result|outcome
Expand All @@ -144,7 +148,8 @@ ReturnCode rfalCdDetectCard(rfalCdRes *result);
*
*****************************************************************************
*/
ReturnCode rfalCdStartDetectCard(rfalCdRes *result);
ReturnCode rfalCdStartDetectCard( rfalCdRes *result );


/*!
*****************************************************************************
Expand All @@ -160,14 +165,15 @@ ReturnCode rfalCdStartDetectCard(rfalCdRes *result);
*
*****************************************************************************
*/
ReturnCode rfalCdGetDetectCardStatus(void);
ReturnCode rfalCdGetDetectCardStatus( void );


#endif /* RFAL_CD_H */

/**
* @}
*
* @}
*
* @}
*/
* @}
*
* @}
*
* @}
*/
Loading

0 comments on commit 073bd6c

Please sign in to comment.