MTB CAT5 Peripheral driver library
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages

General Description

Functions

cy_en_adccomp_status_t Cy_ADCCOMP_LPCOMP_Init (CyADCCOMP_Type *base, cy_en_adccomp_lpcomp_id_t lpcompId, cy_en_adccomp_lpcomp_mode_t lpcompMode, cy_stc_adccomp_lpcomp_config_t *pCfg)
 Configures Low power comparator for DC mode or noise threshold detect(NTD) mode. More...
 
cy_en_adccomp_status_t Cy_ADCCOMP_LPCOMP_Enable (CyADCCOMP_Type *base, cy_en_adccomp_lpcomp_id_t lpcompId)
 Enable comparator for either DC threshold detection or NTD(Noise Threshold mode). More...
 
cy_en_adccomp_status_t Cy_ADCCOMP_LPCOMP_Disable (CyADCCOMP_Type *base, cy_en_adccomp_lpcomp_id_t lpcompId)
 Disables comparator. More...
 
cy_en_adccomp_status_t Cy_ADCCOMP_LPCOMP_DeInit (CyADCCOMP_Type *base, cy_en_adccomp_lpcomp_id_t lpcompId)
 Disable comparator and resets configuration to default values, i.e. More...
 
void Cy_ADCCOMP_LPCOMP_EnableWakeConfig (cy_en_adccomp_lpcomp_id_t lpcompId)
 Configures comparator as wake source. More...
 
void Cy_ADCCOMP_LPCOMP_DisableWakeConfig (cy_en_adccomp_lpcomp_id_t lpcompId)
 Disables comparator wake source configuration. More...
 
cy_en_adccomp_status_t Cy_ADCCOMP_LPCOMP_ClearLatch (CyADCCOMP_Type *base, cy_en_adccomp_lpcomp_id_t lpcompId)
 Clears the comparator latched status. More...
 
cy_en_adccomp_status_t Cy_ADCCOMP_ADC_Init (CyADCCOMP_Type *base, cy_en_adccomp_adc_mode_t adcMode, cy_stc_adccomp_adc_config_t *pCfg)
 Configures ADC block for DC conversion or analog MIC mode for audio acquistion. More...
 
cy_en_adccomp_status_t Cy_ADCCOMP_ADC_SelectDcChannel (CyADCCOMP_Type *base, cy_en_adccomp_adc_dc_channel_t channel)
 Sets the specified DC measurement channel. More...
 
cy_en_adccomp_status_t Cy_ADCCOMP_SetPgaGain (CyADCCOMP_Type *base, cy_en_adccomp_adc_pga_gain_ctrl_t gain)
 Configures the PGA gain (gain factor 1 to 8) for MIC. More...
 
cy_en_adccomp_status_t Cy_ADCCOMP_ADC_Enable (CyADCCOMP_Type *base)
 Enable ADC for DC operation or MIC audio capture. More...
 
cy_en_adccomp_status_t Cy_ADCCOMP_ADC_Start (CyADCCOMP_Type *base)
 Triggers CIC operation for DC conversion. More...
 
cy_en_adccomp_status_t Cy_ADCCOMP_ADC_Stop (CyADCCOMP_Type *base)
 Disables PDM data sync and CIC filter. More...
 
cy_en_adccomp_status_t Cy_ADCCOMP_ADC_InitiateDcCalibration (CyADCCOMP_Type *base)
 Configures ADC for DC calibration. More...
 
void Cy_ADCCOMP_ADC_EndDcCalibration (CyADCCOMP_Type *base)
 Program register to power down the ADC DC calibration mode. More...
 
cy_en_adccomp_status_t Cy_ADCCOMP_ADC_Disable (CyADCCOMP_Type *base)
 Program register to power down the ADC block. More...
 
__STATIC_INLINE void Cy_ADCCOMP_EnableTimer (CyADCCOMP_Type *base)
 Enables the timer. More...
 
__STATIC_INLINE void Cy_ADCCOMP_DisableTimer (CyADCCOMP_Type *base)
 Disables the timer. More...
 
__STATIC_INLINE void Cy_ADCCOMP_SetTimerPeriod (CyADCCOMP_Type *base, uint16_t period)
 Sets the timer period. More...
 
