#[doc = "Register `MCUCR` reader"]
pub struct R(crate::R<MCUCR_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<MCUCR_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl core::convert::From<crate::R<MCUCR_SPEC>> for R {
fn from(reader: crate::R<MCUCR_SPEC>) -> Self {
R(reader)
}
}
#[doc = "Register `MCUCR` writer"]
pub struct W(crate::W<MCUCR_SPEC>);
impl core::ops::Deref for W {
type Target = crate::W<MCUCR_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl core::ops::DerefMut for W {
#[inline(always)]
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
impl core::convert::From<crate::W<MCUCR_SPEC>> for W {
fn from(writer: crate::W<MCUCR_SPEC>) -> Self {
W(writer)
}
}
#[doc = "Field `IVCE` reader - Interrupt Vector Change Enable"]
pub struct IVCE_R(crate::FieldReader<bool, bool>);
impl IVCE_R {
pub(crate) fn new(bits: bool) -> Self {
IVCE_R(crate::FieldReader::new(bits))
}
}
impl core::ops::Deref for IVCE_R {
type Target = crate::FieldReader<bool, bool>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
#[doc = "Field `IVCE` writer - Interrupt Vector Change Enable"]
pub struct IVCE_W<'a> {
w: &'a mut W,
}
impl<'a> IVCE_W<'a> {
#[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 = (self.w.bits & !0x01) | ((value as u8) & 0x01);
self.w
}
}
#[doc = "Field `IVSEL` reader - Interrupt Vector Select"]
pub struct IVSEL_R(crate::FieldReader<bool, bool>);
impl IVSEL_R {
pub(crate) fn new(bits: bool) -> Self {
IVSEL_R(crate::FieldReader::new(bits))
}
}
impl core::ops::Deref for IVSEL_R {
type Target = crate::FieldReader<bool, bool>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
#[doc = "Field `IVSEL` writer - Interrupt Vector Select"]
pub struct IVSEL_W<'a> {
w: &'a mut W,
}
impl<'a> IVSEL_W<'a> {
#[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 = (self.w.bits & !(0x01 << 1)) | (((value as u8) & 0x01) << 1);
self.w
}
}
#[doc = "Sleep Mode Select\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum SM2_A {
#[doc = "0: Idle"]
IDLE = 0,
#[doc = "2: ADC Noise Reduction (If Available)"]
ADC = 2,
#[doc = "4: Power Down"]
PDOWN = 4,
#[doc = "5: Standby"]
STDBY = 5,
#[doc = "6: Power Save"]
PSAVE = 6,
#[doc = "7: Extended Standby"]
ESTDBY = 7,
}
impl From<SM2_A> for bool {
#[inline(always)]
fn from(variant: SM2_A) -> Self {
variant as u8 != 0
}
}
#[doc = "Field `SM2` reader - Sleep Mode Select"]
pub struct SM2_R(crate::FieldReader<bool, SM2_A>);
impl SM2_R {
pub(crate) fn new(bits: bool) -> Self {
SM2_R(crate::FieldReader::new(bits))
}
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> crate::Variant<bool, SM2_A> {
use crate::Variant::*;
match self.bits {
false => Val(SM2_A::IDLE),
true => Val(SM2_A::ADC),
true => Val(SM2_A::PDOWN),
true => Val(SM2_A::STDBY),
true => Val(SM2_A::PSAVE),
true => Val(SM2_A::ESTDBY),
i => Res(i),
}
}
#[doc = "Checks if the value of the field is `IDLE`"]
#[inline(always)]
pub fn is_idle(&self) -> bool {
**self == SM2_A::IDLE
}
#[doc = "Checks if the value of the field is `ADC`"]
#[inline(always)]
pub fn is_adc(&self) -> bool {
**self == SM2_A::ADC
}
#[doc = "Checks if the value of the field is `PDOWN`"]
#[inline(always)]
pub fn is_pdown(&self) -> bool {
**self == SM2_A::PDOWN
}
#[doc = "Checks if the value of the field is `STDBY`"]
#[inline(always)]
pub fn is_stdby(&self) -> bool {
**self == SM2_A::STDBY
}
#[doc = "Checks if the value of the field is `PSAVE`"]
#[inline(always)]
pub fn is_psave(&self) -> bool {
**self == SM2_A::PSAVE
}
#[doc = "Checks if the value of the field is `ESTDBY`"]
#[inline(always)]
pub fn is_estdby(&self) -> bool {
**self == SM2_A::ESTDBY
}
}
impl core::ops::Deref for SM2_R {
type Target = crate::FieldReader<bool, SM2_A>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
#[doc = "Field `SM2` writer - Sleep Mode Select"]
pub struct SM2_W<'a> {
w: &'a mut W,
}
impl<'a> SM2_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: SM2_A) -> &'a mut W {
unsafe { self.bit(variant.into()) }
}
#[doc = "Idle"]
#[inline(always)]
pub fn idle(self) -> &'a mut W {
self.variant(SM2_A::IDLE)
}
#[doc = "ADC Noise Reduction (If Available)"]
#[inline(always)]
pub fn adc(self) -> &'a mut W {
self.variant(SM2_A::ADC)
}
#[doc = "Power Down"]
#[inline(always)]
pub fn pdown(self) -> &'a mut W {
self.variant(SM2_A::PDOWN)
}
#[doc = "Standby"]
#[inline(always)]
pub fn stdby(self) -> &'a mut W {
self.variant(SM2_A::STDBY)
}
#[doc = "Power Save"]
#[inline(always)]
pub fn psave(self) -> &'a mut W {
self.variant(SM2_A::PSAVE)
}
#[doc = "Extended Standby"]
#[inline(always)]
pub fn estdby(self) -> &'a mut W {
self.variant(SM2_A::ESTDBY)
}
#[doc = r"Sets the field bit"]
#[inline(always)]
pub unsafe fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub unsafe fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub unsafe fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 2)) | (((value as u8) & 0x01) << 2);
self.w
}
}
#[doc = "Field `SM` reader - Sleep Mode Select"]
pub struct SM_R(crate::FieldReader<u8, u8>);
impl SM_R {
pub(crate) fn new(bits: u8) -> Self {
SM_R(crate::FieldReader::new(bits))
}
}
impl core::ops::Deref for SM_R {
type Target = crate::FieldReader<u8, u8>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
#[doc = "Field `SM` writer - Sleep Mode Select"]
pub struct SM_W<'a> {
w: &'a mut W,
}
impl<'a> SM_W<'a> {
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bits(self, value: u8) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x03 << 3)) | (((value as u8) & 0x03) << 3);
self.w
}
}
#[doc = "Field `SE` reader - Sleep Enable"]
pub struct SE_R(crate::FieldReader<bool, bool>);
impl SE_R {
pub(crate) fn new(bits: bool) -> Self {
SE_R(crate::FieldReader::new(bits))
}
}
impl core::ops::Deref for SE_R {
type Target = crate::FieldReader<bool, bool>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
#[doc = "Field `SE` writer - Sleep Enable"]
pub struct SE_W<'a> {
w: &'a mut W,
}
impl<'a> SE_W<'a> {
#[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 = (self.w.bits & !(0x01 << 5)) | (((value as u8) & 0x01) << 5);
self.w
}
}
#[doc = "Field `SRW10` reader - External SRAM Wait State Select"]
pub struct SRW10_R(crate::FieldReader<bool, bool>);
impl SRW10_R {
pub(crate) fn new(bits: bool) -> Self {
SRW10_R(crate::FieldReader::new(bits))
}
}
impl core::ops::Deref for SRW10_R {
type Target = crate::FieldReader<bool, bool>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
#[doc = "Field `SRW10` writer - External SRAM Wait State Select"]
pub struct SRW10_W<'a> {
w: &'a mut W,
}
impl<'a> SRW10_W<'a> {
#[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 = (self.w.bits & !(0x01 << 6)) | (((value as u8) & 0x01) << 6);
self.w
}
}
#[doc = "Field `SRE` reader - External SRAM Enable"]
pub struct SRE_R(crate::FieldReader<bool, bool>);
impl SRE_R {
pub(crate) fn new(bits: bool) -> Self {
SRE_R(crate::FieldReader::new(bits))
}
}
impl core::ops::Deref for SRE_R {
type Target = crate::FieldReader<bool, bool>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
#[doc = "Field `SRE` writer - External SRAM Enable"]
pub struct SRE_W<'a> {
w: &'a mut W,
}
impl<'a> SRE_W<'a> {
#[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 = (self.w.bits & !(0x01 << 7)) | (((value as u8) & 0x01) << 7);
self.w
}
}
impl R {
#[doc = "Bit 0 - Interrupt Vector Change Enable"]
#[inline(always)]
pub fn ivce(&self) -> IVCE_R {
IVCE_R::new((self.bits & 0x01) != 0)
}
#[doc = "Bit 1 - Interrupt Vector Select"]
#[inline(always)]
pub fn ivsel(&self) -> IVSEL_R {
IVSEL_R::new(((self.bits >> 1) & 0x01) != 0)
}
#[doc = "Bit 2 - Sleep Mode Select"]
#[inline(always)]
pub fn sm2(&self) -> SM2_R {
SM2_R::new(((self.bits >> 2) & 0x01) != 0)
}
#[doc = "Bits 3:4 - Sleep Mode Select"]
#[inline(always)]
pub fn sm(&self) -> SM_R {
SM_R::new(((self.bits >> 3) & 0x03) as u8)
}
#[doc = "Bit 5 - Sleep Enable"]
#[inline(always)]
pub fn se(&self) -> SE_R {
SE_R::new(((self.bits >> 5) & 0x01) != 0)
}
#[doc = "Bit 6 - External SRAM Wait State Select"]
#[inline(always)]
pub fn srw10(&self) -> SRW10_R {
SRW10_R::new(((self.bits >> 6) & 0x01) != 0)
}
#[doc = "Bit 7 - External SRAM Enable"]
#[inline(always)]
pub fn sre(&self) -> SRE_R {
SRE_R::new(((self.bits >> 7) & 0x01) != 0)
}
}
impl W {
#[doc = "Bit 0 - Interrupt Vector Change Enable"]
#[inline(always)]
pub fn ivce(&mut self) -> IVCE_W {
IVCE_W { w: self }
}
#[doc = "Bit 1 - Interrupt Vector Select"]
#[inline(always)]
pub fn ivsel(&mut self) -> IVSEL_W {
IVSEL_W { w: self }
}
#[doc = "Bit 2 - Sleep Mode Select"]
#[inline(always)]
pub fn sm2(&mut self) -> SM2_W {
SM2_W { w: self }
}
#[doc = "Bits 3:4 - Sleep Mode Select"]
#[inline(always)]
pub fn sm(&mut self) -> SM_W {
SM_W { w: self }
}
#[doc = "Bit 5 - Sleep Enable"]
#[inline(always)]
pub fn se(&mut self) -> SE_W {
SE_W { w: self }
}
#[doc = "Bit 6 - External SRAM Wait State Select"]
#[inline(always)]
pub fn srw10(&mut self) -> SRW10_W {
SRW10_W { w: self }
}
#[doc = "Bit 7 - External SRAM Enable"]
#[inline(always)]
pub fn sre(&mut self) -> SRE_W {
SRE_W { w: self }
}
#[doc = "Writes raw bits to the register."]
pub unsafe fn bits(&mut self, bits: u8) -> &mut Self {
self.0.bits(bits);
self
}
}
#[doc = "MCU Control Register\n\nThis register you can [`read`](crate::generic::Reg::read), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [mcucr](index.html) module"]
pub struct MCUCR_SPEC;
impl crate::RegisterSpec for MCUCR_SPEC {
type Ux = u8;
}
#[doc = "`read()` method returns [mcucr::R](R) reader structure"]
impl crate::Readable for MCUCR_SPEC {
type Reader = R;
}
#[doc = "`write(|w| ..)` method takes [mcucr::W](W) writer structure"]
impl crate::Writable for MCUCR_SPEC {
type Writer = W;
}
#[doc = "`reset()` method sets MCUCR to value 0"]
impl crate::Resettable for MCUCR_SPEC {
#[inline(always)]
fn reset_value() -> Self::Ux {
0
}
}