#[doc = "Register `CTRL` reader"]
pub struct R(crate::R<CTRL_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<CTRL_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl From<crate::R<CTRL_SPEC>> for R {
#[inline(always)]
fn from(reader: crate::R<CTRL_SPEC>) -> Self {
R(reader)
}
}
#[doc = "Register `CTRL` writer"]
pub struct W(crate::W<CTRL_SPEC>);
impl core::ops::Deref for W {
type Target = crate::W<CTRL_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<CTRL_SPEC>> for W {
#[inline(always)]
fn from(writer: crate::W<CTRL_SPEC>) -> Self {
W(writer)
}
}
#[doc = "Warm-up Mode\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(u8)]
pub enum WARMUPMODE_A {
#[doc = "0: ADC is shut down after each conversion"]
NORMAL = 0,
#[doc = "1: Bandgap references do not need warm up, but have reduced accuracy."]
FASTBG = 1,
#[doc = "2: Reference selected for scan mode is kept warm."]
KEEPSCANREFWARM = 2,
#[doc = "3: ADC is kept warmed up and scan reference is kept warm"]
KEEPADCWARM = 3,
}
impl From<WARMUPMODE_A> for u8 {
#[inline(always)]
fn from(variant: WARMUPMODE_A) -> Self {
variant as _
}
}
#[doc = "Field `WARMUPMODE` reader - Warm-up Mode"]
pub type WARMUPMODE_R = crate::FieldReader<u8, WARMUPMODE_A>;
impl WARMUPMODE_R {
#[doc = "Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> WARMUPMODE_A {
match self.bits {
0 => WARMUPMODE_A::NORMAL,
1 => WARMUPMODE_A::FASTBG,
2 => WARMUPMODE_A::KEEPSCANREFWARM,
3 => WARMUPMODE_A::KEEPADCWARM,
_ => unreachable!(),
}
}
#[doc = "Checks if the value of the field is `NORMAL`"]
#[inline(always)]
pub fn is_normal(&self) -> bool {
*self == WARMUPMODE_A::NORMAL
}
#[doc = "Checks if the value of the field is `FASTBG`"]
#[inline(always)]
pub fn is_fastbg(&self) -> bool {
*self == WARMUPMODE_A::FASTBG
}
#[doc = "Checks if the value of the field is `KEEPSCANREFWARM`"]
#[inline(always)]
pub fn is_keepscanrefwarm(&self) -> bool {
*self == WARMUPMODE_A::KEEPSCANREFWARM
}
#[doc = "Checks if the value of the field is `KEEPADCWARM`"]
#[inline(always)]
pub fn is_keepadcwarm(&self) -> bool {
*self == WARMUPMODE_A::KEEPADCWARM
}
}
#[doc = "Field `WARMUPMODE` writer - Warm-up Mode"]
pub type WARMUPMODE_W<'a> = crate::FieldWriterSafe<'a, u32, CTRL_SPEC, u8, WARMUPMODE_A, 2, 0>;
impl<'a> WARMUPMODE_W<'a> {
#[doc = "ADC is shut down after each conversion"]
#[inline(always)]
pub fn normal(self) -> &'a mut W {
self.variant(WARMUPMODE_A::NORMAL)
}
#[doc = "Bandgap references do not need warm up, but have reduced accuracy."]
#[inline(always)]
pub fn fastbg(self) -> &'a mut W {
self.variant(WARMUPMODE_A::FASTBG)
}
#[doc = "Reference selected for scan mode is kept warm."]
#[inline(always)]
pub fn keepscanrefwarm(self) -> &'a mut W {
self.variant(WARMUPMODE_A::KEEPSCANREFWARM)
}
#[doc = "ADC is kept warmed up and scan reference is kept warm"]
#[inline(always)]
pub fn keepadcwarm(self) -> &'a mut W {
self.variant(WARMUPMODE_A::KEEPADCWARM)
}
}
#[doc = "Field `TAILGATE` reader - Conversion Tailgating"]
pub type TAILGATE_R = crate::BitReader<bool>;
#[doc = "Field `TAILGATE` writer - Conversion Tailgating"]
pub type TAILGATE_W<'a> = crate::BitWriter<'a, u32, CTRL_SPEC, bool, 3>;
#[doc = "Low Pass Filter Mode\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(u8)]
pub enum LPFMODE_A {
#[doc = "0: No filter or decoupling capacitor"]
BYPASS = 0,
#[doc = "1: On chip decoupling capacitor selected"]
DECAP = 1,
#[doc = "2: On chip RC filter selected"]
RCFILT = 2,
}
impl From<LPFMODE_A> for u8 {
#[inline(always)]
fn from(variant: LPFMODE_A) -> Self {
variant as _
}
}
#[doc = "Field `LPFMODE` reader - Low Pass Filter Mode"]
pub type LPFMODE_R = crate::FieldReader<u8, LPFMODE_A>;
impl LPFMODE_R {
#[doc = "Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> Option<LPFMODE_A> {
match self.bits {
0 => Some(LPFMODE_A::BYPASS),
1 => Some(LPFMODE_A::DECAP),
2 => Some(LPFMODE_A::RCFILT),
_ => None,
}
}
#[doc = "Checks if the value of the field is `BYPASS`"]
#[inline(always)]
pub fn is_bypass(&self) -> bool {
*self == LPFMODE_A::BYPASS
}
#[doc = "Checks if the value of the field is `DECAP`"]
#[inline(always)]
pub fn is_decap(&self) -> bool {
*self == LPFMODE_A::DECAP
}
#[doc = "Checks if the value of the field is `RCFILT`"]
#[inline(always)]
pub fn is_rcfilt(&self) -> bool {
*self == LPFMODE_A::RCFILT
}
}
#[doc = "Field `LPFMODE` writer - Low Pass Filter Mode"]
pub type LPFMODE_W<'a> = crate::FieldWriter<'a, u32, CTRL_SPEC, u8, LPFMODE_A, 2, 4>;
impl<'a> LPFMODE_W<'a> {
#[doc = "No filter or decoupling capacitor"]
#[inline(always)]
pub fn bypass(self) -> &'a mut W {
self.variant(LPFMODE_A::BYPASS)
}
#[doc = "On chip decoupling capacitor selected"]
#[inline(always)]
pub fn decap(self) -> &'a mut W {
self.variant(LPFMODE_A::DECAP)
}
#[doc = "On chip RC filter selected"]
#[inline(always)]
pub fn rcfilt(self) -> &'a mut W {
self.variant(LPFMODE_A::RCFILT)
}
}
#[doc = "Prescaler Setting\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(u8)]
pub enum PRESC_A {
#[doc = "0: `0`"]
NODIVISION = 0,
}
impl From<PRESC_A> for u8 {
#[inline(always)]
fn from(variant: PRESC_A) -> Self {
variant as _
}
}
#[doc = "Field `PRESC` reader - Prescaler Setting"]
pub type PRESC_R = crate::FieldReader<u8, PRESC_A>;
impl PRESC_R {
#[doc = "Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> Option<PRESC_A> {
match self.bits {
0 => Some(PRESC_A::NODIVISION),
_ => None,
}
}
#[doc = "Checks if the value of the field is `NODIVISION`"]
#[inline(always)]
pub fn is_nodivision(&self) -> bool {
*self == PRESC_A::NODIVISION
}
}
#[doc = "Field `PRESC` writer - Prescaler Setting"]
pub type PRESC_W<'a> = crate::FieldWriter<'a, u32, CTRL_SPEC, u8, PRESC_A, 7, 8>;
impl<'a> PRESC_W<'a> {
#[doc = "`0`"]
#[inline(always)]
pub fn nodivision(self) -> &'a mut W {
self.variant(PRESC_A::NODIVISION)
}
}
#[doc = "Field `TIMEBASE` reader - Time Base"]
pub type TIMEBASE_R = crate::FieldReader<u8, u8>;
#[doc = "Field `TIMEBASE` writer - Time Base"]
pub type TIMEBASE_W<'a> = crate::FieldWriter<'a, u32, CTRL_SPEC, u8, u8, 5, 16>;
#[doc = "Oversample Rate Select\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(u8)]
pub enum OVSRSEL_A {
#[doc = "0: 2 samples for each conversion result"]
X2 = 0,
#[doc = "1: 4 samples for each conversion result"]
X4 = 1,
#[doc = "2: 8 samples for each conversion result"]
X8 = 2,
#[doc = "3: 16 samples for each conversion result"]
X16 = 3,
#[doc = "4: 32 samples for each conversion result"]
X32 = 4,
#[doc = "5: 64 samples for each conversion result"]
X64 = 5,
#[doc = "6: 128 samples for each conversion result"]
X128 = 6,
#[doc = "7: 256 samples for each conversion result"]
X256 = 7,
#[doc = "8: 512 samples for each conversion result"]
X512 = 8,
#[doc = "9: 1024 samples for each conversion result"]
X1024 = 9,
#[doc = "10: 2048 samples for each conversion result"]
X2048 = 10,
#[doc = "11: 4096 samples for each conversion result"]
X4096 = 11,
}
impl From<OVSRSEL_A> for u8 {
#[inline(always)]
fn from(variant: OVSRSEL_A) -> Self {
variant as _
}
}
#[doc = "Field `OVSRSEL` reader - Oversample Rate Select"]
pub type OVSRSEL_R = crate::FieldReader<u8, OVSRSEL_A>;
impl OVSRSEL_R {
#[doc = "Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> Option<OVSRSEL_A> {
match self.bits {
0 => Some(OVSRSEL_A::X2),
1 => Some(OVSRSEL_A::X4),
2 => Some(OVSRSEL_A::X8),
3 => Some(OVSRSEL_A::X16),
4 => Some(OVSRSEL_A::X32),
5 => Some(OVSRSEL_A::X64),
6 => Some(OVSRSEL_A::X128),
7 => Some(OVSRSEL_A::X256),
8 => Some(OVSRSEL_A::X512),
9 => Some(OVSRSEL_A::X1024),
10 => Some(OVSRSEL_A::X2048),
11 => Some(OVSRSEL_A::X4096),
_ => None,
}
}
#[doc = "Checks if the value of the field is `X2`"]
#[inline(always)]
pub fn is_x2(&self) -> bool {
*self == OVSRSEL_A::X2
}
#[doc = "Checks if the value of the field is `X4`"]
#[inline(always)]
pub fn is_x4(&self) -> bool {
*self == OVSRSEL_A::X4
}
#[doc = "Checks if the value of the field is `X8`"]
#[inline(always)]
pub fn is_x8(&self) -> bool {
*self == OVSRSEL_A::X8
}
#[doc = "Checks if the value of the field is `X16`"]
#[inline(always)]
pub fn is_x16(&self) -> bool {
*self == OVSRSEL_A::X16
}
#[doc = "Checks if the value of the field is `X32`"]
#[inline(always)]
pub fn is_x32(&self) -> bool {
*self == OVSRSEL_A::X32
}
#[doc = "Checks if the value of the field is `X64`"]
#[inline(always)]
pub fn is_x64(&self) -> bool {
*self == OVSRSEL_A::X64
}
#[doc = "Checks if the value of the field is `X128`"]
#[inline(always)]
pub fn is_x128(&self) -> bool {
*self == OVSRSEL_A::X128
}
#[doc = "Checks if the value of the field is `X256`"]
#[inline(always)]
pub fn is_x256(&self) -> bool {
*self == OVSRSEL_A::X256
}
#[doc = "Checks if the value of the field is `X512`"]
#[inline(always)]
pub fn is_x512(&self) -> bool {
*self == OVSRSEL_A::X512
}
#[doc = "Checks if the value of the field is `X1024`"]
#[inline(always)]
pub fn is_x1024(&self) -> bool {
*self == OVSRSEL_A::X1024
}
#[doc = "Checks if the value of the field is `X2048`"]
#[inline(always)]
pub fn is_x2048(&self) -> bool {
*self == OVSRSEL_A::X2048
}
#[doc = "Checks if the value of the field is `X4096`"]
#[inline(always)]
pub fn is_x4096(&self) -> bool {
*self == OVSRSEL_A::X4096
}
}
#[doc = "Field `OVSRSEL` writer - Oversample Rate Select"]
pub type OVSRSEL_W<'a> = crate::FieldWriter<'a, u32, CTRL_SPEC, u8, OVSRSEL_A, 4, 24>;
impl<'a> OVSRSEL_W<'a> {
#[doc = "2 samples for each conversion result"]
#[inline(always)]
pub fn x2(self) -> &'a mut W {
self.variant(OVSRSEL_A::X2)
}
#[doc = "4 samples for each conversion result"]
#[inline(always)]
pub fn x4(self) -> &'a mut W {
self.variant(OVSRSEL_A::X4)
}
#[doc = "8 samples for each conversion result"]
#[inline(always)]
pub fn x8(self) -> &'a mut W {
self.variant(OVSRSEL_A::X8)
}
#[doc = "16 samples for each conversion result"]
#[inline(always)]
pub fn x16(self) -> &'a mut W {
self.variant(OVSRSEL_A::X16)
}
#[doc = "32 samples for each conversion result"]
#[inline(always)]
pub fn x32(self) -> &'a mut W {
self.variant(OVSRSEL_A::X32)
}
#[doc = "64 samples for each conversion result"]
#[inline(always)]
pub fn x64(self) -> &'a mut W {
self.variant(OVSRSEL_A::X64)
}
#[doc = "128 samples for each conversion result"]
#[inline(always)]
pub fn x128(self) -> &'a mut W {
self.variant(OVSRSEL_A::X128)
}
#[doc = "256 samples for each conversion result"]
#[inline(always)]
pub fn x256(self) -> &'a mut W {
self.variant(OVSRSEL_A::X256)
}
#[doc = "512 samples for each conversion result"]
#[inline(always)]
pub fn x512(self) -> &'a mut W {
self.variant(OVSRSEL_A::X512)
}
#[doc = "1024 samples for each conversion result"]
#[inline(always)]
pub fn x1024(self) -> &'a mut W {
self.variant(OVSRSEL_A::X1024)
}
#[doc = "2048 samples for each conversion result"]
#[inline(always)]
pub fn x2048(self) -> &'a mut W {
self.variant(OVSRSEL_A::X2048)
}
#[doc = "4096 samples for each conversion result"]
#[inline(always)]
pub fn x4096(self) -> &'a mut W {
self.variant(OVSRSEL_A::X4096)
}
}
impl R {
#[doc = "Bits 0:1 - Warm-up Mode"]
#[inline(always)]
pub fn warmupmode(&self) -> WARMUPMODE_R {
WARMUPMODE_R::new((self.bits & 3) as u8)
}
#[doc = "Bit 3 - Conversion Tailgating"]
#[inline(always)]
pub fn tailgate(&self) -> TAILGATE_R {
TAILGATE_R::new(((self.bits >> 3) & 1) != 0)
}
#[doc = "Bits 4:5 - Low Pass Filter Mode"]
#[inline(always)]
pub fn lpfmode(&self) -> LPFMODE_R {
LPFMODE_R::new(((self.bits >> 4) & 3) as u8)
}
#[doc = "Bits 8:14 - Prescaler Setting"]
#[inline(always)]
pub fn presc(&self) -> PRESC_R {
PRESC_R::new(((self.bits >> 8) & 0x7f) as u8)
}
#[doc = "Bits 16:20 - Time Base"]
#[inline(always)]
pub fn timebase(&self) -> TIMEBASE_R {
TIMEBASE_R::new(((self.bits >> 16) & 0x1f) as u8)
}
#[doc = "Bits 24:27 - Oversample Rate Select"]
#[inline(always)]
pub fn ovsrsel(&self) -> OVSRSEL_R {
OVSRSEL_R::new(((self.bits >> 24) & 0x0f) as u8)
}
}
impl W {
#[doc = "Bits 0:1 - Warm-up Mode"]
#[inline(always)]
pub fn warmupmode(&mut self) -> WARMUPMODE_W {
WARMUPMODE_W::new(self)
}
#[doc = "Bit 3 - Conversion Tailgating"]
#[inline(always)]
pub fn tailgate(&mut self) -> TAILGATE_W {
TAILGATE_W::new(self)
}
#[doc = "Bits 4:5 - Low Pass Filter Mode"]
#[inline(always)]
pub fn lpfmode(&mut self) -> LPFMODE_W {
LPFMODE_W::new(self)
}
#[doc = "Bits 8:14 - Prescaler Setting"]
#[inline(always)]
pub fn presc(&mut self) -> PRESC_W {
PRESC_W::new(self)
}
#[doc = "Bits 16:20 - Time Base"]
#[inline(always)]
pub fn timebase(&mut self) -> TIMEBASE_W {
TIMEBASE_W::new(self)
}
#[doc = "Bits 24:27 - Oversample Rate Select"]
#[inline(always)]
pub fn ovsrsel(&mut self) -> OVSRSEL_W {
OVSRSEL_W::new(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 = "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 [ctrl](index.html) module"]
pub struct CTRL_SPEC;
impl crate::RegisterSpec for CTRL_SPEC {
type Ux = u32;
}
#[doc = "`read()` method returns [ctrl::R](R) reader structure"]
impl crate::Readable for CTRL_SPEC {
type Reader = R;
}
#[doc = "`write(|w| ..)` method takes [ctrl::W](W) writer structure"]
impl crate::Writable for CTRL_SPEC {
type Writer = W;
}
#[doc = "`reset()` method sets CTRL to value 0x001f_0000"]
impl crate::Resettable for CTRL_SPEC {
#[inline(always)]
fn reset_value() -> Self::Ux {
0x001f_0000
}
}