__STATIC_INLINE int16_t Cy_ADCCOMP_GetDcResult (CyADCCOMP_Type const *base)
 Returns the DC conversion result from the CIC status register. More...
 
void Cy_ADCCOMP_SetDcOffset (CyADCCOMP_Type *base, int16_t offset, cy_stc_adccomp_adc_context_t *context)
 Sets the offset value for DC measurement calibration. More...
 
__STATIC_INLINE int16_t Cy_ADCCOMP_GetCalibrationResult (CyADCCOMP_Type const *base)
 Get the DC calibration offset API must be called after successful completion of DC calibration procedure. More...
 
void Cy_ADCCOMP_SetDcGain (int16_t gain, cy_stc_adccomp_adc_context_t *context)
 Sets the gain value for DC measurement calibration. More...
 
__STATIC_INLINE int16_t Cy_ADCCOMP_CountsTo_mVolts (int16_t adcCounts, cy_stc_adccomp_adc_context_t const *context)
 Convert the ADC output to millivolts as an int16. More...
 
__STATIC_INLINE int32_t Cy_ADCCOMP_CountsTo_uVolts (int16_t adcCounts, cy_stc_adccomp_adc_context_t const *context)
 Convert the ADC output to microvolts as an int32. More...
 
__STATIC_INLINE UINT32 Cy_ADCCOMP_GetStatusRegisterVal (CyADCCOMP_Type const *base)
 Reads the ADCCOMP status register. More...
 
void Cy_ADCCOMP_EnableInterrupt (CyADCCOMP_Type *base, uint32_t intrMask)
 Sets the specified interrupt bit in the interrupt mask register. More...
 
void Cy_ADCCOMP_DisableInterrupt (CyADCCOMP_Type *base, uint32_t intrMask)
 Clears the specified interrupt bit in the interrupt mask register. More...
 
__STATIC_INLINE UINT32 Cy_ADCCOMP_GetInterruptStatus (CyADCCOMP_Type const *base)
 Returns the interrupt status. More...
 
__STATIC_INLINE void Cy_ADCCOMP_ClearInterrupt (CyADCCOMP_Type *base, UINT32 intrMask)
 Clears the specified interrupts status. More...
 
__STATIC_INLINE UINT32 Cy_ADCCOMP_GetInterruptMask (CyADCCOMP_Type const *base)
 Returns the interrupt mask value. More...
 
__STATIC_INLINE void Cy_ADCCOMP_SetInterrupt (CyADCCOMP_Type *base, uint32_t intrMask)
 sets the interrupt. More...
 
__STATIC_INLINE void Cy_ADCCOMP_SetInterruptMask (CyADCCOMP_Type *base, uint32_t intrMask)
 Write interrupt mask value into interrupt mask register. More...
 
__STATIC_INLINE uint32_t Cy_ADCCOMP_GetInterruptStatusMasked (CyADCCOMP_Type const *base)
 Returns the logical AND of the corresponding INTR and INTR_MASK fields in a single-load operation. More...
 
cy_en_adccomp_status_t Cy_ADCCOMP_RegisterIntrCallback (CY_ADCCOMP_IRQ_THREAD_CB_t pCb)
 Returns the status of registration of callback for ADCCOMP IRQ cy_en_adccomp_status_t. More...
 

Function Documentation

cy_en_adccomp_status_t Cy_ADCCOMP_LPCOMP_Init ( CyADCCOMP_Type *  base,
cy_en_adccomp_lpcomp_id_t  lpcompId,
cy_en_adccomp_lpcomp_mode_t  lpcompMode,
cy_stc_adccomp_lpcomp_config_t pCfg 
)

Configures Low power comparator for DC mode or noise threshold detect(NTD) mode.

Parameters
baseThe pointer to the hardware ADCCOMP block.
lpcompIdLow power comparator Id cy_en_adccomp_lpcomp_id_t.
lpcompModeLow power comparator mode of operation cy_en_adccomp_lpcomp_mode_t.
pCfgThe pointer to the configuration structure cy_stc_adccomp_lpcomp_config_t.
Returns
The status cy_en_adccomp_status_t.
cy_en_adccomp_status_t Cy_ADCCOMP_LPCOMP_Enable ( CyADCCOMP_Type *  base,
cy_en_adccomp_lpcomp_id_t  lpcompId 
)

