stm32l1xx_hal.h 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996
  1. /**
  2. ******************************************************************************
  3. * @file stm32l1xx_hal.h
  4. * @author MCD Application Team
  5. * @brief This file contains all the functions prototypes for the HAL
  6. * module driver.
  7. ******************************************************************************
  8. * @attention
  9. *
  10. * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
  11. * All rights reserved.</center></h2>
  12. *
  13. * This software component is licensed by ST under BSD 3-Clause license,
  14. * the "License"; You may not use this file except in compliance with the
  15. * License. You may obtain a copy of the License at:
  16. * opensource.org/licenses/BSD-3-Clause
  17. *
  18. ******************************************************************************
  19. */
  20. /* Define to prevent recursive inclusion -------------------------------------*/
  21. #ifndef __STM32L1xx_HAL_H
  22. #define __STM32L1xx_HAL_H
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. /* Includes ------------------------------------------------------------------*/
  27. #include "stm32l1xx_hal_conf.h"
  28. /** @addtogroup STM32L1xx_HAL_Driver
  29. * @{
  30. */
  31. /** @addtogroup HAL
  32. * @{
  33. */
  34. /* Exported types ------------------------------------------------------------*/
  35. /* Exported constants --------------------------------------------------------*/
  36. /** @defgroup HAL_Exported_Constants HAL Exported Constants
  37. * @{
  38. */
  39. /** @defgroup HAL_TICK_FREQ Tick Frequency
  40. * @{
  41. */
  42. #define HAL_TICK_FREQ_10HZ 100U
  43. #define HAL_TICK_FREQ_100HZ 10U
  44. #define HAL_TICK_FREQ_1KHZ 1U
  45. #define HAL_TICK_FREQ_DEFAULT HAL_TICK_FREQ_1KHZ
  46. #define IS_TICKFREQ(__FREQ__) (((__FREQ__) == HAL_TICK_FREQ_10HZ) || \
  47. ((__FREQ__) == HAL_TICK_FREQ_100HZ) || \
  48. ((__FREQ__) == HAL_TICK_FREQ_1KHZ))
  49. /**
  50. * @}
  51. */
  52. /**
  53. * @}
  54. */
  55. /** @defgroup SYSCFG_Exported_Constants SYSCFG Exported Constants
  56. * @{
  57. */
  58. /** @defgroup SYSCFG_Constants SYSCFG: SYStem ConFiG
  59. * @{
  60. */
  61. /** @defgroup SYSCFG_BootMode Boot Mode
  62. * @{
  63. */
  64. #define SYSCFG_BOOT_MAINFLASH (0x00000000U)
  65. #define SYSCFG_BOOT_SYSTEMFLASH ((uint32_t)SYSCFG_MEMRMP_BOOT_MODE_0)
  66. #if defined(FSMC_R_BASE)
  67. #define SYSCFG_BOOT_FSMC ((uint32_t)SYSCFG_MEMRMP_BOOT_MODE_1)
  68. #endif /* FSMC_R_BASE */
  69. #define SYSCFG_BOOT_SRAM ((uint32_t)SYSCFG_MEMRMP_BOOT_MODE)
  70. /**
  71. * @}
  72. */
  73. /**
  74. * @}
  75. */
  76. /** @defgroup RI_Constants RI: Routing Interface
  77. * @{
  78. */
  79. /** @defgroup RI_InputCapture Input Capture
  80. * @{
  81. */
  82. #define RI_INPUTCAPTURE_IC1 RI_ICR_IC1 /*!< Input Capture 1 */
  83. #define RI_INPUTCAPTURE_IC2 RI_ICR_IC2 /*!< Input Capture 2 */
  84. #define RI_INPUTCAPTURE_IC3 RI_ICR_IC3 /*!< Input Capture 3 */
  85. #define RI_INPUTCAPTURE_IC4 RI_ICR_IC4 /*!< Input Capture 4 */
  86. /**
  87. * @}
  88. */
  89. /** @defgroup TIM_Select TIM Select
  90. * @{
  91. */
  92. #define TIM_SELECT_NONE (0x00000000U) /*!< None selected */
  93. #define TIM_SELECT_TIM2 ((uint32_t)RI_ICR_TIM_0) /*!< Timer 2 selected */
  94. #define TIM_SELECT_TIM3 ((uint32_t)RI_ICR_TIM_1) /*!< Timer 3 selected */
  95. #define TIM_SELECT_TIM4 ((uint32_t)RI_ICR_TIM) /*!< Timer 4 selected */
  96. #define IS_RI_TIM(__TIM__) (((__TIM__) == TIM_SELECT_NONE) || \
  97. ((__TIM__) == TIM_SELECT_TIM2) || \
  98. ((__TIM__) == TIM_SELECT_TIM3) || \
  99. ((__TIM__) == TIM_SELECT_TIM4))
  100. /**
  101. * @}
  102. */
  103. /** @defgroup RI_InputCaptureRouting Input Capture Routing
  104. * @{
  105. */
  106. /* TIMx_IC1 TIMx_IC2 TIMx_IC3 TIMx_IC4 */
  107. #define RI_INPUTCAPTUREROUTING_0 (0x00000000U) /* PA0 PA1 PA2 PA3 */
  108. #define RI_INPUTCAPTUREROUTING_1 (0x00000001U) /* PA4 PA5 PA6 PA7 */
  109. #define RI_INPUTCAPTUREROUTING_2 (0x00000002U) /* PA8 PA9 PA10 PA11 */
  110. #define RI_INPUTCAPTUREROUTING_3 (0x00000003U) /* PA12 PA13 PA14 PA15 */
  111. #define RI_INPUTCAPTUREROUTING_4 (0x00000004U) /* PC0 PC1 PC2 PC3 */
  112. #define RI_INPUTCAPTUREROUTING_5 (0x00000005U) /* PC4 PC5 PC6 PC7 */
  113. #define RI_INPUTCAPTUREROUTING_6 (0x00000006U) /* PC8 PC9 PC10 PC11 */
  114. #define RI_INPUTCAPTUREROUTING_7 (0x00000007U) /* PC12 PC13 PC14 PC15 */
  115. #define RI_INPUTCAPTUREROUTING_8 (0x00000008U) /* PD0 PD1 PD2 PD3 */
  116. #define RI_INPUTCAPTUREROUTING_9 (0x00000009U) /* PD4 PD5 PD6 PD7 */
  117. #define RI_INPUTCAPTUREROUTING_10 (0x0000000AU) /* PD8 PD9 PD10 PD11 */
  118. #define RI_INPUTCAPTUREROUTING_11 (0x0000000BU) /* PD12 PD13 PD14 PD15 */
  119. #define RI_INPUTCAPTUREROUTING_12 (0x0000000CU) /* PE0 PE1 PE2 PE3 */
  120. #define RI_INPUTCAPTUREROUTING_13 (0x0000000DU) /* PE4 PE5 PE6 PE7 */
  121. #define RI_INPUTCAPTUREROUTING_14 (0x0000000EU) /* PE8 PE9 PE10 PE11 */
  122. #define RI_INPUTCAPTUREROUTING_15 (0x0000000FU) /* PE12 PE13 PE14 PE15 */
  123. #define IS_RI_INPUTCAPTURE_ROUTING(__ROUTING__) (((__ROUTING__) == RI_INPUTCAPTUREROUTING_0) || \
  124. ((__ROUTING__) == RI_INPUTCAPTUREROUTING_1) || \
  125. ((__ROUTING__) == RI_INPUTCAPTUREROUTING_2) || \
  126. ((__ROUTING__) == RI_INPUTCAPTUREROUTING_3) || \
  127. ((__ROUTING__) == RI_INPUTCAPTUREROUTING_4) || \
  128. ((__ROUTING__) == RI_INPUTCAPTUREROUTING_5) || \
  129. ((__ROUTING__) == RI_INPUTCAPTUREROUTING_6) || \
  130. ((__ROUTING__) == RI_INPUTCAPTUREROUTING_7) || \
  131. ((__ROUTING__) == RI_INPUTCAPTUREROUTING_8) || \
  132. ((__ROUTING__) == RI_INPUTCAPTUREROUTING_9) || \
  133. ((__ROUTING__) == RI_INPUTCAPTUREROUTING_10) || \
  134. ((__ROUTING__) == RI_INPUTCAPTUREROUTING_11) || \
  135. ((__ROUTING__) == RI_INPUTCAPTUREROUTING_12) || \
  136. ((__ROUTING__) == RI_INPUTCAPTUREROUTING_13) || \
  137. ((__ROUTING__) == RI_INPUTCAPTUREROUTING_14) || \
  138. ((__ROUTING__) == RI_INPUTCAPTUREROUTING_15))
  139. /**
  140. * @}
  141. */
  142. /** @defgroup RI_IOSwitch IO Switch
  143. * @{
  144. */
  145. #define RI_ASCR1_REGISTER (0x80000000U)
  146. /* ASCR1 I/O switch: bit 31 is set to '1' to indicate that the mask is in ASCR1 register */
  147. #define RI_IOSWITCH_CH0 ((uint32_t)RI_ASCR1_REGISTER | RI_ASCR1_CH_0)
  148. #define RI_IOSWITCH_CH1 ((uint32_t)RI_ASCR1_REGISTER | RI_ASCR1_CH_1)
  149. #define RI_IOSWITCH_CH2 ((uint32_t)RI_ASCR1_REGISTER | RI_ASCR1_CH_2)
  150. #define RI_IOSWITCH_CH3 ((uint32_t)RI_ASCR1_REGISTER | RI_ASCR1_CH_3)
  151. #define RI_IOSWITCH_CH4 ((uint32_t)RI_ASCR1_REGISTER | RI_ASCR1_CH_4)
  152. #define RI_IOSWITCH_CH5 ((uint32_t)RI_ASCR1_REGISTER | RI_ASCR1_CH_5)
  153. #define RI_IOSWITCH_CH6 ((uint32_t)RI_ASCR1_REGISTER | RI_ASCR1_CH_6)
  154. #define RI_IOSWITCH_CH7 ((uint32_t)RI_ASCR1_REGISTER | RI_ASCR1_CH_7)
  155. #define RI_IOSWITCH_CH8 ((uint32_t)RI_ASCR1_REGISTER | RI_ASCR1_CH_8)
  156. #define RI_IOSWITCH_CH9 ((uint32_t)RI_ASCR1_REGISTER | RI_ASCR1_CH_9)
  157. #define RI_IOSWITCH_CH10 ((uint32_t)RI_ASCR1_REGISTER | RI_ASCR1_CH_10)
  158. #define RI_IOSWITCH_CH11 ((uint32_t)RI_ASCR1_REGISTER | RI_ASCR1_CH_11)
  159. #define RI_IOSWITCH_CH12 ((uint32_t)RI_ASCR1_REGISTER | RI_ASCR1_CH_12)
  160. #define RI_IOSWITCH_CH13 ((uint32_t)RI_ASCR1_REGISTER | RI_ASCR1_CH_13)
  161. #define RI_IOSWITCH_CH14 ((uint32_t)RI_ASCR1_REGISTER | RI_ASCR1_CH_14)
  162. #define RI_IOSWITCH_CH15 ((uint32_t)RI_ASCR1_REGISTER | RI_ASCR1_CH_15)
  163. #define RI_IOSWITCH_CH18 ((uint32_t)RI_ASCR1_REGISTER | RI_ASCR1_CH_18)
  164. #define RI_IOSWITCH_CH19 ((uint32_t)RI_ASCR1_REGISTER | RI_ASCR1_CH_19)
  165. #define RI_IOSWITCH_CH20 ((uint32_t)RI_ASCR1_REGISTER | RI_ASCR1_CH_20)
  166. #define RI_IOSWITCH_CH21 ((uint32_t)RI_ASCR1_REGISTER | RI_ASCR1_CH_21)
  167. #define RI_IOSWITCH_CH22 ((uint32_t)RI_ASCR1_REGISTER | RI_ASCR1_CH_22)
  168. #define RI_IOSWITCH_CH23 ((uint32_t)RI_ASCR1_REGISTER | RI_ASCR1_CH_23)
  169. #define RI_IOSWITCH_CH24 ((uint32_t)RI_ASCR1_REGISTER | RI_ASCR1_CH_24)
  170. #define RI_IOSWITCH_CH25 ((uint32_t)RI_ASCR1_REGISTER | RI_ASCR1_CH_25)
  171. #define RI_IOSWITCH_VCOMP ((uint32_t)RI_ASCR1_REGISTER | RI_ASCR1_VCOMP) /* VCOMP (ADC channel 26) is an internal switch used to connect selected channel to COMP1 non inverting input */
  172. #if defined (RI_ASCR2_CH1b) /* STM32L1 devices category Cat.4 and Cat.5 */
  173. #define RI_IOSWITCH_CH27 ((uint32_t)RI_ASCR1_REGISTER | RI_ASCR1_CH_27)
  174. #define RI_IOSWITCH_CH28 ((uint32_t)RI_ASCR1_REGISTER | RI_ASCR1_CH_28)
  175. #define RI_IOSWITCH_CH29 ((uint32_t)RI_ASCR1_REGISTER | RI_ASCR1_CH_29)
  176. #define RI_IOSWITCH_CH30 ((uint32_t)RI_ASCR1_REGISTER | RI_ASCR1_CH_30)
  177. #define RI_IOSWITCH_CH31 ((uint32_t)RI_ASCR1_REGISTER | RI_ASCR1_CH_31)
  178. #endif /* RI_ASCR2_CH1b */
  179. /* ASCR2 IO switch: bit 31 is set to '0' to indicate that the mask is in ASCR2 register */
  180. #define RI_IOSWITCH_GR10_1 ((uint32_t)RI_ASCR2_GR10_1)
  181. #define RI_IOSWITCH_GR10_2 ((uint32_t)RI_ASCR2_GR10_2)
  182. #define RI_IOSWITCH_GR10_3 ((uint32_t)RI_ASCR2_GR10_3)
  183. #define RI_IOSWITCH_GR10_4 ((uint32_t)RI_ASCR2_GR10_4)
  184. #define RI_IOSWITCH_GR6_1 ((uint32_t)RI_ASCR2_GR6_1)
  185. #define RI_IOSWITCH_GR6_2 ((uint32_t)RI_ASCR2_GR6_2)
  186. #define RI_IOSWITCH_GR5_1 ((uint32_t)RI_ASCR2_GR5_1)
  187. #define RI_IOSWITCH_GR5_2 ((uint32_t)RI_ASCR2_GR5_2)
  188. #define RI_IOSWITCH_GR5_3 ((uint32_t)RI_ASCR2_GR5_3)
  189. #define RI_IOSWITCH_GR4_1 ((uint32_t)RI_ASCR2_GR4_1)
  190. #define RI_IOSWITCH_GR4_2 ((uint32_t)RI_ASCR2_GR4_2)
  191. #define RI_IOSWITCH_GR4_3 ((uint32_t)RI_ASCR2_GR4_3)
  192. #if defined (RI_ASCR2_CH0b) /* STM32L1 devices category Cat.3, Cat.4 and Cat.5 */
  193. #define RI_IOSWITCH_CH0b ((uint32_t)RI_ASCR2_CH0b)
  194. #if defined (RI_ASCR2_CH1b) /* STM32L1 devices category Cat.4 and Cat.5 */
  195. #define RI_IOSWITCH_CH1b ((uint32_t)RI_ASCR2_CH1b)
  196. #define RI_IOSWITCH_CH2b ((uint32_t)RI_ASCR2_CH2b)
  197. #define RI_IOSWITCH_CH3b ((uint32_t)RI_ASCR2_CH3b)
  198. #define RI_IOSWITCH_CH6b ((uint32_t)RI_ASCR2_CH6b)
  199. #define RI_IOSWITCH_CH7b ((uint32_t)RI_ASCR2_CH7b)
  200. #define RI_IOSWITCH_CH8b ((uint32_t)RI_ASCR2_CH8b)
  201. #define RI_IOSWITCH_CH9b ((uint32_t)RI_ASCR2_CH9b)
  202. #define RI_IOSWITCH_CH10b ((uint32_t)RI_ASCR2_CH10b)
  203. #define RI_IOSWITCH_CH11b ((uint32_t)RI_ASCR2_CH11b)
  204. #define RI_IOSWITCH_CH12b ((uint32_t)RI_ASCR2_CH12b)
  205. #endif /* RI_ASCR2_CH1b */
  206. #define RI_IOSWITCH_GR6_3 ((uint32_t)RI_ASCR2_GR6_3)
  207. #define RI_IOSWITCH_GR6_4 ((uint32_t)RI_ASCR2_GR6_4)
  208. #endif /* RI_ASCR2_CH0b */
  209. #if defined (RI_ASCR2_CH1b) /* STM32L1 devices category Cat.4 and Cat.5 */
  210. #define IS_RI_IOSWITCH(__IOSWITCH__) (((__IOSWITCH__) == RI_IOSWITCH_CH0) || ((__IOSWITCH__) == RI_IOSWITCH_CH1) || \
  211. ((__IOSWITCH__) == RI_IOSWITCH_CH2) || ((__IOSWITCH__) == RI_IOSWITCH_CH3) || \
  212. ((__IOSWITCH__) == RI_IOSWITCH_CH4) || ((__IOSWITCH__) == RI_IOSWITCH_CH5) || \
  213. ((__IOSWITCH__) == RI_IOSWITCH_CH6) || ((__IOSWITCH__) == RI_IOSWITCH_CH7) || \
  214. ((__IOSWITCH__) == RI_IOSWITCH_CH8) || ((__IOSWITCH__) == RI_IOSWITCH_CH9) || \
  215. ((__IOSWITCH__) == RI_IOSWITCH_CH10) || ((__IOSWITCH__) == RI_IOSWITCH_CH11) || \
  216. ((__IOSWITCH__) == RI_IOSWITCH_CH12) || ((__IOSWITCH__) == RI_IOSWITCH_CH13) || \
  217. ((__IOSWITCH__) == RI_IOSWITCH_CH14) || ((__IOSWITCH__) == RI_IOSWITCH_CH15) || \
  218. ((__IOSWITCH__) == RI_IOSWITCH_CH18) || ((__IOSWITCH__) == RI_IOSWITCH_CH19) || \
  219. ((__IOSWITCH__) == RI_IOSWITCH_CH20) || ((__IOSWITCH__) == RI_IOSWITCH_CH21) || \
  220. ((__IOSWITCH__) == RI_IOSWITCH_CH22) || ((__IOSWITCH__) == RI_IOSWITCH_CH23) || \
  221. ((__IOSWITCH__) == RI_IOSWITCH_CH24) || ((__IOSWITCH__) == RI_IOSWITCH_CH25) || \
  222. ((__IOSWITCH__) == RI_IOSWITCH_VCOMP) || ((__IOSWITCH__) == RI_IOSWITCH_CH27) || \
  223. ((__IOSWITCH__) == RI_IOSWITCH_CH28) || ((__IOSWITCH__) == RI_IOSWITCH_CH29) || \
  224. ((__IOSWITCH__) == RI_IOSWITCH_CH30) || ((__IOSWITCH__) == RI_IOSWITCH_CH31) || \
  225. ((__IOSWITCH__) == RI_IOSWITCH_GR10_1) || ((__IOSWITCH__) == RI_IOSWITCH_GR10_2) || \
  226. ((__IOSWITCH__) == RI_IOSWITCH_GR10_3) || ((__IOSWITCH__) == RI_IOSWITCH_GR10_4) || \
  227. ((__IOSWITCH__) == RI_IOSWITCH_GR6_1) || ((__IOSWITCH__) == RI_IOSWITCH_GR6_2) || \
  228. ((__IOSWITCH__) == RI_IOSWITCH_GR6_3) || ((__IOSWITCH__) == RI_IOSWITCH_GR6_4) || \
  229. ((__IOSWITCH__) == RI_IOSWITCH_GR5_1) || ((__IOSWITCH__) == RI_IOSWITCH_GR5_2) || \
  230. ((__IOSWITCH__) == RI_IOSWITCH_GR5_3) || ((__IOSWITCH__) == RI_IOSWITCH_GR4_1) || \
  231. ((__IOSWITCH__) == RI_IOSWITCH_GR4_2) || ((__IOSWITCH__) == RI_IOSWITCH_GR4_3) || \
  232. ((__IOSWITCH__) == RI_IOSWITCH_CH0b) || ((__IOSWITCH__) == RI_IOSWITCH_CH1b) || \
  233. ((__IOSWITCH__) == RI_IOSWITCH_CH2b) || ((__IOSWITCH__) == RI_IOSWITCH_CH3b) || \
  234. ((__IOSWITCH__) == RI_IOSWITCH_CH6b) || ((__IOSWITCH__) == RI_IOSWITCH_CH7b) || \
  235. ((__IOSWITCH__) == RI_IOSWITCH_CH8b) || ((__IOSWITCH__) == RI_IOSWITCH_CH9b) || \
  236. ((__IOSWITCH__) == RI_IOSWITCH_CH10b) || ((__IOSWITCH__) == RI_IOSWITCH_CH11b) || \
  237. ((__IOSWITCH__) == RI_IOSWITCH_CH12b))
  238. #else /* !RI_ASCR2_CH1b */
  239. #if defined (RI_ASCR2_CH0b) /* STM32L1 devices category Cat.3 */
  240. #define IS_RI_IOSWITCH(__IOSWITCH__) (((__IOSWITCH__) == RI_IOSWITCH_CH0) || ((__IOSWITCH__) == RI_IOSWITCH_CH1) || \
  241. ((__IOSWITCH__) == RI_IOSWITCH_CH2) || ((__IOSWITCH__) == RI_IOSWITCH_CH3) || \
  242. ((__IOSWITCH__) == RI_IOSWITCH_CH4) || ((__IOSWITCH__) == RI_IOSWITCH_CH5) || \
  243. ((__IOSWITCH__) == RI_IOSWITCH_CH6) || ((__IOSWITCH__) == RI_IOSWITCH_CH7) || \
  244. ((__IOSWITCH__) == RI_IOSWITCH_CH8) || ((__IOSWITCH__) == RI_IOSWITCH_CH9) || \
  245. ((__IOSWITCH__) == RI_IOSWITCH_CH10) || ((__IOSWITCH__) == RI_IOSWITCH_CH11) || \
  246. ((__IOSWITCH__) == RI_IOSWITCH_CH12) || ((__IOSWITCH__) == RI_IOSWITCH_CH13) || \
  247. ((__IOSWITCH__) == RI_IOSWITCH_CH14) || ((__IOSWITCH__) == RI_IOSWITCH_CH15) || \
  248. ((__IOSWITCH__) == RI_IOSWITCH_CH18) || ((__IOSWITCH__) == RI_IOSWITCH_CH19) || \
  249. ((__IOSWITCH__) == RI_IOSWITCH_CH20) || ((__IOSWITCH__) == RI_IOSWITCH_CH21) || \
  250. ((__IOSWITCH__) == RI_IOSWITCH_CH22) || ((__IOSWITCH__) == RI_IOSWITCH_CH23) || \
  251. ((__IOSWITCH__) == RI_IOSWITCH_CH24) || ((__IOSWITCH__) == RI_IOSWITCH_CH25) || \
  252. ((__IOSWITCH__) == RI_IOSWITCH_VCOMP) || ((__IOSWITCH__) == RI_IOSWITCH_GR10_1) || \
  253. ((__IOSWITCH__) == RI_IOSWITCH_GR10_2) || ((__IOSWITCH__) == RI_IOSWITCH_GR10_3) || \
  254. ((__IOSWITCH__) == RI_IOSWITCH_GR10_4) || ((__IOSWITCH__) == RI_IOSWITCH_GR6_1) || \
  255. ((__IOSWITCH__) == RI_IOSWITCH_GR6_2) || ((__IOSWITCH__) == RI_IOSWITCH_GR5_1) || \
  256. ((__IOSWITCH__) == RI_IOSWITCH_GR5_2) || ((__IOSWITCH__) == RI_IOSWITCH_GR5_3) || \
  257. ((__IOSWITCH__) == RI_IOSWITCH_GR4_1) || ((__IOSWITCH__) == RI_IOSWITCH_GR4_2) || \
  258. ((__IOSWITCH__) == RI_IOSWITCH_GR4_3) || ((__IOSWITCH__) == RI_IOSWITCH_CH0b))
  259. #else /* !RI_ASCR2_CH0b */ /* STM32L1 devices category Cat.1 and Cat.2 */
  260. #define IS_RI_IOSWITCH(__IOSWITCH__) (((__IOSWITCH__) == RI_IOSWITCH_CH0) || ((__IOSWITCH__) == RI_IOSWITCH_CH1) || \
  261. ((__IOSWITCH__) == RI_IOSWITCH_CH2) || ((__IOSWITCH__) == RI_IOSWITCH_CH3) || \
  262. ((__IOSWITCH__) == RI_IOSWITCH_CH4) || ((__IOSWITCH__) == RI_IOSWITCH_CH5) || \
  263. ((__IOSWITCH__) == RI_IOSWITCH_CH6) || ((__IOSWITCH__) == RI_IOSWITCH_CH7) || \
  264. ((__IOSWITCH__) == RI_IOSWITCH_CH8) || ((__IOSWITCH__) == RI_IOSWITCH_CH9) || \
  265. ((__IOSWITCH__) == RI_IOSWITCH_CH10) || ((__IOSWITCH__) == RI_IOSWITCH_CH11) || \
  266. ((__IOSWITCH__) == RI_IOSWITCH_CH12) || ((__IOSWITCH__) == RI_IOSWITCH_CH13) || \
  267. ((__IOSWITCH__) == RI_IOSWITCH_CH14) || ((__IOSWITCH__) == RI_IOSWITCH_CH15) || \
  268. ((__IOSWITCH__) == RI_IOSWITCH_CH18) || ((__IOSWITCH__) == RI_IOSWITCH_CH19) || \
  269. ((__IOSWITCH__) == RI_IOSWITCH_CH20) || ((__IOSWITCH__) == RI_IOSWITCH_CH21) || \
  270. ((__IOSWITCH__) == RI_IOSWITCH_CH22) || ((__IOSWITCH__) == RI_IOSWITCH_CH23) || \
  271. ((__IOSWITCH__) == RI_IOSWITCH_CH24) || ((__IOSWITCH__) == RI_IOSWITCH_CH25) || \
  272. ((__IOSWITCH__) == RI_IOSWITCH_VCOMP) || ((__IOSWITCH__) == RI_IOSWITCH_GR10_1) || \
  273. ((__IOSWITCH__) == RI_IOSWITCH_GR10_2) || ((__IOSWITCH__) == RI_IOSWITCH_GR10_3) || \
  274. ((__IOSWITCH__) == RI_IOSWITCH_GR10_4) || ((__IOSWITCH__) == RI_IOSWITCH_GR6_1) || \
  275. ((__IOSWITCH__) == RI_IOSWITCH_GR6_2) || ((__IOSWITCH__) == RI_IOSWITCH_GR5_1) || \
  276. ((__IOSWITCH__) == RI_IOSWITCH_GR5_2) || ((__IOSWITCH__) == RI_IOSWITCH_GR5_3) || \
  277. ((__IOSWITCH__) == RI_IOSWITCH_GR4_1) || ((__IOSWITCH__) == RI_IOSWITCH_GR4_2) || \
  278. ((__IOSWITCH__) == RI_IOSWITCH_GR4_3))
  279. #endif /* RI_ASCR2_CH0b */
  280. #endif /* RI_ASCR2_CH1b */
  281. /**
  282. * @}
  283. */
  284. /** @defgroup RI_Pin PIN define
  285. * @{
  286. */
  287. #define RI_PIN_0 ((uint16_t)0x0001) /*!< Pin 0 selected */
  288. #define RI_PIN_1 ((uint16_t)0x0002) /*!< Pin 1 selected */
  289. #define RI_PIN_2 ((uint16_t)0x0004) /*!< Pin 2 selected */
  290. #define RI_PIN_3 ((uint16_t)0x0008) /*!< Pin 3 selected */
  291. #define RI_PIN_4 ((uint16_t)0x0010) /*!< Pin 4 selected */
  292. #define RI_PIN_5 ((uint16_t)0x0020) /*!< Pin 5 selected */
  293. #define RI_PIN_6 ((uint16_t)0x0040) /*!< Pin 6 selected */
  294. #define RI_PIN_7 ((uint16_t)0x0080) /*!< Pin 7 selected */
  295. #define RI_PIN_8 ((uint16_t)0x0100) /*!< Pin 8 selected */
  296. #define RI_PIN_9 ((uint16_t)0x0200) /*!< Pin 9 selected */
  297. #define RI_PIN_10 ((uint16_t)0x0400) /*!< Pin 10 selected */
  298. #define RI_PIN_11 ((uint16_t)0x0800) /*!< Pin 11 selected */
  299. #define RI_PIN_12 ((uint16_t)0x1000) /*!< Pin 12 selected */
  300. #define RI_PIN_13 ((uint16_t)0x2000) /*!< Pin 13 selected */
  301. #define RI_PIN_14 ((uint16_t)0x4000) /*!< Pin 14 selected */
  302. #define RI_PIN_15 ((uint16_t)0x8000) /*!< Pin 15 selected */
  303. #define RI_PIN_ALL ((uint16_t)0xFFFF) /*!< All pins selected */
  304. #define IS_RI_PIN(__PIN__) ((__PIN__) != (uint16_t)0x00)
  305. /**
  306. * @}
  307. */
  308. /**
  309. * @}
  310. */
  311. /**
  312. * @}
  313. */
  314. /* Exported macros -----------------------------------------------------------*/
  315. /** @defgroup HAL_Exported_Macros HAL Exported Macros
  316. * @{
  317. */
  318. /** @defgroup DBGMCU_Macros DBGMCU: Debug MCU
  319. * @{
  320. */
  321. /** @defgroup DBGMCU_Freeze_Unfreeze Freeze Unfreeze Peripherals in Debug mode
  322. * @brief Freeze/Unfreeze Peripherals in Debug mode
  323. * @{
  324. */
  325. /**
  326. * @brief TIM2 Peripherals Debug mode
  327. */
  328. #if defined (DBGMCU_APB1_FZ_DBG_TIM2_STOP)
  329. #define __HAL_DBGMCU_FREEZE_TIM2() SET_BIT(DBGMCU->APB1FZ, DBGMCU_APB1_FZ_DBG_TIM2_STOP)
  330. #define __HAL_DBGMCU_UNFREEZE_TIM2() CLEAR_BIT(DBGMCU->APB1FZ, DBGMCU_APB1_FZ_DBG_TIM2_STOP)
  331. #endif
  332. /**
  333. * @brief TIM3 Peripherals Debug mode
  334. */
  335. #if defined (DBGMCU_APB1_FZ_DBG_TIM3_STOP)
  336. #define __HAL_DBGMCU_FREEZE_TIM3() SET_BIT(DBGMCU->APB1FZ, DBGMCU_APB1_FZ_DBG_TIM3_STOP)
  337. #define __HAL_DBGMCU_UNFREEZE_TIM3() CLEAR_BIT(DBGMCU->APB1FZ, DBGMCU_APB1_FZ_DBG_TIM3_STOP)
  338. #endif
  339. /**
  340. * @brief TIM4 Peripherals Debug mode
  341. */
  342. #if defined (DBGMCU_APB1_FZ_DBG_TIM4_STOP)
  343. #define __HAL_DBGMCU_FREEZE_TIM4() SET_BIT(DBGMCU->APB1FZ, DBGMCU_APB1_FZ_DBG_TIM4_STOP)
  344. #define __HAL_DBGMCU_UNFREEZE_TIM4() CLEAR_BIT(DBGMCU->APB1FZ, DBGMCU_APB1_FZ_DBG_TIM4_STOP)
  345. #endif
  346. /**
  347. * @brief TIM5 Peripherals Debug mode
  348. */
  349. #if defined (DBGMCU_APB1_FZ_DBG_TIM5_STOP)
  350. #define __HAL_DBGMCU_FREEZE_TIM5() SET_BIT(DBGMCU->APB1FZ, DBGMCU_APB1_FZ_DBG_TIM5_STOP)
  351. #define __HAL_DBGMCU_UNFREEZE_TIM5() CLEAR_BIT(DBGMCU->APB1FZ, DBGMCU_APB1_FZ_DBG_TIM5_STOP)
  352. #endif
  353. /**
  354. * @brief TIM6 Peripherals Debug mode
  355. */
  356. #if defined (DBGMCU_APB1_FZ_DBG_TIM6_STOP)
  357. #define __HAL_DBGMCU_FREEZE_TIM6() SET_BIT(DBGMCU->APB1FZ, DBGMCU_APB1_FZ_DBG_TIM6_STOP)
  358. #define __HAL_DBGMCU_UNFREEZE_TIM6() CLEAR_BIT(DBGMCU->APB1FZ, DBGMCU_APB1_FZ_DBG_TIM6_STOP)
  359. #endif
  360. /**
  361. * @brief TIM7 Peripherals Debug mode
  362. */
  363. #if defined (DBGMCU_APB1_FZ_DBG_TIM7_STOP)
  364. #define __HAL_DBGMCU_FREEZE_TIM7() SET_BIT(DBGMCU->APB1FZ, DBGMCU_APB1_FZ_DBG_TIM7_STOP)
  365. #define __HAL_DBGMCU_UNFREEZE_TIM7() CLEAR_BIT(DBGMCU->APB1FZ, DBGMCU_APB1_FZ_DBG_TIM7_STOP)
  366. #endif
  367. /**
  368. * @brief RTC Peripherals Debug mode
  369. */
  370. #if defined (DBGMCU_APB1_FZ_DBG_RTC_STOP)
  371. #define __HAL_DBGMCU_FREEZE_RTC() SET_BIT(DBGMCU->APB1FZ, DBGMCU_APB1_FZ_DBG_RTC_STOP)
  372. #define __HAL_DBGMCU_UNFREEZE_RTC() CLEAR_BIT(DBGMCU->APB1FZ, DBGMCU_APB1_FZ_DBG_RTC_STOP)
  373. #endif
  374. /**
  375. * @brief WWDG Peripherals Debug mode
  376. */
  377. #if defined (DBGMCU_APB1_FZ_DBG_WWDG_STOP)
  378. #define __HAL_DBGMCU_FREEZE_WWDG() SET_BIT(DBGMCU->APB1FZ, DBGMCU_APB1_FZ_DBG_WWDG_STOP)
  379. #define __HAL_DBGMCU_UNFREEZE_WWDG() CLEAR_BIT(DBGMCU->APB1FZ, DBGMCU_APB1_FZ_DBG_WWDG_STOP)
  380. #endif
  381. /**
  382. * @brief IWDG Peripherals Debug mode
  383. */
  384. #if defined (DBGMCU_APB1_FZ_DBG_IWDG_STOP)
  385. #define __HAL_DBGMCU_FREEZE_IWDG() SET_BIT(DBGMCU->APB1FZ, DBGMCU_APB1_FZ_DBG_IWDG_STOP)
  386. #define __HAL_DBGMCU_UNFREEZE_IWDG() CLEAR_BIT(DBGMCU->APB1FZ, DBGMCU_APB1_FZ_DBG_IWDG_STOP)
  387. #endif
  388. /**
  389. * @brief I2C1 Peripherals Debug mode
  390. */
  391. #if defined (DBGMCU_APB1_FZ_DBG_I2C1_SMBUS_TIMEOUT)
  392. #define __HAL_DBGMCU_FREEZE_I2C1_TIMEOUT() SET_BIT(DBGMCU->APB1FZ, DBGMCU_APB1_FZ_DBG_I2C1_SMBUS_TIMEOUT)
  393. #define __HAL_DBGMCU_UNFREEZE_I2C1_TIMEOUT() CLEAR_BIT(DBGMCU->APB1FZ, DBGMCU_APB1_FZ_DBG_I2C1_SMBUS_TIMEOUT)
  394. #endif
  395. /**
  396. * @brief I2C2 Peripherals Debug mode
  397. */
  398. #if defined (DBGMCU_APB1_FZ_DBG_I2C2_SMBUS_TIMEOUT)
  399. #define __HAL_DBGMCU_FREEZE_I2C2_TIMEOUT() SET_BIT(DBGMCU->APB1FZ, DBGMCU_APB1_FZ_DBG_I2C2_SMBUS_TIMEOUT)
  400. #define __HAL_DBGMCU_UNFREEZE_I2C2_TIMEOUT() CLEAR_BIT(DBGMCU->APB1FZ, DBGMCU_APB1_FZ_DBG_I2C2_SMBUS_TIMEOUT)
  401. #endif
  402. /**
  403. * @brief TIM9 Peripherals Debug mode
  404. */
  405. #if defined (DBGMCU_APB2_FZ_DBG_TIM9_STOP)
  406. #define __HAL_DBGMCU_FREEZE_TIM9() SET_BIT(DBGMCU->APB2FZ, DBGMCU_APB2_FZ_DBG_TIM9_STOP)
  407. #define __HAL_DBGMCU_UNFREEZE_TIM9() CLEAR_BIT(DBGMCU->APB2FZ, DBGMCU_APB2_FZ_DBG_TIM9_STOP)
  408. #endif
  409. /**
  410. * @brief TIM10 Peripherals Debug mode
  411. */
  412. #if defined (DBGMCU_APB2_FZ_DBG_TIM10_STOP)
  413. #define __HAL_DBGMCU_FREEZE_TIM10() SET_BIT(DBGMCU->APB2FZ, DBGMCU_APB2_FZ_DBG_TIM10_STOP)
  414. #define __HAL_DBGMCU_UNFREEZE_TIM10() CLEAR_BIT(DBGMCU->APB2FZ, DBGMCU_APB2_FZ_DBG_TIM10_STOP)
  415. #endif
  416. /**
  417. * @brief TIM11 Peripherals Debug mode
  418. */
  419. #if defined (DBGMCU_APB2_FZ_DBG_TIM11_STOP)
  420. #define __HAL_DBGMCU_FREEZE_TIM11() SET_BIT(DBGMCU->APB2FZ, DBGMCU_APB2_FZ_DBG_TIM11_STOP)
  421. #define __HAL_DBGMCU_UNFREEZE_TIM11() CLEAR_BIT(DBGMCU->APB2FZ, DBGMCU_APB2_FZ_DBG_TIM11_STOP)
  422. #endif
  423. /**
  424. * @}
  425. */
  426. /**
  427. * @}
  428. */
  429. /** @defgroup SYSCFG_Macros SYSCFG: SYStem ConFiG
  430. * @{
  431. */
  432. /** @defgroup SYSCFG_VrefInt VREFINT configuration
  433. * @{
  434. */
  435. /**
  436. * @brief Enables or disables the output of internal reference voltage
  437. * (VrefInt) on I/O pin.
  438. * @note The VrefInt output can be routed to any I/O in group 3:
  439. * - For Cat.1 and Cat.2 devices: CH8 (PB0) or CH9 (PB1).
  440. * - For Cat.3 devices: CH8 (PB0), CH9 (PB1) or CH0b (PB2).
  441. * - For Cat.4 and Cat.5 devices: CH8 (PB0), CH9 (PB1), CH0b (PB2),
  442. * CH1b (PF11) or CH2b (PF12).
  443. * Note: Comparator peripheral clock must be preliminarily enabled,
  444. * either in COMP user function "HAL_COMP_MspInit()" (should be
  445. * done if comparators are used) or by direct clock enable:
  446. * Refer to macro "__HAL_RCC_COMP_CLK_ENABLE()".
  447. * Note: In addition with this macro, VrefInt output buffer must be
  448. * connected to the selected I/O pin. Refer to macro
  449. * "__HAL_RI_IOSWITCH_CLOSE()".
  450. * @note VrefInt output enable: Internal reference voltage connected to I/O group 3
  451. * VrefInt output disable: Internal reference voltage disconnected from I/O group 3
  452. * @retval None
  453. */
  454. #define __HAL_SYSCFG_VREFINT_OUT_ENABLE() SET_BIT(COMP->CSR, COMP_CSR_VREFOUTEN)
  455. #define __HAL_SYSCFG_VREFINT_OUT_DISABLE() CLEAR_BIT(COMP->CSR, COMP_CSR_VREFOUTEN)
  456. /**
  457. * @}
  458. */
  459. /** @defgroup SYSCFG_BootModeConfig Boot Mode Configuration
  460. * @{
  461. */
  462. /**
  463. * @brief Main Flash memory mapped at 0x00000000
  464. */
  465. #define __HAL_SYSCFG_REMAPMEMORY_FLASH() CLEAR_BIT(SYSCFG->MEMRMP, SYSCFG_MEMRMP_MEM_MODE)
  466. /** @brief System Flash memory mapped at 0x00000000
  467. */
  468. #define __HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH() MODIFY_REG(SYSCFG->MEMRMP, SYSCFG_MEMRMP_MEM_MODE, SYSCFG_MEMRMP_MEM_MODE_0)
  469. /** @brief Embedded SRAM mapped at 0x00000000
  470. */
  471. #define __HAL_SYSCFG_REMAPMEMORY_SRAM() MODIFY_REG(SYSCFG->MEMRMP, SYSCFG_MEMRMP_MEM_MODE, SYSCFG_MEMRMP_MEM_MODE_0 | SYSCFG_MEMRMP_MEM_MODE_1)
  472. #if defined(FSMC_R_BASE)
  473. /** @brief FSMC Bank1 (NOR/PSRAM 1 and 2) mapped at 0x00000000
  474. */
  475. #define __HAL_SYSCFG_REMAPMEMORY_FSMC() MODIFY_REG(SYSCFG->MEMRMP, SYSCFG_MEMRMP_MEM_MODE, SYSCFG_MEMRMP_MEM_MODE_1)
  476. #endif /* FSMC_R_BASE */
  477. /**
  478. * @brief Returns the boot mode as configured by user.
  479. * @retval The boot mode as configured by user. The returned value can be one
  480. * of the following values:
  481. * @arg SYSCFG_BOOT_MAINFLASH
  482. * @arg SYSCFG_BOOT_SYSTEMFLASH
  483. * @arg SYSCFG_BOOT_FSMC (available only for STM32L151xD, STM32L152xD & STM32L162xD)
  484. * @arg SYSCFG_BOOT_SRAM
  485. */
  486. #define __HAL_SYSCFG_GET_BOOT_MODE() READ_BIT(SYSCFG->MEMRMP, SYSCFG_MEMRMP_BOOT_MODE)
  487. /**
  488. * @}
  489. */
  490. /** @defgroup SYSCFG_USBConfig USB DP line Configuration
  491. * @{
  492. */
  493. /**
  494. * @brief Control the internal pull-up on USB DP line.
  495. */
  496. #define __HAL_SYSCFG_USBPULLUP_ENABLE() SET_BIT(SYSCFG->PMC, SYSCFG_PMC_USB_PU)
  497. #define __HAL_SYSCFG_USBPULLUP_DISABLE() CLEAR_BIT(SYSCFG->PMC, SYSCFG_PMC_USB_PU)
  498. /**
  499. * @}
  500. */
  501. /**
  502. * @}
  503. */
  504. /** @defgroup RI_Macris RI: Routing Interface
  505. * @{
  506. */
  507. /** @defgroup RI_InputCaputureConfig Input Capture configuration
  508. * @{
  509. */
  510. /**
  511. * @brief Configures the routing interface to map Input Capture 1 of TIMx to a selected I/O pin.
  512. * @param __TIMSELECT__ Timer select.
  513. * This parameter can be one of the following values:
  514. * @arg TIM_SELECT_NONE: No timer selected and default Timer mapping is enabled.
  515. * @arg TIM_SELECT_TIM2: Timer 2 Input Captures to be routed.
  516. * @arg TIM_SELECT_TIM3: Timer 3 Input Captures to be routed.
  517. * @arg TIM_SELECT_TIM4: Timer 4 Input Captures to be routed.
  518. * @param __INPUT__ selects which pin to be routed to Input Capture.
  519. * This parameter must be a value of @ref RI_InputCaptureRouting
  520. * e.g.
  521. * __HAL_RI_REMAP_INPUTCAPTURE1(TIM_SELECT_TIM2, RI_INPUTCAPTUREROUTING_1)
  522. * allows routing of Input capture IC1 of TIM2 to PA4.
  523. * For details about correspondence between RI_INPUTCAPTUREROUTING_x
  524. * and I/O pins refer to the parameters' description in the header file
  525. * or refer to the product reference manual.
  526. * @note Input capture selection bits are not reset by this function.
  527. * To reset input capture selection bits, use SYSCFG_RIDeInit() function.
  528. * @note The I/O should be configured in alternate function mode (AF14) using
  529. * GPIO_PinAFConfig() function.
  530. * @retval None.
  531. */
  532. #define __HAL_RI_REMAP_INPUTCAPTURE1(__TIMSELECT__, __INPUT__) \
  533. do {assert_param(IS_RI_TIM(__TIMSELECT__)); \
  534. assert_param(IS_RI_INPUTCAPTURE_ROUTING(__INPUT__)); \
  535. MODIFY_REG(RI->ICR, RI_ICR_TIM, (__TIMSELECT__)); \
  536. SET_BIT(RI->ICR, RI_INPUTCAPTURE_IC1); \
  537. MODIFY_REG(RI->ICR, RI_ICR_IC1OS, (__INPUT__) << POSITION_VAL(RI_ICR_IC1OS)); \
  538. }while(0)
  539. /**
  540. * @brief Configures the routing interface to map Input Capture 2 of TIMx to a selected I/O pin.
  541. * @param __TIMSELECT__ Timer select.
  542. * This parameter can be one of the following values:
  543. * @arg TIM_SELECT_NONE: No timer selected and default Timer mapping is enabled.
  544. * @arg TIM_SELECT_TIM2: Timer 2 Input Captures to be routed.
  545. * @arg TIM_SELECT_TIM3: Timer 3 Input Captures to be routed.
  546. * @arg TIM_SELECT_TIM4: Timer 4 Input Captures to be routed.
  547. * @param __INPUT__ selects which pin to be routed to Input Capture.
  548. * This parameter must be a value of @ref RI_InputCaptureRouting
  549. * @retval None.
  550. */
  551. #define __HAL_RI_REMAP_INPUTCAPTURE2(__TIMSELECT__, __INPUT__) \
  552. do {assert_param(IS_RI_TIM(__TIMSELECT__)); \
  553. assert_param(IS_RI_INPUTCAPTURE_ROUTING(__INPUT__)); \
  554. MODIFY_REG(RI->ICR, RI_ICR_TIM, (__TIMSELECT__)); \
  555. SET_BIT(RI->ICR, RI_INPUTCAPTURE_IC2); \
  556. MODIFY_REG(RI->ICR, RI_ICR_IC2OS, (__INPUT__) << POSITION_VAL(RI_ICR_IC2OS)); \
  557. }while(0)
  558. /**
  559. * @brief Configures the routing interface to map Input Capture 3 of TIMx to a selected I/O pin.
  560. * @param __TIMSELECT__ Timer select.
  561. * This parameter can be one of the following values:
  562. * @arg TIM_SELECT_NONE: No timer selected and default Timer mapping is enabled.
  563. * @arg TIM_SELECT_TIM2: Timer 2 Input Captures to be routed.
  564. * @arg TIM_SELECT_TIM3: Timer 3 Input Captures to be routed.
  565. * @arg TIM_SELECT_TIM4: Timer 4 Input Captures to be routed.
  566. * @param __INPUT__ selects which pin to be routed to Input Capture.
  567. * This parameter must be a value of @ref RI_InputCaptureRouting
  568. * @retval None.
  569. */
  570. #define __HAL_RI_REMAP_INPUTCAPTURE3(__TIMSELECT__, __INPUT__) \
  571. do {assert_param(IS_RI_TIM(__TIMSELECT__)); \
  572. assert_param(IS_RI_INPUTCAPTURE_ROUTING(__INPUT__)); \
  573. MODIFY_REG(RI->ICR, RI_ICR_TIM, (__TIMSELECT__)); \
  574. SET_BIT(RI->ICR, RI_INPUTCAPTURE_IC3); \
  575. MODIFY_REG(RI->ICR, RI_ICR_IC3OS, (__INPUT__) << POSITION_VAL(RI_ICR_IC3OS)); \
  576. }while(0)
  577. /**
  578. * @brief Configures the routing interface to map Input Capture 4 of TIMx to a selected I/O pin.
  579. * @param __TIMSELECT__ Timer select.
  580. * This parameter can be one of the following values:
  581. * @arg TIM_SELECT_NONE: No timer selected and default Timer mapping is enabled.
  582. * @arg TIM_SELECT_TIM2: Timer 2 Input Captures to be routed.
  583. * @arg TIM_SELECT_TIM3: Timer 3 Input Captures to be routed.
  584. * @arg TIM_SELECT_TIM4: Timer 4 Input Captures to be routed.
  585. * @param __INPUT__ selects which pin to be routed to Input Capture.
  586. * This parameter must be a value of @ref RI_InputCaptureRouting
  587. * @retval None.
  588. */
  589. #define __HAL_RI_REMAP_INPUTCAPTURE4(__TIMSELECT__, __INPUT__) \
  590. do {assert_param(IS_RI_TIM(__TIMSELECT__)); \
  591. assert_param(IS_RI_INPUTCAPTURE_ROUTING(__INPUT__)); \
  592. MODIFY_REG(RI->ICR, RI_ICR_TIM, (__TIMSELECT__)); \
  593. SET_BIT(RI->ICR, RI_INPUTCAPTURE_IC4); \
  594. MODIFY_REG(RI->ICR, RI_ICR_IC4OS, (__INPUT__) << POSITION_VAL(RI_ICR_IC4OS)); \
  595. }while(0)
  596. /**
  597. * @}
  598. */
  599. /** @defgroup RI_SwitchControlConfig Switch Control configuration
  600. * @{
  601. */
  602. /**
  603. * @brief Enable or disable the switch control mode.
  604. * @note ENABLE: ADC analog switches closed if the corresponding
  605. * I/O switch is also closed.
  606. * When using COMP1, switch control mode must be enabled.
  607. * @note DISABLE: ADC analog switches open or controlled by the ADC interface.
  608. * When using the ADC for acquisition, switch control mode
  609. * must be disabled.
  610. * @note COMP1 comparator and ADC cannot be used at the same time since
  611. * they share the ADC switch matrix.
  612. * @retval None
  613. */
  614. #define __HAL_RI_SWITCHCONTROLMODE_ENABLE() SET_BIT(RI->ASCR1, RI_ASCR1_SCM)
  615. #define __HAL_RI_SWITCHCONTROLMODE_DISABLE() CLEAR_BIT(RI->ASCR1, RI_ASCR1_SCM)
  616. /*
  617. * @brief Close or Open the routing interface Input Output switches.
  618. * @param __IOSWITCH__ selects the I/O analog switch number.
  619. * This parameter must be a value of @ref RI_IOSwitch
  620. * @retval None
  621. */
  622. #define __HAL_RI_IOSWITCH_CLOSE(__IOSWITCH__) do { assert_param(IS_RI_IOSWITCH(__IOSWITCH__)); \
  623. if ((__IOSWITCH__) >> 31 != 0 ) \
  624. { \
  625. SET_BIT(RI->ASCR1, (__IOSWITCH__) & 0x7FFFFFFF); \
  626. } \
  627. else \
  628. { \
  629. SET_BIT(RI->ASCR2, (__IOSWITCH__)); \
  630. } \
  631. }while(0)
  632. #define __HAL_RI_IOSWITCH_OPEN(__IOSWITCH__) do { assert_param(IS_RI_IOSWITCH(__IOSWITCH__)); \
  633. if ((__IOSWITCH__) >> 31 != 0 ) \
  634. { \
  635. CLEAR_BIT(RI->ASCR1, (__IOSWITCH__) & 0x7FFFFFFF); \
  636. } \
  637. else \
  638. { \
  639. CLEAR_BIT(RI->ASCR2, (__IOSWITCH__)); \
  640. } \
  641. }while(0)
  642. #if defined (COMP_CSR_SW1)
  643. /**
  644. * @brief Close or open the internal switch COMP1_SW1.
  645. * This switch connects I/O pin PC3 (can be used as ADC channel 13)
  646. * and OPAMP3 ouput to ADC switch matrix (ADC channel VCOMP, channel
  647. * 26) and COMP1 non-inverting input.
  648. * Pin PC3 connection depends on another switch setting, refer to
  649. * macro "__HAL_ADC_CHANNEL_SPEED_FAST()".
  650. * @retval None.
  651. */
  652. #define __HAL_RI_SWITCH_COMP1_SW1_CLOSE() SET_BIT(COMP->CSR, COMP_CSR_SW1)
  653. #define __HAL_RI_SWITCH_COMP1_SW1_OPEN() CLEAR_BIT(COMP->CSR, COMP_CSR_SW1)
  654. #endif /* COMP_CSR_SW1 */
  655. /**
  656. * @}
  657. */
  658. /** @defgroup RI_HystConfig Hysteresis Activation and Deactivation
  659. * @{
  660. */
  661. /**
  662. * @brief Enable or disable Hysteresis of the input schmitt triger of Ports A
  663. * When the I/Os are programmed in input mode by standard I/O port
  664. * registers, the Schmitt trigger and the hysteresis are enabled by default.
  665. * When hysteresis is disabled, it is possible to read the
  666. * corresponding port with a trigger level of VDDIO/2.
  667. * @param __IOPIN__ : Selects the pin(s) on which to enable or disable hysteresis.
  668. * This parameter must be a value of @ref RI_Pin
  669. * @retval None
  670. */
  671. #define __HAL_RI_HYSTERIS_PORTA_ON(__IOPIN__) do {assert_param(IS_RI_PIN(__IOPIN__)); \
  672. CLEAR_BIT(RI->HYSCR1, (__IOPIN__)); \
  673. } while(0)
  674. #define __HAL_RI_HYSTERIS_PORTA_OFF(__IOPIN__) do {assert_param(IS_RI_PIN(__IOPIN__)); \
  675. SET_BIT(RI->HYSCR1, (__IOPIN__)); \
  676. } while(0)
  677. /**
  678. * @brief Enable or disable Hysteresis of the input schmitt triger of Ports B
  679. * When the I/Os are programmed in input mode by standard I/O port
  680. * registers, the Schmitt trigger and the hysteresis are enabled by default.
  681. * When hysteresis is disabled, it is possible to read the
  682. * corresponding port with a trigger level of VDDIO/2.
  683. * @param __IOPIN__ : Selects the pin(s) on which to enable or disable hysteresis.
  684. * This parameter must be a value of @ref RI_Pin
  685. * @retval None
  686. */
  687. #define __HAL_RI_HYSTERIS_PORTB_ON(__IOPIN__) do {assert_param(IS_RI_PIN(__IOPIN__)); \
  688. CLEAR_BIT(RI->HYSCR1, (__IOPIN__) << 16 ); \
  689. } while(0)
  690. #define __HAL_RI_HYSTERIS_PORTB_OFF(__IOPIN__) do {assert_param(IS_RI_PIN(__IOPIN__)); \
  691. SET_BIT(RI->HYSCR1, (__IOPIN__) << 16 ); \
  692. } while(0)
  693. /**
  694. * @brief Enable or disable Hysteresis of the input schmitt triger of Ports C
  695. * When the I/Os are programmed in input mode by standard I/O port
  696. * registers, the Schmitt trigger and the hysteresis are enabled by default.
  697. * When hysteresis is disabled, it is possible to read the
  698. * corresponding port with a trigger level of VDDIO/2.
  699. * @param __IOPIN__ : Selects the pin(s) on which to enable or disable hysteresis.
  700. * This parameter must be a value of @ref RI_Pin
  701. * @retval None
  702. */
  703. #define __HAL_RI_HYSTERIS_PORTC_ON(__IOPIN__) do {assert_param(IS_RI_PIN(__IOPIN__)); \
  704. CLEAR_BIT(RI->HYSCR2, (__IOPIN__)); \
  705. } while(0)
  706. #define __HAL_RI_HYSTERIS_PORTC_OFF(__IOPIN__) do {assert_param(IS_RI_PIN(__IOPIN__)); \
  707. SET_BIT(RI->HYSCR2, (__IOPIN__)); \
  708. } while(0)
  709. /**
  710. * @brief Enable or disable Hysteresis of the input schmitt triger of Ports D
  711. * When the I/Os are programmed in input mode by standard I/O port
  712. * registers, the Schmitt trigger and the hysteresis are enabled by default.
  713. * When hysteresis is disabled, it is possible to read the
  714. * corresponding port with a trigger level of VDDIO/2.
  715. * @param __IOPIN__ : Selects the pin(s) on which to enable or disable hysteresis.
  716. * This parameter must be a value of @ref RI_Pin
  717. * @retval None
  718. */
  719. #define __HAL_RI_HYSTERIS_PORTD_ON(__IOPIN__) do {assert_param(IS_RI_PIN(__IOPIN__)); \
  720. CLEAR_BIT(RI->HYSCR2, (__IOPIN__) << 16 ); \
  721. } while(0)
  722. #define __HAL_RI_HYSTERIS_PORTD_OFF(__IOPIN__) do {assert_param(IS_RI_PIN(__IOPIN__)); \
  723. SET_BIT(RI->HYSCR2, (__IOPIN__) << 16 ); \
  724. } while(0)
  725. #if defined (GPIOE_BASE)
  726. /**
  727. * @brief Enable or disable Hysteresis of the input schmitt triger of Ports E
  728. * When the I/Os are programmed in input mode by standard I/O port
  729. * registers, the Schmitt trigger and the hysteresis are enabled by default.
  730. * When hysteresis is disabled, it is possible to read the
  731. * corresponding port with a trigger level of VDDIO/2.
  732. * @param __IOPIN__ : Selects the pin(s) on which to enable or disable hysteresis.
  733. * This parameter must be a value of @ref RI_Pin
  734. * @retval None
  735. */
  736. #define __HAL_RI_HYSTERIS_PORTE_ON(__IOPIN__) do {assert_param(IS_RI_PIN(__IOPIN__)); \
  737. CLEAR_BIT(RI->HYSCR3, (__IOPIN__)); \
  738. } while(0)
  739. #define __HAL_RI_HYSTERIS_PORTE_OFF(__IOPIN__) do {assert_param(IS_RI_PIN(__IOPIN__)); \
  740. SET_BIT(RI->HYSCR3, (__IOPIN__)); \
  741. } while(0)
  742. #endif /* GPIOE_BASE */
  743. #if defined(GPIOF_BASE) || defined(GPIOG_BASE)
  744. /**
  745. * @brief Enable or disable Hysteresis of the input schmitt triger of Ports F
  746. * When the I/Os are programmed in input mode by standard I/O port
  747. * registers, the Schmitt trigger and the hysteresis are enabled by default.
  748. * When hysteresis is disabled, it is possible to read the
  749. * corresponding port with a trigger level of VDDIO/2.
  750. * @param __IOPIN__ : Selects the pin(s) on which to enable or disable hysteresis.
  751. * This parameter must be a value of @ref RI_Pin
  752. * @retval None
  753. */
  754. #define __HAL_RI_HYSTERIS_PORTF_ON(__IOPIN__) do {assert_param(IS_RI_PIN(__IOPIN__)); \
  755. CLEAR_BIT(RI->HYSCR3, (__IOPIN__) << 16 ); \
  756. } while(0)
  757. #define __HAL_RI_HYSTERIS_PORTF_OFF(__IOPIN__) do {assert_param(IS_RI_PIN(__IOPIN__)); \
  758. SET_BIT(RI->HYSCR3, (__IOPIN__) << 16 ); \
  759. } while(0)
  760. /**
  761. * @brief Enable or disable Hysteresis of the input schmitt triger of Ports G
  762. * When the I/Os are programmed in input mode by standard I/O port
  763. * registers, the Schmitt trigger and the hysteresis are enabled by default.
  764. * When hysteresis is disabled, it is possible to read the
  765. * corresponding port with a trigger level of VDDIO/2.
  766. * @param __IOPIN__ : Selects the pin(s) on which to enable or disable hysteresis.
  767. * This parameter must be a value of @ref RI_Pin
  768. * @retval None
  769. */
  770. #define __HAL_RI_HYSTERIS_PORTG_ON(__IOPIN__) do {assert_param(IS_RI_PIN(__IOPIN__)); \
  771. CLEAR_BIT(RI->HYSCR4, (__IOPIN__)); \
  772. } while(0)
  773. #define __HAL_RI_HYSTERIS_PORTG_OFF(__IOPIN__) do {assert_param(IS_RI_PIN(__IOPIN__)); \
  774. SET_BIT(RI->HYSCR4, (__IOPIN__)); \
  775. } while(0)
  776. #endif /* GPIOF_BASE || GPIOG_BASE */
  777. /**
  778. * @}
  779. */
  780. /**
  781. * @}
  782. */
  783. /**
  784. * @}
  785. */
  786. /* Exported variables --------------------------------------------------------*/
  787. /** @defgroup HAL_Exported_Variables HAL Exported Variables
  788. * @{
  789. */
  790. extern __IO uint32_t uwTick;
  791. extern uint32_t uwTickPrio;
  792. extern uint32_t uwTickFreq;
  793. /**
  794. * @}
  795. */
  796. /* Exported functions --------------------------------------------------------*/
  797. /** @addtogroup HAL_Exported_Functions
  798. * @{
  799. */
  800. /** @addtogroup HAL_Exported_Functions_Group1
  801. * @{
  802. */
  803. /* Initialization and de-initialization functions ******************************/
  804. HAL_StatusTypeDef HAL_Init(void);
  805. HAL_StatusTypeDef HAL_DeInit(void);
  806. void HAL_MspInit(void);
  807. void HAL_MspDeInit(void);
  808. HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority);
  809. /**
  810. * @}
  811. */
  812. /** @addtogroup HAL_Exported_Functions_Group2
  813. * @{
  814. */
  815. /* Peripheral Control functions ************************************************/
  816. void HAL_IncTick(void);
  817. void HAL_Delay(uint32_t Delay);
  818. uint32_t HAL_GetTick(void);
  819. uint32_t HAL_GetTickPrio(void);
  820. HAL_StatusTypeDef HAL_SetTickFreq(uint32_t Freq);
  821. uint32_t HAL_GetTickFreq(void);
  822. void HAL_SuspendTick(void);
  823. void HAL_ResumeTick(void);
  824. uint32_t HAL_GetHalVersion(void);
  825. uint32_t HAL_GetREVID(void);
  826. uint32_t HAL_GetDEVID(void);
  827. uint32_t HAL_GetUIDw0(void);
  828. uint32_t HAL_GetUIDw1(void);
  829. uint32_t HAL_GetUIDw2(void);
  830. /**
  831. * @}
  832. */
  833. /** @addtogroup HAL_Exported_Functions_Group3
  834. * @{
  835. */
  836. /* DBGMCU Peripheral Control functions *****************************************/
  837. void HAL_DBGMCU_EnableDBGSleepMode(void);
  838. void HAL_DBGMCU_DisableDBGSleepMode(void);
  839. void HAL_DBGMCU_EnableDBGStopMode(void);
  840. void HAL_DBGMCU_DisableDBGStopMode(void);
  841. void HAL_DBGMCU_EnableDBGStandbyMode(void);
  842. void HAL_DBGMCU_DisableDBGStandbyMode(void);
  843. /**
  844. * @}
  845. */
  846. /**
  847. * @}
  848. */
  849. /**
  850. * @}
  851. */
  852. /**
  853. * @}
  854. */
  855. #ifdef __cplusplus
  856. }
  857. #endif
  858. #endif /* __STM32L1xx_HAL_H */
  859. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/