#![allow(clippy::missing_safety_doc)]
#![allow(clippy::identity_op)]
#![allow(clippy::unnecessary_cast)]
#![allow(clippy::erasing_op)]
#[doc = "Analog-to-Digital Converter"]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Adc {
ptr: *mut u8,
}
unsafe impl Send for Adc {}
unsafe impl Sync for Adc {}
impl Adc {
#[inline(always)]
pub const unsafe fn from_ptr(ptr: *mut ()) -> Self {
Self { ptr: ptr as _ }
}
#[inline(always)]
pub const fn as_ptr(&self) -> *mut () {
self.ptr as _
}
#[doc = "interrupt and status register"]
#[inline(always)]
pub const fn isr(self) -> crate::common::Reg<regs::Isr, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x0usize) as _) }
}
#[doc = "interrupt enable register"]
#[inline(always)]
pub const fn ier(self) -> crate::common::Reg<regs::Ier, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x04usize) as _) }
}
#[doc = "control register"]
#[inline(always)]
pub const fn cr(self) -> crate::common::Reg<regs::Cr, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x08usize) as _) }
}
#[doc = "configuration register"]
#[inline(always)]
pub const fn cfgr(self) -> crate::common::Reg<regs::Cfgr, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x0cusize) as _) }
}
#[doc = "configuration register"]
#[inline(always)]
pub const fn cfgr2(self) -> crate::common::Reg<regs::Cfgr2, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x10usize) as _) }
}
#[doc = "sample time register 1"]
#[inline(always)]
pub const fn smpr(self, n: usize) -> crate::common::Reg<regs::Smpr, crate::common::RW> {
assert!(n < 2usize);
unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x14usize + n * 4usize) as _) }
}
#[doc = "watchdog threshold register 1"]
#[inline(always)]
pub const fn tr(self, n: usize) -> crate::common::Reg<regs::Tr, crate::common::RW> {
assert!(n < 3usize);
unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x20usize + n * 4usize) as _) }
}
#[doc = "regular sequence register 1"]
#[inline(always)]
pub const fn sqr1(self) -> crate::common::Reg<regs::Sqr1, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x30usize) as _) }
}
#[doc = "regular sequence register 2"]
#[inline(always)]
pub const fn sqr2(self) -> crate::common::Reg<regs::Sqr2, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x34usize) as _) }
}
#[doc = "regular sequence register 3"]
#[inline(always)]
pub const fn sqr3(self) -> crate::common::Reg<regs::Sqr3, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x38usize) as _) }
}
#[doc = "regular sequence register 4"]
#[inline(always)]
pub const fn sqr4(self) -> crate::common::Reg<regs::Sqr4, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x3cusize) as _) }
}
#[doc = "regular Data Register"]
#[inline(always)]
pub const fn dr(self) -> crate::common::Reg<regs::Dr, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x40usize) as _) }
}
#[doc = "injected sequence register"]
#[inline(always)]
pub const fn jsqr(self) -> crate::common::Reg<regs::Jsqr, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x4cusize) as _) }
}
#[doc = "offset register 1"]
#[inline(always)]
pub const fn ofr(self, n: usize) -> crate::common::Reg<regs::Ofr, crate::common::RW> {
assert!(n < 4usize);
unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x60usize + n * 4usize) as _) }
}
#[doc = "injected data registers"]
#[inline(always)]
pub const fn jdr(self, n: usize) -> crate::common::Reg<regs::Jdr, crate::common::R> {
assert!(n < 4usize);
unsafe { crate::common::Reg::from_ptr(self.ptr.add(0x80usize + n * 4usize) as _) }
}
#[doc = "Analog Watchdog 2 Configuration Register"]
#[inline(always)]
pub const fn awd2cr(self) -> crate::common::Reg<regs::Awd2cr, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.add(0xa0usize) as _) }
}
#[doc = "Analog Watchdog 3 Configuration Register"]
#[inline(always)]
pub const fn awd3cr(self) -> crate::common::Reg<regs::Awd3cr, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.add(0xa4usize) as _) }
}
#[doc = "Differential Mode Selection Register 2"]
#[inline(always)]
pub const fn difsel(self) -> crate::common::Reg<regs::Difsel, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.add(0xb0usize) as _) }
}
#[doc = "Calibration Factors"]
#[inline(always)]
pub const fn calfact(self) -> crate::common::Reg<regs::Calfact, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.add(0xb4usize) as _) }
}
}
pub mod regs {
#[doc = "Analog Watchdog 2 Configuration Register"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Awd2cr(pub u32);
impl Awd2cr {
#[doc = "AWD2CH"]
#[inline(always)]
pub const fn awd2ch(&self) -> u32 {
let val = (self.0 >> 1usize) & 0x0003_ffff;
val as u32
}
#[doc = "AWD2CH"]
#[inline(always)]
pub fn set_awd2ch(&mut self, val: u32) {
self.0 = (self.0 & !(0x0003_ffff << 1usize)) | (((val as u32) & 0x0003_ffff) << 1usize);
}
}
impl Default for Awd2cr {
#[inline(always)]
fn default() -> Awd2cr {
Awd2cr(0)
}
}
impl core::fmt::Debug for Awd2cr {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Awd2cr").field("awd2ch", &self.awd2ch()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Awd2cr {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Awd2cr {{ awd2ch: {=u32:?} }}", self.awd2ch())
}
}
#[doc = "Analog Watchdog 3 Configuration Register"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Awd3cr(pub u32);
impl Awd3cr {
#[doc = "AWD3CH"]
#[inline(always)]
pub const fn awd3ch(&self) -> u32 {
let val = (self.0 >> 1usize) & 0x0003_ffff;
val as u32
}
#[doc = "AWD3CH"]
#[inline(always)]
pub fn set_awd3ch(&mut self, val: u32) {
self.0 = (self.0 & !(0x0003_ffff << 1usize)) | (((val as u32) & 0x0003_ffff) << 1usize);
}
}
impl Default for Awd3cr {
#[inline(always)]
fn default() -> Awd3cr {
Awd3cr(0)
}
}
impl core::fmt::Debug for Awd3cr {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Awd3cr").field("awd3ch", &self.awd3ch()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Awd3cr {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Awd3cr {{ awd3ch: {=u32:?} }}", self.awd3ch())
}
}
#[doc = "Calibration Factors"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Calfact(pub u32);
impl Calfact {
#[doc = "CALFACT_S"]
#[inline(always)]
pub const fn calfact_s(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x7f;
val as u8
}
#[doc = "CALFACT_S"]
#[inline(always)]
pub fn set_calfact_s(&mut self, val: u8) {
self.0 = (self.0 & !(0x7f << 0usize)) | (((val as u32) & 0x7f) << 0usize);
}
#[doc = "CALFACT_D"]
#[inline(always)]
pub const fn calfact_d(&self) -> u8 {
let val = (self.0 >> 16usize) & 0x7f;
val as u8
}
#[doc = "CALFACT_D"]
#[inline(always)]
pub fn set_calfact_d(&mut self, val: u8) {
self.0 = (self.0 & !(0x7f << 16usize)) | (((val as u32) & 0x7f) << 16usize);
}
}
impl Default for Calfact {
#[inline(always)]
fn default() -> Calfact {
Calfact(0)
}
}
impl core::fmt::Debug for Calfact {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Calfact")
.field("calfact_s", &self.calfact_s())
.field("calfact_d", &self.calfact_d())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Calfact {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Calfact {{ calfact_s: {=u8:?}, calfact_d: {=u8:?} }}",
self.calfact_s(),
self.calfact_d()
)
}
}
#[doc = "configuration register"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Cfgr(pub u32);
impl Cfgr {
#[doc = "DMAEN"]
#[inline(always)]
pub const fn dmaen(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "DMAEN"]
#[inline(always)]
pub fn set_dmaen(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Direct memory access configuration"]
#[inline(always)]
pub const fn dmacfg(&self) -> super::vals::Dmacfg {
let val = (self.0 >> 1usize) & 0x01;
super::vals::Dmacfg::from_bits(val as u8)
}
#[doc = "Direct memory access configuration"]
#[inline(always)]
pub fn set_dmacfg(&mut self, val: super::vals::Dmacfg) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val.to_bits() as u32) & 0x01) << 1usize);
}
#[doc = "RES"]
#[inline(always)]
pub const fn res(&self) -> super::vals::Res {
let val = (self.0 >> 3usize) & 0x03;
super::vals::Res::from_bits(val as u8)
}
#[doc = "RES"]
#[inline(always)]
pub fn set_res(&mut self, val: super::vals::Res) {
self.0 = (self.0 & !(0x03 << 3usize)) | (((val.to_bits() as u32) & 0x03) << 3usize);
}
#[doc = "ALIGN"]
#[inline(always)]
pub const fn align(&self) -> bool {
let val = (self.0 >> 5usize) & 0x01;
val != 0
}
#[doc = "ALIGN"]
#[inline(always)]
pub fn set_align(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
}
#[doc = "EXTSEL"]
#[inline(always)]
pub const fn extsel(&self) -> u8 {
let val = (self.0 >> 6usize) & 0x0f;
val as u8
}
#[doc = "EXTSEL"]
#[inline(always)]
pub fn set_extsel(&mut self, val: u8) {
self.0 = (self.0 & !(0x0f << 6usize)) | (((val as u32) & 0x0f) << 6usize);
}
#[doc = "EXTEN"]
#[inline(always)]
pub const fn exten(&self) -> u8 {
let val = (self.0 >> 10usize) & 0x03;
val as u8
}
#[doc = "EXTEN"]
#[inline(always)]
pub fn set_exten(&mut self, val: u8) {
self.0 = (self.0 & !(0x03 << 10usize)) | (((val as u32) & 0x03) << 10usize);
}
#[doc = "OVRMOD"]
#[inline(always)]
pub const fn ovrmod(&self) -> bool {
let val = (self.0 >> 12usize) & 0x01;
val != 0
}
#[doc = "OVRMOD"]
#[inline(always)]
pub fn set_ovrmod(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 12usize)) | (((val as u32) & 0x01) << 12usize);
}
#[doc = "CONT"]
#[inline(always)]
pub const fn cont(&self) -> bool {
let val = (self.0 >> 13usize) & 0x01;
val != 0
}
#[doc = "CONT"]
#[inline(always)]
pub fn set_cont(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 13usize)) | (((val as u32) & 0x01) << 13usize);
}
#[doc = "AUTDLY"]
#[inline(always)]
pub const fn autdly(&self) -> bool {
let val = (self.0 >> 14usize) & 0x01;
val != 0
}
#[doc = "AUTDLY"]
#[inline(always)]
pub fn set_autdly(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 14usize)) | (((val as u32) & 0x01) << 14usize);
}
#[doc = "AUTOFF"]
#[inline(always)]
pub const fn autoff(&self) -> bool {
let val = (self.0 >> 15usize) & 0x01;
val != 0
}
#[doc = "AUTOFF"]
#[inline(always)]
pub fn set_autoff(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 15usize)) | (((val as u32) & 0x01) << 15usize);
}
#[doc = "DISCEN"]
#[inline(always)]
pub const fn discen(&self) -> bool {
let val = (self.0 >> 16usize) & 0x01;
val != 0
}
#[doc = "DISCEN"]
#[inline(always)]
pub fn set_discen(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 16usize)) | (((val as u32) & 0x01) << 16usize);
}
#[doc = "DISCNUM"]
#[inline(always)]
pub const fn discnum(&self) -> u8 {
let val = (self.0 >> 17usize) & 0x07;
val as u8
}
#[doc = "DISCNUM"]
#[inline(always)]
pub fn set_discnum(&mut self, val: u8) {
self.0 = (self.0 & !(0x07 << 17usize)) | (((val as u32) & 0x07) << 17usize);
}
#[doc = "JDISCEN"]
#[inline(always)]
pub const fn jdiscen(&self) -> bool {
let val = (self.0 >> 20usize) & 0x01;
val != 0
}
#[doc = "JDISCEN"]
#[inline(always)]
pub fn set_jdiscen(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 20usize)) | (((val as u32) & 0x01) << 20usize);
}
#[doc = "JQM"]
#[inline(always)]
pub const fn jqm(&self) -> bool {
let val = (self.0 >> 21usize) & 0x01;
val != 0
}
#[doc = "JQM"]
#[inline(always)]
pub fn set_jqm(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 21usize)) | (((val as u32) & 0x01) << 21usize);
}
#[doc = "AWD1SGL"]
#[inline(always)]
pub const fn awd1sgl(&self) -> bool {
let val = (self.0 >> 22usize) & 0x01;
val != 0
}
#[doc = "AWD1SGL"]
#[inline(always)]
pub fn set_awd1sgl(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 22usize)) | (((val as u32) & 0x01) << 22usize);
}
#[doc = "AWD1EN"]
#[inline(always)]
pub const fn awd1en(&self) -> bool {
let val = (self.0 >> 23usize) & 0x01;
val != 0
}
#[doc = "AWD1EN"]
#[inline(always)]
pub fn set_awd1en(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 23usize)) | (((val as u32) & 0x01) << 23usize);
}
#[doc = "JAWD1EN"]
#[inline(always)]
pub const fn jawd1en(&self) -> bool {
let val = (self.0 >> 24usize) & 0x01;
val != 0
}
#[doc = "JAWD1EN"]
#[inline(always)]
pub fn set_jawd1en(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 24usize)) | (((val as u32) & 0x01) << 24usize);
}
#[doc = "JAUTO"]
#[inline(always)]
pub const fn jauto(&self) -> bool {
let val = (self.0 >> 25usize) & 0x01;
val != 0
}
#[doc = "JAUTO"]
#[inline(always)]
pub fn set_jauto(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 25usize)) | (((val as u32) & 0x01) << 25usize);
}
#[doc = "AWDCH1CH"]
#[inline(always)]
pub const fn awdch1ch(&self) -> u8 {
let val = (self.0 >> 26usize) & 0x1f;
val as u8
}
#[doc = "AWDCH1CH"]
#[inline(always)]
pub fn set_awdch1ch(&mut self, val: u8) {
self.0 = (self.0 & !(0x1f << 26usize)) | (((val as u32) & 0x1f) << 26usize);
}
}
impl Default for Cfgr {
#[inline(always)]
fn default() -> Cfgr {
Cfgr(0)
}
}
impl core::fmt::Debug for Cfgr {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Cfgr")
.field("dmaen", &self.dmaen())
.field("dmacfg", &self.dmacfg())
.field("res", &self.res())
.field("align", &self.align())
.field("extsel", &self.extsel())
.field("exten", &self.exten())
.field("ovrmod", &self.ovrmod())
.field("cont", &self.cont())
.field("autdly", &self.autdly())
.field("autoff", &self.autoff())
.field("discen", &self.discen())
.field("discnum", &self.discnum())
.field("jdiscen", &self.jdiscen())
.field("jqm", &self.jqm())
.field("awd1sgl", &self.awd1sgl())
.field("awd1en", &self.awd1en())
.field("jawd1en", &self.jawd1en())
.field("jauto", &self.jauto())
.field("awdch1ch", &self.awdch1ch())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Cfgr {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Cfgr {{ dmaen: {=bool:?}, dmacfg: {:?}, res: {:?}, align: {=bool:?}, extsel: {=u8:?}, exten: {=u8:?}, ovrmod: {=bool:?}, cont: {=bool:?}, autdly: {=bool:?}, autoff: {=bool:?}, discen: {=bool:?}, discnum: {=u8:?}, jdiscen: {=bool:?}, jqm: {=bool:?}, awd1sgl: {=bool:?}, awd1en: {=bool:?}, jawd1en: {=bool:?}, jauto: {=bool:?}, awdch1ch: {=u8:?} }}" , self . dmaen () , self . dmacfg () , self . res () , self . align () , self . extsel () , self . exten () , self . ovrmod () , self . cont () , self . autdly () , self . autoff () , self . discen () , self . discnum () , self . jdiscen () , self . jqm () , self . awd1sgl () , self . awd1en () , self . jawd1en () , self . jauto () , self . awdch1ch ())
}
}
#[doc = "configuration register"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Cfgr2(pub u32);
impl Cfgr2 {
#[doc = "Regular Oversampling Enable"]
#[inline(always)]
pub const fn rovse(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Regular Oversampling Enable"]
#[inline(always)]
pub fn set_rovse(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Injected Oversampling Enable"]
#[inline(always)]
pub const fn jovse(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Injected Oversampling Enable"]
#[inline(always)]
pub fn set_jovse(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "Oversampling Ratio"]
#[inline(always)]
pub const fn ovsr(&self) -> super::vals::OversamplingRatio {
let val = (self.0 >> 2usize) & 0x07;
super::vals::OversamplingRatio::from_bits(val as u8)
}
#[doc = "Oversampling Ratio"]
#[inline(always)]
pub fn set_ovsr(&mut self, val: super::vals::OversamplingRatio) {
self.0 = (self.0 & !(0x07 << 2usize)) | (((val.to_bits() as u32) & 0x07) << 2usize);
}
#[doc = "Oversampling Shift"]
#[inline(always)]
pub const fn ovss(&self) -> super::vals::OversamplingShift {
let val = (self.0 >> 5usize) & 0x0f;
super::vals::OversamplingShift::from_bits(val as u8)
}
#[doc = "Oversampling Shift"]
#[inline(always)]
pub fn set_ovss(&mut self, val: super::vals::OversamplingShift) {
self.0 = (self.0 & !(0x0f << 5usize)) | (((val.to_bits() as u32) & 0x0f) << 5usize);
}
#[doc = "Triggered Regular Oversampling"]
#[inline(always)]
pub const fn trovs(&self) -> super::vals::Trovs {
let val = (self.0 >> 9usize) & 0x01;
super::vals::Trovs::from_bits(val as u8)
}
#[doc = "Triggered Regular Oversampling"]
#[inline(always)]
pub fn set_trovs(&mut self, val: super::vals::Trovs) {
self.0 = (self.0 & !(0x01 << 9usize)) | (((val.to_bits() as u32) & 0x01) << 9usize);
}
#[doc = "Regular Oversampling Mode"]
#[inline(always)]
pub const fn rovsm(&self) -> super::vals::Rovsm {
let val = (self.0 >> 10usize) & 0x01;
super::vals::Rovsm::from_bits(val as u8)
}
#[doc = "Regular Oversampling Mode"]
#[inline(always)]
pub fn set_rovsm(&mut self, val: super::vals::Rovsm) {
self.0 = (self.0 & !(0x01 << 10usize)) | (((val.to_bits() as u32) & 0x01) << 10usize);
}
}
impl Default for Cfgr2 {
#[inline(always)]
fn default() -> Cfgr2 {
Cfgr2(0)
}
}
impl core::fmt::Debug for Cfgr2 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Cfgr2")
.field("rovse", &self.rovse())
.field("jovse", &self.jovse())
.field("ovsr", &self.ovsr())
.field("ovss", &self.ovss())
.field("trovs", &self.trovs())
.field("rovsm", &self.rovsm())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Cfgr2 {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Cfgr2 {{ rovse: {=bool:?}, jovse: {=bool:?}, ovsr: {:?}, ovss: {:?}, trovs: {:?}, rovsm: {:?} }}",
self.rovse(),
self.jovse(),
self.ovsr(),
self.ovss(),
self.trovs(),
self.rovsm()
)
}
}
#[doc = "control register"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Cr(pub u32);
impl Cr {
#[doc = "ADEN"]
#[inline(always)]
pub const fn aden(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "ADEN"]
#[inline(always)]
pub fn set_aden(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "ADDIS"]
#[inline(always)]
pub const fn addis(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "ADDIS"]
#[inline(always)]
pub fn set_addis(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "ADSTART"]
#[inline(always)]
pub const fn adstart(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "ADSTART"]
#[inline(always)]
pub fn set_adstart(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "JADSTART"]
#[inline(always)]
pub const fn jadstart(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "JADSTART"]
#[inline(always)]
pub fn set_jadstart(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
#[doc = "ADSTP"]
#[inline(always)]
pub const fn adstp(&self) -> bool {
let val = (self.0 >> 4usize) & 0x01;
val != 0
}
#[doc = "ADSTP"]
#[inline(always)]
pub fn set_adstp(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
}
#[doc = "JADSTP"]
#[inline(always)]
pub const fn jadstp(&self) -> bool {
let val = (self.0 >> 5usize) & 0x01;
val != 0
}
#[doc = "JADSTP"]
#[inline(always)]
pub fn set_jadstp(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
}
#[doc = "ADVREGEN"]
#[inline(always)]
pub const fn advregen(&self) -> bool {
let val = (self.0 >> 28usize) & 0x01;
val != 0
}
#[doc = "ADVREGEN"]
#[inline(always)]
pub fn set_advregen(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 28usize)) | (((val as u32) & 0x01) << 28usize);
}
#[doc = "DEEPPWD"]
#[inline(always)]
pub const fn deeppwd(&self) -> bool {
let val = (self.0 >> 29usize) & 0x01;
val != 0
}
#[doc = "DEEPPWD"]
#[inline(always)]
pub fn set_deeppwd(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 29usize)) | (((val as u32) & 0x01) << 29usize);
}
#[doc = "ADCALDIF"]
#[inline(always)]
pub const fn adcaldif(&self) -> bool {
let val = (self.0 >> 30usize) & 0x01;
val != 0
}
#[doc = "ADCALDIF"]
#[inline(always)]
pub fn set_adcaldif(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 30usize)) | (((val as u32) & 0x01) << 30usize);
}
#[doc = "ADCAL"]
#[inline(always)]
pub const fn adcal(&self) -> bool {
let val = (self.0 >> 31usize) & 0x01;
val != 0
}
#[doc = "ADCAL"]
#[inline(always)]
pub fn set_adcal(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 31usize)) | (((val as u32) & 0x01) << 31usize);
}
}
impl Default for Cr {
#[inline(always)]
fn default() -> Cr {
Cr(0)
}
}
impl core::fmt::Debug for Cr {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Cr")
.field("aden", &self.aden())
.field("addis", &self.addis())
.field("adstart", &self.adstart())
.field("jadstart", &self.jadstart())
.field("adstp", &self.adstp())
.field("jadstp", &self.jadstp())
.field("advregen", &self.advregen())
.field("deeppwd", &self.deeppwd())
.field("adcaldif", &self.adcaldif())
.field("adcal", &self.adcal())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Cr {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Cr {{ aden: {=bool:?}, addis: {=bool:?}, adstart: {=bool:?}, jadstart: {=bool:?}, adstp: {=bool:?}, jadstp: {=bool:?}, advregen: {=bool:?}, deeppwd: {=bool:?}, adcaldif: {=bool:?}, adcal: {=bool:?} }}" , self . aden () , self . addis () , self . adstart () , self . jadstart () , self . adstp () , self . jadstp () , self . advregen () , self . deeppwd () , self . adcaldif () , self . adcal ())
}
}
#[doc = "Differential Mode Selection Register 2"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Difsel(pub u32);
impl Difsel {
#[doc = "Differential mode for channels 15 to 1"]
#[inline(always)]
pub const fn difsel_1_15(&self) -> u16 {
let val = (self.0 >> 1usize) & 0x7fff;
val as u16
}
#[doc = "Differential mode for channels 15 to 1"]
#[inline(always)]
pub fn set_difsel_1_15(&mut self, val: u16) {
self.0 = (self.0 & !(0x7fff << 1usize)) | (((val as u32) & 0x7fff) << 1usize);
}
#[doc = "Differential mode for channels 18 to 16"]
#[inline(always)]
pub const fn difsel_16_18(&self) -> u8 {
let val = (self.0 >> 16usize) & 0x07;
val as u8
}
#[doc = "Differential mode for channels 18 to 16"]
#[inline(always)]
pub fn set_difsel_16_18(&mut self, val: u8) {
self.0 = (self.0 & !(0x07 << 16usize)) | (((val as u32) & 0x07) << 16usize);
}
}
impl Default for Difsel {
#[inline(always)]
fn default() -> Difsel {
Difsel(0)
}
}
impl core::fmt::Debug for Difsel {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Difsel")
.field("difsel_1_15", &self.difsel_1_15())
.field("difsel_16_18", &self.difsel_16_18())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Difsel {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Difsel {{ difsel_1_15: {=u16:?}, difsel_16_18: {=u8:?} }}",
self.difsel_1_15(),
self.difsel_16_18()
)
}
}
#[doc = "regular Data Register"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Dr(pub u32);
impl Dr {
#[doc = "regularDATA"]
#[inline(always)]
pub const fn regular_data(&self) -> u16 {
let val = (self.0 >> 0usize) & 0xffff;
val as u16
}
#[doc = "regularDATA"]
#[inline(always)]
pub fn set_regular_data(&mut self, val: u16) {
self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize);
}
}
impl Default for Dr {
#[inline(always)]
fn default() -> Dr {
Dr(0)
}
}
impl core::fmt::Debug for Dr {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Dr")
.field("regular_data", &self.regular_data())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Dr {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Dr {{ regular_data: {=u16:?} }}", self.regular_data())
}
}
#[doc = "interrupt enable register"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Ier(pub u32);
impl Ier {
#[doc = "ADRDYIE"]
#[inline(always)]
pub const fn adrdyie(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "ADRDYIE"]
#[inline(always)]
pub fn set_adrdyie(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "EOSMPIE"]
#[inline(always)]
pub const fn eosmpie(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "EOSMPIE"]
#[inline(always)]
pub fn set_eosmpie(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "EOCIE"]
#[inline(always)]
pub const fn eocie(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "EOCIE"]
#[inline(always)]
pub fn set_eocie(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "EOSIE"]
#[inline(always)]
pub const fn eosie(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "EOSIE"]
#[inline(always)]
pub fn set_eosie(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
#[doc = "OVRIE"]
#[inline(always)]
pub const fn ovrie(&self) -> bool {
let val = (self.0 >> 4usize) & 0x01;
val != 0
}
#[doc = "OVRIE"]
#[inline(always)]
pub fn set_ovrie(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
}
#[doc = "JEOCIE"]
#[inline(always)]
pub const fn jeocie(&self) -> bool {
let val = (self.0 >> 5usize) & 0x01;
val != 0
}
#[doc = "JEOCIE"]
#[inline(always)]
pub fn set_jeocie(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
}
#[doc = "JEOSIE"]
#[inline(always)]
pub const fn jeosie(&self) -> bool {
let val = (self.0 >> 6usize) & 0x01;
val != 0
}
#[doc = "JEOSIE"]
#[inline(always)]
pub fn set_jeosie(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize);
}
#[doc = "AWD1IE"]
#[inline(always)]
pub const fn awd1ie(&self) -> bool {
let val = (self.0 >> 7usize) & 0x01;
val != 0
}
#[doc = "AWD1IE"]
#[inline(always)]
pub fn set_awd1ie(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize);
}
#[doc = "AWD2IE"]
#[inline(always)]
pub const fn awd2ie(&self) -> bool {
let val = (self.0 >> 8usize) & 0x01;
val != 0
}
#[doc = "AWD2IE"]
#[inline(always)]
pub fn set_awd2ie(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize);
}
#[doc = "AWD3IE"]
#[inline(always)]
pub const fn awd3ie(&self) -> bool {
let val = (self.0 >> 9usize) & 0x01;
val != 0
}
#[doc = "AWD3IE"]
#[inline(always)]
pub fn set_awd3ie(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 9usize)) | (((val as u32) & 0x01) << 9usize);
}
#[doc = "JQOVFIE"]
#[inline(always)]
pub const fn jqovfie(&self) -> bool {
let val = (self.0 >> 10usize) & 0x01;
val != 0
}
#[doc = "JQOVFIE"]
#[inline(always)]
pub fn set_jqovfie(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 10usize)) | (((val as u32) & 0x01) << 10usize);
}
}
impl Default for Ier {
#[inline(always)]
fn default() -> Ier {
Ier(0)
}
}
impl core::fmt::Debug for Ier {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Ier")
.field("adrdyie", &self.adrdyie())
.field("eosmpie", &self.eosmpie())
.field("eocie", &self.eocie())
.field("eosie", &self.eosie())
.field("ovrie", &self.ovrie())
.field("jeocie", &self.jeocie())
.field("jeosie", &self.jeosie())
.field("awd1ie", &self.awd1ie())
.field("awd2ie", &self.awd2ie())
.field("awd3ie", &self.awd3ie())
.field("jqovfie", &self.jqovfie())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Ier {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Ier {{ adrdyie: {=bool:?}, eosmpie: {=bool:?}, eocie: {=bool:?}, eosie: {=bool:?}, ovrie: {=bool:?}, jeocie: {=bool:?}, jeosie: {=bool:?}, awd1ie: {=bool:?}, awd2ie: {=bool:?}, awd3ie: {=bool:?}, jqovfie: {=bool:?} }}" , self . adrdyie () , self . eosmpie () , self . eocie () , self . eosie () , self . ovrie () , self . jeocie () , self . jeosie () , self . awd1ie () , self . awd2ie () , self . awd3ie () , self . jqovfie ())
}
}
#[doc = "interrupt and status register"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Isr(pub u32);
impl Isr {
#[doc = "ADRDY"]
#[inline(always)]
pub const fn adrdy(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "ADRDY"]
#[inline(always)]
pub fn set_adrdy(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "EOSMP"]
#[inline(always)]
pub const fn eosmp(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "EOSMP"]
#[inline(always)]
pub fn set_eosmp(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "EOC"]
#[inline(always)]
pub const fn eoc(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "EOC"]
#[inline(always)]
pub fn set_eoc(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "EOS"]
#[inline(always)]
pub const fn eos(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "EOS"]
#[inline(always)]
pub fn set_eos(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
#[doc = "OVR"]
#[inline(always)]
pub const fn ovr(&self) -> bool {
let val = (self.0 >> 4usize) & 0x01;
val != 0
}
#[doc = "OVR"]
#[inline(always)]
pub fn set_ovr(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
}
#[doc = "JEOC"]
#[inline(always)]
pub const fn jeoc(&self) -> bool {
let val = (self.0 >> 5usize) & 0x01;
val != 0
}
#[doc = "JEOC"]
#[inline(always)]
pub fn set_jeoc(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
}
#[doc = "JEOS"]
#[inline(always)]
pub const fn jeos(&self) -> bool {
let val = (self.0 >> 6usize) & 0x01;
val != 0
}
#[doc = "JEOS"]
#[inline(always)]
pub fn set_jeos(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize);
}
#[doc = "AWD1"]
#[inline(always)]
pub const fn awd(&self, n: usize) -> bool {
assert!(n < 3usize);
let offs = 7usize + n * 1usize;
let val = (self.0 >> offs) & 0x01;
val != 0
}
#[doc = "AWD1"]
#[inline(always)]
pub fn set_awd(&mut self, n: usize, val: bool) {
assert!(n < 3usize);
let offs = 7usize + n * 1usize;
self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
}
#[doc = "JQOVF"]
#[inline(always)]
pub const fn jqovf(&self) -> bool {
let val = (self.0 >> 10usize) & 0x01;
val != 0
}
#[doc = "JQOVF"]
#[inline(always)]
pub fn set_jqovf(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 10usize)) | (((val as u32) & 0x01) << 10usize);
}
}
impl Default for Isr {
#[inline(always)]
fn default() -> Isr {
Isr(0)
}
}
impl core::fmt::Debug for Isr {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Isr")
.field("adrdy", &self.adrdy())
.field("eosmp", &self.eosmp())
.field("eoc", &self.eoc())
.field("eos", &self.eos())
.field("ovr", &self.ovr())
.field("jeoc", &self.jeoc())
.field("jeos", &self.jeos())
.field("awd[0]", &self.awd(0usize))
.field("awd[1]", &self.awd(1usize))
.field("awd[2]", &self.awd(2usize))
.field("jqovf", &self.jqovf())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Isr {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Isr {{ adrdy: {=bool:?}, eosmp: {=bool:?}, eoc: {=bool:?}, eos: {=bool:?}, ovr: {=bool:?}, jeoc: {=bool:?}, jeos: {=bool:?}, awd[0]: {=bool:?}, awd[1]: {=bool:?}, awd[2]: {=bool:?}, jqovf: {=bool:?} }}" , self . adrdy () , self . eosmp () , self . eoc () , self . eos () , self . ovr () , self . jeoc () , self . jeos () , self . awd (0usize) , self . awd (1usize) , self . awd (2usize) , self . jqovf ())
}
}
#[doc = "injected data register 1"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Jdr(pub u32);
impl Jdr {
#[doc = "JDATA1"]
#[inline(always)]
pub const fn jdata(&self) -> u16 {
let val = (self.0 >> 0usize) & 0xffff;
val as u16
}
#[doc = "JDATA1"]
#[inline(always)]
pub fn set_jdata(&mut self, val: u16) {
self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize);
}
}
impl Default for Jdr {
#[inline(always)]
fn default() -> Jdr {
Jdr(0)
}
}
impl core::fmt::Debug for Jdr {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Jdr").field("jdata", &self.jdata()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Jdr {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Jdr {{ jdata: {=u16:?} }}", self.jdata())
}
}
#[doc = "injected sequence register"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Jsqr(pub u32);
impl Jsqr {
#[doc = "JL"]
#[inline(always)]
pub const fn jl(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x03;
val as u8
}
#[doc = "JL"]
#[inline(always)]
pub fn set_jl(&mut self, val: u8) {
self.0 = (self.0 & !(0x03 << 0usize)) | (((val as u32) & 0x03) << 0usize);
}
#[doc = "JEXTSEL"]
#[inline(always)]
pub const fn jextsel(&self) -> u8 {
let val = (self.0 >> 2usize) & 0x0f;
val as u8
}
#[doc = "JEXTSEL"]
#[inline(always)]
pub fn set_jextsel(&mut self, val: u8) {
self.0 = (self.0 & !(0x0f << 2usize)) | (((val as u32) & 0x0f) << 2usize);
}
#[doc = "JEXTEN"]
#[inline(always)]
pub const fn jexten(&self) -> u8 {
let val = (self.0 >> 6usize) & 0x03;
val as u8
}
#[doc = "JEXTEN"]
#[inline(always)]
pub fn set_jexten(&mut self, val: u8) {
self.0 = (self.0 & !(0x03 << 6usize)) | (((val as u32) & 0x03) << 6usize);
}
#[doc = "JSQ"]
#[inline(always)]
pub const fn jsq(&self, n: usize) -> u8 {
assert!(n < 4usize);
let offs = 8usize + n * 6usize;
let val = (self.0 >> offs) & 0x1f;
val as u8
}
#[doc = "JSQ"]
#[inline(always)]
pub fn set_jsq(&mut self, n: usize, val: u8) {
assert!(n < 4usize);
let offs = 8usize + n * 6usize;
self.0 = (self.0 & !(0x1f << offs)) | (((val as u32) & 0x1f) << offs);
}
}
impl Default for Jsqr {
#[inline(always)]
fn default() -> Jsqr {
Jsqr(0)
}
}
impl core::fmt::Debug for Jsqr {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Jsqr")
.field("jl", &self.jl())
.field("jextsel", &self.jextsel())
.field("jexten", &self.jexten())
.field("jsq[0]", &self.jsq(0usize))
.field("jsq[1]", &self.jsq(1usize))
.field("jsq[2]", &self.jsq(2usize))
.field("jsq[3]", &self.jsq(3usize))
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Jsqr {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Jsqr {{ jl: {=u8:?}, jextsel: {=u8:?}, jexten: {=u8:?}, jsq[0]: {=u8:?}, jsq[1]: {=u8:?}, jsq[2]: {=u8:?}, jsq[3]: {=u8:?} }}" , self . jl () , self . jextsel () , self . jexten () , self . jsq (0usize) , self . jsq (1usize) , self . jsq (2usize) , self . jsq (3usize))
}
}
#[doc = "offset register"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Ofr(pub u32);
impl Ofr {
#[inline(always)]
pub const fn offset(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x0fff;
val as u16
}
#[inline(always)]
pub fn set_offset(&mut self, val: u16) {
self.0 = (self.0 & !(0x0fff << 0usize)) | (((val as u32) & 0x0fff) << 0usize);
}
#[inline(always)]
pub const fn offset_ch(&self) -> u8 {
let val = (self.0 >> 26usize) & 0x1f;
val as u8
}
#[inline(always)]
pub fn set_offset_ch(&mut self, val: u8) {
self.0 = (self.0 & !(0x1f << 26usize)) | (((val as u32) & 0x1f) << 26usize);
}
#[inline(always)]
pub const fn offset_en(&self) -> bool {
let val = (self.0 >> 31usize) & 0x01;
val != 0
}
#[inline(always)]
pub fn set_offset_en(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 31usize)) | (((val as u32) & 0x01) << 31usize);
}
}
impl Default for Ofr {
#[inline(always)]
fn default() -> Ofr {
Ofr(0)
}
}
impl core::fmt::Debug for Ofr {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Ofr")
.field("offset", &self.offset())
.field("offset_ch", &self.offset_ch())
.field("offset_en", &self.offset_en())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Ofr {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Ofr {{ offset: {=u16:?}, offset_ch: {=u8:?}, offset_en: {=bool:?} }}",
self.offset(),
self.offset_ch(),
self.offset_en()
)
}
}
#[doc = "sample time register 1"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Smpr(pub u32);
impl Smpr {
#[doc = "Channel 0 sampling time selection"]
#[inline(always)]
pub const fn smp(&self, n: usize) -> super::vals::SampleTime {
assert!(n < 10usize);
let offs = 0usize + n * 3usize;
let val = (self.0 >> offs) & 0x07;
super::vals::SampleTime::from_bits(val as u8)
}
#[doc = "Channel 0 sampling time selection"]
#[inline(always)]
pub fn set_smp(&mut self, n: usize, val: super::vals::SampleTime) {
assert!(n < 10usize);
let offs = 0usize + n * 3usize;
self.0 = (self.0 & !(0x07 << offs)) | (((val.to_bits() as u32) & 0x07) << offs);
}
}
impl Default for Smpr {
#[inline(always)]
fn default() -> Smpr {
Smpr(0)
}
}
impl core::fmt::Debug for Smpr {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Smpr")
.field("smp[0]", &self.smp(0usize))
.field("smp[1]", &self.smp(1usize))
.field("smp[2]", &self.smp(2usize))
.field("smp[3]", &self.smp(3usize))
.field("smp[4]", &self.smp(4usize))
.field("smp[5]", &self.smp(5usize))
.field("smp[6]", &self.smp(6usize))
.field("smp[7]", &self.smp(7usize))
.field("smp[8]", &self.smp(8usize))
.field("smp[9]", &self.smp(9usize))
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Smpr {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Smpr {{ smp[0]: {:?}, smp[1]: {:?}, smp[2]: {:?}, smp[3]: {:?}, smp[4]: {:?}, smp[5]: {:?}, smp[6]: {:?}, smp[7]: {:?}, smp[8]: {:?}, smp[9]: {:?} }}" , self . smp (0usize) , self . smp (1usize) , self . smp (2usize) , self . smp (3usize) , self . smp (4usize) , self . smp (5usize) , self . smp (6usize) , self . smp (7usize) , self . smp (8usize) , self . smp (9usize))
}
}
#[doc = "regular sequence register 1"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Sqr1(pub u32);
impl Sqr1 {
#[doc = "Regular channel sequence length"]
#[inline(always)]
pub const fn l(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x0f;
val as u8
}
#[doc = "Regular channel sequence length"]
#[inline(always)]
pub fn set_l(&mut self, val: u8) {
self.0 = (self.0 & !(0x0f << 0usize)) | (((val as u32) & 0x0f) << 0usize);
}
#[doc = "SQ1"]
#[inline(always)]
pub const fn sq(&self, n: usize) -> u8 {
assert!(n < 4usize);
let offs = 6usize + n * 6usize;
let val = (self.0 >> offs) & 0x1f;
val as u8
}
#[doc = "SQ1"]
#[inline(always)]
pub fn set_sq(&mut self, n: usize, val: u8) {
assert!(n < 4usize);
let offs = 6usize + n * 6usize;
self.0 = (self.0 & !(0x1f << offs)) | (((val as u32) & 0x1f) << offs);
}
}
impl Default for Sqr1 {
#[inline(always)]
fn default() -> Sqr1 {
Sqr1(0)
}
}
impl core::fmt::Debug for Sqr1 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Sqr1")
.field("l", &self.l())
.field("sq[0]", &self.sq(0usize))
.field("sq[1]", &self.sq(1usize))
.field("sq[2]", &self.sq(2usize))
.field("sq[3]", &self.sq(3usize))
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Sqr1 {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Sqr1 {{ l: {=u8:?}, sq[0]: {=u8:?}, sq[1]: {=u8:?}, sq[2]: {=u8:?}, sq[3]: {=u8:?} }}",
self.l(),
self.sq(0usize),
self.sq(1usize),
self.sq(2usize),
self.sq(3usize)
)
}
}
#[doc = "regular sequence register 2"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Sqr2(pub u32);
impl Sqr2 {
#[doc = "SQ5"]
#[inline(always)]
pub const fn sq(&self, n: usize) -> u8 {
assert!(n < 5usize);
let offs = 0usize + n * 6usize;
let val = (self.0 >> offs) & 0x1f;
val as u8
}
#[doc = "SQ5"]
#[inline(always)]
pub fn set_sq(&mut self, n: usize, val: u8) {
assert!(n < 5usize);
let offs = 0usize + n * 6usize;
self.0 = (self.0 & !(0x1f << offs)) | (((val as u32) & 0x1f) << offs);
}
}
impl Default for Sqr2 {
#[inline(always)]
fn default() -> Sqr2 {
Sqr2(0)
}
}
impl core::fmt::Debug for Sqr2 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Sqr2")
.field("sq[0]", &self.sq(0usize))
.field("sq[1]", &self.sq(1usize))
.field("sq[2]", &self.sq(2usize))
.field("sq[3]", &self.sq(3usize))
.field("sq[4]", &self.sq(4usize))
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Sqr2 {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Sqr2 {{ sq[0]: {=u8:?}, sq[1]: {=u8:?}, sq[2]: {=u8:?}, sq[3]: {=u8:?}, sq[4]: {=u8:?} }}",
self.sq(0usize),
self.sq(1usize),
self.sq(2usize),
self.sq(3usize),
self.sq(4usize)
)
}
}
#[doc = "regular sequence register 3"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Sqr3(pub u32);
impl Sqr3 {
#[doc = "SQ10"]
#[inline(always)]
pub const fn sq(&self, n: usize) -> u8 {
assert!(n < 5usize);
let offs = 0usize + n * 6usize;
let val = (self.0 >> offs) & 0x1f;
val as u8
}
#[doc = "SQ10"]
#[inline(always)]
pub fn set_sq(&mut self, n: usize, val: u8) {
assert!(n < 5usize);
let offs = 0usize + n * 6usize;
self.0 = (self.0 & !(0x1f << offs)) | (((val as u32) & 0x1f) << offs);
}
}
impl Default for Sqr3 {
#[inline(always)]
fn default() -> Sqr3 {
Sqr3(0)
}
}
impl core::fmt::Debug for Sqr3 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Sqr3")
.field("sq[0]", &self.sq(0usize))
.field("sq[1]", &self.sq(1usize))
.field("sq[2]", &self.sq(2usize))
.field("sq[3]", &self.sq(3usize))
.field("sq[4]", &self.sq(4usize))
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Sqr3 {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Sqr3 {{ sq[0]: {=u8:?}, sq[1]: {=u8:?}, sq[2]: {=u8:?}, sq[3]: {=u8:?}, sq[4]: {=u8:?} }}",
self.sq(0usize),
self.sq(1usize),
self.sq(2usize),
self.sq(3usize),
self.sq(4usize)
)
}
}
#[doc = "regular sequence register 4"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Sqr4(pub u32);
impl Sqr4 {
#[doc = "SQ15"]
#[inline(always)]
pub const fn sq(&self, n: usize) -> u8 {
assert!(n < 2usize);
let offs = 0usize + n * 6usize;
let val = (self.0 >> offs) & 0x1f;
val as u8
}
#[doc = "SQ15"]
#[inline(always)]
pub fn set_sq(&mut self, n: usize, val: u8) {
assert!(n < 2usize);
let offs = 0usize + n * 6usize;
self.0 = (self.0 & !(0x1f << offs)) | (((val as u32) & 0x1f) << offs);
}
}
impl Default for Sqr4 {
#[inline(always)]
fn default() -> Sqr4 {
Sqr4(0)
}
}
impl core::fmt::Debug for Sqr4 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Sqr4")
.field("sq[0]", &self.sq(0usize))
.field("sq[1]", &self.sq(1usize))
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Sqr4 {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Sqr4 {{ sq[0]: {=u8:?}, sq[1]: {=u8:?} }}",
self.sq(0usize),
self.sq(1usize)
)
}
}
#[doc = "watchdog threshold register"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Tr(pub u32);
impl Tr {
#[doc = "LT1"]
#[inline(always)]
pub const fn lt(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x0fff;
val as u16
}
#[doc = "LT1"]
#[inline(always)]
pub fn set_lt(&mut self, val: u16) {
self.0 = (self.0 & !(0x0fff << 0usize)) | (((val as u32) & 0x0fff) << 0usize);
}
#[doc = "HT1"]
#[inline(always)]
pub const fn ht(&self) -> u16 {
let val = (self.0 >> 16usize) & 0x0fff;
val as u16
}
#[doc = "HT1"]
#[inline(always)]
pub fn set_ht(&mut self, val: u16) {
self.0 = (self.0 & !(0x0fff << 16usize)) | (((val as u32) & 0x0fff) << 16usize);
}
}
impl Default for Tr {
#[inline(always)]
fn default() -> Tr {
Tr(0)
}
}
impl core::fmt::Debug for Tr {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Tr")
.field("lt", &self.lt())
.field("ht", &self.ht())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Tr {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Tr {{ lt: {=u16:?}, ht: {=u16:?} }}", self.lt(), self.ht())
}
}
}
pub mod vals {
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Dmacfg {
#[doc = "DMA One Shot mode selected"]
ONE_SHOT = 0x0,
#[doc = "DMA Circular mode selected"]
CIRCULAR = 0x01,
}
impl Dmacfg {
#[inline(always)]
pub const fn from_bits(val: u8) -> Dmacfg {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Dmacfg {
#[inline(always)]
fn from(val: u8) -> Dmacfg {
Dmacfg::from_bits(val)
}
}
impl From<Dmacfg> for u8 {
#[inline(always)]
fn from(val: Dmacfg) -> u8 {
Dmacfg::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum OversamplingRatio {
#[doc = "2x Oversampling Ratio"]
RATIO2 = 0x0,
#[doc = "4x Oversampling Ratio"]
RATIO4 = 0x01,
#[doc = "8x Oversampling Ratio"]
RATIO8 = 0x02,
#[doc = "16x Oversampling Ratio"]
RATIO16 = 0x03,
#[doc = "32x Oversampling Ratio"]
RATIO32 = 0x04,
#[doc = "64x Oversampling Ratio"]
RATIO64 = 0x05,
#[doc = "128x Oversampling Ratio"]
RATIO128 = 0x06,
#[doc = "256x Oversampling Ratio"]
RATIO256 = 0x07,
}
impl OversamplingRatio {
#[inline(always)]
pub const fn from_bits(val: u8) -> OversamplingRatio {
unsafe { core::mem::transmute(val & 0x07) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for OversamplingRatio {
#[inline(always)]
fn from(val: u8) -> OversamplingRatio {
OversamplingRatio::from_bits(val)
}
}
impl From<OversamplingRatio> for u8 {
#[inline(always)]
fn from(val: OversamplingRatio) -> u8 {
OversamplingRatio::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum OversamplingShift {
#[doc = "No shift"]
SHIFT0 = 0x0,
#[doc = "Shift 1-bit"]
SHIFT1 = 0x01,
#[doc = "Shift 2-bits"]
SHIFT2 = 0x02,
#[doc = "Shift 3-bits"]
SHIFT3 = 0x03,
#[doc = "Shift 4-bits"]
SHIFT4 = 0x04,
#[doc = "Shift 5-bits"]
SHIFT5 = 0x05,
#[doc = "Shift 6-bits"]
SHIFT6 = 0x06,
#[doc = "Shift 7-bits"]
SHIFT7 = 0x07,
#[doc = "Shift 8-bits"]
SHIFT8 = 0x08,
_RESERVED_9 = 0x09,
_RESERVED_a = 0x0a,
_RESERVED_b = 0x0b,
_RESERVED_c = 0x0c,
_RESERVED_d = 0x0d,
_RESERVED_e = 0x0e,
_RESERVED_f = 0x0f,
}
impl OversamplingShift {
#[inline(always)]
pub const fn from_bits(val: u8) -> OversamplingShift {
unsafe { core::mem::transmute(val & 0x0f) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for OversamplingShift {
#[inline(always)]
fn from(val: u8) -> OversamplingShift {
OversamplingShift::from_bits(val)
}
}
impl From<OversamplingShift> for u8 {
#[inline(always)]
fn from(val: OversamplingShift) -> u8 {
OversamplingShift::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Res {
#[doc = "12-bit resolution"]
BITS12 = 0x0,
#[doc = "10-bit resolution"]
BITS10 = 0x01,
#[doc = "8-bit resolution"]
BITS8 = 0x02,
#[doc = "6-bit resolution"]
BITS6 = 0x03,
}
impl Res {
#[inline(always)]
pub const fn from_bits(val: u8) -> Res {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Res {
#[inline(always)]
fn from(val: u8) -> Res {
Res::from_bits(val)
}
}
impl From<Res> for u8 {
#[inline(always)]
fn from(val: Res) -> u8 {
Res::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Rovsm {
#[doc = "Oversampling is temporarily stopped and continued after injection sequence"]
CONTINUED = 0x0,
#[doc = "Oversampling is aborted and resumed from start after injection sequence"]
RESUMED = 0x01,
}
impl Rovsm {
#[inline(always)]
pub const fn from_bits(val: u8) -> Rovsm {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Rovsm {
#[inline(always)]
fn from(val: u8) -> Rovsm {
Rovsm::from_bits(val)
}
}
impl From<Rovsm> for u8 {
#[inline(always)]
fn from(val: Rovsm) -> u8 {
Rovsm::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum SampleTime {
#[doc = "2.5 ADC cycles"]
CYCLES2_5 = 0x0,
#[doc = "6.5 ADC cycles"]
CYCLES6_5 = 0x01,
#[doc = "12.5 ADC cycles"]
CYCLES12_5 = 0x02,
#[doc = "24.5 ADC cycles"]
CYCLES24_5 = 0x03,
#[doc = "47.5 ADC cycles"]
CYCLES47_5 = 0x04,
#[doc = "92.5 ADC cycles"]
CYCLES92_5 = 0x05,
#[doc = "247.5 ADC cycles"]
CYCLES247_5 = 0x06,
#[doc = "640.5 ADC cycles"]
CYCLES640_5 = 0x07,
}
impl SampleTime {
#[inline(always)]
pub const fn from_bits(val: u8) -> SampleTime {
unsafe { core::mem::transmute(val & 0x07) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for SampleTime {
#[inline(always)]
fn from(val: u8) -> SampleTime {
SampleTime::from_bits(val)
}
}
impl From<SampleTime> for u8 {
#[inline(always)]
fn from(val: SampleTime) -> u8 {
SampleTime::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Trovs {
#[doc = "All oversampled conversions for a channel are done consecutively following a trigger"]
AUTOMATIC = 0x0,
#[doc = "Each oversampled conversion for a channel needs a new trigger"]
TRIGGERED = 0x01,
}
impl Trovs {
#[inline(always)]
pub const fn from_bits(val: u8) -> Trovs {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Trovs {
#[inline(always)]
fn from(val: u8) -> Trovs {
Trovs::from_bits(val)
}
}
impl From<Trovs> for u8 {
#[inline(always)]
fn from(val: Trovs) -> u8 {
Trovs::to_bits(val)
}
}
}