Enable comparator for either DC threshold detection or NTD(Noise Threshold mode).

when comparator i/p(i.e. +ve terminal i/p) is above threshold(i.e. -ve terminal value), comparator interrupt group_adccomp_macros_interrupt get generated. In interrupt callback, ADC status register cy_adccomp_status_register_mask_t can be read to check for comparator o/p latched high.

Parameters
baseThe pointer to the hardware ADCCOMP block.
lpcompIdLow power comparator Id cy_en_adccomp_lpcomp_id_t.
Returns
The status cy_en_adccomp_status_t.
Note
if comparator configured for NTD mode and enabling, application must wait for comparator to settle and configure as wake source using /ref Cy_ADCCOMP_LPCOMP_EnableWakeConfig what is comparator settling? When comparator configured for NTD mode first time after power up, it take a while for comparator to settle down depending on DC blocking capacitor and MIC output common-mode (DC output), both are application configurable. During this time comparator may latch if the voltage difference between comparator +ve and -ve terminal exceed configured hysterisis limit. Application needs to poll for every 10 ms for comparator latched status using /ref Cy_ADCCOMP_GetStatusRegisterVal and clear latch using /ref Cy_ADCCOMP_GetStatusRegisterVal. Once application does not see comparator latch, few 10 ms intervals continuously then application configure comparator as wake source using /ref Cy_ADCCOMP_LPCOMP_EnableWakeConfig and then only allow device to enter to low power mode.
cy_en_adccomp_status_t Cy_ADCCOMP_LPCOMP_Disable ( CyADCCOMP_Type *  base,
cy_en_adccomp_lpcomp_id_t  lpcompId 
)

Disables comparator.

Parameters
baseThe pointer to the hardware ADCCOMP block.
lpcompIdLow power comparator Id cy_en_adccomp_lpcomp_id_t.
Returns
The status cy_en_adccomp_status_t.
cy_en_adccomp_status_t Cy_ADCCOMP_LPCOMP_DeInit ( CyADCCOMP_Type *  base,
cy_en_adccomp_lpcomp_id_t  lpcompId 
)

Disable comparator and resets configuration to default values, i.e.

input to comparator is open, Resets comparator o/p, Clears NTD mode and Set Hysterisis to CY_LPCOMP_HYST_LIMIT_0MV_NONE

Parameters
baseThe pointer to the hardware ADCCOMP block.
lpcompIdLow power comparator Id cy_en_adccomp_lpcomp_id_t.
Returns
The status cy_en_adccomp_status_t.
void Cy_ADCCOMP_LPCOMP_EnableWakeConfig ( cy_en_adccomp_lpcomp_id_t  lpcompId)

Configures comparator as wake source.

Applicable to use in NTD mode only.

Parameters
lpcompIdLow power comparator Id cy_en_adccomp_lpcomp_id_t.
Note
This function must be called after comparator settled down after comparator configured for NTD mode. /ref Cy_ADCCOMP_LPCOMP_Enable description
void Cy_ADCCOMP_LPCOMP_DisableWakeConfig ( cy_en_adccomp_lpcomp_id_t  lpcompId)

Disables comparator wake source configuration.

Applicable to use in NTD mode only.

Parameters
lpcompIdLow power comparator Id cy_en_adccomp_lpcomp_id_t.
cy_en_adccomp_status_t Cy_ADCCOMP_LPCOMP_ClearLatch ( CyADCCOMP_Type *  base,
cy_en_adccomp_lpcomp_id_t  lpcompId 
)

Clears the comparator latched status.

Parameters
baseThe pointer to the hardware ADCCOMP block.
lpcompIdLow power comparator Id cy_en_adccomp_lpcomp_id_t.
Returns
The status cy_en_adccomp_status_t.
cy_en_adccomp_status_t Cy_ADCCOMP_ADC_Init ( CyADCCOMP_Type *  base,
cy_en_adccomp_adc_mode_t  adcMode,
cy_stc_adccomp_adc_config_t pCfg 
)

Configures ADC block for DC conversion or analog MIC mode for audio acquistion.

