pub type R = crate::R<CFG2rs>;
pub type W = crate::W<CFG2rs>;
pub type MSSI_R = crate::FieldReader;
pub type MSSI_W<'a, REG> = crate::FieldWriter<'a, REG, 4, u8, crate::Safe>;
pub type MIDI_R = crate::FieldReader;
pub type MIDI_W<'a, REG> = crate::FieldWriter<'a, REG, 4, u8, crate::Safe>;
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum IOSWP {
Disabled = 0,
Enabled = 1,
}
impl From<IOSWP> for bool {
#[inline(always)]
fn from(variant: IOSWP) -> Self {
variant as u8 != 0
}
}
pub type IOSWP_R = crate::BitReader<IOSWP>;
impl IOSWP_R {
#[inline(always)]
pub const fn variant(&self) -> IOSWP {
match self.bits {
false => IOSWP::Disabled,
true => IOSWP::Enabled,
}
}
#[inline(always)]
pub fn is_disabled(&self) -> bool {
*self == IOSWP::Disabled
}
#[inline(always)]
pub fn is_enabled(&self) -> bool {
*self == IOSWP::Enabled
}
}
pub type IOSWP_W<'a, REG> = crate::BitWriter<'a, REG, IOSWP>;
impl<'a, REG> IOSWP_W<'a, REG>
where
REG: crate::Writable + crate::RegisterSpec,
{
#[inline(always)]
pub fn disabled(self) -> &'a mut crate::W<REG> {
self.variant(IOSWP::Disabled)
}
#[inline(always)]
pub fn enabled(self) -> &'a mut crate::W<REG> {
self.variant(IOSWP::Enabled)
}
}
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum COMM {
FullDuplex = 0,
Transmitter = 1,
Receiver = 2,
HalfDuplex = 3,
}
impl From<COMM> for u8 {
#[inline(always)]
fn from(variant: COMM) -> Self {
variant as _
}
}
impl crate::FieldSpec for COMM {
type Ux = u8;
}
impl crate::IsEnum for COMM {}
pub type COMM_R = crate::FieldReader<COMM>;
impl COMM_R {
#[inline(always)]
pub const fn variant(&self) -> COMM {
match self.bits {
0 => COMM::FullDuplex,
1 => COMM::Transmitter,
2 => COMM::Receiver,
3 => COMM::HalfDuplex,
_ => unreachable!(),
}
}
#[inline(always)]
pub fn is_full_duplex(&self) -> bool {
*self == COMM::FullDuplex
}
#[inline(always)]
pub fn is_transmitter(&self) -> bool {
*self == COMM::Transmitter
}
#[inline(always)]
pub fn is_receiver(&self) -> bool {
*self == COMM::Receiver
}
#[inline(always)]
pub fn is_half_duplex(&self) -> bool {
*self == COMM::HalfDuplex
}
}
pub type COMM_W<'a, REG> = crate::FieldWriter<'a, REG, 2, COMM, crate::Safe>;
impl<'a, REG> COMM_W<'a, REG>
where
REG: crate::Writable + crate::RegisterSpec,
REG::Ux: From<u8>,
{
#[inline(always)]
pub fn full_duplex(self) -> &'a mut crate::W<REG> {
self.variant(COMM::FullDuplex)
}
#[inline(always)]
pub fn transmitter(self) -> &'a mut crate::W<REG> {
self.variant(COMM::Transmitter)
}
#[inline(always)]
pub fn receiver(self) -> &'a mut crate::W<REG> {
self.variant(COMM::Receiver)
}
#[inline(always)]
pub fn half_duplex(self) -> &'a mut crate::W<REG> {
self.variant(COMM::HalfDuplex)
}
}
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum SP {
Motorola = 0,
Ti = 1,
}
impl From<SP> for u8 {
#[inline(always)]
fn from(variant: SP) -> Self {
variant as _
}
}
impl crate::FieldSpec for SP {
type Ux = u8;
}
impl crate::IsEnum for SP {}
pub type SP_R = crate::FieldReader<SP>;
impl SP_R {
#[inline(always)]
pub const fn variant(&self) -> Option<SP> {
match self.bits {
0 => Some(SP::Motorola),
1 => Some(SP::Ti),
_ => None,
}
}
#[inline(always)]
pub fn is_motorola(&self) -> bool {
*self == SP::Motorola
}
#[inline(always)]
pub fn is_ti(&self) -> bool {
*self == SP::Ti
}
}
pub type SP_W<'a, REG> = crate::FieldWriter<'a, REG, 3, SP>;
impl<'a, REG> SP_W<'a, REG>
where
REG: crate::Writable + crate::RegisterSpec,
REG::Ux: From<u8>,
{
#[inline(always)]
pub fn motorola(self) -> &'a mut crate::W<REG> {
self.variant(SP::Motorola)
}
#[inline(always)]
pub fn ti(self) -> &'a mut crate::W<REG> {
self.variant(SP::Ti)
}
}
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum MASTER {
Slave = 0,
Master = 1,
}
impl From<MASTER> for bool {
#[inline(always)]
fn from(variant: MASTER) -> Self {
variant as u8 != 0
}
}
pub type MASTER_R = crate::BitReader<MASTER>;
impl MASTER_R {
#[inline(always)]
pub const fn variant(&self) -> MASTER {
match self.bits {
false => MASTER::Slave,
true => MASTER::Master,
}
}
#[inline(always)]
pub fn is_slave(&self) -> bool {
*self == MASTER::Slave
}
#[inline(always)]
pub fn is_master(&self) -> bool {
*self == MASTER::Master
}
}
pub type MASTER_W<'a, REG> = crate::BitWriter<'a, REG, MASTER>;
impl<'a, REG> MASTER_W<'a, REG>
where
REG: crate::Writable + crate::RegisterSpec,
{
#[inline(always)]
pub fn slave(self) -> &'a mut crate::W<REG> {
self.variant(MASTER::Slave)
}
#[inline(always)]
pub fn master(self) -> &'a mut crate::W<REG> {
self.variant(MASTER::Master)
}
}
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum LSBFRST {
Msbfirst = 0,
Lsbfirst = 1,
}
impl From<LSBFRST> for bool {
#[inline(always)]
fn from(variant: LSBFRST) -> Self {
variant as u8 != 0
}
}
pub type LSBFRST_R = crate::BitReader<LSBFRST>;
impl LSBFRST_R {
#[inline(always)]
pub const fn variant(&self) -> LSBFRST {
match self.bits {
false => LSBFRST::Msbfirst,
true => LSBFRST::Lsbfirst,
}
}
#[inline(always)]
pub fn is_msbfirst(&self) -> bool {
*self == LSBFRST::Msbfirst
}
#[inline(always)]
pub fn is_lsbfirst(&self) -> bool {
*self == LSBFRST::Lsbfirst
}
}
pub type LSBFRST_W<'a, REG> = crate::BitWriter<'a, REG, LSBFRST>;
impl<'a, REG> LSBFRST_W<'a, REG>
where
REG: crate::Writable + crate::RegisterSpec,
{
#[inline(always)]
pub fn msbfirst(self) -> &'a mut crate::W<REG> {
self.variant(LSBFRST::Msbfirst)
}
#[inline(always)]
pub fn lsbfirst(self) -> &'a mut crate::W<REG> {
self.variant(LSBFRST::Lsbfirst)
}
}
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum CPHA {
FirstEdge = 0,
SecondEdge = 1,
}
impl From<CPHA> for bool {
#[inline(always)]
fn from(variant: CPHA) -> Self {
variant as u8 != 0
}
}
pub type CPHA_R = crate::BitReader<CPHA>;
impl CPHA_R {
#[inline(always)]
pub const fn variant(&self) -> CPHA {
match self.bits {
false => CPHA::FirstEdge,
true => CPHA::SecondEdge,
}
}
#[inline(always)]
pub fn is_first_edge(&self) -> bool {
*self == CPHA::FirstEdge
}
#[inline(always)]
pub fn is_second_edge(&self) -> bool {
*self == CPHA::SecondEdge
}
}
pub type CPHA_W<'a, REG> = crate::BitWriter<'a, REG, CPHA>;
impl<'a, REG> CPHA_W<'a, REG>
where
REG: crate::Writable + crate::RegisterSpec,
{
#[inline(always)]
pub fn first_edge(self) -> &'a mut crate::W<REG> {
self.variant(CPHA::FirstEdge)
}
#[inline(always)]
pub fn second_edge(self) -> &'a mut crate::W<REG> {
self.variant(CPHA::SecondEdge)
}
}
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum CPOL {
IdleLow = 0,
IdleHigh = 1,
}
impl From<CPOL> for bool {
#[inline(always)]
fn from(variant: CPOL) -> Self {
variant as u8 != 0
}
}
pub type CPOL_R = crate::BitReader<CPOL>;
impl CPOL_R {
#[inline(always)]
pub const fn variant(&self) -> CPOL {
match self.bits {
false => CPOL::IdleLow,
true => CPOL::IdleHigh,
}
}
#[inline(always)]
pub fn is_idle_low(&self) -> bool {
*self == CPOL::IdleLow
}
#[inline(always)]
pub fn is_idle_high(&self) -> bool {
*self == CPOL::IdleHigh
}
}
pub type CPOL_W<'a, REG> = crate::BitWriter<'a, REG, CPOL>;
impl<'a, REG> CPOL_W<'a, REG>
where
REG: crate::Writable + crate::RegisterSpec,
{
#[inline(always)]
pub fn idle_low(self) -> &'a mut crate::W<REG> {
self.variant(CPOL::IdleLow)
}
#[inline(always)]
pub fn idle_high(self) -> &'a mut crate::W<REG> {
self.variant(CPOL::IdleHigh)
}
}
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SSM {
Disabled = 0,
Enabled = 1,
}
impl From<SSM> for bool {
#[inline(always)]
fn from(variant: SSM) -> Self {
variant as u8 != 0
}
}
pub type SSM_R = crate::BitReader<SSM>;
impl SSM_R {
#[inline(always)]
pub const fn variant(&self) -> SSM {
match self.bits {
false => SSM::Disabled,
true => SSM::Enabled,
}
}
#[inline(always)]
pub fn is_disabled(&self) -> bool {
*self == SSM::Disabled
}
#[inline(always)]
pub fn is_enabled(&self) -> bool {
*self == SSM::Enabled
}
}
pub type SSM_W<'a, REG> = crate::BitWriter<'a, REG, SSM>;
impl<'a, REG> SSM_W<'a, REG>
where
REG: crate::Writable + crate::RegisterSpec,
{
#[inline(always)]
pub fn disabled(self) -> &'a mut crate::W<REG> {
self.variant(SSM::Disabled)
}
#[inline(always)]
pub fn enabled(self) -> &'a mut crate::W<REG> {
self.variant(SSM::Enabled)
}
}
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SSIOP {
ActiveLow = 0,
ActiveHigh = 1,
}
impl From<SSIOP> for bool {
#[inline(always)]
fn from(variant: SSIOP) -> Self {
variant as u8 != 0
}
}
pub type SSIOP_R = crate::BitReader<SSIOP>;
impl SSIOP_R {
#[inline(always)]
pub const fn variant(&self) -> SSIOP {
match self.bits {
false => SSIOP::ActiveLow,
true => SSIOP::ActiveHigh,
}
}
#[inline(always)]
pub fn is_active_low(&self) -> bool {
*self == SSIOP::ActiveLow
}
#[inline(always)]
pub fn is_active_high(&self) -> bool {
*self == SSIOP::ActiveHigh
}
}
pub type SSIOP_W<'a, REG> = crate::BitWriter<'a, REG, SSIOP>;
impl<'a, REG> SSIOP_W<'a, REG>
where
REG: crate::Writable + crate::RegisterSpec,
{
#[inline(always)]
pub fn active_low(self) -> &'a mut crate::W<REG> {
self.variant(SSIOP::ActiveLow)
}
#[inline(always)]
pub fn active_high(self) -> &'a mut crate::W<REG> {
self.variant(SSIOP::ActiveHigh)
}
}
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SSOE {
Disabled = 0,
Enabled = 1,
}
impl From<SSOE> for bool {
#[inline(always)]
fn from(variant: SSOE) -> Self {
variant as u8 != 0
}
}
pub type SSOE_R = crate::BitReader<SSOE>;
impl SSOE_R {
#[inline(always)]
pub const fn variant(&self) -> SSOE {
match self.bits {
false => SSOE::Disabled,
true => SSOE::Enabled,
}
}
#[inline(always)]
pub fn is_disabled(&self) -> bool {
*self == SSOE::Disabled
}
#[inline(always)]
pub fn is_enabled(&self) -> bool {
*self == SSOE::Enabled
}
}
pub type SSOE_W<'a, REG> = crate::BitWriter<'a, REG, SSOE>;
impl<'a, REG> SSOE_W<'a, REG>
where
REG: crate::Writable + crate::RegisterSpec,
{
#[inline(always)]
pub fn disabled(self) -> &'a mut crate::W<REG> {
self.variant(SSOE::Disabled)
}
#[inline(always)]
pub fn enabled(self) -> &'a mut crate::W<REG> {
self.variant(SSOE::Enabled)
}
}
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SSOM {
Asserted = 0,
NotAsserted = 1,
}
impl From<SSOM> for bool {
#[inline(always)]
fn from(variant: SSOM) -> Self {
variant as u8 != 0
}
}
pub type SSOM_R = crate::BitReader<SSOM>;
impl SSOM_R {
#[inline(always)]
pub const fn variant(&self) -> SSOM {
match self.bits {
false => SSOM::Asserted,
true => SSOM::NotAsserted,
}
}
#[inline(always)]
pub fn is_asserted(&self) -> bool {
*self == SSOM::Asserted
}
#[inline(always)]
pub fn is_not_asserted(&self) -> bool {
*self == SSOM::NotAsserted
}
}
pub type SSOM_W<'a, REG> = crate::BitWriter<'a, REG, SSOM>;
impl<'a, REG> SSOM_W<'a, REG>
where
REG: crate::Writable + crate::RegisterSpec,
{
#[inline(always)]
pub fn asserted(self) -> &'a mut crate::W<REG> {
self.variant(SSOM::Asserted)
}
#[inline(always)]
pub fn not_asserted(self) -> &'a mut crate::W<REG> {
self.variant(SSOM::NotAsserted)
}
}
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum AFCNTR {
NotControlled = 0,
Controlled = 1,
}
impl From<AFCNTR> for bool {
#[inline(always)]
fn from(variant: AFCNTR) -> Self {
variant as u8 != 0
}
}
pub type AFCNTR_R = crate::BitReader<AFCNTR>;
impl AFCNTR_R {
#[inline(always)]
pub const fn variant(&self) -> AFCNTR {
match self.bits {
false => AFCNTR::NotControlled,
true => AFCNTR::Controlled,
}
}
#[inline(always)]
pub fn is_not_controlled(&self) -> bool {
*self == AFCNTR::NotControlled
}
#[inline(always)]
pub fn is_controlled(&self) -> bool {
*self == AFCNTR::Controlled
}
}
pub type AFCNTR_W<'a, REG> = crate::BitWriter<'a, REG, AFCNTR>;
impl<'a, REG> AFCNTR_W<'a, REG>
where
REG: crate::Writable + crate::RegisterSpec,
{
#[inline(always)]
pub fn not_controlled(self) -> &'a mut crate::W<REG> {
self.variant(AFCNTR::NotControlled)
}
#[inline(always)]
pub fn controlled(self) -> &'a mut crate::W<REG> {
self.variant(AFCNTR::Controlled)
}
}
impl R {
#[inline(always)]
pub fn mssi(&self) -> MSSI_R {
MSSI_R::new((self.bits & 0x0f) as u8)
}
#[inline(always)]
pub fn midi(&self) -> MIDI_R {
MIDI_R::new(((self.bits >> 4) & 0x0f) as u8)
}
#[inline(always)]
pub fn ioswp(&self) -> IOSWP_R {
IOSWP_R::new(((self.bits >> 15) & 1) != 0)
}
#[inline(always)]
pub fn comm(&self) -> COMM_R {
COMM_R::new(((self.bits >> 17) & 3) as u8)
}
#[inline(always)]
pub fn sp(&self) -> SP_R {
SP_R::new(((self.bits >> 19) & 7) as u8)
}
#[inline(always)]
pub fn master(&self) -> MASTER_R {
MASTER_R::new(((self.bits >> 22) & 1) != 0)
}
#[inline(always)]
pub fn lsbfrst(&self) -> LSBFRST_R {
LSBFRST_R::new(((self.bits >> 23) & 1) != 0)
}
#[inline(always)]
pub fn cpha(&self) -> CPHA_R {
CPHA_R::new(((self.bits >> 24) & 1) != 0)
}
#[inline(always)]
pub fn cpol(&self) -> CPOL_R {
CPOL_R::new(((self.bits >> 25) & 1) != 0)
}
#[inline(always)]
pub fn ssm(&self) -> SSM_R {
SSM_R::new(((self.bits >> 26) & 1) != 0)
}
#[inline(always)]
pub fn ssiop(&self) -> SSIOP_R {
SSIOP_R::new(((self.bits >> 28) & 1) != 0)
}
#[inline(always)]
pub fn ssoe(&self) -> SSOE_R {
SSOE_R::new(((self.bits >> 29) & 1) != 0)
}
#[inline(always)]
pub fn ssom(&self) -> SSOM_R {
SSOM_R::new(((self.bits >> 30) & 1) != 0)
}
#[inline(always)]
pub fn afcntr(&self) -> AFCNTR_R {
AFCNTR_R::new(((self.bits >> 31) & 1) != 0)
}
}
impl core::fmt::Debug for R {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("CFG2")
.field("afcntr", &self.afcntr())
.field("ssom", &self.ssom())
.field("ssoe", &self.ssoe())
.field("ssiop", &self.ssiop())
.field("ssm", &self.ssm())
.field("cpol", &self.cpol())
.field("cpha", &self.cpha())
.field("lsbfrst", &self.lsbfrst())
.field("master", &self.master())
.field("sp", &self.sp())
.field("comm", &self.comm())
.field("ioswp", &self.ioswp())
.field("midi", &self.midi())
.field("mssi", &self.mssi())
.finish()
}
}
impl W {
#[inline(always)]
pub fn mssi(&mut self) -> MSSI_W<CFG2rs> {
MSSI_W::new(self, 0)
}
#[inline(always)]
pub fn midi(&mut self) -> MIDI_W<CFG2rs> {
MIDI_W::new(self, 4)
}
#[inline(always)]
pub fn ioswp(&mut self) -> IOSWP_W<CFG2rs> {
IOSWP_W::new(self, 15)
}
#[inline(always)]
pub fn comm(&mut self) -> COMM_W<CFG2rs> {
COMM_W::new(self, 17)
}
#[inline(always)]
pub fn sp(&mut self) -> SP_W<CFG2rs> {
SP_W::new(self, 19)
}
#[inline(always)]
pub fn master(&mut self) -> MASTER_W<CFG2rs> {
MASTER_W::new(self, 22)
}
#[inline(always)]
pub fn lsbfrst(&mut self) -> LSBFRST_W<CFG2rs> {
LSBFRST_W::new(self, 23)
}
#[inline(always)]
pub fn cpha(&mut self) -> CPHA_W<CFG2rs> {
CPHA_W::new(self, 24)
}
#[inline(always)]
pub fn cpol(&mut self) -> CPOL_W<CFG2rs> {
CPOL_W::new(self, 25)
}
#[inline(always)]
pub fn ssm(&mut self) -> SSM_W<CFG2rs> {
SSM_W::new(self, 26)
}
#[inline(always)]
pub fn ssiop(&mut self) -> SSIOP_W<CFG2rs> {
SSIOP_W::new(self, 28)
}
#[inline(always)]
pub fn ssoe(&mut self) -> SSOE_W<CFG2rs> {
SSOE_W::new(self, 29)
}
#[inline(always)]
pub fn ssom(&mut self) -> SSOM_W<CFG2rs> {
SSOM_W::new(self, 30)
}
#[inline(always)]
pub fn afcntr(&mut self) -> AFCNTR_W<CFG2rs> {
AFCNTR_W::new(self, 31)
}
}
pub struct CFG2rs;
impl crate::RegisterSpec for CFG2rs {
type Ux = u32;
}
impl crate::Readable for CFG2rs {}
impl crate::Writable for CFG2rs {
type Safety = crate::Unsafe;
}
impl crate::Resettable for CFG2rs {}