A31L12x F/W Packages  1.4.0
ABOV Cortex-M0+ Core based MCUs Integrated Driver
Functions
A31L12x_hal_cmpn.c File Reference

Contains all functions support for cmpn firmware library on A31L12x. More...

Go to the source code of this file.

Functions

HAL_Status_Type HAL_COMP_Init (CMPn_Type *CMPx)
 Initialize the target peripheral. More...
 
HAL_Status_Type HAL_COMP_Deinit (CMPn_Type *CMPx)
 Deinitialize the target peripheral. More...
 
HAL_Status_Type HAL_COMP_ConfigPositiveInput (CMPn_Type *CMPx, CMPn_CR_CMPnPOS_Enum PositiveInputPin)
 Select the positive input pin of a comparator. More...
 
HAL_Status_Type HAL_COMP_ConfigNegativeInput (CMPn_Type *CMPx, CMPn_CR_CMPnNEG_Enum NegativeInputPin)
 Select the negative input pin of a comparator. More...
 
HAL_Status_Type HAL_COMP_ConfigHysteresis (CMPn_Type *CMPx, CMPn_CR_HYSnEN_Enum ControlValue)
 Control the hysteresis function. More...
 
HAL_Status_Type HAL_COMP_ConfigSpeed (CMPn_Type *CMPx, CMPn_CR_CMPnSPD_Enum Speed)
 Select the speed of a comparator. More...
 
HAL_Status_Type HAL_COMP_ConfigNoiseFilter (CMPn_Type *CMPx, CMPn_CR_NFCKn_Enum SamplingClock)
 Select the sampling clock of a noise filter. More...
 
HAL_Status_Type HAL_COMP_ConfigInterruptPolarity (CMPn_Type *CMPx, CMPn_CR_CMPnPOL_Enum Polarity)
 Select the interrupt trigger polarity. More...
 
HAL_Status_Type HAL_COMP_ConfigIntRef (CMPn_Type *CMPx, CMPn_RCR_REFnEN_Enum ControlValue, CMPn_RCR_CMPnREF_Enum RefVoltage)
 Control the reference voltage generator and select the reference voltage. More...
 
HAL_Status_Type HAL_COMP_Enable (CMPn_Type *CMPx)
 Enable the comparator function. More...
 
HAL_Status_Type HAL_COMP_Disable (CMPn_Type *CMPx)
 Disable the comparator function. More...
 
HAL_Status_Type HAL_COMP_ClearStatus (CMPn_Type *CMPx, uint32_t mask)
 Clear the Status Register. More...
 
uint32_t HAL_COMP_GetStatus (CMPn_Type *CMPx)
 Get the Status Register. More...
 

Detailed Description

Contains all functions support for cmpn firmware library on A31L12x.

Version
1.00
Date
2020-05-29
Author
ABOV Application Team

Copyright(C) 2019, ABOV Semiconductor All rights reserved.

ABOV Disclaimer

IMPORTANT NOTICE ? PLEASE READ CAREFULLY ABOV Semiconductor ("ABOV") reserves the right to make changes, corrections, enhancements, modifications, and improvements to ABOV products and/or to this document at any time without notice. ABOV does not give warranties as to the accuracy or completeness of the information included herein. Purchasers should obtain the latest relevant information of ABOV products before placing orders. Purchasers are entirely responsible for the choice, selection, and use of ABOV products and ABOV assumes no liability for application assistance or the design of purchasers' products. No license, express or implied, to any intellectual property rights is granted by ABOV herein. ABOV disclaims all express and implied warranties and shall not be responsible or liable for any injuries or damages related to use of ABOV products in such unauthorized applications. ABOV and the ABOV logo are trademarks of ABOV. All other product or service names are the property of their respective owners. Information in this document supersedes and replaces the information previously supplied in any former versions of this document. 2020 ABOV Semiconductor All rights reserved

