stm32f1_staging/stm32f102/usart1/
cr2.rspub type R = crate::R<CR2rs>;
pub type W = crate::W<CR2rs>;
pub type ADD_R = crate::FieldReader;
pub type ADD_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 LBDL {
Lbdl10 = 0,
Lbdl11 = 1,
}
impl From<LBDL> for bool {
#[inline(always)]
fn from(variant: LBDL) -> Self {
variant as u8 != 0
}
}
pub type LBDL_R = crate::BitReader<LBDL>;
impl LBDL_R {
#[inline(always)]
pub const fn variant(&self) -> LBDL {
match self.bits {
false => LBDL::Lbdl10,
true => LBDL::Lbdl11,
}
}
#[inline(always)]
pub fn is_lbdl10(&self) -> bool {
*self == LBDL::Lbdl10
}
#[inline(always)]
pub fn is_lbdl11(&self) -> bool {
*self == LBDL::Lbdl11
}
}
pub type LBDL_W<'a, REG> = crate::BitWriter<'a, REG, LBDL>;
impl<'a, REG> LBDL_W<'a, REG>
where
REG: crate::Writable + crate::RegisterSpec,
{
#[inline(always)]
pub fn lbdl10(self) -> &'a mut crate::W<REG> {
self.variant(LBDL::Lbdl10)
}
#[inline(always)]
pub fn lbdl11(self) -> &'a mut crate::W<REG> {
self.variant(LBDL::Lbdl11)
}
}
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum LBDIE {
Disabled = 0,
Enabled = 1,
}
impl From<LBDIE> for bool {
#[inline(always)]
fn from(variant: LBDIE) -> Self {
variant as u8 != 0
}
}
pub type LBDIE_R = crate::BitReader<LBDIE>;
impl LBDIE_R {
#[inline(always)]
pub const fn variant(&self) -> LBDIE {
match self.bits {
false => LBDIE::Disabled,
true => LBDIE::Enabled,
}
}
#[inline(always)]
pub fn is_disabled(&self) -> bool {
*self == LBDIE::Disabled
}
#[inline(always)]
pub fn is_enabled(&self) -> bool {
*self == LBDIE::Enabled
}
}
pub type LBDIE_W<'a, REG> = crate::BitWriter<'a, REG, LBDIE>;
impl<'a, REG> LBDIE_W<'a, REG>
where
REG: crate::Writable + crate::RegisterSpec,
{
#[inline(always)]
pub fn disabled(self) -> &'a mut crate::W<REG> {
self.variant(LBDIE::Disabled)
}
#[inline(always)]
pub fn enabled(self) -> &'a mut crate::W<REG> {
self.variant(LBDIE::Enabled)
}
}
pub type LBCL_R = crate::BitReader;
pub type LBCL_W<'a, REG> = crate::BitWriter<'a, REG>;
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum CPHA {
First = 0,
Second = 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::First,
true => CPHA::Second,
}
}
#[inline(always)]
pub fn is_first(&self) -> bool {
*self == CPHA::First
}
#[inline(always)]
pub fn is_second(&self) -> bool {
*self == CPHA::Second
}
}
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(self) -> &'a mut crate::W<REG> {
self.variant(CPHA::First)
}
#[inline(always)]
pub fn second(self) -> &'a mut crate::W<REG> {
self.variant(CPHA::Second)
}
}
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum CPOL {
Low = 0,
High = 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::Low,
true => CPOL::High,
}
}
#[inline(always)]
pub fn is_low(&self) -> bool {
*self == CPOL::Low
}
#[inline(always)]
pub fn is_high(&self) -> bool {
*self == CPOL::High
}
}
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 low(self) -> &'a mut crate::W<REG> {
self.variant(CPOL::Low)
}
#[inline(always)]
pub fn high(self) -> &'a mut crate::W<REG> {
self.variant(CPOL::High)
}
}
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum CLKEN {
Disabled = 0,
Enabled = 1,
}
impl From<CLKEN> for bool {
#[inline(always)]
fn from(variant: CLKEN) -> Self {
variant as u8 != 0
}
}
pub type CLKEN_R = crate::BitReader<CLKEN>;
impl CLKEN_R {
#[inline(always)]
pub const fn variant(&self) -> CLKEN {
match self.bits {
false => CLKEN::Disabled,
true => CLKEN::Enabled,
}
}
#[inline(always)]
pub fn is_disabled(&self) -> bool {
*self == CLKEN::Disabled
}
#[inline(always)]
pub fn is_enabled(&self) -> bool {
*self == CLKEN::Enabled
}
}
pub type CLKEN_W<'a, REG> = crate::BitWriter<'a, REG, CLKEN>;
impl<'a, REG> CLKEN_W<'a, REG>
where
REG: crate::Writable + crate::RegisterSpec,
{
#[inline(always)]
pub fn disabled(self) -> &'a mut crate::W<REG> {
self.variant(CLKEN::Disabled)
}
#[inline(always)]
pub fn enabled(self) -> &'a mut crate::W<REG> {
self.variant(CLKEN::Enabled)
}
}
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum STOP {
Stop1 = 0,
Stop0p5 = 1,
Stop2 = 2,
Stop1p5 = 3,
}
impl From<STOP> for u8 {
#[inline(always)]
fn from(variant: STOP) -> Self {
variant as _
}
}
impl crate::FieldSpec for STOP {
type Ux = u8;
}
impl crate::IsEnum for STOP {}
pub type STOP_R = crate::FieldReader<STOP>;
impl STOP_R {
#[inline(always)]
pub const fn variant(&self) -> STOP {
match self.bits {
0 => STOP::Stop1,
1 => STOP::Stop0p5,
2 => STOP::Stop2,
3 => STOP::Stop1p5,
_ => unreachable!(),
}
}
#[inline(always)]
pub fn is_stop1(&self) -> bool {
*self == STOP::Stop1
}
#[inline(always)]
pub fn is_stop0p5(&self) -> bool {
*self == STOP::Stop0p5
}
#[inline(always)]
pub fn is_stop2(&self) -> bool {
*self == STOP::Stop2
}
#[inline(always)]
pub fn is_stop1p5(&self) -> bool {
*self == STOP::Stop1p5
}
}
pub type STOP_W<'a, REG> = crate::FieldWriter<'a, REG, 2, STOP, crate::Safe>;
impl<'a, REG> STOP_W<'a, REG>
where
REG: crate::Writable + crate::RegisterSpec,
REG::Ux: From<u8>,
{
#[inline(always)]
pub fn stop1(self) -> &'a mut crate::W<REG> {
self.variant(STOP::Stop1)
}
#[inline(always)]
pub fn stop0p5(self) -> &'a mut crate::W<REG> {
self.variant(STOP::Stop0p5)
}
#[inline(always)]
pub fn stop2(self) -> &'a mut crate::W<REG> {
self.variant(STOP::Stop2)
}
#[inline(always)]
pub fn stop1p5(self) -> &'a mut crate::W<REG> {
self.variant(STOP::Stop1p5)
}
}
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum LINEN {
Disabled = 0,
Enabled = 1,
}
impl From<LINEN> for bool {
#[inline(always)]
fn from(variant: LINEN) -> Self {
variant as u8 != 0
}
}
pub type LINEN_R = crate::BitReader<LINEN>;
impl LINEN_R {
#[inline(always)]
pub const fn variant(&self) -> LINEN {
match self.bits {
false => LINEN::Disabled,
true => LINEN::Enabled,
}
}
#[inline(always)]
pub fn is_disabled(&self) -> bool {
*self == LINEN::Disabled
}
#[inline(always)]
pub fn is_enabled(&self) -> bool {
*self == LINEN::Enabled
}
}
pub type LINEN_W<'a, REG> = crate::BitWriter<'a, REG, LINEN>;
impl<'a, REG> LINEN_W<'a, REG>
where
REG: crate::Writable + crate::RegisterSpec,
{
#[inline(always)]
pub fn disabled(self) -> &'a mut crate::W<REG> {
self.variant(LINEN::Disabled)
}
#[inline(always)]
pub fn enabled(self) -> &'a mut crate::W<REG> {
self.variant(LINEN::Enabled)
}
}
impl R {
#[inline(always)]
pub fn add(&self) -> ADD_R {
ADD_R::new((self.bits & 0x0f) as u8)
}
#[inline(always)]
pub fn lbdl(&self) -> LBDL_R {
LBDL_R::new(((self.bits >> 5) & 1) != 0)
}
#[inline(always)]
pub fn lbdie(&self) -> LBDIE_R {
LBDIE_R::new(((self.bits >> 6) & 1) != 0)
}
#[inline(always)]
pub fn lbcl(&self) -> LBCL_R {
LBCL_R::new(((self.bits >> 8) & 1) != 0)
}
#[inline(always)]
pub fn cpha(&self) -> CPHA_R {
CPHA_R::new(((self.bits >> 9) & 1) != 0)
}
#[inline(always)]
pub fn cpol(&self) -> CPOL_R {
CPOL_R::new(((self.bits >> 10) & 1) != 0)
}
#[inline(always)]
pub fn clken(&self) -> CLKEN_R {
CLKEN_R::new(((self.bits >> 11) & 1) != 0)
}
#[inline(always)]
pub fn stop(&self) -> STOP_R {
STOP_R::new(((self.bits >> 12) & 3) as u8)
}
#[inline(always)]
pub fn linen(&self) -> LINEN_R {
LINEN_R::new(((self.bits >> 14) & 1) != 0)
}
}
impl core::fmt::Debug for R {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("CR2")
.field("linen", &self.linen())
.field("stop", &self.stop())
.field("clken", &self.clken())
.field("cpol", &self.cpol())
.field("cpha", &self.cpha())
.field("lbcl", &self.lbcl())
.field("lbdie", &self.lbdie())
.field("lbdl", &self.lbdl())
.field("add", &self.add())
.finish()
}
}
impl W {
#[inline(always)]
#[must_use]
pub fn add(&mut self) -> ADD_W<CR2rs> {
ADD_W::new(self, 0)
}
#[inline(always)]
#[must_use]
pub fn lbdl(&mut self) -> LBDL_W<CR2rs> {
LBDL_W::new(self, 5)
}
#[inline(always)]
#[must_use]
pub fn lbdie(&mut self) -> LBDIE_W<CR2rs> {
LBDIE_W::new(self, 6)
}
#[inline(always)]
#[must_use]
pub fn lbcl(&mut self) -> LBCL_W<CR2rs> {
LBCL_W::new(self, 8)
}
#[inline(always)]
#[must_use]
pub fn cpha(&mut self) -> CPHA_W<CR2rs> {
CPHA_W::new(self, 9)
}
#[inline(always)]
#[must_use]
pub fn cpol(&mut self) -> CPOL_W<CR2rs> {
CPOL_W::new(self, 10)
}
#[inline(always)]
#[must_use]
pub fn clken(&mut self) -> CLKEN_W<CR2rs> {
CLKEN_W::new(self, 11)
}
#[inline(always)]
#[must_use]
pub fn stop(&mut self) -> STOP_W<CR2rs> {
STOP_W::new(self, 12)
}
#[inline(always)]
#[must_use]
pub fn linen(&mut self) -> LINEN_W<CR2rs> {
LINEN_W::new(self, 14)
}
}
pub struct CR2rs;
impl crate::RegisterSpec for CR2rs {
type Ux = u32;
}
impl crate::Readable for CR2rs {}
impl crate::Writable for CR2rs {
type Safety = crate::Unsafe;
const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
}
impl crate::Resettable for CR2rs {
const RESET_VALUE: u32 = 0;
}