#[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::CCMR1_OUTPUT {
#[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 = "Possible values of the field `CC1S`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum CC1SR {
#[doc = "CC1 channel is configured as output"]
OUTPUT,
#[doc = r"Reserved"]
_Reserved(u8),
}
impl CC1SR {
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bits(&self) -> u8 {
match *self {
CC1SR::OUTPUT => 0,
CC1SR::_Reserved(bits) => bits,
}
}
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _from(value: u8) -> CC1SR {
match value {
0 => CC1SR::OUTPUT,
i => CC1SR::_Reserved(i),
}
}
#[doc = "Checks if the value of the field is `OUTPUT`"]
#[inline(always)]
pub fn is_output(&self) -> bool {
*self == CC1SR::OUTPUT
}
}
#[doc = "Values that can be written to the field `CC1S`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum CC1SW {
#[doc = "CC1 channel is configured as output"]
OUTPUT,
}
impl CC1SW {
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _bits(&self) -> u8 {
match *self {
CC1SW::OUTPUT => 0,
}
}
}
#[doc = r"Proxy"]
pub struct _CC1SW<'a> {
w: &'a mut W,
}
impl<'a> _CC1SW<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: CC1SW) -> &'a mut W {
unsafe { self.bits(variant._bits()) }
}
#[doc = "CC1 channel is configured as output"]
#[inline(always)]
pub fn output(self) -> &'a mut W {
self.variant(CC1SW::OUTPUT)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub unsafe fn bits(self, value: u8) -> &'a mut W {
self.w.bits &= !(0x03 << 0);
self.w.bits |= ((value as u32) & 0x03) << 0;
self.w
}
}
#[doc = r"Value of the field"]
pub struct OC1FER {
bits: bool,
}
impl OC1FER {
#[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 _OC1FEW<'a> {
w: &'a mut W,
}
impl<'a> _OC1FEW<'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 << 2);
self.w.bits |= ((value as u32) & 0x01) << 2;
self.w
}
}
#[doc = "Possible values of the field `OC1PE`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum OC1PER {
#[doc = "Preload register on CCR1 disabled. New values written to CCR1 are taken into account immediately"]
DISABLED,
#[doc = "Preload register on CCR1 enabled. Preload value is loaded into active register on each update event"]
ENABLED,
}
impl OC1PER {
#[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 {
OC1PER::DISABLED => false,
OC1PER::ENABLED => true,
}
}
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _from(value: bool) -> OC1PER {
match value {
false => OC1PER::DISABLED,
true => OC1PER::ENABLED,
}
}
#[doc = "Checks if the value of the field is `DISABLED`"]
#[inline(always)]
pub fn is_disabled(&self) -> bool {
*self == OC1PER::DISABLED
}
#[doc = "Checks if the value of the field is `ENABLED`"]
#[inline(always)]
pub fn is_enabled(&self) -> bool {
*self == OC1PER::ENABLED
}
}
#[doc = "Values that can be written to the field `OC1PE`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum OC1PEW {
#[doc = "Preload register on CCR1 disabled. New values written to CCR1 are taken into account immediately"]
DISABLED,
#[doc = "Preload register on CCR1 enabled. Preload value is loaded into active register on each update event"]
ENABLED,
}
impl OC1PEW {
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _bits(&self) -> bool {
match *self {
OC1PEW::DISABLED => false,
OC1PEW::ENABLED => true,
}
}
}
#[doc = r"Proxy"]
pub struct _OC1PEW<'a> {
w: &'a mut W,
}
impl<'a> _OC1PEW<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: OC1PEW) -> &'a mut W {
{
self.bit(variant._bits())
}
}
#[doc = "Preload register on CCR1 disabled. New values written to CCR1 are taken into account immediately"]
#[inline(always)]
pub fn disabled(self) -> &'a mut W {
self.variant(OC1PEW::DISABLED)
}
#[doc = "Preload register on CCR1 enabled. Preload value is loaded into active register on each update event"]
#[inline(always)]
pub fn enabled(self) -> &'a mut W {
self.variant(OC1PEW::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 << 3);
self.w.bits |= ((value as u32) & 0x01) << 3;
self.w
}
}
#[doc = "Possible values of the field `OC1M`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum OC1MR {
#[doc = "The comparison between the output compare register TIMx_CCRy and the counter TIMx_CNT has no effect on the outputs"]
FROZEN,
#[doc = "Set channel to active level on match. OCyREF signal is forced high when the counter matches the capture/compare register"]
ACTIVEONMATCH,
#[doc = "Set channel to inactive level on match. OCyREF signal is forced low when the counter matches the capture/compare register"]
INACTIVEONMATCH,
#[doc = "OCyREF toggles when TIMx_CNT=TIMx_CCRy"]
TOGGLE,
#[doc = "OCyREF is forced low"]
FORCEINACTIVE,
#[doc = "OCyREF is forced high"]
FORCEACTIVE,
#[doc = "In upcounting, channel is active as long as TIMx_CNT<TIMx_CCRy else inactive. In downcounting, channel is inactive as long as TIMx_CNT>TIMx_CCRy else active"]
PWMMODE1,
#[doc = "Inversely to PwmMode1"]
PWMMODE2,
#[doc = "Retriggerable OPM mode 1 - In up-counting mode, the channel is active until a trigger event is detected (on TRGI signal). In down-counting mode, the channel is inactive"]
OPMMODE1,
#[doc = "Inversely to OpmMode1"]
OPMMODE2,
#[doc = "OCyREF has the same behavior as in PWM mode 1. OCyREFC is the logical OR between OC1REF and OC2REF"]
COMBINEDPWMMODE1,
#[doc = "OCyREF has the same behavior as in PWM mode 2. OCyREFC is the logical AND between OC1REF and OC2REF"]
COMBINEDPWMMODE2,
#[doc = "OCyREF has the same behavior as in PWM mode 1. OCyREFC outputs OC1REF when the counter is counting up, OC2REF when it is counting down"]
ASYMMETRICPWMMODE1,
#[doc = "OCyREF has the same behavior as in PWM mode 2. OCyREFC outputs OC1REF when the counter is counting up, OC2REF when it is counting down"]
ASYMMETRICPWMMODE2,
#[doc = r"Reserved"]
_Reserved(u8),
}
impl OC1MR {
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bits(&self) -> u8 {
match *self {
OC1MR::FROZEN => 0,
OC1MR::ACTIVEONMATCH => 0x01,
OC1MR::INACTIVEONMATCH => 0x02,
OC1MR::TOGGLE => 0x03,
OC1MR::FORCEINACTIVE => 0x04,
OC1MR::FORCEACTIVE => 0x05,
OC1MR::PWMMODE1 => 0x06,
OC1MR::PWMMODE2 => 0x07,
OC1MR::OPMMODE1 => 0x08,
OC1MR::OPMMODE2 => 0x09,
OC1MR::COMBINEDPWMMODE1 => 0x0c,
OC1MR::COMBINEDPWMMODE2 => 0x0d,
OC1MR::ASYMMETRICPWMMODE1 => 0x0e,
OC1MR::ASYMMETRICPWMMODE2 => 0x0f,
OC1MR::_Reserved(bits) => bits,
}
}
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _from(value: u8) -> OC1MR {
match value {
0 => OC1MR::FROZEN,
1 => OC1MR::ACTIVEONMATCH,
2 => OC1MR::INACTIVEONMATCH,
3 => OC1MR::TOGGLE,
4 => OC1MR::FORCEINACTIVE,
5 => OC1MR::FORCEACTIVE,
6 => OC1MR::PWMMODE1,
7 => OC1MR::PWMMODE2,
8 => OC1MR::OPMMODE1,
9 => OC1MR::OPMMODE2,
12 => OC1MR::COMBINEDPWMMODE1,
13 => OC1MR::COMBINEDPWMMODE2,
14 => OC1MR::ASYMMETRICPWMMODE1,
15 => OC1MR::ASYMMETRICPWMMODE2,
i => OC1MR::_Reserved(i),
}
}
#[doc = "Checks if the value of the field is `FROZEN`"]
#[inline(always)]
pub fn is_frozen(&self) -> bool {
*self == OC1MR::FROZEN
}
#[doc = "Checks if the value of the field is `ACTIVEONMATCH`"]
#[inline(always)]
pub fn is_active_on_match(&self) -> bool {
*self == OC1MR::ACTIVEONMATCH
}
#[doc = "Checks if the value of the field is `INACTIVEONMATCH`"]
#[inline(always)]
pub fn is_inactive_on_match(&self) -> bool {
*self == OC1MR::INACTIVEONMATCH
}
#[doc = "Checks if the value of the field is `TOGGLE`"]
#[inline(always)]
pub fn is_toggle(&self) -> bool {
*self == OC1MR::TOGGLE
}
#[doc = "Checks if the value of the field is `FORCEINACTIVE`"]
#[inline(always)]
pub fn is_force_inactive(&self) -> bool {
*self == OC1MR::FORCEINACTIVE
}
#[doc = "Checks if the value of the field is `FORCEACTIVE`"]
#[inline(always)]
pub fn is_force_active(&self) -> bool {
*self == OC1MR::FORCEACTIVE
}
#[doc = "Checks if the value of the field is `PWMMODE1`"]
#[inline(always)]
pub fn is_pwm_mode1(&self) -> bool {
*self == OC1MR::PWMMODE1
}
#[doc = "Checks if the value of the field is `PWMMODE2`"]
#[inline(always)]
pub fn is_pwm_mode2(&self) -> bool {
*self == OC1MR::PWMMODE2
}
#[doc = "Checks if the value of the field is `OPMMODE1`"]
#[inline(always)]
pub fn is_opm_mode1(&self) -> bool {
*self == OC1MR::OPMMODE1
}
#[doc = "Checks if the value of the field is `OPMMODE2`"]
#[inline(always)]
pub fn is_opm_mode2(&self) -> bool {
*self == OC1MR::OPMMODE2
}
#[doc = "Checks if the value of the field is `COMBINEDPWMMODE1`"]
#[inline(always)]
pub fn is_combined_pwm_mode1(&self) -> bool {
*self == OC1MR::COMBINEDPWMMODE1
}
#[doc = "Checks if the value of the field is `COMBINEDPWMMODE2`"]
#[inline(always)]
pub fn is_combined_pwm_mode2(&self) -> bool {
*self == OC1MR::COMBINEDPWMMODE2
}
#[doc = "Checks if the value of the field is `ASYMMETRICPWMMODE1`"]
#[inline(always)]
pub fn is_asymmetric_pwm_mode1(&self) -> bool {
*self == OC1MR::ASYMMETRICPWMMODE1
}
#[doc = "Checks if the value of the field is `ASYMMETRICPWMMODE2`"]
#[inline(always)]
pub fn is_asymmetric_pwm_mode2(&self) -> bool {
*self == OC1MR::ASYMMETRICPWMMODE2
}
}
#[doc = "Values that can be written to the field `OC1M`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum OC1MW {
#[doc = "The comparison between the output compare register TIMx_CCRy and the counter TIMx_CNT has no effect on the outputs"]
FROZEN,
#[doc = "Set channel to active level on match. OCyREF signal is forced high when the counter matches the capture/compare register"]
ACTIVEONMATCH,
#[doc = "Set channel to inactive level on match. OCyREF signal is forced low when the counter matches the capture/compare register"]
INACTIVEONMATCH,
#[doc = "OCyREF toggles when TIMx_CNT=TIMx_CCRy"]
TOGGLE,
#[doc = "OCyREF is forced low"]
FORCEINACTIVE,
#[doc = "OCyREF is forced high"]
FORCEACTIVE,
#[doc = "In upcounting, channel is active as long as TIMx_CNT<TIMx_CCRy else inactive. In downcounting, channel is inactive as long as TIMx_CNT>TIMx_CCRy else active"]
PWMMODE1,
#[doc = "Inversely to PwmMode1"]
PWMMODE2,
#[doc = "Retriggerable OPM mode 1 - In up-counting mode, the channel is active until a trigger event is detected (on TRGI signal). In down-counting mode, the channel is inactive"]
OPMMODE1,
#[doc = "Inversely to OpmMode1"]
OPMMODE2,
#[doc = "OCyREF has the same behavior as in PWM mode 1. OCyREFC is the logical OR between OC1REF and OC2REF"]
COMBINEDPWMMODE1,
#[doc = "OCyREF has the same behavior as in PWM mode 2. OCyREFC is the logical AND between OC1REF and OC2REF"]
COMBINEDPWMMODE2,
#[doc = "OCyREF has the same behavior as in PWM mode 1. OCyREFC outputs OC1REF when the counter is counting up, OC2REF when it is counting down"]
ASYMMETRICPWMMODE1,
#[doc = "OCyREF has the same behavior as in PWM mode 2. OCyREFC outputs OC1REF when the counter is counting up, OC2REF when it is counting down"]
ASYMMETRICPWMMODE2,
}
impl OC1MW {
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _bits(&self) -> u8 {
match *self {
OC1MW::FROZEN => 0,
OC1MW::ACTIVEONMATCH => 1,
OC1MW::INACTIVEONMATCH => 2,
OC1MW::TOGGLE => 3,
OC1MW::FORCEINACTIVE => 4,
OC1MW::FORCEACTIVE => 5,
OC1MW::PWMMODE1 => 6,
OC1MW::PWMMODE2 => 7,
OC1MW::OPMMODE1 => 8,
OC1MW::OPMMODE2 => 9,
OC1MW::COMBINEDPWMMODE1 => 12,
OC1MW::COMBINEDPWMMODE2 => 13,
OC1MW::ASYMMETRICPWMMODE1 => 14,
OC1MW::ASYMMETRICPWMMODE2 => 15,
}
}
}
#[doc = r"Proxy"]
pub struct _OC1MW<'a> {
w: &'a mut W,
}
impl<'a> _OC1MW<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: OC1MW) -> &'a mut W {
unsafe { self.bits(variant._bits()) }
}
#[doc = "The comparison between the output compare register TIMx_CCRy and the counter TIMx_CNT has no effect on the outputs"]
#[inline(always)]
pub fn frozen(self) -> &'a mut W {
self.variant(OC1MW::FROZEN)
}
#[doc = "Set channel to active level on match. OCyREF signal is forced high when the counter matches the capture/compare register"]
#[inline(always)]
pub fn active_on_match(self) -> &'a mut W {
self.variant(OC1MW::ACTIVEONMATCH)
}
#[doc = "Set channel to inactive level on match. OCyREF signal is forced low when the counter matches the capture/compare register"]
#[inline(always)]
pub fn inactive_on_match(self) -> &'a mut W {
self.variant(OC1MW::INACTIVEONMATCH)
}
#[doc = "OCyREF toggles when TIMx_CNT=TIMx_CCRy"]
#[inline(always)]
pub fn toggle(self) -> &'a mut W {
self.variant(OC1MW::TOGGLE)
}
#[doc = "OCyREF is forced low"]
#[inline(always)]
pub fn force_inactive(self) -> &'a mut W {
self.variant(OC1MW::FORCEINACTIVE)
}
#[doc = "OCyREF is forced high"]
#[inline(always)]
pub fn force_active(self) -> &'a mut W {
self.variant(OC1MW::FORCEACTIVE)
}
#[doc = "In upcounting, channel is active as long as TIMx_CNT<TIMx_CCRy else inactive. In downcounting, channel is inactive as long as TIMx_CNT>TIMx_CCRy else active"]
#[inline(always)]
pub fn pwm_mode1(self) -> &'a mut W {
self.variant(OC1MW::PWMMODE1)
}
#[doc = "Inversely to PwmMode1"]
#[inline(always)]
pub fn pwm_mode2(self) -> &'a mut W {
self.variant(OC1MW::PWMMODE2)
}
#[doc = "Retriggerable OPM mode 1 - In up-counting mode, the channel is active until a trigger event is detected (on TRGI signal). In down-counting mode, the channel is inactive"]
#[inline(always)]
pub fn opm_mode1(self) -> &'a mut W {
self.variant(OC1MW::OPMMODE1)
}
#[doc = "Inversely to OpmMode1"]
#[inline(always)]
pub fn opm_mode2(self) -> &'a mut W {
self.variant(OC1MW::OPMMODE2)
}
#[doc = "OCyREF has the same behavior as in PWM mode 1. OCyREFC is the logical OR between OC1REF and OC2REF"]
#[inline(always)]
pub fn combined_pwm_mode1(self) -> &'a mut W {
self.variant(OC1MW::COMBINEDPWMMODE1)
}
#[doc = "OCyREF has the same behavior as in PWM mode 2. OCyREFC is the logical AND between OC1REF and OC2REF"]
#[inline(always)]
pub fn combined_pwm_mode2(self) -> &'a mut W {
self.variant(OC1MW::COMBINEDPWMMODE2)
}
#[doc = "OCyREF has the same behavior as in PWM mode 1. OCyREFC outputs OC1REF when the counter is counting up, OC2REF when it is counting down"]
#[inline(always)]
pub fn asymmetric_pwm_mode1(self) -> &'a mut W {
self.variant(OC1MW::ASYMMETRICPWMMODE1)
}
#[doc = "OCyREF has the same behavior as in PWM mode 2. OCyREFC outputs OC1REF when the counter is counting up, OC2REF when it is counting down"]
#[inline(always)]
pub fn asymmetric_pwm_mode2(self) -> &'a mut W {
self.variant(OC1MW::ASYMMETRICPWMMODE2)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub unsafe fn bits(self, value: u8) -> &'a mut W {
self.w.bits &= !(0x07 << 4);
self.w.bits |= ((value as u32) & 0x07) << 4;
self.w
}
}
#[doc = r"Value of the field"]
pub struct OC1CER {
bits: bool,
}
impl OC1CER {
#[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 _OC1CEW<'a> {
w: &'a mut W,
}
impl<'a> _OC1CEW<'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 << 7);
self.w.bits |= ((value as u32) & 0x01) << 7;
self.w
}
}
#[doc = "Possible values of the field `CC2S`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum CC2SR {
#[doc = "CC2 channel is configured as output"]
OUTPUT,
#[doc = r"Reserved"]
_Reserved(u8),
}
impl CC2SR {
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bits(&self) -> u8 {
match *self {
CC2SR::OUTPUT => 0,
CC2SR::_Reserved(bits) => bits,
}
}
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _from(value: u8) -> CC2SR {
match value {
0 => CC2SR::OUTPUT,
i => CC2SR::_Reserved(i),
}
}
#[doc = "Checks if the value of the field is `OUTPUT`"]
#[inline(always)]
pub fn is_output(&self) -> bool {
*self == CC2SR::OUTPUT
}
}
#[doc = "Values that can be written to the field `CC2S`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum CC2SW {
#[doc = "CC2 channel is configured as output"]
OUTPUT,
}
impl CC2SW {
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _bits(&self) -> u8 {
match *self {
CC2SW::OUTPUT => 0,
}
}
}
#[doc = r"Proxy"]
pub struct _CC2SW<'a> {
w: &'a mut W,
}
impl<'a> _CC2SW<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: CC2SW) -> &'a mut W {
unsafe { self.bits(variant._bits()) }
}
#[doc = "CC2 channel is configured as output"]
#[inline(always)]
pub fn output(self) -> &'a mut W {
self.variant(CC2SW::OUTPUT)
}
#[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 = r"Value of the field"]
pub struct OC2FER {
bits: bool,
}
impl OC2FER {
#[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 _OC2FEW<'a> {
w: &'a mut W,
}
impl<'a> _OC2FEW<'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 << 10);
self.w.bits |= ((value as u32) & 0x01) << 10;
self.w
}
}
#[doc = "Possible values of the field `OC2PE`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum OC2PER {
#[doc = "Preload register on CCR2 disabled. New values written to CCR2 are taken into account immediately"]
DISABLED,
#[doc = "Preload register on CCR2 enabled. Preload value is loaded into active register on each update event"]
ENABLED,
}
impl OC2PER {
#[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 {
OC2PER::DISABLED => false,
OC2PER::ENABLED => true,
}
}
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _from(value: bool) -> OC2PER {
match value {
false => OC2PER::DISABLED,
true => OC2PER::ENABLED,
}
}
#[doc = "Checks if the value of the field is `DISABLED`"]
#[inline(always)]
pub fn is_disabled(&self) -> bool {
*self == OC2PER::DISABLED
}
#[doc = "Checks if the value of the field is `ENABLED`"]
#[inline(always)]
pub fn is_enabled(&self) -> bool {
*self == OC2PER::ENABLED
}
}
#[doc = "Values that can be written to the field `OC2PE`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum OC2PEW {
#[doc = "Preload register on CCR2 disabled. New values written to CCR2 are taken into account immediately"]
DISABLED,
#[doc = "Preload register on CCR2 enabled. Preload value is loaded into active register on each update event"]
ENABLED,
}
impl OC2PEW {
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _bits(&self) -> bool {
match *self {
OC2PEW::DISABLED => false,
OC2PEW::ENABLED => true,
}
}
}
#[doc = r"Proxy"]
pub struct _OC2PEW<'a> {
w: &'a mut W,
}
impl<'a> _OC2PEW<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: OC2PEW) -> &'a mut W {
{
self.bit(variant._bits())
}
}
#[doc = "Preload register on CCR2 disabled. New values written to CCR2 are taken into account immediately"]
#[inline(always)]
pub fn disabled(self) -> &'a mut W {
self.variant(OC2PEW::DISABLED)
}
#[doc = "Preload register on CCR2 enabled. Preload value is loaded into active register on each update event"]
#[inline(always)]
pub fn enabled(self) -> &'a mut W {
self.variant(OC2PEW::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 << 11);
self.w.bits |= ((value as u32) & 0x01) << 11;
self.w
}
}
#[doc = "Possible values of the field `OC2M`"]
pub type OC2MR = OC1MR;
#[doc = "Values that can be written to the field `OC2M`"]
pub type OC2MW = OC1MW;
#[doc = r"Proxy"]
pub struct _OC2MW<'a> {
w: &'a mut W,
}
impl<'a> _OC2MW<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: OC2MW) -> &'a mut W {
unsafe { self.bits(variant._bits()) }
}
#[doc = "The comparison between the output compare register TIMx_CCRy and the counter TIMx_CNT has no effect on the outputs"]
#[inline(always)]
pub fn frozen(self) -> &'a mut W {
self.variant(OC1MW::FROZEN)
}
#[doc = "Set channel to active level on match. OCyREF signal is forced high when the counter matches the capture/compare register"]
#[inline(always)]
pub fn active_on_match(self) -> &'a mut W {
self.variant(OC1MW::ACTIVEONMATCH)
}
#[doc = "Set channel to inactive level on match. OCyREF signal is forced low when the counter matches the capture/compare register"]
#[inline(always)]
pub fn inactive_on_match(self) -> &'a mut W {
self.variant(OC1MW::INACTIVEONMATCH)
}
#[doc = "OCyREF toggles when TIMx_CNT=TIMx_CCRy"]
#[inline(always)]
pub fn toggle(self) -> &'a mut W {
self.variant(OC1MW::TOGGLE)
}
#[doc = "OCyREF is forced low"]
#[inline(always)]
pub fn force_inactive(self) -> &'a mut W {
self.variant(OC1MW::FORCEINACTIVE)
}
#[doc = "OCyREF is forced high"]
#[inline(always)]
pub fn force_active(self) -> &'a mut W {
self.variant(OC1MW::FORCEACTIVE)
}
#[doc = "In upcounting, channel is active as long as TIMx_CNT<TIMx_CCRy else inactive. In downcounting, channel is inactive as long as TIMx_CNT>TIMx_CCRy else active"]
#[inline(always)]
pub fn pwm_mode1(self) -> &'a mut W {
self.variant(OC1MW::PWMMODE1)
}
#[doc = "Inversely to PwmMode1"]
#[inline(always)]
pub fn pwm_mode2(self) -> &'a mut W {
self.variant(OC1MW::PWMMODE2)
}
#[doc = "Retriggerable OPM mode 1 - In up-counting mode, the channel is active until a trigger event is detected (on TRGI signal). In down-counting mode, the channel is inactive"]
#[inline(always)]
pub fn opm_mode1(self) -> &'a mut W {
self.variant(OC1MW::OPMMODE1)
}
#[doc = "Inversely to OpmMode1"]
#[inline(always)]
pub fn opm_mode2(self) -> &'a mut W {
self.variant(OC1MW::OPMMODE2)
}
#[doc = "OCyREF has the same behavior as in PWM mode 1. OCyREFC is the logical OR between OC1REF and OC2REF"]
#[inline(always)]
pub fn combined_pwm_mode1(self) -> &'a mut W {
self.variant(OC1MW::COMBINEDPWMMODE1)
}
#[doc = "OCyREF has the same behavior as in PWM mode 2. OCyREFC is the logical AND between OC1REF and OC2REF"]
#[inline(always)]
pub fn combined_pwm_mode2(self) -> &'a mut W {
self.variant(OC1MW::COMBINEDPWMMODE2)
}
#[doc = "OCyREF has the same behavior as in PWM mode 1. OCyREFC outputs OC1REF when the counter is counting up, OC2REF when it is counting down"]
#[inline(always)]
pub fn asymmetric_pwm_mode1(self) -> &'a mut W {
self.variant(OC1MW::ASYMMETRICPWMMODE1)
}
#[doc = "OCyREF has the same behavior as in PWM mode 2. OCyREFC outputs OC1REF when the counter is counting up, OC2REF when it is counting down"]
#[inline(always)]
pub fn asymmetric_pwm_mode2(self) -> &'a mut W {
self.variant(OC1MW::ASYMMETRICPWMMODE2)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub unsafe fn bits(self, value: u8) -> &'a mut W {
self.w.bits &= !(0x07 << 12);
self.w.bits |= ((value as u32) & 0x07) << 12;
self.w
}
}
#[doc = r"Value of the field"]
pub struct OC2CER {
bits: bool,
}
impl OC2CER {
#[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 _OC2CEW<'a> {
w: &'a mut W,
}
impl<'a> _OC2CEW<'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 << 15);
self.w.bits |= ((value as u32) & 0x01) << 15;
self.w
}
}
#[doc = r"Value of the field"]
pub struct OC1M_3R {
bits: bool,
}
impl OC1M_3R {
#[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 _OC1M_3W<'a> {
w: &'a mut W,
}
impl<'a> _OC1M_3W<'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 << 16);
self.w.bits |= ((value as u32) & 0x01) << 16;
self.w
}
}
#[doc = r"Value of the field"]
pub struct OC2M_3R {
bits: bool,
}
impl OC2M_3R {
#[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 _OC2M_3W<'a> {
w: &'a mut W,
}
impl<'a> _OC2M_3W<'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
}
}
impl R {
#[doc = r"Value of the register as raw bits"]
#[inline(always)]
pub fn bits(&self) -> u32 {
self.bits
}
#[doc = "Bits 0:1 - CC1S"]
#[inline(always)]
pub fn cc1s(&self) -> CC1SR {
CC1SR::_from(((self.bits >> 0) & 0x03) as u8)
}
#[doc = "Bit 2 - OC1FE"]
#[inline(always)]
pub fn oc1fe(&self) -> OC1FER {
let bits = ((self.bits >> 2) & 0x01) != 0;
OC1FER { bits }
}
#[doc = "Bit 3 - OC1PE"]
#[inline(always)]
pub fn oc1pe(&self) -> OC1PER {
OC1PER::_from(((self.bits >> 3) & 0x01) != 0)
}
#[doc = "Bits 4:6 - OC1M"]
#[inline(always)]
pub fn oc1m(&self) -> OC1MR {
OC1MR::_from(((self.bits >> 4) & 0x07) as u8)
}
#[doc = "Bit 7 - OC1CE"]
#[inline(always)]
pub fn oc1ce(&self) -> OC1CER {
let bits = ((self.bits >> 7) & 0x01) != 0;
OC1CER { bits }
}
#[doc = "Bits 8:9 - CC2S"]
#[inline(always)]
pub fn cc2s(&self) -> CC2SR {
CC2SR::_from(((self.bits >> 8) & 0x03) as u8)
}
#[doc = "Bit 10 - OC2FE"]
#[inline(always)]
pub fn oc2fe(&self) -> OC2FER {
let bits = ((self.bits >> 10) & 0x01) != 0;
OC2FER { bits }
}
#[doc = "Bit 11 - OC2PE"]
#[inline(always)]
pub fn oc2pe(&self) -> OC2PER {
OC2PER::_from(((self.bits >> 11) & 0x01) != 0)
}
#[doc = "Bits 12:14 - OC2M"]
#[inline(always)]
pub fn oc2m(&self) -> OC2MR {
OC2MR::_from(((self.bits >> 12) & 0x07) as u8)
}
#[doc = "Bit 15 - OC2CE"]
#[inline(always)]
pub fn oc2ce(&self) -> OC2CER {
let bits = ((self.bits >> 15) & 0x01) != 0;
OC2CER { bits }
}
#[doc = "Bit 16 - Output Compare 1 mode - bit 3"]
#[inline(always)]
pub fn oc1m_3(&self) -> OC1M_3R {
let bits = ((self.bits >> 16) & 0x01) != 0;
OC1M_3R { bits }
}
#[doc = "Bit 24 - Output Compare 2 mode - bit 3"]
#[inline(always)]
pub fn oc2m_3(&self) -> OC2M_3R {
let bits = ((self.bits >> 24) & 0x01) != 0;
OC2M_3R { 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:1 - CC1S"]
#[inline(always)]
pub fn cc1s(&mut self) -> _CC1SW {
_CC1SW { w: self }
}
#[doc = "Bit 2 - OC1FE"]
#[inline(always)]
pub fn oc1fe(&mut self) -> _OC1FEW {
_OC1FEW { w: self }
}
#[doc = "Bit 3 - OC1PE"]
#[inline(always)]
pub fn oc1pe(&mut self) -> _OC1PEW {
_OC1PEW { w: self }
}
#[doc = "Bits 4:6 - OC1M"]
#[inline(always)]
pub fn oc1m(&mut self) -> _OC1MW {
_OC1MW { w: self }
}
#[doc = "Bit 7 - OC1CE"]
#[inline(always)]
pub fn oc1ce(&mut self) -> _OC1CEW {
_OC1CEW { w: self }
}
#[doc = "Bits 8:9 - CC2S"]
#[inline(always)]
pub fn cc2s(&mut self) -> _CC2SW {
_CC2SW { w: self }
}
#[doc = "Bit 10 - OC2FE"]
#[inline(always)]
pub fn oc2fe(&mut self) -> _OC2FEW {
_OC2FEW { w: self }
}
#[doc = "Bit 11 - OC2PE"]
#[inline(always)]
pub fn oc2pe(&mut self) -> _OC2PEW {
_OC2PEW { w: self }
}
#[doc = "Bits 12:14 - OC2M"]
#[inline(always)]
pub fn oc2m(&mut self) -> _OC2MW {
_OC2MW { w: self }
}
#[doc = "Bit 15 - OC2CE"]
#[inline(always)]
pub fn oc2ce(&mut self) -> _OC2CEW {
_OC2CEW { w: self }
}
#[doc = "Bit 16 - Output Compare 1 mode - bit 3"]
#[inline(always)]
pub fn oc1m_3(&mut self) -> _OC1M_3W {
_OC1M_3W { w: self }
}
#[doc = "Bit 24 - Output Compare 2 mode - bit 3"]
#[inline(always)]
pub fn oc2m_3(&mut self) -> _OC2M_3W {
_OC2M_3W { w: self }
}
}