Definition in file A31L12x_hal_cmpn.c.

Function Documentation

◆ HAL_COMP_ClearStatus()

HAL_Status_Type HAL_COMP_ClearStatus ( CMPn_Type *  CMPx,
uint32_t  mask 
)

Clear the Status Register.

Parameters
[in]CMPxPointer to the target CMP peripheral
  • CMP0 ~ CMP1
[in]maskMask indicating the target status flag.
  • CMPn_SR_CMPnIFLAG_Msk
Returns
HAL_Status_Type
[Example]
HAL_COMP_ClearStatus( ( CMPn_Type* )CMP0, CMPn_SR_CMPnIFLAG_Msk );

Definition at line 419 of file A31L12x_hal_cmpn.c.

420 {
421  /* Check CMP handle */
422  if( CMPx == NULL )
423  {
424  return HAL_ERROR;
425  }
426 
427  switch( mask )
428  {
429  case CMPn_SR_CMPnIFLAG_Msk:
430  CMPx->SR = 0
431  | CMPn_SR_CMPnIFLAG_Msk
432  ;
433  break;
434  }
435 
436  return HAL_OK;
437 }

References HAL_ERROR, and HAL_OK.

◆ HAL_COMP_ConfigHysteresis()

HAL_Status_Type HAL_COMP_ConfigHysteresis ( CMPn_Type *  CMPx,
CMPn_CR_HYSnEN_Enum  ControlValue 
)

Control the hysteresis function.

Parameters
[in]CMPxPointer to the target CMP peripheral
  • CMP0 ~ CMP1
[in]ControlValue
  • HYSnEN_Disable
  • HYSnEN_Enable
Returns
HAL_Status_Type
[Example]
HAL_COMP_ConfigHysteresis( ( CMPn_Type* )CMP0, HYSnEN_Enable );

Definition at line 212 of file A31L12x_hal_cmpn.c.

213 {
214  /* Check CMP handle */
215  if( CMPx == NULL )
216  {
217  return HAL_ERROR;
218  }
219 
220  CMPx->CR_b.HYSnEN = ControlValue;
221 
222  return HAL_OK;
223 }

References HAL_ERROR, and HAL_OK.

◆ HAL_COMP_ConfigInterruptPolarity()

HAL_Status_Type HAL_COMP_ConfigInterruptPolarity ( CMPn_Type *  CMPx,
CMPn_CR_CMPnPOL_Enum  Polarity 
)

Select the interrupt trigger polarity.

Parameters
[in]CMPxPointer to the target CMP peripheral
  • CMP0 ~ CMP1
[in]Polarity
  • CMPnPOL_NoInterrupt
  • CMPnPOL_FallingEdge
  • CMPnPOL_RisingEdge
  • CMPnPOL_BothEdge
Returns
HAL_Status_Type
[Example]
HAL_COMP_ConfigInterruptPolarity( ( CMPn_Type* )CMP0, CMPnPOL_BothEdge );

Definition at line 303 of file A31L12x_hal_cmpn.c.

304 {
305  /* Check CMP handle */
306  if( CMPx == NULL )
307  {
308  return HAL_ERROR;
309  }
310 
311  CMPx->CR_b.CMPnPOL = Polarity;
312 
313  return HAL_OK;
314 }

References HAL_ERROR, and HAL_OK.

◆ HAL_COMP_ConfigIntRef()

HAL_Status_Type HAL_COMP_ConfigIntRef ( CMPn_Type *  CMPx,
CMPn_RCR_REFnEN_Enum  ControlValue,
CMPn_RCR_CMPnREF_Enum  RefVoltage 
)

Control the reference voltage generator and select the reference voltage.

Parameters
[in]CMPxPointer to the target CMP peripheral
  • CMP0 ~ CMP1
[in]ControlValue
  • REFnEN_Disable
  • REFnEN_Enable
