#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Anach {
#[doc = "No analog change on channel switching: DIFF0, GAIN0 and OFF0 are used for all channels"]
NONE = 0x0,
#[doc = "Allows different analog settings for each channel. See ADC_CGR and ADC_COR Registers"]
ALLOWED = 0x01,
}
impl Anach {
#[inline(always)]
pub const fn from_bits(val: u8) -> Anach {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Anach {
#[inline(always)]
fn from(val: u8) -> Anach {
Anach::from_bits(val)
}
}
impl From<Anach> for u8 {
#[inline(always)]
fn from(val: Anach) -> u8 {
Anach::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Cmpmode {
#[doc = "Generates an event when the converted data is lower than the low threshold of the window."]
LOW = 0x0,
#[doc = "Generates an event when the converted data is higher than the high threshold of the window."]
HIGH = 0x01,
#[doc = "Generates an event when the converted data is in the comparison window."]
IN = 0x02,
#[doc = "Generates an event when the converted data is out of the comparison window."]
OUT = 0x03,
}
impl Cmpmode {
#[inline(always)]
pub const fn from_bits(val: u8) -> Cmpmode {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Cmpmode {
#[inline(always)]
fn from(val: u8) -> Cmpmode {
Cmpmode::from_bits(val)
}
}
impl From<Cmpmode> for u8 {
#[inline(always)]
fn from(val: Cmpmode) -> u8 {
Cmpmode::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Freerun {
#[doc = "Normal Mode"]
OFF = 0x0,
#[doc = "Free Run Mode: Never wait for any trigger."]
ON = 0x01,
}
impl Freerun {
#[inline(always)]
pub const fn from_bits(val: u8) -> Freerun {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Freerun {
#[inline(always)]
fn from(val: u8) -> Freerun {
Freerun::from_bits(val)
}
}
impl From<Freerun> for u8 {
#[inline(always)]
fn from(val: Freerun) -> u8 {
Freerun::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Fwup {
#[doc = "If SLEEP is 1 then both ADC Core and reference voltage circuitry are OFF between conversions"]
OFF = 0x0,
#[doc = "If SLEEP is 1 then Fast Wake-up Sleep Mode: The Voltage reference is ON between conversions and ADC Core is OFF"]
ON = 0x01,
}
impl Fwup {
#[inline(always)]
pub const fn from_bits(val: u8) -> Fwup {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Fwup {
#[inline(always)]
fn from(val: u8) -> Fwup {
Fwup::from_bits(val)
}
}
impl From<Fwup> for u8 {
#[inline(always)]
fn from(val: Fwup) -> u8 {
Fwup::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Resolution {
High = 0x0,
Low = 0x01,
}
impl Resolution {
#[inline(always)]
pub const fn from_bits(val: u8) -> Resolution {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Resolution {
#[inline(always)]
fn from(val: u8) -> Resolution {
Resolution::from_bits(val)
}
}
impl From<Resolution> for u8 {
#[inline(always)]
fn from(val: Resolution) -> u8 {
Resolution::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Settling {
#[doc = "3 periods of ADCClock"]
AST3 = 0x0,
#[doc = "5 periods of ADCClock"]
AST5 = 0x01,
#[doc = "9 periods of ADCClock"]
AST9 = 0x02,
#[doc = "17 periods of ADCClock"]
AST17 = 0x03,
}
impl Settling {
#[inline(always)]
pub const fn from_bits(val: u8) -> Settling {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Settling {
#[inline(always)]
fn from(val: u8) -> Settling {
Settling::from_bits(val)
}
}
impl From<Settling> for u8 {
#[inline(always)]
fn from(val: Settling) -> u8 {
Settling::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Sleep {
#[doc = "Normal Mode: The ADC Core and reference voltage circuitry are kept ON between conversions"]
NORMAL = 0x0,
#[doc = "Sleep Mode: The wake-up time can be modified by programming FWUP bit"]
SLEEP = 0x01,
}
impl Sleep {
#[inline(always)]
pub const fn from_bits(val: u8) -> Sleep {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Sleep {
#[inline(always)]
fn from(val: u8) -> Sleep {
Sleep::from_bits(val)
}
}
impl From<Sleep> for u8 {
#[inline(always)]
fn from(val: Sleep) -> u8 {
Sleep::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Startup {
#[doc = "0 periods of ADCClock"]
SUT0 = 0x0,
#[doc = "8 periods of ADCClock"]
SUT8 = 0x01,
#[doc = "16 periods of ADCClock"]
SUT16 = 0x02,
#[doc = "24 periods of ADCClock"]
SUT24 = 0x03,
#[doc = "64 periods of ADCClock"]
SUT64 = 0x04,
#[doc = "80 periods of ADCClock"]
SUT80 = 0x05,
#[doc = "96 periods of ADCClock"]
SUT96 = 0x06,
#[doc = "112 periods of ADCClock"]
SUT112 = 0x07,
#[doc = "512 periods of ADCClock"]
SUT512 = 0x08,
#[doc = "576 periods of ADCClock"]
SUT576 = 0x09,
#[doc = "640 periods of ADCClock"]
SUT640 = 0x0a,
#[doc = "704 periods of ADCClock"]
SUT704 = 0x0b,
#[doc = "768 periods of ADCClock"]
SUT768 = 0x0c,
#[doc = "832 periods of ADCClock"]
SUT832 = 0x0d,
#[doc = "896 periods of ADCClock"]
SUT896 = 0x0e,
#[doc = "960 periods of ADCClock"]
SUT960 = 0x0f,
}
impl Startup {
#[inline(always)]
pub const fn from_bits(val: u8) -> Startup {
unsafe { core::mem::transmute(val & 0x0f) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Startup {
#[inline(always)]
fn from(val: u8) -> Startup {
Startup::from_bits(val)
}
}
impl From<Startup> for u8 {
#[inline(always)]
fn from(val: Startup) -> u8 {
Startup::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Trgen {
#[doc = "Hardware triggers are disabled. Starting a conversion is only possible by software."]
DIS = 0x0,
#[doc = "Hardware trigger selected by TRGSEL field is enabled."]
EN = 0x01,
}
impl Trgen {
#[inline(always)]
pub const fn from_bits(val: u8) -> Trgen {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Trgen {
#[inline(always)]
fn from(val: u8) -> Trgen {
Trgen::from_bits(val)
}
}
impl From<Trgen> for u8 {
#[inline(always)]
fn from(val: Trgen) -> u8 {
Trgen::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Trgsel {
#[doc = "External : ADCTRG"]
ADC_TRIG0 = 0x0,
#[doc = "TIOA Output of the Timer Counter Channel 0"]
ADC_TRIG1 = 0x01,
#[doc = "TIOA Output of the Timer Counter Channel 1"]
ADC_TRIG2 = 0x02,
#[doc = "TIOA Output of the Timer Counter Channel 2"]
ADC_TRIG3 = 0x03,
#[doc = "PWM Event Line 0"]
ADC_TRIG4 = 0x04,
#[doc = "PWM Event Line 0"]
ADC_TRIG5 = 0x05,
_RESERVED_6 = 0x06,
_RESERVED_7 = 0x07,
}
impl Trgsel {
#[inline(always)]
pub const fn from_bits(val: u8) -> Trgsel {
unsafe { core::mem::transmute(val & 0x07) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Trgsel {
#[inline(always)]
fn from(val: u8) -> Trgsel {
Trgsel::from_bits(val)
}
}
impl From<Trgsel> for u8 {
#[inline(always)]
fn from(val: Trgsel) -> u8 {
Trgsel::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Useq {
#[doc = "Normal Mode: The controller converts channels in a simple numeric order depending only on the channel index."]
NUM_ORDER = 0x0,
#[doc = "User Sequence Mode: The sequence respects what is defined in ADC_SEQR1 and ADC_SEQR2 registers and can be used to convert several times the same channel."]
REG_ORDER = 0x01,
}
impl Useq {
#[inline(always)]
pub const fn from_bits(val: u8) -> Useq {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Useq {
#[inline(always)]
fn from(val: u8) -> Useq {
Useq::from_bits(val)
}
}
impl From<Useq> for u8 {
#[inline(always)]
fn from(val: Useq) -> u8 {
Useq::to_bits(val)
}
}
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct WpKey(u32);
impl WpKey {
#[doc = "Writing any other value in this field aborts the write operation of the WPEN bit.Always reads as 0"]
pub const PASSWD: Self = Self(0x0041_4443);
}
impl WpKey {
pub const fn from_bits(val: u32) -> WpKey {
Self(val & 0x00ff_ffff)
}
pub const fn to_bits(self) -> u32 {
self.0
}
}
impl core::fmt::Debug for WpKey {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self.0 {
0x0041_4443 => f.write_str("PASSWD"),
other => core::write!(f, "0x{:02X}", other),
}
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for WpKey {
fn format(&self, f: defmt::Formatter) {
match self.0 {
0x0041_4443 => defmt::write!(f, "PASSWD"),
other => defmt::write!(f, "0x{:02X}", other),
}
}
}
impl From<u32> for WpKey {
#[inline(always)]
fn from(val: u32) -> WpKey {
WpKey::from_bits(val)
}
}
impl From<WpKey> for u32 {
#[inline(always)]
fn from(val: WpKey) -> u32 {
WpKey::to_bits(val)
}
}