pub struct Timer<TIM> {
    pub regs: TIM,
    pub cfg: TimerConfig,
    /* private fields */
}
Expand description

Represents a General Purpose or Advanced Control timer.

Fields

regs: TIMcfg: TimerConfig

Implementations

Initialize a DFSDM peripheral, including enabling and resetting its RCC peripheral clock.

Enable a specific type of Timer interrupt.

Disable a specific type of Timer interrupt.

Clears interrupt associated with this timer.

If the interrupt is not cleared, it will immediately retrigger after the ISR has finished. For examlpe, place this at the top of your timer’s interrupt handler.

Enable the timer.

Disable the timer.

Check if the timer is enabled.

Set the timer frequency, in Hz. Overrides the period or frequency set in the constructor.

Set the timer period, in seconds. Overrides the period or frequency set in the constructor.

Set the auto-reload register value. Used for adjusting frequency.

Set the prescaler value. Used for adjusting frequency.

Reset the countdown; set the counter to 0.

Re-initialize the counter and generates an update of the registers. Note that the prescaler counter is cleared too (anyway the prescaler ratio is not affected). The counter is cleared. When changing timer frequency (or period) via PSC, you may need to run this. Alternatively, change the freq in an update ISR. Note from RM, PSC reg: PSC contains the value to be loaded in the active prescaler register at each update event (including when the counter is cleared through UG bit of TIMx_EGR register or through trigger controller when configured in “reset mode”).’ If you’re doing something where the updates can wait a cycle, this isn’t required. (eg PWM with changing duty period).

Read the current counter value.

Enables PWM output for a given channel and output compare, with an initial duty cycle, in Hz.

Return the integer associated with the maximum duty period.

See G4 RM, section 29.4.24: Dma burst mode. “The TIMx timers have the capability to generate multiple DMA requests upon a single event. The main purpose is to be able to re-program part of the timer multiple times without software overhead, but it can also be used to read several registers in a row, at regular intervals.”

Enables basic PWM input. TODO: Doesn’t work yet. L4 RM, section 26.3.8

Set Output Compare Mode. See docs on the OutputCompare enum.

Return the set duty period for a given channel. Divide by get_max_duty() to find the portion of the duty cycle used.

Set the duty cycle, as a portion of ARR (get_max_duty()). Note that this needs to be re-run if you change ARR at any point.

Set output polarity. See docs on the Polarity enum.

Set complementary output polarity. See docs on the Polarity enum.

Disables capture compare on a specific channel.

Enables capture compare on a specific channel.

Set Capture Compare Mode. See docs on the CaptureCompare enum.

Set preload mode. OC1PE: Output Compare 1 preload enable 0: Preload register on TIMx_CCR1 disabled. TIMx_CCR1 can be written at anytime, the new value is taken in account immediately. 1: Preload register on TIMx_CCR1 enabled. Read/Write operations access the preload register. TIMx_CCR1 preload value is loaded in the active register at each update event. Note: 1: These bits can not be modified as long as LOCK level 3 has been programmed (LOCK bits in TIMx_BDTR register) and CC1S=’00’ (the channel is configured in output). 2: The PWM mode can be used without validating the preload register only in one pulse mode (OPM bit set in TIMx_CR1 register). Else the behavior is not guaranteed.

Setting preload is required to enable PWM.

Initialize a DFSDM peripheral, including enabling and resetting its RCC peripheral clock.

Enable a specific type of Timer interrupt.

Disable a specific type of Timer interrupt.

Clears interrupt associated with this timer.

If the interrupt is not cleared, it will immediately retrigger after the ISR has finished. For examlpe, place this at the top of your timer’s interrupt handler.

Enable the timer.

Disable the timer.

Check if the timer is enabled.

Set the timer frequency, in Hz. Overrides the period or frequency set in the constructor.

Set the timer period, in seconds. Overrides the period or frequency set in the constructor.

Set the auto-reload register value. Used for adjusting frequency.

Set the prescaler value. Used for adjusting frequency.

Reset the countdown; set the counter to 0.

