#[doc = "CR1"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Cr1(pub u32);
impl Cr1 {
#[doc = "Clock phase"]
#[must_use]
#[inline(always)]
pub const fn cpha(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Clock phase"]
#[inline(always)]
pub const fn set_cpha(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Clock polarity"]
#[must_use]
#[inline(always)]
pub const fn cpol(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Clock polarity"]
#[inline(always)]
pub const fn set_cpol(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "Master selection"]
#[must_use]
#[inline(always)]
pub const fn mstr(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Master selection"]
#[inline(always)]
pub const fn set_mstr(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "Baud rate control"]
#[must_use]
#[inline(always)]
pub const fn br(&self) -> u8 {
let val = (self.0 >> 3usize) & 0x07;
val as u8
}
#[doc = "Baud rate control"]
#[inline(always)]
pub const fn set_br(&mut self, val: u8) {
self.0 = (self.0 & !(0x07 << 3usize)) | (((val as u32) & 0x07) << 3usize);
}
#[doc = "SPI enable"]
#[must_use]
#[inline(always)]
pub const fn spe(&self) -> bool {
let val = (self.0 >> 6usize) & 0x01;
val != 0
}
#[doc = "SPI enable"]
#[inline(always)]
pub const fn set_spe(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize);
}
#[doc = "Frame format"]
#[must_use]
#[inline(always)]
pub const fn lsbfirst(&self) -> bool {
let val = (self.0 >> 7usize) & 0x01;
val != 0
}
#[doc = "Frame format"]
#[inline(always)]
pub const fn set_lsbfirst(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize);
}
#[doc = "Internal slave select"]
#[must_use]
#[inline(always)]
pub const fn ssi(&self) -> bool {
let val = (self.0 >> 8usize) & 0x01;
val != 0
}
#[doc = "Internal slave select"]
#[inline(always)]
pub const fn set_ssi(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize);
}
#[doc = "Software slave management"]
#[must_use]
#[inline(always)]
pub const fn ssm(&self) -> bool {
let val = (self.0 >> 9usize) & 0x01;
val != 0
}
#[doc = "Software slave management"]
#[inline(always)]
pub const fn set_ssm(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 9usize)) | (((val as u32) & 0x01) << 9usize);
}
#[doc = "Receive only mode enabled"]
#[must_use]
#[inline(always)]
pub const fn rxonly(&self) -> bool {
let val = (self.0 >> 10usize) & 0x01;
val != 0
}
#[doc = "Receive only mode enabled"]
#[inline(always)]
pub const fn set_rxonly(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 10usize)) | (((val as u32) & 0x01) << 10usize);
}
#[doc = "Output enable in bidirectional mode"]
#[must_use]
#[inline(always)]
pub const fn bidioe(&self) -> bool {
let val = (self.0 >> 14usize) & 0x01;
val != 0
}
#[doc = "Output enable in bidirectional mode"]
#[inline(always)]
pub const fn set_bidioe(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 14usize)) | (((val as u32) & 0x01) << 14usize);
}
#[doc = "Bidirectional data mode enable"]
#[must_use]
#[inline(always)]
pub const fn bidimode(&self) -> bool {
let val = (self.0 >> 15usize) & 0x01;
val != 0
}
#[doc = "Bidirectional data mode enable"]
#[inline(always)]
pub const fn set_bidimode(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 15usize)) | (((val as u32) & 0x01) << 15usize);
}
#[doc = "Fake interface"]
#[inline(always)]
pub const fn set_crcen(&mut self, _val: bool) {
}
}
impl Default for Cr1 {
#[inline(always)]
fn default() -> Cr1 {
Cr1(0)
}
}
impl core::fmt::Debug for Cr1 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Cr1")
.field("cpha", &self.cpha())
.field("cpol", &self.cpol())
.field("mstr", &self.mstr())
.field("br", &self.br())
.field("spe", &self.spe())
.field("lsbfirst", &self.lsbfirst())
.field("ssi", &self.ssi())
.field("ssm", &self.ssm())
.field("rxonly", &self.rxonly())
.field("bidioe", &self.bidioe())
.field("bidimode", &self.bidimode())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Cr1 {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Cr1 {{ cpha: {=bool:?}, cpol: {=bool:?}, mstr: {=bool:?}, br: {=u8:?}, spe: {=bool:?}, lsbfirst: {=bool:?}, ssi: {=bool:?}, ssm: {=bool:?}, rxonly: {=bool:?}, bidioe: {=bool:?}, bidimode: {=bool:?} }}" , self . cpha () , self . cpol () , self . mstr () , self . br () , self . spe () , self . lsbfirst () , self . ssi () , self . ssm () , self . rxonly () , self . bidioe () , self . bidimode ())
}
}
#[doc = "CR2"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Cr2(pub u32);
impl Cr2 {
#[doc = "SS output enable"]
#[must_use]
#[inline(always)]
pub const fn ssoe(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "SS output enable"]
#[inline(always)]
pub const fn set_ssoe(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "NSS pulse management"]
#[must_use]
#[inline(always)]
pub const fn nssp(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "NSS pulse management"]
#[inline(always)]
pub const fn set_nssp(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
#[doc = "Frame format"]
#[must_use]
#[inline(always)]
pub const fn frf(&self) -> bool {
let val = (self.0 >> 4usize) & 0x01;
val != 0
}
#[doc = "Frame format"]
#[inline(always)]
pub const fn set_frf(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
}
#[doc = "Error interrupt enable"]
#[must_use]
#[inline(always)]
pub const fn errie(&self) -> bool {
let val = (self.0 >> 5usize) & 0x01;
val != 0
}
#[doc = "Error interrupt enable"]
#[inline(always)]
pub const fn set_errie(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
}
#[doc = "RX buffer not empty interrupt enable"]
#[must_use]
#[inline(always)]
pub const fn rxneie(&self) -> bool {
let val = (self.0 >> 6usize) & 0x01;
val != 0
}
#[doc = "RX buffer not empty interrupt enable"]
#[inline(always)]
pub const fn set_rxneie(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize);
}
#[doc = "TX buffer empty interrupt enable"]
#[must_use]
#[inline(always)]
pub const fn txeie(&self) -> bool {
let val = (self.0 >> 7usize) & 0x01;
val != 0
}
#[doc = "TX buffer empty interrupt enable"]
#[inline(always)]
pub const fn set_txeie(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize);
}
#[doc = "Data size"]
#[must_use]
#[inline(always)]
pub const fn ds(&self) -> u8 {
let val = (self.0 >> 8usize) & 0x0f;
val as u8
}
#[doc = "Data size"]
#[inline(always)]
pub const fn set_ds(&mut self, val: u8) {
self.0 = (self.0 & !(0x0f << 8usize)) | (((val as u32) & 0x0f) << 8usize);
}
#[doc = "FIFO reception threshold"]
#[must_use]
#[inline(always)]
pub const fn frxth(&self) -> bool {
let val = (self.0 >> 12usize) & 0x01;
val != 0
}
#[doc = "FIFO reception threshold"]
#[inline(always)]
pub const fn set_frxth(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 12usize)) | (((val as u32) & 0x01) << 12usize);
}
#[doc = "Transmit finish interrupt enable"]
#[must_use]
#[inline(always)]
pub const fn txfie(&self) -> bool {
let val = (self.0 >> 15usize) & 0x01;
val != 0
}
#[doc = "Transmit finish interrupt enable"]
#[inline(always)]
pub const fn set_txfie(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 15usize)) | (((val as u32) & 0x01) << 15usize);
}
}
impl Default for Cr2 {
#[inline(always)]
fn default() -> Cr2 {
Cr2(0)
}
}
impl core::fmt::Debug for Cr2 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Cr2")
.field("ssoe", &self.ssoe())
.field("nssp", &self.nssp())
.field("frf", &self.frf())
.field("errie", &self.errie())
.field("rxneie", &self.rxneie())
.field("txeie", &self.txeie())
.field("ds", &self.ds())
.field("frxth", &self.frxth())
.field("txfie", &self.txfie())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Cr2 {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Cr2 {{ ssoe: {=bool:?}, nssp: {=bool:?}, frf: {=bool:?}, errie: {=bool:?}, rxneie: {=bool:?}, txeie: {=bool:?}, ds: {=u8:?}, frxth: {=bool:?}, txfie: {=bool:?} }}" , self . ssoe () , self . nssp () , self . frf () , self . errie () , self . rxneie () , self . txeie () , self . ds () , self . frxth () , self . txfie ())
}
}
#[doc = "CR3"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Cr3(pub u32);
impl Cr3 {
#[doc = "RX_CLK improvement enable"]
#[must_use]
#[inline(always)]
pub const fn rx_clk_imp_en(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "RX_CLK improvement enable"]
#[inline(always)]
pub const fn set_rx_clk_imp_en(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
}
impl Default for Cr3 {
#[inline(always)]
fn default() -> Cr3 {
Cr3(0)
}
}
impl core::fmt::Debug for Cr3 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Cr3")
.field("rx_clk_imp_en", &self.rx_clk_imp_en())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Cr3 {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Cr3 {{ rx_clk_imp_en: {=bool:?} }}",
self.rx_clk_imp_en()
)
}
}
#[doc = "CR4"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Cr4(pub u32);
impl Cr4 {
#[doc = "Transmit Data"]
#[must_use]
#[inline(always)]
pub const fn rep_tx_data(&self) -> u16 {
let val = (self.0 >> 0usize) & 0xffff;
val as u16
}
#[doc = "Transmit Data"]
#[inline(always)]
pub const fn set_rep_tx_data(&mut self, val: u16) {
self.0 = (self.0 & !(0xffff << 0usize)) | (((val as u32) & 0xffff) << 0usize);
}
#[doc = "Retransmit Counter"]
#[must_use]
#[inline(always)]
pub const fn rep_tx_cnt(&self) -> u16 {
let val = (self.0 >> 16usize) & 0x7fff;
val as u16
}
#[doc = "Retransmit Counter"]
#[inline(always)]
pub const fn set_rep_tx_cnt(&mut self, val: u16) {
self.0 = (self.0 & !(0x7fff << 16usize)) | (((val as u32) & 0x7fff) << 16usize);
}
#[doc = "Retransmit enable"]
#[must_use]
#[inline(always)]
pub const fn rep_tx(&self) -> bool {
let val = (self.0 >> 31usize) & 0x01;
val != 0
}
#[doc = "Retransmit enable"]
#[inline(always)]
pub const fn set_rep_tx(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 31usize)) | (((val as u32) & 0x01) << 31usize);
}
}
impl Default for Cr4 {
#[inline(always)]
fn default() -> Cr4 {
Cr4(0)
}
}
impl core::fmt::Debug for Cr4 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Cr4")
.field("rep_tx_data", &self.rep_tx_data())
.field("rep_tx_cnt", &self.rep_tx_cnt())
.field("rep_tx", &self.rep_tx())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Cr4 {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Cr4 {{ rep_tx_data: {=u16:?}, rep_tx_cnt: {=u16:?}, rep_tx: {=bool:?} }}",
self.rep_tx_data(),
self.rep_tx_cnt(),
self.rep_tx()
)
}
}
#[doc = "DR"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Dr(pub u8);
impl Dr {
#[doc = "Data register"]
#[must_use]
#[inline(always)]
pub const fn dr(&self) -> u8 {
self.0
}
#[doc = "Data register"]
#[inline(always)]
pub const fn set_dr(&mut self, val: u8) {
self.0 = val;
}
}
impl Default for Dr {
#[inline(always)]
fn default() -> Dr {
Dr(0)
}
}
impl core::fmt::Debug for Dr {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Dr").field("dr", &self.dr()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Dr {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Dr {{ dr: {=u16:?} }}", self.dr())
}
}
#[doc = "SR"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Sr(pub u32);
impl Sr {
#[doc = "Receive buffer not empty"]
#[must_use]
#[inline(always)]
pub const fn rxne(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Receive buffer not empty"]
#[inline(always)]
pub const fn set_rxne(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Transmit buffer empty"]
#[must_use]
#[inline(always)]
pub const fn txe(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Transmit buffer empty"]
#[inline(always)]
pub const fn set_txe(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "Transmit finish"]
#[must_use]
#[inline(always)]
pub const fn txf(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Transmit finish"]
#[inline(always)]
pub const fn set_txf(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "Mode fault"]
#[must_use]
#[inline(always)]
pub const fn modf(&self) -> bool {
let val = (self.0 >> 5usize) & 0x01;
val != 0
}
#[doc = "Mode fault"]
#[inline(always)]
pub const fn set_modf(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
}
#[doc = "Overrun flag"]
#[must_use]
#[inline(always)]
pub const fn ovr(&self) -> bool {
let val = (self.0 >> 6usize) & 0x01;
val != 0
}
#[doc = "Overrun flag"]
#[inline(always)]
pub const fn set_ovr(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize);
}
#[doc = "Busy flag"]
#[must_use]
#[inline(always)]
pub const fn bsy(&self) -> bool {
let val = (self.0 >> 7usize) & 0x01;
val != 0
}
#[doc = "Busy flag"]
#[inline(always)]
pub const fn set_bsy(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize);
}
#[doc = "FIFO reception level"]
#[must_use]
#[inline(always)]
pub const fn frlvl(&self) -> u8 {
let val = (self.0 >> 9usize) & 0x03;
val as u8
}
#[doc = "FIFO reception level"]
#[inline(always)]
pub const fn set_frlvl(&mut self, val: u8) {
self.0 = (self.0 & !(0x03 << 9usize)) | (((val as u32) & 0x03) << 9usize);
}
#[doc = "FIFO Transmission Level"]
#[must_use]
#[inline(always)]
pub const fn ftlvl(&self) -> u8 {
let val = (self.0 >> 11usize) & 0x03;
val as u8
}
#[doc = "FIFO Transmission Level"]
#[inline(always)]
pub const fn set_ftlvl(&mut self, val: u8) {
self.0 = (self.0 & !(0x03 << 11usize)) | (((val as u32) & 0x03) << 11usize);
}
}
impl Default for Sr {
#[inline(always)]
fn default() -> Sr {
Sr(0)
}
}
impl core::fmt::Debug for Sr {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Sr")
.field("rxne", &self.rxne())
.field("txe", &self.txe())
.field("txf", &self.txf())
.field("modf", &self.modf())
.field("ovr", &self.ovr())
.field("bsy", &self.bsy())
.field("frlvl", &self.frlvl())
.field("ftlvl", &self.ftlvl())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Sr {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Sr {{ rxne: {=bool:?}, txe: {=bool:?}, txf: {=bool:?}, modf: {=bool:?}, ovr: {=bool:?}, bsy: {=bool:?}, frlvl: {=u8:?}, ftlvl: {=u8:?} }}" , self . rxne () , self . txe () , self . txf () , self . modf () , self . ovr () , self . bsy () , self . frlvl () , self . ftlvl ())
}
}