stm32l1xx_hal_opamp.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  1. /**
  2. ******************************************************************************
  3. * @file stm32l1xx_hal_opamp.h
  4. * @author MCD Application Team
  5. * @version V1.0.0
  6. * @date 5-September-2014
  7. * @brief Header file of OPAMP HAL module.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
  12. *
  13. * Redistribution and use in source and binary forms, with or without modification,
  14. * are permitted provided that the following conditions are met:
  15. * 1. Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and/or other materials provided with the distribution.
  20. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  21. * may be used to endorse or promote products derived from this software
  22. * without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  27. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  28. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  30. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  31. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  32. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  33. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ******************************************************************************
  36. */
  37. /* Define to prevent recursive inclusion -------------------------------------*/
  38. #ifndef __STM32L1xx_HAL_OPAMP_H
  39. #define __STM32L1xx_HAL_OPAMP_H
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. #if defined (STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined (STM32L151xE) || defined (STM32L152xE) || defined (STM32L162xE) || defined (STM32L162xC) || defined (STM32L152xC) || defined (STM32L151xC)
  44. /* Includes ------------------------------------------------------------------*/
  45. #include "stm32l1xx_hal_def.h"
  46. /** @addtogroup STM32L1xx_HAL_Driver
  47. * @{
  48. */
  49. /** @addtogroup OPAMP
  50. * @{
  51. */
  52. /* Exported types ------------------------------------------------------------*/
  53. /** @defgroup OPAMP_Exported_Types OPAMP Exported Types
  54. * @{
  55. */
  56. /**
  57. * @brief OPAMP Init structure definition
  58. */
  59. typedef struct
  60. {
  61. uint32_t PowerSupplyRange; /*!< Specifies the power supply range: above or under 2.4V.
  62. This parameter must be a value of @ref OPAMP_PowerSupplyRange
  63. Caution: This parameter is common to all OPAMP instances: a modification of this parameter for the selected OPAMP impacts the other OPAMP instances. */
  64. uint32_t UserTrimming; /*!< Specifies the trimming mode
  65. This parameter must be a value of @ref OPAMP_UserTrimming
  66. UserTrimming is either factory or user trimming.
  67. Caution: This parameter is common to all OPAMP instances: a modification of this parameter for the selected OPAMP impacts the other OPAMP instances. */
  68. uint32_t Mode; /*!< Specifies the OPAMP mode
  69. This parameter must be a value of @ref OPAMP_Mode
  70. mode is either Standalone or Follower */
  71. uint32_t InvertingInput; /*!< Specifies the inverting input in Standalone mode
  72. - In Standalone mode: i.e when mode is OPAMP_STANDALONE_MODE
  73. This parameter must be a value of @ref OPAMP_InvertingInput
  74. InvertingInput is either VM0 or VM1
  75. - In Follower mode: i.e when mode is OPAMP_FOLLOWER_MODE
  76. This parameter is Not Applicable */
  77. uint32_t NonInvertingInput; /*!< Specifies the non inverting input of the opamp:
  78. This parameter must be a value of @ref OPAMP_NonInvertingInput
  79. NonInvertingInput is either VP0, VP1 or VP2 */
  80. uint32_t PowerMode; /*!< Specifies the power mode Normal or Low-Power.
  81. This parameter must be a value of @ref OPAMP_PowerMode */
  82. uint32_t TrimmingValueP; /*!< Specifies the offset trimming value (PMOS)
  83. i.e. when UserTrimming is OPAMP_TRIMMING_USER.
  84. This parameter must be a number between Min_Data = 0 and Max_Data = 30 (Trimming value 31 is forbidden) */
  85. uint32_t TrimmingValueN; /*!< Specifies the offset trimming value (NMOS)
  86. i.e. when UserTrimming is OPAMP_TRIMMING_USER.
  87. This parameter must be a number between Min_Data = 0 and Max_Data = 30 (Trimming value 31 is forbidden) */
  88. uint32_t TrimmingValuePLowPower; /*!< Specifies the offset trimming value (PMOS)
  89. i.e. when UserTrimming is OPAMP_TRIMMING_USER.
  90. This parameter must be a number between Min_Data = 0 and Max_Data = 30 (Trimming value 31 is forbidden) */
  91. uint32_t TrimmingValueNLowPower; /*!< Specifies the offset trimming value (NMOS)
  92. i.e. when UserTrimming is OPAMP_TRIMMING_USER.
  93. This parameter must be a number between Min_Data = 0 and Max_Data = 30 (Trimming value 31 is forbidden) */
  94. }OPAMP_InitTypeDef;
  95. /**
  96. * @brief HAL State structures definition
  97. */
  98. typedef enum
  99. {
  100. HAL_OPAMP_STATE_RESET = 0x00000000, /*!< OPMAP is not yet Initialized */
  101. HAL_OPAMP_STATE_READY = 0x00000001, /*!< OPAMP is initialized and ready for use */
  102. HAL_OPAMP_STATE_CALIBBUSY = 0x00000002, /*!< OPAMP is enabled in auto calibration mode */
  103. HAL_OPAMP_STATE_BUSY = 0x00000004, /*!< OPAMP is enabled and running in normal mode */
  104. HAL_OPAMP_STATE_BUSYLOCKED = 0x00000005, /*!< OPAMP is locked
  105. only system reset allows reconfiguring the opamp. */
  106. }HAL_OPAMP_StateTypeDef;
  107. /**
  108. * @brief OPAMP Handle Structure definition
  109. */
  110. typedef struct
  111. {
  112. OPAMP_TypeDef *Instance; /*!< OPAMP instance's registers base address */
  113. OPAMP_InitTypeDef Init; /*!< OPAMP required parameters */
  114. HAL_StatusTypeDef Status; /*!< OPAMP peripheral status */
  115. HAL_LockTypeDef Lock; /*!< Locking object */
  116. __IO HAL_OPAMP_StateTypeDef State; /*!< OPAMP communication state */
  117. } OPAMP_HandleTypeDef;
  118. /**
  119. * @brief OPAMP_TrimmingValueTypeDef @brief definition
  120. */
  121. typedef uint32_t OPAMP_TrimmingValueTypeDef;
  122. /**
  123. * @}
  124. */
  125. /* Exported constants --------------------------------------------------------*/
  126. /** @defgroup OPAMP_Exported_Constants OPAMP Exported Constants
  127. * @{
  128. */
  129. /**
  130. * OTR register Mask
  131. */
  132. #define OPAMP_TRIM_VALUE_MASK OPAMP_OTR_AO1_OPT_OFFSET_TRIM_LOW
  133. /**
  134. * CSR register Mask
  135. */
  136. #define OPAMP_CSR_INSTANCE_OFFSET ((uint32_t) 8) /* Offset of each OPAMP instance into register CSR */
  137. #define OPAMP_OTR_INSTANCE_OFFSET ((uint32_t) 10) /* Offset of each OPAMP instance into register OTR */
  138. /** @defgroup OPAMP_Mode OPAMP Mode
  139. * @{
  140. */
  141. #define OPAMP_STANDALONE_MODE ((uint32_t)0x00000000) /*!< OPAMP standalone mode */
  142. #define OPAMP_FOLLOWER_MODE ((uint32_t)0x00000001) /*!< OPAMP follower mode */
  143. #define IS_OPAMP_FUNCTIONAL_NORMALMODE(INPUT) (((INPUT) == OPAMP_STANDALONE_MODE) || \
  144. ((INPUT) == OPAMP_FOLLOWER_MODE))
  145. /**
  146. * @}
  147. */
  148. /** @defgroup OPAMP_NonInvertingInput OPAMP NonInvertingInput
  149. * @{
  150. */
  151. #define OPAMP_NONINVERTINGINPUT_VP0 ((uint32_t)0x00000000) /*!< Comparator non-inverting input connected to dedicated IO pin low-leakage */
  152. #define OPAMP_NONINVERTINGINPUT_DAC_CH1 ((uint32_t)0x00000001) /*!< Comparator non-inverting input connected internally to DAC channel 1 */
  153. #define OPAMP_NONINVERTINGINPUT_DAC_CH2 ((uint32_t)0x00000002) /*!< Comparator non-inverting input connected internally to DAC channel 2. Available on OPAMP2 only. */
  154. #define IS_OPAMP_NONINVERTING_INPUT(INPUT) (((INPUT) == OPAMP_NONINVERTINGINPUT_VP0) || \
  155. ((INPUT) == OPAMP_NONINVERTINGINPUT_DAC_CH1) || \
  156. ((INPUT) == OPAMP_NONINVERTINGINPUT_DAC_CH2) )
  157. /**
  158. * @}
  159. */
  160. /** @defgroup OPAMP_InvertingInput OPAMP InvertingInput
  161. * @{
  162. */
  163. #define OPAMP_INVERTINGINPUT_VM0 ((uint32_t)0x00000000) /*!< Comparator inverting input connected to dedicated IO pin low-leakage */
  164. #define OPAMP_INVERTINGINPUT_VM1 ((uint32_t)0x00000001) /*!< Comparator inverting input connected to alternative IO pin available on some device packages */
  165. #define OPAMP_INVERTINGINPUT_VINM OPAMP_INVERTINGINPUT_VM1 /*!< Alternate name for comparator inverting input connected to alternative IO pin available on some device packages */
  166. #define IOPAMP_INVERTINGINPUT_VM0 OPAMP_INVERTINGINPUT_VM0 /* For compatibility with other STM32 devices */
  167. #define IOPAMP_INVERTINGINPUT_VM1 OPAMP_INVERTINGINPUT_VM1 /* For compatibility with other STM32 devices */
  168. #define IS_OPAMP_INVERTING_INPUT(INPUT) (((INPUT) == OPAMP_INVERTINGINPUT_VM0) || \
  169. ((INPUT) == OPAMP_INVERTINGINPUT_VM1) )
  170. /**
  171. * @}
  172. */
  173. /** @defgroup OPAMP_PowerMode OPAMP PowerMode
  174. * @{
  175. */
  176. #define OPAMP_POWERMODE_NORMAL ((uint32_t)0x00000000)
  177. #define OPAMP_POWERMODE_LOWPOWER ((uint32_t)0x00000001)
  178. #define IS_OPAMP_POWERMODE(TRIMMING) (((TRIMMING) == OPAMP_POWERMODE_NORMAL) || \
  179. ((TRIMMING) == OPAMP_POWERMODE_LOWPOWER) )
  180. /**
  181. * @}
  182. */
  183. /** @defgroup OPAMP_PowerSupplyRange OPAMP PowerSupplyRange
  184. * @{
  185. */
  186. #define OPAMP_POWERSUPPLY_LOW ((uint32_t)0x00000000) /*!< Power supply range low (VDDA lower than 2.4V) */
  187. #define OPAMP_POWERSUPPLY_HIGH OPAMP_CSR_AOP_RANGE /*!< Power supply range high (VDDA higher than 2.4V) */
  188. #define IS_OPAMP_POWER_SUPPLY_RANGE(RANGE) (((RANGE) == OPAMP_POWERSUPPLY_LOW) || \
  189. ((RANGE) == OPAMP_POWERSUPPLY_HIGH) )
  190. /**
  191. * @}
  192. */
  193. /** @defgroup OPAMP_UserTrimming OPAMP UserTrimming
  194. * @{
  195. */
  196. #define OPAMP_TRIMMING_FACTORY ((uint32_t)0x00000000) /*!< Factory trimming */
  197. #define OPAMP_TRIMMING_USER OPAMP_OTR_OT_USER /*!< User trimming */
  198. #define IS_OPAMP_TRIMMING(TRIMMING) (((TRIMMING) == OPAMP_TRIMMING_FACTORY) || \
  199. ((TRIMMING) == OPAMP_TRIMMING_USER))
  200. /**
  201. * @}
  202. */
  203. /** @defgroup OPAMP_FactoryTrimming OPAMP FactoryTrimming
  204. * @{
  205. */
  206. #define OPAMP_FACTORYTRIMMING_DUMMY ((uint32_t)0xFFFFFFFF) /*!< Dummy value if trimming value could not be retrieved */
  207. #define OPAMP_FACTORYTRIMMING_P ((uint32_t)0x00000000) /*!< Offset trimming P */
  208. #define OPAMP_FACTORYTRIMMING_N POSITION_VAL(OPAMP_OTR_AO1_OPT_OFFSET_TRIM_HIGH) /*!< Offset trimming N */
  209. #define IS_OPAMP_FACTORYTRIMMING(TRIMMING) (((TRIMMING) == OPAMP_FACTORYTRIMMING_N) || \
  210. ((TRIMMING) == OPAMP_FACTORYTRIMMING_P) )
  211. /**
  212. * @}
  213. */
  214. /**
  215. * @}
  216. */
  217. /* Private constants ---------------------------------------------------------*/
  218. /** @defgroup OPAMP_Private_Constants OPAMP Private Constants
  219. * @{
  220. */
  221. /* Offset trimming time: during calibration, minimum time needed between two */
  222. /* steps to have 1 mV accuracy. */
  223. /* Refer to datasheet, electrical characteristics: parameter tOFFTRIM Typ=1ms.*/
  224. /* Unit: ms. */
  225. #define OPAMP_TRIMMING_DELAY ((uint32_t) 1)
  226. /**
  227. * @}
  228. */
  229. /* Exported macros -----------------------------------------------------------*/
  230. /** @defgroup OPAMP_Private_Macro OPAMP Private Macro
  231. * @{
  232. */
  233. /** @brief Reset OPAMP handle state
  234. * @param __HANDLE__: OPAMP handle.
  235. * @retval None
  236. */
  237. #define __HAL_OPAMP_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_OPAMP_STATE_RESET)
  238. /**
  239. * @}
  240. */
  241. /* Private macro -------------------------------------------------------------*/
  242. /** @defgroup OPAMP_Private_Macro OPAMP Private Macro
  243. * @{
  244. */
  245. /**
  246. * @brief Select the OPAMP bit OPAxPD (power-down) corresponding to the
  247. * selected OPAMP instance.
  248. * @param __HANDLE__: OPAMP handle
  249. * @retval None
  250. */
  251. #define __OPAMP_CSR_OPAXPD(__HANDLE__) \
  252. (OPAMP_CSR_OPA1PD << (__OPAMP_INSTANCE_DECIMAL__(__HANDLE__) * OPAMP_CSR_INSTANCE_OFFSET))
  253. /**
  254. * @brief Select the OPAMP bit S3SELx (switch 3) corresponding to the
  255. * selected OPAMP instance.
  256. * @param __HANDLE__: OPAMP handle
  257. * @retval None
  258. */
  259. #define __OPAMP_CSR_S3SELX(__HANDLE__) \
  260. (OPAMP_CSR_S3SEL1 << (__OPAMP_INSTANCE_DECIMAL__(__HANDLE__) * OPAMP_CSR_INSTANCE_OFFSET))
  261. /**
  262. * @brief Select the OPAMP bit S4SELx (switch 4) corresponding to the
  263. * selected OPAMP instance.
  264. * @param __HANDLE__: OPAMP handle
  265. * @retval None
  266. */
  267. #define __OPAMP_CSR_S4SELX(__HANDLE__) \
  268. (OPAMP_CSR_S4SEL1 << (__OPAMP_INSTANCE_DECIMAL__(__HANDLE__) * OPAMP_CSR_INSTANCE_OFFSET))
  269. /**
  270. * @brief Select the OPAMP bit S5SELx (switch 5) corresponding to the
  271. * selected OPAMP instance.
  272. * @param __HANDLE__: OPAMP handle
  273. * @retval None
  274. */
  275. #define __OPAMP_CSR_S5SELX(__HANDLE__) \
  276. (OPAMP_CSR_S5SEL1 << (__OPAMP_INSTANCE_DECIMAL__(__HANDLE__) * OPAMP_CSR_INSTANCE_OFFSET))
  277. /**
  278. * @brief Select the OPAMP bit S3SELx (switch 6) corresponding to the
  279. * selected OPAMP instance.
  280. * @param __HANDLE__: OPAMP handle
  281. * @retval None
  282. */
  283. #define __OPAMP_CSR_S6SELX(__HANDLE__) \
  284. (OPAMP_CSR_S6SEL1 << (__OPAMP_INSTANCE_DECIMAL__(__HANDLE__) * OPAMP_CSR_INSTANCE_OFFSET))
  285. /**
  286. * @brief Select the OPAMP bit OPAxCAL_L (offset calibration for differential
  287. * pair P) corresponding to the selected OPAMP instance.
  288. * @param __HANDLE__: OPAMP handle
  289. * @retval None
  290. */
  291. #define __OPAMP_CSR_OPAXCAL_L(__HANDLE__) \
  292. (OPAMP_CSR_OPA1CAL_L << (__OPAMP_INSTANCE_DECIMAL__(__HANDLE__) * OPAMP_CSR_INSTANCE_OFFSET))
  293. /**
  294. * @brief Select the OPAMP bit OPAxCAL_H (offset calibration for differential
  295. * pair N) corresponding to the selected OPAMP instance.
  296. * @param __HANDLE__: OPAMP handle
  297. * @retval None
  298. */
  299. #define __OPAMP_CSR_OPAXCAL_H(__HANDLE__) \
  300. (OPAMP_CSR_OPA1CAL_H << (__OPAMP_INSTANCE_DECIMAL__(__HANDLE__) * OPAMP_CSR_INSTANCE_OFFSET))
  301. /**
  302. * @brief Select the OPAMP bit OPAxLPM (low power mode) corresponding to the
  303. * selected OPAMP instance.
  304. * @param __HANDLE__: OPAMP handle
  305. * @retval None
  306. */
  307. #define __OPAMP_CSR_OPAXLPM(__HANDLE__) \
  308. (OPAMP_CSR_OPA1LPM << (__OPAMP_INSTANCE_DECIMAL__(__HANDLE__) * OPAMP_CSR_INSTANCE_OFFSET))
  309. /**
  310. * @brief Select the OPAMP bits of all switches corresponding to the
  311. * selected OPAMP instance.
  312. * @param __HANDLE__: OPAMP handle
  313. * @retval None
  314. */
  315. #define __OPAMP_CSR_ALL_SWITCHES(__HANDLE__) \
  316. ( ( ((__HANDLE__)->Instance != OPAMP2) \
  317. )? \
  318. ( \
  319. ((OPAMP_CSR_S3SEL1 | OPAMP_CSR_S4SEL1 | OPAMP_CSR_S5SEL1 | OPAMP_CSR_S6SEL1) << (__OPAMP_INSTANCE_DECIMAL__(__HANDLE__) * OPAMP_CSR_INSTANCE_OFFSET)) \
  320. | \
  321. (OPAMP_CSR_ANAWSEL1 << (__OPAMP_INSTANCE_DECIMAL__(__HANDLE__))) \
  322. ) \
  323. : \
  324. ( \
  325. ((OPAMP_CSR_S3SEL1 | OPAMP_CSR_S4SEL1 | OPAMP_CSR_S5SEL1 | OPAMP_CSR_S6SEL1) << (__OPAMP_INSTANCE_DECIMAL__(__HANDLE__) * OPAMP_CSR_INSTANCE_OFFSET)) \
  326. | \
  327. (OPAMP_CSR_ANAWSEL1 << (__OPAMP_INSTANCE_DECIMAL__(__HANDLE__))) \
  328. | \
  329. (OPAMP_CSR_S7SEL2) \
  330. ) \
  331. )
  332. /**
  333. * @brief Select the OPAMP bit ANAWSELx (switch SanA) corresponding to the
  334. * selected OPAMP instance.
  335. * @param __HANDLE__: OPAMP handle
  336. * @retval None
  337. */
  338. #define __OPAMP_CSR_ANAWSELX(__HANDLE__) \
  339. (OPAMP_CSR_ANAWSEL1 << (__OPAMP_INSTANCE_DECIMAL__(__HANDLE__)))
  340. /**
  341. * @brief Select the OPAMP bit OPAxCALOUT in function of the selected
  342. * OPAMP instance.
  343. * @param __HANDLE__: OPAMP handle
  344. * @retval None
  345. */
  346. #define __OPAMP_CSR_OPAXCALOUT(__HANDLE__) \
  347. (OPAMP_CSR_OPA1CALOUT << (__OPAMP_INSTANCE_DECIMAL__(__HANDLE__)))
  348. /**
  349. * @brief Select the OPAMP trimming bits position value (position of LSB)
  350. * in register OPAMP_OTR or register OPAMP_LPOTR in function of the selected
  351. * OPAMP instance and the transistors differential pair high (PMOS) or
  352. * low (NMOS).
  353. * @param __HANDLE__: OPAMP handle
  354. * @param __TRIM_HIGH_LOW__: transistors differential pair high or low.
  355. * Must be a value of @ref OPAMP_FactoryTrimming.
  356. * @retval None
  357. */
  358. #define __OPAMP_OFFSET_TRIM_BITSPOSITION(__HANDLE__, __TRIM_HIGH_LOW__) \
  359. ((__OPAMP_INSTANCE_DECIMAL__((__HANDLE__)) * OPAMP_OTR_INSTANCE_OFFSET) + (__TRIM_HIGH_LOW__))
  360. /**
  361. * @brief Shift the OPAMP trimming bits to register OPAMP_OTR or register
  362. * OPAMP_LPOTR in function of the selected OPAMP instance and the transistors
  363. * differential pair high (PMOS) or low (NMOS).
  364. * @param __HANDLE__: OPAMP handle
  365. * @param __TRIM_HIGH_LOW__: transistors differential pair high or low.
  366. * Must be a value of @ref OPAMP_FactoryTrimming.
  367. * @param __TRIMMING_VALUE__: Trimming value
  368. * @retval None
  369. */
  370. #define __OPAMP_OFFSET_TRIM_SET(__HANDLE__, __TRIM_HIGH_LOW__, __TRIMMING_VALUE__) \
  371. ((__TRIMMING_VALUE__) << (__OPAMP_OFFSET_TRIM_BITSPOSITION((__HANDLE__), (__TRIM_HIGH_LOW__))))
  372. /**
  373. * @brief Check that trimming value is within correct range
  374. * @param TRIMMINGVALUE: OPAMP trimming value
  375. * @retval None
  376. */
  377. #define IS_OPAMP_TRIMMINGVALUE(TRIMMINGVALUE) ((TRIMMINGVALUE) <= 0x1E)
  378. /**
  379. * @}
  380. */
  381. /* Include OPAMP HAL Extension module */
  382. #include "stm32l1xx_hal_opamp_ex.h"
  383. /* Exported functions --------------------------------------------------------*/
  384. /** @addtogroup OPAMP_Exported_Functions
  385. * @{
  386. */
  387. /** @addtogroup OPAMP_Exported_Functions_Group1
  388. * @{
  389. */
  390. /* Initialization/de-initialization functions **********************************/
  391. HAL_StatusTypeDef HAL_OPAMP_Init(OPAMP_HandleTypeDef *hopamp);
  392. HAL_StatusTypeDef HAL_OPAMP_DeInit (OPAMP_HandleTypeDef *hopamp);
  393. void HAL_OPAMP_MspInit(OPAMP_HandleTypeDef *hopamp);
  394. void HAL_OPAMP_MspDeInit(OPAMP_HandleTypeDef *hopamp);
  395. /**
  396. * @}
  397. */
  398. /** @addtogroup OPAMP_Exported_Functions_Group2
  399. * @{
  400. */
  401. /* I/O operation functions *****************************************************/
  402. HAL_StatusTypeDef HAL_OPAMP_Start(OPAMP_HandleTypeDef *hopamp);
  403. HAL_StatusTypeDef HAL_OPAMP_Stop(OPAMP_HandleTypeDef *hopamp);
  404. HAL_StatusTypeDef HAL_OPAMP_SelfCalibrate(OPAMP_HandleTypeDef *hopamp);
  405. OPAMP_TrimmingValueTypeDef HAL_OPAMP_GetTrimOffset (OPAMP_HandleTypeDef *hopamp, uint32_t trimmingoffset);
  406. /**
  407. * @}
  408. */
  409. /** @addtogroup OPAMP_Exported_Functions_Group3
  410. * @{
  411. */
  412. /* Peripheral Control functions ************************************************/
  413. HAL_StatusTypeDef HAL_OPAMP_Lock(OPAMP_HandleTypeDef *hopamp);
  414. /**
  415. * @}
  416. */
  417. /** @addtogroup OPAMP_Exported_Functions_Group4
  418. * @{
  419. */
  420. /* Peripheral State functions **************************************************/
  421. HAL_OPAMP_StateTypeDef HAL_OPAMP_GetState(OPAMP_HandleTypeDef *hopamp);
  422. /**
  423. * @}
  424. */
  425. /**
  426. * @}
  427. */
  428. /**
  429. * @}
  430. */
  431. /**
  432. * @}
  433. */
  434. #endif /* STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L152xE || STM32L162xE || STM32L162xC || STM32L152xC || STM32L151xC */
  435. #ifdef __cplusplus
  436. }
  437. #endif
  438. #endif /* __STM32L1xx_HAL_OPAMP_H */
  439. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/