Re-initialize the counter and generates an update of the registers. Note that the prescaler counter is cleared too (anyway the prescaler ratio is not affected). The counter is cleared. When changing timer frequency (or period) via PSC, you may need to run this. Alternatively, change the freq in an update ISR. Note from RM, PSC reg: PSC contains the value to be loaded in the active prescaler register at each update event (including when the counter is cleared through UG bit of TIMx_EGR register or through trigger controller when configured in “reset mode”).’ If you’re doing something where the updates can wait a cycle, this isn’t required. (eg PWM with changing duty period).

Read the current counter value.

Enables PWM output for a given channel and output compare, with an initial duty cycle, in Hz.

Return the integer associated with the maximum duty period.

See G4 RM, section 29.4.24: Dma burst mode. “The TIMx timers have the capability to generate multiple DMA requests upon a single event. The main purpose is to be able to re-program part of the timer multiple times without software overhead, but it can also be used to read several registers in a row, at regular intervals.”

Function that allows us to set direction only on timers that have this option.

Enables basic PWM input. TODO: Doesn’t work yet. L4 RM, section 26.3.8

Set Output Compare Mode. See docs on the OutputCompare enum.

Return the set duty period for a given channel. Divide by get_max_duty() to find the portion of the duty cycle used.

Set the duty cycle, as a portion of ARR (get_max_duty()). Note that this needs to be re-run if you change ARR at any point.

Set timer alignment to Edge, or one of 3 center modes. STM32F303 ref man, section 21.4.1: Bits 6:5 CMS: Center-aligned mode selection 00: Edge-aligned mode. The counter counts up or down depending on the direction bit (DIR). 01: Center-aligned mode 1. The counter counts up and down alternatively. Output compare interrupt flags of channels configured in output (CCxS=00 in TIMx_CCMRx register) are set only when the counter is counting down. 10: Center-aligned mode 2. The counter counts up and down alternatively. Output compare interrupt flags of channels configured in output (CCxS=00 in TIMx_CCMRx register) are set only when the counter is counting up. 11: Center-aligned mode 3. The counter counts up and down alternatively. Output compare interrupt flags of channels configured in output (CCxS=00 in TIMx_CCMRx register) are set both when the counter is counting up or down.

Set output polarity. See docs on the Polarity enum.

Set complementary output polarity. See docs on the Polarity enum.

Disables capture compare on a specific channel.

Enables capture compare on a specific channel.

Set Capture Compare Mode. See docs on the CaptureCompare enum.

Set preload mode. OC1PE: Output Compare 1 preload enable 0: Preload register on TIMx_CCR1 disabled. TIMx_CCR1 can be written at anytime, the new value is taken in account immediately. 1: Preload register on TIMx_CCR1 enabled. Read/Write operations access the preload register. TIMx_CCR1 preload value is loaded in the active register at each update event. Note: 1: These bits can not be modified as long as LOCK level 3 has been programmed (LOCK bits in TIMx_BDTR register) and CC1S=’00’ (the channel is configured in output). 2: The PWM mode can be used without validating the preload register only in one pulse mode (OPM bit set in TIMx_CR1 register). Else the behavior is not guaranteed.

Setting preload is required to enable PWM.

Initialize a DFSDM peripheral, including enabling and resetting its RCC peripheral clock.

Enable a specific type of Timer interrupt.

Disable a specific type of Timer interrupt.

Clears interrupt associated with this timer.

If the interrupt is not cleared, it will immediately retrigger after the ISR has finished. For examlpe, place this at the top of your timer’s interrupt handler.

Enable the timer.

Disable the timer.

Check if the timer is enabled.

Set the timer frequency, in Hz. Overrides the period or frequency set in the constructor.

Set the timer period, in seconds. Overrides the period or frequency set in the constructor.

Set the auto-reload register value. Used for adjusting frequency.

Set the prescaler value. Used for adjusting frequency.

Reset the countdown; set the counter to 0.

Re-initialize the counter and generates an update of the registers. Note that the prescaler counter is cleared too (anyway the prescaler ratio is not affected). The counter is cleared. When changing timer frequency (or period) via PSC, you may need to run this. Alternatively, change the freq in an update ISR. Note from RM, PSC reg: PSC contains the value to be loaded in the active prescaler register at each update event (including when the counter is cleared through UG bit of TIMx_EGR register or through trigger controller when configured in “reset mode”).’ If you’re doing something where the updates can wait a cycle, this isn’t required. (eg PWM with changing duty period).

Read the current counter value.

