[STM32F0] Add support for timers.
This commit has been based on kuldeepdhaka's pioneer work, but it was reformatted to apply libopencm3 inclusion tree correctly. timer_common_all.c now supports new rcc_periph_reset_pulse function for all families.
This commit is contained in:
committed by
Karl Palsson
parent
f780075d4d
commit
bf01d890f6
@@ -45,11 +45,15 @@ specific memorymap.h header before including this header file.*/
|
|||||||
#define TIM1 TIM1_BASE
|
#define TIM1 TIM1_BASE
|
||||||
#define TIM2 TIM2_BASE
|
#define TIM2 TIM2_BASE
|
||||||
#define TIM3 TIM3_BASE
|
#define TIM3 TIM3_BASE
|
||||||
|
#if defined(TIM4_BASE)
|
||||||
#define TIM4 TIM4_BASE
|
#define TIM4 TIM4_BASE
|
||||||
|
#endif
|
||||||
#define TIM5 TIM5_BASE
|
#define TIM5 TIM5_BASE
|
||||||
#define TIM6 TIM6_BASE
|
#define TIM6 TIM6_BASE
|
||||||
#define TIM7 TIM7_BASE
|
#define TIM7 TIM7_BASE
|
||||||
#define TIM8 TIM8_BASE
|
#if defined(TIM8_BASE)
|
||||||
|
# define TIM8 TIM8_BASE
|
||||||
|
#endif
|
||||||
/**@}*/
|
/**@}*/
|
||||||
|
|
||||||
/* --- Timer registers ----------------------------------------------------- */
|
/* --- Timer registers ----------------------------------------------------- */
|
||||||
|
|||||||
@@ -32,4 +32,6 @@
|
|||||||
#ifndef LIBOPENCM3_TIMER_H
|
#ifndef LIBOPENCM3_TIMER_H
|
||||||
#define LIBOPENCM3_TIMER_H
|
#define LIBOPENCM3_TIMER_H
|
||||||
|
|
||||||
|
#include <libopencm3/stm32/common/timer_common_all.h>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -103,6 +103,12 @@ to alternate function push-pull outputs where the PWM output will appear.
|
|||||||
|
|
||||||
#define ADVANCED_TIMERS (defined(TIM1_BASE) || defined(TIM8_BASE))
|
#define ADVANCED_TIMERS (defined(TIM1_BASE) || defined(TIM8_BASE))
|
||||||
|
|
||||||
|
#if defined(TIM8)
|
||||||
|
#define TIMER_IS_ADVANCED(periph) ((periph == TIM1) || (periph == TIM8))
|
||||||
|
#else
|
||||||
|
#define TIMER_IS_ADVANCED(periph) (periph == TIM1)
|
||||||
|
#endif
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/** @brief Reset a Timer.
|
/** @brief Reset a Timer.
|
||||||
|
|
||||||
@@ -118,72 +124,55 @@ void timer_reset(uint32_t timer_peripheral)
|
|||||||
switch (timer_peripheral) {
|
switch (timer_peripheral) {
|
||||||
#if defined(TIM1_BASE)
|
#if defined(TIM1_BASE)
|
||||||
case TIM1:
|
case TIM1:
|
||||||
rcc_peripheral_reset(&RCC_APB2RSTR, RCC_APB2RSTR_TIM1RST);
|
rcc_periph_reset_pulse(RST_TIM1);
|
||||||
rcc_peripheral_clear_reset(&RCC_APB2RSTR, RCC_APB2RSTR_TIM1RST);
|
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case TIM2:
|
case TIM2:
|
||||||
rcc_peripheral_reset(&RCC_APB1RSTR, RCC_APB1RSTR_TIM2RST);
|
rcc_periph_reset_pulse(RST_TIM2);
|
||||||
rcc_peripheral_clear_reset(&RCC_APB1RSTR, RCC_APB1RSTR_TIM2RST);
|
|
||||||
break;
|
break;
|
||||||
case TIM3:
|
case TIM3:
|
||||||
rcc_peripheral_reset(&RCC_APB1RSTR, RCC_APB1RSTR_TIM3RST);
|
rcc_periph_reset_pulse(RST_TIM3);
|
||||||
rcc_peripheral_clear_reset(&RCC_APB1RSTR, RCC_APB1RSTR_TIM3RST);
|
|
||||||
break;
|
break;
|
||||||
|
#if defined(TIM4_BASE)
|
||||||
case TIM4:
|
case TIM4:
|
||||||
rcc_peripheral_reset(&RCC_APB1RSTR, RCC_APB1RSTR_TIM4RST);
|
rcc_periph_reset_pulse(RST_TIM4);
|
||||||
rcc_peripheral_clear_reset(&RCC_APB1RSTR, RCC_APB1RSTR_TIM4RST);
|
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
#if defined(TIM5_BASE)
|
#if defined(TIM5_BASE)
|
||||||
case TIM5:
|
case TIM5:
|
||||||
rcc_peripheral_reset(&RCC_APB1RSTR, RCC_APB1RSTR_TIM5RST);
|
rcc_periph_reset_pulse(RST_TIM5);
|
||||||
rcc_peripheral_clear_reset(&RCC_APB1RSTR, RCC_APB1RSTR_TIM5RST);
|
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case TIM6:
|
case TIM6:
|
||||||
rcc_peripheral_reset(&RCC_APB1RSTR, RCC_APB1RSTR_TIM6RST);
|
rcc_periph_reset_pulse(RST_TIM6);
|
||||||
rcc_peripheral_clear_reset(&RCC_APB1RSTR, RCC_APB1RSTR_TIM6RST);
|
|
||||||
break;
|
break;
|
||||||
case TIM7:
|
case TIM7:
|
||||||
rcc_peripheral_reset(&RCC_APB1RSTR, RCC_APB1RSTR_TIM7RST);
|
rcc_periph_reset_pulse(RST_TIM7);
|
||||||
rcc_peripheral_clear_reset(&RCC_APB1RSTR, RCC_APB1RSTR_TIM7RST);
|
|
||||||
break;
|
break;
|
||||||
#if defined(TIM8_BASE)
|
#if defined(TIM8_BASE)
|
||||||
case TIM8:
|
case TIM8:
|
||||||
rcc_peripheral_reset(&RCC_APB2RSTR, RCC_APB2RSTR_TIM8RST);
|
rcc_periph_reset_pulse(RST_TIM8);
|
||||||
rcc_peripheral_clear_reset(&RCC_APB2RSTR, RCC_APB2RSTR_TIM8RST);
|
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
/* These timers are not supported in libopencm3 yet */
|
/* These timers are not supported in libopencm3 yet */
|
||||||
/*
|
/*
|
||||||
case TIM9:
|
case TIM9:
|
||||||
rcc_peripheral_reset(&RCC_APB2RSTR, RCC_APB2RSTR_TIM9RST);
|
rcc_periph_reset_pulse(RST_TIM9);
|
||||||
rcc_peripheral_clear_reset(&RCC_APB2RSTR, RCC_APB2RSTR_TIM9RST);
|
|
||||||
break;
|
break;
|
||||||
case TIM10:
|
case TIM10:
|
||||||
rcc_peripheral_reset(&RCC_APB2RSTR, RCC_APB2RSTR_TIM10RST);
|
rcc_periph_reset_pulse(RST_TIM10);
|
||||||
rcc_peripheral_clear_reset(&RCC_APB2RSTR,
|
|
||||||
RCC_APB2RSTR_TIM10RST);
|
|
||||||
break;
|
break;
|
||||||
case TIM11:
|
case TIM11:
|
||||||
rcc_peripheral_reset(&RCC_APB2RSTR, RCC_APB2RSTR_TIM11RST);
|
rcc_periph_reset_pulse(RST_TIM11);
|
||||||
rcc_peripheral_clear_reset(&RCC_APB2RSTR,
|
|
||||||
RCC_APB2RSTR_TIM11RST);
|
|
||||||
break;
|
break;
|
||||||
case TIM12:
|
case TIM12:
|
||||||
rcc_peripheral_reset(&RCC_APB1RSTR, RCC_APB1RSTR_TIM12RST);
|
rcc_periph_reset_pulse(RST_TIM12);
|
||||||
rcc_peripheral_clear_reset(&RCC_APB1RSTR,
|
|
||||||
RCC_APB1RSTR_TIM12RST);
|
|
||||||
break;
|
break;
|
||||||
case TIM13:
|
case TIM13:
|
||||||
rcc_peripheral_reset(&RCC_APB1RSTR, RCC_APB1RSTR_TIM13RST);
|
rcc_periph_reset_pulse(RST_TIM13);
|
||||||
rcc_peripheral_clear_reset(&RCC_APB1RSTR,
|
|
||||||
RCC_APB1RSTR_TIM13RST);
|
|
||||||
break;
|
break;
|
||||||
case TIM14:
|
case TIM14:
|
||||||
rcc_peripheral_reset(&RCC_APB1RSTR, RCC_APB1RSTR_TIM14RST);
|
rcc_periph_reset_pulse(RST_TIM14);
|
||||||
rcc_peripheral_clear_reset(&RCC_APB1RSTR,
|
|
||||||
RCC_APB1RSTR_TIM14RST);
|
|
||||||
break;
|
break;
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
@@ -242,9 +231,9 @@ bool timer_interrupt_source(uint32_t timer_peripheral, uint32_t flag)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/* Only an interrupt source for advanced timers */
|
/* Only an interrupt source for advanced timers */
|
||||||
#if (defined(TIM1_BASE) || defined(TIM8_BASE))
|
#if ADVANCED_TIMERS
|
||||||
if ((flag == TIM_SR_BIF) || (flag == TIM_SR_COMIF)) {
|
if ((flag == TIM_SR_BIF) || (flag == TIM_SR_COMIF)) {
|
||||||
return (timer_peripheral == TIM1) || (timer_peripheral == TIM8);
|
return TIMER_IS_ADVANCED(timer_peripheral);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
@@ -542,8 +531,8 @@ output control values.
|
|||||||
|
|
||||||
void timer_set_output_idle_state(uint32_t timer_peripheral, uint32_t outputs)
|
void timer_set_output_idle_state(uint32_t timer_peripheral, uint32_t outputs)
|
||||||
{
|
{
|
||||||
#if (defined(TIM1_BASE) || defined(TIM8_BASE))
|
#if ADVANCED_TIMERS
|
||||||
if ((timer_peripheral == TIM1) || (timer_peripheral == TIM8)) {
|
if (TIMER_IS_ADVANCED(timer_peripheral)) {
|
||||||
TIM_CR2(timer_peripheral) |= outputs & TIM_CR2_OIS_MASK;
|
TIM_CR2(timer_peripheral) |= outputs & TIM_CR2_OIS_MASK;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -569,8 +558,8 @@ tim_x_cr2_ois
|
|||||||
|
|
||||||
void timer_reset_output_idle_state(uint32_t timer_peripheral, uint32_t outputs)
|
void timer_reset_output_idle_state(uint32_t timer_peripheral, uint32_t outputs)
|
||||||
{
|
{
|
||||||
#if (defined(TIM1_BASE) || defined(TIM8_BASE))
|
#if ADVANCED_TIMERS
|
||||||
if ((timer_peripheral == TIM1) || (timer_peripheral == TIM8)) {
|
if (TIMER_IS_ADVANCED(timer_peripheral)) {
|
||||||
TIM_CR2(timer_peripheral) &= ~(outputs & TIM_CR2_OIS_MASK);
|
TIM_CR2(timer_peripheral) &= ~(outputs & TIM_CR2_OIS_MASK);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -669,8 +658,8 @@ tim_reg_base
|
|||||||
|
|
||||||
void timer_enable_compare_control_update_on_trigger(uint32_t timer_peripheral)
|
void timer_enable_compare_control_update_on_trigger(uint32_t timer_peripheral)
|
||||||
{
|
{
|
||||||
#if (defined(TIM1_BASE) || defined(TIM8_BASE))
|
#if ADVANCED_TIMERS
|
||||||
if ((timer_peripheral == TIM1) || (timer_peripheral == TIM8)) {
|
if (TIMER_IS_ADVANCED(timer_peripheral)) {
|
||||||
TIM_CR2(timer_peripheral) |= TIM_CR2_CCUS;
|
TIM_CR2(timer_peripheral) |= TIM_CR2_CCUS;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -694,8 +683,8 @@ tim_reg_base
|
|||||||
|
|
||||||
void timer_disable_compare_control_update_on_trigger(uint32_t timer_peripheral)
|
void timer_disable_compare_control_update_on_trigger(uint32_t timer_peripheral)
|
||||||
{
|
{
|
||||||
#if (defined(TIM1_BASE) || defined(TIM8_BASE))
|
#if ADVANCED_TIMERS
|
||||||
if ((timer_peripheral == TIM1) || (timer_peripheral == TIM8)) {
|
if (TIMER_IS_ADVANCED(timer_peripheral)) {
|
||||||
TIM_CR2(timer_peripheral) &= ~TIM_CR2_CCUS;
|
TIM_CR2(timer_peripheral) &= ~TIM_CR2_CCUS;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -718,8 +707,8 @@ tim_reg_base
|
|||||||
|
|
||||||
void timer_enable_preload_complementry_enable_bits(uint32_t timer_peripheral)
|
void timer_enable_preload_complementry_enable_bits(uint32_t timer_peripheral)
|
||||||
{
|
{
|
||||||
#if (defined(TIM1_BASE) || defined(TIM8_BASE))
|
#if ADVANCED_TIMERS
|
||||||
if ((timer_peripheral == TIM1) || (timer_peripheral == TIM8)) {
|
if (TIMER_IS_ADVANCED(timer_peripheral)) {
|
||||||
TIM_CR2(timer_peripheral) |= TIM_CR2_CCPC;
|
TIM_CR2(timer_peripheral) |= TIM_CR2_CCPC;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -741,8 +730,8 @@ tim_reg_base
|
|||||||
|
|
||||||
void timer_disable_preload_complementry_enable_bits(uint32_t timer_peripheral)
|
void timer_disable_preload_complementry_enable_bits(uint32_t timer_peripheral)
|
||||||
{
|
{
|
||||||
#if (defined(TIM1_BASE) || defined(TIM8_BASE))
|
#if ADVANCED_TIMERS
|
||||||
if ((timer_peripheral == TIM1) || (timer_peripheral == TIM8)) {
|
if (TIMER_IS_ADVANCED(timer_peripheral)) {
|
||||||
TIM_CR2(timer_peripheral) &= ~TIM_CR2_CCPC;
|
TIM_CR2(timer_peripheral) &= ~TIM_CR2_CCPC;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -780,8 +769,8 @@ tim_reg_base
|
|||||||
|
|
||||||
void timer_set_repetition_counter(uint32_t timer_peripheral, uint32_t value)
|
void timer_set_repetition_counter(uint32_t timer_peripheral, uint32_t value)
|
||||||
{
|
{
|
||||||
#if (defined(TIM1_BASE) || defined(TIM8_BASE))
|
#if ADVANCED_TIMERS
|
||||||
if ((timer_peripheral == TIM1) || (timer_peripheral == TIM8)) {
|
if (TIMER_IS_ADVANCED(timer_peripheral)) {
|
||||||
TIM_RCR(timer_peripheral) = value;
|
TIM_RCR(timer_peripheral) = value;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -1216,8 +1205,8 @@ void timer_set_oc_polarity_high(uint32_t timer_peripheral, enum tim_oc_id oc_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Acting for TIM1 and TIM8 only from here onwards. */
|
/* Acting for TIM1 and TIM8 only from here onwards. */
|
||||||
#if (defined(TIM1_BASE) || defined(TIM8_BASE))
|
#if ADVANCED_TIMERS
|
||||||
if ((timer_peripheral != TIM1) && (timer_peripheral != TIM8)) {
|
if (!TIMER_IS_ADVANCED(timer_peripheral)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -1278,8 +1267,8 @@ void timer_set_oc_polarity_low(uint32_t timer_peripheral, enum tim_oc_id oc_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Acting for TIM1 and TIM8 only from here onwards. */
|
/* Acting for TIM1 and TIM8 only from here onwards. */
|
||||||
#if (defined(TIM1_BASE) || defined(TIM8_BASE))
|
#if ADVANCED_TIMERS
|
||||||
if ((timer_peripheral != TIM1) && (timer_peripheral != TIM8)) {
|
if (!TIMER_IS_ADVANCED(timer_peripheral)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -1340,8 +1329,8 @@ void timer_enable_oc_output(uint32_t timer_peripheral, enum tim_oc_id oc_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Acting for TIM1 and TIM8 only from here onwards. */
|
/* Acting for TIM1 and TIM8 only from here onwards. */
|
||||||
#if (defined(TIM1_BASE) || defined(TIM8_BASE))
|
#if ADVANCED_TIMERS
|
||||||
if ((timer_peripheral != TIM1) && (timer_peripheral != TIM8)) {
|
if (!TIMER_IS_ADVANCED(timer_peripheral)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -1402,8 +1391,8 @@ void timer_disable_oc_output(uint32_t timer_peripheral, enum tim_oc_id oc_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Acting for TIM1 and TIM8 only from here onwards. */
|
/* Acting for TIM1 and TIM8 only from here onwards. */
|
||||||
#if (defined(TIM1_BASE) || defined(TIM8_BASE))
|
#if ADVANCED_TIMERS
|
||||||
if ((timer_peripheral != TIM1) && (timer_peripheral != TIM8)) {
|
if (!TIMER_IS_ADVANCED(timer_peripheral)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -1447,9 +1436,9 @@ tim_reg_base
|
|||||||
void timer_set_oc_idle_state_set(uint32_t timer_peripheral,
|
void timer_set_oc_idle_state_set(uint32_t timer_peripheral,
|
||||||
enum tim_oc_id oc_id)
|
enum tim_oc_id oc_id)
|
||||||
{
|
{
|
||||||
#if (defined(TIM1_BASE) || defined(TIM8_BASE))
|
#if ADVANCED_TIMERS
|
||||||
/* Acting for TIM1 and TIM8 only. */
|
/* Acting for TIM1 and TIM8 only. */
|
||||||
if ((timer_peripheral != TIM1) && (timer_peripheral != TIM8)) {
|
if (!TIMER_IS_ADVANCED(timer_peripheral)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1500,9 +1489,9 @@ tim_reg_base
|
|||||||
void timer_set_oc_idle_state_unset(uint32_t timer_peripheral,
|
void timer_set_oc_idle_state_unset(uint32_t timer_peripheral,
|
||||||
enum tim_oc_id oc_id)
|
enum tim_oc_id oc_id)
|
||||||
{
|
{
|
||||||
#if (defined(TIM1_BASE) || defined(TIM8_BASE))
|
#if ADVANCED_TIMERS
|
||||||
/* Acting for TIM1 and TIM8 only. */
|
/* Acting for TIM1 and TIM8 only. */
|
||||||
if ((timer_peripheral != TIM1) && (timer_peripheral != TIM8)) {
|
if (!TIMER_IS_ADVANCED(timer_peripheral)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1590,8 +1579,8 @@ TIM8
|
|||||||
|
|
||||||
void timer_enable_break_main_output(uint32_t timer_peripheral)
|
void timer_enable_break_main_output(uint32_t timer_peripheral)
|
||||||
{
|
{
|
||||||
#if (defined(TIM1_BASE) || defined(TIM8_BASE))
|
#if ADVANCED_TIMERS
|
||||||
if ((timer_peripheral == TIM1) || (timer_peripheral == TIM8)) {
|
if (TIMER_IS_ADVANCED(timer_peripheral)) {
|
||||||
TIM_BDTR(timer_peripheral) |= TIM_BDTR_MOE;
|
TIM_BDTR(timer_peripheral) |= TIM_BDTR_MOE;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -1613,8 +1602,8 @@ TIM8
|
|||||||
|
|
||||||
void timer_disable_break_main_output(uint32_t timer_peripheral)
|
void timer_disable_break_main_output(uint32_t timer_peripheral)
|
||||||
{
|
{
|
||||||
#if (defined(TIM1_BASE) || defined(TIM8_BASE))
|
#if ADVANCED_TIMERS
|
||||||
if ((timer_peripheral == TIM1) || (timer_peripheral == TIM8)) {
|
if (TIMER_IS_ADVANCED(timer_peripheral)) {
|
||||||
TIM_BDTR(timer_peripheral) &= ~TIM_BDTR_MOE;
|
TIM_BDTR(timer_peripheral) &= ~TIM_BDTR_MOE;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -1637,8 +1626,8 @@ TIM8
|
|||||||
|
|
||||||
void timer_enable_break_automatic_output(uint32_t timer_peripheral)
|
void timer_enable_break_automatic_output(uint32_t timer_peripheral)
|
||||||
{
|
{
|
||||||
#if (defined(TIM1_BASE) || defined(TIM8_BASE))
|
#if ADVANCED_TIMERS
|
||||||
if ((timer_peripheral == TIM1) || (timer_peripheral == TIM8)) {
|
if (TIMER_IS_ADVANCED(timer_peripheral)) {
|
||||||
TIM_BDTR(timer_peripheral) |= TIM_BDTR_AOE;
|
TIM_BDTR(timer_peripheral) |= TIM_BDTR_AOE;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -1661,8 +1650,8 @@ TIM8
|
|||||||
|
|
||||||
void timer_disable_break_automatic_output(uint32_t timer_peripheral)
|
void timer_disable_break_automatic_output(uint32_t timer_peripheral)
|
||||||
{
|
{
|
||||||
#if (defined(TIM1_BASE) || defined(TIM8_BASE))
|
#if ADVANCED_TIMERS
|
||||||
if ((timer_peripheral == TIM1) || (timer_peripheral == TIM8)) {
|
if (TIMER_IS_ADVANCED(timer_peripheral)) {
|
||||||
TIM_BDTR(timer_peripheral) &= ~TIM_BDTR_AOE;
|
TIM_BDTR(timer_peripheral) &= ~TIM_BDTR_AOE;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -1683,8 +1672,8 @@ TIM8
|
|||||||
|
|
||||||
void timer_set_break_polarity_high(uint32_t timer_peripheral)
|
void timer_set_break_polarity_high(uint32_t timer_peripheral)
|
||||||
{
|
{
|
||||||
#if (defined(TIM1_BASE) || defined(TIM8_BASE))
|
#if ADVANCED_TIMERS
|
||||||
if ((timer_peripheral == TIM1) || (timer_peripheral == TIM8)) {
|
if (TIMER_IS_ADVANCED(timer_peripheral)) {
|
||||||
TIM_BDTR(timer_peripheral) |= TIM_BDTR_BKP;
|
TIM_BDTR(timer_peripheral) |= TIM_BDTR_BKP;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -1705,8 +1694,8 @@ TIM8
|
|||||||
|
|
||||||
void timer_set_break_polarity_low(uint32_t timer_peripheral)
|
void timer_set_break_polarity_low(uint32_t timer_peripheral)
|
||||||
{
|
{
|
||||||
#if (defined(TIM1_BASE) || defined(TIM8_BASE))
|
#if ADVANCED_TIMERS
|
||||||
if ((timer_peripheral == TIM1) || (timer_peripheral == TIM8)) {
|
if (TIMER_IS_ADVANCED(timer_peripheral)) {
|
||||||
TIM_BDTR(timer_peripheral) &= ~TIM_BDTR_BKP;
|
TIM_BDTR(timer_peripheral) &= ~TIM_BDTR_BKP;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -1727,8 +1716,8 @@ TIM8
|
|||||||
|
|
||||||
void timer_enable_break(uint32_t timer_peripheral)
|
void timer_enable_break(uint32_t timer_peripheral)
|
||||||
{
|
{
|
||||||
#if (defined(TIM1_BASE) || defined(TIM8_BASE))
|
#if ADVANCED_TIMERS
|
||||||
if ((timer_peripheral == TIM1) || (timer_peripheral == TIM8)) {
|
if (TIMER_IS_ADVANCED(timer_peripheral)) {
|
||||||
TIM_BDTR(timer_peripheral) |= TIM_BDTR_BKE;
|
TIM_BDTR(timer_peripheral) |= TIM_BDTR_BKE;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -1749,8 +1738,8 @@ TIM8
|
|||||||
|
|
||||||
void timer_disable_break(uint32_t timer_peripheral)
|
void timer_disable_break(uint32_t timer_peripheral)
|
||||||
{
|
{
|
||||||
#if (defined(TIM1_BASE) || defined(TIM8_BASE))
|
#if ADVANCED_TIMERS
|
||||||
if ((timer_peripheral == TIM1) || (timer_peripheral == TIM8)) {
|
if (TIMER_IS_ADVANCED(timer_peripheral)) {
|
||||||
TIM_BDTR(timer_peripheral) &= ~TIM_BDTR_BKE;
|
TIM_BDTR(timer_peripheral) &= ~TIM_BDTR_BKE;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -1775,8 +1764,8 @@ TIM8
|
|||||||
|
|
||||||
void timer_set_enabled_off_state_in_run_mode(uint32_t timer_peripheral)
|
void timer_set_enabled_off_state_in_run_mode(uint32_t timer_peripheral)
|
||||||
{
|
{
|
||||||
#if (defined(TIM1_BASE) || defined(TIM8_BASE))
|
#if ADVANCED_TIMERS
|
||||||
if ((timer_peripheral == TIM1) || (timer_peripheral == TIM8)) {
|
if (TIMER_IS_ADVANCED(timer_peripheral)) {
|
||||||
TIM_BDTR(timer_peripheral) |= TIM_BDTR_OSSR;
|
TIM_BDTR(timer_peripheral) |= TIM_BDTR_OSSR;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -1800,8 +1789,8 @@ TIM8
|
|||||||
|
|
||||||
void timer_set_disabled_off_state_in_run_mode(uint32_t timer_peripheral)
|
void timer_set_disabled_off_state_in_run_mode(uint32_t timer_peripheral)
|
||||||
{
|
{
|
||||||
#if (defined(TIM1_BASE) || defined(TIM8_BASE))
|
#if ADVANCED_TIMERS
|
||||||
if ((timer_peripheral == TIM1) || (timer_peripheral == TIM8)) {
|
if (TIMER_IS_ADVANCED(timer_peripheral)) {
|
||||||
TIM_BDTR(timer_peripheral) &= ~TIM_BDTR_OSSR;
|
TIM_BDTR(timer_peripheral) &= ~TIM_BDTR_OSSR;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -1824,8 +1813,8 @@ TIM8
|
|||||||
|
|
||||||
void timer_set_enabled_off_state_in_idle_mode(uint32_t timer_peripheral)
|
void timer_set_enabled_off_state_in_idle_mode(uint32_t timer_peripheral)
|
||||||
{
|
{
|
||||||
#if (defined(TIM1_BASE) || defined(TIM8_BASE))
|
#if ADVANCED_TIMERS
|
||||||
if ((timer_peripheral == TIM1) || (timer_peripheral == TIM8)) {
|
if (TIMER_IS_ADVANCED(timer_peripheral)) {
|
||||||
TIM_BDTR(timer_peripheral) |= TIM_BDTR_OSSI;
|
TIM_BDTR(timer_peripheral) |= TIM_BDTR_OSSI;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -1847,8 +1836,8 @@ TIM8
|
|||||||
|
|
||||||
void timer_set_disabled_off_state_in_idle_mode(uint32_t timer_peripheral)
|
void timer_set_disabled_off_state_in_idle_mode(uint32_t timer_peripheral)
|
||||||
{
|
{
|
||||||
#if (defined(TIM1_BASE) || defined(TIM8_BASE))
|
#if ADVANCED_TIMERS
|
||||||
if ((timer_peripheral == TIM1) || (timer_peripheral == TIM8)) {
|
if (TIMER_IS_ADVANCED(timer_peripheral)) {
|
||||||
TIM_BDTR(timer_peripheral) &= ~TIM_BDTR_OSSI;
|
TIM_BDTR(timer_peripheral) &= ~TIM_BDTR_OSSI;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -1872,8 +1861,8 @@ TIM8
|
|||||||
|
|
||||||
void timer_set_break_lock(uint32_t timer_peripheral, uint32_t lock)
|
void timer_set_break_lock(uint32_t timer_peripheral, uint32_t lock)
|
||||||
{
|
{
|
||||||
#if (defined(TIM1_BASE) || defined(TIM8_BASE))
|
#if ADVANCED_TIMERS
|
||||||
if ((timer_peripheral == TIM1) || (timer_peripheral == TIM8)) {
|
if (TIMER_IS_ADVANCED(timer_peripheral)) {
|
||||||
TIM_BDTR(timer_peripheral) |= lock;
|
TIM_BDTR(timer_peripheral) |= lock;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -1904,8 +1893,8 @@ above.
|
|||||||
|
|
||||||
void timer_set_deadtime(uint32_t timer_peripheral, uint32_t deadtime)
|
void timer_set_deadtime(uint32_t timer_peripheral, uint32_t deadtime)
|
||||||
{
|
{
|
||||||
#if (defined(TIM1_BASE) || defined(TIM8_BASE))
|
#if ADVANCED_TIMERS
|
||||||
if ((timer_peripheral == TIM1) || (timer_peripheral == TIM8)) {
|
if (TIMER_IS_ADVANCED(timer_peripheral)) {
|
||||||
TIM_BDTR(timer_peripheral) |= deadtime;
|
TIM_BDTR(timer_peripheral) |= deadtime;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -40,7 +40,8 @@ OBJS = flash.o rcc.o usart.o dma.o rtc.o comparator.o crc.o \
|
|||||||
OBJS += gpio_common_all.o gpio_common_f0234.o crc_common_all.o \
|
OBJS += gpio_common_all.o gpio_common_f0234.o crc_common_all.o \
|
||||||
pwr_common_all.o iwdg_common_all.o rtc_common_l1f024.o \
|
pwr_common_all.o iwdg_common_all.o rtc_common_l1f024.o \
|
||||||
dma_common_l1f013.o exti_common_all.o spi_common_all.o \
|
dma_common_l1f013.o exti_common_all.o spi_common_all.o \
|
||||||
spi_common_f03.o flash_common_f01.o dac_common_all.o
|
spi_common_f03.o flash_common_f01.o dac_common_all.o \
|
||||||
|
timer_common_all.o
|
||||||
|
|
||||||
VPATH += ../../usb:../:../../cm3:../common
|
VPATH += ../../usb:../:../../cm3:../common
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user