#[doc = "Reader of register CR1"]
pub type R = crate::R<u8, super::CR1>;
#[doc = "Writer for register CR1"]
pub type W = crate::W<u8, super::CR1>;
#[doc = "Register CR1 `reset()`'s with value 0"]
impl crate::ResetValue for super::CR1 {
type Type = u8;
#[inline(always)]
fn reset_value() -> Self::Type {
0
}
}
#[doc = "Possible values of the field `EN`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum EN_A {
#[doc = "Analog Comparator is disabled."]
_0,
#[doc = "Analog Comparator is enabled."]
_1,
}
impl crate::ToBits<bool> for EN_A {
#[inline(always)]
fn _bits(&self) -> bool {
match *self {
EN_A::_0 => false,
EN_A::_1 => true,
}
}
}
#[doc = "Reader of field `EN`"]
pub type EN_R = crate::R<bool, EN_A>;
impl EN_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> EN_A {
match self.bits {
false => EN_A::_0,
true => EN_A::_1,
}
}
#[doc = "Checks if the value of the field is `_0`"]
#[inline(always)]
pub fn is_0(&self) -> bool {
*self == EN_A::_0
}
#[doc = "Checks if the value of the field is `_1`"]
#[inline(always)]
pub fn is_1(&self) -> bool {
*self == EN_A::_1
}
}
#[doc = "Write proxy for field `EN`"]
pub struct EN_W<'a> {
w: &'a mut W,
}
impl<'a> EN_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: EN_A) -> &'a mut W {
use crate::ToBits;
{
self.bit(variant._bits())
}
}
#[doc = "Analog Comparator is disabled."]
#[inline(always)]
pub fn _0(self) -> &'a mut W {
self.variant(EN_A::_0)
}
#[doc = "Analog Comparator is enabled."]
#[inline(always)]
pub fn _1(self) -> &'a mut W {
self.variant(EN_A::_1)
}
#[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) | ((value as u8) & 0x01);
self.w
}
}
#[doc = "Possible values of the field `OPE`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum OPE_A {
#[doc = "CMPO is not available on the associated CMPO output pin. If the comparator does not own the pin, this field has no effect."]
_0,
#[doc = "CMPO is available on the associated CMPO output pin. The comparator output (CMPO) is driven out on the associated CMPO output pin if the comparator owns the pin. If the comparator does not own the field, this bit has no effect."]
_1,
}
impl crate::ToBits<bool> for OPE_A {
#[inline(always)]
fn _bits(&self) -> bool {
match *self {
OPE_A::_0 => false,
OPE_A::_1 => true,
}
}
}
#[doc = "Reader of field `OPE`"]
pub type OPE_R = crate::R<bool, OPE_A>;
impl OPE_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> OPE_A {
match self.bits {
false => OPE_A::_0,
true => OPE_A::_1,
}
}
#[doc = "Checks if the value of the field is `_0`"]
#[inline(always)]
pub fn is_0(&self) -> bool {
*self == OPE_A::_0
}
#[doc = "Checks if the value of the field is `_1`"]
#[inline(always)]
pub fn is_1(&self) -> bool {
*self == OPE_A::_1
}
}
#[doc = "Write proxy for field `OPE`"]
pub struct OPE_W<'a> {
w: &'a mut W,
}
impl<'a> OPE_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: OPE_A) -> &'a mut W {
use crate::ToBits;
{
self.bit(variant._bits())
}
}
#[doc = "CMPO is not available on the associated CMPO output pin. If the comparator does not own the pin, this field has no effect."]
#[inline(always)]
pub fn _0(self) -> &'a mut W {
self.variant(OPE_A::_0)
}
#[doc = "CMPO is available on the associated CMPO output pin. The comparator output (CMPO) is driven out on the associated CMPO output pin if the comparator owns the pin. If the comparator does not own the field, this bit has no effect."]
#[inline(always)]
pub fn _1(self) -> &'a mut W {
self.variant(OPE_A::_1)
}
#[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 << 1)) | (((value as u8) & 0x01) << 1);
self.w
}
}
#[doc = "Possible values of the field `COS`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum COS_A {
#[doc = "Set the filtered comparator output (CMPO) to equal COUT."]
_0,
#[doc = "Set the unfiltered comparator output (CMPO) to equal COUTA."]
_1,
}
impl crate::ToBits<bool> for COS_A {
#[inline(always)]
fn _bits(&self) -> bool {
match *self {
COS_A::_0 => false,
COS_A::_1 => true,
}
}
}
#[doc = "Reader of field `COS`"]
pub type COS_R = crate::R<bool, COS_A>;
impl COS_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> COS_A {
match self.bits {
false => COS_A::_0,
true => COS_A::_1,
}
}
#[doc = "Checks if the value of the field is `_0`"]
#[inline(always)]
pub fn is_0(&self) -> bool {
*self == COS_A::_0
}
#[doc = "Checks if the value of the field is `_1`"]
#[inline(always)]
pub fn is_1(&self) -> bool {
*self == COS_A::_1
}
}
#[doc = "Write proxy for field `COS`"]
pub struct COS_W<'a> {
w: &'a mut W,
}
impl<'a> COS_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: COS_A) -> &'a mut W {
use crate::ToBits;
{
self.bit(variant._bits())
}
}
#[doc = "Set the filtered comparator output (CMPO) to equal COUT."]
#[inline(always)]
pub fn _0(self) -> &'a mut W {
self.variant(COS_A::_0)
}
#[doc = "Set the unfiltered comparator output (CMPO) to equal COUTA."]
#[inline(always)]
pub fn _1(self) -> &'a mut W {
self.variant(COS_A::_1)
}
#[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 << 2)) | (((value as u8) & 0x01) << 2);
self.w
}
}
#[doc = "Possible values of the field `INV`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum INV_A {
#[doc = "Does not invert the comparator output."]
_0,
#[doc = "Inverts the comparator output."]
_1,
}
impl crate::ToBits<bool> for INV_A {
#[inline(always)]
fn _bits(&self) -> bool {
match *self {
INV_A::_0 => false,
INV_A::_1 => true,
}
}
}
#[doc = "Reader of field `INV`"]
pub type INV_R = crate::R<bool, INV_A>;
impl INV_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> INV_A {
match self.bits {
false => INV_A::_0,
true => INV_A::_1,
}
}
#[doc = "Checks if the value of the field is `_0`"]
#[inline(always)]
pub fn is_0(&self) -> bool {
*self == INV_A::_0
}
#[doc = "Checks if the value of the field is `_1`"]
#[inline(always)]
pub fn is_1(&self) -> bool {
*self == INV_A::_1
}
}
#[doc = "Write proxy for field `INV`"]
pub struct INV_W<'a> {
w: &'a mut W,
}
impl<'a> INV_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: INV_A) -> &'a mut W {
use crate::ToBits;
{
self.bit(variant._bits())
}
}
#[doc = "Does not invert the comparator output."]
#[inline(always)]
pub fn _0(self) -> &'a mut W {
self.variant(INV_A::_0)
}
#[doc = "Inverts the comparator output."]
#[inline(always)]
pub fn _1(self) -> &'a mut W {
self.variant(INV_A::_1)
}
#[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 << 3)) | (((value as u8) & 0x01) << 3);
self.w
}
}
#[doc = "Possible values of the field `PMODE`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum PMODE_A {
#[doc = "Low-Speed (LS) Comparison mode selected. In this mode, CMP has slower output propagation delay and lower current consumption."]
_0,
#[doc = "High-Speed (HS) Comparison mode selected. In this mode, CMP has faster output propagation delay and higher current consumption."]
_1,
}
impl crate::ToBits<bool> for PMODE_A {
#[inline(always)]
fn _bits(&self) -> bool {
match *self {
PMODE_A::_0 => false,
PMODE_A::_1 => true,
}
}
}
#[doc = "Reader of field `PMODE`"]
pub type PMODE_R = crate::R<bool, PMODE_A>;
impl PMODE_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> PMODE_A {
match self.bits {
false => PMODE_A::_0,
true => PMODE_A::_1,
}
}
#[doc = "Checks if the value of the field is `_0`"]
#[inline(always)]
pub fn is_0(&self) -> bool {
*self == PMODE_A::_0
}
#[doc = "Checks if the value of the field is `_1`"]
#[inline(always)]
pub fn is_1(&self) -> bool {
*self == PMODE_A::_1
}
}
#[doc = "Write proxy for field `PMODE`"]
pub struct PMODE_W<'a> {
w: &'a mut W,
}
impl<'a> PMODE_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: PMODE_A) -> &'a mut W {
use crate::ToBits;
{
self.bit(variant._bits())
}
}
#[doc = "Low-Speed (LS) Comparison mode selected. In this mode, CMP has slower output propagation delay and lower current consumption."]
#[inline(always)]
pub fn _0(self) -> &'a mut W {
self.variant(PMODE_A::_0)
}
#[doc = "High-Speed (HS) Comparison mode selected. In this mode, CMP has faster output propagation delay and higher current consumption."]
#[inline(always)]
pub fn _1(self) -> &'a mut W {
self.variant(PMODE_A::_1)
}
#[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 << 4)) | (((value as u8) & 0x01) << 4);
self.w
}
}
#[doc = "Possible values of the field `TRIGM`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum TRIGM_A {
#[doc = "Trigger mode is disabled."]
_0,
#[doc = "Trigger mode is enabled."]
_1,
}
impl crate::ToBits<bool> for TRIGM_A {
#[inline(always)]
fn _bits(&self) -> bool {
match *self {
TRIGM_A::_0 => false,
TRIGM_A::_1 => true,
}
}
}
#[doc = "Reader of field `TRIGM`"]
pub type TRIGM_R = crate::R<bool, TRIGM_A>;
impl TRIGM_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> TRIGM_A {
match self.bits {
false => TRIGM_A::_0,
true => TRIGM_A::_1,
}
}
#[doc = "Checks if the value of the field is `_0`"]
#[inline(always)]
pub fn is_0(&self) -> bool {
*self == TRIGM_A::_0
}
#[doc = "Checks if the value of the field is `_1`"]
#[inline(always)]
pub fn is_1(&self) -> bool {
*self == TRIGM_A::_1
}
}
#[doc = "Write proxy for field `TRIGM`"]
pub struct TRIGM_W<'a> {
w: &'a mut W,
}
impl<'a> TRIGM_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: TRIGM_A) -> &'a mut W {
use crate::ToBits;
{
self.bit(variant._bits())
}
}
#[doc = "Trigger mode is disabled."]
#[inline(always)]
pub fn _0(self) -> &'a mut W {
self.variant(TRIGM_A::_0)
}
#[doc = "Trigger mode is enabled."]
#[inline(always)]
pub fn _1(self) -> &'a mut W {
self.variant(TRIGM_A::_1)
}
#[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 << 5)) | (((value as u8) & 0x01) << 5);
self.w
}
}
#[doc = "Possible values of the field `WE`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum WE_A {
#[doc = "Windowing mode is not selected."]
_0,
#[doc = "Windowing mode is selected."]
_1,
}
impl crate::ToBits<bool> for WE_A {
#[inline(always)]
fn _bits(&self) -> bool {
match *self {
WE_A::_0 => false,
WE_A::_1 => true,
}
}
}
#[doc = "Reader of field `WE`"]
pub type WE_R = crate::R<bool, WE_A>;
impl WE_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> WE_A {
match self.bits {
false => WE_A::_0,
true => WE_A::_1,
}
}
#[doc = "Checks if the value of the field is `_0`"]
#[inline(always)]
pub fn is_0(&self) -> bool {
*self == WE_A::_0
}
#[doc = "Checks if the value of the field is `_1`"]
#[inline(always)]
pub fn is_1(&self) -> bool {
*self == WE_A::_1
}
}
#[doc = "Write proxy for field `WE`"]
pub struct WE_W<'a> {
w: &'a mut W,
}
impl<'a> WE_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: WE_A) -> &'a mut W {
use crate::ToBits;
{
self.bit(variant._bits())
}
}
#[doc = "Windowing mode is not selected."]
#[inline(always)]
pub fn _0(self) -> &'a mut W {
self.variant(WE_A::_0)
}
#[doc = "Windowing mode is selected."]
#[inline(always)]
pub fn _1(self) -> &'a mut W {
self.variant(WE_A::_1)
}
#[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 << 6)) | (((value as u8) & 0x01) << 6);
self.w
}
}
#[doc = "Possible values of the field `SE`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum SE_A {
#[doc = "Sampling mode is not selected."]
_0,
#[doc = "Sampling mode is selected."]
_1,
}
impl crate::ToBits<bool> for SE_A {
#[inline(always)]
fn _bits(&self) -> bool {
match *self {
SE_A::_0 => false,
SE_A::_1 => true,
}
}
}
#[doc = "Reader of field `SE`"]
pub type SE_R = crate::R<bool, SE_A>;
impl SE_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> SE_A {
match self.bits {
false => SE_A::_0,
true => SE_A::_1,
}
}
#[doc = "Checks if the value of the field is `_0`"]
#[inline(always)]
pub fn is_0(&self) -> bool {
*self == SE_A::_0
}
#[doc = "Checks if the value of the field is `_1`"]
#[inline(always)]
pub fn is_1(&self) -> bool {
*self == SE_A::_1
}
}
#[doc = "Write proxy for field `SE`"]
pub struct SE_W<'a> {
w: &'a mut W,
}
impl<'a> SE_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: SE_A) -> &'a mut W {
use crate::ToBits;
{
self.bit(variant._bits())
}
}
#[doc = "Sampling mode is not selected."]
#[inline(always)]
pub fn _0(self) -> &'a mut W {
self.variant(SE_A::_0)
}
#[doc = "Sampling mode is selected."]
#[inline(always)]
pub fn _1(self) -> &'a mut W {
self.variant(SE_A::_1)
}
#[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 << 7)) | (((value as u8) & 0x01) << 7);
self.w
}
}
impl R {
#[doc = "Bit 0 - Comparator Module Enable"]
#[inline(always)]
pub fn en(&self) -> EN_R {
EN_R::new((self.bits & 0x01) != 0)
}
#[doc = "Bit 1 - Comparator Output Pin Enable"]
#[inline(always)]
pub fn ope(&self) -> OPE_R {
OPE_R::new(((self.bits >> 1) & 0x01) != 0)
}
#[doc = "Bit 2 - Comparator Output Select"]
#[inline(always)]
pub fn cos(&self) -> COS_R {
COS_R::new(((self.bits >> 2) & 0x01) != 0)
}
#[doc = "Bit 3 - Comparator INVERT"]
#[inline(always)]
pub fn inv(&self) -> INV_R {
INV_R::new(((self.bits >> 3) & 0x01) != 0)
}
#[doc = "Bit 4 - Power Mode Select"]
#[inline(always)]
pub fn pmode(&self) -> PMODE_R {
PMODE_R::new(((self.bits >> 4) & 0x01) != 0)
}
#[doc = "Bit 5 - Trigger Mode Enable"]
#[inline(always)]
pub fn trigm(&self) -> TRIGM_R {
TRIGM_R::new(((self.bits >> 5) & 0x01) != 0)
}
#[doc = "Bit 6 - Windowing Enable"]
#[inline(always)]
pub fn we(&self) -> WE_R {
WE_R::new(((self.bits >> 6) & 0x01) != 0)
}
#[doc = "Bit 7 - Sample Enable"]
#[inline(always)]
pub fn se(&self) -> SE_R {
SE_R::new(((self.bits >> 7) & 0x01) != 0)
}
}
impl W {
#[doc = "Bit 0 - Comparator Module Enable"]
#[inline(always)]
pub fn en(&mut self) -> EN_W {
EN_W { w: self }
}
#[doc = "Bit 1 - Comparator Output Pin Enable"]
#[inline(always)]
pub fn ope(&mut self) -> OPE_W {
OPE_W { w: self }
}
#[doc = "Bit 2 - Comparator Output Select"]
#[inline(always)]
pub fn cos(&mut self) -> COS_W {
COS_W { w: self }
}
#[doc = "Bit 3 - Comparator INVERT"]
#[inline(always)]
pub fn inv(&mut self) -> INV_W {
INV_W { w: self }
}
#[doc = "Bit 4 - Power Mode Select"]
#[inline(always)]
pub fn pmode(&mut self) -> PMODE_W {
PMODE_W { w: self }
}
#[doc = "Bit 5 - Trigger Mode Enable"]
#[inline(always)]
pub fn trigm(&mut self) -> TRIGM_W {
TRIGM_W { w: self }
}
#[doc = "Bit 6 - Windowing Enable"]
#[inline(always)]
pub fn we(&mut self) -> WE_W {
WE_W { w: self }
}
#[doc = "Bit 7 - Sample Enable"]
#[inline(always)]
pub fn se(&mut self) -> SE_W {
SE_W { w: self }
}
}