Enables PWM output for a given channel and output compare, with an initial duty cycle, in Hz.

Return the integer associated with the maximum duty period.

See G4 RM, section 29.4.24: Dma burst mode. “The TIMx timers have the capability to generate multiple DMA requests upon a single event. The main purpose is to be able to re-program part of the timer multiple times without software overhead, but it can also be used to read several registers in a row, at regular intervals.”

Function that allows us to set direction only on timers that have this option.

Enables basic PWM input. TODO: Doesn’t work yet. L4 RM, section 26.3.8

Set Output Compare Mode. See docs on the OutputCompare enum.

Return the set duty period for a given channel. Divide by get_max_duty() to find the portion of the duty cycle used.

Set the duty cycle, as a portion of ARR (get_max_duty()). Note that this needs to be re-run if you change ARR at any point.

Set timer alignment to Edge, or one of 3 center modes. STM32F303 ref man, section 21.4.1: Bits 6:5 CMS: Center-aligned mode selection 00: Edge-aligned mode. The counter counts up or down depending on the direction bit (DIR). 01: Center-aligned mode 1. The counter counts up and down alternatively. Output compare interrupt flags of channels configured in output (CCxS=00 in TIMx_CCMRx register) are set only when the counter is counting down. 10: Center-aligned mode 2. The counter counts up and down alternatively. Output compare interrupt flags of channels configured in output (CCxS=00 in TIMx_CCMRx register) are set only when the counter is counting up. 11: Center-aligned mode 3. The counter counts up and down alternatively. Output compare interrupt flags of channels configured in output (CCxS=00 in TIMx_CCMRx register) are set both when the counter is counting up or down.

Set output polarity. See docs on the Polarity enum.

Set complementary output polarity. See docs on the Polarity enum.

Disables capture compare on a specific channel.

Enables capture compare on a specific channel.

Set Capture Compare Mode. See docs on the CaptureCompare enum.

Set preload mode. OC1PE: Output Compare 1 preload enable 0: Preload register on TIMx_CCR1 disabled. TIMx_CCR1 can be written at anytime, the new value is taken in account immediately. 1: Preload register on TIMx_CCR1 enabled. Read/Write operations access the preload register. TIMx_CCR1 preload value is loaded in the active register at each update event. Note: 1: These bits can not be modified as long as LOCK level 3 has been programmed (LOCK bits in TIMx_BDTR register) and CC1S=’00’ (the channel is configured in output). 2: The PWM mode can be used without validating the preload register only in one pulse mode (OPM bit set in TIMx_CR1 register). Else the behavior is not guaranteed.

Setting preload is required to enable PWM.

Initialize a DFSDM peripheral, including enabling and resetting its RCC peripheral clock.

Enable a specific type of Timer interrupt.

Disable a specific type of Timer interrupt.

Clears interrupt associated with this timer.

If the interrupt is not cleared, it will immediately retrigger after the ISR has finished. For examlpe, place this at the top of your timer’s interrupt handler.

Enable the timer.

Disable the timer.

Check if the timer is enabled.

Set the timer frequency, in Hz. Overrides the period or frequency set in the constructor.

Set the timer period, in seconds. Overrides the period or frequency set in the constructor.

Set the auto-reload register value. Used for adjusting frequency.

Set the prescaler value. Used for adjusting frequency.

Reset the countdown; set the counter to 0.

Re-initialize the counter and generates an update of the registers. Note that the prescaler counter is cleared too (anyway the prescaler ratio is not affected). The counter is cleared. When changing timer frequency (or period) via PSC, you may need to run this. Alternatively, change the freq in an update ISR. Note from RM, PSC reg: PSC contains the value to be loaded in the active prescaler register at each update event (including when the counter is cleared through UG bit of TIMx_EGR register or through trigger controller when configured in “reset mode”).’ If you’re doing something where the updates can wait a cycle, this isn’t required. (eg PWM with changing duty period).

Read the current counter value.

Enables PWM output for a given channel and output compare, with an initial duty cycle, in Hz.

Return the integer associated with the maximum duty period.

See G4 RM, section 29.4.24: Dma burst mode. “The TIMx timers have the capability to generate multiple DMA requests upon a single event. The main purpose is to be able to re-program part of the timer multiple times without software overhead, but it can also be used to read several registers in a row, at regular intervals.”

