#[doc = r"Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r"Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::ISR {
#[doc = r"Modifies the contents of the register"]
#[inline(always)]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w mut W) -> &'w mut W,
{
let bits = self.register.get();
self.register.set(f(&R { bits }, &mut W { bits }).bits);
}
#[doc = r"Reads the contents of the register"]
#[inline(always)]
pub fn read(&self) -> R {
R {
bits: self.register.get(),
}
}
#[doc = r"Writes to the register"]
#[inline(always)]
pub fn write<F>(&self, f: F)
where
F: FnOnce(&mut W) -> &mut W,
{
self.register.set(
f(&mut W {
bits: Self::reset_value(),
})
.bits,
);
}
#[doc = r"Reset value of the register"]
#[inline(always)]
pub const fn reset_value() -> u32 {
0x01
}
#[doc = r"Writes the reset value to the register"]
#[inline(always)]
pub fn reset(&self) {
self.register.set(Self::reset_value())
}
}
#[doc = "Possible values of the field `TXE`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum TXER {
#[doc = "TXDR register not empty"]
NOTEMPTY,
#[doc = "TXDR register empty"]
EMPTY,
}
impl TXER {
#[doc = r"Returns `true` if the bit is clear (0)"]
#[inline(always)]
pub fn bit_is_clear(&self) -> bool {
!self.bit()
}
#[doc = r"Returns `true` if the bit is set (1)"]
#[inline(always)]
pub fn bit_is_set(&self) -> bool {
self.bit()
}
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bit(&self) -> bool {
match *self {
TXER::NOTEMPTY => false,
TXER::EMPTY => true,
}
}
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _from(value: bool) -> TXER {
match value {
false => TXER::NOTEMPTY,
true => TXER::EMPTY,
}
}
#[doc = "Checks if the value of the field is `NOTEMPTY`"]
#[inline(always)]
pub fn is_not_empty(&self) -> bool {
*self == TXER::NOTEMPTY
}
#[doc = "Checks if the value of the field is `EMPTY`"]
#[inline(always)]
pub fn is_empty(&self) -> bool {
*self == TXER::EMPTY
}
}
#[doc = "Values that can be written to the field `TXE`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum TXEW {
#[doc = "TXDR register not empty"]
NOTEMPTY,
#[doc = "TXDR register empty"]
EMPTY,
}
impl TXEW {
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _bits(&self) -> bool {
match *self {
TXEW::NOTEMPTY => false,
TXEW::EMPTY => true,
}
}
}
#[doc = r"Proxy"]
pub struct _TXEW<'a> {
w: &'a mut W,
}
impl<'a> _TXEW<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: TXEW) -> &'a mut W {
{
self.bit(variant._bits())
}
}
#[doc = "TXDR register not empty"]
#[inline(always)]
pub fn not_empty(self) -> &'a mut W {
self.variant(TXEW::NOTEMPTY)
}
#[doc = "TXDR register empty"]
#[inline(always)]
pub fn empty(self) -> &'a mut W {
self.variant(TXEW::EMPTY)
}
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits &= !(0x01 << 0);
self.w.bits |= ((value as u32) & 0x01) << 0;
self.w
}
}
#[doc = "Possible values of the field `TXIS`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum TXISR {
#[doc = "The TXDR register is not empty"]
NOTEMPTY,
#[doc = "The TXDR register is empty and the data to be transmitted must be written in the TXDR register"]
EMPTY,
}
impl TXISR {
#[doc = r"Returns `true` if the bit is clear (0)"]
#[inline(always)]
pub fn bit_is_clear(&self) -> bool {
!self.bit()
}
#[doc = r"Returns `true` if the bit is set (1)"]
#[inline(always)]
pub fn bit_is_set(&self) -> bool {
self.bit()
}
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bit(&self) -> bool {
match *self {
TXISR::NOTEMPTY => false,
TXISR::EMPTY => true,
}
}
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _from(value: bool) -> TXISR {
match value {
false => TXISR::NOTEMPTY,
true => TXISR::EMPTY,
}
}
#[doc = "Checks if the value of the field is `NOTEMPTY`"]
#[inline(always)]
pub fn is_not_empty(&self) -> bool {
*self == TXISR::NOTEMPTY
}
#[doc = "Checks if the value of the field is `EMPTY`"]
#[inline(always)]
pub fn is_empty(&self) -> bool {
*self == TXISR::EMPTY
}
}
#[doc = "Values that can be written to the field `TXIS`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum TXISW {
#[doc = "The TXDR register is not empty"]
NOTEMPTY,
#[doc = "The TXDR register is empty and the data to be transmitted must be written in the TXDR register"]
EMPTY,
}
impl TXISW {
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _bits(&self) -> bool {
match *self {
TXISW::NOTEMPTY => false,
TXISW::EMPTY => true,
}
}
}
#[doc = r"Proxy"]
pub struct _TXISW<'a> {
w: &'a mut W,
}
impl<'a> _TXISW<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: TXISW) -> &'a mut W {
{
self.bit(variant._bits())
}
}
#[doc = "The TXDR register is not empty"]
#[inline(always)]
pub fn not_empty(self) -> &'a mut W {
self.variant(TXISW::NOTEMPTY)
}
#[doc = "The TXDR register is empty and the data to be transmitted must be written in the TXDR register"]
#[inline(always)]
pub fn empty(self) -> &'a mut W {
self.variant(TXISW::EMPTY)
}
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits &= !(0x01 << 1);
self.w.bits |= ((value as u32) & 0x01) << 1;
self.w
}
}
#[doc = "Possible values of the field `RXNE`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum RXNER {
#[doc = "The RXDR register is empty"]
EMPTY,
#[doc = "Received data is copied into the RXDR register, and is ready to be read"]
NOTEMPTY,
}
impl RXNER {
#[doc = r"Returns `true` if the bit is clear (0)"]
#[inline(always)]
pub fn bit_is_clear(&self) -> bool {
!self.bit()
}
#[doc = r"Returns `true` if the bit is set (1)"]
#[inline(always)]
pub fn bit_is_set(&self) -> bool {
self.bit()
}
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bit(&self) -> bool {
match *self {
RXNER::EMPTY => false,
RXNER::NOTEMPTY => true,
}
}
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _from(value: bool) -> RXNER {
match value {
false => RXNER::EMPTY,
true => RXNER::NOTEMPTY,
}
}
#[doc = "Checks if the value of the field is `EMPTY`"]
#[inline(always)]
pub fn is_empty(&self) -> bool {
*self == RXNER::EMPTY
}
#[doc = "Checks if the value of the field is `NOTEMPTY`"]
#[inline(always)]
pub fn is_not_empty(&self) -> bool {
*self == RXNER::NOTEMPTY
}
}
#[doc = "Possible values of the field `ADDR`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum ADDRR {
#[doc = "Adress mismatched or not received"]
NOTMATCH,
#[doc = "Received slave address matched with one of the enabled slave addresses"]
MATCH,
}
impl ADDRR {
#[doc = r"Returns `true` if the bit is clear (0)"]
#[inline(always)]
pub fn bit_is_clear(&self) -> bool {
!self.bit()
}
#[doc = r"Returns `true` if the bit is set (1)"]
#[inline(always)]
pub fn bit_is_set(&self) -> bool {
self.bit()
}
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bit(&self) -> bool {
match *self {
ADDRR::NOTMATCH => false,
ADDRR::MATCH => true,
}
}
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _from(value: bool) -> ADDRR {
match value {
false => ADDRR::NOTMATCH,
true => ADDRR::MATCH,
}
}
#[doc = "Checks if the value of the field is `NOTMATCH`"]
#[inline(always)]
pub fn is_not_match(&self) -> bool {
*self == ADDRR::NOTMATCH
}
#[doc = "Checks if the value of the field is `MATCH`"]
#[inline(always)]
pub fn is_match_(&self) -> bool {
*self == ADDRR::MATCH
}
}
#[doc = "Possible values of the field `NACKF`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum NACKFR {
#[doc = "No NACK has been received"]
NONACK,
#[doc = "NACK has been received"]
NACK,
}
impl NACKFR {
#[doc = r"Returns `true` if the bit is clear (0)"]
#[inline(always)]
pub fn bit_is_clear(&self) -> bool {
!self.bit()
}
#[doc = r"Returns `true` if the bit is set (1)"]
#[inline(always)]
pub fn bit_is_set(&self) -> bool {
self.bit()
}
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bit(&self) -> bool {
match *self {
NACKFR::NONACK => false,
NACKFR::NACK => true,
}
}
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _from(value: bool) -> NACKFR {
match value {
false => NACKFR::NONACK,
true => NACKFR::NACK,
}
}
#[doc = "Checks if the value of the field is `NONACK`"]
#[inline(always)]
pub fn is_no_nack(&self) -> bool {
*self == NACKFR::NONACK
}
#[doc = "Checks if the value of the field is `NACK`"]
#[inline(always)]
pub fn is_nack(&self) -> bool {
*self == NACKFR::NACK
}
}
#[doc = "Possible values of the field `STOPF`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum STOPFR {
#[doc = "No Stop condition detected"]
NOSTOP,
#[doc = "Stop condition detected"]
STOP,
}
impl STOPFR {
#[doc = r"Returns `true` if the bit is clear (0)"]
#[inline(always)]
pub fn bit_is_clear(&self) -> bool {
!self.bit()
}
#[doc = r"Returns `true` if the bit is set (1)"]
#[inline(always)]
pub fn bit_is_set(&self) -> bool {
self.bit()
}
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bit(&self) -> bool {
match *self {
STOPFR::NOSTOP => false,
STOPFR::STOP => true,
}
}
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _from(value: bool) -> STOPFR {
match value {
false => STOPFR::NOSTOP,
true => STOPFR::STOP,
}
}
#[doc = "Checks if the value of the field is `NOSTOP`"]
#[inline(always)]
pub fn is_no_stop(&self) -> bool {
*self == STOPFR::NOSTOP
}
#[doc = "Checks if the value of the field is `STOP`"]
#[inline(always)]
pub fn is_stop(&self) -> bool {
*self == STOPFR::STOP
}
}
#[doc = "Possible values of the field `TC`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum TCR {
#[doc = "Transfer is not complete"]
NOTCOMPLETE,
#[doc = "NBYTES has been transfered"]
COMPLETE,
}
impl TCR {
#[doc = r"Returns `true` if the bit is clear (0)"]
#[inline(always)]
pub fn bit_is_clear(&self) -> bool {
!self.bit()
}
#[doc = r"Returns `true` if the bit is set (1)"]
#[inline(always)]
pub fn bit_is_set(&self) -> bool {
self.bit()
}
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bit(&self) -> bool {
match *self {
TCR::NOTCOMPLETE => false,
TCR::COMPLETE => true,
}
}
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _from(value: bool) -> TCR {
match value {
false => TCR::NOTCOMPLETE,
true => TCR::COMPLETE,
}
}
#[doc = "Checks if the value of the field is `NOTCOMPLETE`"]
#[inline(always)]
pub fn is_not_complete(&self) -> bool {
*self == TCR::NOTCOMPLETE
}
#[doc = "Checks if the value of the field is `COMPLETE`"]
#[inline(always)]
pub fn is_complete(&self) -> bool {
*self == TCR::COMPLETE
}
}
#[doc = "Possible values of the field `TCR`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum TCRR {
#[doc = "Transfer is not complete"]
NOTCOMPLETE,
#[doc = "NBYTES has been transfered"]
COMPLETE,
}
impl TCRR {
#[doc = r"Returns `true` if the bit is clear (0)"]
#[inline(always)]
pub fn bit_is_clear(&self) -> bool {
!self.bit()
}
#[doc = r"Returns `true` if the bit is set (1)"]
#[inline(always)]
pub fn bit_is_set(&self) -> bool {
self.bit()
}
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bit(&self) -> bool {
match *self {
TCRR::NOTCOMPLETE => false,
TCRR::COMPLETE => true,
}
}
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _from(value: bool) -> TCRR {
match value {
false => TCRR::NOTCOMPLETE,
true => TCRR::COMPLETE,
}
}
#[doc = "Checks if the value of the field is `NOTCOMPLETE`"]
#[inline(always)]
pub fn is_not_complete(&self) -> bool {
*self == TCRR::NOTCOMPLETE
}
#[doc = "Checks if the value of the field is `COMPLETE`"]
#[inline(always)]
pub fn is_complete(&self) -> bool {
*self == TCRR::COMPLETE
}
}
#[doc = "Possible values of the field `BERR`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum BERRR {
#[doc = "No bus error"]
NOERROR,
#[doc = "Misplaced Start and Stop condition is detected"]
ERROR,
}
impl BERRR {
#[doc = r"Returns `true` if the bit is clear (0)"]
#[inline(always)]
pub fn bit_is_clear(&self) -> bool {
!self.bit()
}
#[doc = r"Returns `true` if the bit is set (1)"]
#[inline(always)]
pub fn bit_is_set(&self) -> bool {
self.bit()
}
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bit(&self) -> bool {
match *self {
BERRR::NOERROR => false,
BERRR::ERROR => true,
}
}
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _from(value: bool) -> BERRR {
match value {
false => BERRR::NOERROR,
true => BERRR::ERROR,
}
}
#[doc = "Checks if the value of the field is `NOERROR`"]
#[inline(always)]
pub fn is_no_error(&self) -> bool {
*self == BERRR::NOERROR
}
#[doc = "Checks if the value of the field is `ERROR`"]
#[inline(always)]
pub fn is_error(&self) -> bool {
*self == BERRR::ERROR
}
}
#[doc = "Possible values of the field `ARLO`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum ARLOR {
#[doc = "No arbitration lost"]
NOTLOST,
#[doc = "Arbitration lost"]
LOST,
}
impl ARLOR {
#[doc = r"Returns `true` if the bit is clear (0)"]
#[inline(always)]
pub fn bit_is_clear(&self) -> bool {
!self.bit()
}
#[doc = r"Returns `true` if the bit is set (1)"]
#[inline(always)]
pub fn bit_is_set(&self) -> bool {
self.bit()
}
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bit(&self) -> bool {
match *self {
ARLOR::NOTLOST => false,
ARLOR::LOST => true,
}
}
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _from(value: bool) -> ARLOR {
match value {
false => ARLOR::NOTLOST,
true => ARLOR::LOST,
}
}
#[doc = "Checks if the value of the field is `NOTLOST`"]
#[inline(always)]
pub fn is_not_lost(&self) -> bool {
*self == ARLOR::NOTLOST
}
#[doc = "Checks if the value of the field is `LOST`"]
#[inline(always)]
pub fn is_lost(&self) -> bool {
*self == ARLOR::LOST
}
}
#[doc = "Possible values of the field `OVR`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum OVRR {
#[doc = "No overrun/underrun error occurs"]
NOOVERRUN,
#[doc = "slave mode with NOSTRETCH=1, when an overrun/underrun error occurs"]
OVERRUN,
}
impl OVRR {
#[doc = r"Returns `true` if the bit is clear (0)"]
#[inline(always)]
pub fn bit_is_clear(&self) -> bool {
!self.bit()
}
#[doc = r"Returns `true` if the bit is set (1)"]
#[inline(always)]
pub fn bit_is_set(&self) -> bool {
self.bit()
}
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bit(&self) -> bool {
match *self {
OVRR::NOOVERRUN => false,
OVRR::OVERRUN => true,
}
}
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _from(value: bool) -> OVRR {
match value {
false => OVRR::NOOVERRUN,
true => OVRR::OVERRUN,
}
}
#[doc = "Checks if the value of the field is `NOOVERRUN`"]
#[inline(always)]
pub fn is_no_overrun(&self) -> bool {
*self == OVRR::NOOVERRUN
}
#[doc = "Checks if the value of the field is `OVERRUN`"]
#[inline(always)]
pub fn is_overrun(&self) -> bool {
*self == OVRR::OVERRUN
}
}
#[doc = "Possible values of the field `PECERR`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum PECERRR {
#[doc = "Received PEC does match with PEC register"]
MATCH,
#[doc = "Received PEC does not match with PEC register"]
NOMATCH,
}
impl PECERRR {
#[doc = r"Returns `true` if the bit is clear (0)"]
#[inline(always)]
pub fn bit_is_clear(&self) -> bool {
!self.bit()
}
#[doc = r"Returns `true` if the bit is set (1)"]
#[inline(always)]
pub fn bit_is_set(&self) -> bool {
self.bit()
}
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bit(&self) -> bool {
match *self {
PECERRR::MATCH => false,
PECERRR::NOMATCH => true,
}
}
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _from(value: bool) -> PECERRR {
match value {
false => PECERRR::MATCH,
true => PECERRR::NOMATCH,
}
}
#[doc = "Checks if the value of the field is `MATCH`"]
#[inline(always)]
pub fn is_match_(&self) -> bool {
*self == PECERRR::MATCH
}
#[doc = "Checks if the value of the field is `NOMATCH`"]
#[inline(always)]
pub fn is_no_match(&self) -> bool {
*self == PECERRR::NOMATCH
}
}
#[doc = "Possible values of the field `TIMEOUT`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum TIMEOUTR {
#[doc = "No timeout occured"]
NOTIMEOUT,
#[doc = "Timeout occured"]
TIMEOUT,
}
impl TIMEOUTR {
#[doc = r"Returns `true` if the bit is clear (0)"]
#[inline(always)]
pub fn bit_is_clear(&self) -> bool {
!self.bit()
}
#[doc = r"Returns `true` if the bit is set (1)"]
#[inline(always)]
pub fn bit_is_set(&self) -> bool {
self.bit()
}
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bit(&self) -> bool {
match *self {
TIMEOUTR::NOTIMEOUT => false,
TIMEOUTR::TIMEOUT => true,
}
}
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _from(value: bool) -> TIMEOUTR {
match value {
false => TIMEOUTR::NOTIMEOUT,
true => TIMEOUTR::TIMEOUT,
}
}
#[doc = "Checks if the value of the field is `NOTIMEOUT`"]
#[inline(always)]
pub fn is_no_timeout(&self) -> bool {
*self == TIMEOUTR::NOTIMEOUT
}
#[doc = "Checks if the value of the field is `TIMEOUT`"]
#[inline(always)]
pub fn is_timeout(&self) -> bool {
*self == TIMEOUTR::TIMEOUT
}
}
#[doc = "Possible values of the field `ALERT`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum ALERTR {
#[doc = "SMBA alert is not detected"]
NOALERT,
#[doc = "SMBA alert event is detected on SMBA pin"]
ALERT,
}
impl ALERTR {
#[doc = r"Returns `true` if the bit is clear (0)"]
#[inline(always)]
pub fn bit_is_clear(&self) -> bool {
!self.bit()
}
#[doc = r"Returns `true` if the bit is set (1)"]
#[inline(always)]
pub fn bit_is_set(&self) -> bool {
self.bit()
}
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bit(&self) -> bool {
match *self {
ALERTR::NOALERT => false,
ALERTR::ALERT => true,
}
}
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _from(value: bool) -> ALERTR {
match value {
false => ALERTR::NOALERT,
true => ALERTR::ALERT,
}
}
#[doc = "Checks if the value of the field is `NOALERT`"]
#[inline(always)]
pub fn is_no_alert(&self) -> bool {
*self == ALERTR::NOALERT
}
#[doc = "Checks if the value of the field is `ALERT`"]
#[inline(always)]
pub fn is_alert(&self) -> bool {
*self == ALERTR::ALERT
}
}
#[doc = "Possible values of the field `BUSY`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum BUSYR {
#[doc = "No communication is in progress on the bus"]
NOTBUSY,
#[doc = "A communication is in progress on the bus"]
BUSY,
}
impl BUSYR {
#[doc = r"Returns `true` if the bit is clear (0)"]
#[inline(always)]
pub fn bit_is_clear(&self) -> bool {
!self.bit()
}
#[doc = r"Returns `true` if the bit is set (1)"]
#[inline(always)]
pub fn bit_is_set(&self) -> bool {
self.bit()
}
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bit(&self) -> bool {
match *self {
BUSYR::NOTBUSY => false,
BUSYR::BUSY => true,
}
}
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _from(value: bool) -> BUSYR {
match value {
false => BUSYR::NOTBUSY,
true => BUSYR::BUSY,
}
}
#[doc = "Checks if the value of the field is `NOTBUSY`"]
#[inline(always)]
pub fn is_not_busy(&self) -> bool {
*self == BUSYR::NOTBUSY
}
#[doc = "Checks if the value of the field is `BUSY`"]
#[inline(always)]
pub fn is_busy(&self) -> bool {
*self == BUSYR::BUSY
}
}
#[doc = "Possible values of the field `DIR`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum DIRR {
#[doc = "Write transfer, slave enters receiver mode"]
WRITE,
#[doc = "Read transfer, slave enters transmitter mode"]
READ,
}
impl DIRR {
#[doc = r"Returns `true` if the bit is clear (0)"]
#[inline(always)]
pub fn bit_is_clear(&self) -> bool {
!self.bit()
}
#[doc = r"Returns `true` if the bit is set (1)"]
#[inline(always)]
pub fn bit_is_set(&self) -> bool {
self.bit()
}
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bit(&self) -> bool {
match *self {
DIRR::WRITE => false,
DIRR::READ => true,
}
}
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _from(value: bool) -> DIRR {
match value {
false => DIRR::WRITE,
true => DIRR::READ,
}
}
#[doc = "Checks if the value of the field is `WRITE`"]
#[inline(always)]
pub fn is_write(&self) -> bool {
*self == DIRR::WRITE
}
#[doc = "Checks if the value of the field is `READ`"]
#[inline(always)]
pub fn is_read(&self) -> bool {
*self == DIRR::READ
}
}
#[doc = r"Value of the field"]
pub struct ADDCODER {
bits: u8,
}
impl ADDCODER {
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bits(&self) -> u8 {
self.bits
}
}
impl R {
#[doc = r"Value of the register as raw bits"]
#[inline(always)]
pub fn bits(&self) -> u32 {
self.bits
}
#[doc = "Bit 0 - Transmit data register empty (transmitters) This bit is set by hardware when the I2C_TXDR register is empty. It is cleared when the next data to be sent is written in the I2C_TXDR register. This bit can be written to 1 by software in order to flush the transmit data register I2C_TXDR. Note: This bit is set by hardware when PE=0."]
#[inline(always)]
pub fn txe(&self) -> TXER {
TXER::_from(((self.bits >> 0) & 0x01) != 0)
}
#[doc = "Bit 1 - Transmit interrupt status (transmitters) This bit is set by hardware when the I2C_TXDR register is empty and the data to be transmitted must be written in the I2C_TXDR register. It is cleared when the next data to be sent is written in the I2C_TXDR register. This bit can be written to 1 by software when NOSTRETCH=1 only, in order to generate a TXIS event (interrupt if TXIE=1 or DMA request if TXDMAEN=1). Note: This bit is cleared by hardware when PE=0."]
#[inline(always)]
pub fn txis(&self) -> TXISR {
TXISR::_from(((self.bits >> 1) & 0x01) != 0)
}
#[doc = "Bit 2 - Receive data register not empty (receivers) This bit is set by hardware when the received data is copied into the I2C_RXDR register, and is ready to be read. It is cleared when I2C_RXDR is read. Note: This bit is cleared by hardware when PE=0."]
#[inline(always)]
pub fn rxne(&self) -> RXNER {
RXNER::_from(((self.bits >> 2) & 0x01) != 0)
}
#[doc = "Bit 3 - Address matched (slave mode) This bit is set by hardware as soon as the received slave address matched with one of the enabled slave addresses. It is cleared by software by setting ADDRCF bit. Note: This bit is cleared by hardware when PE=0."]
#[inline(always)]
pub fn addr(&self) -> ADDRR {
ADDRR::_from(((self.bits >> 3) & 0x01) != 0)
}
#[doc = "Bit 4 - Not Acknowledge received flag This flag is set by hardware when a NACK is received after a byte transmission. It is cleared by software by setting the NACKCF bit. Note: This bit is cleared by hardware when PE=0."]
#[inline(always)]
pub fn nackf(&self) -> NACKFR {
NACKFR::_from(((self.bits >> 4) & 0x01) != 0)
}
#[doc = "Bit 5 - Stop detection flag This flag is set by hardware when a Stop condition is detected on the bus and the peripheral is involved in this transfer: either as a master, provided that the STOP condition is generated by the peripheral. or as a slave, provided that the peripheral has been addressed previously during this transfer. It is cleared by software by setting the STOPCF bit. Note: This bit is cleared by hardware when PE=0."]
#[inline(always)]
pub fn stopf(&self) -> STOPFR {
STOPFR::_from(((self.bits >> 5) & 0x01) != 0)
}
#[doc = "Bit 6 - Transfer Complete (master mode) This flag is set by hardware when RELOAD=0, AUTOEND=0 and NBYTES data have been transferred. It is cleared by software when START bit or STOP bit is set. Note: This bit is cleared by hardware when PE=0."]
#[inline(always)]
pub fn tc(&self) -> TCR {
TCR::_from(((self.bits >> 6) & 0x01) != 0)
}
#[doc = "Bit 7 - Transfer Complete Reload This flag is set by hardware when RELOAD=1 and NBYTES data have been transferred. It is cleared by software when NBYTES is written to a non-zero value. Note: This bit is cleared by hardware when PE=0. This flag is only for master mode, or for slave mode when the SBC bit is set."]
#[inline(always)]
pub fn tcr(&self) -> TCRR {
TCRR::_from(((self.bits >> 7) & 0x01) != 0)
}
#[doc = "Bit 8 - Bus error This flag is set by hardware when a misplaced Start or Stop condition is detected whereas the peripheral is involved in the transfer. The flag is not set during the address phase in slave mode. It is cleared by software by setting BERRCF bit. Note: This bit is cleared by hardware when PE=0."]
#[inline(always)]
pub fn berr(&self) -> BERRR {
BERRR::_from(((self.bits >> 8) & 0x01) != 0)
}
#[doc = "Bit 9 - Arbitration lost This flag is set by hardware in case of arbitration loss. It is cleared by software by setting the ARLOCF bit. Note: This bit is cleared by hardware when PE=0."]
#[inline(always)]
pub fn arlo(&self) -> ARLOR {
ARLOR::_from(((self.bits >> 9) & 0x01) != 0)
}
#[doc = "Bit 10 - Overrun/Underrun (slave mode) This flag is set by hardware in slave mode with NOSTRETCH=1, when an overrun/underrun error occurs. It is cleared by software by setting the OVRCF bit. Note: This bit is cleared by hardware when PE=0."]
#[inline(always)]
pub fn ovr(&self) -> OVRR {
OVRR::_from(((self.bits >> 10) & 0x01) != 0)
}
#[doc = "Bit 11 - PEC Error in reception This flag is set by hardware when the received PEC does not match with the PEC register content. A NACK is automatically sent after the wrong PEC reception. It is cleared by software by setting the PECCF bit. Note: This bit is cleared by hardware when PE=0. If the SMBus feature is not supported, this bit is reserved and forced by hardware to 0. Please refer to Section25.3: I2C implementation."]
#[inline(always)]
pub fn pecerr(&self) -> PECERRR {
PECERRR::_from(((self.bits >> 11) & 0x01) != 0)
}
#[doc = "Bit 12 - Timeout or tLOW detection flag This flag is set by hardware when a timeout or extended clock timeout occurred. It is cleared by software by setting the TIMEOUTCF bit. Note: This bit is cleared by hardware when PE=0. If the SMBus feature is not supported, this bit is reserved and forced by hardware to 0. Please refer to Section25.3: I2C implementation."]
#[inline(always)]
pub fn timeout(&self) -> TIMEOUTR {
TIMEOUTR::_from(((self.bits >> 12) & 0x01) != 0)
}
#[doc = "Bit 13 - SMBus alert This flag is set by hardware when SMBHEN=1 (SMBus host configuration), ALERTEN=1 and a SMBALERT event (falling edge) is detected on SMBA pin. It is cleared by software by setting the ALERTCF bit. Note: This bit is cleared by hardware when PE=0. If the SMBus feature is not supported, this bit is reserved and forced by hardware to 0. Please refer to Section25.3: I2C implementation."]
#[inline(always)]
pub fn alert(&self) -> ALERTR {
ALERTR::_from(((self.bits >> 13) & 0x01) != 0)
}
#[doc = "Bit 15 - Bus busy This flag indicates that a communication is in progress on the bus. It is set by hardware when a START condition is detected. It is cleared by hardware when a Stop condition is detected, or when PE=0."]
#[inline(always)]
pub fn busy(&self) -> BUSYR {
BUSYR::_from(((self.bits >> 15) & 0x01) != 0)
}
#[doc = "Bit 16 - Transfer direction (Slave mode) This flag is updated when an address match event occurs (ADDR=1)."]
#[inline(always)]
pub fn dir(&self) -> DIRR {
DIRR::_from(((self.bits >> 16) & 0x01) != 0)
}
#[doc = "Bits 17:23 - Address match code (Slave mode) These bits are updated with the received address when an address match event occurs (ADDR = 1). In the case of a 10-bit address, ADDCODE provides the 10-bit header followed by the 2 MSBs of the address."]
#[inline(always)]
pub fn addcode(&self) -> ADDCODER {
let bits = ((self.bits >> 17) & 0x7f) as u8;
ADDCODER { bits }
}
}
impl W {
#[doc = r"Writes raw bits to the register"]
#[inline(always)]
pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
self.bits = bits;
self
}
#[doc = "Bit 0 - Transmit data register empty (transmitters) This bit is set by hardware when the I2C_TXDR register is empty. It is cleared when the next data to be sent is written in the I2C_TXDR register. This bit can be written to 1 by software in order to flush the transmit data register I2C_TXDR. Note: This bit is set by hardware when PE=0."]
#[inline(always)]
pub fn txe(&mut self) -> _TXEW {
_TXEW { w: self }
}
#[doc = "Bit 1 - Transmit interrupt status (transmitters) This bit is set by hardware when the I2C_TXDR register is empty and the data to be transmitted must be written in the I2C_TXDR register. It is cleared when the next data to be sent is written in the I2C_TXDR register. This bit can be written to 1 by software when NOSTRETCH=1 only, in order to generate a TXIS event (interrupt if TXIE=1 or DMA request if TXDMAEN=1). Note: This bit is cleared by hardware when PE=0."]
#[inline(always)]
pub fn txis(&mut self) -> _TXISW {
_TXISW { w: self }
}
}