stm32l1xx_hal.h 44 KB

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