Function that allows us to set direction only on timers that have this option.

Enables basic PWM input. TODO: Doesn’t work yet. L4 RM, section 26.3.8

Set Output Compare Mode. See docs on the OutputCompare enum.

Return the set duty period for a given channel. Divide by get_max_duty() to find the portion of the duty cycle used.

Set the duty cycle, as a portion of ARR (get_max_duty()). Note that this needs to be re-run if you change ARR at any point.

Set timer alignment to Edge, or one of 3 center modes. STM32F303 ref man, section 21.4.1: Bits 6:5 CMS: Center-aligned mode selection 00: Edge-aligned mode. The counter counts up or down depending on the direction bit (DIR). 01: Center-aligned mode 1. The counter counts up and down alternatively. Output compare interrupt flags of channels configured in output (CCxS=00 in TIMx_CCMRx register) are set only when the counter is counting down. 10: Center-aligned mode 2. The counter counts up and down alternatively. Output compare interrupt flags of channels configured in output (CCxS=00 in TIMx_CCMRx register) are set only when the counter is counting up. 11: Center-aligned mode 3. The counter counts up and down alternatively. Output compare interrupt flags of channels configured in output (CCxS=00 in TIMx_CCMRx register) are set both when the counter is counting up or down.

Set output polarity. See docs on the Polarity enum.

Set complementary output polarity. See docs on the Polarity enum.

Disables capture compare on a specific channel.

Enables capture compare on a specific channel.

Set Capture Compare Mode. See docs on the CaptureCompare enum.

Set preload mode. OC1PE: Output Compare 1 preload enable 0: Preload register on TIMx_CCR1 disabled. TIMx_CCR1 can be written at anytime, the new value is taken in account immediately. 1: Preload register on TIMx_CCR1 enabled. Read/Write operations access the preload register. TIMx_CCR1 preload value is loaded in the active register at each update event. Note: 1: These bits can not be modified as long as LOCK level 3 has been programmed (LOCK bits in TIMx_BDTR register) and CC1S=’00’ (the channel is configured in output). 2: The PWM mode can be used without validating the preload register only in one pulse mode (OPM bit set in TIMx_CR1 register). Else the behavior is not guaranteed.

Setting preload is required to enable PWM.

Initialize a DFSDM peripheral, including enabling and resetting its RCC peripheral clock.

Enable a specific type of Timer interrupt.

Disable a specific type of Timer interrupt.

Clears interrupt associated with this timer.

If the interrupt is not cleared, it will immediately retrigger after the ISR has finished. For examlpe, place this at the top of your timer’s interrupt handler.

Enable the timer.

Disable the timer.

Check if the timer is enabled.

Set the timer frequency, in Hz. Overrides the period or frequency set in the constructor.

Set the timer period, in seconds. Overrides the period or frequency set in the constructor.

Set the auto-reload register value. Used for adjusting frequency.

Set the prescaler value. Used for adjusting frequency.

Reset the countdown; set the counter to 0.

Re-initialize the counter and generates an update of the registers. Note that the prescaler counter is cleared too (anyway the prescaler ratio is not affected). The counter is cleared. When changing timer frequency (or period) via PSC, you may need to run this. Alternatively, change the freq in an update ISR. Note from RM, PSC reg: PSC contains the value to be loaded in the active prescaler register at each update event (including when the counter is cleared through UG bit of TIMx_EGR register or through trigger controller when configured in “reset mode”).’ If you’re doing something where the updates can wait a cycle, this isn’t required. (eg PWM with changing duty period).

Read the current counter value.

Enables PWM output for a given channel and output compare, with an initial duty cycle, in Hz.

Return the integer associated with the maximum duty period.

See G4 RM, section 29.4.24: Dma burst mode. “The TIMx timers have the capability to generate multiple DMA requests upon a single event. The main purpose is to be able to re-program part of the timer multiple times without software overhead, but it can also be used to read several registers in a row, at regular intervals.”

Function that allows us to set direction only on timers that have this option.

Enables basic PWM input. TODO: Doesn’t work yet. L4 RM, section 26.3.8

Set Output Compare Mode. See docs on the OutputCompare enum.

Return the set duty period for a given channel. Divide by get_max_duty() to find the portion of the duty cycle used.

