#[doc = "Reader of register CCR"]
pub type R = crate::R<u32, super::CCR>;
#[doc = "Writer for register CCR"]
pub type W = crate::W<u32, super::CCR>;
#[doc = "Register CCR `reset()`'s with value 0"]
impl crate::ResetValue for super::CCR {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Type {
0
}
}
#[doc = "Dual ADC mode selection\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(u8)]
pub enum DUAL_A {
#[doc = "0: Independent mode"]
INDEPENDENT = 0,
#[doc = "1: Dual, combined regular simultaneous + injected simultaneous mode"]
DUALRJ = 1,
#[doc = "2: Dual, combined regular simultaneous + alternate trigger mode"]
DUALRA = 2,
#[doc = "3: Dual, combined interleaved mode + injected simultaneous mode"]
DUALIJ = 3,
#[doc = "5: Dual, injected simultaneous mode only"]
DUALJ = 5,
#[doc = "6: Dual, regular simultaneous mode only"]
DUALR = 6,
#[doc = "7: Dual, interleaved mode only"]
DUALI = 7,
#[doc = "9: Dual, alternate trigger mode only"]
DUALA = 9,
}
impl From<DUAL_A> for u8 {
#[inline(always)]
fn from(variant: DUAL_A) -> Self {
variant as _
}
}
#[doc = "Reader of field `DUAL`"]
pub type DUAL_R = crate::R<u8, DUAL_A>;
impl DUAL_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> crate::Variant<u8, DUAL_A> {
use crate::Variant::*;
match self.bits {
0 => Val(DUAL_A::INDEPENDENT),
1 => Val(DUAL_A::DUALRJ),
2 => Val(DUAL_A::DUALRA),
3 => Val(DUAL_A::DUALIJ),
5 => Val(DUAL_A::DUALJ),
6 => Val(DUAL_A::DUALR),
7 => Val(DUAL_A::DUALI),
9 => Val(DUAL_A::DUALA),
i => Res(i),
}
}
#[doc = "Checks if the value of the field is `INDEPENDENT`"]
#[inline(always)]
pub fn is_independent(&self) -> bool {
*self == DUAL_A::INDEPENDENT
}
#[doc = "Checks if the value of the field is `DUALRJ`"]
#[inline(always)]
pub fn is_dual_rj(&self) -> bool {
*self == DUAL_A::DUALRJ
}
#[doc = "Checks if the value of the field is `DUALRA`"]
#[inline(always)]
pub fn is_dual_ra(&self) -> bool {
*self == DUAL_A::DUALRA
}
#[doc = "Checks if the value of the field is `DUALIJ`"]
#[inline(always)]
pub fn is_dual_ij(&self) -> bool {
*self == DUAL_A::DUALIJ
}
#[doc = "Checks if the value of the field is `DUALJ`"]
#[inline(always)]
pub fn is_dual_j(&self) -> bool {
*self == DUAL_A::DUALJ
}
#[doc = "Checks if the value of the field is `DUALR`"]
#[inline(always)]
pub fn is_dual_r(&self) -> bool {
*self == DUAL_A::DUALR
}
#[doc = "Checks if the value of the field is `DUALI`"]
#[inline(always)]
pub fn is_dual_i(&self) -> bool {
*self == DUAL_A::DUALI
}
#[doc = "Checks if the value of the field is `DUALA`"]
#[inline(always)]
pub fn is_dual_a(&self) -> bool {
*self == DUAL_A::DUALA
}
}
#[doc = "Write proxy for field `DUAL`"]
pub struct DUAL_W<'a> {
w: &'a mut W,
}
impl<'a> DUAL_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: DUAL_A) -> &'a mut W {
unsafe { self.bits(variant.into()) }
}
#[doc = "Independent mode"]
#[inline(always)]
pub fn independent(self) -> &'a mut W {
self.variant(DUAL_A::INDEPENDENT)
}
#[doc = "Dual, combined regular simultaneous + injected simultaneous mode"]
#[inline(always)]
pub fn dual_rj(self) -> &'a mut W {
self.variant(DUAL_A::DUALRJ)
}
#[doc = "Dual, combined regular simultaneous + alternate trigger mode"]
#[inline(always)]
pub fn dual_ra(self) -> &'a mut W {
self.variant(DUAL_A::DUALRA)
}
#[doc = "Dual, combined interleaved mode + injected simultaneous mode"]
#[inline(always)]
pub fn dual_ij(self) -> &'a mut W {
self.variant(DUAL_A::DUALIJ)
}
#[doc = "Dual, injected simultaneous mode only"]
#[inline(always)]
pub fn dual_j(self) -> &'a mut W {
self.variant(DUAL_A::DUALJ)
}
#[doc = "Dual, regular simultaneous mode only"]
#[inline(always)]
pub fn dual_r(self) -> &'a mut W {
self.variant(DUAL_A::DUALR)
}
#[doc = "Dual, interleaved mode only"]
#[inline(always)]
pub fn dual_i(self) -> &'a mut W {
self.variant(DUAL_A::DUALI)
}
#[doc = "Dual, alternate trigger mode only"]
#[inline(always)]
pub fn dual_a(self) -> &'a mut W {
self.variant(DUAL_A::DUALA)
}
#[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 = "Reader of field `DELAY`"]
pub type DELAY_R = crate::R<u8, u8>;
#[doc = "Write proxy for field `DELAY`"]
pub struct DELAY_W<'a> {
w: &'a mut W,
}
impl<'a> DELAY_W<'a> {
#[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 & !(0x0f << 8)) | (((value as u32) & 0x0f) << 8);
self.w
}
}
#[doc = "Dual ADC Mode Data Format\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(u8)]
pub enum DAMDF_A {
#[doc = "0: Without data packing, CDR/CDR2 not used"]
NOPACK = 0,
#[doc = "2: CDR formatted for 32-bit down to 10-bit resolution"]
FORMAT32TO10 = 2,
#[doc = "3: CDR formatted for 8-bit resolution"]
FORMAT8 = 3,
}
impl From<DAMDF_A> for u8 {
#[inline(always)]
fn from(variant: DAMDF_A) -> Self {
variant as _
}
}
#[doc = "Reader of field `DAMDF`"]
pub type DAMDF_R = crate::R<u8, DAMDF_A>;
impl DAMDF_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> crate::Variant<u8, DAMDF_A> {
use crate::Variant::*;
match self.bits {
0 => Val(DAMDF_A::NOPACK),
2 => Val(DAMDF_A::FORMAT32TO10),
3 => Val(DAMDF_A::FORMAT8),
i => Res(i),
}
}
#[doc = "Checks if the value of the field is `NOPACK`"]
#[inline(always)]
pub fn is_no_pack(&self) -> bool {
*self == DAMDF_A::NOPACK
}
#[doc = "Checks if the value of the field is `FORMAT32TO10`"]
#[inline(always)]
pub fn is_format32to10(&self) -> bool {
*self == DAMDF_A::FORMAT32TO10
}
#[doc = "Checks if the value of the field is `FORMAT8`"]
#[inline(always)]
pub fn is_format8(&self) -> bool {
*self == DAMDF_A::FORMAT8
}
}
#[doc = "Write proxy for field `DAMDF`"]
pub struct DAMDF_W<'a> {
w: &'a mut W,
}
impl<'a> DAMDF_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: DAMDF_A) -> &'a mut W {
unsafe { self.bits(variant.into()) }
}
#[doc = "Without data packing, CDR/CDR2 not used"]
#[inline(always)]
pub fn no_pack(self) -> &'a mut W {
self.variant(DAMDF_A::NOPACK)
}
#[doc = "CDR formatted for 32-bit down to 10-bit resolution"]
#[inline(always)]
pub fn format32to10(self) -> &'a mut W {
self.variant(DAMDF_A::FORMAT32TO10)
}
#[doc = "CDR formatted for 8-bit resolution"]
#[inline(always)]
pub fn format8(self) -> &'a mut W {
self.variant(DAMDF_A::FORMAT8)
}
#[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 << 14)) | (((value as u32) & 0x03) << 14);
self.w
}
}
#[doc = "ADC clock mode\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(u8)]
pub enum CKMODE_A {
#[doc = "0: Use Kernel Clock adc_ker_ck_input divided by PRESC. Asynchronous to AHB clock"]
ASYNCHRONOUS = 0,
#[doc = "1: Use AHB clock rcc_hclk3. In this case rcc_hclk must equal sys_d1cpre_ck"]
SYNCDIV1 = 1,
#[doc = "2: Use AHB clock rcc_hclk3 divided by 2"]
SYNCDIV2 = 2,
#[doc = "3: Use AHB clock rcc_hclk3 divided by 4"]
SYNCDIV4 = 3,
}
impl From<CKMODE_A> for u8 {
#[inline(always)]
fn from(variant: CKMODE_A) -> Self {
variant as _
}
}
#[doc = "Reader of field `CKMODE`"]
pub type CKMODE_R = crate::R<u8, CKMODE_A>;
impl CKMODE_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> CKMODE_A {
match self.bits {
0 => CKMODE_A::ASYNCHRONOUS,
1 => CKMODE_A::SYNCDIV1,
2 => CKMODE_A::SYNCDIV2,
3 => CKMODE_A::SYNCDIV4,
_ => unreachable!(),
}
}
#[doc = "Checks if the value of the field is `ASYNCHRONOUS`"]
#[inline(always)]
pub fn is_asynchronous(&self) -> bool {
*self == CKMODE_A::ASYNCHRONOUS
}
#[doc = "Checks if the value of the field is `SYNCDIV1`"]
#[inline(always)]
pub fn is_sync_div1(&self) -> bool {
*self == CKMODE_A::SYNCDIV1
}
#[doc = "Checks if the value of the field is `SYNCDIV2`"]
#[inline(always)]
pub fn is_sync_div2(&self) -> bool {
*self == CKMODE_A::SYNCDIV2
}
#[doc = "Checks if the value of the field is `SYNCDIV4`"]
#[inline(always)]
pub fn is_sync_div4(&self) -> bool {
*self == CKMODE_A::SYNCDIV4
}
}
#[doc = "Write proxy for field `CKMODE`"]
pub struct CKMODE_W<'a> {
w: &'a mut W,
}
impl<'a> CKMODE_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: CKMODE_A) -> &'a mut W {
{
self.bits(variant.into())
}
}
#[doc = "Use Kernel Clock adc_ker_ck_input divided by PRESC. Asynchronous to AHB clock"]
#[inline(always)]
pub fn asynchronous(self) -> &'a mut W {
self.variant(CKMODE_A::ASYNCHRONOUS)
}
#[doc = "Use AHB clock rcc_hclk3. In this case rcc_hclk must equal sys_d1cpre_ck"]
#[inline(always)]
pub fn sync_div1(self) -> &'a mut W {
self.variant(CKMODE_A::SYNCDIV1)
}
#[doc = "Use AHB clock rcc_hclk3 divided by 2"]
#[inline(always)]
pub fn sync_div2(self) -> &'a mut W {
self.variant(CKMODE_A::SYNCDIV2)
}
#[doc = "Use AHB clock rcc_hclk3 divided by 4"]
#[inline(always)]
pub fn sync_div4(self) -> &'a mut W {
self.variant(CKMODE_A::SYNCDIV4)
}
#[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 << 16)) | (((value as u32) & 0x03) << 16);
self.w
}
}
#[doc = "ADC prescaler\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(u8)]
pub enum PRESC_A {
#[doc = "0: adc_ker_ck_input not divided"]
DIV1 = 0,
#[doc = "1: adc_ker_ck_input divided by 2"]
DIV2 = 1,
#[doc = "2: adc_ker_ck_input divided by 4"]
DIV4 = 2,
#[doc = "3: adc_ker_ck_input divided by 6"]
DIV6 = 3,
#[doc = "4: adc_ker_ck_input divided by 8"]
DIV8 = 4,
#[doc = "5: adc_ker_ck_input divided by 10"]
DIV10 = 5,
#[doc = "6: adc_ker_ck_input divided by 12"]
DIV12 = 6,
#[doc = "7: adc_ker_ck_input divided by 16"]
DIV16 = 7,
#[doc = "8: adc_ker_ck_input divided by 32"]
DIV32 = 8,
#[doc = "9: adc_ker_ck_input divided by 64"]
DIV64 = 9,
#[doc = "10: adc_ker_ck_input divided by 128"]
DIV128 = 10,
#[doc = "11: adc_ker_ck_input divided by 256"]
DIV256 = 11,
}
impl From<PRESC_A> for u8 {
#[inline(always)]
fn from(variant: PRESC_A) -> Self {
variant as _
}
}
#[doc = "Reader of field `PRESC`"]
pub type PRESC_R = crate::R<u8, PRESC_A>;
impl PRESC_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> crate::Variant<u8, PRESC_A> {
use crate::Variant::*;
match self.bits {
0 => Val(PRESC_A::DIV1),
1 => Val(PRESC_A::DIV2),
2 => Val(PRESC_A::DIV4),
3 => Val(PRESC_A::DIV6),
4 => Val(PRESC_A::DIV8),
5 => Val(PRESC_A::DIV10),
6 => Val(PRESC_A::DIV12),
7 => Val(PRESC_A::DIV16),
8 => Val(PRESC_A::DIV32),
9 => Val(PRESC_A::DIV64),
10 => Val(PRESC_A::DIV128),
11 => Val(PRESC_A::DIV256),
i => Res(i),
}
}
#[doc = "Checks if the value of the field is `DIV1`"]
#[inline(always)]
pub fn is_div1(&self) -> bool {
*self == PRESC_A::DIV1
}
#[doc = "Checks if the value of the field is `DIV2`"]
#[inline(always)]
pub fn is_div2(&self) -> bool {
*self == PRESC_A::DIV2
}
#[doc = "Checks if the value of the field is `DIV4`"]
#[inline(always)]
pub fn is_div4(&self) -> bool {
*self == PRESC_A::DIV4
}
#[doc = "Checks if the value of the field is `DIV6`"]
#[inline(always)]
pub fn is_div6(&self) -> bool {
*self == PRESC_A::DIV6
}
#[doc = "Checks if the value of the field is `DIV8`"]
#[inline(always)]
pub fn is_div8(&self) -> bool {
*self == PRESC_A::DIV8
}
#[doc = "Checks if the value of the field is `DIV10`"]
#[inline(always)]
pub fn is_div10(&self) -> bool {
*self == PRESC_A::DIV10
}
#[doc = "Checks if the value of the field is `DIV12`"]
#[inline(always)]
pub fn is_div12(&self) -> bool {
*self == PRESC_A::DIV12
}
#[doc = "Checks if the value of the field is `DIV16`"]
#[inline(always)]
pub fn is_div16(&self) -> bool {
*self == PRESC_A::DIV16
}
#[doc = "Checks if the value of the field is `DIV32`"]
#[inline(always)]
pub fn is_div32(&self) -> bool {
*self == PRESC_A::DIV32
}
#[doc = "Checks if the value of the field is `DIV64`"]
#[inline(always)]
pub fn is_div64(&self) -> bool {
*self == PRESC_A::DIV64
}
#[doc = "Checks if the value of the field is `DIV128`"]
#[inline(always)]
pub fn is_div128(&self) -> bool {
*self == PRESC_A::DIV128
}
#[doc = "Checks if the value of the field is `DIV256`"]
#[inline(always)]
pub fn is_div256(&self) -> bool {
*self == PRESC_A::DIV256
}
}
#[doc = "Write proxy for field `PRESC`"]
pub struct PRESC_W<'a> {
w: &'a mut W,
}
impl<'a> PRESC_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: PRESC_A) -> &'a mut W {
unsafe { self.bits(variant.into()) }
}
#[doc = "adc_ker_ck_input not divided"]
#[inline(always)]
pub fn div1(self) -> &'a mut W {
self.variant(PRESC_A::DIV1)
}
#[doc = "adc_ker_ck_input divided by 2"]
#[inline(always)]
pub fn div2(self) -> &'a mut W {
self.variant(PRESC_A::DIV2)
}
#[doc = "adc_ker_ck_input divided by 4"]
#[inline(always)]
pub fn div4(self) -> &'a mut W {
self.variant(PRESC_A::DIV4)
}
#[doc = "adc_ker_ck_input divided by 6"]
#[inline(always)]
pub fn div6(self) -> &'a mut W {
self.variant(PRESC_A::DIV6)
}
#[doc = "adc_ker_ck_input divided by 8"]
#[inline(always)]
pub fn div8(self) -> &'a mut W {
self.variant(PRESC_A::DIV8)
}
#[doc = "adc_ker_ck_input divided by 10"]
#[inline(always)]
pub fn div10(self) -> &'a mut W {
self.variant(PRESC_A::DIV10)
}
#[doc = "adc_ker_ck_input divided by 12"]
#[inline(always)]
pub fn div12(self) -> &'a mut W {
self.variant(PRESC_A::DIV12)
}
#[doc = "adc_ker_ck_input divided by 16"]
#[inline(always)]
pub fn div16(self) -> &'a mut W {
self.variant(PRESC_A::DIV16)
}
#[doc = "adc_ker_ck_input divided by 32"]
#[inline(always)]
pub fn div32(self) -> &'a mut W {
self.variant(PRESC_A::DIV32)
}
#[doc = "adc_ker_ck_input divided by 64"]
#[inline(always)]
pub fn div64(self) -> &'a mut W {
self.variant(PRESC_A::DIV64)
}
#[doc = "adc_ker_ck_input divided by 128"]
#[inline(always)]
pub fn div128(self) -> &'a mut W {
self.variant(PRESC_A::DIV128)
}
#[doc = "adc_ker_ck_input divided by 256"]
#[inline(always)]
pub fn div256(self) -> &'a mut W {
self.variant(PRESC_A::DIV256)
}
#[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 << 18)) | (((value as u32) & 0x0f) << 18);
self.w
}
}
#[doc = "VREFINT enable\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum VREFEN_A {
#[doc = "0: V_REFINT channel disabled"]
DISABLED = 0,
#[doc = "1: V_REFINT channel enabled"]
ENABLED = 1,
}
impl From<VREFEN_A> for bool {
#[inline(always)]
fn from(variant: VREFEN_A) -> Self {
variant as u8 != 0
}
}
#[doc = "Reader of field `VREFEN`"]
pub type VREFEN_R = crate::R<bool, VREFEN_A>;
impl VREFEN_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> VREFEN_A {
match self.bits {
false => VREFEN_A::DISABLED,
true => VREFEN_A::ENABLED,
}
}
#[doc = "Checks if the value of the field is `DISABLED`"]
#[inline(always)]
pub fn is_disabled(&self) -> bool {
*self == VREFEN_A::DISABLED
}
#[doc = "Checks if the value of the field is `ENABLED`"]
#[inline(always)]
pub fn is_enabled(&self) -> bool {
*self == VREFEN_A::ENABLED
}
}
#[doc = "Write proxy for field `VREFEN`"]
pub struct VREFEN_W<'a> {
w: &'a mut W,
}
impl<'a> VREFEN_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: VREFEN_A) -> &'a mut W {
{
self.bit(variant.into())
}
}
#[doc = "V_REFINT channel disabled"]
#[inline(always)]
pub fn disabled(self) -> &'a mut W {
self.variant(VREFEN_A::DISABLED)
}
#[doc = "V_REFINT channel enabled"]
#[inline(always)]
pub fn enabled(self) -> &'a mut W {
self.variant(VREFEN_A::ENABLED)
}
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 22)) | (((value as u32) & 0x01) << 22);
self.w
}
}
#[doc = "Temperature sensor enable\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum VSENSEEN_A {
#[doc = "0: Temperature sensor channel disabled"]
DISABLED = 0,
#[doc = "1: Temperature sensor channel enabled"]
ENABLED = 1,
}
impl From<VSENSEEN_A> for bool {
#[inline(always)]
fn from(variant: VSENSEEN_A) -> Self {
variant as u8 != 0
}
}
#[doc = "Reader of field `VSENSEEN`"]
pub type VSENSEEN_R = crate::R<bool, VSENSEEN_A>;
impl VSENSEEN_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> VSENSEEN_A {
match self.bits {
false => VSENSEEN_A::DISABLED,
true => VSENSEEN_A::ENABLED,
}
}
#[doc = "Checks if the value of the field is `DISABLED`"]
#[inline(always)]
pub fn is_disabled(&self) -> bool {
*self == VSENSEEN_A::DISABLED
}
#[doc = "Checks if the value of the field is `ENABLED`"]
#[inline(always)]
pub fn is_enabled(&self) -> bool {
*self == VSENSEEN_A::ENABLED
}
}
#[doc = "Write proxy for field `VSENSEEN`"]
pub struct VSENSEEN_W<'a> {
w: &'a mut W,
}
impl<'a> VSENSEEN_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: VSENSEEN_A) -> &'a mut W {
{
self.bit(variant.into())
}
}
#[doc = "Temperature sensor channel disabled"]
#[inline(always)]
pub fn disabled(self) -> &'a mut W {
self.variant(VSENSEEN_A::DISABLED)
}
#[doc = "Temperature sensor channel enabled"]
#[inline(always)]
pub fn enabled(self) -> &'a mut W {
self.variant(VSENSEEN_A::ENABLED)
}
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 23)) | (((value as u32) & 0x01) << 23);
self.w
}
}
#[doc = "VBAT enable\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum VBATEN_A {
#[doc = "0: V_BAT channel disabled"]
DISABLED = 0,
#[doc = "1: V_BAT channel enabled"]
ENABLED = 1,
}
impl From<VBATEN_A> for bool {
#[inline(always)]
fn from(variant: VBATEN_A) -> Self {
variant as u8 != 0
}
}
#[doc = "Reader of field `VBATEN`"]
pub type VBATEN_R = crate::R<bool, VBATEN_A>;
impl VBATEN_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> VBATEN_A {
match self.bits {
false => VBATEN_A::DISABLED,
true => VBATEN_A::ENABLED,
}
}
#[doc = "Checks if the value of the field is `DISABLED`"]
#[inline(always)]
pub fn is_disabled(&self) -> bool {
*self == VBATEN_A::DISABLED
}
#[doc = "Checks if the value of the field is `ENABLED`"]
#[inline(always)]
pub fn is_enabled(&self) -> bool {
*self == VBATEN_A::ENABLED
}
}
#[doc = "Write proxy for field `VBATEN`"]
pub struct VBATEN_W<'a> {
w: &'a mut W,
}
impl<'a> VBATEN_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: VBATEN_A) -> &'a mut W {
{
self.bit(variant.into())
}
}
#[doc = "V_BAT channel disabled"]
#[inline(always)]
pub fn disabled(self) -> &'a mut W {
self.variant(VBATEN_A::DISABLED)
}
#[doc = "V_BAT channel enabled"]
#[inline(always)]
pub fn enabled(self) -> &'a mut W {
self.variant(VBATEN_A::ENABLED)
}
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 24)) | (((value as u32) & 0x01) << 24);
self.w
}
}
impl R {
#[doc = "Bits 0:4 - Dual ADC mode selection"]
#[inline(always)]
pub fn dual(&self) -> DUAL_R {
DUAL_R::new((self.bits & 0x1f) as u8)
}
#[doc = "Bits 8:11 - Delay between 2 sampling phases"]
#[inline(always)]
pub fn delay(&self) -> DELAY_R {
DELAY_R::new(((self.bits >> 8) & 0x0f) as u8)
}
#[doc = "Bits 14:15 - Dual ADC Mode Data Format"]
#[inline(always)]
pub fn damdf(&self) -> DAMDF_R {
DAMDF_R::new(((self.bits >> 14) & 0x03) as u8)
}
#[doc = "Bits 16:17 - ADC clock mode"]
#[inline(always)]
pub fn ckmode(&self) -> CKMODE_R {
CKMODE_R::new(((self.bits >> 16) & 0x03) as u8)
}
#[doc = "Bits 18:21 - ADC prescaler"]
#[inline(always)]
pub fn presc(&self) -> PRESC_R {
PRESC_R::new(((self.bits >> 18) & 0x0f) as u8)
}
#[doc = "Bit 22 - VREFINT enable"]
#[inline(always)]
pub fn vrefen(&self) -> VREFEN_R {
VREFEN_R::new(((self.bits >> 22) & 0x01) != 0)
}
#[doc = "Bit 23 - Temperature sensor enable"]
#[inline(always)]
pub fn vsenseen(&self) -> VSENSEEN_R {
VSENSEEN_R::new(((self.bits >> 23) & 0x01) != 0)
}
#[doc = "Bit 24 - VBAT enable"]
#[inline(always)]
pub fn vbaten(&self) -> VBATEN_R {
VBATEN_R::new(((self.bits >> 24) & 0x01) != 0)
}
}
impl W {
#[doc = "Bits 0:4 - Dual ADC mode selection"]
#[inline(always)]
pub fn dual(&mut self) -> DUAL_W {
DUAL_W { w: self }
}
#[doc = "Bits 8:11 - Delay between 2 sampling phases"]
#[inline(always)]
pub fn delay(&mut self) -> DELAY_W {
DELAY_W { w: self }
}
#[doc = "Bits 14:15 - Dual ADC Mode Data Format"]
#[inline(always)]
pub fn damdf(&mut self) -> DAMDF_W {
DAMDF_W { w: self }
}
#[doc = "Bits 16:17 - ADC clock mode"]
#[inline(always)]
pub fn ckmode(&mut self) -> CKMODE_W {
CKMODE_W { w: self }
}
#[doc = "Bits 18:21 - ADC prescaler"]
#[inline(always)]
pub fn presc(&mut self) -> PRESC_W {
PRESC_W { w: self }
}
#[doc = "Bit 22 - VREFINT enable"]
#[inline(always)]
pub fn vrefen(&mut self) -> VREFEN_W {
VREFEN_W { w: self }
}
#[doc = "Bit 23 - Temperature sensor enable"]
#[inline(always)]
pub fn vsenseen(&mut self) -> VSENSEEN_W {
VSENSEEN_W { w: self }
}
#[doc = "Bit 24 - VBAT enable"]
#[inline(always)]
pub fn vbaten(&mut self) -> VBATEN_W {
VBATEN_W { w: self }
}
}