#[doc = "CR1"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Cr1(pub u32);
impl Cr1 {
#[doc = "Peripheral enable"]
#[must_use]
#[inline(always)]
pub const fn pe(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Peripheral enable"]
#[inline(always)]
pub const fn set_pe(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "TX interrupt enable"]
#[must_use]
#[inline(always)]
pub const fn txie(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "TX interrupt enable"]
#[inline(always)]
pub const fn set_txie(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "RX interrupt enable"]
#[must_use]
#[inline(always)]
pub const fn rxie(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "RX interrupt enable"]
#[inline(always)]
pub const fn set_rxie(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "Address match interrupt enable of slave only"]
#[must_use]
#[inline(always)]
pub const fn addrie(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "Address match interrupt enable of slave only"]
#[inline(always)]
pub const fn set_addrie(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
#[doc = "Not acknowledge received interrupt enable"]
#[must_use]
#[inline(always)]
pub const fn nackie(&self) -> bool {
let val = (self.0 >> 4usize) & 0x01;
val != 0
}
#[doc = "Not acknowledge received interrupt enable"]
#[inline(always)]
pub const fn set_nackie(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
}
#[doc = "STOP detection interrupt enable"]
#[must_use]
#[inline(always)]
pub const fn stopie(&self) -> bool {
let val = (self.0 >> 5usize) & 0x01;
val != 0
}
#[doc = "STOP detection interrupt enable"]
#[inline(always)]
pub const fn set_stopie(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
}
#[doc = "Transfer complete interrupt enable"]
#[must_use]
#[inline(always)]
pub const fn tcie(&self) -> bool {
let val = (self.0 >> 6usize) & 0x01;
val != 0
}
#[doc = "Transfer complete interrupt enable"]
#[inline(always)]
pub const fn set_tcie(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize);
}
#[doc = "Error interrupts enable"]
#[must_use]
#[inline(always)]
pub const fn errie(&self) -> bool {
let val = (self.0 >> 7usize) & 0x01;
val != 0
}
#[doc = "Error interrupts enable"]
#[inline(always)]
pub const fn set_errie(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize);
}
#[doc = "Digital noise filter"]
#[must_use]
#[inline(always)]
pub const fn dnf(&self) -> u8 {
let val = (self.0 >> 8usize) & 0x0f;
val as u8
}
#[doc = "Digital noise filter"]
#[inline(always)]
pub const fn set_dnf(&mut self, val: u8) {
self.0 = (self.0 & !(0x0f << 8usize)) | (((val as u32) & 0x0f) << 8usize);
}
#[doc = "Slave byte control"]
#[must_use]
#[inline(always)]
pub const fn sbc(&self) -> bool {
let val = (self.0 >> 16usize) & 0x01;
val != 0
}
#[doc = "Slave byte control"]
#[inline(always)]
pub const fn set_sbc(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 16usize)) | (((val as u32) & 0x01) << 16usize);
}
#[doc = "Clock stretching disable"]
#[must_use]
#[inline(always)]
pub const fn nostretch(&self) -> bool {
let val = (self.0 >> 17usize) & 0x01;
val != 0
}
#[doc = "Clock stretching disable"]
#[inline(always)]
pub const fn set_nostretch(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 17usize)) | (((val as u32) & 0x01) << 17usize);
}
#[doc = "General call enable"]
#[must_use]
#[inline(always)]
pub const fn gcen(&self) -> bool {
let val = (self.0 >> 19usize) & 0x01;
val != 0
}
#[doc = "General call enable"]
#[inline(always)]
pub const fn set_gcen(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 19usize)) | (((val as u32) & 0x01) << 19usize);
}
#[doc = "SMBus Host address enable"]
#[must_use]
#[inline(always)]
pub const fn smbhen(&self) -> bool {
let val = (self.0 >> 20usize) & 0x01;
val != 0
}
#[doc = "SMBus Host address enable"]
#[inline(always)]
pub const fn set_smbhen(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 20usize)) | (((val as u32) & 0x01) << 20usize);
}
#[doc = "SMBus device default address enable"]
#[must_use]
#[inline(always)]
pub const fn smbden(&self) -> bool {
let val = (self.0 >> 21usize) & 0x01;
val != 0
}
#[doc = "SMBus device default address enable"]
#[inline(always)]
pub const fn set_smbden(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 21usize)) | (((val as u32) & 0x01) << 21usize);
}
#[doc = "SMBus alert enable"]
#[must_use]
#[inline(always)]
pub const fn alerten(&self) -> bool {
let val = (self.0 >> 22usize) & 0x01;
val != 0
}
#[doc = "SMBus alert enable"]
#[inline(always)]
pub const fn set_alerten(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 22usize)) | (((val as u32) & 0x01) << 22usize);
}
#[doc = "PEC enable"]
#[must_use]
#[inline(always)]
pub const fn pecen(&self) -> bool {
let val = (self.0 >> 23usize) & 0x01;
val != 0
}
#[doc = "PEC enable"]
#[inline(always)]
pub const fn set_pecen(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 23usize)) | (((val as u32) & 0x01) << 23usize);
}
#[doc = "Exchange SDA/SCL pin"]
#[must_use]
#[inline(always)]
pub const fn swap(&self) -> bool {
let val = (self.0 >> 31usize) & 0x01;
val != 0
}
#[doc = "Exchange SDA/SCL pin"]
#[inline(always)]
pub const fn set_swap(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 31usize)) | (((val as u32) & 0x01) << 31usize);
}
}
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("pe", &self.pe())
.field("txie", &self.txie())
.field("rxie", &self.rxie())
.field("addrie", &self.addrie())
.field("nackie", &self.nackie())
.field("stopie", &self.stopie())
.field("tcie", &self.tcie())
.field("errie", &self.errie())
.field("dnf", &self.dnf())
.field("sbc", &self.sbc())
.field("nostretch", &self.nostretch())
.field("gcen", &self.gcen())
.field("smbhen", &self.smbhen())
.field("smbden", &self.smbden())
.field("alerten", &self.alerten())
.field("pecen", &self.pecen())
.field("swap", &self.swap())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Cr1 {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Cr1 {{ pe: {=bool:?}, txie: {=bool:?}, rxie: {=bool:?}, addrie: {=bool:?}, nackie: {=bool:?}, stopie: {=bool:?}, tcie: {=bool:?}, errie: {=bool:?}, dnf: {=u8:?}, sbc: {=bool:?}, nostretch: {=bool:?}, gcen: {=bool:?}, smbhen: {=bool:?}, smbden: {=bool:?}, alerten: {=bool:?}, pecen: {=bool:?}, swap: {=bool:?} }}" , self . pe () , self . txie () , self . rxie () , self . addrie () , self . nackie () , self . stopie () , self . tcie () , self . errie () , self . dnf () , self . sbc () , self . nostretch () , self . gcen () , self . smbhen () , self . smbden () , self . alerten () , self . pecen () , self . swap ())
}
}
#[doc = "CR2"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Cr2(pub u32);
impl Cr2 {
#[doc = "Slave address bit 9:0"]
#[must_use]
#[inline(always)]
pub const fn sadd(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x03ff;
val as u16
}
#[doc = "Slave address bit 9:0"]
#[inline(always)]
pub const fn set_sadd(&mut self, val: u16) {
self.0 = (self.0 & !(0x03ff << 0usize)) | (((val as u32) & 0x03ff) << 0usize);
}
#[doc = "Transfer direction of master mode"]
#[must_use]
#[inline(always)]
pub const fn rd_wrn(&self) -> bool {
let val = (self.0 >> 10usize) & 0x01;
val != 0
}
#[doc = "Transfer direction of master mode"]
#[inline(always)]
pub const fn set_rd_wrn(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 10usize)) | (((val as u32) & 0x01) << 10usize);
}
#[doc = "10-bit addressing mode of master mode"]
#[must_use]
#[inline(always)]
pub const fn add10(&self) -> bool {
let val = (self.0 >> 11usize) & 0x01;
val != 0
}
#[doc = "10-bit addressing mode of master mode"]
#[inline(always)]
pub const fn set_add10(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 11usize)) | (((val as u32) & 0x01) << 11usize);
}
#[doc = "10-bit address header only read direction of master receiver mode"]
#[must_use]
#[inline(always)]
pub const fn head10r(&self) -> bool {
let val = (self.0 >> 12usize) & 0x01;
val != 0
}
#[doc = "10-bit address header only read direction of master receiver mode"]
#[inline(always)]
pub const fn set_head10r(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 12usize)) | (((val as u32) & 0x01) << 12usize);
}
#[doc = "Start generation"]
#[must_use]
#[inline(always)]
pub const fn start(&self) -> bool {
let val = (self.0 >> 13usize) & 0x01;
val != 0
}
#[doc = "Start generation"]
#[inline(always)]
pub const fn set_start(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 13usize)) | (((val as u32) & 0x01) << 13usize);
}
#[doc = "STOP generation of master mode"]
#[must_use]
#[inline(always)]
pub const fn stop(&self) -> bool {
let val = (self.0 >> 14usize) & 0x01;
val != 0
}
#[doc = "STOP generation of master mode"]
#[inline(always)]
pub const fn set_stop(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 14usize)) | (((val as u32) & 0x01) << 14usize);
}
#[doc = "NACK generation of slave mode"]
#[must_use]
#[inline(always)]
pub const fn nack(&self) -> bool {
let val = (self.0 >> 15usize) & 0x01;
val != 0
}
#[doc = "NACK generation of slave mode"]
#[inline(always)]
pub const fn set_nack(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 15usize)) | (((val as u32) & 0x01) << 15usize);
}
#[doc = "Number of bytes"]
#[must_use]
#[inline(always)]
pub const fn nbytes(&self) -> u8 {
let val = (self.0 >> 16usize) & 0xff;
val as u8
}
#[doc = "Number of bytes"]
#[inline(always)]
pub const fn set_nbytes(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 16usize)) | (((val as u32) & 0xff) << 16usize);
}
#[doc = "NBYTES reload mode"]
#[must_use]
#[inline(always)]
pub const fn reload(&self) -> bool {
let val = (self.0 >> 24usize) & 0x01;
val != 0
}
#[doc = "NBYTES reload mode"]
#[inline(always)]
pub const fn set_reload(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 24usize)) | (((val as u32) & 0x01) << 24usize);
}
#[doc = "Automatic end mode of master mode"]
#[must_use]
#[inline(always)]
pub const fn autoend(&self) -> bool {
let val = (self.0 >> 25usize) & 0x01;
val != 0
}
#[doc = "Automatic end mode of master mode"]
#[inline(always)]
pub const fn set_autoend(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 25usize)) | (((val as u32) & 0x01) << 25usize);
}
#[doc = "Packet error checking byte"]
#[must_use]
#[inline(always)]
pub const fn pecbyte(&self) -> bool {
let val = (self.0 >> 26usize) & 0x01;
val != 0
}
#[doc = "Packet error checking byte"]
#[inline(always)]
pub const fn set_pecbyte(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 26usize)) | (((val as u32) & 0x01) << 26usize);
}
}
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("sadd", &self.sadd())
.field("rd_wrn", &self.rd_wrn())
.field("add10", &self.add10())
.field("head10r", &self.head10r())
.field("start", &self.start())
.field("stop", &self.stop())
.field("nack", &self.nack())
.field("nbytes", &self.nbytes())
.field("reload", &self.reload())
.field("autoend", &self.autoend())
.field("pecbyte", &self.pecbyte())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Cr2 {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Cr2 {{ sadd: {=u16:?}, rd_wrn: {=bool:?}, add10: {=bool:?}, head10r: {=bool:?}, start: {=bool:?}, stop: {=bool:?}, nack: {=bool:?}, nbytes: {=u8:?}, reload: {=bool:?}, autoend: {=bool:?}, pecbyte: {=bool:?} }}" , self . sadd () , self . rd_wrn () , self . add10 () , self . head10r () , self . start () , self . stop () , self . nack () , self . nbytes () , self . reload () , self . autoend () , self . pecbyte ())
}
}
#[doc = "ICR"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Icr(pub u32);
impl Icr {
#[doc = "Address matched flag clear"]
#[must_use]
#[inline(always)]
pub const fn addrcf(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "Address matched flag clear"]
#[inline(always)]
pub const fn set_addrcf(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
#[doc = "Not Acknowledge flag clear"]
#[must_use]
#[inline(always)]
pub const fn nackcf(&self) -> bool {
let val = (self.0 >> 4usize) & 0x01;
val != 0
}
#[doc = "Not Acknowledge flag clear"]
#[inline(always)]
pub const fn set_nackcf(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
}
#[doc = "STOP detection flag clear"]
#[must_use]
#[inline(always)]
pub const fn stopcf(&self) -> bool {
let val = (self.0 >> 5usize) & 0x01;
val != 0
}
#[doc = "STOP detection flag clear"]
#[inline(always)]
pub const fn set_stopcf(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
}
#[doc = "Bus error flag clear"]
#[must_use]
#[inline(always)]
pub const fn berrcf(&self) -> bool {
let val = (self.0 >> 8usize) & 0x01;
val != 0
}
#[doc = "Bus error flag clear"]
#[inline(always)]
pub const fn set_berrcf(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize);
}
#[doc = "Arbitration lost flag clear"]
#[must_use]
#[inline(always)]
pub const fn arlocf(&self) -> bool {
let val = (self.0 >> 9usize) & 0x01;
val != 0
}
#[doc = "Arbitration lost flag clear"]
#[inline(always)]
pub const fn set_arlocf(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 9usize)) | (((val as u32) & 0x01) << 9usize);
}
#[doc = "Overrun/Underrun flag clear"]
#[must_use]
#[inline(always)]
pub const fn overcf(&self) -> bool {
let val = (self.0 >> 10usize) & 0x01;
val != 0
}
#[doc = "Overrun/Underrun flag clear"]
#[inline(always)]
pub const fn set_overcf(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 10usize)) | (((val as u32) & 0x01) << 10usize);
}
#[doc = "PEC Error flag clear"]
#[must_use]
#[inline(always)]
pub const fn peccf(&self) -> bool {
let val = (self.0 >> 11usize) & 0x01;
val != 0
}
#[doc = "PEC Error flag clear"]
#[inline(always)]
pub const fn set_peccf(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 11usize)) | (((val as u32) & 0x01) << 11usize);
}
#[doc = "Timeout detection flag clear"]
#[must_use]
#[inline(always)]
pub const fn timoutcf(&self) -> bool {
let val = (self.0 >> 12usize) & 0x01;
val != 0
}
#[doc = "Timeout detection flag clear"]
#[inline(always)]
pub const fn set_timoutcf(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 12usize)) | (((val as u32) & 0x01) << 12usize);
}
#[doc = "Alert flag clear"]
#[must_use]
#[inline(always)]
pub const fn alertcf(&self) -> bool {
let val = (self.0 >> 13usize) & 0x01;
val != 0
}
#[doc = "Alert flag clear"]
#[inline(always)]
pub const fn set_alertcf(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 13usize)) | (((val as u32) & 0x01) << 13usize);
}
}
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("addrcf", &self.addrcf())
.field("nackcf", &self.nackcf())
.field("stopcf", &self.stopcf())
.field("berrcf", &self.berrcf())
.field("arlocf", &self.arlocf())
.field("overcf", &self.overcf())
.field("peccf", &self.peccf())
.field("timoutcf", &self.timoutcf())
.field("alertcf", &self.alertcf())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Icr {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Icr {{ addrcf: {=bool:?}, nackcf: {=bool:?}, stopcf: {=bool:?}, berrcf: {=bool:?}, arlocf: {=bool:?}, overcf: {=bool:?}, peccf: {=bool:?}, timoutcf: {=bool:?}, alertcf: {=bool:?} }}" , self . addrcf () , self . nackcf () , self . stopcf () , self . berrcf () , self . arlocf () , self . overcf () , self . peccf () , self . timoutcf () , self . alertcf ())
}
}
#[doc = "ISR"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Isr(pub u32);
impl Isr {
#[doc = "Transmit data register empty of transmitters"]
#[must_use]
#[inline(always)]
pub const fn txe(&self) -> bool {
let val = (self.0 >> 0usize) & 0x01;
val != 0
}
#[doc = "Transmit data register empty of transmitters"]
#[inline(always)]
pub const fn set_txe(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 0usize)) | (((val as u32) & 0x01) << 0usize);
}
#[doc = "Transmit interrupt status of transmitters"]
#[must_use]
#[inline(always)]
pub const fn txis(&self) -> bool {
let val = (self.0 >> 1usize) & 0x01;
val != 0
}
#[doc = "Transmit interrupt status of transmitters"]
#[inline(always)]
pub const fn set_txis(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 1usize)) | (((val as u32) & 0x01) << 1usize);
}
#[doc = "Receive data register not empty of receivers"]
#[must_use]
#[inline(always)]
pub const fn rxne(&self) -> bool {
let val = (self.0 >> 2usize) & 0x01;
val != 0
}
#[doc = "Receive data register not empty of receivers"]
#[inline(always)]
pub const fn set_rxne(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 2usize)) | (((val as u32) & 0x01) << 2usize);
}
#[doc = "Address matched of slave mode"]
#[must_use]
#[inline(always)]
pub const fn addr(&self) -> bool {
let val = (self.0 >> 3usize) & 0x01;
val != 0
}
#[doc = "Address matched of slave mode"]
#[inline(always)]
pub const fn set_addr(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 3usize)) | (((val as u32) & 0x01) << 3usize);
}
#[doc = "Not Acknowledge received flag"]
#[must_use]
#[inline(always)]
pub const fn nackf(&self) -> bool {
let val = (self.0 >> 4usize) & 0x01;
val != 0
}
#[doc = "Not Acknowledge received flag"]
#[inline(always)]
pub const fn set_nackf(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 4usize)) | (((val as u32) & 0x01) << 4usize);
}
#[doc = "STOP detection flag"]
#[must_use]
#[inline(always)]
pub const fn stopf(&self) -> bool {
let val = (self.0 >> 5usize) & 0x01;
val != 0
}
#[doc = "STOP detection flag"]
#[inline(always)]
pub const fn set_stopf(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 5usize)) | (((val as u32) & 0x01) << 5usize);
}
#[doc = "Transfer complete of master mode"]
#[must_use]
#[inline(always)]
pub const fn tc(&self) -> bool {
let val = (self.0 >> 6usize) & 0x01;
val != 0
}
#[doc = "Transfer complete of master mode"]
#[inline(always)]
pub const fn set_tc(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 6usize)) | (((val as u32) & 0x01) << 6usize);
}
#[doc = "Transfer complete reload"]
#[must_use]
#[inline(always)]
pub const fn tcr(&self) -> bool {
let val = (self.0 >> 7usize) & 0x01;
val != 0
}
#[doc = "Transfer complete reload"]
#[inline(always)]
pub const fn set_tcr(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 7usize)) | (((val as u32) & 0x01) << 7usize);
}
#[doc = "Bus error"]
#[must_use]
#[inline(always)]
pub const fn berr(&self) -> bool {
let val = (self.0 >> 8usize) & 0x01;
val != 0
}
#[doc = "Bus error"]
#[inline(always)]
pub const fn set_berr(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 8usize)) | (((val as u32) & 0x01) << 8usize);
}
#[doc = "Arbitration lost"]
#[must_use]
#[inline(always)]
pub const fn arlo(&self) -> bool {
let val = (self.0 >> 9usize) & 0x01;
val != 0
}
#[doc = "Arbitration lost"]
#[inline(always)]
pub const fn set_arlo(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 9usize)) | (((val as u32) & 0x01) << 9usize);
}
#[doc = "Overrun/Underrun of slave mode"]
#[must_use]
#[inline(always)]
pub const fn ovr(&self) -> bool {
let val = (self.0 >> 10usize) & 0x01;
val != 0
}
#[doc = "Overrun/Underrun of slave mode"]
#[inline(always)]
pub const fn set_ovr(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 10usize)) | (((val as u32) & 0x01) << 10usize);
}
#[doc = "PEC Error in reception"]
#[must_use]
#[inline(always)]
pub const fn pecerr(&self) -> bool {
let val = (self.0 >> 11usize) & 0x01;
val != 0
}
#[doc = "PEC Error in reception"]
#[inline(always)]
pub const fn set_pecerr(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 11usize)) | (((val as u32) & 0x01) << 11usize);
}
#[doc = "Timeout or tLOW detection flag"]
#[must_use]
#[inline(always)]
pub const fn timeout(&self) -> bool {
let val = (self.0 >> 12usize) & 0x01;
val != 0
}
#[doc = "Timeout or tLOW detection flag"]
#[inline(always)]
pub const fn set_timeout(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 12usize)) | (((val as u32) & 0x01) << 12usize);
}
#[doc = "SMBus alert"]
#[must_use]
#[inline(always)]
pub const fn alert(&self) -> bool {
let val = (self.0 >> 13usize) & 0x01;
val != 0
}
#[doc = "SMBus alert"]
#[inline(always)]
pub const fn set_alert(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 13usize)) | (((val as u32) & 0x01) << 13usize);
}
#[doc = "Bus busy"]
#[must_use]
#[inline(always)]
pub const fn busy(&self) -> bool {
let val = (self.0 >> 15usize) & 0x01;
val != 0
}
#[doc = "Bus busy"]
#[inline(always)]
pub const fn set_busy(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 15usize)) | (((val as u32) & 0x01) << 15usize);
}
#[doc = "Transfer direction of Slave mode"]
#[must_use]
#[inline(always)]
pub const fn dir(&self) -> bool {
let val = (self.0 >> 16usize) & 0x01;
val != 0
}
#[doc = "Transfer direction of Slave mode"]
#[inline(always)]
pub const fn set_dir(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 16usize)) | (((val as u32) & 0x01) << 16usize);
}
#[doc = "Address match code of Slave mode"]
#[must_use]
#[inline(always)]
pub const fn addcode(&self) -> u8 {
let val = (self.0 >> 17usize) & 0x7f;
val as u8
}
#[doc = "Address match code of Slave mode"]
#[inline(always)]
pub const fn set_addcode(&mut self, val: u8) {
self.0 = (self.0 & !(0x7f << 17usize)) | (((val as u32) & 0x7f) << 17usize);
}
}
impl Default for Isr {
#[inline(always)]
fn default() -> Isr {
Isr(0)
}
}
impl core::fmt::Debug for Isr {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Isr")
.field("txe", &self.txe())
.field("txis", &self.txis())
.field("rxne", &self.rxne())
.field("addr", &self.addr())
.field("nackf", &self.nackf())
.field("stopf", &self.stopf())
.field("tc", &self.tc())
.field("tcr", &self.tcr())
.field("berr", &self.berr())
.field("arlo", &self.arlo())
.field("ovr", &self.ovr())
.field("pecerr", &self.pecerr())
.field("timeout", &self.timeout())
.field("alert", &self.alert())
.field("busy", &self.busy())
.field("dir", &self.dir())
.field("addcode", &self.addcode())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Isr {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Isr {{ txe: {=bool:?}, txis: {=bool:?}, rxne: {=bool:?}, addr: {=bool:?}, nackf: {=bool:?}, stopf: {=bool:?}, tc: {=bool:?}, tcr: {=bool:?}, berr: {=bool:?}, arlo: {=bool:?}, ovr: {=bool:?}, pecerr: {=bool:?}, timeout: {=bool:?}, alert: {=bool:?}, busy: {=bool:?}, dir: {=bool:?}, addcode: {=u8:?} }}" , self . txe () , self . txis () , self . rxne () , self . addr () , self . nackf () , self . stopf () , self . tc () , self . tcr () , self . berr () , self . arlo () , self . ovr () , self . pecerr () , self . timeout () , self . alert () , self . busy () , self . dir () , self . addcode ())
}
}
#[doc = "OAR1"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Oar1(pub u32);
impl Oar1 {
#[doc = "Interface address 9:0 bits"]
#[must_use]
#[inline(always)]
pub const fn oa1(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x03ff;
val as u16
}
#[doc = "Interface address 9:0 bits"]
#[inline(always)]
pub const fn set_oa1(&mut self, val: u16) {
self.0 = (self.0 & !(0x03ff << 0usize)) | (((val as u32) & 0x03ff) << 0usize);
}
#[doc = "Own address 1 10-bit mode"]
#[must_use]
#[inline(always)]
pub const fn oa1mode(&self) -> bool {
let val = (self.0 >> 10usize) & 0x01;
val != 0
}
#[doc = "Own address 1 10-bit mode"]
#[inline(always)]
pub const fn set_oa1mode(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 10usize)) | (((val as u32) & 0x01) << 10usize);
}
#[doc = "Own address 1 enable"]
#[must_use]
#[inline(always)]
pub const fn oa1en(&self) -> bool {
let val = (self.0 >> 15usize) & 0x01;
val != 0
}
#[doc = "Own address 1 enable"]
#[inline(always)]
pub const fn set_oa1en(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 15usize)) | (((val as u32) & 0x01) << 15usize);
}
}
impl Default for Oar1 {
#[inline(always)]
fn default() -> Oar1 {
Oar1(0)
}
}
impl core::fmt::Debug for Oar1 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Oar1")
.field("oa1", &self.oa1())
.field("oa1mode", &self.oa1mode())
.field("oa1en", &self.oa1en())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Oar1 {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Oar1 {{ oa1: {=u16:?}, oa1mode: {=bool:?}, oa1en: {=bool:?} }}",
self.oa1(),
self.oa1mode(),
self.oa1en()
)
}
}
#[doc = "OAR2"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Oar2(pub u32);
impl Oar2 {
#[doc = "Interface address 7:1 bits"]
#[must_use]
#[inline(always)]
pub const fn oa2(&self) -> u8 {
let val = (self.0 >> 1usize) & 0x7f;
val as u8
}
#[doc = "Interface address 7:1 bits"]
#[inline(always)]
pub const fn set_oa2(&mut self, val: u8) {
self.0 = (self.0 & !(0x7f << 1usize)) | (((val as u32) & 0x7f) << 1usize);
}
#[doc = "Own address 2 masks"]
#[must_use]
#[inline(always)]
pub const fn oa2msk(&self) -> u8 {
let val = (self.0 >> 8usize) & 0x07;
val as u8
}
#[doc = "Own address 2 masks"]
#[inline(always)]
pub const fn set_oa2msk(&mut self, val: u8) {
self.0 = (self.0 & !(0x07 << 8usize)) | (((val as u32) & 0x07) << 8usize);
}
#[doc = "Own address 2 enable"]
#[must_use]
#[inline(always)]
pub const fn oa2en(&self) -> bool {
let val = (self.0 >> 15usize) & 0x01;
val != 0
}
#[doc = "Own address 2 enable"]
#[inline(always)]
pub const fn set_oa2en(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 15usize)) | (((val as u32) & 0x01) << 15usize);
}
}
impl Default for Oar2 {
#[inline(always)]
fn default() -> Oar2 {
Oar2(0)
}
}
impl core::fmt::Debug for Oar2 {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Oar2")
.field("oa2", &self.oa2())
.field("oa2msk", &self.oa2msk())
.field("oa2en", &self.oa2en())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Oar2 {
fn format(&self, f: defmt::Formatter) {
defmt::write!(
f,
"Oar2 {{ oa2: {=u8:?}, oa2msk: {=u8:?}, oa2en: {=bool:?} }}",
self.oa2(),
self.oa2msk(),
self.oa2en()
)
}
}
#[doc = "PECR"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Pecr(pub u32);
impl Pecr {
#[doc = "Packet error checking register"]
#[must_use]
#[inline(always)]
pub const fn pec(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "Packet error checking register"]
#[inline(always)]
pub const fn set_pec(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
}
impl Default for Pecr {
#[inline(always)]
fn default() -> Pecr {
Pecr(0)
}
}
impl core::fmt::Debug for Pecr {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Pecr").field("pec", &self.pec()).finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Pecr {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Pecr {{ pec: {=u8:?} }}", self.pec())
}
}
#[doc = "RXDR"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Rxdr(pub u32);
impl Rxdr {
#[doc = "8-bit receive data"]
#[must_use]
#[inline(always)]
pub const fn rxdata(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "8-bit receive data"]
#[inline(always)]
pub const fn set_rxdata(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
}
impl Default for Rxdr {
#[inline(always)]
fn default() -> Rxdr {
Rxdr(0)
}
}
impl core::fmt::Debug for Rxdr {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Rxdr")
.field("rxdata", &self.rxdata())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Rxdr {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Rxdr {{ rxdata: {=u8:?} }}", self.rxdata())
}
}
#[doc = "TIMEOUTR"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Timeoutr(pub u32);
impl Timeoutr {
#[doc = "Bus timeout A"]
#[must_use]
#[inline(always)]
pub const fn timeouta(&self) -> u16 {
let val = (self.0 >> 0usize) & 0x0fff;
val as u16
}
#[doc = "Bus timeout A"]
#[inline(always)]
pub const fn set_timeouta(&mut self, val: u16) {
self.0 = (self.0 & !(0x0fff << 0usize)) | (((val as u32) & 0x0fff) << 0usize);
}
#[doc = "Idle clock timeout detection"]
#[must_use]
#[inline(always)]
pub const fn tidle(&self) -> bool {
let val = (self.0 >> 12usize) & 0x01;
val != 0
}
#[doc = "Idle clock timeout detection"]
#[inline(always)]
pub const fn set_tidle(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 12usize)) | (((val as u32) & 0x01) << 12usize);
}
#[doc = "Clock timeout enable"]
#[must_use]
#[inline(always)]
pub const fn timeouten(&self) -> bool {
let val = (self.0 >> 15usize) & 0x01;
val != 0
}
#[doc = "Clock timeout enable"]
#[inline(always)]
pub const fn set_timeouten(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 15usize)) | (((val as u32) & 0x01) << 15usize);
}
#[doc = "Bus timeout B"]
#[must_use]
#[inline(always)]
pub const fn timeoutb(&self) -> u16 {
let val = (self.0 >> 16usize) & 0x0fff;
val as u16
}
#[doc = "Bus timeout B"]
#[inline(always)]
pub const fn set_timeoutb(&mut self, val: u16) {
self.0 = (self.0 & !(0x0fff << 16usize)) | (((val as u32) & 0x0fff) << 16usize);
}
#[doc = "Extended clock timeout enable"]
#[must_use]
#[inline(always)]
pub const fn texten(&self) -> bool {
let val = (self.0 >> 31usize) & 0x01;
val != 0
}
#[doc = "Extended clock timeout enable"]
#[inline(always)]
pub const fn set_texten(&mut self, val: bool) {
self.0 = (self.0 & !(0x01 << 31usize)) | (((val as u32) & 0x01) << 31usize);
}
}
impl Default for Timeoutr {
#[inline(always)]
fn default() -> Timeoutr {
Timeoutr(0)
}
}
impl core::fmt::Debug for Timeoutr {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Timeoutr")
.field("timeouta", &self.timeouta())
.field("tidle", &self.tidle())
.field("timeouten", &self.timeouten())
.field("timeoutb", &self.timeoutb())
.field("texten", &self.texten())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Timeoutr {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Timeoutr {{ timeouta: {=u16:?}, tidle: {=bool:?}, timeouten: {=bool:?}, timeoutb: {=u16:?}, texten: {=bool:?} }}" , self . timeouta () , self . tidle () , self . timeouten () , self . timeoutb () , self . texten ())
}
}
#[doc = "TIMINGR"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Timingr(pub u32);
impl Timingr {
#[doc = "SCL low period of master mode"]
#[must_use]
#[inline(always)]
pub const fn scll(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "SCL low period of master mode"]
#[inline(always)]
pub const fn set_scll(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
#[doc = "SCL high period of master mode"]
#[must_use]
#[inline(always)]
pub const fn sclh(&self) -> u8 {
let val = (self.0 >> 8usize) & 0xff;
val as u8
}
#[doc = "SCL high period of master mode"]
#[inline(always)]
pub const fn set_sclh(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 8usize)) | (((val as u32) & 0xff) << 8usize);
}
#[doc = "Data hold time"]
#[must_use]
#[inline(always)]
pub const fn sdadel(&self) -> u8 {
let val = (self.0 >> 16usize) & 0x0f;
val as u8
}
#[doc = "Data hold time"]
#[inline(always)]
pub const fn set_sdadel(&mut self, val: u8) {
self.0 = (self.0 & !(0x0f << 16usize)) | (((val as u32) & 0x0f) << 16usize);
}
#[doc = "Data setup time"]
#[must_use]
#[inline(always)]
pub const fn scldel(&self) -> u8 {
let val = (self.0 >> 20usize) & 0x0f;
val as u8
}
#[doc = "Data setup time"]
#[inline(always)]
pub const fn set_scldel(&mut self, val: u8) {
self.0 = (self.0 & !(0x0f << 20usize)) | (((val as u32) & 0x0f) << 20usize);
}
#[doc = "Timing prescaler"]
#[must_use]
#[inline(always)]
pub const fn presc(&self) -> u8 {
let val = (self.0 >> 28usize) & 0x0f;
val as u8
}
#[doc = "Timing prescaler"]
#[inline(always)]
pub const fn set_presc(&mut self, val: u8) {
self.0 = (self.0 & !(0x0f << 28usize)) | (((val as u32) & 0x0f) << 28usize);
}
}
impl Default for Timingr {
#[inline(always)]
fn default() -> Timingr {
Timingr(0)
}
}
impl core::fmt::Debug for Timingr {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Timingr")
.field("scll", &self.scll())
.field("sclh", &self.sclh())
.field("sdadel", &self.sdadel())
.field("scldel", &self.scldel())
.field("presc", &self.presc())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Timingr {
fn format(&self, f: defmt::Formatter) {
defmt :: write ! (f , "Timingr {{ scll: {=u8:?}, sclh: {=u8:?}, sdadel: {=u8:?}, scldel: {=u8:?}, presc: {=u8:?} }}" , self . scll () , self . sclh () , self . sdadel () , self . scldel () , self . presc ())
}
}
#[doc = "TXDR"]
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Txdr(pub u32);
impl Txdr {
#[doc = "8-bit transmit data"]
#[must_use]
#[inline(always)]
pub const fn txdata(&self) -> u8 {
let val = (self.0 >> 0usize) & 0xff;
val as u8
}
#[doc = "8-bit transmit data"]
#[inline(always)]
pub const fn set_txdata(&mut self, val: u8) {
self.0 = (self.0 & !(0xff << 0usize)) | (((val as u32) & 0xff) << 0usize);
}
}
impl Default for Txdr {
#[inline(always)]
fn default() -> Txdr {
Txdr(0)
}
}
impl core::fmt::Debug for Txdr {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("Txdr")
.field("txdata", &self.txdata())
.finish()
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for Txdr {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, "Txdr {{ txdata: {=u8:?} }}", self.txdata())
}
}