Comparator Driver

Detailed Description

Comparator Peripheral Driver.

Definitions

Data Structures

struct  cmp_comparator_t
 Defines the block configuration. More...
 
struct  cmp_anmux_t
 Defines the analog mux. More...
 
struct  cmp_dac_t
 Defines the DAC block. More...
 
struct  cmp_trigger_mode_t
 Defines the trigger mode. More...
 
struct  cmp_module_t
 Defines the comparator module configuration. More...
 

Macros

#define CMP_INPUT_FLAGS_MASK   0xFF0000
 
#define CMP_INPUT_FLAGS_SHIFT   16U
 
#define CMP_ROUND_ROBIN_CHANNELS_MASK   0xFF0000
 
#define CMP_ROUND_ROBIN_CHANNELS_SHIFT   16U
 

Typedefs

typedef uint8_t cmp_ch_list_t
 Comparator channels list (1bit/channel) |------—|------—|--—|------—|------—| |CH7_state|CH6_state|.....|CH1_state|CH0_state| |------—|------—|--—|------—|------—| Implements : cmp_ch_list_t_Class. More...
 
typedef uint8_t cmp_ch_number_t
 Number of channel Implements : cmp_ch_number_t_Class. More...
 

Enumerations

enum  cmp_power_mode_t { CMP_LOW_SPEED = 0U, CMP_HIGH_SPEED = 1U }
 Power Modes selection Implements : cmp_power_mode_t_Class. More...
 
enum  cmp_voltage_reference_t { CMP_VIN1 = 0U, CMP_VIN2 = 1U }
 Voltage Reference selection Implements : cmp_voltage_reference_t_Class. More...
 
enum  cmp_port_mux_t { CMP_DAC = 0U, CMP_MUX = 1U }
 Port Mux Source selection Implements : cmp_port_mux_t_Class. More...
 
enum  cmp_inverter_t { CMP_NORMAL = 0U, CMP_INVERT = 1U }
 Comparator output invert selection Implements : cmp_inverter_t_Class. More...
 
enum  cmp_output_select_t { CMP_COUT = 0U, CMP_COUTA = 1U }
 Comparator output select selection Implements : cmp_output_select_t_Class. More...
 
enum  cmp_output_enable_t { CMP_UNAVAILABLE = 0U, CMP_AVAILABLE = 1U }
 Comparator output pin enable selection Implements : cmp_output_enable_t_Class. More...
 
enum  cmp_offset_t { CMP_LEVEL_OFFSET_0 = 0U, CMP_LEVEL_OFFSET_1 = 1U }
 Comparator hard block offset control Implements : cmp_offset_t_Class. More...
 
enum  cmp_hysteresis_t { CMP_LEVEL_HYS_0 = 0U, CMP_LEVEL_HYS_1 = 1U, CMP_LEVEL_HYS_2 = 2U, CMP_LEVEL_HYS_3 = 3U }
 Comparator hysteresis control Implements : cmp_hysteresis_t_Class. More...
 
enum  cmp_fixed_port_t { CMP_PLUS_FIXED = 0U, CMP_MINUS_FIXED = 1U }
 Comparator Round-Robin fixed port Implements : cmp_fixed_port_t_Class. More...
 
enum  cmp_output_trigger_t { CMP_NO_EVENT = 0U, CMP_FALLING_EDGE = 1U, CMP_RISING_EDGE = 2U, CMP_BOTH_EDGES = 3U }
 Comparator output interrupt configuration Implements : cmp_output_trigger_t_Class. More...
 
enum  cmp_mode_t {
  CMP_DISABLED = 0U, CMP_CONTINUOUS = 1U, CMP_SAMPLED_NONFILTRED_INT_CLK = 2U, CMP_SAMPLED_NONFILTRED_EXT_CLK = 3U,
  CMP_SAMPLED_FILTRED_INT_CLK = 4U, CMP_SAMPLED_FILTRED_EXT_CLK = 5U, CMP_WINDOWED = 6U, CMP_WINDOWED_RESAMPLED = 7U,
  CMP_WINDOWED_FILTRED = 8U
}
 Comparator functional modes Implements : cmp_mode_t_Class. More...
 

cMP DRV.

status_t CMP_DRV_Reset (const uint32_t instance)
 Reset all registers. More...
 
status_t CMP_DRV_GetInitConfigAll (cmp_module_t *config)
 Get reset configuration for all registers. More...
 
status_t CMP_DRV_Init (const uint32_t instance, const cmp_module_t *const config)
 Configure all comparator features with the given configuration structure. More...
 
