diff --git a/.gitmodules b/.gitmodules index 2d40cfc1..824c45bd 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,6 @@ [submodule "firmware/iot-risk-logger-stm32l4/libraries/RTT"] path = firmware/iot-risk-logger-stm32l4/libraries/RTT url = https://github.com/SEGGERMicro/RTT +[submodule "firmware/iot-risk-logger-stm32l4/libraries/fp-sns-stbox1"] + path = firmware/iot-risk-logger-stm32l4/libraries/fp-sns-stbox1 + url = https://github.com/STMicroelectronics/fp-sns-stbox1.git diff --git a/firmware/iot-risk-logger-stm32l4/Middlewares/ST/lib_nfc/Common/LICENSE.txt b/firmware/iot-risk-logger-stm32l4/Middlewares/ST/lib_nfc/Common/LICENSE.txt deleted file mode 100644 index a8900afd..00000000 --- a/firmware/iot-risk-logger-stm32l4/Middlewares/ST/lib_nfc/Common/LICENSE.txt +++ /dev/null @@ -1,86 +0,0 @@ -This software component is provided to you as part of a software package and -applicable license terms are in the Package_license file. If you received this -software component outside of a package or without applicable license terms, -the terms of the SLA0044 license shall apply and are fully reproduced below: - -SLA0044 Rev5/February 2018 - -Software license agreement - -ULTIMATE LIBERTY SOFTWARE LICENSE AGREEMENT - -BY INSTALLING, COPYING, DOWNLOADING, ACCESSING OR OTHERWISE USING THIS SOFTWARE -OR ANY PART THEREOF (AND THE RELATED DOCUMENTATION) FROM STMICROELECTRONICS -INTERNATIONAL N.V, SWISS BRANCH AND/OR ITS AFFILIATED COMPANIES -(STMICROELECTRONICS), THE RECIPIENT, ON BEHALF OF HIMSELF OR HERSELF, OR ON -BEHALF OF ANY ENTITY BY WHICH SUCH RECIPIENT IS EMPLOYED AND/OR ENGAGED AGREES -TO BE BOUND BY THIS SOFTWARE LICENSE AGREEMENT. - -Under STMicroelectronics’ intellectual property rights, the redistribution, -reproduction and use in source and binary forms of the software or any part -thereof, with or without modification, are permitted provided that the following -conditions are met: - -1. Redistribution of source code (modified or not) must retain any copyright -notice, this list of conditions and the disclaimer set forth below as items 10 -and 11. - -2. Redistributions in binary form, except as embedded into microcontroller or -microprocessor device manufactured by or for STMicroelectronics or a software -update for such device, must reproduce any copyright notice provided with the -binary code, this list of conditions, and the disclaimer set forth below as -items 10 and 11, in documentation and/or other materials provided with the -distribution. - -3. Neither the name of STMicroelectronics nor the names of other contributors to -this software may be used to endorse or promote products derived from this -software or part thereof without specific written permission. - -4. This software or any part thereof, including modifications and/or derivative -works of this software, must be used and execute solely and exclusively on or in -combination with a microcontroller or microprocessor device manufactured by or -for STMicroelectronics. - -5. No use, reproduction or redistribution of this software partially or totally -may be done in any manner that would subject this software to any Open Source -Terms. “Open Source Terms” shall mean any open source license which requires as -part of distribution of software that the source code of such software is -distributed therewith or otherwise made available, or open source license that -substantially complies with the Open Source definition specified at -www.opensource.org and any other comparable open source license such as for -example GNU General Public License (GPL), Eclipse Public License (EPL), Apache -Software License, BSD license or MIT license. - -6. STMicroelectronics has no obligation to provide any maintenance, support or -updates for the software. - -7. The software is and will remain the exclusive property of STMicroelectronics -and its licensors. The recipient will not take any action that jeopardizes -STMicroelectronics and its licensors' proprietary rights or acquire any rights -in the software, except the limited rights specified hereunder. - -8. The recipient shall comply with all applicable laws and regulations affecting -the use of the software or any part thereof including any applicable export -control law or regulation. - -9. Redistribution and use of this software or any part thereof other than as -permitted under this license is void and will automatically terminate your -rights under this license. - -10. THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY RIGHTS, WHICH ARE -DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT SHALL -STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -11. EXCEPT AS EXPRESSLY PERMITTED HEREUNDER, NO LICENSE OR OTHER RIGHTS, WHETHER -EXPRESS OR IMPLIED, ARE GRANTED UNDER ANY PATENT OR OTHER INTELLECTUAL PROPERTY -RIGHTS OF STMICROELECTRONICS OR ANY THIRD PARTY. - diff --git a/firmware/iot-risk-logger-stm32l4/Middlewares/ST/lib_nfc/Common/inc/lib_95HF.h b/firmware/iot-risk-logger-stm32l4/Middlewares/ST/lib_nfc/Common/inc/lib_95HF.h deleted file mode 100644 index d62cdf45..00000000 --- a/firmware/iot-risk-logger-stm32l4/Middlewares/ST/lib_nfc/Common/inc/lib_95HF.h +++ /dev/null @@ -1,113 +0,0 @@ -/** - ****************************************************************************** - * @file lib_95HF.h - * @author MMY Application Team - * @version 1.0.1 - * @date 28-Feb-2022 - * @brief This file provides set of xx95HF device. - * @brief The commands as defined in 95HF's family product datasheet. - ****************************************************************************** - * @attention - * - * Copyright (c) 2022 STMicroelectronics. - * All rights reserved. - * - * This software is licensed under terms that can be found in the LICENSE file - * in the root directory of this software component. - * If no LICENSE file comes with this software, it is provided AS-IS. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef _LIB_95HF_H -#define _LIB_95HF_H - - -/* Includes ------------------------------------------------------------------*/ -#include "drv_95HF.h" -#include "common.h" - -#if defined (ST95HF) || defined (CR95HF) -#include "lib_nfctype1pcd.h" -#include "lib_nfctype2pcd.h" -#include "lib_nfctype3pcd.h" -#include "lib_nfctype4pcd.h" -#include "lib_nfctype5pcd.h" -#endif /* defined (ST95HF) || defined (CR95HF) */ - -/* Analogue configuration register for protocol initialization -------------------------------------------*/ -#define TIMER_WINDOW_REG_ADD 0x3A -#define TIMER_WINDOW_UPDATE_CONFIRM_CMD 0x04 - - -#define AFE_ANALOG_CONF_REG_SELECTION 0x68 -#define AFE_ANALOG_CONF_REG_UPDATE 0x69 - -#define AFE_ACCONFIGA_OFFSET 0x04 - -/* ROM CODE Revision --------------------------------------------------------------*/ -#define ROM_CODE_REVISION_OFFSET 13 - -/* RFtrans 95HF family command definition ---------------------------------------------------------------*/ -#define IDN 0x01 -#define PROTOCOL_SELECT 0x02 -#define POLL_FIELD 0x03 -#define SEND_RECEIVE 0x04 -#define LISTEN 0x05 -#define SEND 0x06 -#define IDLE 0x07 -#define READ_REGISTER 0x08 -#define WRITE_REGISTER 0x09 -#define BAUD_RATE 0x0A -#define SUB_FREQ_RES 0x0B -#define AC_FILTER 0x0D -#define TEST_MODE 0x0E -#define SLEEP_MODE 0x0F -#define ECHO 0x55 - - -/* poll field status ------------------------------------------------------------------ */ -#define POLLFIELD_RESULTSCODE_OK 0x00 - - - -// Send command field status -#define SEND_RESULTSCODE_OK 0x00 -#define SEND_ERRORCODE_LENGTH 0x82 -#define SEND_ERRORCODE_PROTOCOL 0x83 -/* Idle command field status ----------------------------------------------------------------- */ -#define IDLE_RESULTSCODE_OK 0x00 -#define IDLE_ERRORCODE_LENGTH 0x82 -/* read register command field status -------------------------------------------------------- */ -#define READREG_RESULTSCODE_OK 0x00 -#define READREG_ERRORCODE_LENGTH 0x82 -/* write register command field status ------------------------------------------------------- */ -#define WRITEREG_RESULTSCODE_OK 0x00 -/* Baud rate command field status ------------------------------------------------------------ */ -#define BAUDRATE_RESULTSCODE_OK 0x55 -/* AC filter command field status ------------------------------------------------------------ */ -#define ACFILTER_RESULTSCODE_OK 0x00 -#define ACFILTER_ERRORCODE_LENGTH 0x82 -/* sub freq command field status ------------------------------------------------------------- */ -#define SUBFREQ_RESULTSCODE_OK 0x00 -/* Test mode command field status ------------------------------------------------------------ */ -#define TESTMODE_RESULTSCODE_OK 0x00 - -#define ASK_FOR_SESSION 0x0000 -#define TAKE_SESSION 0xFFFF - -#define XX95_ACTION_COMPLETED 0x9000 - - - -typedef enum { - QJA = 0x30, - QJB, - QJC, - QJD, - QJE -}IC_VERSION; - - -#endif /* _LIB_95HF_H */ diff --git a/firmware/iot-risk-logger-stm32l4/Middlewares/ST/lib_nfc/Common/inc/lib_95HFConfigManager.h b/firmware/iot-risk-logger-stm32l4/Middlewares/ST/lib_nfc/Common/inc/lib_95HFConfigManager.h deleted file mode 100644 index b1a7cd54..00000000 --- a/firmware/iot-risk-logger-stm32l4/Middlewares/ST/lib_nfc/Common/inc/lib_95HFConfigManager.h +++ /dev/null @@ -1,130 +0,0 @@ -/** - ****************************************************************************** - * @file lib_95HFConfigManager.h - * @author MMY Application Team - * @version 1.0.1 - * @date 28-Feb-2022 - * @brief This file provides set of firmware functions to manage device modes. - ****************************************************************************** - * @attention - * - * Copyright (c) 2022 STMicroelectronics. - * All rights reserved. - * - * This software is licensed under terms that can be found in the LICENSE file - * in the root directory of this software component. - * If no LICENSE file comes with this software, it is provided AS-IS. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion --------------------------------------------*/ -#ifndef _LIB_95HFCONFIGMANAGER_H -#define _LIB_95HFCONFIGMANAGER_H - -/* Includes -------------------------------------------------------------------------*/ -#if defined(ST95HF) || defined(RX95HF) - #include "lib_PICCemulator.h" -#endif - -#if defined(ST95HF) || defined(CR95HF) - #include "lib_iso15693pcd.h" - #include "lib_iso14443Apcd.h" - #include "lib_iso14443Bpcd.h" - #include "lib_iso18092pcd.h" -#endif - -#if defined(ST95HF) - #include "lib_nfcdepinitiator.h" - #include "lib_llcp.h" - #include "lib_snep.h" - - #include "lib_proprietaryP2P.h" -#endif - -/* Manager status and erroc code ----------------------------------------------------*/ -#define MANAGER_SUCCESSCODE RESULTOK -#define MANAGER_ERRORCODE_DEFAULT 0xF1 -#define MANAGER_ERRORCODE_PORERROR 0xF2 -#define MANAGER_ERRORCODE_COMMUNICATION_LOST 0xF3 - -/* Flags for PICC/PCD tracking ----------------------------------------------------------*/ -#define TRACK_NOTHING 0x00 -#define TRACK_NFCTYPE1 0x01 /* 0000 0001 */ -#define TRACK_NFCTYPE2 0x02 /* 0000 0010 */ -#define TRACK_NFCTYPE3 0x04 /* 0000 0100 */ -#define TRACK_NFCTYPE4A 0x08 /* 0000 1000 */ -#define TRACK_NFCTYPE4B 0x10 /* 0001 0000 */ -#define TRACK_NFCTYPE5 0x20 /* 0010 0000 */ -#define TRACK_ALL 0xFF /* 1111 1111 */ - -/* Flags for Initiator/Target tracking ------------------------------------------------------*/ -#define P2P_NOTHING 0x00 -#define INITIATOR_NFCA 0x01 /* 0000 0001 */ -#define INITIATOR_NFCF 0x02 /* 0000 0010 */ -#define TARGET_NFCA 0x04 /* 0000 0100 */ -#define TARGET_NFCF 0x08 /* 0000 1000 */ -#define TARGET_LLCPA 0x10 /* 0000 0100 */ -#define TARGET_LLCPF 0x20 /* 0000 1000 */ -#define INITIATOR_LLCPA 0x40 /* 0000 0100 */ -#define INITIATOR_LLCPF 0x80 /* 0000 1000 */ -#define P2P_ALL 0xFF /* 1111 1111 */ - -/* Flags for Proprietary P2P tracking ------------------------------------------------------*/ -#define PP2P_NOTHING 0x00 -#define PP2P_INITIATOR_NFCA 0x01 /* 0000 0001 */ -#define PP2P_TARGET_NFCA 0x10 /* 0000 0100 */ -#define PP2P_ALL 0xFF /* 1111 1111 */ - -/* Flags for SelectMode ----------------------------------------------------------*/ -#define SELECT_NOTHING 0x00 -#define SELECT_PCD 0x01 /* 0000 0001 */ -#define SELECT_PICC 0x02 /* 0000 0010 */ -#define SELECT_P2P 0x04 /* 0000 0100 */ -#define SELECT_ALL 0xFF /* 1111 1111 */ - -/* structure of the manager state --------------------------------------------------*/ -typedef struct { - uint8_t SelectedMode; - uint8_t PcdMode; - uint8_t PiccMode; - uint8_t P2pMode; - uint8_t Result; - uint16_t timeoutEmul; - uint16_t timeoutReadEmul; -}MANAGER_CONFIG; - -typedef enum PICCEMULATOR_SELECT_TAG_TYPE PICCEMULATOR_SELECT_TAG_TYPE; - -/* public function ----------------------------------------------------------------*/ - -void ConfigManager_HWInit (void); - -#if defined(ST95HF) - void ConfigManager_AutoMode (MANAGER_CONFIG *pManagerConfig); - uint8_t ConfigManager_P2P(uint8_t P2Pmode, uint16_t timeout); -#endif - -#if defined(ST95HF) || defined(CR95HF) - uint8_t ConfigManager_TagHunting ( uint8_t tagsToFind ); -#endif - -#if defined(ST95HF) || defined(RX95HF) - uint8_t ConfigManager_TagEmulation (PICCEMULATOR_SELECT_TAG_TYPE TagEmulated, uint16_t timeoutEmul, uint16_t timeoutReadEmul); - void ConfigManager_CardEmulation (PICCEMULATOR_SELECT_TAG_TYPE TagEmulated, void (*pCallBackFunction)(void)); - - /* NFC Forum P2P */ - void ConfigManager_ActivateP2PStack( void ); - void ConfigManager_DesactivateP2PStack( void ); - uint8_t ConfigManager_P2PTarget (void(*pCallBackFunction)(void)); - uint8_t ConfigManager_P2PInitiator (void(*pCallBackFunction)(void)); - - /* Proprietary P2P */ - uint8_t ConfigManager_P2PP(uint8_t P2Pmode, uint16_t timeout); - uint8_t ConfigManager_P2PPInitiator (void(*pCallBackFunction)(void)); - uint8_t ConfigManager_PP2PTarget (void(*pCallBackFunction)(void)); -#endif - -void ConfigManager_Stop(void); - -#endif diff --git a/firmware/iot-risk-logger-stm32l4/Middlewares/ST/lib_nfc/Common/inc/lib_iso14443A.h b/firmware/iot-risk-logger-stm32l4/Middlewares/ST/lib_nfc/Common/inc/lib_iso14443A.h deleted file mode 100644 index 21498b1f..00000000 --- a/firmware/iot-risk-logger-stm32l4/Middlewares/ST/lib_nfc/Common/inc/lib_iso14443A.h +++ /dev/null @@ -1,118 +0,0 @@ -/** - ****************************************************************************** - * @file lib_iso14443A.h - * @author MMY Application Team - * @version 1.0.1 - * @date 28-Feb-2022 - * @brief ISO14443A common constants. - ****************************************************************************** - * @attention - * - * Copyright (c) 2022 STMicroelectronics. - * All rights reserved. - * - * This software is licensed under terms that can be found in the LICENSE file - * in the root directory of this software component. - * If no LICENSE file comes with this software, it is provided AS-IS. - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------------------------*/ -#ifndef __ISO14443A_H -#define __ISO14443A_H - -#include "stdint.h" -#include "stdbool.h" - -/* status and error code ---------------------------------------------------------------------- */ -#define ISO14443A_SUCCESSCODE RESULTOK -#define ISO14443A_ERRORCODE_DEFAULT 0x61 -#define ISO14443A_ERRORCODE_CRC 0x62 - -/* Anticollison levels (commands) ------------------------------------------------------------- */ -#define SEL_CASCADE_LVL_1 0x93 -#define SEL_CASCADE_LVL_2 0x95 -#define SEL_CASCADE_LVL_3 0x97 -#define COMMAND_REQA 0x26 -#define COMMAND_WUPA 0x52 -#define COMMAND_SELECT_LV1 0x93 -#define COMMAND_SELECT_LV2 0x95 -#define COMMAND_SELECT_LV3 0x97 -#define COMMAND_HLTA 0x50 - -#define COMMAND_RATS 0xE0 -#define COMMAND_PPS 0xD0 -#define COMMAND_DESELECT 0xC2 -#define COMMAND_DESELECTCID 0xCA - -/* Iblock ------------------------------------------------------------------------------------- */ -#define COMMAND_IBLOCK02 0x02 -#define COMMAND_IBLOCK03 0x03 -#define COMMAND_SBLOCK 0xC2 -#define COMMAND_NACKBLOCK_B2 0xB2 -#define COMMAND_NACKBLOCK_B3 0xB3 -#define COMMAND_ACKBLOCK 0xA2 - - -/* numbr of the cascade level ----------------------------------------------------------------- */ -#define CASCADE_LVL_1 1 -#define CASCADE_LVL_2 2 -#define CASCADE_LVL_3 3 - -#define ISO14443A_NVM_10 0x10 -#define ISO14443A_NVM_20 0x20 -#define ISO14443A_NVM_30 0x30 -#define ISO14443A_NVM_40 0x40 -#define ISO14443A_NVM_50 0x50 -#define ISO14443A_NVM_60 0x60 -#define ISO14443A_NVM_70 0x70 - -/* UID Sizes ---------------------------------------------------------------------------------- */ -#define ISO14443A_UIDSIZE_UNDEFINED -1 -#define ISO14443A_UID_PART 3 -#define ISO14443A_UID_SINGLE_SIZE 4 -#define ISO14443A_UID_DOUBLE_SIZE 7 -#define ISO14443A_UID_TRIPLE_SIZE 10 - - -/* Mask used for ATQA ------------------------------------------------------------------------ */ -#define ISO14443A_UID_MASK 0xC0 -#define ISO14443A_AC_BIT_FRAME_MASK 0x1F -#define ISO14443A_CID_MASK 0x0F -#define ISO14443A_FSDI_MASK 0xF0 - -/* Size for ISO14443A variables ------------------------------------------------------------- */ -#define ISO14443A_MAX_NAME_SIZE 50 -#define ISO14443A_MAX_UID_SIZE 10 -#define ISO14443A_ATQA_SIZE 2 - -/* SAK FLAG --------------------------------------------------------------------------------- */ -#define SAK_FLAG_ATS_SUPPORTED 0x20 -#define SAK_FLAG_UID_NOT_COMPLETE 0x04 - - -/* ATQ FLAG */ -#define ATQ_FLAG_UID_SINGLE_SIZE 0 -#define ATQ_FLAG_UID_DOUBLE_SIZE 1 -#define ATQ_FLAG_UID_TRIPLE_SIZE 2 - -typedef struct{ - /* ATQA answer to request of type A*/ - uint8_t ATQA[ISO14443A_ATQA_SIZE]; - uint8_t CascadeLevel; - /* UID : unique Identification*/ - uint8_t UIDsize; - uint8_t UID[ISO14443A_MAX_UID_SIZE]; - /* SAK : Select acknowledge*/ - uint8_t SAK; - bool ATSSupported; - bool IsDetected; - char LogMsg[120]; - uint8_t CID, - FSDI, - DRI, - DSI; -}ISO14443A_CARD; - -#endif /* __ISO14443A_H */ diff --git a/firmware/iot-risk-logger-stm32l4/Middlewares/ST/lib_nfc/lib_NDEF/Core/src/lib_95HF_wrapper.c b/firmware/iot-risk-logger-stm32l4/Middlewares/ST/lib_nfc/lib_NDEF/Core/src/lib_95HF_wrapper.c deleted file mode 100644 index 0edbd95b..00000000 --- a/firmware/iot-risk-logger-stm32l4/Middlewares/ST/lib_nfc/lib_NDEF/Core/src/lib_95HF_wrapper.c +++ /dev/null @@ -1,406 +0,0 @@ -/** - ****************************************************************************** - * @file lib_95HF_wrapper.c - * @author MMY Application Team - * @version 1.3.2 - * @date 28-Feb-2022 - * @brief Interface for xx95HF in order to use NDEF lib - ****************************************************************************** - * @attention - * - * Copyright (c) 2022 STMicroelectronics. - * All rights reserved. - * - * This software is licensed under terms that can be found in the LICENSE file - * in the root directory of this software component. - * If no LICENSE file comes with this software, it is provided AS-IS. - * - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "lib_wrapper.h" -#include "lib_ndef.h" - -#if defined (ST95HF) || defined (CR95HF) -#include "lib_nfctype1pcd.h" -#include "lib_nfctype2pcd.h" -#include "lib_nfctype3pcd.h" -#include "lib_nfctype4pcd.h" -#include "lib_nfctype5pcd.h" -#endif /* defined (ST95HF) || defined (CR95HF) */ - - /* Variables for the different modes */ -extern DeviceMode_t devicemode; -extern TagType_t nfc_tagtype; - -bool updateFlash = false; - -/* Tag type 1 */ -extern uint8_t TT1Tag[]; - -/* Tag type 2 */ -extern uint8_t TT2Tag[]; - -/* Tag type 3 */ -extern uint8_t TT3Tag[]; -extern uint8_t *TT3AttribInfo, *TT3NDEFfile; - -/* Tag type 4 */ -/* NDEF buffer */ -extern uint8_t CardNDEFfileT4A []; -extern uint8_t CardNDEFfileT4B []; -/* CC buffer*/ -extern uint8_t CardCCfile []; - -/* Tag type 5 */ -#if defined (CR95HF) || defined (ST95HF) -extern uint8_t TT5Tag[]; -#endif - -/** @addtogroup NFC_libraries - * @{ - * @brief This is the library used to manage the content of the TAG (data) - * But also the specific feature of the tag, for instance - * password, gpo... - */ - - -/** @addtogroup libNFC_FORUM - * @{ - * @brief This part of the library manage data which follow NFC forum organisation. - */ - - -/** @defgroup lib_95HF_Private_Functions - * @{ - */ - -/** - * @} - */ - -/** @defgroup lib_95HF_Public_Functions - * @{ - */ - -/** - * @brief This fonction read the data stored in NDEF file at defined offset. - * @param Offset : Offset in the NDEF file. - * @param DataSize : Number of byte to read. - * @param pData : pointer on buffer to store read data. - * @retval ACTION_COMPLETED : The operation is completed. - */ -uint16_t ReadData( uint16_t Offset , uint16_t DataSize , uint8_t* pData ) -{ - uint16_t i; - switch( nfc_tagtype ) - { -#if defined (ST95HF) || defined (CR95HF) - case TT1: - if( DataSize > NFCT1_MAX_TAGMEMORY ) - return NDEF_ERROR_MEMORY_INTERNAL; - for( i = Offset; i < (DataSize+Offset); i++ ) - { - if( i == 0 ) // We need the size - { - /* 2 bytes length */ - if( TT1Tag[17] == 0xFF ) - { - pData[0] = TT1Tag[18]; - pData[1] = TT1Tag[19]; - } - /* 1 bytes length */ - else - { - pData[0] = 0x00; - pData[1] = TT1Tag[17]; - } - i++; - } - else // We need the NDEF message - { - /* 2 bytes length */ - if( TT1Tag[17] == 0xFF ) - pData[i-Offset] = TT1Tag[18+i]; - /* 1 bytes length */ - else - pData[i-Offset] = TT1Tag[16+i]; - } - } - break; -#endif /* (ST95HF) || (CR95HF) */ - - case TT2: - if( DataSize > NFCT2_MAX_TAGMEMORY ) - return NDEF_ERROR_MEMORY_INTERNAL; - for( i = Offset; i < (DataSize+Offset); i++ ) - { - if( i == 0 ) // We need the size - { - /* 2 bytes length */ - if( TT2Tag[NFCT2_MAX_CONFIG+NFCT2_MAX_CC_SIZE+1] == 0xFF ) - { - pData[0] = TT2Tag[NFCT2_MAX_CONFIG+NFCT2_MAX_CC_SIZE+2]; - pData[1] = TT2Tag[NFCT2_MAX_CONFIG+NFCT2_MAX_CC_SIZE+3]; - } - /* 1 bytes length */ - else - { - pData[0] = 0x00; - pData[1] = TT2Tag[NFCT2_MAX_CONFIG+NFCT2_MAX_CC_SIZE+1]; - } - i++; - } - else // We need the NDEF message - { - /* 2 bytes length */ - if( TT2Tag[NFCT2_MAX_CONFIG+NFCT2_MAX_CC_SIZE+1] == 0xFF ) - pData[i-Offset] = TT2Tag[NFCT2_MAX_CONFIG+NFCT2_MAX_CC_SIZE+2+i]; - /* 1 bytes length */ - else - pData[i-Offset] = TT2Tag[NFCT2_MAX_CONFIG+NFCT2_MAX_CC_SIZE+i]; - } - } - break; - - case TT3: - if( DataSize > NFCT3_MAX_TAGMEMORY ) - return NDEF_ERROR_MEMORY_INTERNAL; - for( i = Offset; i < (DataSize+Offset); i++ ) - { - if( i == 0 ) // We need the size - { - pData[0] = TT3AttribInfo[12]; - pData[1] = TT3AttribInfo[13]; - i++; - } - else - { - pData[i-Offset] = *(TT3NDEFfile + i - 2); - } - } - break; - - case TT4A: - if( DataSize > NFCT4A_MAX_NDEFMEMORY ) - return NDEF_ERROR_MEMORY_INTERNAL; - memcpy( pData, &CardNDEFfileT4A[Offset], DataSize ); - break; - - case TT4B: - if( DataSize > NFCT4B_MAX_NDEFMEMORY ) - return NDEF_ERROR_MEMORY_INTERNAL; - memcpy( pData, &CardNDEFfileT4B[Offset], DataSize ); - break; - -#if defined (CR95HF) || defined (ST95HF) - case TT5: - if( DataSize > NFCT5_MAX_TAGMEMORY ) - return NDEF_ERROR_MEMORY_INTERNAL; - for( i = Offset; i < (DataSize+Offset); i++ ) - { - if( i == 0 ) // We need the size - { - /* 2 bytes length */ - if( TT5Tag[5] == 0xFF ) - { - pData[0] = TT5Tag[6]; - pData[1] = TT5Tag[7]; - } - /* 1 bytes length */ - else - { - pData[0] = 0x00; - pData[1] = TT5Tag[5]; - } - i++; - } - else // We need the NDEF message - { - /* 2 bytes length */ - if( TT5Tag[5] == 0xFF ) - pData[i-Offset] = TT5Tag[6+i]; - /* 1 bytes length */ - else - pData[i-Offset] = TT5Tag[4+i]; - } - } - break; -#endif - - default: - break; - } - return NDEF_OK; -} - -/** - * @brief This fonction write data in NDEF file at defined offset. - * @param Offset : Offset in the NDEF file. - * @param DataSize : Number of byte to write. - * @param pData : pointer on buffer to copy. - * @retval ACTION_COMPLETED : The operation is completed. - */ -uint16_t WriteData( uint16_t Offset, uint32_t DataSize, uint8_t* pData ) -{ - uint16_t index = 0, i, sum = 0; - switch( nfc_tagtype ) - { -#if defined (ST95HF) || defined (CR95HF) - case TT1: - if( DataSize > NFCT1_MAX_TAGMEMORY ) - return NDEF_ERROR_MEMORY_INTERNAL; - index = Offset + 14; - DataSize -= 2; - /* Write the NDEF TLV [0x03 length message] */ - TT1Tag[index++] = 0x03; - /* Size can be stored in one byte or 3 bytes depending on the length */ - if( DataSize < 255 ) - { - TT1Tag[index++] = DataSize; - } - else - { - TT1Tag[index++] = 0xFF; - TT1Tag[index++] = ( DataSize&0x0000FF00 ) >> 8; - TT1Tag[index++] = DataSize & 0x000000FF; - } - memcpy( &(TT1Tag[index]), pData+2, DataSize ); - /* Write the terminating TLV [0xFE] */ - TT1Tag[index+DataSize] = 0xFE; - /* Update the phisical tag if needed */ - #if defined(ST95HF) || defined(CR95HF) - if( devicemode == PCD ) - return PCDNFCT1_WriteNDEF( ); - #endif - break; -#endif /* (ST95HF) || (CR95HF) */ - - case TT2: - if( DataSize > NFCT2_MAX_TAGMEMORY ) - return NDEF_ERROR_MEMORY_INTERNAL; - index = Offset + NFCT2_MAX_CONFIG + NFCT2_MAX_CC_SIZE; - DataSize -= 2; - /* Write the NDEF TLV [0x03 length message] */ - TT2Tag[index++] = 0x03; - /* Size can be stored in one byte or 3 bytes depending on the length */ - if( DataSize < 255 ) - { - TT2Tag[index++] = DataSize; - } - else - { - TT2Tag[index++] = 0xFF; - TT2Tag[index++] = ( DataSize&0x0000FF00 ) >> 8; - TT2Tag[index++] = DataSize & 0x000000FF; - } - memcpy( &(TT2Tag[index]), pData+2, DataSize ); - /* Write the terminating TLV [0xFE] */ - TT2Tag[index+DataSize] = 0xFE; - /* Update the phisical tag if needed */ - #if defined(ST95HF) || defined(CR95HF) - if( devicemode == PCD ) - return PCDNFCT2_WriteNDEF( ); - else - #endif - updateFlash = true; - break; - - case TT3: - if( DataSize > NFCT3_MAX_TAGMEMORY ) - return NDEF_ERROR_MEMORY_INTERNAL; - DataSize -= 2; - /* Write the ndef message first */ - memcpy( TT3NDEFfile, pData+2, DataSize ); - /* Update AttribInfo */ - TT3AttribInfo[11] = ( DataSize&0x00FF0000 ) >> 16; - TT3AttribInfo[12] = ( DataSize&0x0000FF00 ) >> 8; - TT3AttribInfo[13] = DataSize & 0x000000FF; - /* Update checksum */ - for( i = 0; i < 14; i++ ) - sum += TT3AttribInfo[i]; - TT3AttribInfo[14] = ( sum&0xFF00 ) >> 8; - TT3AttribInfo[15] = sum & 0x00FF; - /* Update the phisical tag if needed */ - #if defined(ST95HF) || defined(CR95HF) - if( devicemode == PCD ) - return PCDNFCT3_WriteNDEF( ); - else - #endif - updateFlash = true; - break; - - case TT4A: - if( DataSize > NFCT4A_MAX_NDEFMEMORY ) - return NDEF_ERROR_MEMORY_INTERNAL; - memcpy( &(CardNDEFfileT4A[Offset]), pData, DataSize ); - /* Update the phisical tag if needed */ - #if defined(ST95HF) || defined(CR95HF) - if( devicemode == PCD ) - return PCDNFCT4_WriteNDEF( ); - else - #endif - updateFlash = true; - break; - - case TT4B: - if( DataSize > NFCT4_MAX_NDEFMEMORY ) - return NDEF_ERROR_MEMORY_INTERNAL; - memcpy( &(CardNDEFfileT4B[Offset]), pData, DataSize ); - /* Update the phisical tag if needed */ - #if defined(ST95HF) || defined(CR95HF) - if( devicemode == PCD ) - return PCDNFCT4_WriteNDEF( ); - else - #endif - updateFlash = true; - break; - -#if defined (CR95HF) || defined (ST95HF) - case TT5: - if( DataSize > NFCT5_MAX_TAGMEMORY ) - return NDEF_ERROR_MEMORY_INTERNAL; - index = 4; - DataSize -= 2; - /* Write the NDEF TLV [0x03 length message] */ - TT5Tag[index++] = 0x03; - /* Size can be stored in one byte or 3 bytes depending on the length */ - if( DataSize < 255 ) - { - TT5Tag[index++] = DataSize; - } - else - { - TT5Tag[index++] = 0xFF; - TT5Tag[index++] = ( DataSize&0x0000FF00 ) >> 8; - TT5Tag[index++] = DataSize & 0x000000FF; - } - memcpy( &(TT5Tag[index]), pData + 2, DataSize ); - /* Write the terminating TLV [0xFE] */ - TT5Tag[index+DataSize] = 0xFE; - /* Update the phisical tag if needed */ - #if defined(ST95HF) || defined(CR95HF) - if( devicemode == PCD ) - return PCDNFCT5_WriteNDEF( ); - #endif - break; - #endif - - default: - break; - } - return NDEF_OK; -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ diff --git a/firmware/iot-risk-logger-stm32l4/Middlewares/ST/lib_nfc/lib_NDEF/Core/src/lib_NDEF_config.c b/firmware/iot-risk-logger-stm32l4/Middlewares/ST/lib_nfc/lib_NDEF/Core/src/lib_NDEF_config.c deleted file mode 100644 index b777e32e..00000000 --- a/firmware/iot-risk-logger-stm32l4/Middlewares/ST/lib_nfc/lib_NDEF/Core/src/lib_NDEF_config.c +++ /dev/null @@ -1,60 +0,0 @@ -/** - ****************************************************************************** - * @file lib_NDEF_config.c - * @author MMY Application Team - * @version 1.3.2 - * @date 28-Feb-2022 - * @brief This file is a template to be modified in the project to configure - * how the lib_NDEF is supposed to access the nfctag memory. - ****************************************************************************** - * @attention - * - * Copyright (c) 2022 STMicroelectronics. - * All rights reserved. - * - * This software is licensed under terms that can be found in the LICENSE file - * in the root directory of this software component. - * If no LICENSE file comes with this software, it is provided AS-IS. - * - ****************************************************************************** - */ -#include "lib_NDEF_config.h" -#include "nfc04a1_nfctag.h" - -/** - * @brief Reads data in the nfctag at specific address - * @param pData : pointer to store read data - * @param offset: Address to read - * @param Size : Size in bytes of the value to be read - * @retval NDEF_OK if success, NDEF_ERROR in case of failure - */ -int32_t NDEF_Wrapper_ReadData(uint8_t* pData, uint32_t offset, uint32_t length ) -{ - if(NFC04A1_NFCTAG_ReadData(NFC04A1_NFCTAG_INSTANCE, pData, offset, length ) != NFCTAG_OK) - return NDEF_ERROR; - return NDEF_OK; -} - -/** - * @brief Zrites data in the nfctag at specific address - * @param pData : pointer to the data to be written - * @param offset: Address to write - * @param Size : Number of bytes to be written - * @retval NDEF_OK if success, NDEF_ERROR in case of failure - */ -int32_t NDEF_Wrapper_WriteData(const uint8_t* pData, uint32_t offset, uint32_t length ) -{ - if(NFC04A1_NFCTAG_WriteData(NFC04A1_NFCTAG_INSTANCE, pData, offset, length ) != NFCTAG_OK) - return NDEF_ERROR; - return NDEF_OK; -} - - -/** - * @brief Compute the NFCTAG Memory Size. - * @return uint32_t Memory size in bytes. - */ -uint32_t NDEF_Wrapper_GetMemorySize(void) -{ - return NFC04A1_NFCTAG_GetByteSize(NFC04A1_NFCTAG_INSTANCE); -} diff --git a/firmware/iot-risk-logger-stm32l4/Middlewares/ST/lib_nfc/lib_NDEF/Core/src/lib_flash_ndef.c b/firmware/iot-risk-logger-stm32l4/Middlewares/ST/lib_nfc/lib_NDEF/Core/src/lib_flash_ndef.c deleted file mode 100644 index 61d5c4dc..00000000 --- a/firmware/iot-risk-logger-stm32l4/Middlewares/ST/lib_nfc/lib_NDEF/Core/src/lib_flash_ndef.c +++ /dev/null @@ -1,238 +0,0 @@ -/** - ****************************************************************************** - * @file lib_flash_ndef.c - * @author MMY Application Team - * @version 1.3.2 - * @date 28-Feb-2022 - * @brief This file provides set of functions to write or read the NDEF file into flash. - ****************************************************************************** - * @attention - * - * Copyright (c) 2022 STMicroelectronics. - * All rights reserved. - * - * This software is licensed under terms that can be found in the LICENSE file - * in the root directory of this software component. - * If no LICENSE file comes with this software, it is provided AS-IS. - * - ****************************************************************************** - */ - -#include "lib_flash_ndef.h" - -/* Variables for the different modes */ -extern DeviceMode_t devicemode; -extern TagType_t nfc_tagtype; - -/* Variables for buffers */ -/**** TT2 ****/ -extern uint8_t TT2Tag[]; -#define TT2_DEFAULT_SIZE 30 -static uc8 TT2Default[TT2_DEFAULT_SIZE] ={ -//0x02,0x80,0x74,0x7E,0x4A,0xEF,0x22,0x80,0x07,0x00,0x00,0x00, /* UID */ -0x02,0x80,0x74,0xDA,0x4A,0xEF,0x22,0x80,0xF1,0x48,0x00,0x00, /* UID */ -0xE1,0x10,(NFCT2_MAX_NDEFFILE/8),0x00, /* CC */ -0x03,0x0B,0xD1,0x01,0x07,0x55,0x01,'s','t','.','c','o','m',0xFE}; /* NDEF */ - -/**** TT3 ****/ -extern uint8_t TT3Tag[]; -#define TT3_DEFAULT_SIZE 32 -static uc8 TT3Default[TT3_DEFAULT_SIZE] = { -0x10,0x08,0x08,NFCT3_NB_BLOC_MSB,NFCT3_NB_BLOC_LSB,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x0B,0x00,0x2C+NFCT3_NB_BLOC_LSB, /* AttribInfo */ -0xD1,0x01,0x07,0x55,0x01, 's', 't', '.', 'c', 'o', 'm',0x00,0x00,0x00,0x00,0x00};/* NDEF */ - -/**** TT4 ****/ -extern uint8_t CardNDEFfileT4A []; -extern uint8_t CardNDEFfileT4B []; -#define TT4_DEFAULT_SIZE 13 -static uc8 TT4Default[TT4_DEFAULT_SIZE] = { -0x00,0x0B,0xD1,0x01,0x07,0x55,0x01,'s','t','.','c','o','m'}; /* NDEF */ - -/* Flags used by the library */ -extern bool updateFlash; - -/** @addtogroup NFC_libraries - * @{ - * @brief This is the library used to manage the content of the TAG (data) - * But also the specific feature of the tag, for instance - * password, gpo... - */ - - -/** @addtogroup libNFC_FORUM - * @{ - * @brief This part of the library manage data which follow NFC forum organisation. - */ - - -/** @defgroup lib_flash_ndef_Private_Functions - * @{ - */ - -/** - * @} - */ - -/** @defgroup lib_flash_ndef_Public_Functions - * @{ - */ - -/** - * @brief This function initialize the RAM buffer with FLASH content if available - */ -void initFlashNDEF(void) -{ - if( readNDEFFromFlash( TT2Tag, NFCT2_MAX_TAGMEMORY, PICCNFCT2_NDEF_ADDRESS ) == FLASH_NO_NDEF ) - { - memcpy( TT2Tag, TT2Default, TT2_DEFAULT_SIZE ); - writeNDEFToFlash( TT2Tag, NFCT2_MAX_TAGMEMORY, PICCNFCT2_NDEF_ADDRESS ); - } - if( readNDEFFromFlash( TT3Tag, NFCT3_MAX_TAGMEMORY, PICCNFCT3_NDEF_ADDRESS ) == FLASH_NO_NDEF ) - { - memcpy( TT3Tag, TT3Default, TT3_DEFAULT_SIZE ); - writeNDEFToFlash( TT3Tag, NFCT3_MAX_TAGMEMORY, PICCNFCT3_NDEF_ADDRESS ); - } - if( readNDEFFromFlash( CardNDEFfileT4A, NFCT4A_MAX_NDEFMEMORY, PICCNFCT4A_NDEF_ADDRESS ) == FLASH_NO_NDEF ) - { - memcpy( CardNDEFfileT4A, TT4Default, TT4_DEFAULT_SIZE ); - writeNDEFToFlash( CardNDEFfileT4A, NFCT4A_MAX_NDEFMEMORY, PICCNFCT4A_NDEF_ADDRESS ); - } - if( readNDEFFromFlash( CardNDEFfileT4B, NFCT4B_MAX_NDEFMEMORY, PICCNFCT4B_NDEF_ADDRESS ) == FLASH_NO_NDEF ) - { - memcpy( CardNDEFfileT4B, TT4Default, TT4_DEFAULT_SIZE ); - writeNDEFToFlash( CardNDEFfileT4B, NFCT4B_MAX_NDEFMEMORY, PICCNFCT4B_NDEF_ADDRESS ); - } -} - -/** - * @brief This function will write the correct buffer to the flash if needed. - */ -void manageFlashNDEF( void ) -{ - #ifndef DISABLE_NDEF_FLASH - if( updateFlash ) - { - switch( nfc_tagtype ) - { - case TT2: - writeNDEFToFlash( TT2Tag, NFCT2_MAX_TAGMEMORY, PICCNFCT2_NDEF_ADDRESS ); - break; - case TT3: - writeNDEFToFlash( TT3Tag, NFCT3_MAX_TAGMEMORY, PICCNFCT3_NDEF_ADDRESS ); - break; - case TT4A: - writeNDEFToFlash( CardNDEFfileT4A, NFCT4A_MAX_NDEFMEMORY, PICCNFCT4A_NDEF_ADDRESS ); - break; - case TT4B: - writeNDEFToFlash( CardNDEFfileT4B, NFCT4B_MAX_NDEFMEMORY, PICCNFCT4B_NDEF_ADDRESS ); - break; - default: - break; - } - updateFlash = false; - } - #endif -} - -/** - * @brief This function writes the NDEF file from the RAM to the FLASH. - * @param dataToWrite : The buffer which contains the memory to be written. - * @param size : The buffer size. - * @param address : The destination address inside the FLASH. - * @retval FLASH_OK : The file is written successfully. - * @retval FLASH_ERROR_SIZE : The NDEF size is higher than the FLASH available. - */ -uint8_t writeNDEFToFlash( uint8_t *dataToWrite, uint32_t size, uint32_t address ) -{ - #ifndef DISABLE_NDEF_FLASH - int32_t j; - uint32_t data=0; - uint32_t *pdata; - uint32_t EraseCounter = 0x0; - uint32_t NbrOfPage = 0; - FLASH_Status FLASHStatus = FLASH_COMPLETE; - - /* Test the size of the image to be sent */ - /* Image size is greater than Flash size */ - if( !IS_FLASH_ADDRESS( size + FLASH_MAGIC_NUMBER_LENTH + address ) ) - { - return FLASH_ERROR_SIZE; - } - - /* Unlock the FLASH */ - FLASH_Unlock( ); - - /* Clear All pending flags */ - FLASH_ClearFlag( FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR ); - - /* Erase the needed pages where the user application will be loaded */ - /* Define the number of page to be erased */ - NbrOfPage = FLASH_PagesMask( size + FLASH_MAGIC_NUMBER_LENTH ); - - /* Erase the FLASH pages */ - for( EraseCounter = 0; ( EraseCounter < NbrOfPage ) && ( FLASHStatus == FLASH_COMPLETE ); EraseCounter++ ) - { - FLASHStatus = FLASH_ErasePage( address + (PAGE_SIZE * EraseCounter) ); - } - pdata = (uint32_t*)(dataToWrite); - - /* Write the magic number */ - FLASH_ProgramWord( address,FLASH_MAGIC_NUMBER ); - address += FLASH_MAGIC_NUMBER_LENTH; - - for( j = 0; j < size; j += 4 ) - { - data = *pdata; - FLASH_ProgramWord( address,data ); - pdata++; - address += 4; - } - /* Lock the FLASH */ - FLASH_Lock( ); - #endif - return FLASH_OK; -} - -/** - * @brief This function reads the NDEF file from the FLASH to the RAM. - * @param dataToRead : The buffer which will contains the memory read. - * @param size : The buffer size. - * @param address : The destination address inside the FLASH. - * @retval FLASH_OK : The file is read successfully. - * @retval FLASH_NO_NDEF : The NDEF file is not present on the FLASH. - */ -uint8_t readNDEFFromFlash( uint8_t *dataToRead, uint32_t size, uint32_t address ) -{ - #ifndef DISABLE_NDEF_FLASH - /* If the flash does not contain any NDEF file */ - if( *((uint32_t*)(address)) != FLASH_MAGIC_NUMBER ) - { - return FLASH_NO_NDEF; - } - - /* Read size of the NDEF file */ - if( size == 0 ) - return FLASH_NO_NDEF; - - address += FLASH_MAGIC_NUMBER_LENTH; - /* Read from flash the NDEF file */ - memcpy( dataToRead, (uint32_t*)(address), size ); - - return FLASH_OK; - #else - return FLASH_NO_NDEF; - #endif -} - - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ diff --git a/firmware/iot-risk-logger-stm32l4/Middlewares/ST/lib_nfc/lib_NDEF/LICENSE.txt b/firmware/iot-risk-logger-stm32l4/Middlewares/ST/lib_nfc/lib_NDEF/LICENSE.txt deleted file mode 100644 index a8900afd..00000000 --- a/firmware/iot-risk-logger-stm32l4/Middlewares/ST/lib_nfc/lib_NDEF/LICENSE.txt +++ /dev/null @@ -1,86 +0,0 @@ -This software component is provided to you as part of a software package and -applicable license terms are in the Package_license file. If you received this -software component outside of a package or without applicable license terms, -the terms of the SLA0044 license shall apply and are fully reproduced below: - -SLA0044 Rev5/February 2018 - -Software license agreement - -ULTIMATE LIBERTY SOFTWARE LICENSE AGREEMENT - -BY INSTALLING, COPYING, DOWNLOADING, ACCESSING OR OTHERWISE USING THIS SOFTWARE -OR ANY PART THEREOF (AND THE RELATED DOCUMENTATION) FROM STMICROELECTRONICS -INTERNATIONAL N.V, SWISS BRANCH AND/OR ITS AFFILIATED COMPANIES -(STMICROELECTRONICS), THE RECIPIENT, ON BEHALF OF HIMSELF OR HERSELF, OR ON -BEHALF OF ANY ENTITY BY WHICH SUCH RECIPIENT IS EMPLOYED AND/OR ENGAGED AGREES -TO BE BOUND BY THIS SOFTWARE LICENSE AGREEMENT. - -Under STMicroelectronics’ intellectual property rights, the redistribution, -reproduction and use in source and binary forms of the software or any part -thereof, with or without modification, are permitted provided that the following -conditions are met: - -1. Redistribution of source code (modified or not) must retain any copyright -notice, this list of conditions and the disclaimer set forth below as items 10 -and 11. - -2. Redistributions in binary form, except as embedded into microcontroller or -microprocessor device manufactured by or for STMicroelectronics or a software -update for such device, must reproduce any copyright notice provided with the -binary code, this list of conditions, and the disclaimer set forth below as -items 10 and 11, in documentation and/or other materials provided with the -distribution. - -3. Neither the name of STMicroelectronics nor the names of other contributors to -this software may be used to endorse or promote products derived from this -software or part thereof without specific written permission. - -4. This software or any part thereof, including modifications and/or derivative -works of this software, must be used and execute solely and exclusively on or in -combination with a microcontroller or microprocessor device manufactured by or -for STMicroelectronics. - -5. No use, reproduction or redistribution of this software partially or totally -may be done in any manner that would subject this software to any Open Source -Terms. “Open Source Terms” shall mean any open source license which requires as -part of distribution of software that the source code of such software is -distributed therewith or otherwise made available, or open source license that -substantially complies with the Open Source definition specified at -www.opensource.org and any other comparable open source license such as for -example GNU General Public License (GPL), Eclipse Public License (EPL), Apache -Software License, BSD license or MIT license. - -6. STMicroelectronics has no obligation to provide any maintenance, support or -updates for the software. - -7. The software is and will remain the exclusive property of STMicroelectronics -and its licensors. The recipient will not take any action that jeopardizes -STMicroelectronics and its licensors' proprietary rights or acquire any rights -in the software, except the limited rights specified hereunder. - -8. The recipient shall comply with all applicable laws and regulations affecting -the use of the software or any part thereof including any applicable export -control law or regulation. - -9. Redistribution and use of this software or any part thereof other than as -permitted under this license is void and will automatically terminate your -rights under this license. - -10. THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY RIGHTS, WHICH ARE -DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT SHALL -STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -11. EXCEPT AS EXPRESSLY PERMITTED HEREUNDER, NO LICENSE OR OTHER RIGHTS, WHETHER -EXPRESS OR IMPLIED, ARE GRANTED UNDER ANY PATENT OR OTHER INTELLECTUAL PROPERTY -RIGHTS OF STMICROELECTRONICS OR ANY THIRD PARTY. - diff --git a/firmware/iot-risk-logger-stm32l4/app/tasks/nfc/README.md b/firmware/iot-risk-logger-stm32l4/app/tasks/nfc/README.md index f52e7cad..b42d7afb 100644 --- a/firmware/iot-risk-logger-stm32l4/app/tasks/nfc/README.md +++ b/firmware/iot-risk-logger-stm32l4/app/tasks/nfc/README.md @@ -6,7 +6,7 @@
Diagram as a code - + ```plantuml @startuml title NFC FSM @@ -22,3 +22,96 @@ STANDBY --> ERROR : ERROR @enduml ```
+ +### Mailbox Data Exchange Protocol (ST25FTM) Packet Format + +| **Field** | **Description** | +|-------------|----------------------------------------------------| +| **Command** | 1 byte (e.g., `WRITE_PART`, `WRITE_FINAL`, `READ`) | +| **Length** | 1 byte size of the payload in bytes | +| **Payload** | up to 252 bytes | +| **Checksum**| 2 bytes (standard CRC16 for error detection) | + +### Mailbox Data Exchange Protocol (ST25FTM) + +
+ Diagram as a code + +```plantuml +@startuml +title ST25FTM Protocol Data Exchange (Abstract) + +actor "Mobile phone" as reader +participant "ST25DV Tag" as tag +participant "STM32L4 MCU" as mcu + +== Initial Setup == +reader -> tag : Initiate Communication +tag -> mcu : Signal via Mailbox (Data Request) +mcu -> mcu : Prepare Data for Transmission + +== Data Transmission (Chunk 1) == +mcu -> tag : Write Data Chunk 1 to Mailbox (T2H) +tag -> reader : Notify Data Ready (Chunk 1) +reader -> tag : Read Data Chunk 1 from Mailbox +reader -> reader : Verify Data Integrity (Chunk 1) +reader -> tag : Acknowledge Chunk 1 (ACK) + +== Data Transmission (Chunk 2) == +mcu -> mcu : Prepare Next Data Chunk (Chunk 2) +mcu -> tag : Write Data Chunk 2 to Mailbox (T2H) +tag -> reader : Notify Data Ready (Chunk 2) +reader -> tag : Read Data Chunk 2 from Mailbox +reader -> reader : Verify Data Integrity (Chunk 2) +reader -> tag : Acknowledge Chunk 2 (ACK) + +== Finalization == +reader -> reader : Combine and Process Full Data +reader -> tag : End Communication + +@enduml +``` +
+ +### Mailbox Data Exchange Protocol (ST25FTM) for NOR Flash Data transfer + +
+ Diagram as a code + +```plantuml +@startuml +actor "Mobile phone" as reader +participant "ST25DV Tag" as tag +participant "STM32L4 MCU" as mcu + +== Data Request == + +reader -> tag : Request Data (Read NOR Flash Page) +tag -> mcu : Signal Data Request (Mailbox Interrupt) + +== Data Chunk 1 (128 bytes) == + +mcu -> mcu : Read NOR Flash (First 128 bytes) +mcu -> tag : Write Chunk 1 to T2H Mailbox +tag -> reader : Notify Data Available (Chunk 1) +reader -> tag : Read T2H Mailbox (Chunk 1) + +reader -> reader : Process Data (Chunk 1) +reader -> tag : ACK for Chunk 1 + +== Data Chunk 2 (128 bytes) == + +mcu -> mcu : Read NOR Flash (Next 128 bytes) +mcu -> tag : Write Chunk 2 to T2H Mailbox +tag -> reader : Notify Data Available (Chunk 2) +reader -> tag : Read T2H Mailbox (Chunk 2) + +reader -> reader : Process Data (Chunk 2) +reader -> tag : ACK for Chunk 2 + +== Data Exchange Complete == +reader -> reader : Assemble Complete 256 bytes + +@enduml +``` +
diff --git a/firmware/iot-risk-logger-stm32l4/libraries/fp-sns-stbox1 b/firmware/iot-risk-logger-stm32l4/libraries/fp-sns-stbox1 new file mode 160000 index 00000000..492166e0 --- /dev/null +++ b/firmware/iot-risk-logger-stm32l4/libraries/fp-sns-stbox1 @@ -0,0 +1 @@ +Subproject commit 492166e009cc3ce9c59bd5491c09d84192502a2e