New timers added to STM32 GPT, ICU and PWM drivers.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12525 110e8d01-0319-4d1e-a829-52ad28d1bb01
This commit is contained in:
parent
523aea591e
commit
874f246e6f
|
@ -100,7 +100,7 @@
|
||||||
* @brief Enables the ICU subsystem.
|
* @brief Enables the ICU subsystem.
|
||||||
*/
|
*/
|
||||||
#if !defined(HAL_USE_ICU) || defined(__DOXYGEN__)
|
#if !defined(HAL_USE_ICU) || defined(__DOXYGEN__)
|
||||||
#define HAL_USE_ICU FALSE
|
#define HAL_USE_ICU TRUE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -121,7 +121,7 @@
|
||||||
* @brief Enables the PWM subsystem.
|
* @brief Enables the PWM subsystem.
|
||||||
*/
|
*/
|
||||||
#if !defined(HAL_USE_PWM) || defined(__DOXYGEN__)
|
#if !defined(HAL_USE_PWM) || defined(__DOXYGEN__)
|
||||||
#define HAL_USE_PWM FALSE
|
#define HAL_USE_PWM TRUE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -137,15 +137,15 @@
|
||||||
/*
|
/*
|
||||||
* GPT driver system settings.
|
* GPT driver system settings.
|
||||||
*/
|
*/
|
||||||
#define STM32_GPT_USE_TIM1 TRUE
|
#define STM32_GPT_USE_TIM1 FALSE
|
||||||
#define STM32_GPT_USE_TIM2 FALSE
|
#define STM32_GPT_USE_TIM2 FALSE
|
||||||
#define STM32_GPT_USE_TIM3 FALSE
|
#define STM32_GPT_USE_TIM3 FALSE
|
||||||
#define STM32_GPT_USE_TIM4 FALSE
|
#define STM32_GPT_USE_TIM4 FALSE
|
||||||
#define STM32_GPT_USE_TIM6 FALSE
|
#define STM32_GPT_USE_TIM6 FALSE
|
||||||
#define STM32_GPT_USE_TIM7 FALSE
|
#define STM32_GPT_USE_TIM7 FALSE
|
||||||
#define STM32_GPT_USE_TIM8 FALSE
|
#define STM32_GPT_USE_TIM8 FALSE
|
||||||
#define STM32_GPT_USE_TIM15 TRUE
|
#define STM32_GPT_USE_TIM15 FALSE
|
||||||
#define STM32_GPT_USE_TIM16 TRUE
|
#define STM32_GPT_USE_TIM16 FALSE
|
||||||
#define STM32_GPT_USE_TIM17 TRUE
|
#define STM32_GPT_USE_TIM17 TRUE
|
||||||
#define STM32_GPT_TIM2_IRQ_PRIORITY 7
|
#define STM32_GPT_TIM2_IRQ_PRIORITY 7
|
||||||
#define STM32_GPT_TIM3_IRQ_PRIORITY 7
|
#define STM32_GPT_TIM3_IRQ_PRIORITY 7
|
||||||
|
@ -153,6 +153,9 @@
|
||||||
#define STM32_GPT_TIM6_IRQ_PRIORITY 7
|
#define STM32_GPT_TIM6_IRQ_PRIORITY 7
|
||||||
#define STM32_GPT_TIM7_IRQ_PRIORITY 7
|
#define STM32_GPT_TIM7_IRQ_PRIORITY 7
|
||||||
#define STM32_GPT_TIM8_IRQ_PRIORITY 7
|
#define STM32_GPT_TIM8_IRQ_PRIORITY 7
|
||||||
|
#define STM32_GPT_TIM15_IRQ_PRIORITY 7
|
||||||
|
#define STM32_GPT_TIM16_IRQ_PRIORITY 7
|
||||||
|
#define STM32_GPT_TIM17_IRQ_PRIORITY 7
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* I2C driver system settings.
|
* I2C driver system settings.
|
||||||
|
@ -175,24 +178,32 @@
|
||||||
#define STM32_ICU_USE_TIM3 FALSE
|
#define STM32_ICU_USE_TIM3 FALSE
|
||||||
#define STM32_ICU_USE_TIM4 FALSE
|
#define STM32_ICU_USE_TIM4 FALSE
|
||||||
#define STM32_ICU_USE_TIM8 FALSE
|
#define STM32_ICU_USE_TIM8 FALSE
|
||||||
|
#define STM32_ICU_USE_TIM15 TRUE
|
||||||
#define STM32_ICU_TIM2_IRQ_PRIORITY 7
|
#define STM32_ICU_TIM2_IRQ_PRIORITY 7
|
||||||
#define STM32_ICU_TIM3_IRQ_PRIORITY 7
|
#define STM32_ICU_TIM3_IRQ_PRIORITY 7
|
||||||
#define STM32_ICU_TIM4_IRQ_PRIORITY 7
|
#define STM32_ICU_TIM4_IRQ_PRIORITY 7
|
||||||
#define STM32_ICU_TIM8_IRQ_PRIORITY 7
|
#define STM32_ICU_TIM8_IRQ_PRIORITY 7
|
||||||
|
#define STM32_ICU_TIM15_IRQ_PRIORITY 7
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* PWM driver system settings.
|
* PWM driver system settings.
|
||||||
*/
|
*/
|
||||||
#define STM32_PWM_USE_ADVANCED FALSE
|
#define STM32_PWM_USE_ADVANCED FALSE
|
||||||
#define STM32_PWM_USE_TIM1 FALSE
|
#define STM32_PWM_USE_TIM1 TRUE
|
||||||
#define STM32_PWM_USE_TIM2 FALSE
|
#define STM32_PWM_USE_TIM2 FALSE
|
||||||
#define STM32_PWM_USE_TIM3 FALSE
|
#define STM32_PWM_USE_TIM3 FALSE
|
||||||
#define STM32_PWM_USE_TIM4 FALSE
|
#define STM32_PWM_USE_TIM4 FALSE
|
||||||
#define STM32_PWM_USE_TIM8 FALSE
|
#define STM32_PWM_USE_TIM8 FALSE
|
||||||
|
#define STM32_PWM_USE_TIM15 FALSE
|
||||||
|
#define STM32_PWM_USE_TIM16 TRUE
|
||||||
|
#define STM32_PWM_USE_TIM17 FALSE
|
||||||
#define STM32_PWM_TIM2_IRQ_PRIORITY 7
|
#define STM32_PWM_TIM2_IRQ_PRIORITY 7
|
||||||
#define STM32_PWM_TIM3_IRQ_PRIORITY 7
|
#define STM32_PWM_TIM3_IRQ_PRIORITY 7
|
||||||
#define STM32_PWM_TIM4_IRQ_PRIORITY 7
|
#define STM32_PWM_TIM4_IRQ_PRIORITY 7
|
||||||
#define STM32_PWM_TIM8_IRQ_PRIORITY 7
|
#define STM32_PWM_TIM8_IRQ_PRIORITY 7
|
||||||
|
#define STM32_PWM_TIM15_IRQ_PRIORITY 7
|
||||||
|
#define STM32_PWM_TIM16_IRQ_PRIORITY 7
|
||||||
|
#define STM32_PWM_TIM17_IRQ_PRIORITY 7
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* RTC driver system settings.
|
* RTC driver system settings.
|
||||||
|
|
|
@ -94,6 +94,14 @@ ICUDriver ICUD8;
|
||||||
ICUDriver ICUD9;
|
ICUDriver ICUD9;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ICUD15 driver identifier.
|
||||||
|
* @note The driver ICUD15 allocates the timer TIM15 when enabled.
|
||||||
|
*/
|
||||||
|
#if STM32_ICU_USE_TIM15 || defined(__DOXYGEN__)
|
||||||
|
ICUDriver ICUD15;
|
||||||
|
#endif
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver local variables and types. */
|
/* Driver local variables and types. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -323,6 +331,12 @@ OSAL_IRQ_HANDLER(STM32_TIM9_HANDLER) {
|
||||||
#endif /* !defined(STM32_TIM9_SUPPRESS_ISR) */
|
#endif /* !defined(STM32_TIM9_SUPPRESS_ISR) */
|
||||||
#endif /* STM32_ICU_USE_TIM9 */
|
#endif /* STM32_ICU_USE_TIM9 */
|
||||||
|
|
||||||
|
#if STM32_ICU_USE_TIM15 || defined(__DOXYGEN__)
|
||||||
|
#if !defined(STM32_TIM15_SUPPRESS_ISR)
|
||||||
|
#error "TIM15 ISR not defined by platform"
|
||||||
|
#endif /* !defined(STM32_TIM15_SUPPRESS_ISR) */
|
||||||
|
#endif /* STM32_ICU_USE_TIM15 */
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver exported functions. */
|
/* Driver exported functions. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -375,6 +389,12 @@ void icu_lld_init(void) {
|
||||||
icuObjectInit(&ICUD9);
|
icuObjectInit(&ICUD9);
|
||||||
ICUD9.tim = STM32_TIM9;
|
ICUD9.tim = STM32_TIM9;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if STM32_ICU_USE_TIM15
|
||||||
|
/* Driver initialization.*/
|
||||||
|
icuObjectInit(&ICUD15);
|
||||||
|
ICUD15.tim = STM32_TIM15;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -499,6 +519,18 @@ void icu_lld_start(ICUDriver *icup) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if STM32_ICU_USE_TIM15
|
||||||
|
if (&ICUD15 == icup) {
|
||||||
|
rccEnableTIM15(true);
|
||||||
|
rccResetTIM15();
|
||||||
|
#if defined(STM32_TIM15CLK)
|
||||||
|
icup->clock = STM32_TIM15CLK;
|
||||||
|
#else
|
||||||
|
icup->clock = STM32_TIMCLK2;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* Driver re-configuration scenario, it must be stopped first.*/
|
/* Driver re-configuration scenario, it must be stopped first.*/
|
||||||
|
@ -650,6 +682,12 @@ void icu_lld_stop(ICUDriver *icup) {
|
||||||
rccDisableTIM9();
|
rccDisableTIM9();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if STM32_ICU_USE_TIM15
|
||||||
|
if (&ICUD15 == icup) {
|
||||||
|
rccDisableTIM15();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -104,6 +104,15 @@
|
||||||
#define STM32_ICU_USE_TIM9 FALSE
|
#define STM32_ICU_USE_TIM9 FALSE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ICUD15 driver enable switch.
|
||||||
|
* @details If set to @p TRUE the support for ICUD15 is included.
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(STM32_ICU_USE_TIM15) || defined(__DOXYGEN__)
|
||||||
|
#define STM32_ICU_USE_TIM15 FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ICUD1 interrupt priority level setting.
|
* @brief ICUD1 interrupt priority level setting.
|
||||||
*/
|
*/
|
||||||
|
@ -152,6 +161,13 @@
|
||||||
#if !defined(STM32_ICU_TIM9_IRQ_PRIORITY) || defined(__DOXYGEN__)
|
#if !defined(STM32_ICU_TIM9_IRQ_PRIORITY) || defined(__DOXYGEN__)
|
||||||
#define STM32_ICU_TIM9_IRQ_PRIORITY 7
|
#define STM32_ICU_TIM9_IRQ_PRIORITY 7
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ICUD15 interrupt priority level setting.
|
||||||
|
*/
|
||||||
|
#if !defined(STM32_ICU_TIM15_IRQ_PRIORITY) || defined(__DOXYGEN__)
|
||||||
|
#define STM32_ICU_TIM15_IRQ_PRIORITY 7
|
||||||
|
#endif
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -186,6 +202,10 @@
|
||||||
#define STM32_HAS_TIM9 FALSE
|
#define STM32_HAS_TIM9 FALSE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(STM32_HAS_TIM15)
|
||||||
|
#define STM32_HAS_TIM15 FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
#if STM32_ICU_USE_TIM1 && !STM32_HAS_TIM1
|
#if STM32_ICU_USE_TIM1 && !STM32_HAS_TIM1
|
||||||
#error "TIM1 not present in the selected device"
|
#error "TIM1 not present in the selected device"
|
||||||
#endif
|
#endif
|
||||||
|
@ -214,10 +234,14 @@
|
||||||
#error "TIM9 not present in the selected device"
|
#error "TIM9 not present in the selected device"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if STM32_ICU_USE_TIM15 && !STM32_HAS_TIM15
|
||||||
|
#error "TIM15 not present in the selected device"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !STM32_ICU_USE_TIM1 && !STM32_ICU_USE_TIM2 && \
|
#if !STM32_ICU_USE_TIM1 && !STM32_ICU_USE_TIM2 && \
|
||||||
!STM32_ICU_USE_TIM3 && !STM32_ICU_USE_TIM4 && \
|
!STM32_ICU_USE_TIM3 && !STM32_ICU_USE_TIM4 && \
|
||||||
!STM32_ICU_USE_TIM5 && !STM32_ICU_USE_TIM8 && \
|
!STM32_ICU_USE_TIM5 && !STM32_ICU_USE_TIM8 && \
|
||||||
!STM32_ICU_USE_TIM9
|
!STM32_ICU_USE_TIM9 && !STM32_ICU_USE_TIM15
|
||||||
#error "ICU driver activated but no TIM peripheral assigned"
|
#error "ICU driver activated but no TIM peripheral assigned"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -278,6 +302,14 @@
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if STM32_ICU_USE_TIM15
|
||||||
|
#if defined(STM32_TIM15_IS_USED)
|
||||||
|
#error "ICUD15 requires TIM15 but the timer is already used"
|
||||||
|
#else
|
||||||
|
#define STM32_TIM15_IS_USED
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/* IRQ priority checks.*/
|
/* IRQ priority checks.*/
|
||||||
#if STM32_ICU_USE_TIM1 && !defined(STM32_TIM1_SUPPRESS_ISR) && \
|
#if STM32_ICU_USE_TIM1 && !defined(STM32_TIM1_SUPPRESS_ISR) && \
|
||||||
!OSAL_IRQ_IS_VALID_PRIORITY(STM32_ICU_TIM1_IRQ_PRIORITY)
|
!OSAL_IRQ_IS_VALID_PRIORITY(STM32_ICU_TIM1_IRQ_PRIORITY)
|
||||||
|
@ -314,6 +346,11 @@
|
||||||
#error "Invalid IRQ priority assigned to TIM9"
|
#error "Invalid IRQ priority assigned to TIM9"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if STM32_ICU_USE_TIM15 && !defined(STM32_TIM15_SUPPRESS_ISR) && \
|
||||||
|
!OSAL_IRQ_IS_VALID_PRIORITY(STM32_ICU_TIM15_IRQ_PRIORITY)
|
||||||
|
#error "Invalid IRQ priority assigned to TIM15"
|
||||||
|
#endif
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver data structures and types. */
|
/* Driver data structures and types. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -492,6 +529,10 @@ extern ICUDriver ICUD8;
|
||||||
extern ICUDriver ICUD9;
|
extern ICUDriver ICUD9;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if STM32_ICU_USE_TIM15 && !defined(__DOXYGEN__)
|
||||||
|
extern ICUDriver ICUD15;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -90,6 +90,30 @@ PWMDriver PWMD8;
|
||||||
PWMDriver PWMD9;
|
PWMDriver PWMD9;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief PWMD15 driver identifier.
|
||||||
|
* @note The driver PWMD15 allocates the timer TIM15 when enabled.
|
||||||
|
*/
|
||||||
|
#if STM32_PWM_USE_TIM15 || defined(__DOXYGEN__)
|
||||||
|
PWMDriver PWMD15;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief PWMD16 driver identifier.
|
||||||
|
* @note The driver PWMD16 allocates the timer TIM16 when enabled.
|
||||||
|
*/
|
||||||
|
#if STM32_PWM_USE_TIM16 || defined(__DOXYGEN__)
|
||||||
|
PWMDriver PWMD16;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief PWMD17 driver identifier.
|
||||||
|
* @note The driver PWMD17 allocates the timer TIM17 when enabled.
|
||||||
|
*/
|
||||||
|
#if STM32_PWM_USE_TIM17 || defined(__DOXYGEN__)
|
||||||
|
PWMDriver PWMD17;
|
||||||
|
#endif
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver local variables and types. */
|
/* Driver local variables and types. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -295,6 +319,24 @@ OSAL_IRQ_HANDLER(STM32_TIM9_HANDLER) {
|
||||||
#endif /* !defined(STM32_TIM9_SUPPRESS_ISR) */
|
#endif /* !defined(STM32_TIM9_SUPPRESS_ISR) */
|
||||||
#endif /* STM32_PWM_USE_TIM9 */
|
#endif /* STM32_PWM_USE_TIM9 */
|
||||||
|
|
||||||
|
#if STM32_PWM_USE_TIM15 || defined(__DOXYGEN__)
|
||||||
|
#if !defined(STM32_TIM15_SUPPRESS_ISR)
|
||||||
|
#error "TIM15 ISR not defined by platform"
|
||||||
|
#endif /* !defined(STM32_TIM15_SUPPRESS_ISR) */
|
||||||
|
#endif /* STM32_PWM_USE_TIM15 */
|
||||||
|
|
||||||
|
#if STM32_PWM_USE_TIM16 || defined(__DOXYGEN__)
|
||||||
|
#if !defined(STM32_TIM16_SUPPRESS_ISR)
|
||||||
|
#error "TIM16 ISR not defined by platform"
|
||||||
|
#endif /* !defined(STM32_TIM16_SUPPRESS_ISR) */
|
||||||
|
#endif /* STM32_PWM_USE_TIM16 */
|
||||||
|
|
||||||
|
#if STM32_PWM_USE_TIM17 || defined(__DOXYGEN__)
|
||||||
|
#if !defined(STM32_TIM17_SUPPRESS_ISR)
|
||||||
|
#error "TIM17 ISR not defined by platform"
|
||||||
|
#endif /* !defined(STM32_TIM17_SUPPRESS_ISR) */
|
||||||
|
#endif /* STM32_PWM_USE_TIM17 */
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver exported functions. */
|
/* Driver exported functions. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -354,6 +396,27 @@ void pwm_lld_init(void) {
|
||||||
PWMD9.channels = STM32_TIM9_CHANNELS;
|
PWMD9.channels = STM32_TIM9_CHANNELS;
|
||||||
PWMD9.tim = STM32_TIM9;
|
PWMD9.tim = STM32_TIM9;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if STM32_PWM_USE_TIM15
|
||||||
|
/* Driver initialization.*/
|
||||||
|
pwmObjectInit(&PWMD15);
|
||||||
|
PWMD15.channels = STM32_TIM15_CHANNELS;
|
||||||
|
PWMD15.tim = STM32_TIM15;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if STM32_PWM_USE_TIM16
|
||||||
|
/* Driver initialization.*/
|
||||||
|
pwmObjectInit(&PWMD16);
|
||||||
|
PWMD16.channels = STM32_TIM16_CHANNELS;
|
||||||
|
PWMD16.tim = STM32_TIM16;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if STM32_PWM_USE_TIM17
|
||||||
|
/* Driver initialization.*/
|
||||||
|
pwmObjectInit(&PWMD17);
|
||||||
|
PWMD17.channels = STM32_TIM17_CHANNELS;
|
||||||
|
PWMD17.tim = STM32_TIM17;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -478,6 +541,42 @@ void pwm_lld_start(PWMDriver *pwmp) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if STM32_PWM_USE_TIM15
|
||||||
|
if (&PWMD15 == pwmp) {
|
||||||
|
rccEnableTIM15(true);
|
||||||
|
rccResetTIM15();
|
||||||
|
#if defined(STM32_TIM15CLK)
|
||||||
|
pwmp->clock = STM32_TIM15CLK;
|
||||||
|
#else
|
||||||
|
pwmp->clock = STM32_TIMCLK2;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if STM32_PWM_USE_TIM16
|
||||||
|
if (&PWMD16 == pwmp) {
|
||||||
|
rccEnableTIM16(true);
|
||||||
|
rccResetTIM16();
|
||||||
|
#if defined(STM32_TIM16CLK)
|
||||||
|
pwmp->clock = STM32_TIM16CLK;
|
||||||
|
#else
|
||||||
|
pwmp->clock = STM32_TIMCLK2;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if STM32_PWM_USE_TIM17
|
||||||
|
if (&PWMD17 == pwmp) {
|
||||||
|
rccEnableTIM17(true);
|
||||||
|
rccResetTIM17();
|
||||||
|
#if defined(STM32_TIM17CLK)
|
||||||
|
pwmp->clock = STM32_TIM17CLK;
|
||||||
|
#else
|
||||||
|
pwmp->clock = STM32_TIMCLK2;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* All channels configured in PWM1 mode with preload enabled and will
|
/* All channels configured in PWM1 mode with preload enabled and will
|
||||||
stay that way until the driver is stopped.*/
|
stay that way until the driver is stopped.*/
|
||||||
pwmp->tim->CCMR1 = STM32_TIM_CCMR1_OC1M(6) | STM32_TIM_CCMR1_OC1PE |
|
pwmp->tim->CCMR1 = STM32_TIM_CCMR1_OC1M(6) | STM32_TIM_CCMR1_OC1PE |
|
||||||
|
@ -698,6 +797,24 @@ void pwm_lld_stop(PWMDriver *pwmp) {
|
||||||
rccDisableTIM9();
|
rccDisableTIM9();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if STM32_PWM_USE_TIM15
|
||||||
|
if (&PWMD15 == pwmp) {
|
||||||
|
rccDisableTIM15();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if STM32_PWM_USE_TIM16
|
||||||
|
if (&PWMD16 == pwmp) {
|
||||||
|
rccDisableTIM16();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if STM32_PWM_USE_TIM17
|
||||||
|
if (&PWMD17 == pwmp) {
|
||||||
|
rccDisableTIM17();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -154,6 +154,33 @@
|
||||||
#define STM32_PWM_USE_TIM9 FALSE
|
#define STM32_PWM_USE_TIM9 FALSE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief PWMD15 driver enable switch.
|
||||||
|
* @details If set to @p TRUE the support for PWMD15 is included.
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(STM32_PWM_USE_TIM15) || defined(__DOXYGEN__)
|
||||||
|
#define STM32_PWM_USE_TIM15 FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief PWMD16 driver enable switch.
|
||||||
|
* @details If set to @p TRUE the support for PWMD16 is included.
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(STM32_PWM_USE_TIM16) || defined(__DOXYGEN__)
|
||||||
|
#define STM32_PWM_USE_TIM16 FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief PWMD17 driver enable switch.
|
||||||
|
* @details If set to @p TRUE the support for PWMD17 is included.
|
||||||
|
* @note The default is @p TRUE.
|
||||||
|
*/
|
||||||
|
#if !defined(STM32_PWM_USE_TIM17) || defined(__DOXYGEN__)
|
||||||
|
#define STM32_PWM_USE_TIM17 FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief PWMD1 interrupt priority level setting.
|
* @brief PWMD1 interrupt priority level setting.
|
||||||
*/
|
*/
|
||||||
|
@ -202,6 +229,27 @@
|
||||||
#if !defined(STM32_PWM_TIM9_IRQ_PRIORITY) || defined(__DOXYGEN__)
|
#if !defined(STM32_PWM_TIM9_IRQ_PRIORITY) || defined(__DOXYGEN__)
|
||||||
#define STM32_PWM_TIM9_IRQ_PRIORITY 7
|
#define STM32_PWM_TIM9_IRQ_PRIORITY 7
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief PWMD15 interrupt priority level setting.
|
||||||
|
*/
|
||||||
|
#if !defined(STM32_PWM_TIM15_IRQ_PRIORITY) || defined(__DOXYGEN__)
|
||||||
|
#define STM32_PWM_TIM15_IRQ_PRIORITY 7
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief PWMD16 interrupt priority level setting.
|
||||||
|
*/
|
||||||
|
#if !defined(STM32_PWM_TIM16_IRQ_PRIORITY) || defined(__DOXYGEN__)
|
||||||
|
#define STM32_PWM_TIM16_IRQ_PRIORITY 7
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief PWMD17 interrupt priority level setting.
|
||||||
|
*/
|
||||||
|
#if !defined(STM32_PWM_TIM17_IRQ_PRIORITY) || defined(__DOXYGEN__)
|
||||||
|
#define STM32_PWM_TIM17_IRQ_PRIORITY 7
|
||||||
|
#endif
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -236,6 +284,18 @@
|
||||||
#define STM32_HAS_TIM9 FALSE
|
#define STM32_HAS_TIM9 FALSE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(STM32_HAS_TIM15)
|
||||||
|
#define STM32_HAS_TIM15 FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(STM32_HAS_TIM16)
|
||||||
|
#define STM32_HAS_TIM16 FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(STM32_HAS_TIM17)
|
||||||
|
#define STM32_HAS_TIM17 FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
#if STM32_PWM_USE_TIM1 && !STM32_HAS_TIM1
|
#if STM32_PWM_USE_TIM1 && !STM32_HAS_TIM1
|
||||||
#error "TIM1 not present in the selected device"
|
#error "TIM1 not present in the selected device"
|
||||||
#endif
|
#endif
|
||||||
|
@ -264,10 +324,23 @@
|
||||||
#error "TIM9 not present in the selected device"
|
#error "TIM9 not present in the selected device"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !STM32_PWM_USE_TIM1 && !STM32_PWM_USE_TIM2 && \
|
#if STM32_PWM_USE_TIM15 && !STM32_HAS_TIM15
|
||||||
!STM32_PWM_USE_TIM3 && !STM32_PWM_USE_TIM4 && \
|
#error "TIM15 not present in the selected device"
|
||||||
!STM32_PWM_USE_TIM5 && !STM32_PWM_USE_TIM8 && \
|
#endif
|
||||||
!STM32_PWM_USE_TIM9
|
|
||||||
|
#if STM32_PWM_USE_TIM16 && !STM32_HAS_TIM16
|
||||||
|
#error "TIM16 not present in the selected device"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if STM32_PWM_USE_TIM17 && !STM32_HAS_TIM17
|
||||||
|
#error "TIM17 not present in the selected device"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !STM32_PWM_USE_TIM1 && !STM32_PWM_USE_TIM2 && \
|
||||||
|
!STM32_PWM_USE_TIM3 && !STM32_PWM_USE_TIM4 && \
|
||||||
|
!STM32_PWM_USE_TIM5 && !STM32_PWM_USE_TIM8 && \
|
||||||
|
!STM32_PWM_USE_TIM9 && !STM32_PWM_USE_TIM15 && \
|
||||||
|
!STM32_PWM_USE_TIM16 && !STM32_PWM_USE_TIM17
|
||||||
#error "PWM driver activated but no TIM peripheral assigned"
|
#error "PWM driver activated but no TIM peripheral assigned"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -332,6 +405,30 @@
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if STM32_PWM_USE_TIM15
|
||||||
|
#if defined(STM32_TIM15_IS_USED)
|
||||||
|
#error "PWMD15 requires TIM15 but the timer is already used"
|
||||||
|
#else
|
||||||
|
#define STM32_TIM15_IS_USED
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if STM32_PWM_USE_TIM16
|
||||||
|
#if defined(STM32_TIM16_IS_USED)
|
||||||
|
#error "PWMD16 requires TIM16 but the timer is already used"
|
||||||
|
#else
|
||||||
|
#define STM32_TIM16_IS_USED
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if STM32_PWM_USE_TIM17
|
||||||
|
#if defined(STM32_TIM17_IS_USED)
|
||||||
|
#error "PWMD17 requires TIM17 but the timer is already used"
|
||||||
|
#else
|
||||||
|
#define STM32_TIM17_IS_USED
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/* IRQ priority checks.*/
|
/* IRQ priority checks.*/
|
||||||
#if STM32_PWM_USE_TIM1 && !defined(STM32_TIM1_SUPPRESS_ISR) && \
|
#if STM32_PWM_USE_TIM1 && !defined(STM32_TIM1_SUPPRESS_ISR) && \
|
||||||
!OSAL_IRQ_IS_VALID_PRIORITY(STM32_PWM_TIM1_IRQ_PRIORITY)
|
!OSAL_IRQ_IS_VALID_PRIORITY(STM32_PWM_TIM1_IRQ_PRIORITY)
|
||||||
|
@ -368,6 +465,21 @@
|
||||||
#error "Invalid IRQ priority assigned to TIM9"
|
#error "Invalid IRQ priority assigned to TIM9"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if STM32_PWM_USE_TIM15 && !defined(STM32_TIM15_SUPPRESS_ISR) && \
|
||||||
|
!OSAL_IRQ_IS_VALID_PRIORITY(STM32_PWM_TIM15_IRQ_PRIORITY)
|
||||||
|
#error "Invalid IRQ priority assigned to TIM15"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if STM32_PWM_USE_TIM16 && !defined(STM32_TIM16_SUPPRESS_ISR) && \
|
||||||
|
!OSAL_IRQ_IS_VALID_PRIORITY(STM32_PWM_TIM16_IRQ_PRIORITY)
|
||||||
|
#error "Invalid IRQ priority assigned to TIM16"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if STM32_PWM_USE_TIM17 && !defined(STM32_TIM17_SUPPRESS_ISR) && \
|
||||||
|
!OSAL_IRQ_IS_VALID_PRIORITY(STM32_PWM_TIM17_IRQ_PRIORITY)
|
||||||
|
#error "Invalid IRQ priority assigned to TIM17"
|
||||||
|
#endif
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver data structures and types. */
|
/* Driver data structures and types. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -549,6 +661,18 @@ extern PWMDriver PWMD8;
|
||||||
extern PWMDriver PWMD9;
|
extern PWMDriver PWMD9;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if STM32_PWM_USE_TIM15 && !defined(__DOXYGEN__)
|
||||||
|
extern PWMDriver PWMD15;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if STM32_PWM_USE_TIM16 && !defined(__DOXYGEN__)
|
||||||
|
extern PWMDriver PWMD16;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if STM32_PWM_USE_TIM17 && !defined(__DOXYGEN__)
|
||||||
|
extern PWMDriver PWMD17;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -261,9 +261,6 @@ OSAL_IRQ_HANDLER(VectorA4) {
|
||||||
#if STM32_ICU_USE_TIM1
|
#if STM32_ICU_USE_TIM1
|
||||||
icu_lld_serve_interrupt(&ICUD1);
|
icu_lld_serve_interrupt(&ICUD1);
|
||||||
#endif
|
#endif
|
||||||
#if STM32_ICU_USE_TIM16
|
|
||||||
icu_lld_serve_interrupt(&ICUD16);
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
#if HAL_USE_PWM
|
#if HAL_USE_PWM
|
||||||
#if STM32_PWM_USE_TIM1
|
#if STM32_PWM_USE_TIM1
|
||||||
|
@ -292,9 +289,7 @@ OSAL_IRQ_HANDLER(VectorA8) {
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if HAL_USE_ICU
|
#if HAL_USE_ICU
|
||||||
#if STM32_ICU_USE_TIM17
|
/* Not used by ICU.*/
|
||||||
icu_lld_serve_interrupt(&ICUD17);
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
#if HAL_USE_PWM
|
#if HAL_USE_PWM
|
||||||
#if STM32_PWM_USE_TIM17
|
#if STM32_PWM_USE_TIM17
|
||||||
|
|
Loading…
Reference in New Issue