#![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 = "5 - NFCT"]
NFCT = 5,
#[doc = "6 - GPIOTE"]
GPIOTE = 6,
#[doc = "7 - SAADC"]
SAADC = 7,
#[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_LPCOMP"]
COMP_LPCOMP = 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 = "27 - TIMER4"]
TIMER4 = 27,
#[doc = "28 - PWM0"]
PWM0 = 28,
#[doc = "29 - PDM"]
PDM = 29,
#[doc = "32 - MWU"]
MWU = 32,
#[doc = "33 - PWM1"]
PWM1 = 33,
#[doc = "34 - PWM2"]
PWM2 = 34,
#[doc = "35 - SPI2"]
SPI2 = 35,
#[doc = "36 - RTC2"]
RTC2 = 36,
#[doc = "37 - I2S"]
I2S = 37,
#[doc = "38 - FPU"]
FPU = 38,
#[doc = "39 - USBD"]
USBD = 39,
#[doc = "40 - UARTE1"]
UARTE1 = 40,
#[doc = "41 - QSPI"]
QSPI = 41,
#[doc = "42 - CRYPTOCELL"]
CRYPTOCELL = 42,
#[doc = "45 - PWM3"]
PWM3 = 45,
#[doc = "47 - SPIM3"]
SPIM3 = 47,
}
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 NFCT();
fn GPIOTE();
fn SAADC();
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_LPCOMP();
fn EGU0_SWI0();
fn EGU1_SWI1();
fn EGU2_SWI2();
fn EGU3_SWI3();
fn EGU4_SWI4();
fn EGU5_SWI5();
fn TIMER3();
fn TIMER4();
fn PWM0();
fn PDM();
fn MWU();
fn PWM1();
fn PWM2();
fn SPI2();
fn RTC2();
fn I2S();
fn FPU();
fn USBD();
fn UARTE1();
fn QSPI();
fn CRYPTOCELL();
fn PWM3();
fn SPIM3();
}
pub union Vector {
_handler: unsafe extern "C" fn(),
_reserved: u32,
}
#[unsafe(link_section = ".vector_table.interrupts")]
#[unsafe(no_mangle)]
pub static __INTERRUPTS: [Vector; 48] = [
Vector {
_handler: CLOCK_POWER,
},
Vector { _handler: RADIO },
Vector { _handler: UARTE0 },
Vector { _handler: TWISPI0 },
Vector { _handler: TWISPI1 },
Vector { _handler: NFCT },
Vector { _handler: GPIOTE },
Vector { _handler: SAADC },
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_LPCOMP,
},
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 { _handler: TIMER4 },
Vector { _handler: PWM0 },
Vector { _handler: PDM },
Vector { _reserved: 0 },
Vector { _reserved: 0 },
Vector { _handler: MWU },
Vector { _handler: PWM1 },
Vector { _handler: PWM2 },
Vector { _handler: SPI2 },
Vector { _handler: RTC2 },
Vector { _handler: I2S },
Vector { _handler: FPU },
Vector { _handler: USBD },
Vector { _handler: UARTE1 },
Vector { _handler: QSPI },
Vector {
_handler: CRYPTOCELL,
},
Vector { _reserved: 0 },
Vector { _reserved: 0 },
Vector { _handler: PWM3 },
Vector { _reserved: 0 },
Vector { _handler: SPIM3 },
];
}
#[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 0"]
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 = "NFC-A compatible radio"]
pub const NFCT: nfct::Nfct = unsafe { nfct::Nfct::from_ptr(0x4000_5000usize as _) };
#[doc = "GPIO Tasks and Events"]
pub const GPIOTE: gpiote::Gpiote = unsafe { gpiote::Gpiote::from_ptr(0x4000_6000usize as _) };
#[doc = "Successive approximation register (SAR) analog-to-digital converter"]
pub const SAADC: saadc::Saadc = unsafe { saadc::Saadc::from_ptr(0x4000_7000usize 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 = "Low-power comparator"]
pub const LPCOMP: lpcomp::Lpcomp = unsafe { lpcomp::Lpcomp::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 = "Timer/Counter 4"]
pub const TIMER4: timer::Timer = unsafe { timer::Timer::from_ptr(0x4001_b000usize as _) };
#[doc = "Pulse width modulation unit 0"]
pub const PWM0: pwm::Pwm = unsafe { pwm::Pwm::from_ptr(0x4001_c000usize as _) };
#[doc = "Pulse Density Modulation (Digital Microphone) Interface"]
pub const PDM: pdm::Pdm = unsafe { pdm::Pdm::from_ptr(0x4001_d000usize 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 = "Memory Watch Unit"]
pub const MWU: mwu::Mwu = unsafe { mwu::Mwu::from_ptr(0x4002_0000usize as _) };
#[doc = "Pulse width modulation unit 1"]
pub const PWM1: pwm::Pwm = unsafe { pwm::Pwm::from_ptr(0x4002_1000usize as _) };
#[doc = "Pulse width modulation unit 2"]
pub const PWM2: pwm::Pwm = unsafe { pwm::Pwm::from_ptr(0x4002_2000usize as _) };
#[doc = "Serial Peripheral Interface 2"]
pub const SPI2: spi::Spi = unsafe { spi::Spi::from_ptr(0x4002_3000usize as _) };
#[doc = "Serial Peripheral Interface Master with EasyDMA 2"]
pub const SPIM2: spim::Spim = unsafe { spim::Spim::from_ptr(0x4002_3000usize as _) };
#[doc = "SPI Slave 2"]
pub const SPIS2: spis::Spis = unsafe { spis::Spis::from_ptr(0x4002_3000usize as _) };
#[doc = "Real time counter 2"]
pub const RTC2: rtc::Rtc = unsafe { rtc::Rtc::from_ptr(0x4002_4000usize as _) };
#[doc = "Inter-IC Sound"]
pub const I2S: i2s::I2s = unsafe { i2s::I2s::from_ptr(0x4002_5000usize as _) };
#[doc = "FPU"]
pub const FPU: fpu::Fpu = unsafe { fpu::Fpu::from_ptr(0x4002_6000usize as _) };
#[doc = "Universal serial bus device"]
pub const USBD: usbd::Usbd = unsafe { usbd::Usbd::from_ptr(0x4002_7000usize as _) };
#[doc = "UART with EasyDMA 1"]
pub const UARTE1: uarte::Uarte = unsafe { uarte::Uarte::from_ptr(0x4002_8000usize as _) };
#[doc = "External flash interface"]
pub const QSPI: qspi::Qspi = unsafe { qspi::Qspi::from_ptr(0x4002_9000usize as _) };
#[doc = "Pulse width modulation unit 3"]
pub const PWM3: pwm::Pwm = unsafe { pwm::Pwm::from_ptr(0x4002_d000usize as _) };
#[doc = "Serial Peripheral Interface Master with EasyDMA 3"]
pub const SPIM3: spim::Spim = unsafe { spim::Spim::from_ptr(0x4002_f000usize as _) };
#[doc = "GPIO Port 0"]
pub const P0: gpio::Gpio = unsafe { gpio::Gpio::from_ptr(0x5000_0000usize as _) };
#[doc = "GPIO Port 1"]
pub const P1: gpio::Gpio = unsafe { gpio::Gpio::from_ptr(0x5000_0300usize as _) };
#[doc = "CRYPTOCELL register interface"]
pub const CRYPTOCELL: cryptocell::Cryptocell =
unsafe { cryptocell::Cryptocell::from_ptr(0x5002_a000usize as _) };
#[doc = "CRYPTOCELL AES engine"]
pub const CC_AES: cc_aes::CcAes = unsafe { cc_aes::CcAes::from_ptr(0x5002_b000usize as _) };
#[doc = "CRYPTOCELL CHACHA engine"]
pub const CC_CHACHA: cc_chacha::CcChacha =
unsafe { cc_chacha::CcChacha::from_ptr(0x5002_b000usize as _) };
#[doc = "CRYPTOCELL CTL interface"]
pub const CC_CTL: cc_ctl::CcCtl = unsafe { cc_ctl::CcCtl::from_ptr(0x5002_b000usize as _) };
#[doc = "CRYPTOCELL Data IN interface"]
pub const CC_DIN: cc_din::CcDin = unsafe { cc_din::CcDin::from_ptr(0x5002_b000usize as _) };
#[doc = "CRYPTOCELL Data OUT interface"]
pub const CC_DOUT: cc_dout::CcDout = unsafe { cc_dout::CcDout::from_ptr(0x5002_b000usize as _) };
#[doc = "CRYPTOCELL HASH engine"]
pub const CC_HASH: cc_hash::CcHash = unsafe { cc_hash::CcHash::from_ptr(0x5002_b000usize as _) };
#[doc = "CRYPTOCELL HOST register interface"]
pub const CC_HOST_RGF: cc_host_rgf::CcHostRgf =
unsafe { cc_host_rgf::CcHostRgf::from_ptr(0x5002_b000usize as _) };
#[doc = "CRYPTOCELL MISC interface"]
pub const CC_MISC: cc_misc::CcMisc = unsafe { cc_misc::CcMisc::from_ptr(0x5002_b000usize as _) };
#[doc = "CRYPTOCELL PKA engine"]
pub const CC_PKA: cc_pka::CcPka = unsafe { cc_pka::CcPka::from_ptr(0x5002_b000usize as _) };
#[doc = "CRYPTOCELL RNG engine"]
pub const CC_RNG: cc_rng::CcRng = unsafe { cc_rng::CcRng::from_ptr(0x5002_b000usize as _) };
#[doc = "CRYPTOCELL RNG SRAM interface"]
pub const CC_RNG_SRAM: cc_rng_sram::CcRngSram =
unsafe { cc_rng_sram::CcRngSram::from_ptr(0x5002_b000usize 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 cc_aes {
#[doc = "CRYPTOCELL AES engine."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct CcAes {
ptr: *mut u8,
}
unsafe impl Send for CcAes {}
unsafe impl Sync for CcAes {}
impl CcAes {
#[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: AES key value to use. The initial AES_KEY_0\\[0\\] register holds the least significant bits \\[31:0\\] of the key value."]
#[inline(always)]
pub const fn aes_key_0(self, n: usize) -> crate::common::Reg<u32, crate::common::W> {
assert!(n < 8usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0400usize + n * 4usize) as _)
}
}
#[doc = "Description collection: AES Initialization Vector (IV) to use. The initial AES_IV_0\\[0\\] register holds the least significant bits \\[31:0\\] of the IV."]
#[inline(always)]
pub const fn aes_iv_0(self, n: usize) -> crate::common::Reg<u32, crate::common::RW> {
assert!(n < 4usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0440usize + n * 4usize) as _)
}
}
#[doc = "Description collection: AES counter (CTR) to use. The initial AES_CTR\\[0\\] register holds the least significant bits \\[31:0\\] of the CTR."]
#[inline(always)]
pub const fn aes_ctr(self, n: usize) -> crate::common::Reg<u32, crate::common::RW> {
assert!(n < 4usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0460usize + n * 4usize) as _)
}
}
#[doc = "Status register for AES engine activity."]
#[inline(always)]
pub const fn aes_busy(self) -> crate::common::Reg<regs::AesBusy, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0470usize) as _) }
}
#[doc = "Writing to this address trigger sampling of the HW key to the AES_KEY_0 register."]
#[inline(always)]
pub const fn aes_sk(self) -> crate::common::Reg<regs::AesSk, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0478usize) as _) }
}
#[doc = "Writing to this address triggers the AES engine to generate K1 and K2 for AES-CMAC operations."]
#[inline(always)]
pub const fn aes_cmac_init(
self,
) -> crate::common::Reg<regs::AesCmacInit, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x047cusize) as _) }
}
#[doc = "This register should be set with the amount of remaining bytes until the end of the current AES operation."]
#[inline(always)]
pub const fn aes_remaining_bytes(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04bcusize) as _) }
}
#[doc = "Control the AES engine behavior."]
#[inline(always)]
pub const fn aes_control(self) -> crate::common::Reg<regs::AesControl, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04c0usize) as _) }
}
#[doc = "Hardware configuration of the AES engine. Reset value holds the supported features."]
#[inline(always)]
pub const fn aes_hw_flags(self) -> crate::common::Reg<regs::AesHwFlags, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04c8usize) as _) }
}
#[doc = "This register enables the AES CTR no increment mode in which the counter mode is not incremented between two blocks."]
#[inline(always)]
pub const fn aes_ctr_no_increment(
self,
) -> crate::common::Reg<regs::AesCtrNoIncrement, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04d8usize) as _) }
}
#[doc = "Reset the AES engine."]
#[inline(always)]
pub const fn aes_sw_reset(self) -> crate::common::Reg<regs::AesSwReset, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04f4usize) as _) }
}
#[doc = "Writing to this address triggers the AES engine to perform a CMAC operation with size 0. The CMAC result can be read from the AES_IV_0 register."]
#[inline(always)]
pub const fn aes_cmac_size0_kick(
self,
) -> crate::common::Reg<regs::AesCmacSize0Kick, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0524usize) as _) }
}
}
pub mod regs {
#[doc = "Status register for AES engine activity."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct AesBusy(pub u32);
impl AesBusy {
#[doc = "AES engine status."]
#[must_use]
#[inline(always)]
pub const fn status(&self) -> super::vals::Status {
let val = (self.0 >> 0usize) & 0x01;
super::vals::Status::from_bits(val as u8)
}
#[doc = "AES engine status."]
#[inline(always)]
pub const fn set_status(&mut self, val: super::vals::Status) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
}
impl Default for AesBusy {
#[inline(always)]
fn default() -> AesBusy {
AesBusy(0)
}
}
impl core::fmt::Debug for AesBusy {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("AesBusy")
.field("status", &self.status())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for AesBusy {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "AesBusy {{ status: {:?} }}", self.status())
}
}
#[doc = "Writing to this address triggers the AES engine to generate K1 and K2 for AES-CMAC operations."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct AesCmacInit(pub u32);
impl AesCmacInit {
#[doc = "Generate K1 and K2 for the AES-CMAC operations."]
#[must_use]
#[inline(always)]
pub const fn enable(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Generate K1 and K2 for the AES-CMAC operations."]
#[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 AesCmacInit {
#[inline(always)]
fn default() -> AesCmacInit {
AesCmacInit(0)
}
}
impl core::fmt::Debug for AesCmacInit {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("AesCmacInit")
.field("enable", &self.enable())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for AesCmacInit {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "AesCmacInit {{ enable: {=bool:?} }}", self.enable())
}
}
#[doc = "Writing to this address triggers the AES engine to perform a CMAC operation with size 0. The CMAC result can be read from the AES_IV_0 register."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct AesCmacSize0Kick(pub u32);
impl AesCmacSize0Kick {
#[doc = "Force AES CMAC operation with size 0."]
#[must_use]
#[inline(always)]
pub const fn enable(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Force AES CMAC operation with size 0."]
#[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 AesCmacSize0Kick {
#[inline(always)]
fn default() -> AesCmacSize0Kick {
AesCmacSize0Kick(0)
}
}
impl core::fmt::Debug for AesCmacSize0Kick {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("AesCmacSize0Kick")
.field("enable", &self.enable())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for AesCmacSize0Kick {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "AesCmacSize0Kick {{ enable: {=bool:?} }}", self.enable())
}
}
#[doc = "Control the AES engine behavior."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct AesControl(pub u32);
impl AesControl {
#[doc = "Set AES encrypt or decrypt mode in non-tunneling operations."]
#[must_use]
#[inline(always)]
pub const fn dec_key0(&self) -> super::vals::DecKey0 {
let val = (self.0 >> 0usize) & 0x01;
super::vals::DecKey0::from_bits(val as u8)
}
#[doc = "Set AES encrypt or decrypt mode in non-tunneling operations."]
#[inline(always)]
pub const fn set_dec_key0(&mut self, val: super::vals::DecKey0) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
#[doc = "Set the AES mode."]
#[must_use]
#[inline(always)]
pub const fn mode_key0(&self) -> super::vals::ModeKey0 {
let val = (self.0 >> 2usize) & 0x07;
super::vals::ModeKey0::from_bits(val as u8)
}
#[doc = "Set the AES mode."]
#[inline(always)]
pub const fn set_mode_key0(&mut self, val: super::vals::ModeKey0) {
self.0 = (self.0 & !(0x07 << 2usize)) | (((val.to_bits() as u32) & 0x07) << 2usize);
}
#[doc = "Set the AES key length."]
#[must_use]
#[inline(always)]
pub const fn nk_key0(&self) -> super::vals::NkKey0 {
let val = (self.0 >> 12usize) & 0x03;
super::vals::NkKey0::from_bits(val as u8)
}
#[doc = "Set the AES key length."]
#[inline(always)]
pub const fn set_nk_key0(&mut self, val: super::vals::NkKey0) {
self.0 =
(self.0 & !(0x03 << 12usize)) | (((val.to_bits() as u32) & 0x03) << 12usize);
}
#[doc = "This field determines the value that is written to AES_KEY_0, when AES_SK is kicked."]
#[must_use]
#[inline(always)]
pub const fn aes_xor_cryptokey(&self) -> bool {
let val = (self.0 >> 29usize) & 0x01;
val != 0
}
#[doc = "This field determines the value that is written to AES_KEY_0, when AES_SK is kicked."]
#[inline(always)]
pub const fn set_aes_xor_cryptokey(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 29usize)) | (((val as u32) & 0x01) << 29usize);
}
#[doc = "Using direct access and not the DIN-DOUT DMA interface."]
#[must_use]
#[inline(always)]
pub const fn direct_access(&self) -> bool {
let val = (self.0 >> 31usize) & 0x01;
val != 0
}
#[doc = "Using direct access and not the DIN-DOUT DMA interface."]
#[inline(always)]
pub const fn set_direct_access(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 31usize)) | (((val as u32) & 0x01) << 31usize);
}
}
impl Default for AesControl {
#[inline(always)]
fn default() -> AesControl {
AesControl(0)
}
}
impl core::fmt::Debug for AesControl {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("AesControl")
.field("dec_key0", &self.dec_key0())
.field("mode_key0", &self.mode_key0())
.field("nk_key0", &self.nk_key0())
.field("aes_xor_cryptokey", &self.aes_xor_cryptokey())
.field("direct_access", &self.direct_access())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for AesControl {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "AesControl {{ dec_key0: {:?}, mode_key0: {:?}, nk_key0: {:?}, aes_xor_cryptokey: {=bool:?}, direct_access: {=bool:?} }}" , self . dec_key0 () , self . mode_key0 () , self . nk_key0 () , self . aes_xor_cryptokey () , self . direct_access ())
}
}
#[doc = "This register enables the AES CTR no increment mode in which the counter mode is not incremented between two blocks."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct AesCtrNoIncrement(pub u32);
impl AesCtrNoIncrement {
#[doc = "This field enables the AES CTR no increment mode in which the counter mode is not incremented between two blocks."]
#[must_use]
#[inline(always)]
pub const fn enable(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "This field enables the AES CTR no increment mode in which the counter mode is not incremented between two blocks."]
#[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 AesCtrNoIncrement {
#[inline(always)]
fn default() -> AesCtrNoIncrement {
AesCtrNoIncrement(0)
}
}
impl core::fmt::Debug for AesCtrNoIncrement {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("AesCtrNoIncrement")
.field("enable", &self.enable())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for AesCtrNoIncrement {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"AesCtrNoIncrement {{ enable: {=bool:?} }}",
self.enable()
)
}
}
#[doc = "Hardware configuration of the AES engine. Reset value holds the supported features."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct AesHwFlags(pub u32);
impl AesHwFlags {
#[doc = "If this flag is set, the engine support 192 bits and 256 bits key size."]
#[must_use]
#[inline(always)]
pub const fn support_256_192_key(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the engine support 192 bits and 256 bits key size."]
#[inline(always)]
pub const fn set_support_256_192_key(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "If this flag is set, the engine support AES_LARGE_RKEK."]
#[must_use]
#[inline(always)]
pub const fn aes_large_rkek(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the engine support AES_LARGE_RKEK."]
#[inline(always)]
pub const fn set_aes_large_rkek(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "If this flag is set, the engine support DPA countermeasures."]
#[must_use]
#[inline(always)]
pub const fn dpa_cntrmsr_exist(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the engine support DPA countermeasures."]
#[inline(always)]
pub const fn set_dpa_cntrmsr_exist(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "If this flag is set, the engine support AES CTR mode."]
#[must_use]
#[inline(always)]
pub const fn ctr_exist(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the engine support AES CTR mode."]
#[inline(always)]
pub const fn set_ctr_exist(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
#[doc = "If this flag is set, the engine only support encrypt operations."]
#[must_use]
#[inline(always)]
pub const fn only_encrypt(&self) -> bool {
let val = (self.0 >> 4usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the engine only support encrypt operations."]
#[inline(always)]
pub const fn set_only_encrypt(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
}
#[doc = "If this flag is set, the engine uses SBOX tables."]
#[must_use]
#[inline(always)]
pub const fn use_sbox_table(&self) -> bool {
let val = (self.0 >> 5usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the engine uses SBOX tables."]
#[inline(always)]
pub const fn set_use_sbox_table(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
}
#[doc = "If this flag is set, the engine uses 5 SBOX where each AES round takes 4 cycles."]
#[must_use]
#[inline(always)]
pub const fn use_5_sboxes(&self) -> bool {
let val = (self.0 >> 8usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the engine uses 5 SBOX where each AES round takes 4 cycles."]
#[inline(always)]
pub const fn set_use_5_sboxes(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize);
}
#[doc = "If this flag is set, the engine contains the PREV_IV register for faster AES XCBC MAC calculation."]
#[must_use]
#[inline(always)]
pub const fn aes_support_prev_iv(&self) -> bool {
let val = (self.0 >> 9usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the engine contains the PREV_IV register for faster AES XCBC MAC calculation."]
#[inline(always)]
pub const fn set_aes_support_prev_iv(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 9usize)) | (((val as u32) & 0x01) << 9usize);
}
#[doc = "If this flag is set, the engine support tunneling operations."]
#[must_use]
#[inline(always)]
pub const fn aes_tunnel_exist(&self) -> bool {
let val = (self.0 >> 10usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the engine support tunneling operations."]
#[inline(always)]
pub const fn set_aes_tunnel_exist(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 10usize)) | (((val as u32) & 0x01) << 10usize);
}
#[doc = "If this flag is set, the engine support a second register set for tunneling operations."]
#[must_use]
#[inline(always)]
pub const fn second_regs_set_exist(&self) -> bool {
let val = (self.0 >> 11usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the engine support a second register set for tunneling operations."]
#[inline(always)]
pub const fn set_second_regs_set_exist(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 11usize)) | (((val as u32) & 0x01) << 11usize);
}
#[doc = "If this flag is set, the engine support DFA countermeasures."]
#[must_use]
#[inline(always)]
pub const fn dfa_cntrmsr_exist(&self) -> bool {
let val = (self.0 >> 12usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the engine support DFA countermeasures."]
#[inline(always)]
pub const fn set_dfa_cntrmsr_exist(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 12usize)) | (((val as u32) & 0x01) << 12usize);
}
}
impl Default for AesHwFlags {
#[inline(always)]
fn default() -> AesHwFlags {
AesHwFlags(0)
}
}
impl core::fmt::Debug for AesHwFlags {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("AesHwFlags")
.field("support_256_192_key", &self.support_256_192_key())
.field("aes_large_rkek", &self.aes_large_rkek())
.field("dpa_cntrmsr_exist", &self.dpa_cntrmsr_exist())
.field("ctr_exist", &self.ctr_exist())
.field("only_encrypt", &self.only_encrypt())
.field("use_sbox_table", &self.use_sbox_table())
.field("use_5_sboxes", &self.use_5_sboxes())
.field("aes_support_prev_iv", &self.aes_support_prev_iv())
.field("aes_tunnel_exist", &self.aes_tunnel_exist())
.field("second_regs_set_exist", &self.second_regs_set_exist())
.field("dfa_cntrmsr_exist", &self.dfa_cntrmsr_exist())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for AesHwFlags {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "AesHwFlags {{ support_256_192_key: {=bool:?}, aes_large_rkek: {=bool:?}, dpa_cntrmsr_exist: {=bool:?}, ctr_exist: {=bool:?}, only_encrypt: {=bool:?}, use_sbox_table: {=bool:?}, use_5_sboxes: {=bool:?}, aes_support_prev_iv: {=bool:?}, aes_tunnel_exist: {=bool:?}, second_regs_set_exist: {=bool:?}, dfa_cntrmsr_exist: {=bool:?} }}" , self . support_256_192_key () , self . aes_large_rkek () , self . dpa_cntrmsr_exist () , self . ctr_exist () , self . only_encrypt () , self . use_sbox_table () , self . use_5_sboxes () , self . aes_support_prev_iv () , self . aes_tunnel_exist () , self . second_regs_set_exist () , self . dfa_cntrmsr_exist ())
}
}
#[doc = "Writing to this address trigger sampling of the HW key to the AES_KEY_0 register."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct AesSk(pub u32);
impl AesSk {
#[doc = "Sample HW key to AES_KEY_0 registers."]
#[must_use]
#[inline(always)]
pub const fn aes_sk(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Sample HW key to AES_KEY_0 registers."]
#[inline(always)]
pub const fn set_aes_sk(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for AesSk {
#[inline(always)]
fn default() -> AesSk {
AesSk(0)
}
}
impl core::fmt::Debug for AesSk {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("AesSk")
.field("aes_sk", &self.aes_sk())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for AesSk {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "AesSk {{ aes_sk: {=bool:?} }}", self.aes_sk())
}
}
#[doc = "Reset the AES engine."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct AesSwReset(pub u32);
impl AesSwReset {
#[doc = "Writing any value to this address resets the AES engine. The reset takes 4 CPU clock cycles to complete."]
#[must_use]
#[inline(always)]
pub const fn reset(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Writing any value to this address resets the AES engine. The reset takes 4 CPU clock cycles to complete."]
#[inline(always)]
pub const fn set_reset(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for AesSwReset {
#[inline(always)]
fn default() -> AesSwReset {
AesSwReset(0)
}
}
impl core::fmt::Debug for AesSwReset {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("AesSwReset")
.field("reset", &self.reset())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for AesSwReset {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "AesSwReset {{ reset: {=bool:?} }}", self.reset())
}
}
}
pub mod vals {
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum DecKey0 {
#[doc = "Perform AES encryption."]
Encrypt = 0x0,
#[doc = "Perform AES decryption."]
Decrypt = 0x01,
}
impl DecKey0 {
#[inline(always)]
pub const fn from_bits(val: u8) -> DecKey0 {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for DecKey0 {
#[inline(always)]
fn from(val: u8) -> DecKey0 {
DecKey0::from_bits(val)
}
}
impl From<DecKey0> for u8 {
#[inline(always)]
fn from(val: DecKey0) -> u8 {
DecKey0::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum ModeKey0 {
#[doc = "Electronic codebook mode."]
Ecb = 0x0,
#[doc = "Cipher block chaining mode."]
Cbc = 0x01,
#[doc = "Counter mode."]
Ctr = 0x02,
#[doc = "Cipher Block Chaining Message Authentication Code."]
CbcMac = 0x03,
_RESERVED_4 = 0x04,
_RESERVED_5 = 0x05,
_RESERVED_6 = 0x06,
#[doc = "Cipher-based Message Authentication Code."]
Cmac = 0x07,
}
impl ModeKey0 {
#[inline(always)]
pub const fn from_bits(val: u8) -> ModeKey0 {
unsafe { core::mem::transmute(val & 0x07) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for ModeKey0 {
#[inline(always)]
fn from(val: u8) -> ModeKey0 {
ModeKey0::from_bits(val)
}
}
impl From<ModeKey0> for u8 {
#[inline(always)]
fn from(val: ModeKey0) -> u8 {
ModeKey0::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum NkKey0 {
#[doc = "128 bits key length."]
_128bits = 0x0,
_RESERVED_1 = 0x01,
_RESERVED_2 = 0x02,
_RESERVED_3 = 0x03,
}
impl NkKey0 {
#[inline(always)]
pub const fn from_bits(val: u8) -> NkKey0 {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for NkKey0 {
#[inline(always)]
fn from(val: u8) -> NkKey0 {
NkKey0::from_bits(val)
}
}
impl From<NkKey0> for u8 {
#[inline(always)]
fn from(val: NkKey0) -> u8 {
NkKey0::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Status {
#[doc = "AES engine is idle."]
Idle = 0x0,
#[doc = "AES engine is busy."]
Busy = 0x01,
}
impl Status {
#[inline(always)]
pub const fn from_bits(val: u8) -> Status {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Status {
#[inline(always)]
fn from(val: u8) -> Status {
Status::from_bits(val)
}
}
impl From<Status> for u8 {
#[inline(always)]
fn from(val: Status) -> u8 {
Status::to_bits(val)
}
}
}
}
pub mod cc_chacha {
#[doc = "CRYPTOCELL CHACHA engine."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct CcChacha {
ptr: *mut u8,
}
unsafe impl Send for CcChacha {}
unsafe impl Sync for CcChacha {}
impl CcChacha {
#[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 = "Control the CHACHA engine behavior."]
#[inline(always)]
pub const fn chacha_control(
self,
) -> crate::common::Reg<regs::ChachaControl, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0380usize) as _) }
}
#[doc = "CHACHA engine HW version."]
#[inline(always)]
pub const fn chacha_version(self) -> crate::common::Reg<u32, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0384usize) as _) }
}
#[doc = "Description collection: CHACHA key value to use. The initial CHACHA_KEY\\[0\\] register holds the least significant bits \\[31:0\\] of the key value."]
#[inline(always)]
pub const fn chacha_key(self, n: usize) -> crate::common::Reg<u32, crate::common::W> {
assert!(n < 8usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0388usize + n * 4usize) as _)
}
}
#[doc = "Description collection: CHACHA Initialization Vector (IV) to use. The IV is also known as the nonce."]
#[inline(always)]
pub const fn chacha_iv(self, n: usize) -> crate::common::Reg<u32, crate::common::RW> {
assert!(n < 2usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x03a8usize + n * 4usize) as _)
}
}
#[doc = "Status register for CHACHA engine activity."]
#[inline(always)]
pub const fn chacha_busy(self) -> crate::common::Reg<regs::ChachaBusy, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x03b0usize) as _) }
}
#[doc = "Hardware configuration of the CHACHA engine. Reset value holds the supported features."]
#[inline(always)]
pub const fn chacha_hw_flags(
self,
) -> crate::common::Reg<regs::ChachaHwFlags, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x03b4usize) as _) }
}
#[doc = "Store the LSB value of the block counter, in order to support suspend/resume of operation."]
#[inline(always)]
pub const fn chacha_block_cnt_lsb(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x03b8usize) as _) }
}
#[doc = "Store the MSB value of the block counter, in order to support suspend/resume of operation."]
#[inline(always)]
pub const fn chacha_block_cnt_msb(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x03bcusize) as _) }
}
#[doc = "Reset the CHACHA engine."]
#[inline(always)]
pub const fn chacha_sw_reset(
self,
) -> crate::common::Reg<regs::ChachaSwReset, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x03c0usize) as _) }
}
#[doc = "Description collection: The auto-generated key to use in Poly1305 MAC calculation. The initial CHACHA_POLY1305_KEY\\[0\\] register holds the least significant bits \\[31:0\\] of the key value."]
#[inline(always)]
pub const fn chacha_poly1305_key(
self,
n: usize,
) -> crate::common::Reg<u32, crate::common::R> {
assert!(n < 8usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x03c4usize + n * 4usize) as _)
}
}
#[doc = "CHACHA engine data order configuration."]
#[inline(always)]
pub const fn chacha_endianness(
self,
) -> crate::common::Reg<regs::ChachaEndianness, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x03e4usize) as _) }
}
#[doc = "Debug register for the CHACHA engine."]
#[inline(always)]
pub const fn chacha_debug(self) -> crate::common::Reg<regs::ChachaDebug, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x03e8usize) as _) }
}
}
pub mod regs {
#[doc = "Status register for CHACHA engine activity."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct ChachaBusy(pub u32);
impl ChachaBusy {
#[doc = "CHACHA engine status."]
#[must_use]
#[inline(always)]
pub const fn status(&self) -> super::vals::Status {
let val = (self.0 >> 0usize) & 0x01;
super::vals::Status::from_bits(val as u8)
}
#[doc = "CHACHA engine status."]
#[inline(always)]
pub const fn set_status(&mut self, val: super::vals::Status) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
}
impl Default for ChachaBusy {
#[inline(always)]
fn default() -> ChachaBusy {
ChachaBusy(0)
}
}
impl core::fmt::Debug for ChachaBusy {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("ChachaBusy")
.field("status", &self.status())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for ChachaBusy {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "ChachaBusy {{ status: {:?} }}", self.status())
}
}
#[doc = "Control the CHACHA engine behavior."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct ChachaControl(pub u32);
impl ChachaControl {
#[doc = "Run engine in ChaCha or Salsa mode."]
#[must_use]
#[inline(always)]
pub const fn chacha_or_salsa(&self) -> super::vals::ChachaOrSalsa {
let val = (self.0 >> 0usize) & 0x01;
super::vals::ChachaOrSalsa::from_bits(val as u8)
}
#[doc = "Run engine in ChaCha or Salsa mode."]
#[inline(always)]
pub const fn set_chacha_or_salsa(&mut self, val: super::vals::ChachaOrSalsa) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
#[doc = "Perform initialization for a new message."]
#[must_use]
#[inline(always)]
pub const fn init(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Perform initialization for a new message."]
#[inline(always)]
pub const fn set_init(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "Generate the key to use in Poly1305 message authentication code calculation."]
#[must_use]
#[inline(always)]
pub const fn gen_key_poly1305(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Generate the key to use in Poly1305 message authentication code calculation."]
#[inline(always)]
pub const fn set_gen_key_poly1305(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "Key length selection."]
#[must_use]
#[inline(always)]
pub const fn key_len(&self) -> super::vals::KeyLen {
let val = (self.0 >> 3usize) & 0x01;
super::vals::KeyLen::from_bits(val as u8)
}
#[doc = "Key length selection."]
#[inline(always)]
pub const fn set_key_len(&mut self, val: super::vals::KeyLen) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val.to_bits() as u32) & 0x01) << 3usize);
}
#[doc = "Set number of permutation rounds, default value is 20."]
#[must_use]
#[inline(always)]
pub const fn num_of_rounds(&self) -> super::vals::NumOfRounds {
let val = (self.0 >> 4usize) & 0x03;
super::vals::NumOfRounds::from_bits(val as u8)
}
#[doc = "Set number of permutation rounds, default value is 20."]
#[inline(always)]
pub const fn set_num_of_rounds(&mut self, val: super::vals::NumOfRounds) {
self.0 = (self.0 & !(0x03 << 4usize)) | (((val.to_bits() as u32) & 0x03) << 4usize);
}
#[doc = "Reset block counter for new messages."]
#[must_use]
#[inline(always)]
pub const fn reset_block_cnt(&self) -> bool {
let val = (self.0 >> 9usize) & 0x01;
val != 0
}
#[doc = "Reset block counter for new messages."]
#[inline(always)]
pub const fn set_reset_block_cnt(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 9usize)) | (((val as u32) & 0x01) << 9usize);
}
#[doc = "Use 96 bits Initialization Vector (IV)."]
#[must_use]
#[inline(always)]
pub const fn use_iv_96bit(&self) -> bool {
let val = (self.0 >> 10usize) & 0x01;
val != 0
}
#[doc = "Use 96 bits Initialization Vector (IV)."]
#[inline(always)]
pub const fn set_use_iv_96bit(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 10usize)) | (((val as u32) & 0x01) << 10usize);
}
}
impl Default for ChachaControl {
#[inline(always)]
fn default() -> ChachaControl {
ChachaControl(0)
}
}
impl core::fmt::Debug for ChachaControl {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("ChachaControl")
.field("chacha_or_salsa", &self.chacha_or_salsa())
.field("init", &self.init())
.field("gen_key_poly1305", &self.gen_key_poly1305())
.field("key_len", &self.key_len())
.field("num_of_rounds", &self.num_of_rounds())
.field("reset_block_cnt", &self.reset_block_cnt())
.field("use_iv_96bit", &self.use_iv_96bit())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for ChachaControl {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "ChachaControl {{ chacha_or_salsa: {:?}, init: {=bool:?}, gen_key_poly1305: {=bool:?}, key_len: {:?}, num_of_rounds: {:?}, reset_block_cnt: {=bool:?}, use_iv_96bit: {=bool:?} }}" , self . chacha_or_salsa () , self . init () , self . gen_key_poly1305 () , self . key_len () , self . num_of_rounds () , self . reset_block_cnt () , self . use_iv_96bit ())
}
}
#[doc = "Debug register for the CHACHA engine."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct ChachaDebug(pub u32);
impl ChachaDebug {
#[doc = "Reflects the debug state of the CHACHA FSM."]
#[must_use]
#[inline(always)]
pub const fn fsm_state(&self) -> super::vals::FsmState {
let val = (self.0 >> 0usize) & 0x03;
super::vals::FsmState::from_bits(val as u8)
}
#[doc = "Reflects the debug state of the CHACHA FSM."]
#[inline(always)]
pub const fn set_fsm_state(&mut self, val: super::vals::FsmState) {
self.0 = (self.0 & !(0x03 << 0usize)) | (((val.to_bits() as u32) & 0x03) << 0usize);
}
}
impl Default for ChachaDebug {
#[inline(always)]
fn default() -> ChachaDebug {
ChachaDebug(0)
}
}
impl core::fmt::Debug for ChachaDebug {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("ChachaDebug")
.field("fsm_state", &self.fsm_state())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for ChachaDebug {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "ChachaDebug {{ fsm_state: {:?} }}", self.fsm_state())
}
}
#[doc = "CHACHA engine data order configuration."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct ChachaEndianness(pub u32);
impl ChachaEndianness {
#[doc = "Change the word order of the input data."]
#[must_use]
#[inline(always)]
pub const fn chacha_din_word_order(&self) -> super::vals::ChachaDinWordOrder {
let val = (self.0 >> 0usize) & 0x01;
super::vals::ChachaDinWordOrder::from_bits(val as u8)
}
#[doc = "Change the word order of the input data."]
#[inline(always)]
pub const fn set_chacha_din_word_order(
&mut self,
val: super::vals::ChachaDinWordOrder,
) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
#[doc = "Change the byte order of the input data."]
#[must_use]
#[inline(always)]
pub const fn chacha_din_byte_order(&self) -> super::vals::ChachaDinByteOrder {
let val = (self.0 >> 1usize) & 0x01;
super::vals::ChachaDinByteOrder::from_bits(val as u8)
}
#[doc = "Change the byte order of the input data."]
#[inline(always)]
pub const fn set_chacha_din_byte_order(
&mut self,
val: super::vals::ChachaDinByteOrder,
) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val.to_bits() as u32) & 0x01) << 1usize);
}
#[doc = "Change the quarter of a matrix order in the engine."]
#[must_use]
#[inline(always)]
pub const fn chacha_core_matrix_lbe_order(
&self,
) -> super::vals::ChachaCoreMatrixLbeOrder {
let val = (self.0 >> 2usize) & 0x01;
super::vals::ChachaCoreMatrixLbeOrder::from_bits(val as u8)
}
#[doc = "Change the quarter of a matrix order in the engine."]
#[inline(always)]
pub const fn set_chacha_core_matrix_lbe_order(
&mut self,
val: super::vals::ChachaCoreMatrixLbeOrder,
) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val.to_bits() as u32) & 0x01) << 2usize);
}
#[doc = "Change the word order of the output data."]
#[must_use]
#[inline(always)]
pub const fn chacha_dout_word_order(&self) -> super::vals::ChachaDoutWordOrder {
let val = (self.0 >> 3usize) & 0x01;
super::vals::ChachaDoutWordOrder::from_bits(val as u8)
}
#[doc = "Change the word order of the output data."]
#[inline(always)]
pub const fn set_chacha_dout_word_order(
&mut self,
val: super::vals::ChachaDoutWordOrder,
) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val.to_bits() as u32) & 0x01) << 3usize);
}
#[doc = "Change the byte order of the output data."]
#[must_use]
#[inline(always)]
pub const fn chacha_dout_byte_order(&self) -> super::vals::ChachaDoutByteOrder {
let val = (self.0 >> 4usize) & 0x01;
super::vals::ChachaDoutByteOrder::from_bits(val as u8)
}
#[doc = "Change the byte order of the output data."]
#[inline(always)]
pub const fn set_chacha_dout_byte_order(
&mut self,
val: super::vals::ChachaDoutByteOrder,
) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val.to_bits() as u32) & 0x01) << 4usize);
}
}
impl Default for ChachaEndianness {
#[inline(always)]
fn default() -> ChachaEndianness {
ChachaEndianness(0)
}
}
impl core::fmt::Debug for ChachaEndianness {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("ChachaEndianness")
.field("chacha_din_word_order", &self.chacha_din_word_order())
.field("chacha_din_byte_order", &self.chacha_din_byte_order())
.field(
"chacha_core_matrix_lbe_order",
&self.chacha_core_matrix_lbe_order(),
)
.field("chacha_dout_word_order", &self.chacha_dout_word_order())
.field("chacha_dout_byte_order", &self.chacha_dout_byte_order())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for ChachaEndianness {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "ChachaEndianness {{ chacha_din_word_order: {:?}, chacha_din_byte_order: {:?}, chacha_core_matrix_lbe_order: {:?}, chacha_dout_word_order: {:?}, chacha_dout_byte_order: {:?} }}" , self . chacha_din_word_order () , self . chacha_din_byte_order () , self . chacha_core_matrix_lbe_order () , self . chacha_dout_word_order () , self . chacha_dout_byte_order ())
}
}
#[doc = "Hardware configuration of the CHACHA engine. Reset value holds the supported features."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct ChachaHwFlags(pub u32);
impl ChachaHwFlags {
#[doc = "If this flag is set, the engine include ChaCha support."]
#[must_use]
#[inline(always)]
pub const fn chacha_exists(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the engine include ChaCha support."]
#[inline(always)]
pub const fn set_chacha_exists(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "If this flag is set, the engine include Salsa support."]
#[must_use]
#[inline(always)]
pub const fn salsa_exists(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the engine include Salsa support."]
#[inline(always)]
pub const fn set_salsa_exists(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "If this flag is set, the next matrix calculated when the current one is written to data output path."]
#[must_use]
#[inline(always)]
pub const fn fast_chacha(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the next matrix calculated when the current one is written to data output path."]
#[inline(always)]
pub const fn set_fast_chacha(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
}
impl Default for ChachaHwFlags {
#[inline(always)]
fn default() -> ChachaHwFlags {
ChachaHwFlags(0)
}
}
impl core::fmt::Debug for ChachaHwFlags {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("ChachaHwFlags")
.field("chacha_exists", &self.chacha_exists())
.field("salsa_exists", &self.salsa_exists())
.field("fast_chacha", &self.fast_chacha())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for ChachaHwFlags {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "ChachaHwFlags {{ chacha_exists: {=bool:?}, salsa_exists: {=bool:?}, fast_chacha: {=bool:?} }}" , self . chacha_exists () , self . salsa_exists () , self . fast_chacha ())
}
}
#[doc = "Reset the CHACHA engine."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct ChachaSwReset(pub u32);
impl ChachaSwReset {
#[doc = "Writing any value to this address resets the CHACHA engine. The reset takes 4 CPU clock cycles to complete."]
#[must_use]
#[inline(always)]
pub const fn reset(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Writing any value to this address resets the CHACHA engine. The reset takes 4 CPU clock cycles to complete."]
#[inline(always)]
pub const fn set_reset(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for ChachaSwReset {
#[inline(always)]
fn default() -> ChachaSwReset {
ChachaSwReset(0)
}
}
impl core::fmt::Debug for ChachaSwReset {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("ChachaSwReset")
.field("reset", &self.reset())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for ChachaSwReset {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "ChachaSwReset {{ reset: {=bool:?} }}", self.reset())
}
}
}
pub mod vals {
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum ChachaCoreMatrixLbeOrder {
#[doc = "Use default quarter of matrix order, where quarters are ordered as follows: q0, q1, q2, q3. Each quarter represents a 128-bits section of the matrix."]
Default = 0x0,
#[doc = "Reverse the order of matrix quarters, where quarters are re-ordered as follows: q3, q2, q1, q0. Each quarter represents a 128-bits section of the matrix."]
Reverse = 0x01,
}
impl ChachaCoreMatrixLbeOrder {
#[inline(always)]
pub const fn from_bits(val: u8) -> ChachaCoreMatrixLbeOrder {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for ChachaCoreMatrixLbeOrder {
#[inline(always)]
fn from(val: u8) -> ChachaCoreMatrixLbeOrder {
ChachaCoreMatrixLbeOrder::from_bits(val)
}
}
impl From<ChachaCoreMatrixLbeOrder> for u8 {
#[inline(always)]
fn from(val: ChachaCoreMatrixLbeOrder) -> u8 {
ChachaCoreMatrixLbeOrder::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum ChachaDinByteOrder {
#[doc = "Use default byte order within each input word, where bytes are ordered as follows: B0, B1, B2, B3."]
Default = 0x0,
#[doc = "Reverse the byte order within each input word, where bytes are re-ordered as follows: B3, B2, B1, B0."]
Reverse = 0x01,
}
impl ChachaDinByteOrder {
#[inline(always)]
pub const fn from_bits(val: u8) -> ChachaDinByteOrder {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for ChachaDinByteOrder {
#[inline(always)]
fn from(val: u8) -> ChachaDinByteOrder {
ChachaDinByteOrder::from_bits(val)
}
}
impl From<ChachaDinByteOrder> for u8 {
#[inline(always)]
fn from(val: ChachaDinByteOrder) -> u8 {
ChachaDinByteOrder::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum ChachaDinWordOrder {
#[doc = "Use default word order for 128-bits input, where words are ordered as follows: w0, w1, w2, w3."]
Default = 0x0,
#[doc = "Reverses the word order for 128-bits input, where words are re-ordered as follows: w3, w2, w1, w0."]
Reverse = 0x01,
}
impl ChachaDinWordOrder {
#[inline(always)]
pub const fn from_bits(val: u8) -> ChachaDinWordOrder {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for ChachaDinWordOrder {
#[inline(always)]
fn from(val: u8) -> ChachaDinWordOrder {
ChachaDinWordOrder::from_bits(val)
}
}
impl From<ChachaDinWordOrder> for u8 {
#[inline(always)]
fn from(val: ChachaDinWordOrder) -> u8 {
ChachaDinWordOrder::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum ChachaDoutByteOrder {
#[doc = "Use default byte order within each output word, where bytes are ordered as follows: B0, B1, B2, B3."]
Default = 0x0,
#[doc = "Reverse the byte order within each output word, where bytes are re-ordered as follows: B3, B2, B1, B0."]
Reverse = 0x01,
}
impl ChachaDoutByteOrder {
#[inline(always)]
pub const fn from_bits(val: u8) -> ChachaDoutByteOrder {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for ChachaDoutByteOrder {
#[inline(always)]
fn from(val: u8) -> ChachaDoutByteOrder {
ChachaDoutByteOrder::from_bits(val)
}
}
impl From<ChachaDoutByteOrder> for u8 {
#[inline(always)]
fn from(val: ChachaDoutByteOrder) -> u8 {
ChachaDoutByteOrder::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum ChachaDoutWordOrder {
#[doc = "Uses default word order for 128-bits output, where words are ordered as follows: w0, w1, w2, w3."]
Default = 0x0,
#[doc = "Reverse the word order for 128-bits output, where words are re-ordered as follows: w3, w2, w1, w0."]
Reverse = 0x01,
}
impl ChachaDoutWordOrder {
#[inline(always)]
pub const fn from_bits(val: u8) -> ChachaDoutWordOrder {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for ChachaDoutWordOrder {
#[inline(always)]
fn from(val: u8) -> ChachaDoutWordOrder {
ChachaDoutWordOrder::from_bits(val)
}
}
impl From<ChachaDoutWordOrder> for u8 {
#[inline(always)]
fn from(val: ChachaDoutWordOrder) -> u8 {
ChachaDoutWordOrder::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum ChachaOrSalsa {
#[doc = "Run engine in ChaCha mode."]
ChaCha = 0x0,
#[doc = "Run engine in Salsa mode."]
Salsa = 0x01,
}
impl ChachaOrSalsa {
#[inline(always)]
pub const fn from_bits(val: u8) -> ChachaOrSalsa {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for ChachaOrSalsa {
#[inline(always)]
fn from(val: u8) -> ChachaOrSalsa {
ChachaOrSalsa::from_bits(val)
}
}
impl From<ChachaOrSalsa> for u8 {
#[inline(always)]
fn from(val: ChachaOrSalsa) -> u8 {
ChachaOrSalsa::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum FsmState {
#[doc = "CHACHA FSM is in idle state."]
IdleState = 0x0,
#[doc = "CHACHA FSM is in init state."]
InitState = 0x01,
#[doc = "CHACHA FSM is in rounds state."]
RoundsState = 0x02,
#[doc = "CHACHA FSM is in final state."]
FinalState = 0x03,
}
impl FsmState {
#[inline(always)]
pub const fn from_bits(val: u8) -> FsmState {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for FsmState {
#[inline(always)]
fn from(val: u8) -> FsmState {
FsmState::from_bits(val)
}
}
impl From<FsmState> for u8 {
#[inline(always)]
fn from(val: FsmState) -> u8 {
FsmState::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum KeyLen {
#[doc = "Use 256 bits key length."]
_256bits = 0x0,
#[doc = "Use 128 bits key length."]
_128bits = 0x01,
}
impl KeyLen {
#[inline(always)]
pub const fn from_bits(val: u8) -> KeyLen {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for KeyLen {
#[inline(always)]
fn from(val: u8) -> KeyLen {
KeyLen::from_bits(val)
}
}
impl From<KeyLen> for u8 {
#[inline(always)]
fn from(val: KeyLen) -> u8 {
KeyLen::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum NumOfRounds {
#[doc = "Use 20 rounds of rotation (default)."]
Default = 0x0,
#[doc = "Use 12 rounds of rotation."]
_12rounds = 0x01,
#[doc = "Use 8 rounds of rotation."]
_8rounds = 0x02,
_RESERVED_3 = 0x03,
}
impl NumOfRounds {
#[inline(always)]
pub const fn from_bits(val: u8) -> NumOfRounds {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for NumOfRounds {
#[inline(always)]
fn from(val: u8) -> NumOfRounds {
NumOfRounds::from_bits(val)
}
}
impl From<NumOfRounds> for u8 {
#[inline(always)]
fn from(val: NumOfRounds) -> u8 {
NumOfRounds::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Status {
#[doc = "CHACHA engine is idle."]
Idle = 0x0,
#[doc = "CHACHA engine is busy."]
Busy = 0x01,
}
impl Status {
#[inline(always)]
pub const fn from_bits(val: u8) -> Status {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Status {
#[inline(always)]
fn from(val: u8) -> Status {
Status::from_bits(val)
}
}
impl From<Status> for u8 {
#[inline(always)]
fn from(val: Status) -> u8 {
Status::to_bits(val)
}
}
}
}
pub mod cc_ctl {
#[doc = "CRYPTOCELL CTL interface."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct CcCtl {
ptr: *mut u8,
}
unsafe impl Send for CcCtl {}
unsafe impl Sync for CcCtl {}
impl CcCtl {
#[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 = "Defines the cryptographic flow."]
#[inline(always)]
pub const fn crypto_ctl(self) -> crate::common::Reg<regs::CryptoCtl, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0900usize) as _) }
}
#[doc = "Status register for cryptographic cores engine activity."]
#[inline(always)]
pub const fn crypto_busy(self) -> crate::common::Reg<regs::CryptoBusy, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0910usize) as _) }
}
#[doc = "Status register for HASH engine activity."]
#[inline(always)]
pub const fn hash_busy(self) -> crate::common::Reg<regs::HashBusy, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x091cusize) as _) }
}
#[doc = "A general-purpose read/write register."]
#[inline(always)]
pub const fn context_id(self) -> crate::common::Reg<regs::ContextId, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0930usize) as _) }
}
}
pub mod regs {
#[doc = "A general-purpose read/write register."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct ContextId(pub u32);
impl ContextId {
#[doc = "Context ID."]
#[must_use]
#[inline(always)]
pub const fn context_id(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "Context ID."]
#[inline(always)]
pub const fn set_context_id(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
}
impl Default for ContextId {
#[inline(always)]
fn default() -> ContextId {
ContextId(0)
}
}
impl core::fmt::Debug for ContextId {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("ContextId")
.field("context_id", &self.context_id())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for ContextId {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "ContextId {{ context_id: {=u8:?} }}", self.context_id())
}
}
#[doc = "Status register for cryptographic cores engine activity."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct CryptoBusy(pub u32);
impl CryptoBusy {
#[doc = "Cryptographic core engines status."]
#[must_use]
#[inline(always)]
pub const fn status(&self) -> super::vals::CryptoBusyStatus {
let val = (self.0 >> 0usize) & 0x01;
super::vals::CryptoBusyStatus::from_bits(val as u8)
}
#[doc = "Cryptographic core engines status."]
#[inline(always)]
pub const fn set_status(&mut self, val: super::vals::CryptoBusyStatus) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
}
impl Default for CryptoBusy {
#[inline(always)]
fn default() -> CryptoBusy {
CryptoBusy(0)
}
}
impl core::fmt::Debug for CryptoBusy {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("CryptoBusy")
.field("status", &self.status())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for CryptoBusy {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "CryptoBusy {{ status: {:?} }}", self.status())
}
}
#[doc = "Defines the cryptographic flow."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct CryptoCtl(pub u32);
impl CryptoCtl {
#[doc = "Configure the cryptographic engine mode."]
#[must_use]
#[inline(always)]
pub const fn mode(&self) -> super::vals::Mode {
let val = (self.0 >> 0usize) & 0x1f;
super::vals::Mode::from_bits(val as u8)
}
#[doc = "Configure the cryptographic engine mode."]
#[inline(always)]
pub const fn set_mode(&mut self, val: super::vals::Mode) {
self.0 = (self.0 & !(0x1f << 0usize)) | (((val.to_bits() as u32) & 0x1f) << 0usize);
}
}
impl Default for CryptoCtl {
#[inline(always)]
fn default() -> CryptoCtl {
CryptoCtl(0)
}
}
impl core::fmt::Debug for CryptoCtl {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("CryptoCtl")
.field("mode", &self.mode())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for CryptoCtl {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "CryptoCtl {{ mode: {:?} }}", self.mode())
}
}
#[doc = "Status register for HASH engine activity."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct HashBusy(pub u32);
impl HashBusy {
#[doc = "Hash engine status."]
#[must_use]
#[inline(always)]
pub const fn status(&self) -> super::vals::HashBusyStatus {
let val = (self.0 >> 0usize) & 0x01;
super::vals::HashBusyStatus::from_bits(val as u8)
}
#[doc = "Hash engine status."]
#[inline(always)]
pub const fn set_status(&mut self, val: super::vals::HashBusyStatus) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
}
impl Default for HashBusy {
#[inline(always)]
fn default() -> HashBusy {
HashBusy(0)
}
}
impl core::fmt::Debug for HashBusy {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("HashBusy")
.field("status", &self.status())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for HashBusy {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "HashBusy {{ status: {:?} }}", self.status())
}
}
}
pub mod vals {
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum CryptoBusyStatus {
#[doc = "Cryptographic core engines are idle."]
Idle = 0x0,
#[doc = "Cryptographic core engines are busy."]
Busy = 0x01,
}
impl CryptoBusyStatus {
#[inline(always)]
pub const fn from_bits(val: u8) -> CryptoBusyStatus {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for CryptoBusyStatus {
#[inline(always)]
fn from(val: u8) -> CryptoBusyStatus {
CryptoBusyStatus::from_bits(val)
}
}
impl From<CryptoBusyStatus> for u8 {
#[inline(always)]
fn from(val: CryptoBusyStatus) -> u8 {
CryptoBusyStatus::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum HashBusyStatus {
#[doc = "HASH engine is idle."]
Idle = 0x0,
#[doc = "HASH engine is busy."]
Busy = 0x01,
}
impl HashBusyStatus {
#[inline(always)]
pub const fn from_bits(val: u8) -> HashBusyStatus {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for HashBusyStatus {
#[inline(always)]
fn from(val: u8) -> HashBusyStatus {
HashBusyStatus::from_bits(val)
}
}
impl From<HashBusyStatus> for u8 {
#[inline(always)]
fn from(val: HashBusyStatus) -> u8 {
HashBusyStatus::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Mode {
#[doc = "Bypass cryptographic engine."]
Bypass = 0x0,
#[doc = "Use AES engine."]
AesActive = 0x01,
#[doc = "Pipe AES engine output to HASH engine input."]
AesToHashActive = 0x02,
#[doc = "Process input using both AES and HASH engine in parallell."]
AesAndHashActive = 0x03,
_RESERVED_4 = 0x04,
_RESERVED_5 = 0x05,
_RESERVED_6 = 0x06,
#[doc = "Use HASH engine."]
HashActive = 0x07,
_RESERVED_8 = 0x08,
#[doc = "Calculate AES MAC and bypass."]
AesmacAndBypassActive = 0x09,
#[doc = "Pipe AES engine output to HASH engine input. The resulting digest output is piped to DOUT buffer."]
AesToHashAndDoutActive = 0x0a,
_RESERVED_b = 0x0b,
_RESERVED_c = 0x0c,
_RESERVED_d = 0x0d,
_RESERVED_e = 0x0e,
_RESERVED_f = 0x0f,
#[doc = "Use CHACHA engine."]
ChaChaActive = 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 Mode {
#[inline(always)]
pub const fn from_bits(val: u8) -> Mode {
unsafe { core::mem::transmute(val & 0x1f) }
}
#[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 cc_din {
#[doc = "CRYPTOCELL Data IN interface."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct CcDin {
ptr: *mut u8,
}
unsafe impl Send for CcDin {}
unsafe impl Sync for CcDin {}
impl CcDin {
#[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 = "Used by CPU to write data directly to the DIN buffer, which is then sent to the cryptographic engines for processing."]
#[inline(always)]
pub const fn din_buffer(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0c00usize) as _) }
}
#[doc = "Status register for DIN DMA engine activity when accessing memory."]
#[inline(always)]
pub const fn din_dma_mem_busy(
self,
) -> crate::common::Reg<regs::DinDmaMemBusy, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0c20usize) as _) }
}
#[doc = "Data source address in memory."]
#[inline(always)]
pub const fn src_mem_addr(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0c28usize) as _) }
}
#[doc = "The number of bytes to be read from memory. Writing to this register triggers the DMA operation."]
#[inline(always)]
pub const fn src_mem_size(self) -> crate::common::Reg<regs::SrcMemSize, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0c2cusize) as _) }
}
#[doc = "Data source address in RNG SRAM."]
#[inline(always)]
pub const fn src_sram_addr(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0c30usize) as _) }
}
#[doc = "The number of bytes to be read from RNG SRAM. Writing to this register triggers the DMA operation."]
#[inline(always)]
pub const fn src_sram_size(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0c34usize) as _) }
}
#[doc = "Status register for DIN DMA engine activity when accessing RNG SRAM."]
#[inline(always)]
pub const fn din_dma_sram_busy(
self,
) -> crate::common::Reg<regs::DinDmaSramBusy, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0c38usize) as _) }
}
#[doc = "Configure the endianness of DIN DMA transactions towards RNG SRAM."]
#[inline(always)]
pub const fn din_dma_sram_endianness(
self,
) -> crate::common::Reg<regs::DinDmaSramEndianness, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0c3cusize) as _) }
}
#[doc = "Reset the DIN DMA engine."]
#[inline(always)]
pub const fn din_sw_reset(self) -> crate::common::Reg<regs::DinSwReset, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0c44usize) as _) }
}
#[doc = "Specifies the number of bytes the CPU will write to the DIN_BUFFER, ensuring the cryptographic engine processes the correct amount of data."]
#[inline(always)]
pub const fn din_cpu_data(self) -> crate::common::Reg<regs::DinCpuData, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0c48usize) as _) }
}
#[doc = "Indicates that the next CPU write to the DIN_BUFFER is the last in the sequence. This is needed only when the data size is NOT modulo 4 (e.g. HASH padding)."]
#[inline(always)]
pub const fn din_write_align(
self,
) -> crate::common::Reg<regs::DinWriteAlign, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0c4cusize) as _) }
}
#[doc = "Register indicating if DIN FIFO is empty and if more data can be accepted."]
#[inline(always)]
pub const fn din_fifo_empty(
self,
) -> crate::common::Reg<regs::DinFifoEmpty, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0c50usize) as _) }
}
#[doc = "Reset the DIN FIFO, effectively clearing the FIFO for new data."]
#[inline(always)]
pub const fn din_fifo_reset(
self,
) -> crate::common::Reg<regs::DinFifoReset, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0c58usize) as _) }
}
}
pub mod regs {
#[doc = "Specifies the number of bytes the CPU will write to the DIN_BUFFER, ensuring the cryptographic engine processes the correct amount of data."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct DinCpuData(pub u32);
impl DinCpuData {
#[doc = "When using CPU direct write to the DIN_BUFFER, the size of input data in bytes should be written to this register."]
#[must_use]
#[inline(always)]
pub const fn size(&self) -> u16 {
let val = (self.0 >> 0usize) & 0xffff;
val as u16
}
#[doc = "When using CPU direct write to the DIN_BUFFER, the size of input data in bytes should be written to this register."]
#[inline(always)]
pub const fn set_size(&mut self, val: u16) {
self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize);
}
}
impl Default for DinCpuData {
#[inline(always)]
fn default() -> DinCpuData {
DinCpuData(0)
}
}
impl core::fmt::Debug for DinCpuData {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("DinCpuData")
.field("size", &self.size())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for DinCpuData {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "DinCpuData {{ size: {=u16:?} }}", self.size())
}
}
#[doc = "Status register for DIN DMA engine activity when accessing memory."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct DinDmaMemBusy(pub u32);
impl DinDmaMemBusy {
#[doc = "DIN memory DMA engine status."]
#[must_use]
#[inline(always)]
pub const fn status(&self) -> super::vals::DinDmaMemBusyStatus {
let val = (self.0 >> 0usize) & 0x01;
super::vals::DinDmaMemBusyStatus::from_bits(val as u8)
}
#[doc = "DIN memory DMA engine status."]
#[inline(always)]
pub const fn set_status(&mut self, val: super::vals::DinDmaMemBusyStatus) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
}
impl Default for DinDmaMemBusy {
#[inline(always)]
fn default() -> DinDmaMemBusy {
DinDmaMemBusy(0)
}
}
impl core::fmt::Debug for DinDmaMemBusy {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("DinDmaMemBusy")
.field("status", &self.status())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for DinDmaMemBusy {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "DinDmaMemBusy {{ status: {:?} }}", self.status())
}
}
#[doc = "Status register for DIN DMA engine activity when accessing RNG SRAM."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct DinDmaSramBusy(pub u32);
impl DinDmaSramBusy {
#[doc = "DIN RNG SRAM DMA engine status."]
#[must_use]
#[inline(always)]
pub const fn status(&self) -> super::vals::DinDmaSramBusyStatus {
let val = (self.0 >> 0usize) & 0x01;
super::vals::DinDmaSramBusyStatus::from_bits(val as u8)
}
#[doc = "DIN RNG SRAM DMA engine status."]
#[inline(always)]
pub const fn set_status(&mut self, val: super::vals::DinDmaSramBusyStatus) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
}
impl Default for DinDmaSramBusy {
#[inline(always)]
fn default() -> DinDmaSramBusy {
DinDmaSramBusy(0)
}
}
impl core::fmt::Debug for DinDmaSramBusy {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("DinDmaSramBusy")
.field("status", &self.status())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for DinDmaSramBusy {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "DinDmaSramBusy {{ status: {:?} }}", self.status())
}
}
#[doc = "Configure the endianness of DIN DMA transactions towards RNG SRAM."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct DinDmaSramEndianness(pub u32);
impl DinDmaSramEndianness {
#[doc = "Endianness of DIN DMA transactions towards RNG SRAM. The default value is little-endian."]
#[must_use]
#[inline(always)]
pub const fn endian(&self) -> super::vals::Endian {
let val = (self.0 >> 0usize) & 0x01;
super::vals::Endian::from_bits(val as u8)
}
#[doc = "Endianness of DIN DMA transactions towards RNG SRAM. The default value is little-endian."]
#[inline(always)]
pub const fn set_endian(&mut self, val: super::vals::Endian) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
}
impl Default for DinDmaSramEndianness {
#[inline(always)]
fn default() -> DinDmaSramEndianness {
DinDmaSramEndianness(0)
}
}
impl core::fmt::Debug for DinDmaSramEndianness {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("DinDmaSramEndianness")
.field("endian", &self.endian())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for DinDmaSramEndianness {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "DinDmaSramEndianness {{ endian: {:?} }}", self.endian())
}
}
#[doc = "Register indicating if DIN FIFO is empty and if more data can be accepted."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct DinFifoEmpty(pub u32);
impl DinFifoEmpty {
#[doc = "DIN FIFO status."]
#[must_use]
#[inline(always)]
pub const fn status(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "DIN FIFO status."]
#[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 DinFifoEmpty {
#[inline(always)]
fn default() -> DinFifoEmpty {
DinFifoEmpty(0)
}
}
impl core::fmt::Debug for DinFifoEmpty {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("DinFifoEmpty")
.field("status", &self.status())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for DinFifoEmpty {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "DinFifoEmpty {{ status: {=bool:?} }}", self.status())
}
}
#[doc = "Reset the DIN FIFO, effectively clearing the FIFO for new data."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct DinFifoReset(pub u32);
impl DinFifoReset {
#[doc = "Writing any value to this address resets the DIN FIFO."]
#[must_use]
#[inline(always)]
pub const fn reset(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Writing any value to this address resets the DIN FIFO."]
#[inline(always)]
pub const fn set_reset(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for DinFifoReset {
#[inline(always)]
fn default() -> DinFifoReset {
DinFifoReset(0)
}
}
impl core::fmt::Debug for DinFifoReset {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("DinFifoReset")
.field("reset", &self.reset())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for DinFifoReset {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "DinFifoReset {{ reset: {=bool:?} }}", self.reset())
}
}
#[doc = "Reset the DIN DMA engine."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct DinSwReset(pub u32);
impl DinSwReset {
#[doc = "Writing any value to this address resets the DIN DMA engine. The reset takes 4 CPU clock cycles to complete."]
#[must_use]
#[inline(always)]
pub const fn reset(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Writing any value to this address resets the DIN DMA engine. The reset takes 4 CPU clock cycles to complete."]
#[inline(always)]
pub const fn set_reset(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for DinSwReset {
#[inline(always)]
fn default() -> DinSwReset {
DinSwReset(0)
}
}
impl core::fmt::Debug for DinSwReset {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("DinSwReset")
.field("reset", &self.reset())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for DinSwReset {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "DinSwReset {{ reset: {=bool:?} }}", self.reset())
}
}
#[doc = "Indicates that the next CPU write to the DIN_BUFFER is the last in the sequence. This is needed only when the data size is NOT modulo 4 (e.g. HASH padding)."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct DinWriteAlign(pub u32);
impl DinWriteAlign {
#[doc = "Next CPU write to the DIN_BUFFER is the last word."]
#[must_use]
#[inline(always)]
pub const fn last(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Next CPU write to the DIN_BUFFER is the last word."]
#[inline(always)]
pub const fn set_last(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for DinWriteAlign {
#[inline(always)]
fn default() -> DinWriteAlign {
DinWriteAlign(0)
}
}
impl core::fmt::Debug for DinWriteAlign {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("DinWriteAlign")
.field("last", &self.last())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for DinWriteAlign {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "DinWriteAlign {{ last: {=bool:?} }}", self.last())
}
}
#[doc = "The number of bytes to be read from memory. Writing to this register triggers the DMA operation."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct SrcMemSize(pub u32);
impl SrcMemSize {
#[doc = "Total number of bytes to read from memory."]
#[must_use]
#[inline(always)]
pub const fn size(&self) -> u32 {
let val = (self.0 >> 0usize) & 0x3fff_ffff;
val as u32
}
#[doc = "Total number of bytes to read from memory."]
#[inline(always)]
pub const fn set_size(&mut self, val: u32) {
self.0 =
(self.0 & !(0x3fff_ffff << 0usize)) | (((val as u32) & 0x3fff_ffff) << 0usize);
}
#[doc = "This field is reserved."]
#[must_use]
#[inline(always)]
pub const fn first(&self) -> bool {
let val = (self.0 >> 30usize) & 0x01;
val != 0
}
#[doc = "This field is reserved."]
#[inline(always)]
pub const fn set_first(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 30usize)) | (((val as u32) & 0x01) << 30usize);
}
#[doc = "This field is reserved."]
#[must_use]
#[inline(always)]
pub const fn last(&self) -> bool {
let val = (self.0 >> 31usize) & 0x01;
val != 0
}
#[doc = "This field is reserved."]
#[inline(always)]
pub const fn set_last(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 31usize)) | (((val as u32) & 0x01) << 31usize);
}
}
impl Default for SrcMemSize {
#[inline(always)]
fn default() -> SrcMemSize {
SrcMemSize(0)
}
}
impl core::fmt::Debug for SrcMemSize {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("SrcMemSize")
.field("size", &self.size())
.field("first", &self.first())
.field("last", &self.last())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for SrcMemSize {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"SrcMemSize {{ size: {=u32:?}, first: {=bool:?}, last: {=bool:?} }}",
self.size(),
self.first(),
self.last()
)
}
}
}
pub mod vals {
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum DinDmaMemBusyStatus {
#[doc = "DIN memory DMA engine is idle."]
Idle = 0x0,
#[doc = "DIN memory DMA engine is busy."]
Busy = 0x01,
}
impl DinDmaMemBusyStatus {
#[inline(always)]
pub const fn from_bits(val: u8) -> DinDmaMemBusyStatus {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for DinDmaMemBusyStatus {
#[inline(always)]
fn from(val: u8) -> DinDmaMemBusyStatus {
DinDmaMemBusyStatus::from_bits(val)
}
}
impl From<DinDmaMemBusyStatus> for u8 {
#[inline(always)]
fn from(val: DinDmaMemBusyStatus) -> u8 {
DinDmaMemBusyStatus::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum DinDmaSramBusyStatus {
#[doc = "DIN RNG SRAM DMA engine is idle."]
Idle = 0x0,
#[doc = "DIN RNG SRAM DMA engine is busy."]
Busy = 0x01,
}
impl DinDmaSramBusyStatus {
#[inline(always)]
pub const fn from_bits(val: u8) -> DinDmaSramBusyStatus {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for DinDmaSramBusyStatus {
#[inline(always)]
fn from(val: u8) -> DinDmaSramBusyStatus {
DinDmaSramBusyStatus::from_bits(val)
}
}
impl From<DinDmaSramBusyStatus> for u8 {
#[inline(always)]
fn from(val: DinDmaSramBusyStatus) -> u8 {
DinDmaSramBusyStatus::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Endian {
#[doc = "Use little-endian format for RNG SRAM DMA transactions."]
LittleEndian = 0x0,
#[doc = "Use big-endian format for RNG SRAM DMA transactions."]
BigEndian = 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)
}
}
}
}
pub mod cc_dout {
#[doc = "CRYPTOCELL Data OUT interface."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct CcDout {
ptr: *mut u8,
}
unsafe impl Send for CcDout {}
unsafe impl Sync for CcDout {}
impl CcDout {
#[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 = "Cryptographic results directly accessible by the CPU."]
#[inline(always)]
pub const fn dout_buffer(self) -> crate::common::Reg<u32, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0c00usize) as _) }
}
#[doc = "Status register for DOUT DMA engine activity when accessing memory."]
#[inline(always)]
pub const fn dout_dma_mem_busy(
self,
) -> crate::common::Reg<regs::DoutDmaMemBusy, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0d20usize) as _) }
}
#[doc = "Data destination address in memory."]
#[inline(always)]
pub const fn dst_mem_addr(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0d28usize) as _) }
}
#[doc = "The number of bytes to be written to memory."]
#[inline(always)]
pub const fn dst_mem_size(self) -> crate::common::Reg<regs::DstMemSize, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0d2cusize) as _) }
}
#[doc = "Data destination address in RNG SRAM."]
#[inline(always)]
pub const fn dst_sram_addr(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0d30usize) as _) }
}
#[doc = "The number of bytes to be written to RNG SRAM."]
#[inline(always)]
pub const fn dst_sram_size(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0d34usize) as _) }
}
#[doc = "Status register for DOUT DMA engine activity when accessing RNG SRAM."]
#[inline(always)]
pub const fn dout_dma_sram_busy(
self,
) -> crate::common::Reg<regs::DoutDmaSramBusy, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0d38usize) as _) }
}
#[doc = "Configure the endianness of DOUT DMA transactions towards RNG SRAM."]
#[inline(always)]
pub const fn dout_dma_sram_endianness(
self,
) -> crate::common::Reg<regs::DoutDmaSramEndianness, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0d3cusize) as _) }
}
#[doc = "Indication that the next CPU read from the DOUT_BUFFER is the last in the sequence. This is needed only when the data size is NOT modulo 4 (e.g. HASH padding)."]
#[inline(always)]
pub const fn dout_read_align(
self,
) -> crate::common::Reg<regs::DoutReadAlign, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0d44usize) as _) }
}
#[doc = "Register indicating if DOUT FIFO is empty or if more data will come."]
#[inline(always)]
pub const fn dout_fifo_empty(
self,
) -> crate::common::Reg<regs::DoutFifoEmpty, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0d50usize) as _) }
}
#[doc = "Reset the DOUT DMA engine."]
#[inline(always)]
pub const fn dout_sw_reset(
self,
) -> crate::common::Reg<regs::DoutSwReset, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0d58usize) as _) }
}
}
pub mod regs {
#[doc = "Status register for DOUT DMA engine activity when accessing memory."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct DoutDmaMemBusy(pub u32);
impl DoutDmaMemBusy {
#[doc = "DOUT memory DMA engine status."]
#[must_use]
#[inline(always)]
pub const fn status(&self) -> super::vals::DoutDmaMemBusyStatus {
let val = (self.0 >> 0usize) & 0x01;
super::vals::DoutDmaMemBusyStatus::from_bits(val as u8)
}
#[doc = "DOUT memory DMA engine status."]
#[inline(always)]
pub const fn set_status(&mut self, val: super::vals::DoutDmaMemBusyStatus) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
}
impl Default for DoutDmaMemBusy {
#[inline(always)]
fn default() -> DoutDmaMemBusy {
DoutDmaMemBusy(0)
}
}
impl core::fmt::Debug for DoutDmaMemBusy {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("DoutDmaMemBusy")
.field("status", &self.status())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for DoutDmaMemBusy {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "DoutDmaMemBusy {{ status: {:?} }}", self.status())
}
}
#[doc = "Status register for DOUT DMA engine activity when accessing RNG SRAM."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct DoutDmaSramBusy(pub u32);
impl DoutDmaSramBusy {
#[doc = "DOUT RNG SRAM DMA engine status."]
#[must_use]
#[inline(always)]
pub const fn status(&self) -> super::vals::DoutDmaSramBusyStatus {
let val = (self.0 >> 0usize) & 0x01;
super::vals::DoutDmaSramBusyStatus::from_bits(val as u8)
}
#[doc = "DOUT RNG SRAM DMA engine status."]
#[inline(always)]
pub const fn set_status(&mut self, val: super::vals::DoutDmaSramBusyStatus) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
}
impl Default for DoutDmaSramBusy {
#[inline(always)]
fn default() -> DoutDmaSramBusy {
DoutDmaSramBusy(0)
}
}
impl core::fmt::Debug for DoutDmaSramBusy {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("DoutDmaSramBusy")
.field("status", &self.status())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for DoutDmaSramBusy {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "DoutDmaSramBusy {{ status: {:?} }}", self.status())
}
}
#[doc = "Configure the endianness of DOUT DMA transactions towards RNG SRAM."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct DoutDmaSramEndianness(pub u32);
impl DoutDmaSramEndianness {
#[doc = "Endianness of DOUT DMA transactions towards RNG SRAM. The default value is little-endian."]
#[must_use]
#[inline(always)]
pub const fn endian(&self) -> super::vals::Endian {
let val = (self.0 >> 0usize) & 0x01;
super::vals::Endian::from_bits(val as u8)
}
#[doc = "Endianness of DOUT DMA transactions towards RNG SRAM. The default value is little-endian."]
#[inline(always)]
pub const fn set_endian(&mut self, val: super::vals::Endian) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
}
impl Default for DoutDmaSramEndianness {
#[inline(always)]
fn default() -> DoutDmaSramEndianness {
DoutDmaSramEndianness(0)
}
}
impl core::fmt::Debug for DoutDmaSramEndianness {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("DoutDmaSramEndianness")
.field("endian", &self.endian())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for DoutDmaSramEndianness {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "DoutDmaSramEndianness {{ endian: {:?} }}", self.endian())
}
}
#[doc = "Register indicating if DOUT FIFO is empty or if more data will come."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct DoutFifoEmpty(pub u32);
impl DoutFifoEmpty {
#[doc = "DOUT FIFO status."]
#[must_use]
#[inline(always)]
pub const fn status(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "DOUT FIFO status."]
#[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 DoutFifoEmpty {
#[inline(always)]
fn default() -> DoutFifoEmpty {
DoutFifoEmpty(0)
}
}
impl core::fmt::Debug for DoutFifoEmpty {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("DoutFifoEmpty")
.field("status", &self.status())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for DoutFifoEmpty {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "DoutFifoEmpty {{ status: {=bool:?} }}", self.status())
}
}
#[doc = "Indication that the next CPU read from the DOUT_BUFFER is the last in the sequence. This is needed only when the data size is NOT modulo 4 (e.g. HASH padding)."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct DoutReadAlign(pub u32);
impl DoutReadAlign {
#[doc = "Next CPU read from the DOUT_BUFFER is the last word, and the remaining read aligned content can be flushed."]
#[must_use]
#[inline(always)]
pub const fn last(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Next CPU read from the DOUT_BUFFER is the last word, and the remaining read aligned content can be flushed."]
#[inline(always)]
pub const fn set_last(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for DoutReadAlign {
#[inline(always)]
fn default() -> DoutReadAlign {
DoutReadAlign(0)
}
}
impl core::fmt::Debug for DoutReadAlign {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("DoutReadAlign")
.field("last", &self.last())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for DoutReadAlign {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "DoutReadAlign {{ last: {=bool:?} }}", self.last())
}
}
#[doc = "Reset the DOUT DMA engine."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct DoutSwReset(pub u32);
impl DoutSwReset {
#[doc = "Writing any value to this address resets the DOUT DMA engine. The reset takes 4 CPU clock cycles to complete."]
#[must_use]
#[inline(always)]
pub const fn reset(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Writing any value to this address resets the DOUT DMA engine. The reset takes 4 CPU clock cycles to complete."]
#[inline(always)]
pub const fn set_reset(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for DoutSwReset {
#[inline(always)]
fn default() -> DoutSwReset {
DoutSwReset(0)
}
}
impl core::fmt::Debug for DoutSwReset {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("DoutSwReset")
.field("reset", &self.reset())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for DoutSwReset {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "DoutSwReset {{ reset: {=bool:?} }}", self.reset())
}
}
#[doc = "The number of bytes to be written to memory."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct DstMemSize(pub u32);
impl DstMemSize {
#[doc = "Total number of bytes to write to memory."]
#[must_use]
#[inline(always)]
pub const fn size(&self) -> u32 {
let val = (self.0 >> 0usize) & 0x3fff_ffff;
val as u32
}
#[doc = "Total number of bytes to write to memory."]
#[inline(always)]
pub const fn set_size(&mut self, val: u32) {
self.0 =
(self.0 & !(0x3fff_ffff << 0usize)) | (((val as u32) & 0x3fff_ffff) << 0usize);
}
#[doc = "This field is reserved."]
#[must_use]
#[inline(always)]
pub const fn first(&self) -> bool {
let val = (self.0 >> 30usize) & 0x01;
val != 0
}
#[doc = "This field is reserved."]
#[inline(always)]
pub const fn set_first(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 30usize)) | (((val as u32) & 0x01) << 30usize);
}
#[doc = "This field is reserved."]
#[must_use]
#[inline(always)]
pub const fn last(&self) -> bool {
let val = (self.0 >> 31usize) & 0x01;
val != 0
}
#[doc = "This field is reserved."]
#[inline(always)]
pub const fn set_last(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 31usize)) | (((val as u32) & 0x01) << 31usize);
}
}
impl Default for DstMemSize {
#[inline(always)]
fn default() -> DstMemSize {
DstMemSize(0)
}
}
impl core::fmt::Debug for DstMemSize {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("DstMemSize")
.field("size", &self.size())
.field("first", &self.first())
.field("last", &self.last())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for DstMemSize {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"DstMemSize {{ size: {=u32:?}, first: {=bool:?}, last: {=bool:?} }}",
self.size(),
self.first(),
self.last()
)
}
}
}
pub mod vals {
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum DoutDmaMemBusyStatus {
#[doc = "DOUT memory DMA engine is idle."]
Idle = 0x0,
#[doc = "DOUT memory DMA engine is busy."]
Busy = 0x01,
}
impl DoutDmaMemBusyStatus {
#[inline(always)]
pub const fn from_bits(val: u8) -> DoutDmaMemBusyStatus {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for DoutDmaMemBusyStatus {
#[inline(always)]
fn from(val: u8) -> DoutDmaMemBusyStatus {
DoutDmaMemBusyStatus::from_bits(val)
}
}
impl From<DoutDmaMemBusyStatus> for u8 {
#[inline(always)]
fn from(val: DoutDmaMemBusyStatus) -> u8 {
DoutDmaMemBusyStatus::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum DoutDmaSramBusyStatus {
#[doc = "DOUT RNG SRAM DMA engine is idle."]
Idle = 0x0,
#[doc = "DOUT RNG SRAM DMA engine is busy."]
Busy = 0x01,
}
impl DoutDmaSramBusyStatus {
#[inline(always)]
pub const fn from_bits(val: u8) -> DoutDmaSramBusyStatus {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for DoutDmaSramBusyStatus {
#[inline(always)]
fn from(val: u8) -> DoutDmaSramBusyStatus {
DoutDmaSramBusyStatus::from_bits(val)
}
}
impl From<DoutDmaSramBusyStatus> for u8 {
#[inline(always)]
fn from(val: DoutDmaSramBusyStatus) -> u8 {
DoutDmaSramBusyStatus::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Endian {
#[doc = "Use little-endian format for RNG SRAM DMA transactions."]
LittleEndian = 0x0,
#[doc = "Use big-endian format for RNG SRAM DMA transactions."]
BigEndian = 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)
}
}
}
}
pub mod cc_hash {
#[doc = "CRYPTOCELL HASH engine."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct CcHash {
ptr: *mut u8,
}
unsafe impl Send for CcHash {}
unsafe impl Sync for CcHash {}
impl CcHash {
#[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: HASH_H value registers. The initial HASH_H\\[0\\] register holds the least significant bits \\[31:0\\] of the value."]
#[inline(always)]
pub const fn hash_h(self, n: usize) -> crate::common::Reg<u32, crate::common::RW> {
assert!(n < 8usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0640usize + n * 4usize) as _)
}
}
#[doc = "Configure the HASH engine to automatically pad data at the end of the DMA transfer to complete the digest operation."]
#[inline(always)]
pub const fn hash_pad_auto(
self,
) -> crate::common::Reg<regs::HashPadAuto, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0684usize) as _) }
}
#[doc = "Configure HASH engine initial state registers."]
#[inline(always)]
pub const fn hash_init_state(
self,
) -> crate::common::Reg<regs::HashInitState, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0694usize) as _) }
}
#[doc = "HASH engine HW version."]
#[inline(always)]
pub const fn hash_version(self) -> crate::common::Reg<regs::HashVersion, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x07b0usize) as _) }
}
#[doc = "Control the HASH engine behavior."]
#[inline(always)]
pub const fn hash_control(
self,
) -> crate::common::Reg<regs::HashControl, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x07c0usize) as _) }
}
#[doc = "Enable the hardware padding feature of the HASH engine."]
#[inline(always)]
pub const fn hash_pad(self) -> crate::common::Reg<regs::HashPad, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x07c4usize) as _) }
}
#[doc = "Force the hardware padding operation to trigger if the input data length is zero bytes."]
#[inline(always)]
pub const fn hash_pad_force(
self,
) -> crate::common::Reg<regs::HashPadForce, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x07c8usize) as _) }
}
#[doc = "Bits \\[31:0\\] of the number of bytes that have been digested so far."]
#[inline(always)]
pub const fn hash_cur_len_0(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x07ccusize) as _) }
}
#[doc = "Bits \\[63:32\\] of the number of bytes that have been digested so far."]
#[inline(always)]
pub const fn hash_cur_len_1(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x07d0usize) as _) }
}
#[doc = "Hardware configuration of the HASH engine. Reset value holds the supported features."]
#[inline(always)]
pub const fn hash_hw_flags(
self,
) -> crate::common::Reg<regs::HashHwFlags, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x07dcusize) as _) }
}
#[doc = "Reset the HASH engine."]
#[inline(always)]
pub const fn hash_sw_reset(
self,
) -> crate::common::Reg<regs::HashSwReset, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x07e4usize) as _) }
}
#[doc = "Configure the endianness of HASH data and padding generation."]
#[inline(always)]
pub const fn hash_endianness(
self,
) -> crate::common::Reg<regs::HashEndianness, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x07e8usize) as _) }
}
}
pub mod regs {
#[doc = "Control the HASH engine behavior."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct HashControl(pub u32);
impl HashControl {
#[doc = "Select HASH mode to execute."]
#[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 = "Select HASH mode to execute."]
#[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 HashControl {
#[inline(always)]
fn default() -> HashControl {
HashControl(0)
}
}
impl core::fmt::Debug for HashControl {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("HashControl")
.field("mode", &self.mode())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for HashControl {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "HashControl {{ mode: {:?} }}", self.mode())
}
}
#[doc = "Configure the endianness of HASH data and padding generation."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct HashEndianness(pub u32);
impl HashEndianness {
#[doc = "Endianness of HASH data and padding generation. The default value is little-endian."]
#[must_use]
#[inline(always)]
pub const fn endian(&self) -> super::vals::Endian {
let val = (self.0 >> 0usize) & 0x01;
super::vals::Endian::from_bits(val as u8)
}
#[doc = "Endianness of HASH data and padding generation. The default value is little-endian."]
#[inline(always)]
pub const fn set_endian(&mut self, val: super::vals::Endian) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
}
impl Default for HashEndianness {
#[inline(always)]
fn default() -> HashEndianness {
HashEndianness(0)
}
}
impl core::fmt::Debug for HashEndianness {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("HashEndianness")
.field("endian", &self.endian())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for HashEndianness {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "HashEndianness {{ endian: {:?} }}", self.endian())
}
}
#[doc = "Hardware configuration of the HASH engine. Reset value holds the supported features."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct HashHwFlags(pub u32);
impl HashHwFlags {
#[doc = "Indicates the number of concurrent words the hash is using to compute signature."]
#[must_use]
#[inline(always)]
pub const fn cw(&self) -> super::vals::Cw {
let val = (self.0 >> 0usize) & 0x0f;
super::vals::Cw::from_bits(val as u8)
}
#[doc = "Indicates the number of concurrent words the hash is using to compute signature."]
#[inline(always)]
pub const fn set_cw(&mut self, val: super::vals::Cw) {
self.0 = (self.0 & !(0x0f << 0usize)) | (((val.to_bits() as u32) & 0x0f) << 0usize);
}
#[doc = "Indicate if Hi adders are present for each Hi value or 1 adder is shared for all Hi."]
#[must_use]
#[inline(always)]
pub const fn ch(&self) -> super::vals::Ch {
let val = (self.0 >> 4usize) & 0x0f;
super::vals::Ch::from_bits(val as u8)
}
#[doc = "Indicate if Hi adders are present for each Hi value or 1 adder is shared for all Hi."]
#[inline(always)]
pub const fn set_ch(&mut self, val: super::vals::Ch) {
self.0 = (self.0 & !(0x0f << 4usize)) | (((val.to_bits() as u32) & 0x0f) << 4usize);
}
#[doc = "Determine the granularity of word size."]
#[must_use]
#[inline(always)]
pub const fn dw(&self) -> super::vals::Dw {
let val = (self.0 >> 8usize) & 0x0f;
super::vals::Dw::from_bits(val as u8)
}
#[doc = "Determine the granularity of word size."]
#[inline(always)]
pub const fn set_dw(&mut self, val: super::vals::Dw) {
self.0 = (self.0 & !(0x0f << 8usize)) | (((val.to_bits() as u32) & 0x0f) << 8usize);
}
#[doc = "If this flag is set, the engine include SHA-512 support."]
#[must_use]
#[inline(always)]
pub const fn sha_512_exists(&self) -> bool {
let val = (self.0 >> 12usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the engine include SHA-512 support."]
#[inline(always)]
pub const fn set_sha_512_exists(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 12usize)) | (((val as u32) & 0x01) << 12usize);
}
#[doc = "If this flag is set, the engine include pad block support."]
#[must_use]
#[inline(always)]
pub const fn pad_exists(&self) -> bool {
let val = (self.0 >> 13usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the engine include pad block support."]
#[inline(always)]
pub const fn set_pad_exists(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 13usize)) | (((val as u32) & 0x01) << 13usize);
}
#[doc = "If this flag is set, the engine include MD5 support."]
#[must_use]
#[inline(always)]
pub const fn md5_exists(&self) -> bool {
let val = (self.0 >> 14usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the engine include MD5 support."]
#[inline(always)]
pub const fn set_md5_exists(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 14usize)) | (((val as u32) & 0x01) << 14usize);
}
#[doc = "If this flag is set, the engine include HMAC support."]
#[must_use]
#[inline(always)]
pub const fn hmac_exists(&self) -> bool {
let val = (self.0 >> 15usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the engine include HMAC support."]
#[inline(always)]
pub const fn set_hmac_exists(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 15usize)) | (((val as u32) & 0x01) << 15usize);
}
#[doc = "If this flag is set, the engine include SHA-256 support."]
#[must_use]
#[inline(always)]
pub const fn sha_256_exists(&self) -> bool {
let val = (self.0 >> 16usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the engine include SHA-256 support."]
#[inline(always)]
pub const fn set_sha_256_exists(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 16usize)) | (((val as u32) & 0x01) << 16usize);
}
#[doc = "If this flag is set, the engine include compare digest logic."]
#[must_use]
#[inline(always)]
pub const fn hash_compare_exists(&self) -> bool {
let val = (self.0 >> 17usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the engine include compare digest logic."]
#[inline(always)]
pub const fn set_hash_compare_exists(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 17usize)) | (((val as u32) & 0x01) << 17usize);
}
#[doc = "If this flag is set, the engine include HASH to DOUT support."]
#[must_use]
#[inline(always)]
pub const fn dump_hash_to_dout_exists(&self) -> bool {
let val = (self.0 >> 18usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the engine include HASH to DOUT support."]
#[inline(always)]
pub const fn set_dump_hash_to_dout_exists(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 18usize)) | (((val as u32) & 0x01) << 18usize);
}
}
impl Default for HashHwFlags {
#[inline(always)]
fn default() -> HashHwFlags {
HashHwFlags(0)
}
}
impl core::fmt::Debug for HashHwFlags {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("HashHwFlags")
.field("cw", &self.cw())
.field("ch", &self.ch())
.field("dw", &self.dw())
.field("sha_512_exists", &self.sha_512_exists())
.field("pad_exists", &self.pad_exists())
.field("md5_exists", &self.md5_exists())
.field("hmac_exists", &self.hmac_exists())
.field("sha_256_exists", &self.sha_256_exists())
.field("hash_compare_exists", &self.hash_compare_exists())
.field("dump_hash_to_dout_exists", &self.dump_hash_to_dout_exists())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for HashHwFlags {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "HashHwFlags {{ cw: {:?}, ch: {:?}, dw: {:?}, sha_512_exists: {=bool:?}, pad_exists: {=bool:?}, md5_exists: {=bool:?}, hmac_exists: {=bool:?}, sha_256_exists: {=bool:?}, hash_compare_exists: {=bool:?}, dump_hash_to_dout_exists: {=bool:?} }}" , self . cw () , self . ch () , self . dw () , self . sha_512_exists () , self . pad_exists () , self . md5_exists () , self . hmac_exists () , self . sha_256_exists () , self . hash_compare_exists () , self . dump_hash_to_dout_exists ())
}
}
#[doc = "Configure HASH engine initial state registers."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct HashInitState(pub u32);
impl HashInitState {
#[doc = "Enable loading of data to initial state registers. Digest/IV for HASH/AES_MAC."]
#[must_use]
#[inline(always)]
pub const fn load(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Enable loading of data to initial state registers. Digest/IV for HASH/AES_MAC."]
#[inline(always)]
pub const fn set_load(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for HashInitState {
#[inline(always)]
fn default() -> HashInitState {
HashInitState(0)
}
}
impl core::fmt::Debug for HashInitState {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("HashInitState")
.field("load", &self.load())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for HashInitState {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "HashInitState {{ load: {=bool:?} }}", self.load())
}
}
#[doc = "Enable the hardware padding feature of the HASH engine."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct HashPad(pub u32);
impl HashPad {
#[doc = "Configure hardware padding feature."]
#[must_use]
#[inline(always)]
pub const fn enable(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Configure hardware padding feature."]
#[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 HashPad {
#[inline(always)]
fn default() -> HashPad {
HashPad(0)
}
}
impl core::fmt::Debug for HashPad {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("HashPad")
.field("enable", &self.enable())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for HashPad {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "HashPad {{ enable: {=bool:?} }}", self.enable())
}
}
#[doc = "Configure the HASH engine to automatically pad data at the end of the DMA transfer to complete the digest operation."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct HashPadAuto(pub u32);
impl HashPadAuto {
#[doc = "Enable automatic padding in hardware."]
#[must_use]
#[inline(always)]
pub const fn hwpad(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Enable automatic padding in hardware."]
#[inline(always)]
pub const fn set_hwpad(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for HashPadAuto {
#[inline(always)]
fn default() -> HashPadAuto {
HashPadAuto(0)
}
}
impl core::fmt::Debug for HashPadAuto {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("HashPadAuto")
.field("hwpad", &self.hwpad())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for HashPadAuto {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "HashPadAuto {{ hwpad: {=bool:?} }}", self.hwpad())
}
}
#[doc = "Force the hardware padding operation to trigger if the input data length is zero bytes."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct HashPadForce(pub u32);
impl HashPadForce {
#[doc = "Trigger hardware padding operation."]
#[must_use]
#[inline(always)]
pub const fn enable(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Trigger hardware padding operation."]
#[inline(always)]
pub const fn set_enable(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
}
impl Default for HashPadForce {
#[inline(always)]
fn default() -> HashPadForce {
HashPadForce(0)
}
}
impl core::fmt::Debug for HashPadForce {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("HashPadForce")
.field("enable", &self.enable())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for HashPadForce {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "HashPadForce {{ enable: {=bool:?} }}", self.enable())
}
}
#[doc = "Reset the HASH engine."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct HashSwReset(pub u32);
impl HashSwReset {
#[doc = "Writing any value to this address resets the HASH engine. The reset takes 4 CPU clock cycles to complete."]
#[must_use]
#[inline(always)]
pub const fn reset(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Writing any value to this address resets the HASH engine. The reset takes 4 CPU clock cycles to complete."]
#[inline(always)]
pub const fn set_reset(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for HashSwReset {
#[inline(always)]
fn default() -> HashSwReset {
HashSwReset(0)
}
}
impl core::fmt::Debug for HashSwReset {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("HashSwReset")
.field("reset", &self.reset())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for HashSwReset {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "HashSwReset {{ reset: {=bool:?} }}", self.reset())
}
}
#[doc = "HASH engine HW version."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct HashVersion(pub u32);
impl HashVersion {
#[must_use]
#[inline(always)]
pub const fn patch(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[inline(always)]
pub const fn set_patch(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
#[doc = "Minor version number."]
#[must_use]
#[inline(always)]
pub const fn minor_version_number(&self) -> u8 {
let val = (self.0 >> 8usize) & 0x0f;
val as u8
}
#[doc = "Minor version number."]
#[inline(always)]
pub const fn set_minor_version_number(&mut self, val: u8) {
self.0 = (self.0 & !(0x0f << 8usize)) | (((val as u32) & 0x0f) << 8usize);
}
#[doc = "Major version number."]
#[must_use]
#[inline(always)]
pub const fn major_version_number(&self) -> u8 {
let val = (self.0 >> 12usize) & 0x0f;
val as u8
}
#[doc = "Major version number."]
#[inline(always)]
pub const fn set_major_version_number(&mut self, val: u8) {
self.0 = (self.0 & !(0x0f << 12usize)) | (((val as u32) & 0x0f) << 12usize);
}
}
impl Default for HashVersion {
#[inline(always)]
fn default() -> HashVersion {
HashVersion(0)
}
}
impl core::fmt::Debug for HashVersion {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("HashVersion")
.field("patch", &self.patch())
.field("minor_version_number", &self.minor_version_number())
.field("major_version_number", &self.major_version_number())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for HashVersion {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "HashVersion {{ patch: {=u8:?}, minor_version_number: {=u8:?}, major_version_number: {=u8:?} }}" , self . patch () , self . minor_version_number () , self . major_version_number ())
}
}
}
pub mod vals {
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Ch {
#[doc = "One Hi value is updated at a time."]
One = 0x0,
#[doc = "All Hi values are updated at the same time."]
All = 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 Ch {
#[inline(always)]
pub const fn from_bits(val: u8) -> Ch {
unsafe { core::mem::transmute(val & 0x0f) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Ch {
#[inline(always)]
fn from(val: u8) -> Ch {
Ch::from_bits(val)
}
}
impl From<Ch> for u8 {
#[inline(always)]
fn from(val: Ch) -> u8 {
Ch::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Cw {
_RESERVED_0 = 0x0,
#[doc = "One concurrent word used by hash during signature generation."]
One = 0x01,
#[doc = "Two concurrent words used by hash during signature generation."]
Two = 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 Cw {
#[inline(always)]
pub const fn from_bits(val: u8) -> Cw {
unsafe { core::mem::transmute(val & 0x0f) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Cw {
#[inline(always)]
fn from(val: u8) -> Cw {
Cw::from_bits(val)
}
}
impl From<Cw> for u8 {
#[inline(always)]
fn from(val: Cw) -> u8 {
Cw::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Dw {
#[doc = "32 bits word data."]
_32bits = 0x0,
#[doc = "64 bits word data."]
_64bits = 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 Dw {
#[inline(always)]
pub const fn from_bits(val: u8) -> Dw {
unsafe { core::mem::transmute(val & 0x0f) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Dw {
#[inline(always)]
fn from(val: u8) -> Dw {
Dw::from_bits(val)
}
}
impl From<Dw> for u8 {
#[inline(always)]
fn from(val: Dw) -> u8 {
Dw::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Endian {
#[doc = "Use little-endian format for data and padding."]
LittleEndian = 0x0,
#[doc = "Use big-endian format for data and padding."]
BigEndian = 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 Mode {
_RESERVED_0 = 0x0,
#[doc = "Select SHA1 mode."]
Sha1 = 0x01,
#[doc = "Select SHA256 mode."]
Sha256 = 0x02,
_RESERVED_3 = 0x03,
_RESERVED_4 = 0x04,
_RESERVED_5 = 0x05,
_RESERVED_6 = 0x06,
_RESERVED_7 = 0x07,
_RESERVED_8 = 0x08,
_RESERVED_9 = 0x09,
#[doc = "Select SHA224 mode."]
Sha224 = 0x0a,
_RESERVED_b = 0x0b,
_RESERVED_c = 0x0c,
_RESERVED_d = 0x0d,
_RESERVED_e = 0x0e,
_RESERVED_f = 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)
}
}
}
}
pub mod cc_host_rgf {
#[doc = "CRYPTOCELL HOST register interface."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct CcHostRgf {
ptr: *mut u8,
}
unsafe impl Send for CcHostRgf {}
unsafe impl Sync for CcHostRgf {}
impl CcHostRgf {
#[inline(always)]
pub const unsafe fn from_ptr(ptr: *mut ()) -> Self {
Self { ptr: ptr as _ }
}
#[inline(always)]
pub const fn as_ptr(&self) -> *mut () {
self.ptr as _
}
#[doc = "Interrupt request register. Each bit of this register holds the interrupt status of a single interrupt source. If corresponding IMR bit is unmasked, an interrupt is generated."]
#[inline(always)]
pub const fn irr(self) -> crate::common::Reg<regs::Irr, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0a00usize) as _) }
}
#[doc = "Interrupt mask register. Each bit of this register holds the mask of a single interrupt source."]
#[inline(always)]
pub const fn imr(self) -> crate::common::Reg<regs::Imr, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0a04usize) as _) }
}
#[doc = "Interrupt clear register. Writing a 1 bit into a field in this register will clear the corresponding bit in IRR."]
#[inline(always)]
pub const fn icr(self) -> crate::common::Reg<regs::Icr, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0a08usize) as _) }
}
#[doc = "This register defines the endianness of the Host-accessible registers, and can only be written once."]
#[inline(always)]
pub const fn endianness(self) -> crate::common::Reg<regs::Endianness, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0a0cusize) as _) }
}
#[doc = "This register holds the CRYPTOCELL subsystem signature. See reset value."]
#[inline(always)]
pub const fn host_signature(self) -> crate::common::Reg<u32, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0a24usize) as _) }
}
#[doc = "Hardware configuration of the CRYPTOCELL subsystem. Reset value holds the supported features."]
#[inline(always)]
pub const fn host_boot(self) -> crate::common::Reg<regs::HostBoot, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0a28usize) as _) }
}
#[doc = "AES hardware key select."]
#[inline(always)]
pub const fn host_cryptokey_sel(
self,
) -> crate::common::Reg<regs::HostCryptokeySel, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0a38usize) as _) }
}
#[doc = "This write-once register is the K_PRTL lock register. When this register is set, K_PRTL cannot be used and a zeroed key will be used instead. The value of this register is saved in the CRYPTOCELL AO power domain."]
#[inline(always)]
pub const fn host_iot_kprtl_lock(
self,
) -> crate::common::Reg<regs::HostIotKprtlLock, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0a4cusize) as _) }
}
#[doc = "This register holds bits 31:0 of K_DR. The value of this register is saved in the CRYPTOCELL AO power domain. Reading from this address returns the K_DR valid status indicating if K_DR is successfully retained."]
#[inline(always)]
pub const fn host_iot_kdr0(
self,
) -> crate::common::Reg<regs::HostIotKdr0, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0a50usize) as _) }
}
#[doc = "This register holds bits 63:32 of K_DR. The value of this register is saved in the CRYPTOCELL AO power domain."]
#[inline(always)]
pub const fn host_iot_kdr1(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0a54usize) as _) }
}
#[doc = "This register holds bits 95:64 of K_DR. The value of this register is saved in the CRYPTOCELL AO power domain."]
#[inline(always)]
pub const fn host_iot_kdr2(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0a58usize) as _) }
}
#[doc = "This register holds bits 127:96 of K_DR. The value of this register is saved in the CRYPTOCELL AO power domain."]
#[inline(always)]
pub const fn host_iot_kdr3(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0a5cusize) as _) }
}
#[doc = "Controls life-cycle state (LCS) for CRYPTOCELL subsystem."]
#[inline(always)]
pub const fn host_iot_lcs(self) -> crate::common::Reg<regs::HostIotLcs, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0a60usize) as _) }
}
}
pub mod regs {
#[doc = "This register defines the endianness of the Host-accessible registers, and can only be written once."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Endianness(pub u32);
impl Endianness {
#[doc = "DOUT write endianness."]
#[must_use]
#[inline(always)]
pub const fn dout_wr_bg(&self) -> super::vals::DoutWrBg {
let val = (self.0 >> 3usize) & 0x01;
super::vals::DoutWrBg::from_bits(val as u8)
}
#[doc = "DOUT write endianness."]
#[inline(always)]
pub const fn set_dout_wr_bg(&mut self, val: super::vals::DoutWrBg) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val.to_bits() as u32) & 0x01) << 3usize);
}
#[doc = "DIN read endianness."]
#[must_use]
#[inline(always)]
pub const fn din_rd_bg(&self) -> super::vals::DinRdBg {
let val = (self.0 >> 7usize) & 0x01;
super::vals::DinRdBg::from_bits(val as u8)
}
#[doc = "DIN read endianness."]
#[inline(always)]
pub const fn set_din_rd_bg(&mut self, val: super::vals::DinRdBg) {
self.0 = (self.0 & !(0x01 << 7usize)) | (((val.to_bits() as u32) & 0x01) << 7usize);
}
#[doc = "DOUT write word endianness."]
#[must_use]
#[inline(always)]
pub const fn dout_wr_wbg(&self) -> super::vals::DoutWrWbg {
let val = (self.0 >> 11usize) & 0x01;
super::vals::DoutWrWbg::from_bits(val as u8)
}
#[doc = "DOUT write word endianness."]
#[inline(always)]
pub const fn set_dout_wr_wbg(&mut self, val: super::vals::DoutWrWbg) {
self.0 =
(self.0 & !(0x01 << 11usize)) | (((val.to_bits() as u32) & 0x01) << 11usize);
}
#[doc = "DIN read word endianness."]
#[must_use]
#[inline(always)]
pub const fn din_rd_wbg(&self) -> super::vals::DinRdWbg {
let val = (self.0 >> 15usize) & 0x01;
super::vals::DinRdWbg::from_bits(val as u8)
}
#[doc = "DIN read word endianness."]
#[inline(always)]
pub const fn set_din_rd_wbg(&mut self, val: super::vals::DinRdWbg) {
self.0 =
(self.0 & !(0x01 << 15usize)) | (((val.to_bits() as u32) & 0x01) << 15usize);
}
}
impl Default for Endianness {
#[inline(always)]
fn default() -> Endianness {
Endianness(0)
}
}
impl core::fmt::Debug for Endianness {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Endianness")
.field("dout_wr_bg", &self.dout_wr_bg())
.field("din_rd_bg", &self.din_rd_bg())
.field("dout_wr_wbg", &self.dout_wr_wbg())
.field("din_rd_wbg", &self.din_rd_wbg())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Endianness {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Endianness {{ dout_wr_bg: {:?}, din_rd_bg: {:?}, dout_wr_wbg: {:?}, din_rd_wbg: {:?} }}" , self . dout_wr_bg () , self . din_rd_bg () , self . dout_wr_wbg () , self . din_rd_wbg ())
}
}
#[doc = "Hardware configuration of the CRYPTOCELL subsystem. Reset value holds the supported features."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct HostBoot(pub u32);
impl HostBoot {
#[doc = "If this flag is set, full power gating is implemented."]
#[must_use]
#[inline(always)]
pub const fn power_gating_exists_local(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, full power gating is implemented."]
#[inline(always)]
pub const fn set_power_gating_exists_local(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "If this flag is set, large RKEK is supported."]
#[must_use]
#[inline(always)]
pub const fn large_rkek_local(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, large RKEK is supported."]
#[inline(always)]
pub const fn set_large_rkek_local(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "If this flag is set, HASH in fuses is supported."]
#[must_use]
#[inline(always)]
pub const fn hash_in_fuses_local(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, HASH in fuses is supported."]
#[inline(always)]
pub const fn set_hash_in_fuses_local(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "If this flag is set, external secure memory is supported."]
#[must_use]
#[inline(always)]
pub const fn ext_mem_secured_local(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, external secure memory is supported."]
#[inline(always)]
pub const fn set_ext_mem_secured_local(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
#[doc = "If this flag is set, RKEK ECC is supported."]
#[must_use]
#[inline(always)]
pub const fn rkek_ecc_exists_local_n(&self) -> bool {
let val = (self.0 >> 5usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, RKEK ECC is supported."]
#[inline(always)]
pub const fn set_rkek_ecc_exists_local_n(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
}
#[doc = "SRAM size."]
#[must_use]
#[inline(always)]
pub const fn sram_size_local(&self) -> u8 {
let val = (self.0 >> 6usize) & 0x07;
val as u8
}
#[doc = "SRAM size."]
#[inline(always)]
pub const fn set_sram_size_local(&mut self, val: u8) {
self.0 = (self.0 & !(0x07 << 6usize)) | (((val as u32) & 0x07) << 6usize);
}
#[doc = "If this flag is set, Descriptors are supported."]
#[must_use]
#[inline(always)]
pub const fn dscrptr_exists_local(&self) -> bool {
let val = (self.0 >> 9usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, Descriptors are supported."]
#[inline(always)]
pub const fn set_dscrptr_exists_local(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 9usize)) | (((val as u32) & 0x01) << 9usize);
}
#[doc = "If this flag is set, PAU is supported."]
#[must_use]
#[inline(always)]
pub const fn pau_exists_local(&self) -> bool {
let val = (self.0 >> 10usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, PAU is supported."]
#[inline(always)]
pub const fn set_pau_exists_local(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 10usize)) | (((val as u32) & 0x01) << 10usize);
}
#[doc = "If this flag is set, the RNG engine is present."]
#[must_use]
#[inline(always)]
pub const fn rng_exists_local(&self) -> bool {
let val = (self.0 >> 11usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the RNG engine is present."]
#[inline(always)]
pub const fn set_rng_exists_local(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 11usize)) | (((val as u32) & 0x01) << 11usize);
}
#[doc = "If this flag is set, the PKA engine is present."]
#[must_use]
#[inline(always)]
pub const fn pka_exists_local(&self) -> bool {
let val = (self.0 >> 12usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the PKA engine is present."]
#[inline(always)]
pub const fn set_pka_exists_local(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 12usize)) | (((val as u32) & 0x01) << 12usize);
}
#[doc = "If this flag is set, the RC4 engine is present."]
#[must_use]
#[inline(always)]
pub const fn rc4_exists_local(&self) -> bool {
let val = (self.0 >> 13usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the RC4 engine is present."]
#[inline(always)]
pub const fn set_rc4_exists_local(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 13usize)) | (((val as u32) & 0x01) << 13usize);
}
#[doc = "If this flag is set, the HASH engine supports SHA512."]
#[must_use]
#[inline(always)]
pub const fn sha_512_prsnt_local(&self) -> bool {
let val = (self.0 >> 14usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the HASH engine supports SHA512."]
#[inline(always)]
pub const fn set_sha_512_prsnt_local(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 14usize)) | (((val as u32) & 0x01) << 14usize);
}
#[doc = "If this flag is set, the HASH engine supports SHA256."]
#[must_use]
#[inline(always)]
pub const fn sha_256_prsnt_local(&self) -> bool {
let val = (self.0 >> 15usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the HASH engine supports SHA256."]
#[inline(always)]
pub const fn set_sha_256_prsnt_local(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 15usize)) | (((val as u32) & 0x01) << 15usize);
}
#[doc = "If this flag is set, the HASH engine supports MD5."]
#[must_use]
#[inline(always)]
pub const fn md5_prsnt_local(&self) -> bool {
let val = (self.0 >> 16usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the HASH engine supports MD5."]
#[inline(always)]
pub const fn set_md5_prsnt_local(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 16usize)) | (((val as u32) & 0x01) << 16usize);
}
#[doc = "If this flag is set, the HASH engine is present."]
#[must_use]
#[inline(always)]
pub const fn hash_exists_local(&self) -> bool {
let val = (self.0 >> 17usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the HASH engine is present."]
#[inline(always)]
pub const fn set_hash_exists_local(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 17usize)) | (((val as u32) & 0x01) << 17usize);
}
#[doc = "If this flag is set, the C2 engine is present."]
#[must_use]
#[inline(always)]
pub const fn c2_exists_local(&self) -> bool {
let val = (self.0 >> 18usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the C2 engine is present."]
#[inline(always)]
pub const fn set_c2_exists_local(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 18usize)) | (((val as u32) & 0x01) << 18usize);
}
#[doc = "If this flag is set, the DES engine is present."]
#[must_use]
#[inline(always)]
pub const fn des_exists_local(&self) -> bool {
let val = (self.0 >> 19usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the DES engine is present."]
#[inline(always)]
pub const fn set_des_exists_local(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 19usize)) | (((val as u32) & 0x01) << 19usize);
}
#[doc = "If this flag is set, AES XCBC-MAC mode is supported."]
#[must_use]
#[inline(always)]
pub const fn aes_xcbc_mac_exists_local(&self) -> bool {
let val = (self.0 >> 20usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, AES XCBC-MAC mode is supported."]
#[inline(always)]
pub const fn set_aes_xcbc_mac_exists_local(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 20usize)) | (((val as u32) & 0x01) << 20usize);
}
#[doc = "If this flag is set, AES CMAC mode is supported."]
#[must_use]
#[inline(always)]
pub const fn aes_cmac_exists_local(&self) -> bool {
let val = (self.0 >> 21usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, AES CMAC mode is supported."]
#[inline(always)]
pub const fn set_aes_cmac_exists_local(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 21usize)) | (((val as u32) & 0x01) << 21usize);
}
#[doc = "If this flag is set, AES CCM mode is supported."]
#[must_use]
#[inline(always)]
pub const fn aes_ccm_exists_local(&self) -> bool {
let val = (self.0 >> 22usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, AES CCM mode is supported."]
#[inline(always)]
pub const fn set_aes_ccm_exists_local(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 22usize)) | (((val as u32) & 0x01) << 22usize);
}
#[doc = "If this flag is set, AES XEX mode T-value calculation in HW is supported."]
#[must_use]
#[inline(always)]
pub const fn aes_xex_hw_t_calc_local(&self) -> bool {
let val = (self.0 >> 23usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, AES XEX mode T-value calculation in HW is supported."]
#[inline(always)]
pub const fn set_aes_xex_hw_t_calc_local(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 23usize)) | (((val as u32) & 0x01) << 23usize);
}
#[doc = "If this flag is set, AES XEX mode is supported."]
#[must_use]
#[inline(always)]
pub const fn aes_xex_exists_local(&self) -> bool {
let val = (self.0 >> 24usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, AES XEX mode is supported."]
#[inline(always)]
pub const fn set_aes_xex_exists_local(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 24usize)) | (((val as u32) & 0x01) << 24usize);
}
#[doc = "If this flag is set, AES CTR mode is supported."]
#[must_use]
#[inline(always)]
pub const fn ctr_exists_local(&self) -> bool {
let val = (self.0 >> 25usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, AES CTR mode is supported."]
#[inline(always)]
pub const fn set_ctr_exists_local(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 25usize)) | (((val as u32) & 0x01) << 25usize);
}
#[doc = "If this flag is set, the AES engine data input support byte size resolution."]
#[must_use]
#[inline(always)]
pub const fn aes_din_byte_resolution_local(&self) -> bool {
let val = (self.0 >> 26usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the AES engine data input support byte size resolution."]
#[inline(always)]
pub const fn set_aes_din_byte_resolution_local(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 26usize)) | (((val as u32) & 0x01) << 26usize);
}
#[doc = "If this flag is set, the AES engine supports tunneling operations."]
#[must_use]
#[inline(always)]
pub const fn tunneling_enb_local(&self) -> bool {
let val = (self.0 >> 27usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the AES engine supports tunneling operations."]
#[inline(always)]
pub const fn set_tunneling_enb_local(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 27usize)) | (((val as u32) & 0x01) << 27usize);
}
#[doc = "If this flag is set, the AES engine supports 192/256 bits key sizes."]
#[must_use]
#[inline(always)]
pub const fn support_256_192_key_local(&self) -> bool {
let val = (self.0 >> 28usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the AES engine supports 192/256 bits key sizes."]
#[inline(always)]
pub const fn set_support_256_192_key_local(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 28usize)) | (((val as u32) & 0x01) << 28usize);
}
#[doc = "If this flag is set, the AES engine only support encryption."]
#[must_use]
#[inline(always)]
pub const fn only_encrypt_local(&self) -> bool {
let val = (self.0 >> 29usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the AES engine only support encryption."]
#[inline(always)]
pub const fn set_only_encrypt_local(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 29usize)) | (((val as u32) & 0x01) << 29usize);
}
#[doc = "If this flag is set, the AES engine is present."]
#[must_use]
#[inline(always)]
pub const fn aes_exists_local(&self) -> bool {
let val = (self.0 >> 30usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the AES engine is present."]
#[inline(always)]
pub const fn set_aes_exists_local(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 30usize)) | (((val as u32) & 0x01) << 30usize);
}
}
impl Default for HostBoot {
#[inline(always)]
fn default() -> HostBoot {
HostBoot(0)
}
}
impl core::fmt::Debug for HostBoot {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("HostBoot")
.field(
"power_gating_exists_local",
&self.power_gating_exists_local(),
)
.field("large_rkek_local", &self.large_rkek_local())
.field("hash_in_fuses_local", &self.hash_in_fuses_local())
.field("ext_mem_secured_local", &self.ext_mem_secured_local())
.field("rkek_ecc_exists_local_n", &self.rkek_ecc_exists_local_n())
.field("sram_size_local", &self.sram_size_local())
.field("dscrptr_exists_local", &self.dscrptr_exists_local())
.field("pau_exists_local", &self.pau_exists_local())
.field("rng_exists_local", &self.rng_exists_local())
.field("pka_exists_local", &self.pka_exists_local())
.field("rc4_exists_local", &self.rc4_exists_local())
.field("sha_512_prsnt_local", &self.sha_512_prsnt_local())
.field("sha_256_prsnt_local", &self.sha_256_prsnt_local())
.field("md5_prsnt_local", &self.md5_prsnt_local())
.field("hash_exists_local", &self.hash_exists_local())
.field("c2_exists_local", &self.c2_exists_local())
.field("des_exists_local", &self.des_exists_local())
.field(
"aes_xcbc_mac_exists_local",
&self.aes_xcbc_mac_exists_local(),
)
.field("aes_cmac_exists_local", &self.aes_cmac_exists_local())
.field("aes_ccm_exists_local", &self.aes_ccm_exists_local())
.field("aes_xex_hw_t_calc_local", &self.aes_xex_hw_t_calc_local())
.field("aes_xex_exists_local", &self.aes_xex_exists_local())
.field("ctr_exists_local", &self.ctr_exists_local())
.field(
"aes_din_byte_resolution_local",
&self.aes_din_byte_resolution_local(),
)
.field("tunneling_enb_local", &self.tunneling_enb_local())
.field(
"support_256_192_key_local",
&self.support_256_192_key_local(),
)
.field("only_encrypt_local", &self.only_encrypt_local())
.field("aes_exists_local", &self.aes_exists_local())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for HostBoot {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "HostBoot {{ power_gating_exists_local: {=bool:?}, large_rkek_local: {=bool:?}, hash_in_fuses_local: {=bool:?}, ext_mem_secured_local: {=bool:?}, rkek_ecc_exists_local_n: {=bool:?}, sram_size_local: {=u8:?}, dscrptr_exists_local: {=bool:?}, pau_exists_local: {=bool:?}, rng_exists_local: {=bool:?}, pka_exists_local: {=bool:?}, rc4_exists_local: {=bool:?}, sha_512_prsnt_local: {=bool:?}, sha_256_prsnt_local: {=bool:?}, md5_prsnt_local: {=bool:?}, hash_exists_local: {=bool:?}, c2_exists_local: {=bool:?}, des_exists_local: {=bool:?}, aes_xcbc_mac_exists_local: {=bool:?}, aes_cmac_exists_local: {=bool:?}, aes_ccm_exists_local: {=bool:?}, aes_xex_hw_t_calc_local: {=bool:?}, aes_xex_exists_local: {=bool:?}, ctr_exists_local: {=bool:?}, aes_din_byte_resolution_local: {=bool:?}, tunneling_enb_local: {=bool:?}, support_256_192_key_local: {=bool:?}, only_encrypt_local: {=bool:?}, aes_exists_local: {=bool:?} }}" , self . power_gating_exists_local () , self . large_rkek_local () , self . hash_in_fuses_local () , self . ext_mem_secured_local () , self . rkek_ecc_exists_local_n () , self . sram_size_local () , self . dscrptr_exists_local () , self . pau_exists_local () , self . rng_exists_local () , self . pka_exists_local () , self . rc4_exists_local () , self . sha_512_prsnt_local () , self . sha_256_prsnt_local () , self . md5_prsnt_local () , self . hash_exists_local () , self . c2_exists_local () , self . des_exists_local () , self . aes_xcbc_mac_exists_local () , self . aes_cmac_exists_local () , self . aes_ccm_exists_local () , self . aes_xex_hw_t_calc_local () , self . aes_xex_exists_local () , self . ctr_exists_local () , self . aes_din_byte_resolution_local () , self . tunneling_enb_local () , self . support_256_192_key_local () , self . only_encrypt_local () , self . aes_exists_local ())
}
}
#[doc = "AES hardware key select."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct HostCryptokeySel(pub u32);
impl HostCryptokeySel {
#[doc = "Select the source of the HW key that is used by the AES engine."]
#[must_use]
#[inline(always)]
pub const fn host_cryptokey_sel(&self) -> super::vals::HostCryptokeySel {
let val = (self.0 >> 0usize) & 0x03;
super::vals::HostCryptokeySel::from_bits(val as u8)
}
#[doc = "Select the source of the HW key that is used by the AES engine."]
#[inline(always)]
pub const fn set_host_cryptokey_sel(&mut self, val: super::vals::HostCryptokeySel) {
self.0 = (self.0 & !(0x03 << 0usize)) | (((val.to_bits() as u32) & 0x03) << 0usize);
}
}
impl Default for HostCryptokeySel {
#[inline(always)]
fn default() -> HostCryptokeySel {
HostCryptokeySel(0)
}
}
impl core::fmt::Debug for HostCryptokeySel {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("HostCryptokeySel")
.field("host_cryptokey_sel", &self.host_cryptokey_sel())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for HostCryptokeySel {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"HostCryptokeySel {{ host_cryptokey_sel: {:?} }}",
self.host_cryptokey_sel()
)
}
}
#[doc = "This register holds bits 31:0 of K_DR. The value of this register is saved in the CRYPTOCELL AO power domain. Reading from this address returns the K_DR valid status indicating if K_DR is successfully retained."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct HostIotKdr0(pub u32);
impl HostIotKdr0 {
#[doc = "This register holds bits 31:0 of K_DR. The value of this register is saved in the CRYPTOCELL AO power domain. Reading from this address returns the K_DR valid status indicating if K_DR is successfully retained. Write: K_DR bits 31:0."]
#[must_use]
#[inline(always)]
pub const fn host_iot_kdr0(&self) -> super::vals::HostIotKdr0 {
let val = (self.0 >> 0usize) & 0xffff_ffff;
super::vals::HostIotKdr0::from_bits(val as u32)
}
#[doc = "This register holds bits 31:0 of K_DR. The value of this register is saved in the CRYPTOCELL AO power domain. Reading from this address returns the K_DR valid status indicating if K_DR is successfully retained. Write: K_DR bits 31:0."]
#[inline(always)]
pub const fn set_host_iot_kdr0(&mut self, val: super::vals::HostIotKdr0) {
self.0 = (self.0 & !(0xffff_ffff << 0usize))
| (((val.to_bits() as u32) & 0xffff_ffff) << 0usize);
}
}
impl Default for HostIotKdr0 {
#[inline(always)]
fn default() -> HostIotKdr0 {
HostIotKdr0(0)
}
}
impl core::fmt::Debug for HostIotKdr0 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("HostIotKdr0")
.field("host_iot_kdr0", &self.host_iot_kdr0())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for HostIotKdr0 {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"HostIotKdr0 {{ host_iot_kdr0: {:?} }}",
self.host_iot_kdr0()
)
}
}
#[doc = "This write-once register is the K_PRTL lock register. When this register is set, K_PRTL cannot be used and a zeroed key will be used instead. The value of this register is saved in the CRYPTOCELL AO power domain."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct HostIotKprtlLock(pub u32);
impl HostIotKprtlLock {
#[doc = "This register is the K_PRTL lock register. When this register is set, K_PRTL cannot be used and a zeroed key will be used instead. The value of this register is saved in the CRYPTOCELL AO power domain."]
#[must_use]
#[inline(always)]
pub const fn host_iot_kprtl_lock(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "This register is the K_PRTL lock register. When this register is set, K_PRTL cannot be used and a zeroed key will be used instead. The value of this register is saved in the CRYPTOCELL AO power domain."]
#[inline(always)]
pub const fn set_host_iot_kprtl_lock(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for HostIotKprtlLock {
#[inline(always)]
fn default() -> HostIotKprtlLock {
HostIotKprtlLock(0)
}
}
impl core::fmt::Debug for HostIotKprtlLock {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("HostIotKprtlLock")
.field("host_iot_kprtl_lock", &self.host_iot_kprtl_lock())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for HostIotKprtlLock {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"HostIotKprtlLock {{ host_iot_kprtl_lock: {=bool:?} }}",
self.host_iot_kprtl_lock()
)
}
}
#[doc = "Controls life-cycle state (LCS) for CRYPTOCELL subsystem."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct HostIotLcs(pub u32);
impl HostIotLcs {
#[doc = "Life-cycle state value. This field is write-once per reset."]
#[must_use]
#[inline(always)]
pub const fn lcs(&self) -> super::vals::Lcs {
let val = (self.0 >> 0usize) & 0x07;
super::vals::Lcs::from_bits(val as u8)
}
#[doc = "Life-cycle state value. This field is write-once per reset."]
#[inline(always)]
pub const fn set_lcs(&mut self, val: super::vals::Lcs) {
self.0 = (self.0 & !(0x07 << 0usize)) | (((val.to_bits() as u32) & 0x07) << 0usize);
}
#[doc = "Read-only field. Indicates if CRYPTOCELL LCS has been successfully configured since last reset."]
#[must_use]
#[inline(always)]
pub const fn lcs_is_valid(&self) -> bool {
let val = (self.0 >> 8usize) & 0x01;
val != 0
}
#[doc = "Read-only field. Indicates if CRYPTOCELL LCS has been successfully configured since last reset."]
#[inline(always)]
pub const fn set_lcs_is_valid(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize);
}
}
impl Default for HostIotLcs {
#[inline(always)]
fn default() -> HostIotLcs {
HostIotLcs(0)
}
}
impl core::fmt::Debug for HostIotLcs {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("HostIotLcs")
.field("lcs", &self.lcs())
.field("lcs_is_valid", &self.lcs_is_valid())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for HostIotLcs {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"HostIotLcs {{ lcs: {:?}, lcs_is_valid: {=bool:?} }}",
self.lcs(),
self.lcs_is_valid()
)
}
}
#[doc = "Interrupt clear register. Writing a 1 bit into a field in this register will clear the corresponding bit in IRR."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Icr(pub u32);
impl Icr {
#[doc = "The RNG SRAM to DIN DMA done interrupt clear."]
#[must_use]
#[inline(always)]
pub const fn sram_to_din_clear(&self) -> bool {
let val = (self.0 >> 4usize) & 0x01;
val != 0
}
#[doc = "The RNG SRAM to DIN DMA done interrupt clear."]
#[inline(always)]
pub const fn set_sram_to_din_clear(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
}
#[doc = "The DOUT to RNG SRAM DMA done interrupt clear."]
#[must_use]
#[inline(always)]
pub const fn dout_to_sram_clear(&self) -> bool {
let val = (self.0 >> 5usize) & 0x01;
val != 0
}
#[doc = "The DOUT to RNG SRAM DMA done interrupt clear."]
#[inline(always)]
pub const fn set_dout_to_sram_clear(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
}
#[doc = "The memory to DIN DMA done interrupt clear."]
#[must_use]
#[inline(always)]
pub const fn mem_to_din_clear(&self) -> bool {
let val = (self.0 >> 6usize) & 0x01;
val != 0
}
#[doc = "The memory to DIN DMA done interrupt clear."]
#[inline(always)]
pub const fn set_mem_to_din_clear(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize);
}
#[doc = "The DOUT to memory DMA done interrupt clear."]
#[must_use]
#[inline(always)]
pub const fn dout_to_mem_clear(&self) -> bool {
let val = (self.0 >> 7usize) & 0x01;
val != 0
}
#[doc = "The DOUT to memory DMA done interrupt clear."]
#[inline(always)]
pub const fn set_dout_to_mem_clear(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize);
}
#[doc = "The AHB error interrupt clear."]
#[must_use]
#[inline(always)]
pub const fn ahb_err_clear(&self) -> bool {
let val = (self.0 >> 8usize) & 0x01;
val != 0
}
#[doc = "The AHB error interrupt clear."]
#[inline(always)]
pub const fn set_ahb_err_clear(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize);
}
#[doc = "The PKA end of operation interrupt clear."]
#[must_use]
#[inline(always)]
pub const fn pka_clear(&self) -> bool {
let val = (self.0 >> 9usize) & 0x01;
val != 0
}
#[doc = "The PKA end of operation interrupt clear."]
#[inline(always)]
pub const fn set_pka_clear(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 9usize)) | (((val as u32) & 0x01) << 9usize);
}
#[doc = "The RNG interrupt clear. Register RNG_ISR in the RNG engine must be cleared before this interrupt can be cleared."]
#[must_use]
#[inline(always)]
pub const fn rng_clear(&self) -> bool {
let val = (self.0 >> 10usize) & 0x01;
val != 0
}
#[doc = "The RNG interrupt clear. Register RNG_ISR in the RNG engine must be cleared before this interrupt can be cleared."]
#[inline(always)]
pub const fn set_rng_clear(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 10usize)) | (((val as u32) & 0x01) << 10usize);
}
}
impl Default for Icr {
#[inline(always)]
fn default() -> Icr {
Icr(0)
}
}
impl core::fmt::Debug for Icr {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Icr")
.field("sram_to_din_clear", &self.sram_to_din_clear())
.field("dout_to_sram_clear", &self.dout_to_sram_clear())
.field("mem_to_din_clear", &self.mem_to_din_clear())
.field("dout_to_mem_clear", &self.dout_to_mem_clear())
.field("ahb_err_clear", &self.ahb_err_clear())
.field("pka_clear", &self.pka_clear())
.field("rng_clear", &self.rng_clear())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Icr {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Icr {{ sram_to_din_clear: {=bool:?}, dout_to_sram_clear: {=bool:?}, mem_to_din_clear: {=bool:?}, dout_to_mem_clear: {=bool:?}, ahb_err_clear: {=bool:?}, pka_clear: {=bool:?}, rng_clear: {=bool:?} }}" , self . sram_to_din_clear () , self . dout_to_sram_clear () , self . mem_to_din_clear () , self . dout_to_mem_clear () , self . ahb_err_clear () , self . pka_clear () , self . rng_clear ())
}
}
#[doc = "Interrupt mask register. Each bit of this register holds the mask of a single interrupt source."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Imr(pub u32);
impl Imr {
#[doc = "The RNG SRAM to DIN DMA done interrupt mask."]
#[must_use]
#[inline(always)]
pub const fn sram_to_din_mask(&self) -> super::vals::SramToDinMask {
let val = (self.0 >> 4usize) & 0x01;
super::vals::SramToDinMask::from_bits(val as u8)
}
#[doc = "The RNG SRAM to DIN DMA done interrupt mask."]
#[inline(always)]
pub const fn set_sram_to_din_mask(&mut self, val: super::vals::SramToDinMask) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val.to_bits() as u32) & 0x01) << 4usize);
}
#[doc = "The DOUT to RNG SRAM DMA done interrupt mask."]
#[must_use]
#[inline(always)]
pub const fn dout_to_sram_mask(&self) -> super::vals::DoutToSramMask {
let val = (self.0 >> 5usize) & 0x01;
super::vals::DoutToSramMask::from_bits(val as u8)
}
#[doc = "The DOUT to RNG SRAM DMA done interrupt mask."]
#[inline(always)]
pub const fn set_dout_to_sram_mask(&mut self, val: super::vals::DoutToSramMask) {
self.0 = (self.0 & !(0x01 << 5usize)) | (((val.to_bits() as u32) & 0x01) << 5usize);
}
#[doc = "The memory to DIN DMA done interrupt mask."]
#[must_use]
#[inline(always)]
pub const fn mem_to_din_mask(&self) -> super::vals::MemToDinMask {
let val = (self.0 >> 6usize) & 0x01;
super::vals::MemToDinMask::from_bits(val as u8)
}
#[doc = "The memory to DIN DMA done interrupt mask."]
#[inline(always)]
pub const fn set_mem_to_din_mask(&mut self, val: super::vals::MemToDinMask) {
self.0 = (self.0 & !(0x01 << 6usize)) | (((val.to_bits() as u32) & 0x01) << 6usize);
}
#[doc = "The DOUT to memory DMA done interrupt mask."]
#[must_use]
#[inline(always)]
pub const fn dout_to_mem_mask(&self) -> super::vals::DoutToMemMask {
let val = (self.0 >> 7usize) & 0x01;
super::vals::DoutToMemMask::from_bits(val as u8)
}
#[doc = "The DOUT to memory DMA done interrupt mask."]
#[inline(always)]
pub const fn set_dout_to_mem_mask(&mut self, val: super::vals::DoutToMemMask) {
self.0 = (self.0 & !(0x01 << 7usize)) | (((val.to_bits() as u32) & 0x01) << 7usize);
}
#[doc = "The AHB error interrupt mask."]
#[must_use]
#[inline(always)]
pub const fn ahb_err_mask(&self) -> super::vals::AhbErrMask {
let val = (self.0 >> 8usize) & 0x01;
super::vals::AhbErrMask::from_bits(val as u8)
}
#[doc = "The AHB error interrupt mask."]
#[inline(always)]
pub const fn set_ahb_err_mask(&mut self, val: super::vals::AhbErrMask) {
self.0 = (self.0 & !(0x01 << 8usize)) | (((val.to_bits() as u32) & 0x01) << 8usize);
}
#[doc = "The PKA end of operation interrupt mask."]
#[must_use]
#[inline(always)]
pub const fn pka_mask(&self) -> super::vals::PkaMask {
let val = (self.0 >> 9usize) & 0x01;
super::vals::PkaMask::from_bits(val as u8)
}
#[doc = "The PKA end of operation interrupt mask."]
#[inline(always)]
pub const fn set_pka_mask(&mut self, val: super::vals::PkaMask) {
self.0 = (self.0 & !(0x01 << 9usize)) | (((val.to_bits() as u32) & 0x01) << 9usize);
}
#[doc = "The RNG interrupt mask."]
#[must_use]
#[inline(always)]
pub const fn rng_mask(&self) -> super::vals::RngMask {
let val = (self.0 >> 10usize) & 0x01;
super::vals::RngMask::from_bits(val as u8)
}
#[doc = "The RNG interrupt mask."]
#[inline(always)]
pub const fn set_rng_mask(&mut self, val: super::vals::RngMask) {
self.0 =
(self.0 & !(0x01 << 10usize)) | (((val.to_bits() as u32) & 0x01) << 10usize);
}
}
impl Default for Imr {
#[inline(always)]
fn default() -> Imr {
Imr(0)
}
}
impl core::fmt::Debug for Imr {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Imr")
.field("sram_to_din_mask", &self.sram_to_din_mask())
.field("dout_to_sram_mask", &self.dout_to_sram_mask())
.field("mem_to_din_mask", &self.mem_to_din_mask())
.field("dout_to_mem_mask", &self.dout_to_mem_mask())
.field("ahb_err_mask", &self.ahb_err_mask())
.field("pka_mask", &self.pka_mask())
.field("rng_mask", &self.rng_mask())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Imr {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Imr {{ sram_to_din_mask: {:?}, dout_to_sram_mask: {:?}, mem_to_din_mask: {:?}, dout_to_mem_mask: {:?}, ahb_err_mask: {:?}, pka_mask: {:?}, rng_mask: {:?} }}" , self . sram_to_din_mask () , self . dout_to_sram_mask () , self . mem_to_din_mask () , self . dout_to_mem_mask () , self . ahb_err_mask () , self . pka_mask () , self . rng_mask ())
}
}
#[doc = "Interrupt request register. Each bit of this register holds the interrupt status of a single interrupt source. If corresponding IMR bit is unmasked, an interrupt is generated."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Irr(pub u32);
impl Irr {
#[doc = "The RNG SRAM to DIN DMA done interrupt status. This interrupt is asserted when all data was delivered from RNG SRAM to DIN buffer."]
#[must_use]
#[inline(always)]
pub const fn sram_to_din_int(&self) -> bool {
let val = (self.0 >> 4usize) & 0x01;
val != 0
}
#[doc = "The RNG SRAM to DIN DMA done interrupt status. This interrupt is asserted when all data was delivered from RNG SRAM to DIN buffer."]
#[inline(always)]
pub const fn set_sram_to_din_int(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
}
#[doc = "The DOUT to RNG SRAM DMA done interrupt status. This interrupt is asserted when all data was delivered from DOUT buffer to RNG SRAM."]
#[must_use]
#[inline(always)]
pub const fn dout_to_sram_int(&self) -> bool {
let val = (self.0 >> 5usize) & 0x01;
val != 0
}
#[doc = "The DOUT to RNG SRAM DMA done interrupt status. This interrupt is asserted when all data was delivered from DOUT buffer to RNG SRAM."]
#[inline(always)]
pub const fn set_dout_to_sram_int(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
}
#[doc = "The memory to DIN DMA done interrupt status. This interrupt is asserted when all data was delivered from memory to DIN buffer."]
#[must_use]
#[inline(always)]
pub const fn mem_to_din_int(&self) -> bool {
let val = (self.0 >> 6usize) & 0x01;
val != 0
}
#[doc = "The memory to DIN DMA done interrupt status. This interrupt is asserted when all data was delivered from memory to DIN buffer."]
#[inline(always)]
pub const fn set_mem_to_din_int(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize);
}
#[doc = "The DOUT to memory DMA done interrupt status. This interrupt is asserted when all data was delivered from DOUT buffer to memory."]
#[must_use]
#[inline(always)]
pub const fn dout_to_mem_int(&self) -> bool {
let val = (self.0 >> 7usize) & 0x01;
val != 0
}
#[doc = "The DOUT to memory DMA done interrupt status. This interrupt is asserted when all data was delivered from DOUT buffer to memory."]
#[inline(always)]
pub const fn set_dout_to_mem_int(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize);
}
#[doc = "The AHB error interrupt status."]
#[must_use]
#[inline(always)]
pub const fn ahb_err_int(&self) -> bool {
let val = (self.0 >> 8usize) & 0x01;
val != 0
}
#[doc = "The AHB error interrupt status."]
#[inline(always)]
pub const fn set_ahb_err_int(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize);
}
#[doc = "The PKA end of operation interrupt status."]
#[must_use]
#[inline(always)]
pub const fn pka_int(&self) -> bool {
let val = (self.0 >> 9usize) & 0x01;
val != 0
}
#[doc = "The PKA end of operation interrupt status."]
#[inline(always)]
pub const fn set_pka_int(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 9usize)) | (((val as u32) & 0x01) << 9usize);
}
#[doc = "The RNG interrupt status."]
#[must_use]
#[inline(always)]
pub const fn rng_int(&self) -> bool {
let val = (self.0 >> 10usize) & 0x01;
val != 0
}
#[doc = "The RNG interrupt status."]
#[inline(always)]
pub const fn set_rng_int(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 10usize)) | (((val as u32) & 0x01) << 10usize);
}
}
impl Default for Irr {
#[inline(always)]
fn default() -> Irr {
Irr(0)
}
}
impl core::fmt::Debug for Irr {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Irr")
.field("sram_to_din_int", &self.sram_to_din_int())
.field("dout_to_sram_int", &self.dout_to_sram_int())
.field("mem_to_din_int", &self.mem_to_din_int())
.field("dout_to_mem_int", &self.dout_to_mem_int())
.field("ahb_err_int", &self.ahb_err_int())
.field("pka_int", &self.pka_int())
.field("rng_int", &self.rng_int())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Irr {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Irr {{ sram_to_din_int: {=bool:?}, dout_to_sram_int: {=bool:?}, mem_to_din_int: {=bool:?}, dout_to_mem_int: {=bool:?}, ahb_err_int: {=bool:?}, pka_int: {=bool:?}, rng_int: {=bool:?} }}" , self . sram_to_din_int () , self . dout_to_sram_int () , self . mem_to_din_int () , self . dout_to_mem_int () , self . ahb_err_int () , self . pka_int () , self . rng_int ())
}
}
}
pub mod vals {
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum AhbErrMask {
#[doc = "Do not mask AHB error interrupt i.e. interrupt is generated."]
IrqEnable = 0x0,
#[doc = "Mask AHB error interrupt i.e. no interrupt is generated."]
IrqDisable = 0x01,
}
impl AhbErrMask {
#[inline(always)]
pub const fn from_bits(val: u8) -> AhbErrMask {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for AhbErrMask {
#[inline(always)]
fn from(val: u8) -> AhbErrMask {
AhbErrMask::from_bits(val)
}
}
impl From<AhbErrMask> for u8 {
#[inline(always)]
fn from(val: AhbErrMask) -> u8 {
AhbErrMask::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum DinRdBg {
#[doc = "Configure DIN read as little-endian."]
LittleEndian = 0x0,
#[doc = "Configure DIN read as big-endian."]
BigEndian = 0x01,
}
impl DinRdBg {
#[inline(always)]
pub const fn from_bits(val: u8) -> DinRdBg {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for DinRdBg {
#[inline(always)]
fn from(val: u8) -> DinRdBg {
DinRdBg::from_bits(val)
}
}
impl From<DinRdBg> for u8 {
#[inline(always)]
fn from(val: DinRdBg) -> u8 {
DinRdBg::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum DinRdWbg {
#[doc = "Configure DIN read word as little-endian."]
LittleEndian = 0x0,
#[doc = "Configure DIN read word as big-endian."]
BigEndian = 0x01,
}
impl DinRdWbg {
#[inline(always)]
pub const fn from_bits(val: u8) -> DinRdWbg {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for DinRdWbg {
#[inline(always)]
fn from(val: u8) -> DinRdWbg {
DinRdWbg::from_bits(val)
}
}
impl From<DinRdWbg> for u8 {
#[inline(always)]
fn from(val: DinRdWbg) -> u8 {
DinRdWbg::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum DoutToMemMask {
#[doc = "Do not mask DOUT to memory DMA done interrupt i.e. interrupt is generated."]
IrqEnable = 0x0,
#[doc = "Mask DOUT to memory DMA done interrupt i.e. no interrupt is generated."]
IrqDisable = 0x01,
}
impl DoutToMemMask {
#[inline(always)]
pub const fn from_bits(val: u8) -> DoutToMemMask {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for DoutToMemMask {
#[inline(always)]
fn from(val: u8) -> DoutToMemMask {
DoutToMemMask::from_bits(val)
}
}
impl From<DoutToMemMask> for u8 {
#[inline(always)]
fn from(val: DoutToMemMask) -> u8 {
DoutToMemMask::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum DoutToSramMask {
#[doc = "Do not mask DOUT to RNG SRAM DMA done interrupt i.e. interrupt is generated."]
IrqEnable = 0x0,
#[doc = "Mask DOUT to RNG SRAM DMA done interrupt i.e. no interrupt is generated."]
IrqDisable = 0x01,
}
impl DoutToSramMask {
#[inline(always)]
pub const fn from_bits(val: u8) -> DoutToSramMask {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for DoutToSramMask {
#[inline(always)]
fn from(val: u8) -> DoutToSramMask {
DoutToSramMask::from_bits(val)
}
}
impl From<DoutToSramMask> for u8 {
#[inline(always)]
fn from(val: DoutToSramMask) -> u8 {
DoutToSramMask::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum DoutWrBg {
#[doc = "Configure DOUT write as little-endian."]
LittleEndian = 0x0,
#[doc = "Configure DOUT write as big-endian."]
BigEndian = 0x01,
}
impl DoutWrBg {
#[inline(always)]
pub const fn from_bits(val: u8) -> DoutWrBg {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for DoutWrBg {
#[inline(always)]
fn from(val: u8) -> DoutWrBg {
DoutWrBg::from_bits(val)
}
}
impl From<DoutWrBg> for u8 {
#[inline(always)]
fn from(val: DoutWrBg) -> u8 {
DoutWrBg::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum DoutWrWbg {
#[doc = "Configure DOUT write word as little-endian."]
LittleEndian = 0x0,
#[doc = "Configure DOUT write word as big-endian."]
BigEndian = 0x01,
}
impl DoutWrWbg {
#[inline(always)]
pub const fn from_bits(val: u8) -> DoutWrWbg {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for DoutWrWbg {
#[inline(always)]
fn from(val: u8) -> DoutWrWbg {
DoutWrWbg::from_bits(val)
}
}
impl From<DoutWrWbg> for u8 {
#[inline(always)]
fn from(val: DoutWrWbg) -> u8 {
DoutWrWbg::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum HostCryptokeySel {
#[doc = "Use device root key K_DR from CRYPTOCELL AO power domain."]
KDr = 0x0,
#[doc = "Use hard-coded RTL key K_PRTL."]
KPrtl = 0x01,
#[doc = "Use provided session key."]
Session = 0x02,
_RESERVED_3 = 0x03,
}
impl HostCryptokeySel {
#[inline(always)]
pub const fn from_bits(val: u8) -> HostCryptokeySel {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for HostCryptokeySel {
#[inline(always)]
fn from(val: u8) -> HostCryptokeySel {
HostCryptokeySel::from_bits(val)
}
}
impl From<HostCryptokeySel> for u8 {
#[inline(always)]
fn from(val: HostCryptokeySel) -> u8 {
HostCryptokeySel::to_bits(val)
}
}
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct HostIotKdr0(u32);
impl HostIotKdr0 {
#[doc = "Read: 128 bits K_DR key value is not yet retained in the CRYPTOCELL AO power domain."]
pub const NotRetained: Self = Self(0x0);
#[doc = "Read: 128 bits K_DR key value is successfully retained in the CRYPTOCELL AO power domain."]
pub const Retained: Self = Self(0x01);
}
impl HostIotKdr0 {
pub const fn from_bits(val: u32) -> HostIotKdr0 {
Self(val & 0xffff_ffff)
}
pub const fn to_bits(self) -> u32 {
self.0
}
}
impl core::fmt::Debug for HostIotKdr0 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self.0 {
0x0 => f.write_str("NotRetained"),
0x01 => f.write_str("Retained"),
other => core::write!(f, "0x{:02X}", other),
}
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for HostIotKdr0 {
fn format(&self, f: defmt::Formatter) {
match self.0 {
0x0 => defmt::write!(f, "NotRetained"),
0x01 => defmt::write!(f, "Retained"),
other => defmt::write!(f, "0x{:02X}", other),
}
}
}
impl From<u32> for HostIotKdr0 {
#[inline(always)]
fn from(val: u32) -> HostIotKdr0 {
HostIotKdr0::from_bits(val)
}
}
impl From<HostIotKdr0> for u32 {
#[inline(always)]
fn from(val: HostIotKdr0) -> u32 {
HostIotKdr0::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Lcs {
#[doc = "CC310 operates in debug mode."]
DebugEnable = 0x0,
_RESERVED_1 = 0x01,
#[doc = "CC310 operates in secure mode."]
Secure = 0x02,
_RESERVED_3 = 0x03,
_RESERVED_4 = 0x04,
_RESERVED_5 = 0x05,
_RESERVED_6 = 0x06,
_RESERVED_7 = 0x07,
}
impl Lcs {
#[inline(always)]
pub const fn from_bits(val: u8) -> Lcs {
unsafe { core::mem::transmute(val & 0x07) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Lcs {
#[inline(always)]
fn from(val: u8) -> Lcs {
Lcs::from_bits(val)
}
}
impl From<Lcs> for u8 {
#[inline(always)]
fn from(val: Lcs) -> u8 {
Lcs::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum MemToDinMask {
#[doc = "Do not mask memory to DIN DMA done interrupt i.e. interrupt is generated."]
IrqEnable = 0x0,
#[doc = "Mask memory to DIN DMA done interrupt i.e. no interrupt is generated."]
IrqDisable = 0x01,
}
impl MemToDinMask {
#[inline(always)]
pub const fn from_bits(val: u8) -> MemToDinMask {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for MemToDinMask {
#[inline(always)]
fn from(val: u8) -> MemToDinMask {
MemToDinMask::from_bits(val)
}
}
impl From<MemToDinMask> for u8 {
#[inline(always)]
fn from(val: MemToDinMask) -> u8 {
MemToDinMask::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum PkaMask {
#[doc = "Do not mask PKA end of operation interrupt i.e. interrupt is generated."]
IrqEnable = 0x0,
#[doc = "Mask PKA end of operation interrupt i.e. no interrupt is generated."]
IrqDisable = 0x01,
}
impl PkaMask {
#[inline(always)]
pub const fn from_bits(val: u8) -> PkaMask {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for PkaMask {
#[inline(always)]
fn from(val: u8) -> PkaMask {
PkaMask::from_bits(val)
}
}
impl From<PkaMask> for u8 {
#[inline(always)]
fn from(val: PkaMask) -> u8 {
PkaMask::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum RngMask {
#[doc = "Do not mask RNG interrupt i.e. interrupt is generated."]
IrqEnable = 0x0,
#[doc = "Mask RNG interrupt i.e. no interrupt is generated."]
IrqDisable = 0x01,
}
impl RngMask {
#[inline(always)]
pub const fn from_bits(val: u8) -> RngMask {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for RngMask {
#[inline(always)]
fn from(val: u8) -> RngMask {
RngMask::from_bits(val)
}
}
impl From<RngMask> for u8 {
#[inline(always)]
fn from(val: RngMask) -> u8 {
RngMask::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum SramToDinMask {
#[doc = "Do not mask RNG SRAM to DIN DMA done interrupt i.e. interrupt is generated."]
IrqEnable = 0x0,
#[doc = "Mask RNG SRAM to DIN DMA done interrupt i.e. no interrupt is generated."]
IrqDisable = 0x01,
}
impl SramToDinMask {
#[inline(always)]
pub const fn from_bits(val: u8) -> SramToDinMask {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for SramToDinMask {
#[inline(always)]
fn from(val: u8) -> SramToDinMask {
SramToDinMask::from_bits(val)
}
}
impl From<SramToDinMask> for u8 {
#[inline(always)]
fn from(val: SramToDinMask) -> u8 {
SramToDinMask::to_bits(val)
}
}
}
}
pub mod cc_misc {
#[doc = "CRYPTOCELL MISC interface."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct CcMisc {
ptr: *mut u8,
}
unsafe impl Send for CcMisc {}
unsafe impl Sync for CcMisc {}
impl CcMisc {
#[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 = "Clock control for the AES engine."]
#[inline(always)]
pub const fn aes_clk(self) -> crate::common::Reg<regs::AesClk, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0810usize) as _) }
}
#[doc = "Clock control for the HASH engine."]
#[inline(always)]
pub const fn hash_clk(self) -> crate::common::Reg<regs::HashClk, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0818usize) as _) }
}
#[doc = "Clock control for the PKA engine."]
#[inline(always)]
pub const fn pka_clk(self) -> crate::common::Reg<regs::PkaClk, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x081cusize) as _) }
}
#[doc = "Clock control for the DMA engines."]
#[inline(always)]
pub const fn dma_clk(self) -> crate::common::Reg<regs::DmaClk, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0820usize) as _) }
}
#[doc = "CRYPTOCELL clocks status register."]
#[inline(always)]
pub const fn clk_status(self) -> crate::common::Reg<regs::ClkStatus, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0824usize) as _) }
}
#[doc = "Clock control for the CHACHA engine."]
#[inline(always)]
pub const fn chacha_clk(self) -> crate::common::Reg<regs::ChachaClk, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0858usize) as _) }
}
}
pub mod regs {
#[doc = "Clock control for the AES engine."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct AesClk(pub u32);
impl AesClk {
#[doc = "Enables clock for the AES engine."]
#[must_use]
#[inline(always)]
pub const fn enable(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Enables clock for the AES engine."]
#[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 AesClk {
#[inline(always)]
fn default() -> AesClk {
AesClk(0)
}
}
impl core::fmt::Debug for AesClk {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("AesClk")
.field("enable", &self.enable())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for AesClk {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "AesClk {{ enable: {=bool:?} }}", self.enable())
}
}
#[doc = "Clock control for the CHACHA engine."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct ChachaClk(pub u32);
impl ChachaClk {
#[doc = "Enables clock for the CHACHA engine."]
#[must_use]
#[inline(always)]
pub const fn enable(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Enables clock for the CHACHA engine."]
#[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 ChachaClk {
#[inline(always)]
fn default() -> ChachaClk {
ChachaClk(0)
}
}
impl core::fmt::Debug for ChachaClk {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("ChachaClk")
.field("enable", &self.enable())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for ChachaClk {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "ChachaClk {{ enable: {=bool:?} }}", self.enable())
}
}
#[doc = "CRYPTOCELL clocks status register."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct ClkStatus(pub u32);
impl ClkStatus {
#[doc = "Status of AES engine clock."]
#[must_use]
#[inline(always)]
pub const fn aes_clk(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Status of AES engine clock."]
#[inline(always)]
pub const fn set_aes_clk(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Status of HASH engine clock."]
#[must_use]
#[inline(always)]
pub const fn hash_clk(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Status of HASH engine clock."]
#[inline(always)]
pub const fn set_hash_clk(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "Status of PKA engine clock."]
#[must_use]
#[inline(always)]
pub const fn pka_clk(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "Status of PKA engine clock."]
#[inline(always)]
pub const fn set_pka_clk(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
#[doc = "Status of CHACHA engine clock."]
#[must_use]
#[inline(always)]
pub const fn chacha_clk(&self) -> bool {
let val = (self.0 >> 7usize) & 0x01;
val != 0
}
#[doc = "Status of CHACHA engine clock."]
#[inline(always)]
pub const fn set_chacha_clk(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize);
}
#[doc = "Status of DMA engines clock."]
#[must_use]
#[inline(always)]
pub const fn dma_clk(&self) -> bool {
let val = (self.0 >> 8usize) & 0x01;
val != 0
}
#[doc = "Status of DMA engines clock."]
#[inline(always)]
pub const fn set_dma_clk(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize);
}
}
impl Default for ClkStatus {
#[inline(always)]
fn default() -> ClkStatus {
ClkStatus(0)
}
}
impl core::fmt::Debug for ClkStatus {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("ClkStatus")
.field("aes_clk", &self.aes_clk())
.field("hash_clk", &self.hash_clk())
.field("pka_clk", &self.pka_clk())
.field("chacha_clk", &self.chacha_clk())
.field("dma_clk", &self.dma_clk())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for ClkStatus {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "ClkStatus {{ aes_clk: {=bool:?}, hash_clk: {=bool:?}, pka_clk: {=bool:?}, chacha_clk: {=bool:?}, dma_clk: {=bool:?} }}" , self . aes_clk () , self . hash_clk () , self . pka_clk () , self . chacha_clk () , self . dma_clk ())
}
}
#[doc = "Clock control for the DMA engines."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct DmaClk(pub u32);
impl DmaClk {
#[doc = "Enables clock for the DMA engines."]
#[must_use]
#[inline(always)]
pub const fn enable(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Enables clock for the DMA engines."]
#[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 DmaClk {
#[inline(always)]
fn default() -> DmaClk {
DmaClk(0)
}
}
impl core::fmt::Debug for DmaClk {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("DmaClk")
.field("enable", &self.enable())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for DmaClk {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "DmaClk {{ enable: {=bool:?} }}", self.enable())
}
}
#[doc = "Clock control for the HASH engine."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct HashClk(pub u32);
impl HashClk {
#[doc = "Enables clock for the HASH engine."]
#[must_use]
#[inline(always)]
pub const fn enable(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Enables clock for the HASH engine."]
#[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 HashClk {
#[inline(always)]
fn default() -> HashClk {
HashClk(0)
}
}
impl core::fmt::Debug for HashClk {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("HashClk")
.field("enable", &self.enable())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for HashClk {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "HashClk {{ enable: {=bool:?} }}", self.enable())
}
}
#[doc = "Clock control for the PKA engine."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct PkaClk(pub u32);
impl PkaClk {
#[doc = "Enables clock for the PKA engine."]
#[must_use]
#[inline(always)]
pub const fn enable(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Enables clock for the PKA engine."]
#[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 PkaClk {
#[inline(always)]
fn default() -> PkaClk {
PkaClk(0)
}
}
impl core::fmt::Debug for PkaClk {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("PkaClk")
.field("enable", &self.enable())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for PkaClk {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "PkaClk {{ enable: {=bool:?} }}", self.enable())
}
}
}
}
pub mod cc_pka {
#[doc = "CRYPTOCELL PKA engine."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct CcPka {
ptr: *mut u8,
}
unsafe impl Send for CcPka {}
unsafe impl Sync for CcPka {}
impl CcPka {
#[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: Register for mapping the virtual register R\\[n\\] to a physical address in the PKA SRAM."]
#[inline(always)]
pub const fn memory_map(
self,
n: usize,
) -> crate::common::Reg<regs::MemoryMap, crate::common::RW> {
assert!(n < 32usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize + n * 4usize) as _)
}
}
#[doc = "Operation code to be executed by the PKA engine. Writing to this register triggers the PKA operation."]
#[inline(always)]
pub const fn opcode(self) -> crate::common::Reg<regs::Opcode, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x80usize) as _) }
}
#[doc = "This register defines the N, Np, T0, and T1 virtual register index."]
#[inline(always)]
pub const fn n_np_t0_t1_addr(
self,
) -> crate::common::Reg<regs::NNpT0T1Addr, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x84usize) as _) }
}
#[doc = "This register holds the status for the PKA pipeline."]
#[inline(always)]
pub const fn pka_status(self) -> crate::common::Reg<regs::PkaStatus, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x88usize) as _) }
}
#[doc = "Reset the PKA engine."]
#[inline(always)]
pub const fn pka_sw_reset(self) -> crate::common::Reg<regs::PkaSwReset, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x8cusize) as _) }
}
#[doc = "Description collection: This register holds the operands bit size."]
#[inline(always)]
pub const fn pka_l(self, n: usize) -> crate::common::Reg<regs::PkaL, crate::common::RW> {
assert!(n < 8usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x90usize + n * 4usize) as _)
}
}
#[doc = "Status register indicating if the PKA pipeline is ready to receive a new OPCODE."]
#[inline(always)]
pub const fn pka_pipe(self) -> crate::common::Reg<regs::PkaPipe, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0xb0usize) as _) }
}
#[doc = "Status register indicating if the PKA operation has been completed."]
#[inline(always)]
pub const fn pka_done(self) -> crate::common::Reg<regs::PkaDone, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0xb4usize) as _) }
}
#[doc = "PKA engine HW version. Reset value holds the version."]
#[inline(always)]
pub const fn pka_version(self) -> crate::common::Reg<u32, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0xc4usize) as _) }
}
#[doc = "Start address in PKA SRAM for subsequent write transactions."]
#[inline(always)]
pub const fn pka_sram_waddr(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0xd4usize) as _) }
}
#[doc = "Write data to PKA SRAM. Writing to this register triggers a DMA transaction writing data into PKA SRAM. The DMA address offset is automatically incremented during write."]
#[inline(always)]
pub const fn pka_sram_wdata(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0xd8usize) as _) }
}
#[doc = "Read data from PKA SRAM. Reading from this register triggers a DMA transaction read data from PKA SRAM. The DMA address offset is automatically incremented during read."]
#[inline(always)]
pub const fn pka_sram_rdata(self) -> crate::common::Reg<u32, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0xdcusize) as _) }
}
#[doc = "Register for clearing PKA SRAM write buffer."]
#[inline(always)]
pub const fn pka_sram_wclear(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0xe0usize) as _) }
}
#[doc = "Start address in PKA SRAM for subsequent read transactions."]
#[inline(always)]
pub const fn pka_sram_raddr(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0xe4usize) as _) }
}
}
pub mod regs {
#[doc = "Description collection: Register for mapping the virtual register R\\[n\\] to a physical address in the PKA SRAM."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct MemoryMap(pub u32);
impl MemoryMap {
#[doc = "The physical word address used for the virtual register."]
#[must_use]
#[inline(always)]
pub const fn addr(&self) -> u16 {
let val = (self.0 >> 1usize) & 0x01ff;
val as u16
}
#[doc = "The physical word address used for the virtual register."]
#[inline(always)]
pub const fn set_addr(&mut self, val: u16) {
self.0 = (self.0 & !(0x01ff << 1usize)) | (((val as u32) & 0x01ff) << 1usize);
}
}
impl Default for MemoryMap {
#[inline(always)]
fn default() -> MemoryMap {
MemoryMap(0)
}
}
impl core::fmt::Debug for MemoryMap {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("MemoryMap")
.field("addr", &self.addr())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for MemoryMap {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "MemoryMap {{ addr: {=u16:?} }}", self.addr())
}
}
#[doc = "This register defines the N, Np, T0, and T1 virtual register index."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct NNpT0T1Addr(pub u32);
impl NNpT0T1Addr {
#[doc = "Register N virtual register index. Default is R0."]
#[must_use]
#[inline(always)]
pub const fn n_virtual_addr(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x1f;
val as u8
}
#[doc = "Register N virtual register index. Default is R0."]
#[inline(always)]
pub const fn set_n_virtual_addr(&mut self, val: u8) {
self.0 = (self.0 & !(0x1f << 0usize)) | (((val as u32) & 0x1f) << 0usize);
}
#[doc = "Register Np virtual register index. Default is R1."]
#[must_use]
#[inline(always)]
pub const fn np_virtual_addr(&self) -> u8 {
let val = (self.0 >> 5usize) & 0x1f;
val as u8
}
#[doc = "Register Np virtual register index. Default is R1."]
#[inline(always)]
pub const fn set_np_virtual_addr(&mut self, val: u8) {
self.0 = (self.0 & !(0x1f << 5usize)) | (((val as u32) & 0x1f) << 5usize);
}
#[doc = "Temporary register 0 virtual register index. Default is R30."]
#[must_use]
#[inline(always)]
pub const fn t0_virtual_addr(&self) -> u8 {
let val = (self.0 >> 10usize) & 0x1f;
val as u8
}
#[doc = "Temporary register 0 virtual register index. Default is R30."]
#[inline(always)]
pub const fn set_t0_virtual_addr(&mut self, val: u8) {
self.0 = (self.0 & !(0x1f << 10usize)) | (((val as u32) & 0x1f) << 10usize);
}
#[doc = "Temporary register 1 virtual register index. Default is R31."]
#[must_use]
#[inline(always)]
pub const fn t1_virtual_addr(&self) -> u8 {
let val = (self.0 >> 15usize) & 0x1f;
val as u8
}
#[doc = "Temporary register 1 virtual register index. Default is R31."]
#[inline(always)]
pub const fn set_t1_virtual_addr(&mut self, val: u8) {
self.0 = (self.0 & !(0x1f << 15usize)) | (((val as u32) & 0x1f) << 15usize);
}
}
impl Default for NNpT0T1Addr {
#[inline(always)]
fn default() -> NNpT0T1Addr {
NNpT0T1Addr(0)
}
}
impl core::fmt::Debug for NNpT0T1Addr {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("NNpT0T1Addr")
.field("n_virtual_addr", &self.n_virtual_addr())
.field("np_virtual_addr", &self.np_virtual_addr())
.field("t0_virtual_addr", &self.t0_virtual_addr())
.field("t1_virtual_addr", &self.t1_virtual_addr())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for NNpT0T1Addr {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "NNpT0T1Addr {{ n_virtual_addr: {=u8:?}, np_virtual_addr: {=u8:?}, t0_virtual_addr: {=u8:?}, t1_virtual_addr: {=u8:?} }}" , self . n_virtual_addr () , self . np_virtual_addr () , self . t0_virtual_addr () , self . t1_virtual_addr ())
}
}
#[doc = "Operation code to be executed by the PKA engine. Writing to this register triggers the PKA operation."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Opcode(pub u32);
impl Opcode {
#[doc = "Holds the operation tag or the operand C virtual register index."]
#[must_use]
#[inline(always)]
pub const fn tag(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x3f;
val as u8
}
#[doc = "Holds the operation tag or the operand C virtual register index."]
#[inline(always)]
pub const fn set_tag(&mut self, val: u8) {
self.0 = (self.0 & !(0x3f << 0usize)) | (((val as u32) & 0x3f) << 0usize);
}
#[doc = "Result register virtual register index."]
#[must_use]
#[inline(always)]
pub const fn reg_r(&self) -> u8 {
let val = (self.0 >> 6usize) & 0x1f;
val as u8
}
#[doc = "Result register virtual register index."]
#[inline(always)]
pub const fn set_reg_r(&mut self, val: u8) {
self.0 = (self.0 & !(0x1f << 6usize)) | (((val as u32) & 0x1f) << 6usize);
}
#[doc = "This field controls the interpretation of REG_R."]
#[must_use]
#[inline(always)]
pub const fn discard_r(&self) -> super::vals::DiscardR {
let val = (self.0 >> 11usize) & 0x01;
super::vals::DiscardR::from_bits(val as u8)
}
#[doc = "This field controls the interpretation of REG_R."]
#[inline(always)]
pub const fn set_discard_r(&mut self, val: super::vals::DiscardR) {
self.0 =
(self.0 & !(0x01 << 11usize)) | (((val.to_bits() as u32) & 0x01) << 11usize);
}
#[doc = "Operand B virtual register index."]
#[must_use]
#[inline(always)]
pub const fn reg_b(&self) -> u8 {
let val = (self.0 >> 12usize) & 0x1f;
val as u8
}
#[doc = "Operand B virtual register index."]
#[inline(always)]
pub const fn set_reg_b(&mut self, val: u8) {
self.0 = (self.0 & !(0x1f << 12usize)) | (((val as u32) & 0x1f) << 12usize);
}
#[doc = "This field controls the interpretation of REG_B."]
#[must_use]
#[inline(always)]
pub const fn const_b(&self) -> super::vals::ConstB {
let val = (self.0 >> 17usize) & 0x01;
super::vals::ConstB::from_bits(val as u8)
}
#[doc = "This field controls the interpretation of REG_B."]
#[inline(always)]
pub const fn set_const_b(&mut self, val: super::vals::ConstB) {
self.0 =
(self.0 & !(0x01 << 17usize)) | (((val.to_bits() as u32) & 0x01) << 17usize);
}
#[doc = "Operand A virtual register index."]
#[must_use]
#[inline(always)]
pub const fn reg_a(&self) -> u8 {
let val = (self.0 >> 18usize) & 0x1f;
val as u8
}
#[doc = "Operand A virtual register index."]
#[inline(always)]
pub const fn set_reg_a(&mut self, val: u8) {
self.0 = (self.0 & !(0x1f << 18usize)) | (((val as u32) & 0x1f) << 18usize);
}
#[doc = "This field controls the interpretation of REG_A."]
#[must_use]
#[inline(always)]
pub const fn const_a(&self) -> super::vals::ConstA {
let val = (self.0 >> 23usize) & 0x01;
super::vals::ConstA::from_bits(val as u8)
}
#[doc = "This field controls the interpretation of REG_A."]
#[inline(always)]
pub const fn set_const_a(&mut self, val: super::vals::ConstA) {
self.0 =
(self.0 & !(0x01 << 23usize)) | (((val.to_bits() as u32) & 0x01) << 23usize);
}
#[doc = "The length of the operands. This value serves as an PKA length register index. E.g.: if LEN field value is set to 0, PKA_L\\[0\\] holds the size of the operands."]
#[must_use]
#[inline(always)]
pub const fn len(&self) -> u8 {
let val = (self.0 >> 24usize) & 0x07;
val as u8
}
#[doc = "The length of the operands. This value serves as an PKA length register index. E.g.: if LEN field value is set to 0, PKA_L\\[0\\] holds the size of the operands."]
#[inline(always)]
pub const fn set_len(&mut self, val: u8) {
self.0 = (self.0 & !(0x07 << 24usize)) | (((val as u32) & 0x07) << 24usize);
}
#[doc = "Operation code to be executed by the PKA engine."]
#[must_use]
#[inline(always)]
pub const fn opcode(&self) -> super::vals::Opcode {
let val = (self.0 >> 27usize) & 0x1f;
super::vals::Opcode::from_bits(val as u8)
}
#[doc = "Operation code to be executed by the PKA engine."]
#[inline(always)]
pub const fn set_opcode(&mut self, val: super::vals::Opcode) {
self.0 =
(self.0 & !(0x1f << 27usize)) | (((val.to_bits() as u32) & 0x1f) << 27usize);
}
}
impl Default for Opcode {
#[inline(always)]
fn default() -> Opcode {
Opcode(0)
}
}
impl core::fmt::Debug for Opcode {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Opcode")
.field("tag", &self.tag())
.field("reg_r", &self.reg_r())
.field("discard_r", &self.discard_r())
.field("reg_b", &self.reg_b())
.field("const_b", &self.const_b())
.field("reg_a", &self.reg_a())
.field("const_a", &self.const_a())
.field("len", &self.len())
.field("opcode", &self.opcode())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Opcode {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Opcode {{ tag: {=u8:?}, reg_r: {=u8:?}, discard_r: {:?}, reg_b: {=u8:?}, const_b: {:?}, reg_a: {=u8:?}, const_a: {:?}, len: {=u8:?}, opcode: {:?} }}" , self . tag () , self . reg_r () , self . discard_r () , self . reg_b () , self . const_b () , self . reg_a () , self . const_a () , self . len () , self . opcode ())
}
}
#[doc = "Status register indicating if the PKA operation has been completed."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct PkaDone(pub u32);
impl PkaDone {
#[doc = "PKA operation status."]
#[must_use]
#[inline(always)]
pub const fn status(&self) -> super::vals::PkaDoneStatus {
let val = (self.0 >> 0usize) & 0x01;
super::vals::PkaDoneStatus::from_bits(val as u8)
}
#[doc = "PKA operation status."]
#[inline(always)]
pub const fn set_status(&mut self, val: super::vals::PkaDoneStatus) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
}
impl Default for PkaDone {
#[inline(always)]
fn default() -> PkaDone {
PkaDone(0)
}
}
impl core::fmt::Debug for PkaDone {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("PkaDone")
.field("status", &self.status())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for PkaDone {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "PkaDone {{ status: {:?} }}", self.status())
}
}
#[doc = "Description collection: This register holds the operands bit size."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct PkaL(pub u32);
impl PkaL {
#[doc = "Operand bit size."]
#[must_use]
#[inline(always)]
pub const fn op_size(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x1fff;
val as u16
}
#[doc = "Operand bit size."]
#[inline(always)]
pub const fn set_op_size(&mut self, val: u16) {
self.0 = (self.0 & !(0x1fff << 0usize)) | (((val as u32) & 0x1fff) << 0usize);
}
}
impl Default for PkaL {
#[inline(always)]
fn default() -> PkaL {
PkaL(0)
}
}
impl core::fmt::Debug for PkaL {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("PkaL")
.field("op_size", &self.op_size())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for PkaL {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "PkaL {{ op_size: {=u16:?} }}", self.op_size())
}
}
#[doc = "Status register indicating if the PKA pipeline is ready to receive a new OPCODE."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct PkaPipe(pub u32);
impl PkaPipe {
#[doc = "PKA pipeline status."]
#[must_use]
#[inline(always)]
pub const fn status(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "PKA pipeline status."]
#[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 PkaPipe {
#[inline(always)]
fn default() -> PkaPipe {
PkaPipe(0)
}
}
impl core::fmt::Debug for PkaPipe {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("PkaPipe")
.field("status", &self.status())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for PkaPipe {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "PkaPipe {{ status: {=bool:?} }}", self.status())
}
}
#[doc = "This register holds the status for the PKA pipeline."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct PkaStatus(pub u32);
impl PkaStatus {
#[doc = "The most significant 4-bits of the operand updated in shift operation."]
#[must_use]
#[inline(always)]
pub const fn alu_msb_4bits(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x0f;
val as u8
}
#[doc = "The most significant 4-bits of the operand updated in shift operation."]
#[inline(always)]
pub const fn set_alu_msb_4bits(&mut self, val: u8) {
self.0 = (self.0 & !(0x0f << 0usize)) | (((val as u32) & 0x0f) << 0usize);
}
#[doc = "The least significant 4-bits of the operand updated in shift operation."]
#[must_use]
#[inline(always)]
pub const fn alu_lsb_4bits(&self) -> u8 {
let val = (self.0 >> 4usize) & 0x0f;
val as u8
}
#[doc = "The least significant 4-bits of the operand updated in shift operation."]
#[inline(always)]
pub const fn set_alu_lsb_4bits(&mut self, val: u8) {
self.0 = (self.0 & !(0x0f << 4usize)) | (((val as u32) & 0x0f) << 4usize);
}
#[doc = "Indicates the MSB sign of the last operation."]
#[must_use]
#[inline(always)]
pub const fn alu_sign_out(&self) -> bool {
let val = (self.0 >> 8usize) & 0x01;
val != 0
}
#[doc = "Indicates the MSB sign of the last operation."]
#[inline(always)]
pub const fn set_alu_sign_out(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize);
}
#[doc = "Holds the carry of the last ALU operation."]
#[must_use]
#[inline(always)]
pub const fn alu_carry(&self) -> bool {
let val = (self.0 >> 9usize) & 0x01;
val != 0
}
#[doc = "Holds the carry of the last ALU operation."]
#[inline(always)]
pub const fn set_alu_carry(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 9usize)) | (((val as u32) & 0x01) << 9usize);
}
#[doc = "Holds the carry of the last modular operation."]
#[must_use]
#[inline(always)]
pub const fn alu_carry_mod(&self) -> bool {
let val = (self.0 >> 10usize) & 0x01;
val != 0
}
#[doc = "Holds the carry of the last modular operation."]
#[inline(always)]
pub const fn set_alu_carry_mod(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 10usize)) | (((val as u32) & 0x01) << 10usize);
}
#[doc = "Indicates the last subtraction operation sign."]
#[must_use]
#[inline(always)]
pub const fn alu_sub_is_zero(&self) -> bool {
let val = (self.0 >> 11usize) & 0x01;
val != 0
}
#[doc = "Indicates the last subtraction operation sign."]
#[inline(always)]
pub const fn set_alu_sub_is_zero(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 11usize)) | (((val as u32) & 0x01) << 11usize);
}
#[doc = "Indicates if the result of ALU OUT is zero."]
#[must_use]
#[inline(always)]
pub const fn alu_out_zero(&self) -> bool {
let val = (self.0 >> 12usize) & 0x01;
val != 0
}
#[doc = "Indicates if the result of ALU OUT is zero."]
#[inline(always)]
pub const fn set_alu_out_zero(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 12usize)) | (((val as u32) & 0x01) << 12usize);
}
#[doc = "Modular overflow flag."]
#[must_use]
#[inline(always)]
pub const fn alu_modovrflw(&self) -> bool {
let val = (self.0 >> 13usize) & 0x01;
val != 0
}
#[doc = "Modular overflow flag."]
#[inline(always)]
pub const fn set_alu_modovrflw(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 13usize)) | (((val as u32) & 0x01) << 13usize);
}
#[doc = "Indication if the division is done by zero."]
#[must_use]
#[inline(always)]
pub const fn div_by_zero(&self) -> bool {
let val = (self.0 >> 14usize) & 0x01;
val != 0
}
#[doc = "Indication if the division is done by zero."]
#[inline(always)]
pub const fn set_div_by_zero(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 14usize)) | (((val as u32) & 0x01) << 14usize);
}
#[doc = "Indicates the modular inverse of zero."]
#[must_use]
#[inline(always)]
pub const fn modinv_of_zero(&self) -> bool {
let val = (self.0 >> 15usize) & 0x01;
val != 0
}
#[doc = "Indicates the modular inverse of zero."]
#[inline(always)]
pub const fn set_modinv_of_zero(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 15usize)) | (((val as u32) & 0x01) << 15usize);
}
#[doc = "Opcode of the last operation."]
#[must_use]
#[inline(always)]
pub const fn opcode(&self) -> u8 {
let val = (self.0 >> 16usize) & 0x1f;
val as u8
}
#[doc = "Opcode of the last operation."]
#[inline(always)]
pub const fn set_opcode(&mut self, val: u8) {
self.0 = (self.0 & !(0x1f << 16usize)) | (((val as u32) & 0x1f) << 16usize);
}
}
impl Default for PkaStatus {
#[inline(always)]
fn default() -> PkaStatus {
PkaStatus(0)
}
}
impl core::fmt::Debug for PkaStatus {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("PkaStatus")
.field("alu_msb_4bits", &self.alu_msb_4bits())
.field("alu_lsb_4bits", &self.alu_lsb_4bits())
.field("alu_sign_out", &self.alu_sign_out())
.field("alu_carry", &self.alu_carry())
.field("alu_carry_mod", &self.alu_carry_mod())
.field("alu_sub_is_zero", &self.alu_sub_is_zero())
.field("alu_out_zero", &self.alu_out_zero())
.field("alu_modovrflw", &self.alu_modovrflw())
.field("div_by_zero", &self.div_by_zero())
.field("modinv_of_zero", &self.modinv_of_zero())
.field("opcode", &self.opcode())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for PkaStatus {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "PkaStatus {{ alu_msb_4bits: {=u8:?}, alu_lsb_4bits: {=u8:?}, alu_sign_out: {=bool:?}, alu_carry: {=bool:?}, alu_carry_mod: {=bool:?}, alu_sub_is_zero: {=bool:?}, alu_out_zero: {=bool:?}, alu_modovrflw: {=bool:?}, div_by_zero: {=bool:?}, modinv_of_zero: {=bool:?}, opcode: {=u8:?} }}" , self . alu_msb_4bits () , self . alu_lsb_4bits () , self . alu_sign_out () , self . alu_carry () , self . alu_carry_mod () , self . alu_sub_is_zero () , self . alu_out_zero () , self . alu_modovrflw () , self . div_by_zero () , self . modinv_of_zero () , self . opcode ())
}
}
#[doc = "Reset the PKA engine."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct PkaSwReset(pub u32);
impl PkaSwReset {
#[doc = "Writing any value to this address resets the PKA engine. The reset takes 4 CPU clock cycles to complete."]
#[must_use]
#[inline(always)]
pub const fn reset(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Writing any value to this address resets the PKA engine. The reset takes 4 CPU clock cycles to complete."]
#[inline(always)]
pub const fn set_reset(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for PkaSwReset {
#[inline(always)]
fn default() -> PkaSwReset {
PkaSwReset(0)
}
}
impl core::fmt::Debug for PkaSwReset {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("PkaSwReset")
.field("reset", &self.reset())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for PkaSwReset {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "PkaSwReset {{ reset: {=bool:?} }}", self.reset())
}
}
}
pub mod vals {
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum ConstA {
#[doc = "REG_A is intepreted as a register index."]
Register = 0x0,
#[doc = "REG_A is intepreted as a constant."]
Constant = 0x01,
}
impl ConstA {
#[inline(always)]
pub const fn from_bits(val: u8) -> ConstA {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for ConstA {
#[inline(always)]
fn from(val: u8) -> ConstA {
ConstA::from_bits(val)
}
}
impl From<ConstA> for u8 {
#[inline(always)]
fn from(val: ConstA) -> u8 {
ConstA::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum ConstB {
#[doc = "REG_B is intepreted as a register index."]
Register = 0x0,
#[doc = "REG_B is intepreted as a constant."]
Constant = 0x01,
}
impl ConstB {
#[inline(always)]
pub const fn from_bits(val: u8) -> ConstB {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for ConstB {
#[inline(always)]
fn from(val: u8) -> ConstB {
ConstB::from_bits(val)
}
}
impl From<ConstB> for u8 {
#[inline(always)]
fn from(val: ConstB) -> u8 {
ConstB::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum DiscardR {
#[doc = "REG_R is intepreted as a register index."]
Register = 0x0,
#[doc = "Result is discarded."]
Discard = 0x01,
}
impl DiscardR {
#[inline(always)]
pub const fn from_bits(val: u8) -> DiscardR {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for DiscardR {
#[inline(always)]
fn from(val: u8) -> DiscardR {
DiscardR::from_bits(val)
}
}
impl From<DiscardR> for u8 {
#[inline(always)]
fn from(val: DiscardR) -> u8 {
DiscardR::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Opcode {
#[doc = "Terminate operation."]
Terminate = 0x0,
_RESERVED_1 = 0x01,
_RESERVED_2 = 0x02,
_RESERVED_3 = 0x03,
#[doc = "Add or Increment."]
AddInc = 0x04,
#[doc = "Subtract, Decrement, or Negate."]
SubDecNeg = 0x05,
#[doc = "Modular Add or Modular Increment."]
ModAddInc = 0x06,
#[doc = "Modular Subtract, Modular Decrement, or Modular Negate."]
ModSubDecNeg = 0x07,
#[doc = "Perform AND, test, or clear."]
Andtst0clr0 = 0x08,
#[doc = "Perform OR, copy, or set bits."]
Orcopyset0 = 0x09,
#[doc = "Perform XOR, flip bits, invert, or compare."]
Xorflp0invcmp = 0x0a,
_RESERVED_b = 0x0b,
#[doc = "Shift right 0 operation."]
Shr0 = 0x0c,
#[doc = "Shift right 1 operation."]
Shr1 = 0x0d,
#[doc = "Shift left 0 operation."]
Shl0 = 0x0e,
#[doc = "Shift left 1 operation."]
Shl1 = 0x0f,
#[doc = "Multiply low operation."]
MulLow = 0x10,
#[doc = "Modular multiply operation."]
ModMul = 0x11,
#[doc = "Modular multiply N operation."]
ModMulN = 0x12,
#[doc = "Modular exponentiation operation."]
ModExp = 0x13,
#[doc = "Division operation."]
Division = 0x14,
#[doc = "Modular inversion operation."]
ModInv = 0x15,
#[doc = "Modular division operation."]
ModDiv = 0x16,
#[doc = "Multiply high operation."]
MulHigh = 0x17,
#[doc = "Modular multiplication acceleration."]
ModMlac = 0x18,
#[doc = "Modular multiplication acceleration where final reduction is omitted."]
ModMlacnr = 0x19,
_RESERVED_1a = 0x1a,
#[doc = "Reduction operation."]
Reduction = 0x1b,
_RESERVED_1c = 0x1c,
_RESERVED_1d = 0x1d,
_RESERVED_1e = 0x1e,
_RESERVED_1f = 0x1f,
}
impl Opcode {
#[inline(always)]
pub const fn from_bits(val: u8) -> Opcode {
unsafe { core::mem::transmute(val & 0x1f) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Opcode {
#[inline(always)]
fn from(val: u8) -> Opcode {
Opcode::from_bits(val)
}
}
impl From<Opcode> for u8 {
#[inline(always)]
fn from(val: Opcode) -> u8 {
Opcode::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum PkaDoneStatus {
#[doc = "PKA operation is processing."]
Processing = 0x0,
#[doc = "PKA operation is completed and pipeline is empty."]
Completed = 0x01,
}
impl PkaDoneStatus {
#[inline(always)]
pub const fn from_bits(val: u8) -> PkaDoneStatus {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for PkaDoneStatus {
#[inline(always)]
fn from(val: u8) -> PkaDoneStatus {
PkaDoneStatus::from_bits(val)
}
}
impl From<PkaDoneStatus> for u8 {
#[inline(always)]
fn from(val: PkaDoneStatus) -> u8 {
PkaDoneStatus::to_bits(val)
}
}
}
}
pub mod cc_rng {
#[doc = "CRYPTOCELL RNG engine."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct CcRng {
ptr: *mut u8,
}
unsafe impl Send for CcRng {}
unsafe impl Sync for CcRng {}
impl CcRng {
#[inline(always)]
pub const unsafe fn from_ptr(ptr: *mut ()) -> Self {
Self { ptr: ptr as _ }
}
#[inline(always)]
pub const fn as_ptr(&self) -> *mut () {
self.ptr as _
}
#[doc = "Interrupt mask register. Each bit of this register holds the mask of a single interrupt source."]
#[inline(always)]
pub const fn rng_imr(self) -> crate::common::Reg<regs::RngImr, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0100usize) as _) }
}
#[doc = "Interrupt status register. Each bit of this register holds the interrupt status of a single interrupt source. If corresponding RNG_IMR bit is unmasked, an interrupt is generated."]
#[inline(always)]
pub const fn rng_isr(self) -> crate::common::Reg<regs::RngIsr, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0104usize) as _) }
}
#[doc = "Interrupt clear register. Writing a 1 bit into a field in this register will clear the corresponding bit in RNG_ISR."]
#[inline(always)]
pub const fn rng_icr(self) -> crate::common::Reg<regs::RngIcr, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0108usize) as _) }
}
#[doc = "TRNG ring oscillator length configuration."]
#[inline(always)]
pub const fn trng_config(self) -> crate::common::Reg<regs::TrngConfig, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x010cusize) as _) }
}
#[doc = "This register indicates if TRNG entropy collection is valid."]
#[inline(always)]
pub const fn trng_valid(self) -> crate::common::Reg<regs::TrngValid, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0110usize) as _) }
}
#[doc = "Description collection: The entropy holding registers (EHR) hold 192-bits random data collected by the TRNG. The initial EHR_DATA\\[0\\] register holds the least significant bits \\[31:0\\] of the random data value."]
#[inline(always)]
pub const fn ehr_data(self, n: usize) -> crate::common::Reg<u32, crate::common::R> {
assert!(n < 6usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0114usize + n * 4usize) as _)
}
}
#[doc = "This register controls the ring oscillator circuit used as a noise source."]
#[inline(always)]
pub const fn noise_source(
self,
) -> crate::common::Reg<regs::NoiseSource, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x012cusize) as _) }
}
#[doc = "Sample count defining the number of CPU clock cycles between two consecutive noise source samples."]
#[inline(always)]
pub const fn sample_cnt(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0130usize) as _) }
}
#[doc = "Statistics counter for autocorrelation test activations. Statistics collection is stopped if one of the counters reach its limit of all ones."]
#[inline(always)]
pub const fn autocorr_statistic(
self,
) -> crate::common::Reg<regs::AutocorrStatistic, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0134usize) as _) }
}
#[doc = "Debug register for the TRNG. This register is used to bypass TRNG tests in hardware."]
#[inline(always)]
pub const fn trng_debug(self) -> crate::common::Reg<regs::TrngDebug, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0138usize) as _) }
}
#[doc = "Reset the RNG engine."]
#[inline(always)]
pub const fn rng_sw_reset(self) -> crate::common::Reg<regs::RngSwReset, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0140usize) as _) }
}
#[doc = "Status register for RNG engine activity."]
#[inline(always)]
pub const fn rng_busy(self) -> crate::common::Reg<regs::RngBusy, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x01b8usize) as _) }
}
#[doc = "Reset the TRNG, including internal counter of collected bits and registers EHR_DATA and TRNG_VALID."]
#[inline(always)]
pub const fn trng_reset(self) -> crate::common::Reg<regs::TrngReset, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x01bcusize) as _) }
}
#[doc = "Hardware configuration of RNG engine. Reset value holds the supported features."]
#[inline(always)]
pub const fn rng_hw_flags(self) -> crate::common::Reg<regs::RngHwFlags, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x01c0usize) as _) }
}
#[doc = "Control clock for the RNG engine."]
#[inline(always)]
pub const fn rng_clk(self) -> crate::common::Reg<regs::RngClk, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x01c4usize) as _) }
}
#[doc = "Writing to this register enables the RNG DMA engine."]
#[inline(always)]
pub const fn rng_dma(self) -> crate::common::Reg<regs::RngDma, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x01c8usize) as _) }
}
#[doc = "This register defines which ring oscillator length configuration should be used when using the RNG DMA engine."]
#[inline(always)]
pub const fn rng_dma_rosc_len(
self,
) -> crate::common::Reg<regs::RngDmaRoscLen, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x01ccusize) as _) }
}
#[doc = "This register defines the start address in TRNG SRAM for the TRNG data to be collected by the RNG DMA engine."]
#[inline(always)]
pub const fn rng_dma_sram_addr(
self,
) -> crate::common::Reg<regs::RngDmaSramAddr, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x01d0usize) as _) }
}
#[doc = "This register defines the number of 192-bits samples that the RNG DMA engine collects per run."]
#[inline(always)]
pub const fn rng_dma_samples_num(
self,
) -> crate::common::Reg<regs::RngDmaSamplesNum, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x01d4usize) as _) }
}
#[doc = "This register defines the maximum number of CPU clock cycles per TRNG collection of 192-bits samples. If the number of cycles for a collection exceeds this threshold the WATCHDOG interrupt is triggered."]
#[inline(always)]
pub const fn rng_watchdog_val(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x01d8usize) as _) }
}
#[doc = "Status register for RNG DMA engine activity."]
#[inline(always)]
pub const fn rng_dma_busy(self) -> crate::common::Reg<regs::RngDmaBusy, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x01dcusize) as _) }
}
}
pub mod regs {
#[doc = "Statistics counter for autocorrelation test activations. Statistics collection is stopped if one of the counters reach its limit of all ones."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct AutocorrStatistic(pub u32);
impl AutocorrStatistic {
#[doc = "Count each time an autocorrelation test starts. Any write to the field resets the counter."]
#[must_use]
#[inline(always)]
pub const fn autocorr_trys(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x3fff;
val as u16
}
#[doc = "Count each time an autocorrelation test starts. Any write to the field resets the counter."]
#[inline(always)]
pub const fn set_autocorr_trys(&mut self, val: u16) {
self.0 = (self.0 & !(0x3fff << 0usize)) | (((val as u32) & 0x3fff) << 0usize);
}
#[doc = "Count each time an autocorrelation test fails. Any write to the field resets the counter."]
#[must_use]
#[inline(always)]
pub const fn autocorr_fails(&self) -> u8 {
let val = (self.0 >> 14usize) & 0xff;
val as u8
}
#[doc = "Count each time an autocorrelation test fails. Any write to the field resets the counter."]
#[inline(always)]
pub const fn set_autocorr_fails(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 14usize)) | (((val as u32) & 0xff) << 14usize);
}
}
impl Default for AutocorrStatistic {
#[inline(always)]
fn default() -> AutocorrStatistic {
AutocorrStatistic(0)
}
}
impl core::fmt::Debug for AutocorrStatistic {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("AutocorrStatistic")
.field("autocorr_trys", &self.autocorr_trys())
.field("autocorr_fails", &self.autocorr_fails())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for AutocorrStatistic {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"AutocorrStatistic {{ autocorr_trys: {=u16:?}, autocorr_fails: {=u8:?} }}",
self.autocorr_trys(),
self.autocorr_fails()
)
}
}
#[doc = "This register controls the ring oscillator circuit used as a noise source."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct NoiseSource(pub u32);
impl NoiseSource {
#[doc = "Enable or disable the noise source."]
#[must_use]
#[inline(always)]
pub const fn enable(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Enable or disable the noise source."]
#[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 NoiseSource {
#[inline(always)]
fn default() -> NoiseSource {
NoiseSource(0)
}
}
impl core::fmt::Debug for NoiseSource {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("NoiseSource")
.field("enable", &self.enable())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for NoiseSource {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "NoiseSource {{ enable: {=bool:?} }}", self.enable())
}
}
#[doc = "Status register for RNG engine activity."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct RngBusy(pub u32);
impl RngBusy {
#[doc = "RNG engine status."]
#[must_use]
#[inline(always)]
pub const fn status(&self) -> super::vals::RngBusyStatus {
let val = (self.0 >> 0usize) & 0x01;
super::vals::RngBusyStatus::from_bits(val as u8)
}
#[doc = "RNG engine status."]
#[inline(always)]
pub const fn set_status(&mut self, val: super::vals::RngBusyStatus) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
#[doc = "TRNG status."]
#[must_use]
#[inline(always)]
pub const fn trng_status(&self) -> super::vals::TrngStatus {
let val = (self.0 >> 1usize) & 0x01;
super::vals::TrngStatus::from_bits(val as u8)
}
#[doc = "TRNG status."]
#[inline(always)]
pub const fn set_trng_status(&mut self, val: super::vals::TrngStatus) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val.to_bits() as u32) & 0x01) << 1usize);
}
}
impl Default for RngBusy {
#[inline(always)]
fn default() -> RngBusy {
RngBusy(0)
}
}
impl core::fmt::Debug for RngBusy {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("RngBusy")
.field("status", &self.status())
.field("trng_status", &self.trng_status())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for RngBusy {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"RngBusy {{ status: {:?}, trng_status: {:?} }}",
self.status(),
self.trng_status()
)
}
}
#[doc = "Control clock for the RNG engine."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct RngClk(pub u32);
impl RngClk {
#[doc = "Enables clock for the RNG engine."]
#[must_use]
#[inline(always)]
pub const fn enable(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Enables clock for the RNG engine."]
#[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 RngClk {
#[inline(always)]
fn default() -> RngClk {
RngClk(0)
}
}
impl core::fmt::Debug for RngClk {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("RngClk")
.field("enable", &self.enable())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for RngClk {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "RngClk {{ enable: {=bool:?} }}", self.enable())
}
}
#[doc = "Writing to this register enables the RNG DMA engine."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct RngDma(pub u32);
impl RngDma {
#[must_use]
#[inline(always)]
pub const fn enable(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[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 RngDma {
#[inline(always)]
fn default() -> RngDma {
RngDma(0)
}
}
impl core::fmt::Debug for RngDma {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("RngDma")
.field("enable", &self.enable())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for RngDma {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "RngDma {{ enable: {=bool:?} }}", self.enable())
}
}
#[doc = "Status register for RNG DMA engine activity."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct RngDmaBusy(pub u32);
impl RngDmaBusy {
#[doc = "RNG DMA engine status."]
#[must_use]
#[inline(always)]
pub const fn status(&self) -> super::vals::RngDmaBusyStatus {
let val = (self.0 >> 0usize) & 0x01;
super::vals::RngDmaBusyStatus::from_bits(val as u8)
}
#[doc = "RNG DMA engine status."]
#[inline(always)]
pub const fn set_status(&mut self, val: super::vals::RngDmaBusyStatus) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
#[doc = "The active ring oscillator length configuration used by the RNG DMA engine."]
#[must_use]
#[inline(always)]
pub const fn rosc_len(&self) -> super::vals::RngDmaBusyRoscLen {
let val = (self.0 >> 1usize) & 0x03;
super::vals::RngDmaBusyRoscLen::from_bits(val as u8)
}
#[doc = "The active ring oscillator length configuration used by the RNG DMA engine."]
#[inline(always)]
pub const fn set_rosc_len(&mut self, val: super::vals::RngDmaBusyRoscLen) {
self.0 = (self.0 & !(0x03 << 1usize)) | (((val.to_bits() as u32) & 0x03) << 1usize);
}
#[doc = "Number of samples already collected using the current ring oscillator configuration."]
#[must_use]
#[inline(always)]
pub const fn num_of_samples(&self) -> u8 {
let val = (self.0 >> 3usize) & 0xff;
val as u8
}
#[doc = "Number of samples already collected using the current ring oscillator configuration."]
#[inline(always)]
pub const fn set_num_of_samples(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 3usize)) | (((val as u32) & 0xff) << 3usize);
}
}
impl Default for RngDmaBusy {
#[inline(always)]
fn default() -> RngDmaBusy {
RngDmaBusy(0)
}
}
impl core::fmt::Debug for RngDmaBusy {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("RngDmaBusy")
.field("status", &self.status())
.field("rosc_len", &self.rosc_len())
.field("num_of_samples", &self.num_of_samples())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for RngDmaBusy {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"RngDmaBusy {{ status: {:?}, rosc_len: {:?}, num_of_samples: {=u8:?} }}",
self.status(),
self.rosc_len(),
self.num_of_samples()
)
}
}
#[doc = "This register defines which ring oscillator length configuration should be used when using the RNG DMA engine."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct RngDmaRoscLen(pub u32);
impl RngDmaRoscLen {
#[doc = "Use shortest ROSC1 ring oscillator configuration."]
#[must_use]
#[inline(always)]
pub const fn rosc1(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Use shortest ROSC1 ring oscillator configuration."]
#[inline(always)]
pub const fn set_rosc1(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Use ROSC2 ring oscillator configuration."]
#[must_use]
#[inline(always)]
pub const fn rosc2(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Use ROSC2 ring oscillator configuration."]
#[inline(always)]
pub const fn set_rosc2(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "Use ROSC3 ring oscillator configuration."]
#[must_use]
#[inline(always)]
pub const fn rosc3(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Use ROSC3 ring oscillator configuration."]
#[inline(always)]
pub const fn set_rosc3(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "Use longest ROSC4 ring oscillator configuration."]
#[must_use]
#[inline(always)]
pub const fn rosc4(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "Use longest ROSC4 ring oscillator configuration."]
#[inline(always)]
pub const fn set_rosc4(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
}
impl Default for RngDmaRoscLen {
#[inline(always)]
fn default() -> RngDmaRoscLen {
RngDmaRoscLen(0)
}
}
impl core::fmt::Debug for RngDmaRoscLen {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("RngDmaRoscLen")
.field("rosc1", &self.rosc1())
.field("rosc2", &self.rosc2())
.field("rosc3", &self.rosc3())
.field("rosc4", &self.rosc4())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for RngDmaRoscLen {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "RngDmaRoscLen {{ rosc1: {=bool:?}, rosc2: {=bool:?}, rosc3: {=bool:?}, rosc4: {=bool:?} }}" , self . rosc1 () , self . rosc2 () , self . rosc3 () , self . rosc4 ())
}
}
#[doc = "This register defines the number of 192-bits samples that the RNG DMA engine collects per run."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct RngDmaSamplesNum(pub u32);
impl RngDmaSamplesNum {
#[doc = "Defines the number of 192-bits samples that the DMA engine collects per run."]
#[must_use]
#[inline(always)]
pub const fn rng_samples_num(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "Defines the number of 192-bits samples that the DMA engine collects per run."]
#[inline(always)]
pub const fn set_rng_samples_num(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
}
impl Default for RngDmaSamplesNum {
#[inline(always)]
fn default() -> RngDmaSamplesNum {
RngDmaSamplesNum(0)
}
}
impl core::fmt::Debug for RngDmaSamplesNum {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("RngDmaSamplesNum")
.field("rng_samples_num", &self.rng_samples_num())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for RngDmaSamplesNum {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"RngDmaSamplesNum {{ rng_samples_num: {=u8:?} }}",
self.rng_samples_num()
)
}
}
#[doc = "This register defines the start address in TRNG SRAM for the TRNG data to be collected by the RNG DMA engine."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct RngDmaSramAddr(pub u32);
impl RngDmaSramAddr {
#[doc = "Start address of the TRNG data in TRNG SRAM."]
#[must_use]
#[inline(always)]
pub const fn rng_sram_dma_addr(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x07ff;
val as u16
}
#[doc = "Start address of the TRNG data in TRNG SRAM."]
#[inline(always)]
pub const fn set_rng_sram_dma_addr(&mut self, val: u16) {
self.0 = (self.0 & !(0x07ff << 0usize)) | (((val as u32) & 0x07ff) << 0usize);
}
}
impl Default for RngDmaSramAddr {
#[inline(always)]
fn default() -> RngDmaSramAddr {
RngDmaSramAddr(0)
}
}
impl core::fmt::Debug for RngDmaSramAddr {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("RngDmaSramAddr")
.field("rng_sram_dma_addr", &self.rng_sram_dma_addr())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for RngDmaSramAddr {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"RngDmaSramAddr {{ rng_sram_dma_addr: {=u16:?} }}",
self.rng_sram_dma_addr()
)
}
}
#[doc = "Hardware configuration of RNG engine. Reset value holds the supported features."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct RngHwFlags(pub u32);
impl RngHwFlags {
#[doc = "Data width supported by the entropy collector."]
#[must_use]
#[inline(always)]
pub const fn ehr_width(&self) -> super::vals::EhrWidth {
let val = (self.0 >> 0usize) & 0x01;
super::vals::EhrWidth::from_bits(val as u8)
}
#[doc = "Data width supported by the entropy collector."]
#[inline(always)]
pub const fn set_ehr_width(&mut self, val: super::vals::EhrWidth) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
#[doc = "If this flag is set, the engine include support for continuous random number generator test."]
#[must_use]
#[inline(always)]
pub const fn crngt_exists(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the engine include support for continuous random number generator test."]
#[inline(always)]
pub const fn set_crngt_exists(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "If this flag is set, the engine include support for autocorrelation test."]
#[must_use]
#[inline(always)]
pub const fn autocorr_exists(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the engine include support for autocorrelation test."]
#[inline(always)]
pub const fn set_autocorr_exists(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "If this flag is set, the engine include support for bypassing TRNG tests."]
#[must_use]
#[inline(always)]
pub const fn bypass_exists(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the engine include support for bypassing TRNG tests."]
#[inline(always)]
pub const fn set_bypass_exists(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
#[doc = "If this flag is set, the engine include a pseudo-random number generator."]
#[must_use]
#[inline(always)]
pub const fn prng_exists(&self) -> bool {
let val = (self.0 >> 4usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the engine include a pseudo-random number generator."]
#[inline(always)]
pub const fn set_prng_exists(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
}
#[doc = "If this flag is set, the engine include support for known answer tests."]
#[must_use]
#[inline(always)]
pub const fn kat_exists(&self) -> bool {
let val = (self.0 >> 5usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the engine include support for known answer tests."]
#[inline(always)]
pub const fn set_kat_exists(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
}
#[doc = "If this flag is set, the engine include support for automatic reseeding."]
#[must_use]
#[inline(always)]
pub const fn reseeding_exists(&self) -> bool {
let val = (self.0 >> 6usize) & 0x01;
val != 0
}
#[doc = "If this flag is set, the engine include support for automatic reseeding."]
#[inline(always)]
pub const fn set_reseeding_exists(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize);
}
#[must_use]
#[inline(always)]
pub const fn rng_use_5_sboxes(&self) -> bool {
let val = (self.0 >> 7usize) & 0x01;
val != 0
}
#[inline(always)]
pub const fn set_rng_use_5_sboxes(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize);
}
}
impl Default for RngHwFlags {
#[inline(always)]
fn default() -> RngHwFlags {
RngHwFlags(0)
}
}
impl core::fmt::Debug for RngHwFlags {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("RngHwFlags")
.field("ehr_width", &self.ehr_width())
.field("crngt_exists", &self.crngt_exists())
.field("autocorr_exists", &self.autocorr_exists())
.field("bypass_exists", &self.bypass_exists())
.field("prng_exists", &self.prng_exists())
.field("kat_exists", &self.kat_exists())
.field("reseeding_exists", &self.reseeding_exists())
.field("rng_use_5_sboxes", &self.rng_use_5_sboxes())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for RngHwFlags {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "RngHwFlags {{ ehr_width: {:?}, crngt_exists: {=bool:?}, autocorr_exists: {=bool:?}, bypass_exists: {=bool:?}, prng_exists: {=bool:?}, kat_exists: {=bool:?}, reseeding_exists: {=bool:?}, rng_use_5_sboxes: {=bool:?} }}" , self . ehr_width () , self . crngt_exists () , self . autocorr_exists () , self . bypass_exists () , self . prng_exists () , self . kat_exists () , self . reseeding_exists () , self . rng_use_5_sboxes ())
}
}
#[doc = "Interrupt clear register. Writing a 1 bit into a field in this register will clear the corresponding bit in RNG_ISR."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct RngIcr(pub u32);
impl RngIcr {
#[doc = "Writing value '1' clears corresponding bit in RNG_ISR."]
#[must_use]
#[inline(always)]
pub const fn ehr_valid_clear(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Writing value '1' clears corresponding bit in RNG_ISR."]
#[inline(always)]
pub const fn set_ehr_valid_clear(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Cannot be cleared by software! Only RNG reset clears this bit."]
#[must_use]
#[inline(always)]
pub const fn autocorr_err_clear(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Cannot be cleared by software! Only RNG reset clears this bit."]
#[inline(always)]
pub const fn set_autocorr_err_clear(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "Writing value '1' clears corresponding bit in RNG_ISR."]
#[must_use]
#[inline(always)]
pub const fn crngt_err_clear(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Writing value '1' clears corresponding bit in RNG_ISR."]
#[inline(always)]
pub const fn set_crngt_err_clear(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "Writing value '1' clears corresponding bit in RNG_ISR."]
#[must_use]
#[inline(always)]
pub const fn vnc_err_clear(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "Writing value '1' clears corresponding bit in RNG_ISR."]
#[inline(always)]
pub const fn set_vnc_err_clear(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
#[doc = "Writing value '1' clears corresponding bit in RNG_ISR."]
#[must_use]
#[inline(always)]
pub const fn watchdog_clear(&self) -> bool {
let val = (self.0 >> 4usize) & 0x01;
val != 0
}
#[doc = "Writing value '1' clears corresponding bit in RNG_ISR."]
#[inline(always)]
pub const fn set_watchdog_clear(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
}
#[doc = "Writing value '1' clears corresponding bit in RNG_ISR."]
#[must_use]
#[inline(always)]
pub const fn dma_done_clear(&self) -> bool {
let val = (self.0 >> 5usize) & 0x01;
val != 0
}
#[doc = "Writing value '1' clears corresponding bit in RNG_ISR."]
#[inline(always)]
pub const fn set_dma_done_clear(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
}
}
impl Default for RngIcr {
#[inline(always)]
fn default() -> RngIcr {
RngIcr(0)
}
}
impl core::fmt::Debug for RngIcr {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("RngIcr")
.field("ehr_valid_clear", &self.ehr_valid_clear())
.field("autocorr_err_clear", &self.autocorr_err_clear())
.field("crngt_err_clear", &self.crngt_err_clear())
.field("vnc_err_clear", &self.vnc_err_clear())
.field("watchdog_clear", &self.watchdog_clear())
.field("dma_done_clear", &self.dma_done_clear())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for RngIcr {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "RngIcr {{ ehr_valid_clear: {=bool:?}, autocorr_err_clear: {=bool:?}, crngt_err_clear: {=bool:?}, vnc_err_clear: {=bool:?}, watchdog_clear: {=bool:?}, dma_done_clear: {=bool:?} }}" , self . ehr_valid_clear () , self . autocorr_err_clear () , self . crngt_err_clear () , self . vnc_err_clear () , self . watchdog_clear () , self . dma_done_clear ())
}
}
#[doc = "Interrupt mask register. Each bit of this register holds the mask of a single interrupt source."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct RngImr(pub u32);
impl RngImr {
#[doc = "See RNG_ISR for explanation on this interrupt."]
#[must_use]
#[inline(always)]
pub const fn ehr_valid_mask(&self) -> super::vals::EhrValidMask {
let val = (self.0 >> 0usize) & 0x01;
super::vals::EhrValidMask::from_bits(val as u8)
}
#[doc = "See RNG_ISR for explanation on this interrupt."]
#[inline(always)]
pub const fn set_ehr_valid_mask(&mut self, val: super::vals::EhrValidMask) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
#[doc = "See RNG_ISR for explanation on this interrupt."]
#[must_use]
#[inline(always)]
pub const fn autocorr_err_mask(&self) -> super::vals::AutocorrErrMask {
let val = (self.0 >> 1usize) & 0x01;
super::vals::AutocorrErrMask::from_bits(val as u8)
}
#[doc = "See RNG_ISR for explanation on this interrupt."]
#[inline(always)]
pub const fn set_autocorr_err_mask(&mut self, val: super::vals::AutocorrErrMask) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val.to_bits() as u32) & 0x01) << 1usize);
}
#[doc = "See RNG_ISR for explanation on this interrupt."]
#[must_use]
#[inline(always)]
pub const fn crngt_err_mask(&self) -> super::vals::CrngtErrMask {
let val = (self.0 >> 2usize) & 0x01;
super::vals::CrngtErrMask::from_bits(val as u8)
}
#[doc = "See RNG_ISR for explanation on this interrupt."]
#[inline(always)]
pub const fn set_crngt_err_mask(&mut self, val: super::vals::CrngtErrMask) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val.to_bits() as u32) & 0x01) << 2usize);
}
#[doc = "See RNG_ISR for explanation on this interrupt."]
#[must_use]
#[inline(always)]
pub const fn vnc_err_mask(&self) -> super::vals::VncErrMask {
let val = (self.0 >> 3usize) & 0x01;
super::vals::VncErrMask::from_bits(val as u8)
}
#[doc = "See RNG_ISR for explanation on this interrupt."]
#[inline(always)]
pub const fn set_vnc_err_mask(&mut self, val: super::vals::VncErrMask) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val.to_bits() as u32) & 0x01) << 3usize);
}
#[doc = "See RNG_ISR for explanation on this interrupt."]
#[must_use]
#[inline(always)]
pub const fn watchdog_mask(&self) -> super::vals::WatchdogMask {
let val = (self.0 >> 4usize) & 0x01;
super::vals::WatchdogMask::from_bits(val as u8)
}
#[doc = "See RNG_ISR for explanation on this interrupt."]
#[inline(always)]
pub const fn set_watchdog_mask(&mut self, val: super::vals::WatchdogMask) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val.to_bits() as u32) & 0x01) << 4usize);
}
#[doc = "See RNG_ISR for explanation on this interrupt."]
#[must_use]
#[inline(always)]
pub const fn dma_done_mask(&self) -> super::vals::DmaDoneMask {
let val = (self.0 >> 5usize) & 0x01;
super::vals::DmaDoneMask::from_bits(val as u8)
}
#[doc = "See RNG_ISR for explanation on this interrupt."]
#[inline(always)]
pub const fn set_dma_done_mask(&mut self, val: super::vals::DmaDoneMask) {
self.0 = (self.0 & !(0x01 << 5usize)) | (((val.to_bits() as u32) & 0x01) << 5usize);
}
}
impl Default for RngImr {
#[inline(always)]
fn default() -> RngImr {
RngImr(0)
}
}
impl core::fmt::Debug for RngImr {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("RngImr")
.field("ehr_valid_mask", &self.ehr_valid_mask())
.field("autocorr_err_mask", &self.autocorr_err_mask())
.field("crngt_err_mask", &self.crngt_err_mask())
.field("vnc_err_mask", &self.vnc_err_mask())
.field("watchdog_mask", &self.watchdog_mask())
.field("dma_done_mask", &self.dma_done_mask())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for RngImr {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "RngImr {{ ehr_valid_mask: {:?}, autocorr_err_mask: {:?}, crngt_err_mask: {:?}, vnc_err_mask: {:?}, watchdog_mask: {:?}, dma_done_mask: {:?} }}" , self . ehr_valid_mask () , self . autocorr_err_mask () , self . crngt_err_mask () , self . vnc_err_mask () , self . watchdog_mask () , self . dma_done_mask ())
}
}
#[doc = "Interrupt status register. Each bit of this register holds the interrupt status of a single interrupt source. If corresponding RNG_IMR bit is unmasked, an interrupt is generated."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct RngIsr(pub u32);
impl RngIsr {
#[doc = "192-bits have been collected and are ready to be read."]
#[must_use]
#[inline(always)]
pub const fn ehr_valid_int(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "192-bits have been collected and are ready to be read."]
#[inline(always)]
pub const fn set_ehr_valid_int(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Autocorrelation error. Failure occurs when autocorrelation test has failed four times in a row. Once set, the TRNG ceases to function until next reset."]
#[must_use]
#[inline(always)]
pub const fn autocorr_err_int(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Autocorrelation error. Failure occurs when autocorrelation test has failed four times in a row. Once set, the TRNG ceases to function until next reset."]
#[inline(always)]
pub const fn set_autocorr_err_int(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "Continuous random number generator test error. Failure occurs when two consecutive blocks of 16 collected bits are equal."]
#[must_use]
#[inline(always)]
pub const fn crngt_err_int(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Continuous random number generator test error. Failure occurs when two consecutive blocks of 16 collected bits are equal."]
#[inline(always)]
pub const fn set_crngt_err_int(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "von Neumann corrector error. Failure occurs if 32 consecutive collected bits are identical, ZERO, or ONE."]
#[must_use]
#[inline(always)]
pub const fn vnc_err_int(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "von Neumann corrector error. Failure occurs if 32 consecutive collected bits are identical, ZERO, or ONE."]
#[inline(always)]
pub const fn set_vnc_err_int(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
#[doc = "Maximum number of CPU clock cycles per sample have been exceeded. See RNG_WATCHDOG_VAL for more information."]
#[must_use]
#[inline(always)]
pub const fn watchdog_int(&self) -> bool {
let val = (self.0 >> 4usize) & 0x01;
val != 0
}
#[doc = "Maximum number of CPU clock cycles per sample have been exceeded. See RNG_WATCHDOG_VAL for more information."]
#[inline(always)]
pub const fn set_watchdog_int(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
}
#[doc = "RNG DMA to SRAM is completed."]
#[must_use]
#[inline(always)]
pub const fn dma_done_int(&self) -> bool {
let val = (self.0 >> 5usize) & 0x01;
val != 0
}
#[doc = "RNG DMA to SRAM is completed."]
#[inline(always)]
pub const fn set_dma_done_int(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
}
}
impl Default for RngIsr {
#[inline(always)]
fn default() -> RngIsr {
RngIsr(0)
}
}
impl core::fmt::Debug for RngIsr {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("RngIsr")
.field("ehr_valid_int", &self.ehr_valid_int())
.field("autocorr_err_int", &self.autocorr_err_int())
.field("crngt_err_int", &self.crngt_err_int())
.field("vnc_err_int", &self.vnc_err_int())
.field("watchdog_int", &self.watchdog_int())
.field("dma_done_int", &self.dma_done_int())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for RngIsr {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "RngIsr {{ ehr_valid_int: {=bool:?}, autocorr_err_int: {=bool:?}, crngt_err_int: {=bool:?}, vnc_err_int: {=bool:?}, watchdog_int: {=bool:?}, dma_done_int: {=bool:?} }}" , self . ehr_valid_int () , self . autocorr_err_int () , self . crngt_err_int () , self . vnc_err_int () , self . watchdog_int () , self . dma_done_int ())
}
}
#[doc = "Reset the RNG engine."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct RngSwReset(pub u32);
impl RngSwReset {
#[doc = "Writing any value to this address resets the RNG engine. The reset takes 4 CPU clock cycles to complete."]
#[must_use]
#[inline(always)]
pub const fn reset(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Writing any value to this address resets the RNG engine. The reset takes 4 CPU clock cycles to complete."]
#[inline(always)]
pub const fn set_reset(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for RngSwReset {
#[inline(always)]
fn default() -> RngSwReset {
RngSwReset(0)
}
}
impl core::fmt::Debug for RngSwReset {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("RngSwReset")
.field("reset", &self.reset())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for RngSwReset {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "RngSwReset {{ reset: {=bool:?} }}", self.reset())
}
}
#[doc = "TRNG ring oscillator length configuration."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct TrngConfig(pub u32);
impl TrngConfig {
#[doc = "Set the length of the oscillator ring (= the number of inverters) out of four possible configurations."]
#[must_use]
#[inline(always)]
pub const fn rosc_len(&self) -> super::vals::TrngConfigRoscLen {
let val = (self.0 >> 0usize) & 0x03;
super::vals::TrngConfigRoscLen::from_bits(val as u8)
}
#[doc = "Set the length of the oscillator ring (= the number of inverters) out of four possible configurations."]
#[inline(always)]
pub const fn set_rosc_len(&mut self, val: super::vals::TrngConfigRoscLen) {
self.0 = (self.0 & !(0x03 << 0usize)) | (((val.to_bits() as u32) & 0x03) << 0usize);
}
}
impl Default for TrngConfig {
#[inline(always)]
fn default() -> TrngConfig {
TrngConfig(0)
}
}
impl core::fmt::Debug for TrngConfig {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("TrngConfig")
.field("rosc_len", &self.rosc_len())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for TrngConfig {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "TrngConfig {{ rosc_len: {:?} }}", self.rosc_len())
}
}
#[doc = "Debug register for the TRNG. This register is used to bypass TRNG tests in hardware."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct TrngDebug(pub u32);
impl TrngDebug {
#[doc = "Bypass the von Neumann corrector post-processing test, including the 32 consecutive bits test."]
#[must_use]
#[inline(always)]
pub const fn vnc_bypass(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Bypass the von Neumann corrector post-processing test, including the 32 consecutive bits test."]
#[inline(always)]
pub const fn set_vnc_bypass(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "Bypass the Continuous Random Number Generator Test (CRNGT)."]
#[must_use]
#[inline(always)]
pub const fn crngt_bypass(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Bypass the Continuous Random Number Generator Test (CRNGT)."]
#[inline(always)]
pub const fn set_crngt_bypass(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "Bypass the autocorrelation test."]
#[must_use]
#[inline(always)]
pub const fn autocorr_bypass(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "Bypass the autocorrelation test."]
#[inline(always)]
pub const fn set_autocorr_bypass(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
}
impl Default for TrngDebug {
#[inline(always)]
fn default() -> TrngDebug {
TrngDebug(0)
}
}
impl core::fmt::Debug for TrngDebug {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("TrngDebug")
.field("vnc_bypass", &self.vnc_bypass())
.field("crngt_bypass", &self.crngt_bypass())
.field("autocorr_bypass", &self.autocorr_bypass())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for TrngDebug {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "TrngDebug {{ vnc_bypass: {=bool:?}, crngt_bypass: {=bool:?}, autocorr_bypass: {=bool:?} }}" , self . vnc_bypass () , self . crngt_bypass () , self . autocorr_bypass ())
}
}
#[doc = "Reset the TRNG, including internal counter of collected bits and registers EHR_DATA and TRNG_VALID."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct TrngReset(pub u32);
impl TrngReset {
#[doc = "Writing any value to this address resets the internal bits counter and registers EHR_DATA and TRNG_VALID. Register NOISE_SOURCE must be disabled in order for the reset to take place."]
#[must_use]
#[inline(always)]
pub const fn reset(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Writing any value to this address resets the internal bits counter and registers EHR_DATA and TRNG_VALID. Register NOISE_SOURCE must be disabled in order for the reset to take place."]
#[inline(always)]
pub const fn set_reset(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for TrngReset {
#[inline(always)]
fn default() -> TrngReset {
TrngReset(0)
}
}
impl core::fmt::Debug for TrngReset {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("TrngReset")
.field("reset", &self.reset())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for TrngReset {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "TrngReset {{ reset: {=bool:?} }}", self.reset())
}
}
#[doc = "This register indicates if TRNG entropy collection is valid."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct TrngValid(pub u32);
impl TrngValid {
#[doc = "A value of 1 indicates that collection of bits in the TRNG is completed, and data can be read from EHR_DATA registers."]
#[must_use]
#[inline(always)]
pub const fn ehr_data(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "A value of 1 indicates that collection of bits in the TRNG is completed, and data can be read from EHR_DATA registers."]
#[inline(always)]
pub const fn set_ehr_data(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for TrngValid {
#[inline(always)]
fn default() -> TrngValid {
TrngValid(0)
}
}
impl core::fmt::Debug for TrngValid {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("TrngValid")
.field("ehr_data", &self.ehr_data())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for TrngValid {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "TrngValid {{ ehr_data: {=bool:?} }}", self.ehr_data())
}
}
}
pub mod vals {
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum AutocorrErrMask {
#[doc = "Do not mask autocorrelation interrupt i.e. interrupt is generated."]
IrqEnable = 0x0,
#[doc = "Mask autocorrelation interrupt i.e. no interrupt is generated."]
IrqDisable = 0x01,
}
impl AutocorrErrMask {
#[inline(always)]
pub const fn from_bits(val: u8) -> AutocorrErrMask {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for AutocorrErrMask {
#[inline(always)]
fn from(val: u8) -> AutocorrErrMask {
AutocorrErrMask::from_bits(val)
}
}
impl From<AutocorrErrMask> for u8 {
#[inline(always)]
fn from(val: AutocorrErrMask) -> u8 {
AutocorrErrMask::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum CrngtErrMask {
#[doc = "Do not mask the CRNGT error interrupt i.e. interrupt is generated."]
IrqEnable = 0x0,
#[doc = "Mask the CRNGT error interrupt i.e. no interrupt is generated."]
IrqDisable = 0x01,
}
impl CrngtErrMask {
#[inline(always)]
pub const fn from_bits(val: u8) -> CrngtErrMask {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for CrngtErrMask {
#[inline(always)]
fn from(val: u8) -> CrngtErrMask {
CrngtErrMask::from_bits(val)
}
}
impl From<CrngtErrMask> for u8 {
#[inline(always)]
fn from(val: CrngtErrMask) -> u8 {
CrngtErrMask::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum DmaDoneMask {
#[doc = "Do not mask the RNG DMA completion interrupt i.e. interrupt is generated."]
IrqEnable = 0x0,
#[doc = "Mask the RNG DMA completion interrupt i.e. no interrupt is generated."]
IrqDisable = 0x01,
}
impl DmaDoneMask {
#[inline(always)]
pub const fn from_bits(val: u8) -> DmaDoneMask {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for DmaDoneMask {
#[inline(always)]
fn from(val: u8) -> DmaDoneMask {
DmaDoneMask::from_bits(val)
}
}
impl From<DmaDoneMask> for u8 {
#[inline(always)]
fn from(val: DmaDoneMask) -> u8 {
DmaDoneMask::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum EhrValidMask {
#[doc = "Do not mask EHR interrupt i.e. interrupt is generated."]
IrqEnable = 0x0,
#[doc = "Mask EHR interrupt i.e. no interrupt is generated."]
IrqDisable = 0x01,
}
impl EhrValidMask {
#[inline(always)]
pub const fn from_bits(val: u8) -> EhrValidMask {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for EhrValidMask {
#[inline(always)]
fn from(val: u8) -> EhrValidMask {
EhrValidMask::from_bits(val)
}
}
impl From<EhrValidMask> for u8 {
#[inline(always)]
fn from(val: EhrValidMask) -> u8 {
EhrValidMask::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum EhrWidth {
#[doc = "128 bits EHR width."]
_128bits = 0x0,
#[doc = "192 bits EHR width."]
_192bits = 0x01,
}
impl EhrWidth {
#[inline(always)]
pub const fn from_bits(val: u8) -> EhrWidth {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for EhrWidth {
#[inline(always)]
fn from(val: u8) -> EhrWidth {
EhrWidth::from_bits(val)
}
}
impl From<EhrWidth> for u8 {
#[inline(always)]
fn from(val: EhrWidth) -> u8 {
EhrWidth::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum RngBusyStatus {
#[doc = "RNG engine is idle."]
Idle = 0x0,
#[doc = "RNG engine is busy."]
Busy = 0x01,
}
impl RngBusyStatus {
#[inline(always)]
pub const fn from_bits(val: u8) -> RngBusyStatus {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for RngBusyStatus {
#[inline(always)]
fn from(val: u8) -> RngBusyStatus {
RngBusyStatus::from_bits(val)
}
}
impl From<RngBusyStatus> for u8 {
#[inline(always)]
fn from(val: RngBusyStatus) -> u8 {
RngBusyStatus::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum RngDmaBusyRoscLen {
#[doc = "Shortest ROSC1 ring oscillator configuration used."]
Rosc1 = 0x0,
#[doc = "ROSC2 ring oscillator configuration used."]
Rosc2 = 0x01,
#[doc = "ROSC3 ring oscillator configuration used."]
Rosc3 = 0x02,
#[doc = "Longest ROSC4 ring oscillator configuration used."]
Rosc4 = 0x03,
}
impl RngDmaBusyRoscLen {
#[inline(always)]
pub const fn from_bits(val: u8) -> RngDmaBusyRoscLen {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for RngDmaBusyRoscLen {
#[inline(always)]
fn from(val: u8) -> RngDmaBusyRoscLen {
RngDmaBusyRoscLen::from_bits(val)
}
}
impl From<RngDmaBusyRoscLen> for u8 {
#[inline(always)]
fn from(val: RngDmaBusyRoscLen) -> u8 {
RngDmaBusyRoscLen::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum RngDmaBusyStatus {
#[doc = "RNG DMA engine is idle."]
Idle = 0x0,
#[doc = "RNG DMA engine is busy."]
Busy = 0x01,
}
impl RngDmaBusyStatus {
#[inline(always)]
pub const fn from_bits(val: u8) -> RngDmaBusyStatus {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for RngDmaBusyStatus {
#[inline(always)]
fn from(val: u8) -> RngDmaBusyStatus {
RngDmaBusyStatus::from_bits(val)
}
}
impl From<RngDmaBusyStatus> for u8 {
#[inline(always)]
fn from(val: RngDmaBusyStatus) -> u8 {
RngDmaBusyStatus::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum TrngConfigRoscLen {
#[doc = "Use shortest ROSC1 ring oscillator configuration."]
Rosc1 = 0x0,
#[doc = "Use ROSC2 ring oscillator configuration."]
Rosc2 = 0x01,
#[doc = "Use ROSC3 ring oscillator configuration."]
Rosc3 = 0x02,
#[doc = "Use longest ROSC4 ring oscillator configuration."]
Rosc4 = 0x03,
}
impl TrngConfigRoscLen {
#[inline(always)]
pub const fn from_bits(val: u8) -> TrngConfigRoscLen {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for TrngConfigRoscLen {
#[inline(always)]
fn from(val: u8) -> TrngConfigRoscLen {
TrngConfigRoscLen::from_bits(val)
}
}
impl From<TrngConfigRoscLen> for u8 {
#[inline(always)]
fn from(val: TrngConfigRoscLen) -> u8 {
TrngConfigRoscLen::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum TrngStatus {
#[doc = "TRNG is idle."]
Idle = 0x0,
#[doc = "TRNG is busy."]
Busy = 0x01,
}
impl TrngStatus {
#[inline(always)]
pub const fn from_bits(val: u8) -> TrngStatus {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for TrngStatus {
#[inline(always)]
fn from(val: u8) -> TrngStatus {
TrngStatus::from_bits(val)
}
}
impl From<TrngStatus> for u8 {
#[inline(always)]
fn from(val: TrngStatus) -> u8 {
TrngStatus::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum VncErrMask {
#[doc = "Do not mask the von Neumann corrector error interrupt i.e. interrupt is generated."]
IrqEnable = 0x0,
#[doc = "Mask the von Neumann corrector error interrupt i.e. no interrupt is generated."]
IrqDisable = 0x01,
}
impl VncErrMask {
#[inline(always)]
pub const fn from_bits(val: u8) -> VncErrMask {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for VncErrMask {
#[inline(always)]
fn from(val: u8) -> VncErrMask {
VncErrMask::from_bits(val)
}
}
impl From<VncErrMask> for u8 {
#[inline(always)]
fn from(val: VncErrMask) -> u8 {
VncErrMask::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum WatchdogMask {
#[doc = "Do not mask the watchdog interrupt i.e. interrupt is generated."]
IrqEnable = 0x0,
#[doc = "Mask the watchdog interrupt i.e. no interrupt is generated."]
IrqDisable = 0x01,
}
impl WatchdogMask {
#[inline(always)]
pub const fn from_bits(val: u8) -> WatchdogMask {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for WatchdogMask {
#[inline(always)]
fn from(val: u8) -> WatchdogMask {
WatchdogMask::from_bits(val)
}
}
impl From<WatchdogMask> for u8 {
#[inline(always)]
fn from(val: WatchdogMask) -> u8 {
WatchdogMask::to_bits(val)
}
}
}
}
pub mod cc_rng_sram {
#[doc = "CRYPTOCELL RNG SRAM interface."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct CcRngSram {
ptr: *mut u8,
}
unsafe impl Send for CcRngSram {}
unsafe impl Sync for CcRngSram {}
impl CcRngSram {
#[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 = "Read/Write data from RNG SRAM."]
#[inline(always)]
pub const fn sram_data(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0f00usize) as _) }
}
#[doc = "First address given to RNG SRAM DMA for read/write transactions from/to RNG SRAM."]
#[inline(always)]
pub const fn sram_addr(self) -> crate::common::Reg<regs::SramAddr, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0f04usize) as _) }
}
#[doc = "RNG SRAM DMA engine is ready to read/write from/to RNG SRAM."]
#[inline(always)]
pub const fn sram_data_ready(
self,
) -> crate::common::Reg<regs::SramDataReady, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0f08usize) as _) }
}
}
pub mod regs {
#[doc = "First address given to RNG SRAM DMA for read/write transactions from/to RNG SRAM."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct SramAddr(pub u32);
impl SramAddr {
#[doc = "RNG SRAM starting address."]
#[must_use]
#[inline(always)]
pub const fn sram_addr(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x7fff;
val as u16
}
#[doc = "RNG SRAM starting address."]
#[inline(always)]
pub const fn set_sram_addr(&mut self, val: u16) {
self.0 = (self.0 & !(0x7fff << 0usize)) | (((val as u32) & 0x7fff) << 0usize);
}
}
impl Default for SramAddr {
#[inline(always)]
fn default() -> SramAddr {
SramAddr(0)
}
}
impl core::fmt::Debug for SramAddr {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("SramAddr")
.field("sram_addr", &self.sram_addr())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for SramAddr {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "SramAddr {{ sram_addr: {=u16:?} }}", self.sram_addr())
}
}
#[doc = "RNG SRAM DMA engine is ready to read/write from/to RNG SRAM."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct SramDataReady(pub u32);
impl SramDataReady {
#[doc = "RNG SRAM DMA status."]
#[must_use]
#[inline(always)]
pub const fn sram_ready(&self) -> super::vals::SramReady {
let val = (self.0 >> 0usize) & 0x01;
super::vals::SramReady::from_bits(val as u8)
}
#[doc = "RNG SRAM DMA status."]
#[inline(always)]
pub const fn set_sram_ready(&mut self, val: super::vals::SramReady) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
}
impl Default for SramDataReady {
#[inline(always)]
fn default() -> SramDataReady {
SramDataReady(0)
}
}
impl core::fmt::Debug for SramDataReady {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("SramDataReady")
.field("sram_ready", &self.sram_ready())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for SramDataReady {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "SramDataReady {{ sram_ready: {:?} }}", self.sram_ready())
}
}
}
pub mod vals {
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum SramReady {
#[doc = "DMA is busy."]
Busy = 0x0,
#[doc = "DMA is idle."]
Idle = 0x01,
}
impl SramReady {
#[inline(always)]
pub const fn from_bits(val: u8) -> SramReady {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for SramReady {
#[inline(always)]
fn from(val: u8) -> SramReady {
SramReady::from_bits(val)
}
}
impl From<SramReady> for u8 {
#[inline(always)]
fn from(val: SramReady) -> u8 {
SramReady::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 _) }
}
}
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 = "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 = "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 _) }
}
#[doc = "Clocking options for the trace port debug interface."]
#[inline(always)]
pub const fn traceconfig(self) -> crate::common::Reg<regs::Traceconfig, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x055cusize) as _) }
}
#[doc = "LFRC mode configuration."]
#[inline(always)]
pub const fn lfrcmode(self) -> crate::common::Reg<regs::Lfrcmode, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x05b4usize) 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 = "LFRC mode configuration."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Lfrcmode(pub u32);
impl Lfrcmode {
#[doc = "Set LFRC mode."]
#[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 = "Set LFRC mode."]
#[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 = "Active LFRC mode. This field is read only."]
#[must_use]
#[inline(always)]
pub const fn status(&self) -> super::vals::LfrcmodeStatus {
let val = (self.0 >> 16usize) & 0x01;
super::vals::LfrcmodeStatus::from_bits(val as u8)
}
#[doc = "Active LFRC mode. This field is read only."]
#[inline(always)]
pub const fn set_status(&mut self, val: super::vals::LfrcmodeStatus) {
self.0 =
(self.0 & !(0x01 << 16usize)) | (((val.to_bits() as u32) & 0x01) << 16usize);
}
}
impl Default for Lfrcmode {
#[inline(always)]
fn default() -> Lfrcmode {
Lfrcmode(0)
}
}
impl core::fmt::Debug for Lfrcmode {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Lfrcmode")
.field("mode", &self.mode())
.field("status", &self.status())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Lfrcmode {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Lfrcmode {{ mode: {:?}, status: {:?} }}",
self.mode(),
self.status()
)
}
}
#[doc = "Clocking options for the trace port debug interface."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Traceconfig(pub u32);
impl Traceconfig {
#[doc = "Speed of trace port clock. Note that the TRACECLK pin will output this clock divided by two."]
#[must_use]
#[inline(always)]
pub const fn traceportspeed(&self) -> super::vals::Traceportspeed {
let val = (self.0 >> 0usize) & 0x03;
super::vals::Traceportspeed::from_bits(val as u8)
}
#[doc = "Speed of trace port clock. Note that the TRACECLK pin will output this clock divided by two."]
#[inline(always)]
pub const fn set_traceportspeed(&mut self, val: super::vals::Traceportspeed) {
self.0 = (self.0 & !(0x03 << 0usize)) | (((val.to_bits() as u32) & 0x03) << 0usize);
}
#[doc = "Pin multiplexing of trace signals. See pin assignment chapter for more details."]
#[must_use]
#[inline(always)]
pub const fn tracemux(&self) -> super::vals::Tracemux {
let val = (self.0 >> 16usize) & 0x03;
super::vals::Tracemux::from_bits(val as u8)
}
#[doc = "Pin multiplexing of trace signals. See pin assignment chapter for more details."]
#[inline(always)]
pub const fn set_tracemux(&mut self, val: super::vals::Tracemux) {
self.0 =
(self.0 & !(0x03 << 16usize)) | (((val.to_bits() as u32) & 0x03) << 16usize);
}
}
impl Default for Traceconfig {
#[inline(always)]
fn default() -> Traceconfig {
Traceconfig(0)
}
}
impl core::fmt::Debug for Traceconfig {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Traceconfig")
.field("traceportspeed", &self.traceportspeed())
.field("tracemux", &self.tracemux())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Traceconfig {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Traceconfig {{ traceportspeed: {:?}, tracemux: {:?} }}",
self.traceportspeed(),
self.tracemux()
)
}
}
}
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 TSX-3225, FA-20H and FA-128 crystals."]
pub const Db256us: Self = Self(0x10);
#[doc = "1024 us debounce time. Recommended for NX1612AA and NX1210AB crystals."]
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 LfrcmodeStatus {
#[doc = "Normal mode."]
Normal = 0x0,
#[doc = "Ultra-low power mode (ULP)."]
Ulp = 0x01,
}
impl LfrcmodeStatus {
#[inline(always)]
pub const fn from_bits(val: u8) -> LfrcmodeStatus {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for LfrcmodeStatus {
#[inline(always)]
fn from(val: u8) -> LfrcmodeStatus {
LfrcmodeStatus::from_bits(val)
}
}
impl From<LfrcmodeStatus> for u8 {
#[inline(always)]
fn from(val: LfrcmodeStatus) -> u8 {
LfrcmodeStatus::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Mode {
#[doc = "Normal mode."]
Normal = 0x0,
#[doc = "Ultra-low power mode (ULP)."]
Ulp = 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 Tracemux {
#[doc = "No trace signals routed to pins. All pins can be used as regular GPIOs."]
Gpio = 0x0,
#[doc = "SWO trace signal routed to pin. Remaining pins can be used as regular GPIOs."]
Serial = 0x01,
#[doc = "All trace signals (TRACECLK and TRACEDATA\\[n\\]) routed to pins."]
Parallel = 0x02,
_RESERVED_3 = 0x03,
}
impl Tracemux {
#[inline(always)]
pub const fn from_bits(val: u8) -> Tracemux {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Tracemux {
#[inline(always)]
fn from(val: u8) -> Tracemux {
Tracemux::from_bits(val)
}
}
impl From<Tracemux> for u8 {
#[inline(always)]
fn from(val: Tracemux) -> u8 {
Tracemux::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Traceportspeed {
#[doc = "32 MHz trace port clock (TRACECLK = 16 MHz)."]
_32mHz = 0x0,
#[doc = "16 MHz trace port clock (TRACECLK = 8 MHz)."]
_16mHz = 0x01,
#[doc = "8 MHz trace port clock (TRACECLK = 4 MHz)."]
_8mHz = 0x02,
#[doc = "4 MHz trace port clock (TRACECLK = 2 MHz)."]
_4mHz = 0x03,
}
impl Traceportspeed {
#[inline(always)]
pub const fn from_bits(val: u8) -> Traceportspeed {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Traceportspeed {
#[inline(always)]
fn from(val: u8) -> Traceportspeed {
Traceportspeed::from_bits(val)
}
}
impl From<Traceportspeed> for u8 {
#[inline(always)]
fn from(val: Traceportspeed) -> u8 {
Traceportspeed::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,
#[doc = "Use AIN4 as external analog reference."]
AnalogReference4 = 0x04,
#[doc = "Use AIN5 as external analog reference."]
AnalogReference5 = 0x05,
#[doc = "Use AIN6 as external analog reference."]
AnalogReference6 = 0x06,
#[doc = "Use AIN7 as external analog reference."]
AnalogReference7 = 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,
#[doc = "AIN4 selected as analog input."]
AnalogInput4 = 0x04,
#[doc = "AIN5 selected as analog input."]
AnalogInput5 = 0x05,
#[doc = "AIN6 selected as analog input."]
AnalogInput6 = 0x06,
#[doc = "AIN7 selected as analog input."]
AnalogInput7 = 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 cryptocell {
#[doc = "CRYPTOCELL register interface."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Cryptocell {
ptr: *mut u8,
}
unsafe impl Send for Cryptocell {}
unsafe impl Sync for Cryptocell {}
impl Cryptocell {
#[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 CRYPTOCELL subsystem."]
#[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 _) }
}
}
pub mod regs {
#[doc = "Enable CRYPTOCELL subsystem."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Enable(pub u32);
impl Enable {
#[doc = "Enable or disable the CRYPTOCELL subsystem."]
#[must_use]
#[inline(always)]
pub const fn enable(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Enable or disable the CRYPTOCELL subsystem."]
#[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())
}
}
}
}
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 = "Unspecified."]
#[inline(always)]
pub const fn nfc(self) -> Nfc {
unsafe { Nfc::from_ptr(self.ptr.wrapping_add(0x0450usize) as _) }
}
#[doc = "NIST800-90B RNG calibration data."]
#[inline(always)]
pub const fn trng90b(self) -> Trng90b {
unsafe { Trng90b::from_ptr(self.ptr.wrapping_add(0x0c00usize) 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, last two letters of Package Variant and first two characters of Build Code, encoded in ASCII."]
#[inline(always)]
pub const fn variant(self) -> crate::common::Reg<u32, 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 = "Unspecified."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Nfc {
ptr: *mut u8,
}
unsafe impl Send for Nfc {}
unsafe impl Sync for Nfc {}
impl Nfc {
#[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 = "Default header for NFC tag. Software can read these values to populate NFCID1_3RD_LAST, NFCID1_2ND_LAST, and NFCID1_LAST."]
#[inline(always)]
pub const fn tagheader0(self) -> crate::common::Reg<regs::Tagheader0, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Default header for NFC tag. Software can read these values to populate NFCID1_3RD_LAST, NFCID1_2ND_LAST, and NFCID1_LAST."]
#[inline(always)]
pub const fn tagheader1(self) -> crate::common::Reg<regs::Tagheader1, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Default header for NFC tag. Software can read these values to populate NFCID1_3RD_LAST, NFCID1_2ND_LAST, and NFCID1_LAST."]
#[inline(always)]
pub const fn tagheader2(self) -> crate::common::Reg<regs::Tagheader2, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
#[doc = "Default header for NFC tag. Software can read these values to populate NFCID1_3RD_LAST, NFCID1_2ND_LAST, and NFCID1_LAST."]
#[inline(always)]
pub const fn tagheader3(self) -> crate::common::Reg<regs::Tagheader3, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0cusize) 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 _) }
}
}
#[doc = "NIST800-90B RNG calibration data."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Trng90b {
ptr: *mut u8,
}
unsafe impl Send for Trng90b {}
unsafe impl Sync for Trng90b {}
impl Trng90b {
#[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 = "Amount of bytes for the required entropy bits."]
#[inline(always)]
pub const fn bytes(self) -> crate::common::Reg<u32, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Repetition counter cutoff."]
#[inline(always)]
pub const fn rccutoff(self) -> crate::common::Reg<u32, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Adaptive proportion cutoff."]
#[inline(always)]
pub const fn apcutoff(self) -> crate::common::Reg<u32, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
#[doc = "Amount of bytes for the startup tests."]
#[inline(always)]
pub const fn startup(self) -> crate::common::Reg<u32, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0cusize) as _) }
}
#[doc = "Sample count for ring oscillator 1."]
#[inline(always)]
pub const fn rosc1(self) -> crate::common::Reg<u32, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x10usize) as _) }
}
#[doc = "Sample count for ring oscillator 2."]
#[inline(always)]
pub const fn rosc2(self) -> crate::common::Reg<u32, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x14usize) as _) }
}
#[doc = "Sample count for ring oscillator 3."]
#[inline(always)]
pub const fn rosc3(self) -> crate::common::Reg<u32, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x18usize) as _) }
}
#[doc = "Sample count for ring oscillator 4."]
#[inline(always)]
pub const fn rosc4(self) -> crate::common::Reg<u32, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x1cusize) 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 = "Default header for NFC tag. Software can read these values to populate NFCID1_3RD_LAST, NFCID1_2ND_LAST, and NFCID1_LAST."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Tagheader0(pub u32);
impl Tagheader0 {
#[doc = "Default Manufacturer ID: Nordic Semiconductor ASA has ICM 0x5F."]
#[must_use]
#[inline(always)]
pub const fn mfgid(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "Default Manufacturer ID: Nordic Semiconductor ASA has ICM 0x5F."]
#[inline(always)]
pub const fn set_mfgid(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
#[doc = "Unique identifier byte 1."]
#[must_use]
#[inline(always)]
pub const fn ud1(&self) -> u8 {
let val = (self.0 >> 8usize) & 0xff;
val as u8
}
#[doc = "Unique identifier byte 1."]
#[inline(always)]
pub const fn set_ud1(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 8usize)) | (((val as u32) & 0xff) << 8usize);
}
#[doc = "Unique identifier byte 2."]
#[must_use]
#[inline(always)]
pub const fn ud2(&self) -> u8 {
let val = (self.0 >> 16usize) & 0xff;
val as u8
}
#[doc = "Unique identifier byte 2."]
#[inline(always)]
pub const fn set_ud2(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 16usize)) | (((val as u32) & 0xff) << 16usize);
}
#[doc = "Unique identifier byte 3."]
#[must_use]
#[inline(always)]
pub const fn ud3(&self) -> u8 {
let val = (self.0 >> 24usize) & 0xff;
val as u8
}
#[doc = "Unique identifier byte 3."]
#[inline(always)]
pub const fn set_ud3(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 24usize)) | (((val as u32) & 0xff) << 24usize);
}
}
impl Default for Tagheader0 {
#[inline(always)]
fn default() -> Tagheader0 {
Tagheader0(0)
}
}
impl core::fmt::Debug for Tagheader0 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Tagheader0")
.field("mfgid", &self.mfgid())
.field("ud1", &self.ud1())
.field("ud2", &self.ud2())
.field("ud3", &self.ud3())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Tagheader0 {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Tagheader0 {{ mfgid: {=u8:?}, ud1: {=u8:?}, ud2: {=u8:?}, ud3: {=u8:?} }}",
self.mfgid(),
self.ud1(),
self.ud2(),
self.ud3()
)
}
}
#[doc = "Default header for NFC tag. Software can read these values to populate NFCID1_3RD_LAST, NFCID1_2ND_LAST, and NFCID1_LAST."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Tagheader1(pub u32);
impl Tagheader1 {
#[doc = "Unique identifier byte 4."]
#[must_use]
#[inline(always)]
pub const fn ud4(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "Unique identifier byte 4."]
#[inline(always)]
pub const fn set_ud4(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
#[doc = "Unique identifier byte 5."]
#[must_use]
#[inline(always)]
pub const fn ud5(&self) -> u8 {
let val = (self.0 >> 8usize) & 0xff;
val as u8
}
#[doc = "Unique identifier byte 5."]
#[inline(always)]
pub const fn set_ud5(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 8usize)) | (((val as u32) & 0xff) << 8usize);
}
#[doc = "Unique identifier byte 6."]
#[must_use]
#[inline(always)]
pub const fn ud6(&self) -> u8 {
let val = (self.0 >> 16usize) & 0xff;
val as u8
}
#[doc = "Unique identifier byte 6."]
#[inline(always)]
pub const fn set_ud6(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 16usize)) | (((val as u32) & 0xff) << 16usize);
}
#[doc = "Unique identifier byte 7."]
#[must_use]
#[inline(always)]
pub const fn ud7(&self) -> u8 {
let val = (self.0 >> 24usize) & 0xff;
val as u8
}
#[doc = "Unique identifier byte 7."]
#[inline(always)]
pub const fn set_ud7(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 24usize)) | (((val as u32) & 0xff) << 24usize);
}
}
impl Default for Tagheader1 {
#[inline(always)]
fn default() -> Tagheader1 {
Tagheader1(0)
}
}
impl core::fmt::Debug for Tagheader1 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Tagheader1")
.field("ud4", &self.ud4())
.field("ud5", &self.ud5())
.field("ud6", &self.ud6())
.field("ud7", &self.ud7())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Tagheader1 {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Tagheader1 {{ ud4: {=u8:?}, ud5: {=u8:?}, ud6: {=u8:?}, ud7: {=u8:?} }}",
self.ud4(),
self.ud5(),
self.ud6(),
self.ud7()
)
}
}
#[doc = "Default header for NFC tag. Software can read these values to populate NFCID1_3RD_LAST, NFCID1_2ND_LAST, and NFCID1_LAST."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Tagheader2(pub u32);
impl Tagheader2 {
#[doc = "Unique identifier byte 8."]
#[must_use]
#[inline(always)]
pub const fn ud8(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "Unique identifier byte 8."]
#[inline(always)]
pub const fn set_ud8(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
#[doc = "Unique identifier byte 9."]
#[must_use]
#[inline(always)]
pub const fn ud9(&self) -> u8 {
let val = (self.0 >> 8usize) & 0xff;
val as u8
}
#[doc = "Unique identifier byte 9."]
#[inline(always)]
pub const fn set_ud9(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 8usize)) | (((val as u32) & 0xff) << 8usize);
}
#[doc = "Unique identifier byte 10."]
#[must_use]
#[inline(always)]
pub const fn ud10(&self) -> u8 {
let val = (self.0 >> 16usize) & 0xff;
val as u8
}
#[doc = "Unique identifier byte 10."]
#[inline(always)]
pub const fn set_ud10(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 16usize)) | (((val as u32) & 0xff) << 16usize);
}
#[doc = "Unique identifier byte 11."]
#[must_use]
#[inline(always)]
pub const fn ud11(&self) -> u8 {
let val = (self.0 >> 24usize) & 0xff;
val as u8
}
#[doc = "Unique identifier byte 11."]
#[inline(always)]
pub const fn set_ud11(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 24usize)) | (((val as u32) & 0xff) << 24usize);
}
}
impl Default for Tagheader2 {
#[inline(always)]
fn default() -> Tagheader2 {
Tagheader2(0)
}
}
impl core::fmt::Debug for Tagheader2 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Tagheader2")
.field("ud8", &self.ud8())
.field("ud9", &self.ud9())
.field("ud10", &self.ud10())
.field("ud11", &self.ud11())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Tagheader2 {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Tagheader2 {{ ud8: {=u8:?}, ud9: {=u8:?}, ud10: {=u8:?}, ud11: {=u8:?} }}",
self.ud8(),
self.ud9(),
self.ud10(),
self.ud11()
)
}
}
#[doc = "Default header for NFC tag. Software can read these values to populate NFCID1_3RD_LAST, NFCID1_2ND_LAST, and NFCID1_LAST."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Tagheader3(pub u32);
impl Tagheader3 {
#[doc = "Unique identifier byte 12."]
#[must_use]
#[inline(always)]
pub const fn ud12(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "Unique identifier byte 12."]
#[inline(always)]
pub const fn set_ud12(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
#[doc = "Unique identifier byte 13."]
#[must_use]
#[inline(always)]
pub const fn ud13(&self) -> u8 {
let val = (self.0 >> 8usize) & 0xff;
val as u8
}
#[doc = "Unique identifier byte 13."]
#[inline(always)]
pub const fn set_ud13(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 8usize)) | (((val as u32) & 0xff) << 8usize);
}
#[doc = "Unique identifier byte 14."]
#[must_use]
#[inline(always)]
pub const fn ud14(&self) -> u8 {
let val = (self.0 >> 16usize) & 0xff;
val as u8
}
#[doc = "Unique identifier byte 14."]
#[inline(always)]
pub const fn set_ud14(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 16usize)) | (((val as u32) & 0xff) << 16usize);
}
#[doc = "Unique identifier byte 15."]
#[must_use]
#[inline(always)]
pub const fn ud15(&self) -> u8 {
let val = (self.0 >> 24usize) & 0xff;
val as u8
}
#[doc = "Unique identifier byte 15."]
#[inline(always)]
pub const fn set_ud15(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 24usize)) | (((val as u32) & 0xff) << 24usize);
}
}
impl Default for Tagheader3 {
#[inline(always)]
fn default() -> Tagheader3 {
Tagheader3(0)
}
}
impl core::fmt::Debug for Tagheader3 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Tagheader3")
.field("ud12", &self.ud12())
.field("ud13", &self.ud13())
.field("ud14", &self.ud14())
.field("ud15", &self.ud15())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Tagheader3 {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Tagheader3 {{ ud12: {=u8:?}, ud13: {=u8:?}, ud14: {=u8:?}, ud15: {=u8:?} }}",
self.ud12(),
self.ud13(),
self.ud14(),
self.ud15()
)
}
}
}
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 = "QFxx - 6x6 48-pin QFN."]
pub const Qf: Self = Self(0x2000);
#[doc = "QIxx - 7x7 73-pin aQFN."]
pub const Qi: Self = Self(0x2004);
#[doc = "CKxx - 3.544 x 3.607 WLCSP."]
pub const Ck: Self = Self(0x2005);
#[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 {
0x2000 => f.write_str("Qf"),
0x2004 => f.write_str("Qi"),
0x2005 => f.write_str("Ck"),
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 {
0x2000 => defmt::write!(f, "Qf"),
0x2004 => defmt::write!(f, "Qi"),
0x2005 => defmt::write!(f, "Ck"),
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 = "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_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_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)
}
}
}
}
pub mod fpu {
#[doc = "FPU."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Fpu {
ptr: *mut u8,
}
unsafe impl Send for Fpu {}
unsafe impl Sync for Fpu {}
impl Fpu {
#[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 gpio {
#[doc = "GPIO Port 0."]
#[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 = "Port number."]
#[must_use]
#[inline(always)]
pub const fn port(&self) -> bool {
let val = (self.0 >> 13usize) & 0x01;
val != 0
}
#[doc = "Port number."]
#[inline(always)]
pub const fn set_port(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 13usize)) | (((val as u32) & 0x01) << 13usize);
}
#[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("port", &self.port())
.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:?}, port: {=bool:?}, polarity: {:?}, outinit: {:?} }}" , self . mode () , self . psel () , self . port () , 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 i2s {
#[doc = "Unspecified."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Config {
ptr: *mut u8,
}
unsafe impl Send for Config {}
unsafe impl Sync for Config {}
impl Config {
#[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 = "I2S 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(0x0usize) as _) }
}
#[doc = "Reception (RX) enable."]
#[inline(always)]
pub const fn rxen(self) -> crate::common::Reg<regs::Rxen, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Transmission (TX) enable."]
#[inline(always)]
pub const fn txen(self) -> crate::common::Reg<regs::Txen, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
#[doc = "Master clock generator enable."]
#[inline(always)]
pub const fn mcken(self) -> crate::common::Reg<regs::Mcken, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0cusize) as _) }
}
#[doc = "Master clock generator frequency."]
#[inline(always)]
pub const fn mckfreq(self) -> crate::common::Reg<regs::Mckfreq, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x10usize) as _) }
}
#[doc = "MCK / LRCK ratio."]
#[inline(always)]
pub const fn ratio(self) -> crate::common::Reg<regs::Ratio, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x14usize) as _) }
}
#[doc = "Sample width."]
#[inline(always)]
pub const fn swidth(self) -> crate::common::Reg<regs::Swidth, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x18usize) as _) }
}
#[doc = "Alignment of sample within a frame."]
#[inline(always)]
pub const fn align(self) -> crate::common::Reg<regs::Align, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x1cusize) as _) }
}
#[doc = "Frame format."]
#[inline(always)]
pub const fn format(self) -> crate::common::Reg<regs::Format, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x20usize) as _) }
}
#[doc = "Enable channels."]
#[inline(always)]
pub const fn channels(self) -> crate::common::Reg<regs::Channels, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x24usize) as _) }
}
}
#[doc = "Inter-IC Sound."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct I2s {
ptr: *mut u8,
}
unsafe impl Send for I2s {}
unsafe impl Sync for I2s {}
impl I2s {
#[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 = "Starts continuous I2S transfer. Also starts MCK generator when this is enabled."]
#[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 = "Stops I2S transfer. Also stops MCK generator. Triggering this task will cause the STOPPED event to be generated."]
#[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 = "The RXD.PTR register has been copied to internal double-buffers. When the I2S module is started and RX is enabled, this event will be generated for every RXTXD.MAXCNT words that are received on the SDIN pin."]
#[inline(always)]
pub const fn events_rxptrupd(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0104usize) as _) }
}
#[doc = "I2S transfer 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(0x0108usize) as _) }
}
#[doc = "The TDX.PTR register has been copied to internal double-buffers. When the I2S module is started and TX is enabled, this event will be generated for every RXTXD.MAXCNT words that are sent on the SDOUT pin."]
#[inline(always)]
pub const fn events_txptrupd(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0114usize) 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 = "Enable I2S module."]
#[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 config(self) -> Config {
unsafe { Config::from_ptr(self.ptr.wrapping_add(0x0504usize) as _) }
}
#[doc = "Unspecified."]
#[inline(always)]
pub const fn rxd(self) -> Rxd {
unsafe { Rxd::from_ptr(self.ptr.wrapping_add(0x0538usize) as _) }
}
#[doc = "Unspecified."]
#[inline(always)]
pub const fn txd(self) -> Txd {
unsafe { Txd::from_ptr(self.ptr.wrapping_add(0x0540usize) as _) }
}
#[doc = "Unspecified."]
#[inline(always)]
pub const fn rxtxd(self) -> Rxtxd {
unsafe { Rxtxd::from_ptr(self.ptr.wrapping_add(0x0550usize) as _) }
}
#[doc = "Unspecified."]
#[inline(always)]
pub const fn psel(self) -> Psel {
unsafe { Psel::from_ptr(self.ptr.wrapping_add(0x0560usize) 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 MCK signal."]
#[inline(always)]
pub const fn mck(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 SCK signal."]
#[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(0x04usize) as _) }
}
#[doc = "Pin select for LRCK signal."]
#[inline(always)]
pub const fn lrck(
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 SDIN signal."]
#[inline(always)]
pub const fn sdin(
self,
) -> crate::common::Reg<super::shared::regs::Psel, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0cusize) as _) }
}
#[doc = "Pin select for SDOUT signal."]
#[inline(always)]
pub const fn sdout(
self,
) -> crate::common::Reg<super::shared::regs::Psel, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x10usize) as _) }
}
}
#[doc = "Unspecified."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Rxd {
ptr: *mut u8,
}
unsafe impl Send for Rxd {}
unsafe impl Sync for Rxd {}
impl Rxd {
#[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 RAM start address."]
#[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 = "Unspecified."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Rxtxd {
ptr: *mut u8,
}
unsafe impl Send for Rxtxd {}
unsafe impl Sync for Rxtxd {}
impl Rxtxd {
#[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 = "Size of RXD and TXD buffers."]
#[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(0x0usize) as _) }
}
}
#[doc = "Unspecified."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Txd {
ptr: *mut u8,
}
unsafe impl Send for Txd {}
unsafe impl Sync for Txd {}
impl Txd {
#[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 = "Transmit buffer RAM start address."]
#[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 _) }
}
}
pub mod regs {
#[doc = "Alignment of sample within a frame."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Align(pub u32);
impl Align {
#[doc = "Alignment of sample within a frame."]
#[must_use]
#[inline(always)]
pub const fn align(&self) -> super::vals::Align {
let val = (self.0 >> 0usize) & 0x01;
super::vals::Align::from_bits(val as u8)
}
#[doc = "Alignment of sample within a frame."]
#[inline(always)]
pub const fn set_align(&mut self, val: super::vals::Align) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
}
impl Default for Align {
#[inline(always)]
fn default() -> Align {
Align(0)
}
}
impl core::fmt::Debug for Align {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Align")
.field("align", &self.align())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Align {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Align {{ align: {:?} }}", self.align())
}
}
#[doc = "Enable channels."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Channels(pub u32);
impl Channels {
#[doc = "Enable channels."]
#[must_use]
#[inline(always)]
pub const fn channels(&self) -> super::vals::Channels {
let val = (self.0 >> 0usize) & 0x03;
super::vals::Channels::from_bits(val as u8)
}
#[doc = "Enable channels."]
#[inline(always)]
pub const fn set_channels(&mut self, val: super::vals::Channels) {
self.0 = (self.0 & !(0x03 << 0usize)) | (((val.to_bits() as u32) & 0x03) << 0usize);
}
}
impl Default for Channels {
#[inline(always)]
fn default() -> Channels {
Channels(0)
}
}
impl core::fmt::Debug for Channels {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Channels")
.field("channels", &self.channels())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Channels {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Channels {{ channels: {:?} }}", self.channels())
}
}
#[doc = "Enable I2S module."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Enable(pub u32);
impl Enable {
#[doc = "Enable I2S module."]
#[must_use]
#[inline(always)]
pub const fn enable(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Enable I2S module."]
#[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 = "Frame format."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Format(pub u32);
impl Format {
#[doc = "Frame format."]
#[must_use]
#[inline(always)]
pub const fn format(&self) -> super::vals::Format {
let val = (self.0 >> 0usize) & 0x01;
super::vals::Format::from_bits(val as u8)
}
#[doc = "Frame format."]
#[inline(always)]
pub const fn set_format(&mut self, val: super::vals::Format) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
}
impl Default for Format {
#[inline(always)]
fn default() -> Format {
Format(0)
}
}
impl core::fmt::Debug for Format {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Format")
.field("format", &self.format())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Format {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Format {{ format: {:?} }}", self.format())
}
}
#[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 RXPTRUPD."]
#[must_use]
#[inline(always)]
pub const fn rxptrupd(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event RXPTRUPD."]
#[inline(always)]
pub const fn set_rxptrupd(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "Enable or disable interrupt for event STOPPED."]
#[must_use]
#[inline(always)]
pub const fn stopped(&self) -> bool {
let val = (self.0 >> 2usize) & 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 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "Enable or disable interrupt for event TXPTRUPD."]
#[must_use]
#[inline(always)]
pub const fn txptrupd(&self) -> bool {
let val = (self.0 >> 5usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event TXPTRUPD."]
#[inline(always)]
pub const fn set_txptrupd(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
}
}
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("rxptrupd", &self.rxptrupd())
.field("stopped", &self.stopped())
.field("txptrupd", &self.txptrupd())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Int {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Int {{ rxptrupd: {=bool:?}, stopped: {=bool:?}, txptrupd: {=bool:?} }}",
self.rxptrupd(),
self.stopped(),
self.txptrupd()
)
}
}
#[doc = "Size of RXD and TXD buffers."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Maxcnt(pub u32);
impl Maxcnt {
#[doc = "Size of RXD and TXD buffers in number of 32 bit words."]
#[must_use]
#[inline(always)]
pub const fn maxcnt(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x3fff;
val as u16
}
#[doc = "Size of RXD and TXD buffers in number of 32 bit words."]
#[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 = "Master clock generator enable."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Mcken(pub u32);
impl Mcken {
#[doc = "Master clock generator enable."]
#[must_use]
#[inline(always)]
pub const fn mcken(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Master clock generator enable."]
#[inline(always)]
pub const fn set_mcken(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for Mcken {
#[inline(always)]
fn default() -> Mcken {
Mcken(0)
}
}
impl core::fmt::Debug for Mcken {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Mcken")
.field("mcken", &self.mcken())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Mcken {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Mcken {{ mcken: {=bool:?} }}", self.mcken())
}
}
#[doc = "Master clock generator frequency."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Mckfreq(pub u32);
impl Mckfreq {
#[doc = "Master clock generator frequency."]
#[must_use]
#[inline(always)]
pub const fn mckfreq(&self) -> super::vals::Mckfreq {
let val = (self.0 >> 0usize) & 0xffff_ffff;
super::vals::Mckfreq::from_bits(val as u32)
}
#[doc = "Master clock generator frequency."]
#[inline(always)]
pub const fn set_mckfreq(&mut self, val: super::vals::Mckfreq) {
self.0 = (self.0 & !(0xffff_ffff << 0usize))
| (((val.to_bits() as u32) & 0xffff_ffff) << 0usize);
}
}
impl Default for Mckfreq {
#[inline(always)]
fn default() -> Mckfreq {
Mckfreq(0)
}
}
impl core::fmt::Debug for Mckfreq {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Mckfreq")
.field("mckfreq", &self.mckfreq())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Mckfreq {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Mckfreq {{ mckfreq: {:?} }}", self.mckfreq())
}
}
#[doc = "I2S mode."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Mode(pub u32);
impl Mode {
#[doc = "I2S mode."]
#[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 = "I2S mode."]
#[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);
}
}
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 = "MCK / LRCK ratio."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Ratio(pub u32);
impl Ratio {
#[doc = "MCK / LRCK ratio."]
#[must_use]
#[inline(always)]
pub const fn ratio(&self) -> super::vals::Ratio {
let val = (self.0 >> 0usize) & 0x0f;
super::vals::Ratio::from_bits(val as u8)
}
#[doc = "MCK / LRCK ratio."]
#[inline(always)]
pub const fn set_ratio(&mut self, val: super::vals::Ratio) {
self.0 = (self.0 & !(0x0f << 0usize)) | (((val.to_bits() as u32) & 0x0f) << 0usize);
}
}
impl Default for Ratio {
#[inline(always)]
fn default() -> Ratio {
Ratio(0)
}
}
impl core::fmt::Debug for Ratio {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Ratio")
.field("ratio", &self.ratio())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Ratio {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Ratio {{ ratio: {:?} }}", self.ratio())
}
}
#[doc = "Reception (RX) enable."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Rxen(pub u32);
impl Rxen {
#[doc = "Reception (RX) enable."]
#[must_use]
#[inline(always)]
pub const fn rxen(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Reception (RX) enable."]
#[inline(always)]
pub const fn set_rxen(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for Rxen {
#[inline(always)]
fn default() -> Rxen {
Rxen(0)
}
}
impl core::fmt::Debug for Rxen {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Rxen").field("rxen", &self.rxen()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Rxen {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Rxen {{ rxen: {=bool:?} }}", self.rxen())
}
}
#[doc = "Sample width."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Swidth(pub u32);
impl Swidth {
#[doc = "Sample width."]
#[must_use]
#[inline(always)]
pub const fn swidth(&self) -> super::vals::Swidth {
let val = (self.0 >> 0usize) & 0x03;
super::vals::Swidth::from_bits(val as u8)
}
#[doc = "Sample width."]
#[inline(always)]
pub const fn set_swidth(&mut self, val: super::vals::Swidth) {
self.0 = (self.0 & !(0x03 << 0usize)) | (((val.to_bits() as u32) & 0x03) << 0usize);
}
}
impl Default for Swidth {
#[inline(always)]
fn default() -> Swidth {
Swidth(0)
}
}
impl core::fmt::Debug for Swidth {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Swidth")
.field("swidth", &self.swidth())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Swidth {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Swidth {{ swidth: {:?} }}", self.swidth())
}
}
#[doc = "Transmission (TX) enable."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Txen(pub u32);
impl Txen {
#[doc = "Transmission (TX) enable."]
#[must_use]
#[inline(always)]
pub const fn txen(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Transmission (TX) enable."]
#[inline(always)]
pub const fn set_txen(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for Txen {
#[inline(always)]
fn default() -> Txen {
Txen(0)
}
}
impl core::fmt::Debug for Txen {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Txen").field("txen", &self.txen()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Txen {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Txen {{ txen: {=bool:?} }}", self.txen())
}
}
}
pub mod vals {
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Align {
#[doc = "Left-aligned."]
Left = 0x0,
#[doc = "Right-aligned."]
Right = 0x01,
}
impl Align {
#[inline(always)]
pub const fn from_bits(val: u8) -> Align {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Align {
#[inline(always)]
fn from(val: u8) -> Align {
Align::from_bits(val)
}
}
impl From<Align> for u8 {
#[inline(always)]
fn from(val: Align) -> u8 {
Align::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Channels {
#[doc = "Stereo."]
Stereo = 0x0,
#[doc = "Left only."]
Left = 0x01,
#[doc = "Right only."]
Right = 0x02,
_RESERVED_3 = 0x03,
}
impl Channels {
#[inline(always)]
pub const fn from_bits(val: u8) -> Channels {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Channels {
#[inline(always)]
fn from(val: u8) -> Channels {
Channels::from_bits(val)
}
}
impl From<Channels> for u8 {
#[inline(always)]
fn from(val: Channels) -> u8 {
Channels::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Format {
#[doc = "Original I2S format."]
I2s = 0x0,
#[doc = "Alternate (left- or right-aligned) format."]
Aligned = 0x01,
}
impl Format {
#[inline(always)]
pub const fn from_bits(val: u8) -> Format {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Format {
#[inline(always)]
fn from(val: u8) -> Format {
Format::from_bits(val)
}
}
impl From<Format> for u8 {
#[inline(always)]
fn from(val: Format) -> u8 {
Format::to_bits(val)
}
}
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct Mckfreq(u32);
impl Mckfreq {
#[doc = "32 MHz / 125 = 0.256 MHz."]
pub const _32mdiv125: Self = Self(0x020c_0000);
#[doc = "32 MHz / 63 = 0.5079365 MHz."]
pub const _32mdiv63: Self = Self(0x0410_0000);
#[doc = "32 MHz / 42 = 0.7619048 MHz."]
pub const _32mdiv42: Self = Self(0x0600_0000);
#[doc = "32 MHz / 32 = 1.0 MHz."]
pub const _32mdiv32: Self = Self(0x0800_0000);
#[doc = "32 MHz / 31 = 1.0322581 MHz."]
pub const _32mdiv31: Self = Self(0x0840_0000);
#[doc = "32 MHz / 30 = 1.0666667 MHz."]
pub const _32mdiv30: Self = Self(0x0880_0000);
#[doc = "32 MHz / 23 = 1.3913043 MHz."]
pub const _32mdiv23: Self = Self(0x0b00_0000);
#[doc = "32 MHz / 21 = 1.5238095."]
pub const _32mdiv21: Self = Self(0x0c00_0000);
#[doc = "32 MHz / 16 = 2.0 MHz."]
pub const _32mdiv16: Self = Self(0x1000_0000);
#[doc = "32 MHz / 15 = 2.1333333 MHz."]
pub const _32mdiv15: Self = Self(0x1100_0000);
#[doc = "32 MHz / 11 = 2.9090909 MHz."]
pub const _32mdiv11: Self = Self(0x1600_0000);
#[doc = "32 MHz / 10 = 3.2 MHz."]
pub const _32mdiv10: Self = Self(0x1800_0000);
#[doc = "32 MHz / 8 = 4.0 MHz."]
pub const _32mdiv8: Self = Self(0x2000_0000);
}
impl Mckfreq {
pub const fn from_bits(val: u32) -> Mckfreq {
Self(val & 0xffff_ffff)
}
pub const fn to_bits(self) -> u32 {
self.0
}
}
impl core::fmt::Debug for Mckfreq {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self.0 {
0x020c_0000 => f.write_str("_32mdiv125"),
0x0410_0000 => f.write_str("_32mdiv63"),
0x0600_0000 => f.write_str("_32mdiv42"),
0x0800_0000 => f.write_str("_32mdiv32"),
0x0840_0000 => f.write_str("_32mdiv31"),
0x0880_0000 => f.write_str("_32mdiv30"),
0x0b00_0000 => f.write_str("_32mdiv23"),
0x0c00_0000 => f.write_str("_32mdiv21"),
0x1000_0000 => f.write_str("_32mdiv16"),
0x1100_0000 => f.write_str("_32mdiv15"),
0x1600_0000 => f.write_str("_32mdiv11"),
0x1800_0000 => f.write_str("_32mdiv10"),
0x2000_0000 => f.write_str("_32mdiv8"),
other => core::write!(f, "0x{:02X}", other),
}
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Mckfreq {
fn format(&self, f: defmt::Formatter) {
match self.0 {
0x020c_0000 => defmt::write!(f, "_32mdiv125"),
0x0410_0000 => defmt::write!(f, "_32mdiv63"),
0x0600_0000 => defmt::write!(f, "_32mdiv42"),
0x0800_0000 => defmt::write!(f, "_32mdiv32"),
0x0840_0000 => defmt::write!(f, "_32mdiv31"),
0x0880_0000 => defmt::write!(f, "_32mdiv30"),
0x0b00_0000 => defmt::write!(f, "_32mdiv23"),
0x0c00_0000 => defmt::write!(f, "_32mdiv21"),
0x1000_0000 => defmt::write!(f, "_32mdiv16"),
0x1100_0000 => defmt::write!(f, "_32mdiv15"),
0x1600_0000 => defmt::write!(f, "_32mdiv11"),
0x1800_0000 => defmt::write!(f, "_32mdiv10"),
0x2000_0000 => defmt::write!(f, "_32mdiv8"),
other => defmt::write!(f, "0x{:02X}", other),
}
}
}
impl From<u32> for Mckfreq {
#[inline(always)]
fn from(val: u32) -> Mckfreq {
Mckfreq::from_bits(val)
}
}
impl From<Mckfreq> for u32 {
#[inline(always)]
fn from(val: Mckfreq) -> u32 {
Mckfreq::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Mode {
#[doc = "Master mode. SCK and LRCK generated from internal master clcok (MCK) and output on pins defined by PSEL.xxx."]
Master = 0x0,
#[doc = "Slave mode. SCK and LRCK generated by external master and received on pins defined by PSEL.xxx."]
Slave = 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 Ratio {
#[doc = "LRCK = MCK / 32."]
_32x = 0x0,
#[doc = "LRCK = MCK / 48."]
_48x = 0x01,
#[doc = "LRCK = MCK / 64."]
_64x = 0x02,
#[doc = "LRCK = MCK / 96."]
_96x = 0x03,
#[doc = "LRCK = MCK / 128."]
_128x = 0x04,
#[doc = "LRCK = MCK / 192."]
_192x = 0x05,
#[doc = "LRCK = MCK / 256."]
_256x = 0x06,
#[doc = "LRCK = MCK / 384."]
_384x = 0x07,
#[doc = "LRCK = MCK / 512."]
_512x = 0x08,
_RESERVED_9 = 0x09,
_RESERVED_a = 0x0a,
_RESERVED_b = 0x0b,
_RESERVED_c = 0x0c,
_RESERVED_d = 0x0d,
_RESERVED_e = 0x0e,
_RESERVED_f = 0x0f,
}
impl Ratio {
#[inline(always)]
pub const fn from_bits(val: u8) -> Ratio {
unsafe { core::mem::transmute(val & 0x0f) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Ratio {
#[inline(always)]
fn from(val: u8) -> Ratio {
Ratio::from_bits(val)
}
}
impl From<Ratio> for u8 {
#[inline(always)]
fn from(val: Ratio) -> u8 {
Ratio::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Swidth {
#[doc = "8 bit."]
_8bit = 0x0,
#[doc = "16 bit."]
_16bit = 0x01,
#[doc = "24 bit."]
_24bit = 0x02,
_RESERVED_3 = 0x03,
}
impl Swidth {
#[inline(always)]
pub const fn from_bits(val: u8) -> Swidth {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Swidth {
#[inline(always)]
fn from(val: u8) -> Swidth {
Swidth::from_bits(val)
}
}
impl From<Swidth> for u8 {
#[inline(always)]
fn from(val: Swidth) -> u8 {
Swidth::to_bits(val)
}
}
}
}
pub mod lpcomp {
#[doc = "Low-power comparator."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Lpcomp {
ptr: *mut u8,
}
unsafe impl Send for Lpcomp {}
unsafe impl Sync for Lpcomp {}
impl Lpcomp {
#[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 = "LPCOMP 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 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 = "Enable LPCOMP."]
#[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 = "Input 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 select."]
#[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 = "Analog detect configuration."]
#[inline(always)]
pub const fn anadetect(self) -> crate::common::Reg<regs::Anadetect, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0520usize) 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 = "Analog detect configuration."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Anadetect(pub u32);
impl Anadetect {
#[doc = "Analog detect configuration."]
#[must_use]
#[inline(always)]
pub const fn anadetect(&self) -> super::vals::Anadetect {
let val = (self.0 >> 0usize) & 0x03;
super::vals::Anadetect::from_bits(val as u8)
}
#[doc = "Analog detect configuration."]
#[inline(always)]
pub const fn set_anadetect(&mut self, val: super::vals::Anadetect) {
self.0 = (self.0 & !(0x03 << 0usize)) | (((val.to_bits() as u32) & 0x03) << 0usize);
}
}
impl Default for Anadetect {
#[inline(always)]
fn default() -> Anadetect {
Anadetect(0)
}
}
impl core::fmt::Debug for Anadetect {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Anadetect")
.field("anadetect", &self.anadetect())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Anadetect {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Anadetect {{ anadetect: {:?} }}", self.anadetect())
}
}
#[doc = "Enable LPCOMP."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Enable(pub u32);
impl Enable {
#[doc = "Enable or disable LPCOMP."]
#[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 LPCOMP."]
#[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) & 0x01;
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 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 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 enable."]
#[must_use]
#[inline(always)]
pub const fn hyst(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Comparator hysteresis enable."]
#[inline(always)]
pub const fn set_hyst(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val 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: {=bool:?} }}", self.hyst())
}
}
#[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 DOWN."]
#[must_use]
#[inline(always)]
pub const fn down(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Write '1' to 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 = "Write '1' to disable interrupt for event UP."]
#[must_use]
#[inline(always)]
pub const fn up(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Write '1' to 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 = "Write '1' to disable interrupt for event CROSS."]
#[must_use]
#[inline(always)]
pub const fn cross(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "Write '1' to 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 = "Input 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 select."]
#[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) & 0x0f;
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 & !(0x0f << 0usize)) | (((val.to_bits() as u32) & 0x0f) << 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 ())
}
}
}
pub mod vals {
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Anadetect {
#[doc = "Generate ANADETECT on crossing, both upward crossing and downward crossing."]
Cross = 0x0,
#[doc = "Generate ANADETECT on upward crossing only."]
Up = 0x01,
#[doc = "Generate ANADETECT on downward crossing only."]
Down = 0x02,
_RESERVED_3 = 0x03,
}
impl Anadetect {
#[inline(always)]
pub const fn from_bits(val: u8) -> Anadetect {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Anadetect {
#[inline(always)]
fn from(val: u8) -> Anadetect {
Anadetect::from_bits(val)
}
}
impl From<Anadetect> for u8 {
#[inline(always)]
fn from(val: Anadetect) -> u8 {
Anadetect::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,
#[doc = "Enable."]
Enabled = 0x01,
_RESERVED_2 = 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,
}
impl Extrefsel {
#[inline(always)]
pub const fn from_bits(val: u8) -> Extrefsel {
unsafe { core::mem::transmute(val & 0x01) }
}
#[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 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,
#[doc = "AIN4 selected as analog input."]
AnalogInput4 = 0x04,
#[doc = "AIN5 selected as analog input."]
AnalogInput5 = 0x05,
#[doc = "AIN6 selected as analog input."]
AnalogInput6 = 0x06,
#[doc = "AIN7 selected as analog input."]
AnalogInput7 = 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 = "VDD * 1/8 selected as reference."]
Ref18vdd = 0x0,
#[doc = "VDD * 2/8 selected as reference."]
Ref28vdd = 0x01,
#[doc = "VDD * 3/8 selected as reference."]
Ref38vdd = 0x02,
#[doc = "VDD * 4/8 selected as reference."]
Ref48vdd = 0x03,
#[doc = "VDD * 5/8 selected as reference."]
Ref58vdd = 0x04,
#[doc = "VDD * 6/8 selected as reference."]
Ref68vdd = 0x05,
#[doc = "VDD * 7/8 selected as reference."]
Ref78vdd = 0x06,
#[doc = "External analog reference selected."]
ARef = 0x07,
#[doc = "VDD * 1/16 selected as reference."]
Ref116vdd = 0x08,
#[doc = "VDD * 3/16 selected as reference."]
Ref316vdd = 0x09,
#[doc = "VDD * 5/16 selected as reference."]
Ref516vdd = 0x0a,
#[doc = "VDD * 7/16 selected as reference."]
Ref716vdd = 0x0b,
#[doc = "VDD * 9/16 selected as reference."]
Ref916vdd = 0x0c,
#[doc = "VDD * 11/16 selected as reference."]
Ref1116vdd = 0x0d,
#[doc = "VDD * 13/16 selected as reference."]
Ref1316vdd = 0x0e,
#[doc = "VDD * 15/16 selected as reference."]
Ref1516vdd = 0x0f,
}
impl Refsel {
#[inline(always)]
pub const fn from_bits(val: u8) -> Refsel {
unsafe { core::mem::transmute(val & 0x0f) }
}
#[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 reference threshold (VIN+ < VIN-)."]
Below = 0x0,
#[doc = "Input voltage is above the reference 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)
}
}
}
}
pub mod mwu {
#[doc = "Peripheral events."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct EventsPregion {
ptr: *mut u8,
}
unsafe impl Send for EventsPregion {}
unsafe impl Sync for EventsPregion {}
impl EventsPregion {
#[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: Write access to peripheral region n detected."]
#[inline(always)]
pub const fn wa(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Description cluster: Read access to peripheral region n detected."]
#[inline(always)]
pub const fn ra(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
}
#[doc = "Peripheral events."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct EventsRegion {
ptr: *mut u8,
}
unsafe impl Send for EventsRegion {}
unsafe impl Sync for EventsRegion {}
impl EventsRegion {
#[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: Write access to region n detected."]
#[inline(always)]
pub const fn wa(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Description cluster: Read access to region n detected."]
#[inline(always)]
pub const fn ra(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
}
#[doc = "Memory Watch Unit."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Mwu {
ptr: *mut u8,
}
unsafe impl Send for Mwu {}
unsafe impl Sync for Mwu {}
impl Mwu {
#[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 = "Peripheral events."]
#[inline(always)]
pub const fn events_region(self, n: usize) -> EventsRegion {
assert!(n < 4usize);
unsafe { EventsRegion::from_ptr(self.ptr.wrapping_add(0x0100usize + n * 8usize) as _) }
}
#[doc = "Peripheral events."]
#[inline(always)]
pub const fn events_pregion(self, n: usize) -> EventsPregion {
assert!(n < 2usize);
unsafe { EventsPregion::from_ptr(self.ptr.wrapping_add(0x0160usize + n * 8usize) 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 = "Enable or disable interrupt."]
#[inline(always)]
pub const fn nmien(self) -> crate::common::Reg<regs::Nmi, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0320usize) as _) }
}
#[doc = "Enable interrupt."]
#[inline(always)]
pub const fn nmienset(self) -> crate::common::Reg<regs::Nmi, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0324usize) as _) }
}
#[doc = "Disable interrupt."]
#[inline(always)]
pub const fn nmienclr(self) -> crate::common::Reg<regs::Nmi, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0328usize) as _) }
}
#[doc = "Unspecified."]
#[inline(always)]
pub const fn perregion(self, n: usize) -> Perregion {
assert!(n < 2usize);
unsafe { Perregion::from_ptr(self.ptr.wrapping_add(0x0400usize + n * 8usize) as _) }
}
#[doc = "Enable/disable regions watch."]
#[inline(always)]
pub const fn regionen(self) -> crate::common::Reg<regs::Regionen, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0510usize) as _) }
}
#[doc = "Enable regions watch."]
#[inline(always)]
pub const fn regionenset(self) -> crate::common::Reg<regs::Regionen, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0514usize) as _) }
}
#[doc = "Disable regions watch."]
#[inline(always)]
pub const fn regionenclr(self) -> crate::common::Reg<regs::Regionen, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0518usize) as _) }
}
#[doc = "Unspecified."]
#[inline(always)]
pub const fn region(self, n: usize) -> Region {
assert!(n < 4usize);
unsafe { Region::from_ptr(self.ptr.wrapping_add(0x0600usize + n * 16usize) as _) }
}
#[doc = "Unspecified."]
#[inline(always)]
pub const fn pregion(self, n: usize) -> Pregion {
assert!(n < 2usize);
unsafe { Pregion::from_ptr(self.ptr.wrapping_add(0x06c0usize + n * 16usize) as _) }
}
}
#[doc = "Unspecified."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Perregion {
ptr: *mut u8,
}
unsafe impl Send for Perregion {}
unsafe impl Sync for Perregion {}
impl Perregion {
#[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: Source of event/interrupt in region n, write access detected while corresponding subregion was enabled for watching."]
#[inline(always)]
pub const fn substatwa(self) -> crate::common::Reg<regs::Substatwa, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Description cluster: Source of event/interrupt in region n, read access detected while corresponding subregion was enabled for watching."]
#[inline(always)]
pub const fn substatra(self) -> crate::common::Reg<regs::Substatra, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
}
#[doc = "Unspecified."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Pregion {
ptr: *mut u8,
}
unsafe impl Send for Pregion {}
unsafe impl Sync for Pregion {}
impl Pregion {
#[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: Reserved for future use."]
#[inline(always)]
pub const fn start(self) -> crate::common::Reg<u32, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Description cluster: Reserved for future use."]
#[inline(always)]
pub const fn end(self) -> crate::common::Reg<u32, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Description cluster: Subregions of region n."]
#[inline(always)]
pub const fn subs(self) -> crate::common::Reg<regs::Subs, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
}
#[doc = "Unspecified."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Region {
ptr: *mut u8,
}
unsafe impl Send for Region {}
unsafe impl Sync for Region {}
impl Region {
#[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 for region n."]
#[inline(always)]
pub const fn start(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Description cluster: End address of region n."]
#[inline(always)]
pub const fn end(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) 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 REGION0WA."]
#[must_use]
#[inline(always)]
pub const fn region0wa(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event REGION0WA."]
#[inline(always)]
pub const fn set_region0wa(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Enable or disable interrupt for event REGION0RA."]
#[must_use]
#[inline(always)]
pub const fn region0ra(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event REGION0RA."]
#[inline(always)]
pub const fn set_region0ra(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "Enable or disable interrupt for event REGION1WA."]
#[must_use]
#[inline(always)]
pub const fn region1wa(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event REGION1WA."]
#[inline(always)]
pub const fn set_region1wa(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "Enable or disable interrupt for event REGION1RA."]
#[must_use]
#[inline(always)]
pub const fn region1ra(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event REGION1RA."]
#[inline(always)]
pub const fn set_region1ra(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
#[doc = "Enable or disable interrupt for event REGION2WA."]
#[must_use]
#[inline(always)]
pub const fn region2wa(&self) -> bool {
let val = (self.0 >> 4usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event REGION2WA."]
#[inline(always)]
pub const fn set_region2wa(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
}
#[doc = "Enable or disable interrupt for event REGION2RA."]
#[must_use]
#[inline(always)]
pub const fn region2ra(&self) -> bool {
let val = (self.0 >> 5usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event REGION2RA."]
#[inline(always)]
pub const fn set_region2ra(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
}
#[doc = "Enable or disable interrupt for event REGION3WA."]
#[must_use]
#[inline(always)]
pub const fn region3wa(&self) -> bool {
let val = (self.0 >> 6usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event REGION3WA."]
#[inline(always)]
pub const fn set_region3wa(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize);
}
#[doc = "Enable or disable interrupt for event REGION3RA."]
#[must_use]
#[inline(always)]
pub const fn region3ra(&self) -> bool {
let val = (self.0 >> 7usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event REGION3RA."]
#[inline(always)]
pub const fn set_region3ra(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize);
}
#[doc = "Enable or disable interrupt for event PREGION0WA."]
#[must_use]
#[inline(always)]
pub const fn pregion0wa(&self) -> bool {
let val = (self.0 >> 24usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event PREGION0WA."]
#[inline(always)]
pub const fn set_pregion0wa(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 24usize)) | (((val as u32) & 0x01) << 24usize);
}
#[doc = "Enable or disable interrupt for event PREGION0RA."]
#[must_use]
#[inline(always)]
pub const fn pregion0ra(&self) -> bool {
let val = (self.0 >> 25usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event PREGION0RA."]
#[inline(always)]
pub const fn set_pregion0ra(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 25usize)) | (((val as u32) & 0x01) << 25usize);
}
#[doc = "Enable or disable interrupt for event PREGION1WA."]
#[must_use]
#[inline(always)]
pub const fn pregion1wa(&self) -> bool {
let val = (self.0 >> 26usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event PREGION1WA."]
#[inline(always)]
pub const fn set_pregion1wa(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 26usize)) | (((val as u32) & 0x01) << 26usize);
}
#[doc = "Enable or disable interrupt for event PREGION1RA."]
#[must_use]
#[inline(always)]
pub const fn pregion1ra(&self) -> bool {
let val = (self.0 >> 27usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event PREGION1RA."]
#[inline(always)]
pub const fn set_pregion1ra(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 27usize)) | (((val as u32) & 0x01) << 27usize);
}
}
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("region0wa", &self.region0wa())
.field("region0ra", &self.region0ra())
.field("region1wa", &self.region1wa())
.field("region1ra", &self.region1ra())
.field("region2wa", &self.region2wa())
.field("region2ra", &self.region2ra())
.field("region3wa", &self.region3wa())
.field("region3ra", &self.region3ra())
.field("pregion0wa", &self.pregion0wa())
.field("pregion0ra", &self.pregion0ra())
.field("pregion1wa", &self.pregion1wa())
.field("pregion1ra", &self.pregion1ra())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Int {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Int {{ region0wa: {=bool:?}, region0ra: {=bool:?}, region1wa: {=bool:?}, region1ra: {=bool:?}, region2wa: {=bool:?}, region2ra: {=bool:?}, region3wa: {=bool:?}, region3ra: {=bool:?}, pregion0wa: {=bool:?}, pregion0ra: {=bool:?}, pregion1wa: {=bool:?}, pregion1ra: {=bool:?} }}" , self . region0wa () , self . region0ra () , self . region1wa () , self . region1ra () , self . region2wa () , self . region2ra () , self . region3wa () , self . region3ra () , self . pregion0wa () , self . pregion0ra () , self . pregion1wa () , self . pregion1ra ())
}
}
#[doc = "Enable or disable interrupt."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Nmi(pub u32);
impl Nmi {
#[doc = "Enable or disable interrupt for event REGION0WA."]
#[must_use]
#[inline(always)]
pub const fn region0wa(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event REGION0WA."]
#[inline(always)]
pub const fn set_region0wa(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Enable or disable interrupt for event REGION0RA."]
#[must_use]
#[inline(always)]
pub const fn region0ra(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event REGION0RA."]
#[inline(always)]
pub const fn set_region0ra(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "Enable or disable interrupt for event REGION1WA."]
#[must_use]
#[inline(always)]
pub const fn region1wa(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event REGION1WA."]
#[inline(always)]
pub const fn set_region1wa(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "Enable or disable interrupt for event REGION1RA."]
#[must_use]
#[inline(always)]
pub const fn region1ra(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event REGION1RA."]
#[inline(always)]
pub const fn set_region1ra(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
#[doc = "Enable or disable interrupt for event REGION2WA."]
#[must_use]
#[inline(always)]
pub const fn region2wa(&self) -> bool {
let val = (self.0 >> 4usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event REGION2WA."]
#[inline(always)]
pub const fn set_region2wa(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
}
#[doc = "Enable or disable interrupt for event REGION2RA."]
#[must_use]
#[inline(always)]
pub const fn region2ra(&self) -> bool {
let val = (self.0 >> 5usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event REGION2RA."]
#[inline(always)]
pub const fn set_region2ra(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
}
#[doc = "Enable or disable interrupt for event REGION3WA."]
#[must_use]
#[inline(always)]
pub const fn region3wa(&self) -> bool {
let val = (self.0 >> 6usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event REGION3WA."]
#[inline(always)]
pub const fn set_region3wa(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize);
}
#[doc = "Enable or disable interrupt for event REGION3RA."]
#[must_use]
#[inline(always)]
pub const fn region3ra(&self) -> bool {
let val = (self.0 >> 7usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event REGION3RA."]
#[inline(always)]
pub const fn set_region3ra(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize);
}
#[doc = "Enable or disable interrupt for event PREGION0WA."]
#[must_use]
#[inline(always)]
pub const fn pregion0wa(&self) -> bool {
let val = (self.0 >> 24usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event PREGION0WA."]
#[inline(always)]
pub const fn set_pregion0wa(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 24usize)) | (((val as u32) & 0x01) << 24usize);
}
#[doc = "Enable or disable interrupt for event PREGION0RA."]
#[must_use]
#[inline(always)]
pub const fn pregion0ra(&self) -> bool {
let val = (self.0 >> 25usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event PREGION0RA."]
#[inline(always)]
pub const fn set_pregion0ra(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 25usize)) | (((val as u32) & 0x01) << 25usize);
}
#[doc = "Enable or disable interrupt for event PREGION1WA."]
#[must_use]
#[inline(always)]
pub const fn pregion1wa(&self) -> bool {
let val = (self.0 >> 26usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event PREGION1WA."]
#[inline(always)]
pub const fn set_pregion1wa(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 26usize)) | (((val as u32) & 0x01) << 26usize);
}
#[doc = "Enable or disable interrupt for event PREGION1RA."]
#[must_use]
#[inline(always)]
pub const fn pregion1ra(&self) -> bool {
let val = (self.0 >> 27usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event PREGION1RA."]
#[inline(always)]
pub const fn set_pregion1ra(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 27usize)) | (((val as u32) & 0x01) << 27usize);
}
}
impl Default for Nmi {
#[inline(always)]
fn default() -> Nmi {
Nmi(0)
}
}
impl core::fmt::Debug for Nmi {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Nmi")
.field("region0wa", &self.region0wa())
.field("region0ra", &self.region0ra())
.field("region1wa", &self.region1wa())
.field("region1ra", &self.region1ra())
.field("region2wa", &self.region2wa())
.field("region2ra", &self.region2ra())
.field("region3wa", &self.region3wa())
.field("region3ra", &self.region3ra())
.field("pregion0wa", &self.pregion0wa())
.field("pregion0ra", &self.pregion0ra())
.field("pregion1wa", &self.pregion1wa())
.field("pregion1ra", &self.pregion1ra())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Nmi {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Nmi {{ region0wa: {=bool:?}, region0ra: {=bool:?}, region1wa: {=bool:?}, region1ra: {=bool:?}, region2wa: {=bool:?}, region2ra: {=bool:?}, region3wa: {=bool:?}, region3ra: {=bool:?}, pregion0wa: {=bool:?}, pregion0ra: {=bool:?}, pregion1wa: {=bool:?}, pregion1ra: {=bool:?} }}" , self . region0wa () , self . region0ra () , self . region1wa () , self . region1ra () , self . region2wa () , self . region2ra () , self . region3wa () , self . region3ra () , self . pregion0wa () , self . pregion0ra () , self . pregion1wa () , self . pregion1ra ())
}
}
#[doc = "Enable/disable regions watch."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Regionen(pub u32);
impl Regionen {
#[doc = "Enable/disable write access watch in region\\[0\\]."]
#[must_use]
#[inline(always)]
pub const fn rgn_wa(&self, n: usize) -> bool {
assert!(n < 4usize);
let offs = 0usize + n * 2usize;
let val = (self.0 >> offs) & 0x01;
val != 0
}
#[doc = "Enable/disable write access watch in region\\[0\\]."]
#[inline(always)]
pub const fn set_rgn_wa(&mut self, n: usize, val: bool) {
assert!(n < 4usize);
let offs = 0usize + n * 2usize;
self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
}
#[doc = "Enable/disable read access watch in region\\[0\\]."]
#[must_use]
#[inline(always)]
pub const fn rgn_ra(&self, n: usize) -> bool {
assert!(n < 4usize);
let offs = 1usize + n * 2usize;
let val = (self.0 >> offs) & 0x01;
val != 0
}
#[doc = "Enable/disable read access watch in region\\[0\\]."]
#[inline(always)]
pub const fn set_rgn_ra(&mut self, n: usize, val: bool) {
assert!(n < 4usize);
let offs = 1usize + n * 2usize;
self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
}
#[doc = "Enable/disable write access watch in PREGION\\[0\\]."]
#[must_use]
#[inline(always)]
pub const fn prgn_wa(&self, n: usize) -> bool {
assert!(n < 2usize);
let offs = 24usize + n * 2usize;
let val = (self.0 >> offs) & 0x01;
val != 0
}
#[doc = "Enable/disable write access watch in PREGION\\[0\\]."]
#[inline(always)]
pub const fn set_prgn_wa(&mut self, n: usize, val: bool) {
assert!(n < 2usize);
let offs = 24usize + n * 2usize;
self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
}
#[doc = "Enable/disable read access watch in PREGION\\[0\\]."]
#[must_use]
#[inline(always)]
pub const fn prgn_ra(&self, n: usize) -> bool {
assert!(n < 2usize);
let offs = 25usize + n * 2usize;
let val = (self.0 >> offs) & 0x01;
val != 0
}
#[doc = "Enable/disable read access watch in PREGION\\[0\\]."]
#[inline(always)]
pub const fn set_prgn_ra(&mut self, n: usize, val: bool) {
assert!(n < 2usize);
let offs = 25usize + n * 2usize;
self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
}
}
impl Default for Regionen {
#[inline(always)]
fn default() -> Regionen {
Regionen(0)
}
}
impl core::fmt::Debug for Regionen {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Regionen")
.field("rgn_wa[0]", &self.rgn_wa(0usize))
.field("rgn_wa[1]", &self.rgn_wa(1usize))
.field("rgn_wa[2]", &self.rgn_wa(2usize))
.field("rgn_wa[3]", &self.rgn_wa(3usize))
.field("rgn_ra[0]", &self.rgn_ra(0usize))
.field("rgn_ra[1]", &self.rgn_ra(1usize))
.field("rgn_ra[2]", &self.rgn_ra(2usize))
.field("rgn_ra[3]", &self.rgn_ra(3usize))
.field("prgn_wa[0]", &self.prgn_wa(0usize))
.field("prgn_wa[1]", &self.prgn_wa(1usize))
.field("prgn_ra[0]", &self.prgn_ra(0usize))
.field("prgn_ra[1]", &self.prgn_ra(1usize))
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Regionen {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Regionen {{ rgn_wa[0]: {=bool:?}, rgn_wa[1]: {=bool:?}, rgn_wa[2]: {=bool:?}, rgn_wa[3]: {=bool:?}, rgn_ra[0]: {=bool:?}, rgn_ra[1]: {=bool:?}, rgn_ra[2]: {=bool:?}, rgn_ra[3]: {=bool:?}, prgn_wa[0]: {=bool:?}, prgn_wa[1]: {=bool:?}, prgn_ra[0]: {=bool:?}, prgn_ra[1]: {=bool:?} }}" , self . rgn_wa (0usize) , self . rgn_wa (1usize) , self . rgn_wa (2usize) , self . rgn_wa (3usize) , self . rgn_ra (0usize) , self . rgn_ra (1usize) , self . rgn_ra (2usize) , self . rgn_ra (3usize) , self . prgn_wa (0usize) , self . prgn_wa (1usize) , self . prgn_ra (0usize) , self . prgn_ra (1usize))
}
}
#[doc = "Description cluster: Subregions of region n."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Subs(pub u32);
impl Subs {
#[doc = "Include or exclude subregion 0 in region."]
#[must_use]
#[inline(always)]
pub const fn sr(&self, n: usize) -> bool {
assert!(n < 32usize);
let offs = 0usize + n * 1usize;
let val = (self.0 >> offs) & 0x01;
val != 0
}
#[doc = "Include or exclude subregion 0 in region."]
#[inline(always)]
pub const fn set_sr(&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 Subs {
#[inline(always)]
fn default() -> Subs {
Subs(0)
}
}
impl core::fmt::Debug for Subs {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Subs")
.field("sr[0]", &self.sr(0usize))
.field("sr[1]", &self.sr(1usize))
.field("sr[2]", &self.sr(2usize))
.field("sr[3]", &self.sr(3usize))
.field("sr[4]", &self.sr(4usize))
.field("sr[5]", &self.sr(5usize))
.field("sr[6]", &self.sr(6usize))
.field("sr[7]", &self.sr(7usize))
.field("sr[8]", &self.sr(8usize))
.field("sr[9]", &self.sr(9usize))
.field("sr[10]", &self.sr(10usize))
.field("sr[11]", &self.sr(11usize))
.field("sr[12]", &self.sr(12usize))
.field("sr[13]", &self.sr(13usize))
.field("sr[14]", &self.sr(14usize))
.field("sr[15]", &self.sr(15usize))
.field("sr[16]", &self.sr(16usize))
.field("sr[17]", &self.sr(17usize))
.field("sr[18]", &self.sr(18usize))
.field("sr[19]", &self.sr(19usize))
.field("sr[20]", &self.sr(20usize))
.field("sr[21]", &self.sr(21usize))
.field("sr[22]", &self.sr(22usize))
.field("sr[23]", &self.sr(23usize))
.field("sr[24]", &self.sr(24usize))
.field("sr[25]", &self.sr(25usize))
.field("sr[26]", &self.sr(26usize))
.field("sr[27]", &self.sr(27usize))
.field("sr[28]", &self.sr(28usize))
.field("sr[29]", &self.sr(29usize))
.field("sr[30]", &self.sr(30usize))
.field("sr[31]", &self.sr(31usize))
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Subs {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Subs {{ sr[0]: {=bool:?}, sr[1]: {=bool:?}, sr[2]: {=bool:?}, sr[3]: {=bool:?}, sr[4]: {=bool:?}, sr[5]: {=bool:?}, sr[6]: {=bool:?}, sr[7]: {=bool:?}, sr[8]: {=bool:?}, sr[9]: {=bool:?}, sr[10]: {=bool:?}, sr[11]: {=bool:?}, sr[12]: {=bool:?}, sr[13]: {=bool:?}, sr[14]: {=bool:?}, sr[15]: {=bool:?}, sr[16]: {=bool:?}, sr[17]: {=bool:?}, sr[18]: {=bool:?}, sr[19]: {=bool:?}, sr[20]: {=bool:?}, sr[21]: {=bool:?}, sr[22]: {=bool:?}, sr[23]: {=bool:?}, sr[24]: {=bool:?}, sr[25]: {=bool:?}, sr[26]: {=bool:?}, sr[27]: {=bool:?}, sr[28]: {=bool:?}, sr[29]: {=bool:?}, sr[30]: {=bool:?}, sr[31]: {=bool:?} }}" , self . sr (0usize) , self . sr (1usize) , self . sr (2usize) , self . sr (3usize) , self . sr (4usize) , self . sr (5usize) , self . sr (6usize) , self . sr (7usize) , self . sr (8usize) , self . sr (9usize) , self . sr (10usize) , self . sr (11usize) , self . sr (12usize) , self . sr (13usize) , self . sr (14usize) , self . sr (15usize) , self . sr (16usize) , self . sr (17usize) , self . sr (18usize) , self . sr (19usize) , self . sr (20usize) , self . sr (21usize) , self . sr (22usize) , self . sr (23usize) , self . sr (24usize) , self . sr (25usize) , self . sr (26usize) , self . sr (27usize) , self . sr (28usize) , self . sr (29usize) , self . sr (30usize) , self . sr (31usize))
}
}
#[doc = "Description cluster: Source of event/interrupt in region n, read access detected while corresponding subregion was enabled for watching."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Substatra(pub u32);
impl Substatra {
#[doc = "Subregion 0 in region n (write '1' to clear)."]
#[must_use]
#[inline(always)]
pub const fn sr(&self, n: usize) -> bool {
assert!(n < 32usize);
let offs = 0usize + n * 1usize;
let val = (self.0 >> offs) & 0x01;
val != 0
}
#[doc = "Subregion 0 in region n (write '1' to clear)."]
#[inline(always)]
pub const fn set_sr(&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 Substatra {
#[inline(always)]
fn default() -> Substatra {
Substatra(0)
}
}
impl core::fmt::Debug for Substatra {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Substatra")
.field("sr[0]", &self.sr(0usize))
.field("sr[1]", &self.sr(1usize))
.field("sr[2]", &self.sr(2usize))
.field("sr[3]", &self.sr(3usize))
.field("sr[4]", &self.sr(4usize))
.field("sr[5]", &self.sr(5usize))
.field("sr[6]", &self.sr(6usize))
.field("sr[7]", &self.sr(7usize))
.field("sr[8]", &self.sr(8usize))
.field("sr[9]", &self.sr(9usize))
.field("sr[10]", &self.sr(10usize))
.field("sr[11]", &self.sr(11usize))
.field("sr[12]", &self.sr(12usize))
.field("sr[13]", &self.sr(13usize))
.field("sr[14]", &self.sr(14usize))
.field("sr[15]", &self.sr(15usize))
.field("sr[16]", &self.sr(16usize))
.field("sr[17]", &self.sr(17usize))
.field("sr[18]", &self.sr(18usize))
.field("sr[19]", &self.sr(19usize))
.field("sr[20]", &self.sr(20usize))
.field("sr[21]", &self.sr(21usize))
.field("sr[22]", &self.sr(22usize))
.field("sr[23]", &self.sr(23usize))
.field("sr[24]", &self.sr(24usize))
.field("sr[25]", &self.sr(25usize))
.field("sr[26]", &self.sr(26usize))
.field("sr[27]", &self.sr(27usize))
.field("sr[28]", &self.sr(28usize))
.field("sr[29]", &self.sr(29usize))
.field("sr[30]", &self.sr(30usize))
.field("sr[31]", &self.sr(31usize))
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Substatra {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Substatra {{ sr[0]: {=bool:?}, sr[1]: {=bool:?}, sr[2]: {=bool:?}, sr[3]: {=bool:?}, sr[4]: {=bool:?}, sr[5]: {=bool:?}, sr[6]: {=bool:?}, sr[7]: {=bool:?}, sr[8]: {=bool:?}, sr[9]: {=bool:?}, sr[10]: {=bool:?}, sr[11]: {=bool:?}, sr[12]: {=bool:?}, sr[13]: {=bool:?}, sr[14]: {=bool:?}, sr[15]: {=bool:?}, sr[16]: {=bool:?}, sr[17]: {=bool:?}, sr[18]: {=bool:?}, sr[19]: {=bool:?}, sr[20]: {=bool:?}, sr[21]: {=bool:?}, sr[22]: {=bool:?}, sr[23]: {=bool:?}, sr[24]: {=bool:?}, sr[25]: {=bool:?}, sr[26]: {=bool:?}, sr[27]: {=bool:?}, sr[28]: {=bool:?}, sr[29]: {=bool:?}, sr[30]: {=bool:?}, sr[31]: {=bool:?} }}" , self . sr (0usize) , self . sr (1usize) , self . sr (2usize) , self . sr (3usize) , self . sr (4usize) , self . sr (5usize) , self . sr (6usize) , self . sr (7usize) , self . sr (8usize) , self . sr (9usize) , self . sr (10usize) , self . sr (11usize) , self . sr (12usize) , self . sr (13usize) , self . sr (14usize) , self . sr (15usize) , self . sr (16usize) , self . sr (17usize) , self . sr (18usize) , self . sr (19usize) , self . sr (20usize) , self . sr (21usize) , self . sr (22usize) , self . sr (23usize) , self . sr (24usize) , self . sr (25usize) , self . sr (26usize) , self . sr (27usize) , self . sr (28usize) , self . sr (29usize) , self . sr (30usize) , self . sr (31usize))
}
}
#[doc = "Description cluster: Source of event/interrupt in region n, write access detected while corresponding subregion was enabled for watching."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Substatwa(pub u32);
impl Substatwa {
#[doc = "Subregion 0 in region n (write '1' to clear)."]
#[must_use]
#[inline(always)]
pub const fn sr(&self, n: usize) -> bool {
assert!(n < 32usize);
let offs = 0usize + n * 1usize;
let val = (self.0 >> offs) & 0x01;
val != 0
}
#[doc = "Subregion 0 in region n (write '1' to clear)."]
#[inline(always)]
pub const fn set_sr(&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 Substatwa {
#[inline(always)]
fn default() -> Substatwa {
Substatwa(0)
}
}
impl core::fmt::Debug for Substatwa {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Substatwa")
.field("sr[0]", &self.sr(0usize))
.field("sr[1]", &self.sr(1usize))
.field("sr[2]", &self.sr(2usize))
.field("sr[3]", &self.sr(3usize))
.field("sr[4]", &self.sr(4usize))
.field("sr[5]", &self.sr(5usize))
.field("sr[6]", &self.sr(6usize))
.field("sr[7]", &self.sr(7usize))
.field("sr[8]", &self.sr(8usize))
.field("sr[9]", &self.sr(9usize))
.field("sr[10]", &self.sr(10usize))
.field("sr[11]", &self.sr(11usize))
.field("sr[12]", &self.sr(12usize))
.field("sr[13]", &self.sr(13usize))
.field("sr[14]", &self.sr(14usize))
.field("sr[15]", &self.sr(15usize))
.field("sr[16]", &self.sr(16usize))
.field("sr[17]", &self.sr(17usize))
.field("sr[18]", &self.sr(18usize))
.field("sr[19]", &self.sr(19usize))
.field("sr[20]", &self.sr(20usize))
.field("sr[21]", &self.sr(21usize))
.field("sr[22]", &self.sr(22usize))
.field("sr[23]", &self.sr(23usize))
.field("sr[24]", &self.sr(24usize))
.field("sr[25]", &self.sr(25usize))
.field("sr[26]", &self.sr(26usize))
.field("sr[27]", &self.sr(27usize))
.field("sr[28]", &self.sr(28usize))
.field("sr[29]", &self.sr(29usize))
.field("sr[30]", &self.sr(30usize))
.field("sr[31]", &self.sr(31usize))
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Substatwa {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Substatwa {{ sr[0]: {=bool:?}, sr[1]: {=bool:?}, sr[2]: {=bool:?}, sr[3]: {=bool:?}, sr[4]: {=bool:?}, sr[5]: {=bool:?}, sr[6]: {=bool:?}, sr[7]: {=bool:?}, sr[8]: {=bool:?}, sr[9]: {=bool:?}, sr[10]: {=bool:?}, sr[11]: {=bool:?}, sr[12]: {=bool:?}, sr[13]: {=bool:?}, sr[14]: {=bool:?}, sr[15]: {=bool:?}, sr[16]: {=bool:?}, sr[17]: {=bool:?}, sr[18]: {=bool:?}, sr[19]: {=bool:?}, sr[20]: {=bool:?}, sr[21]: {=bool:?}, sr[22]: {=bool:?}, sr[23]: {=bool:?}, sr[24]: {=bool:?}, sr[25]: {=bool:?}, sr[26]: {=bool:?}, sr[27]: {=bool:?}, sr[28]: {=bool:?}, sr[29]: {=bool:?}, sr[30]: {=bool:?}, sr[31]: {=bool:?} }}" , self . sr (0usize) , self . sr (1usize) , self . sr (2usize) , self . sr (3usize) , self . sr (4usize) , self . sr (5usize) , self . sr (6usize) , self . sr (7usize) , self . sr (8usize) , self . sr (9usize) , self . sr (10usize) , self . sr (11usize) , self . sr (12usize) , self . sr (13usize) , self . sr (14usize) , self . sr (15usize) , self . sr (16usize) , self . sr (17usize) , self . sr (18usize) , self . sr (19usize) , self . sr (20usize) , self . sr (21usize) , self . sr (22usize) , self . sr (23usize) , self . sr (24usize) , self . sr (25usize) , self . sr (26usize) , self . sr (27usize) , self . sr (28usize) , self . sr (29usize) , self . sr (30usize) , self . sr (31usize))
}
}
}
}
pub mod nfct {
#[doc = "Unspecified."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Framestatus {
ptr: *mut u8,
}
unsafe impl Send for Framestatus {}
unsafe impl Sync for Framestatus {}
impl Framestatus {
#[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 = "Result of last incoming frame."]
#[inline(always)]
pub const fn rx(self) -> crate::common::Reg<regs::Rx, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
}
#[doc = "NFC-A compatible radio."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Nfct {
ptr: *mut u8,
}
unsafe impl Send for Nfct {}
unsafe impl Sync for Nfct {}
impl Nfct {
#[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 = "Activate NFCT peripheral for incoming and outgoing frames, change state to activated."]
#[inline(always)]
pub const fn tasks_activate(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Disable NFCT peripheral."]
#[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(0x04usize) as _) }
}
#[doc = "Enable NFC sense field mode, change state to sense mode."]
#[inline(always)]
pub const fn tasks_sense(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
#[doc = "Start transmission of an outgoing frame, change state to transmit."]
#[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(0x0cusize) as _) }
}
#[doc = "Initializes the EasyDMA for receive."]
#[inline(always)]
pub const fn tasks_enablerxdata(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x1cusize) as _) }
}
#[doc = "Force state machine to IDLE state."]
#[inline(always)]
pub const fn tasks_goidle(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x24usize) as _) }
}
#[doc = "Force state machine to SLEEP_A state."]
#[inline(always)]
pub const fn tasks_gosleep(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x28usize) as _) }
}
#[doc = "The NFCT peripheral is ready to receive and send frames."]
#[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 = "Remote NFC field detected."]
#[inline(always)]
pub const fn events_fielddetected(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0104usize) as _) }
}
#[doc = "Remote NFC field lost."]
#[inline(always)]
pub const fn events_fieldlost(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0108usize) as _) }
}
#[doc = "Marks the start of the first symbol of a transmitted frame."]
#[inline(always)]
pub const fn events_txframestart(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x010cusize) as _) }
}
#[doc = "Marks the end of the last transmitted on-air symbol of a frame."]
#[inline(always)]
pub const fn events_txframeend(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0110usize) as _) }
}
#[doc = "Marks the end of the first symbol of a received frame."]
#[inline(always)]
pub const fn events_rxframestart(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0114usize) as _) }
}
#[doc = "Received data has been checked (CRC, parity) and transferred to RAM, and EasyDMA has ended accessing the RX buffer."]
#[inline(always)]
pub const fn events_rxframeend(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0118usize) as _) }
}
#[doc = "NFC error reported. The ERRORSTATUS register contains details on the source of the 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(0x011cusize) as _) }
}
#[doc = "NFC RX frame error reported. The FRAMESTATUS.RX register contains details on the source of the error."]
#[inline(always)]
pub const fn events_rxerror(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0128usize) as _) }
}
#[doc = "RX buffer (as defined by PACKETPTR and MAXLEN) in Data RAM full."]
#[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(0x012cusize) as _) }
}
#[doc = "Transmission of data in RAM has ended, and EasyDMA has ended accessing the TX buffer."]
#[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(0x0130usize) as _) }
}
#[doc = "Auto collision resolution process has started."]
#[inline(always)]
pub const fn events_autocolresstarted(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0138usize) as _) }
}
#[doc = "NFC auto collision resolution error reported."]
#[inline(always)]
pub const fn events_collision(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0148usize) as _) }
}
#[doc = "NFC auto collision resolution successfully completed."]
#[inline(always)]
pub const fn events_selected(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x014cusize) as _) }
}
#[doc = "EasyDMA is ready to receive or send frames."]
#[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(0x0150usize) 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 = "NFC Error Status register."]
#[inline(always)]
pub const fn errorstatus(self) -> crate::common::Reg<regs::Errorstatus, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0404usize) as _) }
}
#[doc = "Unspecified."]
#[inline(always)]
pub const fn framestatus(self) -> Framestatus {
unsafe { Framestatus::from_ptr(self.ptr.wrapping_add(0x040cusize) as _) }
}
#[doc = "NfcTag state register."]
#[inline(always)]
pub const fn nfctagstate(self) -> crate::common::Reg<regs::Nfctagstate, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0410usize) as _) }
}
#[doc = "Sleep state during automatic collision resolution."]
#[inline(always)]
pub const fn sleepstate(self) -> crate::common::Reg<regs::Sleepstate, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0420usize) as _) }
}
#[doc = "Indicates the presence or not of a valid field."]
#[inline(always)]
pub const fn fieldpresent(
self,
) -> crate::common::Reg<regs::Fieldpresent, crate::common::R> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x043cusize) as _) }
}
#[doc = "Minimum frame delay."]
#[inline(always)]
pub const fn framedelaymin(
self,
) -> crate::common::Reg<regs::Framedelaymin, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0504usize) as _) }
}
#[doc = "Maximum frame delay."]
#[inline(always)]
pub const fn framedelaymax(
self,
) -> crate::common::Reg<regs::Framedelaymax, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0508usize) as _) }
}
#[doc = "Configuration register for the Frame Delay Timer."]
#[inline(always)]
pub const fn framedelaymode(
self,
) -> crate::common::Reg<regs::Framedelaymode, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x050cusize) as _) }
}
#[doc = "Packet pointer for TXD and RXD data storage in Data RAM."]
#[inline(always)]
pub const fn packetptr(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0510usize) as _) }
}
#[doc = "Size of the RAM buffer allocated to TXD and RXD data storage each."]
#[inline(always)]
pub const fn maxlen(self) -> crate::common::Reg<regs::Maxlen, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0514usize) as _) }
}
#[doc = "Unspecified."]
#[inline(always)]
pub const fn txd(self) -> Txd {
unsafe { Txd::from_ptr(self.ptr.wrapping_add(0x0518usize) as _) }
}
#[doc = "Unspecified."]
#[inline(always)]
pub const fn rxd(self) -> Rxd {
unsafe { Rxd::from_ptr(self.ptr.wrapping_add(0x0520usize) as _) }
}
#[doc = "Last NFCID1 part (4, 7 or 10 bytes ID)."]
#[inline(always)]
pub const fn nfcid1_last(self) -> crate::common::Reg<regs::Nfcid1Last, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0590usize) as _) }
}
#[doc = "Second last NFCID1 part (7 or 10 bytes ID)."]
#[inline(always)]
pub const fn nfcid1_2nd_last(
self,
) -> crate::common::Reg<regs::Nfcid12ndLast, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0594usize) as _) }
}
#[doc = "Third last NFCID1 part (10 bytes ID)."]
#[inline(always)]
pub const fn nfcid1_3rd_last(
self,
) -> crate::common::Reg<regs::Nfcid13rdLast, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0598usize) as _) }
}
#[doc = "Controls the auto collision resolution function. This setting must be done before the NFCT peripheral is activated."]
#[inline(always)]
pub const fn autocolresconfig(
self,
) -> crate::common::Reg<regs::Autocolresconfig, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x059cusize) as _) }
}
#[doc = "NFC-A SENS_RES auto-response settings."]
#[inline(always)]
pub const fn sensres(self) -> crate::common::Reg<regs::Sensres, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x05a0usize) as _) }
}
#[doc = "NFC-A SEL_RES auto-response settings."]
#[inline(always)]
pub const fn selres(self) -> crate::common::Reg<regs::Selres, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x05a4usize) as _) }
}
}
#[doc = "Unspecified."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Rxd {
ptr: *mut u8,
}
unsafe impl Send for Rxd {}
unsafe impl Sync for Rxd {}
impl Rxd {
#[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 = "Configuration of incoming frames."]
#[inline(always)]
pub const fn frameconfig(
self,
) -> crate::common::Reg<regs::RxdFrameconfig, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Size of last incoming frame."]
#[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(0x04usize) as _) }
}
}
#[doc = "Unspecified."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Txd {
ptr: *mut u8,
}
unsafe impl Send for Txd {}
unsafe impl Sync for Txd {}
impl Txd {
#[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 = "Configuration of outgoing frames."]
#[inline(always)]
pub const fn frameconfig(
self,
) -> crate::common::Reg<regs::TxdFrameconfig, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Size of outgoing frame."]
#[inline(always)]
pub const fn amount(self) -> crate::common::Reg<regs::TxdAmount, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
}
pub mod regs {
#[doc = "Controls the auto collision resolution function. This setting must be done before the NFCT peripheral is activated."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Autocolresconfig(pub u32);
impl Autocolresconfig {
#[doc = "Enables/disables auto collision resolution."]
#[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 = "Enables/disables auto collision resolution."]
#[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);
}
}
impl Default for Autocolresconfig {
#[inline(always)]
fn default() -> Autocolresconfig {
Autocolresconfig(0)
}
}
impl core::fmt::Debug for Autocolresconfig {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Autocolresconfig")
.field("mode", &self.mode())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Autocolresconfig {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Autocolresconfig {{ mode: {:?} }}", self.mode())
}
}
#[doc = "NFC Error Status register."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Errorstatus(pub u32);
impl Errorstatus {
#[doc = "No STARTTX task triggered before expiration of the time set in FRAMEDELAYMAX."]
#[must_use]
#[inline(always)]
pub const fn framedelaytimeout(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "No STARTTX task triggered before expiration of the time set in FRAMEDELAYMAX."]
#[inline(always)]
pub const fn set_framedelaytimeout(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for Errorstatus {
#[inline(always)]
fn default() -> Errorstatus {
Errorstatus(0)
}
}
impl core::fmt::Debug for Errorstatus {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Errorstatus")
.field("framedelaytimeout", &self.framedelaytimeout())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Errorstatus {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Errorstatus {{ framedelaytimeout: {=bool:?} }}",
self.framedelaytimeout()
)
}
}
#[doc = "Indicates the presence or not of a valid field."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Fieldpresent(pub u32);
impl Fieldpresent {
#[doc = "Indicates if a valid field is present. Available only in the activated state."]
#[must_use]
#[inline(always)]
pub const fn fieldpresent(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Indicates if a valid field is present. Available only in the activated state."]
#[inline(always)]
pub const fn set_fieldpresent(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Indicates if the low level has locked to the field."]
#[must_use]
#[inline(always)]
pub const fn lockdetect(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Indicates if the low level has locked to the field."]
#[inline(always)]
pub const fn set_lockdetect(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
}
impl Default for Fieldpresent {
#[inline(always)]
fn default() -> Fieldpresent {
Fieldpresent(0)
}
}
impl core::fmt::Debug for Fieldpresent {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Fieldpresent")
.field("fieldpresent", &self.fieldpresent())
.field("lockdetect", &self.lockdetect())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Fieldpresent {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Fieldpresent {{ fieldpresent: {=bool:?}, lockdetect: {=bool:?} }}",
self.fieldpresent(),
self.lockdetect()
)
}
}
#[doc = "Maximum frame delay."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Framedelaymax(pub u32);
impl Framedelaymax {
#[doc = "Maximum frame delay in number of 13.56 MHz clocks."]
#[must_use]
#[inline(always)]
pub const fn framedelaymax(&self) -> u32 {
let val = (self.0 >> 0usize) & 0x000f_ffff;
val as u32
}
#[doc = "Maximum frame delay in number of 13.56 MHz clocks."]
#[inline(always)]
pub const fn set_framedelaymax(&mut self, val: u32) {
self.0 =
(self.0 & !(0x000f_ffff << 0usize)) | (((val as u32) & 0x000f_ffff) << 0usize);
}
}
impl Default for Framedelaymax {
#[inline(always)]
fn default() -> Framedelaymax {
Framedelaymax(0)
}
}
impl core::fmt::Debug for Framedelaymax {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Framedelaymax")
.field("framedelaymax", &self.framedelaymax())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Framedelaymax {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Framedelaymax {{ framedelaymax: {=u32:?} }}",
self.framedelaymax()
)
}
}
#[doc = "Minimum frame delay."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Framedelaymin(pub u32);
impl Framedelaymin {
#[doc = "Minimum frame delay in number of 13.56 MHz clocks."]
#[must_use]
#[inline(always)]
pub const fn framedelaymin(&self) -> u16 {
let val = (self.0 >> 0usize) & 0xffff;
val as u16
}
#[doc = "Minimum frame delay in number of 13.56 MHz clocks."]
#[inline(always)]
pub const fn set_framedelaymin(&mut self, val: u16) {
self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize);
}
}
impl Default for Framedelaymin {
#[inline(always)]
fn default() -> Framedelaymin {
Framedelaymin(0)
}
}
impl core::fmt::Debug for Framedelaymin {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Framedelaymin")
.field("framedelaymin", &self.framedelaymin())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Framedelaymin {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Framedelaymin {{ framedelaymin: {=u16:?} }}",
self.framedelaymin()
)
}
}
#[doc = "Configuration register for the Frame Delay Timer."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Framedelaymode(pub u32);
impl Framedelaymode {
#[doc = "Configuration register for the Frame Delay Timer."]
#[must_use]
#[inline(always)]
pub const fn framedelaymode(&self) -> super::vals::Framedelaymode {
let val = (self.0 >> 0usize) & 0x03;
super::vals::Framedelaymode::from_bits(val as u8)
}
#[doc = "Configuration register for the Frame Delay Timer."]
#[inline(always)]
pub const fn set_framedelaymode(&mut self, val: super::vals::Framedelaymode) {
self.0 = (self.0 & !(0x03 << 0usize)) | (((val.to_bits() as u32) & 0x03) << 0usize);
}
}
impl Default for Framedelaymode {
#[inline(always)]
fn default() -> Framedelaymode {
Framedelaymode(0)
}
}
impl core::fmt::Debug for Framedelaymode {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Framedelaymode")
.field("framedelaymode", &self.framedelaymode())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Framedelaymode {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Framedelaymode {{ framedelaymode: {:?} }}",
self.framedelaymode()
)
}
}
#[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 FIELDDETECTED."]
#[must_use]
#[inline(always)]
pub const fn fielddetected(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event FIELDDETECTED."]
#[inline(always)]
pub const fn set_fielddetected(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "Enable or disable interrupt for event FIELDLOST."]
#[must_use]
#[inline(always)]
pub const fn fieldlost(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event FIELDLOST."]
#[inline(always)]
pub const fn set_fieldlost(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "Enable or disable interrupt for event TXFRAMESTART."]
#[must_use]
#[inline(always)]
pub const fn txframestart(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event TXFRAMESTART."]
#[inline(always)]
pub const fn set_txframestart(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
#[doc = "Enable or disable interrupt for event TXFRAMEEND."]
#[must_use]
#[inline(always)]
pub const fn txframeend(&self) -> bool {
let val = (self.0 >> 4usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event TXFRAMEEND."]
#[inline(always)]
pub const fn set_txframeend(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
}
#[doc = "Enable or disable interrupt for event RXFRAMESTART."]
#[must_use]
#[inline(always)]
pub const fn rxframestart(&self) -> bool {
let val = (self.0 >> 5usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event RXFRAMESTART."]
#[inline(always)]
pub const fn set_rxframestart(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
}
#[doc = "Enable or disable interrupt for event RXFRAMEEND."]
#[must_use]
#[inline(always)]
pub const fn rxframeend(&self) -> bool {
let val = (self.0 >> 6usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event RXFRAMEEND."]
#[inline(always)]
pub const fn set_rxframeend(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize);
}
#[doc = "Enable or disable interrupt for event ERROR."]
#[must_use]
#[inline(always)]
pub const fn error(&self) -> bool {
let val = (self.0 >> 7usize) & 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 << 7usize)) | (((val as u32) & 0x01) << 7usize);
}
#[doc = "Enable or disable interrupt for event RXERROR."]
#[must_use]
#[inline(always)]
pub const fn rxerror(&self) -> bool {
let val = (self.0 >> 10usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event RXERROR."]
#[inline(always)]
pub const fn set_rxerror(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 10usize)) | (((val as u32) & 0x01) << 10usize);
}
#[doc = "Enable or disable interrupt for event ENDRX."]
#[must_use]
#[inline(always)]
pub const fn endrx(&self) -> bool {
let val = (self.0 >> 11usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event ENDRX."]
#[inline(always)]
pub const fn set_endrx(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 11usize)) | (((val as u32) & 0x01) << 11usize);
}
#[doc = "Enable or disable interrupt for event ENDTX."]
#[must_use]
#[inline(always)]
pub const fn endtx(&self) -> bool {
let val = (self.0 >> 12usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event ENDTX."]
#[inline(always)]
pub const fn set_endtx(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 12usize)) | (((val as u32) & 0x01) << 12usize);
}
#[doc = "Enable or disable interrupt for event AUTOCOLRESSTARTED."]
#[must_use]
#[inline(always)]
pub const fn autocolresstarted(&self) -> bool {
let val = (self.0 >> 14usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event AUTOCOLRESSTARTED."]
#[inline(always)]
pub const fn set_autocolresstarted(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 14usize)) | (((val as u32) & 0x01) << 14usize);
}
#[doc = "Enable or disable interrupt for event COLLISION."]
#[must_use]
#[inline(always)]
pub const fn collision(&self) -> bool {
let val = (self.0 >> 18usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event COLLISION."]
#[inline(always)]
pub const fn set_collision(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 18usize)) | (((val as u32) & 0x01) << 18usize);
}
#[doc = "Enable or disable interrupt for event SELECTED."]
#[must_use]
#[inline(always)]
pub const fn selected(&self) -> bool {
let val = (self.0 >> 19usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event SELECTED."]
#[inline(always)]
pub const fn set_selected(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 19usize)) | (((val as u32) & 0x01) << 19usize);
}
#[doc = "Enable or disable interrupt for event STARTED."]
#[must_use]
#[inline(always)]
pub const fn started(&self) -> bool {
let val = (self.0 >> 20usize) & 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 << 20usize)) | (((val as u32) & 0x01) << 20usize);
}
}
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("fielddetected", &self.fielddetected())
.field("fieldlost", &self.fieldlost())
.field("txframestart", &self.txframestart())
.field("txframeend", &self.txframeend())
.field("rxframestart", &self.rxframestart())
.field("rxframeend", &self.rxframeend())
.field("error", &self.error())
.field("rxerror", &self.rxerror())
.field("endrx", &self.endrx())
.field("endtx", &self.endtx())
.field("autocolresstarted", &self.autocolresstarted())
.field("collision", &self.collision())
.field("selected", &self.selected())
.field("started", &self.started())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Int {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Int {{ ready: {=bool:?}, fielddetected: {=bool:?}, fieldlost: {=bool:?}, txframestart: {=bool:?}, txframeend: {=bool:?}, rxframestart: {=bool:?}, rxframeend: {=bool:?}, error: {=bool:?}, rxerror: {=bool:?}, endrx: {=bool:?}, endtx: {=bool:?}, autocolresstarted: {=bool:?}, collision: {=bool:?}, selected: {=bool:?}, started: {=bool:?} }}" , self . ready () , self . fielddetected () , self . fieldlost () , self . txframestart () , self . txframeend () , self . rxframestart () , self . rxframeend () , self . error () , self . rxerror () , self . endrx () , self . endtx () , self . autocolresstarted () , self . collision () , self . selected () , self . started ())
}
}
#[doc = "Size of the RAM buffer allocated to TXD and RXD data storage each."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Maxlen(pub u32);
impl Maxlen {
#[doc = "Size of the RAM buffer allocated to TXD and RXD data storage each."]
#[must_use]
#[inline(always)]
pub const fn maxlen(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x01ff;
val as u16
}
#[doc = "Size of the RAM buffer allocated to TXD and RXD data storage each."]
#[inline(always)]
pub const fn set_maxlen(&mut self, val: u16) {
self.0 = (self.0 & !(0x01ff << 0usize)) | (((val as u32) & 0x01ff) << 0usize);
}
}
impl Default for Maxlen {
#[inline(always)]
fn default() -> Maxlen {
Maxlen(0)
}
}
impl core::fmt::Debug for Maxlen {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Maxlen")
.field("maxlen", &self.maxlen())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Maxlen {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Maxlen {{ maxlen: {=u16:?} }}", self.maxlen())
}
}
#[doc = "Second last NFCID1 part (7 or 10 bytes ID)."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Nfcid12ndLast(pub u32);
impl Nfcid12ndLast {
#[doc = "NFCID1 byte V."]
#[must_use]
#[inline(always)]
pub const fn nfcid1_v(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "NFCID1 byte V."]
#[inline(always)]
pub const fn set_nfcid1_v(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
#[doc = "NFCID1 byte U."]
#[must_use]
#[inline(always)]
pub const fn nfcid1_u(&self) -> u8 {
let val = (self.0 >> 8usize) & 0xff;
val as u8
}
#[doc = "NFCID1 byte U."]
#[inline(always)]
pub const fn set_nfcid1_u(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 8usize)) | (((val as u32) & 0xff) << 8usize);
}
#[doc = "NFCID1 byte T."]
#[must_use]
#[inline(always)]
pub const fn nfcid1_t(&self) -> u8 {
let val = (self.0 >> 16usize) & 0xff;
val as u8
}
#[doc = "NFCID1 byte T."]
#[inline(always)]
pub const fn set_nfcid1_t(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 16usize)) | (((val as u32) & 0xff) << 16usize);
}
}
impl Default for Nfcid12ndLast {
#[inline(always)]
fn default() -> Nfcid12ndLast {
Nfcid12ndLast(0)
}
}
impl core::fmt::Debug for Nfcid12ndLast {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Nfcid12ndLast")
.field("nfcid1_v", &self.nfcid1_v())
.field("nfcid1_u", &self.nfcid1_u())
.field("nfcid1_t", &self.nfcid1_t())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Nfcid12ndLast {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Nfcid12ndLast {{ nfcid1_v: {=u8:?}, nfcid1_u: {=u8:?}, nfcid1_t: {=u8:?} }}",
self.nfcid1_v(),
self.nfcid1_u(),
self.nfcid1_t()
)
}
}
#[doc = "Third last NFCID1 part (10 bytes ID)."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Nfcid13rdLast(pub u32);
impl Nfcid13rdLast {
#[doc = "NFCID1 byte S."]
#[must_use]
#[inline(always)]
pub const fn nfcid1_s(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "NFCID1 byte S."]
#[inline(always)]
pub const fn set_nfcid1_s(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
#[doc = "NFCID1 byte R."]
#[must_use]
#[inline(always)]
pub const fn nfcid1_r(&self) -> u8 {
let val = (self.0 >> 8usize) & 0xff;
val as u8
}
#[doc = "NFCID1 byte R."]
#[inline(always)]
pub const fn set_nfcid1_r(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 8usize)) | (((val as u32) & 0xff) << 8usize);
}
#[doc = "NFCID1 byte Q."]
#[must_use]
#[inline(always)]
pub const fn nfcid1_q(&self) -> u8 {
let val = (self.0 >> 16usize) & 0xff;
val as u8
}
#[doc = "NFCID1 byte Q."]
#[inline(always)]
pub const fn set_nfcid1_q(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 16usize)) | (((val as u32) & 0xff) << 16usize);
}
}
impl Default for Nfcid13rdLast {
#[inline(always)]
fn default() -> Nfcid13rdLast {
Nfcid13rdLast(0)
}
}
impl core::fmt::Debug for Nfcid13rdLast {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Nfcid13rdLast")
.field("nfcid1_s", &self.nfcid1_s())
.field("nfcid1_r", &self.nfcid1_r())
.field("nfcid1_q", &self.nfcid1_q())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Nfcid13rdLast {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Nfcid13rdLast {{ nfcid1_s: {=u8:?}, nfcid1_r: {=u8:?}, nfcid1_q: {=u8:?} }}",
self.nfcid1_s(),
self.nfcid1_r(),
self.nfcid1_q()
)
}
}
#[doc = "Last NFCID1 part (4, 7 or 10 bytes ID)."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Nfcid1Last(pub u32);
impl Nfcid1Last {
#[doc = "NFCID1 byte Z (very last byte sent)."]
#[must_use]
#[inline(always)]
pub const fn nfcid1_z(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "NFCID1 byte Z (very last byte sent)."]
#[inline(always)]
pub const fn set_nfcid1_z(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
#[doc = "NFCID1 byte Y."]
#[must_use]
#[inline(always)]
pub const fn nfcid1_y(&self) -> u8 {
let val = (self.0 >> 8usize) & 0xff;
val as u8
}
#[doc = "NFCID1 byte Y."]
#[inline(always)]
pub const fn set_nfcid1_y(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 8usize)) | (((val as u32) & 0xff) << 8usize);
}
#[doc = "NFCID1 byte X."]
#[must_use]
#[inline(always)]
pub const fn nfcid1_x(&self) -> u8 {
let val = (self.0 >> 16usize) & 0xff;
val as u8
}
#[doc = "NFCID1 byte X."]
#[inline(always)]
pub const fn set_nfcid1_x(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 16usize)) | (((val as u32) & 0xff) << 16usize);
}
#[doc = "NFCID1 byte W."]
#[must_use]
#[inline(always)]
pub const fn nfcid1_w(&self) -> u8 {
let val = (self.0 >> 24usize) & 0xff;
val as u8
}
#[doc = "NFCID1 byte W."]
#[inline(always)]
pub const fn set_nfcid1_w(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 24usize)) | (((val as u32) & 0xff) << 24usize);
}
}
impl Default for Nfcid1Last {
#[inline(always)]
fn default() -> Nfcid1Last {
Nfcid1Last(0)
}
}
impl core::fmt::Debug for Nfcid1Last {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Nfcid1Last")
.field("nfcid1_z", &self.nfcid1_z())
.field("nfcid1_y", &self.nfcid1_y())
.field("nfcid1_x", &self.nfcid1_x())
.field("nfcid1_w", &self.nfcid1_w())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Nfcid1Last {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Nfcid1Last {{ nfcid1_z: {=u8:?}, nfcid1_y: {=u8:?}, nfcid1_x: {=u8:?}, nfcid1_w: {=u8:?} }}" , self . nfcid1_z () , self . nfcid1_y () , self . nfcid1_x () , self . nfcid1_w ())
}
}
#[doc = "NfcTag state register."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Nfctagstate(pub u32);
impl Nfctagstate {
#[doc = "NfcTag state."]
#[must_use]
#[inline(always)]
pub const fn nfctagstate(&self) -> super::vals::Nfctagstate {
let val = (self.0 >> 0usize) & 0x07;
super::vals::Nfctagstate::from_bits(val as u8)
}
#[doc = "NfcTag state."]
#[inline(always)]
pub const fn set_nfctagstate(&mut self, val: super::vals::Nfctagstate) {
self.0 = (self.0 & !(0x07 << 0usize)) | (((val.to_bits() as u32) & 0x07) << 0usize);
}
}
impl Default for Nfctagstate {
#[inline(always)]
fn default() -> Nfctagstate {
Nfctagstate(0)
}
}
impl core::fmt::Debug for Nfctagstate {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Nfctagstate")
.field("nfctagstate", &self.nfctagstate())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Nfctagstate {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Nfctagstate {{ nfctagstate: {:?} }}", self.nfctagstate())
}
}
#[doc = "Result of last incoming frame."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Rx(pub u32);
impl Rx {
#[doc = "No valid end of frame (EoF) detected."]
#[must_use]
#[inline(always)]
pub const fn crcerror(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "No valid end of frame (EoF) detected."]
#[inline(always)]
pub const fn set_crcerror(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Parity status of received frame."]
#[must_use]
#[inline(always)]
pub const fn paritystatus(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Parity status of received frame."]
#[inline(always)]
pub const fn set_paritystatus(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "Overrun detected."]
#[must_use]
#[inline(always)]
pub const fn overrun(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "Overrun detected."]
#[inline(always)]
pub const fn set_overrun(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
}
impl Default for Rx {
#[inline(always)]
fn default() -> Rx {
Rx(0)
}
}
impl core::fmt::Debug for Rx {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Rx")
.field("crcerror", &self.crcerror())
.field("paritystatus", &self.paritystatus())
.field("overrun", &self.overrun())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Rx {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Rx {{ crcerror: {=bool:?}, paritystatus: {=bool:?}, overrun: {=bool:?} }}",
self.crcerror(),
self.paritystatus(),
self.overrun()
)
}
}
#[doc = "Size of last incoming frame."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct RxdAmount(pub u32);
impl RxdAmount {
#[doc = "Number of bits in the last byte in the frame, if less than 8 (including CRC, but excluding parity and SoF/EoF framing)."]
#[must_use]
#[inline(always)]
pub const fn rxdatabits(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x07;
val as u8
}
#[doc = "Number of bits in the last byte in the frame, if less than 8 (including CRC, but excluding parity and SoF/EoF framing)."]
#[inline(always)]
pub const fn set_rxdatabits(&mut self, val: u8) {
self.0 = (self.0 & !(0x07 << 0usize)) | (((val as u32) & 0x07) << 0usize);
}
#[doc = "Number of complete bytes received in the frame (including CRC, but excluding parity and SoF/EoF framing)."]
#[must_use]
#[inline(always)]
pub const fn rxdatabytes(&self) -> u16 {
let val = (self.0 >> 3usize) & 0x01ff;
val as u16
}
#[doc = "Number of complete bytes received in the frame (including CRC, but excluding parity and SoF/EoF framing)."]
#[inline(always)]
pub const fn set_rxdatabytes(&mut self, val: u16) {
self.0 = (self.0 & !(0x01ff << 3usize)) | (((val as u32) & 0x01ff) << 3usize);
}
}
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("rxdatabits", &self.rxdatabits())
.field("rxdatabytes", &self.rxdatabytes())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for RxdAmount {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"RxdAmount {{ rxdatabits: {=u8:?}, rxdatabytes: {=u16:?} }}",
self.rxdatabits(),
self.rxdatabytes()
)
}
}
#[doc = "Configuration of incoming frames."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct RxdFrameconfig(pub u32);
impl RxdFrameconfig {
#[doc = "Indicates if parity expected in RX frame."]
#[must_use]
#[inline(always)]
pub const fn parity(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Indicates if parity expected in RX frame."]
#[inline(always)]
pub const fn set_parity(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "SoF expected or not in RX frames."]
#[must_use]
#[inline(always)]
pub const fn sof(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "SoF expected or not in RX frames."]
#[inline(always)]
pub const fn set_sof(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "CRC mode for incoming frames."]
#[must_use]
#[inline(always)]
pub const fn crcmoderx(&self) -> bool {
let val = (self.0 >> 4usize) & 0x01;
val != 0
}
#[doc = "CRC mode for incoming frames."]
#[inline(always)]
pub const fn set_crcmoderx(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
}
}
impl Default for RxdFrameconfig {
#[inline(always)]
fn default() -> RxdFrameconfig {
RxdFrameconfig(0)
}
}
impl core::fmt::Debug for RxdFrameconfig {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("RxdFrameconfig")
.field("parity", &self.parity())
.field("sof", &self.sof())
.field("crcmoderx", &self.crcmoderx())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for RxdFrameconfig {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"RxdFrameconfig {{ parity: {=bool:?}, sof: {=bool:?}, crcmoderx: {=bool:?} }}",
self.parity(),
self.sof(),
self.crcmoderx()
)
}
}
#[doc = "NFC-A SEL_RES auto-response settings."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Selres(pub u32);
impl Selres {
#[doc = "Reserved for future use. Shall be 0."]
#[must_use]
#[inline(always)]
pub const fn rfu10(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x03;
val as u8
}
#[doc = "Reserved for future use. Shall be 0."]
#[inline(always)]
pub const fn set_rfu10(&mut self, val: u8) {
self.0 = (self.0 & !(0x03 << 0usize)) | (((val as u32) & 0x03) << 0usize);
}
#[doc = "Cascade as defined by the b3 of SEL_RES response in the NFC Forum, NFC Digital Protocol Technical Specification (controlled by hardware, shall be 0)."]
#[must_use]
#[inline(always)]
pub const fn cascade(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Cascade as defined by the b3 of SEL_RES response in the NFC Forum, NFC Digital Protocol Technical Specification (controlled by hardware, shall be 0)."]
#[inline(always)]
pub const fn set_cascade(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "Reserved for future use. Shall be 0."]
#[must_use]
#[inline(always)]
pub const fn rfu43(&self) -> u8 {
let val = (self.0 >> 3usize) & 0x03;
val as u8
}
#[doc = "Reserved for future use. Shall be 0."]
#[inline(always)]
pub const fn set_rfu43(&mut self, val: u8) {
self.0 = (self.0 & !(0x03 << 3usize)) | (((val as u32) & 0x03) << 3usize);
}
#[doc = "Protocol as defined by the b7:b6 of SEL_RES response in the NFC Forum, NFC Digital Protocol Technical Specification."]
#[must_use]
#[inline(always)]
pub const fn protocol(&self) -> u8 {
let val = (self.0 >> 5usize) & 0x03;
val as u8
}
#[doc = "Protocol as defined by the b7:b6 of SEL_RES response in the NFC Forum, NFC Digital Protocol Technical Specification."]
#[inline(always)]
pub const fn set_protocol(&mut self, val: u8) {
self.0 = (self.0 & !(0x03 << 5usize)) | (((val as u32) & 0x03) << 5usize);
}
#[doc = "Reserved for future use. Shall be 0."]
#[must_use]
#[inline(always)]
pub const fn rfu7(&self) -> bool {
let val = (self.0 >> 7usize) & 0x01;
val != 0
}
#[doc = "Reserved for future use. Shall be 0."]
#[inline(always)]
pub const fn set_rfu7(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize);
}
}
impl Default for Selres {
#[inline(always)]
fn default() -> Selres {
Selres(0)
}
}
impl core::fmt::Debug for Selres {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Selres")
.field("rfu10", &self.rfu10())
.field("cascade", &self.cascade())
.field("rfu43", &self.rfu43())
.field("protocol", &self.protocol())
.field("rfu7", &self.rfu7())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Selres {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Selres {{ rfu10: {=u8:?}, cascade: {=bool:?}, rfu43: {=u8:?}, protocol: {=u8:?}, rfu7: {=bool:?} }}" , self . rfu10 () , self . cascade () , self . rfu43 () , self . protocol () , self . rfu7 ())
}
}
#[doc = "NFC-A SENS_RES auto-response settings."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Sensres(pub u32);
impl Sensres {
#[doc = "Bit frame SDD as defined by the b5:b1 of byte 1 in SENS_RES response in the NFC Forum, NFC Digital Protocol Technical Specification."]
#[must_use]
#[inline(always)]
pub const fn bitframesdd(&self) -> super::vals::Bitframesdd {
let val = (self.0 >> 0usize) & 0x1f;
super::vals::Bitframesdd::from_bits(val as u8)
}
#[doc = "Bit frame SDD as defined by the b5:b1 of byte 1 in SENS_RES response in the NFC Forum, NFC Digital Protocol Technical Specification."]
#[inline(always)]
pub const fn set_bitframesdd(&mut self, val: super::vals::Bitframesdd) {
self.0 = (self.0 & !(0x1f << 0usize)) | (((val.to_bits() as u32) & 0x1f) << 0usize);
}
#[doc = "Reserved for future use. Shall be 0."]
#[must_use]
#[inline(always)]
pub const fn rfu5(&self) -> bool {
let val = (self.0 >> 5usize) & 0x01;
val != 0
}
#[doc = "Reserved for future use. Shall be 0."]
#[inline(always)]
pub const fn set_rfu5(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
}
#[doc = "NFCID1 size. This value is used by the auto collision resolution engine."]
#[must_use]
#[inline(always)]
pub const fn nfcidsize(&self) -> super::vals::Nfcidsize {
let val = (self.0 >> 6usize) & 0x03;
super::vals::Nfcidsize::from_bits(val as u8)
}
#[doc = "NFCID1 size. This value is used by the auto collision resolution engine."]
#[inline(always)]
pub const fn set_nfcidsize(&mut self, val: super::vals::Nfcidsize) {
self.0 = (self.0 & !(0x03 << 6usize)) | (((val.to_bits() as u32) & 0x03) << 6usize);
}
#[doc = "Tag platform configuration as defined by the b4:b1 of byte 2 in SENS_RES response in the NFC Forum, NFC Digital Protocol Technical Specification."]
#[must_use]
#[inline(always)]
pub const fn platfconfig(&self) -> u8 {
let val = (self.0 >> 8usize) & 0x0f;
val as u8
}
#[doc = "Tag platform configuration as defined by the b4:b1 of byte 2 in SENS_RES response in the NFC Forum, NFC Digital Protocol Technical Specification."]
#[inline(always)]
pub const fn set_platfconfig(&mut self, val: u8) {
self.0 = (self.0 & !(0x0f << 8usize)) | (((val as u32) & 0x0f) << 8usize);
}
#[doc = "Reserved for future use. Shall be 0."]
#[must_use]
#[inline(always)]
pub const fn rfu74(&self) -> u8 {
let val = (self.0 >> 12usize) & 0x0f;
val as u8
}
#[doc = "Reserved for future use. Shall be 0."]
#[inline(always)]
pub const fn set_rfu74(&mut self, val: u8) {
self.0 = (self.0 & !(0x0f << 12usize)) | (((val as u32) & 0x0f) << 12usize);
}
}
impl Default for Sensres {
#[inline(always)]
fn default() -> Sensres {
Sensres(0)
}
}
impl core::fmt::Debug for Sensres {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Sensres")
.field("bitframesdd", &self.bitframesdd())
.field("rfu5", &self.rfu5())
.field("nfcidsize", &self.nfcidsize())
.field("platfconfig", &self.platfconfig())
.field("rfu74", &self.rfu74())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Sensres {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Sensres {{ bitframesdd: {:?}, rfu5: {=bool:?}, nfcidsize: {:?}, platfconfig: {=u8:?}, rfu74: {=u8:?} }}" , self . bitframesdd () , self . rfu5 () , self . nfcidsize () , self . platfconfig () , self . rfu74 ())
}
}
#[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 FIELDDETECTED and task ACTIVATE."]
#[must_use]
#[inline(always)]
pub const fn fielddetected_activate(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event FIELDDETECTED and task ACTIVATE."]
#[inline(always)]
pub const fn set_fielddetected_activate(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Shortcut between event FIELDLOST and task SENSE."]
#[must_use]
#[inline(always)]
pub const fn fieldlost_sense(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event FIELDLOST and task SENSE."]
#[inline(always)]
pub const fn set_fieldlost_sense(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "Shortcut between event TXFRAMEEND and task ENABLERXDATA."]
#[must_use]
#[inline(always)]
pub const fn txframeend_enablerxdata(&self) -> bool {
let val = (self.0 >> 5usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event TXFRAMEEND and task ENABLERXDATA."]
#[inline(always)]
pub const fn set_txframeend_enablerxdata(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
}
}
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("fielddetected_activate", &self.fielddetected_activate())
.field("fieldlost_sense", &self.fieldlost_sense())
.field("txframeend_enablerxdata", &self.txframeend_enablerxdata())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Shorts {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Shorts {{ fielddetected_activate: {=bool:?}, fieldlost_sense: {=bool:?}, txframeend_enablerxdata: {=bool:?} }}" , self . fielddetected_activate () , self . fieldlost_sense () , self . txframeend_enablerxdata ())
}
}
#[doc = "Sleep state during automatic collision resolution."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Sleepstate(pub u32);
impl Sleepstate {
#[doc = "Reflects the sleep state during automatic collision resolution. Set to IDLE by a GOIDLE task. Set to SLEEP_A when a valid SLEEP_REQ frame is received or by a GOSLEEP task."]
#[must_use]
#[inline(always)]
pub const fn sleepstate(&self) -> super::vals::Sleepstate {
let val = (self.0 >> 0usize) & 0x01;
super::vals::Sleepstate::from_bits(val as u8)
}
#[doc = "Reflects the sleep state during automatic collision resolution. Set to IDLE by a GOIDLE task. Set to SLEEP_A when a valid SLEEP_REQ frame is received or by a GOSLEEP task."]
#[inline(always)]
pub const fn set_sleepstate(&mut self, val: super::vals::Sleepstate) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
}
impl Default for Sleepstate {
#[inline(always)]
fn default() -> Sleepstate {
Sleepstate(0)
}
}
impl core::fmt::Debug for Sleepstate {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Sleepstate")
.field("sleepstate", &self.sleepstate())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Sleepstate {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Sleepstate {{ sleepstate: {:?} }}", self.sleepstate())
}
}
#[doc = "Size of outgoing frame."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct TxdAmount(pub u32);
impl TxdAmount {
#[doc = "Number of bits in the last or first byte read from RAM that shall be included in the frame (excluding parity bit)."]
#[must_use]
#[inline(always)]
pub const fn txdatabits(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x07;
val as u8
}
#[doc = "Number of bits in the last or first byte read from RAM that shall be included in the frame (excluding parity bit)."]
#[inline(always)]
pub const fn set_txdatabits(&mut self, val: u8) {
self.0 = (self.0 & !(0x07 << 0usize)) | (((val as u32) & 0x07) << 0usize);
}
#[doc = "Number of complete bytes that shall be included in the frame, excluding CRC, parity and framing."]
#[must_use]
#[inline(always)]
pub const fn txdatabytes(&self) -> u16 {
let val = (self.0 >> 3usize) & 0x01ff;
val as u16
}
#[doc = "Number of complete bytes that shall be included in the frame, excluding CRC, parity and framing."]
#[inline(always)]
pub const fn set_txdatabytes(&mut self, val: u16) {
self.0 = (self.0 & !(0x01ff << 3usize)) | (((val as u32) & 0x01ff) << 3usize);
}
}
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("txdatabits", &self.txdatabits())
.field("txdatabytes", &self.txdatabytes())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for TxdAmount {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"TxdAmount {{ txdatabits: {=u8:?}, txdatabytes: {=u16:?} }}",
self.txdatabits(),
self.txdatabytes()
)
}
}
#[doc = "Configuration of outgoing frames."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct TxdFrameconfig(pub u32);
impl TxdFrameconfig {
#[doc = "Indicates if parity is added to the frame."]
#[must_use]
#[inline(always)]
pub const fn parity(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Indicates if parity is added to the frame."]
#[inline(always)]
pub const fn set_parity(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Discarding unused bits at start or end of a frame."]
#[must_use]
#[inline(always)]
pub const fn discardmode(&self) -> super::vals::Discardmode {
let val = (self.0 >> 1usize) & 0x01;
super::vals::Discardmode::from_bits(val as u8)
}
#[doc = "Discarding unused bits at start or end of a frame."]
#[inline(always)]
pub const fn set_discardmode(&mut self, val: super::vals::Discardmode) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val.to_bits() as u32) & 0x01) << 1usize);
}
#[doc = "Adding SoF or not in TX frames."]
#[must_use]
#[inline(always)]
pub const fn sof(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Adding SoF or not in TX frames."]
#[inline(always)]
pub const fn set_sof(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "CRC mode for outgoing frames."]
#[must_use]
#[inline(always)]
pub const fn crcmodetx(&self) -> bool {
let val = (self.0 >> 4usize) & 0x01;
val != 0
}
#[doc = "CRC mode for outgoing frames."]
#[inline(always)]
pub const fn set_crcmodetx(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
}
}
impl Default for TxdFrameconfig {
#[inline(always)]
fn default() -> TxdFrameconfig {
TxdFrameconfig(0)
}
}
impl core::fmt::Debug for TxdFrameconfig {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("TxdFrameconfig")
.field("parity", &self.parity())
.field("discardmode", &self.discardmode())
.field("sof", &self.sof())
.field("crcmodetx", &self.crcmodetx())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for TxdFrameconfig {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "TxdFrameconfig {{ parity: {=bool:?}, discardmode: {:?}, sof: {=bool:?}, crcmodetx: {=bool:?} }}" , self . parity () , self . discardmode () , self . sof () , self . crcmodetx ())
}
}
}
pub mod vals {
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Bitframesdd {
#[doc = "SDD pattern 00000."]
Sdd00000 = 0x0,
#[doc = "SDD pattern 00001."]
Sdd00001 = 0x01,
#[doc = "SDD pattern 00010."]
Sdd00010 = 0x02,
_RESERVED_3 = 0x03,
#[doc = "SDD pattern 00100."]
Sdd00100 = 0x04,
_RESERVED_5 = 0x05,
_RESERVED_6 = 0x06,
_RESERVED_7 = 0x07,
#[doc = "SDD pattern 01000."]
Sdd01000 = 0x08,
_RESERVED_9 = 0x09,
_RESERVED_a = 0x0a,
_RESERVED_b = 0x0b,
_RESERVED_c = 0x0c,
_RESERVED_d = 0x0d,
_RESERVED_e = 0x0e,
_RESERVED_f = 0x0f,
#[doc = "SDD pattern 10000."]
Sdd10000 = 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 Bitframesdd {
#[inline(always)]
pub const fn from_bits(val: u8) -> Bitframesdd {
unsafe { core::mem::transmute(val & 0x1f) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Bitframesdd {
#[inline(always)]
fn from(val: u8) -> Bitframesdd {
Bitframesdd::from_bits(val)
}
}
impl From<Bitframesdd> for u8 {
#[inline(always)]
fn from(val: Bitframesdd) -> u8 {
Bitframesdd::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Discardmode {
#[doc = "Unused bits are discarded at end of frame (EoF)."]
DiscardEnd = 0x0,
#[doc = "Unused bits are discarded at start of frame (SoF)."]
DiscardStart = 0x01,
}
impl Discardmode {
#[inline(always)]
pub const fn from_bits(val: u8) -> Discardmode {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Discardmode {
#[inline(always)]
fn from(val: u8) -> Discardmode {
Discardmode::from_bits(val)
}
}
impl From<Discardmode> for u8 {
#[inline(always)]
fn from(val: Discardmode) -> u8 {
Discardmode::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Framedelaymode {
#[doc = "Transmission is independent of frame timer and will start when the STARTTX task is triggered. No timeout."]
FreeRun = 0x0,
#[doc = "Frame is transmitted between FRAMEDELAYMIN and FRAMEDELAYMAX."]
Window = 0x01,
#[doc = "Frame is transmitted exactly at FRAMEDELAYMAX."]
ExactVal = 0x02,
#[doc = "Frame is transmitted on a bit grid between FRAMEDELAYMIN and FRAMEDELAYMAX."]
WindowGrid = 0x03,
}
impl Framedelaymode {
#[inline(always)]
pub const fn from_bits(val: u8) -> Framedelaymode {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Framedelaymode {
#[inline(always)]
fn from(val: u8) -> Framedelaymode {
Framedelaymode::from_bits(val)
}
}
impl From<Framedelaymode> for u8 {
#[inline(always)]
fn from(val: Framedelaymode) -> u8 {
Framedelaymode::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Mode {
#[doc = "Auto collision resolution enabled."]
Enabled = 0x0,
#[doc = "Auto collision resolution disabled."]
Disabled = 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 Nfcidsize {
#[doc = "NFCID1 size: single (4 bytes)."]
Nfcid1single = 0x0,
#[doc = "NFCID1 size: double (7 bytes)."]
Nfcid1double = 0x01,
#[doc = "NFCID1 size: triple (10 bytes)."]
Nfcid1triple = 0x02,
_RESERVED_3 = 0x03,
}
impl Nfcidsize {
#[inline(always)]
pub const fn from_bits(val: u8) -> Nfcidsize {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Nfcidsize {
#[inline(always)]
fn from(val: u8) -> Nfcidsize {
Nfcidsize::from_bits(val)
}
}
impl From<Nfcidsize> for u8 {
#[inline(always)]
fn from(val: Nfcidsize) -> u8 {
Nfcidsize::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Nfctagstate {
#[doc = "Disabled or sense."]
Disabled = 0x0,
_RESERVED_1 = 0x01,
#[doc = "RampUp."]
RampUp = 0x02,
#[doc = "Idle."]
Idle = 0x03,
#[doc = "Receive."]
Receive = 0x04,
#[doc = "FrameDelay."]
FrameDelay = 0x05,
#[doc = "Transmit."]
Transmit = 0x06,
_RESERVED_7 = 0x07,
}
impl Nfctagstate {
#[inline(always)]
pub const fn from_bits(val: u8) -> Nfctagstate {
unsafe { core::mem::transmute(val & 0x07) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Nfctagstate {
#[inline(always)]
fn from(val: u8) -> Nfctagstate {
Nfctagstate::from_bits(val)
}
}
impl From<Nfctagstate> for u8 {
#[inline(always)]
fn from(val: Nfctagstate) -> u8 {
Nfctagstate::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Sleepstate {
#[doc = "State is IDLE."]
Idle = 0x0,
#[doc = "State is SLEEP_A."]
SleepA = 0x01,
}
impl Sleepstate {
#[inline(always)]
pub const fn from_bits(val: u8) -> Sleepstate {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Sleepstate {
#[inline(always)]
fn from(val: u8) -> Sleepstate {
Sleepstate::from_bits(val)
}
}
impl From<Sleepstate> for u8 {
#[inline(always)]
fn from(val: Sleepstate) -> u8 {
Sleepstate::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 = "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 = "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 _) }
}
#[doc = "I-code cache configuration register."]
#[inline(always)]
pub const fn icachecnf(self) -> crate::common::Reg<regs::Icachecnf, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0540usize) as _) }
}
#[doc = "I-code cache hit counter."]
#[inline(always)]
pub const fn ihit(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0548usize) as _) }
}
#[doc = "I-code cache miss counter."]
#[inline(always)]
pub const fn imiss(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x054cusize) 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. Enabling write or erase will invalidate the cache and keep it invalidated."]
#[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. Enabling write or erase will invalidate the cache and keep it invalidated."]
#[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 = "I-code cache configuration register."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Icachecnf(pub u32);
impl Icachecnf {
#[doc = "Cache enable."]
#[must_use]
#[inline(always)]
pub const fn cacheen(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Cache enable."]
#[inline(always)]
pub const fn set_cacheen(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Cache profiling enable."]
#[must_use]
#[inline(always)]
pub const fn cacheprofen(&self) -> bool {
let val = (self.0 >> 8usize) & 0x01;
val != 0
}
#[doc = "Cache profiling enable."]
#[inline(always)]
pub const fn set_cacheprofen(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize);
}
}
impl Default for Icachecnf {
#[inline(always)]
fn default() -> Icachecnf {
Icachecnf(0)
}
}
impl core::fmt::Debug for Icachecnf {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Icachecnf")
.field("cacheen", &self.cacheen())
.field("cacheprofen", &self.cacheprofen())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Icachecnf {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Icachecnf {{ cacheen: {=bool:?}, cacheprofen: {=bool:?} }}",
self.cacheen(),
self.cacheprofen()
)
}
}
#[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 pdm {
#[doc = "Pulse Density Modulation (Digital Microphone) Interface."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Pdm {
ptr: *mut u8,
}
unsafe impl Send for Pdm {}
unsafe impl Sync for Pdm {}
impl Pdm {
#[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 = "Starts continuous PDM transfer."]
#[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 = "Stops PDM transfer."]
#[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 = "PDM transfer has 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(0x0100usize) as _) }
}
#[doc = "PDM transfer has finished."]
#[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 = "The PDM has written the last sample specified by SAMPLE.MAXCNT (or the last sample after a STOP task has been received) to Data RAM."]
#[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(0x0108usize) 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 = "PDM module enable register."]
#[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 = "PDM clock generator control."]
#[inline(always)]
pub const fn pdmclkctrl(self) -> crate::common::Reg<regs::Pdmclkctrl, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0504usize) as _) }
}
#[doc = "Defines the routing of the connected PDM microphones' signals."]
#[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(0x0508usize) as _) }
}
#[doc = "Left output gain adjustment."]
#[inline(always)]
pub const fn gainl(self) -> crate::common::Reg<regs::Gainl, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0518usize) as _) }
}
#[doc = "Right output gain adjustment."]
#[inline(always)]
pub const fn gainr(self) -> crate::common::Reg<regs::Gainr, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x051cusize) as _) }
}
#[doc = "Selects the ratio between PDM_CLK and output sample rate. Change PDMCLKCTRL accordingly."]
#[inline(always)]
pub const fn ratio(self) -> crate::common::Reg<regs::Ratio, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0520usize) as _) }
}
#[doc = "Unspecified."]
#[inline(always)]
pub const fn psel(self) -> Psel {
unsafe { Psel::from_ptr(self.ptr.wrapping_add(0x0540usize) as _) }
}
#[doc = "Unspecified."]
#[inline(always)]
pub const fn sample(self) -> Sample {
unsafe { Sample::from_ptr(self.ptr.wrapping_add(0x0560usize) 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 number configuration for PDM CLK signal."]
#[inline(always)]
pub const fn clk(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 number configuration for PDM DIN signal."]
#[inline(always)]
pub const fn din(self) -> crate::common::Reg<super::shared::regs::Psel, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
}
#[doc = "Unspecified."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Sample {
ptr: *mut u8,
}
unsafe impl Send for Sample {}
unsafe impl Sync for Sample {}
impl Sample {
#[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 = "RAM address pointer to write samples to with EasyDMA."]
#[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 samples to allocate memory for in EasyDMA mode."]
#[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 _) }
}
}
pub mod regs {
#[doc = "PDM module enable register."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Enable(pub u32);
impl Enable {
#[doc = "Enable or disable PDM module."]
#[must_use]
#[inline(always)]
pub const fn enable(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Enable or disable PDM module."]
#[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 = "Left output gain adjustment."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Gainl(pub u32);
impl Gainl {
#[doc = "Left output gain adjustment, in 0.5 dB steps, around the default module gain (see electrical parameters) 0x00 -20 dB gain adjust 0x01 -19.5 dB gain adjust (...) 0x27 -0.5 dB gain adjust 0x28 0 dB gain adjust 0x29 +0.5 dB gain adjust (...) 0x4F +19.5 dB gain adjust 0x50 +20 dB gain adjust."]
#[must_use]
#[inline(always)]
pub const fn gainl(&self) -> super::vals::Gain {
let val = (self.0 >> 0usize) & 0x7f;
super::vals::Gain::from_bits(val as u8)
}
#[doc = "Left output gain adjustment, in 0.5 dB steps, around the default module gain (see electrical parameters) 0x00 -20 dB gain adjust 0x01 -19.5 dB gain adjust (...) 0x27 -0.5 dB gain adjust 0x28 0 dB gain adjust 0x29 +0.5 dB gain adjust (...) 0x4F +19.5 dB gain adjust 0x50 +20 dB gain adjust."]
#[inline(always)]
pub const fn set_gainl(&mut self, val: super::vals::Gain) {
self.0 = (self.0 & !(0x7f << 0usize)) | (((val.to_bits() as u32) & 0x7f) << 0usize);
}
}
impl Default for Gainl {
#[inline(always)]
fn default() -> Gainl {
Gainl(0)
}
}
impl core::fmt::Debug for Gainl {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Gainl")
.field("gainl", &self.gainl())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Gainl {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Gainl {{ gainl: {:?} }}", self.gainl())
}
}
#[doc = "Right output gain adjustment."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Gainr(pub u32);
impl Gainr {
#[doc = "Right output gain adjustment, in 0.5 dB steps, around the default module gain (see electrical parameters)."]
#[must_use]
#[inline(always)]
pub const fn gainr(&self) -> super::vals::Gain {
let val = (self.0 >> 0usize) & 0x7f;
super::vals::Gain::from_bits(val as u8)
}
#[doc = "Right output gain adjustment, in 0.5 dB steps, around the default module gain (see electrical parameters)."]
#[inline(always)]
pub const fn set_gainr(&mut self, val: super::vals::Gain) {
self.0 = (self.0 & !(0x7f << 0usize)) | (((val.to_bits() as u32) & 0x7f) << 0usize);
}
}
impl Default for Gainr {
#[inline(always)]
fn default() -> Gainr {
Gainr(0)
}
}
impl core::fmt::Debug for Gainr {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Gainr")
.field("gainr", &self.gainr())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Gainr {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Gainr {{ gainr: {:?} }}", self.gainr())
}
}
#[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 STARTED."]
#[must_use]
#[inline(always)]
pub const fn started(&self) -> bool {
let val = (self.0 >> 0usize) & 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 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[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 END."]
#[must_use]
#[inline(always)]
pub const fn end(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event END."]
#[inline(always)]
pub const fn set_end(&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("started", &self.started())
.field("stopped", &self.stopped())
.field("end", &self.end())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Int {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Int {{ started: {=bool:?}, stopped: {=bool:?}, end: {=bool:?} }}",
self.started(),
self.stopped(),
self.end()
)
}
}
#[doc = "Number of samples to allocate memory for in EasyDMA mode."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Maxcnt(pub u32);
impl Maxcnt {
#[doc = "Length of DMA RAM allocation in number of samples."]
#[must_use]
#[inline(always)]
pub const fn buffsize(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x7fff;
val as u16
}
#[doc = "Length of DMA RAM allocation in number of samples."]
#[inline(always)]
pub const fn set_buffsize(&mut self, val: u16) {
self.0 = (self.0 & !(0x7fff << 0usize)) | (((val as u32) & 0x7fff) << 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("buffsize", &self.buffsize())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Maxcnt {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Maxcnt {{ buffsize: {=u16:?} }}", self.buffsize())
}
}
#[doc = "Defines the routing of the connected PDM microphones' signals."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Mode(pub u32);
impl Mode {
#[doc = "Mono or stereo operation."]
#[must_use]
#[inline(always)]
pub const fn operation(&self) -> super::vals::Operation {
let val = (self.0 >> 0usize) & 0x01;
super::vals::Operation::from_bits(val as u8)
}
#[doc = "Mono or stereo operation."]
#[inline(always)]
pub const fn set_operation(&mut self, val: super::vals::Operation) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
#[doc = "Defines on which PDM_CLK edge left (or mono) is sampled."]
#[must_use]
#[inline(always)]
pub const fn edge(&self) -> super::vals::Edge {
let val = (self.0 >> 1usize) & 0x01;
super::vals::Edge::from_bits(val as u8)
}
#[doc = "Defines on which PDM_CLK edge left (or mono) is sampled."]
#[inline(always)]
pub const fn set_edge(&mut self, val: super::vals::Edge) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val.to_bits() as u32) & 0x01) << 1usize);
}
}
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("operation", &self.operation())
.field("edge", &self.edge())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Mode {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Mode {{ operation: {:?}, edge: {:?} }}",
self.operation(),
self.edge()
)
}
}
#[doc = "PDM clock generator control."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Pdmclkctrl(pub u32);
impl Pdmclkctrl {
#[doc = "PDM_CLK frequency configuration."]
#[must_use]
#[inline(always)]
pub const fn freq(&self) -> super::vals::Freq {
let val = (self.0 >> 0usize) & 0xffff_ffff;
super::vals::Freq::from_bits(val as u32)
}
#[doc = "PDM_CLK frequency configuration."]
#[inline(always)]
pub const fn set_freq(&mut self, val: super::vals::Freq) {
self.0 = (self.0 & !(0xffff_ffff << 0usize))
| (((val.to_bits() as u32) & 0xffff_ffff) << 0usize);
}
}
impl Default for Pdmclkctrl {
#[inline(always)]
fn default() -> Pdmclkctrl {
Pdmclkctrl(0)
}
}
impl core::fmt::Debug for Pdmclkctrl {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Pdmclkctrl")
.field("freq", &self.freq())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Pdmclkctrl {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Pdmclkctrl {{ freq: {:?} }}", self.freq())
}
}
#[doc = "Selects the ratio between PDM_CLK and output sample rate. Change PDMCLKCTRL accordingly."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Ratio(pub u32);
impl Ratio {
#[doc = "Selects the ratio between PDM_CLK and output sample rate."]
#[must_use]
#[inline(always)]
pub const fn ratio(&self) -> super::vals::Ratio {
let val = (self.0 >> 0usize) & 0x01;
super::vals::Ratio::from_bits(val as u8)
}
#[doc = "Selects the ratio between PDM_CLK and output sample rate."]
#[inline(always)]
pub const fn set_ratio(&mut self, val: super::vals::Ratio) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
}
impl Default for Ratio {
#[inline(always)]
fn default() -> Ratio {
Ratio(0)
}
}
impl core::fmt::Debug for Ratio {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Ratio")
.field("ratio", &self.ratio())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Ratio {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Ratio {{ ratio: {:?} }}", self.ratio())
}
}
}
pub mod vals {
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Edge {
#[doc = "Left (or mono) is sampled on falling edge of PDM_CLK."]
LeftFalling = 0x0,
#[doc = "Left (or mono) is sampled on rising edge of PDM_CLK."]
LeftRising = 0x01,
}
impl Edge {
#[inline(always)]
pub const fn from_bits(val: u8) -> Edge {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Edge {
#[inline(always)]
fn from(val: u8) -> Edge {
Edge::from_bits(val)
}
}
impl From<Edge> for u8 {
#[inline(always)]
fn from(val: Edge) -> u8 {
Edge::to_bits(val)
}
}
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct Freq(u32);
impl Freq {
#[doc = "PDM_CLK = 32 MHz / 32 = 1.000 MHz."]
pub const _1000k: Self = Self(0x0800_0000);
#[doc = "PDM_CLK = 32 MHz / 31 = 1.032 MHz. Nominal clock for RATIO=Ratio64."]
pub const Default: Self = Self(0x0840_0000);
#[doc = "PDM_CLK = 32 MHz / 30 = 1.067 MHz."]
pub const _1067k: Self = Self(0x0880_0000);
#[doc = "PDM_CLK = 32 MHz / 26 = 1.231 MHz."]
pub const _1231k: Self = Self(0x0980_0000);
#[doc = "PDM_CLK = 32 MHz / 25 = 1.280 MHz. Nominal clock for RATIO=Ratio80."]
pub const _1280k: Self = Self(0x0a00_0000);
#[doc = "PDM_CLK = 32 MHz / 24 = 1.333 MHz."]
pub const _1333k: Self = Self(0x0a80_0000);
}
impl Freq {
pub const fn from_bits(val: u32) -> Freq {
Self(val & 0xffff_ffff)
}
pub const fn to_bits(self) -> u32 {
self.0
}
}
impl core::fmt::Debug for Freq {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self.0 {
0x0800_0000 => f.write_str("_1000k"),
0x0840_0000 => f.write_str("Default"),
0x0880_0000 => f.write_str("_1067k"),
0x0980_0000 => f.write_str("_1231k"),
0x0a00_0000 => f.write_str("_1280k"),
0x0a80_0000 => f.write_str("_1333k"),
other => core::write!(f, "0x{:02X}", other),
}
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Freq {
fn format(&self, f: defmt::Formatter) {
match self.0 {
0x0800_0000 => defmt::write!(f, "_1000k"),
0x0840_0000 => defmt::write!(f, "Default"),
0x0880_0000 => defmt::write!(f, "_1067k"),
0x0980_0000 => defmt::write!(f, "_1231k"),
0x0a00_0000 => defmt::write!(f, "_1280k"),
0x0a80_0000 => defmt::write!(f, "_1333k"),
other => defmt::write!(f, "0x{:02X}", other),
}
}
}
impl From<u32> for Freq {
#[inline(always)]
fn from(val: u32) -> Freq {
Freq::from_bits(val)
}
}
impl From<Freq> for u32 {
#[inline(always)]
fn from(val: Freq) -> u32 {
Freq::to_bits(val)
}
}
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct Gain(u8);
impl Gain {
#[doc = "-20 dB gain adjustment (minimum)."]
pub const MinGain: Self = Self(0x0);
#[doc = "0 dB gain adjustment."]
pub const DefaultGain: Self = Self(0x28);
#[doc = "+20 dB gain adjustment (maximum)."]
pub const MaxGain: Self = Self(0x50);
}
impl Gain {
pub const fn from_bits(val: u8) -> Gain {
Self(val & 0x7f)
}
pub const fn to_bits(self) -> u8 {
self.0
}
}
impl core::fmt::Debug for Gain {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self.0 {
0x0 => f.write_str("MinGain"),
0x28 => f.write_str("DefaultGain"),
0x50 => f.write_str("MaxGain"),
other => core::write!(f, "0x{:02X}", other),
}
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Gain {
fn format(&self, f: defmt::Formatter) {
match self.0 {
0x0 => defmt::write!(f, "MinGain"),
0x28 => defmt::write!(f, "DefaultGain"),
0x50 => defmt::write!(f, "MaxGain"),
other => defmt::write!(f, "0x{:02X}", other),
}
}
}
impl From<u8> for Gain {
#[inline(always)]
fn from(val: u8) -> Gain {
Gain::from_bits(val)
}
}
impl From<Gain> for u8 {
#[inline(always)]
fn from(val: Gain) -> u8 {
Gain::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Operation {
#[doc = "Sample and store one pair (left + right) of 16-bit samples per RAM word R=\\[31:16\\]; L=\\[15:0\\]."]
Stereo = 0x0,
#[doc = "Sample and store two successive left samples (16 bits each) per RAM word L1=\\[31:16\\]; L0=\\[15:0\\]."]
Mono = 0x01,
}
impl Operation {
#[inline(always)]
pub const fn from_bits(val: u8) -> Operation {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Operation {
#[inline(always)]
fn from(val: u8) -> Operation {
Operation::from_bits(val)
}
}
impl From<Operation> for u8 {
#[inline(always)]
fn from(val: Operation) -> u8 {
Operation::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Ratio {
#[doc = "Ratio of 64."]
Ratio64 = 0x0,
#[doc = "Ratio of 80."]
Ratio80 = 0x01,
}
impl Ratio {
#[inline(always)]
pub const fn from_bits(val: u8) -> Ratio {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Ratio {
#[inline(always)]
fn from(val: u8) -> Ratio {
Ratio::from_bits(val)
}
}
impl From<Ratio> for u8 {
#[inline(always)]
fn from(val: Ratio) -> u8 {
Ratio::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 = "Enable DC/DC converter for REG0 stage."]
#[inline(always)]
pub const fn dcdcen0(self) -> crate::common::Reg<regs::Dcdcen0, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0580usize) 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 < 9usize);
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 = "Enable DC/DC converter for REG0 stage."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Dcdcen0(pub u32);
impl Dcdcen0 {
#[doc = "Enable DC/DC converter for REG0 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 REG0 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 Dcdcen0 {
#[inline(always)]
fn default() -> Dcdcen0 {
Dcdcen0(0)
}
}
impl core::fmt::Debug for Dcdcen0 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Dcdcen0")
.field("dcdcen", &self.dcdcen())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Dcdcen0 {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Dcdcen0 {{ 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 < 16usize);
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 < 16usize);
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 < 16usize);
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 < 16usize);
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_power[2]", &self.s_power(2usize))
.field("s_power[3]", &self.s_power(3usize))
.field("s_power[4]", &self.s_power(4usize))
.field("s_power[5]", &self.s_power(5usize))
.field("s_power[6]", &self.s_power(6usize))
.field("s_power[7]", &self.s_power(7usize))
.field("s_power[8]", &self.s_power(8usize))
.field("s_power[9]", &self.s_power(9usize))
.field("s_power[10]", &self.s_power(10usize))
.field("s_power[11]", &self.s_power(11usize))
.field("s_power[12]", &self.s_power(12usize))
.field("s_power[13]", &self.s_power(13usize))
.field("s_power[14]", &self.s_power(14usize))
.field("s_power[15]", &self.s_power(15usize))
.field("s_retention[0]", &self.s_retention(0usize))
.field("s_retention[1]", &self.s_retention(1usize))
.field("s_retention[2]", &self.s_retention(2usize))
.field("s_retention[3]", &self.s_retention(3usize))
.field("s_retention[4]", &self.s_retention(4usize))
.field("s_retention[5]", &self.s_retention(5usize))
.field("s_retention[6]", &self.s_retention(6usize))
.field("s_retention[7]", &self.s_retention(7usize))
.field("s_retention[8]", &self.s_retention(8usize))
.field("s_retention[9]", &self.s_retention(9usize))
.field("s_retention[10]", &self.s_retention(10usize))
.field("s_retention[11]", &self.s_retention(11usize))
.field("s_retention[12]", &self.s_retention(12usize))
.field("s_retention[13]", &self.s_retention(13usize))
.field("s_retention[14]", &self.s_retention(14usize))
.field("s_retention[15]", &self.s_retention(15usize))
.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_power[2]: {=bool:?}, s_power[3]: {=bool:?}, s_power[4]: {=bool:?}, s_power[5]: {=bool:?}, s_power[6]: {=bool:?}, s_power[7]: {=bool:?}, s_power[8]: {=bool:?}, s_power[9]: {=bool:?}, s_power[10]: {=bool:?}, s_power[11]: {=bool:?}, s_power[12]: {=bool:?}, s_power[13]: {=bool:?}, s_power[14]: {=bool:?}, s_power[15]: {=bool:?}, s_retention[0]: {=bool:?}, s_retention[1]: {=bool:?}, s_retention[2]: {=bool:?}, s_retention[3]: {=bool:?}, s_retention[4]: {=bool:?}, s_retention[5]: {=bool:?}, s_retention[6]: {=bool:?}, s_retention[7]: {=bool:?}, s_retention[8]: {=bool:?}, s_retention[9]: {=bool:?}, s_retention[10]: {=bool:?}, s_retention[11]: {=bool:?}, s_retention[12]: {=bool:?}, s_retention[13]: {=bool:?}, s_retention[14]: {=bool:?}, s_retention[15]: {=bool:?} }}" , self . s_power (0usize) , self . s_power (1usize) , self . s_power (2usize) , self . s_power (3usize) , self . s_power (4usize) , self . s_power (5usize) , self . s_power (6usize) , self . s_power (7usize) , self . s_power (8usize) , self . s_power (9usize) , self . s_power (10usize) , self . s_power (11usize) , self . s_power (12usize) , self . s_power (13usize) , self . s_power (14usize) , self . s_power (15usize) , self . s_retention (0usize) , self . s_retention (1usize) , self . s_retention (2usize) , self . s_retention (3usize) , self . s_retention (4usize) , self . s_retention (5usize) , self . s_retention (6usize) , self . s_retention (7usize) , self . s_retention (8usize) , self . s_retention (9usize) , self . s_retention (10usize) , self . s_retention (11usize) , self . s_retention (12usize) , self . s_retention (13usize) , self . s_retention (14usize) , self . s_retention (15usize))
}
}
#[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);
}
#[doc = "RAM block 2 is on or off/powering up."]
#[must_use]
#[inline(always)]
pub const fn ramblock2(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "RAM block 2 is on or off/powering up."]
#[inline(always)]
pub const fn set_ramblock2(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "RAM block 3 is on or off/powering up."]
#[must_use]
#[inline(always)]
pub const fn ramblock3(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "RAM block 3 is on or off/powering up."]
#[inline(always)]
pub const fn set_ramblock3(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
}
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())
.field("ramblock2", &self.ramblock2())
.field("ramblock3", &self.ramblock3())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Ramstatus {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Ramstatus {{ ramblock0: {=bool:?}, ramblock1: {=bool:?}, ramblock2: {=bool:?}, ramblock3: {=bool:?} }}" , self . ramblock0 () , self . ramblock1 () , self . ramblock2 () , self . ramblock3 ())
}
}
#[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 ANADETECT signal from LPCOMP."]
#[must_use]
#[inline(always)]
pub const fn lpcomp(&self) -> bool {
let val = (self.0 >> 17usize) & 0x01;
val != 0
}
#[doc = "Reset due to wake up from System OFF mode when wakeup is triggered from ANADETECT signal from LPCOMP."]
#[inline(always)]
pub const fn set_lpcomp(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 17usize)) | (((val as u32) & 0x01) << 17usize);
}
#[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 NFC field detect."]
#[must_use]
#[inline(always)]
pub const fn nfc(&self) -> bool {
let val = (self.0 >> 19usize) & 0x01;
val != 0
}
#[doc = "Reset due to wake up from System OFF mode by NFC field detect."]
#[inline(always)]
pub const fn set_nfc(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 19usize)) | (((val as u32) & 0x01) << 19usize);
}
#[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("lpcomp", &self.lpcomp())
.field("dif", &self.dif())
.field("nfc", &self.nfc())
.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:?}, lpcomp: {=bool:?}, dif: {=bool:?}, nfc: {=bool:?}, vbus: {=bool:?} }}" , self . resetpin () , self . dog () , self . sreq () , self . lockup () , self . off () , self . lpcomp () , self . dif () , self . nfc () , 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 pwm {
#[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 seq(self, n: usize) -> DmaSeq {
assert!(n < 2usize);
unsafe { DmaSeq::from_ptr(self.ptr.wrapping_add(0x0usize + n * 32usize) as _) }
}
}
#[doc = "Unspecified."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct DmaSeq {
ptr: *mut u8,
}
unsafe impl Send for DmaSeq {}
unsafe impl Sync for DmaSeq {}
impl DmaSeq {
#[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: Beginning address in RAM of this sequence."]
#[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: Number of values (duty cycles) in this sequence."]
#[inline(always)]
pub const fn maxcnt(self) -> crate::common::Reg<regs::Cnt, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Description cluster: Number of additional PWM periods between samples loaded into compare register."]
#[inline(always)]
pub const fn refresh(self) -> crate::common::Reg<regs::Refresh, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
#[doc = "Description cluster: Time added after the sequence."]
#[inline(always)]
pub const fn enddelay(self) -> crate::common::Reg<regs::Enddelay, 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 = "Description collection: Output pin select for PWM channel n."]
#[inline(always)]
pub const fn out(
self,
n: usize,
) -> crate::common::Reg<super::shared::regs::Psel, crate::common::RW> {
assert!(n < 4usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize + n * 4usize) as _)
}
}
}
#[doc = "Pulse width modulation unit 0."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Pwm {
ptr: *mut u8,
}
unsafe impl Send for Pwm {}
unsafe impl Sync for Pwm {}
impl Pwm {
#[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 = "Stops PWM pulse generation on all channels at the end of current PWM period, and stops sequence playback."]
#[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 _) }
}
#[inline(always)]
pub const fn tasks_dma(self) -> TasksDma {
unsafe { TasksDma::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
#[doc = "Steps by one value in the current sequence on all enabled channels if DECODER.MODE=NextStep. Does not cause PWM generation to start if not running."]
#[inline(always)]
pub const fn tasks_nextstep(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x10usize) as _) }
}
#[doc = "Response to STOP task, emitted when PWM pulses are no longer generated."]
#[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 = "Description collection: First PWM period started on sequence n."]
#[inline(always)]
pub const fn events_seqstarted(
self,
n: usize,
) -> crate::common::Reg<u32, crate::common::RW> {
assert!(n < 2usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0108usize + n * 4usize) as _)
}
}
#[doc = "Description collection: Emitted at end of every sequence n, when last value from RAM has been applied to wave counter."]
#[inline(always)]
pub const fn events_seqend(self, n: usize) -> crate::common::Reg<u32, crate::common::RW> {
assert!(n < 2usize);
unsafe {
crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0110usize + n * 4usize) as _)
}
}
#[doc = "Emitted at the end of each PWM period."]
#[inline(always)]
pub const fn events_pwmperiodend(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0118usize) as _) }
}
#[doc = "Concatenated sequences have been played the amount of times defined in LOOP.CNT."]
#[inline(always)]
pub const fn events_loopsdone(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x011cusize) 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 = "PWM module enable register."]
#[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 = "Selects operating mode of the wave counter."]
#[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 = "Value up to which the pulse generator counter counts."]
#[inline(always)]
pub const fn countertop(self) -> crate::common::Reg<regs::Countertop, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0508usize) as _) }
}
#[doc = "Configuration for PWM_CLK."]
#[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(0x050cusize) as _) }
}
#[doc = "Configuration of the decoder."]
#[inline(always)]
pub const fn decoder(self) -> crate::common::Reg<regs::Decoder, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0510usize) as _) }
}
#[doc = "Number of playbacks of a loop."]
#[inline(always)]
pub const fn loop_(self) -> crate::common::Reg<regs::Loop, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0514usize) as _) }
}
#[inline(always)]
pub const fn dma(self) -> Dma {
unsafe { Dma::from_ptr(self.ptr.wrapping_add(0x0520usize) as _) }
}
#[doc = "Unspecified."]
#[inline(always)]
pub const fn psel(self) -> Psel {
unsafe { Psel::from_ptr(self.ptr.wrapping_add(0x0560usize) 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 seq(self, n: usize) -> TasksDmaSeq {
assert!(n < 2usize);
unsafe { TasksDmaSeq::from_ptr(self.ptr.wrapping_add(0x0usize + n * 4usize) as _) }
}
}
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct TasksDmaSeq {
ptr: *mut u8,
}
unsafe impl Send for TasksDmaSeq {}
unsafe impl Sync for TasksDmaSeq {}
impl TasksDmaSeq {
#[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: Loads the first PWM value on all enabled channels from sequence n, and starts playing that sequence at the rate defined in SEQ\\[n\\]REFRESH and/or DECODER.MODE. Causes PWM generation to start if not running."]
#[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 _) }
}
}
pub mod regs {
#[doc = "Description cluster: Number of values (duty cycles) in this sequence."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Cnt(pub u32);
impl Cnt {
#[doc = "Number of values (duty cycles) in this sequence."]
#[must_use]
#[inline(always)]
pub const fn cnt(&self) -> super::vals::CntCnt {
let val = (self.0 >> 0usize) & 0x7fff;
super::vals::CntCnt::from_bits(val as u16)
}
#[doc = "Number of values (duty cycles) in this sequence."]
#[inline(always)]
pub const fn set_cnt(&mut self, val: super::vals::CntCnt) {
self.0 =
(self.0 & !(0x7fff << 0usize)) | (((val.to_bits() as u32) & 0x7fff) << 0usize);
}
}
impl Default for Cnt {
#[inline(always)]
fn default() -> Cnt {
Cnt(0)
}
}
impl core::fmt::Debug for Cnt {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Cnt").field("cnt", &self.cnt()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Cnt {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Cnt {{ cnt: {:?} }}", self.cnt())
}
}
#[doc = "Value up to which the pulse generator counter counts."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Countertop(pub u32);
impl Countertop {
#[doc = "Value up to which the pulse generator counter counts. This register is ignored when DECODER.MODE=WaveForm and only values from RAM are used."]
#[must_use]
#[inline(always)]
pub const fn countertop(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x7fff;
val as u16
}
#[doc = "Value up to which the pulse generator counter counts. This register is ignored when DECODER.MODE=WaveForm and only values from RAM are used."]
#[inline(always)]
pub const fn set_countertop(&mut self, val: u16) {
self.0 = (self.0 & !(0x7fff << 0usize)) | (((val as u32) & 0x7fff) << 0usize);
}
}
impl Default for Countertop {
#[inline(always)]
fn default() -> Countertop {
Countertop(0)
}
}
impl core::fmt::Debug for Countertop {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Countertop")
.field("countertop", &self.countertop())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Countertop {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Countertop {{ countertop: {=u16:?} }}",
self.countertop()
)
}
}
#[doc = "Configuration of the decoder."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Decoder(pub u32);
impl Decoder {
#[doc = "How a sequence is read from RAM and spread to the compare register."]
#[must_use]
#[inline(always)]
pub const fn load(&self) -> super::vals::Load {
let val = (self.0 >> 0usize) & 0x03;
super::vals::Load::from_bits(val as u8)
}
#[doc = "How a sequence is read from RAM and spread to the compare register."]
#[inline(always)]
pub const fn set_load(&mut self, val: super::vals::Load) {
self.0 = (self.0 & !(0x03 << 0usize)) | (((val.to_bits() as u32) & 0x03) << 0usize);
}
#[doc = "Selects source for advancing the active sequence."]
#[must_use]
#[inline(always)]
pub const fn mode(&self) -> super::vals::Mode {
let val = (self.0 >> 8usize) & 0x01;
super::vals::Mode::from_bits(val as u8)
}
#[doc = "Selects source for advancing the active sequence."]
#[inline(always)]
pub const fn set_mode(&mut self, val: super::vals::Mode) {
self.0 = (self.0 & !(0x01 << 8usize)) | (((val.to_bits() as u32) & 0x01) << 8usize);
}
}
impl Default for Decoder {
#[inline(always)]
fn default() -> Decoder {
Decoder(0)
}
}
impl core::fmt::Debug for Decoder {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Decoder")
.field("load", &self.load())
.field("mode", &self.mode())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Decoder {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Decoder {{ load: {:?}, mode: {:?} }}",
self.load(),
self.mode()
)
}
}
#[doc = "PWM module enable register."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Enable(pub u32);
impl Enable {
#[doc = "Enable or disable PWM module."]
#[must_use]
#[inline(always)]
pub const fn enable(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Enable or disable PWM module."]
#[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 = "Description cluster: Time added after the sequence."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Enddelay(pub u32);
impl Enddelay {
#[doc = "Time added after the sequence in PWM periods."]
#[must_use]
#[inline(always)]
pub const fn cnt(&self) -> u32 {
let val = (self.0 >> 0usize) & 0x00ff_ffff;
val as u32
}
#[doc = "Time added after the sequence in PWM periods."]
#[inline(always)]
pub const fn set_cnt(&mut self, val: u32) {
self.0 =
(self.0 & !(0x00ff_ffff << 0usize)) | (((val as u32) & 0x00ff_ffff) << 0usize);
}
}
impl Default for Enddelay {
#[inline(always)]
fn default() -> Enddelay {
Enddelay(0)
}
}
impl core::fmt::Debug for Enddelay {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Enddelay")
.field("cnt", &self.cnt())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Enddelay {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Enddelay {{ cnt: {=u32:?} }}", self.cnt())
}
}
#[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 SEQSTARTED\\[0\\]."]
#[must_use]
#[inline(always)]
pub const fn seqstarted0(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event SEQSTARTED\\[0\\]."]
#[inline(always)]
pub const fn set_seqstarted0(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "Enable or disable interrupt for event SEQSTARTED\\[1\\]."]
#[must_use]
#[inline(always)]
pub const fn seqstarted1(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event SEQSTARTED\\[1\\]."]
#[inline(always)]
pub const fn set_seqstarted1(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
#[doc = "Enable or disable interrupt for event SEQEND\\[0\\]."]
#[must_use]
#[inline(always)]
pub const fn seqend0(&self) -> bool {
let val = (self.0 >> 4usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event SEQEND\\[0\\]."]
#[inline(always)]
pub const fn set_seqend0(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
}
#[doc = "Enable or disable interrupt for event SEQEND\\[1\\]."]
#[must_use]
#[inline(always)]
pub const fn seqend1(&self) -> bool {
let val = (self.0 >> 5usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event SEQEND\\[1\\]."]
#[inline(always)]
pub const fn set_seqend1(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
}
#[doc = "Enable or disable interrupt for event PWMPERIODEND."]
#[must_use]
#[inline(always)]
pub const fn pwmperiodend(&self) -> bool {
let val = (self.0 >> 6usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event PWMPERIODEND."]
#[inline(always)]
pub const fn set_pwmperiodend(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize);
}
#[doc = "Enable or disable interrupt for event LOOPSDONE."]
#[must_use]
#[inline(always)]
pub const fn loopsdone(&self) -> bool {
let val = (self.0 >> 7usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event LOOPSDONE."]
#[inline(always)]
pub const fn set_loopsdone(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize);
}
}
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("seqstarted0", &self.seqstarted0())
.field("seqstarted1", &self.seqstarted1())
.field("seqend0", &self.seqend0())
.field("seqend1", &self.seqend1())
.field("pwmperiodend", &self.pwmperiodend())
.field("loopsdone", &self.loopsdone())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Int {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Int {{ stopped: {=bool:?}, seqstarted0: {=bool:?}, seqstarted1: {=bool:?}, seqend0: {=bool:?}, seqend1: {=bool:?}, pwmperiodend: {=bool:?}, loopsdone: {=bool:?} }}" , self . stopped () , self . seqstarted0 () , self . seqstarted1 () , self . seqend0 () , self . seqend1 () , self . pwmperiodend () , self . loopsdone ())
}
}
#[doc = "Number of playbacks of a loop."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Loop(pub u32);
impl Loop {
#[doc = "Number of playbacks of pattern cycles."]
#[must_use]
#[inline(always)]
pub const fn cnt(&self) -> super::vals::LoopCnt {
let val = (self.0 >> 0usize) & 0xffff;
super::vals::LoopCnt::from_bits(val as u16)
}
#[doc = "Number of playbacks of pattern cycles."]
#[inline(always)]
pub const fn set_cnt(&mut self, val: super::vals::LoopCnt) {
self.0 =
(self.0 & !(0xffff << 0usize)) | (((val.to_bits() as u32) & 0xffff) << 0usize);
}
}
impl Default for Loop {
#[inline(always)]
fn default() -> Loop {
Loop(0)
}
}
impl core::fmt::Debug for Loop {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Loop").field("cnt", &self.cnt()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Loop {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Loop {{ cnt: {:?} }}", self.cnt())
}
}
#[doc = "Selects operating mode of the wave counter."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Mode(pub u32);
impl Mode {
#[doc = "Selects up mode or up-and-down mode for the counter."]
#[must_use]
#[inline(always)]
pub const fn updown(&self) -> super::vals::Updown {
let val = (self.0 >> 0usize) & 0x01;
super::vals::Updown::from_bits(val as u8)
}
#[doc = "Selects up mode or up-and-down mode for the counter."]
#[inline(always)]
pub const fn set_updown(&mut self, val: super::vals::Updown) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 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("updown", &self.updown())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Mode {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Mode {{ updown: {:?} }}", self.updown())
}
}
#[doc = "Configuration for PWM_CLK."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Prescaler(pub u32);
impl Prescaler {
#[doc = "Prescaler of PWM_CLK."]
#[must_use]
#[inline(always)]
pub const fn prescaler(&self) -> super::vals::Prescaler {
let val = (self.0 >> 0usize) & 0x07;
super::vals::Prescaler::from_bits(val as u8)
}
#[doc = "Prescaler of PWM_CLK."]
#[inline(always)]
pub const fn set_prescaler(&mut self, val: super::vals::Prescaler) {
self.0 = (self.0 & !(0x07 << 0usize)) | (((val.to_bits() as u32) & 0x07) << 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: {:?} }}", self.prescaler())
}
}
#[doc = "Description cluster: Number of additional PWM periods between samples loaded into compare register."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Refresh(pub u32);
impl Refresh {
#[doc = "Number of additional PWM periods between samples loaded into compare register (load every REFRESH.CNT+1 PWM periods)."]
#[must_use]
#[inline(always)]
pub const fn cnt(&self) -> super::vals::RefreshCnt {
let val = (self.0 >> 0usize) & 0x00ff_ffff;
super::vals::RefreshCnt::from_bits(val as u32)
}
#[doc = "Number of additional PWM periods between samples loaded into compare register (load every REFRESH.CNT+1 PWM periods)."]
#[inline(always)]
pub const fn set_cnt(&mut self, val: super::vals::RefreshCnt) {
self.0 = (self.0 & !(0x00ff_ffff << 0usize))
| (((val.to_bits() as u32) & 0x00ff_ffff) << 0usize);
}
}
impl Default for Refresh {
#[inline(always)]
fn default() -> Refresh {
Refresh(0)
}
}
impl core::fmt::Debug for Refresh {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Refresh").field("cnt", &self.cnt()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Refresh {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Refresh {{ cnt: {:?} }}", self.cnt())
}
}
#[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 SEQEND\\[0\\] and task STOP."]
#[must_use]
#[inline(always)]
pub const fn seqend0_stop(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event SEQEND\\[0\\] and task STOP."]
#[inline(always)]
pub const fn set_seqend0_stop(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Shortcut between event SEQEND\\[1\\] and task STOP."]
#[must_use]
#[inline(always)]
pub const fn seqend1_stop(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event SEQEND\\[1\\] and task STOP."]
#[inline(always)]
pub const fn set_seqend1_stop(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "Shortcut between event LOOPSDONE and task SEQSTART\\[0\\]."]
#[must_use]
#[inline(always)]
pub const fn loopsdone_dma_seq0_start(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event LOOPSDONE and task SEQSTART\\[0\\]."]
#[inline(always)]
pub const fn set_loopsdone_dma_seq0_start(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "Shortcut between event LOOPSDONE and task SEQSTART\\[1\\]."]
#[must_use]
#[inline(always)]
pub const fn loopsdone_seqstart1(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event LOOPSDONE and task SEQSTART\\[1\\]."]
#[inline(always)]
pub const fn set_loopsdone_seqstart1(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
#[doc = "Shortcut between event LOOPSDONE and task STOP."]
#[must_use]
#[inline(always)]
pub const fn loopsdone_stop(&self) -> bool {
let val = (self.0 >> 4usize) & 0x01;
val != 0
}
#[doc = "Shortcut between event LOOPSDONE and task STOP."]
#[inline(always)]
pub const fn set_loopsdone_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("seqend0_stop", &self.seqend0_stop())
.field("seqend1_stop", &self.seqend1_stop())
.field("loopsdone_dma_seq0_start", &self.loopsdone_dma_seq0_start())
.field("loopsdone_seqstart1", &self.loopsdone_seqstart1())
.field("loopsdone_stop", &self.loopsdone_stop())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Shorts {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Shorts {{ seqend0_stop: {=bool:?}, seqend1_stop: {=bool:?}, loopsdone_dma_seq0_start: {=bool:?}, loopsdone_seqstart1: {=bool:?}, loopsdone_stop: {=bool:?} }}" , self . seqend0_stop () , self . seqend1_stop () , self . loopsdone_dma_seq0_start () , self . loopsdone_seqstart1 () , self . loopsdone_stop ())
}
}
}
pub mod vals {
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct CntCnt(u16);
impl CntCnt {
#[doc = "Sequence is disabled, and shall not be started as it is empty."]
pub const Disabled: Self = Self(0x0);
}
impl CntCnt {
pub const fn from_bits(val: u16) -> CntCnt {
Self(val & 0x7fff)
}
pub const fn to_bits(self) -> u16 {
self.0
}
}
impl core::fmt::Debug for CntCnt {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self.0 {
0x0 => f.write_str("Disabled"),
other => core::write!(f, "0x{:02X}", other),
}
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for CntCnt {
fn format(&self, f: defmt::Formatter) {
match self.0 {
0x0 => defmt::write!(f, "Disabled"),
other => defmt::write!(f, "0x{:02X}", other),
}
}
}
impl From<u16> for CntCnt {
#[inline(always)]
fn from(val: u16) -> CntCnt {
CntCnt::from_bits(val)
}
}
impl From<CntCnt> for u16 {
#[inline(always)]
fn from(val: CntCnt) -> u16 {
CntCnt::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Load {
#[doc = "1st half word (16-bit) used in all PWM channels 0..3."]
Common = 0x0,
#[doc = "1st half word (16-bit) used in channel 0..1; 2nd word in channel 2..3."]
Grouped = 0x01,
#[doc = "1st half word (16-bit) in ch.0; 2nd in ch.1; ...; 4th in ch.3."]
Individual = 0x02,
#[doc = "1st half word (16-bit) in ch.0; 2nd in ch.1; ...; 4th in COUNTERTOP."]
WaveForm = 0x03,
}
impl Load {
#[inline(always)]
pub const fn from_bits(val: u8) -> Load {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Load {
#[inline(always)]
fn from(val: u8) -> Load {
Load::from_bits(val)
}
}
impl From<Load> for u8 {
#[inline(always)]
fn from(val: Load) -> u8 {
Load::to_bits(val)
}
}
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct LoopCnt(u16);
impl LoopCnt {
#[doc = "Looping disabled (stop at the end of the sequence)."]
pub const Disabled: Self = Self(0x0);
}
impl LoopCnt {
pub const fn from_bits(val: u16) -> LoopCnt {
Self(val & 0xffff)
}
pub const fn to_bits(self) -> u16 {
self.0
}
}
impl core::fmt::Debug for LoopCnt {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self.0 {
0x0 => f.write_str("Disabled"),
other => core::write!(f, "0x{:02X}", other),
}
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for LoopCnt {
fn format(&self, f: defmt::Formatter) {
match self.0 {
0x0 => defmt::write!(f, "Disabled"),
other => defmt::write!(f, "0x{:02X}", other),
}
}
}
impl From<u16> for LoopCnt {
#[inline(always)]
fn from(val: u16) -> LoopCnt {
LoopCnt::from_bits(val)
}
}
impl From<LoopCnt> for u16 {
#[inline(always)]
fn from(val: LoopCnt) -> u16 {
LoopCnt::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Mode {
#[doc = "SEQ\\[n\\].REFRESH is used to determine loading internal compare registers."]
RefreshCount = 0x0,
#[doc = "NEXTSTEP task causes a new value to be loaded to internal compare registers."]
NextStep = 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 Prescaler {
#[doc = "Divide by 1 (16 MHz)."]
Div1 = 0x0,
#[doc = "Divide by 2 (8 MHz)."]
Div2 = 0x01,
#[doc = "Divide by 4 (4 MHz)."]
Div4 = 0x02,
#[doc = "Divide by 8 (2 MHz)."]
Div8 = 0x03,
#[doc = "Divide by 16 (1 MHz)."]
Div16 = 0x04,
#[doc = "Divide by 32 (500 kHz)."]
Div32 = 0x05,
#[doc = "Divide by 64 (250 kHz)."]
Div64 = 0x06,
#[doc = "Divide by 128 (125 kHz)."]
Div128 = 0x07,
}
impl Prescaler {
#[inline(always)]
pub const fn from_bits(val: u8) -> Prescaler {
unsafe { core::mem::transmute(val & 0x07) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Prescaler {
#[inline(always)]
fn from(val: u8) -> Prescaler {
Prescaler::from_bits(val)
}
}
impl From<Prescaler> for u8 {
#[inline(always)]
fn from(val: Prescaler) -> u8 {
Prescaler::to_bits(val)
}
}
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct RefreshCnt(u32);
impl RefreshCnt {
#[doc = "Update every PWM period."]
pub const Continuous: Self = Self(0x0);
}
impl RefreshCnt {
pub const fn from_bits(val: u32) -> RefreshCnt {
Self(val & 0x00ff_ffff)
}
pub const fn to_bits(self) -> u32 {
self.0
}
}
impl core::fmt::Debug for RefreshCnt {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self.0 {
0x0 => f.write_str("Continuous"),
other => core::write!(f, "0x{:02X}", other),
}
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for RefreshCnt {
fn format(&self, f: defmt::Formatter) {
match self.0 {
0x0 => defmt::write!(f, "Continuous"),
other => defmt::write!(f, "0x{:02X}", other),
}
}
}
impl From<u32> for RefreshCnt {
#[inline(always)]
fn from(val: u32) -> RefreshCnt {
RefreshCnt::from_bits(val)
}
}
impl From<RefreshCnt> for u32 {
#[inline(always)]
fn from(val: RefreshCnt) -> u32 {
RefreshCnt::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Updown {
#[doc = "Up counter, edge-aligned PWM duty cycle."]
Up = 0x0,
#[doc = "Up and down counter, center-aligned PWM duty cycle."]
UpAndDown = 0x01,
}
impl Updown {
#[inline(always)]
pub const fn from_bits(val: u8) -> Updown {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Updown {
#[inline(always)]
fn from(val: u8) -> Updown {
Updown::from_bits(val)
}
}
impl From<Updown> for u8 {
#[inline(always)]
fn from(val: Updown) -> u8 {
Updown::to_bits(val)
}
}
}
}
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 qspi {
#[doc = "Unspecified."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Erase {
ptr: *mut u8,
}
unsafe impl Send for Erase {}
unsafe impl Sync for Erase {}
impl Erase {
#[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 address of flash block to be erased."]
#[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 = "Size of block to be erased."]
#[inline(always)]
pub const fn len(self) -> crate::common::Reg<regs::Len, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) 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 serial clock 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 chip select signal CSN."]
#[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(0x04usize) as _) }
}
#[doc = "Pin select for serial data MOSI/IO0."]
#[inline(always)]
pub const fn io0(self) -> crate::common::Reg<super::shared::regs::Psel, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0cusize) as _) }
}
#[doc = "Pin select for serial data MISO/IO1."]
#[inline(always)]
pub const fn io1(self) -> crate::common::Reg<super::shared::regs::Psel, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x10usize) as _) }
}
#[doc = "Pin select for serial data IO2."]
#[inline(always)]
pub const fn io2(self) -> crate::common::Reg<super::shared::regs::Psel, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x14usize) as _) }
}
#[doc = "Pin select for serial data IO3."]
#[inline(always)]
pub const fn io3(self) -> crate::common::Reg<super::shared::regs::Psel, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x18usize) as _) }
}
}
#[doc = "External flash interface."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Qspi {
ptr: *mut u8,
}
unsafe impl Send for Qspi {}
unsafe impl Sync for Qspi {}
impl Qspi {
#[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 = "Activate QSPI interface."]
#[inline(always)]
pub const fn tasks_activate(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Start transfer from external flash memory to internal RAM."]
#[inline(always)]
pub const fn tasks_readstart(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Start transfer from internal RAM to external flash memory."]
#[inline(always)]
pub const fn tasks_writestart(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
#[doc = "Start external flash memory erase operation."]
#[inline(always)]
pub const fn tasks_erasestart(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0cusize) as _) }
}
#[doc = "Deactivate QSPI interface."]
#[inline(always)]
pub const fn tasks_deactivate(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x10usize) as _) }
}
#[doc = "QSPI peripheral is ready. This event will be generated as a response to any QSPI task."]
#[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 = "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 = "Enable QSPI peripheral and acquire the pins selected in PSELn registers."]
#[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 read(self) -> Read {
unsafe { Read::from_ptr(self.ptr.wrapping_add(0x0504usize) as _) }
}
#[doc = "Unspecified."]
#[inline(always)]
pub const fn write(self) -> Write {
unsafe { Write::from_ptr(self.ptr.wrapping_add(0x0510usize) as _) }
}
#[doc = "Unspecified."]
#[inline(always)]
pub const fn erase(self) -> Erase {
unsafe { Erase::from_ptr(self.ptr.wrapping_add(0x051cusize) as _) }
}
#[doc = "Unspecified."]
#[inline(always)]
pub const fn psel(self) -> Psel {
unsafe { Psel::from_ptr(self.ptr.wrapping_add(0x0524usize) as _) }
}
#[doc = "Address offset into the external memory for Execute in Place operation."]
#[inline(always)]
pub const fn xipoffset(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0540usize) as _) }
}
#[doc = "Interface configuration."]
#[inline(always)]
pub const fn ifconfig0(self) -> crate::common::Reg<regs::Ifconfig0, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0544usize) as _) }
}
#[doc = "Interface configuration."]
#[inline(always)]
pub const fn ifconfig1(self) -> crate::common::Reg<regs::Ifconfig1, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0600usize) as _) }
}
#[doc = "Status register."]
#[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(0x0604usize) as _) }
}
#[doc = "Set the duration required to enter/exit deep power-down mode (DPM)."]
#[inline(always)]
pub const fn dpmdur(self) -> crate::common::Reg<regs::Dpmdur, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0614usize) as _) }
}
#[doc = "Extended address configuration."]
#[inline(always)]
pub const fn addrconf(self) -> crate::common::Reg<regs::Addrconf, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0624usize) as _) }
}
#[doc = "Custom instruction configuration register."]
#[inline(always)]
pub const fn cinstrconf(self) -> crate::common::Reg<regs::Cinstrconf, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0634usize) as _) }
}
#[doc = "Custom instruction data register 0."]
#[inline(always)]
pub const fn cinstrdat0(self) -> crate::common::Reg<regs::Cinstrdat0, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0638usize) as _) }
}
#[doc = "Custom instruction data register 1."]
#[inline(always)]
pub const fn cinstrdat1(self) -> crate::common::Reg<regs::Cinstrdat1, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x063cusize) as _) }
}
#[doc = "SPI interface timing."]
#[inline(always)]
pub const fn iftiming(self) -> crate::common::Reg<regs::Iftiming, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0640usize) as _) }
}
}
#[doc = "Unspecified."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Read {
ptr: *mut u8,
}
unsafe impl Send for Read {}
unsafe impl Sync for Read {}
impl Read {
#[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 = "Flash memory source address."]
#[inline(always)]
pub const fn src(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "RAM destination address."]
#[inline(always)]
pub const fn dst(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Read transfer length."]
#[inline(always)]
pub const fn cnt(self) -> crate::common::Reg<regs::ReadCnt, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
}
#[doc = "Unspecified."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Write {
ptr: *mut u8,
}
unsafe impl Send for Write {}
unsafe impl Sync for Write {}
impl Write {
#[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 = "Flash destination address."]
#[inline(always)]
pub const fn dst(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "RAM source address."]
#[inline(always)]
pub const fn src(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Write transfer length."]
#[inline(always)]
pub const fn cnt(self) -> crate::common::Reg<regs::WriteCnt, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x08usize) as _) }
}
}
pub mod regs {
#[doc = "Extended address configuration."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Addrconf(pub u32);
impl Addrconf {
#[doc = "Opcode that enters the 32-bit addressing mode."]
#[must_use]
#[inline(always)]
pub const fn opcode(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "Opcode that enters the 32-bit addressing mode."]
#[inline(always)]
pub const fn set_opcode(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
#[doc = "Byte 0 following opcode."]
#[must_use]
#[inline(always)]
pub const fn byte0(&self) -> u8 {
let val = (self.0 >> 8usize) & 0xff;
val as u8
}
#[doc = "Byte 0 following opcode."]
#[inline(always)]
pub const fn set_byte0(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 8usize)) | (((val as u32) & 0xff) << 8usize);
}
#[doc = "Byte 1 following byte 0."]
#[must_use]
#[inline(always)]
pub const fn byte1(&self) -> u8 {
let val = (self.0 >> 16usize) & 0xff;
val as u8
}
#[doc = "Byte 1 following byte 0."]
#[inline(always)]
pub const fn set_byte1(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 16usize)) | (((val as u32) & 0xff) << 16usize);
}
#[doc = "Extended addressing mode."]
#[must_use]
#[inline(always)]
pub const fn mode(&self) -> super::vals::Mode {
let val = (self.0 >> 24usize) & 0x03;
super::vals::Mode::from_bits(val as u8)
}
#[doc = "Extended addressing mode."]
#[inline(always)]
pub const fn set_mode(&mut self, val: super::vals::Mode) {
self.0 =
(self.0 & !(0x03 << 24usize)) | (((val.to_bits() as u32) & 0x03) << 24usize);
}
#[doc = "Wait for write complete before sending command."]
#[must_use]
#[inline(always)]
pub const fn wipwait(&self) -> bool {
let val = (self.0 >> 26usize) & 0x01;
val != 0
}
#[doc = "Wait for write complete before sending command."]
#[inline(always)]
pub const fn set_wipwait(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 26usize)) | (((val as u32) & 0x01) << 26usize);
}
#[doc = "Send WREN (write enable opcode 0x06) before instruction."]
#[must_use]
#[inline(always)]
pub const fn wren(&self) -> bool {
let val = (self.0 >> 27usize) & 0x01;
val != 0
}
#[doc = "Send WREN (write enable opcode 0x06) before instruction."]
#[inline(always)]
pub const fn set_wren(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 27usize)) | (((val as u32) & 0x01) << 27usize);
}
}
impl Default for Addrconf {
#[inline(always)]
fn default() -> Addrconf {
Addrconf(0)
}
}
impl core::fmt::Debug for Addrconf {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Addrconf")
.field("opcode", &self.opcode())
.field("byte0", &self.byte0())
.field("byte1", &self.byte1())
.field("mode", &self.mode())
.field("wipwait", &self.wipwait())
.field("wren", &self.wren())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Addrconf {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Addrconf {{ opcode: {=u8:?}, byte0: {=u8:?}, byte1: {=u8:?}, mode: {:?}, wipwait: {=bool:?}, wren: {=bool:?} }}" , self . opcode () , self . byte0 () , self . byte1 () , self . mode () , self . wipwait () , self . wren ())
}
}
#[doc = "Custom instruction configuration register."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Cinstrconf(pub u32);
impl Cinstrconf {
#[doc = "Opcode of Custom instruction."]
#[must_use]
#[inline(always)]
pub const fn opcode(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "Opcode of Custom instruction."]
#[inline(always)]
pub const fn set_opcode(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
#[doc = "Length of custom instruction in number of bytes."]
#[must_use]
#[inline(always)]
pub const fn length(&self) -> super::vals::Length {
let val = (self.0 >> 8usize) & 0x0f;
super::vals::Length::from_bits(val as u8)
}
#[doc = "Length of custom instruction in number of bytes."]
#[inline(always)]
pub const fn set_length(&mut self, val: super::vals::Length) {
self.0 = (self.0 & !(0x0f << 8usize)) | (((val.to_bits() as u32) & 0x0f) << 8usize);
}
#[doc = "Level of the IO2 pin (if connected) during transmission of custom instruction."]
#[must_use]
#[inline(always)]
pub const fn lio2(&self) -> bool {
let val = (self.0 >> 12usize) & 0x01;
val != 0
}
#[doc = "Level of the IO2 pin (if connected) during transmission of custom instruction."]
#[inline(always)]
pub const fn set_lio2(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 12usize)) | (((val as u32) & 0x01) << 12usize);
}
#[doc = "Level of the IO3 pin (if connected) during transmission of custom instruction."]
#[must_use]
#[inline(always)]
pub const fn lio3(&self) -> bool {
let val = (self.0 >> 13usize) & 0x01;
val != 0
}
#[doc = "Level of the IO3 pin (if connected) during transmission of custom instruction."]
#[inline(always)]
pub const fn set_lio3(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 13usize)) | (((val as u32) & 0x01) << 13usize);
}
#[doc = "Wait for write complete before sending command."]
#[must_use]
#[inline(always)]
pub const fn wipwait(&self) -> bool {
let val = (self.0 >> 14usize) & 0x01;
val != 0
}
#[doc = "Wait for write complete before sending command."]
#[inline(always)]
pub const fn set_wipwait(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 14usize)) | (((val as u32) & 0x01) << 14usize);
}
#[doc = "Send WREN (write enable opcode 0x06) before instruction."]
#[must_use]
#[inline(always)]
pub const fn wren(&self) -> bool {
let val = (self.0 >> 15usize) & 0x01;
val != 0
}
#[doc = "Send WREN (write enable opcode 0x06) before instruction."]
#[inline(always)]
pub const fn set_wren(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 15usize)) | (((val as u32) & 0x01) << 15usize);
}
#[doc = "Enable long frame mode. When enabled, a custom instruction transaction has to be ended by writing the LFSTOP field."]
#[must_use]
#[inline(always)]
pub const fn lfen(&self) -> bool {
let val = (self.0 >> 16usize) & 0x01;
val != 0
}
#[doc = "Enable long frame mode. When enabled, a custom instruction transaction has to be ended by writing the LFSTOP field."]
#[inline(always)]
pub const fn set_lfen(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 16usize)) | (((val as u32) & 0x01) << 16usize);
}
#[doc = "Stop (finalize) long frame transaction."]
#[must_use]
#[inline(always)]
pub const fn lfstop(&self) -> bool {
let val = (self.0 >> 17usize) & 0x01;
val != 0
}
#[doc = "Stop (finalize) long frame transaction."]
#[inline(always)]
pub const fn set_lfstop(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 17usize)) | (((val as u32) & 0x01) << 17usize);
}
}
impl Default for Cinstrconf {
#[inline(always)]
fn default() -> Cinstrconf {
Cinstrconf(0)
}
}
impl core::fmt::Debug for Cinstrconf {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Cinstrconf")
.field("opcode", &self.opcode())
.field("length", &self.length())
.field("lio2", &self.lio2())
.field("lio3", &self.lio3())
.field("wipwait", &self.wipwait())
.field("wren", &self.wren())
.field("lfen", &self.lfen())
.field("lfstop", &self.lfstop())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Cinstrconf {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Cinstrconf {{ opcode: {=u8:?}, length: {:?}, lio2: {=bool:?}, lio3: {=bool:?}, wipwait: {=bool:?}, wren: {=bool:?}, lfen: {=bool:?}, lfstop: {=bool:?} }}" , self . opcode () , self . length () , self . lio2 () , self . lio3 () , self . wipwait () , self . wren () , self . lfen () , self . lfstop ())
}
}
#[doc = "Custom instruction data register 0."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Cinstrdat0(pub u32);
impl Cinstrdat0 {
#[doc = "Data byte 0."]
#[must_use]
#[inline(always)]
pub const fn byte0(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "Data byte 0."]
#[inline(always)]
pub const fn set_byte0(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
#[doc = "Data byte 1."]
#[must_use]
#[inline(always)]
pub const fn byte1(&self) -> u8 {
let val = (self.0 >> 8usize) & 0xff;
val as u8
}
#[doc = "Data byte 1."]
#[inline(always)]
pub const fn set_byte1(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 8usize)) | (((val as u32) & 0xff) << 8usize);
}
#[doc = "Data byte 2."]
#[must_use]
#[inline(always)]
pub const fn byte2(&self) -> u8 {
let val = (self.0 >> 16usize) & 0xff;
val as u8
}
#[doc = "Data byte 2."]
#[inline(always)]
pub const fn set_byte2(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 16usize)) | (((val as u32) & 0xff) << 16usize);
}
#[doc = "Data byte 3."]
#[must_use]
#[inline(always)]
pub const fn byte3(&self) -> u8 {
let val = (self.0 >> 24usize) & 0xff;
val as u8
}
#[doc = "Data byte 3."]
#[inline(always)]
pub const fn set_byte3(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 24usize)) | (((val as u32) & 0xff) << 24usize);
}
}
impl Default for Cinstrdat0 {
#[inline(always)]
fn default() -> Cinstrdat0 {
Cinstrdat0(0)
}
}
impl core::fmt::Debug for Cinstrdat0 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Cinstrdat0")
.field("byte0", &self.byte0())
.field("byte1", &self.byte1())
.field("byte2", &self.byte2())
.field("byte3", &self.byte3())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Cinstrdat0 {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Cinstrdat0 {{ byte0: {=u8:?}, byte1: {=u8:?}, byte2: {=u8:?}, byte3: {=u8:?} }}" , self . byte0 () , self . byte1 () , self . byte2 () , self . byte3 ())
}
}
#[doc = "Custom instruction data register 1."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Cinstrdat1(pub u32);
impl Cinstrdat1 {
#[doc = "Data byte 4."]
#[must_use]
#[inline(always)]
pub const fn byte4(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "Data byte 4."]
#[inline(always)]
pub const fn set_byte4(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
#[doc = "Data byte 5."]
#[must_use]
#[inline(always)]
pub const fn byte5(&self) -> u8 {
let val = (self.0 >> 8usize) & 0xff;
val as u8
}
#[doc = "Data byte 5."]
#[inline(always)]
pub const fn set_byte5(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 8usize)) | (((val as u32) & 0xff) << 8usize);
}
#[doc = "Data byte 6."]
#[must_use]
#[inline(always)]
pub const fn byte6(&self) -> u8 {
let val = (self.0 >> 16usize) & 0xff;
val as u8
}
#[doc = "Data byte 6."]
#[inline(always)]
pub const fn set_byte6(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 16usize)) | (((val as u32) & 0xff) << 16usize);
}
#[doc = "Data byte 7."]
#[must_use]
#[inline(always)]
pub const fn byte7(&self) -> u8 {
let val = (self.0 >> 24usize) & 0xff;
val as u8
}
#[doc = "Data byte 7."]
#[inline(always)]
pub const fn set_byte7(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 24usize)) | (((val as u32) & 0xff) << 24usize);
}
}
impl Default for Cinstrdat1 {
#[inline(always)]
fn default() -> Cinstrdat1 {
Cinstrdat1(0)
}
}
impl core::fmt::Debug for Cinstrdat1 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Cinstrdat1")
.field("byte4", &self.byte4())
.field("byte5", &self.byte5())
.field("byte6", &self.byte6())
.field("byte7", &self.byte7())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Cinstrdat1 {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Cinstrdat1 {{ byte4: {=u8:?}, byte5: {=u8:?}, byte6: {=u8:?}, byte7: {=u8:?} }}" , self . byte4 () , self . byte5 () , self . byte6 () , self . byte7 ())
}
}
#[doc = "Set the duration required to enter/exit deep power-down mode (DPM)."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Dpmdur(pub u32);
impl Dpmdur {
#[doc = "Duration needed by external flash to enter DPM. Duration is given as ENTER * 256 * 62.5 ns."]
#[must_use]
#[inline(always)]
pub const fn enter(&self) -> u16 {
let val = (self.0 >> 0usize) & 0xffff;
val as u16
}
#[doc = "Duration needed by external flash to enter DPM. Duration is given as ENTER * 256 * 62.5 ns."]
#[inline(always)]
pub const fn set_enter(&mut self, val: u16) {
self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize);
}
#[doc = "Duration needed by external flash to exit DPM. Duration is given as EXIT * 256 * 62.5 ns."]
#[must_use]
#[inline(always)]
pub const fn exit(&self) -> u16 {
let val = (self.0 >> 16usize) & 0xffff;
val as u16
}
#[doc = "Duration needed by external flash to exit DPM. Duration is given as EXIT * 256 * 62.5 ns."]
#[inline(always)]
pub const fn set_exit(&mut self, val: u16) {
self.0 = (self.0 & !(0xffff << 16usize)) | (((val as u32) & 0xffff) << 16usize);
}
}
impl Default for Dpmdur {
#[inline(always)]
fn default() -> Dpmdur {
Dpmdur(0)
}
}
impl core::fmt::Debug for Dpmdur {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Dpmdur")
.field("enter", &self.enter())
.field("exit", &self.exit())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Dpmdur {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Dpmdur {{ enter: {=u16:?}, exit: {=u16:?} }}",
self.enter(),
self.exit()
)
}
}
#[doc = "Enable QSPI peripheral and acquire the pins selected in PSELn registers."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Enable(pub u32);
impl Enable {
#[doc = "Enable or disable QSPI."]
#[must_use]
#[inline(always)]
pub const fn enable(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Enable or disable QSPI."]
#[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 = "Interface configuration."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Ifconfig0(pub u32);
impl Ifconfig0 {
#[doc = "Configure number of data lines and opcode used for reading."]
#[must_use]
#[inline(always)]
pub const fn readoc(&self) -> super::vals::Readoc {
let val = (self.0 >> 0usize) & 0x07;
super::vals::Readoc::from_bits(val as u8)
}
#[doc = "Configure number of data lines and opcode used for reading."]
#[inline(always)]
pub const fn set_readoc(&mut self, val: super::vals::Readoc) {
self.0 = (self.0 & !(0x07 << 0usize)) | (((val.to_bits() as u32) & 0x07) << 0usize);
}
#[doc = "Configure number of data lines and opcode used for writing."]
#[must_use]
#[inline(always)]
pub const fn writeoc(&self) -> super::vals::Writeoc {
let val = (self.0 >> 3usize) & 0x07;
super::vals::Writeoc::from_bits(val as u8)
}
#[doc = "Configure number of data lines and opcode used for writing."]
#[inline(always)]
pub const fn set_writeoc(&mut self, val: super::vals::Writeoc) {
self.0 = (self.0 & !(0x07 << 3usize)) | (((val.to_bits() as u32) & 0x07) << 3usize);
}
#[doc = "Addressing mode."]
#[must_use]
#[inline(always)]
pub const fn addrmode(&self) -> super::vals::Addrmode {
let val = (self.0 >> 6usize) & 0x01;
super::vals::Addrmode::from_bits(val as u8)
}
#[doc = "Addressing mode."]
#[inline(always)]
pub const fn set_addrmode(&mut self, val: super::vals::Addrmode) {
self.0 = (self.0 & !(0x01 << 6usize)) | (((val.to_bits() as u32) & 0x01) << 6usize);
}
#[doc = "Enable deep power-down mode (DPM) feature."]
#[must_use]
#[inline(always)]
pub const fn dpmenable(&self) -> bool {
let val = (self.0 >> 7usize) & 0x01;
val != 0
}
#[doc = "Enable deep power-down mode (DPM) feature."]
#[inline(always)]
pub const fn set_dpmenable(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize);
}
#[doc = "Page size for commands PP, PP2O, PP4O and PP4IO."]
#[must_use]
#[inline(always)]
pub const fn ppsize(&self) -> super::vals::Ppsize {
let val = (self.0 >> 12usize) & 0x01;
super::vals::Ppsize::from_bits(val as u8)
}
#[doc = "Page size for commands PP, PP2O, PP4O and PP4IO."]
#[inline(always)]
pub const fn set_ppsize(&mut self, val: super::vals::Ppsize) {
self.0 =
(self.0 & !(0x01 << 12usize)) | (((val.to_bits() as u32) & 0x01) << 12usize);
}
}
impl Default for Ifconfig0 {
#[inline(always)]
fn default() -> Ifconfig0 {
Ifconfig0(0)
}
}
impl core::fmt::Debug for Ifconfig0 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Ifconfig0")
.field("readoc", &self.readoc())
.field("writeoc", &self.writeoc())
.field("addrmode", &self.addrmode())
.field("dpmenable", &self.dpmenable())
.field("ppsize", &self.ppsize())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Ifconfig0 {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Ifconfig0 {{ readoc: {:?}, writeoc: {:?}, addrmode: {:?}, dpmenable: {=bool:?}, ppsize: {:?} }}" , self . readoc () , self . writeoc () , self . addrmode () , self . dpmenable () , self . ppsize ())
}
}
#[doc = "Interface configuration."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Ifconfig1(pub u32);
impl Ifconfig1 {
#[doc = "Minimum amount of time that the CSN pin must stay high before it can go low again. Value is specified in number of 16 MHz periods (62.5 ns)."]
#[must_use]
#[inline(always)]
pub const fn sckdelay(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "Minimum amount of time that the CSN pin must stay high before it can go low again. Value is specified in number of 16 MHz periods (62.5 ns)."]
#[inline(always)]
pub const fn set_sckdelay(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
#[doc = "Enter/exit deep power-down mode (DPM) for external flash memory."]
#[must_use]
#[inline(always)]
pub const fn dpmen(&self) -> bool {
let val = (self.0 >> 24usize) & 0x01;
val != 0
}
#[doc = "Enter/exit deep power-down mode (DPM) for external flash memory."]
#[inline(always)]
pub const fn set_dpmen(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 24usize)) | (((val as u32) & 0x01) << 24usize);
}
#[doc = "Select SPI mode."]
#[must_use]
#[inline(always)]
pub const fn spimode(&self) -> super::vals::Spimode {
let val = (self.0 >> 25usize) & 0x01;
super::vals::Spimode::from_bits(val as u8)
}
#[doc = "Select SPI mode."]
#[inline(always)]
pub const fn set_spimode(&mut self, val: super::vals::Spimode) {
self.0 =
(self.0 & !(0x01 << 25usize)) | (((val.to_bits() as u32) & 0x01) << 25usize);
}
#[doc = "SCK frequency is given as 32 MHz / (SCKFREQ + 1)."]
#[must_use]
#[inline(always)]
pub const fn sckfreq(&self) -> u8 {
let val = (self.0 >> 28usize) & 0x0f;
val as u8
}
#[doc = "SCK frequency is given as 32 MHz / (SCKFREQ + 1)."]
#[inline(always)]
pub const fn set_sckfreq(&mut self, val: u8) {
self.0 = (self.0 & !(0x0f << 28usize)) | (((val as u32) & 0x0f) << 28usize);
}
}
impl Default for Ifconfig1 {
#[inline(always)]
fn default() -> Ifconfig1 {
Ifconfig1(0)
}
}
impl core::fmt::Debug for Ifconfig1 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Ifconfig1")
.field("sckdelay", &self.sckdelay())
.field("dpmen", &self.dpmen())
.field("spimode", &self.spimode())
.field("sckfreq", &self.sckfreq())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Ifconfig1 {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Ifconfig1 {{ sckdelay: {=u8:?}, dpmen: {=bool:?}, spimode: {:?}, sckfreq: {=u8:?} }}" , self . sckdelay () , self . dpmen () , self . spimode () , self . sckfreq ())
}
}
#[doc = "SPI interface timing."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Iftiming(pub u32);
impl Iftiming {
#[doc = "Timing related to sampling of the input serial data. The value of RXDELAY specifies the number of 64 MHz cycles (15.625 ns) delay from the the rising edge of the SPI Clock (SCK) until the input serial data is sampled. As en example, if set to 0 the input serial data is sampled on the rising edge of SCK."]
#[must_use]
#[inline(always)]
pub const fn rxdelay(&self) -> u8 {
let val = (self.0 >> 8usize) & 0x07;
val as u8
}
#[doc = "Timing related to sampling of the input serial data. The value of RXDELAY specifies the number of 64 MHz cycles (15.625 ns) delay from the the rising edge of the SPI Clock (SCK) until the input serial data is sampled. As en example, if set to 0 the input serial data is sampled on the rising edge of SCK."]
#[inline(always)]
pub const fn set_rxdelay(&mut self, val: u8) {
self.0 = (self.0 & !(0x07 << 8usize)) | (((val as u32) & 0x07) << 8usize);
}
}
impl Default for Iftiming {
#[inline(always)]
fn default() -> Iftiming {
Iftiming(0)
}
}
impl core::fmt::Debug for Iftiming {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Iftiming")
.field("rxdelay", &self.rxdelay())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Iftiming {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Iftiming {{ rxdelay: {=u8:?} }}", self.rxdelay())
}
}
#[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);
}
}
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 = "Size of block to be erased."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Len(pub u32);
impl Len {
#[doc = "LEN."]
#[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 = "LEN."]
#[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);
}
}
impl Default for Len {
#[inline(always)]
fn default() -> Len {
Len(0)
}
}
impl core::fmt::Debug for Len {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Len").field("len", &self.len()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Len {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Len {{ len: {:?} }}", self.len())
}
}
#[doc = "Read transfer length."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct ReadCnt(pub u32);
impl ReadCnt {
#[doc = "Read transfer length in number of bytes. The length must be a multiple of 4 bytes."]
#[must_use]
#[inline(always)]
pub const fn cnt(&self) -> u32 {
let val = (self.0 >> 0usize) & 0x0003_ffff;
val as u32
}
#[doc = "Read transfer length in number of bytes. The length must be a multiple of 4 bytes."]
#[inline(always)]
pub const fn set_cnt(&mut self, val: u32) {
self.0 =
(self.0 & !(0x0003_ffff << 0usize)) | (((val as u32) & 0x0003_ffff) << 0usize);
}
}
impl Default for ReadCnt {
#[inline(always)]
fn default() -> ReadCnt {
ReadCnt(0)
}
}
impl core::fmt::Debug for ReadCnt {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("ReadCnt").field("cnt", &self.cnt()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for ReadCnt {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "ReadCnt {{ cnt: {=u32:?} }}", self.cnt())
}
}
#[doc = "Status register."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Status(pub u32);
impl Status {
#[doc = "Deep power-down mode (DPM) status of external flash."]
#[must_use]
#[inline(always)]
pub const fn dpm(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Deep power-down mode (DPM) status of external flash."]
#[inline(always)]
pub const fn set_dpm(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "Ready status."]
#[must_use]
#[inline(always)]
pub const fn ready(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "Ready status."]
#[inline(always)]
pub const fn set_ready(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
#[doc = "Value of external flash device Status Register. When the external flash has two bytes status register this field includes the value of the low byte."]
#[must_use]
#[inline(always)]
pub const fn sreg(&self) -> u8 {
let val = (self.0 >> 24usize) & 0xff;
val as u8
}
#[doc = "Value of external flash device Status Register. When the external flash has two bytes status register this field includes the value of the low byte."]
#[inline(always)]
pub const fn set_sreg(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 24usize)) | (((val as u32) & 0xff) << 24usize);
}
}
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("dpm", &self.dpm())
.field("ready", &self.ready())
.field("sreg", &self.sreg())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Status {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Status {{ dpm: {=bool:?}, ready: {=bool:?}, sreg: {=u8:?} }}",
self.dpm(),
self.ready(),
self.sreg()
)
}
}
#[doc = "Write transfer length."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct WriteCnt(pub u32);
impl WriteCnt {
#[doc = "Write transfer length in number of bytes. The length must be a multiple of 4 bytes."]
#[must_use]
#[inline(always)]
pub const fn cnt(&self) -> u32 {
let val = (self.0 >> 0usize) & 0x0003_ffff;
val as u32
}
#[doc = "Write transfer length in number of bytes. The length must be a multiple of 4 bytes."]
#[inline(always)]
pub const fn set_cnt(&mut self, val: u32) {
self.0 =
(self.0 & !(0x0003_ffff << 0usize)) | (((val as u32) & 0x0003_ffff) << 0usize);
}
}
impl Default for WriteCnt {
#[inline(always)]
fn default() -> WriteCnt {
WriteCnt(0)
}
}
impl core::fmt::Debug for WriteCnt {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("WriteCnt")
.field("cnt", &self.cnt())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for WriteCnt {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "WriteCnt {{ cnt: {=u32:?} }}", self.cnt())
}
}
}
pub mod vals {
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Addrmode {
#[doc = "24-bit addressing."]
_24bit = 0x0,
#[doc = "32-bit addressing."]
_32bit = 0x01,
}
impl Addrmode {
#[inline(always)]
pub const fn from_bits(val: u8) -> Addrmode {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Addrmode {
#[inline(always)]
fn from(val: u8) -> Addrmode {
Addrmode::from_bits(val)
}
}
impl From<Addrmode> for u8 {
#[inline(always)]
fn from(val: Addrmode) -> u8 {
Addrmode::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Len {
#[doc = "Erase 4 kB block (flash command 0x20)."]
_4kb = 0x0,
#[doc = "Erase 64 kB block (flash command 0xD8)."]
_64kb = 0x01,
#[doc = "Erase all (flash command 0xC7)."]
All = 0x02,
_RESERVED_3 = 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 Length {
_RESERVED_0 = 0x0,
#[doc = "Send opcode only."]
_1b = 0x01,
#[doc = "Send opcode, CINSTRDAT0.BYTE0."]
_2b = 0x02,
#[doc = "Send opcode, CINSTRDAT0.BYTE0 -> CINSTRDAT0.BYTE1."]
_3b = 0x03,
#[doc = "Send opcode, CINSTRDAT0.BYTE0 -> CINSTRDAT0.BYTE2."]
_4b = 0x04,
#[doc = "Send opcode, CINSTRDAT0.BYTE0 -> CINSTRDAT0.BYTE3."]
_5b = 0x05,
#[doc = "Send opcode, CINSTRDAT0.BYTE0 -> CINSTRDAT1.BYTE4."]
_6b = 0x06,
#[doc = "Send opcode, CINSTRDAT0.BYTE0 -> CINSTRDAT1.BYTE5."]
_7b = 0x07,
#[doc = "Send opcode, CINSTRDAT0.BYTE0 -> CINSTRDAT1.BYTE6."]
_8b = 0x08,
#[doc = "Send opcode, CINSTRDAT0.BYTE0 -> CINSTRDAT1.BYTE7."]
_9b = 0x09,
_RESERVED_a = 0x0a,
_RESERVED_b = 0x0b,
_RESERVED_c = 0x0c,
_RESERVED_d = 0x0d,
_RESERVED_e = 0x0e,
_RESERVED_f = 0x0f,
}
impl Length {
#[inline(always)]
pub const fn from_bits(val: u8) -> Length {
unsafe { core::mem::transmute(val & 0x0f) }
}
#[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 Mode {
#[doc = "Do not send any instruction."]
NoInstr = 0x0,
#[doc = "Send opcode."]
Opcode = 0x01,
#[doc = "Send opcode, byte0."]
OpByte0 = 0x02,
#[doc = "Send opcode, byte0, byte1."]
All = 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 Ppsize {
#[doc = "256 bytes."]
_256bytes = 0x0,
#[doc = "512 bytes."]
_512bytes = 0x01,
}
impl Ppsize {
#[inline(always)]
pub const fn from_bits(val: u8) -> Ppsize {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Ppsize {
#[inline(always)]
fn from(val: u8) -> Ppsize {
Ppsize::from_bits(val)
}
}
impl From<Ppsize> for u8 {
#[inline(always)]
fn from(val: Ppsize) -> u8 {
Ppsize::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Readoc {
#[doc = "Single data line SPI. FAST_READ (opcode 0x0B)."]
Fastread = 0x0,
#[doc = "Dual data line SPI. READ2O (opcode 0x3B)."]
Read2o = 0x01,
#[doc = "Dual data line SPI. READ2IO (opcode 0xBB)."]
Read2io = 0x02,
#[doc = "Quad data line SPI. READ4O (opcode 0x6B)."]
Read4o = 0x03,
#[doc = "Quad data line SPI. READ4IO (opcode 0xEB)."]
Read4io = 0x04,
_RESERVED_5 = 0x05,
_RESERVED_6 = 0x06,
_RESERVED_7 = 0x07,
}
impl Readoc {
#[inline(always)]
pub const fn from_bits(val: u8) -> Readoc {
unsafe { core::mem::transmute(val & 0x07) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Readoc {
#[inline(always)]
fn from(val: u8) -> Readoc {
Readoc::from_bits(val)
}
}
impl From<Readoc> for u8 {
#[inline(always)]
fn from(val: Readoc) -> u8 {
Readoc::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Spimode {
#[doc = "Mode 0: Data are captured on the clock rising edge and data is output on a falling edge. Base level of clock is 0 (CPOL=0, CPHA=0)."]
Mode0 = 0x0,
#[doc = "Mode 3: Data are captured on the clock falling edge and data is output on a rising edge. Base level of clock is 1 (CPOL=1, CPHA=1)."]
Mode3 = 0x01,
}
impl Spimode {
#[inline(always)]
pub const fn from_bits(val: u8) -> Spimode {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Spimode {
#[inline(always)]
fn from(val: u8) -> Spimode {
Spimode::from_bits(val)
}
}
impl From<Spimode> for u8 {
#[inline(always)]
fn from(val: Spimode) -> u8 {
Spimode::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Writeoc {
#[doc = "Single data line SPI. PP (opcode 0x02)."]
Pp = 0x0,
#[doc = "Dual data line SPI. PP2O (opcode 0xA2)."]
Pp2o = 0x01,
#[doc = "Quad data line SPI. PP4O (opcode 0x32)."]
Pp4o = 0x02,
#[doc = "Quad data line SPI. PP4IO (opcode 0x38)."]
Pp4io = 0x03,
_RESERVED_4 = 0x04,
_RESERVED_5 = 0x05,
_RESERVED_6 = 0x06,
_RESERVED_7 = 0x07,
}
impl Writeoc {
#[inline(always)]
pub const fn from_bits(val: u8) -> Writeoc {
unsafe { core::mem::transmute(val & 0x07) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Writeoc {
#[inline(always)]
fn from(val: u8) -> Writeoc {
Writeoc::from_bits(val)
}
}
impl From<Writeoc> for u8 {
#[inline(always)]
fn from(val: Writeoc) -> u8 {
Writeoc::to_bits(val)
}
}
}
}
pub mod radio {
#[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 in Ble_LR125Kbit, Ble_LR500Kbit and Ieee802154_250Kbit modes when last bit is sent on 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 = "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 = "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::RW> {
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 = "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 = "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 = "CRC configuration."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Crccnf(pub u32);
impl Crccnf {
#[doc = "CRC length in number of bytes."]
#[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."]
#[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 = "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 hard-wired 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 hard-wired 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 = "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);
}
}
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())
.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:?} }}" , 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 ())
}
}
#[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 = "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 125kbps."]
Lr125kbit = 0x0,
#[doc = "Frame is received at 500kbps."]
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 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 .. 2500 MHz."]
Default = 0x0,
#[doc = "Channel map between 2360 MHZ .. 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 Mbit/s Nordic proprietary radio mode."]
Nrf1mbit = 0x0,
#[doc = "2 Mbit/s Nordic proprietary radio mode."]
Nrf2mbit = 0x01,
_RESERVED_2 = 0x02,
#[doc = "1 Mbit/s BLE."]
Ble1mbit = 0x03,
#[doc = "2 Mbit/s BLE."]
Ble2mbit = 0x04,
#[doc = "Long range 125 kbit/s TX, 125 kbit/s and 500 kbit/s RX."]
BleLr125kbit = 0x05,
#[doc = "Long range 500 kbit/s TX, 125 kbit/s and 500 kbit/s 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 kbit/s."]
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 BLE 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 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 specification 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 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(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 saadc {
#[doc = "Unspecified."]
#[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: Input positive pin selection for CH\\[n\\]."]
#[inline(always)]
pub const fn pselp(self) -> crate::common::Reg<regs::Pselp, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Description cluster: Input negative pin selection for CH\\[n\\]."]
#[inline(always)]
pub const fn pseln(self) -> crate::common::Reg<regs::Pseln, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
#[doc = "Description cluster: Input configuration for CH\\[n\\]."]
#[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(0x08usize) as _) }
}
#[doc = "Description cluster: High/low limits for event monitoring of a channel."]
#[inline(always)]
pub const fn limit(self) -> crate::common::Reg<regs::Limit, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0cusize) as _) }
}
}
#[doc = "Peripheral events."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct EventsCh {
ptr: *mut u8,
}
unsafe impl Send for EventsCh {}
unsafe impl Sync for EventsCh {}
impl EventsCh {
#[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: Last result is equal or above CH\\[n\\].LIMIT.HIGH."]
#[inline(always)]
pub const fn limith(self) -> crate::common::Reg<regs::Limith, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Description cluster: Last result is equal or below CH\\[n\\].LIMIT.LOW."]
#[inline(always)]
pub const fn limitl(self) -> crate::common::Reg<regs::Limitl, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) as _) }
}
}
#[doc = "RESULT EasyDMA channel."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Result {
ptr: *mut u8,
}
unsafe impl Send for Result {}
unsafe impl Sync for Result {}
impl Result {
#[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 16-bit samples to be written to output RAM buffer."]
#[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 16-bit samples written to output RAM buffer since the previous START task."]
#[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 = "Successive approximation register (SAR) analog-to-digital converter."]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Saadc {
ptr: *mut u8,
}
unsafe impl Send for Saadc {}
unsafe impl Sync for Saadc {}
impl Saadc {
#[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 = "Starts the SAADC and prepares the result buffer in RAM."]
#[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 = "Takes one SAADC sample."]
#[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(0x04usize) as _) }
}
#[doc = "Stops the SAADC and terminates all on-going conversions."]
#[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 = "Starts offset auto-calibration."]
#[inline(always)]
pub const fn tasks_calibrateoffset(self) -> crate::common::Reg<u32, crate::common::W> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0cusize) as _) }
}
#[doc = "The SAADC has 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(0x0100usize) as _) }
}
#[doc = "The SAADC has filled up the result buffer."]
#[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 _) }
}
#[doc = "A conversion task has been completed. Depending on the configuration, multiple conversions might be needed for a result to be transferred to RAM."]
#[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(0x0108usize) as _) }
}
#[doc = "Result ready for transfer to RAM."]
#[inline(always)]
pub const fn events_resultdone(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x010cusize) as _) }
}
#[doc = "Calibration is complete."]
#[inline(always)]
pub const fn events_calibratedone(self) -> crate::common::Reg<u32, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0110usize) as _) }
}
#[doc = "The SAADC 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(0x0114usize) as _) }
}
#[doc = "Peripheral events."]
#[inline(always)]
pub const fn events_ch(self, n: usize) -> EventsCh {
assert!(n < 8usize);
unsafe { EventsCh::from_ptr(self.ptr.wrapping_add(0x0118usize + n * 8usize) 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 = "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 or disable SAADC."]
#[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 ch(self, n: usize) -> Ch {
assert!(n < 8usize);
unsafe { Ch::from_ptr(self.ptr.wrapping_add(0x0510usize + n * 16usize) as _) }
}
#[doc = "Resolution configuration."]
#[inline(always)]
pub const fn resolution(self) -> crate::common::Reg<regs::Resolution, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x05f0usize) as _) }
}
#[doc = "Oversampling configuration. The RESOLUTION is applied before averaging, thus for high OVERSAMPLE a higher RESOLUTION should be used."]
#[inline(always)]
pub const fn oversample(self) -> crate::common::Reg<regs::Oversample, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x05f4usize) as _) }
}
#[doc = "Controls normal or continuous sample rate."]
#[inline(always)]
pub const fn samplerate(self) -> crate::common::Reg<regs::Samplerate, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x05f8usize) as _) }
}
#[doc = "RESULT EasyDMA channel."]
#[inline(always)]
pub const fn result(self) -> Result {
unsafe { Result::from_ptr(self.ptr.wrapping_add(0x062cusize) as _) }
}
}
pub mod regs {
#[doc = "Number of 16-bit samples written to output RAM buffer since the previous START task."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Amount(pub u32);
impl Amount {
#[doc = "Number of 16-bit samples written to output RAM buffer since the previous START task. This register can be read after an END or STOPPED event."]
#[must_use]
#[inline(always)]
pub const fn amount(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x7fff;
val as u16
}
#[doc = "Number of 16-bit samples written to output RAM buffer since the previous START task. This register can be read after an END or STOPPED event."]
#[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 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 = "Description cluster: Input configuration for CH\\[n\\]."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Config(pub u32);
impl Config {
#[doc = "Positive channel resistor control."]
#[must_use]
#[inline(always)]
pub const fn resp(&self) -> super::vals::Resp {
let val = (self.0 >> 0usize) & 0x03;
super::vals::Resp::from_bits(val as u8)
}
#[doc = "Positive channel resistor control."]
#[inline(always)]
pub const fn set_resp(&mut self, val: super::vals::Resp) {
self.0 = (self.0 & !(0x03 << 0usize)) | (((val.to_bits() as u32) & 0x03) << 0usize);
}
#[doc = "Negative channel resistor control."]
#[must_use]
#[inline(always)]
pub const fn resn(&self) -> super::vals::Resn {
let val = (self.0 >> 4usize) & 0x03;
super::vals::Resn::from_bits(val as u8)
}
#[doc = "Negative channel resistor control."]
#[inline(always)]
pub const fn set_resn(&mut self, val: super::vals::Resn) {
self.0 = (self.0 & !(0x03 << 4usize)) | (((val.to_bits() as u32) & 0x03) << 4usize);
}
#[doc = "Gain control."]
#[must_use]
#[inline(always)]
pub const fn gain(&self) -> super::vals::Gain {
let val = (self.0 >> 8usize) & 0x07;
super::vals::Gain::from_bits(val as u8)
}
#[doc = "Gain control."]
#[inline(always)]
pub const fn set_gain(&mut self, val: super::vals::Gain) {
self.0 = (self.0 & !(0x07 << 8usize)) | (((val.to_bits() as u32) & 0x07) << 8usize);
}
#[doc = "Reference control."]
#[must_use]
#[inline(always)]
pub const fn refsel(&self) -> super::vals::Refsel {
let val = (self.0 >> 12usize) & 0x01;
super::vals::Refsel::from_bits(val as u8)
}
#[doc = "Reference control."]
#[inline(always)]
pub const fn set_refsel(&mut self, val: super::vals::Refsel) {
self.0 =
(self.0 & !(0x01 << 12usize)) | (((val.to_bits() as u32) & 0x01) << 12usize);
}
#[doc = "Acquisition time, the time the SAADC uses to sample the input voltage."]
#[must_use]
#[inline(always)]
pub const fn tacq(&self) -> super::vals::Tacq {
let val = (self.0 >> 16usize) & 0x07;
super::vals::Tacq::from_bits(val as u8)
}
#[doc = "Acquisition time, the time the SAADC uses to sample the input voltage."]
#[inline(always)]
pub const fn set_tacq(&mut self, val: super::vals::Tacq) {
self.0 =
(self.0 & !(0x07 << 16usize)) | (((val.to_bits() as u32) & 0x07) << 16usize);
}
#[doc = "Enable differential mode."]
#[must_use]
#[inline(always)]
pub const fn mode(&self) -> super::vals::ConfigMode {
let val = (self.0 >> 20usize) & 0x01;
super::vals::ConfigMode::from_bits(val as u8)
}
#[doc = "Enable differential mode."]
#[inline(always)]
pub const fn set_mode(&mut self, val: super::vals::ConfigMode) {
self.0 =
(self.0 & !(0x01 << 20usize)) | (((val.to_bits() as u32) & 0x01) << 20usize);
}
#[doc = "Enable burst mode."]
#[must_use]
#[inline(always)]
pub const fn burst(&self) -> bool {
let val = (self.0 >> 24usize) & 0x01;
val != 0
}
#[doc = "Enable burst mode."]
#[inline(always)]
pub const fn set_burst(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 24usize)) | (((val as u32) & 0x01) << 24usize);
}
}
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("resp", &self.resp())
.field("resn", &self.resn())
.field("gain", &self.gain())
.field("refsel", &self.refsel())
.field("tacq", &self.tacq())
.field("mode", &self.mode())
.field("burst", &self.burst())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Config {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Config {{ resp: {:?}, resn: {:?}, gain: {:?}, refsel: {:?}, tacq: {:?}, mode: {:?}, burst: {=bool:?} }}" , self . resp () , self . resn () , self . gain () , self . refsel () , self . tacq () , self . mode () , self . burst ())
}
}
#[doc = "Enable or disable SAADC."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Enable(pub u32);
impl Enable {
#[doc = "Enable or disable SAADC."]
#[must_use]
#[inline(always)]
pub const fn enable(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Enable or disable SAADC."]
#[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 = "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 STARTED."]
#[must_use]
#[inline(always)]
pub const fn started(&self) -> bool {
let val = (self.0 >> 0usize) & 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 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Enable or disable interrupt for event END."]
#[must_use]
#[inline(always)]
pub const fn end(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Enable or 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 = "Enable or disable interrupt for event DONE."]
#[must_use]
#[inline(always)]
pub const fn done(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event DONE."]
#[inline(always)]
pub const fn set_done(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "Enable or disable interrupt for event RESULTDONE."]
#[must_use]
#[inline(always)]
pub const fn resultdone(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event RESULTDONE."]
#[inline(always)]
pub const fn set_resultdone(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
#[doc = "Enable or disable interrupt for event CALIBRATEDONE."]
#[must_use]
#[inline(always)]
pub const fn calibratedone(&self) -> bool {
let val = (self.0 >> 4usize) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event CALIBRATEDONE."]
#[inline(always)]
pub const fn set_calibratedone(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
}
#[doc = "Enable or disable interrupt for event STOPPED."]
#[must_use]
#[inline(always)]
pub const fn stopped(&self) -> bool {
let val = (self.0 >> 5usize) & 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 << 5usize)) | (((val as u32) & 0x01) << 5usize);
}
#[doc = "Enable or disable interrupt for event CH0LIMITH."]
#[must_use]
#[inline(always)]
pub const fn chlimith(&self, n: usize) -> bool {
assert!(n < 8usize);
let offs = 6usize + n * 2usize;
let val = (self.0 >> offs) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event CH0LIMITH."]
#[inline(always)]
pub const fn set_chlimith(&mut self, n: usize, val: bool) {
assert!(n < 8usize);
let offs = 6usize + n * 2usize;
self.0 = (self.0 & !(0x01 << offs)) | (((val as u32) & 0x01) << offs);
}
#[doc = "Enable or disable interrupt for event CH0LIMITL."]
#[must_use]
#[inline(always)]
pub const fn chlimitl(&self, n: usize) -> bool {
assert!(n < 8usize);
let offs = 7usize + n * 2usize;
let val = (self.0 >> offs) & 0x01;
val != 0
}
#[doc = "Enable or disable interrupt for event CH0LIMITL."]
#[inline(always)]
pub const fn set_chlimitl(&mut self, n: usize, val: bool) {
assert!(n < 8usize);
let offs = 7usize + n * 2usize;
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("started", &self.started())
.field("end", &self.end())
.field("done", &self.done())
.field("resultdone", &self.resultdone())
.field("calibratedone", &self.calibratedone())
.field("stopped", &self.stopped())
.field("chlimith[0]", &self.chlimith(0usize))
.field("chlimith[1]", &self.chlimith(1usize))
.field("chlimith[2]", &self.chlimith(2usize))
.field("chlimith[3]", &self.chlimith(3usize))
.field("chlimith[4]", &self.chlimith(4usize))
.field("chlimith[5]", &self.chlimith(5usize))
.field("chlimith[6]", &self.chlimith(6usize))
.field("chlimith[7]", &self.chlimith(7usize))
.field("chlimitl[0]", &self.chlimitl(0usize))
.field("chlimitl[1]", &self.chlimitl(1usize))
.field("chlimitl[2]", &self.chlimitl(2usize))
.field("chlimitl[3]", &self.chlimitl(3usize))
.field("chlimitl[4]", &self.chlimitl(4usize))
.field("chlimitl[5]", &self.chlimitl(5usize))
.field("chlimitl[6]", &self.chlimitl(6usize))
.field("chlimitl[7]", &self.chlimitl(7usize))
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Int {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Int {{ started: {=bool:?}, end: {=bool:?}, done: {=bool:?}, resultdone: {=bool:?}, calibratedone: {=bool:?}, stopped: {=bool:?}, chlimith[0]: {=bool:?}, chlimith[1]: {=bool:?}, chlimith[2]: {=bool:?}, chlimith[3]: {=bool:?}, chlimith[4]: {=bool:?}, chlimith[5]: {=bool:?}, chlimith[6]: {=bool:?}, chlimith[7]: {=bool:?}, chlimitl[0]: {=bool:?}, chlimitl[1]: {=bool:?}, chlimitl[2]: {=bool:?}, chlimitl[3]: {=bool:?}, chlimitl[4]: {=bool:?}, chlimitl[5]: {=bool:?}, chlimitl[6]: {=bool:?}, chlimitl[7]: {=bool:?} }}" , self . started () , self . end () , self . done () , self . resultdone () , self . calibratedone () , self . stopped () , self . chlimith (0usize) , self . chlimith (1usize) , self . chlimith (2usize) , self . chlimith (3usize) , self . chlimith (4usize) , self . chlimith (5usize) , self . chlimith (6usize) , self . chlimith (7usize) , self . chlimitl (0usize) , self . chlimitl (1usize) , self . chlimitl (2usize) , self . chlimitl (3usize) , self . chlimitl (4usize) , self . chlimitl (5usize) , self . chlimitl (6usize) , self . chlimitl (7usize))
}
}
#[doc = "Description cluster: High/low limits for event monitoring of a channel."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Limit(pub u32);
impl Limit {
#[doc = "Low level limit."]
#[must_use]
#[inline(always)]
pub const fn low(&self) -> u16 {
let val = (self.0 >> 0usize) & 0xffff;
val as u16
}
#[doc = "Low level limit."]
#[inline(always)]
pub const fn set_low(&mut self, val: u16) {
self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize);
}
#[doc = "High level limit."]
#[must_use]
#[inline(always)]
pub const fn high(&self) -> u16 {
let val = (self.0 >> 16usize) & 0xffff;
val as u16
}
#[doc = "High level limit."]
#[inline(always)]
pub const fn set_high(&mut self, val: u16) {
self.0 = (self.0 & !(0xffff << 16usize)) | (((val as u32) & 0xffff) << 16usize);
}
}
impl Default for Limit {
#[inline(always)]
fn default() -> Limit {
Limit(0)
}
}
impl core::fmt::Debug for Limit {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Limit")
.field("low", &self.low())
.field("high", &self.high())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Limit {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Limit {{ low: {=u16:?}, high: {=u16:?} }}",
self.low(),
self.high()
)
}
}
#[doc = "Description cluster: Last result is equal or above CH\\[n\\].LIMIT.HIGH."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Limith(pub u32);
impl Limith {
#[doc = "Last result is equal or above CH\\[n\\].LIMIT.HIGH."]
#[must_use]
#[inline(always)]
pub const fn limith(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Last result is equal or above CH\\[n\\].LIMIT.HIGH."]
#[inline(always)]
pub const fn set_limith(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for Limith {
#[inline(always)]
fn default() -> Limith {
Limith(0)
}
}
impl core::fmt::Debug for Limith {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Limith")
.field("limith", &self.limith())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Limith {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Limith {{ limith: {=bool:?} }}", self.limith())
}
}
#[doc = "Description cluster: Last result is equal or below CH\\[n\\].LIMIT.LOW."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Limitl(pub u32);
impl Limitl {
#[doc = "Last result is equal or below CH\\[n\\].LIMIT.LOW."]
#[must_use]
#[inline(always)]
pub const fn limitl(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Last result is equal or below CH\\[n\\].LIMIT.LOW."]
#[inline(always)]
pub const fn set_limitl(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
}
impl Default for Limitl {
#[inline(always)]
fn default() -> Limitl {
Limitl(0)
}
}
impl core::fmt::Debug for Limitl {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Limitl")
.field("limitl", &self.limitl())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Limitl {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Limitl {{ limitl: {=bool:?} }}", self.limitl())
}
}
#[doc = "Maximum number of 16-bit samples to be written to output RAM buffer."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Maxcnt(pub u32);
impl Maxcnt {
#[doc = "Maximum number of 16-bit samples to be written to output RAM buffer."]
#[must_use]
#[inline(always)]
pub const fn maxcnt(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x7fff;
val as u16
}
#[doc = "Maximum number of 16-bit samples to be written to output RAM 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 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 = "Oversampling configuration. The RESOLUTION is applied before averaging, thus for high OVERSAMPLE a higher RESOLUTION should be used."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Oversample(pub u32);
impl Oversample {
#[doc = "Oversample control."]
#[must_use]
#[inline(always)]
pub const fn oversample(&self) -> super::vals::Oversample {
let val = (self.0 >> 0usize) & 0x0f;
super::vals::Oversample::from_bits(val as u8)
}
#[doc = "Oversample control."]
#[inline(always)]
pub const fn set_oversample(&mut self, val: super::vals::Oversample) {
self.0 = (self.0 & !(0x0f << 0usize)) | (((val.to_bits() as u32) & 0x0f) << 0usize);
}
}
impl Default for Oversample {
#[inline(always)]
fn default() -> Oversample {
Oversample(0)
}
}
impl core::fmt::Debug for Oversample {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Oversample")
.field("oversample", &self.oversample())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Oversample {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Oversample {{ oversample: {:?} }}", self.oversample())
}
}
#[doc = "Description cluster: Input negative pin selection for CH\\[n\\]."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Pseln(pub u32);
impl Pseln {
#[doc = "Analog negative input, enables differential channel."]
#[must_use]
#[inline(always)]
pub const fn pseln(&self) -> super::vals::Psel {
let val = (self.0 >> 0usize) & 0x1f;
super::vals::Psel::from_bits(val as u8)
}
#[doc = "Analog negative input, enables differential channel."]
#[inline(always)]
pub const fn set_pseln(&mut self, val: super::vals::Psel) {
self.0 = (self.0 & !(0x1f << 0usize)) | (((val.to_bits() as u32) & 0x1f) << 0usize);
}
}
impl Default for Pseln {
#[inline(always)]
fn default() -> Pseln {
Pseln(0)
}
}
impl core::fmt::Debug for Pseln {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Pseln")
.field("pseln", &self.pseln())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Pseln {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Pseln {{ pseln: {:?} }}", self.pseln())
}
}
#[doc = "Description cluster: Input positive pin selection for CH\\[n\\]."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Pselp(pub u32);
impl Pselp {
#[doc = "Analog positive input channel."]
#[must_use]
#[inline(always)]
pub const fn pselp(&self) -> super::vals::Psel {
let val = (self.0 >> 0usize) & 0x1f;
super::vals::Psel::from_bits(val as u8)
}
#[doc = "Analog positive input channel."]
#[inline(always)]
pub const fn set_pselp(&mut self, val: super::vals::Psel) {
self.0 = (self.0 & !(0x1f << 0usize)) | (((val.to_bits() as u32) & 0x1f) << 0usize);
}
}
impl Default for Pselp {
#[inline(always)]
fn default() -> Pselp {
Pselp(0)
}
}
impl core::fmt::Debug for Pselp {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Pselp")
.field("pselp", &self.pselp())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Pselp {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Pselp {{ pselp: {:?} }}", self.pselp())
}
}
#[doc = "Resolution configuration."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Resolution(pub u32);
impl Resolution {
#[doc = "Set the resolution."]
#[must_use]
#[inline(always)]
pub const fn val(&self) -> super::vals::Val {
let val = (self.0 >> 0usize) & 0x07;
super::vals::Val::from_bits(val as u8)
}
#[doc = "Set the resolution."]
#[inline(always)]
pub const fn set_val(&mut self, val: super::vals::Val) {
self.0 = (self.0 & !(0x07 << 0usize)) | (((val.to_bits() as u32) & 0x07) << 0usize);
}
}
impl Default for Resolution {
#[inline(always)]
fn default() -> Resolution {
Resolution(0)
}
}
impl core::fmt::Debug for Resolution {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Resolution")
.field("val", &self.val())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Resolution {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Resolution {{ val: {:?} }}", self.val())
}
}
#[doc = "Controls normal or continuous sample rate."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Samplerate(pub u32);
impl Samplerate {
#[doc = "Capture and compare value. Sample rate is 16 MHz/CC."]
#[must_use]
#[inline(always)]
pub const fn cc(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x07ff;
val as u16
}
#[doc = "Capture and compare value. Sample rate is 16 MHz/CC."]
#[inline(always)]
pub const fn set_cc(&mut self, val: u16) {
self.0 = (self.0 & !(0x07ff << 0usize)) | (((val as u32) & 0x07ff) << 0usize);
}
#[doc = "Select mode for sample rate control."]
#[must_use]
#[inline(always)]
pub const fn mode(&self) -> super::vals::SamplerateMode {
let val = (self.0 >> 12usize) & 0x01;
super::vals::SamplerateMode::from_bits(val as u8)
}
#[doc = "Select mode for sample rate control."]
#[inline(always)]
pub const fn set_mode(&mut self, val: super::vals::SamplerateMode) {
self.0 =
(self.0 & !(0x01 << 12usize)) | (((val.to_bits() as u32) & 0x01) << 12usize);
}
}
impl Default for Samplerate {
#[inline(always)]
fn default() -> Samplerate {
Samplerate(0)
}
}
impl core::fmt::Debug for Samplerate {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Samplerate")
.field("cc", &self.cc())
.field("mode", &self.mode())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Samplerate {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Samplerate {{ cc: {=u16:?}, mode: {:?} }}",
self.cc(),
self.mode()
)
}
}
#[doc = "Status."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Status(pub u32);
impl Status {
#[doc = "Status."]
#[must_use]
#[inline(always)]
pub const fn status(&self) -> super::vals::Status {
let val = (self.0 >> 0usize) & 0x01;
super::vals::Status::from_bits(val as u8)
}
#[doc = "Status."]
#[inline(always)]
pub const fn set_status(&mut self, val: super::vals::Status) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 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: {:?} }}", self.status())
}
}
}
pub mod vals {
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum ConfigMode {
#[doc = "Single-ended, PSELN will be ignored, negative input to SAADC shorted to GND."]
Se = 0x0,
#[doc = "Differential."]
Diff = 0x01,
}
impl ConfigMode {
#[inline(always)]
pub const fn from_bits(val: u8) -> ConfigMode {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for ConfigMode {
#[inline(always)]
fn from(val: u8) -> ConfigMode {
ConfigMode::from_bits(val)
}
}
impl From<ConfigMode> for u8 {
#[inline(always)]
fn from(val: ConfigMode) -> u8 {
ConfigMode::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Gain {
#[doc = "1/6."]
Gain16 = 0x0,
#[doc = "1/5."]
Gain15 = 0x01,
#[doc = "1/4."]
Gain14 = 0x02,
#[doc = "1/3."]
Gain13 = 0x03,
#[doc = "1/2."]
Gain12 = 0x04,
#[doc = "1."]
Gain1 = 0x05,
#[doc = "2."]
Gain2 = 0x06,
#[doc = "4."]
Gain4 = 0x07,
}
impl Gain {
#[inline(always)]
pub const fn from_bits(val: u8) -> Gain {
unsafe { core::mem::transmute(val & 0x07) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Gain {
#[inline(always)]
fn from(val: u8) -> Gain {
Gain::from_bits(val)
}
}
impl From<Gain> for u8 {
#[inline(always)]
fn from(val: Gain) -> u8 {
Gain::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Oversample {
#[doc = "Bypass oversampling."]
Bypass = 0x0,
#[doc = "Oversample 2x."]
Over2x = 0x01,
#[doc = "Oversample 4x."]
Over4x = 0x02,
#[doc = "Oversample 8x."]
Over8x = 0x03,
#[doc = "Oversample 16x."]
Over16x = 0x04,
#[doc = "Oversample 32x."]
Over32x = 0x05,
#[doc = "Oversample 64x."]
Over64x = 0x06,
#[doc = "Oversample 128x."]
Over128x = 0x07,
#[doc = "Oversample 256x."]
Over256x = 0x08,
_RESERVED_9 = 0x09,
_RESERVED_a = 0x0a,
_RESERVED_b = 0x0b,
_RESERVED_c = 0x0c,
_RESERVED_d = 0x0d,
_RESERVED_e = 0x0e,
_RESERVED_f = 0x0f,
}
impl Oversample {
#[inline(always)]
pub const fn from_bits(val: u8) -> Oversample {
unsafe { core::mem::transmute(val & 0x0f) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Oversample {
#[inline(always)]
fn from(val: u8) -> Oversample {
Oversample::from_bits(val)
}
}
impl From<Oversample> for u8 {
#[inline(always)]
fn from(val: Oversample) -> u8 {
Oversample::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Psel {
#[doc = "Not connected."]
Nc = 0x0,
#[doc = "AIN0."]
AnalogInput0 = 0x01,
#[doc = "AIN1."]
AnalogInput1 = 0x02,
#[doc = "AIN2."]
AnalogInput2 = 0x03,
#[doc = "AIN3."]
AnalogInput3 = 0x04,
#[doc = "AIN4."]
AnalogInput4 = 0x05,
#[doc = "AIN5."]
AnalogInput5 = 0x06,
#[doc = "AIN6."]
AnalogInput6 = 0x07,
#[doc = "AIN7."]
AnalogInput7 = 0x08,
#[doc = "VDD."]
Vdd = 0x09,
_RESERVED_a = 0x0a,
_RESERVED_b = 0x0b,
_RESERVED_c = 0x0c,
#[doc = "VDDH/5."]
Vddhdiv5 = 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 Psel {
#[inline(always)]
pub const fn from_bits(val: u8) -> Psel {
unsafe { core::mem::transmute(val & 0x1f) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Psel {
#[inline(always)]
fn from(val: u8) -> Psel {
Psel::from_bits(val)
}
}
impl From<Psel> for u8 {
#[inline(always)]
fn from(val: Psel) -> u8 {
Psel::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Refsel {
#[doc = "Internal reference (0.6 V)."]
Internal = 0x0,
#[doc = "VDD/4 as reference."]
Vdd14 = 0x01,
}
impl Refsel {
#[inline(always)]
pub const fn from_bits(val: u8) -> Refsel {
unsafe { core::mem::transmute(val & 0x01) }
}
#[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 Resn {
#[doc = "Bypass resistor ladder."]
Bypass = 0x0,
#[doc = "Pull-down to GND."]
Pulldown = 0x01,
#[doc = "Pull-up to VDD."]
Pullup = 0x02,
#[doc = "Set input at VDD/2."]
Vdd12 = 0x03,
}
impl Resn {
#[inline(always)]
pub const fn from_bits(val: u8) -> Resn {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Resn {
#[inline(always)]
fn from(val: u8) -> Resn {
Resn::from_bits(val)
}
}
impl From<Resn> for u8 {
#[inline(always)]
fn from(val: Resn) -> u8 {
Resn::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Resp {
#[doc = "Bypass resistor ladder."]
Bypass = 0x0,
#[doc = "Pull-down to GND."]
Pulldown = 0x01,
#[doc = "Pull-up to VDD."]
Pullup = 0x02,
#[doc = "Set input at VDD/2."]
Vdd12 = 0x03,
}
impl Resp {
#[inline(always)]
pub const fn from_bits(val: u8) -> Resp {
unsafe { core::mem::transmute(val & 0x03) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Resp {
#[inline(always)]
fn from(val: u8) -> Resp {
Resp::from_bits(val)
}
}
impl From<Resp> for u8 {
#[inline(always)]
fn from(val: Resp) -> u8 {
Resp::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum SamplerateMode {
#[doc = "Rate is controlled from SAMPLE task."]
Task = 0x0,
#[doc = "Rate is controlled from local timer (use CC to control the rate)."]
Timers = 0x01,
}
impl SamplerateMode {
#[inline(always)]
pub const fn from_bits(val: u8) -> SamplerateMode {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for SamplerateMode {
#[inline(always)]
fn from(val: u8) -> SamplerateMode {
SamplerateMode::from_bits(val)
}
}
impl From<SamplerateMode> for u8 {
#[inline(always)]
fn from(val: SamplerateMode) -> u8 {
SamplerateMode::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Status {
#[doc = "SAADC is ready. No on-going conversions."]
Ready = 0x0,
#[doc = "SAADC is busy. Conversion in progress."]
Busy = 0x01,
}
impl Status {
#[inline(always)]
pub const fn from_bits(val: u8) -> Status {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Status {
#[inline(always)]
fn from(val: u8) -> Status {
Status::from_bits(val)
}
}
impl From<Status> for u8 {
#[inline(always)]
fn from(val: Status) -> u8 {
Status::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Tacq {
#[doc = "3 us."]
_3us = 0x0,
#[doc = "5 us."]
_5us = 0x01,
#[doc = "10 us."]
_10us = 0x02,
#[doc = "15 us."]
_15us = 0x03,
#[doc = "20 us."]
_20us = 0x04,
#[doc = "40 us."]
_40us = 0x05,
_RESERVED_6 = 0x06,
_RESERVED_7 = 0x07,
}
impl Tacq {
#[inline(always)]
pub const fn from_bits(val: u8) -> Tacq {
unsafe { core::mem::transmute(val & 0x07) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Tacq {
#[inline(always)]
fn from(val: u8) -> Tacq {
Tacq::from_bits(val)
}
}
impl From<Tacq> for u8 {
#[inline(always)]
fn from(val: Tacq) -> u8 {
Tacq::to_bits(val)
}
}
#[repr(u8)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Val {
#[doc = "8 bits."]
_8bit = 0x0,
#[doc = "10 bits."]
_10bit = 0x01,
#[doc = "12 bits."]
_12bit = 0x02,
#[doc = "14 bits."]
_14bit = 0x03,
_RESERVED_4 = 0x04,
_RESERVED_5 = 0x05,
_RESERVED_6 = 0x06,
_RESERVED_7 = 0x07,
}
impl Val {
#[inline(always)]
pub const fn from_bits(val: u8) -> Val {
unsafe { core::mem::transmute(val & 0x07) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Val {
#[inline(always)]
fn from(val: u8) -> Val {
Val::from_bits(val)
}
}
impl From<Val> for u8 {
#[inline(always)]
fn from(val: Val) -> u8 {
Val::to_bits(val)
}
}
}
}
pub mod shared {
pub mod regs {
#[doc = "Pin select for LRCK 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 = "Port number."]
#[must_use]
#[inline(always)]
pub const fn port(&self) -> bool {
let val = (self.0 >> 5usize) & 0x01;
val != 0
}
#[doc = "Port number."]
#[inline(always)]
pub const fn set_port(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
}
#[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("port", &self.port())
.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:?}, port: {=bool:?}, connect: {:?} }}",
self.pin(),
self.port(),
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. Register is cleared on read and the buffer pointer will be modified if read."]
#[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. Register is cleared on read and the buffer pointer will be modified if read."]
#[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 Iftiming {
ptr: *mut u8,
}
unsafe impl Send for Iftiming {}
unsafe impl Sync for Iftiming {}
impl Iftiming {
#[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 = "Sample delay for input serial data on MISO."]
#[inline(always)]
pub const fn rxdelay(self) -> crate::common::Reg<regs::Rxdelay, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0usize) as _) }
}
#[doc = "Minimum duration between edge of CSN and edge of SCK at the start and the end of a transaction, and minimum duration CSN will stay high between transactions if END-START shortcut is used."]
#[inline(always)]
pub const fn csndur(self) -> crate::common::Reg<regs::Csndur, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x04usize) 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 = "Pin select for CSN."]
#[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 = "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 = "Stall status for EasyDMA RAM accesses. The fields in this register are set to STALL by hardware whenever a stall occurs and can be cleared (set to NOSTALL) by the CPU."]
#[inline(always)]
pub const fn stallstat(self) -> crate::common::Reg<regs::Stallstat, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0400usize) 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 = "Unspecified."]
#[inline(always)]
pub const fn iftiming(self) -> Iftiming {
unsafe { Iftiming::from_ptr(self.ptr.wrapping_add(0x0560usize) as _) }
}
#[doc = "Polarity of CSN output."]
#[inline(always)]
pub const fn csnpol(self) -> crate::common::Reg<regs::Csnpol, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0568usize) as _) }
}
#[doc = "Pin select for DCX signal."]
#[inline(always)]
pub const fn pseldcx(
self,
) -> crate::common::Reg<super::shared::regs::Psel, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x056cusize) as _) }
}
#[doc = "DCX configuration."]
#[inline(always)]
pub const fn dcxcnt(self) -> crate::common::Reg<regs::Dcxcnt, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x0570usize) 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 = "Minimum duration between edge of CSN and edge of SCK at the start and the end of a transaction, and minimum duration CSN will stay high between transactions if END-START shortcut is used."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Csndur(pub u32);
impl Csndur {
#[doc = "Minimum duration between edge of CSN and edge of SCK at the start and end of a transaction. If END-START shortcut is used, minimum duration CSN will stay high between transactions. The value is specified in number of 64 MHz clock cycles (15.625 ns)."]
#[must_use]
#[inline(always)]
pub const fn csndur(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "Minimum duration between edge of CSN and edge of SCK at the start and end of a transaction. If END-START shortcut is used, minimum duration CSN will stay high between transactions. The value is specified in number of 64 MHz clock cycles (15.625 ns)."]
#[inline(always)]
pub const fn set_csndur(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
}
impl Default for Csndur {
#[inline(always)]
fn default() -> Csndur {
Csndur(0)
}
}
impl core::fmt::Debug for Csndur {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Csndur")
.field("csndur", &self.csndur())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Csndur {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Csndur {{ csndur: {=u8:?} }}", self.csndur())
}
}
#[doc = "Polarity of CSN output."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Csnpol(pub u32);
impl Csnpol {
#[doc = "Polarity of CSN output."]
#[must_use]
#[inline(always)]
pub const fn csnpol(&self) -> super::vals::Csnpol {
let val = (self.0 >> 0usize) & 0x01;
super::vals::Csnpol::from_bits(val as u8)
}
#[doc = "Polarity of CSN output."]
#[inline(always)]
pub const fn set_csnpol(&mut self, val: super::vals::Csnpol) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
}
impl Default for Csnpol {
#[inline(always)]
fn default() -> Csnpol {
Csnpol(0)
}
}
impl core::fmt::Debug for Csnpol {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Csnpol")
.field("csnpol", &self.csnpol())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Csnpol {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Csnpol {{ csnpol: {:?} }}", self.csnpol())
}
}
#[doc = "DCX configuration."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Dcxcnt(pub u32);
impl Dcxcnt {
#[doc = "This register specifies the number of command bytes preceding the data bytes. The PSEL.DCX line will be low during transmission of command bytes and high during transmission of data bytes. Value 0xF indicates that all bytes are command bytes."]
#[must_use]
#[inline(always)]
pub const fn dcxcnt(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x0f;
val as u8
}
#[doc = "This register specifies the number of command bytes preceding the data bytes. The PSEL.DCX line will be low during transmission of command bytes and high during transmission of data bytes. Value 0xF indicates that all bytes are command bytes."]
#[inline(always)]
pub const fn set_dcxcnt(&mut self, val: u8) {
self.0 = (self.0 & !(0x0f << 0usize)) | (((val as u32) & 0x0f) << 0usize);
}
}
impl Default for Dcxcnt {
#[inline(always)]
fn default() -> Dcxcnt {
Dcxcnt(0)
}
}
impl core::fmt::Debug for Dcxcnt {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Dcxcnt")
.field("dcxcnt", &self.dcxcnt())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Dcxcnt {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Dcxcnt {{ dcxcnt: {=u8:?} }}", self.dcxcnt())
}
}
#[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) & 0xffff;
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 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 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) & 0xffff;
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 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 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 = "Sample delay for input serial data on MISO."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Rxdelay(pub u32);
impl Rxdelay {
#[doc = "Sample delay for input serial data on MISO. The value specifies the number of 64 MHz clock cycles (15.625 ns) delay from the the sampling edge of SCK (leading edge for CONFIG.CPHA = 0, trailing edge for CONFIG.CPHA = 1) until the input serial data is sampled. As en example, if RXDELAY = 0 and CONFIG.CPHA = 0, the input serial data is sampled on the rising edge of SCK."]
#[must_use]
#[inline(always)]
pub const fn rxdelay(&self) -> u8 {
let val = (self.0 >> 0usize) & 0x07;
val as u8
}
#[doc = "Sample delay for input serial data on MISO. The value specifies the number of 64 MHz clock cycles (15.625 ns) delay from the the sampling edge of SCK (leading edge for CONFIG.CPHA = 0, trailing edge for CONFIG.CPHA = 1) until the input serial data is sampled. As en example, if RXDELAY = 0 and CONFIG.CPHA = 0, the input serial data is sampled on the rising edge of SCK."]
#[inline(always)]
pub const fn set_rxdelay(&mut self, val: u8) {
self.0 = (self.0 & !(0x07 << 0usize)) | (((val as u32) & 0x07) << 0usize);
}
}
impl Default for Rxdelay {
#[inline(always)]
fn default() -> Rxdelay {
Rxdelay(0)
}
}
impl core::fmt::Debug for Rxdelay {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Rxdelay")
.field("rxdelay", &self.rxdelay())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Rxdelay {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Rxdelay {{ rxdelay: {=u8:?} }}", self.rxdelay())
}
}
#[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 = "Stall status for EasyDMA RAM accesses. The fields in this register are set to STALL by hardware whenever a stall occurs and can be cleared (set to NOSTALL) by the CPU."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Stallstat(pub u32);
impl Stallstat {
#[doc = "Stall status for EasyDMA RAM reads."]
#[must_use]
#[inline(always)]
pub const fn tx(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Stall status for EasyDMA RAM reads."]
#[inline(always)]
pub const fn set_tx(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Stall status for EasyDMA RAM writes."]
#[must_use]
#[inline(always)]
pub const fn rx(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Stall status for EasyDMA RAM writes."]
#[inline(always)]
pub const fn set_rx(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
}
impl Default for Stallstat {
#[inline(always)]
fn default() -> Stallstat {
Stallstat(0)
}
}
impl core::fmt::Debug for Stallstat {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Stallstat")
.field("tx", &self.tx())
.field("rx", &self.rx())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Stallstat {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Stallstat {{ tx: {=bool:?}, rx: {=bool:?} }}",
self.tx(),
self.rx()
)
}
}
#[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) & 0xffff;
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 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 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) & 0xffff;
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 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 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 Csnpol {
#[doc = "Active low (idle state high)."]
Low = 0x0,
#[doc = "Active high (idle state low)."]
High = 0x01,
}
impl Csnpol {
#[inline(always)]
pub const fn from_bits(val: u8) -> Csnpol {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Csnpol {
#[inline(always)]
fn from(val: u8) -> Csnpol {
Csnpol::from_bits(val)
}
}
impl From<Csnpol> for u8 {
#[inline(always)]
fn from(val: Csnpol) -> u8 {
Csnpol::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 = "16 Mbps."]
pub const M16: Self = Self(0x0a00_0000);
#[doc = "1 Mbps."]
pub const M1: Self = Self(0x1000_0000);
#[doc = "32 Mbps."]
pub const M32: Self = Self(0x1400_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"),
0x0a00_0000 => f.write_str("M16"),
0x1000_0000 => f.write_str("M1"),
0x1400_0000 => f.write_str("M32"),
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"),
0x0a00_0000 => defmt::write!(f, "M16"),
0x1000_0000 => defmt::write!(f, "M1"),
0x1400_0000 => defmt::write!(f, "M32"),
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) & 0xffff;
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 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 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) & 0xffff;
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 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 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) & 0xffff;
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 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 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) & 0xffff;
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 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 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. Register is cleared on read and the buffer pointer will be modified if read."]
#[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. Register is cleared on read and the buffer pointer will be modified if read."]
#[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) & 0xffff;
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 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 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) & 0xffff;
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 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 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) & 0xffff;
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 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 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) & 0xffff;
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 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 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) & 0xffff;
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 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 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) & 0xffff;
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 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 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) & 0xffff;
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 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 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) & 0xffff;
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 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 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. Register is cleared on read and the double buffered byte will be moved to RXD if it exists."]
#[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);
}
}
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())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Config {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Config {{ hwfc: {=bool:?}, parity: {:?}, stop: {:?} }}",
self.hwfc(),
self.parity(),
self.stop()
)
}
}
#[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. Register is cleared on read and the double buffered byte will be moved to RXD if it exists."]
#[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 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 0."]
#[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);
}
}
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())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Config {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Config {{ hwfc: {=bool:?}, parity: {:?}, stop: {:?} }}",
self.hwfc(),
self.parity(),
self.stop()
)
}
}
#[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) & 0xffff;
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 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 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) & 0xffff;
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 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 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) & 0xffff;
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 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 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) & 0xffff;
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 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 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 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 = "Setting of pins dedicated to NFC functionality: NFC antenna or GPIO."]
#[inline(always)]
pub const fn nfcpins(self) -> crate::common::Reg<regs::Nfcpins, crate::common::RW> {
unsafe { crate::common::Reg::from_ptr(self.ptr.wrapping_add(0x020cusize) 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 non-intrusive debug features."]
#[must_use]
#[inline(always)]
pub const fn cpuniden(&self) -> super::vals::Cpuniden {
let val = (self.0 >> 0usize) & 0xff;
super::vals::Cpuniden::from_bits(val as u8)
}
#[doc = "Configure CPU non-intrusive debug features."]
#[inline(always)]
pub const fn set_cpuniden(&mut self, val: super::vals::Cpuniden) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val.to_bits() as u32) & 0xff) << 0usize);
}
#[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("cpuniden", &self.cpuniden())
.field("cpufpben", &self.cpufpben())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Debugctrl {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Debugctrl {{ cpuniden: {:?}, cpufpben: {:?} }}",
self.cpuniden(),
self.cpufpben()
)
}
}
#[doc = "Setting of pins dedicated to NFC functionality: NFC antenna or GPIO."]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Nfcpins(pub u32);
impl Nfcpins {
#[doc = "Setting of pins dedicated to NFC functionality."]
#[must_use]
#[inline(always)]
pub const fn protect(&self) -> super::vals::Protect {
let val = (self.0 >> 0usize) & 0x01;
super::vals::Protect::from_bits(val as u8)
}
#[doc = "Setting of pins dedicated to NFC functionality."]
#[inline(always)]
pub const fn set_protect(&mut self, val: super::vals::Protect) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val.to_bits() as u32) & 0x01) << 0usize);
}
}
impl Default for Nfcpins {
#[inline(always)]
fn default() -> Nfcpins {
Nfcpins(0)
}
}
impl core::fmt::Debug for Nfcpins {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Nfcpins")
.field("protect", &self.protect())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Nfcpins {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Nfcpins {{ protect: {:?} }}", self.protect())
}
}
#[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 Cpuniden(u8);
impl Cpuniden {
#[doc = "Disable CPU ITM and ETM functionality."]
pub const Disabled: Self = Self(0x0);
#[doc = "Enable CPU ITM and ETM functionality (default behavior)."]
pub const Enabled: Self = Self(0xff);
}
impl Cpuniden {
pub const fn from_bits(val: u8) -> Cpuniden {
Self(val & 0xff)
}
pub const fn to_bits(self) -> u8 {
self.0
}
}
impl core::fmt::Debug for Cpuniden {
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 Cpuniden {
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 Cpuniden {
#[inline(always)]
fn from(val: u8) -> Cpuniden {
Cpuniden::from_bits(val)
}
}
impl From<Cpuniden> for u8 {
#[inline(always)]
fn from(val: Cpuniden) -> u8 {
Cpuniden::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 Protect {
#[doc = "Operation as GPIO pins. Same protection as normal GPIO pins."]
Disabled = 0x0,
#[doc = "Operation as NFC antenna pins. Configures the protection for NFC operation."]
Nfc = 0x01,
}
impl Protect {
#[inline(always)]
pub const fn from_bits(val: u8) -> Protect {
unsafe { core::mem::transmute(val & 0x01) }
}
#[inline(always)]
pub const fn to_bits(self) -> u8 {
unsafe { core::mem::transmute(self) }
}
}
impl From<u8> for Protect {
#[inline(always)]
fn from(val: u8) -> Protect {
Protect::from_bits(val)
}
}
impl From<Protect> for u8 {
#[inline(always)]
fn from(val: Protect) -> u8 {
Protect::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)
}
}
}
}