hal_lld.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. /*
  2. ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. /**
  14. * @file STM32F1xx/hal_lld.h
  15. * @brief STM32F1xx HAL subsystem low level driver header.
  16. * @pre This module requires the following macros to be defined in the
  17. * @p board.h file:
  18. * - STM32_LSECLK.
  19. * - STM32_LSE_BYPASS (optionally).
  20. * - STM32_HSECLK.
  21. * - STM32_HSE_BYPASS (optionally).
  22. * .
  23. * One of the following macros must also be defined:
  24. * - STM32F100xB for Value Line Medium Density devices.
  25. * - STM32F100xE for Value Line High Density devices.
  26. * - STM32F101x6, STM32F102x6, STM32F103x6 for Performance
  27. * Low Density devices.
  28. * - STM32F101xB, STM32F102xB, STM32F103xB for Performance
  29. * Medium Density devices.
  30. * - STM32F101xE, STM32F103xE for Performance High Density devices.
  31. * - STM32F101xG, STM32F103xG for Performance eXtra Density devices.
  32. * - STM32F105xC, STM32F107xC for Connectivity Line devices.
  33. * .
  34. *
  35. * @addtogroup HAL
  36. * @{
  37. */
  38. #ifndef HAL_LLD_H
  39. #define HAL_LLD_H
  40. #include "stm32_registry.h"
  41. /*===========================================================================*/
  42. /* Driver constants. */
  43. /*===========================================================================*/
  44. /**
  45. * @name Platform identification
  46. * @{
  47. */
  48. #if defined(__DOXYGEN__)
  49. #define PLATFORM_NAME "STM32F1xx"
  50. #elif defined(STM32F10X_MD_VL)
  51. #define PLATFORM_NAME "STM32F100 Value Line Medium Density"
  52. #elif defined(STM32F10X_HD_VL)
  53. #define PLATFORM_NAME "STM32F100 Value Line High Density"
  54. #elif defined(STM32F10X_LD)
  55. #define PLATFORM_NAME "STM32F10x Performance Line Low Density"
  56. #elif defined(STM32F10X_MD)
  57. #define PLATFORM_NAME "STM32F10x Performance Line Medium Density"
  58. #elif defined(STM32F10X_HD)
  59. #define PLATFORM_NAME "STM32F10x Performance Line High Density"
  60. #elif defined(STM32F10X_XL)
  61. #define PLATFORM_NAME "STM32F10x Performance Line eXtra Density"
  62. #elif defined(STM32F10X_CL)
  63. #define PLATFORM_NAME "STM32F10x Connectivity Line"
  64. #else
  65. #error "unsupported or unrecognized STM32F1xx member"
  66. #endif
  67. /**
  68. * @brief Sub-family identifier.
  69. */
  70. #if !defined(STM32F1XX) || defined(__DOXYGEN__)
  71. #define STM32F1XX
  72. #endif
  73. /** @} */
  74. /**
  75. * @name Internal clock sources
  76. * @{
  77. */
  78. #define STM32_HSICLK 8000000 /**< High speed internal clock. */
  79. #define STM32_LSICLK 40000 /**< Low speed internal clock. */
  80. /** @} */
  81. /**
  82. * @name PWR_CR register bits definitions
  83. * @{
  84. */
  85. #define STM32_PLS_MASK (7 << 5) /**< PLS bits mask. */
  86. #define STM32_PLS_LEV0 (0 << 5) /**< PVD level 0. */
  87. #define STM32_PLS_LEV1 (1 << 5) /**< PVD level 1. */
  88. #define STM32_PLS_LEV2 (2 << 5) /**< PVD level 2. */
  89. #define STM32_PLS_LEV3 (3 << 5) /**< PVD level 3. */
  90. #define STM32_PLS_LEV4 (4 << 5) /**< PVD level 4. */
  91. #define STM32_PLS_LEV5 (5 << 5) /**< PVD level 5. */
  92. #define STM32_PLS_LEV6 (6 << 5) /**< PVD level 6. */
  93. #define STM32_PLS_LEV7 (7 << 5) /**< PVD level 7. */
  94. /** @} */
  95. /*===========================================================================*/
  96. /* Platform capabilities. */
  97. /*===========================================================================*/
  98. /*===========================================================================*/
  99. /* Driver pre-compile time settings. */
  100. /*===========================================================================*/
  101. /**
  102. * @name Configuration options
  103. * @{
  104. */
  105. /**
  106. * @brief Disables the PWR/RCC initialization in the HAL.
  107. */
  108. #if !defined(STM32_NO_INIT) || defined(__DOXYGEN__)
  109. #define STM32_NO_INIT FALSE
  110. #endif
  111. /**
  112. * @brief Enables or disables the programmable voltage detector.
  113. */
  114. #if !defined(STM32_PVD_ENABLE) || defined(__DOXYGEN__)
  115. #define STM32_PVD_ENABLE FALSE
  116. #endif
  117. /**
  118. * @brief Sets voltage level for programmable voltage detector.
  119. */
  120. #if !defined(STM32_PLS) || defined(__DOXYGEN__)
  121. #define STM32_PLS STM32_PLS_LEV0
  122. #endif
  123. /**
  124. * @brief Enables or disables the HSI clock source.
  125. */
  126. #if !defined(STM32_HSI_ENABLED) || defined(__DOXYGEN__)
  127. #define STM32_HSI_ENABLED TRUE
  128. #endif
  129. /**
  130. * @brief Enables or disables the LSI clock source.
  131. */
  132. #if !defined(STM32_LSI_ENABLED) || defined(__DOXYGEN__)
  133. #define STM32_LSI_ENABLED FALSE
  134. #endif
  135. /**
  136. * @brief Enables or disables the HSE clock source.
  137. */
  138. #if !defined(STM32_HSE_ENABLED) || defined(__DOXYGEN__)
  139. #define STM32_HSE_ENABLED TRUE
  140. #endif
  141. /**
  142. * @brief Enables or disables the LSE clock source.
  143. */
  144. #if !defined(STM32_LSE_ENABLED) || defined(__DOXYGEN__)
  145. #define STM32_LSE_ENABLED FALSE
  146. #endif
  147. /** @} */
  148. /*===========================================================================*/
  149. /* Derived constants and error checks. */
  150. /*===========================================================================*/
  151. #if defined(STM32F10X_MD_VL) || defined(STM32F10X_HD_VL) || \
  152. defined(__DOXYGEN__)
  153. #include "hal_lld_f100.h"
  154. #elif defined(STM32F10X_LD) || defined(STM32F10X_MD) || \
  155. defined(STM32F10X_HD) || defined(STM32F10X_XL) || \
  156. defined(__DOXYGEN__)
  157. #include "hal_lld_f103.h"
  158. #elif defined(STM32F10X_CL) || defined(__DOXYGEN__)
  159. #include "hal_lld_f105_f107.h"
  160. #endif
  161. /*===========================================================================*/
  162. /* Driver data structures and types. */
  163. /*===========================================================================*/
  164. /*===========================================================================*/
  165. /* Driver macros. */
  166. /*===========================================================================*/
  167. /*===========================================================================*/
  168. /* External declarations. */
  169. /*===========================================================================*/
  170. /* Various helpers.*/
  171. #include "nvic.h"
  172. #include "cache.h"
  173. #include "mpu_v7m.h"
  174. #include "stm32_isr.h"
  175. #include "stm32_dma.h"
  176. #include "stm32_rcc.h"
  177. #ifdef __cplusplus
  178. extern "C" {
  179. #endif
  180. void hal_lld_init(void);
  181. void stm32_clock_init(void);
  182. #ifdef __cplusplus
  183. }
  184. #endif
  185. #endif /* HAL_LLD_H */
  186. /** @} */