1 /* USER CODE BEGIN Header */ 2 /** 3 ****************************************************************************** 4 * @file miscutil.h 5 * @author GPM WBL Application Team 6 * @brief Header file for HW miscellaneous utilities. 7 ****************************************************************************** 8 * @attention 9 * 10 * Copyright (c) 2024 STMicroelectronics. 11 * All rights reserved. 12 * 13 * This software is licensed under terms that can be found in the LICENSE file 14 * in the root directory of this software component. 15 * If no LICENSE file comes with this software, it is provided AS-IS. 16 * 17 ****************************************************************************** 18 */ 19 /* USER CODE END Header */ 20 21 /* Define to prevent recursive inclusion -------------------------------------*/ 22 23 #ifndef __MISCUTIL_H__ 24 #define __MISCUTIL_H__ 25 26 #include <stdint.h> 27 #include "crash_handler.h" 28 #include "stm32wb0x.h" 29 30 #if defined(STM32WB09) 31 #define DIE_SW_ID_STM32WB09XX ((uint8_t)6) 32 #define JTAG_ID_CODE_STM32WB09XX ((uint32_t)0x02032041) 33 #elif defined(STM32WB07) || defined(STM32WB06) 34 #define DIE_SW_ID_STM32WB07XX ((uint8_t)3) 35 #define JTAG_ID_CODE_STM32WB07XX ((uint32_t)0x0201E041) 36 #elif defined(STM32WB05) 37 #define DIE_SW_ID_STM32WB05XX ((uint8_t)5) 38 #define JTAG_ID_CODE_STM32WB05XX ((uint32_t)0x02028041) 39 #endif 40 41 #define DIE_SW_ID_UNKOWN ((uint8_t)0xFF) 42 43 /** 44 * @brief A structure that represents part information details 45 * 46 */ 47 typedef struct PartInfoS { 48 /** DIE ID number */ 49 uint8_t die_id; 50 /** Die major number */ 51 uint8_t die_major; 52 /** Die cut number */ 53 uint8_t die_cut; 54 /** JTAG ID */ 55 uint32_t jtag_id_code; 56 /** Flash size in bytes */ 57 uint32_t flash_size; 58 /** Flash size in bytes */ 59 uint32_t ram_size; 60 } PartInfoType; 61 62 /** 63 * @brief This function return a structure with information about the device 64 * 65 * @param[out] partInfo Pointer to a PartInfoType structure 66 * 67 * @retval None 68 */ 69 void GetPartInfo(PartInfoType *partInfo); 70 /** 71 * @brief Get Crash Information utility 72 * 73 * This function return the crash information that are stored in RAM, by hard 74 * handler, nmi handler and assert handler. 75 * This function reset the crash information stored in RAM before it returns. 76 * So it avoid to report the same crash information after a normal reboot. 77 * 78 * @param[out] crashInfo Pointer to a crash_info_t structure 79 * 80 * @retval None 81 */ 82 void GetCrashInfo(crash_info_t *crashInfo); 83 /** 84 * @brief Set Crash Information utility 85 * 86 * This function stores crash information in RAM and reset the device 87 * Crash information can be retrieved by using API HAL_GetCrashInfo 88 * 89 * @param[in] msp Stack pointer containing crash info 90 * @param[out] signature CRash reason signature 91 * 92 * @retval None 93 */ 94 void CrashHandler(uint32_t msp, uint32_t signature); 95 96 /** 97 * @brief Read CI field from demodulation register 98 * 99 * @param[in] None 100 * 101 * @retval CI value 102 */ 103 uint8_t GetDemodCI(void); 104 105 #endif /* __MISCUTIL_H__ */ 106