S32 SDK
cmp_hal.h File Reference
#include <stdint.h>
#include <stdbool.h>
#include "device_registers.h"

Go to the source code of this file.

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...
 

Functions

CMP_HAL.
void CMP_HAL_Init (CMP_Type *baseAddr)
 Initializes the comparator registers with reset values. More...
 
cmp_mode_t CMP_HAL_GetFunctionalMode (const CMP_Type *baseAddr)
 Gets the comparator functional mode. If you want to get filter count and filter period please use CMP_HAL_GetFilterSamplePeriod and CMP_HAL_GetSamplingState. More...
 
void CMP_HAL_SetFunctionalMode (CMP_Type *baseAddr, cmp_mode_t mode, uint8_t filter_sample_count, uint8_t filter_sample_period)
 Sets the comparator functional mode (mode, filter count, filter period) More...
 
static bool CMP_HAL_GetDMATriggerState (const CMP_Type *baseAddr)
 Verify if the DMA transfer trigger is enabled. More...
 
static void CMP_HAL_SetDMATriggerState (CMP_Type *baseAddr, bool to_set)
 Configure the DMA transfer trigger. More...
 
static cmp_output_trigger_t CMP_HAL_GetOutputInterruptTrigger (const CMP_Type *baseAddr)
 Return the comparator output interrupts source configuration(none, rising edge, falling edge or both edges) More...
 
static void CMP_HAL_SetOutputInterruptTrigger (CMP_Type *baseAddr, cmp_output_trigger_t to_set)
 Set the comparator output interrupts source configuration(none, rising edge, falling edge or both edges) More...
 
static cmp_output_trigger_t CMP_HAL_GetOutputEvent (const CMP_Type *baseAddr)
 Return type of event occurred at the comparator output. More...
 
static void CMP_HAL_ClearOutputEvent (CMP_Type *baseAddr)
 Clear all output flags. More...
 
static bool CMP_HAL_GetOutputRisingFlag (const CMP_Type *baseAddr)
 Verify if a rising edge occurred on COUT. More...
 
static void CMP_HAL_ClearOutputRisingFlag (CMP_Type *baseAddr)
 Clear rising edge flag. More...
 
static bool CMP_HAL_GetOutputFallingFlag (const CMP_Type *baseAddr)
 Verify if a falling-edge occurred on COUT. More...
 
static void CMP_HAL_ClearOutputFallingFlag (CMP_Type *baseAddr)
 Clear falling edge flag. More...
 
static bool CMP_HAL_GetComparatorOutput (const CMP_Type *baseAddr)
 Return the analog comparator output value. More...
 
static uint8_t CMP_HAL_GetFilterSamplePeriod (const CMP_Type *baseAddr)
 Return the sample period for filter(clock cycles) More...
 
static void CMP_HAL_SetFilterSamplePeriod (CMP_Type *baseAddr, uint8_t to_set)
 Set the filter sample period(clock cycles) More...
 
static bool CMP_HAL_GetSamplingState (const CMP_Type *baseAddr)
 Verify if the sampling mode is selected. More...
 
static void CMP_HAL_SetSamplingState (CMP_Type *baseAddr, bool to_set)
 Set the sampling mode state. More...
 
static bool CMP_HAL_GetWindowingModeState (const CMP_Type *baseAddr)
 
static void CMP_HAL_SetWindowingModeState (CMP_Type *baseAddr, bool to_set)
 Set the windowing mode state. More...
 
static cmp_power_mode_t CMP_HAL_GetPowerMode (const CMP_Type *baseAddr)
 Return the current power mode. More...
 
static void CMP_HAL_SetPowerMode (CMP_Type *baseAddr, cmp_power_mode_t to_set)
 Set the power mode. More...
 
static cmp_inverter_t CMP_HAL_GetInverterState (const CMP_Type *baseAddr)
 Return the current comparator output inverter. More...
 
static void CMP_HAL_SetInverterState (CMP_Type *baseAddr, cmp_inverter_t to_set)
 Configure the comparator output inverter mode. More...
 
static cmp_output_select_t CMP_HAL_GetComparatorOutputSource (const CMP_Type *baseAddr)
 Return the current comparator output selected. More...
 
static void CMP_HAL_SetComparatorOutputSource (CMP_Type *baseAddr, cmp_output_select_t to_set)
 Select the comparator output signal source. More...
 
static cmp_output_enable_t CMP_HAL_GetOutputPinState (const CMP_Type *baseAddr)
 Verify if the comparator output state(available/not available in a packaged pin) More...
 
static void CMP_HAL_SetOutputPinState (CMP_Type *baseAddr, cmp_output_enable_t to_set)
 Set the comparator output pin state(available/not available in a packaged pin) More...
 
static bool CMP_HAL_GetAnalogComparatorState (const CMP_Type *baseAddr)
 Verify if the analog comparator module is enabled. More...
 
static void CMP_HAL_SetAnalogComparatorState (CMP_Type *baseAddr, bool to_set)
 Set the analog comparator module state. More...
 
static uint8_t CMP_HAL_GetFilterSampleCount (const CMP_Type *baseAddr)
 Return the number of consecutive samples that must agree prior to the comparator output filter accepting a new output state. More...
 
static void CMP_HAL_SetFilterSampleCount (CMP_Type *baseAddr, uint8_t to_set)
 Set the number of consecutive samples that must agree prior to the comparator output filter accepting a new output state. More...
 
static cmp_offset_t CMP_HAL_GetOffset (const CMP_Type *baseAddr)
 Return the current offset level. More...
 
static void CMP_HAL_SetOffset (CMP_Type *baseAddr, cmp_offset_t to_set)
 Set the offset level. More...
 
