From 0666a6ba1dbd66cf8b93c113e362ccbcd99152a0 Mon Sep 17 00:00:00 2001 From: Arne Dußin Date: Sat, 6 Nov 2021 11:50:33 +0100 Subject: Initial commit --- src/sdadc/inputctrl.rs | 164 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 src/sdadc/inputctrl.rs (limited to 'src/sdadc/inputctrl.rs') diff --git a/src/sdadc/inputctrl.rs b/src/sdadc/inputctrl.rs new file mode 100644 index 0000000..6173a77 --- /dev/null +++ b/src/sdadc/inputctrl.rs @@ -0,0 +1,164 @@ +#[doc = "Register `INPUTCTRL` reader"] +pub struct R(crate::R); +impl core::ops::Deref for R { + type Target = crate::R; + #[inline(always)] + fn deref(&self) -> &Self::Target { + &self.0 + } +} +impl From> for R { + #[inline(always)] + fn from(reader: crate::R) -> Self { + R(reader) + } +} +#[doc = "Register `INPUTCTRL` writer"] +pub struct W(crate::W); +impl core::ops::Deref for W { + type Target = crate::W; + #[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> for W { + #[inline(always)] + fn from(writer: crate::W) -> Self { + W(writer) + } +} +#[doc = "SDADC Input Selection\n\nValue on reset: 0"] +#[derive(Clone, Copy, Debug, PartialEq)] +#[repr(u8)] +pub enum MUXSEL_A { + #[doc = "0: SDADC AIN0 Pin"] + AIN0 = 0, + #[doc = "1: SDADC AIN1 Pin"] + AIN1 = 1, + #[doc = "2: SDADC AIN2 Pin"] + AIN2 = 2, +} +impl From for u8 { + #[inline(always)] + fn from(variant: MUXSEL_A) -> Self { + variant as _ + } +} +#[doc = "Field `MUXSEL` reader - SDADC Input Selection"] +pub struct MUXSEL_R(crate::FieldReader); +impl MUXSEL_R { + pub(crate) fn new(bits: u8) -> Self { + MUXSEL_R(crate::FieldReader::new(bits)) + } + #[doc = r"Get enumerated values variant"] + #[inline(always)] + pub fn variant(&self) -> Option { + match self.bits { + 0 => Some(MUXSEL_A::AIN0), + 1 => Some(MUXSEL_A::AIN1), + 2 => Some(MUXSEL_A::AIN2), + _ => None, + } + } + #[doc = "Checks if the value of the field is `AIN0`"] + #[inline(always)] + pub fn is_ain0(&self) -> bool { + **self == MUXSEL_A::AIN0 + } + #[doc = "Checks if the value of the field is `AIN1`"] + #[inline(always)] + pub fn is_ain1(&self) -> bool { + **self == MUXSEL_A::AIN1 + } + #[doc = "Checks if the value of the field is `AIN2`"] + #[inline(always)] + pub fn is_ain2(&self) -> bool { + **self == MUXSEL_A::AIN2 + } +} +impl core::ops::Deref for MUXSEL_R { + type Target = crate::FieldReader; + #[inline(always)] + fn deref(&self) -> &Self::Target { + &self.0 + } +} +#[doc = "Field `MUXSEL` writer - SDADC Input Selection"] +pub struct MUXSEL_W<'a> { + w: &'a mut W, +} +impl<'a> MUXSEL_W<'a> { + #[doc = r"Writes `variant` to the field"] + #[inline(always)] + pub fn variant(self, variant: MUXSEL_A) -> &'a mut W { + unsafe { self.bits(variant.into()) } + } + #[doc = "SDADC AIN0 Pin"] + #[inline(always)] + pub fn ain0(self) -> &'a mut W { + self.variant(MUXSEL_A::AIN0) + } + #[doc = "SDADC AIN1 Pin"] + #[inline(always)] + pub fn ain1(self) -> &'a mut W { + self.variant(MUXSEL_A::AIN1) + } + #[doc = "SDADC AIN2 Pin"] + #[inline(always)] + pub fn ain2(self) -> &'a mut W { + self.variant(MUXSEL_A::AIN2) + } + #[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 & !0x0f) | (value as u8 & 0x0f); + self.w + } +} +impl R { + #[doc = "Bits 0:3 - SDADC Input Selection"] + #[inline(always)] + pub fn muxsel(&self) -> MUXSEL_R { + MUXSEL_R::new((self.bits & 0x0f) as u8) + } +} +impl W { + #[doc = "Bits 0:3 - SDADC Input Selection"] + #[inline(always)] + pub fn muxsel(&mut self) -> MUXSEL_W { + MUXSEL_W { w: self } + } + #[doc = "Writes raw bits to the register."] + #[inline(always)] + pub unsafe fn bits(&mut self, bits: u8) -> &mut Self { + self.0.bits(bits); + self + } +} +#[doc = "Input Control\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 [inputctrl](index.html) module"] +pub struct INPUTCTRL_SPEC; +impl crate::RegisterSpec for INPUTCTRL_SPEC { + type Ux = u8; +} +#[doc = "`read()` method returns [inputctrl::R](R) reader structure"] +impl crate::Readable for INPUTCTRL_SPEC { + type Reader = R; +} +#[doc = "`write(|w| ..)` method takes [inputctrl::W](W) writer structure"] +impl crate::Writable for INPUTCTRL_SPEC { + type Writer = W; +} +#[doc = "`reset()` method sets INPUTCTRL to value 0"] +impl crate::Resettable for INPUTCTRL_SPEC { + #[inline(always)] + fn reset_value() -> Self::Ux { + 0 + } +} -- cgit v1.2.3-70-g09d2