STLclassBvar.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. /**
  2. ******************************************************************************
  3. * @file STLclassBvar.h
  4. * @author MCD Application Team
  5. * @version V1.0.0
  6. * @date May-2012
  7. * @brief Contains all safety critical variables; they must have
  8. * predefined addresses and inverse redundant storage
  9. ******************************************************************************
  10. * @copyright
  11. *
  12. * <h2><center>&copy; COPYRIGHT 2012 STMicroelectronics</center></h2>
  13. *
  14. * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  15. * You may not use this file except in compliance with the License.
  16. * You may obtain a copy of the License at:
  17. *
  18. * http://www.st.com/software_license_agreement_liberty_v2
  19. *
  20. * Unless required by applicable law or agreed to in writing, software
  21. * distributed under the License is distributed on an "AS IS" BASIS,
  22. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  23. * See the License for the specific language governing permissions and
  24. * limitations under the License.
  25. */
  26. /* Define to prevent recursive inclusion -------------------------------------*/
  27. #ifndef __STL_CLASS_B_VAR_H
  28. #define __STL_CLASS_B_VAR_H
  29. /* This avoids having mutiply defined global variables */
  30. #ifdef ALLOC_GLOBALS
  31. #define EXTERN
  32. #else
  33. #define EXTERN extern
  34. #endif
  35. /* Includes ------------------------------------------------------------------*/
  36. /* Exported types ------------------------------------------------------------*/
  37. /* Exported constants --------------------------------------------------------*/
  38. #define RT_RAM_BLOCKSIZE ((uint32_t)2) /* Number of RAM words tested at once */
  39. /* Exported macro ------------------------------------------------------------*/
  40. #define init_control_flow() (CtrlFlowCntInv = ~(CtrlFlowCnt = 0uL))
  41. #define control_flow_call(a) (CtrlFlowCnt += (a))
  42. #define control_flow_resume(a) (CtrlFlowCntInv -= (a))
  43. /* Exported functions ------------------------------------------------------- */
  44. #ifdef __IAR_SYSTEMS_ICC__ /* IAR Compiler */
  45. /* Temporary RAM buffer used during transparent run-time tests */
  46. /* WARNING: Real reserved RAM location from 0x20000000 to 0x2000002F (SECTION 2)*/
  47. __no_init EXTERN uint32_t RunTimeRamBuf[RT_RAM_BLOCKSIZE] @ "RUN_TIME_RAM_BUF";
  48. __no_init EXTERN uint32_t *p_RunTimeRamChk1 @ "RUN_TIME_RAM_BUF";
  49. __no_init EXTERN ClassBTestStatus ResultRAM1 @ "RUN_TIME_RAM_BUF";
  50. /* RAM pointer for run-time tests from 0x20000030 to 0x2000004F (SECTION 3)*/
  51. __no_init EXTERN uint32_t *p_RunTimeRamChk @ "RUN_TIME_RAM_PNT";
  52. __no_init EXTERN uint32_t *p_RunTimeRamChkInv @ "RUN_TIME_RAM_PNT";
  53. //__no_init EXTERN uint8_t bTestSectionFlg @ "RUN_TIME_RAM_PNT";
  54. //__no_init EXTERN uint32_t pBlockTest @ "RUN_TIME_RAM_PNT";
  55. //__no_init EXTERN uint32_t bufferTest @ "RUN_TIME_RAM_PNT";
  56. //__no_init EXTERN int8_t const *pBlock @ "RUN_TIME_RAM_PNT";
  57. __no_init EXTERN ClassBTestStatus ResultRAM @ "RUN_TIME_RAM_PNT";
  58. __no_init EXTERN uint8_t RAMsec @ "RUN_TIME_RAM_PNT";
  59. //__no_init EXTERN uint32_t indexi @ "RUN_TIME_RAM_PNT";
  60. __no_init EXTERN uint8_t bRAMFinishFlg @ "RUN_TIME_RAM_PNT";
  61. /* Counter for verifying correct program execution at start */
  62. __no_init EXTERN uint32_t CtrlFlowCnt @ "CLASS_B_RAM";
  63. __no_init EXTERN uint32_t CtrlFlowCntInv @ "CLASS_B_RAM_REV";
  64. /* Counter for verifying correct program execution in interrupt */
  65. __no_init EXTERN uint32_t ISRCtrlFlowCnt @ "CLASS_B_RAM";
  66. __no_init EXTERN uint32_t ISRCtrlFlowCntInv @ "CLASS_B_RAM_REV";
  67. /* First measure stored as reference for run-time checks */
  68. __no_init EXTERN uint32_t StartUpClockFreq @ "CLASS_B_RAM";
  69. __no_init EXTERN uint32_t StartUpClockFreqInv @ "CLASS_B_RAM_REV";
  70. /* First period measure stored as reference for run-time checks */
  71. __no_init EXTERN uint32_t RefHSEPeriod @ "CLASS_B_RAM";
  72. __no_init EXTERN uint32_t RefHSEPeriodInv @ "CLASS_B_RAM_REV";
  73. /* Last period measure sample stored for run-time checks */
  74. __no_init EXTERN uint32_t LastHSEPeriod @ "CLASS_B_RAM";
  75. __no_init EXTERN uint32_t LastHSEPeriodInv @ "CLASS_B_RAM_REV";
  76. __no_init EXTERN uint32_t LastRTCPeriod @ "CLASS_B_RAM";
  77. __no_init EXTERN uint32_t LastRTCPeriodInv @ "CLASS_B_RAM_REV";
  78. /* Last period measure stored as reference for run-time checks */
  79. __no_init EXTERN uint32_t CurrentHSEPeriod @ "CLASS_B_RAM";
  80. __no_init EXTERN uint32_t CurrentHSEPeriodInv @ "CLASS_B_RAM_REV";
  81. __no_init EXTERN uint32_t CurrentRTCPeriod @ "CLASS_B_RAM";
  82. __no_init EXTERN uint32_t CurrentRTCPeriodInv @ "CLASS_B_RAM_REV";
  83. /* Sofware time base used in main program (incremented in SysTick timer ISR */
  84. __no_init EXTERN uint32_t TickCounter @ "CLASS_B_RAM";
  85. __no_init EXTERN uint32_t TickCounterInv @ "CLASS_B_RAM_REV";
  86. /* Indicates to the main routine a 100ms tick */
  87. __no_init EXTERN __IO uint32_t TimeBaseFlag @ "CLASS_B_RAM";
  88. __no_init EXTERN __IO uint32_t TimeBaseFlagInv @ "CLASS_B_RAM_REV";
  89. __no_init EXTERN int16_t Vrefint_cal @ "CLASS_B_RAM";//ly
  90. __no_init EXTERN int16_t Vrefint_data @ "CLASS_B_RAM";//ly
  91. __no_init EXTERN int16_t Vrefint_diff @ "CLASS_B_RAM";//ly
  92. __no_init EXTERN ClassBTestStatus RamTestResult1 @ "CLASS_B_RAM";
  93. /* Stores the Control flow counter from one main loop to the other */
  94. __no_init EXTERN uint32_t LastCtrlFlowCnt @ "CLASS_B_RAM";
  95. __no_init EXTERN uint32_t LastCtrlFlowCntInv @ "CLASS_B_RAM_REV";
  96. /* Pointer to FLASH for crc16 run-time tests */
  97. __no_init EXTERN uint8_t *p_RunCrc16Chk @ "CLASS_B_RAM";
  98. __no_init EXTERN uint8_t *p_RunCrc16ChkInv @ "CLASS_B_RAM_REV";
  99. /* Pointer to FLASH for crc32 run-time tests */
  100. __no_init EXTERN uint32_t *p_RunCrc32Chk @ "CLASS_B_RAM";
  101. __no_init EXTERN uint32_t *p_RunCrc32ChkInv @ "CLASS_B_RAM_REV";
  102. /* Reference 32-bit CRC for run-time tests */
  103. __no_init EXTERN uint32_t RefCrc32 @ "CLASS_B_RAM";
  104. __no_init EXTERN uint32_t RefCrc32Inv @ "CLASS_B_RAM_REV";
  105. /* Current FLASH 16-bit Crc */
  106. __no_init EXTERN uint16_t CurrentCrc16 @ "CLASS_B_RAM";
  107. __no_init EXTERN uint16_t CurrentCrc16Inv @ "CLASS_B_RAM_REV";
  108. /* Magic pattern for Stack overflow in this array */
  109. __no_init EXTERN __IO uint32_t StackOverFlowPtrn[4] @ "STACK_BOTTOM";
  110. #endif /* __IAR_SYSTEMS_ICC__ */
  111. #ifdef __CC_ARM /* KEIL Compiler */
  112. /* Temporary RAM buffer used during transparent run-time tests */
  113. /* WARNING: Uses RAM location from 0x20000000 to 0x20000020 included */
  114. EXTERN uint32_t RunTimeRamBuf[RT_RAM_BLOCKSIZE] __attribute__((section("RUN_TIME_RAM_BUF")));
  115. /* RAM pointer for run-time tests */
  116. EXTERN uint32_t *p_RunTimeRamChk __attribute__((section("RUN_TIME_RAM_PNT")));
  117. EXTERN uint32_t *p_RunTimeRamChkInv __attribute__((section("RUN_TIME_RAM_PNT")));
  118. /* Note: the zero_init forces the linker to place variables in the bss section */
  119. /* This allows the UNINIT directive (in scatter file) to work. On the contrary */
  120. /* all Class B variables would be cleared by the C startup */
  121. /* Counter for verifying correct program execution at start */
  122. EXTERN uint32_t CtrlFlowCnt __attribute__((section("CLASS_B_RAM"), zero_init));
  123. EXTERN uint32_t CtrlFlowCntInv __attribute__((section("CLASS_B_RAM_REV"), zero_init));
  124. /* Counter for verifying correct program execution in interrupt */
  125. EXTERN uint32_t ISRCtrlFlowCnt __attribute__((section("CLASS_B_RAM"), zero_init));
  126. EXTERN uint32_t ISRCtrlFlowCntInv __attribute__((section("CLASS_B_RAM_REV"), zero_init));
  127. /* First frequency measure stored as reference for run-time checks */
  128. EXTERN uint32_t StartUpClockFreq __attribute__((section("CLASS_B_RAM"), zero_init));
  129. EXTERN uint32_t StartUpClockFreqInv __attribute__((section("CLASS_B_RAM_REV"), zero_init));
  130. /* First period measure stored as reference for run-time checks */
  131. EXTERN uint32_t RefHSEPeriod __attribute__((section("CLASS_B_RAM"), zero_init));
  132. EXTERN uint32_t RefHSEPeriodInv __attribute__((section("CLASS_B_RAM_REV"), zero_init));
  133. /* Last period measure sample stored for run-time checks */
  134. EXTERN uint32_t LastHSEPeriod __attribute__((section("CLASS_B_RAM"), zero_init));
  135. EXTERN uint32_t LastHSEPeriodInv __attribute__((section("CLASS_B_RAM_REV"), zero_init));
  136. /* Last period measure stored as reference for run-time checks */
  137. EXTERN uint32_t CurrentHSEPeriod __attribute__((section("CLASS_B_RAM"), zero_init));
  138. EXTERN uint32_t CurrentHSEPeriodInv __attribute__((section("CLASS_B_RAM_REV"), zero_init));
  139. /* Sofware time base used in main program (incremented in SysTick timer ISR */
  140. EXTERN uint32_t TickCounter __attribute__((section("CLASS_B_RAM"), zero_init));
  141. EXTERN uint32_t TickCounterInv __attribute__((section("CLASS_B_RAM_REV"), zero_init));
  142. /* Indicates to the main routine a 100ms tick */
  143. EXTERN __IO uint32_t TimeBaseFlag __attribute__((section("CLASS_B_RAM"), zero_init));
  144. EXTERN __IO uint32_t TimeBaseFlagInv __attribute__((section("CLASS_B_RAM_REV"), zero_init));
  145. /* Stores the Control flow counter from one main loop to the other */
  146. EXTERN uint32_t LastCtrlFlowCnt __attribute__((section("CLASS_B_RAM"), zero_init));
  147. EXTERN uint32_t LastCtrlFlowCntInv __attribute__((section("CLASS_B_RAM_REV"), zero_init));
  148. /* Pointer to FLASH for crc16 run-time tests */
  149. EXTERN uint8_t *p_RunCrc16Chk __attribute__((section("CLASS_B_RAM"), zero_init));
  150. EXTERN uint8_t *p_RunCrc16ChkInv __attribute__((section("CLASS_B_RAM_REV"), zero_init));
  151. /* Pointer to FLASH for crc32 run-time tests */
  152. EXTERN uint32_t *p_RunCrc32Chk __attribute__((section("CLASS_B_RAM"), zero_init));
  153. EXTERN uint32_t *p_RunCrc32ChkInv __attribute__((section("CLASS_B_RAM_REV"), zero_init));
  154. /* Reference 32-bit CRC for run-time tests */
  155. EXTERN uint32_t RefCrc32 __attribute__((section("CLASS_B_RAM"), zero_init));
  156. EXTERN uint32_t RefCrc32Inv __attribute__((section("CLASS_B_RAM_REV"), zero_init));
  157. /* Current FLASH 16-bit Crc */
  158. EXTERN uint16_t CurrentCrc16 __attribute__((section("CLASS_B_RAM"), zero_init));
  159. EXTERN uint16_t CurrentCrc16Inv __attribute__((section("CLASS_B_RAM_REV"), zero_init));
  160. /* Magic pattern for Stack overflow in this array */
  161. EXTERN __IO uint32_t StackOverFlowPtrn[] __attribute__((section("STACK_BOTTOM"), zero_init));
  162. #endif /* __CC_ARM */
  163. #endif /* __STL_CLASS_B_VAR_H */
  164. /******************* (C) COPYRIGHT STMicroelectronics *****END OF FILE****/