Set the duty cycle, as a portion of ARR (get_max_duty()). Note that this needs to be re-run if you change ARR at any point.

Set timer alignment to Edge, or one of 3 center modes. STM32F303 ref man, section 21.4.1: Bits 6:5 CMS: Center-aligned mode selection 00: Edge-aligned mode. The counter counts up or down depending on the direction bit (DIR). 01: Center-aligned mode 1. The counter counts up and down alternatively. Output compare interrupt flags of channels configured in output (CCxS=00 in TIMx_CCMRx register) are set only when the counter is counting down. 10: Center-aligned mode 2. The counter counts up and down alternatively. Output compare interrupt flags of channels configured in output (CCxS=00 in TIMx_CCMRx register) are set only when the counter is counting up. 11: Center-aligned mode 3. The counter counts up and down alternatively. Output compare interrupt flags of channels configured in output (CCxS=00 in TIMx_CCMRx register) are set both when the counter is counting up or down.

Set output polarity. See docs on the Polarity enum.

Set complementary output polarity. See docs on the Polarity enum.

Disables capture compare on a specific channel.

Enables capture compare on a specific channel.

Set Capture Compare Mode. See docs on the CaptureCompare enum.

Set preload mode. OC1PE: Output Compare 1 preload enable 0: Preload register on TIMx_CCR1 disabled. TIMx_CCR1 can be written at anytime, the new value is taken in account immediately. 1: Preload register on TIMx_CCR1 enabled. Read/Write operations access the preload register. TIMx_CCR1 preload value is loaded in the active register at each update event. Note: 1: These bits can not be modified as long as LOCK level 3 has been programmed (LOCK bits in TIMx_BDTR register) and CC1S=’00’ (the channel is configured in output). 2: The PWM mode can be used without validating the preload register only in one pulse mode (OPM bit set in TIMx_CR1 register). Else the behavior is not guaranteed.

Setting preload is required to enable PWM.

Initialize a DFSDM peripheral, including enabling and resetting its RCC peripheral clock.

Enable a specific type of Timer interrupt.

Disable a specific type of Timer interrupt.

Clears interrupt associated with this timer.

If the interrupt is not cleared, it will immediately retrigger after the ISR has finished. For examlpe, place this at the top of your timer’s interrupt handler.

Enable the timer.

Disable the timer.

Check if the timer is enabled.

Set the timer frequency, in Hz. Overrides the period or frequency set in the constructor.

Set the timer period, in seconds. Overrides the period or frequency set in the constructor.

Set the auto-reload register value. Used for adjusting frequency.

Set the prescaler value. Used for adjusting frequency.

Reset the countdown; set the counter to 0.

Re-initialize the counter and generates an update of the registers. Note that the prescaler counter is cleared too (anyway the prescaler ratio is not affected). The counter is cleared. When changing timer frequency (or period) via PSC, you may need to run this. Alternatively, change the freq in an update ISR. Note from RM, PSC reg: PSC contains the value to be loaded in the active prescaler register at each update event (including when the counter is cleared through UG bit of TIMx_EGR register or through trigger controller when configured in “reset mode”).’ If you’re doing something where the updates can wait a cycle, this isn’t required. (eg PWM with changing duty period).

Read the current counter value.

Enables PWM output for a given channel and output compare, with an initial duty cycle, in Hz.

Return the integer associated with the maximum duty period.

See G4 RM, section 29.4.24: Dma burst mode. “The TIMx timers have the capability to generate multiple DMA requests upon a single event. The main purpose is to be able to re-program part of the timer multiple times without software overhead, but it can also be used to read several registers in a row, at regular intervals.”

Enables basic PWM input. TODO: Doesn’t work yet. L4 RM, section 26.3.8

Set Output Compare Mode. See docs on the OutputCompare enum.

Return the set duty period for a given channel. Divide by get_max_duty() to find the portion of the duty cycle used.

Set the duty cycle, as a portion of ARR (get_max_duty()). Note that this needs to be re-run if you change ARR at any point.

Set output polarity. See docs on the Polarity enum.

Set complementary output polarity. See docs on the Polarity enum.

Disables capture compare on a specific channel.

Enables capture compare on a specific channel.

Set Capture Compare Mode. See docs on the CaptureCompare enum.