[in]RefVoltage
  • CMPnREF_2over11VDD
  • CMPnREF_3over11VDD
  • CMPnREF_4over11VDD
  • CMPnREF_5over11VDD
  • CMPnREF_6over11VDD
  • CMPnREF_7over11VDD
  • CMPnREF_8over11VDD
  • CMPnREF_9over11VDD
Returns
HAL_Status_Type
[Example]
HAL_COMP_ConfigIntRef( ( CMPn_Type* )CMP0, REFnEN_Enable, CMPnREF_6over11VDD );

Definition at line 340 of file A31L12x_hal_cmpn.c.

341 {
342  /* Check CMP handle */
343  if( CMPx == NULL )
344  {
345  return HAL_ERROR;
346  }
347 
348  CMPx->RCR_b.REFnEN = ControlValue;
349  CMPx->RCR_b.CMPnREF = RefVoltage;
350 
351  return HAL_OK;
352 }

References HAL_ERROR, and HAL_OK.

◆ HAL_COMP_ConfigNegativeInput()

HAL_Status_Type HAL_COMP_ConfigNegativeInput ( CMPn_Type *  CMPx,
CMPn_CR_CMPnNEG_Enum  NegativeInputPin 
)

Select the negative input pin of a comparator.

Parameters
[in]CMPxPointer to the target CMP peripheral
  • CMP0 ~ CMP1
[in]NegativeInputPinNegative input pin
  • CMPnNEG_CPnN0
  • CMPnNEG_CPnN1
  • CMPnNEG_CPnN2
  • CMPnNEG_CPnN3
  • CMPnNEG_IntRef
Returns
HAL_Status_Type
[Example]
HAL_COMP_ConfigNegativeInput( ( CMPn_Type* )CMP0, CMPnNEG_IntRef );

Definition at line 184 of file A31L12x_hal_cmpn.c.

185 {
186  /* Check CMP handle */
187  if( CMPx == NULL )
188  {
189  return HAL_ERROR;
190  }
191 
192  CMPx->CR_b.CMPnNEG = NegativeInputPin;
193 
194  return HAL_OK;
195 }

References HAL_ERROR, and HAL_OK.

◆ HAL_COMP_ConfigNoiseFilter()

HAL_Status_Type HAL_COMP_ConfigNoiseFilter ( CMPn_Type *  CMPx,
CMPn_CR_NFCKn_Enum  SamplingClock 
)

Select the sampling clock of a noise filter.

Parameters
[in]CMPxPointer to the target CMP peripheral
  • CMP0 ~ CMP1
[in]SamplingClock
  • NFCKn_PCLK1
  • NFCKn_PCLK2
  • NFCKn_PCLK4
  • NFCKn_PCLK8
  • NFCKn_PCLK16
  • NFCKn_PCLK32
  • NFCKn_PCLK64
Returns
HAL_Status_Type
[Example]
HAL_COMP_ConfigNoiseFilter( ( CMPn_Type* )CMP0, NFCKn_PCLK1 );

Definition at line 273 of file A31L12x_hal_cmpn.c.

274 {
275  /* Check CMP handle */
276  if( CMPx == NULL )
277  {
278  return HAL_ERROR;
279  }
280 
281  CMPx->CR_b.NFCKn = SamplingClock;
282 
283  return HAL_OK;
284 }

References HAL_ERROR, and HAL_OK.

◆ HAL_COMP_ConfigPositiveInput()

HAL_Status_Type HAL_COMP_ConfigPositiveInput ( CMPn_Type *  CMPx,
CMPn_CR_CMPnPOS_Enum  PositiveInputPin 
)

Select the positive input pin of a comparator.

Parameters
[in]CMPxPointer to the target CMP peripheral
  • CMP0 ~ CMP1
[in]PositiveInputPinPositive input pin
  • CMPnPOS_CPnP0
  • CMPnPOS_CPnP1
  • CMPnPOS_CPnP2
  • CMPnPOS_CPnP3
  • CMPnPOS_CPnP4
  • CMPnPOS_CPnP5
