#[doc = "Register `BDCR` reader"]
pub struct R(crate::R<BDCR_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<BDCR_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl From<crate::R<BDCR_SPEC>> for R {
#[inline(always)]
fn from(reader: crate::R<BDCR_SPEC>) -> Self {
R(reader)
}
}
#[doc = "Register `BDCR` writer"]
pub struct W(crate::W<BDCR_SPEC>);
impl core::ops::Deref for W {
type Target = crate::W<BDCR_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 From<crate::W<BDCR_SPEC>> for W {
#[inline(always)]
fn from(writer: crate::W<BDCR_SPEC>) -> Self {
W(writer)
}
}
#[doc = "Backup domain software reset\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum BDRST_A {
#[doc = "0: Reset not activated"]
DISABLED = 0,
#[doc = "1: Reset the entire RTC domain"]
ENABLED = 1,
}
impl From<BDRST_A> for bool {
#[inline(always)]
fn from(variant: BDRST_A) -> Self {
variant as u8 != 0
}
}
#[doc = "Field `BDRST` reader - Backup domain software reset"]
pub struct BDRST_R(crate::FieldReader<bool, BDRST_A>);
impl BDRST_R {
pub(crate) fn new(bits: bool) -> Self {
BDRST_R(crate::FieldReader::new(bits))
}
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> BDRST_A {
match self.bits {
false => BDRST_A::DISABLED,
true => BDRST_A::ENABLED,
}
}
#[doc = "Checks if the value of the field is `DISABLED`"]
#[inline(always)]
pub fn is_disabled(&self) -> bool {
**self == BDRST_A::DISABLED
}
#[doc = "Checks if the value of the field is `ENABLED`"]
#[inline(always)]
pub fn is_enabled(&self) -> bool {
**self == BDRST_A::ENABLED
}
}
impl core::ops::Deref for BDRST_R {
type Target = crate::FieldReader<bool, BDRST_A>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
#[doc = "Field `BDRST` writer - Backup domain software reset"]
pub struct BDRST_W<'a> {
w: &'a mut W,
}
impl<'a> BDRST_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: BDRST_A) -> &'a mut W {
self.bit(variant.into())
}
#[doc = "Reset not activated"]
#[inline(always)]
pub fn disabled(self) -> &'a mut W {
self.variant(BDRST_A::DISABLED)
}
#[doc = "Reset the entire RTC domain"]
#[inline(always)]
pub fn enabled(self) -> &'a mut W {
self.variant(BDRST_A::ENABLED)
}
#[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 << 16)) | ((value as u32 & 0x01) << 16);
self.w
}
}
#[doc = "RTC clock enable\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum RTCEN_A {
#[doc = "0: RTC clock disabled"]
DISABLED = 0,
#[doc = "1: RTC clock enabled"]
ENABLED = 1,
}
impl From<RTCEN_A> for bool {
#[inline(always)]
fn from(variant: RTCEN_A) -> Self {
variant as u8 != 0
}
}
#[doc = "Field `RTCEN` reader - RTC clock enable"]
pub struct RTCEN_R(crate::FieldReader<bool, RTCEN_A>);
impl RTCEN_R {
pub(crate) fn new(bits: bool) -> Self {
RTCEN_R(crate::FieldReader::new(bits))
}
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> RTCEN_A {
match self.bits {
false => RTCEN_A::DISABLED,
true => RTCEN_A::ENABLED,
}
}
#[doc = "Checks if the value of the field is `DISABLED`"]
#[inline(always)]
pub fn is_disabled(&self) -> bool {
**self == RTCEN_A::DISABLED
}
#[doc = "Checks if the value of the field is `ENABLED`"]
#[inline(always)]
pub fn is_enabled(&self) -> bool {
**self == RTCEN_A::ENABLED
}
}
impl core::ops::Deref for RTCEN_R {
type Target = crate::FieldReader<bool, RTCEN_A>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
#[doc = "Field `RTCEN` writer - RTC clock enable"]
pub struct RTCEN_W<'a> {
w: &'a mut W,
}
impl<'a> RTCEN_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: RTCEN_A) -> &'a mut W {
self.bit(variant.into())
}
#[doc = "RTC clock disabled"]
#[inline(always)]
pub fn disabled(self) -> &'a mut W {
self.variant(RTCEN_A::DISABLED)
}
#[doc = "RTC clock enabled"]
#[inline(always)]
pub fn enabled(self) -> &'a mut W {
self.variant(RTCEN_A::ENABLED)
}
#[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 << 15)) | ((value as u32 & 0x01) << 15);
self.w
}
}
#[doc = "External low-speed oscillator bypass\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum LSEBYP_A {
#[doc = "0: LSE crystal oscillator not bypassed"]
NOTBYPASSED = 0,
#[doc = "1: LSE crystal oscillator bypassed with external clock"]
BYPASSED = 1,
}
impl From<LSEBYP_A> for bool {
#[inline(always)]
fn from(variant: LSEBYP_A) -> Self {
variant as u8 != 0
}
}
#[doc = "Field `LSEBYP` reader - External low-speed oscillator bypass"]
pub struct LSEBYP_R(crate::FieldReader<bool, LSEBYP_A>);
impl LSEBYP_R {
pub(crate) fn new(bits: bool) -> Self {
LSEBYP_R(crate::FieldReader::new(bits))
}
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> LSEBYP_A {
match self.bits {
false => LSEBYP_A::NOTBYPASSED,
true => LSEBYP_A::BYPASSED,
}
}
#[doc = "Checks if the value of the field is `NOTBYPASSED`"]
#[inline(always)]
pub fn is_not_bypassed(&self) -> bool {
**self == LSEBYP_A::NOTBYPASSED
}
#[doc = "Checks if the value of the field is `BYPASSED`"]
#[inline(always)]
pub fn is_bypassed(&self) -> bool {
**self == LSEBYP_A::BYPASSED
}
}
impl core::ops::Deref for LSEBYP_R {
type Target = crate::FieldReader<bool, LSEBYP_A>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
#[doc = "Field `LSEBYP` writer - External low-speed oscillator bypass"]
pub struct LSEBYP_W<'a> {
w: &'a mut W,
}
impl<'a> LSEBYP_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: LSEBYP_A) -> &'a mut W {
self.bit(variant.into())
}
#[doc = "LSE crystal oscillator not bypassed"]
#[inline(always)]
pub fn not_bypassed(self) -> &'a mut W {
self.variant(LSEBYP_A::NOTBYPASSED)
}
#[doc = "LSE crystal oscillator bypassed with external clock"]
#[inline(always)]
pub fn bypassed(self) -> &'a mut W {
self.variant(LSEBYP_A::BYPASSED)
}
#[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 << 2)) | ((value as u32 & 0x01) << 2);
self.w
}
}
#[doc = "External low-speed oscillator ready\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum LSERDY_A {
#[doc = "0: LSE oscillator not ready"]
NOTREADY = 0,
#[doc = "1: LSE oscillator ready"]
READY = 1,
}
impl From<LSERDY_A> for bool {
#[inline(always)]
fn from(variant: LSERDY_A) -> Self {
variant as u8 != 0
}
}
#[doc = "Field `LSERDY` reader - External low-speed oscillator ready"]
pub struct LSERDY_R(crate::FieldReader<bool, LSERDY_A>);
impl LSERDY_R {
pub(crate) fn new(bits: bool) -> Self {
LSERDY_R(crate::FieldReader::new(bits))
}
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> LSERDY_A {
match self.bits {
false => LSERDY_A::NOTREADY,
true => LSERDY_A::READY,
}
}
#[doc = "Checks if the value of the field is `NOTREADY`"]
#[inline(always)]
pub fn is_not_ready(&self) -> bool {
**self == LSERDY_A::NOTREADY
}
#[doc = "Checks if the value of the field is `READY`"]
#[inline(always)]
pub fn is_ready(&self) -> bool {
**self == LSERDY_A::READY
}
}
impl core::ops::Deref for LSERDY_R {
type Target = crate::FieldReader<bool, LSERDY_A>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
#[doc = "External low-speed oscillator enable\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum LSEON_A {
#[doc = "0: LSE oscillator Off"]
OFF = 0,
#[doc = "1: LSE oscillator On"]
ON = 1,
}
impl From<LSEON_A> for bool {
#[inline(always)]
fn from(variant: LSEON_A) -> Self {
variant as u8 != 0
}
}
#[doc = "Field `LSEON` reader - External low-speed oscillator enable"]
pub struct LSEON_R(crate::FieldReader<bool, LSEON_A>);
impl LSEON_R {
pub(crate) fn new(bits: bool) -> Self {
LSEON_R(crate::FieldReader::new(bits))
}
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> LSEON_A {
match self.bits {
false => LSEON_A::OFF,
true => LSEON_A::ON,
}
}
#[doc = "Checks if the value of the field is `OFF`"]
#[inline(always)]
pub fn is_off(&self) -> bool {
**self == LSEON_A::OFF
}
#[doc = "Checks if the value of the field is `ON`"]
#[inline(always)]
pub fn is_on(&self) -> bool {
**self == LSEON_A::ON
}
}
impl core::ops::Deref for LSEON_R {
type Target = crate::FieldReader<bool, LSEON_A>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
#[doc = "Field `LSEON` writer - External low-speed oscillator enable"]
pub struct LSEON_W<'a> {
w: &'a mut W,
}
impl<'a> LSEON_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: LSEON_A) -> &'a mut W {
self.bit(variant.into())
}
#[doc = "LSE oscillator Off"]
#[inline(always)]
pub fn off(self) -> &'a mut W {
self.variant(LSEON_A::OFF)
}
#[doc = "LSE oscillator On"]
#[inline(always)]
pub fn on(self) -> &'a mut W {
self.variant(LSEON_A::ON)
}
#[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 u32 & 0x01);
self.w
}
}
#[doc = "RTC clock source selection\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(u8)]
pub enum RTCSEL_A {
#[doc = "0: No clock"]
NOCLOCK = 0,
#[doc = "1: LSE oscillator clock used as RTC clock"]
LSE = 1,
#[doc = "2: LSI oscillator clock used as RTC clock"]
LSI = 2,
#[doc = "3: HSE oscillator clock divided by a prescaler used as RTC clock"]
HSE = 3,
}
impl From<RTCSEL_A> for u8 {
#[inline(always)]
fn from(variant: RTCSEL_A) -> Self {
variant as _
}
}
#[doc = "Field `RTCSEL` reader - RTC clock source selection"]
pub struct RTCSEL_R(crate::FieldReader<u8, RTCSEL_A>);
impl RTCSEL_R {
pub(crate) fn new(bits: u8) -> Self {
RTCSEL_R(crate::FieldReader::new(bits))
}
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> RTCSEL_A {
match self.bits {
0 => RTCSEL_A::NOCLOCK,
1 => RTCSEL_A::LSE,
2 => RTCSEL_A::LSI,
3 => RTCSEL_A::HSE,
_ => unreachable!(),
}
}
#[doc = "Checks if the value of the field is `NOCLOCK`"]
#[inline(always)]
pub fn is_no_clock(&self) -> bool {
**self == RTCSEL_A::NOCLOCK
}
#[doc = "Checks if the value of the field is `LSE`"]
#[inline(always)]
pub fn is_lse(&self) -> bool {
**self == RTCSEL_A::LSE
}
#[doc = "Checks if the value of the field is `LSI`"]
#[inline(always)]
pub fn is_lsi(&self) -> bool {
**self == RTCSEL_A::LSI
}
#[doc = "Checks if the value of the field is `HSE`"]
#[inline(always)]
pub fn is_hse(&self) -> bool {
**self == RTCSEL_A::HSE
}
}
impl core::ops::Deref for RTCSEL_R {
type Target = crate::FieldReader<u8, RTCSEL_A>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
#[doc = "Field `RTCSEL` writer - RTC clock source selection"]
pub struct RTCSEL_W<'a> {
w: &'a mut W,
}
impl<'a> RTCSEL_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: RTCSEL_A) -> &'a mut W {
self.bits(variant.into())
}
#[doc = "No clock"]
#[inline(always)]
pub fn no_clock(self) -> &'a mut W {
self.variant(RTCSEL_A::NOCLOCK)
}
#[doc = "LSE oscillator clock used as RTC clock"]
#[inline(always)]
pub fn lse(self) -> &'a mut W {
self.variant(RTCSEL_A::LSE)
}
#[doc = "LSI oscillator clock used as RTC clock"]
#[inline(always)]
pub fn lsi(self) -> &'a mut W {
self.variant(RTCSEL_A::LSI)
}
#[doc = "HSE oscillator clock divided by a prescaler used as RTC clock"]
#[inline(always)]
pub fn hse(self) -> &'a mut W {
self.variant(RTCSEL_A::HSE)
}
#[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 << 8)) | ((value as u32 & 0x03) << 8);
self.w
}
}
impl R {
#[doc = "Bit 16 - Backup domain software reset"]
#[inline(always)]
pub fn bdrst(&self) -> BDRST_R {
BDRST_R::new(((self.bits >> 16) & 0x01) != 0)
}
#[doc = "Bit 15 - RTC clock enable"]
#[inline(always)]
pub fn rtcen(&self) -> RTCEN_R {
RTCEN_R::new(((self.bits >> 15) & 0x01) != 0)
}
#[doc = "Bit 2 - External low-speed oscillator bypass"]
#[inline(always)]
pub fn lsebyp(&self) -> LSEBYP_R {
LSEBYP_R::new(((self.bits >> 2) & 0x01) != 0)
}
#[doc = "Bit 1 - External low-speed oscillator ready"]
#[inline(always)]
pub fn lserdy(&self) -> LSERDY_R {
LSERDY_R::new(((self.bits >> 1) & 0x01) != 0)
}
#[doc = "Bit 0 - External low-speed oscillator enable"]
#[inline(always)]
pub fn lseon(&self) -> LSEON_R {
LSEON_R::new((self.bits & 0x01) != 0)
}
#[doc = "Bits 8:9 - RTC clock source selection"]
#[inline(always)]
pub fn rtcsel(&self) -> RTCSEL_R {
RTCSEL_R::new(((self.bits >> 8) & 0x03) as u8)
}
}
impl W {
#[doc = "Bit 16 - Backup domain software reset"]
#[inline(always)]
pub fn bdrst(&mut self) -> BDRST_W {
BDRST_W { w: self }
}
#[doc = "Bit 15 - RTC clock enable"]
#[inline(always)]
pub fn rtcen(&mut self) -> RTCEN_W {
RTCEN_W { w: self }
}
#[doc = "Bit 2 - External low-speed oscillator bypass"]
#[inline(always)]
pub fn lsebyp(&mut self) -> LSEBYP_W {
LSEBYP_W { w: self }
}
#[doc = "Bit 0 - External low-speed oscillator enable"]
#[inline(always)]
pub fn lseon(&mut self) -> LSEON_W {
LSEON_W { w: self }
}
#[doc = "Bits 8:9 - RTC clock source selection"]
#[inline(always)]
pub fn rtcsel(&mut self) -> RTCSEL_W {
RTCSEL_W { w: self }
}
#[doc = "Writes raw bits to the register."]
#[inline(always)]
pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
self.0.bits(bits);
self
}
}
#[doc = "Backup domain 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 [bdcr](index.html) module"]
pub struct BDCR_SPEC;
impl crate::RegisterSpec for BDCR_SPEC {
type Ux = u32;
}
#[doc = "`read()` method returns [bdcr::R](R) reader structure"]
impl crate::Readable for BDCR_SPEC {
type Reader = R;
}
#[doc = "`write(|w| ..)` method takes [bdcr::W](W) writer structure"]
impl crate::Writable for BDCR_SPEC {
type Writer = W;
}
#[doc = "`reset()` method sets BDCR to value 0"]
impl crate::Resettable for BDCR_SPEC {
#[inline(always)]
fn reset_value() -> Self::Ux {
0
}
}