Parameters
baseThe pointer to the hardware ADCCOMP block.
adcModeADC mode of operation cy_en_adccomp_adc_mode_t.
pCfgThe pointer to the configuration structure cy_stc_adccomp_adc_config_t.
Returns
The status cy_en_adccomp_status_t.
cy_en_adccomp_status_t Cy_ADCCOMP_ADC_SelectDcChannel ( CyADCCOMP_Type *  base,
cy_en_adccomp_adc_dc_channel_t  channel 
)

Sets the specified DC measurement channel.

Parameters
baseThe pointer to the hardware ADCCOMP block.
channelThe DC measurement channel cy_en_adccomp_adc_dc_channel_t.
Note
This function is useful for DC measurement only.
Returns
The status cy_en_adccomp_status_t.
cy_en_adccomp_status_t Cy_ADCCOMP_SetPgaGain ( CyADCCOMP_Type *  base,
cy_en_adccomp_adc_pga_gain_ctrl_t  gain 
)

Configures the PGA gain (gain factor 1 to 8) for MIC.

In DC mode, gain not applicable, i.e gain = 1. This API must be called before ADC enabled

Parameters
baseThe pointer to the hardware ADCCOMP block.
gainThe gain value cy_en_adccomp_adc_pga_gain_ctrl_t.
Returns
The status cy_en_adccomp_status_t.
cy_en_adccomp_status_t Cy_ADCCOMP_ADC_Enable ( CyADCCOMP_Type *  base)

Enable ADC for DC operation or MIC audio capture.

CY_ADCCOMP_INTR_ADC_READY group_adccomp_macros_interrupt interrupt get generated, on ADC LDO stable(i.e. ADC ready for operation). From interrupt callback, call below APIs for corresponding operation. DC mode: DC conversion: Call Cy_ADCCOMP_ADC_Start for DC conversion DC calibration: Call Cy_ADCCOMP_ADC_InitiateDcCalibration MIC audio capture: call pdmpcm APIs cy_pdm_pcm.h to capture PCM audio samples

Parameters
baseThe pointer to the hardware ADCCOMP block.
Returns
The status cy_en_adccomp_status_t.
cy_en_adccomp_status_t Cy_ADCCOMP_ADC_Start ( CyADCCOMP_Type *  base)

Triggers CIC operation for DC conversion.

CY_ADCCOMP_INTR_CIC group_adccomp_macros_interrupt interrupt get generated on CIC operation completion. From interrupt callback, call corresponding APIs to get DC result. For DC calibration value, call Cy_ADCCOMP_GetDcOffset to get signed DCc alibration result. User has to save this value in memory cy_stc_adccomp_adc_context_t and use it in subsequent DC measures.

Parameters
baseThe pointer to the hardware ADCCOMP block.
Returns
The status cy_en_adccomp_status_t.
cy_en_adccomp_status_t Cy_ADCCOMP_ADC_Stop ( CyADCCOMP_Type *  base)

Disables PDM data sync and CIC filter.

Parameters
baseThe pointer to the hardware ADCCOMP block.
Returns
The status cy_en_adccomp_status_t.
cy_en_adccomp_status_t Cy_ADCCOMP_ADC_InitiateDcCalibration ( CyADCCOMP_Type *  base)

Configures ADC for DC calibration.

CY_ADCCOMP_INTR_ADC_READY group_adccomp_macros_interrupt interrupt get generated From interrupt callback, call Cy_ADCCOMP_ADC_Start to start CIC operation.

Parameters
baseThe pointer to the hardware ADCCOMP block.
Returns
The status cy_en_adccomp_status_t.
void Cy_ADCCOMP_ADC_EndDcCalibration ( CyADCCOMP_Type *  base)

Program register to power down the ADC DC calibration mode.

Parameters
baseThe pointer to the hardware ADCCOMP block.
cy_en_adccomp_status_t Cy_ADCCOMP_ADC_Disable ( CyADCCOMP_Type *  base)

Program register to power down the ADC block.

Parameters
baseThe pointer to the hardware ADCCOMP block.
Returns
The status cy_en_adccomp_status_t.
__STATIC_INLINE void Cy_ADCCOMP_EnableTimer ( CyADCCOMP_Type *  base)

Enables the timer.

Cy_ADCCOMP_SetTimerPeriod for timer requirement.

Parameters
baseThe pointer to the hardware ADCCOMP block.
__STATIC_INLINE void Cy_ADCCOMP_DisableTimer ( CyADCCOMP_Type *  base)

