modm API documentation
modm::platform::Comp1 Class Reference

Comparator Class for STM32. More...

#include <modm/platform/comp/comp_1.hpp>

Inheritance diagram for modm::platform::Comp1:
modm::platform::CompBase

Public Types

enum  InvertingInput {
  Vref1Div4 = 0b0000 << 4, Vref1Div2 = 0b0001 << 4, Vref3Div4 = 0b0010 << 4, Vref = 0b0011 << 4,
  Dac1Ch1 = 0b0100 << 4, Dac1Ch2 = 0b0101 << 4, GpioB1 = 0b0110 << 4, GpioC4 = 0b0111 << 4,
  GpioA0 = 0b1000 << 4
}
 
enum  NonInvertingInput { GpioC5 = 0b00 << 8, GpioB2 = 0b01 << 8, GpioA1 = 0b10 << 8 }
 
enum  BlankingSource {
  NoBlanking = 0b000 << 18, Tim1Oc4 = 0b00001 << COMP_CSR_BLANKING_Pos, Tim1Oc5 = 0b00010 << COMP_CSR_BLANKING_Pos, Tim2Oc3 = 0b00100 << COMP_CSR_BLANKING_Pos,
  Tim3Oc3 = 0b01000 << COMP_CSR_BLANKING_Pos, Tim15Oc2 = 0b10000 << COMP_CSR_BLANKING_Pos
}
 
enum  Hysteresis { NoHysteresis = 0b00 << 16, LowHysteresis = 0b01 << 16, MediumHysteresis = 0b10 << 16, HighHysteresis = 0b11 << 16 }
 
enum  Mode { HighSpeed = 0b00 << 2, MediumSpeed = 0b01 << 2 }
 
enum  Polarity { NonInverted = 0b0 << 15, Inverted = 0b1 << 15 }
 

Static Public Member Functions

static void initialize (InvertingInput n_in, NonInvertingInput p_in, Hysteresis hyst=Hysteresis::NoHysteresis, Mode mode=Mode::HighSpeed, Polarity pol=Polarity::NonInverted, bool lock_comp=false)
 
static void setEnabled (bool enabled)
 Enable/Disable the comparator.
 
static bool isEnabled ()
 Returns whether the comparator is enabled.
 
static void setMode (Mode mode)
 Sets the mode that determins speed/power consumption. More...
 
static Mode getMode ()
 Sets the mode that determins speed/power consumption. More...
 
static void setInvertingInput (InvertingInput input)
 Selects what the inverting input is connected to.
 
static InvertingInput getInvertingInput ()
 Returns what is connected to the inverting input. More...
 
static void setNonInvertingInput (NonInvertingInput input)
 Selects what the non-inverting input is connected to.
 
static NonInvertingInput getNonInvertingInput ()
 Returns what is connected to the non-inverting input. More...
 
static void setWindowMode (bool enabled)
 Enable/Disable window mode for COMP0/1.
 
static bool isWindowModeEnabled ()
 Returns true if win mode for COMP0/1 on.
 
static void setPolarity (Polarity pol)
 Selects output polarity.
 
static Polarity getPolarity ()
 Returns output polarity. More...
 
static void setHysteresis (Hysteresis hyst)
 Selects the hysteresis.
 
static Hysteresis getHysteresis ()
 Returns the hysteresis. More...
 
static void setBlankingSource (BlankingSource blanking)
 Selects the blanking source.
 
static BlankingSource getBlankingSource ()
 Returns the blanking source. More...
 
static bool getOutput ()
 Returns the current Comparator output.
 
static void lock (void)
 Locks the comparator. More...
 
static bool isLocked (void)
 Returns true if the comparator is locked.
 
template<class... Signals>
static void connect ()
 

Static Protected Attributes

static constexpr uint32_t InvertingInputMask = (0b1111 << 4)
 
static constexpr uint32_t NonInvertingInputMask = 0b11 << 8
 
static constexpr uint32_t BlankingSourceMask = COMP_CSR_BLANKING_Msk
 
static constexpr uint32_t HysteresisMask = 0b11 << 16
 
static constexpr uint32_t ModeMask = 0b11 << 2
 
static constexpr uint32_t PolarityMask = 0b1 << 15
 

Detailed Description

Comparator Class for STM32.

Member Function Documentation

static BlankingSource modm::platform::Comp1::getBlankingSource ( )
inlinestatic

Returns the blanking source.

static Hysteresis modm::platform::Comp1::getHysteresis ( )
inlinestatic

Returns the hysteresis.

static InvertingInput modm::platform::Comp1::getInvertingInput ( )
inlinestatic

Returns what is connected to the inverting input.

static Mode modm::platform::Comp1::getMode ( )
inlinestatic

Sets the mode that determins speed/power consumption.

This setting is also called "output mode".

static NonInvertingInput modm::platform::Comp1::getNonInvertingInput ( )
inlinestatic

Returns what is connected to the non-inverting input.

static Polarity modm::platform::Comp1::getPolarity ( )
inlinestatic

Returns output polarity.

static void modm::platform::Comp1::initialize ( InvertingInput  n_in,
NonInvertingInput  p_in,
Hysteresis  hyst = Hysteresis::NoHysteresis,
Mode  mode = Mode::HighSpeed,
Polarity  pol = Polarity::NonInverted,
bool  lock_comp = false 
)
inlinestatic

Initialize and enable the comparator.

Enables the comperator and sets important values.

Do NOT set lock = true if you want to be able to set other values later.

static void modm::platform::Comp1::lock ( void  )
inlinestatic

Locks the comparator.

Comparator can only be unlocked by a system reset.

static void modm::platform::Comp1::setMode ( Mode  mode)
inlinestatic

Sets the mode that determins speed/power consumption.

This setting is also called "output mode".


The documentation for this class was generated from the following file: