#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
#![doc = "Peripheral access API (generated using chiptool v0.1.0 (bcf538a 2026-05-18))"]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Interrupt {
#[doc = "0 - CLOCK_POWER"]
CLOCK_POWER = 0,
#[doc = "1 - RADIO"]
RADIO = 1,
#[doc = "2 - UARTE0"]
UARTE0 = 2,
#[doc = "3 - TWISPI0"]
TWISPI0 = 3,
#[doc = "4 - TWISPI1"]
TWISPI1 = 4,
#[doc = "6 - GPIOTE"]
GPIOTE = 6,
#[doc = "8 - TIMER0"]
TIMER0 = 8,
#[doc = "9 - TIMER1"]
TIMER1 = 9,
#[doc = "10 - TIMER2"]
TIMER2 = 10,
#[doc = "11 - RTC0"]
RTC0 = 11,
#[doc = "12 - TEMP"]
TEMP = 12,
#[doc = "13 - RNG"]
RNG = 13,
#[doc = "14 - ECB"]
ECB = 14,
#[doc = "15 - AAR_CCM"]
AAR_CCM = 15,
#[doc = "16 - WDT"]
WDT = 16,
#[doc = "17 - RTC1"]
RTC1 = 17,
#[doc = "18 - QDEC"]
QDEC = 18,
#[doc = "19 - COMP"]
COMP = 19,
#[doc = "20 - EGU0_SWI0"]
EGU0_SWI0 = 20,
#[doc = "21 - EGU1_SWI1"]
EGU1_SWI1 = 21,
#[doc = "22 - EGU2_SWI2"]
EGU2_SWI2 = 22,
#[doc = "23 - EGU3_SWI3"]
EGU3_SWI3 = 23,
#[doc = "24 - EGU4_SWI4"]
EGU4_SWI4 = 24,
#[doc = "25 - EGU5_SWI5"]
EGU5_SWI5 = 25,
#[doc = "26 - TIMER3"]
TIMER3 = 26,
#[doc = "39 - USBD"]
USBD = 39,
}
unsafe impl cortex_m::interrupt::InterruptNumber for Interrupt {
#[inline(always)]
fn number(self) -> u16 {
self as u16
}
}
#[cfg(feature = "rt")]
mod _vectors {
unsafe extern "C" {
fn CLOCK_POWER();
fn RADIO();
fn UARTE0();
fn TWISPI0();
fn TWISPI1();
fn GPIOTE();
fn TIMER0();
fn TIMER1();
fn TIMER2();
fn RTC0();
fn TEMP();
fn RNG();
fn ECB();
fn AAR_CCM();
fn WDT();
fn RTC1();
fn QDEC();
fn COMP();
fn EGU0_SWI0();
fn EGU1_SWI1();
fn EGU2_SWI2();
fn EGU3_SWI3();
fn EGU4_SWI4();
fn EGU5_SWI5();
fn TIMER3();
fn USBD();
}
pub union Vector {
_handler: unsafe extern "C" fn(),
_reserved: u32,
}
#[unsafe(link_section = ".vector_table.interrupts")]
#[unsafe(no_mangle)]
pub static __INTERRUPTS: [Vector; 40] = [
Vector {
_handler: CLOCK_POWER,
},
Vector { _handler: RADIO },
Vector { _handler: UARTE0 },
Vector { _handler: TWISPI0 },
Vector { _handler: TWISPI1 },
Vector { _reserved: 0 },
Vector { _handler: GPIOTE },
Vector { _reserved: 0 },
Vector { _handler: TIMER0 },
Vector { _handler: TIMER1 },
Vector { _handler: TIMER2 },
Vector { _handler: RTC0 },
Vector { _handler: TEMP },
Vector { _handler: RNG },
Vector { _handler: ECB },
Vector { _handler: AAR_CCM },
Vector { _handler: WDT },
Vector { _handler: RTC1 },
Vector { _handler: QDEC },
Vector { _handler: COMP },
Vector {
_handler: EGU0_SWI0,
},
Vector {
_handler: EGU1_SWI1,
},
Vector {
_handler: EGU2_SWI2,
},
Vector {
_handler: EGU3_SWI3,
},
Vector {
_handler: EGU4_SWI4,
},
Vector {
_handler: EGU5_SWI5,
},
Vector { _handler: TIMER3 },
Vector { _reserved: 0 },
Vector { _reserved: 0 },
Vector { _reserved: 0 },
Vector { _reserved: 0 },
Vector { _reserved: 0 },
Vector { _reserved: 0 },
Vector { _reserved: 0 },
Vector { _reserved: 0 },
Vector { _reserved: 0 },
Vector { _reserved: 0 },
Vector { _reserved: 0 },
Vector { _reserved: 0 },
Vector { _handler: USBD },
];
}
#[doc = "Factory information configuration registers"]
pub const FICR: ficr::Ficr = unsafe { ficr::Ficr::from_ptr(0x1000_0000usize as _) };
#[doc = "User information configuration registers"]
pub const UICR: uicr::Uicr = unsafe { uicr::Uicr::from_ptr(0x1000_1000usize as _) };
#[doc = "Access Port Protection"]
pub const APPROTECT: approtect::Approtect =
unsafe { approtect::Approtect::from_ptr(0x4000_0000usize as _) };
#[doc = "Clock control"]
pub const CLOCK: clock::Clock = unsafe { clock::Clock::from_ptr(0x4000_0000usize as _) };
#[doc = "Power control"]
pub const POWER: power::Power = unsafe { power::Power::from_ptr(0x4000_0000usize as _) };
#[doc = "2.4 GHz radio"]
pub const RADIO: radio::Radio = unsafe { radio::Radio::from_ptr(0x4000_1000usize as _) };
#[doc = "Universal Asynchronous Receiver/Transmitter"]
pub const UART0: uart::Uart = unsafe { uart::Uart::from_ptr(0x4000_2000usize as _) };
#[doc = "UART with EasyDMA"]
pub const UARTE0: uarte::Uarte = unsafe { uarte::Uarte::from_ptr(0x4000_2000usize as _) };
#[doc = "Serial Peripheral Interface 0"]
pub const SPI0: spi::Spi = unsafe { spi::Spi::from_ptr(0x4000_3000usize as _) };
#[doc = "Serial Peripheral Interface Master with EasyDMA 0"]
pub const SPIM0: spim::Spim = unsafe { spim::Spim::from_ptr(0x4000_3000usize as _) };
#[doc = "SPI Slave 0"]
pub const SPIS0: spis::Spis = unsafe { spis::Spis::from_ptr(0x4000_3000usize as _) };
#[doc = "I2C compatible Two-Wire Interface 0"]
pub const TWI0: twi::Twi = unsafe { twi::Twi::from_ptr(0x4000_3000usize as _) };
#[doc = "I2C compatible Two-Wire Master Interface with EasyDMA 0"]
pub const TWIM0: twim::Twim = unsafe { twim::Twim::from_ptr(0x4000_3000usize as _) };
#[doc = "I2C compatible Two-Wire Slave Interface with EasyDMA 0"]
pub const TWIS0: twis::Twis = unsafe { twis::Twis::from_ptr(0x4000_3000usize as _) };
#[doc = "Serial Peripheral Interface 1"]
pub const SPI1: spi::Spi = unsafe { spi::Spi::from_ptr(0x4000_4000usize as _) };
#[doc = "Serial Peripheral Interface Master with EasyDMA 1"]
pub const SPIM1: spim::Spim = unsafe { spim::Spim::from_ptr(0x4000_4000usize as _) };
#[doc = "SPI Slave 1"]
pub const SPIS1: spis::Spis = unsafe { spis::Spis::from_ptr(0x4000_4000usize as _) };
#[doc = "I2C compatible Two-Wire Interface 1"]
pub const TWI1: twi::Twi = unsafe { twi::Twi::from_ptr(0x4000_4000usize as _) };
#[doc = "I2C compatible Two-Wire Master Interface with EasyDMA 1"]
pub const TWIM1: twim::Twim = unsafe { twim::Twim::from_ptr(0x4000_4000usize as _) };
#[doc = "I2C compatible Two-Wire Slave Interface with EasyDMA 1"]
pub const TWIS1: twis::Twis = unsafe { twis::Twis::from_ptr(0x4000_4000usize as _) };
#[doc = "GPIO Tasks and Events"]
pub const GPIOTE: gpiote::Gpiote = unsafe { gpiote::Gpiote::from_ptr(0x4000_6000usize as _) };
#[doc = "Timer/Counter 0"]
pub const TIMER0: timer::Timer = unsafe { timer::Timer::from_ptr(0x4000_8000usize as _) };
#[doc = "Timer/Counter 1"]
pub const TIMER1: timer::Timer = unsafe { timer::Timer::from_ptr(0x4000_9000usize as _) };
#[doc = "Timer/Counter 2"]
pub const TIMER2: timer::Timer = unsafe { timer::Timer::from_ptr(0x4000_a000usize as _) };
#[doc = "Real time counter 0"]
pub const RTC0: rtc::Rtc = unsafe { rtc::Rtc::from_ptr(0x4000_b000usize as _) };
#[doc = "Temperature Sensor"]
pub const TEMP: temp::Temp = unsafe { temp::Temp::from_ptr(0x4000_c000usize as _) };
#[doc = "Random Number Generator"]
pub const RNG: rng::Rng = unsafe { rng::Rng::from_ptr(0x4000_d000usize as _) };
#[doc = "AES ECB Mode Encryption"]
pub const ECB: ecb::Ecb = unsafe { ecb::Ecb::from_ptr(0x4000_e000usize as _) };
#[doc = "Accelerated Address Resolver"]
pub const AAR: aar::Aar = unsafe { aar::Aar::from_ptr(0x4000_f000usize as _) };
#[doc = "AES CCM mode encryption"]
pub const CCM: ccm::Ccm = unsafe { ccm::Ccm::from_ptr(0x4000_f000usize as _) };
#[doc = "Watchdog Timer"]
pub const WDT: wdt::Wdt = unsafe { wdt::Wdt::from_ptr(0x4001_0000usize as _) };
#[doc = "Real time counter 1"]
pub const RTC1: rtc::Rtc = unsafe { rtc::Rtc::from_ptr(0x4001_1000usize as _) };
#[doc = "Quadrature Decoder"]
pub const QDEC: qdec::Qdec = unsafe { qdec::Qdec::from_ptr(0x4001_2000usize as _) };
#[doc = "Comparator"]
pub const COMP: comp::Comp = unsafe { comp::Comp::from_ptr(0x4001_3000usize as _) };
#[doc = "Event generator unit 0"]
pub const EGU0: egu::Egu = unsafe { egu::Egu::from_ptr(0x4001_4000usize as _) };
#[doc = "Software interrupt 0"]
pub const SWI0: swi::Swi = unsafe { swi::Swi::from_ptr(0x4001_4000usize as _) };
#[doc = "Event generator unit 1"]
pub const EGU1: egu::Egu = unsafe { egu::Egu::from_ptr(0x4001_5000usize as _) };
#[doc = "Software interrupt 1"]
pub const SWI1: swi::Swi = unsafe { swi::Swi::from_ptr(0x4001_5000usize as _) };
#[doc = "Event generator unit 2"]
pub const EGU2: egu::Egu = unsafe { egu::Egu::from_ptr(0x4001_6000usize as _) };
#[doc = "Software interrupt 2"]
pub const SWI2: swi::Swi = unsafe { swi::Swi::from_ptr(0x4001_6000usize as _) };
#[doc = "Event generator unit 3"]
pub const EGU3: egu::Egu = unsafe { egu::Egu::from_ptr(0x4001_7000usize as _) };
#[doc = "Software interrupt 3"]
pub const SWI3: swi::Swi = unsafe { swi::Swi::from_ptr(0x4001_7000usize as _) };
#[doc = "Event generator unit 4"]
pub const EGU4: egu::Egu = unsafe { egu::Egu::from_ptr(0x4001_8000usize as _) };
#[doc = "Software interrupt 4"]
pub const SWI4: swi::Swi = unsafe { swi::Swi::from_ptr(0x4001_8000usize as _) };
#[doc = "Event generator unit 5"]
pub const EGU5: egu::Egu = unsafe { egu::Egu::from_ptr(0x4001_9000usize as _) };
#[doc = "Software interrupt 5"]
pub const SWI5: swi::Swi = unsafe { swi::Swi::from_ptr(0x4001_9000usize as _) };
#[doc = "Timer/Counter 3"]
pub const TIMER3: timer::Timer = unsafe { timer::Timer::from_ptr(0x4001_a000usize as _) };
#[doc = "Access control lists"]
pub const ACL: acl::Acl = unsafe { acl::Acl::from_ptr(0x4001_e000usize as _) };
#[doc = "Non Volatile Memory Controller"]
pub const NVMC: nvmc::Nvmc = unsafe { nvmc::Nvmc::from_ptr(0x4001_e000usize as _) };
#[doc = "Programmable Peripheral Interconnect"]
pub const PPI: ppi::Ppi = unsafe { ppi::Ppi::from_ptr(0x4001_f000usize as _) };
#[doc = "Universal serial bus device"]
pub const USBD: usbd::Usbd = unsafe { usbd::Usbd::from_ptr(0x4002_7000usize as _) };
#[doc = "GPIO Port 1"]
pub const P0: gpio::Gpio = unsafe { gpio::Gpio::from_ptr(0x5000_0000usize as _) };
#[doc = r" Number available in the NVIC for configuring priority"]
#[cfg(feature = "rt")]
pub const NVIC_PRIO_BITS: u8 = 3;
#[cfg(feature = "rt")]
pub use cortex_m_rt::interrupt;
#[cfg(feature = "rt")]
pub use Interrupt as interrupt;
pub mod aar {
#[doc = "Accelerated Address Resolver."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Aar {
ptr: *mut u8,
}
unsafe impl Send for Aar {}
unsafe impl Sync for Aar {}
impl Aar {
#[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 = "Start resolving addresses based on IRKs specified in the IRK data structure."]
#[inline(always)]
pub const fn tasks_start(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Stop resolving addresses."]
#[inline(always)]
pub const fn tasks_stop(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
#[doc = "Address resolution procedure complete."]
#[inline(always)]
pub const fn events_end(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0100usize) as _) }
}
#[doc = "Address resolved."]
#[inline(always)]
pub const fn events_resolved(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0104usize) as _) }
}
#[doc = "Address not resolved."]
#[inline(always)]
pub const fn events_notresolved(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0108usize) as _) }
}
#[doc = "Enable interrupt."]
#[inline(always)]
pub const fn intenset(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0304usize) as _) }
}
#[doc = "Disable interrupt."]
#[inline(always)]
pub const fn intenclr(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0308usize) as _) }
}
#[doc = "Resolution status."]
#[inline(always)]
pub const fn status(self) -> crate::common::Reg<regs::Status, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0400usize) as _) }
}
#[doc = "Enable AAR."]
#[inline(always)]
pub const fn enable(self) -> crate::common::Reg<regs::Enable, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0500usize) as _) }
}
#[doc = "Number of IRKs."]
#[inline(always)]
pub const fn nirk(self) -> crate::common::Reg<regs::Nirk, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0504usize) as _) }
}
#[doc = "Pointer to IRK data structure."]
#[inline(always)]
pub const fn irkptr(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0508usize) as _) }
}
#[doc = "Pointer to the resolvable address."]
#[inline(always)]
pub const fn addrptr(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0510usize) as _) }
}
#[doc = "Pointer to data area used for temporary storage."]
#[inline(always)]
pub const fn scratchptr(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0514usize) as _) }
}
}
pub mod regs {
#[doc = "Enable AAR."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Enable(pub u32);
impl Enable {
#[doc = "Enable or disable AAR."]
#[must_use]
#[inline(always)]
pub const fn enable(&self) -> super::vals::Enable {
let val = (self.0 >> 0usize) & 0x03;
super::vals::Enable::from_bits(val as u8)
}
#[doc = "Enable or disable AAR."]
#[inline(always)]
pub const fn set_enable(&mut self, val: super::vals::Enable) {
self.0 = (self.0 & !(0x03 << 0usize)) | (((val.to_bits() as u32) & 0x03) << 0usize);
}
}
impl Default for Enable {
#[inline(always)]
fn default() -> Enable {
Enable(0)
}
}
impl core::fmt::Debug for Enable {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Enable")
.field("enable", &self.enable())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Enable {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Enable {{ enable: {:?} }}", self.enable())
}
}
#[doc = "Disable interrupt."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Int(pub u32);
impl Int {
#[doc = "Write '1' to disable interrupt for event END."]
#[must_use]
#[inline(always)]
pub const fn end(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event END."]
#[inline(always)]
pub const fn set_end(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Write '1' to disable interrupt for event RESOLVED."]
#[must_use]
#[inline(always)]
pub const fn resolved(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event RESOLVED."]
#[inline(always)]
pub const fn set_resolved(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "Write '1' to disable interrupt for event NOTRESOLVED."]
#[must_use]
#[inline(always)]
pub const fn notresolved(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event NOTRESOLVED."]
#[inline(always)]
pub const fn set_notresolved(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
}
impl Default for Int {
#[inline(always)]
fn default() -> Int {
Int(0)
}
}
impl core::fmt::Debug for Int {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Int")
.field("end", &self.end())
.field("resolved", &self.resolved())
.field("notresolved", &self.notresolved())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Int {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Int {{ end: {=bool:?}, resolved: {=bool:?}, notresolved: {=bool:?} }}",
self.end(),
self.resolved(),
self.notresolved()
)
}
}
#[doc = "Number of IRKs."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Nirk(pub u32);
impl Nirk {
#[doc = "Number of Identity Root Keys available in the IRK data structure."]
#[must_use]
#[inline(always)]
pub const fn nirk(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x1f;
val as u8
}
#[doc = "Number of Identity Root Keys available in the IRK data structure."]
#[inline(always)]
pub const fn set_nirk(&mut self, val: u8) {
self.0 = (self.0 & !(0x1f << 0usize)) | (((val as u32) & 0x1f) << 0usize);
}
}
impl Default for Nirk {
#[inline(always)]
fn default() -> Nirk {
Nirk(0)
}
}
impl core::fmt::Debug for Nirk {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Nirk").field("nirk", &self.nirk()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Nirk {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Nirk {{ nirk: {=u8:?} }}", self.nirk())
}
}
#[doc = "Resolution status."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Status(pub u32);
impl Status {
#[doc = "The IRK that was used last time an address was resolved."]
#[must_use]
#[inline(always)]
pub const fn status(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x0f;
val as u8
}
#[doc = "The IRK that was used last time an address was resolved."]
#[inline(always)]
pub const fn set_status(&mut self, val: u8) {
self.0 = (self.0 & !(0x0f << 0usize)) | (((val as u32) & 0x0f) << 0usize);
}
}
impl Default for Status {
#[inline(always)]
fn default() -> Status {
Status(0)
}
}
impl core::fmt::Debug for Status {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Status")
.field("status", &self.status())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Status {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Status {{ status: {=u8:?} }}", self.status())
}
}
}
pub mod vals {
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Enable {
#[doc = "Disable."]
Disabled = 0x0,
_RESERVED_1 = 0x01,
_RESERVED_2 = 0x02,
#[doc = "Enable."]
Enabled = 0x03,
}
impl Enable {
#[inline(always)]
pub const fn from_bits(val: u8) -> Enable {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Enable {
#[inline(always)]
fn from(val: u8) -> Enable {
Enable::from_bits(val)
}
}
impl From<Enable> for u8 {
#[inline(always)]
fn from(val: Enable) -> u8 {
Enable::to_bits(val)
}
}
}
}
pub mod acl {
#[doc = "Access control lists."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Acl {
ptr: *mut u8,
}
unsafe impl Send for Acl {}
unsafe impl Sync for Acl {}
impl Acl {
#[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 = "Unspecified."]
#[inline(always)]
pub const fn acl(self, n: usize) -> AclAcl {
assert!(n < 8usize);
unsafe { AclAcl::from_ptr(self.ptr.wrapping_add(0x0800usize + n * 16usize) as _) }
}
}
#[doc = "Unspecified."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct AclAcl {
ptr: *mut u8,
}
unsafe impl Send for AclAcl {}
unsafe impl Sync for AclAcl {}
impl AclAcl {
#[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 = "Description cluster: Start address of region to protect. The start address must be word-aligned."]
#[inline(always)]
pub const fn addr(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Description cluster: Size of region to protect counting from address ACL\\[n\\].ADDR. Writing a '0' has no effect."]
#[inline(always)]
pub const fn size(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Description cluster: Access permissions for region n as defined by start address ACL\\[n\\].ADDR and size ACL\\[n\\].SIZE."]
#[inline(always)]
pub const fn perm(self) -> crate::common::Reg<regs::Perm, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
}
pub mod regs {
#[doc = "Description cluster: Access permissions for region n as defined by start address ACL\\[n\\].ADDR and size ACL\\[n\\].SIZE."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Perm(pub u32);
impl Perm {
#[doc = "Configure write and erase permissions for region n. Writing a '0' has no effect."]
#[must_use]
#[inline(always)]
pub const fn write(&self) -> super::vals::Write {
let val = (self.0 >> 1usize) & 0x01;
super::vals::Write::from_bits(val as u8)
}
#[doc = "Configure write and erase permissions for region n. Writing a '0' has no effect."]
#[inline(always)]
pub const fn set_write(&mut self, val: super::vals::Write) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val.to_bits() as u32) & 0x01) << 1usize);
}
#[doc = "Configure read permissions for region n. Writing a '0' has no effect."]
#[must_use]
#[inline(always)]
pub const fn read(&self) -> super::vals::Read {
let val = (self.0 >> 2usize) & 0x01;
super::vals::Read::from_bits(val as u8)
}
#[doc = "Configure read permissions for region n. Writing a '0' has no effect."]
#[inline(always)]
pub const fn set_read(&mut self, val: super::vals::Read) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val.to_bits() as u32) & 0x01) << 2usize);
}
}
impl Default for Perm {
#[inline(always)]
fn default() -> Perm {
Perm(0)
}
}
impl core::fmt::Debug for Perm {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Perm")
.field("write", &self.write())
.field("read", &self.read())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Perm {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Perm {{ write: {:?}, read: {:?} }}",
self.write(),
self.read()
)
}
}
}
pub mod vals {
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Read {
#[doc = "Allow read instructions to region n."]
Enable = 0x0,
#[doc = "Block read instructions to region n."]
Disable = 0x01,
}
impl Read {
#[inline(always)]
pub const fn from_bits(val: u8) -> Read {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Read {
#[inline(always)]
fn from(val: u8) -> Read {
Read::from_bits(val)
}
}
impl From<Read> for u8 {
#[inline(always)]
fn from(val: Read) -> u8 {
Read::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Write {
#[doc = "Allow write and erase instructions to region n."]
Enable = 0x0,
#[doc = "Block write and erase instructions to region n."]
Disable = 0x01,
}
impl Write {
#[inline(always)]
pub const fn from_bits(val: u8) -> Write {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Write {
#[inline(always)]
fn from(val: u8) -> Write {
Write::from_bits(val)
}
}
impl From<Write> for u8 {
#[inline(always)]
fn from(val: Write) -> u8 {
Write::to_bits(val)
}
}
}
}
pub mod approtect {
#[doc = "Access Port Protection."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Approtect {
ptr: *mut u8,
}
unsafe impl Send for Approtect {}
unsafe impl Sync for Approtect {}
impl Approtect {
#[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 = "Software force enable APPROTECT mechanism until next reset."]
#[inline(always)]
pub const fn forceprotect(
self,
) -> crate::common::Reg<regs::Forceprotect, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0550usize) as _) }
}
#[doc = "Software disable APPROTECT mechanism."]
#[inline(always)]
pub const fn disable(self) -> crate::common::Reg<regs::Disable, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0558usize) as _) }
}
}
pub mod regs {
#[doc = "Software disable APPROTECT mechanism."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Disable(pub u32);
impl Disable {
#[doc = "Software disable APPROTECT mechanism."]
#[must_use]
#[inline(always)]
pub const fn disable(&self) -> super::vals::Disable {
let val = (self.0 >> 0usize) & 0xff;
super::vals::Disable::from_bits(val as u8)
}
#[doc = "Software disable APPROTECT mechanism."]
#[inline(always)]
pub const fn set_disable(&mut self, val: super::vals::Disable) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val.to_bits() as u32) & 0xff) << 0usize);
}
}
impl Default for Disable {
#[inline(always)]
fn default() -> Disable {
Disable(0)
}
}
impl core::fmt::Debug for Disable {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Disable")
.field("disable", &self.disable())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Disable {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Disable {{ disable: {:?} }}", self.disable())
}
}
#[doc = "Software force enable APPROTECT mechanism until next reset."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Forceprotect(pub u32);
impl Forceprotect {
#[doc = "Write 0x0 to force enable APPROTECT mechanism."]
#[must_use]
#[inline(always)]
pub const fn forceprotect(&self) -> super::vals::Forceprotect {
let val = (self.0 >> 0usize) & 0xff;
super::vals::Forceprotect::from_bits(val as u8)
}
#[doc = "Write 0x0 to force enable APPROTECT mechanism."]
#[inline(always)]
pub const fn set_forceprotect(&mut self, val: super::vals::Forceprotect) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val.to_bits() as u32) & 0xff) << 0usize);
}
}
impl Default for Forceprotect {
#[inline(always)]
fn default() -> Forceprotect {
Forceprotect(0)
}
}
impl core::fmt::Debug for Forceprotect {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Forceprotect")
.field("forceprotect", &self.forceprotect())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Forceprotect {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Forceprotect {{ forceprotect: {:?} }}",
self.forceprotect()
)
}
}
}
pub mod vals {
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct Disable(u8);
impl Disable {
#[doc = "Software disable APPROTECT mechanism."]
pub const SwDisable: Self = Self(0x5a);
}
impl Disable {
pub const fn from_bits(val: u8) -> Disable {
Self(val & 0xff)
}
pub const fn to_bits(self) -> u8 {
self.0
}
}
impl core::fmt::Debug for Disable {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self.0 {
0x5a => f.write_str("SwDisable"),
other => core::write!(f, "0x{:02X}", other),
}
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Disable {
fn format(&self, f: defmt::Formatter) {
match self.0 {
0x5a => defmt::write!(f, "SwDisable"),
other => defmt::write!(f, "0x{:02X}", other),
}
}
}
impl From<u8> for Disable {
#[inline(always)]
fn from(val: u8) -> Disable {
Disable::from_bits(val)
}
}
impl From<Disable> for u8 {
#[inline(always)]
fn from(val: Disable) -> u8 {
Disable::to_bits(val)
}
}
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct Forceprotect(u8);
impl Forceprotect {
#[doc = "Software force enable APPROTECT mechanism."]
pub const Force: Self = Self(0x0);
}
impl Forceprotect {
pub const fn from_bits(val: u8) -> Forceprotect {
Self(val & 0xff)
}
pub const fn to_bits(self) -> u8 {
self.0
}
}
impl core::fmt::Debug for Forceprotect {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self.0 {
0x0 => f.write_str("Force"),
other => core::write!(f, "0x{:02X}", other),
}
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Forceprotect {
fn format(&self, f: defmt::Formatter) {
match self.0 {
0x0 => defmt::write!(f, "Force"),
other => defmt::write!(f, "0x{:02X}", other),
}
}
}
impl From<u8> for Forceprotect {
#[inline(always)]
fn from(val: u8) -> Forceprotect {
Forceprotect::from_bits(val)
}
}
impl From<Forceprotect> for u8 {
#[inline(always)]
fn from(val: Forceprotect) -> u8 {
Forceprotect::to_bits(val)
}
}
}
}
pub mod ccm {
#[doc = "AES CCM mode encryption."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Ccm {
ptr: *mut u8,
}
unsafe impl Send for Ccm {}
unsafe impl Sync for Ccm {}
impl Ccm {
#[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 = "Start generation of keystream. This operation will stop by itself when completed."]
#[inline(always)]
pub const fn tasks_ksgen(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Start encryption/decryption. This operation will stop by itself when completed."]
#[inline(always)]
pub const fn tasks_crypt(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Stop encryption/decryption."]
#[inline(always)]
pub const fn tasks_stop(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
#[doc = "Override DATARATE setting in MODE register with the contents of the RATEOVERRIDE register for any ongoing encryption/decryption."]
#[inline(always)]
pub const fn tasks_rateoverride(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0cusize) as _) }
}
#[doc = "Keystream generation complete."]
#[inline(always)]
pub const fn events_endksgen(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0100usize) as _) }
}
#[doc = "Encrypt/decrypt complete."]
#[inline(always)]
pub const fn events_endcrypt(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0104usize) as _) }
}
#[doc = "Deprecated register - CCM error event."]
#[inline(always)]
pub const fn events_error(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0108usize) as _) }
}
#[doc = "Shortcuts between local events and tasks."]
#[inline(always)]
pub const fn shorts(self) -> crate::common::Reg<regs::Shorts, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0200usize) as _) }
}
#[doc = "Enable interrupt."]
#[inline(always)]
pub const fn intenset(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0304usize) as _) }
}
#[doc = "Disable interrupt."]
#[inline(always)]
pub const fn intenclr(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0308usize) as _) }
}
#[doc = "MIC check result."]
#[inline(always)]
pub const fn micstatus(self) -> crate::common::Reg<regs::Micstatus, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0400usize) as _) }
}
#[doc = "Enable."]
#[inline(always)]
pub const fn enable(self) -> crate::common::Reg<regs::Enable, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0500usize) as _) }
}
#[doc = "Operation mode."]
#[inline(always)]
pub const fn mode(self) -> crate::common::Reg<regs::Mode, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0504usize) as _) }
}
#[doc = "Pointer to data structure holding the AES key and the NONCE vector."]
#[inline(always)]
pub const fn cnfptr(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0508usize) as _) }
}
#[doc = "Input pointer."]
#[inline(always)]
pub const fn inptr(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x050cusize) as _) }
}
#[doc = "Output pointer."]
#[inline(always)]
pub const fn outptr(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0510usize) as _) }
}
#[doc = "Pointer to data area used for temporary storage."]
#[inline(always)]
pub const fn scratchptr(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0514usize) as _) }
}
#[doc = "Length of keystream generated when MODE.LENGTH = Extended."]
#[inline(always)]
pub const fn maxpacketsize(
self,
) -> crate::common::Reg<regs::Maxpacketsize, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0518usize) as _) }
}
#[doc = "Data rate override setting."]
#[inline(always)]
pub const fn rateoverride(
self,
) -> crate::common::Reg<regs::Rateoverride, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x051cusize) as _) }
}
#[doc = "Header (S0) mask."]
#[inline(always)]
pub const fn headermask(self) -> crate::common::Reg<regs::Headermask, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0520usize) as _) }
}
}
pub mod regs {
#[doc = "Enable."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Enable(pub u32);
impl Enable {
#[doc = "Enable or disable CCM."]
#[must_use]
#[inline(always)]
pub const fn enable(&self) -> super::vals::Enable {
let val = (self.0 >> 0usize) & 0x03;
super::vals::Enable::from_bits(val as u8)
}
#[doc = "Enable or disable CCM."]
#[inline(always)]
pub const fn set_enable(&mut self, val: super::vals::Enable) {
self.0 = (self.0 & !(0x03 << 0usize)) | (((val.to_bits() as u32) & 0x03) << 0usize);
}
}
impl Default for Enable {
#[inline(always)]
fn default() -> Enable {
Enable(0)
}
}
impl core::fmt::Debug for Enable {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Enable")
.field("enable", &self.enable())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Enable {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Enable {{ enable: {:?} }}", self.enable())
}
}
#[doc = "Header (S0) mask."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Headermask(pub u32);
impl Headermask {
#[doc = "Header (S0) mask."]
#[must_use]
#[inline(always)]
pub const fn headermask(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "Header (S0) mask."]
#[inline(always)]
pub const fn set_headermask(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
}
impl Default for Headermask {
#[inline(always)]
fn default() -> Headermask {
Headermask(0)
}
}
impl core::fmt::Debug for Headermask {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Headermask")
.field("headermask", &self.headermask())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Headermask {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Headermask {{ headermask: {=u8:?} }}", self.headermask())
}
}
#[doc = "Disable interrupt."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Int(pub u32);
impl Int {
#[doc = "Write '1' to disable interrupt for event ENDKSGEN."]
#[must_use]
#[inline(always)]
pub const fn endksgen(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event ENDKSGEN."]
#[inline(always)]
pub const fn set_endksgen(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Write '1' to disable interrupt for event ENDCRYPT."]
#[must_use]
#[inline(always)]
pub const fn endcrypt(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event ENDCRYPT."]
#[inline(always)]
pub const fn set_endcrypt(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "Deprecated intclrfield - Write '1' to disable interrupt for event ERROR."]
#[must_use]
#[inline(always)]
pub const fn error(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Deprecated intclrfield - Write '1' to disable interrupt for event ERROR."]
#[inline(always)]
pub const fn set_error(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
}
impl Default for Int {
#[inline(always)]
fn default() -> Int {
Int(0)
}
}
impl core::fmt::Debug for Int {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Int")
.field("endksgen", &self.endksgen())
.field("endcrypt", &self.endcrypt())
.field("error", &self.error())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Int {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Int {{ endksgen: {=bool:?}, endcrypt: {=bool:?}, error: {=bool:?} }}",
self.endksgen(),
self.endcrypt(),
self.error()
)
}
}
#[doc = "Length of keystream generated when MODE.LENGTH = Extended."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Maxpacketsize(pub u32);
impl Maxpacketsize {
#[doc = "Length of keystream generated when MODE.LENGTH = Extended. This value must be greater than or equal to the subsequent packet payload to be encrypted/decrypted."]
#[must_use]
#[inline(always)]
pub const fn maxpacketsize(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "Length of keystream generated when MODE.LENGTH = Extended. This value must be greater than or equal to the subsequent packet payload to be encrypted/decrypted."]
#[inline(always)]
pub const fn set_maxpacketsize(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
}
impl Default for Maxpacketsize {
#[inline(always)]
fn default() -> Maxpacketsize {
Maxpacketsize(0)
}
}
impl core::fmt::Debug for Maxpacketsize {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Maxpacketsize")
.field("maxpacketsize", &self.maxpacketsize())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Maxpacketsize {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Maxpacketsize {{ maxpacketsize: {=u8:?} }}",
self.maxpacketsize()
)
}
}
#[doc = "MIC check result."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Micstatus(pub u32);
impl Micstatus {
#[doc = "The result of the MIC check performed during the previous decryption operation."]
#[must_use]
#[inline(always)]
pub const fn micstatus(&self) -> super::vals::Micstatus {
let val = (self.0 >> 0usize) & 0x01;
super::vals::Micstatus::from_bits(val as u8)
}
#[doc = "The result of the MIC check performed during the previous decryption operation."]
#[inline(always)]
pub const fn set_micstatus(&mut self, val: super::vals::Micstatus) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
}
impl Default for Micstatus {
#[inline(always)]
fn default() -> Micstatus {
Micstatus(0)
}
}
impl core::fmt::Debug for Micstatus {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Micstatus")
.field("micstatus", &self.micstatus())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Micstatus {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Micstatus {{ micstatus: {:?} }}", self.micstatus())
}
}
#[doc = "Operation mode."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Mode(pub u32);
impl Mode {
#[doc = "The mode of operation to be used. Settings in this register apply whenever either the KSGEN task or the CRYPT task is triggered."]
#[must_use]
#[inline(always)]
pub const fn mode(&self) -> super::vals::Mode {
let val = (self.0 >> 0usize) & 0x01;
super::vals::Mode::from_bits(val as u8)
}
#[doc = "The mode of operation to be used. Settings in this register apply whenever either the KSGEN task or the CRYPT task is triggered."]
#[inline(always)]
pub const fn set_mode(&mut self, val: super::vals::Mode) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
#[doc = "Radio data rate that the CCM shall run synchronous with."]
#[must_use]
#[inline(always)]
pub const fn datarate(&self) -> super::vals::Datarate {
let val = (self.0 >> 16usize) & 0x03;
super::vals::Datarate::from_bits(val as u8)
}
#[doc = "Radio data rate that the CCM shall run synchronous with."]
#[inline(always)]
pub const fn set_datarate(&mut self, val: super::vals::Datarate) {
self.0 =
(self.0 & !(0x03 << 16usize)) | (((val.to_bits() as u32) & 0x03) << 16usize);
}
#[doc = "Packet length configuration."]
#[must_use]
#[inline(always)]
pub const fn length(&self) -> super::vals::Length {
let val = (self.0 >> 24usize) & 0x01;
super::vals::Length::from_bits(val as u8)
}
#[doc = "Packet length configuration."]
#[inline(always)]
pub const fn set_length(&mut self, val: super::vals::Length) {
self.0 =
(self.0 & !(0x01 << 24usize)) | (((val.to_bits() as u32) & 0x01) << 24usize);
}
}
impl Default for Mode {
#[inline(always)]
fn default() -> Mode {
Mode(0)
}
}
impl core::fmt::Debug for Mode {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Mode")
.field("mode", &self.mode())
.field("datarate", &self.datarate())
.field("length", &self.length())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Mode {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Mode {{ mode: {:?}, datarate: {:?}, length: {:?} }}",
self.mode(),
self.datarate(),
self.length()
)
}
}
#[doc = "Data rate override setting."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Rateoverride(pub u32);
impl Rateoverride {
#[doc = "Data rate override setting."]
#[must_use]
#[inline(always)]
pub const fn rateoverride(&self) -> super::vals::Rateoverride {
let val = (self.0 >> 0usize) & 0x03;
super::vals::Rateoverride::from_bits(val as u8)
}
#[doc = "Data rate override setting."]
#[inline(always)]
pub const fn set_rateoverride(&mut self, val: super::vals::Rateoverride) {
self.0 = (self.0 & !(0x03 << 0usize)) | (((val.to_bits() as u32) & 0x03) << 0usize);
}
}
impl Default for Rateoverride {
#[inline(always)]
fn default() -> Rateoverride {
Rateoverride(0)
}
}
impl core::fmt::Debug for Rateoverride {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Rateoverride")
.field("rateoverride", &self.rateoverride())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Rateoverride {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Rateoverride {{ rateoverride: {:?} }}",
self.rateoverride()
)
}
}
#[doc = "Shortcuts between local events and tasks."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Shorts(pub u32);
impl Shorts {
#[doc = "Shortcut between event ENDKSGEN and task CRYPT."]
#[must_use]
#[inline(always)]
pub const fn endksgen_crypt(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event ENDKSGEN and task CRYPT."]
#[inline(always)]
pub const fn set_endksgen_crypt(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for Shorts {
#[inline(always)]
fn default() -> Shorts {
Shorts(0)
}
}
impl core::fmt::Debug for Shorts {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Shorts")
.field("endksgen_crypt", &self.endksgen_crypt())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Shorts {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Shorts {{ endksgen_crypt: {=bool:?} }}",
self.endksgen_crypt()
)
}
}
}
pub mod vals {
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Datarate {
#[doc = "1 Mbps."]
_1mbit = 0x0,
#[doc = "2 Mbps."]
_2mbit = 0x01,
#[doc = "125 kbps."]
_125kbps = 0x02,
#[doc = "500 kbps."]
_500kbps = 0x03,
}
impl Datarate {
#[inline(always)]
pub const fn from_bits(val: u8) -> Datarate {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Datarate {
#[inline(always)]
fn from(val: u8) -> Datarate {
Datarate::from_bits(val)
}
}
impl From<Datarate> for u8 {
#[inline(always)]
fn from(val: Datarate) -> u8 {
Datarate::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Enable {
#[doc = "Disable."]
Disabled = 0x0,
_RESERVED_1 = 0x01,
#[doc = "Enable."]
Enabled = 0x02,
_RESERVED_3 = 0x03,
}
impl Enable {
#[inline(always)]
pub const fn from_bits(val: u8) -> Enable {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Enable {
#[inline(always)]
fn from(val: u8) -> Enable {
Enable::from_bits(val)
}
}
impl From<Enable> for u8 {
#[inline(always)]
fn from(val: Enable) -> u8 {
Enable::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Length {
#[doc = "Default length. Effective length of LENGTH field in encrypted/decrypted packet is 5 bits. A keystream for packet payloads up to 27 bytes will be generated."]
Default = 0x0,
#[doc = "Extended length. Effective length of LENGTH field in encrypted/decrypted packet is 8 bits. A keystream for packet payloads up to MAXPACKETSIZE bytes will be generated."]
Extended = 0x01,
}
impl Length {
#[inline(always)]
pub const fn from_bits(val: u8) -> Length {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Length {
#[inline(always)]
fn from(val: u8) -> Length {
Length::from_bits(val)
}
}
impl From<Length> for u8 {
#[inline(always)]
fn from(val: Length) -> u8 {
Length::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Micstatus {
#[doc = "MIC check failed."]
CheckFailed = 0x0,
#[doc = "MIC check passed."]
CheckPassed = 0x01,
}
impl Micstatus {
#[inline(always)]
pub const fn from_bits(val: u8) -> Micstatus {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Micstatus {
#[inline(always)]
fn from(val: u8) -> Micstatus {
Micstatus::from_bits(val)
}
}
impl From<Micstatus> for u8 {
#[inline(always)]
fn from(val: Micstatus) -> u8 {
Micstatus::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Mode {
#[doc = "AES CCM packet encryption mode."]
Encryption = 0x0,
#[doc = "AES CCM packet decryption mode."]
Decryption = 0x01,
}
impl Mode {
#[inline(always)]
pub const fn from_bits(val: u8) -> Mode {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Mode {
#[inline(always)]
fn from(val: u8) -> Mode {
Mode::from_bits(val)
}
}
impl From<Mode> for u8 {
#[inline(always)]
fn from(val: Mode) -> u8 {
Mode::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Rateoverride {
#[doc = "1 Mbps."]
_1mbit = 0x0,
#[doc = "2 Mbps."]
_2mbit = 0x01,
#[doc = "125 kbps."]
_125kbps = 0x02,
#[doc = "500 kbps."]
_500kbps = 0x03,
}
impl Rateoverride {
#[inline(always)]
pub const fn from_bits(val: u8) -> Rateoverride {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Rateoverride {
#[inline(always)]
fn from(val: u8) -> Rateoverride {
Rateoverride::from_bits(val)
}
}
impl From<Rateoverride> for u8 {
#[inline(always)]
fn from(val: Rateoverride) -> u8 {
Rateoverride::to_bits(val)
}
}
}
}
pub mod clock {
#[doc = "Clock control."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Clock {
ptr: *mut u8,
}
unsafe impl Send for Clock {}
unsafe impl Sync for Clock {}
impl Clock {
#[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 = "Start HFXO crystal oscillator."]
#[inline(always)]
pub const fn tasks_hfclkstart(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Stop HFXO crystal oscillator."]
#[inline(always)]
pub const fn tasks_hfclkstop(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Start LFCLK."]
#[inline(always)]
pub const fn tasks_lfclkstart(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
#[doc = "Stop LFCLK."]
#[inline(always)]
pub const fn tasks_lfclkstop(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0cusize) as _) }
}
#[doc = "Start calibration of LFRC."]
#[inline(always)]
pub const fn tasks_cal(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x10usize) as _) }
}
#[doc = "Start calibration timer."]
#[inline(always)]
pub const fn tasks_ctstart(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x14usize) as _) }
}
#[doc = "Stop calibration timer."]
#[inline(always)]
pub const fn tasks_ctstop(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x18usize) as _) }
}
#[doc = "HFXO crystal oscillator started."]
#[inline(always)]
pub const fn events_hfclkstarted(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0100usize) as _) }
}
#[doc = "LFCLK started."]
#[inline(always)]
pub const fn events_lfclkstarted(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0104usize) as _) }
}
#[doc = "Calibration of LFRC completed."]
#[inline(always)]
pub const fn events_done(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x010cusize) as _) }
}
#[doc = "Calibration timer timeout."]
#[inline(always)]
pub const fn events_ctto(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0110usize) as _) }
}
#[doc = "Calibration timer has been started and is ready to process new tasks."]
#[inline(always)]
pub const fn events_ctstarted(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0128usize) as _) }
}
#[doc = "Calibration timer has been stopped and is ready to process new tasks."]
#[inline(always)]
pub const fn events_ctstopped(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x012cusize) as _) }
}
#[doc = "Enable interrupt."]
#[inline(always)]
pub const fn intenset(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0304usize) as _) }
}
#[doc = "Disable interrupt."]
#[inline(always)]
pub const fn intenclr(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0308usize) as _) }
}
#[doc = "Status indicating that HFCLKSTART task has been triggered."]
#[inline(always)]
pub const fn hfclkrun(self) -> crate::common::Reg<regs::Hfclkrun, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0408usize) as _) }
}
#[doc = "HFCLK status."]
#[inline(always)]
pub const fn hfclkstat(self) -> crate::common::Reg<regs::Hfclkstat, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x040cusize) as _) }
}
#[doc = "Status indicating that LFCLKSTART task has been triggered."]
#[inline(always)]
pub const fn lfclkrun(self) -> crate::common::Reg<regs::Lfclkrun, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0414usize) as _) }
}
#[doc = "LFCLK status."]
#[inline(always)]
pub const fn lfclkstat(self) -> crate::common::Reg<regs::Lfclkstat, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0418usize) as _) }
}
#[doc = "Copy of LFCLKSRC register, set when LFCLKSTART task was triggered."]
#[inline(always)]
pub const fn lfclksrccopy(
self,
) -> crate::common::Reg<regs::Lfclksrccopy, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x041cusize) as _) }
}
#[doc = "Clock source for the LFCLK."]
#[inline(always)]
pub const fn lfclksrc(self) -> crate::common::Reg<regs::Lfclksrc, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0518usize) as _) }
}
#[doc = "HFXO debounce time. The HFXO is started by triggering the TASKS_HFCLKSTART task."]
#[inline(always)]
pub const fn hfxodebounce(
self,
) -> crate::common::Reg<regs::Hfxodebounce, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0528usize) as _) }
}
#[doc = "LFXO debounce time. The LFXO is started by triggering the TASKS_LFCLKSTART task when the LFCLKSRC register is configured for Xtal."]
#[inline(always)]
pub const fn lfxodebounce(
self,
) -> crate::common::Reg<regs::Lfxodebounce, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x052cusize) as _) }
}
#[doc = "Calibration timer interval."]
#[inline(always)]
pub const fn ctiv(self) -> crate::common::Reg<regs::Ctiv, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0538usize) as _) }
}
}
pub mod regs {
#[doc = "Calibration timer interval."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Ctiv(pub u32);
impl Ctiv {
#[doc = "Calibration timer interval in multiple of 0.25 seconds. Range: 0.25 seconds to 31.75 seconds."]
#[must_use]
#[inline(always)]
pub const fn ctiv(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x7f;
val as u8
}
#[doc = "Calibration timer interval in multiple of 0.25 seconds. Range: 0.25 seconds to 31.75 seconds."]
#[inline(always)]
pub const fn set_ctiv(&mut self, val: u8) {
self.0 = (self.0 & !(0x7f << 0usize)) | (((val as u32) & 0x7f) << 0usize);
}
}
impl Default for Ctiv {
#[inline(always)]
fn default() -> Ctiv {
Ctiv(0)
}
}
impl core::fmt::Debug for Ctiv {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Ctiv").field("ctiv", &self.ctiv()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Ctiv {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Ctiv {{ ctiv: {=u8:?} }}", self.ctiv())
}
}
#[doc = "Status indicating that HFCLKSTART task has been triggered."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Hfclkrun(pub u32);
impl Hfclkrun {
#[doc = "HFCLKSTART task triggered or not."]
#[must_use]
#[inline(always)]
pub const fn status(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "HFCLKSTART task triggered or not."]
#[inline(always)]
pub const fn set_status(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for Hfclkrun {
#[inline(always)]
fn default() -> Hfclkrun {
Hfclkrun(0)
}
}
impl core::fmt::Debug for Hfclkrun {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Hfclkrun")
.field("status", &self.status())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Hfclkrun {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Hfclkrun {{ status: {=bool:?} }}", self.status())
}
}
#[doc = "HFCLK status."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Hfclkstat(pub u32);
impl Hfclkstat {
#[doc = "Source of HFCLK."]
#[must_use]
#[inline(always)]
pub const fn src(&self) -> super::vals::HfclkstatSrc {
let val = (self.0 >> 0usize) & 0x01;
super::vals::HfclkstatSrc::from_bits(val as u8)
}
#[doc = "Source of HFCLK."]
#[inline(always)]
pub const fn set_src(&mut self, val: super::vals::HfclkstatSrc) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
#[doc = "HFCLK state."]
#[must_use]
#[inline(always)]
pub const fn state(&self) -> bool {
let val = (self.0 >> 16usize) & 0x01;
val != 0
}
#[doc = "HFCLK state."]
#[inline(always)]
pub const fn set_state(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 16usize)) | (((val as u32) & 0x01) << 16usize);
}
}
impl Default for Hfclkstat {
#[inline(always)]
fn default() -> Hfclkstat {
Hfclkstat(0)
}
}
impl core::fmt::Debug for Hfclkstat {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Hfclkstat")
.field("src", &self.src())
.field("state", &self.state())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Hfclkstat {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Hfclkstat {{ src: {:?}, state: {=bool:?} }}",
self.src(),
self.state()
)
}
}
#[doc = "HFXO debounce time. The HFXO is started by triggering the TASKS_HFCLKSTART task."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Hfxodebounce(pub u32);
impl Hfxodebounce {
#[doc = "HFXO debounce time. Debounce time = HFXODEBOUNCE * 16 us."]
#[must_use]
#[inline(always)]
pub const fn hfxodebounce(&self) -> super::vals::Hfxodebounce {
let val = (self.0 >> 0usize) & 0xff;
super::vals::Hfxodebounce::from_bits(val as u8)
}
#[doc = "HFXO debounce time. Debounce time = HFXODEBOUNCE * 16 us."]
#[inline(always)]
pub const fn set_hfxodebounce(&mut self, val: super::vals::Hfxodebounce) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val.to_bits() as u32) & 0xff) << 0usize);
}
}
impl Default for Hfxodebounce {
#[inline(always)]
fn default() -> Hfxodebounce {
Hfxodebounce(0)
}
}
impl core::fmt::Debug for Hfxodebounce {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Hfxodebounce")
.field("hfxodebounce", &self.hfxodebounce())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Hfxodebounce {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Hfxodebounce {{ hfxodebounce: {:?} }}",
self.hfxodebounce()
)
}
}
#[doc = "Disable interrupt."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Int(pub u32);
impl Int {
#[doc = "Write '1' to disable interrupt for event HFCLKSTARTED."]
#[must_use]
#[inline(always)]
pub const fn hfclkstarted(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event HFCLKSTARTED."]
#[inline(always)]
pub const fn set_hfclkstarted(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Write '1' to disable interrupt for event LFCLKSTARTED."]
#[must_use]
#[inline(always)]
pub const fn lfclkstarted(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event LFCLKSTARTED."]
#[inline(always)]
pub const fn set_lfclkstarted(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "Write '1' to disable interrupt for event DONE."]
#[must_use]
#[inline(always)]
pub const fn done(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event DONE."]
#[inline(always)]
pub const fn set_done(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
#[doc = "Write '1' to disable interrupt for event CTTO."]
#[must_use]
#[inline(always)]
pub const fn ctto(&self) -> bool {
let val = (self.0 >> 4usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event CTTO."]
#[inline(always)]
pub const fn set_ctto(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
}
#[doc = "Write '1' to disable interrupt for event CTSTARTED."]
#[must_use]
#[inline(always)]
pub const fn ctstarted(&self) -> bool {
let val = (self.0 >> 10usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event CTSTARTED."]
#[inline(always)]
pub const fn set_ctstarted(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 10usize)) | (((val as u32) & 0x01) << 10usize);
}
#[doc = "Write '1' to disable interrupt for event CTSTOPPED."]
#[must_use]
#[inline(always)]
pub const fn ctstopped(&self) -> bool {
let val = (self.0 >> 11usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event CTSTOPPED."]
#[inline(always)]
pub const fn set_ctstopped(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 11usize)) | (((val as u32) & 0x01) << 11usize);
}
}
impl Default for Int {
#[inline(always)]
fn default() -> Int {
Int(0)
}
}
impl core::fmt::Debug for Int {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Int")
.field("hfclkstarted", &self.hfclkstarted())
.field("lfclkstarted", &self.lfclkstarted())
.field("done", &self.done())
.field("ctto", &self.ctto())
.field("ctstarted", &self.ctstarted())
.field("ctstopped", &self.ctstopped())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Int {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Int {{ hfclkstarted: {=bool:?}, lfclkstarted: {=bool:?}, done: {=bool:?}, ctto: {=bool:?}, ctstarted: {=bool:?}, ctstopped: {=bool:?} }}" , self . hfclkstarted () , self . lfclkstarted () , self . done () , self . ctto () , self . ctstarted () , self . ctstopped ())
}
}
#[doc = "Status indicating that LFCLKSTART task has been triggered."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Lfclkrun(pub u32);
impl Lfclkrun {
#[doc = "LFCLKSTART task triggered or not."]
#[must_use]
#[inline(always)]
pub const fn status(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "LFCLKSTART task triggered or not."]
#[inline(always)]
pub const fn set_status(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for Lfclkrun {
#[inline(always)]
fn default() -> Lfclkrun {
Lfclkrun(0)
}
}
impl core::fmt::Debug for Lfclkrun {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Lfclkrun")
.field("status", &self.status())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Lfclkrun {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Lfclkrun {{ status: {=bool:?} }}", self.status())
}
}
#[doc = "Clock source for the LFCLK."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Lfclksrc(pub u32);
impl Lfclksrc {
#[doc = "Clock source."]
#[must_use]
#[inline(always)]
pub const fn src(&self) -> super::vals::Lfclksrc {
let val = (self.0 >> 0usize) & 0x03;
super::vals::Lfclksrc::from_bits(val as u8)
}
#[doc = "Clock source."]
#[inline(always)]
pub const fn set_src(&mut self, val: super::vals::Lfclksrc) {
self.0 = (self.0 & !(0x03 << 0usize)) | (((val.to_bits() as u32) & 0x03) << 0usize);
}
#[doc = "Enable or disable bypass of LFCLK crystal oscillator with external clock source."]
#[must_use]
#[inline(always)]
pub const fn bypass(&self) -> bool {
let val = (self.0 >> 16usize) & 0x01;
val != 0
}
#[doc = "Enable or disable bypass of LFCLK crystal oscillator with external clock source."]
#[inline(always)]
pub const fn set_bypass(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 16usize)) | (((val as u32) & 0x01) << 16usize);
}
#[doc = "Enable or disable external source for LFCLK."]
#[must_use]
#[inline(always)]
pub const fn external(&self) -> bool {
let val = (self.0 >> 17usize) & 0x01;
val != 0
}
#[doc = "Enable or disable external source for LFCLK."]
#[inline(always)]
pub const fn set_external(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 17usize)) | (((val as u32) & 0x01) << 17usize);
}
}
impl Default for Lfclksrc {
#[inline(always)]
fn default() -> Lfclksrc {
Lfclksrc(0)
}
}
impl core::fmt::Debug for Lfclksrc {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Lfclksrc")
.field("src", &self.src())
.field("bypass", &self.bypass())
.field("external", &self.external())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Lfclksrc {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Lfclksrc {{ src: {:?}, bypass: {=bool:?}, external: {=bool:?} }}",
self.src(),
self.bypass(),
self.external()
)
}
}
#[doc = "Copy of LFCLKSRC register, set when LFCLKSTART task was triggered."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Lfclksrccopy(pub u32);
impl Lfclksrccopy {
#[doc = "Clock source."]
#[must_use]
#[inline(always)]
pub const fn src(&self) -> super::vals::Lfclksrc {
let val = (self.0 >> 0usize) & 0x03;
super::vals::Lfclksrc::from_bits(val as u8)
}
#[doc = "Clock source."]
#[inline(always)]
pub const fn set_src(&mut self, val: super::vals::Lfclksrc) {
self.0 = (self.0 & !(0x03 << 0usize)) | (((val.to_bits() as u32) & 0x03) << 0usize);
}
}
impl Default for Lfclksrccopy {
#[inline(always)]
fn default() -> Lfclksrccopy {
Lfclksrccopy(0)
}
}
impl core::fmt::Debug for Lfclksrccopy {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Lfclksrccopy")
.field("src", &self.src())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Lfclksrccopy {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Lfclksrccopy {{ src: {:?} }}", self.src())
}
}
#[doc = "LFCLK status."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Lfclkstat(pub u32);
impl Lfclkstat {
#[doc = "Source of LFCLK."]
#[must_use]
#[inline(always)]
pub const fn src(&self) -> super::vals::Lfclksrc {
let val = (self.0 >> 0usize) & 0x03;
super::vals::Lfclksrc::from_bits(val as u8)
}
#[doc = "Source of LFCLK."]
#[inline(always)]
pub const fn set_src(&mut self, val: super::vals::Lfclksrc) {
self.0 = (self.0 & !(0x03 << 0usize)) | (((val.to_bits() as u32) & 0x03) << 0usize);
}
#[doc = "LFCLK state."]
#[must_use]
#[inline(always)]
pub const fn state(&self) -> bool {
let val = (self.0 >> 16usize) & 0x01;
val != 0
}
#[doc = "LFCLK state."]
#[inline(always)]
pub const fn set_state(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 16usize)) | (((val as u32) & 0x01) << 16usize);
}
}
impl Default for Lfclkstat {
#[inline(always)]
fn default() -> Lfclkstat {
Lfclkstat(0)
}
}
impl core::fmt::Debug for Lfclkstat {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Lfclkstat")
.field("src", &self.src())
.field("state", &self.state())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Lfclkstat {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Lfclkstat {{ src: {:?}, state: {=bool:?} }}",
self.src(),
self.state()
)
}
}
#[doc = "LFXO debounce time. The LFXO is started by triggering the TASKS_LFCLKSTART task when the LFCLKSRC register is configured for Xtal."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Lfxodebounce(pub u32);
impl Lfxodebounce {
#[doc = "LFXO debounce time."]
#[must_use]
#[inline(always)]
pub const fn lfxodebounce(&self) -> super::vals::Lfxodebounce {
let val = (self.0 >> 0usize) & 0x01;
super::vals::Lfxodebounce::from_bits(val as u8)
}
#[doc = "LFXO debounce time."]
#[inline(always)]
pub const fn set_lfxodebounce(&mut self, val: super::vals::Lfxodebounce) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
}
impl Default for Lfxodebounce {
#[inline(always)]
fn default() -> Lfxodebounce {
Lfxodebounce(0)
}
}
impl core::fmt::Debug for Lfxodebounce {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Lfxodebounce")
.field("lfxodebounce", &self.lfxodebounce())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Lfxodebounce {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Lfxodebounce {{ lfxodebounce: {:?} }}",
self.lfxodebounce()
)
}
}
}
pub mod vals {
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum HfclkstatSrc {
#[doc = "64 MHz internal oscillator (HFINT)."]
Rc = 0x0,
#[doc = "64 MHz crystal oscillator (HFXO)."]
Xtal = 0x01,
}
impl HfclkstatSrc {
#[inline(always)]
pub const fn from_bits(val: u8) -> HfclkstatSrc {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for HfclkstatSrc {
#[inline(always)]
fn from(val: u8) -> HfclkstatSrc {
HfclkstatSrc::from_bits(val)
}
}
impl From<HfclkstatSrc> for u8 {
#[inline(always)]
fn from(val: HfclkstatSrc) -> u8 {
HfclkstatSrc::to_bits(val)
}
}
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct Hfxodebounce(u8);
impl Hfxodebounce {
#[doc = "256 us debounce time. Recommended for 1.6 mm x 2.0 mm crystals and larger."]
pub const Db256us: Self = Self(0x10);
#[doc = "1024 us debounce time. Recommended for 1.6 mm x 1.2 mm crystals and smaller."]
pub const Db1024us: Self = Self(0x40);
}
impl Hfxodebounce {
pub const fn from_bits(val: u8) -> Hfxodebounce {
Self(val & 0xff)
}
pub const fn to_bits(self) -> u8 {
self.0
}
}
impl core::fmt::Debug for Hfxodebounce {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self.0 {
0x10 => f.write_str("Db256us"),
0x40 => f.write_str("Db1024us"),
other => core::write!(f, "0x{:02X}", other),
}
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Hfxodebounce {
fn format(&self, f: defmt::Formatter) {
match self.0 {
0x10 => defmt::write!(f, "Db256us"),
0x40 => defmt::write!(f, "Db1024us"),
other => defmt::write!(f, "0x{:02X}", other),
}
}
}
impl From<u8> for Hfxodebounce {
#[inline(always)]
fn from(val: u8) -> Hfxodebounce {
Hfxodebounce::from_bits(val)
}
}
impl From<Hfxodebounce> for u8 {
#[inline(always)]
fn from(val: Hfxodebounce) -> u8 {
Hfxodebounce::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Lfclksrc {
#[doc = "32.768 kHz RC oscillator (LFRC)."]
Rc = 0x0,
#[doc = "32.768 kHz crystal oscillator (LFXO)."]
Xtal = 0x01,
#[doc = "32.768 kHz synthesized from HFCLK (LFSYNT)."]
Synth = 0x02,
_RESERVED_3 = 0x03,
}
impl Lfclksrc {
#[inline(always)]
pub const fn from_bits(val: u8) -> Lfclksrc {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Lfclksrc {
#[inline(always)]
fn from(val: u8) -> Lfclksrc {
Lfclksrc::from_bits(val)
}
}
impl From<Lfclksrc> for u8 {
#[inline(always)]
fn from(val: Lfclksrc) -> u8 {
Lfclksrc::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Lfxodebounce {
#[doc = "8192 32.768 kHz periods, or 0.25 s. Recommended for normal Operating Temperature conditions."]
Normal = 0x0,
#[doc = "16384 32.768 kHz periods, or 0.5 s. Recommended for Extended Operating Temperature conditions."]
Extended = 0x01,
}
impl Lfxodebounce {
#[inline(always)]
pub const fn from_bits(val: u8) -> Lfxodebounce {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Lfxodebounce {
#[inline(always)]
fn from(val: u8) -> Lfxodebounce {
Lfxodebounce::from_bits(val)
}
}
impl From<Lfxodebounce> for u8 {
#[inline(always)]
fn from(val: Lfxodebounce) -> u8 {
Lfxodebounce::to_bits(val)
}
}
}
}
pub mod common {
use core::marker::PhantomData;
#[derive(Copy, Clone, PartialEq, Eq)]
pub struct RW;
#[derive(Copy, Clone, PartialEq, Eq)]
pub struct R;
#[derive(Copy, Clone, PartialEq, Eq)]
pub struct W;
mod sealed {
use super::*;
pub trait Access {}
impl Access for R {}
impl Access for W {}
impl Access for RW {}
}
pub trait Access: sealed::Access + Copy {}
impl Access for R {}
impl Access for W {}
impl Access for RW {}
pub trait Read: Access {}
impl Read for RW {}
impl Read for R {}
pub trait Write: Access {}
impl Write for RW {}
impl Write for W {}
#[derive(Copy, Clone, PartialEq, Eq)]
pub struct Reg<T: Copy, A: Access> {
ptr: *mut u8,
phantom: PhantomData<*mut (T, A)>,
}
unsafe impl<T: Copy, A: Access> Send for Reg<T, A> {}
unsafe impl<T: Copy, A: Access> Sync for Reg<T, A> {}
impl<T: Copy, A: Access> Reg<T, A> {
#[allow(clippy::missing_safety_doc)]
#[inline(always)]
pub const unsafe fn from_ptr(ptr: *mut T) -> Self {
Self {
ptr: ptr as _,
phantom: PhantomData,
}
}
#[inline(always)]
pub const fn as_ptr(&self) -> *mut T {
self.ptr as _
}
}
impl<T: Copy, A: Read> Reg<T, A> {
#[inline(always)]
pub fn read(&self) -> T {
unsafe { (self.ptr as *mut T).read_volatile() }
}
}
impl<T: Copy, A: Write> Reg<T, A> {
#[inline(always)]
pub fn write_value(&self, val: T) {
unsafe { (self.ptr as *mut T).write_volatile(val) }
}
}
impl<T: Default + Copy, A: Write> Reg<T, A> {
#[inline(always)]
pub fn write(&self, f: impl FnOnce(&mut T)) {
let mut val = Default::default();
f(&mut val);
self.write_value(val);
}
}
impl<T: Copy, A: Read + Write> Reg<T, A> {
#[inline(always)]
pub fn modify(&self, f: impl FnOnce(&mut T)) {
let mut val = self.read();
f(&mut val);
self.write_value(val);
}
}
}
pub mod comp {
#[doc = "Comparator."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Comp {
ptr: *mut u8,
}
unsafe impl Send for Comp {}
unsafe impl Sync for Comp {}
impl Comp {
#[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 = "Start comparator."]
#[inline(always)]
pub const fn tasks_start(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Stop comparator."]
#[inline(always)]
pub const fn tasks_stop(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Sample comparator value."]
#[inline(always)]
pub const fn tasks_sample(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
#[doc = "COMP is ready and output is valid."]
#[inline(always)]
pub const fn events_ready(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0100usize) as _) }
}
#[doc = "Downward crossing."]
#[inline(always)]
pub const fn events_down(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0104usize) as _) }
}
#[doc = "Upward crossing."]
#[inline(always)]
pub const fn events_up(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0108usize) as _) }
}
#[doc = "Downward or upward crossing."]
#[inline(always)]
pub const fn events_cross(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x010cusize) as _) }
}
#[doc = "Shortcuts between local events and tasks."]
#[inline(always)]
pub const fn shorts(self) -> crate::common::Reg<regs::Shorts, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0200usize) as _) }
}
#[doc = "Enable or disable interrupt."]
#[inline(always)]
pub const fn inten(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0300usize) as _) }
}
#[doc = "Enable interrupt."]
#[inline(always)]
pub const fn intenset(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0304usize) as _) }
}
#[doc = "Disable interrupt."]
#[inline(always)]
pub const fn intenclr(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0308usize) as _) }
}
#[doc = "Compare result."]
#[inline(always)]
pub const fn result(self) -> crate::common::Reg<regs::Result, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0400usize) as _) }
}
#[doc = "COMP enable."]
#[inline(always)]
pub const fn enable(self) -> crate::common::Reg<regs::Enable, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0500usize) as _) }
}
#[doc = "Pin select."]
#[inline(always)]
pub const fn psel(self) -> crate::common::Reg<regs::Psel, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0504usize) as _) }
}
#[doc = "Reference source select for single-ended mode."]
#[inline(always)]
pub const fn refsel(self) -> crate::common::Reg<regs::Refsel, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0508usize) as _) }
}
#[doc = "External reference select."]
#[inline(always)]
pub const fn extrefsel(self) -> crate::common::Reg<regs::Extrefsel, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x050cusize) as _) }
}
#[doc = "Threshold configuration for hysteresis unit."]
#[inline(always)]
pub const fn th(self) -> crate::common::Reg<regs::Th, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0530usize) as _) }
}
#[doc = "Mode configuration."]
#[inline(always)]
pub const fn mode(self) -> crate::common::Reg<regs::Mode, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0534usize) as _) }
}
#[doc = "Comparator hysteresis enable."]
#[inline(always)]
pub const fn hyst(self) -> crate::common::Reg<regs::Hyst, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0538usize) as _) }
}
}
pub mod regs {
#[doc = "COMP enable."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Enable(pub u32);
impl Enable {
#[doc = "Enable or disable COMP."]
#[must_use]
#[inline(always)]
pub const fn enable(&self) -> super::vals::Enable {
let val = (self.0 >> 0usize) & 0x03;
super::vals::Enable::from_bits(val as u8)
}
#[doc = "Enable or disable COMP."]
#[inline(always)]
pub const fn set_enable(&mut self, val: super::vals::Enable) {
self.0 = (self.0 & !(0x03 << 0usize)) | (((val.to_bits() as u32) & 0x03) << 0usize);
}
}
impl Default for Enable {
#[inline(always)]
fn default() -> Enable {
Enable(0)
}
}
impl core::fmt::Debug for Enable {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Enable")
.field("enable", &self.enable())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Enable {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Enable {{ enable: {:?} }}", self.enable())
}
}
#[doc = "External reference select."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Extrefsel(pub u32);
impl Extrefsel {
#[doc = "External analog reference select."]
#[must_use]
#[inline(always)]
pub const fn extrefsel(&self) -> super::vals::Extrefsel {
let val = (self.0 >> 0usize) & 0x07;
super::vals::Extrefsel::from_bits(val as u8)
}
#[doc = "External analog reference select."]
#[inline(always)]
pub const fn set_extrefsel(&mut self, val: super::vals::Extrefsel) {
self.0 = (self.0 & !(0x07 << 0usize)) | (((val.to_bits() as u32) & 0x07) << 0usize);
}
}
impl Default for Extrefsel {
#[inline(always)]
fn default() -> Extrefsel {
Extrefsel(0)
}
}
impl core::fmt::Debug for Extrefsel {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Extrefsel")
.field("extrefsel", &self.extrefsel())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Extrefsel {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Extrefsel {{ extrefsel: {:?} }}", self.extrefsel())
}
}
#[doc = "Comparator hysteresis enable."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Hyst(pub u32);
impl Hyst {
#[doc = "Comparator hysteresis."]
#[must_use]
#[inline(always)]
pub const fn hyst(&self) -> super::vals::Hyst {
let val = (self.0 >> 0usize) & 0x01;
super::vals::Hyst::from_bits(val as u8)
}
#[doc = "Comparator hysteresis."]
#[inline(always)]
pub const fn set_hyst(&mut self, val: super::vals::Hyst) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
}
impl Default for Hyst {
#[inline(always)]
fn default() -> Hyst {
Hyst(0)
}
}
impl core::fmt::Debug for Hyst {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Hyst").field("hyst", &self.hyst()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Hyst {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Hyst {{ hyst: {:?} }}", self.hyst())
}
}
#[doc = "Enable or disable interrupt."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Int(pub u32);
impl Int {
#[doc = "Enable or disable interrupt for event READY."]
#[must_use]
#[inline(always)]
pub const fn ready(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event READY."]
#[inline(always)]
pub const fn set_ready(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Enable or disable interrupt for event DOWN."]
#[must_use]
#[inline(always)]
pub const fn down(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event DOWN."]
#[inline(always)]
pub const fn set_down(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "Enable or disable interrupt for event UP."]
#[must_use]
#[inline(always)]
pub const fn up(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event UP."]
#[inline(always)]
pub const fn set_up(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "Enable or disable interrupt for event CROSS."]
#[must_use]
#[inline(always)]
pub const fn cross(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event CROSS."]
#[inline(always)]
pub const fn set_cross(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
}
impl Default for Int {
#[inline(always)]
fn default() -> Int {
Int(0)
}
}
impl core::fmt::Debug for Int {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Int")
.field("ready", &self.ready())
.field("down", &self.down())
.field("up", &self.up())
.field("cross", &self.cross())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Int {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Int {{ ready: {=bool:?}, down: {=bool:?}, up: {=bool:?}, cross: {=bool:?} }}",
self.ready(),
self.down(),
self.up(),
self.cross()
)
}
}
#[doc = "Mode configuration."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Mode(pub u32);
impl Mode {
#[doc = "Speed and power modes."]
#[must_use]
#[inline(always)]
pub const fn sp(&self) -> super::vals::Sp {
let val = (self.0 >> 0usize) & 0x03;
super::vals::Sp::from_bits(val as u8)
}
#[doc = "Speed and power modes."]
#[inline(always)]
pub const fn set_sp(&mut self, val: super::vals::Sp) {
self.0 = (self.0 & !(0x03 << 0usize)) | (((val.to_bits() as u32) & 0x03) << 0usize);
}
#[doc = "Main operation modes."]
#[must_use]
#[inline(always)]
pub const fn main(&self) -> super::vals::Main {
let val = (self.0 >> 8usize) & 0x01;
super::vals::Main::from_bits(val as u8)
}
#[doc = "Main operation modes."]
#[inline(always)]
pub const fn set_main(&mut self, val: super::vals::Main) {
self.0 = (self.0 & !(0x01 << 8usize)) | (((val.to_bits() as u32) & 0x01) << 8usize);
}
}
impl Default for Mode {
#[inline(always)]
fn default() -> Mode {
Mode(0)
}
}
impl core::fmt::Debug for Mode {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Mode")
.field("sp", &self.sp())
.field("main", &self.main())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Mode {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Mode {{ sp: {:?}, main: {:?} }}", self.sp(), self.main())
}
}
#[doc = "Pin select."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Psel(pub u32);
impl Psel {
#[doc = "Analog pin select."]
#[must_use]
#[inline(always)]
pub const fn psel(&self) -> super::vals::PselPsel {
let val = (self.0 >> 0usize) & 0x07;
super::vals::PselPsel::from_bits(val as u8)
}
#[doc = "Analog pin select."]
#[inline(always)]
pub const fn set_psel(&mut self, val: super::vals::PselPsel) {
self.0 = (self.0 & !(0x07 << 0usize)) | (((val.to_bits() as u32) & 0x07) << 0usize);
}
}
impl Default for Psel {
#[inline(always)]
fn default() -> Psel {
Psel(0)
}
}
impl core::fmt::Debug for Psel {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Psel").field("psel", &self.psel()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Psel {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Psel {{ psel: {:?} }}", self.psel())
}
}
#[doc = "Reference source select for single-ended mode."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Refsel(pub u32);
impl Refsel {
#[doc = "Reference select."]
#[must_use]
#[inline(always)]
pub const fn refsel(&self) -> super::vals::Refsel {
let val = (self.0 >> 0usize) & 0x07;
super::vals::Refsel::from_bits(val as u8)
}
#[doc = "Reference select."]
#[inline(always)]
pub const fn set_refsel(&mut self, val: super::vals::Refsel) {
self.0 = (self.0 & !(0x07 << 0usize)) | (((val.to_bits() as u32) & 0x07) << 0usize);
}
}
impl Default for Refsel {
#[inline(always)]
fn default() -> Refsel {
Refsel(0)
}
}
impl core::fmt::Debug for Refsel {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Refsel")
.field("refsel", &self.refsel())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Refsel {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Refsel {{ refsel: {:?} }}", self.refsel())
}
}
#[doc = "Compare result."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Result(pub u32);
impl Result {
#[doc = "Result of last compare. Decision point SAMPLE task."]
#[must_use]
#[inline(always)]
pub const fn result(&self) -> super::vals::Result {
let val = (self.0 >> 0usize) & 0x01;
super::vals::Result::from_bits(val as u8)
}
#[doc = "Result of last compare. Decision point SAMPLE task."]
#[inline(always)]
pub const fn set_result(&mut self, val: super::vals::Result) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
}
impl Default for Result {
#[inline(always)]
fn default() -> Result {
Result(0)
}
}
impl core::fmt::Debug for Result {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Result")
.field("result", &self.result())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Result {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Result {{ result: {:?} }}", self.result())
}
}
#[doc = "Shortcuts between local events and tasks."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Shorts(pub u32);
impl Shorts {
#[doc = "Shortcut between event READY and task SAMPLE."]
#[must_use]
#[inline(always)]
pub const fn ready_sample(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event READY and task SAMPLE."]
#[inline(always)]
pub const fn set_ready_sample(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Shortcut between event READY and task STOP."]
#[must_use]
#[inline(always)]
pub const fn ready_stop(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event READY and task STOP."]
#[inline(always)]
pub const fn set_ready_stop(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "Shortcut between event DOWN and task STOP."]
#[must_use]
#[inline(always)]
pub const fn down_stop(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event DOWN and task STOP."]
#[inline(always)]
pub const fn set_down_stop(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "Shortcut between event UP and task STOP."]
#[must_use]
#[inline(always)]
pub const fn up_stop(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event UP and task STOP."]
#[inline(always)]
pub const fn set_up_stop(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
#[doc = "Shortcut between event CROSS and task STOP."]
#[must_use]
#[inline(always)]
pub const fn cross_stop(&self) -> bool {
let val = (self.0 >> 4usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event CROSS and task STOP."]
#[inline(always)]
pub const fn set_cross_stop(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
}
}
impl Default for Shorts {
#[inline(always)]
fn default() -> Shorts {
Shorts(0)
}
}
impl core::fmt::Debug for Shorts {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Shorts")
.field("ready_sample", &self.ready_sample())
.field("ready_stop", &self.ready_stop())
.field("down_stop", &self.down_stop())
.field("up_stop", &self.up_stop())
.field("cross_stop", &self.cross_stop())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Shorts {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Shorts {{ ready_sample: {=bool:?}, ready_stop: {=bool:?}, down_stop: {=bool:?}, up_stop: {=bool:?}, cross_stop: {=bool:?} }}" , self . ready_sample () , self . ready_stop () , self . down_stop () , self . up_stop () , self . cross_stop ())
}
}
#[doc = "Threshold configuration for hysteresis unit."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Th(pub u32);
impl Th {
#[doc = "VDOWN = (THDOWN+1)/64*VREF."]
#[must_use]
#[inline(always)]
pub const fn thdown(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x3f;
val as u8
}
#[doc = "VDOWN = (THDOWN+1)/64*VREF."]
#[inline(always)]
pub const fn set_thdown(&mut self, val: u8) {
self.0 = (self.0 & !(0x3f << 0usize)) | (((val as u32) & 0x3f) << 0usize);
}
#[doc = "VUP = (THUP+1)/64*VREF."]
#[must_use]
#[inline(always)]
pub const fn thup(&self) -> u8 {
let val = (self.0 >> 8usize) & 0x3f;
val as u8
}
#[doc = "VUP = (THUP+1)/64*VREF."]
#[inline(always)]
pub const fn set_thup(&mut self, val: u8) {
self.0 = (self.0 & !(0x3f << 8usize)) | (((val as u32) & 0x3f) << 8usize);
}
}
impl Default for Th {
#[inline(always)]
fn default() -> Th {
Th(0)
}
}
impl core::fmt::Debug for Th {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Th")
.field("thdown", &self.thdown())
.field("thup", &self.thup())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Th {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Th {{ thdown: {=u8:?}, thup: {=u8:?} }}",
self.thdown(),
self.thup()
)
}
}
}
pub mod vals {
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Enable {
#[doc = "Disable."]
Disabled = 0x0,
_RESERVED_1 = 0x01,
#[doc = "Enable."]
Enabled = 0x02,
_RESERVED_3 = 0x03,
}
impl Enable {
#[inline(always)]
pub const fn from_bits(val: u8) -> Enable {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Enable {
#[inline(always)]
fn from(val: u8) -> Enable {
Enable::from_bits(val)
}
}
impl From<Enable> for u8 {
#[inline(always)]
fn from(val: Enable) -> u8 {
Enable::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Extrefsel {
#[doc = "Use AIN0 as external analog reference."]
AnalogReference0 = 0x0,
#[doc = "Use AIN1 as external analog reference."]
AnalogReference1 = 0x01,
#[doc = "Use AIN2 as external analog reference."]
AnalogReference2 = 0x02,
#[doc = "Use AIN3 as external analog reference."]
AnalogReference3 = 0x03,
_RESERVED_4 = 0x04,
_RESERVED_5 = 0x05,
_RESERVED_6 = 0x06,
_RESERVED_7 = 0x07,
}
impl Extrefsel {
#[inline(always)]
pub const fn from_bits(val: u8) -> Extrefsel {
unsafe { core::mem::transmute(val & 0x07) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Extrefsel {
#[inline(always)]
fn from(val: u8) -> Extrefsel {
Extrefsel::from_bits(val)
}
}
impl From<Extrefsel> for u8 {
#[inline(always)]
fn from(val: Extrefsel) -> u8 {
Extrefsel::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Hyst {
#[doc = "Comparator hysteresis disabled."]
NoHyst = 0x0,
#[doc = "Comparator hysteresis enabled."]
Hyst50mV = 0x01,
}
impl Hyst {
#[inline(always)]
pub const fn from_bits(val: u8) -> Hyst {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Hyst {
#[inline(always)]
fn from(val: u8) -> Hyst {
Hyst::from_bits(val)
}
}
impl From<Hyst> for u8 {
#[inline(always)]
fn from(val: Hyst) -> u8 {
Hyst::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Main {
#[doc = "Single-ended mode."]
Se = 0x0,
#[doc = "Differential mode."]
Diff = 0x01,
}
impl Main {
#[inline(always)]
pub const fn from_bits(val: u8) -> Main {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Main {
#[inline(always)]
fn from(val: u8) -> Main {
Main::from_bits(val)
}
}
impl From<Main> for u8 {
#[inline(always)]
fn from(val: Main) -> u8 {
Main::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum PselPsel {
#[doc = "AIN0 selected as analog input."]
AnalogInput0 = 0x0,
#[doc = "AIN1 selected as analog input."]
AnalogInput1 = 0x01,
#[doc = "AIN2 selected as analog input."]
AnalogInput2 = 0x02,
#[doc = "AIN3 selected as analog input."]
AnalogInput3 = 0x03,
_RESERVED_4 = 0x04,
_RESERVED_5 = 0x05,
_RESERVED_6 = 0x06,
#[doc = "VDDH/5 selected as analog input."]
VddhDiv5 = 0x07,
}
impl PselPsel {
#[inline(always)]
pub const fn from_bits(val: u8) -> PselPsel {
unsafe { core::mem::transmute(val & 0x07) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for PselPsel {
#[inline(always)]
fn from(val: u8) -> PselPsel {
PselPsel::from_bits(val)
}
}
impl From<PselPsel> for u8 {
#[inline(always)]
fn from(val: PselPsel) -> u8 {
PselPsel::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Refsel {
#[doc = "VREF = internal 1.2 V reference (VDD >= 1.7 V)."]
Int1v2 = 0x0,
#[doc = "VREF = internal 1.8 V reference (VDD >= VREF + 0.2 V)."]
Int1v8 = 0x01,
#[doc = "VREF = internal 2.4 V reference (VDD >= VREF + 0.2 V)."]
Int2v4 = 0x02,
_RESERVED_3 = 0x03,
#[doc = "VREF = VDD."]
Vdd = 0x04,
#[doc = "VREF = AREF."]
ARef = 0x05,
_RESERVED_6 = 0x06,
_RESERVED_7 = 0x07,
}
impl Refsel {
#[inline(always)]
pub const fn from_bits(val: u8) -> Refsel {
unsafe { core::mem::transmute(val & 0x07) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Refsel {
#[inline(always)]
fn from(val: u8) -> Refsel {
Refsel::from_bits(val)
}
}
impl From<Refsel> for u8 {
#[inline(always)]
fn from(val: Refsel) -> u8 {
Refsel::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Result {
#[doc = "Input voltage is below the threshold (VIN+ < VIN-)."]
Below = 0x0,
#[doc = "Input voltage is above the threshold (VIN+ > VIN-)."]
Above = 0x01,
}
impl Result {
#[inline(always)]
pub const fn from_bits(val: u8) -> Result {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Result {
#[inline(always)]
fn from(val: u8) -> Result {
Result::from_bits(val)
}
}
impl From<Result> for u8 {
#[inline(always)]
fn from(val: Result) -> u8 {
Result::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Sp {
#[doc = "Low-power mode."]
Low = 0x0,
#[doc = "Normal mode."]
Normal = 0x01,
#[doc = "High-speed mode."]
High = 0x02,
_RESERVED_3 = 0x03,
}
impl Sp {
#[inline(always)]
pub const fn from_bits(val: u8) -> Sp {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Sp {
#[inline(always)]
fn from(val: u8) -> Sp {
Sp::from_bits(val)
}
}
impl From<Sp> for u8 {
#[inline(always)]
fn from(val: Sp) -> u8 {
Sp::to_bits(val)
}
}
}
}
pub mod ecb {
#[doc = "AES ECB Mode Encryption."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Ecb {
ptr: *mut u8,
}
unsafe impl Send for Ecb {}
unsafe impl Sync for Ecb {}
impl Ecb {
#[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 = "Start ECB block encrypt."]
#[inline(always)]
pub const fn tasks_startecb(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Abort a possible executing ECB operation."]
#[inline(always)]
pub const fn tasks_stopecb(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "ECB block encrypt complete."]
#[inline(always)]
pub const fn events_endecb(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0100usize) as _) }
}
#[doc = "ECB block encrypt aborted because of a STOPECB task or due to an error."]
#[inline(always)]
pub const fn events_errorecb(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0104usize) as _) }
}
#[doc = "Enable interrupt."]
#[inline(always)]
pub const fn intenset(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0304usize) as _) }
}
#[doc = "Disable interrupt."]
#[inline(always)]
pub const fn intenclr(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0308usize) as _) }
}
#[doc = "ECB block encrypt memory pointers."]
#[inline(always)]
pub const fn ecbdataptr(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0504usize) as _) }
}
}
pub mod regs {
#[doc = "Disable interrupt."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Int(pub u32);
impl Int {
#[doc = "Write '1' to disable interrupt for event ENDECB."]
#[must_use]
#[inline(always)]
pub const fn endecb(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event ENDECB."]
#[inline(always)]
pub const fn set_endecb(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Write '1' to disable interrupt for event ERRORECB."]
#[must_use]
#[inline(always)]
pub const fn errorecb(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event ERRORECB."]
#[inline(always)]
pub const fn set_errorecb(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
}
impl Default for Int {
#[inline(always)]
fn default() -> Int {
Int(0)
}
}
impl core::fmt::Debug for Int {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Int")
.field("endecb", &self.endecb())
.field("errorecb", &self.errorecb())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Int {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Int {{ endecb: {=bool:?}, errorecb: {=bool:?} }}",
self.endecb(),
self.errorecb()
)
}
}
}
}
pub mod egu {
#[doc = "Event generator unit 0."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Egu {
ptr: *mut u8,
}
unsafe impl Send for Egu {}
unsafe impl Sync for Egu {}
impl Egu {
#[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 = "Description collection: Trigger n for triggering the corresponding TRIGGERED\\[n\\] event."]
#[inline(always)]
pub const fn tasks_trigger(self, n: usize) -> crate::common::Reg<u32, crate::common::W> {
assert!(n < 16usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize + n * 4usize) as _)
}
}
#[doc = "Description collection: Event number n generated by triggering the corresponding TRIGGER\\[n\\] task."]
#[inline(always)]
pub const fn events_triggered(
self,
n: usize,
) -> crate::common::Reg<u32, crate::common::RW> {
assert!(n < 16usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0100usize + n * 4usize) as _)
}
}
#[doc = "Enable or disable interrupt."]
#[inline(always)]
pub const fn inten(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0300usize) as _) }
}
#[doc = "Enable interrupt."]
#[inline(always)]
pub const fn intenset(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0304usize) as _) }
}
#[doc = "Disable interrupt."]
#[inline(always)]
pub const fn intenclr(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0308usize) as _) }
}
}
pub mod regs {
#[doc = "Enable or disable interrupt."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Int(pub u32);
impl Int {
#[doc = "Enable or disable interrupt for event TRIGGERED\\[0\\]."]
#[must_use]
#[inline(always)]
pub const fn triggered(&self, n: usize) -> bool {
assert!(n < 16usize);
let offs = 0usize + n * 1usize;
let val = (self.0 >> offs) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event TRIGGERED\\[0\\]."]
#[inline(always)]
pub const fn set_triggered(&mut self, n: usize, val: bool) {
assert!(n < 16usize);
let offs = 0usize + n * 1usize;
self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
}
}
impl Default for Int {
#[inline(always)]
fn default() -> Int {
Int(0)
}
}
impl core::fmt::Debug for Int {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Int")
.field("triggered[0]", &self.triggered(0usize))
.field("triggered[1]", &self.triggered(1usize))
.field("triggered[2]", &self.triggered(2usize))
.field("triggered[3]", &self.triggered(3usize))
.field("triggered[4]", &self.triggered(4usize))
.field("triggered[5]", &self.triggered(5usize))
.field("triggered[6]", &self.triggered(6usize))
.field("triggered[7]", &self.triggered(7usize))
.field("triggered[8]", &self.triggered(8usize))
.field("triggered[9]", &self.triggered(9usize))
.field("triggered[10]", &self.triggered(10usize))
.field("triggered[11]", &self.triggered(11usize))
.field("triggered[12]", &self.triggered(12usize))
.field("triggered[13]", &self.triggered(13usize))
.field("triggered[14]", &self.triggered(14usize))
.field("triggered[15]", &self.triggered(15usize))
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Int {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Int {{ triggered[0]: {=bool:?}, triggered[1]: {=bool:?}, triggered[2]: {=bool:?}, triggered[3]: {=bool:?}, triggered[4]: {=bool:?}, triggered[5]: {=bool:?}, triggered[6]: {=bool:?}, triggered[7]: {=bool:?}, triggered[8]: {=bool:?}, triggered[9]: {=bool:?}, triggered[10]: {=bool:?}, triggered[11]: {=bool:?}, triggered[12]: {=bool:?}, triggered[13]: {=bool:?}, triggered[14]: {=bool:?}, triggered[15]: {=bool:?} }}" , self . triggered (0usize) , self . triggered (1usize) , self . triggered (2usize) , self . triggered (3usize) , self . triggered (4usize) , self . triggered (5usize) , self . triggered (6usize) , self . triggered (7usize) , self . triggered (8usize) , self . triggered (9usize) , self . triggered (10usize) , self . triggered (11usize) , self . triggered (12usize) , self . triggered (13usize) , self . triggered (14usize) , self . triggered (15usize))
}
}
}
}
pub mod ficr {
#[doc = "Factory information configuration registers."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Ficr {
ptr: *mut u8,
}
unsafe impl Send for Ficr {}
unsafe impl Sync for Ficr {}
impl Ficr {
#[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 = "Code memory page size."]
#[inline(always)]
pub const fn codepagesize(self) -> crate::common::Reg<u32, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x10usize) as _) }
}
#[doc = "Code memory size."]
#[inline(always)]
pub const fn codesize(self) -> crate::common::Reg<u32, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x14usize) as _) }
}
#[doc = "Description collection: Device identifier."]
#[inline(always)]
pub const fn deviceid(self, n: usize) -> crate::common::Reg<u32, crate::common::R> {
assert!(n < 2usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x60usize + n * 4usize) as _)
}
}
#[doc = "Description collection: Encryption root, word n."]
#[inline(always)]
pub const fn er(self, n: usize) -> crate::common::Reg<u32, crate::common::R> {
assert!(n < 4usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x80usize + n * 4usize) as _)
}
}
#[doc = "Description collection: Identity Root, word n."]
#[inline(always)]
pub const fn ir(self, n: usize) -> crate::common::Reg<u32, crate::common::R> {
assert!(n < 4usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x90usize + n * 4usize) as _)
}
}
#[doc = "Device address type."]
#[inline(always)]
pub const fn deviceaddrtype(
self,
) -> crate::common::Reg<regs::Deviceaddrtype, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0xa0usize) as _) }
}
#[doc = "Description collection: Device address n."]
#[inline(always)]
pub const fn deviceaddr(self, n: usize) -> crate::common::Reg<u32, crate::common::R> {
assert!(n < 2usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0xa4usize + n * 4usize) as _)
}
}
#[doc = "Device info."]
#[inline(always)]
pub const fn info(self) -> Info {
unsafe { Info::from_ptr(self.ptr.wrapping_add(0x0100usize) as _) }
}
#[doc = "Description collection: Production test signature n."]
#[inline(always)]
pub const fn prodtest(
self,
n: usize,
) -> crate::common::Reg<regs::Prodtest, crate::common::R> {
assert!(n < 3usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0350usize + n * 4usize) as _)
}
}
#[doc = "Registers storing factory TEMP module linearization coefficients."]
#[inline(always)]
pub const fn temp(self) -> Temp {
unsafe { Temp::from_ptr(self.ptr.wrapping_add(0x0404usize) as _) }
}
}
#[doc = "Device info."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Info {
ptr: *mut u8,
}
unsafe impl Send for Info {}
unsafe impl Sync for Info {}
impl Info {
#[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 = "Part code."]
#[inline(always)]
pub const fn part(self) -> crate::common::Reg<regs::Part, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Build code (hardware version and production configuration)."]
#[inline(always)]
pub const fn variant(self) -> crate::common::Reg<regs::Variant, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Package option."]
#[inline(always)]
pub const fn package(self) -> crate::common::Reg<regs::Package, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
#[doc = "RAM variant."]
#[inline(always)]
pub const fn ram(self) -> crate::common::Reg<regs::Ram, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0cusize) as _) }
}
#[doc = "Flash variant."]
#[inline(always)]
pub const fn flash(self) -> crate::common::Reg<regs::Flash, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x10usize) as _) }
}
}
#[doc = "Registers storing factory TEMP module linearization coefficients."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Temp {
ptr: *mut u8,
}
unsafe impl Send for Temp {}
unsafe impl Sync for Temp {}
impl Temp {
#[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 = "Slope definition A0."]
#[inline(always)]
pub const fn a0(self) -> crate::common::Reg<regs::A0, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Slope definition A1."]
#[inline(always)]
pub const fn a1(self) -> crate::common::Reg<regs::A1, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Slope definition A2."]
#[inline(always)]
pub const fn a2(self) -> crate::common::Reg<regs::A2, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
#[doc = "Slope definition A3."]
#[inline(always)]
pub const fn a3(self) -> crate::common::Reg<regs::A3, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0cusize) as _) }
}
#[doc = "Slope definition A4."]
#[inline(always)]
pub const fn a4(self) -> crate::common::Reg<regs::A4, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x10usize) as _) }
}
#[doc = "Slope definition A5."]
#[inline(always)]
pub const fn a5(self) -> crate::common::Reg<regs::A5, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x14usize) as _) }
}
#[doc = "Y-intercept B0."]
#[inline(always)]
pub const fn b0(self) -> crate::common::Reg<regs::B0, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x18usize) as _) }
}
#[doc = "Y-intercept B1."]
#[inline(always)]
pub const fn b1(self) -> crate::common::Reg<regs::B1, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x1cusize) as _) }
}
#[doc = "Y-intercept B2."]
#[inline(always)]
pub const fn b2(self) -> crate::common::Reg<regs::B2, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x20usize) as _) }
}
#[doc = "Y-intercept B3."]
#[inline(always)]
pub const fn b3(self) -> crate::common::Reg<regs::B3, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x24usize) as _) }
}
#[doc = "Y-intercept B4."]
#[inline(always)]
pub const fn b4(self) -> crate::common::Reg<regs::B4, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x28usize) as _) }
}
#[doc = "Y-intercept B5."]
#[inline(always)]
pub const fn b5(self) -> crate::common::Reg<regs::B5, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x2cusize) as _) }
}
#[doc = "Segment end T0."]
#[inline(always)]
pub const fn t0(self) -> crate::common::Reg<regs::T0, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x30usize) as _) }
}
#[doc = "Segment end T1."]
#[inline(always)]
pub const fn t1(self) -> crate::common::Reg<regs::T1, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x34usize) as _) }
}
#[doc = "Segment end T2."]
#[inline(always)]
pub const fn t2(self) -> crate::common::Reg<regs::T2, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x38usize) as _) }
}
#[doc = "Segment end T3."]
#[inline(always)]
pub const fn t3(self) -> crate::common::Reg<regs::T3, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x3cusize) as _) }
}
#[doc = "Segment end T4."]
#[inline(always)]
pub const fn t4(self) -> crate::common::Reg<regs::T4, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x40usize) as _) }
}
}
pub mod regs {
#[doc = "Slope definition A0."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct A0(pub u32);
impl A0 {
#[doc = "A (slope definition) register."]
#[must_use]
#[inline(always)]
pub const fn a(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x0fff;
val as u16
}
#[doc = "A (slope definition) register."]
#[inline(always)]
pub const fn set_a(&mut self, val: u16) {
self.0 = (self.0 & !(0x0fff << 0usize)) | (((val as u32) & 0x0fff) << 0usize);
}
}
impl Default for A0 {
#[inline(always)]
fn default() -> A0 {
A0(0)
}
}
impl core::fmt::Debug for A0 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("A0").field("a", &self.a()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for A0 {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "A0 {{ a: {=u16:?} }}", self.a())
}
}
#[doc = "Slope definition A1."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct A1(pub u32);
impl A1 {
#[doc = "A (slope definition) register."]
#[must_use]
#[inline(always)]
pub const fn a(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x0fff;
val as u16
}
#[doc = "A (slope definition) register."]
#[inline(always)]
pub const fn set_a(&mut self, val: u16) {
self.0 = (self.0 & !(0x0fff << 0usize)) | (((val as u32) & 0x0fff) << 0usize);
}
}
impl Default for A1 {
#[inline(always)]
fn default() -> A1 {
A1(0)
}
}
impl core::fmt::Debug for A1 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("A1").field("a", &self.a()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for A1 {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "A1 {{ a: {=u16:?} }}", self.a())
}
}
#[doc = "Slope definition A2."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct A2(pub u32);
impl A2 {
#[doc = "A (slope definition) register."]
#[must_use]
#[inline(always)]
pub const fn a(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x0fff;
val as u16
}
#[doc = "A (slope definition) register."]
#[inline(always)]
pub const fn set_a(&mut self, val: u16) {
self.0 = (self.0 & !(0x0fff << 0usize)) | (((val as u32) & 0x0fff) << 0usize);
}
}
impl Default for A2 {
#[inline(always)]
fn default() -> A2 {
A2(0)
}
}
impl core::fmt::Debug for A2 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("A2").field("a", &self.a()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for A2 {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "A2 {{ a: {=u16:?} }}", self.a())
}
}
#[doc = "Slope definition A3."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct A3(pub u32);
impl A3 {
#[doc = "A (slope definition) register."]
#[must_use]
#[inline(always)]
pub const fn a(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x0fff;
val as u16
}
#[doc = "A (slope definition) register."]
#[inline(always)]
pub const fn set_a(&mut self, val: u16) {
self.0 = (self.0 & !(0x0fff << 0usize)) | (((val as u32) & 0x0fff) << 0usize);
}
}
impl Default for A3 {
#[inline(always)]
fn default() -> A3 {
A3(0)
}
}
impl core::fmt::Debug for A3 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("A3").field("a", &self.a()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for A3 {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "A3 {{ a: {=u16:?} }}", self.a())
}
}
#[doc = "Slope definition A4."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct A4(pub u32);
impl A4 {
#[doc = "A (slope definition) register."]
#[must_use]
#[inline(always)]
pub const fn a(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x0fff;
val as u16
}
#[doc = "A (slope definition) register."]
#[inline(always)]
pub const fn set_a(&mut self, val: u16) {
self.0 = (self.0 & !(0x0fff << 0usize)) | (((val as u32) & 0x0fff) << 0usize);
}
}
impl Default for A4 {
#[inline(always)]
fn default() -> A4 {
A4(0)
}
}
impl core::fmt::Debug for A4 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("A4").field("a", &self.a()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for A4 {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "A4 {{ a: {=u16:?} }}", self.a())
}
}
#[doc = "Slope definition A5."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct A5(pub u32);
impl A5 {
#[doc = "A (slope definition) register."]
#[must_use]
#[inline(always)]
pub const fn a(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x0fff;
val as u16
}
#[doc = "A (slope definition) register."]
#[inline(always)]
pub const fn set_a(&mut self, val: u16) {
self.0 = (self.0 & !(0x0fff << 0usize)) | (((val as u32) & 0x0fff) << 0usize);
}
}
impl Default for A5 {
#[inline(always)]
fn default() -> A5 {
A5(0)
}
}
impl core::fmt::Debug for A5 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("A5").field("a", &self.a()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for A5 {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "A5 {{ a: {=u16:?} }}", self.a())
}
}
#[doc = "Y-intercept B0."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct B0(pub u32);
impl B0 {
#[doc = "B (y-intercept)."]
#[must_use]
#[inline(always)]
pub const fn b(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x3fff;
val as u16
}
#[doc = "B (y-intercept)."]
#[inline(always)]
pub const fn set_b(&mut self, val: u16) {
self.0 = (self.0 & !(0x3fff << 0usize)) | (((val as u32) & 0x3fff) << 0usize);
}
}
impl Default for B0 {
#[inline(always)]
fn default() -> B0 {
B0(0)
}
}
impl core::fmt::Debug for B0 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("B0").field("b", &self.b()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for B0 {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "B0 {{ b: {=u16:?} }}", self.b())
}
}
#[doc = "Y-intercept B1."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct B1(pub u32);
impl B1 {
#[doc = "B (y-intercept)."]
#[must_use]
#[inline(always)]
pub const fn b(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x3fff;
val as u16
}
#[doc = "B (y-intercept)."]
#[inline(always)]
pub const fn set_b(&mut self, val: u16) {
self.0 = (self.0 & !(0x3fff << 0usize)) | (((val as u32) & 0x3fff) << 0usize);
}
}
impl Default for B1 {
#[inline(always)]
fn default() -> B1 {
B1(0)
}
}
impl core::fmt::Debug for B1 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("B1").field("b", &self.b()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for B1 {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "B1 {{ b: {=u16:?} }}", self.b())
}
}
#[doc = "Y-intercept B2."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct B2(pub u32);
impl B2 {
#[doc = "B (y-intercept)."]
#[must_use]
#[inline(always)]
pub const fn b(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x3fff;
val as u16
}
#[doc = "B (y-intercept)."]
#[inline(always)]
pub const fn set_b(&mut self, val: u16) {
self.0 = (self.0 & !(0x3fff << 0usize)) | (((val as u32) & 0x3fff) << 0usize);
}
}
impl Default for B2 {
#[inline(always)]
fn default() -> B2 {
B2(0)
}
}
impl core::fmt::Debug for B2 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("B2").field("b", &self.b()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for B2 {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "B2 {{ b: {=u16:?} }}", self.b())
}
}
#[doc = "Y-intercept B3."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct B3(pub u32);
impl B3 {
#[doc = "B (y-intercept)."]
#[must_use]
#[inline(always)]
pub const fn b(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x3fff;
val as u16
}
#[doc = "B (y-intercept)."]
#[inline(always)]
pub const fn set_b(&mut self, val: u16) {
self.0 = (self.0 & !(0x3fff << 0usize)) | (((val as u32) & 0x3fff) << 0usize);
}
}
impl Default for B3 {
#[inline(always)]
fn default() -> B3 {
B3(0)
}
}
impl core::fmt::Debug for B3 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("B3").field("b", &self.b()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for B3 {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "B3 {{ b: {=u16:?} }}", self.b())
}
}
#[doc = "Y-intercept B4."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct B4(pub u32);
impl B4 {
#[doc = "B (y-intercept)."]
#[must_use]
#[inline(always)]
pub const fn b(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x3fff;
val as u16
}
#[doc = "B (y-intercept)."]
#[inline(always)]
pub const fn set_b(&mut self, val: u16) {
self.0 = (self.0 & !(0x3fff << 0usize)) | (((val as u32) & 0x3fff) << 0usize);
}
}
impl Default for B4 {
#[inline(always)]
fn default() -> B4 {
B4(0)
}
}
impl core::fmt::Debug for B4 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("B4").field("b", &self.b()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for B4 {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "B4 {{ b: {=u16:?} }}", self.b())
}
}
#[doc = "Y-intercept B5."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct B5(pub u32);
impl B5 {
#[doc = "B (y-intercept)."]
#[must_use]
#[inline(always)]
pub const fn b(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x3fff;
val as u16
}
#[doc = "B (y-intercept)."]
#[inline(always)]
pub const fn set_b(&mut self, val: u16) {
self.0 = (self.0 & !(0x3fff << 0usize)) | (((val as u32) & 0x3fff) << 0usize);
}
}
impl Default for B5 {
#[inline(always)]
fn default() -> B5 {
B5(0)
}
}
impl core::fmt::Debug for B5 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("B5").field("b", &self.b()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for B5 {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "B5 {{ b: {=u16:?} }}", self.b())
}
}
#[doc = "Device address type."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Deviceaddrtype(pub u32);
impl Deviceaddrtype {
#[doc = "Device address type."]
#[must_use]
#[inline(always)]
pub const fn deviceaddrtype(&self) -> super::vals::Deviceaddrtype {
let val = (self.0 >> 0usize) & 0x01;
super::vals::Deviceaddrtype::from_bits(val as u8)
}
#[doc = "Device address type."]
#[inline(always)]
pub const fn set_deviceaddrtype(&mut self, val: super::vals::Deviceaddrtype) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
}
impl Default for Deviceaddrtype {
#[inline(always)]
fn default() -> Deviceaddrtype {
Deviceaddrtype(0)
}
}
impl core::fmt::Debug for Deviceaddrtype {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Deviceaddrtype")
.field("deviceaddrtype", &self.deviceaddrtype())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Deviceaddrtype {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Deviceaddrtype {{ deviceaddrtype: {:?} }}",
self.deviceaddrtype()
)
}
}
#[doc = "Flash variant."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Flash(pub u32);
impl Flash {
#[doc = "Flash variant."]
#[must_use]
#[inline(always)]
pub const fn flash(&self) -> super::vals::Flash {
let val = (self.0 >> 0usize) & 0xffff_ffff;
super::vals::Flash::from_bits(val as u32)
}
#[doc = "Flash variant."]
#[inline(always)]
pub const fn set_flash(&mut self, val: super::vals::Flash) {
self.0 = (self.0 & !(0xffff_ffff << 0usize))
| (((val.to_bits() as u32) & 0xffff_ffff) << 0usize);
}
}
impl Default for Flash {
#[inline(always)]
fn default() -> Flash {
Flash(0)
}
}
impl core::fmt::Debug for Flash {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Flash")
.field("flash", &self.flash())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Flash {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Flash {{ flash: {:?} }}", self.flash())
}
}
#[doc = "Package option."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Package(pub u32);
impl Package {
#[doc = "Package option."]
#[must_use]
#[inline(always)]
pub const fn package(&self) -> super::vals::Package {
let val = (self.0 >> 0usize) & 0xffff_ffff;
super::vals::Package::from_bits(val as u32)
}
#[doc = "Package option."]
#[inline(always)]
pub const fn set_package(&mut self, val: super::vals::Package) {
self.0 = (self.0 & !(0xffff_ffff << 0usize))
| (((val.to_bits() as u32) & 0xffff_ffff) << 0usize);
}
}
impl Default for Package {
#[inline(always)]
fn default() -> Package {
Package(0)
}
}
impl core::fmt::Debug for Package {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Package")
.field("package", &self.package())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Package {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Package {{ package: {:?} }}", self.package())
}
}
#[doc = "Part code."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Part(pub u32);
impl Part {
#[doc = "Part code."]
#[must_use]
#[inline(always)]
pub const fn part(&self) -> super::vals::Part {
let val = (self.0 >> 0usize) & 0xffff_ffff;
super::vals::Part::from_bits(val as u32)
}
#[doc = "Part code."]
#[inline(always)]
pub const fn set_part(&mut self, val: super::vals::Part) {
self.0 = (self.0 & !(0xffff_ffff << 0usize))
| (((val.to_bits() as u32) & 0xffff_ffff) << 0usize);
}
}
impl Default for Part {
#[inline(always)]
fn default() -> Part {
Part(0)
}
}
impl core::fmt::Debug for Part {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Part").field("part", &self.part()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Part {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Part {{ part: {:?} }}", self.part())
}
}
#[doc = "Description collection: Production test signature n."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Prodtest(pub u32);
impl Prodtest {
#[doc = "Production test signature n."]
#[must_use]
#[inline(always)]
pub const fn prodtest(&self) -> super::vals::Prodtest {
let val = (self.0 >> 0usize) & 0xffff_ffff;
super::vals::Prodtest::from_bits(val as u32)
}
#[doc = "Production test signature n."]
#[inline(always)]
pub const fn set_prodtest(&mut self, val: super::vals::Prodtest) {
self.0 = (self.0 & !(0xffff_ffff << 0usize))
| (((val.to_bits() as u32) & 0xffff_ffff) << 0usize);
}
}
impl Default for Prodtest {
#[inline(always)]
fn default() -> Prodtest {
Prodtest(0)
}
}
impl core::fmt::Debug for Prodtest {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Prodtest")
.field("prodtest", &self.prodtest())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Prodtest {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Prodtest {{ prodtest: {:?} }}", self.prodtest())
}
}
#[doc = "RAM variant."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Ram(pub u32);
impl Ram {
#[doc = "RAM variant."]
#[must_use]
#[inline(always)]
pub const fn ram(&self) -> super::vals::Ram {
let val = (self.0 >> 0usize) & 0xffff_ffff;
super::vals::Ram::from_bits(val as u32)
}
#[doc = "RAM variant."]
#[inline(always)]
pub const fn set_ram(&mut self, val: super::vals::Ram) {
self.0 = (self.0 & !(0xffff_ffff << 0usize))
| (((val.to_bits() as u32) & 0xffff_ffff) << 0usize);
}
}
impl Default for Ram {
#[inline(always)]
fn default() -> Ram {
Ram(0)
}
}
impl core::fmt::Debug for Ram {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Ram").field("ram", &self.ram()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Ram {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Ram {{ ram: {:?} }}", self.ram())
}
}
#[doc = "Segment end T0."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct T0(pub u32);
impl T0 {
#[doc = "T (segment end) register."]
#[must_use]
#[inline(always)]
pub const fn t(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "T (segment end) register."]
#[inline(always)]
pub const fn set_t(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
}
impl Default for T0 {
#[inline(always)]
fn default() -> T0 {
T0(0)
}
}
impl core::fmt::Debug for T0 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("T0").field("t", &self.t()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for T0 {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "T0 {{ t: {=u8:?} }}", self.t())
}
}
#[doc = "Segment end T1."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct T1(pub u32);
impl T1 {
#[doc = "T (segment end) register."]
#[must_use]
#[inline(always)]
pub const fn t(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "T (segment end) register."]
#[inline(always)]
pub const fn set_t(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
}
impl Default for T1 {
#[inline(always)]
fn default() -> T1 {
T1(0)
}
}
impl core::fmt::Debug for T1 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("T1").field("t", &self.t()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for T1 {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "T1 {{ t: {=u8:?} }}", self.t())
}
}
#[doc = "Segment end T2."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct T2(pub u32);
impl T2 {
#[doc = "T (segment end) register."]
#[must_use]
#[inline(always)]
pub const fn t(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "T (segment end) register."]
#[inline(always)]
pub const fn set_t(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
}
impl Default for T2 {
#[inline(always)]
fn default() -> T2 {
T2(0)
}
}
impl core::fmt::Debug for T2 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("T2").field("t", &self.t()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for T2 {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "T2 {{ t: {=u8:?} }}", self.t())
}
}
#[doc = "Segment end T3."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct T3(pub u32);
impl T3 {
#[doc = "T (segment end) register."]
#[must_use]
#[inline(always)]
pub const fn t(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "T (segment end) register."]
#[inline(always)]
pub const fn set_t(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
}
impl Default for T3 {
#[inline(always)]
fn default() -> T3 {
T3(0)
}
}
impl core::fmt::Debug for T3 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("T3").field("t", &self.t()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for T3 {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "T3 {{ t: {=u8:?} }}", self.t())
}
}
#[doc = "Segment end T4."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct T4(pub u32);
impl T4 {
#[doc = "T (segment end) register."]
#[must_use]
#[inline(always)]
pub const fn t(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "T (segment end) register."]
#[inline(always)]
pub const fn set_t(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
}
impl Default for T4 {
#[inline(always)]
fn default() -> T4 {
T4(0)
}
}
impl core::fmt::Debug for T4 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("T4").field("t", &self.t()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for T4 {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "T4 {{ t: {=u8:?} }}", self.t())
}
}
#[doc = "Build code (hardware version and production configuration)."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Variant(pub u32);
impl Variant {
#[doc = "Build code (hardware version and production configuration). Encoded as ASCII."]
#[must_use]
#[inline(always)]
pub const fn variant(&self) -> super::vals::Variant {
let val = (self.0 >> 0usize) & 0xffff_ffff;
super::vals::Variant::from_bits(val as u32)
}
#[doc = "Build code (hardware version and production configuration). Encoded as ASCII."]
#[inline(always)]
pub const fn set_variant(&mut self, val: super::vals::Variant) {
self.0 = (self.0 & !(0xffff_ffff << 0usize))
| (((val.to_bits() as u32) & 0xffff_ffff) << 0usize);
}
}
impl Default for Variant {
#[inline(always)]
fn default() -> Variant {
Variant(0)
}
}
impl core::fmt::Debug for Variant {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Variant")
.field("variant", &self.variant())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Variant {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Variant {{ variant: {:?} }}", self.variant())
}
}
}
pub mod vals {
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Deviceaddrtype {
#[doc = "Public address."]
Public = 0x0,
#[doc = "Random address."]
Random = 0x01,
}
impl Deviceaddrtype {
#[inline(always)]
pub const fn from_bits(val: u8) -> Deviceaddrtype {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Deviceaddrtype {
#[inline(always)]
fn from(val: u8) -> Deviceaddrtype {
Deviceaddrtype::from_bits(val)
}
}
impl From<Deviceaddrtype> for u8 {
#[inline(always)]
fn from(val: Deviceaddrtype) -> u8 {
Deviceaddrtype::to_bits(val)
}
}
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct Flash(u32);
impl Flash {
#[doc = "128 kB FLASH."]
pub const K128: Self = Self(0x80);
#[doc = "256 kB FLASH."]
pub const K256: Self = Self(0x0100);
#[doc = "512 kB FLASH."]
pub const K512: Self = Self(0x0200);
#[doc = "1 MB FLASH."]
pub const K1024: Self = Self(0x0400);
#[doc = "2 MB FLASH."]
pub const K2048: Self = Self(0x0800);
#[doc = "Unspecified."]
pub const Unspecified: Self = Self(0xffff_ffff);
}
impl Flash {
pub const fn from_bits(val: u32) -> Flash {
Self(val & 0xffff_ffff)
}
pub const fn to_bits(self) -> u32 {
self.0
}
}
impl core::fmt::Debug for Flash {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self.0 {
0x80 => f.write_str("K128"),
0x0100 => f.write_str("K256"),
0x0200 => f.write_str("K512"),
0x0400 => f.write_str("K1024"),
0x0800 => f.write_str("K2048"),
0xffff_ffff => f.write_str("Unspecified"),
other => core::write!(f, "0x{:02X}", other),
}
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Flash {
fn format(&self, f: defmt::Formatter) {
match self.0 {
0x80 => defmt::write!(f, "K128"),
0x0100 => defmt::write!(f, "K256"),
0x0200 => defmt::write!(f, "K512"),
0x0400 => defmt::write!(f, "K1024"),
0x0800 => defmt::write!(f, "K2048"),
0xffff_ffff => defmt::write!(f, "Unspecified"),
other => defmt::write!(f, "0x{:02X}", other),
}
}
}
impl From<u32> for Flash {
#[inline(always)]
fn from(val: u32) -> Flash {
Flash::from_bits(val)
}
}
impl From<Flash> for u32 {
#[inline(always)]
fn from(val: Flash) -> u32 {
Flash::to_bits(val)
}
}
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct Package(u32);
impl Package {
#[doc = "QDxx - 5x5 40-pin QFN."]
pub const Qd: Self = Self(0x2007);
#[doc = "Unspecified."]
pub const Unspecified: Self = Self(0xffff_ffff);
}
impl Package {
pub const fn from_bits(val: u32) -> Package {
Self(val & 0xffff_ffff)
}
pub const fn to_bits(self) -> u32 {
self.0
}
}
impl core::fmt::Debug for Package {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self.0 {
0x2007 => f.write_str("Qd"),
0xffff_ffff => f.write_str("Unspecified"),
other => core::write!(f, "0x{:02X}", other),
}
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Package {
fn format(&self, f: defmt::Formatter) {
match self.0 {
0x2007 => defmt::write!(f, "Qd"),
0xffff_ffff => defmt::write!(f, "Unspecified"),
other => defmt::write!(f, "0x{:02X}", other),
}
}
}
impl From<u32> for Package {
#[inline(always)]
fn from(val: u32) -> Package {
Package::from_bits(val)
}
}
impl From<Package> for u32 {
#[inline(always)]
fn from(val: Package) -> u32 {
Package::to_bits(val)
}
}
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct Part(u32);
impl Part {
#[doc = "nRF52820."]
pub const N52820: Self = Self(0x0005_2820);
#[doc = "nRF52833."]
pub const N52833: Self = Self(0x0005_2833);
#[doc = "nRF52840."]
pub const N52840: Self = Self(0x0005_2840);
#[doc = "Unspecified."]
pub const Unspecified: Self = Self(0xffff_ffff);
}
impl Part {
pub const fn from_bits(val: u32) -> Part {
Self(val & 0xffff_ffff)
}
pub const fn to_bits(self) -> u32 {
self.0
}
}
impl core::fmt::Debug for Part {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self.0 {
0x0005_2820 => f.write_str("N52820"),
0x0005_2833 => f.write_str("N52833"),
0x0005_2840 => f.write_str("N52840"),
0xffff_ffff => f.write_str("Unspecified"),
other => core::write!(f, "0x{:02X}", other),
}
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Part {
fn format(&self, f: defmt::Formatter) {
match self.0 {
0x0005_2820 => defmt::write!(f, "N52820"),
0x0005_2833 => defmt::write!(f, "N52833"),
0x0005_2840 => defmt::write!(f, "N52840"),
0xffff_ffff => defmt::write!(f, "Unspecified"),
other => defmt::write!(f, "0x{:02X}", other),
}
}
}
impl From<u32> for Part {
#[inline(always)]
fn from(val: u32) -> Part {
Part::from_bits(val)
}
}
impl From<Part> for u32 {
#[inline(always)]
fn from(val: Part) -> u32 {
Part::to_bits(val)
}
}
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct Prodtest(u32);
impl Prodtest {
#[doc = "Production tests done."]
pub const Done: Self = Self(0xbb42_319f);
#[doc = "Production tests not done."]
pub const NotDone: Self = Self(0xffff_ffff);
}
impl Prodtest {
pub const fn from_bits(val: u32) -> Prodtest {
Self(val & 0xffff_ffff)
}
pub const fn to_bits(self) -> u32 {
self.0
}
}
impl core::fmt::Debug for Prodtest {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self.0 {
0xbb42_319f => f.write_str("Done"),
0xffff_ffff => f.write_str("NotDone"),
other => core::write!(f, "0x{:02X}", other),
}
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Prodtest {
fn format(&self, f: defmt::Formatter) {
match self.0 {
0xbb42_319f => defmt::write!(f, "Done"),
0xffff_ffff => defmt::write!(f, "NotDone"),
other => defmt::write!(f, "0x{:02X}", other),
}
}
}
impl From<u32> for Prodtest {
#[inline(always)]
fn from(val: u32) -> Prodtest {
Prodtest::from_bits(val)
}
}
impl From<Prodtest> for u32 {
#[inline(always)]
fn from(val: Prodtest) -> u32 {
Prodtest::to_bits(val)
}
}
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct Ram(u32);
impl Ram {
#[doc = "16 kB RAM."]
pub const K16: Self = Self(0x10);
#[doc = "32 kB RAM."]
pub const K32: Self = Self(0x20);
#[doc = "64 kB RAM."]
pub const K64: Self = Self(0x40);
#[doc = "128 kB RAM."]
pub const K128: Self = Self(0x80);
#[doc = "256 kB RAM."]
pub const K256: Self = Self(0x0100);
#[doc = "Unspecified."]
pub const Unspecified: Self = Self(0xffff_ffff);
}
impl Ram {
pub const fn from_bits(val: u32) -> Ram {
Self(val & 0xffff_ffff)
}
pub const fn to_bits(self) -> u32 {
self.0
}
}
impl core::fmt::Debug for Ram {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self.0 {
0x10 => f.write_str("K16"),
0x20 => f.write_str("K32"),
0x40 => f.write_str("K64"),
0x80 => f.write_str("K128"),
0x0100 => f.write_str("K256"),
0xffff_ffff => f.write_str("Unspecified"),
other => core::write!(f, "0x{:02X}", other),
}
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Ram {
fn format(&self, f: defmt::Formatter) {
match self.0 {
0x10 => defmt::write!(f, "K16"),
0x20 => defmt::write!(f, "K32"),
0x40 => defmt::write!(f, "K64"),
0x80 => defmt::write!(f, "K128"),
0x0100 => defmt::write!(f, "K256"),
0xffff_ffff => defmt::write!(f, "Unspecified"),
other => defmt::write!(f, "0x{:02X}", other),
}
}
}
impl From<u32> for Ram {
#[inline(always)]
fn from(val: u32) -> Ram {
Ram::from_bits(val)
}
}
impl From<Ram> for u32 {
#[inline(always)]
fn from(val: Ram) -> u32 {
Ram::to_bits(val)
}
}
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct Variant(u32);
impl Variant {
#[doc = "AAAA."]
pub const Aaaa: Self = Self(0x4141_4141);
#[doc = "AABC."]
pub const Aabc: Self = Self(0x4141_4243);
#[doc = "AAC0."]
pub const Aac0: Self = Self(0x4141_4330);
#[doc = "AAC1."]
pub const Aac1: Self = Self(0x4141_4331);
#[doc = "AAD0."]
pub const Aad0: Self = Self(0x4141_4430);
#[doc = "Unspecified."]
pub const Unspecified: Self = Self(0xffff_ffff);
}
impl Variant {
pub const fn from_bits(val: u32) -> Variant {
Self(val & 0xffff_ffff)
}
pub const fn to_bits(self) -> u32 {
self.0
}
}
impl core::fmt::Debug for Variant {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self.0 {
0x4141_4141 => f.write_str("Aaaa"),
0x4141_4243 => f.write_str("Aabc"),
0x4141_4330 => f.write_str("Aac0"),
0x4141_4331 => f.write_str("Aac1"),
0x4141_4430 => f.write_str("Aad0"),
0xffff_ffff => f.write_str("Unspecified"),
other => core::write!(f, "0x{:02X}", other),
}
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Variant {
fn format(&self, f: defmt::Formatter) {
match self.0 {
0x4141_4141 => defmt::write!(f, "Aaaa"),
0x4141_4243 => defmt::write!(f, "Aabc"),
0x4141_4330 => defmt::write!(f, "Aac0"),
0x4141_4331 => defmt::write!(f, "Aac1"),
0x4141_4430 => defmt::write!(f, "Aad0"),
0xffff_ffff => defmt::write!(f, "Unspecified"),
other => defmt::write!(f, "0x{:02X}", other),
}
}
}
impl From<u32> for Variant {
#[inline(always)]
fn from(val: u32) -> Variant {
Variant::from_bits(val)
}
}
impl From<Variant> for u32 {
#[inline(always)]
fn from(val: Variant) -> u32 {
Variant::to_bits(val)
}
}
}
}
pub mod gpio {
#[doc = "GPIO Port 1."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Gpio {
ptr: *mut u8,
}
unsafe impl Send for Gpio {}
unsafe impl Sync for Gpio {}
impl Gpio {
#[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 = "Write GPIO port."]
#[inline(always)]
pub const fn out(self) -> crate::common::Reg<regs::Out, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0504usize) as _) }
}
#[doc = "Set individual bits in GPIO port."]
#[inline(always)]
pub const fn outset(self) -> crate::common::Reg<regs::Outset, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0508usize) as _) }
}
#[doc = "Clear individual bits in GPIO port."]
#[inline(always)]
pub const fn outclr(self) -> crate::common::Reg<regs::Outclr, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x050cusize) as _) }
}
#[doc = "Read GPIO port."]
#[inline(always)]
pub const fn in_(self) -> crate::common::Reg<regs::In, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0510usize) as _) }
}
#[doc = "Direction of GPIO pins."]
#[inline(always)]
pub const fn dir(self) -> crate::common::Reg<regs::Dir, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0514usize) as _) }
}
#[doc = "DIR set register."]
#[inline(always)]
pub const fn dirset(self) -> crate::common::Reg<regs::Dirset, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0518usize) as _) }
}
#[doc = "DIR clear register."]
#[inline(always)]
pub const fn dirclr(self) -> crate::common::Reg<regs::Dirclr, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x051cusize) as _) }
}
#[doc = "Latch register indicating what GPIO pins that have met the criteria set in the PIN_CNF\\[n\\].SENSE registers."]
#[inline(always)]
pub const fn latch(self) -> crate::common::Reg<regs::Latch, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0520usize) as _) }
}
#[doc = "Select between default DETECT signal behavior and LDETECT mode."]
#[inline(always)]
pub const fn detectmode(self) -> crate::common::Reg<regs::Detectmode, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0524usize) as _) }
}
#[doc = "Description collection: Configuration of GPIO pins."]
#[inline(always)]
pub const fn pin_cnf(
self,
n: usize,
) -> crate::common::Reg<regs::PinCnf, crate::common::RW> {
assert!(n < 32usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0700usize + n * 4usize) as _)
}
}
}
pub mod regs {
#[doc = "Select between default DETECT signal behavior and LDETECT mode."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Detectmode(pub u32);
impl Detectmode {
#[doc = "Select between default DETECT signal behavior and LDETECT mode."]
#[must_use]
#[inline(always)]
pub const fn detectmode(&self) -> super::vals::Detectmode {
let val = (self.0 >> 0usize) & 0x01;
super::vals::Detectmode::from_bits(val as u8)
}
#[doc = "Select between default DETECT signal behavior and LDETECT mode."]
#[inline(always)]
pub const fn set_detectmode(&mut self, val: super::vals::Detectmode) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
}
impl Default for Detectmode {
#[inline(always)]
fn default() -> Detectmode {
Detectmode(0)
}
}
impl core::fmt::Debug for Detectmode {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Detectmode")
.field("detectmode", &self.detectmode())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Detectmode {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Detectmode {{ detectmode: {:?} }}", self.detectmode())
}
}
#[doc = "Direction of GPIO pins."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Dir(pub u32);
impl Dir {
#[doc = "Pin 0."]
#[must_use]
#[inline(always)]
pub const fn pin(&self, n: usize) -> super::vals::Dir {
assert!(n < 32usize);
let offs = 0usize + n * 1usize;
let val = (self.0 >> offs) & 0x01;
super::vals::Dir::from_bits(val as u8)
}
#[doc = "Pin 0."]
#[inline(always)]
pub const fn set_pin(&mut self, n: usize, val: super::vals::Dir) {
assert!(n < 32usize);
let offs = 0usize + n * 1usize;
self.0 = (self.0 & !(0x01 << offs)) | (((val.to_bits() as u32) & 0x01) << offs);
}
}
impl Default for Dir {
#[inline(always)]
fn default() -> Dir {
Dir(0)
}
}
impl core::fmt::Debug for Dir {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Dir")
.field("pin[0]", &self.pin(0usize))
.field("pin[1]", &self.pin(1usize))
.field("pin[2]", &self.pin(2usize))
.field("pin[3]", &self.pin(3usize))
.field("pin[4]", &self.pin(4usize))
.field("pin[5]", &self.pin(5usize))
.field("pin[6]", &self.pin(6usize))
.field("pin[7]", &self.pin(7usize))
.field("pin[8]", &self.pin(8usize))
.field("pin[9]", &self.pin(9usize))
.field("pin[10]", &self.pin(10usize))
.field("pin[11]", &self.pin(11usize))
.field("pin[12]", &self.pin(12usize))
.field("pin[13]", &self.pin(13usize))
.field("pin[14]", &self.pin(14usize))
.field("pin[15]", &self.pin(15usize))
.field("pin[16]", &self.pin(16usize))
.field("pin[17]", &self.pin(17usize))
.field("pin[18]", &self.pin(18usize))
.field("pin[19]", &self.pin(19usize))
.field("pin[20]", &self.pin(20usize))
.field("pin[21]", &self.pin(21usize))
.field("pin[22]", &self.pin(22usize))
.field("pin[23]", &self.pin(23usize))
.field("pin[24]", &self.pin(24usize))
.field("pin[25]", &self.pin(25usize))
.field("pin[26]", &self.pin(26usize))
.field("pin[27]", &self.pin(27usize))
.field("pin[28]", &self.pin(28usize))
.field("pin[29]", &self.pin(29usize))
.field("pin[30]", &self.pin(30usize))
.field("pin[31]", &self.pin(31usize))
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Dir {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Dir {{ pin[0]: {:?}, pin[1]: {:?}, pin[2]: {:?}, pin[3]: {:?}, pin[4]: {:?}, pin[5]: {:?}, pin[6]: {:?}, pin[7]: {:?}, pin[8]: {:?}, pin[9]: {:?}, pin[10]: {:?}, pin[11]: {:?}, pin[12]: {:?}, pin[13]: {:?}, pin[14]: {:?}, pin[15]: {:?}, pin[16]: {:?}, pin[17]: {:?}, pin[18]: {:?}, pin[19]: {:?}, pin[20]: {:?}, pin[21]: {:?}, pin[22]: {:?}, pin[23]: {:?}, pin[24]: {:?}, pin[25]: {:?}, pin[26]: {:?}, pin[27]: {:?}, pin[28]: {:?}, pin[29]: {:?}, pin[30]: {:?}, pin[31]: {:?} }}" , self . pin (0usize) , self . pin (1usize) , self . pin (2usize) , self . pin (3usize) , self . pin (4usize) , self . pin (5usize) , self . pin (6usize) , self . pin (7usize) , self . pin (8usize) , self . pin (9usize) , self . pin (10usize) , self . pin (11usize) , self . pin (12usize) , self . pin (13usize) , self . pin (14usize) , self . pin (15usize) , self . pin (16usize) , self . pin (17usize) , self . pin (18usize) , self . pin (19usize) , self . pin (20usize) , self . pin (21usize) , self . pin (22usize) , self . pin (23usize) , self . pin (24usize) , self . pin (25usize) , self . pin (26usize) , self . pin (27usize) , self . pin (28usize) , self . pin (29usize) , self . pin (30usize) , self . pin (31usize))
}
}
#[doc = "DIR clear register."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Dirclr(pub u32);
impl Dirclr {
#[doc = "Set as input pin 0."]
#[must_use]
#[inline(always)]
pub const fn pin(&self, n: usize) -> bool {
assert!(n < 32usize);
let offs = 0usize + n * 1usize;
let val = (self.0 >> offs) & 0x01;
val != 0
}
#[doc = "Set as input pin 0."]
#[inline(always)]
pub const fn set_pin(&mut self, n: usize, val: bool) {
assert!(n < 32usize);
let offs = 0usize + n * 1usize;
self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
}
}
impl Default for Dirclr {
#[inline(always)]
fn default() -> Dirclr {
Dirclr(0)
}
}
impl core::fmt::Debug for Dirclr {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Dirclr")
.field("pin[0]", &self.pin(0usize))
.field("pin[1]", &self.pin(1usize))
.field("pin[2]", &self.pin(2usize))
.field("pin[3]", &self.pin(3usize))
.field("pin[4]", &self.pin(4usize))
.field("pin[5]", &self.pin(5usize))
.field("pin[6]", &self.pin(6usize))
.field("pin[7]", &self.pin(7usize))
.field("pin[8]", &self.pin(8usize))
.field("pin[9]", &self.pin(9usize))
.field("pin[10]", &self.pin(10usize))
.field("pin[11]", &self.pin(11usize))
.field("pin[12]", &self.pin(12usize))
.field("pin[13]", &self.pin(13usize))
.field("pin[14]", &self.pin(14usize))
.field("pin[15]", &self.pin(15usize))
.field("pin[16]", &self.pin(16usize))
.field("pin[17]", &self.pin(17usize))
.field("pin[18]", &self.pin(18usize))
.field("pin[19]", &self.pin(19usize))
.field("pin[20]", &self.pin(20usize))
.field("pin[21]", &self.pin(21usize))
.field("pin[22]", &self.pin(22usize))
.field("pin[23]", &self.pin(23usize))
.field("pin[24]", &self.pin(24usize))
.field("pin[25]", &self.pin(25usize))
.field("pin[26]", &self.pin(26usize))
.field("pin[27]", &self.pin(27usize))
.field("pin[28]", &self.pin(28usize))
.field("pin[29]", &self.pin(29usize))
.field("pin[30]", &self.pin(30usize))
.field("pin[31]", &self.pin(31usize))
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Dirclr {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Dirclr {{ pin[0]: {=bool:?}, pin[1]: {=bool:?}, pin[2]: {=bool:?}, pin[3]: {=bool:?}, pin[4]: {=bool:?}, pin[5]: {=bool:?}, pin[6]: {=bool:?}, pin[7]: {=bool:?}, pin[8]: {=bool:?}, pin[9]: {=bool:?}, pin[10]: {=bool:?}, pin[11]: {=bool:?}, pin[12]: {=bool:?}, pin[13]: {=bool:?}, pin[14]: {=bool:?}, pin[15]: {=bool:?}, pin[16]: {=bool:?}, pin[17]: {=bool:?}, pin[18]: {=bool:?}, pin[19]: {=bool:?}, pin[20]: {=bool:?}, pin[21]: {=bool:?}, pin[22]: {=bool:?}, pin[23]: {=bool:?}, pin[24]: {=bool:?}, pin[25]: {=bool:?}, pin[26]: {=bool:?}, pin[27]: {=bool:?}, pin[28]: {=bool:?}, pin[29]: {=bool:?}, pin[30]: {=bool:?}, pin[31]: {=bool:?} }}" , self . pin (0usize) , self . pin (1usize) , self . pin (2usize) , self . pin (3usize) , self . pin (4usize) , self . pin (5usize) , self . pin (6usize) , self . pin (7usize) , self . pin (8usize) , self . pin (9usize) , self . pin (10usize) , self . pin (11usize) , self . pin (12usize) , self . pin (13usize) , self . pin (14usize) , self . pin (15usize) , self . pin (16usize) , self . pin (17usize) , self . pin (18usize) , self . pin (19usize) , self . pin (20usize) , self . pin (21usize) , self . pin (22usize) , self . pin (23usize) , self . pin (24usize) , self . pin (25usize) , self . pin (26usize) , self . pin (27usize) , self . pin (28usize) , self . pin (29usize) , self . pin (30usize) , self . pin (31usize))
}
}
#[doc = "DIR set register."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Dirset(pub u32);
impl Dirset {
#[doc = "Set as output pin 0."]
#[must_use]
#[inline(always)]
pub const fn pin(&self, n: usize) -> bool {
assert!(n < 32usize);
let offs = 0usize + n * 1usize;
let val = (self.0 >> offs) & 0x01;
val != 0
}
#[doc = "Set as output pin 0."]
#[inline(always)]
pub const fn set_pin(&mut self, n: usize, val: bool) {
assert!(n < 32usize);
let offs = 0usize + n * 1usize;
self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
}
}
impl Default for Dirset {
#[inline(always)]
fn default() -> Dirset {
Dirset(0)
}
}
impl core::fmt::Debug for Dirset {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Dirset")
.field("pin[0]", &self.pin(0usize))
.field("pin[1]", &self.pin(1usize))
.field("pin[2]", &self.pin(2usize))
.field("pin[3]", &self.pin(3usize))
.field("pin[4]", &self.pin(4usize))
.field("pin[5]", &self.pin(5usize))
.field("pin[6]", &self.pin(6usize))
.field("pin[7]", &self.pin(7usize))
.field("pin[8]", &self.pin(8usize))
.field("pin[9]", &self.pin(9usize))
.field("pin[10]", &self.pin(10usize))
.field("pin[11]", &self.pin(11usize))
.field("pin[12]", &self.pin(12usize))
.field("pin[13]", &self.pin(13usize))
.field("pin[14]", &self.pin(14usize))
.field("pin[15]", &self.pin(15usize))
.field("pin[16]", &self.pin(16usize))
.field("pin[17]", &self.pin(17usize))
.field("pin[18]", &self.pin(18usize))
.field("pin[19]", &self.pin(19usize))
.field("pin[20]", &self.pin(20usize))
.field("pin[21]", &self.pin(21usize))
.field("pin[22]", &self.pin(22usize))
.field("pin[23]", &self.pin(23usize))
.field("pin[24]", &self.pin(24usize))
.field("pin[25]", &self.pin(25usize))
.field("pin[26]", &self.pin(26usize))
.field("pin[27]", &self.pin(27usize))
.field("pin[28]", &self.pin(28usize))
.field("pin[29]", &self.pin(29usize))
.field("pin[30]", &self.pin(30usize))
.field("pin[31]", &self.pin(31usize))
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Dirset {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Dirset {{ pin[0]: {=bool:?}, pin[1]: {=bool:?}, pin[2]: {=bool:?}, pin[3]: {=bool:?}, pin[4]: {=bool:?}, pin[5]: {=bool:?}, pin[6]: {=bool:?}, pin[7]: {=bool:?}, pin[8]: {=bool:?}, pin[9]: {=bool:?}, pin[10]: {=bool:?}, pin[11]: {=bool:?}, pin[12]: {=bool:?}, pin[13]: {=bool:?}, pin[14]: {=bool:?}, pin[15]: {=bool:?}, pin[16]: {=bool:?}, pin[17]: {=bool:?}, pin[18]: {=bool:?}, pin[19]: {=bool:?}, pin[20]: {=bool:?}, pin[21]: {=bool:?}, pin[22]: {=bool:?}, pin[23]: {=bool:?}, pin[24]: {=bool:?}, pin[25]: {=bool:?}, pin[26]: {=bool:?}, pin[27]: {=bool:?}, pin[28]: {=bool:?}, pin[29]: {=bool:?}, pin[30]: {=bool:?}, pin[31]: {=bool:?} }}" , self . pin (0usize) , self . pin (1usize) , self . pin (2usize) , self . pin (3usize) , self . pin (4usize) , self . pin (5usize) , self . pin (6usize) , self . pin (7usize) , self . pin (8usize) , self . pin (9usize) , self . pin (10usize) , self . pin (11usize) , self . pin (12usize) , self . pin (13usize) , self . pin (14usize) , self . pin (15usize) , self . pin (16usize) , self . pin (17usize) , self . pin (18usize) , self . pin (19usize) , self . pin (20usize) , self . pin (21usize) , self . pin (22usize) , self . pin (23usize) , self . pin (24usize) , self . pin (25usize) , self . pin (26usize) , self . pin (27usize) , self . pin (28usize) , self . pin (29usize) , self . pin (30usize) , self . pin (31usize))
}
}
#[doc = "Read GPIO port."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct In(pub u32);
impl In {
#[doc = "Pin 0."]
#[must_use]
#[inline(always)]
pub const fn pin(&self, n: usize) -> bool {
assert!(n < 32usize);
let offs = 0usize + n * 1usize;
let val = (self.0 >> offs) & 0x01;
val != 0
}
#[doc = "Pin 0."]
#[inline(always)]
pub const fn set_pin(&mut self, n: usize, val: bool) {
assert!(n < 32usize);
let offs = 0usize + n * 1usize;
self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
}
}
impl Default for In {
#[inline(always)]
fn default() -> In {
In(0)
}
}
impl core::fmt::Debug for In {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("In")
.field("pin[0]", &self.pin(0usize))
.field("pin[1]", &self.pin(1usize))
.field("pin[2]", &self.pin(2usize))
.field("pin[3]", &self.pin(3usize))
.field("pin[4]", &self.pin(4usize))
.field("pin[5]", &self.pin(5usize))
.field("pin[6]", &self.pin(6usize))
.field("pin[7]", &self.pin(7usize))
.field("pin[8]", &self.pin(8usize))
.field("pin[9]", &self.pin(9usize))
.field("pin[10]", &self.pin(10usize))
.field("pin[11]", &self.pin(11usize))
.field("pin[12]", &self.pin(12usize))
.field("pin[13]", &self.pin(13usize))
.field("pin[14]", &self.pin(14usize))
.field("pin[15]", &self.pin(15usize))
.field("pin[16]", &self.pin(16usize))
.field("pin[17]", &self.pin(17usize))
.field("pin[18]", &self.pin(18usize))
.field("pin[19]", &self.pin(19usize))
.field("pin[20]", &self.pin(20usize))
.field("pin[21]", &self.pin(21usize))
.field("pin[22]", &self.pin(22usize))
.field("pin[23]", &self.pin(23usize))
.field("pin[24]", &self.pin(24usize))
.field("pin[25]", &self.pin(25usize))
.field("pin[26]", &self.pin(26usize))
.field("pin[27]", &self.pin(27usize))
.field("pin[28]", &self.pin(28usize))
.field("pin[29]", &self.pin(29usize))
.field("pin[30]", &self.pin(30usize))
.field("pin[31]", &self.pin(31usize))
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for In {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "In {{ pin[0]: {=bool:?}, pin[1]: {=bool:?}, pin[2]: {=bool:?}, pin[3]: {=bool:?}, pin[4]: {=bool:?}, pin[5]: {=bool:?}, pin[6]: {=bool:?}, pin[7]: {=bool:?}, pin[8]: {=bool:?}, pin[9]: {=bool:?}, pin[10]: {=bool:?}, pin[11]: {=bool:?}, pin[12]: {=bool:?}, pin[13]: {=bool:?}, pin[14]: {=bool:?}, pin[15]: {=bool:?}, pin[16]: {=bool:?}, pin[17]: {=bool:?}, pin[18]: {=bool:?}, pin[19]: {=bool:?}, pin[20]: {=bool:?}, pin[21]: {=bool:?}, pin[22]: {=bool:?}, pin[23]: {=bool:?}, pin[24]: {=bool:?}, pin[25]: {=bool:?}, pin[26]: {=bool:?}, pin[27]: {=bool:?}, pin[28]: {=bool:?}, pin[29]: {=bool:?}, pin[30]: {=bool:?}, pin[31]: {=bool:?} }}" , self . pin (0usize) , self . pin (1usize) , self . pin (2usize) , self . pin (3usize) , self . pin (4usize) , self . pin (5usize) , self . pin (6usize) , self . pin (7usize) , self . pin (8usize) , self . pin (9usize) , self . pin (10usize) , self . pin (11usize) , self . pin (12usize) , self . pin (13usize) , self . pin (14usize) , self . pin (15usize) , self . pin (16usize) , self . pin (17usize) , self . pin (18usize) , self . pin (19usize) , self . pin (20usize) , self . pin (21usize) , self . pin (22usize) , self . pin (23usize) , self . pin (24usize) , self . pin (25usize) , self . pin (26usize) , self . pin (27usize) , self . pin (28usize) , self . pin (29usize) , self . pin (30usize) , self . pin (31usize))
}
}
#[doc = "Latch register indicating what GPIO pins that have met the criteria set in the PIN_CNF\\[n\\].SENSE registers."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Latch(pub u32);
impl Latch {
#[doc = "Status on whether PIN0 has met criteria set in PIN_CNF0.SENSE register. Write '1' to clear."]
#[must_use]
#[inline(always)]
pub const fn pin(&self, n: usize) -> bool {
assert!(n < 32usize);
let offs = 0usize + n * 1usize;
let val = (self.0 >> offs) & 0x01;
val != 0
}
#[doc = "Status on whether PIN0 has met criteria set in PIN_CNF0.SENSE register. Write '1' to clear."]
#[inline(always)]
pub const fn set_pin(&mut self, n: usize, val: bool) {
assert!(n < 32usize);
let offs = 0usize + n * 1usize;
self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
}
}
impl Default for Latch {
#[inline(always)]
fn default() -> Latch {
Latch(0)
}
}
impl core::fmt::Debug for Latch {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Latch")
.field("pin[0]", &self.pin(0usize))
.field("pin[1]", &self.pin(1usize))
.field("pin[2]", &self.pin(2usize))
.field("pin[3]", &self.pin(3usize))
.field("pin[4]", &self.pin(4usize))
.field("pin[5]", &self.pin(5usize))
.field("pin[6]", &self.pin(6usize))
.field("pin[7]", &self.pin(7usize))
.field("pin[8]", &self.pin(8usize))
.field("pin[9]", &self.pin(9usize))
.field("pin[10]", &self.pin(10usize))
.field("pin[11]", &self.pin(11usize))
.field("pin[12]", &self.pin(12usize))
.field("pin[13]", &self.pin(13usize))
.field("pin[14]", &self.pin(14usize))
.field("pin[15]", &self.pin(15usize))
.field("pin[16]", &self.pin(16usize))
.field("pin[17]", &self.pin(17usize))
.field("pin[18]", &self.pin(18usize))
.field("pin[19]", &self.pin(19usize))
.field("pin[20]", &self.pin(20usize))
.field("pin[21]", &self.pin(21usize))
.field("pin[22]", &self.pin(22usize))
.field("pin[23]", &self.pin(23usize))
.field("pin[24]", &self.pin(24usize))
.field("pin[25]", &self.pin(25usize))
.field("pin[26]", &self.pin(26usize))
.field("pin[27]", &self.pin(27usize))
.field("pin[28]", &self.pin(28usize))
.field("pin[29]", &self.pin(29usize))
.field("pin[30]", &self.pin(30usize))
.field("pin[31]", &self.pin(31usize))
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Latch {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Latch {{ pin[0]: {=bool:?}, pin[1]: {=bool:?}, pin[2]: {=bool:?}, pin[3]: {=bool:?}, pin[4]: {=bool:?}, pin[5]: {=bool:?}, pin[6]: {=bool:?}, pin[7]: {=bool:?}, pin[8]: {=bool:?}, pin[9]: {=bool:?}, pin[10]: {=bool:?}, pin[11]: {=bool:?}, pin[12]: {=bool:?}, pin[13]: {=bool:?}, pin[14]: {=bool:?}, pin[15]: {=bool:?}, pin[16]: {=bool:?}, pin[17]: {=bool:?}, pin[18]: {=bool:?}, pin[19]: {=bool:?}, pin[20]: {=bool:?}, pin[21]: {=bool:?}, pin[22]: {=bool:?}, pin[23]: {=bool:?}, pin[24]: {=bool:?}, pin[25]: {=bool:?}, pin[26]: {=bool:?}, pin[27]: {=bool:?}, pin[28]: {=bool:?}, pin[29]: {=bool:?}, pin[30]: {=bool:?}, pin[31]: {=bool:?} }}" , self . pin (0usize) , self . pin (1usize) , self . pin (2usize) , self . pin (3usize) , self . pin (4usize) , self . pin (5usize) , self . pin (6usize) , self . pin (7usize) , self . pin (8usize) , self . pin (9usize) , self . pin (10usize) , self . pin (11usize) , self . pin (12usize) , self . pin (13usize) , self . pin (14usize) , self . pin (15usize) , self . pin (16usize) , self . pin (17usize) , self . pin (18usize) , self . pin (19usize) , self . pin (20usize) , self . pin (21usize) , self . pin (22usize) , self . pin (23usize) , self . pin (24usize) , self . pin (25usize) , self . pin (26usize) , self . pin (27usize) , self . pin (28usize) , self . pin (29usize) , self . pin (30usize) , self . pin (31usize))
}
}
#[doc = "Write GPIO port."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Out(pub u32);
impl Out {
#[doc = "Pin 0."]
#[must_use]
#[inline(always)]
pub const fn pin(&self, n: usize) -> bool {
assert!(n < 32usize);
let offs = 0usize + n * 1usize;
let val = (self.0 >> offs) & 0x01;
val != 0
}
#[doc = "Pin 0."]
#[inline(always)]
pub const fn set_pin(&mut self, n: usize, val: bool) {
assert!(n < 32usize);
let offs = 0usize + n * 1usize;
self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
}
}
impl Default for Out {
#[inline(always)]
fn default() -> Out {
Out(0)
}
}
impl core::fmt::Debug for Out {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Out")
.field("pin[0]", &self.pin(0usize))
.field("pin[1]", &self.pin(1usize))
.field("pin[2]", &self.pin(2usize))
.field("pin[3]", &self.pin(3usize))
.field("pin[4]", &self.pin(4usize))
.field("pin[5]", &self.pin(5usize))
.field("pin[6]", &self.pin(6usize))
.field("pin[7]", &self.pin(7usize))
.field("pin[8]", &self.pin(8usize))
.field("pin[9]", &self.pin(9usize))
.field("pin[10]", &self.pin(10usize))
.field("pin[11]", &self.pin(11usize))
.field("pin[12]", &self.pin(12usize))
.field("pin[13]", &self.pin(13usize))
.field("pin[14]", &self.pin(14usize))
.field("pin[15]", &self.pin(15usize))
.field("pin[16]", &self.pin(16usize))
.field("pin[17]", &self.pin(17usize))
.field("pin[18]", &self.pin(18usize))
.field("pin[19]", &self.pin(19usize))
.field("pin[20]", &self.pin(20usize))
.field("pin[21]", &self.pin(21usize))
.field("pin[22]", &self.pin(22usize))
.field("pin[23]", &self.pin(23usize))
.field("pin[24]", &self.pin(24usize))
.field("pin[25]", &self.pin(25usize))
.field("pin[26]", &self.pin(26usize))
.field("pin[27]", &self.pin(27usize))
.field("pin[28]", &self.pin(28usize))
.field("pin[29]", &self.pin(29usize))
.field("pin[30]", &self.pin(30usize))
.field("pin[31]", &self.pin(31usize))
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Out {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Out {{ pin[0]: {=bool:?}, pin[1]: {=bool:?}, pin[2]: {=bool:?}, pin[3]: {=bool:?}, pin[4]: {=bool:?}, pin[5]: {=bool:?}, pin[6]: {=bool:?}, pin[7]: {=bool:?}, pin[8]: {=bool:?}, pin[9]: {=bool:?}, pin[10]: {=bool:?}, pin[11]: {=bool:?}, pin[12]: {=bool:?}, pin[13]: {=bool:?}, pin[14]: {=bool:?}, pin[15]: {=bool:?}, pin[16]: {=bool:?}, pin[17]: {=bool:?}, pin[18]: {=bool:?}, pin[19]: {=bool:?}, pin[20]: {=bool:?}, pin[21]: {=bool:?}, pin[22]: {=bool:?}, pin[23]: {=bool:?}, pin[24]: {=bool:?}, pin[25]: {=bool:?}, pin[26]: {=bool:?}, pin[27]: {=bool:?}, pin[28]: {=bool:?}, pin[29]: {=bool:?}, pin[30]: {=bool:?}, pin[31]: {=bool:?} }}" , self . pin (0usize) , self . pin (1usize) , self . pin (2usize) , self . pin (3usize) , self . pin (4usize) , self . pin (5usize) , self . pin (6usize) , self . pin (7usize) , self . pin (8usize) , self . pin (9usize) , self . pin (10usize) , self . pin (11usize) , self . pin (12usize) , self . pin (13usize) , self . pin (14usize) , self . pin (15usize) , self . pin (16usize) , self . pin (17usize) , self . pin (18usize) , self . pin (19usize) , self . pin (20usize) , self . pin (21usize) , self . pin (22usize) , self . pin (23usize) , self . pin (24usize) , self . pin (25usize) , self . pin (26usize) , self . pin (27usize) , self . pin (28usize) , self . pin (29usize) , self . pin (30usize) , self . pin (31usize))
}
}
#[doc = "Clear individual bits in GPIO port."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Outclr(pub u32);
impl Outclr {
#[doc = "Pin 0."]
#[must_use]
#[inline(always)]
pub const fn pin(&self, n: usize) -> bool {
assert!(n < 32usize);
let offs = 0usize + n * 1usize;
let val = (self.0 >> offs) & 0x01;
val != 0
}
#[doc = "Pin 0."]
#[inline(always)]
pub const fn set_pin(&mut self, n: usize, val: bool) {
assert!(n < 32usize);
let offs = 0usize + n * 1usize;
self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
}
}
impl Default for Outclr {
#[inline(always)]
fn default() -> Outclr {
Outclr(0)
}
}
impl core::fmt::Debug for Outclr {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Outclr")
.field("pin[0]", &self.pin(0usize))
.field("pin[1]", &self.pin(1usize))
.field("pin[2]", &self.pin(2usize))
.field("pin[3]", &self.pin(3usize))
.field("pin[4]", &self.pin(4usize))
.field("pin[5]", &self.pin(5usize))
.field("pin[6]", &self.pin(6usize))
.field("pin[7]", &self.pin(7usize))
.field("pin[8]", &self.pin(8usize))
.field("pin[9]", &self.pin(9usize))
.field("pin[10]", &self.pin(10usize))
.field("pin[11]", &self.pin(11usize))
.field("pin[12]", &self.pin(12usize))
.field("pin[13]", &self.pin(13usize))
.field("pin[14]", &self.pin(14usize))
.field("pin[15]", &self.pin(15usize))
.field("pin[16]", &self.pin(16usize))
.field("pin[17]", &self.pin(17usize))
.field("pin[18]", &self.pin(18usize))
.field("pin[19]", &self.pin(19usize))
.field("pin[20]", &self.pin(20usize))
.field("pin[21]", &self.pin(21usize))
.field("pin[22]", &self.pin(22usize))
.field("pin[23]", &self.pin(23usize))
.field("pin[24]", &self.pin(24usize))
.field("pin[25]", &self.pin(25usize))
.field("pin[26]", &self.pin(26usize))
.field("pin[27]", &self.pin(27usize))
.field("pin[28]", &self.pin(28usize))
.field("pin[29]", &self.pin(29usize))
.field("pin[30]", &self.pin(30usize))
.field("pin[31]", &self.pin(31usize))
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Outclr {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Outclr {{ pin[0]: {=bool:?}, pin[1]: {=bool:?}, pin[2]: {=bool:?}, pin[3]: {=bool:?}, pin[4]: {=bool:?}, pin[5]: {=bool:?}, pin[6]: {=bool:?}, pin[7]: {=bool:?}, pin[8]: {=bool:?}, pin[9]: {=bool:?}, pin[10]: {=bool:?}, pin[11]: {=bool:?}, pin[12]: {=bool:?}, pin[13]: {=bool:?}, pin[14]: {=bool:?}, pin[15]: {=bool:?}, pin[16]: {=bool:?}, pin[17]: {=bool:?}, pin[18]: {=bool:?}, pin[19]: {=bool:?}, pin[20]: {=bool:?}, pin[21]: {=bool:?}, pin[22]: {=bool:?}, pin[23]: {=bool:?}, pin[24]: {=bool:?}, pin[25]: {=bool:?}, pin[26]: {=bool:?}, pin[27]: {=bool:?}, pin[28]: {=bool:?}, pin[29]: {=bool:?}, pin[30]: {=bool:?}, pin[31]: {=bool:?} }}" , self . pin (0usize) , self . pin (1usize) , self . pin (2usize) , self . pin (3usize) , self . pin (4usize) , self . pin (5usize) , self . pin (6usize) , self . pin (7usize) , self . pin (8usize) , self . pin (9usize) , self . pin (10usize) , self . pin (11usize) , self . pin (12usize) , self . pin (13usize) , self . pin (14usize) , self . pin (15usize) , self . pin (16usize) , self . pin (17usize) , self . pin (18usize) , self . pin (19usize) , self . pin (20usize) , self . pin (21usize) , self . pin (22usize) , self . pin (23usize) , self . pin (24usize) , self . pin (25usize) , self . pin (26usize) , self . pin (27usize) , self . pin (28usize) , self . pin (29usize) , self . pin (30usize) , self . pin (31usize))
}
}
#[doc = "Set individual bits in GPIO port."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Outset(pub u32);
impl Outset {
#[doc = "Pin 0."]
#[must_use]
#[inline(always)]
pub const fn pin(&self, n: usize) -> bool {
assert!(n < 32usize);
let offs = 0usize + n * 1usize;
let val = (self.0 >> offs) & 0x01;
val != 0
}
#[doc = "Pin 0."]
#[inline(always)]
pub const fn set_pin(&mut self, n: usize, val: bool) {
assert!(n < 32usize);
let offs = 0usize + n * 1usize;
self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
}
}
impl Default for Outset {
#[inline(always)]
fn default() -> Outset {
Outset(0)
}
}
impl core::fmt::Debug for Outset {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Outset")
.field("pin[0]", &self.pin(0usize))
.field("pin[1]", &self.pin(1usize))
.field("pin[2]", &self.pin(2usize))
.field("pin[3]", &self.pin(3usize))
.field("pin[4]", &self.pin(4usize))
.field("pin[5]", &self.pin(5usize))
.field("pin[6]", &self.pin(6usize))
.field("pin[7]", &self.pin(7usize))
.field("pin[8]", &self.pin(8usize))
.field("pin[9]", &self.pin(9usize))
.field("pin[10]", &self.pin(10usize))
.field("pin[11]", &self.pin(11usize))
.field("pin[12]", &self.pin(12usize))
.field("pin[13]", &self.pin(13usize))
.field("pin[14]", &self.pin(14usize))
.field("pin[15]", &self.pin(15usize))
.field("pin[16]", &self.pin(16usize))
.field("pin[17]", &self.pin(17usize))
.field("pin[18]", &self.pin(18usize))
.field("pin[19]", &self.pin(19usize))
.field("pin[20]", &self.pin(20usize))
.field("pin[21]", &self.pin(21usize))
.field("pin[22]", &self.pin(22usize))
.field("pin[23]", &self.pin(23usize))
.field("pin[24]", &self.pin(24usize))
.field("pin[25]", &self.pin(25usize))
.field("pin[26]", &self.pin(26usize))
.field("pin[27]", &self.pin(27usize))
.field("pin[28]", &self.pin(28usize))
.field("pin[29]", &self.pin(29usize))
.field("pin[30]", &self.pin(30usize))
.field("pin[31]", &self.pin(31usize))
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Outset {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Outset {{ pin[0]: {=bool:?}, pin[1]: {=bool:?}, pin[2]: {=bool:?}, pin[3]: {=bool:?}, pin[4]: {=bool:?}, pin[5]: {=bool:?}, pin[6]: {=bool:?}, pin[7]: {=bool:?}, pin[8]: {=bool:?}, pin[9]: {=bool:?}, pin[10]: {=bool:?}, pin[11]: {=bool:?}, pin[12]: {=bool:?}, pin[13]: {=bool:?}, pin[14]: {=bool:?}, pin[15]: {=bool:?}, pin[16]: {=bool:?}, pin[17]: {=bool:?}, pin[18]: {=bool:?}, pin[19]: {=bool:?}, pin[20]: {=bool:?}, pin[21]: {=bool:?}, pin[22]: {=bool:?}, pin[23]: {=bool:?}, pin[24]: {=bool:?}, pin[25]: {=bool:?}, pin[26]: {=bool:?}, pin[27]: {=bool:?}, pin[28]: {=bool:?}, pin[29]: {=bool:?}, pin[30]: {=bool:?}, pin[31]: {=bool:?} }}" , self . pin (0usize) , self . pin (1usize) , self . pin (2usize) , self . pin (3usize) , self . pin (4usize) , self . pin (5usize) , self . pin (6usize) , self . pin (7usize) , self . pin (8usize) , self . pin (9usize) , self . pin (10usize) , self . pin (11usize) , self . pin (12usize) , self . pin (13usize) , self . pin (14usize) , self . pin (15usize) , self . pin (16usize) , self . pin (17usize) , self . pin (18usize) , self . pin (19usize) , self . pin (20usize) , self . pin (21usize) , self . pin (22usize) , self . pin (23usize) , self . pin (24usize) , self . pin (25usize) , self . pin (26usize) , self . pin (27usize) , self . pin (28usize) , self . pin (29usize) , self . pin (30usize) , self . pin (31usize))
}
}
#[doc = "Description collection: Configuration of GPIO pins."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct PinCnf(pub u32);
impl PinCnf {
#[doc = "Pin direction. Same physical register as DIR register."]
#[must_use]
#[inline(always)]
pub const fn dir(&self) -> super::vals::Dir {
let val = (self.0 >> 0usize) & 0x01;
super::vals::Dir::from_bits(val as u8)
}
#[doc = "Pin direction. Same physical register as DIR register."]
#[inline(always)]
pub const fn set_dir(&mut self, val: super::vals::Dir) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
#[doc = "Connect or disconnect input buffer."]
#[must_use]
#[inline(always)]
pub const fn input(&self) -> super::vals::Input {
let val = (self.0 >> 1usize) & 0x01;
super::vals::Input::from_bits(val as u8)
}
#[doc = "Connect or disconnect input buffer."]
#[inline(always)]
pub const fn set_input(&mut self, val: super::vals::Input) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val.to_bits() as u32) & 0x01) << 1usize);
}
#[doc = "Pull configuration."]
#[must_use]
#[inline(always)]
pub const fn pull(&self) -> super::vals::Pull {
let val = (self.0 >> 2usize) & 0x03;
super::vals::Pull::from_bits(val as u8)
}
#[doc = "Pull configuration."]
#[inline(always)]
pub const fn set_pull(&mut self, val: super::vals::Pull) {
self.0 = (self.0 & !(0x03 << 2usize)) | (((val.to_bits() as u32) & 0x03) << 2usize);
}
#[doc = "Drive configuration."]
#[must_use]
#[inline(always)]
pub const fn drive(&self) -> super::vals::Drive {
let val = (self.0 >> 8usize) & 0x07;
super::vals::Drive::from_bits(val as u8)
}
#[doc = "Drive configuration."]
#[inline(always)]
pub const fn set_drive(&mut self, val: super::vals::Drive) {
self.0 = (self.0 & !(0x07 << 8usize)) | (((val.to_bits() as u32) & 0x07) << 8usize);
}
#[doc = "Pin sensing mechanism."]
#[must_use]
#[inline(always)]
pub const fn sense(&self) -> super::vals::Sense {
let val = (self.0 >> 16usize) & 0x03;
super::vals::Sense::from_bits(val as u8)
}
#[doc = "Pin sensing mechanism."]
#[inline(always)]
pub const fn set_sense(&mut self, val: super::vals::Sense) {
self.0 =
(self.0 & !(0x03 << 16usize)) | (((val.to_bits() as u32) & 0x03) << 16usize);
}
}
impl Default for PinCnf {
#[inline(always)]
fn default() -> PinCnf {
PinCnf(0)
}
}
impl core::fmt::Debug for PinCnf {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("PinCnf")
.field("dir", &self.dir())
.field("input", &self.input())
.field("pull", &self.pull())
.field("drive", &self.drive())
.field("sense", &self.sense())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for PinCnf {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"PinCnf {{ dir: {:?}, input: {:?}, pull: {:?}, drive: {:?}, sense: {:?} }}",
self.dir(),
self.input(),
self.pull(),
self.drive(),
self.sense()
)
}
}
}
pub mod vals {
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Detectmode {
#[doc = "DETECT directly connected to PIN DETECT signals."]
Default = 0x0,
#[doc = "Use the latched LDETECT behavior."]
Ldetect = 0x01,
}
impl Detectmode {
#[inline(always)]
pub const fn from_bits(val: u8) -> Detectmode {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Detectmode {
#[inline(always)]
fn from(val: u8) -> Detectmode {
Detectmode::from_bits(val)
}
}
impl From<Detectmode> for u8 {
#[inline(always)]
fn from(val: Detectmode) -> u8 {
Detectmode::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Dir {
#[doc = "Configure pin as an input pin."]
Input = 0x0,
#[doc = "Configure pin as an output pin."]
Output = 0x01,
}
impl Dir {
#[inline(always)]
pub const fn from_bits(val: u8) -> Dir {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Dir {
#[inline(always)]
fn from(val: u8) -> Dir {
Dir::from_bits(val)
}
}
impl From<Dir> for u8 {
#[inline(always)]
fn from(val: Dir) -> u8 {
Dir::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Drive {
#[doc = "Standard '0', standard '1'."]
S0s1 = 0x0,
#[doc = "High drive '0', standard '1'."]
H0s1 = 0x01,
#[doc = "Standard '0', high drive '1'."]
S0h1 = 0x02,
#[doc = "High drive '0', high 'drive '1''."]
H0h1 = 0x03,
#[doc = "Disconnect '0' standard '1' (normally used for wired-or connections)."]
D0s1 = 0x04,
#[doc = "Disconnect '0', high drive '1' (normally used for wired-or connections)."]
D0h1 = 0x05,
#[doc = "Standard '0'. disconnect '1' (normally used for wired-and connections)."]
S0d1 = 0x06,
#[doc = "High drive '0', disconnect '1' (normally used for wired-and connections)."]
H0d1 = 0x07,
}
impl Drive {
#[inline(always)]
pub const fn from_bits(val: u8) -> Drive {
unsafe { core::mem::transmute(val & 0x07) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Drive {
#[inline(always)]
fn from(val: u8) -> Drive {
Drive::from_bits(val)
}
}
impl From<Drive> for u8 {
#[inline(always)]
fn from(val: Drive) -> u8 {
Drive::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Input {
#[doc = "Connect input buffer."]
Connect = 0x0,
#[doc = "Disconnect input buffer."]
Disconnect = 0x01,
}
impl Input {
#[inline(always)]
pub const fn from_bits(val: u8) -> Input {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Input {
#[inline(always)]
fn from(val: u8) -> Input {
Input::from_bits(val)
}
}
impl From<Input> for u8 {
#[inline(always)]
fn from(val: Input) -> u8 {
Input::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Pull {
#[doc = "No pull."]
Disabled = 0x0,
#[doc = "Pull down on pin."]
Pulldown = 0x01,
_RESERVED_2 = 0x02,
#[doc = "Pull up on pin."]
Pullup = 0x03,
}
impl Pull {
#[inline(always)]
pub const fn from_bits(val: u8) -> Pull {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Pull {
#[inline(always)]
fn from(val: u8) -> Pull {
Pull::from_bits(val)
}
}
impl From<Pull> for u8 {
#[inline(always)]
fn from(val: Pull) -> u8 {
Pull::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Sense {
#[doc = "Disabled."]
Disabled = 0x0,
_RESERVED_1 = 0x01,
#[doc = "Sense for high level."]
High = 0x02,
#[doc = "Sense for low level."]
Low = 0x03,
}
impl Sense {
#[inline(always)]
pub const fn from_bits(val: u8) -> Sense {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Sense {
#[inline(always)]
fn from(val: u8) -> Sense {
Sense::from_bits(val)
}
}
impl From<Sense> for u8 {
#[inline(always)]
fn from(val: Sense) -> u8 {
Sense::to_bits(val)
}
}
}
}
pub mod gpiote {
#[doc = "GPIO Tasks and Events."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Gpiote {
ptr: *mut u8,
}
unsafe impl Send for Gpiote {}
unsafe impl Sync for Gpiote {}
impl Gpiote {
#[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 = "Description collection: Task for writing to pin specified in CONFIG\\[n\\].PSEL. Action on pin is configured in CONFIG\\[n\\].POLARITY."]
#[inline(always)]
pub const fn tasks_out(self, n: usize) -> crate::common::Reg<u32, crate::common::W> {
assert!(n < 8usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize + n * 4usize) as _)
}
}
#[doc = "Description collection: Task for writing to pin specified in CONFIG\\[n\\].PSEL. Action on pin is to set it high."]
#[inline(always)]
pub const fn tasks_set(self, n: usize) -> crate::common::Reg<u32, crate::common::W> {
assert!(n < 8usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x30usize + n * 4usize) as _)
}
}
#[doc = "Description collection: Task for writing to pin specified in CONFIG\\[n\\].PSEL. Action on pin is to set it low."]
#[inline(always)]
pub const fn tasks_clr(self, n: usize) -> crate::common::Reg<u32, crate::common::W> {
assert!(n < 8usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x60usize + n * 4usize) as _)
}
}
#[doc = "Description collection: Event generated from pin specified in CONFIG\\[n\\].PSEL."]
#[inline(always)]
pub const fn events_in(self, n: usize) -> crate::common::Reg<u32, crate::common::RW> {
assert!(n < 8usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0100usize + n * 4usize) as _)
}
}
#[doc = "Event generated from multiple input GPIO pins with SENSE mechanism enabled."]
#[inline(always)]
pub const fn events_port(self, n: usize) -> crate::common::Reg<u32, crate::common::RW> {
assert!(n < 1usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x017cusize + n * 0usize) as _)
}
}
#[doc = "Enable interrupt."]
#[inline(always)]
pub const fn intenset(self, n: usize) -> crate::common::Reg<regs::Int, crate::common::RW> {
assert!(n < 1usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0304usize + n * 0usize) as _)
}
}
#[doc = "Disable interrupt."]
#[inline(always)]
pub const fn intenclr(self, n: usize) -> crate::common::Reg<regs::Int, crate::common::RW> {
assert!(n < 1usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0308usize + n * 0usize) as _)
}
}
#[doc = "Description collection: Configuration for OUT\\[n\\], SET\\[n\\], and CLR\\[n\\] tasks and IN\\[n\\] event."]
#[inline(always)]
pub const fn config(self, n: usize) -> crate::common::Reg<regs::Config, crate::common::RW> {
assert!(n < 8usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0510usize + n * 4usize) as _)
}
}
}
pub mod regs {
#[doc = "Description collection: Configuration for OUT\\[n\\], SET\\[n\\], and CLR\\[n\\] tasks and IN\\[n\\] event."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Config(pub u32);
impl Config {
#[doc = "Mode."]
#[must_use]
#[inline(always)]
pub const fn mode(&self) -> super::vals::Mode {
let val = (self.0 >> 0usize) & 0x03;
super::vals::Mode::from_bits(val as u8)
}
#[doc = "Mode."]
#[inline(always)]
pub const fn set_mode(&mut self, val: super::vals::Mode) {
self.0 = (self.0 & !(0x03 << 0usize)) | (((val.to_bits() as u32) & 0x03) << 0usize);
}
#[doc = "GPIO number associated with SET\\[n\\], CLR\\[n\\], and OUT\\[n\\] tasks and IN\\[n\\] event."]
#[must_use]
#[inline(always)]
pub const fn psel(&self) -> u8 {
let val = (self.0 >> 8usize) & 0x1f;
val as u8
}
#[doc = "GPIO number associated with SET\\[n\\], CLR\\[n\\], and OUT\\[n\\] tasks and IN\\[n\\] event."]
#[inline(always)]
pub const fn set_psel(&mut self, val: u8) {
self.0 = (self.0 & !(0x1f << 8usize)) | (((val as u32) & 0x1f) << 8usize);
}
#[doc = "When In task mode: Operation to be performed on output when OUT\\[n\\] task is triggered. When In event mode: Operation on input that shall trigger IN\\[n\\] event."]
#[must_use]
#[inline(always)]
pub const fn polarity(&self) -> super::vals::Polarity {
let val = (self.0 >> 16usize) & 0x03;
super::vals::Polarity::from_bits(val as u8)
}
#[doc = "When In task mode: Operation to be performed on output when OUT\\[n\\] task is triggered. When In event mode: Operation on input that shall trigger IN\\[n\\] event."]
#[inline(always)]
pub const fn set_polarity(&mut self, val: super::vals::Polarity) {
self.0 =
(self.0 & !(0x03 << 16usize)) | (((val.to_bits() as u32) & 0x03) << 16usize);
}
#[doc = "When in task mode: Initial value of the output when the GPIOTE channel is configured. When in event mode: No effect."]
#[must_use]
#[inline(always)]
pub const fn outinit(&self) -> super::vals::Outinit {
let val = (self.0 >> 20usize) & 0x01;
super::vals::Outinit::from_bits(val as u8)
}
#[doc = "When in task mode: Initial value of the output when the GPIOTE channel is configured. When in event mode: No effect."]
#[inline(always)]
pub const fn set_outinit(&mut self, val: super::vals::Outinit) {
self.0 =
(self.0 & !(0x01 << 20usize)) | (((val.to_bits() as u32) & 0x01) << 20usize);
}
}
impl Default for Config {
#[inline(always)]
fn default() -> Config {
Config(0)
}
}
impl core::fmt::Debug for Config {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Config")
.field("mode", &self.mode())
.field("psel", &self.psel())
.field("polarity", &self.polarity())
.field("outinit", &self.outinit())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Config {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Config {{ mode: {:?}, psel: {=u8:?}, polarity: {:?}, outinit: {:?} }}",
self.mode(),
self.psel(),
self.polarity(),
self.outinit()
)
}
}
#[doc = "Disable interrupt."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Int(pub u32);
impl Int {
#[doc = "Write '1' to disable interrupt for event IN\\[0\\]."]
#[must_use]
#[inline(always)]
pub const fn in_(&self, n: usize) -> bool {
assert!(n < 8usize);
let offs = 0usize + n * 1usize;
let val = (self.0 >> offs) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event IN\\[0\\]."]
#[inline(always)]
pub const fn set_in_(&mut self, n: usize, val: bool) {
assert!(n < 8usize);
let offs = 0usize + n * 1usize;
self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
}
#[doc = "Write '1' to disable interrupt for event PORT."]
#[must_use]
#[inline(always)]
pub const fn port(&self) -> bool {
let val = (self.0 >> 31usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event PORT."]
#[inline(always)]
pub const fn set_port(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 31usize)) | (((val as u32) & 0x01) << 31usize);
}
}
impl Default for Int {
#[inline(always)]
fn default() -> Int {
Int(0)
}
}
impl core::fmt::Debug for Int {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Int")
.field("in_[0]", &self.in_(0usize))
.field("in_[1]", &self.in_(1usize))
.field("in_[2]", &self.in_(2usize))
.field("in_[3]", &self.in_(3usize))
.field("in_[4]", &self.in_(4usize))
.field("in_[5]", &self.in_(5usize))
.field("in_[6]", &self.in_(6usize))
.field("in_[7]", &self.in_(7usize))
.field("port", &self.port())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Int {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Int {{ in_[0]: {=bool:?}, in_[1]: {=bool:?}, in_[2]: {=bool:?}, in_[3]: {=bool:?}, in_[4]: {=bool:?}, in_[5]: {=bool:?}, in_[6]: {=bool:?}, in_[7]: {=bool:?}, port: {=bool:?} }}" , self . in_ (0usize) , self . in_ (1usize) , self . in_ (2usize) , self . in_ (3usize) , self . in_ (4usize) , self . in_ (5usize) , self . in_ (6usize) , self . in_ (7usize) , self . port ())
}
}
}
pub mod vals {
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Mode {
#[doc = "Disabled. Pin specified by PSEL will not be acquired by the GPIOTE module."]
Disabled = 0x0,
#[doc = "Event mode."]
Event = 0x01,
_RESERVED_2 = 0x02,
#[doc = "Task mode."]
Task = 0x03,
}
impl Mode {
#[inline(always)]
pub const fn from_bits(val: u8) -> Mode {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Mode {
#[inline(always)]
fn from(val: u8) -> Mode {
Mode::from_bits(val)
}
}
impl From<Mode> for u8 {
#[inline(always)]
fn from(val: Mode) -> u8 {
Mode::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Outinit {
#[doc = "Task mode: Initial value of pin before task triggering is low."]
Low = 0x0,
#[doc = "Task mode: Initial value of pin before task triggering is high."]
High = 0x01,
}
impl Outinit {
#[inline(always)]
pub const fn from_bits(val: u8) -> Outinit {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Outinit {
#[inline(always)]
fn from(val: u8) -> Outinit {
Outinit::from_bits(val)
}
}
impl From<Outinit> for u8 {
#[inline(always)]
fn from(val: Outinit) -> u8 {
Outinit::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Polarity {
#[doc = "Task mode: No effect on pin from OUT\\[n\\] task. Event mode: no IN\\[n\\] event generated on pin activity."]
None = 0x0,
#[doc = "Task mode: Set pin from OUT\\[n\\] task. Event mode: Generate IN\\[n\\] event when rising edge on pin."]
LoToHi = 0x01,
#[doc = "Task mode: Clear pin from OUT\\[n\\] task. Event mode: Generate IN\\[n\\] event when falling edge on pin."]
HiToLo = 0x02,
#[doc = "Task mode: Toggle pin from OUT\\[n\\]. Event mode: Generate IN\\[n\\] when any change on pin."]
Toggle = 0x03,
}
impl Polarity {
#[inline(always)]
pub const fn from_bits(val: u8) -> Polarity {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Polarity {
#[inline(always)]
fn from(val: u8) -> Polarity {
Polarity::from_bits(val)
}
}
impl From<Polarity> for u8 {
#[inline(always)]
fn from(val: Polarity) -> u8 {
Polarity::to_bits(val)
}
}
}
}
pub mod nvmc {
#[doc = "Non Volatile Memory Controller."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Nvmc {
ptr: *mut u8,
}
unsafe impl Send for Nvmc {}
unsafe impl Sync for Nvmc {}
impl Nvmc {
#[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 = "Ready flag."]
#[inline(always)]
pub const fn ready(self) -> crate::common::Reg<regs::Ready, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0400usize) as _) }
}
#[doc = "Ready flag."]
#[inline(always)]
pub const fn readynext(self) -> crate::common::Reg<regs::Readynext, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0408usize) as _) }
}
#[doc = "Configuration register."]
#[inline(always)]
pub const fn config(self) -> crate::common::Reg<regs::Config, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0504usize) as _) }
}
#[doc = "Register for erasing a page in code area."]
#[inline(always)]
pub const fn erasepage(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0508usize) as _) }
}
#[doc = "Deprecated register - Register for erasing a page in code area, equivalent to ERASEPAGE."]
#[inline(always)]
pub const fn erasepcr1(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0508usize) as _) }
}
#[doc = "Register for erasing all non-volatile user memory."]
#[inline(always)]
pub const fn eraseall(self) -> crate::common::Reg<regs::Eraseall, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x050cusize) as _) }
}
#[doc = "Deprecated register - Register for erasing a page in code area, equivalent to ERASEPAGE."]
#[inline(always)]
pub const fn erasepcr0(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0510usize) as _) }
}
#[doc = "Register for erasing user information configuration registers."]
#[inline(always)]
pub const fn eraseuicr(self) -> crate::common::Reg<regs::Eraseuicr, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0514usize) as _) }
}
#[doc = "Register for partial erase of a page in code area."]
#[inline(always)]
pub const fn erasepagepartial(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0518usize) as _) }
}
#[doc = "Register for partial erase configuration."]
#[inline(always)]
pub const fn erasepagepartialcfg(
self,
) -> crate::common::Reg<regs::Erasepagepartialcfg, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x051cusize) as _) }
}
}
pub mod regs {
#[doc = "Configuration register."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Config(pub u32);
impl Config {
#[doc = "Program memory access mode. It is strongly recommended to only activate erase and write modes when they are actively used."]
#[must_use]
#[inline(always)]
pub const fn wen(&self) -> super::vals::Wen {
let val = (self.0 >> 0usize) & 0x03;
super::vals::Wen::from_bits(val as u8)
}
#[doc = "Program memory access mode. It is strongly recommended to only activate erase and write modes when they are actively used."]
#[inline(always)]
pub const fn set_wen(&mut self, val: super::vals::Wen) {
self.0 = (self.0 & !(0x03 << 0usize)) | (((val.to_bits() as u32) & 0x03) << 0usize);
}
}
impl Default for Config {
#[inline(always)]
fn default() -> Config {
Config(0)
}
}
impl core::fmt::Debug for Config {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Config").field("wen", &self.wen()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Config {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Config {{ wen: {:?} }}", self.wen())
}
}
#[doc = "Register for erasing all non-volatile user memory."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Eraseall(pub u32);
impl Eraseall {
#[doc = "Erase all non-volatile memory including UICR registers. The erase must be enabled using CONFIG.WEN before the non-volatile memory can be erased."]
#[must_use]
#[inline(always)]
pub const fn eraseall(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Erase all non-volatile memory including UICR registers. The erase must be enabled using CONFIG.WEN before the non-volatile memory can be erased."]
#[inline(always)]
pub const fn set_eraseall(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for Eraseall {
#[inline(always)]
fn default() -> Eraseall {
Eraseall(0)
}
}
impl core::fmt::Debug for Eraseall {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Eraseall")
.field("eraseall", &self.eraseall())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Eraseall {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Eraseall {{ eraseall: {=bool:?} }}", self.eraseall())
}
}
#[doc = "Register for partial erase configuration."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Erasepagepartialcfg(pub u32);
impl Erasepagepartialcfg {
#[doc = "Duration of the partial erase in milliseconds."]
#[must_use]
#[inline(always)]
pub const fn duration(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x7f;
val as u8
}
#[doc = "Duration of the partial erase in milliseconds."]
#[inline(always)]
pub const fn set_duration(&mut self, val: u8) {
self.0 = (self.0 & !(0x7f << 0usize)) | (((val as u32) & 0x7f) << 0usize);
}
}
impl Default for Erasepagepartialcfg {
#[inline(always)]
fn default() -> Erasepagepartialcfg {
Erasepagepartialcfg(0)
}
}
impl core::fmt::Debug for Erasepagepartialcfg {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Erasepagepartialcfg")
.field("duration", &self.duration())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Erasepagepartialcfg {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Erasepagepartialcfg {{ duration: {=u8:?} }}",
self.duration()
)
}
}
#[doc = "Register for erasing user information configuration registers."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Eraseuicr(pub u32);
impl Eraseuicr {
#[doc = "Register starting erase of all user information configuration registers. The erase must be enabled using CONFIG.WEN before the UICR can be erased."]
#[must_use]
#[inline(always)]
pub const fn eraseuicr(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Register starting erase of all user information configuration registers. The erase must be enabled using CONFIG.WEN before the UICR can be erased."]
#[inline(always)]
pub const fn set_eraseuicr(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for Eraseuicr {
#[inline(always)]
fn default() -> Eraseuicr {
Eraseuicr(0)
}
}
impl core::fmt::Debug for Eraseuicr {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Eraseuicr")
.field("eraseuicr", &self.eraseuicr())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Eraseuicr {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Eraseuicr {{ eraseuicr: {=bool:?} }}", self.eraseuicr())
}
}
#[doc = "Ready flag."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Ready(pub u32);
impl Ready {
#[doc = "NVMC is ready or busy."]
#[must_use]
#[inline(always)]
pub const fn ready(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "NVMC is ready or busy."]
#[inline(always)]
pub const fn set_ready(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for Ready {
#[inline(always)]
fn default() -> Ready {
Ready(0)
}
}
impl core::fmt::Debug for Ready {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Ready")
.field("ready", &self.ready())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Ready {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Ready {{ ready: {=bool:?} }}", self.ready())
}
}
#[doc = "Ready flag."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Readynext(pub u32);
impl Readynext {
#[doc = "NVMC can accept a new write operation."]
#[must_use]
#[inline(always)]
pub const fn readynext(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "NVMC can accept a new write operation."]
#[inline(always)]
pub const fn set_readynext(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for Readynext {
#[inline(always)]
fn default() -> Readynext {
Readynext(0)
}
}
impl core::fmt::Debug for Readynext {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Readynext")
.field("readynext", &self.readynext())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Readynext {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Readynext {{ readynext: {=bool:?} }}", self.readynext())
}
}
}
pub mod vals {
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Wen {
#[doc = "Read only access."]
Ren = 0x0,
#[doc = "Write enabled."]
Wen = 0x01,
#[doc = "Erase enabled."]
Een = 0x02,
_RESERVED_3 = 0x03,
}
impl Wen {
#[inline(always)]
pub const fn from_bits(val: u8) -> Wen {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Wen {
#[inline(always)]
fn from(val: u8) -> Wen {
Wen::from_bits(val)
}
}
impl From<Wen> for u8 {
#[inline(always)]
fn from(val: Wen) -> u8 {
Wen::to_bits(val)
}
}
}
}
pub mod power {
#[doc = "Power control."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Power {
ptr: *mut u8,
}
unsafe impl Send for Power {}
unsafe impl Sync for Power {}
impl Power {
#[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 = "Enable Constant Latency mode."]
#[inline(always)]
pub const fn tasks_constlat(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x78usize) as _) }
}
#[doc = "Enable Low-power mode (variable latency)."]
#[inline(always)]
pub const fn tasks_lowpwr(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x7cusize) as _) }
}
#[doc = "Power failure warning."]
#[inline(always)]
pub const fn events_pofwarn(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0108usize) as _) }
}
#[doc = "CPU entered WFI/WFE sleep."]
#[inline(always)]
pub const fn events_sleepenter(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0114usize) as _) }
}
#[doc = "CPU exited WFI/WFE sleep."]
#[inline(always)]
pub const fn events_sleepexit(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0118usize) as _) }
}
#[doc = "Voltage supply detected on VBUS."]
#[inline(always)]
pub const fn events_usbdetected(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x011cusize) as _) }
}
#[doc = "Voltage supply removed from VBUS."]
#[inline(always)]
pub const fn events_usbremoved(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0120usize) as _) }
}
#[doc = "USB 3.3 V supply ready."]
#[inline(always)]
pub const fn events_usbpwrrdy(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0124usize) as _) }
}
#[doc = "Enable interrupt."]
#[inline(always)]
pub const fn intenset(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0304usize) as _) }
}
#[doc = "Disable interrupt."]
#[inline(always)]
pub const fn intenclr(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0308usize) as _) }
}
#[doc = "Reset reason."]
#[inline(always)]
pub const fn resetreas(self) -> crate::common::Reg<regs::Resetreas, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0400usize) as _) }
}
#[doc = "Deprecated register - RAM status register."]
#[inline(always)]
pub const fn ramstatus(self) -> crate::common::Reg<regs::Ramstatus, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0428usize) as _) }
}
#[doc = "USB supply status."]
#[inline(always)]
pub const fn usbregstatus(
self,
) -> crate::common::Reg<regs::Usbregstatus, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0438usize) as _) }
}
#[doc = "System OFF register."]
#[inline(always)]
pub const fn systemoff(self) -> crate::common::Reg<regs::Systemoff, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0500usize) as _) }
}
#[doc = "Power-fail comparator configuration."]
#[inline(always)]
pub const fn pofcon(self) -> crate::common::Reg<regs::Pofcon, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0510usize) as _) }
}
#[doc = "General purpose retention register."]
#[inline(always)]
pub const fn gpregret(self) -> crate::common::Reg<regs::Gpregret, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x051cusize) as _) }
}
#[doc = "General purpose retention register."]
#[inline(always)]
pub const fn gpregret2(self) -> crate::common::Reg<regs::Gpregret2, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0520usize) as _) }
}
#[doc = "Enable DC/DC converter for REG1 stage."]
#[inline(always)]
pub const fn dcdcen(self) -> crate::common::Reg<regs::Dcdcen, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0578usize) as _) }
}
#[doc = "Main supply status."]
#[inline(always)]
pub const fn mainregstatus(
self,
) -> crate::common::Reg<regs::Mainregstatus, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0640usize) as _) }
}
#[doc = "Unspecified."]
#[inline(always)]
pub const fn ram(self, n: usize) -> Ram {
assert!(n < 4usize);
unsafe { Ram::from_ptr(self.ptr.wrapping_add(0x0900usize + n * 16usize) as _) }
}
}
#[doc = "Unspecified."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Ram {
ptr: *mut u8,
}
unsafe impl Send for Ram {}
unsafe impl Sync for Ram {}
impl Ram {
#[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 = "Description cluster: RAMn power control register."]
#[inline(always)]
pub const fn power(self) -> crate::common::Reg<regs::Power, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Description cluster: RAMn power control set register."]
#[inline(always)]
pub const fn powerset(self) -> crate::common::Reg<regs::Power, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Description cluster: RAMn power control clear register."]
#[inline(always)]
pub const fn powerclr(self) -> crate::common::Reg<regs::Power, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
}
pub mod regs {
#[doc = "Enable DC/DC converter for REG1 stage."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Dcdcen(pub u32);
impl Dcdcen {
#[doc = "Enable DC/DC converter for REG1 stage."]
#[must_use]
#[inline(always)]
pub const fn dcdcen(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Enable DC/DC converter for REG1 stage."]
#[inline(always)]
pub const fn set_dcdcen(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for Dcdcen {
#[inline(always)]
fn default() -> Dcdcen {
Dcdcen(0)
}
}
impl core::fmt::Debug for Dcdcen {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Dcdcen")
.field("dcdcen", &self.dcdcen())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Dcdcen {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Dcdcen {{ dcdcen: {=bool:?} }}", self.dcdcen())
}
}
#[doc = "General purpose retention register."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Gpregret(pub u32);
impl Gpregret {
#[doc = "General purpose retention register."]
#[must_use]
#[inline(always)]
pub const fn gpregret(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "General purpose retention register."]
#[inline(always)]
pub const fn set_gpregret(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
}
impl Default for Gpregret {
#[inline(always)]
fn default() -> Gpregret {
Gpregret(0)
}
}
impl core::fmt::Debug for Gpregret {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Gpregret")
.field("gpregret", &self.gpregret())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Gpregret {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Gpregret {{ gpregret: {=u8:?} }}", self.gpregret())
}
}
#[doc = "General purpose retention register."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Gpregret2(pub u32);
impl Gpregret2 {
#[doc = "General purpose retention register."]
#[must_use]
#[inline(always)]
pub const fn gpregret(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "General purpose retention register."]
#[inline(always)]
pub const fn set_gpregret(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
}
impl Default for Gpregret2 {
#[inline(always)]
fn default() -> Gpregret2 {
Gpregret2(0)
}
}
impl core::fmt::Debug for Gpregret2 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Gpregret2")
.field("gpregret", &self.gpregret())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Gpregret2 {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Gpregret2 {{ gpregret: {=u8:?} }}", self.gpregret())
}
}
#[doc = "Disable interrupt."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Int(pub u32);
impl Int {
#[doc = "Write '1' to disable interrupt for event POFWARN."]
#[must_use]
#[inline(always)]
pub const fn pofwarn(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event POFWARN."]
#[inline(always)]
pub const fn set_pofwarn(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "Write '1' to disable interrupt for event SLEEPENTER."]
#[must_use]
#[inline(always)]
pub const fn sleepenter(&self) -> bool {
let val = (self.0 >> 5usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event SLEEPENTER."]
#[inline(always)]
pub const fn set_sleepenter(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
}
#[doc = "Write '1' to disable interrupt for event SLEEPEXIT."]
#[must_use]
#[inline(always)]
pub const fn sleepexit(&self) -> bool {
let val = (self.0 >> 6usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event SLEEPEXIT."]
#[inline(always)]
pub const fn set_sleepexit(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize);
}
#[doc = "Write '1' to disable interrupt for event USBDETECTED."]
#[must_use]
#[inline(always)]
pub const fn usbdetected(&self) -> bool {
let val = (self.0 >> 7usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event USBDETECTED."]
#[inline(always)]
pub const fn set_usbdetected(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize);
}
#[doc = "Write '1' to disable interrupt for event USBREMOVED."]
#[must_use]
#[inline(always)]
pub const fn usbremoved(&self) -> bool {
let val = (self.0 >> 8usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event USBREMOVED."]
#[inline(always)]
pub const fn set_usbremoved(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize);
}
#[doc = "Write '1' to disable interrupt for event USBPWRRDY."]
#[must_use]
#[inline(always)]
pub const fn usbpwrrdy(&self) -> bool {
let val = (self.0 >> 9usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event USBPWRRDY."]
#[inline(always)]
pub const fn set_usbpwrrdy(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 9usize)) | (((val as u32) & 0x01) << 9usize);
}
}
impl Default for Int {
#[inline(always)]
fn default() -> Int {
Int(0)
}
}
impl core::fmt::Debug for Int {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Int")
.field("pofwarn", &self.pofwarn())
.field("sleepenter", &self.sleepenter())
.field("sleepexit", &self.sleepexit())
.field("usbdetected", &self.usbdetected())
.field("usbremoved", &self.usbremoved())
.field("usbpwrrdy", &self.usbpwrrdy())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Int {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Int {{ pofwarn: {=bool:?}, sleepenter: {=bool:?}, sleepexit: {=bool:?}, usbdetected: {=bool:?}, usbremoved: {=bool:?}, usbpwrrdy: {=bool:?} }}" , self . pofwarn () , self . sleepenter () , self . sleepexit () , self . usbdetected () , self . usbremoved () , self . usbpwrrdy ())
}
}
#[doc = "Main supply status."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Mainregstatus(pub u32);
impl Mainregstatus {
#[doc = "Main supply status."]
#[must_use]
#[inline(always)]
pub const fn mainregstatus(&self) -> super::vals::Mainregstatus {
let val = (self.0 >> 0usize) & 0x01;
super::vals::Mainregstatus::from_bits(val as u8)
}
#[doc = "Main supply status."]
#[inline(always)]
pub const fn set_mainregstatus(&mut self, val: super::vals::Mainregstatus) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
}
impl Default for Mainregstatus {
#[inline(always)]
fn default() -> Mainregstatus {
Mainregstatus(0)
}
}
impl core::fmt::Debug for Mainregstatus {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Mainregstatus")
.field("mainregstatus", &self.mainregstatus())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Mainregstatus {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Mainregstatus {{ mainregstatus: {:?} }}",
self.mainregstatus()
)
}
}
#[doc = "Power-fail comparator configuration."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Pofcon(pub u32);
impl Pofcon {
#[doc = "Enable or disable power failure warning."]
#[must_use]
#[inline(always)]
pub const fn pof(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Enable or disable power failure warning."]
#[inline(always)]
pub const fn set_pof(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Power-fail comparator threshold setting. This setting applies both for normal voltage mode (supply connected to both VDD and VDDH) and high voltage mode (supply connected to VDDH only). Values 0-3 set threshold below 1.7 V and should not be used as brown out detection will be activated before power failure warning on such low voltages."]
#[must_use]
#[inline(always)]
pub const fn threshold(&self) -> super::vals::Threshold {
let val = (self.0 >> 1usize) & 0x0f;
super::vals::Threshold::from_bits(val as u8)
}
#[doc = "Power-fail comparator threshold setting. This setting applies both for normal voltage mode (supply connected to both VDD and VDDH) and high voltage mode (supply connected to VDDH only). Values 0-3 set threshold below 1.7 V and should not be used as brown out detection will be activated before power failure warning on such low voltages."]
#[inline(always)]
pub const fn set_threshold(&mut self, val: super::vals::Threshold) {
self.0 = (self.0 & !(0x0f << 1usize)) | (((val.to_bits() as u32) & 0x0f) << 1usize);
}
#[doc = "Power-fail comparator threshold setting for high voltage mode (supply connected to VDDH only). This setting does not apply for normal voltage mode (supply connected to both VDD and VDDH)."]
#[must_use]
#[inline(always)]
pub const fn thresholdvddh(&self) -> super::vals::Thresholdvddh {
let val = (self.0 >> 8usize) & 0x0f;
super::vals::Thresholdvddh::from_bits(val as u8)
}
#[doc = "Power-fail comparator threshold setting for high voltage mode (supply connected to VDDH only). This setting does not apply for normal voltage mode (supply connected to both VDD and VDDH)."]
#[inline(always)]
pub const fn set_thresholdvddh(&mut self, val: super::vals::Thresholdvddh) {
self.0 = (self.0 & !(0x0f << 8usize)) | (((val.to_bits() as u32) & 0x0f) << 8usize);
}
}
impl Default for Pofcon {
#[inline(always)]
fn default() -> Pofcon {
Pofcon(0)
}
}
impl core::fmt::Debug for Pofcon {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Pofcon")
.field("pof", &self.pof())
.field("threshold", &self.threshold())
.field("thresholdvddh", &self.thresholdvddh())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Pofcon {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Pofcon {{ pof: {=bool:?}, threshold: {:?}, thresholdvddh: {:?} }}",
self.pof(),
self.threshold(),
self.thresholdvddh()
)
}
}
#[doc = "Description cluster: RAMn power control register."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Power(pub u32);
impl Power {
#[doc = "Keep RAM section S0 on or off in System ON mode."]
#[must_use]
#[inline(always)]
pub const fn s_power(&self, n: usize) -> bool {
assert!(n < 2usize);
let offs = 0usize + n * 1usize;
let val = (self.0 >> offs) & 0x01;
val != 0
}
#[doc = "Keep RAM section S0 on or off in System ON mode."]
#[inline(always)]
pub const fn set_s_power(&mut self, n: usize, val: bool) {
assert!(n < 2usize);
let offs = 0usize + n * 1usize;
self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
}
#[doc = "Keep retention on RAM section S0 when RAM section is off."]
#[must_use]
#[inline(always)]
pub const fn s_retention(&self, n: usize) -> bool {
assert!(n < 2usize);
let offs = 16usize + n * 1usize;
let val = (self.0 >> offs) & 0x01;
val != 0
}
#[doc = "Keep retention on RAM section S0 when RAM section is off."]
#[inline(always)]
pub const fn set_s_retention(&mut self, n: usize, val: bool) {
assert!(n < 2usize);
let offs = 16usize + n * 1usize;
self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
}
}
impl Default for Power {
#[inline(always)]
fn default() -> Power {
Power(0)
}
}
impl core::fmt::Debug for Power {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Power")
.field("s_power[0]", &self.s_power(0usize))
.field("s_power[1]", &self.s_power(1usize))
.field("s_retention[0]", &self.s_retention(0usize))
.field("s_retention[1]", &self.s_retention(1usize))
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Power {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Power {{ s_power[0]: {=bool:?}, s_power[1]: {=bool:?}, s_retention[0]: {=bool:?}, s_retention[1]: {=bool:?} }}" , self . s_power (0usize) , self . s_power (1usize) , self . s_retention (0usize) , self . s_retention (1usize))
}
}
#[doc = "Deprecated register - RAM status register."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Ramstatus(pub u32);
impl Ramstatus {
#[doc = "RAM block 0 is on or off/powering up."]
#[must_use]
#[inline(always)]
pub const fn ramblock0(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "RAM block 0 is on or off/powering up."]
#[inline(always)]
pub const fn set_ramblock0(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "RAM block 1 is on or off/powering up."]
#[must_use]
#[inline(always)]
pub const fn ramblock1(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "RAM block 1 is on or off/powering up."]
#[inline(always)]
pub const fn set_ramblock1(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
}
impl Default for Ramstatus {
#[inline(always)]
fn default() -> Ramstatus {
Ramstatus(0)
}
}
impl core::fmt::Debug for Ramstatus {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Ramstatus")
.field("ramblock0", &self.ramblock0())
.field("ramblock1", &self.ramblock1())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Ramstatus {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Ramstatus {{ ramblock0: {=bool:?}, ramblock1: {=bool:?} }}",
self.ramblock0(),
self.ramblock1()
)
}
}
#[doc = "Reset reason."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Resetreas(pub u32);
impl Resetreas {
#[doc = "Reset from pin-reset detected."]
#[must_use]
#[inline(always)]
pub const fn resetpin(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Reset from pin-reset detected."]
#[inline(always)]
pub const fn set_resetpin(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Reset from watchdog detected."]
#[must_use]
#[inline(always)]
pub const fn dog(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Reset from watchdog detected."]
#[inline(always)]
pub const fn set_dog(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "Reset from soft reset detected."]
#[must_use]
#[inline(always)]
pub const fn sreq(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Reset from soft reset detected."]
#[inline(always)]
pub const fn set_sreq(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "Reset from CPU lock-up detected."]
#[must_use]
#[inline(always)]
pub const fn lockup(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "Reset from CPU lock-up detected."]
#[inline(always)]
pub const fn set_lockup(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
#[doc = "Reset due to wake up from System OFF mode when wakeup is triggered from DETECT signal from GPIO."]
#[must_use]
#[inline(always)]
pub const fn off(&self) -> bool {
let val = (self.0 >> 16usize) & 0x01;
val != 0
}
#[doc = "Reset due to wake up from System OFF mode when wakeup is triggered from DETECT signal from GPIO."]
#[inline(always)]
pub const fn set_off(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 16usize)) | (((val as u32) & 0x01) << 16usize);
}
#[doc = "Reset due to wake up from System OFF mode when wakeup is triggered from entering into debug interface mode."]
#[must_use]
#[inline(always)]
pub const fn dif(&self) -> bool {
let val = (self.0 >> 18usize) & 0x01;
val != 0
}
#[doc = "Reset due to wake up from System OFF mode when wakeup is triggered from entering into debug interface mode."]
#[inline(always)]
pub const fn set_dif(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 18usize)) | (((val as u32) & 0x01) << 18usize);
}
#[doc = "Reset due to wake up from System OFF mode by VBUS rising into valid range."]
#[must_use]
#[inline(always)]
pub const fn vbus(&self) -> bool {
let val = (self.0 >> 20usize) & 0x01;
val != 0
}
#[doc = "Reset due to wake up from System OFF mode by VBUS rising into valid range."]
#[inline(always)]
pub const fn set_vbus(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 20usize)) | (((val as u32) & 0x01) << 20usize);
}
}
impl Default for Resetreas {
#[inline(always)]
fn default() -> Resetreas {
Resetreas(0)
}
}
impl core::fmt::Debug for Resetreas {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Resetreas")
.field("resetpin", &self.resetpin())
.field("dog", &self.dog())
.field("sreq", &self.sreq())
.field("lockup", &self.lockup())
.field("off", &self.off())
.field("dif", &self.dif())
.field("vbus", &self.vbus())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Resetreas {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Resetreas {{ resetpin: {=bool:?}, dog: {=bool:?}, sreq: {=bool:?}, lockup: {=bool:?}, off: {=bool:?}, dif: {=bool:?}, vbus: {=bool:?} }}" , self . resetpin () , self . dog () , self . sreq () , self . lockup () , self . off () , self . dif () , self . vbus ())
}
}
#[doc = "System OFF register."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Systemoff(pub u32);
impl Systemoff {
#[doc = "Enable System OFF mode."]
#[must_use]
#[inline(always)]
pub const fn systemoff(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Enable System OFF mode."]
#[inline(always)]
pub const fn set_systemoff(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for Systemoff {
#[inline(always)]
fn default() -> Systemoff {
Systemoff(0)
}
}
impl core::fmt::Debug for Systemoff {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Systemoff")
.field("systemoff", &self.systemoff())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Systemoff {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Systemoff {{ systemoff: {=bool:?} }}", self.systemoff())
}
}
#[doc = "USB supply status."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Usbregstatus(pub u32);
impl Usbregstatus {
#[doc = "VBUS input detection status (USBDETECTED and USBREMOVED events are derived from this information)."]
#[must_use]
#[inline(always)]
pub const fn vbusdetect(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "VBUS input detection status (USBDETECTED and USBREMOVED events are derived from this information)."]
#[inline(always)]
pub const fn set_vbusdetect(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "USB supply output settling time elapsed."]
#[must_use]
#[inline(always)]
pub const fn outputrdy(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "USB supply output settling time elapsed."]
#[inline(always)]
pub const fn set_outputrdy(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
}
impl Default for Usbregstatus {
#[inline(always)]
fn default() -> Usbregstatus {
Usbregstatus(0)
}
}
impl core::fmt::Debug for Usbregstatus {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Usbregstatus")
.field("vbusdetect", &self.vbusdetect())
.field("outputrdy", &self.outputrdy())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Usbregstatus {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Usbregstatus {{ vbusdetect: {=bool:?}, outputrdy: {=bool:?} }}",
self.vbusdetect(),
self.outputrdy()
)
}
}
}
pub mod vals {
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Mainregstatus {
#[doc = "Normal voltage mode. Voltage supplied on VDD."]
Normal = 0x0,
#[doc = "High voltage mode. Voltage supplied on VDDH."]
High = 0x01,
}
impl Mainregstatus {
#[inline(always)]
pub const fn from_bits(val: u8) -> Mainregstatus {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Mainregstatus {
#[inline(always)]
fn from(val: u8) -> Mainregstatus {
Mainregstatus::from_bits(val)
}
}
impl From<Mainregstatus> for u8 {
#[inline(always)]
fn from(val: Mainregstatus) -> u8 {
Mainregstatus::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Threshold {
_RESERVED_0 = 0x0,
_RESERVED_1 = 0x01,
_RESERVED_2 = 0x02,
_RESERVED_3 = 0x03,
#[doc = "Set threshold to 1.7 V."]
V17 = 0x04,
#[doc = "Set threshold to 1.8 V."]
V18 = 0x05,
#[doc = "Set threshold to 1.9 V."]
V19 = 0x06,
#[doc = "Set threshold to 2.0 V."]
V20 = 0x07,
#[doc = "Set threshold to 2.1 V."]
V21 = 0x08,
#[doc = "Set threshold to 2.2 V."]
V22 = 0x09,
#[doc = "Set threshold to 2.3 V."]
V23 = 0x0a,
#[doc = "Set threshold to 2.4 V."]
V24 = 0x0b,
#[doc = "Set threshold to 2.5 V."]
V25 = 0x0c,
#[doc = "Set threshold to 2.6 V."]
V26 = 0x0d,
#[doc = "Set threshold to 2.7 V."]
V27 = 0x0e,
#[doc = "Set threshold to 2.8 V."]
V28 = 0x0f,
}
impl Threshold {
#[inline(always)]
pub const fn from_bits(val: u8) -> Threshold {
unsafe { core::mem::transmute(val & 0x0f) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Threshold {
#[inline(always)]
fn from(val: u8) -> Threshold {
Threshold::from_bits(val)
}
}
impl From<Threshold> for u8 {
#[inline(always)]
fn from(val: Threshold) -> u8 {
Threshold::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Thresholdvddh {
#[doc = "Set threshold to 2.7 V."]
V27 = 0x0,
#[doc = "Set threshold to 2.8 V."]
V28 = 0x01,
#[doc = "Set threshold to 2.9 V."]
V29 = 0x02,
#[doc = "Set threshold to 3.0 V."]
V30 = 0x03,
#[doc = "Set threshold to 3.1 V."]
V31 = 0x04,
#[doc = "Set threshold to 3.2 V."]
V32 = 0x05,
#[doc = "Set threshold to 3.3 V."]
V33 = 0x06,
#[doc = "Set threshold to 3.4 V."]
V34 = 0x07,
#[doc = "Set threshold to 3.5 V."]
V35 = 0x08,
#[doc = "Set threshold to 3.6 V."]
V36 = 0x09,
#[doc = "Set threshold to 3.7 V."]
V37 = 0x0a,
#[doc = "Set threshold to 3.8 V."]
V38 = 0x0b,
#[doc = "Set threshold to 3.9 V."]
V39 = 0x0c,
#[doc = "Set threshold to 4.0 V."]
V40 = 0x0d,
#[doc = "Set threshold to 4.1 V."]
V41 = 0x0e,
#[doc = "Set threshold to 4.2 V."]
V42 = 0x0f,
}
impl Thresholdvddh {
#[inline(always)]
pub const fn from_bits(val: u8) -> Thresholdvddh {
unsafe { core::mem::transmute(val & 0x0f) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Thresholdvddh {
#[inline(always)]
fn from(val: u8) -> Thresholdvddh {
Thresholdvddh::from_bits(val)
}
}
impl From<Thresholdvddh> for u8 {
#[inline(always)]
fn from(val: Thresholdvddh) -> u8 {
Thresholdvddh::to_bits(val)
}
}
}
}
pub mod ppi {
#[doc = "PPI Channel."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Ch {
ptr: *mut u8,
}
unsafe impl Send for Ch {}
unsafe impl Sync for Ch {}
impl Ch {
#[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 = "Description cluster: Channel n event endpoint."]
#[inline(always)]
pub const fn eep(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Description cluster: Channel n task endpoint."]
#[inline(always)]
pub const fn tep(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
}
#[doc = "Fork."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Fork {
ptr: *mut u8,
}
unsafe impl Send for Fork {}
unsafe impl Sync for Fork {}
impl Fork {
#[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 = "Description cluster: Channel n task endpoint."]
#[inline(always)]
pub const fn tep(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
}
#[doc = "Programmable Peripheral Interconnect."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Ppi {
ptr: *mut u8,
}
unsafe impl Send for Ppi {}
unsafe impl Sync for Ppi {}
impl Ppi {
#[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 = "Channel group tasks."]
#[inline(always)]
pub const fn tasks_chg(self, n: usize) -> TasksChg {
assert!(n < 6usize);
unsafe { TasksChg::from_ptr(self.ptr.wrapping_add(0x0usize + n * 8usize) as _) }
}
#[doc = "Channel enable register."]
#[inline(always)]
pub const fn chen(self) -> crate::common::Reg<regs::Chen, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0500usize) as _) }
}
#[doc = "Channel enable set register."]
#[inline(always)]
pub const fn chenset(self) -> crate::common::Reg<regs::Chen, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0504usize) as _) }
}
#[doc = "Channel enable clear register."]
#[inline(always)]
pub const fn chenclr(self) -> crate::common::Reg<regs::Chen, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0508usize) as _) }
}
#[doc = "PPI Channel."]
#[inline(always)]
pub const fn ch(self, n: usize) -> Ch {
assert!(n < 20usize);
unsafe { Ch::from_ptr(self.ptr.wrapping_add(0x0510usize + n * 8usize) as _) }
}
#[doc = "Description collection: Channel group n."]
#[inline(always)]
pub const fn chg(self, n: usize) -> crate::common::Reg<regs::Chg, crate::common::RW> {
assert!(n < 6usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0800usize + n * 4usize) as _)
}
}
#[doc = "Fork."]
#[inline(always)]
pub const fn fork(self, n: usize) -> Fork {
assert!(n < 32usize);
unsafe { Fork::from_ptr(self.ptr.wrapping_add(0x0910usize + n * 4usize) as _) }
}
}
#[doc = "Channel group tasks."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct TasksChg {
ptr: *mut u8,
}
unsafe impl Send for TasksChg {}
unsafe impl Sync for TasksChg {}
impl TasksChg {
#[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 = "Description cluster: Enable channel group n."]
#[inline(always)]
pub const fn en(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Description cluster: Disable channel group n."]
#[inline(always)]
pub const fn dis(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
}
pub mod regs {
#[doc = "Channel enable register."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Chen(pub u32);
impl Chen {
#[doc = "Enable or disable channel 0."]
#[must_use]
#[inline(always)]
pub const fn ch(&self, n: usize) -> bool {
assert!(n < 32usize);
let offs = 0usize + n * 1usize;
let val = (self.0 >> offs) & 0x01;
val != 0
}
#[doc = "Enable or disable channel 0."]
#[inline(always)]
pub const fn set_ch(&mut self, n: usize, val: bool) {
assert!(n < 32usize);
let offs = 0usize + n * 1usize;
self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
}
}
impl Default for Chen {
#[inline(always)]
fn default() -> Chen {
Chen(0)
}
}
impl core::fmt::Debug for Chen {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Chen")
.field("ch[0]", &self.ch(0usize))
.field("ch[1]", &self.ch(1usize))
.field("ch[2]", &self.ch(2usize))
.field("ch[3]", &self.ch(3usize))
.field("ch[4]", &self.ch(4usize))
.field("ch[5]", &self.ch(5usize))
.field("ch[6]", &self.ch(6usize))
.field("ch[7]", &self.ch(7usize))
.field("ch[8]", &self.ch(8usize))
.field("ch[9]", &self.ch(9usize))
.field("ch[10]", &self.ch(10usize))
.field("ch[11]", &self.ch(11usize))
.field("ch[12]", &self.ch(12usize))
.field("ch[13]", &self.ch(13usize))
.field("ch[14]", &self.ch(14usize))
.field("ch[15]", &self.ch(15usize))
.field("ch[16]", &self.ch(16usize))
.field("ch[17]", &self.ch(17usize))
.field("ch[18]", &self.ch(18usize))
.field("ch[19]", &self.ch(19usize))
.field("ch[20]", &self.ch(20usize))
.field("ch[21]", &self.ch(21usize))
.field("ch[22]", &self.ch(22usize))
.field("ch[23]", &self.ch(23usize))
.field("ch[24]", &self.ch(24usize))
.field("ch[25]", &self.ch(25usize))
.field("ch[26]", &self.ch(26usize))
.field("ch[27]", &self.ch(27usize))
.field("ch[28]", &self.ch(28usize))
.field("ch[29]", &self.ch(29usize))
.field("ch[30]", &self.ch(30usize))
.field("ch[31]", &self.ch(31usize))
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Chen {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Chen {{ ch[0]: {=bool:?}, ch[1]: {=bool:?}, ch[2]: {=bool:?}, ch[3]: {=bool:?}, ch[4]: {=bool:?}, ch[5]: {=bool:?}, ch[6]: {=bool:?}, ch[7]: {=bool:?}, ch[8]: {=bool:?}, ch[9]: {=bool:?}, ch[10]: {=bool:?}, ch[11]: {=bool:?}, ch[12]: {=bool:?}, ch[13]: {=bool:?}, ch[14]: {=bool:?}, ch[15]: {=bool:?}, ch[16]: {=bool:?}, ch[17]: {=bool:?}, ch[18]: {=bool:?}, ch[19]: {=bool:?}, ch[20]: {=bool:?}, ch[21]: {=bool:?}, ch[22]: {=bool:?}, ch[23]: {=bool:?}, ch[24]: {=bool:?}, ch[25]: {=bool:?}, ch[26]: {=bool:?}, ch[27]: {=bool:?}, ch[28]: {=bool:?}, ch[29]: {=bool:?}, ch[30]: {=bool:?}, ch[31]: {=bool:?} }}" , self . ch (0usize) , self . ch (1usize) , self . ch (2usize) , self . ch (3usize) , self . ch (4usize) , self . ch (5usize) , self . ch (6usize) , self . ch (7usize) , self . ch (8usize) , self . ch (9usize) , self . ch (10usize) , self . ch (11usize) , self . ch (12usize) , self . ch (13usize) , self . ch (14usize) , self . ch (15usize) , self . ch (16usize) , self . ch (17usize) , self . ch (18usize) , self . ch (19usize) , self . ch (20usize) , self . ch (21usize) , self . ch (22usize) , self . ch (23usize) , self . ch (24usize) , self . ch (25usize) , self . ch (26usize) , self . ch (27usize) , self . ch (28usize) , self . ch (29usize) , self . ch (30usize) , self . ch (31usize))
}
}
#[doc = "Description collection: Channel group n."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Chg(pub u32);
impl Chg {
#[doc = "Include or exclude channel 0."]
#[must_use]
#[inline(always)]
pub const fn ch(&self, n: usize) -> bool {
assert!(n < 32usize);
let offs = 0usize + n * 1usize;
let val = (self.0 >> offs) & 0x01;
val != 0
}
#[doc = "Include or exclude channel 0."]
#[inline(always)]
pub const fn set_ch(&mut self, n: usize, val: bool) {
assert!(n < 32usize);
let offs = 0usize + n * 1usize;
self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
}
}
impl Default for Chg {
#[inline(always)]
fn default() -> Chg {
Chg(0)
}
}
impl core::fmt::Debug for Chg {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Chg")
.field("ch[0]", &self.ch(0usize))
.field("ch[1]", &self.ch(1usize))
.field("ch[2]", &self.ch(2usize))
.field("ch[3]", &self.ch(3usize))
.field("ch[4]", &self.ch(4usize))
.field("ch[5]", &self.ch(5usize))
.field("ch[6]", &self.ch(6usize))
.field("ch[7]", &self.ch(7usize))
.field("ch[8]", &self.ch(8usize))
.field("ch[9]", &self.ch(9usize))
.field("ch[10]", &self.ch(10usize))
.field("ch[11]", &self.ch(11usize))
.field("ch[12]", &self.ch(12usize))
.field("ch[13]", &self.ch(13usize))
.field("ch[14]", &self.ch(14usize))
.field("ch[15]", &self.ch(15usize))
.field("ch[16]", &self.ch(16usize))
.field("ch[17]", &self.ch(17usize))
.field("ch[18]", &self.ch(18usize))
.field("ch[19]", &self.ch(19usize))
.field("ch[20]", &self.ch(20usize))
.field("ch[21]", &self.ch(21usize))
.field("ch[22]", &self.ch(22usize))
.field("ch[23]", &self.ch(23usize))
.field("ch[24]", &self.ch(24usize))
.field("ch[25]", &self.ch(25usize))
.field("ch[26]", &self.ch(26usize))
.field("ch[27]", &self.ch(27usize))
.field("ch[28]", &self.ch(28usize))
.field("ch[29]", &self.ch(29usize))
.field("ch[30]", &self.ch(30usize))
.field("ch[31]", &self.ch(31usize))
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Chg {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Chg {{ ch[0]: {=bool:?}, ch[1]: {=bool:?}, ch[2]: {=bool:?}, ch[3]: {=bool:?}, ch[4]: {=bool:?}, ch[5]: {=bool:?}, ch[6]: {=bool:?}, ch[7]: {=bool:?}, ch[8]: {=bool:?}, ch[9]: {=bool:?}, ch[10]: {=bool:?}, ch[11]: {=bool:?}, ch[12]: {=bool:?}, ch[13]: {=bool:?}, ch[14]: {=bool:?}, ch[15]: {=bool:?}, ch[16]: {=bool:?}, ch[17]: {=bool:?}, ch[18]: {=bool:?}, ch[19]: {=bool:?}, ch[20]: {=bool:?}, ch[21]: {=bool:?}, ch[22]: {=bool:?}, ch[23]: {=bool:?}, ch[24]: {=bool:?}, ch[25]: {=bool:?}, ch[26]: {=bool:?}, ch[27]: {=bool:?}, ch[28]: {=bool:?}, ch[29]: {=bool:?}, ch[30]: {=bool:?}, ch[31]: {=bool:?} }}" , self . ch (0usize) , self . ch (1usize) , self . ch (2usize) , self . ch (3usize) , self . ch (4usize) , self . ch (5usize) , self . ch (6usize) , self . ch (7usize) , self . ch (8usize) , self . ch (9usize) , self . ch (10usize) , self . ch (11usize) , self . ch (12usize) , self . ch (13usize) , self . ch (14usize) , self . ch (15usize) , self . ch (16usize) , self . ch (17usize) , self . ch (18usize) , self . ch (19usize) , self . ch (20usize) , self . ch (21usize) , self . ch (22usize) , self . ch (23usize) , self . ch (24usize) , self . ch (25usize) , self . ch (26usize) , self . ch (27usize) , self . ch (28usize) , self . ch (29usize) , self . ch (30usize) , self . ch (31usize))
}
}
}
}
pub mod qdec {
#[doc = "Unspecified."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Psel {
ptr: *mut u8,
}
unsafe impl Send for Psel {}
unsafe impl Sync for Psel {}
impl Psel {
#[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 = "Pin select for LED signal."]
#[inline(always)]
pub const fn led(self) -> crate::common::Reg<super::shared::regs::Psel, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Pin select for A signal."]
#[inline(always)]
pub const fn a(self) -> crate::common::Reg<super::shared::regs::Psel, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Pin select for B signal."]
#[inline(always)]
pub const fn b(self) -> crate::common::Reg<super::shared::regs::Psel, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
}
#[doc = "Quadrature Decoder."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Qdec {
ptr: *mut u8,
}
unsafe impl Send for Qdec {}
unsafe impl Sync for Qdec {}
impl Qdec {
#[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 = "Task starting the quadrature decoder."]
#[inline(always)]
pub const fn tasks_start(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Task stopping the quadrature decoder."]
#[inline(always)]
pub const fn tasks_stop(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Read and clear ACC and ACCDBL."]
#[inline(always)]
pub const fn tasks_readclracc(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
#[doc = "Read and clear ACC."]
#[inline(always)]
pub const fn tasks_rdclracc(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0cusize) as _) }
}
#[doc = "Read and clear ACCDBL."]
#[inline(always)]
pub const fn tasks_rdclrdbl(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x10usize) as _) }
}
#[doc = "Event being generated for every new sample value written to the SAMPLE register."]
#[inline(always)]
pub const fn events_samplerdy(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0100usize) as _) }
}
#[doc = "Non-null report ready."]
#[inline(always)]
pub const fn events_reportrdy(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0104usize) as _) }
}
#[doc = "ACC or ACCDBL register overflow."]
#[inline(always)]
pub const fn events_accof(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0108usize) as _) }
}
#[doc = "Double displacement(s) detected."]
#[inline(always)]
pub const fn events_dblrdy(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x010cusize) as _) }
}
#[doc = "QDEC has been stopped."]
#[inline(always)]
pub const fn events_stopped(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0110usize) as _) }
}
#[doc = "Shortcuts between local events and tasks."]
#[inline(always)]
pub const fn shorts(self) -> crate::common::Reg<regs::Shorts, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0200usize) as _) }
}
#[doc = "Enable interrupt."]
#[inline(always)]
pub const fn intenset(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0304usize) as _) }
}
#[doc = "Disable interrupt."]
#[inline(always)]
pub const fn intenclr(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0308usize) as _) }
}
#[doc = "Enable the quadrature decoder."]
#[inline(always)]
pub const fn enable(self) -> crate::common::Reg<regs::Enable, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0500usize) as _) }
}
#[doc = "LED output pin polarity."]
#[inline(always)]
pub const fn ledpol(self) -> crate::common::Reg<regs::Ledpol, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0504usize) as _) }
}
#[doc = "Sample period."]
#[inline(always)]
pub const fn sampleper(self) -> crate::common::Reg<regs::Sampleper, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0508usize) as _) }
}
#[doc = "Motion sample value."]
#[inline(always)]
pub const fn sample(self) -> crate::common::Reg<u32, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x050cusize) as _) }
}
#[doc = "Number of samples to be taken before REPORTRDY and DBLRDY events can be generated."]
#[inline(always)]
pub const fn reportper(self) -> crate::common::Reg<regs::Reportper, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0510usize) as _) }
}
#[doc = "Register accumulating the valid transitions."]
#[inline(always)]
pub const fn acc(self) -> crate::common::Reg<u32, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0514usize) as _) }
}
#[doc = "Snapshot of the ACC register, updated by the READCLRACC or RDCLRACC task."]
#[inline(always)]
pub const fn accread(self) -> crate::common::Reg<u32, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0518usize) as _) }
}
#[doc = "Unspecified."]
#[inline(always)]
pub const fn psel(self) -> Psel {
unsafe { Psel::from_ptr(self.ptr.wrapping_add(0x051cusize) as _) }
}
#[doc = "Enable input debounce filters."]
#[inline(always)]
pub const fn dbfen(self) -> crate::common::Reg<regs::Dbfen, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0528usize) as _) }
}
#[doc = "Time period the LED is switched ON prior to sampling."]
#[inline(always)]
pub const fn ledpre(self) -> crate::common::Reg<regs::Ledpre, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0540usize) as _) }
}
#[doc = "Register accumulating the number of detected double transitions."]
#[inline(always)]
pub const fn accdbl(self) -> crate::common::Reg<regs::Accdbl, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0544usize) as _) }
}
#[doc = "Snapshot of the ACCDBL, updated by the READCLRACC or RDCLRDBL task."]
#[inline(always)]
pub const fn accdblread(self) -> crate::common::Reg<regs::Accdblread, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0548usize) as _) }
}
}
pub mod regs {
#[doc = "Register accumulating the number of detected double transitions."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Accdbl(pub u32);
impl Accdbl {
#[doc = "Register accumulating the number of detected double or illegal transitions. ( SAMPLE = 2 )."]
#[must_use]
#[inline(always)]
pub const fn accdbl(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x0f;
val as u8
}
#[doc = "Register accumulating the number of detected double or illegal transitions. ( SAMPLE = 2 )."]
#[inline(always)]
pub const fn set_accdbl(&mut self, val: u8) {
self.0 = (self.0 & !(0x0f << 0usize)) | (((val as u32) & 0x0f) << 0usize);
}
}
impl Default for Accdbl {
#[inline(always)]
fn default() -> Accdbl {
Accdbl(0)
}
}
impl core::fmt::Debug for Accdbl {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Accdbl")
.field("accdbl", &self.accdbl())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Accdbl {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Accdbl {{ accdbl: {=u8:?} }}", self.accdbl())
}
}
#[doc = "Snapshot of the ACCDBL, updated by the READCLRACC or RDCLRDBL task."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Accdblread(pub u32);
impl Accdblread {
#[doc = "Snapshot of the ACCDBL register. This field is updated when the READCLRACC or RDCLRDBL task is triggered."]
#[must_use]
#[inline(always)]
pub const fn accdblread(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x0f;
val as u8
}
#[doc = "Snapshot of the ACCDBL register. This field is updated when the READCLRACC or RDCLRDBL task is triggered."]
#[inline(always)]
pub const fn set_accdblread(&mut self, val: u8) {
self.0 = (self.0 & !(0x0f << 0usize)) | (((val as u32) & 0x0f) << 0usize);
}
}
impl Default for Accdblread {
#[inline(always)]
fn default() -> Accdblread {
Accdblread(0)
}
}
impl core::fmt::Debug for Accdblread {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Accdblread")
.field("accdblread", &self.accdblread())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Accdblread {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Accdblread {{ accdblread: {=u8:?} }}", self.accdblread())
}
}
#[doc = "Enable input debounce filters."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Dbfen(pub u32);
impl Dbfen {
#[doc = "Enable input debounce filters."]
#[must_use]
#[inline(always)]
pub const fn dbfen(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Enable input debounce filters."]
#[inline(always)]
pub const fn set_dbfen(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for Dbfen {
#[inline(always)]
fn default() -> Dbfen {
Dbfen(0)
}
}
impl core::fmt::Debug for Dbfen {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Dbfen")
.field("dbfen", &self.dbfen())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Dbfen {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Dbfen {{ dbfen: {=bool:?} }}", self.dbfen())
}
}
#[doc = "Enable the quadrature decoder."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Enable(pub u32);
impl Enable {
#[doc = "Enable or disable the quadrature decoder."]
#[must_use]
#[inline(always)]
pub const fn enable(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Enable or disable the quadrature decoder."]
#[inline(always)]
pub const fn set_enable(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for Enable {
#[inline(always)]
fn default() -> Enable {
Enable(0)
}
}
impl core::fmt::Debug for Enable {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Enable")
.field("enable", &self.enable())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Enable {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Enable {{ enable: {=bool:?} }}", self.enable())
}
}
#[doc = "Disable interrupt."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Int(pub u32);
impl Int {
#[doc = "Write '1' to disable interrupt for event SAMPLERDY."]
#[must_use]
#[inline(always)]
pub const fn samplerdy(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event SAMPLERDY."]
#[inline(always)]
pub const fn set_samplerdy(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Write '1' to disable interrupt for event REPORTRDY."]
#[must_use]
#[inline(always)]
pub const fn reportrdy(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event REPORTRDY."]
#[inline(always)]
pub const fn set_reportrdy(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "Write '1' to disable interrupt for event ACCOF."]
#[must_use]
#[inline(always)]
pub const fn accof(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event ACCOF."]
#[inline(always)]
pub const fn set_accof(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "Write '1' to disable interrupt for event DBLRDY."]
#[must_use]
#[inline(always)]
pub const fn dblrdy(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event DBLRDY."]
#[inline(always)]
pub const fn set_dblrdy(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
#[doc = "Write '1' to disable interrupt for event STOPPED."]
#[must_use]
#[inline(always)]
pub const fn stopped(&self) -> bool {
let val = (self.0 >> 4usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event STOPPED."]
#[inline(always)]
pub const fn set_stopped(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
}
}
impl Default for Int {
#[inline(always)]
fn default() -> Int {
Int(0)
}
}
impl core::fmt::Debug for Int {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Int")
.field("samplerdy", &self.samplerdy())
.field("reportrdy", &self.reportrdy())
.field("accof", &self.accof())
.field("dblrdy", &self.dblrdy())
.field("stopped", &self.stopped())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Int {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Int {{ samplerdy: {=bool:?}, reportrdy: {=bool:?}, accof: {=bool:?}, dblrdy: {=bool:?}, stopped: {=bool:?} }}" , self . samplerdy () , self . reportrdy () , self . accof () , self . dblrdy () , self . stopped ())
}
}
#[doc = "LED output pin polarity."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Ledpol(pub u32);
impl Ledpol {
#[doc = "LED output pin polarity."]
#[must_use]
#[inline(always)]
pub const fn ledpol(&self) -> super::vals::Ledpol {
let val = (self.0 >> 0usize) & 0x01;
super::vals::Ledpol::from_bits(val as u8)
}
#[doc = "LED output pin polarity."]
#[inline(always)]
pub const fn set_ledpol(&mut self, val: super::vals::Ledpol) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
}
impl Default for Ledpol {
#[inline(always)]
fn default() -> Ledpol {
Ledpol(0)
}
}
impl core::fmt::Debug for Ledpol {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Ledpol")
.field("ledpol", &self.ledpol())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Ledpol {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Ledpol {{ ledpol: {:?} }}", self.ledpol())
}
}
#[doc = "Time period the LED is switched ON prior to sampling."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Ledpre(pub u32);
impl Ledpre {
#[doc = "Period in us the LED is switched on prior to sampling."]
#[must_use]
#[inline(always)]
pub const fn ledpre(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x01ff;
val as u16
}
#[doc = "Period in us the LED is switched on prior to sampling."]
#[inline(always)]
pub const fn set_ledpre(&mut self, val: u16) {
self.0 = (self.0 & !(0x01ff << 0usize)) | (((val as u32) & 0x01ff) << 0usize);
}
}
impl Default for Ledpre {
#[inline(always)]
fn default() -> Ledpre {
Ledpre(0)
}
}
impl core::fmt::Debug for Ledpre {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Ledpre")
.field("ledpre", &self.ledpre())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Ledpre {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Ledpre {{ ledpre: {=u16:?} }}", self.ledpre())
}
}
#[doc = "Number of samples to be taken before REPORTRDY and DBLRDY events can be generated."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Reportper(pub u32);
impl Reportper {
#[doc = "Specifies the number of samples to be accumulated in the ACC register before the REPORTRDY and DBLRDY events can be generated."]
#[must_use]
#[inline(always)]
pub const fn reportper(&self) -> super::vals::Reportper {
let val = (self.0 >> 0usize) & 0x0f;
super::vals::Reportper::from_bits(val as u8)
}
#[doc = "Specifies the number of samples to be accumulated in the ACC register before the REPORTRDY and DBLRDY events can be generated."]
#[inline(always)]
pub const fn set_reportper(&mut self, val: super::vals::Reportper) {
self.0 = (self.0 & !(0x0f << 0usize)) | (((val.to_bits() as u32) & 0x0f) << 0usize);
}
}
impl Default for Reportper {
#[inline(always)]
fn default() -> Reportper {
Reportper(0)
}
}
impl core::fmt::Debug for Reportper {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Reportper")
.field("reportper", &self.reportper())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Reportper {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Reportper {{ reportper: {:?} }}", self.reportper())
}
}
#[doc = "Sample period."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Sampleper(pub u32);
impl Sampleper {
#[doc = "Sample period. The SAMPLE register will be updated for every new sample."]
#[must_use]
#[inline(always)]
pub const fn sampleper(&self) -> super::vals::Sampleper {
let val = (self.0 >> 0usize) & 0x0f;
super::vals::Sampleper::from_bits(val as u8)
}
#[doc = "Sample period. The SAMPLE register will be updated for every new sample."]
#[inline(always)]
pub const fn set_sampleper(&mut self, val: super::vals::Sampleper) {
self.0 = (self.0 & !(0x0f << 0usize)) | (((val.to_bits() as u32) & 0x0f) << 0usize);
}
}
impl Default for Sampleper {
#[inline(always)]
fn default() -> Sampleper {
Sampleper(0)
}
}
impl core::fmt::Debug for Sampleper {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Sampleper")
.field("sampleper", &self.sampleper())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Sampleper {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Sampleper {{ sampleper: {:?} }}", self.sampleper())
}
}
#[doc = "Shortcuts between local events and tasks."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Shorts(pub u32);
impl Shorts {
#[doc = "Shortcut between event REPORTRDY and task READCLRACC."]
#[must_use]
#[inline(always)]
pub const fn reportrdy_readclracc(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event REPORTRDY and task READCLRACC."]
#[inline(always)]
pub const fn set_reportrdy_readclracc(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Shortcut between event SAMPLERDY and task STOP."]
#[must_use]
#[inline(always)]
pub const fn samplerdy_stop(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event SAMPLERDY and task STOP."]
#[inline(always)]
pub const fn set_samplerdy_stop(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "Shortcut between event REPORTRDY and task RDCLRACC."]
#[must_use]
#[inline(always)]
pub const fn reportrdy_rdclracc(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event REPORTRDY and task RDCLRACC."]
#[inline(always)]
pub const fn set_reportrdy_rdclracc(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "Shortcut between event REPORTRDY and task STOP."]
#[must_use]
#[inline(always)]
pub const fn reportrdy_stop(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event REPORTRDY and task STOP."]
#[inline(always)]
pub const fn set_reportrdy_stop(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
#[doc = "Shortcut between event DBLRDY and task RDCLRDBL."]
#[must_use]
#[inline(always)]
pub const fn dblrdy_rdclrdbl(&self) -> bool {
let val = (self.0 >> 4usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event DBLRDY and task RDCLRDBL."]
#[inline(always)]
pub const fn set_dblrdy_rdclrdbl(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
}
#[doc = "Shortcut between event DBLRDY and task STOP."]
#[must_use]
#[inline(always)]
pub const fn dblrdy_stop(&self) -> bool {
let val = (self.0 >> 5usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event DBLRDY and task STOP."]
#[inline(always)]
pub const fn set_dblrdy_stop(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
}
#[doc = "Shortcut between event SAMPLERDY and task READCLRACC."]
#[must_use]
#[inline(always)]
pub const fn samplerdy_readclracc(&self) -> bool {
let val = (self.0 >> 6usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event SAMPLERDY and task READCLRACC."]
#[inline(always)]
pub const fn set_samplerdy_readclracc(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize);
}
}
impl Default for Shorts {
#[inline(always)]
fn default() -> Shorts {
Shorts(0)
}
}
impl core::fmt::Debug for Shorts {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Shorts")
.field("reportrdy_readclracc", &self.reportrdy_readclracc())
.field("samplerdy_stop", &self.samplerdy_stop())
.field("reportrdy_rdclracc", &self.reportrdy_rdclracc())
.field("reportrdy_stop", &self.reportrdy_stop())
.field("dblrdy_rdclrdbl", &self.dblrdy_rdclrdbl())
.field("dblrdy_stop", &self.dblrdy_stop())
.field("samplerdy_readclracc", &self.samplerdy_readclracc())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Shorts {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Shorts {{ reportrdy_readclracc: {=bool:?}, samplerdy_stop: {=bool:?}, reportrdy_rdclracc: {=bool:?}, reportrdy_stop: {=bool:?}, dblrdy_rdclrdbl: {=bool:?}, dblrdy_stop: {=bool:?}, samplerdy_readclracc: {=bool:?} }}" , self . reportrdy_readclracc () , self . samplerdy_stop () , self . reportrdy_rdclracc () , self . reportrdy_stop () , self . dblrdy_rdclrdbl () , self . dblrdy_stop () , self . samplerdy_readclracc ())
}
}
}
pub mod vals {
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Ledpol {
#[doc = "Led active on output pin low."]
ActiveLow = 0x0,
#[doc = "Led active on output pin high."]
ActiveHigh = 0x01,
}
impl Ledpol {
#[inline(always)]
pub const fn from_bits(val: u8) -> Ledpol {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Ledpol {
#[inline(always)]
fn from(val: u8) -> Ledpol {
Ledpol::from_bits(val)
}
}
impl From<Ledpol> for u8 {
#[inline(always)]
fn from(val: Ledpol) -> u8 {
Ledpol::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Reportper {
#[doc = "10 samples/report."]
_10smpl = 0x0,
#[doc = "40 samples/report."]
_40smpl = 0x01,
#[doc = "80 samples/report."]
_80smpl = 0x02,
#[doc = "120 samples/report."]
_120smpl = 0x03,
#[doc = "160 samples/report."]
_160smpl = 0x04,
#[doc = "200 samples/report."]
_200smpl = 0x05,
#[doc = "240 samples/report."]
_240smpl = 0x06,
#[doc = "280 samples/report."]
_280smpl = 0x07,
#[doc = "1 sample/report."]
_1smpl = 0x08,
_RESERVED_9 = 0x09,
_RESERVED_a = 0x0a,
_RESERVED_b = 0x0b,
_RESERVED_c = 0x0c,
_RESERVED_d = 0x0d,
_RESERVED_e = 0x0e,
_RESERVED_f = 0x0f,
}
impl Reportper {
#[inline(always)]
pub const fn from_bits(val: u8) -> Reportper {
unsafe { core::mem::transmute(val & 0x0f) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Reportper {
#[inline(always)]
fn from(val: u8) -> Reportper {
Reportper::from_bits(val)
}
}
impl From<Reportper> for u8 {
#[inline(always)]
fn from(val: Reportper) -> u8 {
Reportper::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Sampleper {
#[doc = "128 us."]
_128us = 0x0,
#[doc = "256 us."]
_256us = 0x01,
#[doc = "512 us."]
_512us = 0x02,
#[doc = "1024 us."]
_1024us = 0x03,
#[doc = "2048 us."]
_2048us = 0x04,
#[doc = "4096 us."]
_4096us = 0x05,
#[doc = "8192 us."]
_8192us = 0x06,
#[doc = "16384 us."]
_16384us = 0x07,
#[doc = "32768 us."]
_32ms = 0x08,
#[doc = "65536 us."]
_65ms = 0x09,
#[doc = "131072 us."]
_131ms = 0x0a,
_RESERVED_b = 0x0b,
_RESERVED_c = 0x0c,
_RESERVED_d = 0x0d,
_RESERVED_e = 0x0e,
_RESERVED_f = 0x0f,
}
impl Sampleper {
#[inline(always)]
pub const fn from_bits(val: u8) -> Sampleper {
unsafe { core::mem::transmute(val & 0x0f) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Sampleper {
#[inline(always)]
fn from(val: u8) -> Sampleper {
Sampleper::from_bits(val)
}
}
impl From<Sampleper> for u8 {
#[inline(always)]
fn from(val: Sampleper) -> u8 {
Sampleper::to_bits(val)
}
}
}
}
pub mod radio {
#[doc = "DFE packet EasyDMA channel."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Dfepacket {
ptr: *mut u8,
}
unsafe impl Send for Dfepacket {}
unsafe impl Sync for Dfepacket {}
impl Dfepacket {
#[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 = "Data pointer."]
#[inline(always)]
pub const fn ptr(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Maximum number of buffer words to transfer."]
#[inline(always)]
pub const fn maxcnt(self) -> crate::common::Reg<regs::Maxcnt, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Number of samples transferred in the last transaction."]
#[inline(always)]
pub const fn amount(self) -> crate::common::Reg<regs::Amount, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
}
#[doc = "Unspecified."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Psel {
ptr: *mut u8,
}
unsafe impl Send for Psel {}
unsafe impl Sync for Psel {}
impl Psel {
#[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 = "Description collection: Pin select for DFE pin n."]
#[inline(always)]
pub const fn dfegpio(
self,
n: usize,
) -> crate::common::Reg<super::shared::regs::Psel, crate::common::RW> {
assert!(n < 8usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize + n * 4usize) as _)
}
}
}
#[doc = "2.4 GHz radio."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Radio {
ptr: *mut u8,
}
unsafe impl Send for Radio {}
unsafe impl Sync for Radio {}
impl Radio {
#[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 = "Enable RADIO in TX mode."]
#[inline(always)]
pub const fn tasks_txen(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Enable RADIO in RX mode."]
#[inline(always)]
pub const fn tasks_rxen(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Start RADIO."]
#[inline(always)]
pub const fn tasks_start(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
#[doc = "Stop RADIO."]
#[inline(always)]
pub const fn tasks_stop(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0cusize) as _) }
}
#[doc = "Disable RADIO."]
#[inline(always)]
pub const fn tasks_disable(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x10usize) as _) }
}
#[doc = "Start the RSSI and take one single sample of the receive signal strength."]
#[inline(always)]
pub const fn tasks_rssistart(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x14usize) as _) }
}
#[doc = "Stop the RSSI measurement."]
#[inline(always)]
pub const fn tasks_rssistop(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x18usize) as _) }
}
#[doc = "Start the bit counter."]
#[inline(always)]
pub const fn tasks_bcstart(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x1cusize) as _) }
}
#[doc = "Stop the bit counter."]
#[inline(always)]
pub const fn tasks_bcstop(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x20usize) as _) }
}
#[doc = "Start the energy detect measurement used in IEEE 802.15.4 mode."]
#[inline(always)]
pub const fn tasks_edstart(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x24usize) as _) }
}
#[doc = "Stop the energy detect measurement."]
#[inline(always)]
pub const fn tasks_edstop(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x28usize) as _) }
}
#[doc = "Start the clear channel assessment used in IEEE 802.15.4 mode."]
#[inline(always)]
pub const fn tasks_ccastart(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x2cusize) as _) }
}
#[doc = "Stop the clear channel assessment."]
#[inline(always)]
pub const fn tasks_ccastop(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x30usize) as _) }
}
#[doc = "RADIO has ramped up and is ready to be started."]
#[inline(always)]
pub const fn events_ready(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0100usize) as _) }
}
#[doc = "Address sent or received."]
#[inline(always)]
pub const fn events_address(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0104usize) as _) }
}
#[doc = "Packet payload sent or received."]
#[inline(always)]
pub const fn events_payload(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0108usize) as _) }
}
#[doc = "Packet sent or received."]
#[inline(always)]
pub const fn events_end(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x010cusize) as _) }
}
#[doc = "RADIO has been disabled."]
#[inline(always)]
pub const fn events_disabled(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0110usize) as _) }
}
#[doc = "A device address match occurred on the last received packet."]
#[inline(always)]
pub const fn events_devmatch(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0114usize) as _) }
}
#[doc = "No device address match occurred on the last received packet."]
#[inline(always)]
pub const fn events_devmiss(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0118usize) as _) }
}
#[doc = "Sampling of receive signal strength complete."]
#[inline(always)]
pub const fn events_rssiend(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x011cusize) as _) }
}
#[doc = "Bit counter reached bit count value."]
#[inline(always)]
pub const fn events_bcmatch(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0128usize) as _) }
}
#[doc = "Packet received with CRC ok."]
#[inline(always)]
pub const fn events_crcok(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0130usize) as _) }
}
#[doc = "Packet received with CRC error."]
#[inline(always)]
pub const fn events_crcerror(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0134usize) as _) }
}
#[doc = "IEEE 802.15.4 length field received."]
#[inline(always)]
pub const fn events_framestart(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0138usize) as _) }
}
#[doc = "Sampling of energy detection complete. A new ED sample is ready for readout from the RADIO.EDSAMPLE register."]
#[inline(always)]
pub const fn events_edend(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x013cusize) as _) }
}
#[doc = "The sampling of energy detection has stopped."]
#[inline(always)]
pub const fn events_edstopped(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0140usize) as _) }
}
#[doc = "Wireless medium in idle - clear to send."]
#[inline(always)]
pub const fn events_ccaidle(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0144usize) as _) }
}
#[doc = "Wireless medium busy - do not send."]
#[inline(always)]
pub const fn events_ccabusy(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0148usize) as _) }
}
#[doc = "The CCA has stopped."]
#[inline(always)]
pub const fn events_ccastopped(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x014cusize) as _) }
}
#[doc = "Ble_LR CI field received, receive mode is changed from Ble_LR125Kbit to Ble_LR500Kbit."]
#[inline(always)]
pub const fn events_rateboost(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0150usize) as _) }
}
#[doc = "RADIO has ramped up and is ready to be started TX path."]
#[inline(always)]
pub const fn events_txready(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0154usize) as _) }
}
#[doc = "RADIO has ramped up and is ready to be started RX path."]
#[inline(always)]
pub const fn events_rxready(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0158usize) as _) }
}
#[doc = "MAC header match found."]
#[inline(always)]
pub const fn events_mhrmatch(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x015cusize) as _) }
}
#[doc = "Preamble indicator."]
#[inline(always)]
pub const fn events_sync(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0168usize) as _) }
}
#[doc = "Generated when last bit is sent on air, or received from air."]
#[inline(always)]
pub const fn events_phyend(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x016cusize) as _) }
}
#[doc = "CTE is present (early warning right after receiving CTEInfo byte)."]
#[inline(always)]
pub const fn events_ctepresent(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0170usize) as _) }
}
#[doc = "Shortcuts between local events and tasks."]
#[inline(always)]
pub const fn shorts(self) -> crate::common::Reg<regs::Shorts, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0200usize) as _) }
}
#[doc = "Enable interrupt."]
#[inline(always)]
pub const fn intenset(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0304usize) as _) }
}
#[doc = "Disable interrupt."]
#[inline(always)]
pub const fn intenclr(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0308usize) as _) }
}
#[doc = "CRC status."]
#[inline(always)]
pub const fn crcstatus(self) -> crate::common::Reg<regs::Crcstatus, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0400usize) as _) }
}
#[doc = "Received address."]
#[inline(always)]
pub const fn rxmatch(self) -> crate::common::Reg<regs::Rxmatch, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0408usize) as _) }
}
#[doc = "CRC field of previously received packet."]
#[inline(always)]
pub const fn rxcrc(self) -> crate::common::Reg<regs::Rxcrc, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x040cusize) as _) }
}
#[doc = "Device address match index."]
#[inline(always)]
pub const fn dai(self) -> crate::common::Reg<regs::Dai, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0410usize) as _) }
}
#[doc = "Payload status."]
#[inline(always)]
pub const fn pdustat(self) -> crate::common::Reg<regs::Pdustat, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0414usize) as _) }
}
#[doc = "CTEInfo parsed from received packet."]
#[inline(always)]
pub const fn ctestatus(self) -> crate::common::Reg<regs::Ctestatus, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x044cusize) as _) }
}
#[doc = "DFE status information."]
#[inline(always)]
pub const fn dfestatus(self) -> crate::common::Reg<regs::Dfestatus, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0458usize) as _) }
}
#[doc = "Packet pointer."]
#[inline(always)]
pub const fn packetptr(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0504usize) as _) }
}
#[doc = "Frequency."]
#[inline(always)]
pub const fn frequency(self) -> crate::common::Reg<regs::Frequency, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0508usize) as _) }
}
#[doc = "Output power."]
#[inline(always)]
pub const fn txpower(self) -> crate::common::Reg<regs::Txpower, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x050cusize) as _) }
}
#[doc = "Data rate and modulation."]
#[inline(always)]
pub const fn mode(self) -> crate::common::Reg<regs::Mode, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0510usize) as _) }
}
#[doc = "Packet configuration register 0."]
#[inline(always)]
pub const fn pcnf0(self) -> crate::common::Reg<regs::Pcnf0, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0514usize) as _) }
}
#[doc = "Packet configuration register 1."]
#[inline(always)]
pub const fn pcnf1(self) -> crate::common::Reg<regs::Pcnf1, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0518usize) as _) }
}
#[doc = "Base address 0."]
#[inline(always)]
pub const fn base0(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x051cusize) as _) }
}
#[doc = "Base address 1."]
#[inline(always)]
pub const fn base1(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0520usize) as _) }
}
#[doc = "Prefixes bytes for logical addresses 0-3."]
#[inline(always)]
pub const fn prefix0(self) -> crate::common::Reg<regs::Prefix0, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0524usize) as _) }
}
#[doc = "Prefixes bytes for logical addresses 4-7."]
#[inline(always)]
pub const fn prefix1(self) -> crate::common::Reg<regs::Prefix1, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0528usize) as _) }
}
#[doc = "Transmit address select."]
#[inline(always)]
pub const fn txaddress(self) -> crate::common::Reg<regs::Txaddress, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x052cusize) as _) }
}
#[doc = "Receive address select."]
#[inline(always)]
pub const fn rxaddresses(self) -> crate::common::Reg<regs::Rxaddresses, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0530usize) as _) }
}
#[doc = "CRC configuration."]
#[inline(always)]
pub const fn crccnf(self) -> crate::common::Reg<regs::Crccnf, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0534usize) as _) }
}
#[doc = "CRC polynomial."]
#[inline(always)]
pub const fn crcpoly(self) -> crate::common::Reg<regs::Crcpoly, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0538usize) as _) }
}
#[doc = "CRC initial value."]
#[inline(always)]
pub const fn crcinit(self) -> crate::common::Reg<regs::Crcinit, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x053cusize) as _) }
}
#[doc = "Interframe spacing in us."]
#[inline(always)]
pub const fn tifs(self) -> crate::common::Reg<regs::Tifs, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0544usize) as _) }
}
#[doc = "RSSI sample."]
#[inline(always)]
pub const fn rssisample(self) -> crate::common::Reg<regs::Rssisample, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0548usize) as _) }
}
#[doc = "Current radio state."]
#[inline(always)]
pub const fn state(self) -> crate::common::Reg<regs::State, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0550usize) as _) }
}
#[doc = "Data whitening initial value."]
#[inline(always)]
pub const fn datawhiteiv(self) -> crate::common::Reg<regs::Datawhiteiv, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0554usize) as _) }
}
#[doc = "Bit counter compare."]
#[inline(always)]
pub const fn bcc(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0560usize) as _) }
}
#[doc = "Description collection: Device address base segment n."]
#[inline(always)]
pub const fn dab(self, n: usize) -> crate::common::Reg<u32, crate::common::RW> {
assert!(n < 8usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0600usize + n * 4usize) as _)
}
}
#[doc = "Description collection: Device address prefix n."]
#[inline(always)]
pub const fn dap(self, n: usize) -> crate::common::Reg<regs::Dap, crate::common::RW> {
assert!(n < 8usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0620usize + n * 4usize) as _)
}
}
#[doc = "Device address match configuration."]
#[inline(always)]
pub const fn dacnf(self) -> crate::common::Reg<regs::Dacnf, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0640usize) as _) }
}
#[doc = "Search pattern configuration."]
#[inline(always)]
pub const fn mhrmatchconf(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0644usize) as _) }
}
#[doc = "Pattern mask."]
#[inline(always)]
pub const fn mhrmatchmas(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0648usize) as _) }
}
#[doc = "Radio mode configuration register 0."]
#[inline(always)]
pub const fn modecnf0(self) -> crate::common::Reg<regs::Modecnf0, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0650usize) as _) }
}
#[doc = "IEEE 802.15.4 start of frame delimiter."]
#[inline(always)]
pub const fn sfd(self) -> crate::common::Reg<regs::Sfd, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0660usize) as _) }
}
#[doc = "IEEE 802.15.4 energy detect loop count."]
#[inline(always)]
pub const fn edcnt(self) -> crate::common::Reg<regs::Edcnt, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0664usize) as _) }
}
#[doc = "IEEE 802.15.4 energy detect level."]
#[inline(always)]
pub const fn edsample(self) -> crate::common::Reg<regs::Edsample, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0668usize) as _) }
}
#[doc = "IEEE 802.15.4 clear channel assessment control."]
#[inline(always)]
pub const fn ccactrl(self) -> crate::common::Reg<regs::Ccactrl, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x066cusize) as _) }
}
#[doc = "Whether to use Angle-of-Arrival (AOA) or Angle-of-Departure (AOD)."]
#[inline(always)]
pub const fn dfemode(self) -> crate::common::Reg<regs::Dfemode, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0900usize) as _) }
}
#[doc = "Configuration for CTE inline mode."]
#[inline(always)]
pub const fn cteinlineconf(
self,
) -> crate::common::Reg<regs::Cteinlineconf, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0904usize) as _) }
}
#[doc = "Various configuration for Direction finding."]
#[inline(always)]
pub const fn dfectrl1(self) -> crate::common::Reg<regs::Dfectrl1, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0910usize) as _) }
}
#[doc = "Start offset for Direction finding."]
#[inline(always)]
pub const fn dfectrl2(self) -> crate::common::Reg<regs::Dfectrl2, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0914usize) as _) }
}
#[doc = "GPIO patterns to be used for each antenna."]
#[inline(always)]
pub const fn switchpattern(
self,
) -> crate::common::Reg<regs::Switchpattern, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0928usize) as _) }
}
#[doc = "Clear the GPIO pattern array for antenna control."]
#[inline(always)]
pub const fn clearpattern(
self,
) -> crate::common::Reg<regs::Clearpattern, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x092cusize) as _) }
}
#[doc = "Unspecified."]
#[inline(always)]
pub const fn psel(self) -> Psel {
unsafe { Psel::from_ptr(self.ptr.wrapping_add(0x0930usize) as _) }
}
#[doc = "DFE packet EasyDMA channel."]
#[inline(always)]
pub const fn dfepacket(self) -> Dfepacket {
unsafe { Dfepacket::from_ptr(self.ptr.wrapping_add(0x0950usize) as _) }
}
#[doc = "Peripheral power control."]
#[inline(always)]
pub const fn power(self) -> crate::common::Reg<regs::Power, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0ffcusize) as _) }
}
}
pub mod regs {
#[doc = "Number of samples transferred in the last transaction."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Amount(pub u32);
impl Amount {
#[doc = "Number of samples transferred in the last transaction."]
#[must_use]
#[inline(always)]
pub const fn amount(&self) -> u16 {
let val = (self.0 >> 0usize) & 0xffff;
val as u16
}
#[doc = "Number of samples transferred in the last transaction."]
#[inline(always)]
pub const fn set_amount(&mut self, val: u16) {
self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize);
}
}
impl Default for Amount {
#[inline(always)]
fn default() -> Amount {
Amount(0)
}
}
impl core::fmt::Debug for Amount {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Amount")
.field("amount", &self.amount())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Amount {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Amount {{ amount: {=u16:?} }}", self.amount())
}
}
#[doc = "IEEE 802.15.4 clear channel assessment control."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Ccactrl(pub u32);
impl Ccactrl {
#[doc = "CCA mode of operation."]
#[must_use]
#[inline(always)]
pub const fn ccamode(&self) -> super::vals::Ccamode {
let val = (self.0 >> 0usize) & 0x07;
super::vals::Ccamode::from_bits(val as u8)
}
#[doc = "CCA mode of operation."]
#[inline(always)]
pub const fn set_ccamode(&mut self, val: super::vals::Ccamode) {
self.0 = (self.0 & !(0x07 << 0usize)) | (((val.to_bits() as u32) & 0x07) << 0usize);
}
#[doc = "CCA energy busy threshold. Used in all the CCA modes except CarrierMode."]
#[must_use]
#[inline(always)]
pub const fn ccaedthres(&self) -> u8 {
let val = (self.0 >> 8usize) & 0xff;
val as u8
}
#[doc = "CCA energy busy threshold. Used in all the CCA modes except CarrierMode."]
#[inline(always)]
pub const fn set_ccaedthres(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 8usize)) | (((val as u32) & 0xff) << 8usize);
}
#[doc = "CCA correlator busy threshold. Only relevant to CarrierMode, CarrierAndEdMode, and CarrierOrEdMode."]
#[must_use]
#[inline(always)]
pub const fn ccacorrthres(&self) -> u8 {
let val = (self.0 >> 16usize) & 0xff;
val as u8
}
#[doc = "CCA correlator busy threshold. Only relevant to CarrierMode, CarrierAndEdMode, and CarrierOrEdMode."]
#[inline(always)]
pub const fn set_ccacorrthres(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 16usize)) | (((val as u32) & 0xff) << 16usize);
}
#[doc = "Limit for occurances above CCACORRTHRES. When not equal to zero the corrolator based signal detect is enabled."]
#[must_use]
#[inline(always)]
pub const fn ccacorrcnt(&self) -> u8 {
let val = (self.0 >> 24usize) & 0xff;
val as u8
}
#[doc = "Limit for occurances above CCACORRTHRES. When not equal to zero the corrolator based signal detect is enabled."]
#[inline(always)]
pub const fn set_ccacorrcnt(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 24usize)) | (((val as u32) & 0xff) << 24usize);
}
}
impl Default for Ccactrl {
#[inline(always)]
fn default() -> Ccactrl {
Ccactrl(0)
}
}
impl core::fmt::Debug for Ccactrl {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Ccactrl")
.field("ccamode", &self.ccamode())
.field("ccaedthres", &self.ccaedthres())
.field("ccacorrthres", &self.ccacorrthres())
.field("ccacorrcnt", &self.ccacorrcnt())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Ccactrl {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Ccactrl {{ ccamode: {:?}, ccaedthres: {=u8:?}, ccacorrthres: {=u8:?}, ccacorrcnt: {=u8:?} }}" , self . ccamode () , self . ccaedthres () , self . ccacorrthres () , self . ccacorrcnt ())
}
}
#[doc = "Clear the GPIO pattern array for antenna control."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Clearpattern(pub u32);
impl Clearpattern {
#[doc = "Clears GPIO pattern array for antenna control."]
#[must_use]
#[inline(always)]
pub const fn clearpattern(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Clears GPIO pattern array for antenna control."]
#[inline(always)]
pub const fn set_clearpattern(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for Clearpattern {
#[inline(always)]
fn default() -> Clearpattern {
Clearpattern(0)
}
}
impl core::fmt::Debug for Clearpattern {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Clearpattern")
.field("clearpattern", &self.clearpattern())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Clearpattern {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Clearpattern {{ clearpattern: {=bool:?} }}",
self.clearpattern()
)
}
}
#[doc = "CRC configuration."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Crccnf(pub u32);
impl Crccnf {
#[doc = "CRC length in number of bytes For MODE Ble_LR125Kbit and Ble_LR500Kbit, only LEN set to 3 is supported."]
#[must_use]
#[inline(always)]
pub const fn len(&self) -> super::vals::Len {
let val = (self.0 >> 0usize) & 0x03;
super::vals::Len::from_bits(val as u8)
}
#[doc = "CRC length in number of bytes For MODE Ble_LR125Kbit and Ble_LR500Kbit, only LEN set to 3 is supported."]
#[inline(always)]
pub const fn set_len(&mut self, val: super::vals::Len) {
self.0 = (self.0 & !(0x03 << 0usize)) | (((val.to_bits() as u32) & 0x03) << 0usize);
}
#[doc = "Include or exclude packet address field out of CRC calculation."]
#[must_use]
#[inline(always)]
pub const fn skipaddr(&self) -> super::vals::Skipaddr {
let val = (self.0 >> 8usize) & 0x03;
super::vals::Skipaddr::from_bits(val as u8)
}
#[doc = "Include or exclude packet address field out of CRC calculation."]
#[inline(always)]
pub const fn set_skipaddr(&mut self, val: super::vals::Skipaddr) {
self.0 = (self.0 & !(0x03 << 8usize)) | (((val.to_bits() as u32) & 0x03) << 8usize);
}
}
impl Default for Crccnf {
#[inline(always)]
fn default() -> Crccnf {
Crccnf(0)
}
}
impl core::fmt::Debug for Crccnf {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Crccnf")
.field("len", &self.len())
.field("skipaddr", &self.skipaddr())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Crccnf {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Crccnf {{ len: {:?}, skipaddr: {:?} }}",
self.len(),
self.skipaddr()
)
}
}
#[doc = "CRC initial value."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Crcinit(pub u32);
impl Crcinit {
#[doc = "CRC initial value."]
#[must_use]
#[inline(always)]
pub const fn crcinit(&self) -> u32 {
let val = (self.0 >> 0usize) & 0x00ff_ffff;
val as u32
}
#[doc = "CRC initial value."]
#[inline(always)]
pub const fn set_crcinit(&mut self, val: u32) {
self.0 =
(self.0 & !(0x00ff_ffff << 0usize)) | (((val as u32) & 0x00ff_ffff) << 0usize);
}
}
impl Default for Crcinit {
#[inline(always)]
fn default() -> Crcinit {
Crcinit(0)
}
}
impl core::fmt::Debug for Crcinit {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Crcinit")
.field("crcinit", &self.crcinit())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Crcinit {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Crcinit {{ crcinit: {=u32:?} }}", self.crcinit())
}
}
#[doc = "CRC polynomial."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Crcpoly(pub u32);
impl Crcpoly {
#[doc = "CRC polynomial."]
#[must_use]
#[inline(always)]
pub const fn crcpoly(&self) -> u32 {
let val = (self.0 >> 0usize) & 0x00ff_ffff;
val as u32
}
#[doc = "CRC polynomial."]
#[inline(always)]
pub const fn set_crcpoly(&mut self, val: u32) {
self.0 =
(self.0 & !(0x00ff_ffff << 0usize)) | (((val as u32) & 0x00ff_ffff) << 0usize);
}
}
impl Default for Crcpoly {
#[inline(always)]
fn default() -> Crcpoly {
Crcpoly(0)
}
}
impl core::fmt::Debug for Crcpoly {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Crcpoly")
.field("crcpoly", &self.crcpoly())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Crcpoly {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Crcpoly {{ crcpoly: {=u32:?} }}", self.crcpoly())
}
}
#[doc = "CRC status."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Crcstatus(pub u32);
impl Crcstatus {
#[doc = "CRC status of packet received."]
#[must_use]
#[inline(always)]
pub const fn crcstatus(&self) -> super::vals::Crcstatus {
let val = (self.0 >> 0usize) & 0x01;
super::vals::Crcstatus::from_bits(val as u8)
}
#[doc = "CRC status of packet received."]
#[inline(always)]
pub const fn set_crcstatus(&mut self, val: super::vals::Crcstatus) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
}
impl Default for Crcstatus {
#[inline(always)]
fn default() -> Crcstatus {
Crcstatus(0)
}
}
impl core::fmt::Debug for Crcstatus {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Crcstatus")
.field("crcstatus", &self.crcstatus())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Crcstatus {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Crcstatus {{ crcstatus: {:?} }}", self.crcstatus())
}
}
#[doc = "Configuration for CTE inline mode."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Cteinlineconf(pub u32);
impl Cteinlineconf {
#[doc = "Enable parsing of CTEInfo from received packet in BLE modes."]
#[must_use]
#[inline(always)]
pub const fn cteinlinectrlen(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Enable parsing of CTEInfo from received packet in BLE modes."]
#[inline(always)]
pub const fn set_cteinlinectrlen(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "CTEInfo is S1 byte or not."]
#[must_use]
#[inline(always)]
pub const fn cteinfoins1(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "CTEInfo is S1 byte or not."]
#[inline(always)]
pub const fn set_cteinfoins1(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
#[doc = "Sampling/switching if CRC is not OK."]
#[must_use]
#[inline(always)]
pub const fn cteerrorhandling(&self) -> bool {
let val = (self.0 >> 4usize) & 0x01;
val != 0
}
#[doc = "Sampling/switching if CRC is not OK."]
#[inline(always)]
pub const fn set_cteerrorhandling(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
}
#[doc = "Max range of CTETime."]
#[must_use]
#[inline(always)]
pub const fn ctetimevalidrange(&self) -> super::vals::Ctetimevalidrange {
let val = (self.0 >> 6usize) & 0x03;
super::vals::Ctetimevalidrange::from_bits(val as u8)
}
#[doc = "Max range of CTETime."]
#[inline(always)]
pub const fn set_ctetimevalidrange(&mut self, val: super::vals::Ctetimevalidrange) {
self.0 = (self.0 & !(0x03 << 6usize)) | (((val.to_bits() as u32) & 0x03) << 6usize);
}
#[doc = "Spacing between samples for the samples in the SWITCHING period when CTEINLINEMODE is set."]
#[must_use]
#[inline(always)]
pub const fn cteinlinerxmode1us(&self) -> super::vals::Cteinlinerxmode1us {
let val = (self.0 >> 10usize) & 0x07;
super::vals::Cteinlinerxmode1us::from_bits(val as u8)
}
#[doc = "Spacing between samples for the samples in the SWITCHING period when CTEINLINEMODE is set."]
#[inline(always)]
pub const fn set_cteinlinerxmode1us(&mut self, val: super::vals::Cteinlinerxmode1us) {
self.0 =
(self.0 & !(0x07 << 10usize)) | (((val.to_bits() as u32) & 0x07) << 10usize);
}
#[doc = "Spacing between samples for the samples in the SWITCHING period when CTEINLINEMODE is set."]
#[must_use]
#[inline(always)]
pub const fn cteinlinerxmode2us(&self) -> super::vals::Cteinlinerxmode2us {
let val = (self.0 >> 13usize) & 0x07;
super::vals::Cteinlinerxmode2us::from_bits(val as u8)
}
#[doc = "Spacing between samples for the samples in the SWITCHING period when CTEINLINEMODE is set."]
#[inline(always)]
pub const fn set_cteinlinerxmode2us(&mut self, val: super::vals::Cteinlinerxmode2us) {
self.0 =
(self.0 & !(0x07 << 13usize)) | (((val.to_bits() as u32) & 0x07) << 13usize);
}
#[doc = "S0 bit pattern to match."]
#[must_use]
#[inline(always)]
pub const fn s0conf(&self) -> u8 {
let val = (self.0 >> 16usize) & 0xff;
val as u8
}
#[doc = "S0 bit pattern to match."]
#[inline(always)]
pub const fn set_s0conf(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 16usize)) | (((val as u32) & 0xff) << 16usize);
}
#[doc = "S0 bit mask to set which bit to match."]
#[must_use]
#[inline(always)]
pub const fn s0mask(&self) -> u8 {
let val = (self.0 >> 24usize) & 0xff;
val as u8
}
#[doc = "S0 bit mask to set which bit to match."]
#[inline(always)]
pub const fn set_s0mask(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 24usize)) | (((val as u32) & 0xff) << 24usize);
}
}
impl Default for Cteinlineconf {
#[inline(always)]
fn default() -> Cteinlineconf {
Cteinlineconf(0)
}
}
impl core::fmt::Debug for Cteinlineconf {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Cteinlineconf")
.field("cteinlinectrlen", &self.cteinlinectrlen())
.field("cteinfoins1", &self.cteinfoins1())
.field("cteerrorhandling", &self.cteerrorhandling())
.field("ctetimevalidrange", &self.ctetimevalidrange())
.field("cteinlinerxmode1us", &self.cteinlinerxmode1us())
.field("cteinlinerxmode2us", &self.cteinlinerxmode2us())
.field("s0conf", &self.s0conf())
.field("s0mask", &self.s0mask())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Cteinlineconf {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Cteinlineconf {{ cteinlinectrlen: {=bool:?}, cteinfoins1: {=bool:?}, cteerrorhandling: {=bool:?}, ctetimevalidrange: {:?}, cteinlinerxmode1us: {:?}, cteinlinerxmode2us: {:?}, s0conf: {=u8:?}, s0mask: {=u8:?} }}" , self . cteinlinectrlen () , self . cteinfoins1 () , self . cteerrorhandling () , self . ctetimevalidrange () , self . cteinlinerxmode1us () , self . cteinlinerxmode2us () , self . s0conf () , self . s0mask ())
}
}
#[doc = "CTEInfo parsed from received packet."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Ctestatus(pub u32);
impl Ctestatus {
#[doc = "CTETime parsed from packet."]
#[must_use]
#[inline(always)]
pub const fn ctetime(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x1f;
val as u8
}
#[doc = "CTETime parsed from packet."]
#[inline(always)]
pub const fn set_ctetime(&mut self, val: u8) {
self.0 = (self.0 & !(0x1f << 0usize)) | (((val as u32) & 0x1f) << 0usize);
}
#[doc = "RFU parsed from packet."]
#[must_use]
#[inline(always)]
pub const fn rfu(&self) -> bool {
let val = (self.0 >> 5usize) & 0x01;
val != 0
}
#[doc = "RFU parsed from packet."]
#[inline(always)]
pub const fn set_rfu(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
}
#[doc = "CTEType parsed from packet."]
#[must_use]
#[inline(always)]
pub const fn ctetype(&self) -> u8 {
let val = (self.0 >> 6usize) & 0x03;
val as u8
}
#[doc = "CTEType parsed from packet."]
#[inline(always)]
pub const fn set_ctetype(&mut self, val: u8) {
self.0 = (self.0 & !(0x03 << 6usize)) | (((val as u32) & 0x03) << 6usize);
}
}
impl Default for Ctestatus {
#[inline(always)]
fn default() -> Ctestatus {
Ctestatus(0)
}
}
impl core::fmt::Debug for Ctestatus {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Ctestatus")
.field("ctetime", &self.ctetime())
.field("rfu", &self.rfu())
.field("ctetype", &self.ctetype())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Ctestatus {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Ctestatus {{ ctetime: {=u8:?}, rfu: {=bool:?}, ctetype: {=u8:?} }}",
self.ctetime(),
self.rfu(),
self.ctetype()
)
}
}
#[doc = "Device address match configuration."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Dacnf(pub u32);
impl Dacnf {
#[doc = "Enable or disable device address matching using device address 0."]
#[must_use]
#[inline(always)]
pub const fn ena0(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Enable or disable device address matching using device address 0."]
#[inline(always)]
pub const fn set_ena0(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Enable or disable device address matching using device address 1."]
#[must_use]
#[inline(always)]
pub const fn ena1(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Enable or disable device address matching using device address 1."]
#[inline(always)]
pub const fn set_ena1(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "Enable or disable device address matching using device address 2."]
#[must_use]
#[inline(always)]
pub const fn ena2(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Enable or disable device address matching using device address 2."]
#[inline(always)]
pub const fn set_ena2(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "Enable or disable device address matching using device address 3."]
#[must_use]
#[inline(always)]
pub const fn ena3(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "Enable or disable device address matching using device address 3."]
#[inline(always)]
pub const fn set_ena3(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
#[doc = "Enable or disable device address matching using device address 4."]
#[must_use]
#[inline(always)]
pub const fn ena4(&self) -> bool {
let val = (self.0 >> 4usize) & 0x01;
val != 0
}
#[doc = "Enable or disable device address matching using device address 4."]
#[inline(always)]
pub const fn set_ena4(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
}
#[doc = "Enable or disable device address matching using device address 5."]
#[must_use]
#[inline(always)]
pub const fn ena5(&self) -> bool {
let val = (self.0 >> 5usize) & 0x01;
val != 0
}
#[doc = "Enable or disable device address matching using device address 5."]
#[inline(always)]
pub const fn set_ena5(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
}
#[doc = "Enable or disable device address matching using device address 6."]
#[must_use]
#[inline(always)]
pub const fn ena6(&self) -> bool {
let val = (self.0 >> 6usize) & 0x01;
val != 0
}
#[doc = "Enable or disable device address matching using device address 6."]
#[inline(always)]
pub const fn set_ena6(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize);
}
#[doc = "Enable or disable device address matching using device address 7."]
#[must_use]
#[inline(always)]
pub const fn ena7(&self) -> bool {
let val = (self.0 >> 7usize) & 0x01;
val != 0
}
#[doc = "Enable or disable device address matching using device address 7."]
#[inline(always)]
pub const fn set_ena7(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize);
}
#[doc = "TxAdd for device address 0."]
#[must_use]
#[inline(always)]
pub const fn txadd0(&self) -> bool {
let val = (self.0 >> 8usize) & 0x01;
val != 0
}
#[doc = "TxAdd for device address 0."]
#[inline(always)]
pub const fn set_txadd0(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize);
}
#[doc = "TxAdd for device address 1."]
#[must_use]
#[inline(always)]
pub const fn txadd1(&self) -> bool {
let val = (self.0 >> 9usize) & 0x01;
val != 0
}
#[doc = "TxAdd for device address 1."]
#[inline(always)]
pub const fn set_txadd1(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 9usize)) | (((val as u32) & 0x01) << 9usize);
}
#[doc = "TxAdd for device address 2."]
#[must_use]
#[inline(always)]
pub const fn txadd2(&self) -> bool {
let val = (self.0 >> 10usize) & 0x01;
val != 0
}
#[doc = "TxAdd for device address 2."]
#[inline(always)]
pub const fn set_txadd2(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 10usize)) | (((val as u32) & 0x01) << 10usize);
}
#[doc = "TxAdd for device address 3."]
#[must_use]
#[inline(always)]
pub const fn txadd3(&self) -> bool {
let val = (self.0 >> 11usize) & 0x01;
val != 0
}
#[doc = "TxAdd for device address 3."]
#[inline(always)]
pub const fn set_txadd3(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 11usize)) | (((val as u32) & 0x01) << 11usize);
}
#[doc = "TxAdd for device address 4."]
#[must_use]
#[inline(always)]
pub const fn txadd4(&self) -> bool {
let val = (self.0 >> 12usize) & 0x01;
val != 0
}
#[doc = "TxAdd for device address 4."]
#[inline(always)]
pub const fn set_txadd4(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 12usize)) | (((val as u32) & 0x01) << 12usize);
}
#[doc = "TxAdd for device address 5."]
#[must_use]
#[inline(always)]
pub const fn txadd5(&self) -> bool {
let val = (self.0 >> 13usize) & 0x01;
val != 0
}
#[doc = "TxAdd for device address 5."]
#[inline(always)]
pub const fn set_txadd5(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 13usize)) | (((val as u32) & 0x01) << 13usize);
}
#[doc = "TxAdd for device address 6."]
#[must_use]
#[inline(always)]
pub const fn txadd6(&self) -> bool {
let val = (self.0 >> 14usize) & 0x01;
val != 0
}
#[doc = "TxAdd for device address 6."]
#[inline(always)]
pub const fn set_txadd6(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 14usize)) | (((val as u32) & 0x01) << 14usize);
}
#[doc = "TxAdd for device address 7."]
#[must_use]
#[inline(always)]
pub const fn txadd7(&self) -> bool {
let val = (self.0 >> 15usize) & 0x01;
val != 0
}
#[doc = "TxAdd for device address 7."]
#[inline(always)]
pub const fn set_txadd7(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 15usize)) | (((val as u32) & 0x01) << 15usize);
}
}
impl Default for Dacnf {
#[inline(always)]
fn default() -> Dacnf {
Dacnf(0)
}
}
impl core::fmt::Debug for Dacnf {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Dacnf")
.field("ena0", &self.ena0())
.field("ena1", &self.ena1())
.field("ena2", &self.ena2())
.field("ena3", &self.ena3())
.field("ena4", &self.ena4())
.field("ena5", &self.ena5())
.field("ena6", &self.ena6())
.field("ena7", &self.ena7())
.field("txadd0", &self.txadd0())
.field("txadd1", &self.txadd1())
.field("txadd2", &self.txadd2())
.field("txadd3", &self.txadd3())
.field("txadd4", &self.txadd4())
.field("txadd5", &self.txadd5())
.field("txadd6", &self.txadd6())
.field("txadd7", &self.txadd7())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Dacnf {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Dacnf {{ ena0: {=bool:?}, ena1: {=bool:?}, ena2: {=bool:?}, ena3: {=bool:?}, ena4: {=bool:?}, ena5: {=bool:?}, ena6: {=bool:?}, ena7: {=bool:?}, txadd0: {=bool:?}, txadd1: {=bool:?}, txadd2: {=bool:?}, txadd3: {=bool:?}, txadd4: {=bool:?}, txadd5: {=bool:?}, txadd6: {=bool:?}, txadd7: {=bool:?} }}" , self . ena0 () , self . ena1 () , self . ena2 () , self . ena3 () , self . ena4 () , self . ena5 () , self . ena6 () , self . ena7 () , self . txadd0 () , self . txadd1 () , self . txadd2 () , self . txadd3 () , self . txadd4 () , self . txadd5 () , self . txadd6 () , self . txadd7 ())
}
}
#[doc = "Device address match index."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Dai(pub u32);
impl Dai {
#[doc = "Device address match index."]
#[must_use]
#[inline(always)]
pub const fn dai(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x07;
val as u8
}
#[doc = "Device address match index."]
#[inline(always)]
pub const fn set_dai(&mut self, val: u8) {
self.0 = (self.0 & !(0x07 << 0usize)) | (((val as u32) & 0x07) << 0usize);
}
}
impl Default for Dai {
#[inline(always)]
fn default() -> Dai {
Dai(0)
}
}
impl core::fmt::Debug for Dai {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Dai").field("dai", &self.dai()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Dai {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Dai {{ dai: {=u8:?} }}", self.dai())
}
}
#[doc = "Description collection: Device address prefix n."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Dap(pub u32);
impl Dap {
#[doc = "Device address prefix n."]
#[must_use]
#[inline(always)]
pub const fn dap(&self) -> u16 {
let val = (self.0 >> 0usize) & 0xffff;
val as u16
}
#[doc = "Device address prefix n."]
#[inline(always)]
pub const fn set_dap(&mut self, val: u16) {
self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize);
}
}
impl Default for Dap {
#[inline(always)]
fn default() -> Dap {
Dap(0)
}
}
impl core::fmt::Debug for Dap {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Dap").field("dap", &self.dap()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Dap {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Dap {{ dap: {=u16:?} }}", self.dap())
}
}
#[doc = "Data whitening initial value."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Datawhiteiv(pub u32);
impl Datawhiteiv {
#[doc = "Data whitening initial value. Bit 6 is hardwired to '1', writing '0' to it has no effect, and it will always be read back and used by the device as '1'."]
#[must_use]
#[inline(always)]
pub const fn datawhiteiv(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x7f;
val as u8
}
#[doc = "Data whitening initial value. Bit 6 is hardwired to '1', writing '0' to it has no effect, and it will always be read back and used by the device as '1'."]
#[inline(always)]
pub const fn set_datawhiteiv(&mut self, val: u8) {
self.0 = (self.0 & !(0x7f << 0usize)) | (((val as u32) & 0x7f) << 0usize);
}
}
impl Default for Datawhiteiv {
#[inline(always)]
fn default() -> Datawhiteiv {
Datawhiteiv(0)
}
}
impl core::fmt::Debug for Datawhiteiv {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Datawhiteiv")
.field("datawhiteiv", &self.datawhiteiv())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Datawhiteiv {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Datawhiteiv {{ datawhiteiv: {=u8:?} }}",
self.datawhiteiv()
)
}
}
#[doc = "Various configuration for Direction finding."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Dfectrl1(pub u32);
impl Dfectrl1 {
#[doc = "Length of the AoA/AoD procedure in number of 8 us units."]
#[must_use]
#[inline(always)]
pub const fn numberof8us(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x3f;
val as u8
}
#[doc = "Length of the AoA/AoD procedure in number of 8 us units."]
#[inline(always)]
pub const fn set_numberof8us(&mut self, val: u8) {
self.0 = (self.0 & !(0x3f << 0usize)) | (((val as u32) & 0x3f) << 0usize);
}
#[doc = "Add CTE extension and do antenna switching/sampling in this extension."]
#[must_use]
#[inline(always)]
pub const fn dfeinextension(&self) -> super::vals::Dfeinextension {
let val = (self.0 >> 7usize) & 0x01;
super::vals::Dfeinextension::from_bits(val as u8)
}
#[doc = "Add CTE extension and do antenna switching/sampling in this extension."]
#[inline(always)]
pub const fn set_dfeinextension(&mut self, val: super::vals::Dfeinextension) {
self.0 = (self.0 & !(0x01 << 7usize)) | (((val.to_bits() as u32) & 0x01) << 7usize);
}
#[doc = "Interval between every time the antenna is changed in the SWITCHING state."]
#[must_use]
#[inline(always)]
pub const fn tswitchspacing(&self) -> super::vals::Tswitchspacing {
let val = (self.0 >> 8usize) & 0x07;
super::vals::Tswitchspacing::from_bits(val as u8)
}
#[doc = "Interval between every time the antenna is changed in the SWITCHING state."]
#[inline(always)]
pub const fn set_tswitchspacing(&mut self, val: super::vals::Tswitchspacing) {
self.0 = (self.0 & !(0x07 << 8usize)) | (((val.to_bits() as u32) & 0x07) << 8usize);
}
#[doc = "Interval between samples in the REFERENCE period."]
#[must_use]
#[inline(always)]
pub const fn tsamplespacingref(&self) -> super::vals::Tsamplespacingref {
let val = (self.0 >> 12usize) & 0x07;
super::vals::Tsamplespacingref::from_bits(val as u8)
}
#[doc = "Interval between samples in the REFERENCE period."]
#[inline(always)]
pub const fn set_tsamplespacingref(&mut self, val: super::vals::Tsamplespacingref) {
self.0 =
(self.0 & !(0x07 << 12usize)) | (((val.to_bits() as u32) & 0x07) << 12usize);
}
#[doc = "Whether to sample I/Q or magnitude/phase."]
#[must_use]
#[inline(always)]
pub const fn sampletype(&self) -> super::vals::Sampletype {
let val = (self.0 >> 15usize) & 0x01;
super::vals::Sampletype::from_bits(val as u8)
}
#[doc = "Whether to sample I/Q or magnitude/phase."]
#[inline(always)]
pub const fn set_sampletype(&mut self, val: super::vals::Sampletype) {
self.0 =
(self.0 & !(0x01 << 15usize)) | (((val.to_bits() as u32) & 0x01) << 15usize);
}
#[doc = "Interval between samples in the SWITCHING period when CTEINLINECTRLEN is 0."]
#[must_use]
#[inline(always)]
pub const fn tsamplespacing(&self) -> super::vals::Tsamplespacing {
let val = (self.0 >> 16usize) & 0x07;
super::vals::Tsamplespacing::from_bits(val as u8)
}
#[doc = "Interval between samples in the SWITCHING period when CTEINLINECTRLEN is 0."]
#[inline(always)]
pub const fn set_tsamplespacing(&mut self, val: super::vals::Tsamplespacing) {
self.0 =
(self.0 & !(0x07 << 16usize)) | (((val.to_bits() as u32) & 0x07) << 16usize);
}
#[doc = "Repeat each individual antenna pattern N times sequentially, i.e. P0, P0, P1, P1, P2, P2, P3, P3, etc."]
#[must_use]
#[inline(always)]
pub const fn repeatpattern(&self) -> super::vals::Repeatpattern {
let val = (self.0 >> 20usize) & 0x0f;
super::vals::Repeatpattern::from_bits(val as u8)
}
#[doc = "Repeat each individual antenna pattern N times sequentially, i.e. P0, P0, P1, P1, P2, P2, P3, P3, etc."]
#[inline(always)]
pub const fn set_repeatpattern(&mut self, val: super::vals::Repeatpattern) {
self.0 =
(self.0 & !(0x0f << 20usize)) | (((val.to_bits() as u32) & 0x0f) << 20usize);
}
#[doc = "Gain will be lowered by the specified number of gain steps at the start of CTE."]
#[must_use]
#[inline(always)]
pub const fn agcbackoffgain(&self) -> u8 {
let val = (self.0 >> 24usize) & 0x0f;
val as u8
}
#[doc = "Gain will be lowered by the specified number of gain steps at the start of CTE."]
#[inline(always)]
pub const fn set_agcbackoffgain(&mut self, val: u8) {
self.0 = (self.0 & !(0x0f << 24usize)) | (((val as u32) & 0x0f) << 24usize);
}
}
impl Default for Dfectrl1 {
#[inline(always)]
fn default() -> Dfectrl1 {
Dfectrl1(0)
}
}
impl core::fmt::Debug for Dfectrl1 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Dfectrl1")
.field("numberof8us", &self.numberof8us())
.field("dfeinextension", &self.dfeinextension())
.field("tswitchspacing", &self.tswitchspacing())
.field("tsamplespacingref", &self.tsamplespacingref())
.field("sampletype", &self.sampletype())
.field("tsamplespacing", &self.tsamplespacing())
.field("repeatpattern", &self.repeatpattern())
.field("agcbackoffgain", &self.agcbackoffgain())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Dfectrl1 {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Dfectrl1 {{ numberof8us: {=u8:?}, dfeinextension: {:?}, tswitchspacing: {:?}, tsamplespacingref: {:?}, sampletype: {:?}, tsamplespacing: {:?}, repeatpattern: {:?}, agcbackoffgain: {=u8:?} }}" , self . numberof8us () , self . dfeinextension () , self . tswitchspacing () , self . tsamplespacingref () , self . sampletype () , self . tsamplespacing () , self . repeatpattern () , self . agcbackoffgain ())
}
}
#[doc = "Start offset for Direction finding."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Dfectrl2(pub u32);
impl Dfectrl2 {
#[doc = "Signed value offset after the end of the CRC before starting switching in number of 16 MHz clock cycles."]
#[must_use]
#[inline(always)]
pub const fn tswitchoffset(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x1fff;
val as u16
}
#[doc = "Signed value offset after the end of the CRC before starting switching in number of 16 MHz clock cycles."]
#[inline(always)]
pub const fn set_tswitchoffset(&mut self, val: u16) {
self.0 = (self.0 & !(0x1fff << 0usize)) | (((val as u32) & 0x1fff) << 0usize);
}
#[doc = "Signed value offset in number of 16 MHz clock cycles for fine tuning of the sampling instant for all IQ samples. With TSAMPLEOFFSET=0 the first sample is taken immediately at the start of the reference period."]
#[must_use]
#[inline(always)]
pub const fn tsampleoffset(&self) -> u16 {
let val = (self.0 >> 16usize) & 0x0fff;
val as u16
}
#[doc = "Signed value offset in number of 16 MHz clock cycles for fine tuning of the sampling instant for all IQ samples. With TSAMPLEOFFSET=0 the first sample is taken immediately at the start of the reference period."]
#[inline(always)]
pub const fn set_tsampleoffset(&mut self, val: u16) {
self.0 = (self.0 & !(0x0fff << 16usize)) | (((val as u32) & 0x0fff) << 16usize);
}
}
impl Default for Dfectrl2 {
#[inline(always)]
fn default() -> Dfectrl2 {
Dfectrl2(0)
}
}
impl core::fmt::Debug for Dfectrl2 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Dfectrl2")
.field("tswitchoffset", &self.tswitchoffset())
.field("tsampleoffset", &self.tsampleoffset())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Dfectrl2 {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Dfectrl2 {{ tswitchoffset: {=u16:?}, tsampleoffset: {=u16:?} }}",
self.tswitchoffset(),
self.tsampleoffset()
)
}
}
#[doc = "Whether to use Angle-of-Arrival (AOA) or Angle-of-Departure (AOD)."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Dfemode(pub u32);
impl Dfemode {
#[doc = "Direction finding operation mode."]
#[must_use]
#[inline(always)]
pub const fn dfeopmode(&self) -> super::vals::Dfeopmode {
let val = (self.0 >> 0usize) & 0x03;
super::vals::Dfeopmode::from_bits(val as u8)
}
#[doc = "Direction finding operation mode."]
#[inline(always)]
pub const fn set_dfeopmode(&mut self, val: super::vals::Dfeopmode) {
self.0 = (self.0 & !(0x03 << 0usize)) | (((val.to_bits() as u32) & 0x03) << 0usize);
}
}
impl Default for Dfemode {
#[inline(always)]
fn default() -> Dfemode {
Dfemode(0)
}
}
impl core::fmt::Debug for Dfemode {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Dfemode")
.field("dfeopmode", &self.dfeopmode())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Dfemode {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Dfemode {{ dfeopmode: {:?} }}", self.dfeopmode())
}
}
#[doc = "DFE status information."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Dfestatus(pub u32);
impl Dfestatus {
#[doc = "Internal state of switching state machine."]
#[must_use]
#[inline(always)]
pub const fn switchingstate(&self) -> super::vals::Switchingstate {
let val = (self.0 >> 0usize) & 0x07;
super::vals::Switchingstate::from_bits(val as u8)
}
#[doc = "Internal state of switching state machine."]
#[inline(always)]
pub const fn set_switchingstate(&mut self, val: super::vals::Switchingstate) {
self.0 = (self.0 & !(0x07 << 0usize)) | (((val.to_bits() as u32) & 0x07) << 0usize);
}
#[doc = "Internal state of sampling state machine."]
#[must_use]
#[inline(always)]
pub const fn samplingstate(&self) -> super::vals::Samplingstate {
let val = (self.0 >> 4usize) & 0x01;
super::vals::Samplingstate::from_bits(val as u8)
}
#[doc = "Internal state of sampling state machine."]
#[inline(always)]
pub const fn set_samplingstate(&mut self, val: super::vals::Samplingstate) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val.to_bits() as u32) & 0x01) << 4usize);
}
}
impl Default for Dfestatus {
#[inline(always)]
fn default() -> Dfestatus {
Dfestatus(0)
}
}
impl core::fmt::Debug for Dfestatus {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Dfestatus")
.field("switchingstate", &self.switchingstate())
.field("samplingstate", &self.samplingstate())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Dfestatus {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Dfestatus {{ switchingstate: {:?}, samplingstate: {:?} }}",
self.switchingstate(),
self.samplingstate()
)
}
}
#[doc = "IEEE 802.15.4 energy detect loop count."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Edcnt(pub u32);
impl Edcnt {
#[doc = "IEEE 802.15.4 energy detect loop count."]
#[must_use]
#[inline(always)]
pub const fn edcnt(&self) -> u32 {
let val = (self.0 >> 0usize) & 0x001f_ffff;
val as u32
}
#[doc = "IEEE 802.15.4 energy detect loop count."]
#[inline(always)]
pub const fn set_edcnt(&mut self, val: u32) {
self.0 =
(self.0 & !(0x001f_ffff << 0usize)) | (((val as u32) & 0x001f_ffff) << 0usize);
}
}
impl Default for Edcnt {
#[inline(always)]
fn default() -> Edcnt {
Edcnt(0)
}
}
impl core::fmt::Debug for Edcnt {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Edcnt")
.field("edcnt", &self.edcnt())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Edcnt {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Edcnt {{ edcnt: {=u32:?} }}", self.edcnt())
}
}
#[doc = "IEEE 802.15.4 energy detect level."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Edsample(pub u32);
impl Edsample {
#[doc = "IEEE 802.15.4 energy detect level."]
#[must_use]
#[inline(always)]
pub const fn edlvl(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "IEEE 802.15.4 energy detect level."]
#[inline(always)]
pub const fn set_edlvl(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
}
impl Default for Edsample {
#[inline(always)]
fn default() -> Edsample {
Edsample(0)
}
}
impl core::fmt::Debug for Edsample {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Edsample")
.field("edlvl", &self.edlvl())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Edsample {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Edsample {{ edlvl: {=u8:?} }}", self.edlvl())
}
}
#[doc = "Frequency."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Frequency(pub u32);
impl Frequency {
#[doc = "Radio channel frequency."]
#[must_use]
#[inline(always)]
pub const fn frequency(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x7f;
val as u8
}
#[doc = "Radio channel frequency."]
#[inline(always)]
pub const fn set_frequency(&mut self, val: u8) {
self.0 = (self.0 & !(0x7f << 0usize)) | (((val as u32) & 0x7f) << 0usize);
}
#[doc = "Channel map selection."]
#[must_use]
#[inline(always)]
pub const fn map(&self) -> super::vals::Map {
let val = (self.0 >> 8usize) & 0x01;
super::vals::Map::from_bits(val as u8)
}
#[doc = "Channel map selection."]
#[inline(always)]
pub const fn set_map(&mut self, val: super::vals::Map) {
self.0 = (self.0 & !(0x01 << 8usize)) | (((val.to_bits() as u32) & 0x01) << 8usize);
}
}
impl Default for Frequency {
#[inline(always)]
fn default() -> Frequency {
Frequency(0)
}
}
impl core::fmt::Debug for Frequency {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Frequency")
.field("frequency", &self.frequency())
.field("map", &self.map())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Frequency {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Frequency {{ frequency: {=u8:?}, map: {:?} }}",
self.frequency(),
self.map()
)
}
}
#[doc = "Disable interrupt."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Int(pub u32);
impl Int {
#[doc = "Write '1' to disable interrupt for event READY."]
#[must_use]
#[inline(always)]
pub const fn ready(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event READY."]
#[inline(always)]
pub const fn set_ready(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Write '1' to disable interrupt for event ADDRESS."]
#[must_use]
#[inline(always)]
pub const fn address(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event ADDRESS."]
#[inline(always)]
pub const fn set_address(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "Write '1' to disable interrupt for event PAYLOAD."]
#[must_use]
#[inline(always)]
pub const fn payload(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event PAYLOAD."]
#[inline(always)]
pub const fn set_payload(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "Write '1' to disable interrupt for event END."]
#[must_use]
#[inline(always)]
pub const fn end(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event END."]
#[inline(always)]
pub const fn set_end(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
#[doc = "Write '1' to disable interrupt for event DISABLED."]
#[must_use]
#[inline(always)]
pub const fn disabled(&self) -> bool {
let val = (self.0 >> 4usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event DISABLED."]
#[inline(always)]
pub const fn set_disabled(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
}
#[doc = "Write '1' to disable interrupt for event DEVMATCH."]
#[must_use]
#[inline(always)]
pub const fn devmatch(&self) -> bool {
let val = (self.0 >> 5usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event DEVMATCH."]
#[inline(always)]
pub const fn set_devmatch(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
}
#[doc = "Write '1' to disable interrupt for event DEVMISS."]
#[must_use]
#[inline(always)]
pub const fn devmiss(&self) -> bool {
let val = (self.0 >> 6usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event DEVMISS."]
#[inline(always)]
pub const fn set_devmiss(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize);
}
#[doc = "Write '1' to disable interrupt for event RSSIEND."]
#[must_use]
#[inline(always)]
pub const fn rssiend(&self) -> bool {
let val = (self.0 >> 7usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event RSSIEND."]
#[inline(always)]
pub const fn set_rssiend(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize);
}
#[doc = "Write '1' to disable interrupt for event BCMATCH."]
#[must_use]
#[inline(always)]
pub const fn bcmatch(&self) -> bool {
let val = (self.0 >> 10usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event BCMATCH."]
#[inline(always)]
pub const fn set_bcmatch(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 10usize)) | (((val as u32) & 0x01) << 10usize);
}
#[doc = "Write '1' to disable interrupt for event CRCOK."]
#[must_use]
#[inline(always)]
pub const fn crcok(&self) -> bool {
let val = (self.0 >> 12usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event CRCOK."]
#[inline(always)]
pub const fn set_crcok(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 12usize)) | (((val as u32) & 0x01) << 12usize);
}
#[doc = "Write '1' to disable interrupt for event CRCERROR."]
#[must_use]
#[inline(always)]
pub const fn crcerror(&self) -> bool {
let val = (self.0 >> 13usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event CRCERROR."]
#[inline(always)]
pub const fn set_crcerror(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 13usize)) | (((val as u32) & 0x01) << 13usize);
}
#[doc = "Write '1' to disable interrupt for event FRAMESTART."]
#[must_use]
#[inline(always)]
pub const fn framestart(&self) -> bool {
let val = (self.0 >> 14usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event FRAMESTART."]
#[inline(always)]
pub const fn set_framestart(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 14usize)) | (((val as u32) & 0x01) << 14usize);
}
#[doc = "Write '1' to disable interrupt for event EDEND."]
#[must_use]
#[inline(always)]
pub const fn edend(&self) -> bool {
let val = (self.0 >> 15usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event EDEND."]
#[inline(always)]
pub const fn set_edend(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 15usize)) | (((val as u32) & 0x01) << 15usize);
}
#[doc = "Write '1' to disable interrupt for event EDSTOPPED."]
#[must_use]
#[inline(always)]
pub const fn edstopped(&self) -> bool {
let val = (self.0 >> 16usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event EDSTOPPED."]
#[inline(always)]
pub const fn set_edstopped(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 16usize)) | (((val as u32) & 0x01) << 16usize);
}
#[doc = "Write '1' to disable interrupt for event CCAIDLE."]
#[must_use]
#[inline(always)]
pub const fn ccaidle(&self) -> bool {
let val = (self.0 >> 17usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event CCAIDLE."]
#[inline(always)]
pub const fn set_ccaidle(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 17usize)) | (((val as u32) & 0x01) << 17usize);
}
#[doc = "Write '1' to disable interrupt for event CCABUSY."]
#[must_use]
#[inline(always)]
pub const fn ccabusy(&self) -> bool {
let val = (self.0 >> 18usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event CCABUSY."]
#[inline(always)]
pub const fn set_ccabusy(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 18usize)) | (((val as u32) & 0x01) << 18usize);
}
#[doc = "Write '1' to disable interrupt for event CCASTOPPED."]
#[must_use]
#[inline(always)]
pub const fn ccastopped(&self) -> bool {
let val = (self.0 >> 19usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event CCASTOPPED."]
#[inline(always)]
pub const fn set_ccastopped(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 19usize)) | (((val as u32) & 0x01) << 19usize);
}
#[doc = "Write '1' to disable interrupt for event RATEBOOST."]
#[must_use]
#[inline(always)]
pub const fn rateboost(&self) -> bool {
let val = (self.0 >> 20usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event RATEBOOST."]
#[inline(always)]
pub const fn set_rateboost(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 20usize)) | (((val as u32) & 0x01) << 20usize);
}
#[doc = "Write '1' to disable interrupt for event TXREADY."]
#[must_use]
#[inline(always)]
pub const fn txready(&self) -> bool {
let val = (self.0 >> 21usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event TXREADY."]
#[inline(always)]
pub const fn set_txready(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 21usize)) | (((val as u32) & 0x01) << 21usize);
}
#[doc = "Write '1' to disable interrupt for event RXREADY."]
#[must_use]
#[inline(always)]
pub const fn rxready(&self) -> bool {
let val = (self.0 >> 22usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event RXREADY."]
#[inline(always)]
pub const fn set_rxready(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 22usize)) | (((val as u32) & 0x01) << 22usize);
}
#[doc = "Write '1' to disable interrupt for event MHRMATCH."]
#[must_use]
#[inline(always)]
pub const fn mhrmatch(&self) -> bool {
let val = (self.0 >> 23usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event MHRMATCH."]
#[inline(always)]
pub const fn set_mhrmatch(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 23usize)) | (((val as u32) & 0x01) << 23usize);
}
#[doc = "Write '1' to disable interrupt for event SYNC."]
#[must_use]
#[inline(always)]
pub const fn sync(&self) -> bool {
let val = (self.0 >> 26usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event SYNC."]
#[inline(always)]
pub const fn set_sync(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 26usize)) | (((val as u32) & 0x01) << 26usize);
}
#[doc = "Write '1' to disable interrupt for event PHYEND."]
#[must_use]
#[inline(always)]
pub const fn phyend(&self) -> bool {
let val = (self.0 >> 27usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event PHYEND."]
#[inline(always)]
pub const fn set_phyend(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 27usize)) | (((val as u32) & 0x01) << 27usize);
}
#[doc = "Write '1' to disable interrupt for event CTEPRESENT."]
#[must_use]
#[inline(always)]
pub const fn ctepresent(&self) -> bool {
let val = (self.0 >> 28usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event CTEPRESENT."]
#[inline(always)]
pub const fn set_ctepresent(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 28usize)) | (((val as u32) & 0x01) << 28usize);
}
}
impl Default for Int {
#[inline(always)]
fn default() -> Int {
Int(0)
}
}
impl core::fmt::Debug for Int {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Int")
.field("ready", &self.ready())
.field("address", &self.address())
.field("payload", &self.payload())
.field("end", &self.end())
.field("disabled", &self.disabled())
.field("devmatch", &self.devmatch())
.field("devmiss", &self.devmiss())
.field("rssiend", &self.rssiend())
.field("bcmatch", &self.bcmatch())
.field("crcok", &self.crcok())
.field("crcerror", &self.crcerror())
.field("framestart", &self.framestart())
.field("edend", &self.edend())
.field("edstopped", &self.edstopped())
.field("ccaidle", &self.ccaidle())
.field("ccabusy", &self.ccabusy())
.field("ccastopped", &self.ccastopped())
.field("rateboost", &self.rateboost())
.field("txready", &self.txready())
.field("rxready", &self.rxready())
.field("mhrmatch", &self.mhrmatch())
.field("sync", &self.sync())
.field("phyend", &self.phyend())
.field("ctepresent", &self.ctepresent())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Int {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Int {{ ready: {=bool:?}, address: {=bool:?}, payload: {=bool:?}, end: {=bool:?}, disabled: {=bool:?}, devmatch: {=bool:?}, devmiss: {=bool:?}, rssiend: {=bool:?}, bcmatch: {=bool:?}, crcok: {=bool:?}, crcerror: {=bool:?}, framestart: {=bool:?}, edend: {=bool:?}, edstopped: {=bool:?}, ccaidle: {=bool:?}, ccabusy: {=bool:?}, ccastopped: {=bool:?}, rateboost: {=bool:?}, txready: {=bool:?}, rxready: {=bool:?}, mhrmatch: {=bool:?}, sync: {=bool:?}, phyend: {=bool:?}, ctepresent: {=bool:?} }}" , self . ready () , self . address () , self . payload () , self . end () , self . disabled () , self . devmatch () , self . devmiss () , self . rssiend () , self . bcmatch () , self . crcok () , self . crcerror () , self . framestart () , self . edend () , self . edstopped () , self . ccaidle () , self . ccabusy () , self . ccastopped () , self . rateboost () , self . txready () , self . rxready () , self . mhrmatch () , self . sync () , self . phyend () , self . ctepresent ())
}
}
#[doc = "Maximum number of buffer words to transfer."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Maxcnt(pub u32);
impl Maxcnt {
#[doc = "Maximum number of buffer words to transfer."]
#[must_use]
#[inline(always)]
pub const fn maxcnt(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x3fff;
val as u16
}
#[doc = "Maximum number of buffer words to transfer."]
#[inline(always)]
pub const fn set_maxcnt(&mut self, val: u16) {
self.0 = (self.0 & !(0x3fff << 0usize)) | (((val as u32) & 0x3fff) << 0usize);
}
}
impl Default for Maxcnt {
#[inline(always)]
fn default() -> Maxcnt {
Maxcnt(0)
}
}
impl core::fmt::Debug for Maxcnt {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Maxcnt")
.field("maxcnt", &self.maxcnt())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Maxcnt {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Maxcnt {{ maxcnt: {=u16:?} }}", self.maxcnt())
}
}
#[doc = "Data rate and modulation."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Mode(pub u32);
impl Mode {
#[doc = "Radio data rate and modulation setting. The radio supports frequency-shift keying (FSK) modulation."]
#[must_use]
#[inline(always)]
pub const fn mode(&self) -> super::vals::Mode {
let val = (self.0 >> 0usize) & 0x0f;
super::vals::Mode::from_bits(val as u8)
}
#[doc = "Radio data rate and modulation setting. The radio supports frequency-shift keying (FSK) modulation."]
#[inline(always)]
pub const fn set_mode(&mut self, val: super::vals::Mode) {
self.0 = (self.0 & !(0x0f << 0usize)) | (((val.to_bits() as u32) & 0x0f) << 0usize);
}
}
impl Default for Mode {
#[inline(always)]
fn default() -> Mode {
Mode(0)
}
}
impl core::fmt::Debug for Mode {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Mode").field("mode", &self.mode()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Mode {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Mode {{ mode: {:?} }}", self.mode())
}
}
#[doc = "Radio mode configuration register 0."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Modecnf0(pub u32);
impl Modecnf0 {
#[doc = "Radio ramp-up time."]
#[must_use]
#[inline(always)]
pub const fn ru(&self) -> super::vals::Ru {
let val = (self.0 >> 0usize) & 0x01;
super::vals::Ru::from_bits(val as u8)
}
#[doc = "Radio ramp-up time."]
#[inline(always)]
pub const fn set_ru(&mut self, val: super::vals::Ru) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
#[doc = "Default TX value."]
#[must_use]
#[inline(always)]
pub const fn dtx(&self) -> super::vals::Dtx {
let val = (self.0 >> 8usize) & 0x03;
super::vals::Dtx::from_bits(val as u8)
}
#[doc = "Default TX value."]
#[inline(always)]
pub const fn set_dtx(&mut self, val: super::vals::Dtx) {
self.0 = (self.0 & !(0x03 << 8usize)) | (((val.to_bits() as u32) & 0x03) << 8usize);
}
}
impl Default for Modecnf0 {
#[inline(always)]
fn default() -> Modecnf0 {
Modecnf0(0)
}
}
impl core::fmt::Debug for Modecnf0 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Modecnf0")
.field("ru", &self.ru())
.field("dtx", &self.dtx())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Modecnf0 {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Modecnf0 {{ ru: {:?}, dtx: {:?} }}",
self.ru(),
self.dtx()
)
}
}
#[doc = "Packet configuration register 0."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Pcnf0(pub u32);
impl Pcnf0 {
#[doc = "Length on air of LENGTH field in number of bits."]
#[must_use]
#[inline(always)]
pub const fn lflen(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x0f;
val as u8
}
#[doc = "Length on air of LENGTH field in number of bits."]
#[inline(always)]
pub const fn set_lflen(&mut self, val: u8) {
self.0 = (self.0 & !(0x0f << 0usize)) | (((val as u32) & 0x0f) << 0usize);
}
#[doc = "Length on air of S0 field in number of bytes."]
#[must_use]
#[inline(always)]
pub const fn s0len(&self) -> bool {
let val = (self.0 >> 8usize) & 0x01;
val != 0
}
#[doc = "Length on air of S0 field in number of bytes."]
#[inline(always)]
pub const fn set_s0len(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize);
}
#[doc = "Length on air of S1 field in number of bits."]
#[must_use]
#[inline(always)]
pub const fn s1len(&self) -> u8 {
let val = (self.0 >> 16usize) & 0x0f;
val as u8
}
#[doc = "Length on air of S1 field in number of bits."]
#[inline(always)]
pub const fn set_s1len(&mut self, val: u8) {
self.0 = (self.0 & !(0x0f << 16usize)) | (((val as u32) & 0x0f) << 16usize);
}
#[doc = "Include or exclude S1 field in RAM."]
#[must_use]
#[inline(always)]
pub const fn s1incl(&self) -> super::vals::S1incl {
let val = (self.0 >> 20usize) & 0x01;
super::vals::S1incl::from_bits(val as u8)
}
#[doc = "Include or exclude S1 field in RAM."]
#[inline(always)]
pub const fn set_s1incl(&mut self, val: super::vals::S1incl) {
self.0 =
(self.0 & !(0x01 << 20usize)) | (((val.to_bits() as u32) & 0x01) << 20usize);
}
#[doc = "Length of code indicator - Long Range."]
#[must_use]
#[inline(always)]
pub const fn cilen(&self) -> u8 {
let val = (self.0 >> 22usize) & 0x03;
val as u8
}
#[doc = "Length of code indicator - Long Range."]
#[inline(always)]
pub const fn set_cilen(&mut self, val: u8) {
self.0 = (self.0 & !(0x03 << 22usize)) | (((val as u32) & 0x03) << 22usize);
}
#[doc = "Length of preamble on air. Decision point: TASKS_START task."]
#[must_use]
#[inline(always)]
pub const fn plen(&self) -> super::vals::Plen {
let val = (self.0 >> 24usize) & 0x03;
super::vals::Plen::from_bits(val as u8)
}
#[doc = "Length of preamble on air. Decision point: TASKS_START task."]
#[inline(always)]
pub const fn set_plen(&mut self, val: super::vals::Plen) {
self.0 =
(self.0 & !(0x03 << 24usize)) | (((val.to_bits() as u32) & 0x03) << 24usize);
}
#[doc = "Indicates if LENGTH field contains CRC or not."]
#[must_use]
#[inline(always)]
pub const fn crcinc(&self) -> super::vals::Crcinc {
let val = (self.0 >> 26usize) & 0x01;
super::vals::Crcinc::from_bits(val as u8)
}
#[doc = "Indicates if LENGTH field contains CRC or not."]
#[inline(always)]
pub const fn set_crcinc(&mut self, val: super::vals::Crcinc) {
self.0 =
(self.0 & !(0x01 << 26usize)) | (((val.to_bits() as u32) & 0x01) << 26usize);
}
#[doc = "Length of TERM field in Long Range operation."]
#[must_use]
#[inline(always)]
pub const fn termlen(&self) -> u8 {
let val = (self.0 >> 29usize) & 0x03;
val as u8
}
#[doc = "Length of TERM field in Long Range operation."]
#[inline(always)]
pub const fn set_termlen(&mut self, val: u8) {
self.0 = (self.0 & !(0x03 << 29usize)) | (((val as u32) & 0x03) << 29usize);
}
}
impl Default for Pcnf0 {
#[inline(always)]
fn default() -> Pcnf0 {
Pcnf0(0)
}
}
impl core::fmt::Debug for Pcnf0 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Pcnf0")
.field("lflen", &self.lflen())
.field("s0len", &self.s0len())
.field("s1len", &self.s1len())
.field("s1incl", &self.s1incl())
.field("cilen", &self.cilen())
.field("plen", &self.plen())
.field("crcinc", &self.crcinc())
.field("termlen", &self.termlen())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Pcnf0 {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Pcnf0 {{ lflen: {=u8:?}, s0len: {=bool:?}, s1len: {=u8:?}, s1incl: {:?}, cilen: {=u8:?}, plen: {:?}, crcinc: {:?}, termlen: {=u8:?} }}" , self . lflen () , self . s0len () , self . s1len () , self . s1incl () , self . cilen () , self . plen () , self . crcinc () , self . termlen ())
}
}
#[doc = "Packet configuration register 1."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Pcnf1(pub u32);
impl Pcnf1 {
#[doc = "Maximum length of packet payload. If the packet payload is larger than MAXLEN, the radio will truncate the payload to MAXLEN."]
#[must_use]
#[inline(always)]
pub const fn maxlen(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "Maximum length of packet payload. If the packet payload is larger than MAXLEN, the radio will truncate the payload to MAXLEN."]
#[inline(always)]
pub const fn set_maxlen(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
#[doc = "Static length in number of bytes."]
#[must_use]
#[inline(always)]
pub const fn statlen(&self) -> u8 {
let val = (self.0 >> 8usize) & 0xff;
val as u8
}
#[doc = "Static length in number of bytes."]
#[inline(always)]
pub const fn set_statlen(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 8usize)) | (((val as u32) & 0xff) << 8usize);
}
#[doc = "Base address length in number of bytes."]
#[must_use]
#[inline(always)]
pub const fn balen(&self) -> u8 {
let val = (self.0 >> 16usize) & 0x07;
val as u8
}
#[doc = "Base address length in number of bytes."]
#[inline(always)]
pub const fn set_balen(&mut self, val: u8) {
self.0 = (self.0 & !(0x07 << 16usize)) | (((val as u32) & 0x07) << 16usize);
}
#[doc = "On-air endianness of packet, this applies to the S0, LENGTH, S1, and the PAYLOAD fields."]
#[must_use]
#[inline(always)]
pub const fn endian(&self) -> super::vals::Endian {
let val = (self.0 >> 24usize) & 0x01;
super::vals::Endian::from_bits(val as u8)
}
#[doc = "On-air endianness of packet, this applies to the S0, LENGTH, S1, and the PAYLOAD fields."]
#[inline(always)]
pub const fn set_endian(&mut self, val: super::vals::Endian) {
self.0 =
(self.0 & !(0x01 << 24usize)) | (((val.to_bits() as u32) & 0x01) << 24usize);
}
#[doc = "Enable or disable packet whitening."]
#[must_use]
#[inline(always)]
pub const fn whiteen(&self) -> bool {
let val = (self.0 >> 25usize) & 0x01;
val != 0
}
#[doc = "Enable or disable packet whitening."]
#[inline(always)]
pub const fn set_whiteen(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 25usize)) | (((val as u32) & 0x01) << 25usize);
}
}
impl Default for Pcnf1 {
#[inline(always)]
fn default() -> Pcnf1 {
Pcnf1(0)
}
}
impl core::fmt::Debug for Pcnf1 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Pcnf1")
.field("maxlen", &self.maxlen())
.field("statlen", &self.statlen())
.field("balen", &self.balen())
.field("endian", &self.endian())
.field("whiteen", &self.whiteen())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Pcnf1 {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Pcnf1 {{ maxlen: {=u8:?}, statlen: {=u8:?}, balen: {=u8:?}, endian: {:?}, whiteen: {=bool:?} }}" , self . maxlen () , self . statlen () , self . balen () , self . endian () , self . whiteen ())
}
}
#[doc = "Payload status."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Pdustat(pub u32);
impl Pdustat {
#[doc = "Status on payload length vs. PCNF1.MAXLEN."]
#[must_use]
#[inline(always)]
pub const fn pdustat(&self) -> super::vals::Pdustat {
let val = (self.0 >> 0usize) & 0x01;
super::vals::Pdustat::from_bits(val as u8)
}
#[doc = "Status on payload length vs. PCNF1.MAXLEN."]
#[inline(always)]
pub const fn set_pdustat(&mut self, val: super::vals::Pdustat) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
#[doc = "Status on what rate packet is received with in Long Range."]
#[must_use]
#[inline(always)]
pub const fn cistat(&self) -> super::vals::Cistat {
let val = (self.0 >> 1usize) & 0x03;
super::vals::Cistat::from_bits(val as u8)
}
#[doc = "Status on what rate packet is received with in Long Range."]
#[inline(always)]
pub const fn set_cistat(&mut self, val: super::vals::Cistat) {
self.0 = (self.0 & !(0x03 << 1usize)) | (((val.to_bits() as u32) & 0x03) << 1usize);
}
}
impl Default for Pdustat {
#[inline(always)]
fn default() -> Pdustat {
Pdustat(0)
}
}
impl core::fmt::Debug for Pdustat {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Pdustat")
.field("pdustat", &self.pdustat())
.field("cistat", &self.cistat())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Pdustat {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Pdustat {{ pdustat: {:?}, cistat: {:?} }}",
self.pdustat(),
self.cistat()
)
}
}
#[doc = "Peripheral power control."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Power(pub u32);
impl Power {
#[doc = "Peripheral power control. The peripheral and its registers will be reset to its initial state by switching the peripheral off and then back on again."]
#[must_use]
#[inline(always)]
pub const fn power(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Peripheral power control. The peripheral and its registers will be reset to its initial state by switching the peripheral off and then back on again."]
#[inline(always)]
pub const fn set_power(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for Power {
#[inline(always)]
fn default() -> Power {
Power(0)
}
}
impl core::fmt::Debug for Power {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Power")
.field("power", &self.power())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Power {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Power {{ power: {=bool:?} }}", self.power())
}
}
#[doc = "Prefixes bytes for logical addresses 0-3."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Prefix0(pub u32);
impl Prefix0 {
#[doc = "Address prefix 0."]
#[must_use]
#[inline(always)]
pub const fn ap0(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "Address prefix 0."]
#[inline(always)]
pub const fn set_ap0(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
#[doc = "Address prefix 1."]
#[must_use]
#[inline(always)]
pub const fn ap1(&self) -> u8 {
let val = (self.0 >> 8usize) & 0xff;
val as u8
}
#[doc = "Address prefix 1."]
#[inline(always)]
pub const fn set_ap1(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 8usize)) | (((val as u32) & 0xff) << 8usize);
}
#[doc = "Address prefix 2."]
#[must_use]
#[inline(always)]
pub const fn ap2(&self) -> u8 {
let val = (self.0 >> 16usize) & 0xff;
val as u8
}
#[doc = "Address prefix 2."]
#[inline(always)]
pub const fn set_ap2(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 16usize)) | (((val as u32) & 0xff) << 16usize);
}
#[doc = "Address prefix 3."]
#[must_use]
#[inline(always)]
pub const fn ap3(&self) -> u8 {
let val = (self.0 >> 24usize) & 0xff;
val as u8
}
#[doc = "Address prefix 3."]
#[inline(always)]
pub const fn set_ap3(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 24usize)) | (((val as u32) & 0xff) << 24usize);
}
}
impl Default for Prefix0 {
#[inline(always)]
fn default() -> Prefix0 {
Prefix0(0)
}
}
impl core::fmt::Debug for Prefix0 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Prefix0")
.field("ap0", &self.ap0())
.field("ap1", &self.ap1())
.field("ap2", &self.ap2())
.field("ap3", &self.ap3())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Prefix0 {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Prefix0 {{ ap0: {=u8:?}, ap1: {=u8:?}, ap2: {=u8:?}, ap3: {=u8:?} }}",
self.ap0(),
self.ap1(),
self.ap2(),
self.ap3()
)
}
}
#[doc = "Prefixes bytes for logical addresses 4-7."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Prefix1(pub u32);
impl Prefix1 {
#[doc = "Address prefix 4."]
#[must_use]
#[inline(always)]
pub const fn ap4(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "Address prefix 4."]
#[inline(always)]
pub const fn set_ap4(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
#[doc = "Address prefix 5."]
#[must_use]
#[inline(always)]
pub const fn ap5(&self) -> u8 {
let val = (self.0 >> 8usize) & 0xff;
val as u8
}
#[doc = "Address prefix 5."]
#[inline(always)]
pub const fn set_ap5(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 8usize)) | (((val as u32) & 0xff) << 8usize);
}
#[doc = "Address prefix 6."]
#[must_use]
#[inline(always)]
pub const fn ap6(&self) -> u8 {
let val = (self.0 >> 16usize) & 0xff;
val as u8
}
#[doc = "Address prefix 6."]
#[inline(always)]
pub const fn set_ap6(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 16usize)) | (((val as u32) & 0xff) << 16usize);
}
#[doc = "Address prefix 7."]
#[must_use]
#[inline(always)]
pub const fn ap7(&self) -> u8 {
let val = (self.0 >> 24usize) & 0xff;
val as u8
}
#[doc = "Address prefix 7."]
#[inline(always)]
pub const fn set_ap7(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 24usize)) | (((val as u32) & 0xff) << 24usize);
}
}
impl Default for Prefix1 {
#[inline(always)]
fn default() -> Prefix1 {
Prefix1(0)
}
}
impl core::fmt::Debug for Prefix1 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Prefix1")
.field("ap4", &self.ap4())
.field("ap5", &self.ap5())
.field("ap6", &self.ap6())
.field("ap7", &self.ap7())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Prefix1 {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Prefix1 {{ ap4: {=u8:?}, ap5: {=u8:?}, ap6: {=u8:?}, ap7: {=u8:?} }}",
self.ap4(),
self.ap5(),
self.ap6(),
self.ap7()
)
}
}
#[doc = "RSSI sample."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Rssisample(pub u32);
impl Rssisample {
#[doc = "RSSI sample."]
#[must_use]
#[inline(always)]
pub const fn rssisample(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x7f;
val as u8
}
#[doc = "RSSI sample."]
#[inline(always)]
pub const fn set_rssisample(&mut self, val: u8) {
self.0 = (self.0 & !(0x7f << 0usize)) | (((val as u32) & 0x7f) << 0usize);
}
}
impl Default for Rssisample {
#[inline(always)]
fn default() -> Rssisample {
Rssisample(0)
}
}
impl core::fmt::Debug for Rssisample {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Rssisample")
.field("rssisample", &self.rssisample())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Rssisample {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Rssisample {{ rssisample: {=u8:?} }}", self.rssisample())
}
}
#[doc = "Receive address select."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Rxaddresses(pub u32);
impl Rxaddresses {
#[doc = "Enable or disable reception on logical address 0."]
#[must_use]
#[inline(always)]
pub const fn addr0(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Enable or disable reception on logical address 0."]
#[inline(always)]
pub const fn set_addr0(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Enable or disable reception on logical address 1."]
#[must_use]
#[inline(always)]
pub const fn addr1(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Enable or disable reception on logical address 1."]
#[inline(always)]
pub const fn set_addr1(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "Enable or disable reception on logical address 2."]
#[must_use]
#[inline(always)]
pub const fn addr2(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Enable or disable reception on logical address 2."]
#[inline(always)]
pub const fn set_addr2(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "Enable or disable reception on logical address 3."]
#[must_use]
#[inline(always)]
pub const fn addr3(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "Enable or disable reception on logical address 3."]
#[inline(always)]
pub const fn set_addr3(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
#[doc = "Enable or disable reception on logical address 4."]
#[must_use]
#[inline(always)]
pub const fn addr4(&self) -> bool {
let val = (self.0 >> 4usize) & 0x01;
val != 0
}
#[doc = "Enable or disable reception on logical address 4."]
#[inline(always)]
pub const fn set_addr4(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
}
#[doc = "Enable or disable reception on logical address 5."]
#[must_use]
#[inline(always)]
pub const fn addr5(&self) -> bool {
let val = (self.0 >> 5usize) & 0x01;
val != 0
}
#[doc = "Enable or disable reception on logical address 5."]
#[inline(always)]
pub const fn set_addr5(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
}
#[doc = "Enable or disable reception on logical address 6."]
#[must_use]
#[inline(always)]
pub const fn addr6(&self) -> bool {
let val = (self.0 >> 6usize) & 0x01;
val != 0
}
#[doc = "Enable or disable reception on logical address 6."]
#[inline(always)]
pub const fn set_addr6(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize);
}
#[doc = "Enable or disable reception on logical address 7."]
#[must_use]
#[inline(always)]
pub const fn addr7(&self) -> bool {
let val = (self.0 >> 7usize) & 0x01;
val != 0
}
#[doc = "Enable or disable reception on logical address 7."]
#[inline(always)]
pub const fn set_addr7(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize);
}
}
impl Default for Rxaddresses {
#[inline(always)]
fn default() -> Rxaddresses {
Rxaddresses(0)
}
}
impl core::fmt::Debug for Rxaddresses {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Rxaddresses")
.field("addr0", &self.addr0())
.field("addr1", &self.addr1())
.field("addr2", &self.addr2())
.field("addr3", &self.addr3())
.field("addr4", &self.addr4())
.field("addr5", &self.addr5())
.field("addr6", &self.addr6())
.field("addr7", &self.addr7())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Rxaddresses {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Rxaddresses {{ addr0: {=bool:?}, addr1: {=bool:?}, addr2: {=bool:?}, addr3: {=bool:?}, addr4: {=bool:?}, addr5: {=bool:?}, addr6: {=bool:?}, addr7: {=bool:?} }}" , self . addr0 () , self . addr1 () , self . addr2 () , self . addr3 () , self . addr4 () , self . addr5 () , self . addr6 () , self . addr7 ())
}
}
#[doc = "CRC field of previously received packet."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Rxcrc(pub u32);
impl Rxcrc {
#[doc = "CRC field of previously received packet."]
#[must_use]
#[inline(always)]
pub const fn rxcrc(&self) -> u32 {
let val = (self.0 >> 0usize) & 0x00ff_ffff;
val as u32
}
#[doc = "CRC field of previously received packet."]
#[inline(always)]
pub const fn set_rxcrc(&mut self, val: u32) {
self.0 =
(self.0 & !(0x00ff_ffff << 0usize)) | (((val as u32) & 0x00ff_ffff) << 0usize);
}
}
impl Default for Rxcrc {
#[inline(always)]
fn default() -> Rxcrc {
Rxcrc(0)
}
}
impl core::fmt::Debug for Rxcrc {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Rxcrc")
.field("rxcrc", &self.rxcrc())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Rxcrc {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Rxcrc {{ rxcrc: {=u32:?} }}", self.rxcrc())
}
}
#[doc = "Received address."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Rxmatch(pub u32);
impl Rxmatch {
#[doc = "Received address."]
#[must_use]
#[inline(always)]
pub const fn rxmatch(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x07;
val as u8
}
#[doc = "Received address."]
#[inline(always)]
pub const fn set_rxmatch(&mut self, val: u8) {
self.0 = (self.0 & !(0x07 << 0usize)) | (((val as u32) & 0x07) << 0usize);
}
}
impl Default for Rxmatch {
#[inline(always)]
fn default() -> Rxmatch {
Rxmatch(0)
}
}
impl core::fmt::Debug for Rxmatch {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Rxmatch")
.field("rxmatch", &self.rxmatch())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Rxmatch {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Rxmatch {{ rxmatch: {=u8:?} }}", self.rxmatch())
}
}
#[doc = "IEEE 802.15.4 start of frame delimiter."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Sfd(pub u32);
impl Sfd {
#[doc = "IEEE 802.15.4 start of frame delimiter."]
#[must_use]
#[inline(always)]
pub const fn sfd(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "IEEE 802.15.4 start of frame delimiter."]
#[inline(always)]
pub const fn set_sfd(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
}
impl Default for Sfd {
#[inline(always)]
fn default() -> Sfd {
Sfd(0)
}
}
impl core::fmt::Debug for Sfd {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Sfd").field("sfd", &self.sfd()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Sfd {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Sfd {{ sfd: {=u8:?} }}", self.sfd())
}
}
#[doc = "Shortcuts between local events and tasks."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Shorts(pub u32);
impl Shorts {
#[doc = "Shortcut between event READY and task START."]
#[must_use]
#[inline(always)]
pub const fn ready_start(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event READY and task START."]
#[inline(always)]
pub const fn set_ready_start(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Shortcut between event END and task DISABLE."]
#[must_use]
#[inline(always)]
pub const fn end_disable(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event END and task DISABLE."]
#[inline(always)]
pub const fn set_end_disable(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "Shortcut between event DISABLED and task TXEN."]
#[must_use]
#[inline(always)]
pub const fn disabled_txen(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event DISABLED and task TXEN."]
#[inline(always)]
pub const fn set_disabled_txen(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "Shortcut between event DISABLED and task RXEN."]
#[must_use]
#[inline(always)]
pub const fn disabled_rxen(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event DISABLED and task RXEN."]
#[inline(always)]
pub const fn set_disabled_rxen(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
#[doc = "Shortcut between event ADDRESS and task RSSISTART."]
#[must_use]
#[inline(always)]
pub const fn address_rssistart(&self) -> bool {
let val = (self.0 >> 4usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event ADDRESS and task RSSISTART."]
#[inline(always)]
pub const fn set_address_rssistart(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
}
#[doc = "Shortcut between event END and task START."]
#[must_use]
#[inline(always)]
pub const fn end_start(&self) -> bool {
let val = (self.0 >> 5usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event END and task START."]
#[inline(always)]
pub const fn set_end_start(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
}
#[doc = "Shortcut between event ADDRESS and task BCSTART."]
#[must_use]
#[inline(always)]
pub const fn address_bcstart(&self) -> bool {
let val = (self.0 >> 6usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event ADDRESS and task BCSTART."]
#[inline(always)]
pub const fn set_address_bcstart(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize);
}
#[doc = "Shortcut between event DISABLED and task RSSISTOP."]
#[must_use]
#[inline(always)]
pub const fn disabled_rssistop(&self) -> bool {
let val = (self.0 >> 8usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event DISABLED and task RSSISTOP."]
#[inline(always)]
pub const fn set_disabled_rssistop(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize);
}
#[doc = "Shortcut between event RXREADY and task CCASTART."]
#[must_use]
#[inline(always)]
pub const fn rxready_ccastart(&self) -> bool {
let val = (self.0 >> 11usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event RXREADY and task CCASTART."]
#[inline(always)]
pub const fn set_rxready_ccastart(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 11usize)) | (((val as u32) & 0x01) << 11usize);
}
#[doc = "Shortcut between event CCAIDLE and task TXEN."]
#[must_use]
#[inline(always)]
pub const fn ccaidle_txen(&self) -> bool {
let val = (self.0 >> 12usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event CCAIDLE and task TXEN."]
#[inline(always)]
pub const fn set_ccaidle_txen(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 12usize)) | (((val as u32) & 0x01) << 12usize);
}
#[doc = "Shortcut between event CCABUSY and task DISABLE."]
#[must_use]
#[inline(always)]
pub const fn ccabusy_disable(&self) -> bool {
let val = (self.0 >> 13usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event CCABUSY and task DISABLE."]
#[inline(always)]
pub const fn set_ccabusy_disable(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 13usize)) | (((val as u32) & 0x01) << 13usize);
}
#[doc = "Shortcut between event FRAMESTART and task BCSTART."]
#[must_use]
#[inline(always)]
pub const fn framestart_bcstart(&self) -> bool {
let val = (self.0 >> 14usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event FRAMESTART and task BCSTART."]
#[inline(always)]
pub const fn set_framestart_bcstart(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 14usize)) | (((val as u32) & 0x01) << 14usize);
}
#[doc = "Shortcut between event READY and task EDSTART."]
#[must_use]
#[inline(always)]
pub const fn ready_edstart(&self) -> bool {
let val = (self.0 >> 15usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event READY and task EDSTART."]
#[inline(always)]
pub const fn set_ready_edstart(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 15usize)) | (((val as u32) & 0x01) << 15usize);
}
#[doc = "Shortcut between event EDEND and task DISABLE."]
#[must_use]
#[inline(always)]
pub const fn edend_disable(&self) -> bool {
let val = (self.0 >> 16usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event EDEND and task DISABLE."]
#[inline(always)]
pub const fn set_edend_disable(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 16usize)) | (((val as u32) & 0x01) << 16usize);
}
#[doc = "Shortcut between event CCAIDLE and task STOP."]
#[must_use]
#[inline(always)]
pub const fn ccaidle_stop(&self) -> bool {
let val = (self.0 >> 17usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event CCAIDLE and task STOP."]
#[inline(always)]
pub const fn set_ccaidle_stop(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 17usize)) | (((val as u32) & 0x01) << 17usize);
}
#[doc = "Shortcut between event TXREADY and task START."]
#[must_use]
#[inline(always)]
pub const fn txready_start(&self) -> bool {
let val = (self.0 >> 18usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event TXREADY and task START."]
#[inline(always)]
pub const fn set_txready_start(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 18usize)) | (((val as u32) & 0x01) << 18usize);
}
#[doc = "Shortcut between event RXREADY and task START."]
#[must_use]
#[inline(always)]
pub const fn rxready_start(&self) -> bool {
let val = (self.0 >> 19usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event RXREADY and task START."]
#[inline(always)]
pub const fn set_rxready_start(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 19usize)) | (((val as u32) & 0x01) << 19usize);
}
#[doc = "Shortcut between event PHYEND and task DISABLE."]
#[must_use]
#[inline(always)]
pub const fn phyend_disable(&self) -> bool {
let val = (self.0 >> 20usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event PHYEND and task DISABLE."]
#[inline(always)]
pub const fn set_phyend_disable(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 20usize)) | (((val as u32) & 0x01) << 20usize);
}
#[doc = "Shortcut between event PHYEND and task START."]
#[must_use]
#[inline(always)]
pub const fn phyend_start(&self) -> bool {
let val = (self.0 >> 21usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event PHYEND and task START."]
#[inline(always)]
pub const fn set_phyend_start(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 21usize)) | (((val as u32) & 0x01) << 21usize);
}
}
impl Default for Shorts {
#[inline(always)]
fn default() -> Shorts {
Shorts(0)
}
}
impl core::fmt::Debug for Shorts {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Shorts")
.field("ready_start", &self.ready_start())
.field("end_disable", &self.end_disable())
.field("disabled_txen", &self.disabled_txen())
.field("disabled_rxen", &self.disabled_rxen())
.field("address_rssistart", &self.address_rssistart())
.field("end_start", &self.end_start())
.field("address_bcstart", &self.address_bcstart())
.field("disabled_rssistop", &self.disabled_rssistop())
.field("rxready_ccastart", &self.rxready_ccastart())
.field("ccaidle_txen", &self.ccaidle_txen())
.field("ccabusy_disable", &self.ccabusy_disable())
.field("framestart_bcstart", &self.framestart_bcstart())
.field("ready_edstart", &self.ready_edstart())
.field("edend_disable", &self.edend_disable())
.field("ccaidle_stop", &self.ccaidle_stop())
.field("txready_start", &self.txready_start())
.field("rxready_start", &self.rxready_start())
.field("phyend_disable", &self.phyend_disable())
.field("phyend_start", &self.phyend_start())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Shorts {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Shorts {{ ready_start: {=bool:?}, end_disable: {=bool:?}, disabled_txen: {=bool:?}, disabled_rxen: {=bool:?}, address_rssistart: {=bool:?}, end_start: {=bool:?}, address_bcstart: {=bool:?}, disabled_rssistop: {=bool:?}, rxready_ccastart: {=bool:?}, ccaidle_txen: {=bool:?}, ccabusy_disable: {=bool:?}, framestart_bcstart: {=bool:?}, ready_edstart: {=bool:?}, edend_disable: {=bool:?}, ccaidle_stop: {=bool:?}, txready_start: {=bool:?}, rxready_start: {=bool:?}, phyend_disable: {=bool:?}, phyend_start: {=bool:?} }}" , self . ready_start () , self . end_disable () , self . disabled_txen () , self . disabled_rxen () , self . address_rssistart () , self . end_start () , self . address_bcstart () , self . disabled_rssistop () , self . rxready_ccastart () , self . ccaidle_txen () , self . ccabusy_disable () , self . framestart_bcstart () , self . ready_edstart () , self . edend_disable () , self . ccaidle_stop () , self . txready_start () , self . rxready_start () , self . phyend_disable () , self . phyend_start ())
}
}
#[doc = "Current radio state."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct State(pub u32);
impl State {
#[doc = "Current radio state."]
#[must_use]
#[inline(always)]
pub const fn state(&self) -> super::vals::State {
let val = (self.0 >> 0usize) & 0x0f;
super::vals::State::from_bits(val as u8)
}
#[doc = "Current radio state."]
#[inline(always)]
pub const fn set_state(&mut self, val: super::vals::State) {
self.0 = (self.0 & !(0x0f << 0usize)) | (((val.to_bits() as u32) & 0x0f) << 0usize);
}
}
impl Default for State {
#[inline(always)]
fn default() -> State {
State(0)
}
}
impl core::fmt::Debug for State {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("State")
.field("state", &self.state())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for State {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "State {{ state: {:?} }}", self.state())
}
}
#[doc = "GPIO patterns to be used for each antenna."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Switchpattern(pub u32);
impl Switchpattern {
#[doc = "Fill array of GPIO patterns for antenna control."]
#[must_use]
#[inline(always)]
pub const fn switchpattern(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "Fill array of GPIO patterns for antenna control."]
#[inline(always)]
pub const fn set_switchpattern(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
}
impl Default for Switchpattern {
#[inline(always)]
fn default() -> Switchpattern {
Switchpattern(0)
}
}
impl core::fmt::Debug for Switchpattern {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Switchpattern")
.field("switchpattern", &self.switchpattern())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Switchpattern {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Switchpattern {{ switchpattern: {=u8:?} }}",
self.switchpattern()
)
}
}
#[doc = "Interframe spacing in us."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Tifs(pub u32);
impl Tifs {
#[doc = "Interframe spacing in us."]
#[must_use]
#[inline(always)]
pub const fn tifs(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x03ff;
val as u16
}
#[doc = "Interframe spacing in us."]
#[inline(always)]
pub const fn set_tifs(&mut self, val: u16) {
self.0 = (self.0 & !(0x03ff << 0usize)) | (((val as u32) & 0x03ff) << 0usize);
}
}
impl Default for Tifs {
#[inline(always)]
fn default() -> Tifs {
Tifs(0)
}
}
impl core::fmt::Debug for Tifs {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Tifs").field("tifs", &self.tifs()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Tifs {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Tifs {{ tifs: {=u16:?} }}", self.tifs())
}
}
#[doc = "Transmit address select."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Txaddress(pub u32);
impl Txaddress {
#[doc = "Transmit address select."]
#[must_use]
#[inline(always)]
pub const fn txaddress(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x07;
val as u8
}
#[doc = "Transmit address select."]
#[inline(always)]
pub const fn set_txaddress(&mut self, val: u8) {
self.0 = (self.0 & !(0x07 << 0usize)) | (((val as u32) & 0x07) << 0usize);
}
}
impl Default for Txaddress {
#[inline(always)]
fn default() -> Txaddress {
Txaddress(0)
}
}
impl core::fmt::Debug for Txaddress {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Txaddress")
.field("txaddress", &self.txaddress())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Txaddress {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Txaddress {{ txaddress: {=u8:?} }}", self.txaddress())
}
}
#[doc = "Output power."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Txpower(pub u32);
impl Txpower {
#[doc = "RADIO output power."]
#[must_use]
#[inline(always)]
pub const fn txpower(&self) -> super::vals::Txpower {
let val = (self.0 >> 0usize) & 0xff;
super::vals::Txpower::from_bits(val as u8)
}
#[doc = "RADIO output power."]
#[inline(always)]
pub const fn set_txpower(&mut self, val: super::vals::Txpower) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val.to_bits() as u32) & 0xff) << 0usize);
}
}
impl Default for Txpower {
#[inline(always)]
fn default() -> Txpower {
Txpower(0)
}
}
impl core::fmt::Debug for Txpower {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Txpower")
.field("txpower", &self.txpower())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Txpower {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Txpower {{ txpower: {:?} }}", self.txpower())
}
}
}
pub mod vals {
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Ccamode {
#[doc = "Energy above threshold."]
EdMode = 0x0,
#[doc = "Carrier seen."]
CarrierMode = 0x01,
#[doc = "Energy above threshold AND carrier seen."]
CarrierAndEdMode = 0x02,
#[doc = "Energy above threshold OR carrier seen."]
CarrierOrEdMode = 0x03,
#[doc = "Energy above threshold test mode that will abort when first ED measurement over threshold is seen. No averaging."]
EdModeTest1 = 0x04,
_RESERVED_5 = 0x05,
_RESERVED_6 = 0x06,
_RESERVED_7 = 0x07,
}
impl Ccamode {
#[inline(always)]
pub const fn from_bits(val: u8) -> Ccamode {
unsafe { core::mem::transmute(val & 0x07) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Ccamode {
#[inline(always)]
fn from(val: u8) -> Ccamode {
Ccamode::from_bits(val)
}
}
impl From<Ccamode> for u8 {
#[inline(always)]
fn from(val: Ccamode) -> u8 {
Ccamode::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Cistat {
#[doc = "Frame is received at 125 kbps."]
Lr125kbit = 0x0,
#[doc = "Frame is received at 500 kbps."]
Lr500kbit = 0x01,
_RESERVED_2 = 0x02,
_RESERVED_3 = 0x03,
}
impl Cistat {
#[inline(always)]
pub const fn from_bits(val: u8) -> Cistat {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Cistat {
#[inline(always)]
fn from(val: u8) -> Cistat {
Cistat::from_bits(val)
}
}
impl From<Cistat> for u8 {
#[inline(always)]
fn from(val: Cistat) -> u8 {
Cistat::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Crcinc {
#[doc = "LENGTH does not contain CRC."]
Exclude = 0x0,
#[doc = "LENGTH includes CRC."]
Include = 0x01,
}
impl Crcinc {
#[inline(always)]
pub const fn from_bits(val: u8) -> Crcinc {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Crcinc {
#[inline(always)]
fn from(val: u8) -> Crcinc {
Crcinc::from_bits(val)
}
}
impl From<Crcinc> for u8 {
#[inline(always)]
fn from(val: Crcinc) -> u8 {
Crcinc::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Crcstatus {
#[doc = "Packet received with CRC error."]
CrcError = 0x0,
#[doc = "Packet received with CRC ok."]
CrcOk = 0x01,
}
impl Crcstatus {
#[inline(always)]
pub const fn from_bits(val: u8) -> Crcstatus {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Crcstatus {
#[inline(always)]
fn from(val: u8) -> Crcstatus {
Crcstatus::from_bits(val)
}
}
impl From<Crcstatus> for u8 {
#[inline(always)]
fn from(val: Crcstatus) -> u8 {
Crcstatus::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Cteinlinerxmode1us {
_RESERVED_0 = 0x0,
#[doc = "4 us."]
_4us = 0x01,
#[doc = "2 us."]
_2us = 0x02,
#[doc = "1 us."]
_1us = 0x03,
#[doc = "0.5 us."]
_500ns = 0x04,
#[doc = "0.25 us."]
_250ns = 0x05,
#[doc = "0.125 us."]
_125ns = 0x06,
_RESERVED_7 = 0x07,
}
impl Cteinlinerxmode1us {
#[inline(always)]
pub const fn from_bits(val: u8) -> Cteinlinerxmode1us {
unsafe { core::mem::transmute(val & 0x07) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Cteinlinerxmode1us {
#[inline(always)]
fn from(val: u8) -> Cteinlinerxmode1us {
Cteinlinerxmode1us::from_bits(val)
}
}
impl From<Cteinlinerxmode1us> for u8 {
#[inline(always)]
fn from(val: Cteinlinerxmode1us) -> u8 {
Cteinlinerxmode1us::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Cteinlinerxmode2us {
_RESERVED_0 = 0x0,
#[doc = "4 us."]
_4us = 0x01,
#[doc = "2 us."]
_2us = 0x02,
#[doc = "1 us."]
_1us = 0x03,
#[doc = "0.5 us."]
_500ns = 0x04,
#[doc = "0.25 us."]
_250ns = 0x05,
#[doc = "0.125 us."]
_125ns = 0x06,
_RESERVED_7 = 0x07,
}
impl Cteinlinerxmode2us {
#[inline(always)]
pub const fn from_bits(val: u8) -> Cteinlinerxmode2us {
unsafe { core::mem::transmute(val & 0x07) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Cteinlinerxmode2us {
#[inline(always)]
fn from(val: u8) -> Cteinlinerxmode2us {
Cteinlinerxmode2us::from_bits(val)
}
}
impl From<Cteinlinerxmode2us> for u8 {
#[inline(always)]
fn from(val: Cteinlinerxmode2us) -> u8 {
Cteinlinerxmode2us::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Ctetimevalidrange {
#[doc = "20 in 8 us unit (default) Set to 20 if parsed CTETime is larger than 20."]
_20 = 0x0,
#[doc = "31 in 8 us unit."]
_31 = 0x01,
#[doc = "63 in 8 us unit."]
_63 = 0x02,
_RESERVED_3 = 0x03,
}
impl Ctetimevalidrange {
#[inline(always)]
pub const fn from_bits(val: u8) -> Ctetimevalidrange {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Ctetimevalidrange {
#[inline(always)]
fn from(val: u8) -> Ctetimevalidrange {
Ctetimevalidrange::from_bits(val)
}
}
impl From<Ctetimevalidrange> for u8 {
#[inline(always)]
fn from(val: Ctetimevalidrange) -> u8 {
Ctetimevalidrange::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Dfeinextension {
#[doc = "Antenna switching/sampling is done in the packet payload."]
Payload = 0x0,
#[doc = "AoA/AoD procedure triggered at end of CRC."]
Crc = 0x01,
}
impl Dfeinextension {
#[inline(always)]
pub const fn from_bits(val: u8) -> Dfeinextension {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Dfeinextension {
#[inline(always)]
fn from(val: u8) -> Dfeinextension {
Dfeinextension::from_bits(val)
}
}
impl From<Dfeinextension> for u8 {
#[inline(always)]
fn from(val: Dfeinextension) -> u8 {
Dfeinextension::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Dfeopmode {
#[doc = "Direction finding mode disabled."]
Disabled = 0x0,
_RESERVED_1 = 0x01,
#[doc = "Direction finding mode set to AoD."]
AoD = 0x02,
#[doc = "Direction finding mode set to AoA."]
AoA = 0x03,
}
impl Dfeopmode {
#[inline(always)]
pub const fn from_bits(val: u8) -> Dfeopmode {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Dfeopmode {
#[inline(always)]
fn from(val: u8) -> Dfeopmode {
Dfeopmode::from_bits(val)
}
}
impl From<Dfeopmode> for u8 {
#[inline(always)]
fn from(val: Dfeopmode) -> u8 {
Dfeopmode::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Dtx {
#[doc = "Transmit '1'."]
B1 = 0x0,
#[doc = "Transmit '0'."]
B0 = 0x01,
#[doc = "Transmit center frequency."]
Center = 0x02,
_RESERVED_3 = 0x03,
}
impl Dtx {
#[inline(always)]
pub const fn from_bits(val: u8) -> Dtx {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Dtx {
#[inline(always)]
fn from(val: u8) -> Dtx {
Dtx::from_bits(val)
}
}
impl From<Dtx> for u8 {
#[inline(always)]
fn from(val: Dtx) -> u8 {
Dtx::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Endian {
#[doc = "Least significant bit on air first."]
Little = 0x0,
#[doc = "Most significant bit on air first."]
Big = 0x01,
}
impl Endian {
#[inline(always)]
pub const fn from_bits(val: u8) -> Endian {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Endian {
#[inline(always)]
fn from(val: u8) -> Endian {
Endian::from_bits(val)
}
}
impl From<Endian> for u8 {
#[inline(always)]
fn from(val: Endian) -> u8 {
Endian::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Len {
#[doc = "CRC length is zero and CRC calculation is disabled."]
Disabled = 0x0,
#[doc = "CRC length is one byte and CRC calculation is enabled."]
One = 0x01,
#[doc = "CRC length is two bytes and CRC calculation is enabled."]
Two = 0x02,
#[doc = "CRC length is three bytes and CRC calculation is enabled."]
Three = 0x03,
}
impl Len {
#[inline(always)]
pub const fn from_bits(val: u8) -> Len {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Len {
#[inline(always)]
fn from(val: u8) -> Len {
Len::from_bits(val)
}
}
impl From<Len> for u8 {
#[inline(always)]
fn from(val: Len) -> u8 {
Len::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Map {
#[doc = "Channel map between 2400 MHz and 2500 MHz."]
Default = 0x0,
#[doc = "Channel map between 2360 MHz and 2460 MHz."]
Low = 0x01,
}
impl Map {
#[inline(always)]
pub const fn from_bits(val: u8) -> Map {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Map {
#[inline(always)]
fn from(val: u8) -> Map {
Map::from_bits(val)
}
}
impl From<Map> for u8 {
#[inline(always)]
fn from(val: Map) -> u8 {
Map::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Mode {
#[doc = "1 Mbps Nordic proprietary radio mode."]
Nrf1mbit = 0x0,
#[doc = "2 Mbps Nordic proprietary radio mode."]
Nrf2mbit = 0x01,
_RESERVED_2 = 0x02,
#[doc = "1 Mbps BLE."]
Ble1mbit = 0x03,
#[doc = "2 Mbps BLE."]
Ble2mbit = 0x04,
#[doc = "Long Range 125 kbps TX, 125 kbps and 500 kbps RX."]
BleLr125kbit = 0x05,
#[doc = "Long Range 500 kbps TX, 125 kbps and 500 kbps RX."]
BleLr500kbit = 0x06,
_RESERVED_7 = 0x07,
_RESERVED_8 = 0x08,
_RESERVED_9 = 0x09,
_RESERVED_a = 0x0a,
_RESERVED_b = 0x0b,
_RESERVED_c = 0x0c,
_RESERVED_d = 0x0d,
_RESERVED_e = 0x0e,
#[doc = "IEEE 802.15.4-2006 250 kbps."]
Ieee802154250kbit = 0x0f,
}
impl Mode {
#[inline(always)]
pub const fn from_bits(val: u8) -> Mode {
unsafe { core::mem::transmute(val & 0x0f) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Mode {
#[inline(always)]
fn from(val: u8) -> Mode {
Mode::from_bits(val)
}
}
impl From<Mode> for u8 {
#[inline(always)]
fn from(val: Mode) -> u8 {
Mode::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Pdustat {
#[doc = "Payload less than PCNF1.MAXLEN."]
LessThan = 0x0,
#[doc = "Payload greater than PCNF1.MAXLEN."]
GreaterThan = 0x01,
}
impl Pdustat {
#[inline(always)]
pub const fn from_bits(val: u8) -> Pdustat {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Pdustat {
#[inline(always)]
fn from(val: u8) -> Pdustat {
Pdustat::from_bits(val)
}
}
impl From<Pdustat> for u8 {
#[inline(always)]
fn from(val: Pdustat) -> u8 {
Pdustat::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Plen {
#[doc = "8-bit preamble."]
_8bit = 0x0,
#[doc = "16-bit preamble."]
_16bit = 0x01,
#[doc = "32-bit zero preamble - used for IEEE 802.15.4."]
_32bitZero = 0x02,
#[doc = "Preamble - used for Bluetooth LE Long Range."]
LongRange = 0x03,
}
impl Plen {
#[inline(always)]
pub const fn from_bits(val: u8) -> Plen {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Plen {
#[inline(always)]
fn from(val: u8) -> Plen {
Plen::from_bits(val)
}
}
impl From<Plen> for u8 {
#[inline(always)]
fn from(val: Plen) -> u8 {
Plen::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Repeatpattern {
#[doc = "Do not repeat (1 time in total)."]
NoRepeat = 0x0,
_RESERVED_1 = 0x01,
_RESERVED_2 = 0x02,
_RESERVED_3 = 0x03,
_RESERVED_4 = 0x04,
_RESERVED_5 = 0x05,
_RESERVED_6 = 0x06,
_RESERVED_7 = 0x07,
_RESERVED_8 = 0x08,
_RESERVED_9 = 0x09,
_RESERVED_a = 0x0a,
_RESERVED_b = 0x0b,
_RESERVED_c = 0x0c,
_RESERVED_d = 0x0d,
_RESERVED_e = 0x0e,
_RESERVED_f = 0x0f,
}
impl Repeatpattern {
#[inline(always)]
pub const fn from_bits(val: u8) -> Repeatpattern {
unsafe { core::mem::transmute(val & 0x0f) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Repeatpattern {
#[inline(always)]
fn from(val: u8) -> Repeatpattern {
Repeatpattern::from_bits(val)
}
}
impl From<Repeatpattern> for u8 {
#[inline(always)]
fn from(val: Repeatpattern) -> u8 {
Repeatpattern::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Ru {
#[doc = "Default ramp-up time (tRXEN and tTXEN), compatible with firmware written for nRF51."]
Default = 0x0,
#[doc = "Fast ramp-up (tRXEN,FAST and tTXEN,FAST), see electrical specifications for more information."]
Fast = 0x01,
}
impl Ru {
#[inline(always)]
pub const fn from_bits(val: u8) -> Ru {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Ru {
#[inline(always)]
fn from(val: u8) -> Ru {
Ru::from_bits(val)
}
}
impl From<Ru> for u8 {
#[inline(always)]
fn from(val: Ru) -> u8 {
Ru::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum S1incl {
#[doc = "Include S1 field in RAM only if S1LEN > 0."]
Automatic = 0x0,
#[doc = "Always include S1 field in RAM independent of S1LEN."]
Include = 0x01,
}
impl S1incl {
#[inline(always)]
pub const fn from_bits(val: u8) -> S1incl {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for S1incl {
#[inline(always)]
fn from(val: u8) -> S1incl {
S1incl::from_bits(val)
}
}
impl From<S1incl> for u8 {
#[inline(always)]
fn from(val: S1incl) -> u8 {
S1incl::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Sampletype {
#[doc = "Complex samples in I and Q."]
Iq = 0x0,
#[doc = "Complex samples as magnitude and phase."]
MagPhase = 0x01,
}
impl Sampletype {
#[inline(always)]
pub const fn from_bits(val: u8) -> Sampletype {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Sampletype {
#[inline(always)]
fn from(val: u8) -> Sampletype {
Sampletype::from_bits(val)
}
}
impl From<Sampletype> for u8 {
#[inline(always)]
fn from(val: Sampletype) -> u8 {
Sampletype::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Samplingstate {
#[doc = "Sampling state Idle."]
Idle = 0x0,
#[doc = "Sampling state Sampling."]
Sampling = 0x01,
}
impl Samplingstate {
#[inline(always)]
pub const fn from_bits(val: u8) -> Samplingstate {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Samplingstate {
#[inline(always)]
fn from(val: u8) -> Samplingstate {
Samplingstate::from_bits(val)
}
}
impl From<Samplingstate> for u8 {
#[inline(always)]
fn from(val: Samplingstate) -> u8 {
Samplingstate::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Skipaddr {
#[doc = "CRC calculation includes address field."]
Include = 0x0,
#[doc = "CRC calculation does not include address field. The CRC calculation will start at the first byte after the address."]
Skip = 0x01,
#[doc = "CRC calculation as per 802.15.4 standard. Starting at first byte after length field."]
Ieee802154 = 0x02,
_RESERVED_3 = 0x03,
}
impl Skipaddr {
#[inline(always)]
pub const fn from_bits(val: u8) -> Skipaddr {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Skipaddr {
#[inline(always)]
fn from(val: u8) -> Skipaddr {
Skipaddr::from_bits(val)
}
}
impl From<Skipaddr> for u8 {
#[inline(always)]
fn from(val: Skipaddr) -> u8 {
Skipaddr::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum State {
#[doc = "RADIO is in the Disabled state."]
Disabled = 0x0,
#[doc = "RADIO is in the RXRU state."]
RxRu = 0x01,
#[doc = "RADIO is in the RXIDLE state."]
RxIdle = 0x02,
#[doc = "RADIO is in the RX state."]
Rx = 0x03,
#[doc = "RADIO is in the RXDISABLED state."]
RxDisable = 0x04,
_RESERVED_5 = 0x05,
_RESERVED_6 = 0x06,
_RESERVED_7 = 0x07,
_RESERVED_8 = 0x08,
#[doc = "RADIO is in the TXRU state."]
TxRu = 0x09,
#[doc = "RADIO is in the TXIDLE state."]
TxIdle = 0x0a,
#[doc = "RADIO is in the TX state."]
Tx = 0x0b,
#[doc = "RADIO is in the TXDISABLED state."]
TxDisable = 0x0c,
_RESERVED_d = 0x0d,
_RESERVED_e = 0x0e,
_RESERVED_f = 0x0f,
}
impl State {
#[inline(always)]
pub const fn from_bits(val: u8) -> State {
unsafe { core::mem::transmute(val & 0x0f) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for State {
#[inline(always)]
fn from(val: u8) -> State {
State::from_bits(val)
}
}
impl From<State> for u8 {
#[inline(always)]
fn from(val: State) -> u8 {
State::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Switchingstate {
#[doc = "Switching state Idle."]
Idle = 0x0,
#[doc = "Switching state Offset."]
Offset = 0x01,
#[doc = "Switching state Guard."]
Guard = 0x02,
#[doc = "Switching state Ref."]
Ref = 0x03,
#[doc = "Switching state Switching."]
Switching = 0x04,
#[doc = "Switching state Ending."]
Ending = 0x05,
_RESERVED_6 = 0x06,
_RESERVED_7 = 0x07,
}
impl Switchingstate {
#[inline(always)]
pub const fn from_bits(val: u8) -> Switchingstate {
unsafe { core::mem::transmute(val & 0x07) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Switchingstate {
#[inline(always)]
fn from(val: u8) -> Switchingstate {
Switchingstate::from_bits(val)
}
}
impl From<Switchingstate> for u8 {
#[inline(always)]
fn from(val: Switchingstate) -> u8 {
Switchingstate::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Tsamplespacing {
_RESERVED_0 = 0x0,
#[doc = "4 us."]
_4us = 0x01,
#[doc = "2 us."]
_2us = 0x02,
#[doc = "1 us."]
_1us = 0x03,
#[doc = "0.5 us."]
_500ns = 0x04,
#[doc = "0.25 us."]
_250ns = 0x05,
#[doc = "0.125 us."]
_125ns = 0x06,
_RESERVED_7 = 0x07,
}
impl Tsamplespacing {
#[inline(always)]
pub const fn from_bits(val: u8) -> Tsamplespacing {
unsafe { core::mem::transmute(val & 0x07) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Tsamplespacing {
#[inline(always)]
fn from(val: u8) -> Tsamplespacing {
Tsamplespacing::from_bits(val)
}
}
impl From<Tsamplespacing> for u8 {
#[inline(always)]
fn from(val: Tsamplespacing) -> u8 {
Tsamplespacing::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Tsamplespacingref {
_RESERVED_0 = 0x0,
#[doc = "4 us."]
_4us = 0x01,
#[doc = "2 us."]
_2us = 0x02,
#[doc = "1 us."]
_1us = 0x03,
#[doc = "0.5 us."]
_500ns = 0x04,
#[doc = "0.25 us."]
_250ns = 0x05,
#[doc = "0.125 us."]
_125ns = 0x06,
_RESERVED_7 = 0x07,
}
impl Tsamplespacingref {
#[inline(always)]
pub const fn from_bits(val: u8) -> Tsamplespacingref {
unsafe { core::mem::transmute(val & 0x07) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Tsamplespacingref {
#[inline(always)]
fn from(val: u8) -> Tsamplespacingref {
Tsamplespacingref::from_bits(val)
}
}
impl From<Tsamplespacingref> for u8 {
#[inline(always)]
fn from(val: Tsamplespacingref) -> u8 {
Tsamplespacingref::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Tswitchspacing {
_RESERVED_0 = 0x0,
#[doc = "4 us."]
_4us = 0x01,
#[doc = "2 us."]
_2us = 0x02,
#[doc = "1 us."]
_1us = 0x03,
_RESERVED_4 = 0x04,
_RESERVED_5 = 0x05,
_RESERVED_6 = 0x06,
_RESERVED_7 = 0x07,
}
impl Tswitchspacing {
#[inline(always)]
pub const fn from_bits(val: u8) -> Tswitchspacing {
unsafe { core::mem::transmute(val & 0x07) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Tswitchspacing {
#[inline(always)]
fn from(val: u8) -> Tswitchspacing {
Tswitchspacing::from_bits(val)
}
}
impl From<Tswitchspacing> for u8 {
#[inline(always)]
fn from(val: Tswitchspacing) -> u8 {
Tswitchspacing::to_bits(val)
}
}
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct Txpower(u8);
impl Txpower {
#[doc = "0 dBm."]
pub const _0dBm: Self = Self(0x0);
#[doc = "+2 dBm."]
pub const Pos2dBm: Self = Self(0x02);
#[doc = "+3 dBm."]
pub const Pos3dBm: Self = Self(0x03);
#[doc = "+4 dBm."]
pub const Pos4dBm: Self = Self(0x04);
#[doc = "+5 dBm."]
pub const Pos5dBm: Self = Self(0x05);
#[doc = "+6 dBm."]
pub const Pos6dBm: Self = Self(0x06);
#[doc = "+7 dBm."]
pub const Pos7dBm: Self = Self(0x07);
#[doc = "+8 dBm."]
pub const Pos8dBm: Self = Self(0x08);
#[doc = "-40 dBm."]
pub const Neg40dBm: Self = Self(0xd8);
#[doc = "Deprecated enumerator - -40 dBm."]
pub const Neg30dBm: Self = Self(0xe2);
#[doc = "-20 dBm."]
pub const Neg20dBm: Self = Self(0xec);
#[doc = "-16 dBm."]
pub const Neg16dBm: Self = Self(0xf0);
#[doc = "-12 dBm."]
pub const Neg12dBm: Self = Self(0xf4);
#[doc = "-8 dBm."]
pub const Neg8dBm: Self = Self(0xf8);
#[doc = "-4 dBm."]
pub const Neg4dBm: Self = Self(0xfc);
}
impl Txpower {
pub const fn from_bits(val: u8) -> Txpower {
Self(val & 0xff)
}
pub const fn to_bits(self) -> u8 {
self.0
}
}
impl core::fmt::Debug for Txpower {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self.0 {
0x0 => f.write_str("_0dBm"),
0x02 => f.write_str("Pos2dBm"),
0x03 => f.write_str("Pos3dBm"),
0x04 => f.write_str("Pos4dBm"),
0x05 => f.write_str("Pos5dBm"),
0x06 => f.write_str("Pos6dBm"),
0x07 => f.write_str("Pos7dBm"),
0x08 => f.write_str("Pos8dBm"),
0xd8 => f.write_str("Neg40dBm"),
0xe2 => f.write_str("Neg30dBm"),
0xec => f.write_str("Neg20dBm"),
0xf0 => f.write_str("Neg16dBm"),
0xf4 => f.write_str("Neg12dBm"),
0xf8 => f.write_str("Neg8dBm"),
0xfc => f.write_str("Neg4dBm"),
other => core::write!(f, "0x{:02X}", other),
}
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Txpower {
fn format(&self, f: defmt::Formatter) {
match self.0 {
0x0 => defmt::write!(f, "_0dBm"),
0x02 => defmt::write!(f, "Pos2dBm"),
0x03 => defmt::write!(f, "Pos3dBm"),
0x04 => defmt::write!(f, "Pos4dBm"),
0x05 => defmt::write!(f, "Pos5dBm"),
0x06 => defmt::write!(f, "Pos6dBm"),
0x07 => defmt::write!(f, "Pos7dBm"),
0x08 => defmt::write!(f, "Pos8dBm"),
0xd8 => defmt::write!(f, "Neg40dBm"),
0xe2 => defmt::write!(f, "Neg30dBm"),
0xec => defmt::write!(f, "Neg20dBm"),
0xf0 => defmt::write!(f, "Neg16dBm"),
0xf4 => defmt::write!(f, "Neg12dBm"),
0xf8 => defmt::write!(f, "Neg8dBm"),
0xfc => defmt::write!(f, "Neg4dBm"),
other => defmt::write!(f, "0x{:02X}", other),
}
}
}
impl From<u8> for Txpower {
#[inline(always)]
fn from(val: u8) -> Txpower {
Txpower::from_bits(val)
}
}
impl From<Txpower> for u8 {
#[inline(always)]
fn from(val: Txpower) -> u8 {
Txpower::to_bits(val)
}
}
}
}
pub mod rng {
#[doc = "Random Number Generator."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Rng {
ptr: *mut u8,
}
unsafe impl Send for Rng {}
unsafe impl Sync for Rng {}
impl Rng {
#[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 = "Task starting the random number generator."]
#[inline(always)]
pub const fn tasks_start(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Task stopping the random number generator."]
#[inline(always)]
pub const fn tasks_stop(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Event being generated for every new random number written to the VALUE register."]
#[inline(always)]
pub const fn events_valrdy(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0100usize) as _) }
}
#[doc = "Shortcuts between local events and tasks."]
#[inline(always)]
pub const fn shorts(self) -> crate::common::Reg<regs::Shorts, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0200usize) as _) }
}
#[doc = "Enable interrupt."]
#[inline(always)]
pub const fn intenset(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0304usize) as _) }
}
#[doc = "Disable interrupt."]
#[inline(always)]
pub const fn intenclr(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0308usize) as _) }
}
#[doc = "Configuration register."]
#[inline(always)]
pub const fn config(self) -> crate::common::Reg<regs::Config, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0504usize) as _) }
}
#[doc = "Output random number."]
#[inline(always)]
pub const fn value(self) -> crate::common::Reg<regs::Value, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0508usize) as _) }
}
}
pub mod regs {
#[doc = "Configuration register."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Config(pub u32);
impl Config {
#[doc = "Bias correction."]
#[must_use]
#[inline(always)]
pub const fn dercen(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Bias correction."]
#[inline(always)]
pub const fn set_dercen(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for Config {
#[inline(always)]
fn default() -> Config {
Config(0)
}
}
impl core::fmt::Debug for Config {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Config")
.field("dercen", &self.dercen())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Config {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Config {{ dercen: {=bool:?} }}", self.dercen())
}
}
#[doc = "Disable interrupt."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Int(pub u32);
impl Int {
#[doc = "Write '1' to disable interrupt for event VALRDY."]
#[must_use]
#[inline(always)]
pub const fn valrdy(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event VALRDY."]
#[inline(always)]
pub const fn set_valrdy(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for Int {
#[inline(always)]
fn default() -> Int {
Int(0)
}
}
impl core::fmt::Debug for Int {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Int")
.field("valrdy", &self.valrdy())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Int {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Int {{ valrdy: {=bool:?} }}", self.valrdy())
}
}
#[doc = "Shortcuts between local events and tasks."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Shorts(pub u32);
impl Shorts {
#[doc = "Shortcut between event VALRDY and task STOP."]
#[must_use]
#[inline(always)]
pub const fn valrdy_stop(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event VALRDY and task STOP."]
#[inline(always)]
pub const fn set_valrdy_stop(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for Shorts {
#[inline(always)]
fn default() -> Shorts {
Shorts(0)
}
}
impl core::fmt::Debug for Shorts {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Shorts")
.field("valrdy_stop", &self.valrdy_stop())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Shorts {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Shorts {{ valrdy_stop: {=bool:?} }}", self.valrdy_stop())
}
}
#[doc = "Output random number."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Value(pub u32);
impl Value {
#[doc = "Generated random number."]
#[must_use]
#[inline(always)]
pub const fn value(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "Generated random number."]
#[inline(always)]
pub const fn set_value(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
}
impl Default for Value {
#[inline(always)]
fn default() -> Value {
Value(0)
}
}
impl core::fmt::Debug for Value {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Value")
.field("value", &self.value())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Value {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Value {{ value: {=u8:?} }}", self.value())
}
}
}
}
pub mod rtc {
#[doc = "Real time counter 0."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Rtc {
ptr: *mut u8,
}
unsafe impl Send for Rtc {}
unsafe impl Sync for Rtc {}
impl Rtc {
#[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 = "Start RTC COUNTER."]
#[inline(always)]
pub const fn tasks_start(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Stop RTC COUNTER."]
#[inline(always)]
pub const fn tasks_stop(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Clear RTC COUNTER."]
#[inline(always)]
pub const fn tasks_clear(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
#[doc = "Set COUNTER to 0xFFFFF0."]
#[inline(always)]
pub const fn tasks_trigovrflw(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0cusize) as _) }
}
#[doc = "Event on COUNTER increment."]
#[inline(always)]
pub const fn events_tick(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0100usize) as _) }
}
#[doc = "Event on COUNTER overflow."]
#[inline(always)]
pub const fn events_ovrflw(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0104usize) as _) }
}
#[doc = "Description collection: Compare event on CC\\[n\\] match."]
#[inline(always)]
pub const fn events_compare(self, n: usize) -> crate::common::Reg<u32, crate::common::RW> {
assert!(n < 4usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0140usize + n * 4usize) as _)
}
}
#[doc = "Enable interrupt."]
#[inline(always)]
pub const fn intenset(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0304usize) as _) }
}
#[doc = "Disable interrupt."]
#[inline(always)]
pub const fn intenclr(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0308usize) as _) }
}
#[doc = "Enable or disable event routing."]
#[inline(always)]
pub const fn evten(self) -> crate::common::Reg<regs::Evt, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0340usize) as _) }
}
#[doc = "Enable event routing."]
#[inline(always)]
pub const fn evtenset(self) -> crate::common::Reg<regs::Evt, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0344usize) as _) }
}
#[doc = "Disable event routing."]
#[inline(always)]
pub const fn evtenclr(self) -> crate::common::Reg<regs::Evt, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0348usize) as _) }
}
#[doc = "Current COUNTER value."]
#[inline(always)]
pub const fn counter(self) -> crate::common::Reg<regs::Counter, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0504usize) as _) }
}
#[doc = "12 bit prescaler for COUNTER frequency (32768/(PRESCALER+1)). Must be written when RTC is stopped."]
#[inline(always)]
pub const fn prescaler(self) -> crate::common::Reg<regs::Prescaler, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0508usize) as _) }
}
#[doc = "Description collection: Compare register n."]
#[inline(always)]
pub const fn cc(self, n: usize) -> crate::common::Reg<regs::Cc, crate::common::RW> {
assert!(n < 4usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0540usize + n * 4usize) as _)
}
}
}
pub mod regs {
#[doc = "Description collection: Compare register n."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Cc(pub u32);
impl Cc {
#[doc = "Compare value."]
#[must_use]
#[inline(always)]
pub const fn compare(&self) -> u32 {
let val = (self.0 >> 0usize) & 0x00ff_ffff;
val as u32
}
#[doc = "Compare value."]
#[inline(always)]
pub const fn set_compare(&mut self, val: u32) {
self.0 =
(self.0 & !(0x00ff_ffff << 0usize)) | (((val as u32) & 0x00ff_ffff) << 0usize);
}
}
impl Default for Cc {
#[inline(always)]
fn default() -> Cc {
Cc(0)
}
}
impl core::fmt::Debug for Cc {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Cc")
.field("compare", &self.compare())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Cc {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Cc {{ compare: {=u32:?} }}", self.compare())
}
}
#[doc = "Current COUNTER value."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Counter(pub u32);
impl Counter {
#[doc = "Counter value."]
#[must_use]
#[inline(always)]
pub const fn counter(&self) -> u32 {
let val = (self.0 >> 0usize) & 0x00ff_ffff;
val as u32
}
#[doc = "Counter value."]
#[inline(always)]
pub const fn set_counter(&mut self, val: u32) {
self.0 =
(self.0 & !(0x00ff_ffff << 0usize)) | (((val as u32) & 0x00ff_ffff) << 0usize);
}
}
impl Default for Counter {
#[inline(always)]
fn default() -> Counter {
Counter(0)
}
}
impl core::fmt::Debug for Counter {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Counter")
.field("counter", &self.counter())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Counter {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Counter {{ counter: {=u32:?} }}", self.counter())
}
}
#[doc = "Enable or disable event routing."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Evt(pub u32);
impl Evt {
#[doc = "Enable or disable event routing for event TICK."]
#[must_use]
#[inline(always)]
pub const fn tick(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Enable or disable event routing for event TICK."]
#[inline(always)]
pub const fn set_tick(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Enable or disable event routing for event OVRFLW."]
#[must_use]
#[inline(always)]
pub const fn ovrflw(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Enable or disable event routing for event OVRFLW."]
#[inline(always)]
pub const fn set_ovrflw(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "Enable or disable event routing for event COMPARE\\[0\\]."]
#[must_use]
#[inline(always)]
pub const fn compare(&self, n: usize) -> bool {
assert!(n < 4usize);
let offs = 16usize + n * 1usize;
let val = (self.0 >> offs) & 0x01;
val != 0
}
#[doc = "Enable or disable event routing for event COMPARE\\[0\\]."]
#[inline(always)]
pub const fn set_compare(&mut self, n: usize, val: bool) {
assert!(n < 4usize);
let offs = 16usize + n * 1usize;
self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
}
}
impl Default for Evt {
#[inline(always)]
fn default() -> Evt {
Evt(0)
}
}
impl core::fmt::Debug for Evt {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Evt")
.field("tick", &self.tick())
.field("ovrflw", &self.ovrflw())
.field("compare[0]", &self.compare(0usize))
.field("compare[1]", &self.compare(1usize))
.field("compare[2]", &self.compare(2usize))
.field("compare[3]", &self.compare(3usize))
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Evt {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Evt {{ tick: {=bool:?}, ovrflw: {=bool:?}, compare[0]: {=bool:?}, compare[1]: {=bool:?}, compare[2]: {=bool:?}, compare[3]: {=bool:?} }}" , self . tick () , self . ovrflw () , self . compare (0usize) , self . compare (1usize) , self . compare (2usize) , self . compare (3usize))
}
}
#[doc = "Disable interrupt."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Int(pub u32);
impl Int {
#[doc = "Write '1' to disable interrupt for event TICK."]
#[must_use]
#[inline(always)]
pub const fn tick(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event TICK."]
#[inline(always)]
pub const fn set_tick(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Write '1' to disable interrupt for event OVRFLW."]
#[must_use]
#[inline(always)]
pub const fn ovrflw(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event OVRFLW."]
#[inline(always)]
pub const fn set_ovrflw(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "Write '1' to disable interrupt for event COMPARE\\[0\\]."]
#[must_use]
#[inline(always)]
pub const fn compare(&self, n: usize) -> bool {
assert!(n < 4usize);
let offs = 16usize + n * 1usize;
let val = (self.0 >> offs) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event COMPARE\\[0\\]."]
#[inline(always)]
pub const fn set_compare(&mut self, n: usize, val: bool) {
assert!(n < 4usize);
let offs = 16usize + n * 1usize;
self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
}
}
impl Default for Int {
#[inline(always)]
fn default() -> Int {
Int(0)
}
}
impl core::fmt::Debug for Int {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Int")
.field("tick", &self.tick())
.field("ovrflw", &self.ovrflw())
.field("compare[0]", &self.compare(0usize))
.field("compare[1]", &self.compare(1usize))
.field("compare[2]", &self.compare(2usize))
.field("compare[3]", &self.compare(3usize))
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Int {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Int {{ tick: {=bool:?}, ovrflw: {=bool:?}, compare[0]: {=bool:?}, compare[1]: {=bool:?}, compare[2]: {=bool:?}, compare[3]: {=bool:?} }}" , self . tick () , self . ovrflw () , self . compare (0usize) , self . compare (1usize) , self . compare (2usize) , self . compare (3usize))
}
}
#[doc = "12 bit prescaler for COUNTER frequency (32768/(PRESCALER+1)). Must be written when RTC is stopped."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Prescaler(pub u32);
impl Prescaler {
#[doc = "Prescaler value."]
#[must_use]
#[inline(always)]
pub const fn prescaler(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x0fff;
val as u16
}
#[doc = "Prescaler value."]
#[inline(always)]
pub const fn set_prescaler(&mut self, val: u16) {
self.0 = (self.0 & !(0x0fff << 0usize)) | (((val as u32) & 0x0fff) << 0usize);
}
}
impl Default for Prescaler {
#[inline(always)]
fn default() -> Prescaler {
Prescaler(0)
}
}
impl core::fmt::Debug for Prescaler {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Prescaler")
.field("prescaler", &self.prescaler())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Prescaler {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Prescaler {{ prescaler: {=u16:?} }}", self.prescaler())
}
}
}
}
pub mod shared {
pub mod regs {
#[doc = "Pin select for A signal."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Psel(pub u32);
impl Psel {
#[doc = "Pin number."]
#[must_use]
#[inline(always)]
pub const fn pin(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x1f;
val as u8
}
#[doc = "Pin number."]
#[inline(always)]
pub const fn set_pin(&mut self, val: u8) {
self.0 = (self.0 & !(0x1f << 0usize)) | (((val as u32) & 0x1f) << 0usize);
}
#[doc = "Connection."]
#[must_use]
#[inline(always)]
pub const fn connect(&self) -> super::vals::Connect {
let val = (self.0 >> 31usize) & 0x01;
super::vals::Connect::from_bits(val as u8)
}
#[doc = "Connection."]
#[inline(always)]
pub const fn set_connect(&mut self, val: super::vals::Connect) {
self.0 =
(self.0 & !(0x01 << 31usize)) | (((val.to_bits() as u32) & 0x01) << 31usize);
}
}
impl Default for Psel {
#[inline(always)]
fn default() -> Psel {
Psel(0)
}
}
impl core::fmt::Debug for Psel {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Psel")
.field("pin", &self.pin())
.field("connect", &self.connect())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Psel {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Psel {{ pin: {=u8:?}, connect: {:?} }}",
self.pin(),
self.connect()
)
}
}
}
pub mod vals {
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Connect {
#[doc = "Connect."]
Connected = 0x0,
#[doc = "Disconnect."]
Disconnected = 0x01,
}
impl Connect {
#[inline(always)]
pub const fn from_bits(val: u8) -> Connect {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Connect {
#[inline(always)]
fn from(val: u8) -> Connect {
Connect::from_bits(val)
}
}
impl From<Connect> for u8 {
#[inline(always)]
fn from(val: Connect) -> u8 {
Connect::to_bits(val)
}
}
}
}
pub mod spi {
#[doc = "Unspecified."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Psel {
ptr: *mut u8,
}
unsafe impl Send for Psel {}
unsafe impl Sync for Psel {}
impl Psel {
#[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 = "Pin select for SCK."]
#[inline(always)]
pub const fn sck(self) -> crate::common::Reg<super::shared::regs::Psel, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Pin select for MOSI signal."]
#[inline(always)]
pub const fn mosi(
self,
) -> crate::common::Reg<super::shared::regs::Psel, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Pin select for MISO signal."]
#[inline(always)]
pub const fn miso(
self,
) -> crate::common::Reg<super::shared::regs::Psel, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
}
#[doc = "Serial Peripheral Interface 0."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Spi {
ptr: *mut u8,
}
unsafe impl Send for Spi {}
unsafe impl Sync for Spi {}
impl Spi {
#[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 = "TXD byte sent and RXD byte received."]
#[inline(always)]
pub const fn events_ready(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0108usize) as _) }
}
#[doc = "Enable interrupt."]
#[inline(always)]
pub const fn intenset(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0304usize) as _) }
}
#[doc = "Disable interrupt."]
#[inline(always)]
pub const fn intenclr(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0308usize) as _) }
}
#[doc = "Enable SPI."]
#[inline(always)]
pub const fn enable(self) -> crate::common::Reg<regs::Enable, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0500usize) as _) }
}
#[doc = "Unspecified."]
#[inline(always)]
pub const fn psel(self) -> Psel {
unsafe { Psel::from_ptr(self.ptr.wrapping_add(0x0508usize) as _) }
}
#[doc = "RXD register."]
#[inline(always)]
pub const fn rxd(self) -> crate::common::Reg<regs::Rxd, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0518usize) as _) }
}
#[doc = "TXD register."]
#[inline(always)]
pub const fn txd(self) -> crate::common::Reg<regs::Txd, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x051cusize) as _) }
}
#[doc = "SPI frequency. Accuracy depends on the HFCLK source selected."]
#[inline(always)]
pub const fn frequency(self) -> crate::common::Reg<regs::Frequency, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0524usize) as _) }
}
#[doc = "Configuration register."]
#[inline(always)]
pub const fn config(self) -> crate::common::Reg<regs::Config, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0554usize) as _) }
}
}
pub mod regs {
#[doc = "Configuration register."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Config(pub u32);
impl Config {
#[doc = "Bit order."]
#[must_use]
#[inline(always)]
pub const fn order(&self) -> super::vals::Order {
let val = (self.0 >> 0usize) & 0x01;
super::vals::Order::from_bits(val as u8)
}
#[doc = "Bit order."]
#[inline(always)]
pub const fn set_order(&mut self, val: super::vals::Order) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
#[doc = "Serial clock (SCK) phase."]
#[must_use]
#[inline(always)]
pub const fn cpha(&self) -> super::vals::Cpha {
let val = (self.0 >> 1usize) & 0x01;
super::vals::Cpha::from_bits(val as u8)
}
#[doc = "Serial clock (SCK) phase."]
#[inline(always)]
pub const fn set_cpha(&mut self, val: super::vals::Cpha) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val.to_bits() as u32) & 0x01) << 1usize);
}
#[doc = "Serial clock (SCK) polarity."]
#[must_use]
#[inline(always)]
pub const fn cpol(&self) -> super::vals::Cpol {
let val = (self.0 >> 2usize) & 0x01;
super::vals::Cpol::from_bits(val as u8)
}
#[doc = "Serial clock (SCK) polarity."]
#[inline(always)]
pub const fn set_cpol(&mut self, val: super::vals::Cpol) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val.to_bits() as u32) & 0x01) << 2usize);
}
}
impl Default for Config {
#[inline(always)]
fn default() -> Config {
Config(0)
}
}
impl core::fmt::Debug for Config {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Config")
.field("order", &self.order())
.field("cpha", &self.cpha())
.field("cpol", &self.cpol())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Config {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Config {{ order: {:?}, cpha: {:?}, cpol: {:?} }}",
self.order(),
self.cpha(),
self.cpol()
)
}
}
#[doc = "Enable SPI."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Enable(pub u32);
impl Enable {
#[doc = "Enable or disable SPI."]
#[must_use]
#[inline(always)]
pub const fn enable(&self) -> super::vals::Enable {
let val = (self.0 >> 0usize) & 0x0f;
super::vals::Enable::from_bits(val as u8)
}
#[doc = "Enable or disable SPI."]
#[inline(always)]
pub const fn set_enable(&mut self, val: super::vals::Enable) {
self.0 = (self.0 & !(0x0f << 0usize)) | (((val.to_bits() as u32) & 0x0f) << 0usize);
}
}
impl Default for Enable {
#[inline(always)]
fn default() -> Enable {
Enable(0)
}
}
impl core::fmt::Debug for Enable {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Enable")
.field("enable", &self.enable())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Enable {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Enable {{ enable: {:?} }}", self.enable())
}
}
#[doc = "SPI frequency. Accuracy depends on the HFCLK source selected."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Frequency(pub u32);
impl Frequency {
#[doc = "SPI master data rate."]
#[must_use]
#[inline(always)]
pub const fn frequency(&self) -> super::vals::Frequency {
let val = (self.0 >> 0usize) & 0xffff_ffff;
super::vals::Frequency::from_bits(val as u32)
}
#[doc = "SPI master data rate."]
#[inline(always)]
pub const fn set_frequency(&mut self, val: super::vals::Frequency) {
self.0 = (self.0 & !(0xffff_ffff << 0usize))
| (((val.to_bits() as u32) & 0xffff_ffff) << 0usize);
}
}
impl Default for Frequency {
#[inline(always)]
fn default() -> Frequency {
Frequency(0)
}
}
impl core::fmt::Debug for Frequency {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Frequency")
.field("frequency", &self.frequency())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Frequency {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Frequency {{ frequency: {:?} }}", self.frequency())
}
}
#[doc = "Disable interrupt."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Int(pub u32);
impl Int {
#[doc = "Write '1' to disable interrupt for event READY."]
#[must_use]
#[inline(always)]
pub const fn ready(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event READY."]
#[inline(always)]
pub const fn set_ready(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
}
impl Default for Int {
#[inline(always)]
fn default() -> Int {
Int(0)
}
}
impl core::fmt::Debug for Int {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Int").field("ready", &self.ready()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Int {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Int {{ ready: {=bool:?} }}", self.ready())
}
}
#[doc = "RXD register."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Rxd(pub u32);
impl Rxd {
#[doc = "RX data received. Double buffered."]
#[must_use]
#[inline(always)]
pub const fn rxd(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "RX data received. Double buffered."]
#[inline(always)]
pub const fn set_rxd(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
}
impl Default for Rxd {
#[inline(always)]
fn default() -> Rxd {
Rxd(0)
}
}
impl core::fmt::Debug for Rxd {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Rxd").field("rxd", &self.rxd()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Rxd {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Rxd {{ rxd: {=u8:?} }}", self.rxd())
}
}
#[doc = "TXD register."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Txd(pub u32);
impl Txd {
#[doc = "TX data to send. Double buffered."]
#[must_use]
#[inline(always)]
pub const fn txd(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "TX data to send. Double buffered."]
#[inline(always)]
pub const fn set_txd(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
}
impl Default for Txd {
#[inline(always)]
fn default() -> Txd {
Txd(0)
}
}
impl core::fmt::Debug for Txd {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Txd").field("txd", &self.txd()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Txd {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Txd {{ txd: {=u8:?} }}", self.txd())
}
}
}
pub mod vals {
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Cpha {
#[doc = "Sample on leading edge of clock, shift serial data on trailing edge."]
Leading = 0x0,
#[doc = "Sample on trailing edge of clock, shift serial data on leading edge."]
Trailing = 0x01,
}
impl Cpha {
#[inline(always)]
pub const fn from_bits(val: u8) -> Cpha {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Cpha {
#[inline(always)]
fn from(val: u8) -> Cpha {
Cpha::from_bits(val)
}
}
impl From<Cpha> for u8 {
#[inline(always)]
fn from(val: Cpha) -> u8 {
Cpha::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Cpol {
#[doc = "Active high."]
ActiveHigh = 0x0,
#[doc = "Active low."]
ActiveLow = 0x01,
}
impl Cpol {
#[inline(always)]
pub const fn from_bits(val: u8) -> Cpol {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Cpol {
#[inline(always)]
fn from(val: u8) -> Cpol {
Cpol::from_bits(val)
}
}
impl From<Cpol> for u8 {
#[inline(always)]
fn from(val: Cpol) -> u8 {
Cpol::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Enable {
#[doc = "Disable SPI."]
Disabled = 0x0,
#[doc = "Enable SPI."]
Enabled = 0x01,
_RESERVED_2 = 0x02,
_RESERVED_3 = 0x03,
_RESERVED_4 = 0x04,
_RESERVED_5 = 0x05,
_RESERVED_6 = 0x06,
_RESERVED_7 = 0x07,
_RESERVED_8 = 0x08,
_RESERVED_9 = 0x09,
_RESERVED_a = 0x0a,
_RESERVED_b = 0x0b,
_RESERVED_c = 0x0c,
_RESERVED_d = 0x0d,
_RESERVED_e = 0x0e,
_RESERVED_f = 0x0f,
}
impl Enable {
#[inline(always)]
pub const fn from_bits(val: u8) -> Enable {
unsafe { core::mem::transmute(val & 0x0f) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Enable {
#[inline(always)]
fn from(val: u8) -> Enable {
Enable::from_bits(val)
}
}
impl From<Enable> for u8 {
#[inline(always)]
fn from(val: Enable) -> u8 {
Enable::to_bits(val)
}
}
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct Frequency(u32);
impl Frequency {
#[doc = "125 kbps."]
pub const K125: Self = Self(0x0200_0000);
#[doc = "250 kbps."]
pub const K250: Self = Self(0x0400_0000);
#[doc = "500 kbps."]
pub const K500: Self = Self(0x0800_0000);
#[doc = "1 Mbps."]
pub const M1: Self = Self(0x1000_0000);
#[doc = "2 Mbps."]
pub const M2: Self = Self(0x2000_0000);
#[doc = "4 Mbps."]
pub const M4: Self = Self(0x4000_0000);
#[doc = "8 Mbps."]
pub const M8: Self = Self(0x8000_0000);
}
impl Frequency {
pub const fn from_bits(val: u32) -> Frequency {
Self(val & 0xffff_ffff)
}
pub const fn to_bits(self) -> u32 {
self.0
}
}
impl core::fmt::Debug for Frequency {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self.0 {
0x0200_0000 => f.write_str("K125"),
0x0400_0000 => f.write_str("K250"),
0x0800_0000 => f.write_str("K500"),
0x1000_0000 => f.write_str("M1"),
0x2000_0000 => f.write_str("M2"),
0x4000_0000 => f.write_str("M4"),
0x8000_0000 => f.write_str("M8"),
other => core::write!(f, "0x{:02X}", other),
}
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Frequency {
fn format(&self, f: defmt::Formatter) {
match self.0 {
0x0200_0000 => defmt::write!(f, "K125"),
0x0400_0000 => defmt::write!(f, "K250"),
0x0800_0000 => defmt::write!(f, "K500"),
0x1000_0000 => defmt::write!(f, "M1"),
0x2000_0000 => defmt::write!(f, "M2"),
0x4000_0000 => defmt::write!(f, "M4"),
0x8000_0000 => defmt::write!(f, "M8"),
other => defmt::write!(f, "0x{:02X}", other),
}
}
}
impl From<u32> for Frequency {
#[inline(always)]
fn from(val: u32) -> Frequency {
Frequency::from_bits(val)
}
}
impl From<Frequency> for u32 {
#[inline(always)]
fn from(val: Frequency) -> u32 {
Frequency::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Order {
#[doc = "Most significant bit shifted out first."]
MsbFirst = 0x0,
#[doc = "Least significant bit shifted out first."]
LsbFirst = 0x01,
}
impl Order {
#[inline(always)]
pub const fn from_bits(val: u8) -> Order {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Order {
#[inline(always)]
fn from(val: u8) -> Order {
Order::from_bits(val)
}
}
impl From<Order> for u8 {
#[inline(always)]
fn from(val: Order) -> u8 {
Order::to_bits(val)
}
}
}
}
pub mod spim {
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Dma {
ptr: *mut u8,
}
unsafe impl Send for Dma {}
unsafe impl Sync for Dma {}
impl Dma {
#[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 = "RXD EasyDMA channel."]
#[inline(always)]
pub const fn rx(self) -> DmaRx {
unsafe { DmaRx::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "TXD EasyDMA channel."]
#[inline(always)]
pub const fn tx(self) -> DmaTx {
unsafe { DmaTx::from_ptr(self.ptr.wrapping_add(0x10usize) as _) }
}
}
#[doc = "RXD EasyDMA channel."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct DmaRx {
ptr: *mut u8,
}
unsafe impl Send for DmaRx {}
unsafe impl Sync for DmaRx {}
impl DmaRx {
#[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 = "Data pointer."]
#[inline(always)]
pub const fn ptr(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Maximum number of bytes in receive buffer."]
#[inline(always)]
pub const fn maxcnt(self) -> crate::common::Reg<regs::RxdMaxcnt, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Number of bytes transferred in the last transaction."]
#[inline(always)]
pub const fn amount(self) -> crate::common::Reg<regs::RxdAmount, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
#[doc = "EasyDMA list type."]
#[inline(always)]
pub const fn list(self) -> crate::common::Reg<regs::RxdList, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0cusize) as _) }
}
}
#[doc = "TXD EasyDMA channel."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct DmaTx {
ptr: *mut u8,
}
unsafe impl Send for DmaTx {}
unsafe impl Sync for DmaTx {}
impl DmaTx {
#[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 = "Data pointer."]
#[inline(always)]
pub const fn ptr(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Number of bytes in transmit buffer."]
#[inline(always)]
pub const fn maxcnt(self) -> crate::common::Reg<regs::TxdMaxcnt, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Number of bytes transferred in the last transaction."]
#[inline(always)]
pub const fn amount(self) -> crate::common::Reg<regs::TxdAmount, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
#[doc = "EasyDMA list type."]
#[inline(always)]
pub const fn list(self) -> crate::common::Reg<regs::TxdList, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0cusize) as _) }
}
}
#[doc = "Unspecified."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Psel {
ptr: *mut u8,
}
unsafe impl Send for Psel {}
unsafe impl Sync for Psel {}
impl Psel {
#[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 = "Pin select for SCK."]
#[inline(always)]
pub const fn sck(self) -> crate::common::Reg<super::shared::regs::Psel, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Pin select for MOSI signal."]
#[inline(always)]
pub const fn mosi(
self,
) -> crate::common::Reg<super::shared::regs::Psel, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Pin select for MISO signal."]
#[inline(always)]
pub const fn miso(
self,
) -> crate::common::Reg<super::shared::regs::Psel, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
}
#[doc = "Serial Peripheral Interface Master with EasyDMA 0."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Spim {
ptr: *mut u8,
}
unsafe impl Send for Spim {}
unsafe impl Sync for Spim {}
impl Spim {
#[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 = "Start SPI transaction."]
#[inline(always)]
pub const fn tasks_start(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x10usize) as _) }
}
#[doc = "Stop SPI transaction."]
#[inline(always)]
pub const fn tasks_stop(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x14usize) as _) }
}
#[doc = "Suspend SPI transaction."]
#[inline(always)]
pub const fn tasks_suspend(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x1cusize) as _) }
}
#[doc = "Resume SPI transaction."]
#[inline(always)]
pub const fn tasks_resume(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x20usize) as _) }
}
#[doc = "SPI transaction has stopped."]
#[inline(always)]
pub const fn events_stopped(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0104usize) as _) }
}
#[doc = "End of RXD buffer reached."]
#[inline(always)]
pub const fn events_endrx(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0110usize) as _) }
}
#[doc = "End of RXD buffer and TXD buffer reached."]
#[inline(always)]
pub const fn events_end(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0118usize) as _) }
}
#[doc = "End of TXD buffer reached."]
#[inline(always)]
pub const fn events_endtx(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0120usize) as _) }
}
#[doc = "Transaction started."]
#[inline(always)]
pub const fn events_started(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x014cusize) as _) }
}
#[doc = "Shortcuts between local events and tasks."]
#[inline(always)]
pub const fn shorts(self) -> crate::common::Reg<regs::Shorts, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0200usize) as _) }
}
#[doc = "Enable interrupt."]
#[inline(always)]
pub const fn intenset(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0304usize) as _) }
}
#[doc = "Disable interrupt."]
#[inline(always)]
pub const fn intenclr(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0308usize) as _) }
}
#[doc = "Enable SPIM."]
#[inline(always)]
pub const fn enable(self) -> crate::common::Reg<regs::Enable, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0500usize) as _) }
}
#[doc = "Unspecified."]
#[inline(always)]
pub const fn psel(self) -> Psel {
unsafe { Psel::from_ptr(self.ptr.wrapping_add(0x0508usize) as _) }
}
#[doc = "SPI frequency. Accuracy depends on the HFCLK source selected."]
#[inline(always)]
pub const fn frequency(self) -> crate::common::Reg<regs::Frequency, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0524usize) as _) }
}
#[inline(always)]
pub const fn dma(self) -> Dma {
unsafe { Dma::from_ptr(self.ptr.wrapping_add(0x0534usize) as _) }
}
#[doc = "Configuration register."]
#[inline(always)]
pub const fn config(self) -> crate::common::Reg<regs::Config, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0554usize) as _) }
}
#[doc = "Byte transmitted after TXD.MAXCNT bytes have been transmitted in the case when RXD.MAXCNT is greater than TXD.MAXCNT."]
#[inline(always)]
pub const fn orc(self) -> crate::common::Reg<regs::Orc, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x05c0usize) as _) }
}
}
pub mod regs {
#[doc = "Configuration register."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Config(pub u32);
impl Config {
#[doc = "Bit order."]
#[must_use]
#[inline(always)]
pub const fn order(&self) -> super::vals::Order {
let val = (self.0 >> 0usize) & 0x01;
super::vals::Order::from_bits(val as u8)
}
#[doc = "Bit order."]
#[inline(always)]
pub const fn set_order(&mut self, val: super::vals::Order) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
#[doc = "Serial clock (SCK) phase."]
#[must_use]
#[inline(always)]
pub const fn cpha(&self) -> super::vals::Cpha {
let val = (self.0 >> 1usize) & 0x01;
super::vals::Cpha::from_bits(val as u8)
}
#[doc = "Serial clock (SCK) phase."]
#[inline(always)]
pub const fn set_cpha(&mut self, val: super::vals::Cpha) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val.to_bits() as u32) & 0x01) << 1usize);
}
#[doc = "Serial clock (SCK) polarity."]
#[must_use]
#[inline(always)]
pub const fn cpol(&self) -> super::vals::Cpol {
let val = (self.0 >> 2usize) & 0x01;
super::vals::Cpol::from_bits(val as u8)
}
#[doc = "Serial clock (SCK) polarity."]
#[inline(always)]
pub const fn set_cpol(&mut self, val: super::vals::Cpol) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val.to_bits() as u32) & 0x01) << 2usize);
}
}
impl Default for Config {
#[inline(always)]
fn default() -> Config {
Config(0)
}
}
impl core::fmt::Debug for Config {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Config")
.field("order", &self.order())
.field("cpha", &self.cpha())
.field("cpol", &self.cpol())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Config {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Config {{ order: {:?}, cpha: {:?}, cpol: {:?} }}",
self.order(),
self.cpha(),
self.cpol()
)
}
}
#[doc = "Enable SPIM."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Enable(pub u32);
impl Enable {
#[doc = "Enable or disable SPIM."]
#[must_use]
#[inline(always)]
pub const fn enable(&self) -> super::vals::Enable {
let val = (self.0 >> 0usize) & 0x0f;
super::vals::Enable::from_bits(val as u8)
}
#[doc = "Enable or disable SPIM."]
#[inline(always)]
pub const fn set_enable(&mut self, val: super::vals::Enable) {
self.0 = (self.0 & !(0x0f << 0usize)) | (((val.to_bits() as u32) & 0x0f) << 0usize);
}
}
impl Default for Enable {
#[inline(always)]
fn default() -> Enable {
Enable(0)
}
}
impl core::fmt::Debug for Enable {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Enable")
.field("enable", &self.enable())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Enable {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Enable {{ enable: {:?} }}", self.enable())
}
}
#[doc = "SPI frequency. Accuracy depends on the HFCLK source selected."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Frequency(pub u32);
impl Frequency {
#[doc = "SPI master data rate."]
#[must_use]
#[inline(always)]
pub const fn frequency(&self) -> super::vals::Frequency {
let val = (self.0 >> 0usize) & 0xffff_ffff;
super::vals::Frequency::from_bits(val as u32)
}
#[doc = "SPI master data rate."]
#[inline(always)]
pub const fn set_frequency(&mut self, val: super::vals::Frequency) {
self.0 = (self.0 & !(0xffff_ffff << 0usize))
| (((val.to_bits() as u32) & 0xffff_ffff) << 0usize);
}
}
impl Default for Frequency {
#[inline(always)]
fn default() -> Frequency {
Frequency(0)
}
}
impl core::fmt::Debug for Frequency {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Frequency")
.field("frequency", &self.frequency())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Frequency {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Frequency {{ frequency: {:?} }}", self.frequency())
}
}
#[doc = "Disable interrupt."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Int(pub u32);
impl Int {
#[doc = "Write '1' to disable interrupt for event STOPPED."]
#[must_use]
#[inline(always)]
pub const fn stopped(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event STOPPED."]
#[inline(always)]
pub const fn set_stopped(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "Write '1' to disable interrupt for event ENDRX."]
#[must_use]
#[inline(always)]
pub const fn endrx(&self) -> bool {
let val = (self.0 >> 4usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event ENDRX."]
#[inline(always)]
pub const fn set_endrx(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
}
#[doc = "Write '1' to disable interrupt for event END."]
#[must_use]
#[inline(always)]
pub const fn end(&self) -> bool {
let val = (self.0 >> 6usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event END."]
#[inline(always)]
pub const fn set_end(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize);
}
#[doc = "Write '1' to disable interrupt for event ENDTX."]
#[must_use]
#[inline(always)]
pub const fn endtx(&self) -> bool {
let val = (self.0 >> 8usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event ENDTX."]
#[inline(always)]
pub const fn set_endtx(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize);
}
#[doc = "Write '1' to disable interrupt for event STARTED."]
#[must_use]
#[inline(always)]
pub const fn started(&self) -> bool {
let val = (self.0 >> 19usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event STARTED."]
#[inline(always)]
pub const fn set_started(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 19usize)) | (((val as u32) & 0x01) << 19usize);
}
}
impl Default for Int {
#[inline(always)]
fn default() -> Int {
Int(0)
}
}
impl core::fmt::Debug for Int {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Int")
.field("stopped", &self.stopped())
.field("endrx", &self.endrx())
.field("end", &self.end())
.field("endtx", &self.endtx())
.field("started", &self.started())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Int {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Int {{ stopped: {=bool:?}, endrx: {=bool:?}, end: {=bool:?}, endtx: {=bool:?}, started: {=bool:?} }}" , self . stopped () , self . endrx () , self . end () , self . endtx () , self . started ())
}
}
#[doc = "Byte transmitted after TXD.MAXCNT bytes have been transmitted in the case when RXD.MAXCNT is greater than TXD.MAXCNT."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Orc(pub u32);
impl Orc {
#[doc = "Byte transmitted after TXD.MAXCNT bytes have been transmitted in the case when RXD.MAXCNT is greater than TXD.MAXCNT."]
#[must_use]
#[inline(always)]
pub const fn orc(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "Byte transmitted after TXD.MAXCNT bytes have been transmitted in the case when RXD.MAXCNT is greater than TXD.MAXCNT."]
#[inline(always)]
pub const fn set_orc(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
}
impl Default for Orc {
#[inline(always)]
fn default() -> Orc {
Orc(0)
}
}
impl core::fmt::Debug for Orc {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Orc").field("orc", &self.orc()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Orc {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Orc {{ orc: {=u8:?} }}", self.orc())
}
}
#[doc = "Number of bytes transferred in the last transaction."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct RxdAmount(pub u32);
impl RxdAmount {
#[doc = "Number of bytes transferred in the last transaction."]
#[must_use]
#[inline(always)]
pub const fn amount(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x7fff;
val as u16
}
#[doc = "Number of bytes transferred in the last transaction."]
#[inline(always)]
pub const fn set_amount(&mut self, val: u16) {
self.0 = (self.0 & !(0x7fff << 0usize)) | (((val as u32) & 0x7fff) << 0usize);
}
}
impl Default for RxdAmount {
#[inline(always)]
fn default() -> RxdAmount {
RxdAmount(0)
}
}
impl core::fmt::Debug for RxdAmount {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("RxdAmount")
.field("amount", &self.amount())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for RxdAmount {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "RxdAmount {{ amount: {=u16:?} }}", self.amount())
}
}
#[doc = "EasyDMA list type."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct RxdList(pub u32);
impl RxdList {
#[doc = "List type."]
#[must_use]
#[inline(always)]
pub const fn list(&self) -> super::vals::RxdListList {
let val = (self.0 >> 0usize) & 0x03;
super::vals::RxdListList::from_bits(val as u8)
}
#[doc = "List type."]
#[inline(always)]
pub const fn set_list(&mut self, val: super::vals::RxdListList) {
self.0 = (self.0 & !(0x03 << 0usize)) | (((val.to_bits() as u32) & 0x03) << 0usize);
}
}
impl Default for RxdList {
#[inline(always)]
fn default() -> RxdList {
RxdList(0)
}
}
impl core::fmt::Debug for RxdList {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("RxdList")
.field("list", &self.list())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for RxdList {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "RxdList {{ list: {:?} }}", self.list())
}
}
#[doc = "Maximum number of bytes in receive buffer."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct RxdMaxcnt(pub u32);
impl RxdMaxcnt {
#[doc = "Maximum number of bytes in receive buffer."]
#[must_use]
#[inline(always)]
pub const fn maxcnt(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x7fff;
val as u16
}
#[doc = "Maximum number of bytes in receive buffer."]
#[inline(always)]
pub const fn set_maxcnt(&mut self, val: u16) {
self.0 = (self.0 & !(0x7fff << 0usize)) | (((val as u32) & 0x7fff) << 0usize);
}
}
impl Default for RxdMaxcnt {
#[inline(always)]
fn default() -> RxdMaxcnt {
RxdMaxcnt(0)
}
}
impl core::fmt::Debug for RxdMaxcnt {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("RxdMaxcnt")
.field("maxcnt", &self.maxcnt())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for RxdMaxcnt {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "RxdMaxcnt {{ maxcnt: {=u16:?} }}", self.maxcnt())
}
}
#[doc = "Shortcuts between local events and tasks."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Shorts(pub u32);
impl Shorts {
#[doc = "Shortcut between event END and task START."]
#[must_use]
#[inline(always)]
pub const fn end_start(&self) -> bool {
let val = (self.0 >> 17usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event END and task START."]
#[inline(always)]
pub const fn set_end_start(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 17usize)) | (((val as u32) & 0x01) << 17usize);
}
}
impl Default for Shorts {
#[inline(always)]
fn default() -> Shorts {
Shorts(0)
}
}
impl core::fmt::Debug for Shorts {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Shorts")
.field("end_start", &self.end_start())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Shorts {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Shorts {{ end_start: {=bool:?} }}", self.end_start())
}
}
#[doc = "Number of bytes transferred in the last transaction."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct TxdAmount(pub u32);
impl TxdAmount {
#[doc = "Number of bytes transferred in the last transaction."]
#[must_use]
#[inline(always)]
pub const fn amount(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x7fff;
val as u16
}
#[doc = "Number of bytes transferred in the last transaction."]
#[inline(always)]
pub const fn set_amount(&mut self, val: u16) {
self.0 = (self.0 & !(0x7fff << 0usize)) | (((val as u32) & 0x7fff) << 0usize);
}
}
impl Default for TxdAmount {
#[inline(always)]
fn default() -> TxdAmount {
TxdAmount(0)
}
}
impl core::fmt::Debug for TxdAmount {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("TxdAmount")
.field("amount", &self.amount())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for TxdAmount {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "TxdAmount {{ amount: {=u16:?} }}", self.amount())
}
}
#[doc = "EasyDMA list type."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct TxdList(pub u32);
impl TxdList {
#[doc = "List type."]
#[must_use]
#[inline(always)]
pub const fn list(&self) -> super::vals::TxdListList {
let val = (self.0 >> 0usize) & 0x03;
super::vals::TxdListList::from_bits(val as u8)
}
#[doc = "List type."]
#[inline(always)]
pub const fn set_list(&mut self, val: super::vals::TxdListList) {
self.0 = (self.0 & !(0x03 << 0usize)) | (((val.to_bits() as u32) & 0x03) << 0usize);
}
}
impl Default for TxdList {
#[inline(always)]
fn default() -> TxdList {
TxdList(0)
}
}
impl core::fmt::Debug for TxdList {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("TxdList")
.field("list", &self.list())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for TxdList {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "TxdList {{ list: {:?} }}", self.list())
}
}
#[doc = "Number of bytes in transmit buffer."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct TxdMaxcnt(pub u32);
impl TxdMaxcnt {
#[doc = "Maximum number of bytes in transmit buffer."]
#[must_use]
#[inline(always)]
pub const fn maxcnt(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x7fff;
val as u16
}
#[doc = "Maximum number of bytes in transmit buffer."]
#[inline(always)]
pub const fn set_maxcnt(&mut self, val: u16) {
self.0 = (self.0 & !(0x7fff << 0usize)) | (((val as u32) & 0x7fff) << 0usize);
}
}
impl Default for TxdMaxcnt {
#[inline(always)]
fn default() -> TxdMaxcnt {
TxdMaxcnt(0)
}
}
impl core::fmt::Debug for TxdMaxcnt {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("TxdMaxcnt")
.field("maxcnt", &self.maxcnt())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for TxdMaxcnt {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "TxdMaxcnt {{ maxcnt: {=u16:?} }}", self.maxcnt())
}
}
}
pub mod vals {
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Cpha {
#[doc = "Sample on leading edge of clock, shift serial data on trailing edge."]
Leading = 0x0,
#[doc = "Sample on trailing edge of clock, shift serial data on leading edge."]
Trailing = 0x01,
}
impl Cpha {
#[inline(always)]
pub const fn from_bits(val: u8) -> Cpha {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Cpha {
#[inline(always)]
fn from(val: u8) -> Cpha {
Cpha::from_bits(val)
}
}
impl From<Cpha> for u8 {
#[inline(always)]
fn from(val: Cpha) -> u8 {
Cpha::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Cpol {
#[doc = "Active high."]
ActiveHigh = 0x0,
#[doc = "Active low."]
ActiveLow = 0x01,
}
impl Cpol {
#[inline(always)]
pub const fn from_bits(val: u8) -> Cpol {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Cpol {
#[inline(always)]
fn from(val: u8) -> Cpol {
Cpol::from_bits(val)
}
}
impl From<Cpol> for u8 {
#[inline(always)]
fn from(val: Cpol) -> u8 {
Cpol::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Enable {
#[doc = "Disable SPIM."]
Disabled = 0x0,
_RESERVED_1 = 0x01,
_RESERVED_2 = 0x02,
_RESERVED_3 = 0x03,
_RESERVED_4 = 0x04,
_RESERVED_5 = 0x05,
_RESERVED_6 = 0x06,
#[doc = "Enable SPIM."]
Enabled = 0x07,
_RESERVED_8 = 0x08,
_RESERVED_9 = 0x09,
_RESERVED_a = 0x0a,
_RESERVED_b = 0x0b,
_RESERVED_c = 0x0c,
_RESERVED_d = 0x0d,
_RESERVED_e = 0x0e,
_RESERVED_f = 0x0f,
}
impl Enable {
#[inline(always)]
pub const fn from_bits(val: u8) -> Enable {
unsafe { core::mem::transmute(val & 0x0f) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Enable {
#[inline(always)]
fn from(val: u8) -> Enable {
Enable::from_bits(val)
}
}
impl From<Enable> for u8 {
#[inline(always)]
fn from(val: Enable) -> u8 {
Enable::to_bits(val)
}
}
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct Frequency(u32);
impl Frequency {
#[doc = "125 kbps."]
pub const K125: Self = Self(0x0200_0000);
#[doc = "250 kbps."]
pub const K250: Self = Self(0x0400_0000);
#[doc = "500 kbps."]
pub const K500: Self = Self(0x0800_0000);
#[doc = "1 Mbps."]
pub const M1: Self = Self(0x1000_0000);
#[doc = "2 Mbps."]
pub const M2: Self = Self(0x2000_0000);
#[doc = "4 Mbps."]
pub const M4: Self = Self(0x4000_0000);
#[doc = "8 Mbps."]
pub const M8: Self = Self(0x8000_0000);
}
impl Frequency {
pub const fn from_bits(val: u32) -> Frequency {
Self(val & 0xffff_ffff)
}
pub const fn to_bits(self) -> u32 {
self.0
}
}
impl core::fmt::Debug for Frequency {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self.0 {
0x0200_0000 => f.write_str("K125"),
0x0400_0000 => f.write_str("K250"),
0x0800_0000 => f.write_str("K500"),
0x1000_0000 => f.write_str("M1"),
0x2000_0000 => f.write_str("M2"),
0x4000_0000 => f.write_str("M4"),
0x8000_0000 => f.write_str("M8"),
other => core::write!(f, "0x{:02X}", other),
}
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Frequency {
fn format(&self, f: defmt::Formatter) {
match self.0 {
0x0200_0000 => defmt::write!(f, "K125"),
0x0400_0000 => defmt::write!(f, "K250"),
0x0800_0000 => defmt::write!(f, "K500"),
0x1000_0000 => defmt::write!(f, "M1"),
0x2000_0000 => defmt::write!(f, "M2"),
0x4000_0000 => defmt::write!(f, "M4"),
0x8000_0000 => defmt::write!(f, "M8"),
other => defmt::write!(f, "0x{:02X}", other),
}
}
}
impl From<u32> for Frequency {
#[inline(always)]
fn from(val: u32) -> Frequency {
Frequency::from_bits(val)
}
}
impl From<Frequency> for u32 {
#[inline(always)]
fn from(val: Frequency) -> u32 {
Frequency::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Order {
#[doc = "Most significant bit shifted out first."]
MsbFirst = 0x0,
#[doc = "Least significant bit shifted out first."]
LsbFirst = 0x01,
}
impl Order {
#[inline(always)]
pub const fn from_bits(val: u8) -> Order {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Order {
#[inline(always)]
fn from(val: u8) -> Order {
Order::from_bits(val)
}
}
impl From<Order> for u8 {
#[inline(always)]
fn from(val: Order) -> u8 {
Order::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum RxdListList {
#[doc = "Disable EasyDMA list."]
Disabled = 0x0,
#[doc = "Use array list."]
ArrayList = 0x01,
_RESERVED_2 = 0x02,
_RESERVED_3 = 0x03,
}
impl RxdListList {
#[inline(always)]
pub const fn from_bits(val: u8) -> RxdListList {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for RxdListList {
#[inline(always)]
fn from(val: u8) -> RxdListList {
RxdListList::from_bits(val)
}
}
impl From<RxdListList> for u8 {
#[inline(always)]
fn from(val: RxdListList) -> u8 {
RxdListList::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum TxdListList {
#[doc = "Disable EasyDMA list."]
Disabled = 0x0,
#[doc = "Use array list."]
ArrayList = 0x01,
_RESERVED_2 = 0x02,
_RESERVED_3 = 0x03,
}
impl TxdListList {
#[inline(always)]
pub const fn from_bits(val: u8) -> TxdListList {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for TxdListList {
#[inline(always)]
fn from(val: u8) -> TxdListList {
TxdListList::from_bits(val)
}
}
impl From<TxdListList> for u8 {
#[inline(always)]
fn from(val: TxdListList) -> u8 {
TxdListList::to_bits(val)
}
}
}
}
pub mod spis {
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Dma {
ptr: *mut u8,
}
unsafe impl Send for Dma {}
unsafe impl Sync for Dma {}
impl Dma {
#[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 = "Unspecified."]
#[inline(always)]
pub const fn rx(self) -> DmaRx {
unsafe { DmaRx::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Unspecified."]
#[inline(always)]
pub const fn tx(self) -> DmaTx {
unsafe { DmaTx::from_ptr(self.ptr.wrapping_add(0x10usize) as _) }
}
}
#[doc = "Unspecified."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct DmaRx {
ptr: *mut u8,
}
unsafe impl Send for DmaRx {}
unsafe impl Sync for DmaRx {}
impl DmaRx {
#[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 = "RXD data pointer."]
#[inline(always)]
pub const fn ptr(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Maximum number of bytes in receive buffer."]
#[inline(always)]
pub const fn maxcnt(self) -> crate::common::Reg<regs::RxdMaxcnt, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Number of bytes received in last granted transaction."]
#[inline(always)]
pub const fn amount(self) -> crate::common::Reg<regs::RxdAmount, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
#[doc = "EasyDMA list type."]
#[inline(always)]
pub const fn list(self) -> crate::common::Reg<regs::RxdList, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0cusize) as _) }
}
}
#[doc = "Unspecified."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct DmaTx {
ptr: *mut u8,
}
unsafe impl Send for DmaTx {}
unsafe impl Sync for DmaTx {}
impl DmaTx {
#[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 = "TXD data pointer."]
#[inline(always)]
pub const fn ptr(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Maximum number of bytes in transmit buffer."]
#[inline(always)]
pub const fn maxcnt(self) -> crate::common::Reg<regs::TxdMaxcnt, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Number of bytes transmitted in last granted transaction."]
#[inline(always)]
pub const fn amount(self) -> crate::common::Reg<regs::TxdAmount, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
#[doc = "EasyDMA list type."]
#[inline(always)]
pub const fn list(self) -> crate::common::Reg<regs::TxdList, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0cusize) as _) }
}
}
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct EventsDma {
ptr: *mut u8,
}
unsafe impl Send for EventsDma {}
unsafe impl Sync for EventsDma {}
impl EventsDma {
#[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 _
}
#[inline(always)]
pub const fn rx(self) -> EventsDmaRx {
unsafe { EventsDmaRx::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
}
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct EventsDmaRx {
ptr: *mut u8,
}
unsafe impl Send for EventsDmaRx {}
unsafe impl Sync for EventsDmaRx {}
impl EventsDmaRx {
#[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 = "End of RXD buffer reached."]
#[inline(always)]
pub const fn end(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
}
#[doc = "Unspecified."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Psel {
ptr: *mut u8,
}
unsafe impl Send for Psel {}
unsafe impl Sync for Psel {}
impl Psel {
#[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 = "Pin select for SCK."]
#[inline(always)]
pub const fn sck(self) -> crate::common::Reg<super::shared::regs::Psel, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Pin select for MISO signal."]
#[inline(always)]
pub const fn miso(
self,
) -> crate::common::Reg<super::shared::regs::Psel, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Pin select for MOSI signal."]
#[inline(always)]
pub const fn mosi(
self,
) -> crate::common::Reg<super::shared::regs::Psel, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
#[doc = "Pin select for CSN signal."]
#[inline(always)]
pub const fn csn(self) -> crate::common::Reg<super::shared::regs::Psel, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0cusize) as _) }
}
}
#[doc = "SPI Slave 0."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Spis {
ptr: *mut u8,
}
unsafe impl Send for Spis {}
unsafe impl Sync for Spis {}
impl Spis {
#[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 = "Acquire SPI semaphore."]
#[inline(always)]
pub const fn tasks_acquire(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x24usize) as _) }
}
#[doc = "Release SPI semaphore, enabling the SPI slave to acquire it."]
#[inline(always)]
pub const fn tasks_release(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x28usize) as _) }
}
#[doc = "Granted transaction completed."]
#[inline(always)]
pub const fn events_end(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0104usize) as _) }
}
#[inline(always)]
pub const fn events_dma(self) -> EventsDma {
unsafe { EventsDma::from_ptr(self.ptr.wrapping_add(0x0110usize) as _) }
}
#[doc = "Semaphore acquired."]
#[inline(always)]
pub const fn events_acquired(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0128usize) as _) }
}
#[doc = "Shortcuts between local events and tasks."]
#[inline(always)]
pub const fn shorts(self) -> crate::common::Reg<regs::Shorts, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0200usize) as _) }
}
#[doc = "Enable interrupt."]
#[inline(always)]
pub const fn intenset(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0304usize) as _) }
}
#[doc = "Disable interrupt."]
#[inline(always)]
pub const fn intenclr(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0308usize) as _) }
}
#[doc = "Semaphore status register."]
#[inline(always)]
pub const fn semstat(self) -> crate::common::Reg<regs::Semstat, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0400usize) as _) }
}
#[doc = "Status from last transaction."]
#[inline(always)]
pub const fn status(self) -> crate::common::Reg<regs::Status, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0440usize) as _) }
}
#[doc = "Enable SPI slave."]
#[inline(always)]
pub const fn enable(self) -> crate::common::Reg<regs::Enable, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0500usize) as _) }
}
#[doc = "Unspecified."]
#[inline(always)]
pub const fn psel(self) -> Psel {
unsafe { Psel::from_ptr(self.ptr.wrapping_add(0x0508usize) as _) }
}
#[inline(always)]
pub const fn dma(self) -> Dma {
unsafe { Dma::from_ptr(self.ptr.wrapping_add(0x0534usize) as _) }
}
#[doc = "Configuration register."]
#[inline(always)]
pub const fn config(self) -> crate::common::Reg<regs::Config, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0554usize) as _) }
}
#[doc = "Default character. Character clocked out in case of an ignored transaction."]
#[inline(always)]
pub const fn def(self) -> crate::common::Reg<regs::Def, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x055cusize) as _) }
}
#[doc = "Over-read character."]
#[inline(always)]
pub const fn orc(self) -> crate::common::Reg<regs::Orc, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x05c0usize) as _) }
}
}
pub mod regs {
#[doc = "Configuration register."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Config(pub u32);
impl Config {
#[doc = "Bit order."]
#[must_use]
#[inline(always)]
pub const fn order(&self) -> super::vals::Order {
let val = (self.0 >> 0usize) & 0x01;
super::vals::Order::from_bits(val as u8)
}
#[doc = "Bit order."]
#[inline(always)]
pub const fn set_order(&mut self, val: super::vals::Order) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
#[doc = "Serial clock (SCK) phase."]
#[must_use]
#[inline(always)]
pub const fn cpha(&self) -> super::vals::Cpha {
let val = (self.0 >> 1usize) & 0x01;
super::vals::Cpha::from_bits(val as u8)
}
#[doc = "Serial clock (SCK) phase."]
#[inline(always)]
pub const fn set_cpha(&mut self, val: super::vals::Cpha) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val.to_bits() as u32) & 0x01) << 1usize);
}
#[doc = "Serial clock (SCK) polarity."]
#[must_use]
#[inline(always)]
pub const fn cpol(&self) -> super::vals::Cpol {
let val = (self.0 >> 2usize) & 0x01;
super::vals::Cpol::from_bits(val as u8)
}
#[doc = "Serial clock (SCK) polarity."]
#[inline(always)]
pub const fn set_cpol(&mut self, val: super::vals::Cpol) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val.to_bits() as u32) & 0x01) << 2usize);
}
}
impl Default for Config {
#[inline(always)]
fn default() -> Config {
Config(0)
}
}
impl core::fmt::Debug for Config {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Config")
.field("order", &self.order())
.field("cpha", &self.cpha())
.field("cpol", &self.cpol())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Config {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Config {{ order: {:?}, cpha: {:?}, cpol: {:?} }}",
self.order(),
self.cpha(),
self.cpol()
)
}
}
#[doc = "Default character. Character clocked out in case of an ignored transaction."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Def(pub u32);
impl Def {
#[doc = "Default character. Character clocked out in case of an ignored transaction."]
#[must_use]
#[inline(always)]
pub const fn def(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "Default character. Character clocked out in case of an ignored transaction."]
#[inline(always)]
pub const fn set_def(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
}
impl Default for Def {
#[inline(always)]
fn default() -> Def {
Def(0)
}
}
impl core::fmt::Debug for Def {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Def").field("def", &self.def()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Def {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Def {{ def: {=u8:?} }}", self.def())
}
}
#[doc = "Enable SPI slave."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Enable(pub u32);
impl Enable {
#[doc = "Enable or disable SPI slave."]
#[must_use]
#[inline(always)]
pub const fn enable(&self) -> super::vals::Enable {
let val = (self.0 >> 0usize) & 0x0f;
super::vals::Enable::from_bits(val as u8)
}
#[doc = "Enable or disable SPI slave."]
#[inline(always)]
pub const fn set_enable(&mut self, val: super::vals::Enable) {
self.0 = (self.0 & !(0x0f << 0usize)) | (((val.to_bits() as u32) & 0x0f) << 0usize);
}
}
impl Default for Enable {
#[inline(always)]
fn default() -> Enable {
Enable(0)
}
}
impl core::fmt::Debug for Enable {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Enable")
.field("enable", &self.enable())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Enable {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Enable {{ enable: {:?} }}", self.enable())
}
}
#[doc = "Disable interrupt."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Int(pub u32);
impl Int {
#[doc = "Write '1' to disable interrupt for event END."]
#[must_use]
#[inline(always)]
pub const fn end(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event END."]
#[inline(always)]
pub const fn set_end(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "Write '1' to disable interrupt for event ENDRX."]
#[must_use]
#[inline(always)]
pub const fn endrx(&self) -> bool {
let val = (self.0 >> 4usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event ENDRX."]
#[inline(always)]
pub const fn set_endrx(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
}
#[doc = "Write '1' to disable interrupt for event ACQUIRED."]
#[must_use]
#[inline(always)]
pub const fn acquired(&self) -> bool {
let val = (self.0 >> 10usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event ACQUIRED."]
#[inline(always)]
pub const fn set_acquired(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 10usize)) | (((val as u32) & 0x01) << 10usize);
}
}
impl Default for Int {
#[inline(always)]
fn default() -> Int {
Int(0)
}
}
impl core::fmt::Debug for Int {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Int")
.field("end", &self.end())
.field("endrx", &self.endrx())
.field("acquired", &self.acquired())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Int {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Int {{ end: {=bool:?}, endrx: {=bool:?}, acquired: {=bool:?} }}",
self.end(),
self.endrx(),
self.acquired()
)
}
}
#[doc = "Over-read character."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Orc(pub u32);
impl Orc {
#[doc = "Over-read character. Character clocked out after an over-read of the transmit buffer."]
#[must_use]
#[inline(always)]
pub const fn orc(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "Over-read character. Character clocked out after an over-read of the transmit buffer."]
#[inline(always)]
pub const fn set_orc(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
}
impl Default for Orc {
#[inline(always)]
fn default() -> Orc {
Orc(0)
}
}
impl core::fmt::Debug for Orc {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Orc").field("orc", &self.orc()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Orc {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Orc {{ orc: {=u8:?} }}", self.orc())
}
}
#[doc = "Number of bytes received in last granted transaction."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct RxdAmount(pub u32);
impl RxdAmount {
#[doc = "Number of bytes received in the last granted transaction."]
#[must_use]
#[inline(always)]
pub const fn amount(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x7fff;
val as u16
}
#[doc = "Number of bytes received in the last granted transaction."]
#[inline(always)]
pub const fn set_amount(&mut self, val: u16) {
self.0 = (self.0 & !(0x7fff << 0usize)) | (((val as u32) & 0x7fff) << 0usize);
}
}
impl Default for RxdAmount {
#[inline(always)]
fn default() -> RxdAmount {
RxdAmount(0)
}
}
impl core::fmt::Debug for RxdAmount {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("RxdAmount")
.field("amount", &self.amount())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for RxdAmount {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "RxdAmount {{ amount: {=u16:?} }}", self.amount())
}
}
#[doc = "EasyDMA list type."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct RxdList(pub u32);
impl RxdList {
#[doc = "List type."]
#[must_use]
#[inline(always)]
pub const fn list(&self) -> super::vals::RxdListList {
let val = (self.0 >> 0usize) & 0x03;
super::vals::RxdListList::from_bits(val as u8)
}
#[doc = "List type."]
#[inline(always)]
pub const fn set_list(&mut self, val: super::vals::RxdListList) {
self.0 = (self.0 & !(0x03 << 0usize)) | (((val.to_bits() as u32) & 0x03) << 0usize);
}
}
impl Default for RxdList {
#[inline(always)]
fn default() -> RxdList {
RxdList(0)
}
}
impl core::fmt::Debug for RxdList {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("RxdList")
.field("list", &self.list())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for RxdList {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "RxdList {{ list: {:?} }}", self.list())
}
}
#[doc = "Maximum number of bytes in receive buffer."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct RxdMaxcnt(pub u32);
impl RxdMaxcnt {
#[doc = "Maximum number of bytes in receive buffer."]
#[must_use]
#[inline(always)]
pub const fn maxcnt(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x7fff;
val as u16
}
#[doc = "Maximum number of bytes in receive buffer."]
#[inline(always)]
pub const fn set_maxcnt(&mut self, val: u16) {
self.0 = (self.0 & !(0x7fff << 0usize)) | (((val as u32) & 0x7fff) << 0usize);
}
}
impl Default for RxdMaxcnt {
#[inline(always)]
fn default() -> RxdMaxcnt {
RxdMaxcnt(0)
}
}
impl core::fmt::Debug for RxdMaxcnt {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("RxdMaxcnt")
.field("maxcnt", &self.maxcnt())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for RxdMaxcnt {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "RxdMaxcnt {{ maxcnt: {=u16:?} }}", self.maxcnt())
}
}
#[doc = "Semaphore status register."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Semstat(pub u32);
impl Semstat {
#[doc = "Semaphore status."]
#[must_use]
#[inline(always)]
pub const fn semstat(&self) -> super::vals::Semstat {
let val = (self.0 >> 0usize) & 0x03;
super::vals::Semstat::from_bits(val as u8)
}
#[doc = "Semaphore status."]
#[inline(always)]
pub const fn set_semstat(&mut self, val: super::vals::Semstat) {
self.0 = (self.0 & !(0x03 << 0usize)) | (((val.to_bits() as u32) & 0x03) << 0usize);
}
}
impl Default for Semstat {
#[inline(always)]
fn default() -> Semstat {
Semstat(0)
}
}
impl core::fmt::Debug for Semstat {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Semstat")
.field("semstat", &self.semstat())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Semstat {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Semstat {{ semstat: {:?} }}", self.semstat())
}
}
#[doc = "Shortcuts between local events and tasks."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Shorts(pub u32);
impl Shorts {
#[doc = "Shortcut between event END and task ACQUIRE."]
#[must_use]
#[inline(always)]
pub const fn end_acquire(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event END and task ACQUIRE."]
#[inline(always)]
pub const fn set_end_acquire(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
}
impl Default for Shorts {
#[inline(always)]
fn default() -> Shorts {
Shorts(0)
}
}
impl core::fmt::Debug for Shorts {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Shorts")
.field("end_acquire", &self.end_acquire())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Shorts {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Shorts {{ end_acquire: {=bool:?} }}", self.end_acquire())
}
}
#[doc = "Status from last transaction."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Status(pub u32);
impl Status {
#[doc = "TX buffer over-read detected, and prevented."]
#[must_use]
#[inline(always)]
pub const fn overread(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "TX buffer over-read detected, and prevented."]
#[inline(always)]
pub const fn set_overread(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "RX buffer overflow detected, and prevented."]
#[must_use]
#[inline(always)]
pub const fn overflow(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "RX buffer overflow detected, and prevented."]
#[inline(always)]
pub const fn set_overflow(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
}
impl Default for Status {
#[inline(always)]
fn default() -> Status {
Status(0)
}
}
impl core::fmt::Debug for Status {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Status")
.field("overread", &self.overread())
.field("overflow", &self.overflow())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Status {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Status {{ overread: {=bool:?}, overflow: {=bool:?} }}",
self.overread(),
self.overflow()
)
}
}
#[doc = "Number of bytes transmitted in last granted transaction."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct TxdAmount(pub u32);
impl TxdAmount {
#[doc = "Number of bytes transmitted in last granted transaction."]
#[must_use]
#[inline(always)]
pub const fn amount(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x7fff;
val as u16
}
#[doc = "Number of bytes transmitted in last granted transaction."]
#[inline(always)]
pub const fn set_amount(&mut self, val: u16) {
self.0 = (self.0 & !(0x7fff << 0usize)) | (((val as u32) & 0x7fff) << 0usize);
}
}
impl Default for TxdAmount {
#[inline(always)]
fn default() -> TxdAmount {
TxdAmount(0)
}
}
impl core::fmt::Debug for TxdAmount {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("TxdAmount")
.field("amount", &self.amount())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for TxdAmount {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "TxdAmount {{ amount: {=u16:?} }}", self.amount())
}
}
#[doc = "EasyDMA list type."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct TxdList(pub u32);
impl TxdList {
#[doc = "List type."]
#[must_use]
#[inline(always)]
pub const fn list(&self) -> super::vals::TxdListList {
let val = (self.0 >> 0usize) & 0x03;
super::vals::TxdListList::from_bits(val as u8)
}
#[doc = "List type."]
#[inline(always)]
pub const fn set_list(&mut self, val: super::vals::TxdListList) {
self.0 = (self.0 & !(0x03 << 0usize)) | (((val.to_bits() as u32) & 0x03) << 0usize);
}
}
impl Default for TxdList {
#[inline(always)]
fn default() -> TxdList {
TxdList(0)
}
}
impl core::fmt::Debug for TxdList {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("TxdList")
.field("list", &self.list())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for TxdList {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "TxdList {{ list: {:?} }}", self.list())
}
}
#[doc = "Maximum number of bytes in transmit buffer."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct TxdMaxcnt(pub u32);
impl TxdMaxcnt {
#[doc = "Maximum number of bytes in transmit buffer."]
#[must_use]
#[inline(always)]
pub const fn maxcnt(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x7fff;
val as u16
}
#[doc = "Maximum number of bytes in transmit buffer."]
#[inline(always)]
pub const fn set_maxcnt(&mut self, val: u16) {
self.0 = (self.0 & !(0x7fff << 0usize)) | (((val as u32) & 0x7fff) << 0usize);
}
}
impl Default for TxdMaxcnt {
#[inline(always)]
fn default() -> TxdMaxcnt {
TxdMaxcnt(0)
}
}
impl core::fmt::Debug for TxdMaxcnt {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("TxdMaxcnt")
.field("maxcnt", &self.maxcnt())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for TxdMaxcnt {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "TxdMaxcnt {{ maxcnt: {=u16:?} }}", self.maxcnt())
}
}
}
pub mod vals {
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Cpha {
#[doc = "Sample on leading edge of clock, shift serial data on trailing edge."]
Leading = 0x0,
#[doc = "Sample on trailing edge of clock, shift serial data on leading edge."]
Trailing = 0x01,
}
impl Cpha {
#[inline(always)]
pub const fn from_bits(val: u8) -> Cpha {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Cpha {
#[inline(always)]
fn from(val: u8) -> Cpha {
Cpha::from_bits(val)
}
}
impl From<Cpha> for u8 {
#[inline(always)]
fn from(val: Cpha) -> u8 {
Cpha::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Cpol {
#[doc = "Active high."]
ActiveHigh = 0x0,
#[doc = "Active low."]
ActiveLow = 0x01,
}
impl Cpol {
#[inline(always)]
pub const fn from_bits(val: u8) -> Cpol {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Cpol {
#[inline(always)]
fn from(val: u8) -> Cpol {
Cpol::from_bits(val)
}
}
impl From<Cpol> for u8 {
#[inline(always)]
fn from(val: Cpol) -> u8 {
Cpol::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Enable {
#[doc = "Disable SPI slave."]
Disabled = 0x0,
_RESERVED_1 = 0x01,
#[doc = "Enable SPI slave."]
Enabled = 0x02,
_RESERVED_3 = 0x03,
_RESERVED_4 = 0x04,
_RESERVED_5 = 0x05,
_RESERVED_6 = 0x06,
_RESERVED_7 = 0x07,
_RESERVED_8 = 0x08,
_RESERVED_9 = 0x09,
_RESERVED_a = 0x0a,
_RESERVED_b = 0x0b,
_RESERVED_c = 0x0c,
_RESERVED_d = 0x0d,
_RESERVED_e = 0x0e,
_RESERVED_f = 0x0f,
}
impl Enable {
#[inline(always)]
pub const fn from_bits(val: u8) -> Enable {
unsafe { core::mem::transmute(val & 0x0f) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Enable {
#[inline(always)]
fn from(val: u8) -> Enable {
Enable::from_bits(val)
}
}
impl From<Enable> for u8 {
#[inline(always)]
fn from(val: Enable) -> u8 {
Enable::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Order {
#[doc = "Most significant bit shifted out first."]
MsbFirst = 0x0,
#[doc = "Least significant bit shifted out first."]
LsbFirst = 0x01,
}
impl Order {
#[inline(always)]
pub const fn from_bits(val: u8) -> Order {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Order {
#[inline(always)]
fn from(val: u8) -> Order {
Order::from_bits(val)
}
}
impl From<Order> for u8 {
#[inline(always)]
fn from(val: Order) -> u8 {
Order::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum RxdListList {
#[doc = "Disable EasyDMA list."]
Disabled = 0x0,
#[doc = "Use array list."]
ArrayList = 0x01,
_RESERVED_2 = 0x02,
_RESERVED_3 = 0x03,
}
impl RxdListList {
#[inline(always)]
pub const fn from_bits(val: u8) -> RxdListList {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for RxdListList {
#[inline(always)]
fn from(val: u8) -> RxdListList {
RxdListList::from_bits(val)
}
}
impl From<RxdListList> for u8 {
#[inline(always)]
fn from(val: RxdListList) -> u8 {
RxdListList::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Semstat {
#[doc = "Semaphore is free."]
Free = 0x0,
#[doc = "Semaphore is assigned to CPU."]
Cpu = 0x01,
#[doc = "Semaphore is assigned to SPI slave."]
Spis = 0x02,
#[doc = "Semaphore is assigned to SPI but a handover to the CPU is pending."]
CpuPending = 0x03,
}
impl Semstat {
#[inline(always)]
pub const fn from_bits(val: u8) -> Semstat {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Semstat {
#[inline(always)]
fn from(val: u8) -> Semstat {
Semstat::from_bits(val)
}
}
impl From<Semstat> for u8 {
#[inline(always)]
fn from(val: Semstat) -> u8 {
Semstat::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum TxdListList {
#[doc = "Disable EasyDMA list."]
Disabled = 0x0,
#[doc = "Use array list."]
ArrayList = 0x01,
_RESERVED_2 = 0x02,
_RESERVED_3 = 0x03,
}
impl TxdListList {
#[inline(always)]
pub const fn from_bits(val: u8) -> TxdListList {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for TxdListList {
#[inline(always)]
fn from(val: u8) -> TxdListList {
TxdListList::from_bits(val)
}
}
impl From<TxdListList> for u8 {
#[inline(always)]
fn from(val: TxdListList) -> u8 {
TxdListList::to_bits(val)
}
}
}
}
pub mod swi {
#[doc = "Software interrupt 0."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Swi {
ptr: *mut u8,
}
unsafe impl Send for Swi {}
unsafe impl Sync for Swi {}
impl Swi {
#[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 = "Unused."]
#[inline(always)]
pub const fn unused(self) -> crate::common::Reg<u32, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
}
}
pub mod temp {
#[doc = "Temperature Sensor."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Temp {
ptr: *mut u8,
}
unsafe impl Send for Temp {}
unsafe impl Sync for Temp {}
impl Temp {
#[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 = "Start temperature measurement."]
#[inline(always)]
pub const fn tasks_start(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Stop temperature measurement."]
#[inline(always)]
pub const fn tasks_stop(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Temperature measurement complete, data ready."]
#[inline(always)]
pub const fn events_datardy(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0100usize) as _) }
}
#[doc = "Enable interrupt."]
#[inline(always)]
pub const fn intenset(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0304usize) as _) }
}
#[doc = "Disable interrupt."]
#[inline(always)]
pub const fn intenclr(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0308usize) as _) }
}
#[doc = "Temperature in degC (0.25deg steps)."]
#[inline(always)]
pub const fn temp(self) -> crate::common::Reg<u32, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0508usize) as _) }
}
#[doc = "Slope of first piecewise linear function."]
#[inline(always)]
pub const fn a(self, n: usize) -> crate::common::Reg<u32, crate::common::RW> {
assert!(n < 6usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0520usize + n * 4usize) as _)
}
}
#[doc = "y-intercept of first piecewise linear function."]
#[inline(always)]
pub const fn b(self, n: usize) -> crate::common::Reg<u32, crate::common::RW> {
assert!(n < 6usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0540usize + n * 4usize) as _)
}
}
#[doc = "End point of first piecewise linear function."]
#[inline(always)]
pub const fn t(self, n: usize) -> crate::common::Reg<u32, crate::common::RW> {
assert!(n < 5usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0560usize + n * 4usize) as _)
}
}
}
pub mod regs {
#[doc = "Disable interrupt."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Int(pub u32);
impl Int {
#[doc = "Write '1' to disable interrupt for event DATARDY."]
#[must_use]
#[inline(always)]
pub const fn datardy(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event DATARDY."]
#[inline(always)]
pub const fn set_datardy(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for Int {
#[inline(always)]
fn default() -> Int {
Int(0)
}
}
impl core::fmt::Debug for Int {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Int")
.field("datardy", &self.datardy())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Int {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Int {{ datardy: {=bool:?} }}", self.datardy())
}
}
}
}
pub mod timer {
#[doc = "Timer/Counter 0."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Timer {
ptr: *mut u8,
}
unsafe impl Send for Timer {}
unsafe impl Sync for Timer {}
impl Timer {
#[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 = "Start Timer."]
#[inline(always)]
pub const fn tasks_start(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Stop Timer."]
#[inline(always)]
pub const fn tasks_stop(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Increment Timer (Counter mode only)."]
#[inline(always)]
pub const fn tasks_count(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
#[doc = "Clear time."]
#[inline(always)]
pub const fn tasks_clear(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0cusize) as _) }
}
#[doc = "Deprecated register - Shut down timer."]
#[inline(always)]
pub const fn tasks_shutdown(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x10usize) as _) }
}
#[doc = "Description collection: Capture Timer value to CC\\[n\\] register."]
#[inline(always)]
pub const fn tasks_capture(self, n: usize) -> crate::common::Reg<u32, crate::common::W> {
assert!(n < 6usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x40usize + n * 4usize) as _)
}
}
#[doc = "Description collection: Compare event on CC\\[n\\] match."]
#[inline(always)]
pub const fn events_compare(self, n: usize) -> crate::common::Reg<u32, crate::common::RW> {
assert!(n < 6usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0140usize + n * 4usize) as _)
}
}
#[doc = "Shortcuts between local events and tasks."]
#[inline(always)]
pub const fn shorts(self) -> crate::common::Reg<regs::Shorts, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0200usize) as _) }
}
#[doc = "Enable interrupt."]
#[inline(always)]
pub const fn intenset(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0304usize) as _) }
}
#[doc = "Disable interrupt."]
#[inline(always)]
pub const fn intenclr(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0308usize) as _) }
}
#[doc = "Timer mode selection."]
#[inline(always)]
pub const fn mode(self) -> crate::common::Reg<regs::Mode, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0504usize) as _) }
}
#[doc = "Configure the number of bits used by the TIMER."]
#[inline(always)]
pub const fn bitmode(self) -> crate::common::Reg<regs::Bitmode, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0508usize) as _) }
}
#[doc = "Timer prescaler register."]
#[inline(always)]
pub const fn prescaler(self) -> crate::common::Reg<regs::Prescaler, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0510usize) as _) }
}
#[doc = "Description collection: Capture/Compare register n."]
#[inline(always)]
pub const fn cc(self, n: usize) -> crate::common::Reg<u32, crate::common::RW> {
assert!(n < 6usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0540usize + n * 4usize) as _)
}
}
}
pub mod regs {
#[doc = "Configure the number of bits used by the TIMER."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Bitmode(pub u32);
impl Bitmode {
#[doc = "Timer bit width."]
#[must_use]
#[inline(always)]
pub const fn bitmode(&self) -> super::vals::Bitmode {
let val = (self.0 >> 0usize) & 0x03;
super::vals::Bitmode::from_bits(val as u8)
}
#[doc = "Timer bit width."]
#[inline(always)]
pub const fn set_bitmode(&mut self, val: super::vals::Bitmode) {
self.0 = (self.0 & !(0x03 << 0usize)) | (((val.to_bits() as u32) & 0x03) << 0usize);
}
}
impl Default for Bitmode {
#[inline(always)]
fn default() -> Bitmode {
Bitmode(0)
}
}
impl core::fmt::Debug for Bitmode {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Bitmode")
.field("bitmode", &self.bitmode())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Bitmode {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Bitmode {{ bitmode: {:?} }}", self.bitmode())
}
}
#[doc = "Disable interrupt."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Int(pub u32);
impl Int {
#[doc = "Write '1' to disable interrupt for event COMPARE\\[0\\]."]
#[must_use]
#[inline(always)]
pub const fn compare(&self, n: usize) -> bool {
assert!(n < 6usize);
let offs = 16usize + n * 1usize;
let val = (self.0 >> offs) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event COMPARE\\[0\\]."]
#[inline(always)]
pub const fn set_compare(&mut self, n: usize, val: bool) {
assert!(n < 6usize);
let offs = 16usize + n * 1usize;
self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
}
}
impl Default for Int {
#[inline(always)]
fn default() -> Int {
Int(0)
}
}
impl core::fmt::Debug for Int {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Int")
.field("compare[0]", &self.compare(0usize))
.field("compare[1]", &self.compare(1usize))
.field("compare[2]", &self.compare(2usize))
.field("compare[3]", &self.compare(3usize))
.field("compare[4]", &self.compare(4usize))
.field("compare[5]", &self.compare(5usize))
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Int {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Int {{ compare[0]: {=bool:?}, compare[1]: {=bool:?}, compare[2]: {=bool:?}, compare[3]: {=bool:?}, compare[4]: {=bool:?}, compare[5]: {=bool:?} }}" , self . compare (0usize) , self . compare (1usize) , self . compare (2usize) , self . compare (3usize) , self . compare (4usize) , self . compare (5usize))
}
}
#[doc = "Timer mode selection."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Mode(pub u32);
impl Mode {
#[doc = "Timer mode."]
#[must_use]
#[inline(always)]
pub const fn mode(&self) -> super::vals::Mode {
let val = (self.0 >> 0usize) & 0x03;
super::vals::Mode::from_bits(val as u8)
}
#[doc = "Timer mode."]
#[inline(always)]
pub const fn set_mode(&mut self, val: super::vals::Mode) {
self.0 = (self.0 & !(0x03 << 0usize)) | (((val.to_bits() as u32) & 0x03) << 0usize);
}
}
impl Default for Mode {
#[inline(always)]
fn default() -> Mode {
Mode(0)
}
}
impl core::fmt::Debug for Mode {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Mode").field("mode", &self.mode()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Mode {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Mode {{ mode: {:?} }}", self.mode())
}
}
#[doc = "Timer prescaler register."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Prescaler(pub u32);
impl Prescaler {
#[doc = "Prescaler value."]
#[must_use]
#[inline(always)]
pub const fn prescaler(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x0f;
val as u8
}
#[doc = "Prescaler value."]
#[inline(always)]
pub const fn set_prescaler(&mut self, val: u8) {
self.0 = (self.0 & !(0x0f << 0usize)) | (((val as u32) & 0x0f) << 0usize);
}
}
impl Default for Prescaler {
#[inline(always)]
fn default() -> Prescaler {
Prescaler(0)
}
}
impl core::fmt::Debug for Prescaler {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Prescaler")
.field("prescaler", &self.prescaler())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Prescaler {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Prescaler {{ prescaler: {=u8:?} }}", self.prescaler())
}
}
#[doc = "Shortcuts between local events and tasks."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Shorts(pub u32);
impl Shorts {
#[doc = "Shortcut between event COMPARE\\[0\\] and task CLEAR."]
#[must_use]
#[inline(always)]
pub const fn compare_clear(&self, n: usize) -> bool {
assert!(n < 6usize);
let offs = 0usize + n * 1usize;
let val = (self.0 >> offs) & 0x01;
val != 0
}
#[doc = "Shortcut between event COMPARE\\[0\\] and task CLEAR."]
#[inline(always)]
pub const fn set_compare_clear(&mut self, n: usize, val: bool) {
assert!(n < 6usize);
let offs = 0usize + n * 1usize;
self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
}
#[doc = "Shortcut between event COMPARE\\[0\\] and task STOP."]
#[must_use]
#[inline(always)]
pub const fn compare_stop(&self, n: usize) -> bool {
assert!(n < 6usize);
let offs = 8usize + n * 1usize;
let val = (self.0 >> offs) & 0x01;
val != 0
}
#[doc = "Shortcut between event COMPARE\\[0\\] and task STOP."]
#[inline(always)]
pub const fn set_compare_stop(&mut self, n: usize, val: bool) {
assert!(n < 6usize);
let offs = 8usize + n * 1usize;
self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
}
}
impl Default for Shorts {
#[inline(always)]
fn default() -> Shorts {
Shorts(0)
}
}
impl core::fmt::Debug for Shorts {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Shorts")
.field("compare_clear[0]", &self.compare_clear(0usize))
.field("compare_clear[1]", &self.compare_clear(1usize))
.field("compare_clear[2]", &self.compare_clear(2usize))
.field("compare_clear[3]", &self.compare_clear(3usize))
.field("compare_clear[4]", &self.compare_clear(4usize))
.field("compare_clear[5]", &self.compare_clear(5usize))
.field("compare_stop[0]", &self.compare_stop(0usize))
.field("compare_stop[1]", &self.compare_stop(1usize))
.field("compare_stop[2]", &self.compare_stop(2usize))
.field("compare_stop[3]", &self.compare_stop(3usize))
.field("compare_stop[4]", &self.compare_stop(4usize))
.field("compare_stop[5]", &self.compare_stop(5usize))
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Shorts {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Shorts {{ compare_clear[0]: {=bool:?}, compare_clear[1]: {=bool:?}, compare_clear[2]: {=bool:?}, compare_clear[3]: {=bool:?}, compare_clear[4]: {=bool:?}, compare_clear[5]: {=bool:?}, compare_stop[0]: {=bool:?}, compare_stop[1]: {=bool:?}, compare_stop[2]: {=bool:?}, compare_stop[3]: {=bool:?}, compare_stop[4]: {=bool:?}, compare_stop[5]: {=bool:?} }}" , self . compare_clear (0usize) , self . compare_clear (1usize) , self . compare_clear (2usize) , self . compare_clear (3usize) , self . compare_clear (4usize) , self . compare_clear (5usize) , self . compare_stop (0usize) , self . compare_stop (1usize) , self . compare_stop (2usize) , self . compare_stop (3usize) , self . compare_stop (4usize) , self . compare_stop (5usize))
}
}
}
pub mod vals {
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Bitmode {
#[doc = "16 bit timer bit width."]
_16bit = 0x0,
#[doc = "8 bit timer bit width."]
_08bit = 0x01,
#[doc = "24 bit timer bit width."]
_24bit = 0x02,
#[doc = "32 bit timer bit width."]
_32bit = 0x03,
}
impl Bitmode {
#[inline(always)]
pub const fn from_bits(val: u8) -> Bitmode {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Bitmode {
#[inline(always)]
fn from(val: u8) -> Bitmode {
Bitmode::from_bits(val)
}
}
impl From<Bitmode> for u8 {
#[inline(always)]
fn from(val: Bitmode) -> u8 {
Bitmode::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Mode {
#[doc = "Select Timer mode."]
Timer = 0x0,
#[doc = "Deprecated enumerator - Select Counter mode."]
Counter = 0x01,
#[doc = "Select Low Power Counter mode."]
LowPowerCounter = 0x02,
_RESERVED_3 = 0x03,
}
impl Mode {
#[inline(always)]
pub const fn from_bits(val: u8) -> Mode {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Mode {
#[inline(always)]
fn from(val: u8) -> Mode {
Mode::from_bits(val)
}
}
impl From<Mode> for u8 {
#[inline(always)]
fn from(val: Mode) -> u8 {
Mode::to_bits(val)
}
}
}
}
pub mod twi {
#[doc = "Unspecified."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Psel {
ptr: *mut u8,
}
unsafe impl Send for Psel {}
unsafe impl Sync for Psel {}
impl Psel {
#[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 = "Pin select for SCL."]
#[inline(always)]
pub const fn scl(self) -> crate::common::Reg<super::shared::regs::Psel, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Pin select for SDA."]
#[inline(always)]
pub const fn sda(self) -> crate::common::Reg<super::shared::regs::Psel, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
}
#[doc = "I2C compatible Two-Wire Interface 0."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Twi {
ptr: *mut u8,
}
unsafe impl Send for Twi {}
unsafe impl Sync for Twi {}
impl Twi {
#[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 = "Start TWI receive sequence."]
#[inline(always)]
pub const fn tasks_startrx(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Start TWI transmit sequence."]
#[inline(always)]
pub const fn tasks_starttx(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
#[doc = "Stop TWI transaction."]
#[inline(always)]
pub const fn tasks_stop(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x14usize) as _) }
}
#[doc = "Suspend TWI transaction."]
#[inline(always)]
pub const fn tasks_suspend(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x1cusize) as _) }
}
#[doc = "Resume TWI transaction."]
#[inline(always)]
pub const fn tasks_resume(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x20usize) as _) }
}
#[doc = "TWI stopped."]
#[inline(always)]
pub const fn events_stopped(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0104usize) as _) }
}
#[doc = "TWI RXD byte received."]
#[inline(always)]
pub const fn events_rxdready(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0108usize) as _) }
}
#[doc = "TWI TXD byte sent."]
#[inline(always)]
pub const fn events_txdsent(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x011cusize) as _) }
}
#[doc = "TWI error."]
#[inline(always)]
pub const fn events_error(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0124usize) as _) }
}
#[doc = "TWI byte boundary, generated before each byte that is sent or received."]
#[inline(always)]
pub const fn events_bb(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0138usize) as _) }
}
#[doc = "TWI entered the suspended state."]
#[inline(always)]
pub const fn events_suspended(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0148usize) as _) }
}
#[doc = "Shortcuts between local events and tasks."]
#[inline(always)]
pub const fn shorts(self) -> crate::common::Reg<regs::Shorts, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0200usize) as _) }
}
#[doc = "Enable interrupt."]
#[inline(always)]
pub const fn intenset(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0304usize) as _) }
}
#[doc = "Disable interrupt."]
#[inline(always)]
pub const fn intenclr(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0308usize) as _) }
}
#[doc = "Error source."]
#[inline(always)]
pub const fn errorsrc(self) -> crate::common::Reg<regs::Errorsrc, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04c4usize) as _) }
}
#[doc = "Enable TWI."]
#[inline(always)]
pub const fn enable(self) -> crate::common::Reg<regs::Enable, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0500usize) as _) }
}
#[doc = "Unspecified."]
#[inline(always)]
pub const fn psel(self) -> Psel {
unsafe { Psel::from_ptr(self.ptr.wrapping_add(0x0508usize) as _) }
}
#[doc = "RXD register."]
#[inline(always)]
pub const fn rxd(self) -> crate::common::Reg<regs::Rxd, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0518usize) as _) }
}
#[doc = "TXD register."]
#[inline(always)]
pub const fn txd(self) -> crate::common::Reg<regs::Txd, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x051cusize) as _) }
}
#[doc = "TWI frequency. Accuracy depends on the HFCLK source selected."]
#[inline(always)]
pub const fn frequency(self) -> crate::common::Reg<regs::Frequency, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0524usize) as _) }
}
#[doc = "Address used in the TWI transfer."]
#[inline(always)]
pub const fn address(self) -> crate::common::Reg<regs::Address, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0588usize) as _) }
}
}
pub mod regs {
#[doc = "Address used in the TWI transfer."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Address(pub u32);
impl Address {
#[doc = "Address used in the TWI transfer."]
#[must_use]
#[inline(always)]
pub const fn address(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x7f;
val as u8
}
#[doc = "Address used in the TWI transfer."]
#[inline(always)]
pub const fn set_address(&mut self, val: u8) {
self.0 = (self.0 & !(0x7f << 0usize)) | (((val as u32) & 0x7f) << 0usize);
}
}
impl Default for Address {
#[inline(always)]
fn default() -> Address {
Address(0)
}
}
impl core::fmt::Debug for Address {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Address")
.field("address", &self.address())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Address {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Address {{ address: {=u8:?} }}", self.address())
}
}
#[doc = "Enable TWI."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Enable(pub u32);
impl Enable {
#[doc = "Enable or disable TWI."]
#[must_use]
#[inline(always)]
pub const fn enable(&self) -> super::vals::Enable {
let val = (self.0 >> 0usize) & 0x0f;
super::vals::Enable::from_bits(val as u8)
}
#[doc = "Enable or disable TWI."]
#[inline(always)]
pub const fn set_enable(&mut self, val: super::vals::Enable) {
self.0 = (self.0 & !(0x0f << 0usize)) | (((val.to_bits() as u32) & 0x0f) << 0usize);
}
}
impl Default for Enable {
#[inline(always)]
fn default() -> Enable {
Enable(0)
}
}
impl core::fmt::Debug for Enable {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Enable")
.field("enable", &self.enable())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Enable {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Enable {{ enable: {:?} }}", self.enable())
}
}
#[doc = "Error source."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Errorsrc(pub u32);
impl Errorsrc {
#[doc = "Overrun error."]
#[must_use]
#[inline(always)]
pub const fn overrun(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Overrun error."]
#[inline(always)]
pub const fn set_overrun(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "NACK received after sending the address (write '1' to clear)."]
#[must_use]
#[inline(always)]
pub const fn anack(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "NACK received after sending the address (write '1' to clear)."]
#[inline(always)]
pub const fn set_anack(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "NACK received after sending a data byte (write '1' to clear)."]
#[must_use]
#[inline(always)]
pub const fn dnack(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "NACK received after sending a data byte (write '1' to clear)."]
#[inline(always)]
pub const fn set_dnack(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
}
impl Default for Errorsrc {
#[inline(always)]
fn default() -> Errorsrc {
Errorsrc(0)
}
}
impl core::fmt::Debug for Errorsrc {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Errorsrc")
.field("overrun", &self.overrun())
.field("anack", &self.anack())
.field("dnack", &self.dnack())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Errorsrc {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Errorsrc {{ overrun: {=bool:?}, anack: {=bool:?}, dnack: {=bool:?} }}",
self.overrun(),
self.anack(),
self.dnack()
)
}
}
#[doc = "TWI frequency. Accuracy depends on the HFCLK source selected."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Frequency(pub u32);
impl Frequency {
#[doc = "TWI master clock frequency."]
#[must_use]
#[inline(always)]
pub const fn frequency(&self) -> super::vals::Frequency {
let val = (self.0 >> 0usize) & 0xffff_ffff;
super::vals::Frequency::from_bits(val as u32)
}
#[doc = "TWI master clock frequency."]
#[inline(always)]
pub const fn set_frequency(&mut self, val: super::vals::Frequency) {
self.0 = (self.0 & !(0xffff_ffff << 0usize))
| (((val.to_bits() as u32) & 0xffff_ffff) << 0usize);
}
}
impl Default for Frequency {
#[inline(always)]
fn default() -> Frequency {
Frequency(0)
}
}
impl core::fmt::Debug for Frequency {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Frequency")
.field("frequency", &self.frequency())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Frequency {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Frequency {{ frequency: {:?} }}", self.frequency())
}
}
#[doc = "Disable interrupt."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Int(pub u32);
impl Int {
#[doc = "Write '1' to disable interrupt for event STOPPED."]
#[must_use]
#[inline(always)]
pub const fn stopped(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event STOPPED."]
#[inline(always)]
pub const fn set_stopped(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "Write '1' to disable interrupt for event RXDREADY."]
#[must_use]
#[inline(always)]
pub const fn rxdready(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event RXDREADY."]
#[inline(always)]
pub const fn set_rxdready(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "Write '1' to disable interrupt for event TXDSENT."]
#[must_use]
#[inline(always)]
pub const fn txdsent(&self) -> bool {
let val = (self.0 >> 7usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event TXDSENT."]
#[inline(always)]
pub const fn set_txdsent(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize);
}
#[doc = "Write '1' to disable interrupt for event ERROR."]
#[must_use]
#[inline(always)]
pub const fn error(&self) -> bool {
let val = (self.0 >> 9usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event ERROR."]
#[inline(always)]
pub const fn set_error(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 9usize)) | (((val as u32) & 0x01) << 9usize);
}
#[doc = "Write '1' to disable interrupt for event BB."]
#[must_use]
#[inline(always)]
pub const fn bb(&self) -> bool {
let val = (self.0 >> 14usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event BB."]
#[inline(always)]
pub const fn set_bb(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 14usize)) | (((val as u32) & 0x01) << 14usize);
}
#[doc = "Write '1' to disable interrupt for event SUSPENDED."]
#[must_use]
#[inline(always)]
pub const fn suspended(&self) -> bool {
let val = (self.0 >> 18usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event SUSPENDED."]
#[inline(always)]
pub const fn set_suspended(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 18usize)) | (((val as u32) & 0x01) << 18usize);
}
}
impl Default for Int {
#[inline(always)]
fn default() -> Int {
Int(0)
}
}
impl core::fmt::Debug for Int {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Int")
.field("stopped", &self.stopped())
.field("rxdready", &self.rxdready())
.field("txdsent", &self.txdsent())
.field("error", &self.error())
.field("bb", &self.bb())
.field("suspended", &self.suspended())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Int {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Int {{ stopped: {=bool:?}, rxdready: {=bool:?}, txdsent: {=bool:?}, error: {=bool:?}, bb: {=bool:?}, suspended: {=bool:?} }}" , self . stopped () , self . rxdready () , self . txdsent () , self . error () , self . bb () , self . suspended ())
}
}
#[doc = "RXD register."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Rxd(pub u32);
impl Rxd {
#[doc = "RXD register."]
#[must_use]
#[inline(always)]
pub const fn rxd(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "RXD register."]
#[inline(always)]
pub const fn set_rxd(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
}
impl Default for Rxd {
#[inline(always)]
fn default() -> Rxd {
Rxd(0)
}
}
impl core::fmt::Debug for Rxd {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Rxd").field("rxd", &self.rxd()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Rxd {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Rxd {{ rxd: {=u8:?} }}", self.rxd())
}
}
#[doc = "Shortcuts between local events and tasks."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Shorts(pub u32);
impl Shorts {
#[doc = "Shortcut between event BB and task SUSPEND."]
#[must_use]
#[inline(always)]
pub const fn bb_suspend(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event BB and task SUSPEND."]
#[inline(always)]
pub const fn set_bb_suspend(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Shortcut between event BB and task STOP."]
#[must_use]
#[inline(always)]
pub const fn bb_stop(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event BB and task STOP."]
#[inline(always)]
pub const fn set_bb_stop(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
}
impl Default for Shorts {
#[inline(always)]
fn default() -> Shorts {
Shorts(0)
}
}
impl core::fmt::Debug for Shorts {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Shorts")
.field("bb_suspend", &self.bb_suspend())
.field("bb_stop", &self.bb_stop())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Shorts {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Shorts {{ bb_suspend: {=bool:?}, bb_stop: {=bool:?} }}",
self.bb_suspend(),
self.bb_stop()
)
}
}
#[doc = "TXD register."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Txd(pub u32);
impl Txd {
#[doc = "TXD register."]
#[must_use]
#[inline(always)]
pub const fn txd(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "TXD register."]
#[inline(always)]
pub const fn set_txd(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
}
impl Default for Txd {
#[inline(always)]
fn default() -> Txd {
Txd(0)
}
}
impl core::fmt::Debug for Txd {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Txd").field("txd", &self.txd()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Txd {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Txd {{ txd: {=u8:?} }}", self.txd())
}
}
}
pub mod vals {
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Enable {
#[doc = "Disable TWI."]
Disabled = 0x0,
_RESERVED_1 = 0x01,
_RESERVED_2 = 0x02,
_RESERVED_3 = 0x03,
_RESERVED_4 = 0x04,
#[doc = "Enable TWI."]
Enabled = 0x05,
_RESERVED_6 = 0x06,
_RESERVED_7 = 0x07,
_RESERVED_8 = 0x08,
_RESERVED_9 = 0x09,
_RESERVED_a = 0x0a,
_RESERVED_b = 0x0b,
_RESERVED_c = 0x0c,
_RESERVED_d = 0x0d,
_RESERVED_e = 0x0e,
_RESERVED_f = 0x0f,
}
impl Enable {
#[inline(always)]
pub const fn from_bits(val: u8) -> Enable {
unsafe { core::mem::transmute(val & 0x0f) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Enable {
#[inline(always)]
fn from(val: u8) -> Enable {
Enable::from_bits(val)
}
}
impl From<Enable> for u8 {
#[inline(always)]
fn from(val: Enable) -> u8 {
Enable::to_bits(val)
}
}
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct Frequency(u32);
impl Frequency {
#[doc = "100 kbps."]
pub const K100: Self = Self(0x0198_0000);
#[doc = "250 kbps."]
pub const K250: Self = Self(0x0400_0000);
#[doc = "400 kbps (actual rate 410.256 kbps)."]
pub const K400: Self = Self(0x0668_0000);
}
impl Frequency {
pub const fn from_bits(val: u32) -> Frequency {
Self(val & 0xffff_ffff)
}
pub const fn to_bits(self) -> u32 {
self.0
}
}
impl core::fmt::Debug for Frequency {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self.0 {
0x0198_0000 => f.write_str("K100"),
0x0400_0000 => f.write_str("K250"),
0x0668_0000 => f.write_str("K400"),
other => core::write!(f, "0x{:02X}", other),
}
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Frequency {
fn format(&self, f: defmt::Formatter) {
match self.0 {
0x0198_0000 => defmt::write!(f, "K100"),
0x0400_0000 => defmt::write!(f, "K250"),
0x0668_0000 => defmt::write!(f, "K400"),
other => defmt::write!(f, "0x{:02X}", other),
}
}
}
impl From<u32> for Frequency {
#[inline(always)]
fn from(val: u32) -> Frequency {
Frequency::from_bits(val)
}
}
impl From<Frequency> for u32 {
#[inline(always)]
fn from(val: Frequency) -> u32 {
Frequency::to_bits(val)
}
}
}
}
pub mod twim {
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Dma {
ptr: *mut u8,
}
unsafe impl Send for Dma {}
unsafe impl Sync for Dma {}
impl Dma {
#[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 = "RXD EasyDMA channel."]
#[inline(always)]
pub const fn rx(self) -> DmaRx {
unsafe { DmaRx::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "TXD EasyDMA channel."]
#[inline(always)]
pub const fn tx(self) -> DmaTx {
unsafe { DmaTx::from_ptr(self.ptr.wrapping_add(0x10usize) as _) }
}
}
#[doc = "RXD EasyDMA channel."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct DmaRx {
ptr: *mut u8,
}
unsafe impl Send for DmaRx {}
unsafe impl Sync for DmaRx {}
impl DmaRx {
#[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 = "Data pointer."]
#[inline(always)]
pub const fn ptr(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Maximum number of bytes in receive buffer."]
#[inline(always)]
pub const fn maxcnt(self) -> crate::common::Reg<regs::RxdMaxcnt, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Number of bytes transferred in the last transaction."]
#[inline(always)]
pub const fn amount(self) -> crate::common::Reg<regs::RxdAmount, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
#[doc = "EasyDMA list type."]
#[inline(always)]
pub const fn list(self) -> crate::common::Reg<regs::RxdList, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0cusize) as _) }
}
}
#[doc = "TXD EasyDMA channel."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct DmaTx {
ptr: *mut u8,
}
unsafe impl Send for DmaTx {}
unsafe impl Sync for DmaTx {}
impl DmaTx {
#[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 = "Data pointer."]
#[inline(always)]
pub const fn ptr(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Maximum number of bytes in transmit buffer."]
#[inline(always)]
pub const fn maxcnt(self) -> crate::common::Reg<regs::TxdMaxcnt, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Number of bytes transferred in the last transaction."]
#[inline(always)]
pub const fn amount(self) -> crate::common::Reg<regs::TxdAmount, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
#[doc = "EasyDMA list type."]
#[inline(always)]
pub const fn list(self) -> crate::common::Reg<regs::TxdList, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0cusize) as _) }
}
}
#[doc = "Unspecified."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Psel {
ptr: *mut u8,
}
unsafe impl Send for Psel {}
unsafe impl Sync for Psel {}
impl Psel {
#[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 = "Pin select for SCL signal."]
#[inline(always)]
pub const fn scl(self) -> crate::common::Reg<super::shared::regs::Psel, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Pin select for SDA signal."]
#[inline(always)]
pub const fn sda(self) -> crate::common::Reg<super::shared::regs::Psel, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
}
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct TasksDma {
ptr: *mut u8,
}
unsafe impl Send for TasksDma {}
unsafe impl Sync for TasksDma {}
impl TasksDma {
#[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 _
}
#[inline(always)]
pub const fn rx(self) -> TasksDmaRx {
unsafe { TasksDmaRx::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[inline(always)]
pub const fn tx(self) -> TasksDmaTx {
unsafe { TasksDmaTx::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
}
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct TasksDmaRx {
ptr: *mut u8,
}
unsafe impl Send for TasksDmaRx {}
unsafe impl Sync for TasksDmaRx {}
impl TasksDmaRx {
#[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 = "Start TWI receive sequence."]
#[inline(always)]
pub const fn start(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
}
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct TasksDmaTx {
ptr: *mut u8,
}
unsafe impl Send for TasksDmaTx {}
unsafe impl Sync for TasksDmaTx {}
impl TasksDmaTx {
#[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 = "Start TWI transmit sequence."]
#[inline(always)]
pub const fn start(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
}
#[doc = "I2C compatible Two-Wire Master Interface with EasyDMA 0."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Twim {
ptr: *mut u8,
}
unsafe impl Send for Twim {}
unsafe impl Sync for Twim {}
impl Twim {
#[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 _
}
#[inline(always)]
pub const fn tasks_dma(self) -> TasksDma {
unsafe { TasksDma::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Stop TWI transaction. Must be issued while the TWI master is not suspended."]
#[inline(always)]
pub const fn tasks_stop(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x14usize) as _) }
}
#[doc = "Suspend TWI transaction."]
#[inline(always)]
pub const fn tasks_suspend(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x1cusize) as _) }
}
#[doc = "Resume TWI transaction."]
#[inline(always)]
pub const fn tasks_resume(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x20usize) as _) }
}
#[doc = "TWI stopped."]
#[inline(always)]
pub const fn events_stopped(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0104usize) as _) }
}
#[doc = "TWI error."]
#[inline(always)]
pub const fn events_error(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0124usize) as _) }
}
#[doc = "SUSPEND task has been issued, TWI traffic is now suspended."]
#[inline(always)]
pub const fn events_suspended(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0148usize) as _) }
}
#[doc = "Receive sequence started."]
#[inline(always)]
pub const fn events_rxstarted(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x014cusize) as _) }
}
#[doc = "Transmit sequence started."]
#[inline(always)]
pub const fn events_txstarted(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0150usize) as _) }
}
#[doc = "Byte boundary, starting to receive the last byte."]
#[inline(always)]
pub const fn events_lastrx(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x015cusize) as _) }
}
#[doc = "Byte boundary, starting to transmit the last byte."]
#[inline(always)]
pub const fn events_lasttx(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0160usize) as _) }
}
#[doc = "Shortcuts between local events and tasks."]
#[inline(always)]
pub const fn shorts(self) -> crate::common::Reg<regs::Shorts, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0200usize) as _) }
}
#[doc = "Enable or disable interrupt."]
#[inline(always)]
pub const fn inten(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0300usize) as _) }
}
#[doc = "Enable interrupt."]
#[inline(always)]
pub const fn intenset(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0304usize) as _) }
}
#[doc = "Disable interrupt."]
#[inline(always)]
pub const fn intenclr(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0308usize) as _) }
}
#[doc = "Error source."]
#[inline(always)]
pub const fn errorsrc(self) -> crate::common::Reg<regs::Errorsrc, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04c4usize) as _) }
}
#[doc = "Enable TWIM."]
#[inline(always)]
pub const fn enable(self) -> crate::common::Reg<regs::Enable, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0500usize) as _) }
}
#[doc = "Unspecified."]
#[inline(always)]
pub const fn psel(self) -> Psel {
unsafe { Psel::from_ptr(self.ptr.wrapping_add(0x0508usize) as _) }
}
#[doc = "TWI frequency. Accuracy depends on the HFCLK source selected."]
#[inline(always)]
pub const fn frequency(self) -> crate::common::Reg<regs::Frequency, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0524usize) as _) }
}
#[inline(always)]
pub const fn dma(self) -> Dma {
unsafe { Dma::from_ptr(self.ptr.wrapping_add(0x0534usize) as _) }
}
#[doc = "Address used in the TWI transfer."]
#[inline(always)]
pub const fn address(self) -> crate::common::Reg<regs::Address, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0588usize) as _) }
}
}
pub mod regs {
#[doc = "Address used in the TWI transfer."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Address(pub u32);
impl Address {
#[doc = "Address used in the TWI transfer."]
#[must_use]
#[inline(always)]
pub const fn address(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x7f;
val as u8
}
#[doc = "Address used in the TWI transfer."]
#[inline(always)]
pub const fn set_address(&mut self, val: u8) {
self.0 = (self.0 & !(0x7f << 0usize)) | (((val as u32) & 0x7f) << 0usize);
}
}
impl Default for Address {
#[inline(always)]
fn default() -> Address {
Address(0)
}
}
impl core::fmt::Debug for Address {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Address")
.field("address", &self.address())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Address {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Address {{ address: {=u8:?} }}", self.address())
}
}
#[doc = "Enable TWIM."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Enable(pub u32);
impl Enable {
#[doc = "Enable or disable TWIM."]
#[must_use]
#[inline(always)]
pub const fn enable(&self) -> super::vals::Enable {
let val = (self.0 >> 0usize) & 0x0f;
super::vals::Enable::from_bits(val as u8)
}
#[doc = "Enable or disable TWIM."]
#[inline(always)]
pub const fn set_enable(&mut self, val: super::vals::Enable) {
self.0 = (self.0 & !(0x0f << 0usize)) | (((val.to_bits() as u32) & 0x0f) << 0usize);
}
}
impl Default for Enable {
#[inline(always)]
fn default() -> Enable {
Enable(0)
}
}
impl core::fmt::Debug for Enable {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Enable")
.field("enable", &self.enable())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Enable {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Enable {{ enable: {:?} }}", self.enable())
}
}
#[doc = "Error source."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Errorsrc(pub u32);
impl Errorsrc {
#[doc = "Overrun error."]
#[must_use]
#[inline(always)]
pub const fn overrun(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Overrun error."]
#[inline(always)]
pub const fn set_overrun(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "NACK received after sending the address (write '1' to clear)."]
#[must_use]
#[inline(always)]
pub const fn anack(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "NACK received after sending the address (write '1' to clear)."]
#[inline(always)]
pub const fn set_anack(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "NACK received after sending a data byte (write '1' to clear)."]
#[must_use]
#[inline(always)]
pub const fn dnack(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "NACK received after sending a data byte (write '1' to clear)."]
#[inline(always)]
pub const fn set_dnack(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
}
impl Default for Errorsrc {
#[inline(always)]
fn default() -> Errorsrc {
Errorsrc(0)
}
}
impl core::fmt::Debug for Errorsrc {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Errorsrc")
.field("overrun", &self.overrun())
.field("anack", &self.anack())
.field("dnack", &self.dnack())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Errorsrc {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Errorsrc {{ overrun: {=bool:?}, anack: {=bool:?}, dnack: {=bool:?} }}",
self.overrun(),
self.anack(),
self.dnack()
)
}
}
#[doc = "TWI frequency. Accuracy depends on the HFCLK source selected."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Frequency(pub u32);
impl Frequency {
#[doc = "TWI master clock frequency."]
#[must_use]
#[inline(always)]
pub const fn frequency(&self) -> super::vals::Frequency {
let val = (self.0 >> 0usize) & 0xffff_ffff;
super::vals::Frequency::from_bits(val as u32)
}
#[doc = "TWI master clock frequency."]
#[inline(always)]
pub const fn set_frequency(&mut self, val: super::vals::Frequency) {
self.0 = (self.0 & !(0xffff_ffff << 0usize))
| (((val.to_bits() as u32) & 0xffff_ffff) << 0usize);
}
}
impl Default for Frequency {
#[inline(always)]
fn default() -> Frequency {
Frequency(0)
}
}
impl core::fmt::Debug for Frequency {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Frequency")
.field("frequency", &self.frequency())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Frequency {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Frequency {{ frequency: {:?} }}", self.frequency())
}
}
#[doc = "Enable or disable interrupt."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Int(pub u32);
impl Int {
#[doc = "Enable or disable interrupt for event STOPPED."]
#[must_use]
#[inline(always)]
pub const fn stopped(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event STOPPED."]
#[inline(always)]
pub const fn set_stopped(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "Enable or disable interrupt for event ERROR."]
#[must_use]
#[inline(always)]
pub const fn error(&self) -> bool {
let val = (self.0 >> 9usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event ERROR."]
#[inline(always)]
pub const fn set_error(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 9usize)) | (((val as u32) & 0x01) << 9usize);
}
#[doc = "Enable or disable interrupt for event SUSPENDED."]
#[must_use]
#[inline(always)]
pub const fn suspended(&self) -> bool {
let val = (self.0 >> 18usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event SUSPENDED."]
#[inline(always)]
pub const fn set_suspended(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 18usize)) | (((val as u32) & 0x01) << 18usize);
}
#[doc = "Enable or disable interrupt for event RXSTARTED."]
#[must_use]
#[inline(always)]
pub const fn rxstarted(&self) -> bool {
let val = (self.0 >> 19usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event RXSTARTED."]
#[inline(always)]
pub const fn set_rxstarted(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 19usize)) | (((val as u32) & 0x01) << 19usize);
}
#[doc = "Enable or disable interrupt for event TXSTARTED."]
#[must_use]
#[inline(always)]
pub const fn txstarted(&self) -> bool {
let val = (self.0 >> 20usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event TXSTARTED."]
#[inline(always)]
pub const fn set_txstarted(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 20usize)) | (((val as u32) & 0x01) << 20usize);
}
#[doc = "Enable or disable interrupt for event LASTRX."]
#[must_use]
#[inline(always)]
pub const fn lastrx(&self) -> bool {
let val = (self.0 >> 23usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event LASTRX."]
#[inline(always)]
pub const fn set_lastrx(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 23usize)) | (((val as u32) & 0x01) << 23usize);
}
#[doc = "Enable or disable interrupt for event LASTTX."]
#[must_use]
#[inline(always)]
pub const fn lasttx(&self) -> bool {
let val = (self.0 >> 24usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event LASTTX."]
#[inline(always)]
pub const fn set_lasttx(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 24usize)) | (((val as u32) & 0x01) << 24usize);
}
}
impl Default for Int {
#[inline(always)]
fn default() -> Int {
Int(0)
}
}
impl core::fmt::Debug for Int {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Int")
.field("stopped", &self.stopped())
.field("error", &self.error())
.field("suspended", &self.suspended())
.field("rxstarted", &self.rxstarted())
.field("txstarted", &self.txstarted())
.field("lastrx", &self.lastrx())
.field("lasttx", &self.lasttx())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Int {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Int {{ stopped: {=bool:?}, error: {=bool:?}, suspended: {=bool:?}, rxstarted: {=bool:?}, txstarted: {=bool:?}, lastrx: {=bool:?}, lasttx: {=bool:?} }}" , self . stopped () , self . error () , self . suspended () , self . rxstarted () , self . txstarted () , self . lastrx () , self . lasttx ())
}
}
#[doc = "Number of bytes transferred in the last transaction."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct RxdAmount(pub u32);
impl RxdAmount {
#[doc = "Number of bytes transferred in the last transaction. In case of NACK error, includes the NACK'ed byte."]
#[must_use]
#[inline(always)]
pub const fn amount(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x7fff;
val as u16
}
#[doc = "Number of bytes transferred in the last transaction. In case of NACK error, includes the NACK'ed byte."]
#[inline(always)]
pub const fn set_amount(&mut self, val: u16) {
self.0 = (self.0 & !(0x7fff << 0usize)) | (((val as u32) & 0x7fff) << 0usize);
}
}
impl Default for RxdAmount {
#[inline(always)]
fn default() -> RxdAmount {
RxdAmount(0)
}
}
impl core::fmt::Debug for RxdAmount {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("RxdAmount")
.field("amount", &self.amount())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for RxdAmount {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "RxdAmount {{ amount: {=u16:?} }}", self.amount())
}
}
#[doc = "EasyDMA list type."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct RxdList(pub u32);
impl RxdList {
#[doc = "List type."]
#[must_use]
#[inline(always)]
pub const fn list(&self) -> super::vals::RxdListList {
let val = (self.0 >> 0usize) & 0x07;
super::vals::RxdListList::from_bits(val as u8)
}
#[doc = "List type."]
#[inline(always)]
pub const fn set_list(&mut self, val: super::vals::RxdListList) {
self.0 = (self.0 & !(0x07 << 0usize)) | (((val.to_bits() as u32) & 0x07) << 0usize);
}
}
impl Default for RxdList {
#[inline(always)]
fn default() -> RxdList {
RxdList(0)
}
}
impl core::fmt::Debug for RxdList {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("RxdList")
.field("list", &self.list())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for RxdList {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "RxdList {{ list: {:?} }}", self.list())
}
}
#[doc = "Maximum number of bytes in receive buffer."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct RxdMaxcnt(pub u32);
impl RxdMaxcnt {
#[doc = "Maximum number of bytes in receive buffer."]
#[must_use]
#[inline(always)]
pub const fn maxcnt(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x7fff;
val as u16
}
#[doc = "Maximum number of bytes in receive buffer."]
#[inline(always)]
pub const fn set_maxcnt(&mut self, val: u16) {
self.0 = (self.0 & !(0x7fff << 0usize)) | (((val as u32) & 0x7fff) << 0usize);
}
}
impl Default for RxdMaxcnt {
#[inline(always)]
fn default() -> RxdMaxcnt {
RxdMaxcnt(0)
}
}
impl core::fmt::Debug for RxdMaxcnt {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("RxdMaxcnt")
.field("maxcnt", &self.maxcnt())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for RxdMaxcnt {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "RxdMaxcnt {{ maxcnt: {=u16:?} }}", self.maxcnt())
}
}
#[doc = "Shortcuts between local events and tasks."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Shorts(pub u32);
impl Shorts {
#[doc = "Shortcut between event LASTTX and task STARTRX."]
#[must_use]
#[inline(always)]
pub const fn lasttx_dma_rx_start(&self) -> bool {
let val = (self.0 >> 7usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event LASTTX and task STARTRX."]
#[inline(always)]
pub const fn set_lasttx_dma_rx_start(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize);
}
#[doc = "Shortcut between event LASTTX and task SUSPEND."]
#[must_use]
#[inline(always)]
pub const fn lasttx_suspend(&self) -> bool {
let val = (self.0 >> 8usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event LASTTX and task SUSPEND."]
#[inline(always)]
pub const fn set_lasttx_suspend(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize);
}
#[doc = "Shortcut between event LASTTX and task STOP."]
#[must_use]
#[inline(always)]
pub const fn lasttx_stop(&self) -> bool {
let val = (self.0 >> 9usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event LASTTX and task STOP."]
#[inline(always)]
pub const fn set_lasttx_stop(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 9usize)) | (((val as u32) & 0x01) << 9usize);
}
#[doc = "Shortcut between event LASTRX and task STARTTX."]
#[must_use]
#[inline(always)]
pub const fn lastrx_dma_tx_start(&self) -> bool {
let val = (self.0 >> 10usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event LASTRX and task STARTTX."]
#[inline(always)]
pub const fn set_lastrx_dma_tx_start(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 10usize)) | (((val as u32) & 0x01) << 10usize);
}
#[doc = "Shortcut between event LASTRX and task SUSPEND."]
#[must_use]
#[inline(always)]
pub const fn lastrx_suspend(&self) -> bool {
let val = (self.0 >> 11usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event LASTRX and task SUSPEND."]
#[inline(always)]
pub const fn set_lastrx_suspend(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 11usize)) | (((val as u32) & 0x01) << 11usize);
}
#[doc = "Shortcut between event LASTRX and task STOP."]
#[must_use]
#[inline(always)]
pub const fn lastrx_stop(&self) -> bool {
let val = (self.0 >> 12usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event LASTRX and task STOP."]
#[inline(always)]
pub const fn set_lastrx_stop(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 12usize)) | (((val as u32) & 0x01) << 12usize);
}
}
impl Default for Shorts {
#[inline(always)]
fn default() -> Shorts {
Shorts(0)
}
}
impl core::fmt::Debug for Shorts {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Shorts")
.field("lasttx_dma_rx_start", &self.lasttx_dma_rx_start())
.field("lasttx_suspend", &self.lasttx_suspend())
.field("lasttx_stop", &self.lasttx_stop())
.field("lastrx_dma_tx_start", &self.lastrx_dma_tx_start())
.field("lastrx_suspend", &self.lastrx_suspend())
.field("lastrx_stop", &self.lastrx_stop())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Shorts {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Shorts {{ lasttx_dma_rx_start: {=bool:?}, lasttx_suspend: {=bool:?}, lasttx_stop: {=bool:?}, lastrx_dma_tx_start: {=bool:?}, lastrx_suspend: {=bool:?}, lastrx_stop: {=bool:?} }}" , self . lasttx_dma_rx_start () , self . lasttx_suspend () , self . lasttx_stop () , self . lastrx_dma_tx_start () , self . lastrx_suspend () , self . lastrx_stop ())
}
}
#[doc = "Number of bytes transferred in the last transaction."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct TxdAmount(pub u32);
impl TxdAmount {
#[doc = "Number of bytes transferred in the last transaction. In case of NACK error, includes the NACK'ed byte."]
#[must_use]
#[inline(always)]
pub const fn amount(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x7fff;
val as u16
}
#[doc = "Number of bytes transferred in the last transaction. In case of NACK error, includes the NACK'ed byte."]
#[inline(always)]
pub const fn set_amount(&mut self, val: u16) {
self.0 = (self.0 & !(0x7fff << 0usize)) | (((val as u32) & 0x7fff) << 0usize);
}
}
impl Default for TxdAmount {
#[inline(always)]
fn default() -> TxdAmount {
TxdAmount(0)
}
}
impl core::fmt::Debug for TxdAmount {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("TxdAmount")
.field("amount", &self.amount())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for TxdAmount {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "TxdAmount {{ amount: {=u16:?} }}", self.amount())
}
}
#[doc = "EasyDMA list type."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct TxdList(pub u32);
impl TxdList {
#[doc = "List type."]
#[must_use]
#[inline(always)]
pub const fn list(&self) -> super::vals::TxdListList {
let val = (self.0 >> 0usize) & 0x07;
super::vals::TxdListList::from_bits(val as u8)
}
#[doc = "List type."]
#[inline(always)]
pub const fn set_list(&mut self, val: super::vals::TxdListList) {
self.0 = (self.0 & !(0x07 << 0usize)) | (((val.to_bits() as u32) & 0x07) << 0usize);
}
}
impl Default for TxdList {
#[inline(always)]
fn default() -> TxdList {
TxdList(0)
}
}
impl core::fmt::Debug for TxdList {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("TxdList")
.field("list", &self.list())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for TxdList {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "TxdList {{ list: {:?} }}", self.list())
}
}
#[doc = "Maximum number of bytes in transmit buffer."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct TxdMaxcnt(pub u32);
impl TxdMaxcnt {
#[doc = "Maximum number of bytes in transmit buffer."]
#[must_use]
#[inline(always)]
pub const fn maxcnt(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x7fff;
val as u16
}
#[doc = "Maximum number of bytes in transmit buffer."]
#[inline(always)]
pub const fn set_maxcnt(&mut self, val: u16) {
self.0 = (self.0 & !(0x7fff << 0usize)) | (((val as u32) & 0x7fff) << 0usize);
}
}
impl Default for TxdMaxcnt {
#[inline(always)]
fn default() -> TxdMaxcnt {
TxdMaxcnt(0)
}
}
impl core::fmt::Debug for TxdMaxcnt {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("TxdMaxcnt")
.field("maxcnt", &self.maxcnt())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for TxdMaxcnt {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "TxdMaxcnt {{ maxcnt: {=u16:?} }}", self.maxcnt())
}
}
}
pub mod vals {
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Enable {
#[doc = "Disable TWIM."]
Disabled = 0x0,
_RESERVED_1 = 0x01,
_RESERVED_2 = 0x02,
_RESERVED_3 = 0x03,
_RESERVED_4 = 0x04,
_RESERVED_5 = 0x05,
#[doc = "Enable TWIM."]
Enabled = 0x06,
_RESERVED_7 = 0x07,
_RESERVED_8 = 0x08,
_RESERVED_9 = 0x09,
_RESERVED_a = 0x0a,
_RESERVED_b = 0x0b,
_RESERVED_c = 0x0c,
_RESERVED_d = 0x0d,
_RESERVED_e = 0x0e,
_RESERVED_f = 0x0f,
}
impl Enable {
#[inline(always)]
pub const fn from_bits(val: u8) -> Enable {
unsafe { core::mem::transmute(val & 0x0f) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Enable {
#[inline(always)]
fn from(val: u8) -> Enable {
Enable::from_bits(val)
}
}
impl From<Enable> for u8 {
#[inline(always)]
fn from(val: Enable) -> u8 {
Enable::to_bits(val)
}
}
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct Frequency(u32);
impl Frequency {
#[doc = "100 kbps."]
pub const K100: Self = Self(0x0198_0000);
#[doc = "250 kbps."]
pub const K250: Self = Self(0x0400_0000);
#[doc = "400 kbps."]
pub const K400: Self = Self(0x0640_0000);
}
impl Frequency {
pub const fn from_bits(val: u32) -> Frequency {
Self(val & 0xffff_ffff)
}
pub const fn to_bits(self) -> u32 {
self.0
}
}
impl core::fmt::Debug for Frequency {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self.0 {
0x0198_0000 => f.write_str("K100"),
0x0400_0000 => f.write_str("K250"),
0x0640_0000 => f.write_str("K400"),
other => core::write!(f, "0x{:02X}", other),
}
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Frequency {
fn format(&self, f: defmt::Formatter) {
match self.0 {
0x0198_0000 => defmt::write!(f, "K100"),
0x0400_0000 => defmt::write!(f, "K250"),
0x0640_0000 => defmt::write!(f, "K400"),
other => defmt::write!(f, "0x{:02X}", other),
}
}
}
impl From<u32> for Frequency {
#[inline(always)]
fn from(val: u32) -> Frequency {
Frequency::from_bits(val)
}
}
impl From<Frequency> for u32 {
#[inline(always)]
fn from(val: Frequency) -> u32 {
Frequency::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum RxdListList {
#[doc = "Disable EasyDMA list."]
Disabled = 0x0,
#[doc = "Use array list."]
ArrayList = 0x01,
_RESERVED_2 = 0x02,
_RESERVED_3 = 0x03,
_RESERVED_4 = 0x04,
_RESERVED_5 = 0x05,
_RESERVED_6 = 0x06,
_RESERVED_7 = 0x07,
}
impl RxdListList {
#[inline(always)]
pub const fn from_bits(val: u8) -> RxdListList {
unsafe { core::mem::transmute(val & 0x07) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for RxdListList {
#[inline(always)]
fn from(val: u8) -> RxdListList {
RxdListList::from_bits(val)
}
}
impl From<RxdListList> for u8 {
#[inline(always)]
fn from(val: RxdListList) -> u8 {
RxdListList::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum TxdListList {
#[doc = "Disable EasyDMA list."]
Disabled = 0x0,
#[doc = "Use array list."]
ArrayList = 0x01,
_RESERVED_2 = 0x02,
_RESERVED_3 = 0x03,
_RESERVED_4 = 0x04,
_RESERVED_5 = 0x05,
_RESERVED_6 = 0x06,
_RESERVED_7 = 0x07,
}
impl TxdListList {
#[inline(always)]
pub const fn from_bits(val: u8) -> TxdListList {
unsafe { core::mem::transmute(val & 0x07) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for TxdListList {
#[inline(always)]
fn from(val: u8) -> TxdListList {
TxdListList::from_bits(val)
}
}
impl From<TxdListList> for u8 {
#[inline(always)]
fn from(val: TxdListList) -> u8 {
TxdListList::to_bits(val)
}
}
}
}
pub mod twis {
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Dma {
ptr: *mut u8,
}
unsafe impl Send for Dma {}
unsafe impl Sync for Dma {}
impl Dma {
#[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 = "RXD EasyDMA channel."]
#[inline(always)]
pub const fn rx(self) -> DmaRx {
unsafe { DmaRx::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "TXD EasyDMA channel."]
#[inline(always)]
pub const fn tx(self) -> DmaTx {
unsafe { DmaTx::from_ptr(self.ptr.wrapping_add(0x10usize) as _) }
}
}
#[doc = "RXD EasyDMA channel."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct DmaRx {
ptr: *mut u8,
}
unsafe impl Send for DmaRx {}
unsafe impl Sync for DmaRx {}
impl DmaRx {
#[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 = "RXD Data pointer."]
#[inline(always)]
pub const fn ptr(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Maximum number of bytes in RXD buffer."]
#[inline(always)]
pub const fn maxcnt(self) -> crate::common::Reg<regs::RxdMaxcnt, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Number of bytes transferred in the last RXD transaction."]
#[inline(always)]
pub const fn amount(self) -> crate::common::Reg<regs::RxdAmount, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
#[doc = "EasyDMA list type."]
#[inline(always)]
pub const fn list(self) -> crate::common::Reg<regs::RxdList, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0cusize) as _) }
}
}
#[doc = "TXD EasyDMA channel."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct DmaTx {
ptr: *mut u8,
}
unsafe impl Send for DmaTx {}
unsafe impl Sync for DmaTx {}
impl DmaTx {
#[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 = "TXD Data pointer."]
#[inline(always)]
pub const fn ptr(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Maximum number of bytes in TXD buffer."]
#[inline(always)]
pub const fn maxcnt(self) -> crate::common::Reg<regs::TxdMaxcnt, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Number of bytes transferred in the last TXD transaction."]
#[inline(always)]
pub const fn amount(self) -> crate::common::Reg<regs::TxdAmount, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
#[doc = "EasyDMA list type."]
#[inline(always)]
pub const fn list(self) -> crate::common::Reg<regs::TxdList, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0cusize) as _) }
}
}
#[doc = "Unspecified."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Psel {
ptr: *mut u8,
}
unsafe impl Send for Psel {}
unsafe impl Sync for Psel {}
impl Psel {
#[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 = "Pin select for SCL signal."]
#[inline(always)]
pub const fn scl(self) -> crate::common::Reg<super::shared::regs::Psel, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Pin select for SDA signal."]
#[inline(always)]
pub const fn sda(self) -> crate::common::Reg<super::shared::regs::Psel, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
}
#[doc = "I2C compatible Two-Wire Slave Interface with EasyDMA 0."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Twis {
ptr: *mut u8,
}
unsafe impl Send for Twis {}
unsafe impl Sync for Twis {}
impl Twis {
#[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 = "Stop TWI transaction."]
#[inline(always)]
pub const fn tasks_stop(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x14usize) as _) }
}
#[doc = "Suspend TWI transaction."]
#[inline(always)]
pub const fn tasks_suspend(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x1cusize) as _) }
}
#[doc = "Resume TWI transaction."]
#[inline(always)]
pub const fn tasks_resume(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x20usize) as _) }
}
#[doc = "Prepare the TWI slave to respond to a write command."]
#[inline(always)]
pub const fn tasks_preparerx(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x30usize) as _) }
}
#[doc = "Prepare the TWI slave to respond to a read command."]
#[inline(always)]
pub const fn tasks_preparetx(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x34usize) as _) }
}
#[doc = "TWI stopped."]
#[inline(always)]
pub const fn events_stopped(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0104usize) as _) }
}
#[doc = "TWI error."]
#[inline(always)]
pub const fn events_error(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0124usize) as _) }
}
#[doc = "Receive sequence started."]
#[inline(always)]
pub const fn events_rxstarted(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x014cusize) as _) }
}
#[doc = "Transmit sequence started."]
#[inline(always)]
pub const fn events_txstarted(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0150usize) as _) }
}
#[doc = "Write command received."]
#[inline(always)]
pub const fn events_write(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0164usize) as _) }
}
#[doc = "Read command received."]
#[inline(always)]
pub const fn events_read(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0168usize) as _) }
}
#[doc = "Shortcuts between local events and tasks."]
#[inline(always)]
pub const fn shorts(self) -> crate::common::Reg<regs::Shorts, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0200usize) as _) }
}
#[doc = "Enable or disable interrupt."]
#[inline(always)]
pub const fn inten(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0300usize) as _) }
}
#[doc = "Enable interrupt."]
#[inline(always)]
pub const fn intenset(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0304usize) as _) }
}
#[doc = "Disable interrupt."]
#[inline(always)]
pub const fn intenclr(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0308usize) as _) }
}
#[doc = "Error source."]
#[inline(always)]
pub const fn errorsrc(self) -> crate::common::Reg<regs::Errorsrc, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04d0usize) as _) }
}
#[doc = "Status register indicating which address had a match."]
#[inline(always)]
pub const fn match_(self) -> crate::common::Reg<regs::Match, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04d4usize) as _) }
}
#[doc = "Enable TWIS."]
#[inline(always)]
pub const fn enable(self) -> crate::common::Reg<regs::Enable, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0500usize) as _) }
}
#[doc = "Unspecified."]
#[inline(always)]
pub const fn psel(self) -> Psel {
unsafe { Psel::from_ptr(self.ptr.wrapping_add(0x0508usize) as _) }
}
#[inline(always)]
pub const fn dma(self) -> Dma {
unsafe { Dma::from_ptr(self.ptr.wrapping_add(0x0534usize) as _) }
}
#[doc = "Description collection: TWI slave address n."]
#[inline(always)]
pub const fn address(
self,
n: usize,
) -> crate::common::Reg<regs::Address, crate::common::RW> {
assert!(n < 2usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0588usize + n * 4usize) as _)
}
}
#[doc = "Configuration register for the address match mechanism."]
#[inline(always)]
pub const fn config(self) -> crate::common::Reg<regs::Config, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0594usize) as _) }
}
#[doc = "Over-read character. Character sent out in case of an over-read of the transmit buffer."]
#[inline(always)]
pub const fn orc(self) -> crate::common::Reg<regs::Orc, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x05c0usize) as _) }
}
}
pub mod regs {
#[doc = "Description collection: TWI slave address n."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Address(pub u32);
impl Address {
#[doc = "TWI slave address."]
#[must_use]
#[inline(always)]
pub const fn address(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x7f;
val as u8
}
#[doc = "TWI slave address."]
#[inline(always)]
pub const fn set_address(&mut self, val: u8) {
self.0 = (self.0 & !(0x7f << 0usize)) | (((val as u32) & 0x7f) << 0usize);
}
}
impl Default for Address {
#[inline(always)]
fn default() -> Address {
Address(0)
}
}
impl core::fmt::Debug for Address {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Address")
.field("address", &self.address())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Address {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Address {{ address: {=u8:?} }}", self.address())
}
}
#[doc = "Configuration register for the address match mechanism."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Config(pub u32);
impl Config {
#[doc = "Enable or disable address matching on ADDRESS\\[0\\]."]
#[must_use]
#[inline(always)]
pub const fn address0(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Enable or disable address matching on ADDRESS\\[0\\]."]
#[inline(always)]
pub const fn set_address0(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Enable or disable address matching on ADDRESS\\[1\\]."]
#[must_use]
#[inline(always)]
pub const fn address1(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Enable or disable address matching on ADDRESS\\[1\\]."]
#[inline(always)]
pub const fn set_address1(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
}
impl Default for Config {
#[inline(always)]
fn default() -> Config {
Config(0)
}
}
impl core::fmt::Debug for Config {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Config")
.field("address0", &self.address0())
.field("address1", &self.address1())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Config {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Config {{ address0: {=bool:?}, address1: {=bool:?} }}",
self.address0(),
self.address1()
)
}
}
#[doc = "Enable TWIS."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Enable(pub u32);
impl Enable {
#[doc = "Enable or disable TWIS."]
#[must_use]
#[inline(always)]
pub const fn enable(&self) -> super::vals::Enable {
let val = (self.0 >> 0usize) & 0x0f;
super::vals::Enable::from_bits(val as u8)
}
#[doc = "Enable or disable TWIS."]
#[inline(always)]
pub const fn set_enable(&mut self, val: super::vals::Enable) {
self.0 = (self.0 & !(0x0f << 0usize)) | (((val.to_bits() as u32) & 0x0f) << 0usize);
}
}
impl Default for Enable {
#[inline(always)]
fn default() -> Enable {
Enable(0)
}
}
impl core::fmt::Debug for Enable {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Enable")
.field("enable", &self.enable())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Enable {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Enable {{ enable: {:?} }}", self.enable())
}
}
#[doc = "Error source."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Errorsrc(pub u32);
impl Errorsrc {
#[doc = "RX buffer overflow detected, and prevented."]
#[must_use]
#[inline(always)]
pub const fn overflow(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "RX buffer overflow detected, and prevented."]
#[inline(always)]
pub const fn set_overflow(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "NACK sent after receiving a data byte."]
#[must_use]
#[inline(always)]
pub const fn dnack(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "NACK sent after receiving a data byte."]
#[inline(always)]
pub const fn set_dnack(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "TX buffer over-read detected, and prevented."]
#[must_use]
#[inline(always)]
pub const fn overread(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "TX buffer over-read detected, and prevented."]
#[inline(always)]
pub const fn set_overread(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
}
impl Default for Errorsrc {
#[inline(always)]
fn default() -> Errorsrc {
Errorsrc(0)
}
}
impl core::fmt::Debug for Errorsrc {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Errorsrc")
.field("overflow", &self.overflow())
.field("dnack", &self.dnack())
.field("overread", &self.overread())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Errorsrc {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Errorsrc {{ overflow: {=bool:?}, dnack: {=bool:?}, overread: {=bool:?} }}",
self.overflow(),
self.dnack(),
self.overread()
)
}
}
#[doc = "Enable or disable interrupt."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Int(pub u32);
impl Int {
#[doc = "Enable or disable interrupt for event STOPPED."]
#[must_use]
#[inline(always)]
pub const fn stopped(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event STOPPED."]
#[inline(always)]
pub const fn set_stopped(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "Enable or disable interrupt for event ERROR."]
#[must_use]
#[inline(always)]
pub const fn error(&self) -> bool {
let val = (self.0 >> 9usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event ERROR."]
#[inline(always)]
pub const fn set_error(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 9usize)) | (((val as u32) & 0x01) << 9usize);
}
#[doc = "Enable or disable interrupt for event RXSTARTED."]
#[must_use]
#[inline(always)]
pub const fn rxstarted(&self) -> bool {
let val = (self.0 >> 19usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event RXSTARTED."]
#[inline(always)]
pub const fn set_rxstarted(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 19usize)) | (((val as u32) & 0x01) << 19usize);
}
#[doc = "Enable or disable interrupt for event TXSTARTED."]
#[must_use]
#[inline(always)]
pub const fn txstarted(&self) -> bool {
let val = (self.0 >> 20usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event TXSTARTED."]
#[inline(always)]
pub const fn set_txstarted(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 20usize)) | (((val as u32) & 0x01) << 20usize);
}
#[doc = "Enable or disable interrupt for event WRITE."]
#[must_use]
#[inline(always)]
pub const fn write(&self) -> bool {
let val = (self.0 >> 25usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event WRITE."]
#[inline(always)]
pub const fn set_write(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 25usize)) | (((val as u32) & 0x01) << 25usize);
}
#[doc = "Enable or disable interrupt for event READ."]
#[must_use]
#[inline(always)]
pub const fn read(&self) -> bool {
let val = (self.0 >> 26usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event READ."]
#[inline(always)]
pub const fn set_read(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 26usize)) | (((val as u32) & 0x01) << 26usize);
}
}
impl Default for Int {
#[inline(always)]
fn default() -> Int {
Int(0)
}
}
impl core::fmt::Debug for Int {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Int")
.field("stopped", &self.stopped())
.field("error", &self.error())
.field("rxstarted", &self.rxstarted())
.field("txstarted", &self.txstarted())
.field("write", &self.write())
.field("read", &self.read())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Int {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Int {{ stopped: {=bool:?}, error: {=bool:?}, rxstarted: {=bool:?}, txstarted: {=bool:?}, write: {=bool:?}, read: {=bool:?} }}" , self . stopped () , self . error () , self . rxstarted () , self . txstarted () , self . write () , self . read ())
}
}
#[doc = "Status register indicating which address had a match."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Match(pub u32);
impl Match {
#[doc = "Indication of which address in {ADDRESS} that matched the incoming address."]
#[must_use]
#[inline(always)]
pub const fn match_(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Indication of which address in {ADDRESS} that matched the incoming address."]
#[inline(always)]
pub const fn set_match_(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for Match {
#[inline(always)]
fn default() -> Match {
Match(0)
}
}
impl core::fmt::Debug for Match {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Match")
.field("match_", &self.match_())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Match {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Match {{ match_: {=bool:?} }}", self.match_())
}
}
#[doc = "Over-read character. Character sent out in case of an over-read of the transmit buffer."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Orc(pub u32);
impl Orc {
#[doc = "Over-read character. Character sent out in case of an over-read of the transmit buffer."]
#[must_use]
#[inline(always)]
pub const fn orc(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "Over-read character. Character sent out in case of an over-read of the transmit buffer."]
#[inline(always)]
pub const fn set_orc(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
}
impl Default for Orc {
#[inline(always)]
fn default() -> Orc {
Orc(0)
}
}
impl core::fmt::Debug for Orc {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Orc").field("orc", &self.orc()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Orc {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Orc {{ orc: {=u8:?} }}", self.orc())
}
}
#[doc = "Number of bytes transferred in the last RXD transaction."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct RxdAmount(pub u32);
impl RxdAmount {
#[doc = "Number of bytes transferred in the last RXD transaction."]
#[must_use]
#[inline(always)]
pub const fn amount(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x7fff;
val as u16
}
#[doc = "Number of bytes transferred in the last RXD transaction."]
#[inline(always)]
pub const fn set_amount(&mut self, val: u16) {
self.0 = (self.0 & !(0x7fff << 0usize)) | (((val as u32) & 0x7fff) << 0usize);
}
}
impl Default for RxdAmount {
#[inline(always)]
fn default() -> RxdAmount {
RxdAmount(0)
}
}
impl core::fmt::Debug for RxdAmount {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("RxdAmount")
.field("amount", &self.amount())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for RxdAmount {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "RxdAmount {{ amount: {=u16:?} }}", self.amount())
}
}
#[doc = "EasyDMA list type."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct RxdList(pub u32);
impl RxdList {
#[doc = "List type."]
#[must_use]
#[inline(always)]
pub const fn list(&self) -> super::vals::RxdListList {
let val = (self.0 >> 0usize) & 0x03;
super::vals::RxdListList::from_bits(val as u8)
}
#[doc = "List type."]
#[inline(always)]
pub const fn set_list(&mut self, val: super::vals::RxdListList) {
self.0 = (self.0 & !(0x03 << 0usize)) | (((val.to_bits() as u32) & 0x03) << 0usize);
}
}
impl Default for RxdList {
#[inline(always)]
fn default() -> RxdList {
RxdList(0)
}
}
impl core::fmt::Debug for RxdList {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("RxdList")
.field("list", &self.list())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for RxdList {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "RxdList {{ list: {:?} }}", self.list())
}
}
#[doc = "Maximum number of bytes in RXD buffer."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct RxdMaxcnt(pub u32);
impl RxdMaxcnt {
#[doc = "Maximum number of bytes in RXD buffer."]
#[must_use]
#[inline(always)]
pub const fn maxcnt(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x7fff;
val as u16
}
#[doc = "Maximum number of bytes in RXD buffer."]
#[inline(always)]
pub const fn set_maxcnt(&mut self, val: u16) {
self.0 = (self.0 & !(0x7fff << 0usize)) | (((val as u32) & 0x7fff) << 0usize);
}
}
impl Default for RxdMaxcnt {
#[inline(always)]
fn default() -> RxdMaxcnt {
RxdMaxcnt(0)
}
}
impl core::fmt::Debug for RxdMaxcnt {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("RxdMaxcnt")
.field("maxcnt", &self.maxcnt())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for RxdMaxcnt {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "RxdMaxcnt {{ maxcnt: {=u16:?} }}", self.maxcnt())
}
}
#[doc = "Shortcuts between local events and tasks."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Shorts(pub u32);
impl Shorts {
#[doc = "Shortcut between event WRITE and task SUSPEND."]
#[must_use]
#[inline(always)]
pub const fn write_suspend(&self) -> bool {
let val = (self.0 >> 13usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event WRITE and task SUSPEND."]
#[inline(always)]
pub const fn set_write_suspend(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 13usize)) | (((val as u32) & 0x01) << 13usize);
}
#[doc = "Shortcut between event READ and task SUSPEND."]
#[must_use]
#[inline(always)]
pub const fn read_suspend(&self) -> bool {
let val = (self.0 >> 14usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event READ and task SUSPEND."]
#[inline(always)]
pub const fn set_read_suspend(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 14usize)) | (((val as u32) & 0x01) << 14usize);
}
}
impl Default for Shorts {
#[inline(always)]
fn default() -> Shorts {
Shorts(0)
}
}
impl core::fmt::Debug for Shorts {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Shorts")
.field("write_suspend", &self.write_suspend())
.field("read_suspend", &self.read_suspend())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Shorts {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Shorts {{ write_suspend: {=bool:?}, read_suspend: {=bool:?} }}",
self.write_suspend(),
self.read_suspend()
)
}
}
#[doc = "Number of bytes transferred in the last TXD transaction."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct TxdAmount(pub u32);
impl TxdAmount {
#[doc = "Number of bytes transferred in the last TXD transaction."]
#[must_use]
#[inline(always)]
pub const fn amount(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x7fff;
val as u16
}
#[doc = "Number of bytes transferred in the last TXD transaction."]
#[inline(always)]
pub const fn set_amount(&mut self, val: u16) {
self.0 = (self.0 & !(0x7fff << 0usize)) | (((val as u32) & 0x7fff) << 0usize);
}
}
impl Default for TxdAmount {
#[inline(always)]
fn default() -> TxdAmount {
TxdAmount(0)
}
}
impl core::fmt::Debug for TxdAmount {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("TxdAmount")
.field("amount", &self.amount())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for TxdAmount {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "TxdAmount {{ amount: {=u16:?} }}", self.amount())
}
}
#[doc = "EasyDMA list type."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct TxdList(pub u32);
impl TxdList {
#[doc = "List type."]
#[must_use]
#[inline(always)]
pub const fn list(&self) -> super::vals::TxdListList {
let val = (self.0 >> 0usize) & 0x03;
super::vals::TxdListList::from_bits(val as u8)
}
#[doc = "List type."]
#[inline(always)]
pub const fn set_list(&mut self, val: super::vals::TxdListList) {
self.0 = (self.0 & !(0x03 << 0usize)) | (((val.to_bits() as u32) & 0x03) << 0usize);
}
}
impl Default for TxdList {
#[inline(always)]
fn default() -> TxdList {
TxdList(0)
}
}
impl core::fmt::Debug for TxdList {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("TxdList")
.field("list", &self.list())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for TxdList {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "TxdList {{ list: {:?} }}", self.list())
}
}
#[doc = "Maximum number of bytes in TXD buffer."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct TxdMaxcnt(pub u32);
impl TxdMaxcnt {
#[doc = "Maximum number of bytes in TXD buffer."]
#[must_use]
#[inline(always)]
pub const fn maxcnt(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x7fff;
val as u16
}
#[doc = "Maximum number of bytes in TXD buffer."]
#[inline(always)]
pub const fn set_maxcnt(&mut self, val: u16) {
self.0 = (self.0 & !(0x7fff << 0usize)) | (((val as u32) & 0x7fff) << 0usize);
}
}
impl Default for TxdMaxcnt {
#[inline(always)]
fn default() -> TxdMaxcnt {
TxdMaxcnt(0)
}
}
impl core::fmt::Debug for TxdMaxcnt {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("TxdMaxcnt")
.field("maxcnt", &self.maxcnt())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for TxdMaxcnt {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "TxdMaxcnt {{ maxcnt: {=u16:?} }}", self.maxcnt())
}
}
}
pub mod vals {
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Enable {
#[doc = "Disable TWIS."]
Disabled = 0x0,
_RESERVED_1 = 0x01,
_RESERVED_2 = 0x02,
_RESERVED_3 = 0x03,
_RESERVED_4 = 0x04,
_RESERVED_5 = 0x05,
_RESERVED_6 = 0x06,
_RESERVED_7 = 0x07,
_RESERVED_8 = 0x08,
#[doc = "Enable TWIS."]
Enabled = 0x09,
_RESERVED_a = 0x0a,
_RESERVED_b = 0x0b,
_RESERVED_c = 0x0c,
_RESERVED_d = 0x0d,
_RESERVED_e = 0x0e,
_RESERVED_f = 0x0f,
}
impl Enable {
#[inline(always)]
pub const fn from_bits(val: u8) -> Enable {
unsafe { core::mem::transmute(val & 0x0f) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Enable {
#[inline(always)]
fn from(val: u8) -> Enable {
Enable::from_bits(val)
}
}
impl From<Enable> for u8 {
#[inline(always)]
fn from(val: Enable) -> u8 {
Enable::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum RxdListList {
#[doc = "Disable EasyDMA list."]
Disabled = 0x0,
#[doc = "Use array list."]
ArrayList = 0x01,
_RESERVED_2 = 0x02,
_RESERVED_3 = 0x03,
}
impl RxdListList {
#[inline(always)]
pub const fn from_bits(val: u8) -> RxdListList {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for RxdListList {
#[inline(always)]
fn from(val: u8) -> RxdListList {
RxdListList::from_bits(val)
}
}
impl From<RxdListList> for u8 {
#[inline(always)]
fn from(val: RxdListList) -> u8 {
RxdListList::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum TxdListList {
#[doc = "Disable EasyDMA list."]
Disabled = 0x0,
#[doc = "Use array list."]
ArrayList = 0x01,
_RESERVED_2 = 0x02,
_RESERVED_3 = 0x03,
}
impl TxdListList {
#[inline(always)]
pub const fn from_bits(val: u8) -> TxdListList {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for TxdListList {
#[inline(always)]
fn from(val: u8) -> TxdListList {
TxdListList::from_bits(val)
}
}
impl From<TxdListList> for u8 {
#[inline(always)]
fn from(val: TxdListList) -> u8 {
TxdListList::to_bits(val)
}
}
}
}
pub mod uart {
#[doc = "Unspecified."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Psel {
ptr: *mut u8,
}
unsafe impl Send for Psel {}
unsafe impl Sync for Psel {}
impl Psel {
#[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 = "Pin select for RTS."]
#[inline(always)]
pub const fn rts(self) -> crate::common::Reg<super::shared::regs::Psel, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Pin select for TXD."]
#[inline(always)]
pub const fn txd(self) -> crate::common::Reg<super::shared::regs::Psel, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Pin select for CTS."]
#[inline(always)]
pub const fn cts(self) -> crate::common::Reg<super::shared::regs::Psel, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
#[doc = "Pin select for RXD."]
#[inline(always)]
pub const fn rxd(self) -> crate::common::Reg<super::shared::regs::Psel, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0cusize) as _) }
}
}
#[doc = "Universal Asynchronous Receiver/Transmitter."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Uart {
ptr: *mut u8,
}
unsafe impl Send for Uart {}
unsafe impl Sync for Uart {}
impl Uart {
#[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 = "Start UART receiver."]
#[inline(always)]
pub const fn tasks_startrx(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Stop UART receiver."]
#[inline(always)]
pub const fn tasks_stoprx(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Start UART transmitter."]
#[inline(always)]
pub const fn tasks_starttx(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
#[doc = "Stop UART transmitter."]
#[inline(always)]
pub const fn tasks_stoptx(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0cusize) as _) }
}
#[doc = "Suspend UART."]
#[inline(always)]
pub const fn tasks_suspend(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x1cusize) as _) }
}
#[doc = "CTS is activated (set low). Clear To Send."]
#[inline(always)]
pub const fn events_cts(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0100usize) as _) }
}
#[doc = "CTS is deactivated (set high). Not Clear To Send."]
#[inline(always)]
pub const fn events_ncts(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0104usize) as _) }
}
#[doc = "Data received in RXD."]
#[inline(always)]
pub const fn events_rxdrdy(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0108usize) as _) }
}
#[doc = "Data sent from TXD."]
#[inline(always)]
pub const fn events_txdrdy(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x011cusize) as _) }
}
#[doc = "Error detected."]
#[inline(always)]
pub const fn events_error(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0124usize) as _) }
}
#[doc = "Receiver timeout."]
#[inline(always)]
pub const fn events_rxto(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0144usize) as _) }
}
#[doc = "Shortcuts between local events and tasks."]
#[inline(always)]
pub const fn shorts(self) -> crate::common::Reg<regs::Shorts, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0200usize) as _) }
}
#[doc = "Enable interrupt."]
#[inline(always)]
pub const fn intenset(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0304usize) as _) }
}
#[doc = "Disable interrupt."]
#[inline(always)]
pub const fn intenclr(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0308usize) as _) }
}
#[doc = "Error source."]
#[inline(always)]
pub const fn errorsrc(self) -> crate::common::Reg<regs::Errorsrc, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0480usize) as _) }
}
#[doc = "Enable UART."]
#[inline(always)]
pub const fn enable(self) -> crate::common::Reg<regs::Enable, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0500usize) as _) }
}
#[doc = "Unspecified."]
#[inline(always)]
pub const fn psel(self) -> Psel {
unsafe { Psel::from_ptr(self.ptr.wrapping_add(0x0508usize) as _) }
}
#[doc = "RXD register."]
#[inline(always)]
pub const fn rxd(self) -> crate::common::Reg<regs::Rxd, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0518usize) as _) }
}
#[doc = "TXD register."]
#[inline(always)]
pub const fn txd(self) -> crate::common::Reg<regs::Txd, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x051cusize) as _) }
}
#[doc = "Baud rate. Accuracy depends on the HFCLK source selected."]
#[inline(always)]
pub const fn baudrate(self) -> crate::common::Reg<regs::Baudrate, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0524usize) as _) }
}
#[doc = "Configuration of parity and hardware flow control."]
#[inline(always)]
pub const fn config(self) -> crate::common::Reg<regs::Config, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x056cusize) as _) }
}
}
pub mod regs {
#[doc = "Baud rate. Accuracy depends on the HFCLK source selected."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Baudrate(pub u32);
impl Baudrate {
#[doc = "Baud rate."]
#[must_use]
#[inline(always)]
pub const fn baudrate(&self) -> super::vals::Baudrate {
let val = (self.0 >> 0usize) & 0xffff_ffff;
super::vals::Baudrate::from_bits(val as u32)
}
#[doc = "Baud rate."]
#[inline(always)]
pub const fn set_baudrate(&mut self, val: super::vals::Baudrate) {
self.0 = (self.0 & !(0xffff_ffff << 0usize))
| (((val.to_bits() as u32) & 0xffff_ffff) << 0usize);
}
}
impl Default for Baudrate {
#[inline(always)]
fn default() -> Baudrate {
Baudrate(0)
}
}
impl core::fmt::Debug for Baudrate {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Baudrate")
.field("baudrate", &self.baudrate())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Baudrate {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Baudrate {{ baudrate: {:?} }}", self.baudrate())
}
}
#[doc = "Configuration of parity and hardware flow control."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Config(pub u32);
impl Config {
#[doc = "Hardware flow control."]
#[must_use]
#[inline(always)]
pub const fn hwfc(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Hardware flow control."]
#[inline(always)]
pub const fn set_hwfc(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Parity."]
#[must_use]
#[inline(always)]
pub const fn parity(&self) -> super::vals::ConfigParity {
let val = (self.0 >> 1usize) & 0x07;
super::vals::ConfigParity::from_bits(val as u8)
}
#[doc = "Parity."]
#[inline(always)]
pub const fn set_parity(&mut self, val: super::vals::ConfigParity) {
self.0 = (self.0 & !(0x07 << 1usize)) | (((val.to_bits() as u32) & 0x07) << 1usize);
}
#[doc = "Stop bits."]
#[must_use]
#[inline(always)]
pub const fn stop(&self) -> super::vals::Stop {
let val = (self.0 >> 4usize) & 0x01;
super::vals::Stop::from_bits(val as u8)
}
#[doc = "Stop bits."]
#[inline(always)]
pub const fn set_stop(&mut self, val: super::vals::Stop) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val.to_bits() as u32) & 0x01) << 4usize);
}
#[doc = "Even or odd parity type."]
#[must_use]
#[inline(always)]
pub const fn paritytype(&self) -> super::vals::Paritytype {
let val = (self.0 >> 8usize) & 0x01;
super::vals::Paritytype::from_bits(val as u8)
}
#[doc = "Even or odd parity type."]
#[inline(always)]
pub const fn set_paritytype(&mut self, val: super::vals::Paritytype) {
self.0 = (self.0 & !(0x01 << 8usize)) | (((val.to_bits() as u32) & 0x01) << 8usize);
}
}
impl Default for Config {
#[inline(always)]
fn default() -> Config {
Config(0)
}
}
impl core::fmt::Debug for Config {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Config")
.field("hwfc", &self.hwfc())
.field("parity", &self.parity())
.field("stop", &self.stop())
.field("paritytype", &self.paritytype())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Config {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Config {{ hwfc: {=bool:?}, parity: {:?}, stop: {:?}, paritytype: {:?} }}",
self.hwfc(),
self.parity(),
self.stop(),
self.paritytype()
)
}
}
#[doc = "Enable UART."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Enable(pub u32);
impl Enable {
#[doc = "Enable or disable UART."]
#[must_use]
#[inline(always)]
pub const fn enable(&self) -> super::vals::Enable {
let val = (self.0 >> 0usize) & 0x0f;
super::vals::Enable::from_bits(val as u8)
}
#[doc = "Enable or disable UART."]
#[inline(always)]
pub const fn set_enable(&mut self, val: super::vals::Enable) {
self.0 = (self.0 & !(0x0f << 0usize)) | (((val.to_bits() as u32) & 0x0f) << 0usize);
}
}
impl Default for Enable {
#[inline(always)]
fn default() -> Enable {
Enable(0)
}
}
impl core::fmt::Debug for Enable {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Enable")
.field("enable", &self.enable())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Enable {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Enable {{ enable: {:?} }}", self.enable())
}
}
#[doc = "Error source."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Errorsrc(pub u32);
impl Errorsrc {
#[doc = "Overrun error."]
#[must_use]
#[inline(always)]
pub const fn overrun(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Overrun error."]
#[inline(always)]
pub const fn set_overrun(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Parity error."]
#[must_use]
#[inline(always)]
pub const fn parity(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Parity error."]
#[inline(always)]
pub const fn set_parity(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "Framing error occurred."]
#[must_use]
#[inline(always)]
pub const fn framing(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Framing error occurred."]
#[inline(always)]
pub const fn set_framing(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "Break condition."]
#[must_use]
#[inline(always)]
pub const fn break_(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "Break condition."]
#[inline(always)]
pub const fn set_break_(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
}
impl Default for Errorsrc {
#[inline(always)]
fn default() -> Errorsrc {
Errorsrc(0)
}
}
impl core::fmt::Debug for Errorsrc {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Errorsrc")
.field("overrun", &self.overrun())
.field("parity", &self.parity())
.field("framing", &self.framing())
.field("break_", &self.break_())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Errorsrc {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Errorsrc {{ overrun: {=bool:?}, parity: {=bool:?}, framing: {=bool:?}, break_: {=bool:?} }}" , self . overrun () , self . parity () , self . framing () , self . break_ ())
}
}
#[doc = "Disable interrupt."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Int(pub u32);
impl Int {
#[doc = "Write '1' to disable interrupt for event CTS."]
#[must_use]
#[inline(always)]
pub const fn cts(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event CTS."]
#[inline(always)]
pub const fn set_cts(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Write '1' to disable interrupt for event NCTS."]
#[must_use]
#[inline(always)]
pub const fn ncts(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event NCTS."]
#[inline(always)]
pub const fn set_ncts(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "Write '1' to disable interrupt for event RXDRDY."]
#[must_use]
#[inline(always)]
pub const fn rxdrdy(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event RXDRDY."]
#[inline(always)]
pub const fn set_rxdrdy(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "Write '1' to disable interrupt for event TXDRDY."]
#[must_use]
#[inline(always)]
pub const fn txdrdy(&self) -> bool {
let val = (self.0 >> 7usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event TXDRDY."]
#[inline(always)]
pub const fn set_txdrdy(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize);
}
#[doc = "Write '1' to disable interrupt for event ERROR."]
#[must_use]
#[inline(always)]
pub const fn error(&self) -> bool {
let val = (self.0 >> 9usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event ERROR."]
#[inline(always)]
pub const fn set_error(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 9usize)) | (((val as u32) & 0x01) << 9usize);
}
#[doc = "Write '1' to disable interrupt for event RXTO."]
#[must_use]
#[inline(always)]
pub const fn rxto(&self) -> bool {
let val = (self.0 >> 17usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event RXTO."]
#[inline(always)]
pub const fn set_rxto(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 17usize)) | (((val as u32) & 0x01) << 17usize);
}
}
impl Default for Int {
#[inline(always)]
fn default() -> Int {
Int(0)
}
}
impl core::fmt::Debug for Int {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Int")
.field("cts", &self.cts())
.field("ncts", &self.ncts())
.field("rxdrdy", &self.rxdrdy())
.field("txdrdy", &self.txdrdy())
.field("error", &self.error())
.field("rxto", &self.rxto())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Int {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Int {{ cts: {=bool:?}, ncts: {=bool:?}, rxdrdy: {=bool:?}, txdrdy: {=bool:?}, error: {=bool:?}, rxto: {=bool:?} }}" , self . cts () , self . ncts () , self . rxdrdy () , self . txdrdy () , self . error () , self . rxto ())
}
}
#[doc = "RXD register."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Rxd(pub u32);
impl Rxd {
#[doc = "RX data received in previous transfers, double buffered."]
#[must_use]
#[inline(always)]
pub const fn rxd(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "RX data received in previous transfers, double buffered."]
#[inline(always)]
pub const fn set_rxd(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
}
impl Default for Rxd {
#[inline(always)]
fn default() -> Rxd {
Rxd(0)
}
}
impl core::fmt::Debug for Rxd {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Rxd").field("rxd", &self.rxd()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Rxd {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Rxd {{ rxd: {=u8:?} }}", self.rxd())
}
}
#[doc = "Shortcuts between local events and tasks."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Shorts(pub u32);
impl Shorts {
#[doc = "Shortcut between event CTS and task STARTRX."]
#[must_use]
#[inline(always)]
pub const fn cts_startrx(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event CTS and task STARTRX."]
#[inline(always)]
pub const fn set_cts_startrx(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
#[doc = "Shortcut between event NCTS and task STOPRX."]
#[must_use]
#[inline(always)]
pub const fn ncts_stoprx(&self) -> bool {
let val = (self.0 >> 4usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event NCTS and task STOPRX."]
#[inline(always)]
pub const fn set_ncts_stoprx(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
}
}
impl Default for Shorts {
#[inline(always)]
fn default() -> Shorts {
Shorts(0)
}
}
impl core::fmt::Debug for Shorts {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Shorts")
.field("cts_startrx", &self.cts_startrx())
.field("ncts_stoprx", &self.ncts_stoprx())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Shorts {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Shorts {{ cts_startrx: {=bool:?}, ncts_stoprx: {=bool:?} }}",
self.cts_startrx(),
self.ncts_stoprx()
)
}
}
#[doc = "TXD register."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Txd(pub u32);
impl Txd {
#[doc = "TX data to be transferred."]
#[must_use]
#[inline(always)]
pub const fn txd(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "TX data to be transferred."]
#[inline(always)]
pub const fn set_txd(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
}
impl Default for Txd {
#[inline(always)]
fn default() -> Txd {
Txd(0)
}
}
impl core::fmt::Debug for Txd {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Txd").field("txd", &self.txd()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Txd {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Txd {{ txd: {=u8:?} }}", self.txd())
}
}
}
pub mod vals {
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct Baudrate(u32);
impl Baudrate {
#[doc = "1200 baud (actual rate: 1205)."]
pub const Baud1200: Self = Self(0x0004_f000);
#[doc = "2400 baud (actual rate: 2396)."]
pub const Baud2400: Self = Self(0x0009_d000);
#[doc = "4800 baud (actual rate: 4808)."]
pub const Baud4800: Self = Self(0x0013_b000);
#[doc = "9600 baud (actual rate: 9598)."]
pub const Baud9600: Self = Self(0x0027_5000);
#[doc = "14400 baud (actual rate: 14414)."]
pub const Baud14400: Self = Self(0x003b_0000);
#[doc = "19200 baud (actual rate: 19208)."]
pub const Baud19200: Self = Self(0x004e_a000);
#[doc = "28800 baud (actual rate: 28829)."]
pub const Baud28800: Self = Self(0x0075_f000);
#[doc = "31250 baud."]
pub const Baud31250: Self = Self(0x0080_0000);
#[doc = "38400 baud (actual rate: 38462)."]
pub const Baud38400: Self = Self(0x009d_5000);
#[doc = "56000 baud (actual rate: 55944)."]
pub const Baud56000: Self = Self(0x00e5_0000);
#[doc = "57600 baud (actual rate: 57762)."]
pub const Baud57600: Self = Self(0x00eb_f000);
#[doc = "76800 baud (actual rate: 76923)."]
pub const Baud76800: Self = Self(0x013a_9000);
#[doc = "115200 baud (actual rate: 115942)."]
pub const Baud115200: Self = Self(0x01d7_e000);
#[doc = "230400 baud (actual rate: 231884)."]
pub const Baud230400: Self = Self(0x03af_b000);
#[doc = "250000 baud."]
pub const Baud250000: Self = Self(0x0400_0000);
#[doc = "460800 baud (actual rate: 470588)."]
pub const Baud460800: Self = Self(0x075f_7000);
#[doc = "921600 baud (actual rate: 941176)."]
pub const Baud921600: Self = Self(0x0ebe_d000);
#[doc = "1Mega baud."]
pub const Baud1m: Self = Self(0x1000_0000);
}
impl Baudrate {
pub const fn from_bits(val: u32) -> Baudrate {
Self(val & 0xffff_ffff)
}
pub const fn to_bits(self) -> u32 {
self.0
}
}
impl core::fmt::Debug for Baudrate {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self.0 {
0x0004_f000 => f.write_str("Baud1200"),
0x0009_d000 => f.write_str("Baud2400"),
0x0013_b000 => f.write_str("Baud4800"),
0x0027_5000 => f.write_str("Baud9600"),
0x003b_0000 => f.write_str("Baud14400"),
0x004e_a000 => f.write_str("Baud19200"),
0x0075_f000 => f.write_str("Baud28800"),
0x0080_0000 => f.write_str("Baud31250"),
0x009d_5000 => f.write_str("Baud38400"),
0x00e5_0000 => f.write_str("Baud56000"),
0x00eb_f000 => f.write_str("Baud57600"),
0x013a_9000 => f.write_str("Baud76800"),
0x01d7_e000 => f.write_str("Baud115200"),
0x03af_b000 => f.write_str("Baud230400"),
0x0400_0000 => f.write_str("Baud250000"),
0x075f_7000 => f.write_str("Baud460800"),
0x0ebe_d000 => f.write_str("Baud921600"),
0x1000_0000 => f.write_str("Baud1m"),
other => core::write!(f, "0x{:02X}", other),
}
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Baudrate {
fn format(&self, f: defmt::Formatter) {
match self.0 {
0x0004_f000 => defmt::write!(f, "Baud1200"),
0x0009_d000 => defmt::write!(f, "Baud2400"),
0x0013_b000 => defmt::write!(f, "Baud4800"),
0x0027_5000 => defmt::write!(f, "Baud9600"),
0x003b_0000 => defmt::write!(f, "Baud14400"),
0x004e_a000 => defmt::write!(f, "Baud19200"),
0x0075_f000 => defmt::write!(f, "Baud28800"),
0x0080_0000 => defmt::write!(f, "Baud31250"),
0x009d_5000 => defmt::write!(f, "Baud38400"),
0x00e5_0000 => defmt::write!(f, "Baud56000"),
0x00eb_f000 => defmt::write!(f, "Baud57600"),
0x013a_9000 => defmt::write!(f, "Baud76800"),
0x01d7_e000 => defmt::write!(f, "Baud115200"),
0x03af_b000 => defmt::write!(f, "Baud230400"),
0x0400_0000 => defmt::write!(f, "Baud250000"),
0x075f_7000 => defmt::write!(f, "Baud460800"),
0x0ebe_d000 => defmt::write!(f, "Baud921600"),
0x1000_0000 => defmt::write!(f, "Baud1m"),
other => defmt::write!(f, "0x{:02X}", other),
}
}
}
impl From<u32> for Baudrate {
#[inline(always)]
fn from(val: u32) -> Baudrate {
Baudrate::from_bits(val)
}
}
impl From<Baudrate> for u32 {
#[inline(always)]
fn from(val: Baudrate) -> u32 {
Baudrate::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum ConfigParity {
#[doc = "Exclude parity bit."]
Excluded = 0x0,
_RESERVED_1 = 0x01,
_RESERVED_2 = 0x02,
_RESERVED_3 = 0x03,
_RESERVED_4 = 0x04,
_RESERVED_5 = 0x05,
_RESERVED_6 = 0x06,
#[doc = "Include parity bit."]
Included = 0x07,
}
impl ConfigParity {
#[inline(always)]
pub const fn from_bits(val: u8) -> ConfigParity {
unsafe { core::mem::transmute(val & 0x07) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for ConfigParity {
#[inline(always)]
fn from(val: u8) -> ConfigParity {
ConfigParity::from_bits(val)
}
}
impl From<ConfigParity> for u8 {
#[inline(always)]
fn from(val: ConfigParity) -> u8 {
ConfigParity::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Enable {
#[doc = "Disable UART."]
Disabled = 0x0,
_RESERVED_1 = 0x01,
_RESERVED_2 = 0x02,
_RESERVED_3 = 0x03,
#[doc = "Enable UART."]
Enabled = 0x04,
_RESERVED_5 = 0x05,
_RESERVED_6 = 0x06,
_RESERVED_7 = 0x07,
_RESERVED_8 = 0x08,
_RESERVED_9 = 0x09,
_RESERVED_a = 0x0a,
_RESERVED_b = 0x0b,
_RESERVED_c = 0x0c,
_RESERVED_d = 0x0d,
_RESERVED_e = 0x0e,
_RESERVED_f = 0x0f,
}
impl Enable {
#[inline(always)]
pub const fn from_bits(val: u8) -> Enable {
unsafe { core::mem::transmute(val & 0x0f) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Enable {
#[inline(always)]
fn from(val: u8) -> Enable {
Enable::from_bits(val)
}
}
impl From<Enable> for u8 {
#[inline(always)]
fn from(val: Enable) -> u8 {
Enable::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Paritytype {
#[doc = "Even parity."]
Even = 0x0,
#[doc = "Odd parity."]
Odd = 0x01,
}
impl Paritytype {
#[inline(always)]
pub const fn from_bits(val: u8) -> Paritytype {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Paritytype {
#[inline(always)]
fn from(val: u8) -> Paritytype {
Paritytype::from_bits(val)
}
}
impl From<Paritytype> for u8 {
#[inline(always)]
fn from(val: Paritytype) -> u8 {
Paritytype::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Stop {
#[doc = "One stop bit."]
One = 0x0,
#[doc = "Two stop bits."]
Two = 0x01,
}
impl Stop {
#[inline(always)]
pub const fn from_bits(val: u8) -> Stop {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Stop {
#[inline(always)]
fn from(val: u8) -> Stop {
Stop::from_bits(val)
}
}
impl From<Stop> for u8 {
#[inline(always)]
fn from(val: Stop) -> u8 {
Stop::to_bits(val)
}
}
}
}
pub mod uarte {
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Dma {
ptr: *mut u8,
}
unsafe impl Send for Dma {}
unsafe impl Sync for Dma {}
impl Dma {
#[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 = "RXD EasyDMA channel."]
#[inline(always)]
pub const fn rx(self) -> DmaRx {
unsafe { DmaRx::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "TXD EasyDMA channel."]
#[inline(always)]
pub const fn tx(self) -> DmaTx {
unsafe { DmaTx::from_ptr(self.ptr.wrapping_add(0x10usize) as _) }
}
}
#[doc = "RXD EasyDMA channel."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct DmaRx {
ptr: *mut u8,
}
unsafe impl Send for DmaRx {}
unsafe impl Sync for DmaRx {}
impl DmaRx {
#[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 = "Data pointer."]
#[inline(always)]
pub const fn ptr(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Maximum number of bytes in receive buffer."]
#[inline(always)]
pub const fn maxcnt(self) -> crate::common::Reg<regs::RxdMaxcnt, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Number of bytes transferred in the last transaction."]
#[inline(always)]
pub const fn amount(self) -> crate::common::Reg<regs::RxdAmount, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
}
#[doc = "TXD EasyDMA channel."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct DmaTx {
ptr: *mut u8,
}
unsafe impl Send for DmaTx {}
unsafe impl Sync for DmaTx {}
impl DmaTx {
#[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 = "Data pointer."]
#[inline(always)]
pub const fn ptr(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Maximum number of bytes in transmit buffer."]
#[inline(always)]
pub const fn maxcnt(self) -> crate::common::Reg<regs::TxdMaxcnt, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Number of bytes transferred in the last transaction."]
#[inline(always)]
pub const fn amount(self) -> crate::common::Reg<regs::TxdAmount, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
}
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct EventsDma {
ptr: *mut u8,
}
unsafe impl Send for EventsDma {}
unsafe impl Sync for EventsDma {}
impl EventsDma {
#[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 _
}
#[inline(always)]
pub const fn rx(self) -> EventsDmaRx {
unsafe { EventsDmaRx::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[inline(always)]
pub const fn tx(self) -> EventsDmaTx {
unsafe { EventsDmaTx::from_ptr(self.ptr.wrapping_add(0x10usize) as _) }
}
}
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct EventsDmaRx {
ptr: *mut u8,
}
unsafe impl Send for EventsDmaRx {}
unsafe impl Sync for EventsDmaRx {}
impl EventsDmaRx {
#[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 = "Receive buffer is filled up."]
#[inline(always)]
pub const fn end(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "UART receiver has started."]
#[inline(always)]
pub const fn ready(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x3cusize) as _) }
}
}
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct EventsDmaTx {
ptr: *mut u8,
}
unsafe impl Send for EventsDmaTx {}
unsafe impl Sync for EventsDmaTx {}
impl EventsDmaTx {
#[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 = "Last TX byte transmitted."]
#[inline(always)]
pub const fn end(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "UART transmitter has started."]
#[inline(always)]
pub const fn ready(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x30usize) as _) }
}
}
#[doc = "Unspecified."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Psel {
ptr: *mut u8,
}
unsafe impl Send for Psel {}
unsafe impl Sync for Psel {}
impl Psel {
#[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 = "Pin select for RTS signal."]
#[inline(always)]
pub const fn rts(self) -> crate::common::Reg<super::shared::regs::Psel, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Pin select for TXD signal."]
#[inline(always)]
pub const fn txd(self) -> crate::common::Reg<super::shared::regs::Psel, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Pin select for CTS signal."]
#[inline(always)]
pub const fn cts(self) -> crate::common::Reg<super::shared::regs::Psel, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
#[doc = "Pin select for RXD signal."]
#[inline(always)]
pub const fn rxd(self) -> crate::common::Reg<super::shared::regs::Psel, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0cusize) as _) }
}
}
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct TasksDma {
ptr: *mut u8,
}
unsafe impl Send for TasksDma {}
unsafe impl Sync for TasksDma {}
impl TasksDma {
#[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 _
}
#[inline(always)]
pub const fn rx(self) -> TasksDmaRx {
unsafe { TasksDmaRx::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[inline(always)]
pub const fn tx(self) -> TasksDmaTx {
unsafe { TasksDmaTx::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
}
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct TasksDmaRx {
ptr: *mut u8,
}
unsafe impl Send for TasksDmaRx {}
unsafe impl Sync for TasksDmaRx {}
impl TasksDmaRx {
#[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 = "Start UART receiver."]
#[inline(always)]
pub const fn start(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Stop UART receiver."]
#[inline(always)]
pub const fn stop(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
}
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct TasksDmaTx {
ptr: *mut u8,
}
unsafe impl Send for TasksDmaTx {}
unsafe impl Sync for TasksDmaTx {}
impl TasksDmaTx {
#[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 = "Start UART transmitter."]
#[inline(always)]
pub const fn start(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Stop UART transmitter."]
#[inline(always)]
pub const fn stop(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
}
#[doc = "UART with EasyDMA."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Uarte {
ptr: *mut u8,
}
unsafe impl Send for Uarte {}
unsafe impl Sync for Uarte {}
impl Uarte {
#[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 _
}
#[inline(always)]
pub const fn tasks_dma(self) -> TasksDma {
unsafe { TasksDma::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Flush RX FIFO into RX buffer."]
#[inline(always)]
pub const fn tasks_flushrx(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x2cusize) as _) }
}
#[doc = "CTS is activated (set low). Clear To Send."]
#[inline(always)]
pub const fn events_cts(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0100usize) as _) }
}
#[doc = "CTS is deactivated (set high). Not Clear To Send."]
#[inline(always)]
pub const fn events_ncts(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0104usize) as _) }
}
#[doc = "Data received in RXD (but potentially not yet transferred to Data RAM)."]
#[inline(always)]
pub const fn events_rxdrdy(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0108usize) as _) }
}
#[inline(always)]
pub const fn events_dma(self) -> EventsDma {
unsafe { EventsDma::from_ptr(self.ptr.wrapping_add(0x0110usize) as _) }
}
#[doc = "Data sent from TXD."]
#[inline(always)]
pub const fn events_txdrdy(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x011cusize) as _) }
}
#[doc = "Error detected."]
#[inline(always)]
pub const fn events_error(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0124usize) as _) }
}
#[doc = "Receiver timeout."]
#[inline(always)]
pub const fn events_rxto(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0144usize) as _) }
}
#[doc = "Transmitter stopped."]
#[inline(always)]
pub const fn events_txstopped(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0158usize) as _) }
}
#[doc = "Shortcuts between local events and tasks."]
#[inline(always)]
pub const fn shorts(self) -> crate::common::Reg<regs::Shorts, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0200usize) as _) }
}
#[doc = "Enable or disable interrupt."]
#[inline(always)]
pub const fn inten(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0300usize) as _) }
}
#[doc = "Enable interrupt."]
#[inline(always)]
pub const fn intenset(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0304usize) as _) }
}
#[doc = "Disable interrupt."]
#[inline(always)]
pub const fn intenclr(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0308usize) as _) }
}
#[doc = "Error source This register is read/write one to clear."]
#[inline(always)]
pub const fn errorsrc(self) -> crate::common::Reg<regs::Errorsrc, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0480usize) as _) }
}
#[doc = "Enable UART."]
#[inline(always)]
pub const fn enable(self) -> crate::common::Reg<regs::Enable, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0500usize) as _) }
}
#[doc = "Unspecified."]
#[inline(always)]
pub const fn psel(self) -> Psel {
unsafe { Psel::from_ptr(self.ptr.wrapping_add(0x0508usize) as _) }
}
#[doc = "Baud rate. Accuracy depends on the HFCLK source selected."]
#[inline(always)]
pub const fn baudrate(self) -> crate::common::Reg<regs::Baudrate, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0524usize) as _) }
}
#[inline(always)]
pub const fn dma(self) -> Dma {
unsafe { Dma::from_ptr(self.ptr.wrapping_add(0x0534usize) as _) }
}
#[doc = "Configuration of parity and hardware flow control."]
#[inline(always)]
pub const fn config(self) -> crate::common::Reg<regs::Config, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x056cusize) as _) }
}
}
pub mod regs {
#[doc = "Baud rate. Accuracy depends on the HFCLK source selected."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Baudrate(pub u32);
impl Baudrate {
#[doc = "Baud rate."]
#[must_use]
#[inline(always)]
pub const fn baudrate(&self) -> super::vals::Baudrate {
let val = (self.0 >> 0usize) & 0xffff_ffff;
super::vals::Baudrate::from_bits(val as u32)
}
#[doc = "Baud rate."]
#[inline(always)]
pub const fn set_baudrate(&mut self, val: super::vals::Baudrate) {
self.0 = (self.0 & !(0xffff_ffff << 0usize))
| (((val.to_bits() as u32) & 0xffff_ffff) << 0usize);
}
}
impl Default for Baudrate {
#[inline(always)]
fn default() -> Baudrate {
Baudrate(0)
}
}
impl core::fmt::Debug for Baudrate {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Baudrate")
.field("baudrate", &self.baudrate())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Baudrate {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Baudrate {{ baudrate: {:?} }}", self.baudrate())
}
}
#[doc = "Configuration of parity and hardware flow control."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Config(pub u32);
impl Config {
#[doc = "Hardware flow control."]
#[must_use]
#[inline(always)]
pub const fn hwfc(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Hardware flow control."]
#[inline(always)]
pub const fn set_hwfc(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Parity."]
#[must_use]
#[inline(always)]
pub const fn parity(&self) -> super::vals::ConfigParity {
let val = (self.0 >> 1usize) & 0x07;
super::vals::ConfigParity::from_bits(val as u8)
}
#[doc = "Parity."]
#[inline(always)]
pub const fn set_parity(&mut self, val: super::vals::ConfigParity) {
self.0 = (self.0 & !(0x07 << 1usize)) | (((val.to_bits() as u32) & 0x07) << 1usize);
}
#[doc = "Stop bits."]
#[must_use]
#[inline(always)]
pub const fn stop(&self) -> super::vals::Stop {
let val = (self.0 >> 4usize) & 0x01;
super::vals::Stop::from_bits(val as u8)
}
#[doc = "Stop bits."]
#[inline(always)]
pub const fn set_stop(&mut self, val: super::vals::Stop) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val.to_bits() as u32) & 0x01) << 4usize);
}
#[doc = "Even or odd parity type."]
#[must_use]
#[inline(always)]
pub const fn paritytype(&self) -> super::vals::Paritytype {
let val = (self.0 >> 8usize) & 0x01;
super::vals::Paritytype::from_bits(val as u8)
}
#[doc = "Even or odd parity type."]
#[inline(always)]
pub const fn set_paritytype(&mut self, val: super::vals::Paritytype) {
self.0 = (self.0 & !(0x01 << 8usize)) | (((val.to_bits() as u32) & 0x01) << 8usize);
}
}
impl Default for Config {
#[inline(always)]
fn default() -> Config {
Config(0)
}
}
impl core::fmt::Debug for Config {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Config")
.field("hwfc", &self.hwfc())
.field("parity", &self.parity())
.field("stop", &self.stop())
.field("paritytype", &self.paritytype())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Config {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Config {{ hwfc: {=bool:?}, parity: {:?}, stop: {:?}, paritytype: {:?} }}",
self.hwfc(),
self.parity(),
self.stop(),
self.paritytype()
)
}
}
#[doc = "Enable UART."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Enable(pub u32);
impl Enable {
#[doc = "Enable or disable UARTE."]
#[must_use]
#[inline(always)]
pub const fn enable(&self) -> super::vals::Enable {
let val = (self.0 >> 0usize) & 0x0f;
super::vals::Enable::from_bits(val as u8)
}
#[doc = "Enable or disable UARTE."]
#[inline(always)]
pub const fn set_enable(&mut self, val: super::vals::Enable) {
self.0 = (self.0 & !(0x0f << 0usize)) | (((val.to_bits() as u32) & 0x0f) << 0usize);
}
}
impl Default for Enable {
#[inline(always)]
fn default() -> Enable {
Enable(0)
}
}
impl core::fmt::Debug for Enable {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Enable")
.field("enable", &self.enable())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Enable {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Enable {{ enable: {:?} }}", self.enable())
}
}
#[doc = "Error source This register is read/write one to clear."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Errorsrc(pub u32);
impl Errorsrc {
#[doc = "Overrun error."]
#[must_use]
#[inline(always)]
pub const fn overrun(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Overrun error."]
#[inline(always)]
pub const fn set_overrun(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Parity error."]
#[must_use]
#[inline(always)]
pub const fn parity(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Parity error."]
#[inline(always)]
pub const fn set_parity(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "Framing error occurred."]
#[must_use]
#[inline(always)]
pub const fn framing(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Framing error occurred."]
#[inline(always)]
pub const fn set_framing(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "Break condition."]
#[must_use]
#[inline(always)]
pub const fn break_(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "Break condition."]
#[inline(always)]
pub const fn set_break_(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
}
impl Default for Errorsrc {
#[inline(always)]
fn default() -> Errorsrc {
Errorsrc(0)
}
}
impl core::fmt::Debug for Errorsrc {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Errorsrc")
.field("overrun", &self.overrun())
.field("parity", &self.parity())
.field("framing", &self.framing())
.field("break_", &self.break_())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Errorsrc {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Errorsrc {{ overrun: {=bool:?}, parity: {=bool:?}, framing: {=bool:?}, break_: {=bool:?} }}" , self . overrun () , self . parity () , self . framing () , self . break_ ())
}
}
#[doc = "Enable or disable interrupt."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Int(pub u32);
impl Int {
#[doc = "Enable or disable interrupt for event CTS."]
#[must_use]
#[inline(always)]
pub const fn cts(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event CTS."]
#[inline(always)]
pub const fn set_cts(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Enable or disable interrupt for event NCTS."]
#[must_use]
#[inline(always)]
pub const fn ncts(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event NCTS."]
#[inline(always)]
pub const fn set_ncts(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "Enable or disable interrupt for event RXDRDY."]
#[must_use]
#[inline(always)]
pub const fn rxdrdy(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event RXDRDY."]
#[inline(always)]
pub const fn set_rxdrdy(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "Enable or disable interrupt for event ENDRX."]
#[must_use]
#[inline(always)]
pub const fn dmarxend(&self) -> bool {
let val = (self.0 >> 4usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event ENDRX."]
#[inline(always)]
pub const fn set_dmarxend(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
}
#[doc = "Enable or disable interrupt for event TXDRDY."]
#[must_use]
#[inline(always)]
pub const fn txdrdy(&self) -> bool {
let val = (self.0 >> 7usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event TXDRDY."]
#[inline(always)]
pub const fn set_txdrdy(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize);
}
#[doc = "Enable or disable interrupt for event ENDTX."]
#[must_use]
#[inline(always)]
pub const fn dmatxend(&self) -> bool {
let val = (self.0 >> 8usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event ENDTX."]
#[inline(always)]
pub const fn set_dmatxend(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize);
}
#[doc = "Enable or disable interrupt for event ERROR."]
#[must_use]
#[inline(always)]
pub const fn error(&self) -> bool {
let val = (self.0 >> 9usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event ERROR."]
#[inline(always)]
pub const fn set_error(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 9usize)) | (((val as u32) & 0x01) << 9usize);
}
#[doc = "Enable or disable interrupt for event RXTO."]
#[must_use]
#[inline(always)]
pub const fn rxto(&self) -> bool {
let val = (self.0 >> 17usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event RXTO."]
#[inline(always)]
pub const fn set_rxto(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 17usize)) | (((val as u32) & 0x01) << 17usize);
}
#[doc = "Enable or disable interrupt for event RXSTARTED."]
#[must_use]
#[inline(always)]
pub const fn dmarxready(&self) -> bool {
let val = (self.0 >> 19usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event RXSTARTED."]
#[inline(always)]
pub const fn set_dmarxready(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 19usize)) | (((val as u32) & 0x01) << 19usize);
}
#[doc = "Enable or disable interrupt for event TXSTARTED."]
#[must_use]
#[inline(always)]
pub const fn dmatxready(&self) -> bool {
let val = (self.0 >> 20usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event TXSTARTED."]
#[inline(always)]
pub const fn set_dmatxready(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 20usize)) | (((val as u32) & 0x01) << 20usize);
}
#[doc = "Enable or disable interrupt for event TXSTOPPED."]
#[must_use]
#[inline(always)]
pub const fn txstopped(&self) -> bool {
let val = (self.0 >> 22usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event TXSTOPPED."]
#[inline(always)]
pub const fn set_txstopped(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 22usize)) | (((val as u32) & 0x01) << 22usize);
}
}
impl Default for Int {
#[inline(always)]
fn default() -> Int {
Int(0)
}
}
impl core::fmt::Debug for Int {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Int")
.field("cts", &self.cts())
.field("ncts", &self.ncts())
.field("rxdrdy", &self.rxdrdy())
.field("dmarxend", &self.dmarxend())
.field("txdrdy", &self.txdrdy())
.field("dmatxend", &self.dmatxend())
.field("error", &self.error())
.field("rxto", &self.rxto())
.field("dmarxready", &self.dmarxready())
.field("dmatxready", &self.dmatxready())
.field("txstopped", &self.txstopped())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Int {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Int {{ cts: {=bool:?}, ncts: {=bool:?}, rxdrdy: {=bool:?}, dmarxend: {=bool:?}, txdrdy: {=bool:?}, dmatxend: {=bool:?}, error: {=bool:?}, rxto: {=bool:?}, dmarxready: {=bool:?}, dmatxready: {=bool:?}, txstopped: {=bool:?} }}" , self . cts () , self . ncts () , self . rxdrdy () , self . dmarxend () , self . txdrdy () , self . dmatxend () , self . error () , self . rxto () , self . dmarxready () , self . dmatxready () , self . txstopped ())
}
}
#[doc = "Number of bytes transferred in the last transaction."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct RxdAmount(pub u32);
impl RxdAmount {
#[doc = "Number of bytes transferred in the last transaction."]
#[must_use]
#[inline(always)]
pub const fn amount(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x7fff;
val as u16
}
#[doc = "Number of bytes transferred in the last transaction."]
#[inline(always)]
pub const fn set_amount(&mut self, val: u16) {
self.0 = (self.0 & !(0x7fff << 0usize)) | (((val as u32) & 0x7fff) << 0usize);
}
}
impl Default for RxdAmount {
#[inline(always)]
fn default() -> RxdAmount {
RxdAmount(0)
}
}
impl core::fmt::Debug for RxdAmount {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("RxdAmount")
.field("amount", &self.amount())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for RxdAmount {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "RxdAmount {{ amount: {=u16:?} }}", self.amount())
}
}
#[doc = "Maximum number of bytes in receive buffer."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct RxdMaxcnt(pub u32);
impl RxdMaxcnt {
#[doc = "Maximum number of bytes in receive buffer."]
#[must_use]
#[inline(always)]
pub const fn maxcnt(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x7fff;
val as u16
}
#[doc = "Maximum number of bytes in receive buffer."]
#[inline(always)]
pub const fn set_maxcnt(&mut self, val: u16) {
self.0 = (self.0 & !(0x7fff << 0usize)) | (((val as u32) & 0x7fff) << 0usize);
}
}
impl Default for RxdMaxcnt {
#[inline(always)]
fn default() -> RxdMaxcnt {
RxdMaxcnt(0)
}
}
impl core::fmt::Debug for RxdMaxcnt {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("RxdMaxcnt")
.field("maxcnt", &self.maxcnt())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for RxdMaxcnt {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "RxdMaxcnt {{ maxcnt: {=u16:?} }}", self.maxcnt())
}
}
#[doc = "Shortcuts between local events and tasks."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Shorts(pub u32);
impl Shorts {
#[doc = "Shortcut between event ENDRX and task STARTRX."]
#[must_use]
#[inline(always)]
pub const fn endrx_startrx(&self) -> bool {
let val = (self.0 >> 5usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event ENDRX and task STARTRX."]
#[inline(always)]
pub const fn set_endrx_startrx(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
}
#[doc = "Shortcut between event ENDRX and task STOPRX."]
#[must_use]
#[inline(always)]
pub const fn endrx_stoprx(&self) -> bool {
let val = (self.0 >> 6usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event ENDRX and task STOPRX."]
#[inline(always)]
pub const fn set_endrx_stoprx(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize);
}
}
impl Default for Shorts {
#[inline(always)]
fn default() -> Shorts {
Shorts(0)
}
}
impl core::fmt::Debug for Shorts {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Shorts")
.field("endrx_startrx", &self.endrx_startrx())
.field("endrx_stoprx", &self.endrx_stoprx())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Shorts {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Shorts {{ endrx_startrx: {=bool:?}, endrx_stoprx: {=bool:?} }}",
self.endrx_startrx(),
self.endrx_stoprx()
)
}
}
#[doc = "Number of bytes transferred in the last transaction."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct TxdAmount(pub u32);
impl TxdAmount {
#[doc = "Number of bytes transferred in the last transaction."]
#[must_use]
#[inline(always)]
pub const fn amount(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x7fff;
val as u16
}
#[doc = "Number of bytes transferred in the last transaction."]
#[inline(always)]
pub const fn set_amount(&mut self, val: u16) {
self.0 = (self.0 & !(0x7fff << 0usize)) | (((val as u32) & 0x7fff) << 0usize);
}
}
impl Default for TxdAmount {
#[inline(always)]
fn default() -> TxdAmount {
TxdAmount(0)
}
}
impl core::fmt::Debug for TxdAmount {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("TxdAmount")
.field("amount", &self.amount())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for TxdAmount {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "TxdAmount {{ amount: {=u16:?} }}", self.amount())
}
}
#[doc = "Maximum number of bytes in transmit buffer."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct TxdMaxcnt(pub u32);
impl TxdMaxcnt {
#[doc = "Maximum number of bytes in transmit buffer."]
#[must_use]
#[inline(always)]
pub const fn maxcnt(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x7fff;
val as u16
}
#[doc = "Maximum number of bytes in transmit buffer."]
#[inline(always)]
pub const fn set_maxcnt(&mut self, val: u16) {
self.0 = (self.0 & !(0x7fff << 0usize)) | (((val as u32) & 0x7fff) << 0usize);
}
}
impl Default for TxdMaxcnt {
#[inline(always)]
fn default() -> TxdMaxcnt {
TxdMaxcnt(0)
}
}
impl core::fmt::Debug for TxdMaxcnt {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("TxdMaxcnt")
.field("maxcnt", &self.maxcnt())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for TxdMaxcnt {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "TxdMaxcnt {{ maxcnt: {=u16:?} }}", self.maxcnt())
}
}
}
pub mod vals {
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct Baudrate(u32);
impl Baudrate {
#[doc = "1200 baud (actual rate: 1205)."]
pub const Baud1200: Self = Self(0x0004_f000);
#[doc = "2400 baud (actual rate: 2396)."]
pub const Baud2400: Self = Self(0x0009_d000);
#[doc = "4800 baud (actual rate: 4808)."]
pub const Baud4800: Self = Self(0x0013_b000);
#[doc = "9600 baud (actual rate: 9598)."]
pub const Baud9600: Self = Self(0x0027_5000);
#[doc = "14400 baud (actual rate: 14401)."]
pub const Baud14400: Self = Self(0x003a_f000);
#[doc = "19200 baud (actual rate: 19208)."]
pub const Baud19200: Self = Self(0x004e_a000);
#[doc = "28800 baud (actual rate: 28777)."]
pub const Baud28800: Self = Self(0x0075_c000);
#[doc = "31250 baud."]
pub const Baud31250: Self = Self(0x0080_0000);
#[doc = "38400 baud (actual rate: 38369)."]
pub const Baud38400: Self = Self(0x009d_0000);
#[doc = "56000 baud (actual rate: 55944)."]
pub const Baud56000: Self = Self(0x00e5_0000);
#[doc = "57600 baud (actual rate: 57554)."]
pub const Baud57600: Self = Self(0x00eb_0000);
#[doc = "76800 baud (actual rate: 76923)."]
pub const Baud76800: Self = Self(0x013a_9000);
#[doc = "115200 baud (actual rate: 115108)."]
pub const Baud115200: Self = Self(0x01d6_0000);
#[doc = "230400 baud (actual rate: 231884)."]
pub const Baud230400: Self = Self(0x03b0_0000);
#[doc = "250000 baud."]
pub const Baud250000: Self = Self(0x0400_0000);
#[doc = "460800 baud (actual rate: 457143)."]
pub const Baud460800: Self = Self(0x0740_0000);
#[doc = "921600 baud (actual rate: 941176)."]
pub const Baud921600: Self = Self(0x0f00_0000);
#[doc = "1 megabaud."]
pub const Baud1m: Self = Self(0x1000_0000);
}
impl Baudrate {
pub const fn from_bits(val: u32) -> Baudrate {
Self(val & 0xffff_ffff)
}
pub const fn to_bits(self) -> u32 {
self.0
}
}
impl core::fmt::Debug for Baudrate {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self.0 {
0x0004_f000 => f.write_str("Baud1200"),
0x0009_d000 => f.write_str("Baud2400"),
0x0013_b000 => f.write_str("Baud4800"),
0x0027_5000 => f.write_str("Baud9600"),
0x003a_f000 => f.write_str("Baud14400"),
0x004e_a000 => f.write_str("Baud19200"),
0x0075_c000 => f.write_str("Baud28800"),
0x0080_0000 => f.write_str("Baud31250"),
0x009d_0000 => f.write_str("Baud38400"),
0x00e5_0000 => f.write_str("Baud56000"),
0x00eb_0000 => f.write_str("Baud57600"),
0x013a_9000 => f.write_str("Baud76800"),
0x01d6_0000 => f.write_str("Baud115200"),
0x03b0_0000 => f.write_str("Baud230400"),
0x0400_0000 => f.write_str("Baud250000"),
0x0740_0000 => f.write_str("Baud460800"),
0x0f00_0000 => f.write_str("Baud921600"),
0x1000_0000 => f.write_str("Baud1m"),
other => core::write!(f, "0x{:02X}", other),
}
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Baudrate {
fn format(&self, f: defmt::Formatter) {
match self.0 {
0x0004_f000 => defmt::write!(f, "Baud1200"),
0x0009_d000 => defmt::write!(f, "Baud2400"),
0x0013_b000 => defmt::write!(f, "Baud4800"),
0x0027_5000 => defmt::write!(f, "Baud9600"),
0x003a_f000 => defmt::write!(f, "Baud14400"),
0x004e_a000 => defmt::write!(f, "Baud19200"),
0x0075_c000 => defmt::write!(f, "Baud28800"),
0x0080_0000 => defmt::write!(f, "Baud31250"),
0x009d_0000 => defmt::write!(f, "Baud38400"),
0x00e5_0000 => defmt::write!(f, "Baud56000"),
0x00eb_0000 => defmt::write!(f, "Baud57600"),
0x013a_9000 => defmt::write!(f, "Baud76800"),
0x01d6_0000 => defmt::write!(f, "Baud115200"),
0x03b0_0000 => defmt::write!(f, "Baud230400"),
0x0400_0000 => defmt::write!(f, "Baud250000"),
0x0740_0000 => defmt::write!(f, "Baud460800"),
0x0f00_0000 => defmt::write!(f, "Baud921600"),
0x1000_0000 => defmt::write!(f, "Baud1m"),
other => defmt::write!(f, "0x{:02X}", other),
}
}
}
impl From<u32> for Baudrate {
#[inline(always)]
fn from(val: u32) -> Baudrate {
Baudrate::from_bits(val)
}
}
impl From<Baudrate> for u32 {
#[inline(always)]
fn from(val: Baudrate) -> u32 {
Baudrate::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum ConfigParity {
#[doc = "Exclude parity bit."]
Excluded = 0x0,
_RESERVED_1 = 0x01,
_RESERVED_2 = 0x02,
_RESERVED_3 = 0x03,
_RESERVED_4 = 0x04,
_RESERVED_5 = 0x05,
_RESERVED_6 = 0x06,
#[doc = "Include even parity bit."]
Included = 0x07,
}
impl ConfigParity {
#[inline(always)]
pub const fn from_bits(val: u8) -> ConfigParity {
unsafe { core::mem::transmute(val & 0x07) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for ConfigParity {
#[inline(always)]
fn from(val: u8) -> ConfigParity {
ConfigParity::from_bits(val)
}
}
impl From<ConfigParity> for u8 {
#[inline(always)]
fn from(val: ConfigParity) -> u8 {
ConfigParity::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Enable {
#[doc = "Disable UARTE."]
Disabled = 0x0,
_RESERVED_1 = 0x01,
_RESERVED_2 = 0x02,
_RESERVED_3 = 0x03,
_RESERVED_4 = 0x04,
_RESERVED_5 = 0x05,
_RESERVED_6 = 0x06,
_RESERVED_7 = 0x07,
#[doc = "Enable UARTE."]
Enabled = 0x08,
_RESERVED_9 = 0x09,
_RESERVED_a = 0x0a,
_RESERVED_b = 0x0b,
_RESERVED_c = 0x0c,
_RESERVED_d = 0x0d,
_RESERVED_e = 0x0e,
_RESERVED_f = 0x0f,
}
impl Enable {
#[inline(always)]
pub const fn from_bits(val: u8) -> Enable {
unsafe { core::mem::transmute(val & 0x0f) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Enable {
#[inline(always)]
fn from(val: u8) -> Enable {
Enable::from_bits(val)
}
}
impl From<Enable> for u8 {
#[inline(always)]
fn from(val: Enable) -> u8 {
Enable::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Paritytype {
#[doc = "Even parity."]
Even = 0x0,
#[doc = "Odd parity."]
Odd = 0x01,
}
impl Paritytype {
#[inline(always)]
pub const fn from_bits(val: u8) -> Paritytype {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Paritytype {
#[inline(always)]
fn from(val: u8) -> Paritytype {
Paritytype::from_bits(val)
}
}
impl From<Paritytype> for u8 {
#[inline(always)]
fn from(val: Paritytype) -> u8 {
Paritytype::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Stop {
#[doc = "One stop bit."]
One = 0x0,
#[doc = "Two stop bits."]
Two = 0x01,
}
impl Stop {
#[inline(always)]
pub const fn from_bits(val: u8) -> Stop {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Stop {
#[inline(always)]
fn from(val: u8) -> Stop {
Stop::from_bits(val)
}
}
impl From<Stop> for u8 {
#[inline(always)]
fn from(val: Stop) -> u8 {
Stop::to_bits(val)
}
}
}
}
pub mod uicr {
#[doc = "User information configuration registers."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Uicr {
ptr: *mut u8,
}
unsafe impl Send for Uicr {}
unsafe impl Sync for Uicr {}
impl Uicr {
#[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 = "Description collection: Reserved for Nordic firmware design."]
#[inline(always)]
pub const fn nrffw(self, n: usize) -> crate::common::Reg<u32, crate::common::RW> {
assert!(n < 13usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x14usize + n * 4usize) as _)
}
}
#[doc = "Description collection: Reserved for Nordic hardware design."]
#[inline(always)]
pub const fn nrfhw(self, n: usize) -> crate::common::Reg<u32, crate::common::RW> {
assert!(n < 12usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x50usize + n * 4usize) as _)
}
}
#[doc = "Description collection: Reserved for customer."]
#[inline(always)]
pub const fn customer(self, n: usize) -> crate::common::Reg<u32, crate::common::RW> {
assert!(n < 32usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x80usize + n * 4usize) as _)
}
}
#[doc = "Description collection: Mapping of the nRESET function (see POWER chapter for details)."]
#[inline(always)]
pub const fn pselreset(
self,
n: usize,
) -> crate::common::Reg<super::shared::regs::Psel, crate::common::RW> {
assert!(n < 2usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0200usize + n * 4usize) as _)
}
}
#[doc = "Access port protection."]
#[inline(always)]
pub const fn approtect(self) -> crate::common::Reg<regs::Approtect, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0208usize) as _) }
}
#[doc = "Processor debug control."]
#[inline(always)]
pub const fn debugctrl(self) -> crate::common::Reg<regs::Debugctrl, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0210usize) as _) }
}
#[doc = "Output voltage from REG0 regulator stage. The maximum output voltage from this stage is given as VDDH - V_VDDH-VDD."]
#[inline(always)]
pub const fn regout0(self) -> crate::common::Reg<regs::Regout0, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0304usize) as _) }
}
}
pub mod regs {
#[doc = "Access port protection."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Approtect(pub u32);
impl Approtect {
#[doc = "Enable or disable access port protection."]
#[must_use]
#[inline(always)]
pub const fn pall(&self) -> super::vals::Pall {
let val = (self.0 >> 0usize) & 0xff;
super::vals::Pall::from_bits(val as u8)
}
#[doc = "Enable or disable access port protection."]
#[inline(always)]
pub const fn set_pall(&mut self, val: super::vals::Pall) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val.to_bits() as u32) & 0xff) << 0usize);
}
}
impl Default for Approtect {
#[inline(always)]
fn default() -> Approtect {
Approtect(0)
}
}
impl core::fmt::Debug for Approtect {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Approtect")
.field("pall", &self.pall())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Approtect {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Approtect {{ pall: {:?} }}", self.pall())
}
}
#[doc = "Processor debug control."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Debugctrl(pub u32);
impl Debugctrl {
#[doc = "Configure CPU flash patch and breakpoint (FPB) unit behavior."]
#[must_use]
#[inline(always)]
pub const fn cpufpben(&self) -> super::vals::Cpufpben {
let val = (self.0 >> 8usize) & 0xff;
super::vals::Cpufpben::from_bits(val as u8)
}
#[doc = "Configure CPU flash patch and breakpoint (FPB) unit behavior."]
#[inline(always)]
pub const fn set_cpufpben(&mut self, val: super::vals::Cpufpben) {
self.0 = (self.0 & !(0xff << 8usize)) | (((val.to_bits() as u32) & 0xff) << 8usize);
}
}
impl Default for Debugctrl {
#[inline(always)]
fn default() -> Debugctrl {
Debugctrl(0)
}
}
impl core::fmt::Debug for Debugctrl {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Debugctrl")
.field("cpufpben", &self.cpufpben())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Debugctrl {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Debugctrl {{ cpufpben: {:?} }}", self.cpufpben())
}
}
#[doc = "Output voltage from REG0 regulator stage. The maximum output voltage from this stage is given as VDDH - V_VDDH-VDD."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Regout0(pub u32);
impl Regout0 {
#[doc = "Output voltage from REG0 regulator stage."]
#[must_use]
#[inline(always)]
pub const fn vout(&self) -> super::vals::Vout {
let val = (self.0 >> 0usize) & 0x07;
super::vals::Vout::from_bits(val as u8)
}
#[doc = "Output voltage from REG0 regulator stage."]
#[inline(always)]
pub const fn set_vout(&mut self, val: super::vals::Vout) {
self.0 = (self.0 & !(0x07 << 0usize)) | (((val.to_bits() as u32) & 0x07) << 0usize);
}
}
impl Default for Regout0 {
#[inline(always)]
fn default() -> Regout0 {
Regout0(0)
}
}
impl core::fmt::Debug for Regout0 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Regout0")
.field("vout", &self.vout())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Regout0 {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Regout0 {{ vout: {:?} }}", self.vout())
}
}
}
pub mod vals {
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct Cpufpben(u8);
impl Cpufpben {
#[doc = "Disable CPU FPB unit. Writes into the FPB registers will be ignored."]
pub const Disabled: Self = Self(0x0);
#[doc = "Enable CPU FPB unit (default behavior)."]
pub const Enabled: Self = Self(0xff);
}
impl Cpufpben {
pub const fn from_bits(val: u8) -> Cpufpben {
Self(val & 0xff)
}
pub const fn to_bits(self) -> u8 {
self.0
}
}
impl core::fmt::Debug for Cpufpben {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self.0 {
0x0 => f.write_str("Disabled"),
0xff => f.write_str("Enabled"),
other => core::write!(f, "0x{:02X}", other),
}
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Cpufpben {
fn format(&self, f: defmt::Formatter) {
match self.0 {
0x0 => defmt::write!(f, "Disabled"),
0xff => defmt::write!(f, "Enabled"),
other => defmt::write!(f, "0x{:02X}", other),
}
}
}
impl From<u8> for Cpufpben {
#[inline(always)]
fn from(val: u8) -> Cpufpben {
Cpufpben::from_bits(val)
}
}
impl From<Cpufpben> for u8 {
#[inline(always)]
fn from(val: Cpufpben) -> u8 {
Cpufpben::to_bits(val)
}
}
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct Pall(u8);
impl Pall {
#[doc = "Enable."]
pub const Enabled: Self = Self(0x0);
#[doc = "Hardware disable of access port protection for devices where access port protection is controlled by hardware and software."]
pub const HwDisabled: Self = Self(0x5a);
#[doc = "Hardware disable of access port protection for devices where access port protection is controlled by hardware."]
pub const Disabled: Self = Self(0xff);
}
impl Pall {
pub const fn from_bits(val: u8) -> Pall {
Self(val & 0xff)
}
pub const fn to_bits(self) -> u8 {
self.0
}
}
impl core::fmt::Debug for Pall {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self.0 {
0x0 => f.write_str("Enabled"),
0x5a => f.write_str("HwDisabled"),
0xff => f.write_str("Disabled"),
other => core::write!(f, "0x{:02X}", other),
}
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Pall {
fn format(&self, f: defmt::Formatter) {
match self.0 {
0x0 => defmt::write!(f, "Enabled"),
0x5a => defmt::write!(f, "HwDisabled"),
0xff => defmt::write!(f, "Disabled"),
other => defmt::write!(f, "0x{:02X}", other),
}
}
}
impl From<u8> for Pall {
#[inline(always)]
fn from(val: u8) -> Pall {
Pall::from_bits(val)
}
}
impl From<Pall> for u8 {
#[inline(always)]
fn from(val: Pall) -> u8 {
Pall::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Vout {
#[doc = "1.8 V."]
_1v8 = 0x0,
#[doc = "2.1 V."]
_2v1 = 0x01,
#[doc = "2.4 V."]
_2v4 = 0x02,
#[doc = "2.7 V."]
_2v7 = 0x03,
#[doc = "3.0 V."]
_3v0 = 0x04,
#[doc = "3.3 V."]
_3v3 = 0x05,
_RESERVED_6 = 0x06,
#[doc = "Default voltage: 1.8 V."]
Default = 0x07,
}
impl Vout {
#[inline(always)]
pub const fn from_bits(val: u8) -> Vout {
unsafe { core::mem::transmute(val & 0x07) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Vout {
#[inline(always)]
fn from(val: u8) -> Vout {
Vout::from_bits(val)
}
}
impl From<Vout> for u8 {
#[inline(always)]
fn from(val: Vout) -> u8 {
Vout::to_bits(val)
}
}
}
}
pub mod usbd {
#[doc = "Unspecified."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Epin {
ptr: *mut u8,
}
unsafe impl Send for Epin {}
unsafe impl Sync for Epin {}
impl Epin {
#[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 = "Description cluster: Data pointer."]
#[inline(always)]
pub const fn ptr(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Description cluster: Maximum number of bytes to transfer."]
#[inline(always)]
pub const fn maxcnt(self) -> crate::common::Reg<regs::EpinMaxcnt, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Description cluster: Number of bytes transferred in the last transaction."]
#[inline(always)]
pub const fn amount(self) -> crate::common::Reg<regs::EpinAmount, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
}
#[doc = "Unspecified."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Epout {
ptr: *mut u8,
}
unsafe impl Send for Epout {}
unsafe impl Sync for Epout {}
impl Epout {
#[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 = "Description cluster: Data pointer."]
#[inline(always)]
pub const fn ptr(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Description cluster: Maximum number of bytes to transfer."]
#[inline(always)]
pub const fn maxcnt(self) -> crate::common::Reg<regs::EpoutMaxcnt, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Description cluster: Number of bytes transferred in the last transaction."]
#[inline(always)]
pub const fn amount(self) -> crate::common::Reg<regs::EpoutAmount, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
}
#[doc = "Unspecified."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Halted {
ptr: *mut u8,
}
unsafe impl Send for Halted {}
unsafe impl Sync for Halted {}
impl Halted {
#[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 = "Description collection: IN endpoint halted status. Can be used as is as response to a GetStatus() request to endpoint."]
#[inline(always)]
pub const fn epin(self, n: usize) -> crate::common::Reg<regs::Epin, crate::common::R> {
assert!(n < 8usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize + n * 4usize) as _)
}
}
#[doc = "Description collection: OUT endpoint halted status. Can be used as is as response to a GetStatus() request to endpoint."]
#[inline(always)]
pub const fn epout(
self,
n: usize,
) -> crate::common::Reg<regs::HaltedEpout, crate::common::R> {
assert!(n < 8usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x24usize + n * 4usize) as _)
}
}
}
#[doc = "Unspecified."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Isoin {
ptr: *mut u8,
}
unsafe impl Send for Isoin {}
unsafe impl Sync for Isoin {}
impl Isoin {
#[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 = "Data pointer."]
#[inline(always)]
pub const fn ptr(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Maximum number of bytes to transfer."]
#[inline(always)]
pub const fn maxcnt(self) -> crate::common::Reg<regs::IsoinMaxcnt, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Number of bytes transferred in the last transaction."]
#[inline(always)]
pub const fn amount(self) -> crate::common::Reg<regs::IsoinAmount, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
}
#[doc = "Unspecified."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Isoout {
ptr: *mut u8,
}
unsafe impl Send for Isoout {}
unsafe impl Sync for Isoout {}
impl Isoout {
#[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 = "Data pointer."]
#[inline(always)]
pub const fn ptr(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Maximum number of bytes to transfer."]
#[inline(always)]
pub const fn maxcnt(self) -> crate::common::Reg<regs::IsooutMaxcnt, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Number of bytes transferred in the last transaction."]
#[inline(always)]
pub const fn amount(self) -> crate::common::Reg<regs::IsooutAmount, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
}
#[doc = "Unspecified."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Size {
ptr: *mut u8,
}
unsafe impl Send for Size {}
unsafe impl Sync for Size {}
impl Size {
#[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 = "Description collection: Number of bytes received last in the data stage of this OUT endpoint."]
#[inline(always)]
pub const fn epout(
self,
n: usize,
) -> crate::common::Reg<regs::SizeEpout, crate::common::RW> {
assert!(n < 8usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize + n * 4usize) as _)
}
}
#[doc = "Number of bytes received last on this ISO OUT data endpoint."]
#[inline(always)]
pub const fn isoout(self) -> crate::common::Reg<regs::Isoout, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x20usize) as _) }
}
}
#[doc = "Universal serial bus device."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Usbd {
ptr: *mut u8,
}
unsafe impl Send for Usbd {}
unsafe impl Sync for Usbd {}
impl Usbd {
#[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 = "Description collection: Captures the EPIN\\[n\\].PTR and EPIN\\[n\\].MAXCNT registers values, and enables endpoint IN n to respond to traffic from host."]
#[inline(always)]
pub const fn tasks_startepin(self, n: usize) -> crate::common::Reg<u32, crate::common::W> {
assert!(n < 8usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize + n * 4usize) as _)
}
}
#[doc = "Captures the ISOIN.PTR and ISOIN.MAXCNT registers values, and enables sending data on ISO endpoint."]
#[inline(always)]
pub const fn tasks_startisoin(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x24usize) as _) }
}
#[doc = "Description collection: Captures the EPOUT\\[n\\].PTR and EPOUT\\[n\\].MAXCNT registers values, and enables endpoint n to respond to traffic from host."]
#[inline(always)]
pub const fn tasks_startepout(self, n: usize) -> crate::common::Reg<u32, crate::common::W> {
assert!(n < 8usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x28usize + n * 4usize) as _)
}
}
#[doc = "Captures the ISOOUT.PTR and ISOOUT.MAXCNT registers values, and enables receiving of data on ISO endpoint."]
#[inline(always)]
pub const fn tasks_startisoout(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x48usize) as _) }
}
#[doc = "Allows OUT data stage on control endpoint 0."]
#[inline(always)]
pub const fn tasks_ep0rcvout(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x4cusize) as _) }
}
#[doc = "Allows status stage on control endpoint 0."]
#[inline(always)]
pub const fn tasks_ep0status(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x50usize) as _) }
}
#[doc = "Stalls data and status stage on control endpoint 0."]
#[inline(always)]
pub const fn tasks_ep0stall(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x54usize) as _) }
}
#[doc = "Forces D+ and D- lines into the state defined in the DPDMVALUE register."]
#[inline(always)]
pub const fn tasks_dpdmdrive(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x58usize) as _) }
}
#[doc = "Stops forcing D+ and D- lines into any state (USB engine takes control)."]
#[inline(always)]
pub const fn tasks_dpdmnodrive(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x5cusize) as _) }
}
#[doc = "Signals that a USB reset condition has been detected on USB lines."]
#[inline(always)]
pub const fn events_usbreset(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0100usize) as _) }
}
#[doc = "Confirms that the EPIN\\[n\\].PTR and EPIN\\[n\\].MAXCNT, or EPOUT\\[n\\].PTR and EPOUT\\[n\\].MAXCNT registers have been captured on all endpoints reported in the EPSTATUS register."]
#[inline(always)]
pub const fn events_started(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0104usize) as _) }
}
#[doc = "Description collection: The whole EPIN\\[n\\] buffer has been consumed. The buffer can be accessed safely by software."]
#[inline(always)]
pub const fn events_endepin(self, n: usize) -> crate::common::Reg<u32, crate::common::RW> {
assert!(n < 8usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0108usize + n * 4usize) as _)
}
}
#[doc = "An acknowledged data transfer has taken place on the control endpoint."]
#[inline(always)]
pub const fn events_ep0datadone(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0128usize) as _) }
}
#[doc = "The whole ISOIN buffer has been consumed. The buffer can be accessed safely by software."]
#[inline(always)]
pub const fn events_endisoin(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x012cusize) as _) }
}
#[doc = "Description collection: The whole EPOUT\\[n\\] buffer has been consumed. The buffer can be accessed safely by software."]
#[inline(always)]
pub const fn events_endepout(self, n: usize) -> crate::common::Reg<u32, crate::common::RW> {
assert!(n < 8usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0130usize + n * 4usize) as _)
}
}
#[doc = "The whole ISOOUT buffer has been consumed. The buffer can be accessed safely by software."]
#[inline(always)]
pub const fn events_endisoout(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0150usize) as _) }
}
#[doc = "Signals that a SOF (start of frame) condition has been detected on USB lines."]
#[inline(always)]
pub const fn events_sof(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0154usize) as _) }
}
#[doc = "An event or an error not covered by specific events has occurred. Check EVENTCAUSE register to find the cause."]
#[inline(always)]
pub const fn events_usbevent(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0158usize) as _) }
}
#[doc = "A valid SETUP token has been received (and acknowledged) on the control endpoint."]
#[inline(always)]
pub const fn events_ep0setup(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x015cusize) as _) }
}
#[doc = "A data transfer has occurred on a data endpoint, indicated by the EPDATASTATUS register."]
#[inline(always)]
pub const fn events_epdata(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0160usize) as _) }
}
#[doc = "Shortcuts between local events and tasks."]
#[inline(always)]
pub const fn shorts(self) -> crate::common::Reg<regs::Shorts, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0200usize) as _) }
}
#[doc = "Enable or disable interrupt."]
#[inline(always)]
pub const fn inten(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0300usize) as _) }
}
#[doc = "Enable interrupt."]
#[inline(always)]
pub const fn intenset(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0304usize) as _) }
}
#[doc = "Disable interrupt."]
#[inline(always)]
pub const fn intenclr(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0308usize) as _) }
}
#[doc = "Details on what caused the USBEVENT event."]
#[inline(always)]
pub const fn eventcause(self) -> crate::common::Reg<regs::Eventcause, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0400usize) as _) }
}
#[doc = "Unspecified."]
#[inline(always)]
pub const fn halted(self) -> Halted {
unsafe { Halted::from_ptr(self.ptr.wrapping_add(0x0420usize) as _) }
}
#[doc = "Provides information on which endpoint's EasyDMA registers have been captured."]
#[inline(always)]
pub const fn epstatus(self) -> crate::common::Reg<regs::Epstatus, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0468usize) as _) }
}
#[doc = "Provides information on which endpoint(s) an acknowledged data transfer has occurred (EPDATA event)."]
#[inline(always)]
pub const fn epdatastatus(
self,
) -> crate::common::Reg<regs::Epdatastatus, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x046cusize) as _) }
}
#[doc = "Device USB address."]
#[inline(always)]
pub const fn usbaddr(self) -> crate::common::Reg<regs::Usbaddr, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0470usize) as _) }
}
#[doc = "SETUP data, byte 0, bmRequestType."]
#[inline(always)]
pub const fn bmrequesttype(
self,
) -> crate::common::Reg<regs::Bmrequesttype, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0480usize) as _) }
}
#[doc = "SETUP data, byte 1, bRequest."]
#[inline(always)]
pub const fn brequest(self) -> crate::common::Reg<regs::Brequest, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0484usize) as _) }
}
#[doc = "SETUP data, byte 2, LSB of wValue."]
#[inline(always)]
pub const fn wvaluel(self) -> crate::common::Reg<regs::Wvaluel, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0488usize) as _) }
}
#[doc = "SETUP data, byte 3, MSB of wValue."]
#[inline(always)]
pub const fn wvalueh(self) -> crate::common::Reg<regs::Wvalueh, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x048cusize) as _) }
}
#[doc = "SETUP data, byte 4, LSB of wIndex."]
#[inline(always)]
pub const fn windexl(self) -> crate::common::Reg<regs::Windexl, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0490usize) as _) }
}
#[doc = "SETUP data, byte 5, MSB of wIndex."]
#[inline(always)]
pub const fn windexh(self) -> crate::common::Reg<regs::Windexh, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0494usize) as _) }
}
#[doc = "SETUP data, byte 6, LSB of wLength."]
#[inline(always)]
pub const fn wlengthl(self) -> crate::common::Reg<regs::Wlengthl, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0498usize) as _) }
}
#[doc = "SETUP data, byte 7, MSB of wLength."]
#[inline(always)]
pub const fn wlengthh(self) -> crate::common::Reg<regs::Wlengthh, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x049cusize) as _) }
}
#[doc = "Unspecified."]
#[inline(always)]
pub const fn size(self) -> Size {
unsafe { Size::from_ptr(self.ptr.wrapping_add(0x04a0usize) as _) }
}
#[doc = "Enable USB."]
#[inline(always)]
pub const fn enable(self) -> crate::common::Reg<regs::Enable, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0500usize) as _) }
}
#[doc = "Control of the USB pull-up."]
#[inline(always)]
pub const fn usbpullup(self) -> crate::common::Reg<regs::Usbpullup, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0504usize) as _) }
}
#[doc = "State D+ and D- lines will be forced into by the DPDMDRIVE task. The DPDMNODRIVE task reverts the control of the lines to MAC IP (no forcing)."]
#[inline(always)]
pub const fn dpdmvalue(self) -> crate::common::Reg<regs::Dpdmvalue, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0508usize) as _) }
}
#[doc = "Data toggle control and status."]
#[inline(always)]
pub const fn dtoggle(self) -> crate::common::Reg<regs::Dtoggle, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x050cusize) as _) }
}
#[doc = "Endpoint IN enable."]
#[inline(always)]
pub const fn epinen(self) -> crate::common::Reg<regs::Epinen, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0510usize) as _) }
}
#[doc = "Endpoint OUT enable."]
#[inline(always)]
pub const fn epouten(self) -> crate::common::Reg<regs::Epouten, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0514usize) as _) }
}
#[doc = "STALL endpoints."]
#[inline(always)]
pub const fn epstall(self) -> crate::common::Reg<regs::Epstall, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0518usize) as _) }
}
#[doc = "Controls the split of ISO buffers."]
#[inline(always)]
pub const fn isosplit(self) -> crate::common::Reg<regs::Isosplit, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x051cusize) as _) }
}
#[doc = "Returns the current value of the start of frame counter."]
#[inline(always)]
pub const fn framecntr(self) -> crate::common::Reg<regs::Framecntr, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0520usize) as _) }
}
#[doc = "Controls USBD peripheral low power mode during USB suspend."]
#[inline(always)]
pub const fn lowpower(self) -> crate::common::Reg<regs::Lowpower, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x052cusize) as _) }
}
#[doc = "Controls the response of the ISO IN endpoint to an IN token when no data is ready to be sent."]
#[inline(always)]
pub const fn isoinconfig(self) -> crate::common::Reg<regs::Isoinconfig, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0530usize) as _) }
}
#[doc = "Unspecified."]
#[inline(always)]
pub const fn epin(self, n: usize) -> Epin {
assert!(n < 8usize);
unsafe { Epin::from_ptr(self.ptr.wrapping_add(0x0600usize + n * 20usize) as _) }
}
#[doc = "Unspecified."]
#[inline(always)]
pub const fn isoin(self) -> Isoin {
unsafe { Isoin::from_ptr(self.ptr.wrapping_add(0x06a0usize) as _) }
}
#[doc = "Unspecified."]
#[inline(always)]
pub const fn epout(self, n: usize) -> Epout {
assert!(n < 8usize);
unsafe { Epout::from_ptr(self.ptr.wrapping_add(0x0700usize + n * 20usize) as _) }
}
#[doc = "Unspecified."]
#[inline(always)]
pub const fn isoout(self) -> Isoout {
unsafe { Isoout::from_ptr(self.ptr.wrapping_add(0x07a0usize) as _) }
}
}
pub mod regs {
#[doc = "SETUP data, byte 0, bmRequestType."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Bmrequesttype(pub u32);
impl Bmrequesttype {
#[doc = "Data transfer type."]
#[must_use]
#[inline(always)]
pub const fn recipient(&self) -> super::vals::Recipient {
let val = (self.0 >> 0usize) & 0x1f;
super::vals::Recipient::from_bits(val as u8)
}
#[doc = "Data transfer type."]
#[inline(always)]
pub const fn set_recipient(&mut self, val: super::vals::Recipient) {
self.0 = (self.0 & !(0x1f << 0usize)) | (((val.to_bits() as u32) & 0x1f) << 0usize);
}
#[doc = "Data transfer type."]
#[must_use]
#[inline(always)]
pub const fn type_(&self) -> super::vals::Type {
let val = (self.0 >> 5usize) & 0x03;
super::vals::Type::from_bits(val as u8)
}
#[doc = "Data transfer type."]
#[inline(always)]
pub const fn set_type_(&mut self, val: super::vals::Type) {
self.0 = (self.0 & !(0x03 << 5usize)) | (((val.to_bits() as u32) & 0x03) << 5usize);
}
#[doc = "Data transfer direction."]
#[must_use]
#[inline(always)]
pub const fn direction(&self) -> super::vals::Io {
let val = (self.0 >> 7usize) & 0x01;
super::vals::Io::from_bits(val as u8)
}
#[doc = "Data transfer direction."]
#[inline(always)]
pub const fn set_direction(&mut self, val: super::vals::Io) {
self.0 = (self.0 & !(0x01 << 7usize)) | (((val.to_bits() as u32) & 0x01) << 7usize);
}
}
impl Default for Bmrequesttype {
#[inline(always)]
fn default() -> Bmrequesttype {
Bmrequesttype(0)
}
}
impl core::fmt::Debug for Bmrequesttype {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Bmrequesttype")
.field("recipient", &self.recipient())
.field("type_", &self.type_())
.field("direction", &self.direction())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Bmrequesttype {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Bmrequesttype {{ recipient: {:?}, type_: {:?}, direction: {:?} }}",
self.recipient(),
self.type_(),
self.direction()
)
}
}
#[doc = "SETUP data, byte 1, bRequest."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Brequest(pub u32);
impl Brequest {
#[doc = "SETUP data, byte 1, bRequest. Values provided for standard requests only, user must implement class and vendor values."]
#[must_use]
#[inline(always)]
pub const fn brequest(&self) -> super::vals::Brequest {
let val = (self.0 >> 0usize) & 0xff;
super::vals::Brequest::from_bits(val as u8)
}
#[doc = "SETUP data, byte 1, bRequest. Values provided for standard requests only, user must implement class and vendor values."]
#[inline(always)]
pub const fn set_brequest(&mut self, val: super::vals::Brequest) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val.to_bits() as u32) & 0xff) << 0usize);
}
}
impl Default for Brequest {
#[inline(always)]
fn default() -> Brequest {
Brequest(0)
}
}
impl core::fmt::Debug for Brequest {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Brequest")
.field("brequest", &self.brequest())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Brequest {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Brequest {{ brequest: {:?} }}", self.brequest())
}
}
#[doc = "State D+ and D- lines will be forced into by the DPDMDRIVE task. The DPDMNODRIVE task reverts the control of the lines to MAC IP (no forcing)."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Dpdmvalue(pub u32);
impl Dpdmvalue {
#[doc = "State D+ and D- lines will be forced into by the DPDMDRIVE task."]
#[must_use]
#[inline(always)]
pub const fn state(&self) -> super::vals::State {
let val = (self.0 >> 0usize) & 0x1f;
super::vals::State::from_bits(val as u8)
}
#[doc = "State D+ and D- lines will be forced into by the DPDMDRIVE task."]
#[inline(always)]
pub const fn set_state(&mut self, val: super::vals::State) {
self.0 = (self.0 & !(0x1f << 0usize)) | (((val.to_bits() as u32) & 0x1f) << 0usize);
}
}
impl Default for Dpdmvalue {
#[inline(always)]
fn default() -> Dpdmvalue {
Dpdmvalue(0)
}
}
impl core::fmt::Debug for Dpdmvalue {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Dpdmvalue")
.field("state", &self.state())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Dpdmvalue {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Dpdmvalue {{ state: {:?} }}", self.state())
}
}
#[doc = "Data toggle control and status."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Dtoggle(pub u32);
impl Dtoggle {
#[doc = "Select bulk endpoint number."]
#[must_use]
#[inline(always)]
pub const fn ep(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x07;
val as u8
}
#[doc = "Select bulk endpoint number."]
#[inline(always)]
pub const fn set_ep(&mut self, val: u8) {
self.0 = (self.0 & !(0x07 << 0usize)) | (((val as u32) & 0x07) << 0usize);
}
#[doc = "Selects IN or OUT endpoint."]
#[must_use]
#[inline(always)]
pub const fn io(&self) -> super::vals::Io {
let val = (self.0 >> 7usize) & 0x01;
super::vals::Io::from_bits(val as u8)
}
#[doc = "Selects IN or OUT endpoint."]
#[inline(always)]
pub const fn set_io(&mut self, val: super::vals::Io) {
self.0 = (self.0 & !(0x01 << 7usize)) | (((val.to_bits() as u32) & 0x01) << 7usize);
}
#[doc = "Data toggle value."]
#[must_use]
#[inline(always)]
pub const fn value(&self) -> super::vals::Value {
let val = (self.0 >> 8usize) & 0x03;
super::vals::Value::from_bits(val as u8)
}
#[doc = "Data toggle value."]
#[inline(always)]
pub const fn set_value(&mut self, val: super::vals::Value) {
self.0 = (self.0 & !(0x03 << 8usize)) | (((val.to_bits() as u32) & 0x03) << 8usize);
}
}
impl Default for Dtoggle {
#[inline(always)]
fn default() -> Dtoggle {
Dtoggle(0)
}
}
impl core::fmt::Debug for Dtoggle {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Dtoggle")
.field("ep", &self.ep())
.field("io", &self.io())
.field("value", &self.value())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Dtoggle {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Dtoggle {{ ep: {=u8:?}, io: {:?}, value: {:?} }}",
self.ep(),
self.io(),
self.value()
)
}
}
#[doc = "Enable USB."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Enable(pub u32);
impl Enable {
#[doc = "Enable USB."]
#[must_use]
#[inline(always)]
pub const fn enable(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Enable USB."]
#[inline(always)]
pub const fn set_enable(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for Enable {
#[inline(always)]
fn default() -> Enable {
Enable(0)
}
}
impl core::fmt::Debug for Enable {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Enable")
.field("enable", &self.enable())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Enable {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Enable {{ enable: {=bool:?} }}", self.enable())
}
}
#[doc = "Provides information on which endpoint(s) an acknowledged data transfer has occurred (EPDATA event)."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Epdatastatus(pub u32);
impl Epdatastatus {
#[doc = "Acknowledged data transfer on this IN endpoint. Write '1' to clear."]
#[must_use]
#[inline(always)]
pub const fn epin(&self, n: usize) -> bool {
assert!(n < 7usize);
let offs = 1usize + n * 1usize;
let val = (self.0 >> offs) & 0x01;
val != 0
}
#[doc = "Acknowledged data transfer on this IN endpoint. Write '1' to clear."]
#[inline(always)]
pub const fn set_epin(&mut self, n: usize, val: bool) {
assert!(n < 7usize);
let offs = 1usize + n * 1usize;
self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
}
#[doc = "Acknowledged data transfer on this OUT endpoint. Write '1' to clear."]
#[must_use]
#[inline(always)]
pub const fn epout(&self, n: usize) -> bool {
assert!(n < 7usize);
let offs = 17usize + n * 1usize;
let val = (self.0 >> offs) & 0x01;
val != 0
}
#[doc = "Acknowledged data transfer on this OUT endpoint. Write '1' to clear."]
#[inline(always)]
pub const fn set_epout(&mut self, n: usize, val: bool) {
assert!(n < 7usize);
let offs = 17usize + n * 1usize;
self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
}
}
impl Default for Epdatastatus {
#[inline(always)]
fn default() -> Epdatastatus {
Epdatastatus(0)
}
}
impl core::fmt::Debug for Epdatastatus {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Epdatastatus")
.field("epin[0]", &self.epin(0usize))
.field("epin[1]", &self.epin(1usize))
.field("epin[2]", &self.epin(2usize))
.field("epin[3]", &self.epin(3usize))
.field("epin[4]", &self.epin(4usize))
.field("epin[5]", &self.epin(5usize))
.field("epin[6]", &self.epin(6usize))
.field("epout[0]", &self.epout(0usize))
.field("epout[1]", &self.epout(1usize))
.field("epout[2]", &self.epout(2usize))
.field("epout[3]", &self.epout(3usize))
.field("epout[4]", &self.epout(4usize))
.field("epout[5]", &self.epout(5usize))
.field("epout[6]", &self.epout(6usize))
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Epdatastatus {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Epdatastatus {{ epin[0]: {=bool:?}, epin[1]: {=bool:?}, epin[2]: {=bool:?}, epin[3]: {=bool:?}, epin[4]: {=bool:?}, epin[5]: {=bool:?}, epin[6]: {=bool:?}, epout[0]: {=bool:?}, epout[1]: {=bool:?}, epout[2]: {=bool:?}, epout[3]: {=bool:?}, epout[4]: {=bool:?}, epout[5]: {=bool:?}, epout[6]: {=bool:?} }}" , self . epin (0usize) , self . epin (1usize) , self . epin (2usize) , self . epin (3usize) , self . epin (4usize) , self . epin (5usize) , self . epin (6usize) , self . epout (0usize) , self . epout (1usize) , self . epout (2usize) , self . epout (3usize) , self . epout (4usize) , self . epout (5usize) , self . epout (6usize))
}
}
#[doc = "Description collection: IN endpoint halted status. Can be used as is as response to a GetStatus() request to endpoint."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Epin(pub u32);
impl Epin {
#[doc = "IN endpoint halted status. Can be used as is as response to a GetStatus() request to endpoint."]
#[must_use]
#[inline(always)]
pub const fn getstatus(&self) -> super::vals::Getstatus {
let val = (self.0 >> 0usize) & 0xffff;
super::vals::Getstatus::from_bits(val as u16)
}
#[doc = "IN endpoint halted status. Can be used as is as response to a GetStatus() request to endpoint."]
#[inline(always)]
pub const fn set_getstatus(&mut self, val: super::vals::Getstatus) {
self.0 =
(self.0 & !(0xffff << 0usize)) | (((val.to_bits() as u32) & 0xffff) << 0usize);
}
}
impl Default for Epin {
#[inline(always)]
fn default() -> Epin {
Epin(0)
}
}
impl core::fmt::Debug for Epin {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Epin")
.field("getstatus", &self.getstatus())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Epin {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Epin {{ getstatus: {:?} }}", self.getstatus())
}
}
#[doc = "Description cluster: Number of bytes transferred in the last transaction."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct EpinAmount(pub u32);
impl EpinAmount {
#[doc = "Number of bytes transferred in the last transaction."]
#[must_use]
#[inline(always)]
pub const fn amount(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x7f;
val as u8
}
#[doc = "Number of bytes transferred in the last transaction."]
#[inline(always)]
pub const fn set_amount(&mut self, val: u8) {
self.0 = (self.0 & !(0x7f << 0usize)) | (((val as u32) & 0x7f) << 0usize);
}
}
impl Default for EpinAmount {
#[inline(always)]
fn default() -> EpinAmount {
EpinAmount(0)
}
}
impl core::fmt::Debug for EpinAmount {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("EpinAmount")
.field("amount", &self.amount())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for EpinAmount {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "EpinAmount {{ amount: {=u8:?} }}", self.amount())
}
}
#[doc = "Description cluster: Maximum number of bytes to transfer."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct EpinMaxcnt(pub u32);
impl EpinMaxcnt {
#[doc = "Maximum number of bytes to transfer."]
#[must_use]
#[inline(always)]
pub const fn maxcnt(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x7f;
val as u8
}
#[doc = "Maximum number of bytes to transfer."]
#[inline(always)]
pub const fn set_maxcnt(&mut self, val: u8) {
self.0 = (self.0 & !(0x7f << 0usize)) | (((val as u32) & 0x7f) << 0usize);
}
}
impl Default for EpinMaxcnt {
#[inline(always)]
fn default() -> EpinMaxcnt {
EpinMaxcnt(0)
}
}
impl core::fmt::Debug for EpinMaxcnt {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("EpinMaxcnt")
.field("maxcnt", &self.maxcnt())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for EpinMaxcnt {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "EpinMaxcnt {{ maxcnt: {=u8:?} }}", self.maxcnt())
}
}
#[doc = "Endpoint IN enable."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Epinen(pub u32);
impl Epinen {
#[doc = "Enable IN endpoint 0."]
#[must_use]
#[inline(always)]
pub const fn in_(&self, n: usize) -> bool {
assert!(n < 8usize);
let offs = 0usize + n * 1usize;
let val = (self.0 >> offs) & 0x01;
val != 0
}
#[doc = "Enable IN endpoint 0."]
#[inline(always)]
pub const fn set_in_(&mut self, n: usize, val: bool) {
assert!(n < 8usize);
let offs = 0usize + n * 1usize;
self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
}
#[doc = "Enable ISO IN endpoint."]
#[must_use]
#[inline(always)]
pub const fn isoin(&self) -> bool {
let val = (self.0 >> 8usize) & 0x01;
val != 0
}
#[doc = "Enable ISO IN endpoint."]
#[inline(always)]
pub const fn set_isoin(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize);
}
}
impl Default for Epinen {
#[inline(always)]
fn default() -> Epinen {
Epinen(0)
}
}
impl core::fmt::Debug for Epinen {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Epinen")
.field("in_[0]", &self.in_(0usize))
.field("in_[1]", &self.in_(1usize))
.field("in_[2]", &self.in_(2usize))
.field("in_[3]", &self.in_(3usize))
.field("in_[4]", &self.in_(4usize))
.field("in_[5]", &self.in_(5usize))
.field("in_[6]", &self.in_(6usize))
.field("in_[7]", &self.in_(7usize))
.field("isoin", &self.isoin())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Epinen {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Epinen {{ in_[0]: {=bool:?}, in_[1]: {=bool:?}, in_[2]: {=bool:?}, in_[3]: {=bool:?}, in_[4]: {=bool:?}, in_[5]: {=bool:?}, in_[6]: {=bool:?}, in_[7]: {=bool:?}, isoin: {=bool:?} }}" , self . in_ (0usize) , self . in_ (1usize) , self . in_ (2usize) , self . in_ (3usize) , self . in_ (4usize) , self . in_ (5usize) , self . in_ (6usize) , self . in_ (7usize) , self . isoin ())
}
}
#[doc = "Description cluster: Number of bytes transferred in the last transaction."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct EpoutAmount(pub u32);
impl EpoutAmount {
#[doc = "Number of bytes transferred in the last transaction."]
#[must_use]
#[inline(always)]
pub const fn amount(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x7f;
val as u8
}
#[doc = "Number of bytes transferred in the last transaction."]
#[inline(always)]
pub const fn set_amount(&mut self, val: u8) {
self.0 = (self.0 & !(0x7f << 0usize)) | (((val as u32) & 0x7f) << 0usize);
}
}
impl Default for EpoutAmount {
#[inline(always)]
fn default() -> EpoutAmount {
EpoutAmount(0)
}
}
impl core::fmt::Debug for EpoutAmount {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("EpoutAmount")
.field("amount", &self.amount())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for EpoutAmount {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "EpoutAmount {{ amount: {=u8:?} }}", self.amount())
}
}
#[doc = "Description cluster: Maximum number of bytes to transfer."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct EpoutMaxcnt(pub u32);
impl EpoutMaxcnt {
#[doc = "Maximum number of bytes to transfer."]
#[must_use]
#[inline(always)]
pub const fn maxcnt(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x7f;
val as u8
}
#[doc = "Maximum number of bytes to transfer."]
#[inline(always)]
pub const fn set_maxcnt(&mut self, val: u8) {
self.0 = (self.0 & !(0x7f << 0usize)) | (((val as u32) & 0x7f) << 0usize);
}
}
impl Default for EpoutMaxcnt {
#[inline(always)]
fn default() -> EpoutMaxcnt {
EpoutMaxcnt(0)
}
}
impl core::fmt::Debug for EpoutMaxcnt {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("EpoutMaxcnt")
.field("maxcnt", &self.maxcnt())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for EpoutMaxcnt {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "EpoutMaxcnt {{ maxcnt: {=u8:?} }}", self.maxcnt())
}
}
#[doc = "Endpoint OUT enable."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Epouten(pub u32);
impl Epouten {
#[doc = "Enable OUT endpoint 0."]
#[must_use]
#[inline(always)]
pub const fn out(&self, n: usize) -> bool {
assert!(n < 8usize);
let offs = 0usize + n * 1usize;
let val = (self.0 >> offs) & 0x01;
val != 0
}
#[doc = "Enable OUT endpoint 0."]
#[inline(always)]
pub const fn set_out(&mut self, n: usize, val: bool) {
assert!(n < 8usize);
let offs = 0usize + n * 1usize;
self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
}
#[doc = "Enable ISO OUT endpoint 8."]
#[must_use]
#[inline(always)]
pub const fn isoout(&self) -> bool {
let val = (self.0 >> 8usize) & 0x01;
val != 0
}
#[doc = "Enable ISO OUT endpoint 8."]
#[inline(always)]
pub const fn set_isoout(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize);
}
}
impl Default for Epouten {
#[inline(always)]
fn default() -> Epouten {
Epouten(0)
}
}
impl core::fmt::Debug for Epouten {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Epouten")
.field("out[0]", &self.out(0usize))
.field("out[1]", &self.out(1usize))
.field("out[2]", &self.out(2usize))
.field("out[3]", &self.out(3usize))
.field("out[4]", &self.out(4usize))
.field("out[5]", &self.out(5usize))
.field("out[6]", &self.out(6usize))
.field("out[7]", &self.out(7usize))
.field("isoout", &self.isoout())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Epouten {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Epouten {{ out[0]: {=bool:?}, out[1]: {=bool:?}, out[2]: {=bool:?}, out[3]: {=bool:?}, out[4]: {=bool:?}, out[5]: {=bool:?}, out[6]: {=bool:?}, out[7]: {=bool:?}, isoout: {=bool:?} }}" , self . out (0usize) , self . out (1usize) , self . out (2usize) , self . out (3usize) , self . out (4usize) , self . out (5usize) , self . out (6usize) , self . out (7usize) , self . isoout ())
}
}
#[doc = "STALL endpoints."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Epstall(pub u32);
impl Epstall {
#[doc = "Select endpoint number."]
#[must_use]
#[inline(always)]
pub const fn ep(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x07;
val as u8
}
#[doc = "Select endpoint number."]
#[inline(always)]
pub const fn set_ep(&mut self, val: u8) {
self.0 = (self.0 & !(0x07 << 0usize)) | (((val as u32) & 0x07) << 0usize);
}
#[doc = "Selects IN or OUT endpoint."]
#[must_use]
#[inline(always)]
pub const fn io(&self) -> super::vals::Io {
let val = (self.0 >> 7usize) & 0x01;
super::vals::Io::from_bits(val as u8)
}
#[doc = "Selects IN or OUT endpoint."]
#[inline(always)]
pub const fn set_io(&mut self, val: super::vals::Io) {
self.0 = (self.0 & !(0x01 << 7usize)) | (((val.to_bits() as u32) & 0x01) << 7usize);
}
#[doc = "Stall selected endpoint."]
#[must_use]
#[inline(always)]
pub const fn stall(&self) -> bool {
let val = (self.0 >> 8usize) & 0x01;
val != 0
}
#[doc = "Stall selected endpoint."]
#[inline(always)]
pub const fn set_stall(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize);
}
}
impl Default for Epstall {
#[inline(always)]
fn default() -> Epstall {
Epstall(0)
}
}
impl core::fmt::Debug for Epstall {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Epstall")
.field("ep", &self.ep())
.field("io", &self.io())
.field("stall", &self.stall())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Epstall {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Epstall {{ ep: {=u8:?}, io: {:?}, stall: {=bool:?} }}",
self.ep(),
self.io(),
self.stall()
)
}
}
#[doc = "Provides information on which endpoint's EasyDMA registers have been captured."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Epstatus(pub u32);
impl Epstatus {
#[doc = "Captured state of endpoint's EasyDMA registers. Write '1' to clear."]
#[must_use]
#[inline(always)]
pub const fn epin(&self, n: usize) -> bool {
assert!(n < 9usize);
let offs = 0usize + n * 1usize;
let val = (self.0 >> offs) & 0x01;
val != 0
}
#[doc = "Captured state of endpoint's EasyDMA registers. Write '1' to clear."]
#[inline(always)]
pub const fn set_epin(&mut self, n: usize, val: bool) {
assert!(n < 9usize);
let offs = 0usize + n * 1usize;
self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
}
#[doc = "Captured state of endpoint's EasyDMA registers. Write '1' to clear."]
#[must_use]
#[inline(always)]
pub const fn epout(&self, n: usize) -> bool {
assert!(n < 9usize);
let offs = 16usize + n * 1usize;
let val = (self.0 >> offs) & 0x01;
val != 0
}
#[doc = "Captured state of endpoint's EasyDMA registers. Write '1' to clear."]
#[inline(always)]
pub const fn set_epout(&mut self, n: usize, val: bool) {
assert!(n < 9usize);
let offs = 16usize + n * 1usize;
self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
}
}
impl Default for Epstatus {
#[inline(always)]
fn default() -> Epstatus {
Epstatus(0)
}
}
impl core::fmt::Debug for Epstatus {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Epstatus")
.field("epin[0]", &self.epin(0usize))
.field("epin[1]", &self.epin(1usize))
.field("epin[2]", &self.epin(2usize))
.field("epin[3]", &self.epin(3usize))
.field("epin[4]", &self.epin(4usize))
.field("epin[5]", &self.epin(5usize))
.field("epin[6]", &self.epin(6usize))
.field("epin[7]", &self.epin(7usize))
.field("epin[8]", &self.epin(8usize))
.field("epout[0]", &self.epout(0usize))
.field("epout[1]", &self.epout(1usize))
.field("epout[2]", &self.epout(2usize))
.field("epout[3]", &self.epout(3usize))
.field("epout[4]", &self.epout(4usize))
.field("epout[5]", &self.epout(5usize))
.field("epout[6]", &self.epout(6usize))
.field("epout[7]", &self.epout(7usize))
.field("epout[8]", &self.epout(8usize))
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Epstatus {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Epstatus {{ epin[0]: {=bool:?}, epin[1]: {=bool:?}, epin[2]: {=bool:?}, epin[3]: {=bool:?}, epin[4]: {=bool:?}, epin[5]: {=bool:?}, epin[6]: {=bool:?}, epin[7]: {=bool:?}, epin[8]: {=bool:?}, epout[0]: {=bool:?}, epout[1]: {=bool:?}, epout[2]: {=bool:?}, epout[3]: {=bool:?}, epout[4]: {=bool:?}, epout[5]: {=bool:?}, epout[6]: {=bool:?}, epout[7]: {=bool:?}, epout[8]: {=bool:?} }}" , self . epin (0usize) , self . epin (1usize) , self . epin (2usize) , self . epin (3usize) , self . epin (4usize) , self . epin (5usize) , self . epin (6usize) , self . epin (7usize) , self . epin (8usize) , self . epout (0usize) , self . epout (1usize) , self . epout (2usize) , self . epout (3usize) , self . epout (4usize) , self . epout (5usize) , self . epout (6usize) , self . epout (7usize) , self . epout (8usize))
}
}
#[doc = "Details on what caused the USBEVENT event."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Eventcause(pub u32);
impl Eventcause {
#[doc = "CRC error was detected on isochronous OUT endpoint 8. Write '1' to clear."]
#[must_use]
#[inline(always)]
pub const fn isooutcrc(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "CRC error was detected on isochronous OUT endpoint 8. Write '1' to clear."]
#[inline(always)]
pub const fn set_isooutcrc(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Signals that USB lines have been idle long enough for the device to enter suspend. Write '1' to clear."]
#[must_use]
#[inline(always)]
pub const fn suspend(&self) -> bool {
let val = (self.0 >> 8usize) & 0x01;
val != 0
}
#[doc = "Signals that USB lines have been idle long enough for the device to enter suspend. Write '1' to clear."]
#[inline(always)]
pub const fn set_suspend(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize);
}
#[doc = "Signals that a RESUME condition (K state or activity restart) has been detected on USB lines. Write '1' to clear."]
#[must_use]
#[inline(always)]
pub const fn resume(&self) -> bool {
let val = (self.0 >> 9usize) & 0x01;
val != 0
}
#[doc = "Signals that a RESUME condition (K state or activity restart) has been detected on USB lines. Write '1' to clear."]
#[inline(always)]
pub const fn set_resume(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 9usize)) | (((val as u32) & 0x01) << 9usize);
}
#[doc = "USB MAC has been woken up and operational. Write '1' to clear."]
#[must_use]
#[inline(always)]
pub const fn usbwuallowed(&self) -> bool {
let val = (self.0 >> 10usize) & 0x01;
val != 0
}
#[doc = "USB MAC has been woken up and operational. Write '1' to clear."]
#[inline(always)]
pub const fn set_usbwuallowed(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 10usize)) | (((val as u32) & 0x01) << 10usize);
}
#[doc = "USB device is ready for normal operation. Write '1' to clear."]
#[must_use]
#[inline(always)]
pub const fn ready(&self) -> bool {
let val = (self.0 >> 11usize) & 0x01;
val != 0
}
#[doc = "USB device is ready for normal operation. Write '1' to clear."]
#[inline(always)]
pub const fn set_ready(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 11usize)) | (((val as u32) & 0x01) << 11usize);
}
}
impl Default for Eventcause {
#[inline(always)]
fn default() -> Eventcause {
Eventcause(0)
}
}
impl core::fmt::Debug for Eventcause {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Eventcause")
.field("isooutcrc", &self.isooutcrc())
.field("suspend", &self.suspend())
.field("resume", &self.resume())
.field("usbwuallowed", &self.usbwuallowed())
.field("ready", &self.ready())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Eventcause {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Eventcause {{ isooutcrc: {=bool:?}, suspend: {=bool:?}, resume: {=bool:?}, usbwuallowed: {=bool:?}, ready: {=bool:?} }}" , self . isooutcrc () , self . suspend () , self . resume () , self . usbwuallowed () , self . ready ())
}
}
#[doc = "Returns the current value of the start of frame counter."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Framecntr(pub u32);
impl Framecntr {
#[doc = "Returns the current value of the start of frame counter."]
#[must_use]
#[inline(always)]
pub const fn framecntr(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x07ff;
val as u16
}
#[doc = "Returns the current value of the start of frame counter."]
#[inline(always)]
pub const fn set_framecntr(&mut self, val: u16) {
self.0 = (self.0 & !(0x07ff << 0usize)) | (((val as u32) & 0x07ff) << 0usize);
}
}
impl Default for Framecntr {
#[inline(always)]
fn default() -> Framecntr {
Framecntr(0)
}
}
impl core::fmt::Debug for Framecntr {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Framecntr")
.field("framecntr", &self.framecntr())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Framecntr {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Framecntr {{ framecntr: {=u16:?} }}", self.framecntr())
}
}
#[doc = "Description collection: OUT endpoint halted status. Can be used as is as response to a GetStatus() request to endpoint."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct HaltedEpout(pub u32);
impl HaltedEpout {
#[doc = "OUT endpoint halted status. Can be used as is as response to a GetStatus() request to endpoint."]
#[must_use]
#[inline(always)]
pub const fn getstatus(&self) -> super::vals::Getstatus {
let val = (self.0 >> 0usize) & 0xffff;
super::vals::Getstatus::from_bits(val as u16)
}
#[doc = "OUT endpoint halted status. Can be used as is as response to a GetStatus() request to endpoint."]
#[inline(always)]
pub const fn set_getstatus(&mut self, val: super::vals::Getstatus) {
self.0 =
(self.0 & !(0xffff << 0usize)) | (((val.to_bits() as u32) & 0xffff) << 0usize);
}
}
impl Default for HaltedEpout {
#[inline(always)]
fn default() -> HaltedEpout {
HaltedEpout(0)
}
}
impl core::fmt::Debug for HaltedEpout {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("HaltedEpout")
.field("getstatus", &self.getstatus())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for HaltedEpout {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "HaltedEpout {{ getstatus: {:?} }}", self.getstatus())
}
}
#[doc = "Enable or disable interrupt."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Int(pub u32);
impl Int {
#[doc = "Enable or disable interrupt for event USBRESET."]
#[must_use]
#[inline(always)]
pub const fn usbreset(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event USBRESET."]
#[inline(always)]
pub const fn set_usbreset(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Enable or disable interrupt for event STARTED."]
#[must_use]
#[inline(always)]
pub const fn started(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event STARTED."]
#[inline(always)]
pub const fn set_started(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "Enable or disable interrupt for event ENDEPIN\\[0\\]."]
#[must_use]
#[inline(always)]
pub const fn endepin(&self, n: usize) -> bool {
assert!(n < 8usize);
let offs = 2usize + n * 1usize;
let val = (self.0 >> offs) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event ENDEPIN\\[0\\]."]
#[inline(always)]
pub const fn set_endepin(&mut self, n: usize, val: bool) {
assert!(n < 8usize);
let offs = 2usize + n * 1usize;
self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
}
#[doc = "Enable or disable interrupt for event EP0DATADONE."]
#[must_use]
#[inline(always)]
pub const fn ep0datadone(&self) -> bool {
let val = (self.0 >> 10usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event EP0DATADONE."]
#[inline(always)]
pub const fn set_ep0datadone(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 10usize)) | (((val as u32) & 0x01) << 10usize);
}
#[doc = "Enable or disable interrupt for event ENDISOIN."]
#[must_use]
#[inline(always)]
pub const fn endisoin(&self) -> bool {
let val = (self.0 >> 11usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event ENDISOIN."]
#[inline(always)]
pub const fn set_endisoin(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 11usize)) | (((val as u32) & 0x01) << 11usize);
}
#[doc = "Enable or disable interrupt for event ENDEPOUT\\[0\\]."]
#[must_use]
#[inline(always)]
pub const fn endepout(&self, n: usize) -> bool {
assert!(n < 8usize);
let offs = 12usize + n * 1usize;
let val = (self.0 >> offs) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event ENDEPOUT\\[0\\]."]
#[inline(always)]
pub const fn set_endepout(&mut self, n: usize, val: bool) {
assert!(n < 8usize);
let offs = 12usize + n * 1usize;
self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
}
#[doc = "Enable or disable interrupt for event ENDISOOUT."]
#[must_use]
#[inline(always)]
pub const fn endisoout(&self) -> bool {
let val = (self.0 >> 20usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event ENDISOOUT."]
#[inline(always)]
pub const fn set_endisoout(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 20usize)) | (((val as u32) & 0x01) << 20usize);
}
#[doc = "Enable or disable interrupt for event SOF."]
#[must_use]
#[inline(always)]
pub const fn sof(&self) -> bool {
let val = (self.0 >> 21usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event SOF."]
#[inline(always)]
pub const fn set_sof(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 21usize)) | (((val as u32) & 0x01) << 21usize);
}
#[doc = "Enable or disable interrupt for event USBEVENT."]
#[must_use]
#[inline(always)]
pub const fn usbevent(&self) -> bool {
let val = (self.0 >> 22usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event USBEVENT."]
#[inline(always)]
pub const fn set_usbevent(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 22usize)) | (((val as u32) & 0x01) << 22usize);
}
#[doc = "Enable or disable interrupt for event EP0SETUP."]
#[must_use]
#[inline(always)]
pub const fn ep0setup(&self) -> bool {
let val = (self.0 >> 23usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event EP0SETUP."]
#[inline(always)]
pub const fn set_ep0setup(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 23usize)) | (((val as u32) & 0x01) << 23usize);
}
#[doc = "Enable or disable interrupt for event EPDATA."]
#[must_use]
#[inline(always)]
pub const fn epdata(&self) -> bool {
let val = (self.0 >> 24usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event EPDATA."]
#[inline(always)]
pub const fn set_epdata(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 24usize)) | (((val as u32) & 0x01) << 24usize);
}
}
impl Default for Int {
#[inline(always)]
fn default() -> Int {
Int(0)
}
}
impl core::fmt::Debug for Int {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Int")
.field("usbreset", &self.usbreset())
.field("started", &self.started())
.field("endepin[0]", &self.endepin(0usize))
.field("endepin[1]", &self.endepin(1usize))
.field("endepin[2]", &self.endepin(2usize))
.field("endepin[3]", &self.endepin(3usize))
.field("endepin[4]", &self.endepin(4usize))
.field("endepin[5]", &self.endepin(5usize))
.field("endepin[6]", &self.endepin(6usize))
.field("endepin[7]", &self.endepin(7usize))
.field("ep0datadone", &self.ep0datadone())
.field("endisoin", &self.endisoin())
.field("endepout[0]", &self.endepout(0usize))
.field("endepout[1]", &self.endepout(1usize))
.field("endepout[2]", &self.endepout(2usize))
.field("endepout[3]", &self.endepout(3usize))
.field("endepout[4]", &self.endepout(4usize))
.field("endepout[5]", &self.endepout(5usize))
.field("endepout[6]", &self.endepout(6usize))
.field("endepout[7]", &self.endepout(7usize))
.field("endisoout", &self.endisoout())
.field("sof", &self.sof())
.field("usbevent", &self.usbevent())
.field("ep0setup", &self.ep0setup())
.field("epdata", &self.epdata())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Int {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Int {{ usbreset: {=bool:?}, started: {=bool:?}, endepin[0]: {=bool:?}, endepin[1]: {=bool:?}, endepin[2]: {=bool:?}, endepin[3]: {=bool:?}, endepin[4]: {=bool:?}, endepin[5]: {=bool:?}, endepin[6]: {=bool:?}, endepin[7]: {=bool:?}, ep0datadone: {=bool:?}, endisoin: {=bool:?}, endepout[0]: {=bool:?}, endepout[1]: {=bool:?}, endepout[2]: {=bool:?}, endepout[3]: {=bool:?}, endepout[4]: {=bool:?}, endepout[5]: {=bool:?}, endepout[6]: {=bool:?}, endepout[7]: {=bool:?}, endisoout: {=bool:?}, sof: {=bool:?}, usbevent: {=bool:?}, ep0setup: {=bool:?}, epdata: {=bool:?} }}" , self . usbreset () , self . started () , self . endepin (0usize) , self . endepin (1usize) , self . endepin (2usize) , self . endepin (3usize) , self . endepin (4usize) , self . endepin (5usize) , self . endepin (6usize) , self . endepin (7usize) , self . ep0datadone () , self . endisoin () , self . endepout (0usize) , self . endepout (1usize) , self . endepout (2usize) , self . endepout (3usize) , self . endepout (4usize) , self . endepout (5usize) , self . endepout (6usize) , self . endepout (7usize) , self . endisoout () , self . sof () , self . usbevent () , self . ep0setup () , self . epdata ())
}
}
#[doc = "Number of bytes transferred in the last transaction."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct IsoinAmount(pub u32);
impl IsoinAmount {
#[doc = "Number of bytes transferred in the last transaction."]
#[must_use]
#[inline(always)]
pub const fn amount(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x03ff;
val as u16
}
#[doc = "Number of bytes transferred in the last transaction."]
#[inline(always)]
pub const fn set_amount(&mut self, val: u16) {
self.0 = (self.0 & !(0x03ff << 0usize)) | (((val as u32) & 0x03ff) << 0usize);
}
}
impl Default for IsoinAmount {
#[inline(always)]
fn default() -> IsoinAmount {
IsoinAmount(0)
}
}
impl core::fmt::Debug for IsoinAmount {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("IsoinAmount")
.field("amount", &self.amount())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for IsoinAmount {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "IsoinAmount {{ amount: {=u16:?} }}", self.amount())
}
}
#[doc = "Maximum number of bytes to transfer."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct IsoinMaxcnt(pub u32);
impl IsoinMaxcnt {
#[doc = "Maximum number of bytes to transfer."]
#[must_use]
#[inline(always)]
pub const fn maxcnt(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x03ff;
val as u16
}
#[doc = "Maximum number of bytes to transfer."]
#[inline(always)]
pub const fn set_maxcnt(&mut self, val: u16) {
self.0 = (self.0 & !(0x03ff << 0usize)) | (((val as u32) & 0x03ff) << 0usize);
}
}
impl Default for IsoinMaxcnt {
#[inline(always)]
fn default() -> IsoinMaxcnt {
IsoinMaxcnt(0)
}
}
impl core::fmt::Debug for IsoinMaxcnt {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("IsoinMaxcnt")
.field("maxcnt", &self.maxcnt())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for IsoinMaxcnt {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "IsoinMaxcnt {{ maxcnt: {=u16:?} }}", self.maxcnt())
}
}
#[doc = "Controls the response of the ISO IN endpoint to an IN token when no data is ready to be sent."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Isoinconfig(pub u32);
impl Isoinconfig {
#[doc = "Controls the response of the ISO IN endpoint to an IN token when no data is ready to be sent."]
#[must_use]
#[inline(always)]
pub const fn response(&self) -> super::vals::Response {
let val = (self.0 >> 0usize) & 0x01;
super::vals::Response::from_bits(val as u8)
}
#[doc = "Controls the response of the ISO IN endpoint to an IN token when no data is ready to be sent."]
#[inline(always)]
pub const fn set_response(&mut self, val: super::vals::Response) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
}
impl Default for Isoinconfig {
#[inline(always)]
fn default() -> Isoinconfig {
Isoinconfig(0)
}
}
impl core::fmt::Debug for Isoinconfig {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Isoinconfig")
.field("response", &self.response())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Isoinconfig {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Isoinconfig {{ response: {:?} }}", self.response())
}
}
#[doc = "Number of bytes received last on this ISO OUT data endpoint."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Isoout(pub u32);
impl Isoout {
#[doc = "Number of bytes received last on this ISO OUT data endpoint."]
#[must_use]
#[inline(always)]
pub const fn size(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x03ff;
val as u16
}
#[doc = "Number of bytes received last on this ISO OUT data endpoint."]
#[inline(always)]
pub const fn set_size(&mut self, val: u16) {
self.0 = (self.0 & !(0x03ff << 0usize)) | (((val as u32) & 0x03ff) << 0usize);
}
#[doc = "Zero-length data packet received."]
#[must_use]
#[inline(always)]
pub const fn zero(&self) -> super::vals::Zero {
let val = (self.0 >> 16usize) & 0x01;
super::vals::Zero::from_bits(val as u8)
}
#[doc = "Zero-length data packet received."]
#[inline(always)]
pub const fn set_zero(&mut self, val: super::vals::Zero) {
self.0 =
(self.0 & !(0x01 << 16usize)) | (((val.to_bits() as u32) & 0x01) << 16usize);
}
}
impl Default for Isoout {
#[inline(always)]
fn default() -> Isoout {
Isoout(0)
}
}
impl core::fmt::Debug for Isoout {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Isoout")
.field("size", &self.size())
.field("zero", &self.zero())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Isoout {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Isoout {{ size: {=u16:?}, zero: {:?} }}",
self.size(),
self.zero()
)
}
}
#[doc = "Number of bytes transferred in the last transaction."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct IsooutAmount(pub u32);
impl IsooutAmount {
#[doc = "Number of bytes transferred in the last transaction."]
#[must_use]
#[inline(always)]
pub const fn amount(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x03ff;
val as u16
}
#[doc = "Number of bytes transferred in the last transaction."]
#[inline(always)]
pub const fn set_amount(&mut self, val: u16) {
self.0 = (self.0 & !(0x03ff << 0usize)) | (((val as u32) & 0x03ff) << 0usize);
}
}
impl Default for IsooutAmount {
#[inline(always)]
fn default() -> IsooutAmount {
IsooutAmount(0)
}
}
impl core::fmt::Debug for IsooutAmount {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("IsooutAmount")
.field("amount", &self.amount())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for IsooutAmount {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "IsooutAmount {{ amount: {=u16:?} }}", self.amount())
}
}
#[doc = "Maximum number of bytes to transfer."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct IsooutMaxcnt(pub u32);
impl IsooutMaxcnt {
#[doc = "Maximum number of bytes to transfer."]
#[must_use]
#[inline(always)]
pub const fn maxcnt(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x03ff;
val as u16
}
#[doc = "Maximum number of bytes to transfer."]
#[inline(always)]
pub const fn set_maxcnt(&mut self, val: u16) {
self.0 = (self.0 & !(0x03ff << 0usize)) | (((val as u32) & 0x03ff) << 0usize);
}
}
impl Default for IsooutMaxcnt {
#[inline(always)]
fn default() -> IsooutMaxcnt {
IsooutMaxcnt(0)
}
}
impl core::fmt::Debug for IsooutMaxcnt {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("IsooutMaxcnt")
.field("maxcnt", &self.maxcnt())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for IsooutMaxcnt {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "IsooutMaxcnt {{ maxcnt: {=u16:?} }}", self.maxcnt())
}
}
#[doc = "Controls the split of ISO buffers."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Isosplit(pub u32);
impl Isosplit {
#[doc = "Controls the split of ISO buffers."]
#[must_use]
#[inline(always)]
pub const fn split(&self) -> super::vals::Split {
let val = (self.0 >> 0usize) & 0xffff;
super::vals::Split::from_bits(val as u16)
}
#[doc = "Controls the split of ISO buffers."]
#[inline(always)]
pub const fn set_split(&mut self, val: super::vals::Split) {
self.0 =
(self.0 & !(0xffff << 0usize)) | (((val.to_bits() as u32) & 0xffff) << 0usize);
}
}
impl Default for Isosplit {
#[inline(always)]
fn default() -> Isosplit {
Isosplit(0)
}
}
impl core::fmt::Debug for Isosplit {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Isosplit")
.field("split", &self.split())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Isosplit {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Isosplit {{ split: {:?} }}", self.split())
}
}
#[doc = "Controls USBD peripheral low power mode during USB suspend."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Lowpower(pub u32);
impl Lowpower {
#[doc = "Controls USBD peripheral low-power mode during USB suspend."]
#[must_use]
#[inline(always)]
pub const fn lowpower(&self) -> super::vals::Lowpower {
let val = (self.0 >> 0usize) & 0x01;
super::vals::Lowpower::from_bits(val as u8)
}
#[doc = "Controls USBD peripheral low-power mode during USB suspend."]
#[inline(always)]
pub const fn set_lowpower(&mut self, val: super::vals::Lowpower) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
}
impl Default for Lowpower {
#[inline(always)]
fn default() -> Lowpower {
Lowpower(0)
}
}
impl core::fmt::Debug for Lowpower {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Lowpower")
.field("lowpower", &self.lowpower())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Lowpower {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Lowpower {{ lowpower: {:?} }}", self.lowpower())
}
}
#[doc = "Shortcuts between local events and tasks."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Shorts(pub u32);
impl Shorts {
#[doc = "Shortcut between event EP0DATADONE and task STARTEPIN\\[0\\]."]
#[must_use]
#[inline(always)]
pub const fn ep0datadone_startepin0(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event EP0DATADONE and task STARTEPIN\\[0\\]."]
#[inline(always)]
pub const fn set_ep0datadone_startepin0(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Shortcut between event EP0DATADONE and task STARTEPOUT\\[0\\]."]
#[must_use]
#[inline(always)]
pub const fn ep0datadone_startepout0(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event EP0DATADONE and task STARTEPOUT\\[0\\]."]
#[inline(always)]
pub const fn set_ep0datadone_startepout0(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "Shortcut between event EP0DATADONE and task EP0STATUS."]
#[must_use]
#[inline(always)]
pub const fn ep0datadone_ep0status(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event EP0DATADONE and task EP0STATUS."]
#[inline(always)]
pub const fn set_ep0datadone_ep0status(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "Shortcut between event ENDEPOUT\\[0\\] and task EP0STATUS."]
#[must_use]
#[inline(always)]
pub const fn endepout0_ep0status(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event ENDEPOUT\\[0\\] and task EP0STATUS."]
#[inline(always)]
pub const fn set_endepout0_ep0status(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
#[doc = "Shortcut between event ENDEPOUT\\[0\\] and task EP0RCVOUT."]
#[must_use]
#[inline(always)]
pub const fn endepout0_ep0rcvout(&self) -> bool {
let val = (self.0 >> 4usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event ENDEPOUT\\[0\\] and task EP0RCVOUT."]
#[inline(always)]
pub const fn set_endepout0_ep0rcvout(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
}
}
impl Default for Shorts {
#[inline(always)]
fn default() -> Shorts {
Shorts(0)
}
}
impl core::fmt::Debug for Shorts {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Shorts")
.field("ep0datadone_startepin0", &self.ep0datadone_startepin0())
.field("ep0datadone_startepout0", &self.ep0datadone_startepout0())
.field("ep0datadone_ep0status", &self.ep0datadone_ep0status())
.field("endepout0_ep0status", &self.endepout0_ep0status())
.field("endepout0_ep0rcvout", &self.endepout0_ep0rcvout())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Shorts {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Shorts {{ ep0datadone_startepin0: {=bool:?}, ep0datadone_startepout0: {=bool:?}, ep0datadone_ep0status: {=bool:?}, endepout0_ep0status: {=bool:?}, endepout0_ep0rcvout: {=bool:?} }}" , self . ep0datadone_startepin0 () , self . ep0datadone_startepout0 () , self . ep0datadone_ep0status () , self . endepout0_ep0status () , self . endepout0_ep0rcvout ())
}
}
#[doc = "Description collection: Number of bytes received last in the data stage of this OUT endpoint."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct SizeEpout(pub u32);
impl SizeEpout {
#[doc = "Number of bytes received last in the data stage of this OUT endpoint."]
#[must_use]
#[inline(always)]
pub const fn size(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x7f;
val as u8
}
#[doc = "Number of bytes received last in the data stage of this OUT endpoint."]
#[inline(always)]
pub const fn set_size(&mut self, val: u8) {
self.0 = (self.0 & !(0x7f << 0usize)) | (((val as u32) & 0x7f) << 0usize);
}
}
impl Default for SizeEpout {
#[inline(always)]
fn default() -> SizeEpout {
SizeEpout(0)
}
}
impl core::fmt::Debug for SizeEpout {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("SizeEpout")
.field("size", &self.size())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for SizeEpout {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "SizeEpout {{ size: {=u8:?} }}", self.size())
}
}
#[doc = "Device USB address."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Usbaddr(pub u32);
impl Usbaddr {
#[doc = "Device USB address."]
#[must_use]
#[inline(always)]
pub const fn addr(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x7f;
val as u8
}
#[doc = "Device USB address."]
#[inline(always)]
pub const fn set_addr(&mut self, val: u8) {
self.0 = (self.0 & !(0x7f << 0usize)) | (((val as u32) & 0x7f) << 0usize);
}
}
impl Default for Usbaddr {
#[inline(always)]
fn default() -> Usbaddr {
Usbaddr(0)
}
}
impl core::fmt::Debug for Usbaddr {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Usbaddr")
.field("addr", &self.addr())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Usbaddr {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Usbaddr {{ addr: {=u8:?} }}", self.addr())
}
}
#[doc = "Control of the USB pull-up."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Usbpullup(pub u32);
impl Usbpullup {
#[doc = "Control of the USB pull-up on the D+ line."]
#[must_use]
#[inline(always)]
pub const fn connect(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Control of the USB pull-up on the D+ line."]
#[inline(always)]
pub const fn set_connect(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for Usbpullup {
#[inline(always)]
fn default() -> Usbpullup {
Usbpullup(0)
}
}
impl core::fmt::Debug for Usbpullup {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Usbpullup")
.field("connect", &self.connect())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Usbpullup {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Usbpullup {{ connect: {=bool:?} }}", self.connect())
}
}
#[doc = "SETUP data, byte 5, MSB of wIndex."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Windexh(pub u32);
impl Windexh {
#[doc = "SETUP data, byte 5, MSB of wIndex."]
#[must_use]
#[inline(always)]
pub const fn windexh(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "SETUP data, byte 5, MSB of wIndex."]
#[inline(always)]
pub const fn set_windexh(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
}
impl Default for Windexh {
#[inline(always)]
fn default() -> Windexh {
Windexh(0)
}
}
impl core::fmt::Debug for Windexh {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Windexh")
.field("windexh", &self.windexh())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Windexh {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Windexh {{ windexh: {=u8:?} }}", self.windexh())
}
}
#[doc = "SETUP data, byte 4, LSB of wIndex."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Windexl(pub u32);
impl Windexl {
#[doc = "SETUP data, byte 4, LSB of wIndex."]
#[must_use]
#[inline(always)]
pub const fn windexl(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "SETUP data, byte 4, LSB of wIndex."]
#[inline(always)]
pub const fn set_windexl(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
}
impl Default for Windexl {
#[inline(always)]
fn default() -> Windexl {
Windexl(0)
}
}
impl core::fmt::Debug for Windexl {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Windexl")
.field("windexl", &self.windexl())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Windexl {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Windexl {{ windexl: {=u8:?} }}", self.windexl())
}
}
#[doc = "SETUP data, byte 7, MSB of wLength."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Wlengthh(pub u32);
impl Wlengthh {
#[doc = "SETUP data, byte 7, MSB of wLength."]
#[must_use]
#[inline(always)]
pub const fn wlengthh(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "SETUP data, byte 7, MSB of wLength."]
#[inline(always)]
pub const fn set_wlengthh(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
}
impl Default for Wlengthh {
#[inline(always)]
fn default() -> Wlengthh {
Wlengthh(0)
}
}
impl core::fmt::Debug for Wlengthh {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Wlengthh")
.field("wlengthh", &self.wlengthh())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Wlengthh {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Wlengthh {{ wlengthh: {=u8:?} }}", self.wlengthh())
}
}
#[doc = "SETUP data, byte 6, LSB of wLength."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Wlengthl(pub u32);
impl Wlengthl {
#[doc = "SETUP data, byte 6, LSB of wLength."]
#[must_use]
#[inline(always)]
pub const fn wlengthl(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "SETUP data, byte 6, LSB of wLength."]
#[inline(always)]
pub const fn set_wlengthl(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
}
impl Default for Wlengthl {
#[inline(always)]
fn default() -> Wlengthl {
Wlengthl(0)
}
}
impl core::fmt::Debug for Wlengthl {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Wlengthl")
.field("wlengthl", &self.wlengthl())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Wlengthl {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Wlengthl {{ wlengthl: {=u8:?} }}", self.wlengthl())
}
}
#[doc = "SETUP data, byte 3, MSB of wValue."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Wvalueh(pub u32);
impl Wvalueh {
#[doc = "SETUP data, byte 3, MSB of wValue."]
#[must_use]
#[inline(always)]
pub const fn wvalueh(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "SETUP data, byte 3, MSB of wValue."]
#[inline(always)]
pub const fn set_wvalueh(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
}
impl Default for Wvalueh {
#[inline(always)]
fn default() -> Wvalueh {
Wvalueh(0)
}
}
impl core::fmt::Debug for Wvalueh {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Wvalueh")
.field("wvalueh", &self.wvalueh())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Wvalueh {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Wvalueh {{ wvalueh: {=u8:?} }}", self.wvalueh())
}
}
#[doc = "SETUP data, byte 2, LSB of wValue."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Wvaluel(pub u32);
impl Wvaluel {
#[doc = "SETUP data, byte 2, LSB of wValue."]
#[must_use]
#[inline(always)]
pub const fn wvaluel(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "SETUP data, byte 2, LSB of wValue."]
#[inline(always)]
pub const fn set_wvaluel(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
}
impl Default for Wvaluel {
#[inline(always)]
fn default() -> Wvaluel {
Wvaluel(0)
}
}
impl core::fmt::Debug for Wvaluel {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Wvaluel")
.field("wvaluel", &self.wvaluel())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Wvaluel {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Wvaluel {{ wvaluel: {=u8:?} }}", self.wvaluel())
}
}
}
pub mod vals {
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct Brequest(u8);
impl Brequest {
#[doc = "Standard request GET_STATUS."]
pub const StdGetStatus: Self = Self(0x0);
#[doc = "Standard request CLEAR_FEATURE."]
pub const StdClearFeature: Self = Self(0x01);
#[doc = "Standard request SET_FEATURE."]
pub const StdSetFeature: Self = Self(0x03);
#[doc = "Standard request SET_ADDRESS."]
pub const StdSetAddress: Self = Self(0x05);
#[doc = "Standard request GET_DESCRIPTOR."]
pub const StdGetDescriptor: Self = Self(0x06);
#[doc = "Standard request SET_DESCRIPTOR."]
pub const StdSetDescriptor: Self = Self(0x07);
#[doc = "Standard request GET_CONFIGURATION."]
pub const StdGetConfiguration: Self = Self(0x08);
#[doc = "Standard request SET_CONFIGURATION."]
pub const StdSetConfiguration: Self = Self(0x09);
#[doc = "Standard request GET_INTERFACE."]
pub const StdGetInterface: Self = Self(0x0a);
#[doc = "Standard request SET_INTERFACE."]
pub const StdSetInterface: Self = Self(0x0b);
#[doc = "Standard request SYNCH_FRAME."]
pub const StdSynchFrame: Self = Self(0x0c);
}
impl Brequest {
pub const fn from_bits(val: u8) -> Brequest {
Self(val & 0xff)
}
pub const fn to_bits(self) -> u8 {
self.0
}
}
impl core::fmt::Debug for Brequest {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self.0 {
0x0 => f.write_str("StdGetStatus"),
0x01 => f.write_str("StdClearFeature"),
0x03 => f.write_str("StdSetFeature"),
0x05 => f.write_str("StdSetAddress"),
0x06 => f.write_str("StdGetDescriptor"),
0x07 => f.write_str("StdSetDescriptor"),
0x08 => f.write_str("StdGetConfiguration"),
0x09 => f.write_str("StdSetConfiguration"),
0x0a => f.write_str("StdGetInterface"),
0x0b => f.write_str("StdSetInterface"),
0x0c => f.write_str("StdSynchFrame"),
other => core::write!(f, "0x{:02X}", other),
}
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Brequest {
fn format(&self, f: defmt::Formatter) {
match self.0 {
0x0 => defmt::write!(f, "StdGetStatus"),
0x01 => defmt::write!(f, "StdClearFeature"),
0x03 => defmt::write!(f, "StdSetFeature"),
0x05 => defmt::write!(f, "StdSetAddress"),
0x06 => defmt::write!(f, "StdGetDescriptor"),
0x07 => defmt::write!(f, "StdSetDescriptor"),
0x08 => defmt::write!(f, "StdGetConfiguration"),
0x09 => defmt::write!(f, "StdSetConfiguration"),
0x0a => defmt::write!(f, "StdGetInterface"),
0x0b => defmt::write!(f, "StdSetInterface"),
0x0c => defmt::write!(f, "StdSynchFrame"),
other => defmt::write!(f, "0x{:02X}", other),
}
}
}
impl From<u8> for Brequest {
#[inline(always)]
fn from(val: u8) -> Brequest {
Brequest::from_bits(val)
}
}
impl From<Brequest> for u8 {
#[inline(always)]
fn from(val: Brequest) -> u8 {
Brequest::to_bits(val)
}
}
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct Getstatus(u16);
impl Getstatus {
#[doc = "Endpoint is not halted."]
pub const NotHalted: Self = Self(0x0);
#[doc = "Endpoint is halted."]
pub const Halted: Self = Self(0x01);
}
impl Getstatus {
pub const fn from_bits(val: u16) -> Getstatus {
Self(val & 0xffff)
}
pub const fn to_bits(self) -> u16 {
self.0
}
}
impl core::fmt::Debug for Getstatus {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self.0 {
0x0 => f.write_str("NotHalted"),
0x01 => f.write_str("Halted"),
other => core::write!(f, "0x{:02X}", other),
}
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Getstatus {
fn format(&self, f: defmt::Formatter) {
match self.0 {
0x0 => defmt::write!(f, "NotHalted"),
0x01 => defmt::write!(f, "Halted"),
other => defmt::write!(f, "0x{:02X}", other),
}
}
}
impl From<u16> for Getstatus {
#[inline(always)]
fn from(val: u16) -> Getstatus {
Getstatus::from_bits(val)
}
}
impl From<Getstatus> for u16 {
#[inline(always)]
fn from(val: Getstatus) -> u16 {
Getstatus::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Io {
#[doc = "Selects OUT endpoint."]
Out = 0x0,
#[doc = "Selects IN endpoint."]
In = 0x01,
}
impl Io {
#[inline(always)]
pub const fn from_bits(val: u8) -> Io {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Io {
#[inline(always)]
fn from(val: u8) -> Io {
Io::from_bits(val)
}
}
impl From<Io> for u8 {
#[inline(always)]
fn from(val: Io) -> u8 {
Io::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Lowpower {
#[doc = "Software must write this value to exit low power mode and before performing a remote wake-up."]
ForceNormal = 0x0,
#[doc = "Software must write this value to enter low power mode after DMA and software have finished interacting with the USB peripheral."]
LowPower = 0x01,
}
impl Lowpower {
#[inline(always)]
pub const fn from_bits(val: u8) -> Lowpower {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Lowpower {
#[inline(always)]
fn from(val: u8) -> Lowpower {
Lowpower::from_bits(val)
}
}
impl From<Lowpower> for u8 {
#[inline(always)]
fn from(val: Lowpower) -> u8 {
Lowpower::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Recipient {
#[doc = "Device."]
Device = 0x0,
#[doc = "Interface."]
Interface = 0x01,
#[doc = "Endpoint."]
Endpoint = 0x02,
#[doc = "Other."]
Other = 0x03,
_RESERVED_4 = 0x04,
_RESERVED_5 = 0x05,
_RESERVED_6 = 0x06,
_RESERVED_7 = 0x07,
_RESERVED_8 = 0x08,
_RESERVED_9 = 0x09,
_RESERVED_a = 0x0a,
_RESERVED_b = 0x0b,
_RESERVED_c = 0x0c,
_RESERVED_d = 0x0d,
_RESERVED_e = 0x0e,
_RESERVED_f = 0x0f,
_RESERVED_10 = 0x10,
_RESERVED_11 = 0x11,
_RESERVED_12 = 0x12,
_RESERVED_13 = 0x13,
_RESERVED_14 = 0x14,
_RESERVED_15 = 0x15,
_RESERVED_16 = 0x16,
_RESERVED_17 = 0x17,
_RESERVED_18 = 0x18,
_RESERVED_19 = 0x19,
_RESERVED_1a = 0x1a,
_RESERVED_1b = 0x1b,
_RESERVED_1c = 0x1c,
_RESERVED_1d = 0x1d,
_RESERVED_1e = 0x1e,
_RESERVED_1f = 0x1f,
}
impl Recipient {
#[inline(always)]
pub const fn from_bits(val: u8) -> Recipient {
unsafe { core::mem::transmute(val & 0x1f) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Recipient {
#[inline(always)]
fn from(val: u8) -> Recipient {
Recipient::from_bits(val)
}
}
impl From<Recipient> for u8 {
#[inline(always)]
fn from(val: Recipient) -> u8 {
Recipient::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Response {
#[doc = "Endpoint does not respond in that case."]
NoResp = 0x0,
#[doc = "Endpoint responds with a zero-length data packet in that case."]
ZeroData = 0x01,
}
impl Response {
#[inline(always)]
pub const fn from_bits(val: u8) -> Response {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Response {
#[inline(always)]
fn from(val: u8) -> Response {
Response::from_bits(val)
}
}
impl From<Response> for u8 {
#[inline(always)]
fn from(val: Response) -> u8 {
Response::to_bits(val)
}
}
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct Split(u16);
impl Split {
#[doc = "Full buffer dedicated to either ISO IN or OUT."]
pub const OneDir: Self = Self(0x0);
#[doc = "Lower half for IN, upper half for OUT."]
pub const HalfIn: Self = Self(0x80);
}
impl Split {
pub const fn from_bits(val: u16) -> Split {
Self(val & 0xffff)
}
pub const fn to_bits(self) -> u16 {
self.0
}
}
impl core::fmt::Debug for Split {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self.0 {
0x0 => f.write_str("OneDir"),
0x80 => f.write_str("HalfIn"),
other => core::write!(f, "0x{:02X}", other),
}
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Split {
fn format(&self, f: defmt::Formatter) {
match self.0 {
0x0 => defmt::write!(f, "OneDir"),
0x80 => defmt::write!(f, "HalfIn"),
other => defmt::write!(f, "0x{:02X}", other),
}
}
}
impl From<u16> for Split {
#[inline(always)]
fn from(val: u16) -> Split {
Split::from_bits(val)
}
}
impl From<Split> for u16 {
#[inline(always)]
fn from(val: Split) -> u16 {
Split::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum State {
_RESERVED_0 = 0x0,
#[doc = "D+ forced low, D- forced high (K state) for a timing preset in hardware (50 us or 5 ms, depending on bus state)."]
Resume = 0x01,
#[doc = "D+ forced high, D- forced low (J state)."]
J = 0x02,
_RESERVED_3 = 0x03,
#[doc = "D+ forced low, D- forced high (K state)."]
K = 0x04,
_RESERVED_5 = 0x05,
_RESERVED_6 = 0x06,
_RESERVED_7 = 0x07,
_RESERVED_8 = 0x08,
_RESERVED_9 = 0x09,
_RESERVED_a = 0x0a,
_RESERVED_b = 0x0b,
_RESERVED_c = 0x0c,
_RESERVED_d = 0x0d,
_RESERVED_e = 0x0e,
_RESERVED_f = 0x0f,
_RESERVED_10 = 0x10,
_RESERVED_11 = 0x11,
_RESERVED_12 = 0x12,
_RESERVED_13 = 0x13,
_RESERVED_14 = 0x14,
_RESERVED_15 = 0x15,
_RESERVED_16 = 0x16,
_RESERVED_17 = 0x17,
_RESERVED_18 = 0x18,
_RESERVED_19 = 0x19,
_RESERVED_1a = 0x1a,
_RESERVED_1b = 0x1b,
_RESERVED_1c = 0x1c,
_RESERVED_1d = 0x1d,
_RESERVED_1e = 0x1e,
_RESERVED_1f = 0x1f,
}
impl State {
#[inline(always)]
pub const fn from_bits(val: u8) -> State {
unsafe { core::mem::transmute(val & 0x1f) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for State {
#[inline(always)]
fn from(val: u8) -> State {
State::from_bits(val)
}
}
impl From<State> for u8 {
#[inline(always)]
fn from(val: State) -> u8 {
State::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Type {
#[doc = "Standard."]
Standard = 0x0,
#[doc = "Class."]
Class = 0x01,
#[doc = "Vendor."]
Vendor = 0x02,
_RESERVED_3 = 0x03,
}
impl Type {
#[inline(always)]
pub const fn from_bits(val: u8) -> Type {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Type {
#[inline(always)]
fn from(val: u8) -> Type {
Type::from_bits(val)
}
}
impl From<Type> for u8 {
#[inline(always)]
fn from(val: Type) -> u8 {
Type::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Value {
#[doc = "No action on data toggle when writing the register with this value."]
Nop = 0x0,
#[doc = "Data toggle is DATA0 on endpoint set by EP and IO."]
Data0 = 0x01,
#[doc = "Data toggle is DATA1 on endpoint set by EP and IO."]
Data1 = 0x02,
_RESERVED_3 = 0x03,
}
impl Value {
#[inline(always)]
pub const fn from_bits(val: u8) -> Value {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Value {
#[inline(always)]
fn from(val: u8) -> Value {
Value::from_bits(val)
}
}
impl From<Value> for u8 {
#[inline(always)]
fn from(val: Value) -> u8 {
Value::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Zero {
#[doc = "No zero-length data received, use value in SIZE."]
Normal = 0x0,
#[doc = "Zero-length data received, ignore value in SIZE."]
ZeroData = 0x01,
}
impl Zero {
#[inline(always)]
pub const fn from_bits(val: u8) -> Zero {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Zero {
#[inline(always)]
fn from(val: u8) -> Zero {
Zero::from_bits(val)
}
}
impl From<Zero> for u8 {
#[inline(always)]
fn from(val: Zero) -> u8 {
Zero::to_bits(val)
}
}
}
}
pub mod wdt {
#[doc = "Watchdog Timer."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Wdt {
ptr: *mut u8,
}
unsafe impl Send for Wdt {}
unsafe impl Sync for Wdt {}
impl Wdt {
#[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 = "Start the watchdog."]
#[inline(always)]
pub const fn tasks_start(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Watchdog timeout."]
#[inline(always)]
pub const fn events_timeout(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0100usize) as _) }
}
#[doc = "Enable interrupt."]
#[inline(always)]
pub const fn intenset(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0304usize) as _) }
}
#[doc = "Disable interrupt."]
#[inline(always)]
pub const fn intenclr(self) -> crate::common::Reg<regs::Int, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0308usize) as _) }
}
#[doc = "Run status."]
#[inline(always)]
pub const fn runstatus(self) -> crate::common::Reg<regs::Runstatus, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0400usize) as _) }
}
#[doc = "Request status."]
#[inline(always)]
pub const fn reqstatus(self) -> crate::common::Reg<regs::Reqstatus, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0404usize) as _) }
}
#[doc = "Counter reload value."]
#[inline(always)]
pub const fn crv(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0504usize) as _) }
}
#[doc = "Enable register for reload request registers."]
#[inline(always)]
pub const fn rren(self) -> crate::common::Reg<regs::Rren, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0508usize) as _) }
}
#[doc = "Configuration register."]
#[inline(always)]
pub const fn config(self) -> crate::common::Reg<regs::Config, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x050cusize) as _) }
}
#[doc = "Description collection: Reload request n."]
#[inline(always)]
pub const fn rr(self, n: usize) -> crate::common::Reg<regs::Rr, crate::common::W> {
assert!(n < 8usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0600usize + n * 4usize) as _)
}
}
}
pub mod regs {
#[doc = "Configuration register."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Config(pub u32);
impl Config {
#[doc = "Configure the watchdog to either be paused, or kept running, while the CPU is sleeping."]
#[must_use]
#[inline(always)]
pub const fn sleep(&self) -> super::vals::Sleep {
let val = (self.0 >> 0usize) & 0x01;
super::vals::Sleep::from_bits(val as u8)
}
#[doc = "Configure the watchdog to either be paused, or kept running, while the CPU is sleeping."]
#[inline(always)]
pub const fn set_sleep(&mut self, val: super::vals::Sleep) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
#[doc = "Configure the watchdog to either be paused, or kept running, while the CPU is halted by the debugger."]
#[must_use]
#[inline(always)]
pub const fn halt(&self) -> super::vals::Halt {
let val = (self.0 >> 3usize) & 0x01;
super::vals::Halt::from_bits(val as u8)
}
#[doc = "Configure the watchdog to either be paused, or kept running, while the CPU is halted by the debugger."]
#[inline(always)]
pub const fn set_halt(&mut self, val: super::vals::Halt) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val.to_bits() as u32) & 0x01) << 3usize);
}
}
impl Default for Config {
#[inline(always)]
fn default() -> Config {
Config(0)
}
}
impl core::fmt::Debug for Config {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Config")
.field("sleep", &self.sleep())
.field("halt", &self.halt())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Config {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Config {{ sleep: {:?}, halt: {:?} }}",
self.sleep(),
self.halt()
)
}
}
#[doc = "Disable interrupt."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Int(pub u32);
impl Int {
#[doc = "Write '1' to disable interrupt for event TIMEOUT."]
#[must_use]
#[inline(always)]
pub const fn timeout(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Write '1' to disable interrupt for event TIMEOUT."]
#[inline(always)]
pub const fn set_timeout(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for Int {
#[inline(always)]
fn default() -> Int {
Int(0)
}
}
impl core::fmt::Debug for Int {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Int")
.field("timeout", &self.timeout())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Int {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Int {{ timeout: {=bool:?} }}", self.timeout())
}
}
#[doc = "Request status."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Reqstatus(pub u32);
impl Reqstatus {
#[doc = "Request status for RR\\[0\\] register."]
#[must_use]
#[inline(always)]
pub const fn rr(&self, n: usize) -> bool {
assert!(n < 8usize);
let offs = 0usize + n * 1usize;
let val = (self.0 >> offs) & 0x01;
val != 0
}
#[doc = "Request status for RR\\[0\\] register."]
#[inline(always)]
pub const fn set_rr(&mut self, n: usize, val: bool) {
assert!(n < 8usize);
let offs = 0usize + n * 1usize;
self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
}
}
impl Default for Reqstatus {
#[inline(always)]
fn default() -> Reqstatus {
Reqstatus(0)
}
}
impl core::fmt::Debug for Reqstatus {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Reqstatus")
.field("rr[0]", &self.rr(0usize))
.field("rr[1]", &self.rr(1usize))
.field("rr[2]", &self.rr(2usize))
.field("rr[3]", &self.rr(3usize))
.field("rr[4]", &self.rr(4usize))
.field("rr[5]", &self.rr(5usize))
.field("rr[6]", &self.rr(6usize))
.field("rr[7]", &self.rr(7usize))
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Reqstatus {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Reqstatus {{ rr[0]: {=bool:?}, rr[1]: {=bool:?}, rr[2]: {=bool:?}, rr[3]: {=bool:?}, rr[4]: {=bool:?}, rr[5]: {=bool:?}, rr[6]: {=bool:?}, rr[7]: {=bool:?} }}" , self . rr (0usize) , self . rr (1usize) , self . rr (2usize) , self . rr (3usize) , self . rr (4usize) , self . rr (5usize) , self . rr (6usize) , self . rr (7usize))
}
}
#[doc = "Description collection: Reload request n."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Rr(pub u32);
impl Rr {
#[doc = "Reload request register."]
#[must_use]
#[inline(always)]
pub const fn rr(&self) -> super::vals::Rr {
let val = (self.0 >> 0usize) & 0xffff_ffff;
super::vals::Rr::from_bits(val as u32)
}
#[doc = "Reload request register."]
#[inline(always)]
pub const fn set_rr(&mut self, val: super::vals::Rr) {
self.0 = (self.0 & !(0xffff_ffff << 0usize))
| (((val.to_bits() as u32) & 0xffff_ffff) << 0usize);
}
}
impl Default for Rr {
#[inline(always)]
fn default() -> Rr {
Rr(0)
}
}
impl core::fmt::Debug for Rr {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Rr").field("rr", &self.rr()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Rr {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Rr {{ rr: {:?} }}", self.rr())
}
}
#[doc = "Enable register for reload request registers."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Rren(pub u32);
impl Rren {
#[doc = "Enable or disable RR\\[0\\] register."]
#[must_use]
#[inline(always)]
pub const fn rr(&self, n: usize) -> bool {
assert!(n < 8usize);
let offs = 0usize + n * 1usize;
let val = (self.0 >> offs) & 0x01;
val != 0
}
#[doc = "Enable or disable RR\\[0\\] register."]
#[inline(always)]
pub const fn set_rr(&mut self, n: usize, val: bool) {
assert!(n < 8usize);
let offs = 0usize + n * 1usize;
self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
}
}
impl Default for Rren {
#[inline(always)]
fn default() -> Rren {
Rren(0)
}
}
impl core::fmt::Debug for Rren {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Rren")
.field("rr[0]", &self.rr(0usize))
.field("rr[1]", &self.rr(1usize))
.field("rr[2]", &self.rr(2usize))
.field("rr[3]", &self.rr(3usize))
.field("rr[4]", &self.rr(4usize))
.field("rr[5]", &self.rr(5usize))
.field("rr[6]", &self.rr(6usize))
.field("rr[7]", &self.rr(7usize))
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Rren {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Rren {{ rr[0]: {=bool:?}, rr[1]: {=bool:?}, rr[2]: {=bool:?}, rr[3]: {=bool:?}, rr[4]: {=bool:?}, rr[5]: {=bool:?}, rr[6]: {=bool:?}, rr[7]: {=bool:?} }}" , self . rr (0usize) , self . rr (1usize) , self . rr (2usize) , self . rr (3usize) , self . rr (4usize) , self . rr (5usize) , self . rr (6usize) , self . rr (7usize))
}
}
#[doc = "Run status."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Runstatus(pub u32);
impl Runstatus {
#[doc = "Indicates whether or not the watchdog is running."]
#[must_use]
#[inline(always)]
pub const fn runstatus(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Indicates whether or not the watchdog is running."]
#[inline(always)]
pub const fn set_runstatus(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for Runstatus {
#[inline(always)]
fn default() -> Runstatus {
Runstatus(0)
}
}
impl core::fmt::Debug for Runstatus {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Runstatus")
.field("runstatus", &self.runstatus())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Runstatus {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Runstatus {{ runstatus: {=bool:?} }}", self.runstatus())
}
}
}
pub mod vals {
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Halt {
#[doc = "Pause watchdog while the CPU is halted by the debugger."]
Pause = 0x0,
#[doc = "Keep the watchdog running while the CPU is halted by the debugger."]
Run = 0x01,
}
impl Halt {
#[inline(always)]
pub const fn from_bits(val: u8) -> Halt {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Halt {
#[inline(always)]
fn from(val: u8) -> Halt {
Halt::from_bits(val)
}
}
impl From<Halt> for u8 {
#[inline(always)]
fn from(val: Halt) -> u8 {
Halt::to_bits(val)
}
}
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct Rr(u32);
impl Rr {
#[doc = "Value to request a reload of the watchdog timer."]
pub const Reload: Self = Self(0x6e52_4635);
}
impl Rr {
pub const fn from_bits(val: u32) -> Rr {
Self(val & 0xffff_ffff)
}
pub const fn to_bits(self) -> u32 {
self.0
}
}
impl core::fmt::Debug for Rr {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self.0 {
0x6e52_4635 => f.write_str("Reload"),
other => core::write!(f, "0x{:02X}", other),
}
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Rr {
fn format(&self, f: defmt::Formatter) {
match self.0 {
0x6e52_4635 => defmt::write!(f, "Reload"),
other => defmt::write!(f, "0x{:02X}", other),
}
}
}
impl From<u32> for Rr {
#[inline(always)]
fn from(val: u32) -> Rr {
Rr::from_bits(val)
}
}
impl From<Rr> for u32 {
#[inline(always)]
fn from(val: Rr) -> u32 {
Rr::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Sleep {
#[doc = "Pause watchdog while the CPU is sleeping."]
Pause = 0x0,
#[doc = "Keep the watchdog running while the CPU is sleeping."]
Run = 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)
}
}
}
}