Set preload mode. OC1PE: Output Compare 1 preload enable 0: Preload register on TIMx_CCR1 disabled. TIMx_CCR1 can be written at anytime, the new value is taken in account immediately. 1: Preload register on TIMx_CCR1 enabled. Read/Write operations access the preload register. TIMx_CCR1 preload value is loaded in the active register at each update event. Note: 1: These bits can not be modified as long as LOCK level 3 has been programmed (LOCK bits in TIMx_BDTR register) and CC1S=’00’ (the channel is configured in output). 2: The PWM mode can be used without validating the preload register only in one pulse mode (OPM bit set in TIMx_CR1 register). Else the behavior is not guaranteed.

Setting preload is required to enable PWM.

Initialize a DFSDM peripheral, including enabling and resetting its RCC peripheral clock.

Enable a specific type of Timer interrupt.

Disable a specific type of Timer interrupt.

Clears interrupt associated with this timer.

If the interrupt is not cleared, it will immediately retrigger after the ISR has finished. For examlpe, place this at the top of your timer’s interrupt handler.

Enable the timer.

Disable the timer.

Check if the timer is enabled.

Set the timer frequency, in Hz. Overrides the period or frequency set in the constructor.

Set the timer period, in seconds. Overrides the period or frequency set in the constructor.

Set the auto-reload register value. Used for adjusting frequency.

Set the prescaler value. Used for adjusting frequency.

Reset the countdown; set the counter to 0.

Re-initialize the counter and generates an update of the registers. Note that the prescaler counter is cleared too (anyway the prescaler ratio is not affected). The counter is cleared. When changing timer frequency (or period) via PSC, you may need to run this. Alternatively, change the freq in an update ISR. Note from RM, PSC reg: PSC contains the value to be loaded in the active prescaler register at each update event (including when the counter is cleared through UG bit of TIMx_EGR register or through trigger controller when configured in “reset mode”).’ If you’re doing something where the updates can wait a cycle, this isn’t required. (eg PWM with changing duty period).

Read the current counter value.

Enables PWM output for a given channel and output compare, with an initial duty cycle, in Hz.

Return the integer associated with the maximum duty period.

See G4 RM, section 29.4.24: Dma burst mode. “The TIMx timers have the capability to generate multiple DMA requests upon a single event. The main purpose is to be able to re-program part of the timer multiple times without software overhead, but it can also be used to read several registers in a row, at regular intervals.”

Enables basic PWM input. TODO: Doesn’t work yet. L4 RM, section 26.3.8

Set Output Compare Mode. See docs on the OutputCompare enum.

Return the set duty period for a given channel. Divide by get_max_duty() to find the portion of the duty cycle used.

Set the duty cycle, as a portion of ARR (get_max_duty()). Note that this needs to be re-run if you change ARR at any point.

Set output polarity. See docs on the Polarity enum.

Set complementary output polarity. See docs on the Polarity enum.

Disables capture compare on a specific channel.

Enables capture compare on a specific channel.

Set Capture Compare Mode. See docs on the CaptureCompare enum.

Set preload mode. OC1PE: Output Compare 1 preload enable 0: Preload register on TIMx_CCR1 disabled. TIMx_CCR1 can be written at anytime, the new value is taken in account immediately. 1: Preload register on TIMx_CCR1 enabled. Read/Write operations access the preload register. TIMx_CCR1 preload value is loaded in the active register at each update event. Note: 1: These bits can not be modified as long as LOCK level 3 has been programmed (LOCK bits in TIMx_BDTR register) and CC1S=’00’ (the channel is configured in output). 2: The PWM mode can be used without validating the preload register only in one pulse mode (OPM bit set in TIMx_CR1 register). Else the behavior is not guaranteed.

Setting preload is required to enable PWM.

Initialize a DFSDM peripheral, including enabling and resetting its RCC peripheral clock.

Enable a specific type of Timer interrupt.

Disable a specific type of Timer interrupt.

Clears interrupt associated with this timer.

If the interrupt is not cleared, it will immediately retrigger after the ISR has finished. For examlpe, place this at the top of your timer’s interrupt handler.

Enable the timer.

Disable the timer.

Check if the timer is enabled.

Set the timer frequency, in Hz. Overrides the period or frequency set in the constructor.

