#[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::CR2 {
#[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 {
0
}
#[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 `RD_WRN`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum RD_WRNR {
#[doc = "Master requests a write transfer"]
WRITE,
#[doc = "Master requests a read transfer"]
READ,
}
impl RD_WRNR {
#[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 {
RD_WRNR::WRITE => false,
RD_WRNR::READ => true,
}
}
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _from(value: bool) -> RD_WRNR {
match value {
false => RD_WRNR::WRITE,
true => RD_WRNR::READ,
}
}
#[doc = "Checks if the value of the field is `WRITE`"]
#[inline(always)]
pub fn is_write(&self) -> bool {
*self == RD_WRNR::WRITE
}
#[doc = "Checks if the value of the field is `READ`"]
#[inline(always)]
pub fn is_read(&self) -> bool {
*self == RD_WRNR::READ
}
}
#[doc = "Values that can be written to the field `RD_WRN`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum RD_WRNW {
#[doc = "Master requests a write transfer"]
WRITE,
#[doc = "Master requests a read transfer"]
READ,
}
impl RD_WRNW {
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _bits(&self) -> bool {
match *self {
RD_WRNW::WRITE => false,
RD_WRNW::READ => true,
}
}
}
#[doc = r"Proxy"]
pub struct _RD_WRNW<'a> {
w: &'a mut W,
}
impl<'a> _RD_WRNW<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: RD_WRNW) -> &'a mut W {
{
self.bit(variant._bits())
}
}
#[doc = "Master requests a write transfer"]
#[inline(always)]
pub fn write(self) -> &'a mut W {
self.variant(RD_WRNW::WRITE)
}
#[doc = "Master requests a read transfer"]
#[inline(always)]
pub fn read(self) -> &'a mut W {
self.variant(RD_WRNW::READ)
}
#[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 << 10);
self.w.bits |= ((value as u32) & 0x01) << 10;
self.w
}
}
#[doc = "Possible values of the field `ADD10`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum ADD10R {
#[doc = "The master operates in 7-bit addressing mode"]
BIT7,
#[doc = "The master operates in 10-bit addressing mode"]
BIT10,
}
impl ADD10R {
#[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 {
ADD10R::BIT7 => false,
ADD10R::BIT10 => true,
}
}
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _from(value: bool) -> ADD10R {
match value {
false => ADD10R::BIT7,
true => ADD10R::BIT10,
}
}
#[doc = "Checks if the value of the field is `BIT7`"]
#[inline(always)]
pub fn is_bit7(&self) -> bool {
*self == ADD10R::BIT7
}
#[doc = "Checks if the value of the field is `BIT10`"]
#[inline(always)]
pub fn is_bit10(&self) -> bool {
*self == ADD10R::BIT10
}
}
#[doc = "Values that can be written to the field `ADD10`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum ADD10W {
#[doc = "The master operates in 7-bit addressing mode"]
BIT7,
#[doc = "The master operates in 10-bit addressing mode"]
BIT10,
}
impl ADD10W {
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _bits(&self) -> bool {
match *self {
ADD10W::BIT7 => false,
ADD10W::BIT10 => true,
}
}
}
#[doc = r"Proxy"]
pub struct _ADD10W<'a> {
w: &'a mut W,
}
impl<'a> _ADD10W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: ADD10W) -> &'a mut W {
{
self.bit(variant._bits())
}
}
#[doc = "The master operates in 7-bit addressing mode"]
#[inline(always)]
pub fn bit7(self) -> &'a mut W {
self.variant(ADD10W::BIT7)
}
#[doc = "The master operates in 10-bit addressing mode"]
#[inline(always)]
pub fn bit10(self) -> &'a mut W {
self.variant(ADD10W::BIT10)
}
#[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 << 11);
self.w.bits |= ((value as u32) & 0x01) << 11;
self.w
}
}
#[doc = "Possible values of the field `HEAD10R`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum HEAD10RR {
#[doc = "The master sends the complete 10 bit slave address read sequence"]
COMPLETE,
#[doc = "The master only sends the 1st 7 bits of the 10 bit address, followed by Read direction"]
PARTIAL,
}
impl HEAD10RR {
#[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 {
HEAD10RR::COMPLETE => false,
HEAD10RR::PARTIAL => true,
}
}
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _from(value: bool) -> HEAD10RR {
match value {
false => HEAD10RR::COMPLETE,
true => HEAD10RR::PARTIAL,
}
}
#[doc = "Checks if the value of the field is `COMPLETE`"]
#[inline(always)]
pub fn is_complete(&self) -> bool {
*self == HEAD10RR::COMPLETE
}
#[doc = "Checks if the value of the field is `PARTIAL`"]
#[inline(always)]
pub fn is_partial(&self) -> bool {
*self == HEAD10RR::PARTIAL
}
}
#[doc = "Values that can be written to the field `HEAD10R`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum HEAD10RW {
#[doc = "The master sends the complete 10 bit slave address read sequence"]
COMPLETE,
#[doc = "The master only sends the 1st 7 bits of the 10 bit address, followed by Read direction"]
PARTIAL,
}
impl HEAD10RW {
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _bits(&self) -> bool {
match *self {
HEAD10RW::COMPLETE => false,
HEAD10RW::PARTIAL => true,
}
}
}
#[doc = r"Proxy"]
pub struct _HEAD10RW<'a> {
w: &'a mut W,
}
impl<'a> _HEAD10RW<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: HEAD10RW) -> &'a mut W {
{
self.bit(variant._bits())
}
}
#[doc = "The master sends the complete 10 bit slave address read sequence"]
#[inline(always)]
pub fn complete(self) -> &'a mut W {
self.variant(HEAD10RW::COMPLETE)
}
#[doc = "The master only sends the 1st 7 bits of the 10 bit address, followed by Read direction"]
#[inline(always)]
pub fn partial(self) -> &'a mut W {
self.variant(HEAD10RW::PARTIAL)
}
#[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 << 12);
self.w.bits |= ((value as u32) & 0x01) << 12;
self.w
}
}
#[doc = "Possible values of the field `START`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum STARTR {
#[doc = "No Start generation"]
NOSTART,
#[doc = "Restart/Start generation"]
START,
}
impl STARTR {
#[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 {
STARTR::NOSTART => false,
STARTR::START => true,
}
}
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _from(value: bool) -> STARTR {
match value {
false => STARTR::NOSTART,
true => STARTR::START,
}
}
#[doc = "Checks if the value of the field is `NOSTART`"]
#[inline(always)]
pub fn is_no_start(&self) -> bool {
*self == STARTR::NOSTART
}
#[doc = "Checks if the value of the field is `START`"]
#[inline(always)]
pub fn is_start(&self) -> bool {
*self == STARTR::START
}
}
#[doc = "Values that can be written to the field `START`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum STARTW {
#[doc = "No Start generation"]
NOSTART,
#[doc = "Restart/Start generation"]
START,
}
impl STARTW {
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _bits(&self) -> bool {
match *self {
STARTW::NOSTART => false,
STARTW::START => true,
}
}
}
#[doc = r"Proxy"]
pub struct _STARTW<'a> {
w: &'a mut W,
}
impl<'a> _STARTW<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: STARTW) -> &'a mut W {
{
self.bit(variant._bits())
}
}
#[doc = "No Start generation"]
#[inline(always)]
pub fn no_start(self) -> &'a mut W {
self.variant(STARTW::NOSTART)
}
#[doc = "Restart/Start generation"]
#[inline(always)]
pub fn start(self) -> &'a mut W {
self.variant(STARTW::START)
}
#[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 << 13);
self.w.bits |= ((value as u32) & 0x01) << 13;
self.w
}
}
#[doc = "Possible values of the field `STOP`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum STOPR {
#[doc = "No Stop generation"]
NOSTOP,
#[doc = "Stop generation after current byte transfer"]
STOP,
}
impl STOPR {
#[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 {
STOPR::NOSTOP => false,
STOPR::STOP => true,
}
}
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _from(value: bool) -> STOPR {
match value {
false => STOPR::NOSTOP,
true => STOPR::STOP,
}
}
#[doc = "Checks if the value of the field is `NOSTOP`"]
#[inline(always)]
pub fn is_no_stop(&self) -> bool {
*self == STOPR::NOSTOP
}
#[doc = "Checks if the value of the field is `STOP`"]
#[inline(always)]
pub fn is_stop(&self) -> bool {
*self == STOPR::STOP
}
}
#[doc = "Values that can be written to the field `STOP`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum STOPW {
#[doc = "No Stop generation"]
NOSTOP,
#[doc = "Stop generation after current byte transfer"]
STOP,
}
impl STOPW {
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _bits(&self) -> bool {
match *self {
STOPW::NOSTOP => false,
STOPW::STOP => true,
}
}
}
#[doc = r"Proxy"]
pub struct _STOPW<'a> {
w: &'a mut W,
}
impl<'a> _STOPW<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: STOPW) -> &'a mut W {
{
self.bit(variant._bits())
}
}
#[doc = "No Stop generation"]
#[inline(always)]
pub fn no_stop(self) -> &'a mut W {
self.variant(STOPW::NOSTOP)
}
#[doc = "Stop generation after current byte transfer"]
#[inline(always)]
pub fn stop(self) -> &'a mut W {
self.variant(STOPW::STOP)
}
#[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 << 14);
self.w.bits |= ((value as u32) & 0x01) << 14;
self.w
}
}
#[doc = "Possible values of the field `NACK`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum NACKR {
#[doc = "an ACK is sent after current received byte"]
ACK,
#[doc = "a NACK is sent after current received byte"]
NACK,
}
impl NACKR {
#[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 {
NACKR::ACK => false,
NACKR::NACK => true,
}
}
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _from(value: bool) -> NACKR {
match value {
false => NACKR::ACK,
true => NACKR::NACK,
}
}
#[doc = "Checks if the value of the field is `ACK`"]
#[inline(always)]
pub fn is_ack(&self) -> bool {
*self == NACKR::ACK
}
#[doc = "Checks if the value of the field is `NACK`"]
#[inline(always)]
pub fn is_nack(&self) -> bool {
*self == NACKR::NACK
}
}
#[doc = "Values that can be written to the field `NACK`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum NACKW {
#[doc = "an ACK is sent after current received byte"]
ACK,
#[doc = "a NACK is sent after current received byte"]
NACK,
}
impl NACKW {
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _bits(&self) -> bool {
match *self {
NACKW::ACK => false,
NACKW::NACK => true,
}
}
}
#[doc = r"Proxy"]
pub struct _NACKW<'a> {
w: &'a mut W,
}
impl<'a> _NACKW<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: NACKW) -> &'a mut W {
{
self.bit(variant._bits())
}
}
#[doc = "an ACK is sent after current received byte"]
#[inline(always)]
pub fn ack(self) -> &'a mut W {
self.variant(NACKW::ACK)
}
#[doc = "a NACK is sent after current received byte"]
#[inline(always)]
pub fn nack(self) -> &'a mut W {
self.variant(NACKW::NACK)
}
#[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 << 15);
self.w.bits |= ((value as u32) & 0x01) << 15;
self.w
}
}
#[doc = r"Value of the field"]
pub struct NBYTESR {
bits: u8,
}
impl NBYTESR {
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bits(&self) -> u8 {
self.bits
}
}
#[doc = r"Proxy"]
pub struct _NBYTESW<'a> {
w: &'a mut W,
}
impl<'a> _NBYTESW<'a> {
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bits(self, value: u8) -> &'a mut W {
self.w.bits &= !(0xff << 16);
self.w.bits |= ((value as u32) & 0xff) << 16;
self.w
}
}
#[doc = "Possible values of the field `RELOAD`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum RELOADR {
#[doc = "The transfer is completed after the NBYTES data transfer (STOP or RESTART will follow)"]
COMPLETED,
#[doc = "The transfer is not completed after the NBYTES data transfer (NBYTES will be reloaded)"]
NOTCOMPETED,
}
impl RELOADR {
#[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 {
RELOADR::COMPLETED => false,
RELOADR::NOTCOMPETED => true,
}
}
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _from(value: bool) -> RELOADR {
match value {
false => RELOADR::COMPLETED,
true => RELOADR::NOTCOMPETED,
}
}
#[doc = "Checks if the value of the field is `COMPLETED`"]
#[inline(always)]
pub fn is_completed(&self) -> bool {
*self == RELOADR::COMPLETED
}
#[doc = "Checks if the value of the field is `NOTCOMPETED`"]
#[inline(always)]
pub fn is_not_competed(&self) -> bool {
*self == RELOADR::NOTCOMPETED
}
}
#[doc = "Values that can be written to the field `RELOAD`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum RELOADW {
#[doc = "The transfer is completed after the NBYTES data transfer (STOP or RESTART will follow)"]
COMPLETED,
#[doc = "The transfer is not completed after the NBYTES data transfer (NBYTES will be reloaded)"]
NOTCOMPETED,
}
impl RELOADW {
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _bits(&self) -> bool {
match *self {
RELOADW::COMPLETED => false,
RELOADW::NOTCOMPETED => true,
}
}
}
#[doc = r"Proxy"]
pub struct _RELOADW<'a> {
w: &'a mut W,
}
impl<'a> _RELOADW<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: RELOADW) -> &'a mut W {
{
self.bit(variant._bits())
}
}
#[doc = "The transfer is completed after the NBYTES data transfer (STOP or RESTART will follow)"]
#[inline(always)]
pub fn completed(self) -> &'a mut W {
self.variant(RELOADW::COMPLETED)
}
#[doc = "The transfer is not completed after the NBYTES data transfer (NBYTES will be reloaded)"]
#[inline(always)]
pub fn not_competed(self) -> &'a mut W {
self.variant(RELOADW::NOTCOMPETED)
}
#[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 << 24);
self.w.bits |= ((value as u32) & 0x01) << 24;
self.w
}
}
#[doc = "Possible values of the field `AUTOEND`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum AUTOENDR {
#[doc = "Software end mode: TC flag is set when NBYTES data are transferred, stretching SCL low"]
SOFTWARE,
#[doc = "Automatic end mode: a STOP condition is automatically sent when NBYTES data are transferred"]
AUTOMATIC,
}
impl AUTOENDR {
#[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 {
AUTOENDR::SOFTWARE => false,
AUTOENDR::AUTOMATIC => true,
}
}
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _from(value: bool) -> AUTOENDR {
match value {
false => AUTOENDR::SOFTWARE,
true => AUTOENDR::AUTOMATIC,
}
}
#[doc = "Checks if the value of the field is `SOFTWARE`"]
#[inline(always)]
pub fn is_software(&self) -> bool {
*self == AUTOENDR::SOFTWARE
}
#[doc = "Checks if the value of the field is `AUTOMATIC`"]
#[inline(always)]
pub fn is_automatic(&self) -> bool {
*self == AUTOENDR::AUTOMATIC
}
}
#[doc = "Values that can be written to the field `AUTOEND`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum AUTOENDW {
#[doc = "Software end mode: TC flag is set when NBYTES data are transferred, stretching SCL low"]
SOFTWARE,
#[doc = "Automatic end mode: a STOP condition is automatically sent when NBYTES data are transferred"]
AUTOMATIC,
}
impl AUTOENDW {
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _bits(&self) -> bool {
match *self {
AUTOENDW::SOFTWARE => false,
AUTOENDW::AUTOMATIC => true,
}
}
}
#[doc = r"Proxy"]
pub struct _AUTOENDW<'a> {
w: &'a mut W,
}
impl<'a> _AUTOENDW<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: AUTOENDW) -> &'a mut W {
{
self.bit(variant._bits())
}
}
#[doc = "Software end mode: TC flag is set when NBYTES data are transferred, stretching SCL low"]
#[inline(always)]
pub fn software(self) -> &'a mut W {
self.variant(AUTOENDW::SOFTWARE)
}
#[doc = "Automatic end mode: a STOP condition is automatically sent when NBYTES data are transferred"]
#[inline(always)]
pub fn automatic(self) -> &'a mut W {
self.variant(AUTOENDW::AUTOMATIC)
}
#[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 << 25);
self.w.bits |= ((value as u32) & 0x01) << 25;
self.w
}
}
#[doc = "Possible values of the field `PECBYTE`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum PECBYTER {
#[doc = "No PEC transfer"]
NOPEC,
#[doc = "PEC transmission/reception is requested"]
PEC,
}
impl PECBYTER {
#[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 {
PECBYTER::NOPEC => false,
PECBYTER::PEC => true,
}
}
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _from(value: bool) -> PECBYTER {
match value {
false => PECBYTER::NOPEC,
true => PECBYTER::PEC,
}
}
#[doc = "Checks if the value of the field is `NOPEC`"]
#[inline(always)]
pub fn is_no_pec(&self) -> bool {
*self == PECBYTER::NOPEC
}
#[doc = "Checks if the value of the field is `PEC`"]
#[inline(always)]
pub fn is_pec(&self) -> bool {
*self == PECBYTER::PEC
}
}
#[doc = "Values that can be written to the field `PECBYTE`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum PECBYTEW {
#[doc = "No PEC transfer"]
NOPEC,
#[doc = "PEC transmission/reception is requested"]
PEC,
}
impl PECBYTEW {
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _bits(&self) -> bool {
match *self {
PECBYTEW::NOPEC => false,
PECBYTEW::PEC => true,
}
}
}
#[doc = r"Proxy"]
pub struct _PECBYTEW<'a> {
w: &'a mut W,
}
impl<'a> _PECBYTEW<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: PECBYTEW) -> &'a mut W {
{
self.bit(variant._bits())
}
}
#[doc = "No PEC transfer"]
#[inline(always)]
pub fn no_pec(self) -> &'a mut W {
self.variant(PECBYTEW::NOPEC)
}
#[doc = "PEC transmission/reception is requested"]
#[inline(always)]
pub fn pec(self) -> &'a mut W {
self.variant(PECBYTEW::PEC)
}
#[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 << 26);
self.w.bits |= ((value as u32) & 0x01) << 26;
self.w
}
}
#[doc = r"Value of the field"]
pub struct SADDR {
bits: u16,
}
impl SADDR {
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bits(&self) -> u16 {
self.bits
}
}
#[doc = r"Proxy"]
pub struct _SADDW<'a> {
w: &'a mut W,
}
impl<'a> _SADDW<'a> {
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bits(self, value: u16) -> &'a mut W {
self.w.bits &= !(0x03ff << 0);
self.w.bits |= ((value as u32) & 0x03ff) << 0;
self.w
}
}
impl R {
#[doc = r"Value of the register as raw bits"]
#[inline(always)]
pub fn bits(&self) -> u32 {
self.bits
}
#[doc = "Bit 10 - Transfer direction (master mode) Note: Changing this bit when the START bit is set is not allowed."]
#[inline(always)]
pub fn rd_wrn(&self) -> RD_WRNR {
RD_WRNR::_from(((self.bits >> 10) & 0x01) != 0)
}
#[doc = "Bit 11 - 10-bit addressing mode (master mode) Note: Changing this bit when the START bit is set is not allowed."]
#[inline(always)]
pub fn add10(&self) -> ADD10R {
ADD10R::_from(((self.bits >> 11) & 0x01) != 0)
}
#[doc = "Bit 12 - 10-bit address header only read direction (master receiver mode) Note: Changing this bit when the START bit is set is not allowed."]
#[inline(always)]
pub fn head10r(&self) -> HEAD10RR {
HEAD10RR::_from(((self.bits >> 12) & 0x01) != 0)
}
#[doc = "Bit 13 - Start generation This bit is set by software, and cleared by hardware after the Start followed by the address sequence is sent, by an arbitration loss, by a timeout error detection, or when PE = 0. It can also be cleared by software by writing 1 to the ADDRCF bit in the I2C_ICR register. If the I2C is already in master mode with AUTOEND = 0, setting this bit generates a Repeated Start condition when RELOAD=0, after the end of the NBYTES transfer. Otherwise setting this bit will generate a START condition once the bus is free. Note: Writing 0 to this bit has no effect. The START bit can be set even if the bus is BUSY or I2C is in slave mode. This bit has no effect when RELOAD is set."]
#[inline(always)]
pub fn start(&self) -> STARTR {
STARTR::_from(((self.bits >> 13) & 0x01) != 0)
}
#[doc = "Bit 14 - Stop generation (master mode) The bit is set by software, cleared by hardware when a Stop condition is detected, or when PE = 0. In Master Mode: Note: Writing 0 to this bit has no effect."]
#[inline(always)]
pub fn stop(&self) -> STOPR {
STOPR::_from(((self.bits >> 14) & 0x01) != 0)
}
#[doc = "Bit 15 - NACK generation (slave mode) The bit is set by software, cleared by hardware when the NACK is sent, or when a STOP condition or an Address matched is received, or when PE=0. Note: Writing 0 to this bit has no effect. This bit is used in slave mode only: in master receiver mode, NACK is automatically generated after last byte preceding STOP or RESTART condition, whatever the NACK bit value. When an overrun occurs in slave receiver NOSTRETCH mode, a NACK is automatically generated whatever the NACK bit value. When hardware PEC checking is enabled (PECBYTE=1), the PEC acknowledge value does not depend on the NACK value."]
#[inline(always)]
pub fn nack(&self) -> NACKR {
NACKR::_from(((self.bits >> 15) & 0x01) != 0)
}
#[doc = "Bits 16:23 - Number of bytes The number of bytes to be transmitted/received is programmed there. This field is dont care in slave mode with SBC=0. Note: Changing these bits when the START bit is set is not allowed."]
#[inline(always)]
pub fn nbytes(&self) -> NBYTESR {
let bits = ((self.bits >> 16) & 0xff) as u8;
NBYTESR { bits }
}
#[doc = "Bit 24 - NBYTES reload mode This bit is set and cleared by software."]
#[inline(always)]
pub fn reload(&self) -> RELOADR {
RELOADR::_from(((self.bits >> 24) & 0x01) != 0)
}
#[doc = "Bit 25 - Automatic end mode (master mode) This bit is set and cleared by software. Note: This bit has no effect in slave mode or when the RELOAD bit is set."]
#[inline(always)]
pub fn autoend(&self) -> AUTOENDR {
AUTOENDR::_from(((self.bits >> 25) & 0x01) != 0)
}
#[doc = "Bit 26 - Packet error checking byte This bit is set by software, and cleared by hardware when the PEC is transferred, or when a STOP condition or an Address matched is received, also when PE=0. Note: Writing 0 to this bit has no effect. This bit has no effect when RELOAD is set. This bit has no effect is slave mode when SBC=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 pecbyte(&self) -> PECBYTER {
PECBYTER::_from(((self.bits >> 26) & 0x01) != 0)
}
#[doc = "Bits 0:9 - Slave address bit 0 (master mode) In 7-bit addressing mode (ADD10 = 0): This bit is dont care In 10-bit addressing mode (ADD10 = 1): This bit should be written with bit 0 of the slave address to be sent Note: Changing these bits when the START bit is set is not allowed."]
#[inline(always)]
pub fn sadd(&self) -> SADDR {
let bits = ((self.bits >> 0) & 0x03ff) as u16;
SADDR { 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 10 - Transfer direction (master mode) Note: Changing this bit when the START bit is set is not allowed."]
#[inline(always)]
pub fn rd_wrn(&mut self) -> _RD_WRNW {
_RD_WRNW { w: self }
}
#[doc = "Bit 11 - 10-bit addressing mode (master mode) Note: Changing this bit when the START bit is set is not allowed."]
#[inline(always)]
pub fn add10(&mut self) -> _ADD10W {
_ADD10W { w: self }
}
#[doc = "Bit 12 - 10-bit address header only read direction (master receiver mode) Note: Changing this bit when the START bit is set is not allowed."]
#[inline(always)]
pub fn head10r(&mut self) -> _HEAD10RW {
_HEAD10RW { w: self }
}
#[doc = "Bit 13 - Start generation This bit is set by software, and cleared by hardware after the Start followed by the address sequence is sent, by an arbitration loss, by a timeout error detection, or when PE = 0. It can also be cleared by software by writing 1 to the ADDRCF bit in the I2C_ICR register. If the I2C is already in master mode with AUTOEND = 0, setting this bit generates a Repeated Start condition when RELOAD=0, after the end of the NBYTES transfer. Otherwise setting this bit will generate a START condition once the bus is free. Note: Writing 0 to this bit has no effect. The START bit can be set even if the bus is BUSY or I2C is in slave mode. This bit has no effect when RELOAD is set."]
#[inline(always)]
pub fn start(&mut self) -> _STARTW {
_STARTW { w: self }
}
#[doc = "Bit 14 - Stop generation (master mode) The bit is set by software, cleared by hardware when a Stop condition is detected, or when PE = 0. In Master Mode: Note: Writing 0 to this bit has no effect."]
#[inline(always)]
pub fn stop(&mut self) -> _STOPW {
_STOPW { w: self }
}
#[doc = "Bit 15 - NACK generation (slave mode) The bit is set by software, cleared by hardware when the NACK is sent, or when a STOP condition or an Address matched is received, or when PE=0. Note: Writing 0 to this bit has no effect. This bit is used in slave mode only: in master receiver mode, NACK is automatically generated after last byte preceding STOP or RESTART condition, whatever the NACK bit value. When an overrun occurs in slave receiver NOSTRETCH mode, a NACK is automatically generated whatever the NACK bit value. When hardware PEC checking is enabled (PECBYTE=1), the PEC acknowledge value does not depend on the NACK value."]
#[inline(always)]
pub fn nack(&mut self) -> _NACKW {
_NACKW { w: self }
}
#[doc = "Bits 16:23 - Number of bytes The number of bytes to be transmitted/received is programmed there. This field is dont care in slave mode with SBC=0. Note: Changing these bits when the START bit is set is not allowed."]
#[inline(always)]
pub fn nbytes(&mut self) -> _NBYTESW {
_NBYTESW { w: self }
}
#[doc = "Bit 24 - NBYTES reload mode This bit is set and cleared by software."]
#[inline(always)]
pub fn reload(&mut self) -> _RELOADW {
_RELOADW { w: self }
}
#[doc = "Bit 25 - Automatic end mode (master mode) This bit is set and cleared by software. Note: This bit has no effect in slave mode or when the RELOAD bit is set."]
#[inline(always)]
pub fn autoend(&mut self) -> _AUTOENDW {
_AUTOENDW { w: self }
}
#[doc = "Bit 26 - Packet error checking byte This bit is set by software, and cleared by hardware when the PEC is transferred, or when a STOP condition or an Address matched is received, also when PE=0. Note: Writing 0 to this bit has no effect. This bit has no effect when RELOAD is set. This bit has no effect is slave mode when SBC=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 pecbyte(&mut self) -> _PECBYTEW {
_PECBYTEW { w: self }
}
#[doc = "Bits 0:9 - Slave address bit 0 (master mode) In 7-bit addressing mode (ADD10 = 0): This bit is dont care In 10-bit addressing mode (ADD10 = 1): This bit should be written with bit 0 of the slave address to be sent Note: Changing these bits when the START bit is set is not allowed."]
#[inline(always)]
pub fn sadd(&mut self) -> _SADDW {
_SADDW { w: self }
}
}