This document consists of sections titled with Driver Overview, Data Structures, Enumerations, Functions, etc., each with an overview list and detailed documentation. It is recommended to read the Driver Overview first for it includes a comprehensive description of the peripheral, driver and driver changes. Other sections give detailed information for APIs, enums, macros, etc., for your further reference.
|
enum | cmp_interrupt_request_t {
kCMP_InterruptRequestDisabled = 0U,
kCMP_InterruptRequestEnableOutputRisingEdge,
kCMP_InterruptRequestEnableOutputFallingEdge,
kCMP_InterrruptRequestEnableAll
} |
| CMP Interrupt request type definition. More...
|
|
enum | cmp_output_flag_t {
kCMP_OutputFlagRisingEdge = CMP_SCR_CFR_MASK,
kCMP_OutputFlagFallingEdge = CMP_SCR_CFF_MASK,
kCMP_OutputFlagBothEdge
} |
| CMP output flags' mask. More...
|
|
enum | cmp_hysteresis_level_t {
kCMP_HysteresisLevel0 = 0U,
kCMP_HysteresisLevel1 = 1U,
kCMP_HysteresisLevel2 = 2U,
kCMP_HysteresisLevel3 = 3U
} |
| CMP Hysteresis level. More...
|
|
enum | cmp_comparasion_speed_mode_t {
kCMP_ComparsionModeLowSpeed = 0U,
kCMP_ComparsionModeHighSpeed = 1U
} |
| CMP compassion speed mode enumerator. More...
|
|
enum | cmp_dac_vref_source_t {
kCMP_DACVrefSourceVin1 = 0U,
kCMP_DACVrefSourceVin2 = 1U
} |
| CMP DAC Voltage Reference source. More...
|
|
enum | cmp_window_output_mode_t {
kCMP_WindowOuputLastLatchedValue,
kCMP_WindowOutputZeroValue = 1U
} |
| CMP output value of window. More...
|
|
enum | cmp_filter_count_t {
kCMP_FilterCountDisable = 0U,
kCMP_FilterCount1 = 1U,
kCMP_FilterCount2 = 2U,
kCMP_FilterCount3 = 3U,
kCMP_FilterCount4 = 4U,
kCMP_FilterCount5 = 5U,
kCMP_FilterCount6 = 6U,
kCMP_FilterCount7 = 7U
} |
| CMP filter count. More...
|
|
enum | cmp_external_sample_count_t {
kCMP_ExternalSampleCount1 = 1U,
kCMP_ExternalSampleCount2 = 2U,
kCMP_ExternalSampleCount3 = 3U,
kCMP_ExternalSampleCount4 = 4U,
kCMP_ExternalSampleCount5 = 5U,
kCMP_ExternalSampleCount6 = 6U,
kCMP_ExternalSampleCount7 = 7U
} |
| CMP external sample count. More...
|
|
enum | cmp_output_source_t {
kCMP_OutputSourceFromFilterCOUT = 0U,
kCMP_OutputSourceFromUnfilteredCOUTA = 1U
} |
| CMP output source enumerator. More...
|
|
enum | cmp_work_mode_t {
kCMP_WorkModeWindowBypassAndNoExternalSample = 0U,
kCMP_WorkModeWindowBypassAndExternalSample = 1U,
kCMP_WorkModeWindowEnabledAndNoExternalSample = 2U
} |
| CMP work mode definition. More...
|
|
|
static void | CMP_Enable (CMP_Type *base, bool bEnable) |
| Enables/disables the CMP module. More...
|
|
static void | CMP_SetInputChannel (CMP_Type *base, cmp_input_mux_t ePlusChannel, cmp_input_mux_t eMinusChannel) |
| Sets the input channels for the comparator. More...
|
|
static void | CMP_SelectOutputSource (CMP_Type *base, cmp_output_source_t eOutputSource) |
| Select comparator output source. More...
|
|
static void | CMP_EnableOuputPin (CMP_Type *base, bool bEnable) |
| Enable/Disable Comparator output pin. More...
|
|
static uint8_t | CMP_GetComparatorOutput (CMP_Type *base) |
| Get Comparator output. More...
|
|
static void | CMP_SetHysteresisLevel (CMP_Type *base, cmp_hysteresis_level_t eHysteresisLevel) |
| Sets hysteresis level. More...
|
|
static void | CMP_SetComparasionSpeedMode (CMP_Type *base, cmp_comparasion_speed_mode_t eComparatorSpeedMode) |
| Sets comparison speed mode. More...
|
|
static void | CMP_EnableInvertOutput (CMP_Type *base, bool bEnable) |
| Enable/Disable comparator invert feature. More...
|
|
static void | CMP_EnableWindow (CMP_Type *base, bool bEnable) |
| Enable the window function. More...
|
|
static void | CMP_EnableExternalSampleMode (CMP_Type *base, bool bEnable) |
| Enable/Disable external Sample mode. More...
|
|
static void | CMP_SetExternalSampleCount (CMP_Type *base, cmp_external_sample_count_t eSampleCount) |
| Sets external sample count. More...
|
|
static void | CMP_SetInternalFilterCount (CMP_Type *base, cmp_filter_count_t eFilterCount) |
| Sets internal filter count. More...
|
|
static void | CMP_SetInternalFilterPeriod (CMP_Type *base, uint8_t u8FilterPeriod) |
| Sets the internal filter period. More...
|
|
void | CMP_SetDACConfig (CMP_Type *base, const cmp_dac_config_t *psConfig) |
| Configures the internal DAC. More...
|
|
static void | CMP_SetDACOutputVoltage (CMP_Type *base, uint8_t u8OutputVoltageDivider) |
| Sets DAC output voltage. More...
|
|
static void | CMP_EnableInternalDAC (CMP_Type *base, bool bEnable) |
| Enable/Disable internal DAC. More...
|
|
static void | CMP_SetDACReferenceVoltageSource (CMP_Type *base, cmp_dac_vref_source_t eDACVrefSource) |
| Sets internal DAC's reference voltage source. More...
|
|
uint8_t cmp_dac_config_t::u8DACOutputVoltageDivider |
union cmp_dma_interrupt_config_t |
- Note
- , the interrupt request and dma request cannot be used at the same time, that is to say When DMA support is enabled by setting SCR[DMAEN] and the interrupt is enabled by setting SCR[IER], SCR[IEF], or both, the corresponding change on COUT forces a DMA transfer request rather than a CPU interrupt instead
bool cmp_config_t::bInvertComparatorOutputPolarity |
uint8_t cmp_config_t::u8FilterPeriod |
The divider to the bus clock. Available range is 0-255, can be used in internal sampling mode. When the filter clock from internal divided bus clock, setting the sample period to 0 will disable the filter
Enumerator |
---|
kCMP_InterruptRequestDisabled |
interrupt disabled
|
kCMP_InterruptRequestEnableOutputRisingEdge |
Comparator interrupt request enable rising edge.
|
kCMP_InterruptRequestEnableOutputFallingEdge |
Comparator interrupt request enable falling edge.
|
kCMP_InterrruptRequestEnableAll |
comparator interrupt request enable on rising edge or falling edge
|
Enumerator |
---|
kCMP_OutputFlagRisingEdge |
Rising-edge on the comparison output has occurred.
|
kCMP_OutputFlagFallingEdge |
Falling-edge on the comparison output has occurred.
|
kCMP_OutputFlagBothEdge |
Rising-edge and Falling-edge on the comparison output has occurred.
|
Enumerator |
---|
kCMP_HysteresisLevel0 |
Hysteresis level 0.
|
kCMP_HysteresisLevel1 |
Hysteresis level 1.
|
kCMP_HysteresisLevel2 |
Hysteresis level 2.
|
kCMP_HysteresisLevel3 |
Hysteresis level 3.
|
Enumerator |
---|
kCMP_ComparsionModeLowSpeed |
Low-Speed Comparison mode has lower current consumption.
|
kCMP_ComparsionModeHighSpeed |
High-Speed Comparison mode has higher current consumption.
|
Enumerator |
---|
kCMP_DACVrefSourceVin1 |
Vin1 is selected as a resistor ladder network supply reference Vin.
|
kCMP_DACVrefSourceVin2 |
Vin2 is selected as a resistor ladder network supply reference Vin.
|
Enumerator |
---|
kCMP_WindowOuputLastLatchedValue |
When WINDOW signal changes from 1 to 0, COUTA output holds the last latched value before WINDOW signal falls to 0.
|
kCMP_WindowOutputZeroValue |
When WINDOW signal changes from 1 to 0, COUTA output is forced to 0.
|
Enumerator |
---|
kCMP_FilterCountDisable |
filter is disabled
|
kCMP_FilterCount1 |
1 sample must agrees, the comparator output is simply sampled
|
kCMP_FilterCount2 |
2 consecutive samples must agrees
|
kCMP_FilterCount3 |
3 consecutive samples must agrees
|
kCMP_FilterCount4 |
4 consecutive samples must agrees
|
kCMP_FilterCount5 |
5 consecutive samples must agrees
|
kCMP_FilterCount6 |
6 consecutive samples must agrees
|
kCMP_FilterCount7 |
7 consecutive samples must agrees
|
Enumerator |
---|
kCMP_ExternalSampleCount1 |
1 sample must agrees, the comparator output is simply sampled
|
kCMP_ExternalSampleCount2 |
2 consecutive samples must agrees
|
kCMP_ExternalSampleCount3 |
3 consecutive samples must agrees
|
kCMP_ExternalSampleCount4 |
4 consecutive samples must agrees
|
kCMP_ExternalSampleCount5 |
5 consecutive samples must agrees
|
kCMP_ExternalSampleCount6 |
6 consecutive samples must agrees
|
kCMP_ExternalSampleCount7 |
7 consecutive samples must agrees
|
Enumerator |
---|
kCMP_OutputSourceFromFilterCOUT |
Set the filtered comparator output to equal COUT.
|
kCMP_OutputSourceFromUnfilteredCOUTA |
Set the unfiltered comparator output to equal COUTA.
|
Enumerator |
---|
kCMP_WorkModeWindowBypassAndNoExternalSample |
window block bypassed, external sampling mode disabled
|
kCMP_WorkModeWindowBypassAndExternalSample |
window block bypassed, external SAMPLE mode enable
|
kCMP_WorkModeWindowEnabledAndNoExternalSample |
window block enabled, external sampling mode disabled
|
This function initializes the user configuration structure to the default values. It is corresponding to the continuous mode configurations.
- Parameters
-
void CMP_Init |
( |
CMP_Type * |
base, |
|
|
const cmp_config_t * |
psConfig |
|
) |
| |
This function initializes the CMP module. The operations included are as follows.
- Enable the clock for CMP module.
- Configure the comparator according to the CMP configuration structure.
- Parameters
-
base | CMP peripheral base address. |
psConfig | Pointer to the configuration structure. |
void CMP_Deinit |
( |
CMP_Type * |
base | ) |
|
This function de-initializes the CMP module. The operations included are as follows.
- Disabling the CMP module.
- Disabling the clock for CMP module.
- Parameters
-
base | CMP peripheral base address. |
static void CMP_Enable |
( |
CMP_Type * |
base, |
|
|
bool |
bEnable |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | CMP peripheral base address. |
bEnable | Enables or disables the module. |
static void CMP_SetInputChannel |
( |
CMP_Type * |
base, |
|
|
cmp_input_mux_t |
ePlusChannel, |
|
|
cmp_input_mux_t |
eMinusChannel |
|
) |
| |
|
inlinestatic |
This function sets the input channels for the comparator. Note that two input channels cannot be set the same way in the application. When the user selects the same input from the analog mux to the positive and negative port, the comparator is disabled automatically.
- Parameters
-
base | CMP peripheral base address. |
ePlusChannel | Plus side input channel number. |
eMinusChannel | Minus side input channel number. |
- Parameters
-
base | CMP peripheral base address. |
eOutputSource | The output signal to be set, please reference cmp_output_source_t for details. |
static void CMP_EnableOuputPin |
( |
CMP_Type * |
base, |
|
|
bool |
bEnable |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | CMP peripheral base address. |
bEnable | Enable/Disable comparator output pin. true – CMPO is available on the associate CMPO output pin. false – CMPO is not available on the associate CMPO output pin. |
static uint8_t CMP_GetComparatorOutput |
( |
CMP_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
base | CMP peripheral base address. |
- Return values
-
current | analog comparator output 0 or 1 |
- Parameters
-
base | CMP peripheral base address. |
eHysteresisLevel | The programmable hysteresis level to be set, please refer to cmp_hysteresis_level_t for details. |
static void CMP_EnableInvertOutput |
( |
CMP_Type * |
base, |
|
|
bool |
bEnable |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | CMP peripheral base address. |
bEnable | Enable/Disable comparator invert feature. true – Inverts the comparator output. false – Does not invert the comparator output. |
static void CMP_EnableWindow |
( |
CMP_Type * |
base, |
|
|
bool |
bEnable |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | CMP peripheral base address. |
bEnable | true is enable, false is disable. |
static void CMP_EnableExternalSampleMode |
( |
CMP_Type * |
base, |
|
|
bool |
bEnable |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | CMP peripheral base address. |
bEnable | true is using external sample mode, false is using interface sample mode. |
- Parameters
-
base | CMP peripheral base address. |
eSampleCount | The number of consecutive samples that must agree prior to the comparator output filter accepting a new output state, cmp_external_sample_count_t. |
static void CMP_SetInternalFilterCount |
( |
CMP_Type * |
base, |
|
|
cmp_filter_count_t |
eFilterCount |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | CMP peripheral base address. |
eFilterCount | The number of consecutive samples that must agree prior to the comparator output filter accepting a new output state, cmp_filter_count_t. |
static void CMP_SetInternalFilterPeriod |
( |
CMP_Type * |
base, |
|
|
uint8_t |
u8FilterPeriod |
|
) |
| |
|
inlinestatic |
It is used as the divider to bus clock.
- Parameters
-
base | CMP peripheral base address. |
u8FilterPeriod | Filter Period. The divider to the bus clock. Available range is 0-255. |
- Parameters
-
base | CMP peripheral base address. |
psConfig | Pointer to the configuration structure. |
static void CMP_SetDACOutputVoltage |
( |
CMP_Type * |
base, |
|
|
uint8_t |
u8OutputVoltageDivider |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | CMP peripheral base address. |
u8OutputVoltageDivider | The digital value which is related to the desired DAC output voltage, |
static void CMP_EnableInternalDAC |
( |
CMP_Type * |
base, |
|
|
bool |
bEnable |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | CMP peripheral base address. |
bEnable | Enable/Disable internal DAC. true – Enable internal DAC. false – Disable internal DAC. |
- Parameters
-
base | CMP peripheral base address. |
- Return values
-
- Parameters
-
base | CMP peripheral base address. |
eOutputFlag | Mask value for the output flags, cmp_output_flag_t |
static uint32_t CMP_GetComparatorResultRegisterAddress |
( |
CMP_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
base | CMP peripheral base address. |
- Returns
- The CMP result register address.