Kinetis SDK v.1.3 API Reference Manual
Rev. 0
Freescale Semiconductor, Inc.
|
This section describes the programming interface of the CMP HAL driver.
Data Structures | |
struct | cmp_comparator_config_t |
Defines a structure for configuring the comparator in the CMP module. More... | |
struct | cmp_sample_filter_config_t |
Defines a structure to configure the window/filter in CMP module. More... | |
struct | cmp_dac_config_t |
Defines a structure to configure the internal DAC in the CMP module. More... | |
Functions | |
void | CMP_HAL_Init (CMP_Type *base) |
Resets the CMP registers to a known state. More... | |
void | CMP_HAL_ConfigComparator (CMP_Type *base, const cmp_comparator_config_t *configPtr) |
Configures the CMP comparator function. More... | |
void | CMP_HAL_ConfigDacChn (CMP_Type *base, const cmp_dac_config_t *configPtr) |
Configures the CMP DAC function. More... | |
void | CMP_HAL_ConfigSampleFilter (CMP_Type *base, const cmp_sample_filter_config_t *configPtr) |
Configures the CMP sample or the filter function. More... | |
static void | CMP_HAL_Enable (CMP_Type *base) |
Enables the comparator in the CMP module. More... | |
static void | CMP_HAL_Disable (CMP_Type *base) |
Disables the comparator in the CMP module. More... | |
static bool | CMP_HAL_GetOutputLogic (CMP_Type *base) |
Gets the comparator logic output in the CMP module. More... | |
static bool | CMP_HAL_GetOutputFallingFlag (CMP_Type *base) |
Gets the logic output falling edge event in the CMP module. More... | |
static void | CMP_HAL_ClearOutputFallingFlag (CMP_Type *base) |
Clears the logic output falling edge event in the CMP module. More... | |
static bool | CMP_HAL_GetOutputRisingFlag (CMP_Type *base) |
Gets the logic output rising edge event in the CMP module. More... | |
static void | CMP_HAL_ClearOutputRisingFlag (CMP_Type *base) |
Clears the logic output rising edge event in the CMP module. More... | |
struct cmp_comparator_config_t |
This structure holds the configuration for the comparator inside the CMP module. With the configuration, the CMP can be set as a basic comparator without additional features.
Data Fields | |
cmp_hystersis_mode_t | hystersisMode |
Set the hysteresis level. | |
bool | pinoutEnable |
Enable outputting the CMPO to pin. | |
bool | pinoutUnfilteredEnable |
Enable outputting unfiltered result to CMPO. | |
bool | invertEnable |
Enable inverting the comparator's result. | |
bool | highSpeedEnable |
Enable working in speed mode. | |
bool | risingIntEnable |
Enable using CMPO rising interrupt. | |
bool | fallingIntEnable |
Enable using CMPO falling interrupt. | |
cmp_chn_mux_mode_t | plusChnMux |
Set the Plus side input to comparator. | |
cmp_chn_mux_mode_t | minusChnMux |
Set the Minus side input to comparator. | |
struct cmp_sample_filter_config_t |
This structure holds the configuration for the window/filter inside the CMP module. With the configuration, the CMP module can operate in advanced mode.
Data Fields | |
cmp_sample_filter_mode_t | workMode |
Sample/Filter's work mode. | |
bool | useExtSampleOrWindow |
Switcher to use external WINDOW/SAMPLE signal. | |
uint8_t | filterClkDiv |
Filter's prescaler which divides from the bus clock. | |
cmp_filter_counter_mode_t | filterCount |
Sample count for filter. More... | |
cmp_filter_counter_mode_t cmp_sample_filter_config_t::filterCount |
See "cmp_filter_counter_mode_t".
struct cmp_dac_config_t |
This structure holds the configuration for the DAC inside the CMP module. With the configuration, the internal DAC provides a reference voltage level and is chosen as the CMP input.
Data Fields | |
bool | dacEnable |
Enable the internal 6-bit DAC. | |
cmp_dac_ref_volt_src_mode_t | refVoltSrcMode |
Select the reference voltage source for internal DAC. | |
uint8_t | dacValue |
Set the value for internal DAC. | |
enum cmp_status_t |
enum cmp_hystersis_mode_t |
The hysteresis control level indicates the smallest window between the two inputs when asserting the change of output. See the chip Data Sheet for detailed electrical characteristics. Generally, the lower level represents the smaller window.
Enumerator | |
---|---|
kCmpHystersisOfLevel0 |
Level 0. |
kCmpHystersisOfLevel1 |
Level 1. |
kCmpHystersisOfLevel2 |
Level 2. |
kCmpHystersisOfLevel3 |
Level 3. |
The selection item represents the number of consecutive samples that must agree prior to the comparator output filter accepting a new output state.
enum cmp_chn_mux_mode_t |
Comparator sample/filter is available in several modes. Use the enumeration to identify the comparator's status:
kCmpContinuousMode - Continuous Mode: Both window control and filter blocks are completely bypassed. The comparator output is updated continuously. kCmpSampleWithNoFilteredMode - Sample, Non-Filtered Mode: Window control is completely bypassed. The comparator output is sampled whenever a rising-edge is detected on the filter block clock input. The filter clock prescaler can be configured as a divider from the bus clock. kCmpSampleWithFilteredMode - Sample, Filtered Mode: Similar to "Sample, Non-Filtered Mode", but the filter is active in this mode. The filter counter value also becomes configurable. kCmpWindowedMode - Windowed Mode: In Windowed Mode, only output of analog comparator is passed when the WINDOW signal is high. The last latched value is held when the WINDOW signal is low. kCmpWindowedFilteredMode - Window/Filtered Mode: This is a complex mode because it uses both window and filtering features. It also has the highest latency of all modes. This can be approximated to up to 1 bus clock synchronization in the window function
void CMP_HAL_Init | ( | CMP_Type * | base | ) |
This function resets the CMP registers to a known state. This state is defined in the chip Reference Manual, which is power on reset value.
base | Register base address for the module. |
void CMP_HAL_ConfigComparator | ( | CMP_Type * | base, |
const cmp_comparator_config_t * | configPtr | ||
) |
This function configures the CMP comparator function.
base | Register base address for the module. |
configPtr | Pointer to configuration structure. See to "cmp_comparator_config_t". |
void CMP_HAL_ConfigDacChn | ( | CMP_Type * | base, |
const cmp_dac_config_t * | configPtr | ||
) |
This function configures the CMP DAC function.
base | Register base address for the module. |
configPtr | Pointer to configuration structure. See to "cmp_dac_config_t". |
void CMP_HAL_ConfigSampleFilter | ( | CMP_Type * | base, |
const cmp_sample_filter_config_t * | configPtr | ||
) |
This function configures the CMP sample or filter function.
base | Register base address for the module. |
configPtr | Pointer to configuration structure. See to "cmp_sample_filter_config_t". |
|
inlinestatic |
This function enables the comparator in the CMP module. The analog comparator is the core component in the CMP module. Only when it is enabled, all other functions for advanced features are meaningful.
base | Register base address for the module. |
|
inlinestatic |
This function disables the comparator in the CMP module. The analog comparator is the core component in the CMP module. When it is disabled, it remains in the off state and consumes no power.
base | Register base address for the module. |
|
inlinestatic |
This function gets the comparator logic output in the CMP module. It returns the current value of the analog comparator output. The value is reset to 0 and read as de-asserted value when the CMP module is disabled. When setting to invert mode, the comparator logic output is inverted as well.
base | Register base address for the module. |
|
inlinestatic |
This function gets the logic output falling edge event in the CMP module. It detects a falling-edge on COUT and returns the asserted state when the falling-edge on COUT has occurred.
base | Register base address for the module. |
|
inlinestatic |
This function clears the logic output falling edge event in the CMP module.
base | Register base address for the module. |
|
inlinestatic |
This function gets the logic output rising edge event in the CMP module. It detects a rising-edge on COUT and returns the asserted state when the rising-edge on COUT has occurred.
base | Register base address for the module. |
|
inlinestatic |
This function clears the logic output rising edge event in the CMP module.
base | Register base address for the module. |