stm32fxx_STUparam.h 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. /* Define to prevent recursive inclusion -------------------------------------*/
  2. #ifndef __SELFTEST_PARAM_H
  3. #define __SELFTEST_PARAM_H
  4. /* Includes ------------------------------------------------------------------*/
  5. #include "stm32f1xx_hal.h"
  6. /* Exported types ------------------------------------------------------------*/
  7. /* Exported constants --------------------------------------------------------*/
  8. ///* This is for having self-diagnostic messages reported on a PC via UART */
  9. //#define STL_VERBOSE_POR /* During Power-on phase only */
  10. //#define STL_VERBOSE /* During main program execution */
  11. /* uncoment next lines to configure watchdogs & resets for debug purposes */
  12. //#define USE_INDEPENDENT_WDOG
  13. //#define USE_WINDOW_WDOG
  14. ///* comment out next lines to remove any eval board control */
  15. //#define STL_EVAL_MODE
  16. ///* comment out next lines to remove any control of eval board LCD display */
  17. //#define STL_EVAL_LCD
  18. /* comment out next line to force micro reset at fail mode */
  19. #define NO_RESET_AT_FAIL_MODE
  20. /* comment out next line when CRC unit is not configurable */
  21. /* #define CRC_UNIT_CONFIGURABLE */
  22. /* comment out next line when there is no window feature at IWDG */
  23. /* #define IWDG_FEATURES_BY_WINDOW_OPTION */
  24. /* comment out next line when HSE clock is not used - clock test then runs based on HSI */
  25. #define HSE_CLOCK_APPLIED
  26. /* system clock & HSE when HSE is applied as PLL source */
  27. //#if !defined (HSE_VALUE)
  28. // #define HSE_VALUE ((uint32_t)25000000U) /*!< Value of the External oscillator in Hz */
  29. //#endif /* HSE_VALUE */
  30. //#define SYSTCLK_AT_RUN_HSE (uint32_t)(72000000uL)
  31. ///* system clock when HSI is applied as PLL source (HSE is not used) */
  32. //#define SYSTCLK_AT_STARTUP (uint32_t)(36000000uL)
  33. //#define SYSTCLK_AT_RUN_HSI (uint32_t)(36000000uL)
  34. /* Reserved area for RAM buffer, incl overlap for test purposes */
  35. /* Don't change this parameter as it is related to physical technology used! */
  36. #define RT_RAM_BLOCKSIZE (uint32_t)6u
  37. /* Min overlap to cover coupling fault from one tested row to the other */
  38. #define RT_RAM_BLOCK_OVERLAP (uint32_t)1u
  39. /* These are the direct and inverted data (pattern) used during the RAM
  40. test, performed using March C- Algorithm */
  41. //#define BCKGRND ((uint32_t)0x00000000uL)
  42. //#define INV_BCKGRND ((uint32_t)0xFFFFFFFFuL)
  43. /* uncoment next line to use March-X test instead of March-C */
  44. /* #define USE_MARCHX_RAM_TEST */
  45. /* This is to provide a time base longer than the SysTick for the main */
  46. /* For instance thi scan be used to signalize refresh the LSI watchdog and window watchdog at main */
  47. //#define SYSTICK_10ms_TB ((uint32_t)10uL) /* 10*1ms */
  48. ///* Value of the Internal LSI oscillator in Hz */
  49. // #define LSI_Freq ((uint32_t)32000uL)
  50. // /* HSE frequency above this limit considered as harmonics */
  51. // #define HSE_LimitHigh(fcy) ((uint32_t)(((fcy)/LSI_Freq)*8u*5u)/4u) /* (HSEValue + 25%) */
  52. // /* HSE frequency below this limit considered as sub-harmonics*/
  53. // #define HSE_LimitLow(fcy) ((uint32_t)(((fcy)/LSI_Freq)*8u*3u)/4u) /* (HSEValue - 25%) */
  54. // /* here you can define HSI frequency limits */
  55. // #define HSI_LimitHigh(fcy) ((uint32_t)(((fcy)/LSI_Freq)*8u*6u)/5u) /* (HSIValue + 20%) */
  56. // #define HSI_LimitLow(fcy) ((uint32_t)(((fcy)/LSI_Freq)*8u*4u)/5u) /* (HSIValue - 20%) */
  57. /* define the maximum U32 */
  58. //#define U32_MAX ((uint32_t)4294967295uL)
  59. /* -------------------------------------------------------------------------- */
  60. /* ------------------ CONTROL FLOW TAGS and CHECKPOINTS --------------------- */
  61. /* -------------------------------------------------------------------------- */
  62. //#define CPU_TEST_CALLER ((uint32_t)2)
  63. //#define CPU_TEST_CALLEE ((uint32_t)3) /* Do not modify: hard coded in assembly file */
  64. //#define WDG_TEST_CALLER ((uint32_t)5)
  65. //#define CRC32_INIT_CALLER ((uint32_t)7)
  66. //#define CRC32_TEST_CALLER ((uint32_t)11)
  67. //#define CRC32_TEST_CALLEE ((uint32_t)13)
  68. //#define CRC_TEST_CALLER ((uint32_t)17)
  69. //#define CRC_STORE_CALLER ((uint32_t)19)
  70. //#define CLOCK_TEST_CALLER ((uint32_t)23)
  71. //#define CLOCK_TEST_CALLEE ((uint32_t)29)
  72. //#define LSI_INIT_CALLEE ((uint32_t)31)
  73. //#define HSE_INIT_CALLEE ((uint32_t)37)
  74. //#define RTC_INIT_CALLEE ((uint32_t)41)
  75. //#define SYSTICK_INIT_CALLEE ((uint32_t)43)
  76. //#define CLOCK_SWITCH_CALLEE ((uint32_t)47)
  77. //#define STACK_OVERFLOW_TEST ((uint32_t)53)
  78. //#define STACK_OVERFLOW_CALLEE ((uint32_t)59)
  79. //#define CLOCKPERIOD_TEST_CALLEE ((uint32_t)61)
  80. //#define FLASH_TEST_CALLER ((uint32_t)63)
  81. //#define CRC32_RUN_TEST_CALLEE ((uint32_t)63)
  82. //#define INSTRUCT_AND_DECODE_TEST_CALLER ((uint32_t)101)
  83. //#define ADDRESSING_TEST_CALLER ((uint32_t)102)
  84. //#define PERIPHERAL_REGS_TEST_CALLER ((uint32_t)103)
  85. #define CPU_TEST_CALLER ((uint32_t)2)
  86. #define INSTRUCT_AND_DECODE_TEST_CALLER ((uint32_t)3)
  87. #define ADDRESSING_TEST_CALLER ((uint32_t)5)
  88. #define PERIPHERAL_REGS_TEST_CALLER ((uint32_t)7)
  89. #define CRC32_TEST_CALLER ((uint32_t)11)
  90. #define STACK_OVERFLOW_TEST ((uint32_t)13)
  91. #define STARTUP_CHECK ((uint32_t)CPU_TEST_CALLER + \
  92. INSTRUCT_AND_DECODE_TEST_CALLER + \
  93. ADDRESSING_TEST_CALLER + \
  94. PERIPHERAL_REGS_TEST_CALLER + \
  95. CRC32_TEST_CALLER )
  96. #define RUNTIME_TEST_CHECK ((uint32_t)CPU_TEST_CALLER + \
  97. INSTRUCT_AND_DECODE_TEST_CALLER + \
  98. ADDRESSING_TEST_CALLER + \
  99. STACK_OVERFLOW_TEST + \
  100. CRC32_TEST_CALLER )
  101. //#define CHECKPOINT1 ((uint32_t)CPU_TEST_CALLER + \
  102. // CPU_TEST_CALLEE + \
  103. // WDG_TEST_CALLER + \
  104. // CRC32_TEST_CALLER + \
  105. // CRC_TEST_CALLER)
  106. //#define CHECKPOINT2 ((uint32_t)CRC_STORE_CALLER +\
  107. // CLOCK_TEST_CALLER + \
  108. // CLOCK_TEST_CALLEE + \
  109. // STACK_OVERFLOW_TEST)
  110. ///* This is for run-time tests with 32-bit CRC */
  111. //#define DELTA_MAIN ((uint32_t)CPU_TEST_CALLER + \
  112. // CPU_TEST_CALLEE + \
  113. // STACK_OVERFLOW_TEST + \
  114. // STACK_OVERFLOW_CALLEE + \
  115. // CLOCK_TEST_CALLER + \
  116. // CLOCKPERIOD_TEST_CALLEE + \
  117. // FLASH_TEST_CALLER + \
  118. // CRC32_RUN_TEST_CALLEE)
  119. //#define LAST_DELTA_MAIN ((uint32_t) DELTA_MAIN + CRC32_INIT_CALLER)
  120. //#define FULL_FLASH_CHECKED ((uint32_t)DELTA_MAIN * STEPS_NUMBER + LAST_DELTA_MAIN)
  121. #define MEASPERIOD_ISR_CALLER ((uint32_t)2)
  122. #define MEASPERIOD_ISR_CALLEE ((uint32_t)3)
  123. #define CLOCKPERIOD_ISR_CALLEE ((uint32_t)5)
  124. #define RAM_MARCHC_ISR_CALLER ((uint32_t)7)
  125. #define RAM_MARCHC_ISR_CALLEE ((uint32_t)11)
  126. /* This is for March C tests */
  127. #define DELTA_ISR (uint32_t)(RAM_MARCHC_ISR_CALLER + \
  128. RAM_MARCHC_ISR_CALLEE)
  129. #define CLASS_B_ROWS (((uint32_t)CLASS_B_END - (uint32_t)CLASS_B_START) / (RT_RAM_BLOCKSIZE - 2u*RT_RAM_BLOCK_OVERLAP))
  130. /* +2 below is for last block & buffer self-test itself */
  131. #define RAM_TEST_COMPLETED ((uint32_t)(DELTA_ISR * (uint32_t)(CLASS_B_ROWS/4u + 2u)))
  132. /* Exported macro ------------------------------------------------------------*/
  133. #define init_control_flow() CtrlFlowCntInv = ~(CtrlFlowCnt = 0uL)
  134. #define control_flow_call(a) CtrlFlowCnt += (a)
  135. #define control_flow_resume(a) CtrlFlowCntInv -= (a)
  136. /* Exported functions ------------------------------------------------------- */
  137. #ifdef __CC_ARM /* KEIL Compiler */
  138. /* This is the KEIL compiler entry point, usually executed right after reset */
  139. extern void Reset_Handler( void );
  140. extern const uint32_t __Check_Sum;
  141. extern void __main( void );
  142. /* Constants necessary for Flash CRC calculation (ROM_SIZE in byte) */
  143. /* byte-aligned addresses */
  144. #define ROM_START ((uint32_t *)0x08003000uL)
  145. #define ROM_END ((uint32_t *)&__Check_Sum)
  146. #define ROM_SIZE ((uint32_t)ROM_END - (uint32_t)ROM_START)
  147. #define ROM_SIZEinWORDS (uint32_t) (ROM_SIZE/4u)
  148. #define STEPS_NUMBER ((uint32_t)ROM_SIZE/64u)
  149. #define FLASH_BLOCK_WORDS (uint32_t)((ROM_SIZEinWORDS)/STEPS_NUMBER)
  150. #define REF_CRC32 __Check_Sum
  151. /* Constants necessary for execution initial March test */
  152. #define RAM_START ((uint32_t *)0x20000000uL)
  153. #define RAM_SIZE (uint32_t)(0x00002000uL)
  154. /* Constants necessary for execution of transparent run time March tests */
  155. #define CLASS_B_START ((uint32_t *)0x20000030uL)
  156. #define CLASS_B_END ((uint32_t *)0x2000007BuL)
  157. #define CRC_FLAG CRC->IDR
  158. #define GotoCompilerStartUp() { CRC_FLAG = 0xAAu; __main(); } /* entry to init C before main() */
  159. #endif /* __CC_ARM */
  160. /* Exported functions ------------------------------------------------------- */
  161. void FailSafePOR(void);
  162. //#if defined STL_EVAL_MODE
  163. // void Eval_Board_HW_Init(void);
  164. //#endif
  165. //#if defined(STL_VERBOSE) || defined(STL_VERBOSE_POR)
  166. // void USART_Configuration(void);
  167. //#endif /* STL_VERBOSE */
  168. ErrorStatus control_flow_check_point(uint32_t chck);
  169. #endif /* __SELFTEST_PARAM_H */
  170. /**********************END OF FILE******************************************/