stm32fxx_STLparam.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. /**
  2. ******************************************************************************
  3. * @file stm32fxx_STLparam.h
  4. * @author MCD Application Team
  5. * @version V2.2.0
  6. * @date 19-Jun-2017
  7. * @brief This file contains the parameters to be customized for
  8. * the final application.
  9. ******************************************************************************
  10. * @attention
  11. *
  12. * <h2><center>&copy; COPYRIGHT 2017 STMicroelectronics</center></h2>
  13. *
  14. * Redistribution and use in source and binary forms, with or without modification,
  15. * are permitted provided that the following conditions are met:
  16. * 1. Redistributions of source code must retain the above copyright notice,
  17. * this list of conditions and the following disclaimer.
  18. * 2. Redistributions in binary form must reproduce the above copyright notice,
  19. * this list of conditions and the following disclaimer in the documentation
  20. * and/or other materials provided with the distribution.
  21. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  22. * may be used to endorse or promote products derived from this software
  23. * without specific prior written permission.
  24. *
  25. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  26. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  27. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  28. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  29. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  30. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  31. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  32. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  33. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  34. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  35. *
  36. ******************************************************************************
  37. */
  38. /* Define to prevent recursive inclusion -------------------------------------*/
  39. #ifndef __SELFTEST_PARAM_H
  40. #define __SELFTEST_PARAM_H
  41. /* Includes ------------------------------------------------------------------*/
  42. /* Exported types ------------------------------------------------------------*/
  43. /* Exported constants --------------------------------------------------------*/
  44. /* This is for having self-diagnostic messages reported on a PC via UART */
  45. #define STL_VERBOSE_POR /* During Power-on phase only */
  46. #define STL_VERBOSE /* During main program execution */
  47. /* uncoment next lines to configure watchdogs & resets for debug purposes */
  48. #define USE_INDEPENDENT_WDOG
  49. #define USE_WINDOW_WDOG
  50. /* comment out next lines to remove any eval board control */
  51. //#define STL_EVAL_MODE
  52. /* comment out next lines to remove any control of eval board LCD display */
  53. //#define STL_EVAL_LCD
  54. /* comment out next line to force micro reset at fail mode */
  55. #define NO_RESET_AT_FAIL_MODE
  56. /* comment out next line when CRC unit is not configurable */
  57. /* #define CRC_UNIT_CONFIGURABLE */
  58. /* comment out next line when there is no window feature at IWDG */
  59. /* #define IWDG_FEATURES_BY_WINDOW_OPTION */
  60. /* comment out next line when HSE clock is not used - clock test then runs based on HSI */
  61. #define HSE_CLOCK_APPLIED
  62. /* system clock & HSE when HSE is applied as PLL source */
  63. #if !defined (HSE_VALUE)
  64. #define HSE_VALUE ((uint32_t)25000000U) /*!< Value of the External oscillator in Hz */
  65. #endif /* HSE_VALUE */
  66. #define SYSTCLK_AT_RUN_HSE (uint32_t)(168000000uL)
  67. /* system clock when HSI is applied as PLL source (HSE is not used) */
  68. #define SYSTCLK_AT_STARTUP (uint32_t)(168000000uL)
  69. #define SYSTCLK_AT_RUN_HSI (uint32_t)(168000000uL)
  70. /* Reserved area for RAM buffer, incl overlap for test purposes */
  71. /* Don't change this parameter as it is related to physical technology used! */
  72. #define RT_RAM_BLOCKSIZE (uint32_t)6u
  73. /* Min overlap to cover coupling fault from one tested row to the other */
  74. #define RT_RAM_BLOCK_OVERLAP (uint32_t)1u
  75. /* These are the direct and inverted data (pattern) used during the RAM
  76. test, performed using March C- Algorithm */
  77. #define BCKGRND ((uint32_t)0x00000000uL)
  78. #define INV_BCKGRND ((uint32_t)0xFFFFFFFFuL)
  79. /* uncoment next line to use March-X test instead of March-C */
  80. /* #define USE_MARCHX_RAM_TEST */
  81. /* This is to provide a time base longer than the SysTick for the main */
  82. /* For instance thi scan be used to signalize refresh the LSI watchdog and window watchdog at main */
  83. #define SYSTICK_10ms_TB ((uint32_t)10uL) /* 10*1ms */
  84. /* Value of the Internal LSI oscillator in Hz */
  85. #define LSI_Freq ((uint32_t)32000uL)
  86. /* HSE frequency above this limit considered as harmonics */
  87. #define HSE_LimitHigh(fcy) ((uint32_t)(((fcy)/LSI_Freq)*4u*5u)/4u) /* (HSEValue + 25%) */
  88. /* HSE frequency below this limit considered as sub-harmonics*/
  89. #define HSE_LimitLow(fcy) ((uint32_t)(((fcy)/LSI_Freq)*4u*3u)/4u) /* (HSEValue - 25%) */
  90. /* here you can define HSI frequency limits */
  91. #define HSI_LimitHigh(fcy) ((uint32_t)(((fcy)/LSI_Freq)*4u*6u)/5u) /* (HSIValue + 20%) */
  92. #define HSI_LimitLow(fcy) ((uint32_t)(((fcy)/LSI_Freq)*4u*4u)/5u) /* (HSIValue - 20%) */
  93. /* define the maximum U32 */
  94. #define U32_MAX ((uint32_t)4294967295uL)
  95. /* -------------------------------------------------------------------------- */
  96. /* ------------------ CONTROL FLOW TAGS and CHECKPOINTS --------------------- */
  97. /* -------------------------------------------------------------------------- */
  98. /* RAM_TEST_CALLEE is only needed for CtrlFlowCntInv when exiting routine */
  99. /* This is because the RAM test routines destroys the control flow counters */
  100. #define RAM_TEST_CALLEE ((uint32_t)0xFFFFFFFFuL)
  101. #define CPU_TEST_CALLER ((uint32_t)2)
  102. #define CPU_TEST_CALLEE ((uint32_t)3) /* Do not modify: hard coded in assembly file */
  103. #define WDG_TEST_CALLER ((uint32_t)5)
  104. #define CRC32_INIT_CALLER ((uint32_t)7)
  105. #define CRC32_TEST_CALLER ((uint32_t)11)
  106. #define CRC32_TEST_CALLEE ((uint32_t)13)
  107. #define CRC_TEST_CALLER ((uint32_t)17)
  108. #define CRC_STORE_CALLER ((uint32_t)19)
  109. #define CLOCK_TEST_CALLER ((uint32_t)23)
  110. #define CLOCK_TEST_CALLEE ((uint32_t)29)
  111. #define LSI_INIT_CALLEE ((uint32_t)31)
  112. #define HSE_INIT_CALLEE ((uint32_t)37)
  113. #define RTC_INIT_CALLEE ((uint32_t)41)
  114. #define SYSTICK_INIT_CALLEE ((uint32_t)43)
  115. #define CLOCK_SWITCH_CALLEE ((uint32_t)47)
  116. #define STACK_OVERFLOW_TEST ((uint32_t)53)
  117. #define STACK_OVERFLOW_CALLEE ((uint32_t)59)
  118. #define CLOCKPERIOD_TEST_CALLEE ((uint32_t)61)
  119. #define FLASH_TEST_CALLER ((uint32_t)63)
  120. #define CRC32_RUN_TEST_CALLEE ((uint32_t)63)
  121. #define CHECKPOINT1 ((uint32_t)CPU_TEST_CALLER + \
  122. CPU_TEST_CALLEE + \
  123. WDG_TEST_CALLER + \
  124. CRC32_TEST_CALLER + \
  125. CRC_TEST_CALLER)
  126. #define CHECKPOINT2 ((uint32_t)CRC_STORE_CALLER +\
  127. CLOCK_TEST_CALLER + \
  128. CLOCK_TEST_CALLEE + \
  129. STACK_OVERFLOW_TEST)
  130. /* This is for run-time tests with 32-bit CRC */
  131. #define DELTA_MAIN ((uint32_t)CPU_TEST_CALLER + \
  132. CPU_TEST_CALLEE + \
  133. STACK_OVERFLOW_TEST + \
  134. STACK_OVERFLOW_CALLEE + \
  135. CLOCK_TEST_CALLER + \
  136. CLOCKPERIOD_TEST_CALLEE + \
  137. FLASH_TEST_CALLER + \
  138. CRC32_RUN_TEST_CALLEE)
  139. #define LAST_DELTA_MAIN ((uint32_t) DELTA_MAIN + CRC32_INIT_CALLER)
  140. #define FULL_FLASH_CHECKED ((uint32_t)DELTA_MAIN * STEPS_NUMBER + LAST_DELTA_MAIN)
  141. #define MEASPERIOD_ISR_CALLER ((uint32_t)2)
  142. #define MEASPERIOD_ISR_CALLEE ((uint32_t)3)
  143. #define CLOCKPERIOD_ISR_CALLEE ((uint32_t)5)
  144. #define RAM_MARCHC_ISR_CALLER ((uint32_t)7)
  145. #define RAM_MARCHC_ISR_CALLEE ((uint32_t)11)
  146. /* This is for March C tests */
  147. #define DELTA_ISR (uint32_t)(RAM_MARCHC_ISR_CALLER + \
  148. RAM_MARCHC_ISR_CALLEE)
  149. #define CLASS_B_ROWS (((uint32_t)CLASS_B_END - (uint32_t)CLASS_B_START) / (RT_RAM_BLOCKSIZE - 2u*RT_RAM_BLOCK_OVERLAP))
  150. /* +2 below is for last block & buffer self-test itself */
  151. #define RAM_TEST_COMPLETED ((uint32_t)(DELTA_ISR * (uint32_t)(CLASS_B_ROWS/4u + 2u)))
  152. /* Exported macro ------------------------------------------------------------*/
  153. #define init_control_flow() CtrlFlowCntInv = ~(CtrlFlowCnt = 0uL)
  154. #define control_flow_call(a) CtrlFlowCnt += (a)
  155. #define control_flow_resume(a) CtrlFlowCntInv -= (a)
  156. /* Exported functions ------------------------------------------------------- */
  157. #ifdef __IAR_SYSTEMS_ICC__ /* IAR Compiler */
  158. /* This is the IAR compiler entry point, usually executed right after reset */
  159. extern void __iar_program_start( void );
  160. extern uint16_t __checksum;
  161. /* The 4 variables here above are set by IAR linker */
  162. extern uint32_t __ICFEDIT_region_ROM_start__;
  163. extern uint32_t __ICFEDIT_region_ROM_end__;
  164. extern uint32_t __ICFEDIT_region_RAM_start__;
  165. extern uint32_t __ICFEDIT_region_RAM_end__;
  166. extern uint32_t __ICFEDIT_region_CLASSB_start__;
  167. extern uint32_t __ICFEDIT_region_CLASSB_end__;
  168. /* Constants necessary for Flash CRC calculation (last block - 64 bytes - separated for CRC) */
  169. #define ROM_START (uint8_t *)&__ICFEDIT_region_ROM_start__
  170. #define ROM_END (uint8_t *)((uint8_t *)(&__checksum) - 1)
  171. #define ROM_SIZE (uint32_t)(ROM_END - ROM_START + 1u)
  172. #define STEPS_NUMBER ((uint32_t)ROM_SIZE/64u)
  173. #define ROM_SIZEinWORDS (uint32_t) (ROM_SIZE/4u)
  174. #define FLASH_BLOCK_WORDS (uint32_t)((ROM_SIZEinWORDS) / STEPS_NUMBER)
  175. /* Constants necessary for Full March tests */
  176. #define RAM_START (uint32_t *)&__ICFEDIT_region_RAM_start__
  177. #define RAM_END (uint32_t *)&__ICFEDIT_region_RAM_end__
  178. /* Constants necessary for Transparent March tests */
  179. #define CLASS_B_START ((uint32_t *)(&__ICFEDIT_region_CLASSB_start__))
  180. #define CLASS_B_END ((uint32_t *)(&__ICFEDIT_region_CLASSB_end__))
  181. #define GotoCompilerStartUp() { __iar_program_start(); }
  182. #define REF_CRC32 __checksum
  183. #
  184. #endif /* __IAR_SYSTEMS_ICC__ */
  185. #ifdef __CC_ARM /* KEIL Compiler */
  186. /* This is the KEIL compiler entry point, usually executed right after reset */
  187. extern void Reset_Handler( void );
  188. extern const uint32_t __Check_Sum;
  189. extern void __main( void );
  190. /* Constants necessary for Flash CRC calculation (ROM_SIZE in byte) */
  191. /* byte-aligned addresses */
  192. #define ROM_START ((uint32_t *)0x08040000uL)
  193. #define ROM_END ((uint32_t *)&__Check_Sum)
  194. #define ROM_SIZE ((uint32_t)ROM_END - (uint32_t)ROM_START)
  195. #define ROM_SIZEinWORDS (uint32_t) (ROM_SIZE/4u)
  196. #define STEPS_NUMBER ((uint32_t)ROM_SIZE/64u)
  197. #define FLASH_BLOCK_WORDS (uint32_t)((ROM_SIZEinWORDS)/STEPS_NUMBER)
  198. #define REF_CRC32 __Check_Sum
  199. /* Constants necessary for execution initial March test */
  200. #define RAM_START ((uint32_t *)0x20000000uL)
  201. #define RAM_END ((uint32_t *)0x2001FFFFuL)
  202. /* Constants necessary for execution of transparent run time March tests */
  203. #define CLASS_B_START ((uint32_t *)0x20000030uL)
  204. #define CLASS_B_END ((uint32_t *)0x2000007BuL)
  205. #define CRC_FLAG CRC->IDR
  206. #define GotoCompilerStartUp() { CRC_FLAG = 0xAAu; __main(); } /* entry to init C before main() */
  207. #endif /* __CC_ARM */
  208. #ifdef __GNUC__ /* GCC Compiler */
  209. /* This is the GCC compiler entry point, usually executed right after reset */
  210. extern void Reset_Handler( void );
  211. extern const uint32_t _Check_Sum;
  212. extern void __main( void );
  213. /* Constants necessary for Flash CRC calculation (ROM_SIZE in byte) */
  214. /* byte-aligned addresses */
  215. #define ROM_START ((uint32_t *)0x08000000uL)
  216. #define ROM_END ((uint32_t *)&_Check_Sum)
  217. #define ROM_SIZE ((uint32_t)ROM_END - (uint32_t)ROM_START)
  218. #define ROM_SIZEinWORDS (uint32_t) (ROM_SIZE/4u)
  219. #define STEPS_NUMBER ((uint32_t)ROM_SIZE/64u)
  220. #define FLASH_BLOCK_WORDS (uint32_t)((ROM_SIZEinWORDS)/STEPS_NUMBER)
  221. #define REF_CRC32 _Check_Sum
  222. /* Constants necessary for execution initial March test */
  223. #define RAM_START ((uint32_t *)0x20000000uL)
  224. #define RAM_END ((uint32_t *)0x2001FFFFuL)
  225. /* Constants necessary for execution of transparent run time March tests */
  226. #define CLASS_B_START ((uint32_t *)0x20000030uL)
  227. #define CLASS_B_END ((uint32_t *)0x2000007BuL)
  228. #define CRC_FLAG CRC->IDR
  229. #define GotoCompilerStartUp() { Startup_Copy_Handler(); SystemInit(); __libc_init_array(); main(); } /* entry to main() */
  230. #endif /* __GNUC__ */
  231. /* Exported functions ------------------------------------------------------- */
  232. void FailSafePOR(void);
  233. #if defined STL_EVAL_MODE
  234. void Eval_Board_HW_Init(void);
  235. #endif
  236. #if defined(STL_VERBOSE) || defined(STL_VERBOSE_POR)
  237. void USART_Configuration(void);
  238. #endif /* STL_VERBOSE */
  239. ErrorStatus control_flow_check_point(uint32_t chck);
  240. #endif /* __SELFTEST_PARAM_H */
  241. /******************* (C) COPYRIGHT STMicroelectronics *****END OF FILE****/