#[doc = "Register `CLK_IMO_SPREAD` reader"]
pub struct R(crate::R<CLK_IMO_SPREAD_SPEC>);
impl core::ops::Deref for R {
    type Target = crate::R<CLK_IMO_SPREAD_SPEC>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
impl core::convert::From<crate::R<CLK_IMO_SPREAD_SPEC>> for R {
    fn from(reader: crate::R<CLK_IMO_SPREAD_SPEC>) -> Self {
        R(reader)
    }
}
#[doc = "Register `CLK_IMO_SPREAD` writer"]
pub struct W(crate::W<CLK_IMO_SPREAD_SPEC>);
impl core::ops::Deref for W {
    type Target = crate::W<CLK_IMO_SPREAD_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<CLK_IMO_SPREAD_SPEC>> for W {
    fn from(writer: crate::W<CLK_IMO_SPREAD_SPEC>) -> Self {
        W(writer)
    }
}
#[doc = "Field `SS_VALUE` reader - Current offset value for spread spectrum modulation. IMO supports values 0..16. Step size is determined by SS_RANGE. Value is encoded in proper thermometric format for IMO in hardware. Value can be modified in firmware only when SS_MODE=0."]
pub struct SS_VALUE_R(crate::FieldReader<u8, u8>);
impl SS_VALUE_R {
    pub(crate) fn new(bits: u8) -> Self {
        SS_VALUE_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for SS_VALUE_R {
    type Target = crate::FieldReader<u8, u8>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `SS_VALUE` writer - Current offset value for spread spectrum modulation. IMO supports values 0..16. Step size is determined by SS_RANGE. Value is encoded in proper thermometric format for IMO in hardware. Value can be modified in firmware only when SS_MODE=0."]
pub struct SS_VALUE_W<'a> {
    w: &'a mut W,
}
impl<'a> SS_VALUE_W<'a> {
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub unsafe fn bits(self, value: u8) -> &'a mut W {
        self.w.bits = (self.w.bits & !0x1f) | (value as u32 & 0x1f);
        self.w
    }
}
#[doc = "Field `SS_MAX` reader - Maximum counter value for spread spectrum. Counter will count from 0..SS_MAX..0 and keep repeating this indefinitely. Only works when SS_MODE=1."]
pub struct SS_MAX_R(crate::FieldReader<u8, u8>);
impl SS_MAX_R {
    pub(crate) fn new(bits: u8) -> Self {
        SS_MAX_R(crate::FieldReader::new(bits))
    }
}
impl core::ops::Deref for SS_MAX_R {
    type Target = crate::FieldReader<u8, u8>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `SS_MAX` writer - Maximum counter value for spread spectrum. Counter will count from 0..SS_MAX..0 and keep repeating this indefinitely. Only works when SS_MODE=1."]
pub struct SS_MAX_W<'a> {
    w: &'a mut W,
}
impl<'a> SS_MAX_W<'a> {
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub unsafe fn bits(self, value: u8) -> &'a mut W {
        self.w.bits = (self.w.bits & !(0x1f << 8)) | ((value as u32 & 0x1f) << 8);
        self.w
    }
}
#[doc = "Spread spectrum range (downspread when SS_VALUE=16).?3: reserved, do not use\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(u8)]
pub enum SS_RANGE_A {
    #[doc = "0: No description available"]
    M1 = 0,
    #[doc = "1: No description available"]
    M2 = 1,
    #[doc = "2: No description available"]
    M4 = 2,
}
impl From<SS_RANGE_A> for u8 {
    #[inline(always)]
    fn from(variant: SS_RANGE_A) -> Self {
        variant as _
    }
}
#[doc = "Field `SS_RANGE` reader - Spread spectrum range (downspread when SS_VALUE=16).?3: reserved, do not use"]
pub struct SS_RANGE_R(crate::FieldReader<u8, SS_RANGE_A>);
impl SS_RANGE_R {
    pub(crate) fn new(bits: u8) -> Self {
        SS_RANGE_R(crate::FieldReader::new(bits))
    }
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> Option<SS_RANGE_A> {
        match self.bits {
            0 => Some(SS_RANGE_A::M1),
            1 => Some(SS_RANGE_A::M2),
            2 => Some(SS_RANGE_A::M4),
            _ => None,
        }
    }
    #[doc = "Checks if the value of the field is `M1`"]
    #[inline(always)]
    pub fn is_m1(&self) -> bool {
        **self == SS_RANGE_A::M1
    }
    #[doc = "Checks if the value of the field is `M2`"]
    #[inline(always)]
    pub fn is_m2(&self) -> bool {
        **self == SS_RANGE_A::M2
    }
    #[doc = "Checks if the value of the field is `M4`"]
    #[inline(always)]
    pub fn is_m4(&self) -> bool {
        **self == SS_RANGE_A::M4
    }
}
impl core::ops::Deref for SS_RANGE_R {
    type Target = crate::FieldReader<u8, SS_RANGE_A>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `SS_RANGE` writer - Spread spectrum range (downspread when SS_VALUE=16).?3: reserved, do not use"]
pub struct SS_RANGE_W<'a> {
    w: &'a mut W,
}
impl<'a> SS_RANGE_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: SS_RANGE_A) -> &'a mut W {
        unsafe { self.bits(variant.into()) }
    }
    #[doc = "No description available"]
    #[inline(always)]
    pub fn m1(self) -> &'a mut W {
        self.variant(SS_RANGE_A::M1)
    }
    #[doc = "No description available"]
    #[inline(always)]
    pub fn m2(self) -> &'a mut W {
        self.variant(SS_RANGE_A::M2)
    }
    #[doc = "No description available"]
    #[inline(always)]
    pub fn m4(self) -> &'a mut W {
        self.variant(SS_RANGE_A::M4)
    }
    #[doc = r"Writes raw bits to the field"]
    #[inline(always)]
    pub unsafe fn bits(self, value: u8) -> &'a mut W {
        self.w.bits = (self.w.bits & !(0x03 << 28)) | ((value as u32 & 0x03) << 28);
        self.w
    }
}
#[doc = "Spread Spectrum Mode.\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(u8)]
pub enum SS_MODE_A {
    #[doc = "0: No description available"]
    OFF = 0,
    #[doc = "1: No description available"]
    TRIANGLE = 1,
    #[doc = "2: No description available"]
    LFSR = 2,
    #[doc = "3: No description available"]
    DSI = 3,
}
impl From<SS_MODE_A> for u8 {
    #[inline(always)]
    fn from(variant: SS_MODE_A) -> Self {
        variant as _
    }
}
#[doc = "Field `SS_MODE` reader - Spread Spectrum Mode."]
pub struct SS_MODE_R(crate::FieldReader<u8, SS_MODE_A>);
impl SS_MODE_R {
    pub(crate) fn new(bits: u8) -> Self {
        SS_MODE_R(crate::FieldReader::new(bits))
    }
    #[doc = r"Get enumerated values variant"]
    #[inline(always)]
    pub fn variant(&self) -> SS_MODE_A {
        match self.bits {
            0 => SS_MODE_A::OFF,
            1 => SS_MODE_A::TRIANGLE,
            2 => SS_MODE_A::LFSR,
            3 => SS_MODE_A::DSI,
            _ => unreachable!(),
        }
    }
    #[doc = "Checks if the value of the field is `OFF`"]
    #[inline(always)]
    pub fn is_off(&self) -> bool {
        **self == SS_MODE_A::OFF
    }
    #[doc = "Checks if the value of the field is `TRIANGLE`"]
    #[inline(always)]
    pub fn is_triangle(&self) -> bool {
        **self == SS_MODE_A::TRIANGLE
    }
    #[doc = "Checks if the value of the field is `LFSR`"]
    #[inline(always)]
    pub fn is_lfsr(&self) -> bool {
        **self == SS_MODE_A::LFSR
    }
    #[doc = "Checks if the value of the field is `DSI`"]
    #[inline(always)]
    pub fn is_dsi(&self) -> bool {
        **self == SS_MODE_A::DSI
    }
}
impl core::ops::Deref for SS_MODE_R {
    type Target = crate::FieldReader<u8, SS_MODE_A>;
    #[inline(always)]
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}
#[doc = "Field `SS_MODE` writer - Spread Spectrum Mode."]
pub struct SS_MODE_W<'a> {
    w: &'a mut W,
}
impl<'a> SS_MODE_W<'a> {
    #[doc = r"Writes `variant` to the field"]
    #[inline(always)]
    pub fn variant(self, variant: SS_MODE_A) -> &'a mut W {
        self.bits(variant.into())
    }
    #[doc = "No description available"]
    #[inline(always)]
    pub fn off(self) -> &'a mut W {
        self.variant(SS_MODE_A::OFF)
    }
    #[doc = "No description available"]
    #[inline(always)]
    pub fn triangle(self) -> &'a mut W {
        self.variant(SS_MODE_A::TRIANGLE)
    }
    #[doc = "No description available"]
    #[inline(always)]
    pub fn lfsr(self) -> &'a mut W {
        self.variant(SS_MODE_A::LFSR)
    }
    #[doc = "No description available"]
    #[inline(always)]
    pub fn dsi(self) -> &'a mut W {
        self.variant(SS_MODE_A::DSI)
    }
    #[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 << 30)) | ((value as u32 & 0x03) << 30);
        self.w
    }
}
impl R {
    #[doc = "Bits 0:4 - Current offset value for spread spectrum modulation. IMO supports values 0..16. Step size is determined by SS_RANGE. Value is encoded in proper thermometric format for IMO in hardware. Value can be modified in firmware only when SS_MODE=0."]
    #[inline(always)]
    pub fn ss_value(&self) -> SS_VALUE_R {
        SS_VALUE_R::new((self.bits & 0x1f) as u8)
    }
    #[doc = "Bits 8:12 - Maximum counter value for spread spectrum. Counter will count from 0..SS_MAX..0 and keep repeating this indefinitely. Only works when SS_MODE=1."]
    #[inline(always)]
    pub fn ss_max(&self) -> SS_MAX_R {
        SS_MAX_R::new(((self.bits >> 8) & 0x1f) as u8)
    }
    #[doc = "Bits 28:29 - Spread spectrum range (downspread when SS_VALUE=16).?3: reserved, do not use"]
    #[inline(always)]
    pub fn ss_range(&self) -> SS_RANGE_R {
        SS_RANGE_R::new(((self.bits >> 28) & 0x03) as u8)
    }
    #[doc = "Bits 30:31 - Spread Spectrum Mode."]
    #[inline(always)]
    pub fn ss_mode(&self) -> SS_MODE_R {
        SS_MODE_R::new(((self.bits >> 30) & 0x03) as u8)
    }
}
impl W {
    #[doc = "Bits 0:4 - Current offset value for spread spectrum modulation. IMO supports values 0..16. Step size is determined by SS_RANGE. Value is encoded in proper thermometric format for IMO in hardware. Value can be modified in firmware only when SS_MODE=0."]
    #[inline(always)]
    pub fn ss_value(&mut self) -> SS_VALUE_W {
        SS_VALUE_W { w: self }
    }
    #[doc = "Bits 8:12 - Maximum counter value for spread spectrum. Counter will count from 0..SS_MAX..0 and keep repeating this indefinitely. Only works when SS_MODE=1."]
    #[inline(always)]
    pub fn ss_max(&mut self) -> SS_MAX_W {
        SS_MAX_W { w: self }
    }
    #[doc = "Bits 28:29 - Spread spectrum range (downspread when SS_VALUE=16).?3: reserved, do not use"]
    #[inline(always)]
    pub fn ss_range(&mut self) -> SS_RANGE_W {
        SS_RANGE_W { w: self }
    }
    #[doc = "Bits 30:31 - Spread Spectrum Mode."]
    #[inline(always)]
    pub fn ss_mode(&mut self) -> SS_MODE_W {
        SS_MODE_W { w: self }
    }
    #[doc = "Writes raw bits to the register."]
    pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
        self.0.bits(bits);
        self
    }
}
#[doc = "IMO Spread Spectrum Configuration\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 [clk_imo_spread](index.html) module"]
pub struct CLK_IMO_SPREAD_SPEC;
impl crate::RegisterSpec for CLK_IMO_SPREAD_SPEC {
    type Ux = u32;
}
#[doc = "`read()` method returns [clk_imo_spread::R](R) reader structure"]
impl crate::Readable for CLK_IMO_SPREAD_SPEC {
    type Reader = R;
}
#[doc = "`write(|w| ..)` method takes [clk_imo_spread::W](W) writer structure"]
impl crate::Writable for CLK_IMO_SPREAD_SPEC {
    type Writer = W;
}
#[doc = "`reset()` method sets CLK_IMO_SPREAD to value 0"]
impl crate::Resettable for CLK_IMO_SPREAD_SPEC {
    #[inline(always)]
    fn reset_value() -> Self::Ux {
        0
    }
}
