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 typedef enum { 46 // HAL_FD_STATE_GET_ATR, 47 HAL_FD_STATE_AUTHENTICATE, 48 HAL_FD_STATE_ERASE_FLASH, 49 HAL_FD_STATE_SEND_RAW_APDU, 50 HAL_FD_STATE_EXIT_APDU, 51 } hal_fd_state_e; 52 53 typedef enum { 54 HAL_FD_ST54L_STATE_PUY_KEYUSER, 55 HAL_FD_ST54L_STATE_ERASE_UPGRADE_START, 56 HAL_FD_ST54L_STATE_ERASE_NFC_AREA, 57 HAL_FD_ST54L_STATE_ERASE_UPGRADE_STOP, 58 HAL_FD_ST54L_STATE_SEND_RAW_APDU, 59 HAL_FD_ST54L_STATE_SET_CONFIG, 60 HAL_FD_ST54L_STATE_SWITCH_TO_USER, 61 } hal_fd_st54l_state_e; 62 63 #define FT_CLF_MODE_ERROR 0 64 #define FT_CLF_MODE_LOADER 1 65 #define FT_CLF_MODE_ROUTER 2 66 67 #define FW_TIMER_DURATION 3000 68 69 #define FW_PATCH_AVAILABLE 1 70 #define FW_CUSTOM_PARAM_AVAILABLE 2 71 #define FW_UWB_PARAM_AVAILABLE 4 72 73 #define FW_UPDATE_NEEDED 1 74 #define CONF_UPDATE_NEEDED 2 75 #define UWB_CONF_UPDATE_NEEDED 4 76 77 // HwVersion : 78 #define HW_NFCD 0x04 79 #define HW_ST54J 0x05 80 #define HW_ST54L 0x06 81 82 /* Function declarations */ 83 int hal_fd_init(); 84 void hal_fd_close(); 85 uint8_t ft_cmd_HwReset(uint8_t* pdata, uint8_t* clf_mode); 86 void ExitHibernateHandler(HALHANDLE mHalHandle, uint16_t data_len, 87 uint8_t* p_data); 88 void FwUpdateHandler(HALHANDLE mHalHandle, uint16_t data_len, uint8_t* p_data); 89 void ApplyCustomParamHandler(HALHANDLE mHalHandle, uint16_t data_len, 90 uint8_t* p_data); 91 void ApplyUwbParamHandler(HALHANDLE mHalHandle, uint16_t data_len, 92 uint8_t* p_data); 93 void resetHandlerState(); 94 bool ft_CheckUWBConf() ; 95 FWInfo* hal_fd_getFwInfo(); 96 #endif /* HAL_FD_H_ */ 97