status_t CMP_DRV_GetConfigAll (const uint32_t instance, cmp_module_t *const config)
 Gets the current comparator configuration. More...
 
status_t CMP_DRV_GetInitConfigDAC (cmp_dac_t *config)
 Get reset configuration for registers related with DAC. More...
 
status_t CMP_DRV_ConfigDAC (const uint32_t instance, const cmp_dac_t *config)
 Configure only the DAC component. More...
 
status_t CMP_DRV_GetDACConfig (const uint32_t instance, cmp_dac_t *const config)
 Return current configuration for DAC. More...
 
status_t CMP_DRV_GetInitConfigMUX (cmp_anmux_t *config)
 Get reset configuration for registers related with MUX. More...
 
status_t CMP_DRV_ConfigMUX (const uint32_t instance, const cmp_anmux_t *config)
 Configure only the MUX component. More...
 
status_t CMP_DRV_GetMUXConfig (const uint32_t instance, cmp_anmux_t *const config)
 Return configuration only for the MUX component. More...
 
status_t CMP_DRV_GetInitTriggerMode (cmp_trigger_mode_t *config)
 Get reset configuration for registers related with Trigger Mode. More...
 
status_t CMP_DRV_ConfigTriggerMode (const uint32_t instance, const cmp_trigger_mode_t *config)
 Configure trigger mode. More...
 
status_t CMP_DRV_GetTriggerModeConfig (const uint32_t instance, cmp_trigger_mode_t *const config)
 Get current trigger mode configuration. More...
 
status_t CMP_DRV_GetOutputFlags (const uint32_t instance, cmp_output_trigger_t *flags)
 Get comparator output flags. More...
 
status_t CMP_DRV_ClearOutputFlags (const uint32_t instance)
 Clear comparator output flags. More...
 
status_t CMP_DRV_GetInputFlags (const uint32_t instance, cmp_ch_list_t *flags)
 Gets input channels change flags. More...
 
status_t CMP_DRV_ClearInputFlags (const uint32_t instance)
 Clear comparator input channels flags. More...
 
status_t CMP_DRV_GetInitConfigComparator (cmp_comparator_t *config)
 Get reset configuration for registers related with comparator features. More...
 
status_t CMP_DRV_ConfigComparator (const uint32_t instance, const cmp_comparator_t *config)
 Configure only comparator features. More...
 
status_t CMP_DRV_GetComparatorConfig (const uint32_t instance, cmp_comparator_t *config)
 Return configuration for comparator from CMP module. More...
 

Macro Definition Documentation

#define CMP_INPUT_FLAGS_MASK   0xFF0000

Definition at line 33 of file cmp_driver.h.

#define CMP_INPUT_FLAGS_SHIFT   16U

Definition at line 34 of file cmp_driver.h.

#define CMP_ROUND_ROBIN_CHANNELS_MASK   0xFF0000

Definition at line 35 of file cmp_driver.h.

#define CMP_ROUND_ROBIN_CHANNELS_SHIFT   16U

Definition at line 36 of file cmp_driver.h.

Typedef Documentation

typedef uint8_t cmp_ch_list_t

Comparator channels list (1bit/channel) |------—|------—|--—|------—|------—| |CH7_state|CH6_state|.....|CH1_state|CH0_state| |------—|------—|--—|------—|------—| Implements : cmp_ch_list_t_Class.

Definition at line 159 of file cmp_driver.h.

typedef uint8_t cmp_ch_number_t

Number of channel Implements : cmp_ch_number_t_Class.

Definition at line 164 of file cmp_driver.h.

Enumeration Type Documentation

Comparator Round-Robin fixed port Implements : cmp_fixed_port_t_Class.

Enumerator
CMP_PLUS_FIXED 

The Plus port is fixed. Only the inputs to the Minus port are swept in each round.

CMP_MINUS_FIXED 

The Minus port is fixed. Only the inputs to the Plus port are swept in each round.

Definition at line 120 of file cmp_driver.h.

Comparator hysteresis control Implements : cmp_hysteresis_t_Class.

Enumerator
CMP_LEVEL_HYS_0 
CMP_LEVEL_HYS_1 
CMP_LEVEL_HYS_2 
CMP_LEVEL_HYS_3 

Definition at line 109 of file cmp_driver.h.

Comparator output invert selection Implements : cmp_inverter_t_Class.

Enumerator
CMP_NORMAL 

Output signal isn't inverted.

