#[doc = r"Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r"Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::BDTR {
#[doc = r"Modifies the contents of the register"]
#[inline(always)]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w mut W) -> &'w mut W,
{
let bits = self.register.get();
self.register.set(f(&R { bits }, &mut W { bits }).bits);
}
#[doc = r"Reads the contents of the register"]
#[inline(always)]
pub fn read(&self) -> R {
R {
bits: self.register.get(),
}
}
#[doc = r"Writes to the register"]
#[inline(always)]
pub fn write<F>(&self, f: F)
where
F: FnOnce(&mut W) -> &mut W,
{
self.register.set(
f(&mut W {
bits: Self::reset_value(),
})
.bits,
);
}
#[doc = r"Reset value of the register"]
#[inline(always)]
pub const fn reset_value() -> u32 {
0
}
#[doc = r"Writes the reset value to the register"]
#[inline(always)]
pub fn reset(&self) {
self.register.set(Self::reset_value())
}
}
#[doc = r"Value of the field"]
pub struct DTGR {
bits: u8,
}
impl DTGR {
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bits(&self) -> u8 {
self.bits
}
}
#[doc = r"Proxy"]
pub struct _DTGW<'a> {
w: &'a mut W,
}
impl<'a> _DTGW<'a> {
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub unsafe fn bits(self, value: u8) -> &'a mut W {
self.w.bits &= !(0xff << 0);
self.w.bits |= ((value as u32) & 0xff) << 0;
self.w
}
}
#[doc = r"Value of the field"]
pub struct LOCKR {
bits: u8,
}
impl LOCKR {
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bits(&self) -> u8 {
self.bits
}
}
#[doc = r"Proxy"]
pub struct _LOCKW<'a> {
w: &'a mut W,
}
impl<'a> _LOCKW<'a> {
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub unsafe fn bits(self, value: u8) -> &'a mut W {
self.w.bits &= !(0x03 << 8);
self.w.bits |= ((value as u32) & 0x03) << 8;
self.w
}
}
#[doc = "Possible values of the field `OSSI`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum OSSIR {
#[doc = "When inactive, OC/OCN outputs are disabled"]
DISABLED,
#[doc = "When inactive, OC/OCN outputs are forced to idle level"]
IDLELEVEL,
}
impl OSSIR {
#[doc = r"Returns `true` if the bit is clear (0)"]
#[inline(always)]
pub fn bit_is_clear(&self) -> bool {
!self.bit()
}
#[doc = r"Returns `true` if the bit is set (1)"]
#[inline(always)]
pub fn bit_is_set(&self) -> bool {
self.bit()
}
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bit(&self) -> bool {
match *self {
OSSIR::DISABLED => false,
OSSIR::IDLELEVEL => true,
}
}
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _from(value: bool) -> OSSIR {
match value {
false => OSSIR::DISABLED,
true => OSSIR::IDLELEVEL,
}
}
#[doc = "Checks if the value of the field is `DISABLED`"]
#[inline(always)]
pub fn is_disabled(&self) -> bool {
*self == OSSIR::DISABLED
}
#[doc = "Checks if the value of the field is `IDLELEVEL`"]
#[inline(always)]
pub fn is_idle_level(&self) -> bool {
*self == OSSIR::IDLELEVEL
}
}
#[doc = "Values that can be written to the field `OSSI`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum OSSIW {
#[doc = "When inactive, OC/OCN outputs are disabled"]
DISABLED,
#[doc = "When inactive, OC/OCN outputs are forced to idle level"]
IDLELEVEL,
}
impl OSSIW {
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _bits(&self) -> bool {
match *self {
OSSIW::DISABLED => false,
OSSIW::IDLELEVEL => true,
}
}
}
#[doc = r"Proxy"]
pub struct _OSSIW<'a> {
w: &'a mut W,
}
impl<'a> _OSSIW<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: OSSIW) -> &'a mut W {
{
self.bit(variant._bits())
}
}
#[doc = "When inactive, OC/OCN outputs are disabled"]
#[inline(always)]
pub fn disabled(self) -> &'a mut W {
self.variant(OSSIW::DISABLED)
}
#[doc = "When inactive, OC/OCN outputs are forced to idle level"]
#[inline(always)]
pub fn idle_level(self) -> &'a mut W {
self.variant(OSSIW::IDLELEVEL)
}
#[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 &= !(0x01 << 10);
self.w.bits |= ((value as u32) & 0x01) << 10;
self.w
}
}
#[doc = "Possible values of the field `OSSR`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum OSSRR {
#[doc = "When inactive, OC/OCN outputs are disabled"]
DISABLED,
#[doc = "When inactive, OC/OCN outputs are enabled with their inactive level"]
IDLELEVEL,
}
impl OSSRR {
#[doc = r"Returns `true` if the bit is clear (0)"]
#[inline(always)]
pub fn bit_is_clear(&self) -> bool {
!self.bit()
}
#[doc = r"Returns `true` if the bit is set (1)"]
#[inline(always)]
pub fn bit_is_set(&self) -> bool {
self.bit()
}
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bit(&self) -> bool {
match *self {
OSSRR::DISABLED => false,
OSSRR::IDLELEVEL => true,
}
}
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _from(value: bool) -> OSSRR {
match value {
false => OSSRR::DISABLED,
true => OSSRR::IDLELEVEL,
}
}
#[doc = "Checks if the value of the field is `DISABLED`"]
#[inline(always)]
pub fn is_disabled(&self) -> bool {
*self == OSSRR::DISABLED
}
#[doc = "Checks if the value of the field is `IDLELEVEL`"]
#[inline(always)]
pub fn is_idle_level(&self) -> bool {
*self == OSSRR::IDLELEVEL
}
}
#[doc = "Values that can be written to the field `OSSR`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum OSSRW {
#[doc = "When inactive, OC/OCN outputs are disabled"]
DISABLED,
#[doc = "When inactive, OC/OCN outputs are enabled with their inactive level"]
IDLELEVEL,
}
impl OSSRW {
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _bits(&self) -> bool {
match *self {
OSSRW::DISABLED => false,
OSSRW::IDLELEVEL => true,
}
}
}
#[doc = r"Proxy"]
pub struct _OSSRW<'a> {
w: &'a mut W,
}
impl<'a> _OSSRW<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: OSSRW) -> &'a mut W {
{
self.bit(variant._bits())
}
}
#[doc = "When inactive, OC/OCN outputs are disabled"]
#[inline(always)]
pub fn disabled(self) -> &'a mut W {
self.variant(OSSRW::DISABLED)
}
#[doc = "When inactive, OC/OCN outputs are enabled with their inactive level"]
#[inline(always)]
pub fn idle_level(self) -> &'a mut W {
self.variant(OSSRW::IDLELEVEL)
}
#[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 &= !(0x01 << 11);
self.w.bits |= ((value as u32) & 0x01) << 11;
self.w
}
}
#[doc = r"Value of the field"]
pub struct BKER {
bits: bool,
}
impl BKER {
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bit(&self) -> bool {
self.bits
}
#[doc = r"Returns `true` if the bit is clear (0)"]
#[inline(always)]
pub fn bit_is_clear(&self) -> bool {
!self.bit()
}
#[doc = r"Returns `true` if the bit is set (1)"]
#[inline(always)]
pub fn bit_is_set(&self) -> bool {
self.bit()
}
}
#[doc = r"Proxy"]
pub struct _BKEW<'a> {
w: &'a mut W,
}
impl<'a> _BKEW<'a> {
#[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 &= !(0x01 << 12);
self.w.bits |= ((value as u32) & 0x01) << 12;
self.w
}
}
#[doc = r"Value of the field"]
pub struct BKPR {
bits: bool,
}
impl BKPR {
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bit(&self) -> bool {
self.bits
}
#[doc = r"Returns `true` if the bit is clear (0)"]
#[inline(always)]
pub fn bit_is_clear(&self) -> bool {
!self.bit()
}
#[doc = r"Returns `true` if the bit is set (1)"]
#[inline(always)]
pub fn bit_is_set(&self) -> bool {
self.bit()
}
}
#[doc = r"Proxy"]
pub struct _BKPW<'a> {
w: &'a mut W,
}
impl<'a> _BKPW<'a> {
#[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 &= !(0x01 << 13);
self.w.bits |= ((value as u32) & 0x01) << 13;
self.w
}
}
#[doc = r"Value of the field"]
pub struct AOER {
bits: bool,
}
impl AOER {
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bit(&self) -> bool {
self.bits
}
#[doc = r"Returns `true` if the bit is clear (0)"]
#[inline(always)]
pub fn bit_is_clear(&self) -> bool {
!self.bit()
}
#[doc = r"Returns `true` if the bit is set (1)"]
#[inline(always)]
pub fn bit_is_set(&self) -> bool {
self.bit()
}
}
#[doc = r"Proxy"]
pub struct _AOEW<'a> {
w: &'a mut W,
}
impl<'a> _AOEW<'a> {
#[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 &= !(0x01 << 14);
self.w.bits |= ((value as u32) & 0x01) << 14;
self.w
}
}
#[doc = "Possible values of the field `MOE`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum MOER {
#[doc = "OC/OCN are disabled or forced idle depending on OSSI"]
DISABLEDIDLE,
#[doc = "OC/OCN are enabled if CCxE/CCxNE are set"]
ENABLED,
}
impl MOER {
#[doc = r"Returns `true` if the bit is clear (0)"]
#[inline(always)]
pub fn bit_is_clear(&self) -> bool {
!self.bit()
}
#[doc = r"Returns `true` if the bit is set (1)"]
#[inline(always)]
pub fn bit_is_set(&self) -> bool {
self.bit()
}
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bit(&self) -> bool {
match *self {
MOER::DISABLEDIDLE => false,
MOER::ENABLED => true,
}
}
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _from(value: bool) -> MOER {
match value {
false => MOER::DISABLEDIDLE,
true => MOER::ENABLED,
}
}
#[doc = "Checks if the value of the field is `DISABLEDIDLE`"]
#[inline(always)]
pub fn is_disabled_idle(&self) -> bool {
*self == MOER::DISABLEDIDLE
}
#[doc = "Checks if the value of the field is `ENABLED`"]
#[inline(always)]
pub fn is_enabled(&self) -> bool {
*self == MOER::ENABLED
}
}
#[doc = "Values that can be written to the field `MOE`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum MOEW {
#[doc = "OC/OCN are disabled or forced idle depending on OSSI"]
DISABLEDIDLE,
#[doc = "OC/OCN are enabled if CCxE/CCxNE are set"]
ENABLED,
}
impl MOEW {
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _bits(&self) -> bool {
match *self {
MOEW::DISABLEDIDLE => false,
MOEW::ENABLED => true,
}
}
}
#[doc = r"Proxy"]
pub struct _MOEW<'a> {
w: &'a mut W,
}
impl<'a> _MOEW<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: MOEW) -> &'a mut W {
{
self.bit(variant._bits())
}
}
#[doc = "OC/OCN are disabled or forced idle depending on OSSI"]
#[inline(always)]
pub fn disabled_idle(self) -> &'a mut W {
self.variant(MOEW::DISABLEDIDLE)
}
#[doc = "OC/OCN are enabled if CCxE/CCxNE are set"]
#[inline(always)]
pub fn enabled(self) -> &'a mut W {
self.variant(MOEW::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 &= !(0x01 << 15);
self.w.bits |= ((value as u32) & 0x01) << 15;
self.w
}
}
#[doc = r"Value of the field"]
pub struct BKFR {
bits: u8,
}
impl BKFR {
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bits(&self) -> u8 {
self.bits
}
}
#[doc = r"Proxy"]
pub struct _BKFW<'a> {
w: &'a mut W,
}
impl<'a> _BKFW<'a> {
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub unsafe fn bits(self, value: u8) -> &'a mut W {
self.w.bits &= !(0x0f << 16);
self.w.bits |= ((value as u32) & 0x0f) << 16;
self.w
}
}
#[doc = r"Value of the field"]
pub struct BK2FR {
bits: u8,
}
impl BK2FR {
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bits(&self) -> u8 {
self.bits
}
}
#[doc = r"Proxy"]
pub struct _BK2FW<'a> {
w: &'a mut W,
}
impl<'a> _BK2FW<'a> {
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub unsafe fn bits(self, value: u8) -> &'a mut W {
self.w.bits &= !(0x0f << 20);
self.w.bits |= ((value as u32) & 0x0f) << 20;
self.w
}
}
#[doc = r"Value of the field"]
pub struct BK2ER {
bits: bool,
}
impl BK2ER {
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bit(&self) -> bool {
self.bits
}
#[doc = r"Returns `true` if the bit is clear (0)"]
#[inline(always)]
pub fn bit_is_clear(&self) -> bool {
!self.bit()
}
#[doc = r"Returns `true` if the bit is set (1)"]
#[inline(always)]
pub fn bit_is_set(&self) -> bool {
self.bit()
}
}
#[doc = r"Proxy"]
pub struct _BK2EW<'a> {
w: &'a mut W,
}
impl<'a> _BK2EW<'a> {
#[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 &= !(0x01 << 24);
self.w.bits |= ((value as u32) & 0x01) << 24;
self.w
}
}
#[doc = r"Value of the field"]
pub struct BK2PR {
bits: bool,
}
impl BK2PR {
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bit(&self) -> bool {
self.bits
}
#[doc = r"Returns `true` if the bit is clear (0)"]
#[inline(always)]
pub fn bit_is_clear(&self) -> bool {
!self.bit()
}
#[doc = r"Returns `true` if the bit is set (1)"]
#[inline(always)]
pub fn bit_is_set(&self) -> bool {
self.bit()
}
}
#[doc = r"Proxy"]
pub struct _BK2PW<'a> {
w: &'a mut W,
}
impl<'a> _BK2PW<'a> {
#[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 &= !(0x01 << 25);
self.w.bits |= ((value as u32) & 0x01) << 25;
self.w
}
}
impl R {
#[doc = r"Value of the register as raw bits"]
#[inline(always)]
pub fn bits(&self) -> u32 {
self.bits
}
#[doc = "Bits 0:7 - Dead-time generator setup"]
#[inline(always)]
pub fn dtg(&self) -> DTGR {
let bits = ((self.bits >> 0) & 0xff) as u8;
DTGR { bits }
}
#[doc = "Bits 8:9 - Lock configuration"]
#[inline(always)]
pub fn lock(&self) -> LOCKR {
let bits = ((self.bits >> 8) & 0x03) as u8;
LOCKR { bits }
}
#[doc = "Bit 10 - Off-state selection for Idle mode"]
#[inline(always)]
pub fn ossi(&self) -> OSSIR {
OSSIR::_from(((self.bits >> 10) & 0x01) != 0)
}
#[doc = "Bit 11 - Off-state selection for Run mode"]
#[inline(always)]
pub fn ossr(&self) -> OSSRR {
OSSRR::_from(((self.bits >> 11) & 0x01) != 0)
}
#[doc = "Bit 12 - Break enable"]
#[inline(always)]
pub fn bke(&self) -> BKER {
let bits = ((self.bits >> 12) & 0x01) != 0;
BKER { bits }
}
#[doc = "Bit 13 - Break polarity"]
#[inline(always)]
pub fn bkp(&self) -> BKPR {
let bits = ((self.bits >> 13) & 0x01) != 0;
BKPR { bits }
}
#[doc = "Bit 14 - Automatic output enable"]
#[inline(always)]
pub fn aoe(&self) -> AOER {
let bits = ((self.bits >> 14) & 0x01) != 0;
AOER { bits }
}
#[doc = "Bit 15 - Main output enable"]
#[inline(always)]
pub fn moe(&self) -> MOER {
MOER::_from(((self.bits >> 15) & 0x01) != 0)
}
#[doc = "Bits 16:19 - Break filter"]
#[inline(always)]
pub fn bkf(&self) -> BKFR {
let bits = ((self.bits >> 16) & 0x0f) as u8;
BKFR { bits }
}
#[doc = "Bits 20:23 - Break 2 filter"]
#[inline(always)]
pub fn bk2f(&self) -> BK2FR {
let bits = ((self.bits >> 20) & 0x0f) as u8;
BK2FR { bits }
}
#[doc = "Bit 24 - Break 2 enable"]
#[inline(always)]
pub fn bk2e(&self) -> BK2ER {
let bits = ((self.bits >> 24) & 0x01) != 0;
BK2ER { bits }
}
#[doc = "Bit 25 - Break 2 polarity"]
#[inline(always)]
pub fn bk2p(&self) -> BK2PR {
let bits = ((self.bits >> 25) & 0x01) != 0;
BK2PR { bits }
}
}
impl W {
#[doc = r"Writes raw bits to the register"]
#[inline(always)]
pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
self.bits = bits;
self
}
#[doc = "Bits 0:7 - Dead-time generator setup"]
#[inline(always)]
pub fn dtg(&mut self) -> _DTGW {
_DTGW { w: self }
}
#[doc = "Bits 8:9 - Lock configuration"]
#[inline(always)]
pub fn lock(&mut self) -> _LOCKW {
_LOCKW { w: self }
}
#[doc = "Bit 10 - Off-state selection for Idle mode"]
#[inline(always)]
pub fn ossi(&mut self) -> _OSSIW {
_OSSIW { w: self }
}
#[doc = "Bit 11 - Off-state selection for Run mode"]
#[inline(always)]
pub fn ossr(&mut self) -> _OSSRW {
_OSSRW { w: self }
}
#[doc = "Bit 12 - Break enable"]
#[inline(always)]
pub fn bke(&mut self) -> _BKEW {
_BKEW { w: self }
}
#[doc = "Bit 13 - Break polarity"]
#[inline(always)]
pub fn bkp(&mut self) -> _BKPW {
_BKPW { w: self }
}
#[doc = "Bit 14 - Automatic output enable"]
#[inline(always)]
pub fn aoe(&mut self) -> _AOEW {
_AOEW { w: self }
}
#[doc = "Bit 15 - Main output enable"]
#[inline(always)]
pub fn moe(&mut self) -> _MOEW {
_MOEW { w: self }
}
#[doc = "Bits 16:19 - Break filter"]
#[inline(always)]
pub fn bkf(&mut self) -> _BKFW {
_BKFW { w: self }
}
#[doc = "Bits 20:23 - Break 2 filter"]
#[inline(always)]
pub fn bk2f(&mut self) -> _BK2FW {
_BK2FW { w: self }
}
#[doc = "Bit 24 - Break 2 enable"]
#[inline(always)]
pub fn bk2e(&mut self) -> _BK2EW {
_BK2EW { w: self }
}
#[doc = "Bit 25 - Break 2 polarity"]
#[inline(always)]
pub fn bk2p(&mut self) -> _BK2PW {
_BK2PW { w: self }
}
}