stm32f1_staging/stm32f102/i2c1/
ccr.rspub type R = crate::R<CCRrs>;
pub type W = crate::W<CCRrs>;
pub type CCR_R = crate::FieldReader<u16>;
pub type CCR_W<'a, REG> = crate::FieldWriter<'a, REG, 12, u16>;
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum DUTY {
Duty2_1 = 0,
Duty16_9 = 1,
}
impl From<DUTY> for bool {
#[inline(always)]
fn from(variant: DUTY) -> Self {
variant as u8 != 0
}
}
pub type DUTY_R = crate::BitReader<DUTY>;
impl DUTY_R {
#[inline(always)]
pub const fn variant(&self) -> DUTY {
match self.bits {
false => DUTY::Duty2_1,
true => DUTY::Duty16_9,
}
}
#[inline(always)]
pub fn is_duty2_1(&self) -> bool {
*self == DUTY::Duty2_1
}
#[inline(always)]
pub fn is_duty16_9(&self) -> bool {
*self == DUTY::Duty16_9
}
}
pub type DUTY_W<'a, REG> = crate::BitWriter<'a, REG, DUTY>;
impl<'a, REG> DUTY_W<'a, REG>
where
REG: crate::Writable + crate::RegisterSpec,
{
#[inline(always)]
pub fn duty2_1(self) -> &'a mut crate::W<REG> {
self.variant(DUTY::Duty2_1)
}
#[inline(always)]
pub fn duty16_9(self) -> &'a mut crate::W<REG> {
self.variant(DUTY::Duty16_9)
}
}
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum F_S {
Standard = 0,
Fast = 1,
}
impl From<F_S> for bool {
#[inline(always)]
fn from(variant: F_S) -> Self {
variant as u8 != 0
}
}
pub type F_S_R = crate::BitReader<F_S>;
impl F_S_R {
#[inline(always)]
pub const fn variant(&self) -> F_S {
match self.bits {
false => F_S::Standard,
true => F_S::Fast,
}
}
#[inline(always)]
pub fn is_standard(&self) -> bool {
*self == F_S::Standard
}
#[inline(always)]
pub fn is_fast(&self) -> bool {
*self == F_S::Fast
}
}
pub type F_S_W<'a, REG> = crate::BitWriter<'a, REG, F_S>;
impl<'a, REG> F_S_W<'a, REG>
where
REG: crate::Writable + crate::RegisterSpec,
{
#[inline(always)]
pub fn standard(self) -> &'a mut crate::W<REG> {
self.variant(F_S::Standard)
}
#[inline(always)]
pub fn fast(self) -> &'a mut crate::W<REG> {
self.variant(F_S::Fast)
}
}
impl R {
#[inline(always)]
pub fn ccr(&self) -> CCR_R {
CCR_R::new((self.bits & 0x0fff) as u16)
}
#[inline(always)]
pub fn duty(&self) -> DUTY_R {
DUTY_R::new(((self.bits >> 14) & 1) != 0)
}
#[inline(always)]
pub fn f_s(&self) -> F_S_R {
F_S_R::new(((self.bits >> 15) & 1) != 0)
}
}
impl core::fmt::Debug for R {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("CCR")
.field("f_s", &self.f_s())
.field("duty", &self.duty())
.field("ccr", &self.ccr())
.finish()
}
}
impl W {
#[inline(always)]
#[must_use]
pub fn ccr(&mut self) -> CCR_W<CCRrs> {
CCR_W::new(self, 0)
}
#[inline(always)]
#[must_use]
pub fn duty(&mut self) -> DUTY_W<CCRrs> {
DUTY_W::new(self, 14)
}
#[inline(always)]
#[must_use]
pub fn f_s(&mut self) -> F_S_W<CCRrs> {
F_S_W::new(self, 15)
}
}
pub struct CCRrs;
impl crate::RegisterSpec for CCRrs {
type Ux = u32;
}
impl crate::Readable for CCRrs {}
impl crate::Writable for CCRrs {
type Safety = crate::Unsafe;
const ZERO_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
const ONE_TO_MODIFY_FIELDS_BITMAP: u32 = 0;
}
impl crate::Resettable for CCRrs {
const RESET_VALUE: u32 = 0;
}