pub type R = crate::R<APB2ENRrs>;
pub type W = crate::W<APB2ENRrs>;
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SYSCFGEN {
Disabled = 0,
Enabled = 1,
}
impl From<SYSCFGEN> for bool {
#[inline(always)]
fn from(variant: SYSCFGEN) -> Self {
variant as u8 != 0
}
}
pub type SYSCFGEN_R = crate::BitReader<SYSCFGEN>;
impl SYSCFGEN_R {
#[inline(always)]
pub const fn variant(&self) -> SYSCFGEN {
match self.bits {
false => SYSCFGEN::Disabled,
true => SYSCFGEN::Enabled,
}
}
#[inline(always)]
pub fn is_disabled(&self) -> bool {
*self == SYSCFGEN::Disabled
}
#[inline(always)]
pub fn is_enabled(&self) -> bool {
*self == SYSCFGEN::Enabled
}
}
pub type SYSCFGEN_W<'a, REG> = crate::BitWriter<'a, REG, SYSCFGEN>;
impl<'a, REG> SYSCFGEN_W<'a, REG>
where
REG: crate::Writable + crate::RegisterSpec,
{
#[inline(always)]
pub fn disabled(self) -> &'a mut crate::W<REG> {
self.variant(SYSCFGEN::Disabled)
}
#[inline(always)]
pub fn enabled(self) -> &'a mut crate::W<REG> {
self.variant(SYSCFGEN::Enabled)
}
}
pub use SYSCFGEN_R as TIM21EN_R;
pub use SYSCFGEN_R as TIM22EN_R;
pub use SYSCFGEN_R as MIFIEN_R;
pub use SYSCFGEN_R as ADCEN_R;
pub use SYSCFGEN_R as SPI1EN_R;
pub use SYSCFGEN_R as USART1EN_R;
pub use SYSCFGEN_R as DBGEN_R;
pub use SYSCFGEN_W as TIM21EN_W;
pub use SYSCFGEN_W as TIM22EN_W;
pub use SYSCFGEN_W as MIFIEN_W;
pub use SYSCFGEN_W as ADCEN_W;
pub use SYSCFGEN_W as SPI1EN_W;
pub use SYSCFGEN_W as USART1EN_W;
pub use SYSCFGEN_W as DBGEN_W;
impl R {
#[inline(always)]
pub fn syscfgen(&self) -> SYSCFGEN_R {
SYSCFGEN_R::new((self.bits & 1) != 0)
}
#[inline(always)]
pub fn tim21en(&self) -> TIM21EN_R {
TIM21EN_R::new(((self.bits >> 2) & 1) != 0)
}
#[inline(always)]
pub fn tim22en(&self) -> TIM22EN_R {
TIM22EN_R::new(((self.bits >> 5) & 1) != 0)
}
#[inline(always)]
pub fn mifien(&self) -> MIFIEN_R {
MIFIEN_R::new(((self.bits >> 7) & 1) != 0)
}
#[inline(always)]
pub fn adcen(&self) -> ADCEN_R {
ADCEN_R::new(((self.bits >> 9) & 1) != 0)
}
#[inline(always)]
pub fn spi1en(&self) -> SPI1EN_R {
SPI1EN_R::new(((self.bits >> 12) & 1) != 0)
}
#[inline(always)]
pub fn usart1en(&self) -> USART1EN_R {
USART1EN_R::new(((self.bits >> 14) & 1) != 0)
}
#[inline(always)]
pub fn dbgen(&self) -> DBGEN_R {
DBGEN_R::new(((self.bits >> 22) & 1) != 0)
}
}
impl core::fmt::Debug for R {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("APB2ENR")
.field("syscfgen", &self.syscfgen())
.field("dbgen", &self.dbgen())
.field("usart1en", &self.usart1en())
.field("spi1en", &self.spi1en())
.field("adcen", &self.adcen())
.field("mifien", &self.mifien())
.field("tim22en", &self.tim22en())
.field("tim21en", &self.tim21en())
.finish()
}
}
impl W {
#[inline(always)]
pub fn syscfgen(&mut self) -> SYSCFGEN_W<APB2ENRrs> {
SYSCFGEN_W::new(self, 0)
}
#[inline(always)]
pub fn tim21en(&mut self) -> TIM21EN_W<APB2ENRrs> {
TIM21EN_W::new(self, 2)
}
#[inline(always)]
pub fn tim22en(&mut self) -> TIM22EN_W<APB2ENRrs> {
TIM22EN_W::new(self, 5)
}
#[inline(always)]
pub fn mifien(&mut self) -> MIFIEN_W<APB2ENRrs> {
MIFIEN_W::new(self, 7)
}
#[inline(always)]
pub fn adcen(&mut self) -> ADCEN_W<APB2ENRrs> {
ADCEN_W::new(self, 9)
}
#[inline(always)]
pub fn spi1en(&mut self) -> SPI1EN_W<APB2ENRrs> {
SPI1EN_W::new(self, 12)
}
#[inline(always)]
pub fn usart1en(&mut self) -> USART1EN_W<APB2ENRrs> {
USART1EN_W::new(self, 14)
}
#[inline(always)]
pub fn dbgen(&mut self) -> DBGEN_W<APB2ENRrs> {
DBGEN_W::new(self, 22)
}
}
pub struct APB2ENRrs;
impl crate::RegisterSpec for APB2ENRrs {
type Ux = u32;
}
impl crate::Readable for APB2ENRrs {}
impl crate::Writable for APB2ENRrs {
type Safety = crate::Unsafe;
}
impl crate::Resettable for APB2ENRrs {}