CMP_INVERT 

Output signal is inverted.

Definition at line 71 of file cmp_driver.h.

enum cmp_mode_t

Comparator functional modes Implements : cmp_mode_t_Class.

Enumerator
CMP_DISABLED 
CMP_CONTINUOUS 
CMP_SAMPLED_NONFILTRED_INT_CLK 
CMP_SAMPLED_NONFILTRED_EXT_CLK 
CMP_SAMPLED_FILTRED_INT_CLK 
CMP_SAMPLED_FILTRED_EXT_CLK 
CMP_WINDOWED 
CMP_WINDOWED_RESAMPLED 
CMP_WINDOWED_FILTRED 

Definition at line 140 of file cmp_driver.h.

Comparator hard block offset control Implements : cmp_offset_t_Class.

Enumerator
CMP_LEVEL_OFFSET_0 
CMP_LEVEL_OFFSET_1 

Definition at line 99 of file cmp_driver.h.

Comparator output pin enable selection Implements : cmp_output_enable_t_Class.

Enumerator
CMP_UNAVAILABLE 

Comparator output isn't available to a specific pin

CMP_AVAILABLE 

Comparator output is available to a specific pin

Definition at line 89 of file cmp_driver.h.

Comparator output select selection Implements : cmp_output_select_t_Class.

Enumerator
CMP_COUT 

Select COUT as comparator output signal.

CMP_COUTA 

Select COUTA as comparator output signal.

Definition at line 80 of file cmp_driver.h.

Comparator output interrupt configuration Implements : cmp_output_trigger_t_Class.

Enumerator
CMP_NO_EVENT 

Comparator output interrupts are disabled OR no event occurred.

CMP_FALLING_EDGE 

Comparator output interrupts will be generated only on falling edge OR only falling edge event occurred.

CMP_RISING_EDGE 

Comparator output interrupts will be generated only on rising edge OR only rising edge event occurred.

CMP_BOTH_EDGES 

Comparator output interrupts will be generated on both edges OR both edges event occurred.

Definition at line 129 of file cmp_driver.h.

Port Mux Source selection Implements : cmp_port_mux_t_Class.

Enumerator
CMP_DAC 

Select DAC as source for the comparator port.

CMP_MUX 

Select MUX8 as source for the comparator port.

Definition at line 62 of file cmp_driver.h.

Power Modes selection Implements : cmp_power_mode_t_Class.

Enumerator
CMP_LOW_SPEED 

Module in low speed mode.

CMP_HIGH_SPEED 

Module in high speed mode.

Definition at line 44 of file cmp_driver.h.

Voltage Reference selection Implements : cmp_voltage_reference_t_Class.

Enumerator
CMP_VIN1 

Use Vin1 as supply reference source for DAC.

CMP_VIN2 

Use Vin2 as supply reference source for DAC.

Definition at line 53 of file cmp_driver.h.

Function Documentation

status_t CMP_DRV_ClearInputFlags ( const uint32_t  instance)

Clear comparator input channels flags.

This function clear comparator input channels flags.

Parameters
instance- instance number
Returns
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 512 of file cmp_driver.c.

status_t CMP_DRV_ClearOutputFlags ( const uint32_t  instance)

Clear comparator output flags.

This function clear comparator output flags(rising and falling edge).

Parameters
instance- instance number
Returns
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 467 of file cmp_driver.c.

status_t CMP_DRV_ConfigComparator ( const uint32_t  instance,
const cmp_comparator_t config 
)

Configure only comparator features.

This function configure only features related with comparator: DMA request, power mode, output select, interrupts enable, invert, offset, hysteresis.

Parameters
instance- instance number
config- the configuration structure
Returns
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 561 of file cmp_driver.c.

status_t CMP_DRV_ConfigDAC ( const uint32_t  instance,
const cmp_dac_t config 
)

Configure only the DAC component.

This function configures the DAC with the options provided in the config structure.

Parameters
instance- instance number
config- the configuration structure
Returns
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 266 of file cmp_driver.c.

status_t CMP_DRV_ConfigMUX ( const uint32_t  instance,
const cmp_anmux_t config 
)

Configure only the MUX component.

This function configures the MUX with the options provided in the config structure.

Parameters
instance- instance number
config- the configuration structure
Returns
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 331 of file cmp_driver.c.

status_t CMP_DRV_ConfigTriggerMode ( const uint32_t  instance,
const cmp_trigger_mode_t config 
)

Configure trigger mode.

This function configures the trigger mode with the options provided in the config structure.