Disables the timer.

Parameters
baseThe pointer to the hardware ADCCOMP block.
__STATIC_INLINE void Cy_ADCCOMP_SetTimerPeriod ( CyADCCOMP_Type *  base,
uint16_t  period 
)

Sets the timer period.

Timer control APIs allows the user to give extra time to ADC LDO to become stable. By default driver bypass the timer and relay on ADC's GMLDO OK signal to generate CY_ADCCOMP_INTR_ADC_READY group_adccomp_macros_interrupt. For examle, at 2.048Mhz default value(= 0xCD) count will be programmed to generate CY_ADCCOMP_INTR_ADC_READY interrupt based on ADC GM LDO OK signal to indicate that 100us has lapsed and the ADC's LDO is stable. User can adjust this count through external timer using these APIs.

Parameters
baseThe pointer to the hardware ADCCOMP block.
periodThe 16-bit timer period.
__STATIC_INLINE int16_t Cy_ADCCOMP_GetDcResult ( CyADCCOMP_Type const *  base)

Returns the DC conversion result from the CIC status register.

Note:- Driver programs HW to get calibrated DC conversion result, so user must program valid calibration offset value using Cy_ADCCOMP_SetDcOffset before start DC measurement operation.

Parameters
baseThe pointer to the hardware ADCCOMP block.
Returns
The signed DC conversion result.
void Cy_ADCCOMP_SetDcOffset ( CyADCCOMP_Type *  base,
int16_t  offset,
cy_stc_adccomp_adc_context_t context 
)

Sets the offset value for DC measurement calibration.

HW CIC updated with offset value

Parameters
baseThe pointer to the hardware ADCCOMP block.
offsetThe offset value.
contextThe pointer to the context structure cy_stc_adccomp_adc_context_t.
__STATIC_INLINE int16_t Cy_ADCCOMP_GetCalibrationResult ( CyADCCOMP_Type const *  base)

Get the DC calibration offset API must be called after successful completion of DC calibration procedure.

Parameters
baseThe pointer to the hardware ADCCOMP block.
Returns
The signed DC calibration result.
void Cy_ADCCOMP_SetDcGain ( int16_t  gain,
cy_stc_adccomp_adc_context_t context 
)

Sets the gain value for DC measurement calibration.

For H1 ADCCOMP IP, this is 2 ^ 15 = 0x8000, essentially it is an amount of raw counts per 1 volt of input voltage.

Parameters
gainThe gain value.
contextThe pointer to the context structure cy_stc_adccomp_adc_context_t.
__STATIC_INLINE int16_t Cy_ADCCOMP_CountsTo_mVolts ( int16_t  adcCounts,
cy_stc_adccomp_adc_context_t const *  context 
)

Convert the ADC output to millivolts as an int16.

For example, if the ADC measured 0.534 volts, the return value would be 534. The calculation of voltage depends on the DC range. The equation used is:

mV = (RawCounts) * 1000 / Gain

where,

  • RawCounts: Raw counts returned by the Cy_ADCCOMP_GetDcResult.
  • Driver programs the hardware to adjust Raw counts by the Cy_ADCCOMP_SetDcOffset, essentially it is a raw count value of ADC internal ground voltage measurement.
  • 1000 * - amount of millivolts in 1 volt
  • Gain: the gain value, can be adjusted by the Cy_ADCCOMP_SetDcGain, depends on DC range, essentially it is an amount of raw counts per 1 volt of input voltage.
Note
This function is for DC measurement only.
Parameters
adcCountsConversion result from Cy_ADCCOMP_GetDcResult
contextThe pointer to the context structure cy_stc_adccomp_adc_context_t.
Returns
Result in millivolts.
__STATIC_INLINE int32_t Cy_ADCCOMP_CountsTo_uVolts ( int16_t  adcCounts,
cy_stc_adccomp_adc_context_t const *  context 
)

Convert the ADC output to microvolts as an int32.

For example, if the ADC measured 0.534 volts, the return value would be 534000. The calculation of voltage depends on the DC range. The equation used is:

uV = (RawCounts) * 1000000 / Gain