Returns
HAL_Status_Type
[Example]
HAL_COMP_ConfigPositiveInput( ( CMPn_Type* )CMP0, CMPnPOS_CPnP0 );

Definition at line 152 of file A31L12x_hal_cmpn.c.

153 {
154  /* Check CMP handle */
155  if( CMPx == NULL )
156  {
157  return HAL_ERROR;
158  }
159 
160  CMPx->CR_b.CMPnPOS = PositiveInputPin;
161 
162  return HAL_OK;
163 }

References HAL_ERROR, and HAL_OK.

◆ HAL_COMP_ConfigSpeed()

HAL_Status_Type HAL_COMP_ConfigSpeed ( CMPn_Type *  CMPx,
CMPn_CR_CMPnSPD_Enum  Speed 
)

Select the speed of a comparator.

Parameters
[in]CMPxPointer to the target CMP peripheral
  • CMP0 ~ CMP1
[in]Speed
  • CMPnSPD_Slow
  • CMPnSPD_Fast
Returns
HAL_Status_Type
[Example]
HAL_COMP_ConfigSpeed( ( CMPn_Type* )CMP0, CMPnSPD_Slow );

Definition at line 240 of file A31L12x_hal_cmpn.c.

241 {
242  /* Check CMP handle */
243  if( CMPx == NULL )
244  {
245  return HAL_ERROR;
246  }
247 
248  CMPx->CR_b.CMPnSPD = Speed;
249 
250  return HAL_OK;
251 }

References HAL_ERROR, and HAL_OK.

◆ HAL_COMP_Deinit()

HAL_Status_Type HAL_COMP_Deinit ( CMPn_Type *  CMPx)

Deinitialize the target peripheral.

Parameters
[in]CMPxPointer to the target CMP peripheral
  • CMP0 ~ CMP1
Returns
HAL_Status_Type

This function resets the target peripheral and disables it's clock.

[Example]
HAL_COMP_Deinit( ( CMPn_Type* )CMP0 );

Definition at line 103 of file A31L12x_hal_cmpn.c.

104 {
105  /* Check CMP handle */
106  if( CMPx == NULL )
107  {
108  return HAL_ERROR;
109  }
110 
111 #if 1 // supported
112  if( CMPx == ( CMPn_Type* )CMP0 )
113  {
114  // reset peripheral and disable peripheral clock
115  HAL_SCU_Peripheral_SetReset2( PPRST2_CMP0RST );
116  HAL_SCU_Peripheral_EnableClock2( PPCLKEN2_CMP0CLKE, PPxCLKE_Disable );
117  }
118 #endif
119 
120 #if 1 // supported
121  if( CMPx == ( CMPn_Type* )CMP1 )
122  {
123  // reset peripheral and disable peripheral clock
124  HAL_SCU_Peripheral_SetReset2( PPRST2_CMP1RST );
125  HAL_SCU_Peripheral_EnableClock2( PPCLKEN2_CMP1CLKE, PPxCLKE_Disable );
126  }
127 #endif
128 
129  return HAL_OK;
130 }
void HAL_SCU_Peripheral_EnableClock2(uint32_t u32PeriClk2, uint32_t u32Ind)
Set Each Peripheral Clock.
void HAL_SCU_Peripheral_SetReset2(uint32_t u32EachPeri2)
Set/Reset Each Peripheral Block Reset of PPRST2 Register.

References HAL_ERROR, HAL_OK, HAL_SCU_Peripheral_EnableClock2(), and HAL_SCU_Peripheral_SetReset2().

Here is the call graph for this function:

◆ HAL_COMP_Disable()

HAL_Status_Type HAL_COMP_Disable ( CMPn_Type *  CMPx)

Disable the comparator function.

