1 /** ---------------------------------------------------------------------- 2 * 3 * Copyright (C) 2018 ST Microelectronics S.A. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 * 18 ----------------------------------------------------------------------*/ 19 20 #ifndef HAL_FD_H_ 21 #define HAL_FD_H_ 22 23 #include "halcore.h" 24 25 #define STFLASHTOOL_VERSION 0x0503 26 /* 27 *Structure containing fw version info 28 */ 29 typedef struct FWInfo { 30 uint32_t patchVersion; 31 uint32_t chipFwVersion; 32 uint8_t chipHwVersion; 33 uint32_t chipLoaderVersion; 34 uint16_t chipCustVersion; 35 uint16_t chipUwbVersion; 36 bool hibernate_exited; 37 38 uint16_t fileUwbVersion; 39 uint8_t fileHwVersion; // if 0, no FW patch available. 40 uint32_t fileFwVersion; 41 uint16_t fileCustVersion; // if 0, no custom params available. 42 uint8_t chipProdType; 43 } FWInfo; 44 45 46 /* 47 *Structure containing capabilities 48 */ 49 typedef struct FWCap { 50 uint8_t ObserveMode; 51 52 } FWCap; 53 54 typedef enum { 55 // HAL_FD_STATE_GET_ATR, 56 HAL_FD_STATE_AUTHENTICATE, 57 HAL_FD_STATE_ERASE_FLASH, 58 HAL_FD_STATE_SEND_RAW_APDU, 59 HAL_FD_STATE_EXIT_APDU, 60 } hal_fd_state_e; 61 62 typedef enum { 63 HAL_FD_ST54L_STATE_PUY_KEYUSER, 64 HAL_FD_ST54L_STATE_ERASE_UPGRADE_START, 65 HAL_FD_ST54L_STATE_ERASE_NFC_AREA, 66 HAL_FD_ST54L_STATE_ERASE_UPGRADE_STOP, 67 HAL_FD_ST54L_STATE_SEND_RAW_APDU, 68 HAL_FD_ST54L_STATE_SET_CONFIG, 69 HAL_FD_ST54L_STATE_SWITCH_TO_USER, 70 } hal_fd_st54l_state_e; 71 72 #define FT_CLF_MODE_ERROR 0 73 #define FT_CLF_MODE_LOADER 1 74 #define FT_CLF_MODE_ROUTER 2 75 76 #define FW_TIMER_DURATION 3000 77 78 #define FW_PATCH_AVAILABLE 1 79 #define FW_CUSTOM_PARAM_AVAILABLE 2 80 #define FW_UWB_PARAM_AVAILABLE 4 81 82 #define FW_UPDATE_NEEDED 1 83 #define CONF_UPDATE_NEEDED 2 84 #define UWB_CONF_UPDATE_NEEDED 4 85 86 // HwVersion : 87 #define HW_NFCD 0x04 88 #define HW_ST54J 0x05 89 #define HW_ST54L 0x06 90 91 /* Function declarations */ 92 int hal_fd_init(); 93 void hal_fd_close(); 94 uint8_t ft_cmd_HwReset(uint8_t* pdata, uint8_t* clf_mode); 95 void ExitHibernateHandler(HALHANDLE mHalHandle, uint16_t data_len, 96 uint8_t* p_data); 97 void FwUpdateHandler(HALHANDLE mHalHandle, uint16_t data_len, uint8_t* p_data); 98 void ApplyCustomParamHandler(HALHANDLE mHalHandle, uint16_t data_len, 99 uint8_t* p_data); 100 void ApplyUwbParamHandler(HALHANDLE mHalHandle, uint16_t data_len, 101 uint8_t* p_data); 102 void resetHandlerState(); 103 bool ft_CheckUWBConf() ; 104 FWInfo* hal_fd_getFwInfo(); 105 FWCap* hal_fd_getFwCap(); 106 #endif /* HAL_FD_H_ */ 107