STM32L4xx_HAL_Driver  1.14.0
Initialization and de-initialization functions

Functions

ErrorStatus LL_COMP_DeInit (COMP_TypeDef *COMPx)
 De-initialize registers of the selected COMP instance to their default reset values. More...
 
ErrorStatus LL_COMP_Init (COMP_TypeDef *COMPx, LL_COMP_InitTypeDef *COMP_InitStruct)
 Initialize some features of COMP instance. More...
 
void LL_COMP_StructInit (LL_COMP_InitTypeDef *COMP_InitStruct)
 Set each LL_COMP_InitTypeDef field to default value. More...
 

Detailed Description

Function Documentation

◆ LL_COMP_DeInit()

ErrorStatus LL_COMP_DeInit ( COMP_TypeDef *  COMPx)

De-initialize registers of the selected COMP instance to their default reset values.

Note
If comparator is locked, de-initialization by software is not possible. The only way to unlock the comparator is a device hardware reset.
Parameters
COMPxCOMP instance
Return values
AnErrorStatus enumeration value:
  • SUCCESS: COMP registers are de-initialized
  • ERROR: COMP registers are not de-initialized

Definition at line 194 of file stm32l4xx_ll_comp.c.

195 {
196  ErrorStatus status = SUCCESS;
197 
198  /* Check the parameters */
199  assert_param(IS_COMP_ALL_INSTANCE(COMPx));
200 
201  /* Note: Hardware constraint (refer to description of this function): */
202  /* COMP instance must not be locked. */
203  if (LL_COMP_IsLocked(COMPx) == 0UL)
204  {
205  LL_COMP_WriteReg(COMPx, CSR, 0x00000000UL);
206 
207  }
208  else
209  {
210  /* Comparator instance is locked: de-initialization by software is */
211  /* not possible. */
212  /* The only way to unlock the comparator is a device hardware reset. */
213  status = ERROR;
214  }
215 
216  return status;
217 }
__STATIC_INLINE uint32_t LL_COMP_IsLocked(COMP_TypeDef *COMPx)
Get comparator lock state (0: COMP is unlocked, 1: COMP is locked).
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ LL_COMP_Init()

ErrorStatus LL_COMP_Init ( COMP_TypeDef *  COMPx,
LL_COMP_InitTypeDef COMP_InitStruct 
)

Initialize some features of COMP instance.

Note
This function configures features of the selected COMP instance. Some features are also available at scope COMP common instance (common to several COMP instances). Refer to functions having argument "COMPxy_COMMON" as parameter.
Parameters
COMPxCOMP instance
COMP_InitStructPointer to a LL_COMP_InitTypeDef structure
Return values
AnErrorStatus enumeration value:
  • SUCCESS: COMP registers are initialized
  • ERROR: COMP registers are not initialized

Definition at line 231 of file stm32l4xx_ll_comp.c.

232 {
233  ErrorStatus status = SUCCESS;
234 
235  /* Check the parameters */
236  assert_param(IS_COMP_ALL_INSTANCE(COMPx));
237  assert_param(IS_LL_COMP_POWER_MODE(COMP_InitStruct->PowerMode));
238  assert_param(IS_LL_COMP_INPUT_PLUS(COMPx, COMP_InitStruct->InputPlus));
239  assert_param(IS_LL_COMP_INPUT_MINUS(COMPx, COMP_InitStruct->InputMinus));
240  assert_param(IS_LL_COMP_INPUT_HYSTERESIS(COMP_InitStruct->InputHysteresis));
241  assert_param(IS_LL_COMP_OUTPUT_POLARITY(COMP_InitStruct->OutputPolarity));
242  assert_param(IS_LL_COMP_OUTPUT_BLANKING_SOURCE(COMPx, COMP_InitStruct->OutputBlankingSource));
243 
244  /* Note: Hardware constraint (refer to description of this function) */
245  /* COMP instance must not be locked. */
246  if (LL_COMP_IsLocked(COMPx) == 0UL)
247  {
248  /* Configuration of comparator instance : */
249  /* - PowerMode */
250  /* - InputPlus */
251  /* - InputMinus */
252  /* - InputHysteresis */
253  /* - OutputPolarity */
254  /* - OutputBlankingSource */
255 #if defined(COMP_CSR_INMESEL_1)
256  MODIFY_REG(COMPx->CSR,
257  COMP_CSR_PWRMODE
258  | COMP_CSR_INPSEL
259  | COMP_CSR_SCALEN
260  | COMP_CSR_BRGEN
261  | COMP_CSR_INMESEL
262  | COMP_CSR_INMSEL
263  | COMP_CSR_HYST
264  | COMP_CSR_POLARITY
265  | COMP_CSR_BLANKING
266  ,
267  COMP_InitStruct->PowerMode
268  | COMP_InitStruct->InputPlus
269  | COMP_InitStruct->InputMinus
270  | COMP_InitStruct->InputHysteresis
271  | COMP_InitStruct->OutputPolarity
272  | COMP_InitStruct->OutputBlankingSource
273  );
274 #else
275  MODIFY_REG(COMPx->CSR,
276  COMP_CSR_PWRMODE
277  | COMP_CSR_INPSEL
278  | COMP_CSR_SCALEN
279  | COMP_CSR_BRGEN
280  | COMP_CSR_INMSEL
281  | COMP_CSR_HYST
282  | COMP_CSR_POLARITY
283  | COMP_CSR_BLANKING
284  ,
285  COMP_InitStruct->PowerMode
286  | COMP_InitStruct->InputPlus
287  | COMP_InitStruct->InputMinus
288  | COMP_InitStruct->InputHysteresis
289  | COMP_InitStruct->OutputPolarity
290  | COMP_InitStruct->OutputBlankingSource
291  );
292 #endif
293 
294  }
295  else
296  {
297  /* Initialization error: COMP instance is locked. */
298  status = ERROR;
299  }
300 
301  return status;
302 }
__STATIC_INLINE uint32_t LL_COMP_IsLocked(COMP_TypeDef *COMPx)
Get comparator lock state (0: COMP is unlocked, 1: COMP is locked).
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ LL_COMP_StructInit()

void LL_COMP_StructInit ( LL_COMP_InitTypeDef COMP_InitStruct)

Set each LL_COMP_InitTypeDef field to default value.

Parameters
COMP_InitStructPointer to a LL_COMP_InitTypeDef structure whose fields will be set to default values.
Return values
None

Definition at line 310 of file stm32l4xx_ll_comp.c.

311 {
312  /* Set COMP_InitStruct fields to default values */
313  COMP_InitStruct->PowerMode = LL_COMP_POWERMODE_ULTRALOWPOWER;
314  COMP_InitStruct->InputPlus = LL_COMP_INPUT_PLUS_IO1;
315  COMP_InitStruct->InputMinus = LL_COMP_INPUT_MINUS_VREFINT;
316  COMP_InitStruct->InputHysteresis = LL_COMP_HYSTERESIS_NONE;
317  COMP_InitStruct->OutputPolarity = LL_COMP_OUTPUTPOL_NONINVERTED;
318  COMP_InitStruct->OutputBlankingSource = LL_COMP_BLANKINGSRC_NONE;
319 }