Set the timer period, in seconds. Overrides the period or frequency set in the constructor.

Set the auto-reload register value. Used for adjusting frequency.

Set the prescaler value. Used for adjusting frequency.

Reset the countdown; set the counter to 0.

Re-initialize the counter and generates an update of the registers. Note that the prescaler counter is cleared too (anyway the prescaler ratio is not affected). The counter is cleared. When changing timer frequency (or period) via PSC, you may need to run this. Alternatively, change the freq in an update ISR. Note from RM, PSC reg: PSC contains the value to be loaded in the active prescaler register at each update event (including when the counter is cleared through UG bit of TIMx_EGR register or through trigger controller when configured in “reset mode”).’ If you’re doing something where the updates can wait a cycle, this isn’t required. (eg PWM with changing duty period).

Read the current counter value.

Enables PWM output for a given channel and output compare, with an initial duty cycle, in Hz.

Return the integer associated with the maximum duty period.

See G4 RM, section 29.4.24: Dma burst mode. “The TIMx timers have the capability to generate multiple DMA requests upon a single event. The main purpose is to be able to re-program part of the timer multiple times without software overhead, but it can also be used to read several registers in a row, at regular intervals.”

Enables basic PWM input. TODO: Doesn’t work yet. L4 RM, section 26.3.8

Set Output Compare Mode. See docs on the OutputCompare enum.

Return the set duty period for a given channel. Divide by get_max_duty() to find the portion of the duty cycle used.

Set the duty cycle, as a portion of ARR (get_max_duty()). Note that this needs to be re-run if you change ARR at any point.

Set output polarity. See docs on the Polarity enum.

Set complementary output polarity. See docs on the Polarity enum.

Disables capture compare on a specific channel.

Enables capture compare on a specific channel.

Set Capture Compare Mode. See docs on the CaptureCompare enum.

Set preload mode. OC1PE: Output Compare 1 preload enable 0: Preload register on TIMx_CCR1 disabled. TIMx_CCR1 can be written at anytime, the new value is taken in account immediately. 1: Preload register on TIMx_CCR1 enabled. Read/Write operations access the preload register. TIMx_CCR1 preload value is loaded in the active register at each update event. Note: 1: These bits can not be modified as long as LOCK level 3 has been programmed (LOCK bits in TIMx_BDTR register) and CC1S=’00’ (the channel is configured in output). 2: The PWM mode can be used without validating the preload register only in one pulse mode (OPM bit set in TIMx_CR1 register). Else the behavior is not guaranteed.

Setting preload is required to enable PWM.

Trait Implementations

Pauses execution for ms milliseconds

Pauses execution for ms milliseconds

Pauses execution for ms milliseconds

Pauses execution for ms milliseconds

Pauses execution for ms milliseconds

Pauses execution for ms milliseconds

Pauses execution for ms milliseconds

Pauses execution for ms milliseconds

Pauses execution for ms milliseconds

Pauses execution for ms milliseconds

Pauses execution for ms milliseconds

Pauses execution for ms milliseconds

Pauses execution for ms milliseconds

Pauses execution for ms milliseconds

Pauses execution for ms milliseconds

Pauses execution for ms milliseconds

Pauses execution for ms milliseconds

Pauses execution for ms milliseconds

Pauses execution for ms milliseconds

Pauses execution for ms milliseconds

Pauses execution for ms milliseconds

Pauses execution for ms milliseconds

Pauses execution for ms milliseconds

Pauses execution for ms milliseconds

Pauses execution for us microseconds

Pauses execution for us microseconds

Pauses execution for us microseconds

Pauses execution for us microseconds

Pauses execution for us microseconds

Pauses execution for us microseconds

Pauses execution for us microseconds

Pauses execution for us microseconds

Pauses execution for us microseconds

Pauses execution for us microseconds

Pauses execution for us microseconds

Pauses execution for us microseconds

Pauses execution for us microseconds

Pauses execution for us microseconds

Pauses execution for us microseconds

Pauses execution for us microseconds

Pauses execution for us microseconds

Pauses execution for us microseconds

Pauses execution for us microseconds

Pauses execution for us microseconds

Pauses execution for us microseconds

Pauses execution for us microseconds

Pauses execution for us microseconds

Pauses execution for us microseconds

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.