where,

  • RawCounts: Raw counts returned by the Cy_ADCCOMP_GetDcResult.
  • Driver programs the hardware to adjust Raw counts by the Cy_ADCCOMP_SetDcOffset, essentially it is a raw count value of ADC internal ground voltage measurement.
  • 1000000 - amount of microvolts in 1 volt
  • Gain: the gain value, can be adjusted by the Cy_ADCCOMP_SetDcGain, depends on DC range, essentially it is an amount of raw counts per 1 volt of input voltage.
Note
This function is for DC measurement only.
Parameters
adcCountsConversion result from Cy_ADCCOMP_GetDcResult
contextThe pointer to the context structure cy_stc_adccomp_adc_context_t.
Returns
Result in microvolts.
__STATIC_INLINE UINT32 Cy_ADCCOMP_GetStatusRegisterVal ( CyADCCOMP_Type const *  base)

Reads the ADCCOMP status register.

Parameters
baseThe pointer to the hardware ADCCOMP block.
Returns
ADC Status register value cy_adccomp_status_register_mask_t.
void Cy_ADCCOMP_EnableInterrupt ( CyADCCOMP_Type *  base,
uint32_t  intrMask 
)

Sets the specified interrupt bit in the interrupt mask register.

Parameters
baseThe pointer to the hardware ADCCOMP block.
intrMaskThe mask of interrupts. Select one or more values from group_adccomp_macros_interrupt and "OR" them together.
void Cy_ADCCOMP_DisableInterrupt ( CyADCCOMP_Type *  base,
uint32_t  intrMask 
)

Clears the specified interrupt bit in the interrupt mask register.

Parameters
baseThe pointer to the hardware ADCCOMP block.
intrMaskThe mask of interrupts. Select one or more values from group_adccomp_macros_interrupt and "OR" them together.
__STATIC_INLINE UINT32 Cy_ADCCOMP_GetInterruptStatus ( CyADCCOMP_Type const *  base)

Returns the interrupt status.

Parameters
baseThe pointer to the hardware ADCCOMP block.
Returns
The interrupt status.
__STATIC_INLINE void Cy_ADCCOMP_ClearInterrupt ( CyADCCOMP_Type *  base,
UINT32  intrMask 
)

Clears the specified interrupts status.

Parameters
baseThe pointer to the hardware ADCCOMP block.
intrMaskThe mask of interrupts to clear. Typically this will be the value returned from Cy_ADCCOMP_GetInterruptStatus. Alternately, select one or more values from group_adccomp_macros_interrupt and "OR" them together.
__STATIC_INLINE UINT32 Cy_ADCCOMP_GetInterruptMask ( CyADCCOMP_Type const *  base)

Returns the interrupt mask value.

Parameters
baseThe pointer to the hardware ADCCOMP block.
Returns
The interrupt mask value.
__STATIC_INLINE void Cy_ADCCOMP_SetInterrupt ( CyADCCOMP_Type *  base,
uint32_t  intrMask 
)

sets the interrupt.

Intended mostly for debugging.

Parameters
baseThe pointer to the hardware ADCCOMP block.
intrMaskThe mask of interrupts. Select one or more values from group_adccomp_macros_interrupt and "OR" them together.
__STATIC_INLINE void Cy_ADCCOMP_SetInterruptMask ( CyADCCOMP_Type *  base,
uint32_t  intrMask 
)

Write interrupt mask value into interrupt mask register.

Parameters
baseThe pointer to the hardware ADCCOMP block. CyADCCOMP_Type
intrMaskThe mask of interrupts. Select one or more values from group_adccomp_macros_interrupt and "OR" them together.
__STATIC_INLINE uint32_t Cy_ADCCOMP_GetInterruptStatusMasked ( CyADCCOMP_Type const *  base)

Returns the logical AND of the corresponding INTR and INTR_MASK fields in a single-load operation.

Parameters
baseThe pointer to the hardware ADCCOMP block. CyADCCOMP_Type
Returns
The masked interrupt status.
cy_en_adccomp_status_t Cy_ADCCOMP_RegisterIntrCallback ( CY_ADCCOMP_IRQ_THREAD_CB_t  pCb)

Returns the status of registration of callback for ADCCOMP IRQ cy_en_adccomp_status_t.

Parameters
pCbCallback for ADCCOMP IRQ to application CY_ADCCOMP_IRQ_THREAD_CB_t