169 if (((
TIM_SR(timer_peripheral) &
170 TIM_DIER(timer_peripheral) & flag) == 0) ||
188 if ((
TIM_SR(timer_peripheral) & flag) != 0) {
206 TIM_SR(timer_peripheral) = ~flag;
238 uint32_t alignment, uint32_t direction)
242 cr1 =
TIM_CR1(timer_peripheral);
246 cr1 |= clock_div | alignment | direction;
248 TIM_CR1(timer_peripheral) = cr1;
266 TIM_CR1(timer_peripheral) &= ~TIM_CR1_CKD_CK_INT_MASK;
267 TIM_CR1(timer_peripheral) |= clock_div;
298 TIM_CR1(timer_peripheral) &= ~TIM_CR1_ARPE;
314 TIM_CR1(timer_peripheral) &= ~TIM_CR1_CMS_MASK;
315 TIM_CR1(timer_peripheral) |= alignment;
329 TIM_CR1(timer_peripheral) &= ~TIM_CR1_DIR_DOWN;
367 TIM_CR1(timer_peripheral) &= ~TIM_CR1_OPM;
384 TIM_CR1(timer_peripheral) &= ~TIM_CR1_URS;
409 TIM_CR1(timer_peripheral) &= ~TIM_CR1_UDIS;
449 TIM_CR1(timer_peripheral) &= ~TIM_CR1_CEN;
519 TIM_CR2(timer_peripheral) &= ~TIM_CR2_TI1S;
535 TIM_CR2(timer_peripheral) &= ~TIM_CR2_MMS_MASK;
536 TIM_CR2(timer_peripheral) |= mode;
550 TIM_CR2(timer_peripheral) &= ~TIM_CR2_CCDS;
602 TIM_CR2(timer_peripheral) &= ~TIM_CR2_CCUS;
637 TIM_CR2(timer_peripheral) &= ~TIM_CR2_CCPC;
652 TIM_PSC(timer_peripheral) = value;
670 TIM_RCR(timer_peripheral) = value;
685 TIM_ARR(timer_peripheral) = period;
740 TIM_CCMR1(timer_peripheral) &= ~TIM_CCMR1_OC1CE;
743 TIM_CCMR1(timer_peripheral) &= ~TIM_CCMR1_OC2CE;
746 TIM_CCMR2(timer_peripheral) &= ~TIM_CCMR2_OC3CE;
749 TIM_CCMR2(timer_peripheral) &= ~TIM_CCMR2_OC4CE;
814 TIM_CCMR1(timer_peripheral) &= ~TIM_CCMR1_OC1FE;
817 TIM_CCMR1(timer_peripheral) &= ~TIM_CCMR1_OC2FE;
820 TIM_CCMR2(timer_peripheral) &= ~TIM_CCMR2_OC3FE;
823 TIM_CCMR2(timer_peripheral) &= ~TIM_CCMR2_OC4FE;
865 TIM_CCMR1(timer_peripheral) &= ~TIM_CCMR1_CC1S_MASK;
867 TIM_CCMR1(timer_peripheral) &= ~TIM_CCMR1_OC1M_MASK;
897 TIM_CCMR1(timer_peripheral) &= ~TIM_CCMR1_CC2S_MASK;
899 TIM_CCMR1(timer_peripheral) &= ~TIM_CCMR1_OC2M_MASK;
929 TIM_CCMR2(timer_peripheral) &= ~TIM_CCMR2_CC3S_MASK;
931 TIM_CCMR2(timer_peripheral) &= ~TIM_CCMR2_OC3M_MASK;
961 TIM_CCMR2(timer_peripheral) &= ~TIM_CCMR2_CC4S_MASK;
963 TIM_CCMR2(timer_peripheral) &= ~TIM_CCMR2_OC4M_MASK;
1045 TIM_CCMR1(timer_peripheral) &= ~TIM_CCMR1_OC1PE;
1048 TIM_CCMR1(timer_peripheral) &= ~TIM_CCMR1_OC2PE;
1051 TIM_CCMR2(timer_peripheral) &= ~TIM_CCMR2_OC3PE;
1054 TIM_CCMR2(timer_peripheral) &= ~TIM_CCMR2_OC4PE;
1080 TIM_CCER(timer_peripheral) &= ~TIM_CCER_CC1P;
1083 TIM_CCER(timer_peripheral) &= ~TIM_CCER_CC2P;
1086 TIM_CCER(timer_peripheral) &= ~TIM_CCER_CC3P;
1089 TIM_CCER(timer_peripheral) &= ~TIM_CCER_CC4P;
1092 TIM_CCER(timer_peripheral) &= ~TIM_CCER_CC1NP;
1095 TIM_CCER(timer_peripheral) &= ~TIM_CCER_CC2NP;
1098 TIM_CCER(timer_peripheral) &= ~TIM_CCER_CC3NP;
1197 TIM_CCER(timer_peripheral) &= ~TIM_CCER_CC1E;
1200 TIM_CCER(timer_peripheral) &= ~TIM_CCER_CC2E;
1203 TIM_CCER(timer_peripheral) &= ~TIM_CCER_CC3E;
1206 TIM_CCER(timer_peripheral) &= ~TIM_CCER_CC4E;
1209 TIM_CCER(timer_peripheral) &= ~TIM_CCER_CC1NE;
1212 TIM_CCER(timer_peripheral) &= ~TIM_CCER_CC2NE;
1215 TIM_CCER(timer_peripheral) &= ~TIM_CCER_CC3NE;
1283 TIM_CR2(timer_peripheral) &= ~TIM_CR2_OIS1;
1286 TIM_CR2(timer_peripheral) &= ~TIM_CR2_OIS1N;
1289 TIM_CR2(timer_peripheral) &= ~TIM_CR2_OIS2;
1292 TIM_CR2(timer_peripheral) &= ~TIM_CR2_OIS2N;
1295 TIM_CR2(timer_peripheral) &= ~TIM_CR2_OIS3;
1298 TIM_CR2(timer_peripheral) &= ~TIM_CR2_OIS3N;
1301 TIM_CR2(timer_peripheral) &= ~TIM_CR2_OIS4;
1324 TIM_CCR1(timer_peripheral) = value;
1327 TIM_CCR2(timer_peripheral) = value;
1330 TIM_CCR3(timer_peripheral) = value;
1333 TIM_CCR4(timer_peripheral) = value;
1378 TIM_BDTR(timer_peripheral) &= ~TIM_BDTR_MOE;
1414 TIM_BDTR(timer_peripheral) &= ~TIM_BDTR_AOE;
1446 TIM_BDTR(timer_peripheral) &= ~TIM_BDTR_BKP;
1478 TIM_BDTR(timer_peripheral) &= ~TIM_BDTR_BKE;
1517 TIM_BDTR(timer_peripheral) &= ~TIM_BDTR_OSSR;
1552 TIM_BDTR(timer_peripheral) &= ~TIM_BDTR_OSSI;
1571 TIM_BDTR(timer_peripheral) |= lock;
1596 TIM_BDTR(timer_peripheral) |= deadtime;
1614 TIM_EGR(timer_peripheral) |= event;
1628 return TIM_CNT(timer_peripheral);
1642 TIM_CNT(timer_peripheral) = count;
1664 TIM_CCMR1(timer_peripheral) &= ~TIM_CCMR1_IC1F_MASK;
1665 TIM_CCMR1(timer_peripheral) |= flt << 4;
1668 TIM_CCMR1(timer_peripheral) &= ~TIM_CCMR1_IC2F_MASK;
1669 TIM_CCMR1(timer_peripheral) |= flt << 12;
1672 TIM_CCMR2(timer_peripheral) &= ~TIM_CCMR2_IC3F_MASK;
1673 TIM_CCMR2(timer_peripheral) |= flt << 4;
1676 TIM_CCMR2(timer_peripheral) &= ~TIM_CCMR2_IC4F_MASK;
1677 TIM_CCMR2(timer_peripheral) |= flt << 12;
1697 TIM_CCMR1(timer_peripheral) &= ~TIM_CCMR1_IC1PSC_MASK;
1698 TIM_CCMR1(timer_peripheral) |= psc << 2;
1701 TIM_CCMR1(timer_peripheral) &= ~TIM_CCMR1_IC2PSC_MASK;
1702 TIM_CCMR1(timer_peripheral) |= psc << 10;
1705 TIM_CCMR2(timer_peripheral) &= ~TIM_CCMR2_IC3PSC_MASK;
1706 TIM_CCMR2(timer_peripheral) |= psc << 2;
1709 TIM_CCMR2(timer_peripheral) &= ~TIM_CCMR2_IC4PSC_MASK;
1710 TIM_CCMR2(timer_peripheral) |= psc << 10;
1749 TIM_CCMR1(timer_peripheral) &= ~TIM_CCMR1_CC1S_MASK;
1753 TIM_CCMR1(timer_peripheral) &= ~TIM_CCMR1_CC2S_MASK;
1757 TIM_CCMR2(timer_peripheral) &= ~TIM_CCMR2_CC3S_MASK;
1761 TIM_CCMR2(timer_peripheral) &= ~TIM_CCMR2_CC4S_MASK;
1776 TIM_CCER(timer_peripheral) |= (0x1 << (ic * 4));
1788 TIM_CCER(timer_peripheral) &= ~(0x1 << (ic * 4));
1806 TIM_SMCR(timer_peripheral) &= ~TIM_SMCR_ETF_MASK;
1807 TIM_SMCR(timer_peripheral) |= flt << 8;
1821 TIM_SMCR(timer_peripheral) &= ~TIM_SMCR_ETPS_MASK;
1822 TIM_SMCR(timer_peripheral) |= psc << 12;
1837 TIM_SMCR(timer_peripheral) &= ~TIM_SMCR_ETP;
1850 TIM_SMCR(timer_peripheral) &= ~TIM_SMCR_SMS_MASK;
1851 TIM_SMCR(timer_peripheral) |= mode;
1863 TIM_SMCR(timer_peripheral) &= ~TIM_SMCR_TS_MASK;
1864 TIM_SMCR(timer_peripheral) |= trigger;
1880 TIM_SMCR(timer_peripheral) &= ~TIM_SMCR_ECE;
#define TIM_SR_BIF
Break interrupt flag.
#define TIM_CR1_CKD_CK_INT_MASK
#define TIM_CR2_OIS3N
Output idle state 3 (OC3N output)
#define TIM_CR2_OIS1
Output idle state 1 (OC1 output)
#define TIM_CR2_OIS2
Output idle state 2 (OC2 output)
#define TIM_CR2_OIS2N
Output idle state 2 (OC2N output)
#define TIM_CR2_OIS4
Output idle state 4 (OC4 output)
#define TIM_CR2_OIS3
Output idle state 3 (OC3 output)
#define TIM_CR2_OIS1N
Output idle state 1 (OC1N output)
#define TIM_CCMR2_CC4S_OUT
#define TIM_CCMR2_OC4M_TOGGLE
#define TIM_CCMR2_OC4M_FORCE_HIGH
#define TIM_CCR4(tim_base)
#define TIM_CCMR2_OC3M_FORCE_HIGH
#define TIM_PSC(tim_base)
tim_ic_psc
Input Capture input prescaler.
#define TIM_CCMR2_OC4M_PWM2
#define TIM_CCMR1_OC2M_PWM2
#define TIM_CCMR1_OC1M_INACTIVE
#define TIM_CCMR1_OC1M_PWM2
#define TIM_CCR2(tim_base)
#define TIM_EGR(tim_base)
#define TIM_CR2(tim_base)
#define TIM_CCMR1_OC1M_PWM1
#define TIM_CCMR1_OC1M_TOGGLE
#define TIM_CCMR1_OC2M_FROZEN
#define TIM_CCMR2_CC3S_OUT
#define TIM_CCMR2_OC3M_PWM1
#define TIM_CCMR2_OC4M_INACTIVE
#define TIM_CCMR1_OC1M_FORCE_HIGH
#define TIM_CCMR2_OC4M_ACTIVE
#define TIM_CCMR2_OC3M_ACTIVE
#define TIM_CCMR2_OC3M_FORCE_LOW
#define TIM_CCMR2_OC4M_PWM1
#define TIM_CCR1(tim_base)
#define TIM_CNT(tim_base)
#define TIM_CCMR1_OC1M_ACTIVE
tim_ic_filter
Input Capture input filter.
#define TIM_CCMR1_OC2M_PWM1
#define TIM_CCMR1_OC2M_INACTIVE
#define TIM_CCMR2_OC3M_TOGGLE
#define TIM_CCMR2_OC3M_FROZEN
#define TIM_ARR(tim_base)
tim_oc_mode
Output Compare mode designators.
#define TIM_CCMR1_CC2S_OUT
tim_et_pol
Slave external trigger polarity.
#define TIM_CCR3(tim_base)
#define TIM_CCMR1_OC2M_TOGGLE
#define TIM_CCER(tim_base)
#define TIM_SMCR(tim_base)
#define TIM_CCMR2_OC4M_FROZEN
#define TIM_CR1(tim_base)
#define TIM_CCMR2(tim_base)
tim_oc_id
Output Compare channel designators.
#define TIM_CCMR1(tim_base)
#define TIM_CCMR1_OC1M_FROZEN
#define TIM_BDTR(tim_base)
#define TIM_CCMR1_OC2M_FORCE_HIGH
tim_ecm2_state
External clock mode 2.
tim_ic_input
Input Capture input source.
#define TIM_RCR(tim_base)
#define TIM_CCMR2_OC3M_INACTIVE
#define TIM_CCMR1_OC2M_ACTIVE
#define TIM_CCMR1_OC2M_FORCE_LOW
#define TIM_CCMR1_CC1S_OUT
#define TIM_CCMR1_OC1M_FORCE_LOW
tim_ic_id
Input Capture channel designators.
#define TIM_DIER(tim_base)
#define TIM_CCMR2_OC3M_PWM2
#define TIM_CCMR2_OC4M_FORCE_LOW
void timer_continuous_mode(uint32_t timer_peripheral)
Enable the Timer to Run Continuously.
void timer_slave_set_trigger(uint32_t timer_peripheral, uint8_t trigger)
Set Slave Trigger Source.
void timer_set_oc_slow_mode(uint32_t timer_peripheral, enum tim_oc_id oc_id)
Timer Enable the Output Compare Slow Mode.
void timer_enable_preload(uint32_t timer_peripheral)
Enable Auto-Reload Buffering.
void timer_reset_output_idle_state(uint32_t timer_peripheral, uint32_t outputs)
Set Timer Output Idle States Low.
void timer_one_shot_mode(uint32_t timer_peripheral)
Enable the Timer for One Cycle and Stop.
void timer_set_master_mode(uint32_t timer_peripheral, uint32_t mode)
Set the Master Mode.
void timer_disable_preload_complementry_enable_bits(uint32_t timer_peripheral)
Disable Timer Capture/Compare Control Preload.
void timer_set_dma_on_compare_event(uint32_t timer_peripheral)
Set Timer DMA Requests on Capture/Compare Events.
void timer_set_oc_fast_mode(uint32_t timer_peripheral, enum tim_oc_id oc_id)
Timer Enable the Output Compare Fast Mode.
void timer_update_on_overflow(uint32_t timer_peripheral)
Set the Timer to Generate Update IRQ or DMA only from Under/Overflow Events.
void timer_set_disabled_off_state_in_idle_mode(uint32_t timer_peripheral)
Disable Off-State in Idle Mode.
void timer_slave_set_mode(uint32_t timer_peripheral, uint8_t mode)
Set Slave Mode.
bool timer_get_flag(uint32_t timer_peripheral, uint32_t flag)
Read a Status Flag.
void timer_enable_compare_control_update_on_trigger(uint32_t timer_peripheral)
Enable Timer Capture/Compare Control Update with Trigger.
void timer_disable_break_main_output(uint32_t timer_peripheral)
Disable Output in Break.
void timer_enable_break(uint32_t timer_peripheral)
Enable Break.
void timer_set_oc_polarity_high(uint32_t timer_peripheral, enum tim_oc_id oc_id)
Timer Set the Output Polarity High.
void timer_set_mode(uint32_t timer_peripheral, uint32_t clock_div, uint32_t alignment, uint32_t direction)
Set the Timer Mode.
void timer_disable_oc_clear(uint32_t timer_peripheral, enum tim_oc_id oc_id)
Timer Disable the Output Compare Clear Function.
void timer_set_break_lock(uint32_t timer_peripheral, uint32_t lock)
Set Lock Bits.
void timer_disable_preload(uint32_t timer_peripheral)
Disable Auto-Reload Buffering.
void timer_set_prescaler(uint32_t timer_peripheral, uint32_t value)
Set the Value for the Timer Prescaler.
void timer_disable_counter(uint32_t timer_peripheral)
Stop the timer from counting.
void timer_enable_oc_clear(uint32_t timer_peripheral, enum tim_oc_id oc_id)
Timer Enable the Output Compare Clear Function.
void timer_set_break_polarity_high(uint32_t timer_peripheral)
Activate Break when Input High.
void timer_set_oc_mode(uint32_t timer_peripheral, enum tim_oc_id oc_id, enum tim_oc_mode oc_mode)
Timer Set Output Compare Mode.
void timer_set_oc_idle_state_unset(uint32_t timer_peripheral, enum tim_oc_id oc_id)
Timer Set Output Compare Idle State Low.
void timer_ic_disable(uint32_t timer_peripheral, enum tim_ic_id ic)
Disable Timer Input Capture.
bool timer_interrupt_source(uint32_t timer_peripheral, uint32_t flag)
Return Interrupt Source.
void timer_set_deadtime(uint32_t timer_peripheral, uint32_t deadtime)
Set Deadtime.
void timer_set_alignment(uint32_t timer_peripheral, uint32_t alignment)
Specify the counter alignment mode.
void timer_slave_set_polarity(uint32_t timer_peripheral, enum tim_et_pol pol)
Set External Trigger Polarity for Slave.
void timer_set_counter(uint32_t timer_peripheral, uint32_t count)
Set Counter.
void timer_enable_oc_preload(uint32_t timer_peripheral, enum tim_oc_id oc_id)
Timer Enable the Output Compare Preload Register.
void timer_set_output_idle_state(uint32_t timer_peripheral, uint32_t outputs)
Set Timer Output Idle States High.
void timer_set_dma_on_update_event(uint32_t timer_peripheral)
Set Timer DMA Requests on Update Events.
void timer_set_enabled_off_state_in_idle_mode(uint32_t timer_peripheral)
Enable Off-State in Idle Mode.
void timer_enable_update_event(uint32_t timer_peripheral)
Enable Timer Update Events.
void timer_enable_preload_complementry_enable_bits(uint32_t timer_peripheral)
Enable Timer Capture/Compare Control Preload.
void timer_enable_counter(uint32_t timer_peripheral)
Enable the timer to start counting.
void timer_ic_set_prescaler(uint32_t timer_peripheral, enum tim_ic_id ic, enum tim_ic_psc psc)
Set Input Capture Prescaler.
void timer_ic_set_filter(uint32_t timer_peripheral, enum tim_ic_id ic, enum tim_ic_filter flt)
Set Input Capture Filter Parameters.
void timer_disable_oc_output(uint32_t timer_peripheral, enum tim_oc_id oc_id)
Timer Disable the Output Compare.
void timer_set_ti1_ch1(uint32_t timer_peripheral)
Set Timer 1 Input to Channel 1.
void timer_set_oc_idle_state_set(uint32_t timer_peripheral, enum tim_oc_id oc_id)
Timer set Output Compare Idle State High.
void timer_disable_oc_preload(uint32_t timer_peripheral, enum tim_oc_id oc_id)
Timer Disable the Output Compare Preload Register.
void timer_direction_down(uint32_t timer_peripheral)
Set the Timer to Count Down.
void timer_disable_compare_control_update_on_trigger(uint32_t timer_peripheral)
Disable Timer Capture/Compare Control Update with Trigger.
void timer_update_on_any(uint32_t timer_peripheral)
Set the Timer to Generate Update IRQ or DMA on any Event.
void timer_disable_break(uint32_t timer_peripheral)
Disable Break.
void timer_enable_irq(uint32_t timer_peripheral, uint32_t irq)
Enable Interrupts for a Timer.
void timer_enable_break_automatic_output(uint32_t timer_peripheral)
Enable Automatic Output in Break.
void timer_set_enabled_off_state_in_run_mode(uint32_t timer_peripheral)
Enable Off-State in Run Mode.
void timer_direction_up(uint32_t timer_peripheral)
Set the Timer to Count Up.
void timer_enable_break_main_output(uint32_t timer_peripheral)
Enable Output in Break.
void timer_set_disabled_off_state_in_run_mode(uint32_t timer_peripheral)
Disable Off-State in Run Mode.
void timer_enable_oc_output(uint32_t timer_peripheral, enum tim_oc_id oc_id)
Timer Enable the Output Compare.
void timer_disable_update_event(uint32_t timer_peripheral)
Disable Timer Update Events.
void timer_set_ti1_ch123_xor(uint32_t timer_peripheral)
Set Timer 1 Input to XOR of Three Channels.
void timer_set_oc_value(uint32_t timer_peripheral, enum tim_oc_id oc_id, uint32_t value)
Timer Set Output Compare Value.
void timer_slave_set_prescaler(uint32_t timer_peripheral, enum tim_ic_psc psc)
Set External Trigger Prescaler for Slave.
void timer_set_oc_polarity_low(uint32_t timer_peripheral, enum tim_oc_id oc_id)
Timer Set the Output Polarity Low.
void timer_ic_set_input(uint32_t timer_peripheral, enum tim_ic_id ic, enum tim_ic_input in)
Set Capture/Compare Channel Direction/Input.
void timer_disable_break_automatic_output(uint32_t timer_peripheral)
Disable Automatic Output in Break.
void timer_ic_enable(uint32_t timer_peripheral, enum tim_ic_id ic)
Enable Timer Input Capture.
void timer_set_break_polarity_low(uint32_t timer_peripheral)
Activate Break when Input Low.
uint32_t timer_get_counter(uint32_t timer_peripheral)
Read Counter.
void timer_generate_event(uint32_t timer_peripheral, uint32_t event)
Force generate a timer event.
void timer_slave_set_extclockmode2(uint32_t timer_peripheral, enum tim_ecm2_state state)
Set External Clock Mode 2.
void timer_set_period(uint32_t timer_peripheral, uint32_t period)
Timer Set Period.
void timer_set_repetition_counter(uint32_t timer_peripheral, uint32_t value)
Set the Value for the Timer Repetition Counter.
void timer_clear_flag(uint32_t timer_peripheral, uint32_t flag)
Clear a Status Flag.
void timer_slave_set_filter(uint32_t timer_peripheral, enum tim_ic_filter flt)
Set External Trigger Filter Parameters for Slave.
void timer_disable_irq(uint32_t timer_peripheral, uint32_t irq)
Disable Interrupts for a Timer.
void timer_set_clock_division(uint32_t timer_peripheral, uint32_t clock_div)
Set Input Filter and Dead-time Clock Divider Ratio.