static cmp_hysteresis_t CMP_HAL_GetHysteresis (const CMP_Type *baseAddr)
 Return the current hysteresis level. More...
 
static void CMP_HAL_SetHysteresis (CMP_Type *baseAddr, cmp_hysteresis_t to_set)
 Set the hysteresis level. More...
 
static void CMP_HAL_SetDACOutputState (CMP_Type *baseAddr, bool to_set)
 Set if the DAC output is enabled to go outside of this block. More...
 
static bool CMP_HAL_GetDACOutputState (const CMP_Type *baseAddr)
 Get if the DAC output is enabled to go outside of this block. More...
 
static cmp_port_mux_t CMP_HAL_GetPositivePortInput (const CMP_Type *baseAddr)
 Return the current source for positive port of the comparator. More...
 
static void CMP_HAL_SetPositivePortInput (CMP_Type *baseAddr, cmp_port_mux_t to_set)
 Set the source for positive port of the comparator. More...
 
static cmp_port_mux_t CMP_HAL_GetNegativePortInput (const CMP_Type *baseAddr)
 Return the current source for negative port of the comparator. More...
 
static void CMP_HAL_SetNegativePortInput (CMP_Type *baseAddr, cmp_port_mux_t to_set)
 Set the source for negative port of the comparator. More...
 
static cmp_ch_list_t CMP_HAL_GetRoundRobinChannels (const CMP_Type *baseAddr)
 Return which channels are used for round-robin checker. More...
 
static void CMP_HAL_SetRoundRobinChannels (CMP_Type *baseAddr, cmp_ch_list_t to_set)
 Set which channels are use for round-robin checker. More...
 
static bool CMP_HAL_GetDACState (const CMP_Type *baseAddr)
 Verify if the DAC is enabled. More...
 
static void CMP_HAL_SetDACState (CMP_Type *baseAddr, bool to_set)
 Set the DAC state (enabled/disabled) More...
 
static cmp_voltage_reference_t CMP_HAL_GetVoltageReference (const CMP_Type *baseAddr)
 Return the current voltage reference. More...
 
static void CMP_HAL_SetVoltageReference (CMP_Type *baseAddr, cmp_voltage_reference_t to_set)
 Set the voltage reference. More...
 
static cmp_ch_number_t CMP_HAL_GetPlusMUXControl (const CMP_Type *baseAddr)
 Determine which input is selected for the plus mux. More...
 
static void CMP_HAL_SetPlusMuxControl (CMP_Type *baseAddr, cmp_ch_number_t to_set)
 Select input for the plus mux. More...
 
static cmp_ch_number_t CMP_HAL_GetMinusMUXControl (const CMP_Type *baseAddr)
 Determine which input is selected for the minus mux. More...
 
static void CMP_HAL_SetMinusMUXControl (CMP_Type *baseAddr, cmp_ch_number_t to_set)
 Select input for the minus mux. More...
 
static uint8_t CMP_HAL_GetVoltage (const CMP_Type *baseAddr)
 Return the current output voltage level(0-255) More...
 
static void CMP_HAL_SetVoltage (CMP_Type *baseAddr, uint8_t to_set)
 Set the output voltage level. More...
 
static bool CMP_HAL_GetRoundRobinState (const CMP_Type *baseAddr)
 Verify if the round robin operation is enabled. More...
 
static void CMP_HAL_SetRoundRobinState (CMP_Type *baseAddr, bool to_set)
 Set the round robin operation state. More...
 
static bool CMP_HAL_GetRoundRobinInterruptState (const CMP_Type *baseAddr)
 Verify if the round robin interrupt is enabled. More...
 
static void CMP_HAL_SetRoundRobinInterruptState (CMP_Type *baseAddr, bool to_set)
 Set the round robin interrupt state. More...
 
static cmp_fixed_port_t CMP_HAL_GetFixedPort (const CMP_Type *baseAddr)
 Return the port fixed for round-robin operation. More...
 
static void CMP_HAL_SetFixedPort (CMP_Type *baseAddr, cmp_fixed_port_t to_set)
 Set the fixed port for round-robin operation. More...
 
static cmp_ch_number_t CMP_HAL_GetFixedChannel (const CMP_Type *baseAddr)
 Return which channel is selected for fixed mux port(as fixed reference) More...
 
static void CMP_HAL_SetFixedChannel (CMP_Type *baseAddr, cmp_ch_number_t to_set)
 Set which channel is used as the fixed reference input for the fixed mux port. More...
 
static cmp_ch_list_t CMP_HAL_GetInputChangedFlags (const CMP_Type *baseAddr)
 Return all input changed flags. More...
 
static void CMP_HAL_ClearInputChangedFlags (CMP_Type *baseAddr)
 Clear all input changed flags. More...
 
static uint8_t CMP_HAL_GetRoundRobinSamplesNumber (const CMP_Type *baseAddr)
 Return how many round-robin clock cycles takes sampling. More...
 
static void CMP_HAL_SetRoundRobinSamplesNumber (CMP_Type *baseAddr, uint8_t to_set)
 Set how many round-robin clock cycles takes sampling. More...
 
static uint8_t CMP_HAL_GetInitDelay (const CMP_Type *baseAddr)
 Return the comparator and DAC initialization delay. More...
 
static void CMP_HAL_SetInitDelay (CMP_Type *baseAddr, uint8_t to_set)
 Set the comparator and DAC initialization delay. More...
 
static cmp_ch_list_t CMP_HAL_GetLastComparisonResult (const CMP_Type *baseAddr)
 Return last input comparison results for all channels. More...
 
static void CMP_HAL_SetPresetState (CMP_Type *baseAddr, cmp_ch_list_t to_set)
 Defines the pre-set state of input channels. More...