Parameters
instance- instance number
config- the configuration structure
Returns
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 395 of file cmp_driver.c.

status_t CMP_DRV_GetComparatorConfig ( const uint32_t  instance,
cmp_comparator_t config 
)

Return configuration for comparator from CMP module.

This function return configuration for features related with comparator: DMA request, power mode, output select, interrupts enable, invert, offset, hysteresis.

Parameters
instance- instance number
config- the configuration structure returned
Returns
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 591 of file cmp_driver.c.

status_t CMP_DRV_GetConfigAll ( const uint32_t  instance,
cmp_module_t *const  config 
)

Gets the current comparator configuration.

This function returns the current configuration for comparator as a configuration structure.

Parameters
instance- instance number
config- the configuration structure
Returns
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 192 of file cmp_driver.c.

status_t CMP_DRV_GetDACConfig ( const uint32_t  instance,
cmp_dac_t *const  config 
)

Return current configuration for DAC.

This function returns current configuration only for DAC.

Parameters
instance- instance number
config- the configuration structure
Returns
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 290 of file cmp_driver.c.

status_t CMP_DRV_GetInitConfigAll ( cmp_module_t config)

Get reset configuration for all registers.

This function returns a configuration structure with reset values for all registers from comparator module.

Parameters
config- the configuration structure
Returns
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 88 of file cmp_driver.c.

status_t CMP_DRV_GetInitConfigComparator ( cmp_comparator_t config)

Get reset configuration for registers related with comparator features.

This function return a configuration structure with reset values for features associated with comparator (DMA request, power mode, output select, interrupts enable, invert, offset, hysteresis).

Parameters
config- the configuration structure
Returns
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 534 of file cmp_driver.c.

status_t CMP_DRV_GetInitConfigDAC ( cmp_dac_t config)

Get reset configuration for registers related with DAC.

This function returns a configuration structure with reset values for features associated with DAC.

Parameters
config- the configuration structure
Returns
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 245 of file cmp_driver.c.

status_t CMP_DRV_GetInitConfigMUX ( cmp_anmux_t config)

Get reset configuration for registers related with MUX.

This function returns a configuration structure with reset values for features associated with MUX.

Parameters
config- the configuration structure
Returns
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 312 of file cmp_driver.c.

status_t CMP_DRV_GetInitTriggerMode ( cmp_trigger_mode_t config)

Get reset configuration for registers related with Trigger Mode.

This function returns a configuration structure with reset values for features associated with Trigger Mode.

Parameters
config- the configuration structure
Returns
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 372 of file cmp_driver.c.

status_t CMP_DRV_GetInputFlags ( const uint32_t  instance,
cmp_ch_list_t flags 
)

Gets input channels change flags.

This function return in <flags> all input channels flags as uint8_t(1 bite for each channel flag).

Parameters
instance- instance number
flags- pointer to input flags
Returns
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 494 of file cmp_driver.c.

status_t CMP_DRV_GetMUXConfig ( const uint32_t  instance,
cmp_anmux_t *const  config 
)

Return configuration only for the MUX component.

This function returns current configuration to determine which signals go to comparator ports.

Parameters
instance- instance number
config- the configuration structure
Returns
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 352 of file cmp_driver.c.

status_t CMP_DRV_GetOutputFlags ( const uint32_t  instance,
cmp_output_trigger_t flags 
)

Get comparator output flags.

This function returns in <flags> comparator output flags(rising and falling edge).

Parameters
instance- instance number
-flags - pointer to output flags NO_EVENT RISING_EDGE FALLING_EDGE BOTH_EDGE
Returns
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 449 of file cmp_driver.c.

status_t CMP_DRV_GetTriggerModeConfig ( const uint32_t  instance,
cmp_trigger_mode_t *const  config 
)

Get current trigger mode configuration.

This function returns the current trigger mode configuration for trigger mode.

Parameters
instance- instance number
config- the configuration structure
Returns
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 422 of file cmp_driver.c.

status_t CMP_DRV_Init ( const uint32_t  instance,
const cmp_module_t *const  config 
)

Configure all comparator features with the given configuration structure.

This function configures the comparator module with the options provided in the config structure.

Parameters
instance- instance number
config- the configuration structure
Returns
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 138 of file cmp_driver.c.

status_t CMP_DRV_Reset ( const uint32_t  instance)

Reset all registers.

This function set all CMP registers to reset values.

Parameters
instance- instance number
Returns
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 69 of file cmp_driver.c.