Parameters
[in]CMPxPointer to the target CMP peripheral
  • CMP0 ~ CMP1
Returns
HAL_Status_Type
[Example]
HAL_COMP_Disable( ( CMPn_Type* )CMP0 );

Definition at line 391 of file A31L12x_hal_cmpn.c.

392 {
393  /* Check CMP handle */
394  if( CMPx == NULL )
395  {
396  return HAL_ERROR;
397  }
398 
399  CMPx->CR_b.CMPnEN = CMPn_CR_CMPnEN_Disable;
400 
401  return HAL_OK;
402 }

References HAL_ERROR, and HAL_OK.

◆ HAL_COMP_Enable()

HAL_Status_Type HAL_COMP_Enable ( CMPn_Type *  CMPx)

Enable the comparator function.

Parameters
[in]CMPxPointer to the target CMP peripheral
  • CMP0 ~ CMP1
Returns
HAL_Status_Type
[Example]
HAL_COMP_Enable( ( CMPn_Type* )CMP0 );

Definition at line 366 of file A31L12x_hal_cmpn.c.

367 {
368  /* Check CMP handle */
369  if( CMPx == NULL )
370  {
371  return HAL_ERROR;
372  }
373 
374  CMPx->CR_b.CMPnEN = CMPn_CR_CMPnEN_Enable;
375 
376  return HAL_OK;
377 }

References HAL_ERROR, and HAL_OK.

◆ HAL_COMP_GetStatus()

uint32_t HAL_COMP_GetStatus ( CMPn_Type *  CMPx)

Get the Status Register.

Parameters
[in]CMPxPointer to the target CMP peripheral
  • CMP0 ~ CMP1
Returns
Status Register value
[Example]
status = HAL_COMP_GetStatus( ( CMPn_Type* )CMP0 );

Definition at line 451 of file A31L12x_hal_cmpn.c.

452 {
453  return CMPx->SR;
454 }

◆ HAL_COMP_Init()

HAL_Status_Type HAL_COMP_Init ( CMPn_Type *  CMPx)

Initialize the target peripheral.

Parameters
[in]CMPxPointer to the target CMP peripheral
  • CMP0 ~ CMP1
Returns
HAL_Status_Type

This function enables the clock of target peripheral and resets it.

[Example]
HAL_COMP_Init( ( CMPn_Type* )CMP0 );

Definition at line 61 of file A31L12x_hal_cmpn.c.

62 {
63  /* Check CMP handle */
64  if( CMPx == NULL )
65  {
66  return HAL_ERROR;
67  }
68 
69 #if 1 // supported
70  if( CMPx == ( CMPn_Type* )CMP0 )
71  {
72  // enable peripheral clock and reset peripheral
73  HAL_SCU_Peripheral_EnableClock2( PPCLKEN2_CMP0CLKE, PPxCLKE_Enable );
74  HAL_SCU_Peripheral_SetReset2( PPRST2_CMP0RST );
75  }
76 #endif
77 
78 #if 1 // supported
79  if( CMPx == ( CMPn_Type* )CMP1 )
80  {
81  // enable peripheral clock and reset peripheral
82  HAL_SCU_Peripheral_EnableClock2( PPCLKEN2_CMP1CLKE, PPxCLKE_Enable );
83  HAL_SCU_Peripheral_SetReset2( PPRST2_CMP1RST );
84  }
85 #endif
86 
87  return HAL_OK;
88 }
void HAL_SCU_Peripheral_EnableClock2(uint32_t u32PeriClk2, uint32_t u32Ind)
Set Each Peripheral Clock.
void HAL_SCU_Peripheral_SetReset2(uint32_t u32EachPeri2)
Set/Reset Each Peripheral Block Reset of PPRST2 Register.

References HAL_ERROR, HAL_OK, HAL_SCU_Peripheral_EnableClock2(), and HAL_SCU_Peripheral_SetReset2().

Here is the call graph for this function: