diff --git a/os/hal/ports/STM32/LLD/TIMv1/hal_st_lld.c b/os/hal/ports/STM32/LLD/TIMv1/hal_st_lld.c index 4b8340906..fe2b6bf66 100644 --- a/os/hal/ports/STM32/LLD/TIMv1/hal_st_lld.c +++ b/os/hal/ports/STM32/LLD/TIMv1/hal_st_lld.c @@ -292,6 +292,81 @@ #define ST_ENABLE_STOP() DBGMCU->APB1FZ |= DBGMCU_APB1_FZ_DBG_TIM14_STOP #endif +#elif STM32_ST_USE_TIMER == 15 + +#if !STM32_HAS_TIM15 +#error "TIM15 not present in the selected device" +#endif + +#if (OSAL_ST_RESOLUTION == 32) && !STM32_TIM15_IS_32BITS +#error "TIM15 is not a 32bits timer" +#endif + +#define ST_HANDLER STM32_TIM15_HANDLER +#define ST_NUMBER STM32_TIM15_NUMBER +#define ST_CLOCK_SRC STM32_TIMCLK2 +#define ST_ENABLE_CLOCK() rccEnableTIM15(true) +#if defined(STM32F1XX) +#define ST_ENABLE_STOP() DBGMCU->CR |= DBGMCU_CR_DBG_TIM15_STOP +#elif defined(STM32L4XX) || defined(STM32L4XXP) || defined(STM32G4XX) || \ + defined(STM32L5XX) || defined(STM32WBXX) +#define ST_ENABLE_STOP() DBGMCU->APB2FZ |= DBGMCU_APB2FZ_DBG_TIM15_STOP +#elif defined(STM32H7XX) +#define ST_ENABLE_STOP() DBGMCU->APB2FZ1 |= DBGMCU_APB2FZ1_DBG_TIM15 +#else +#define ST_ENABLE_STOP() DBGMCU->APB2FZ |= DBGMCU_APB2_FZ_DBG_TIM15_STOP +#endif + +#elif STM32_ST_USE_TIMER == 16 + +#if !STM32_HAS_TIM16 +#error "TIM16 not present in the selected device" +#endif + +#if (OSAL_ST_RESOLUTION == 32) && !STM32_TIM16_IS_32BITS +#error "TIM16 is not a 32bits timer" +#endif + +#define ST_HANDLER STM32_TIM16_HANDLER +#define ST_NUMBER STM32_TIM16_NUMBER +#define ST_CLOCK_SRC STM32_TIMCLK2 +#define ST_ENABLE_CLOCK() rccEnableTIM16(true) +#if defined(STM32F1XX) +#define ST_ENABLE_STOP() DBGMCU->CR |= DBGMCU_CR_DBG_TIM16_STOP +#elif defined(STM32L4XX) || defined(STM32L4XXP) || defined(STM32G4XX) || \ + defined(STM32L5XX) || defined(STM32WBXX) +#define ST_ENABLE_STOP() DBGMCU->APB2FZ |= DBGMCU_APB2FZ_DBG_TIM16_STOP +#elif defined(STM32H7XX) +#define ST_ENABLE_STOP() DBGMCU->APB2FZ1 |= DBGMCU_APB2FZ1_DBG_TIM16 +#else +#define ST_ENABLE_STOP() DBGMCU->APB2FZ |= DBGMCU_APB2_FZ_DBG_TIM16_STOP +#endif + +#elif STM32_ST_USE_TIMER == 17 + +#if !STM32_HAS_TIM17 +#error "TIM17 not present in the selected device" +#endif + +#if (OSAL_ST_RESOLUTION == 32) && !STM32_TIM17_IS_32BITS +#error "TIM17 is not a 32bits timer" +#endif + +#define ST_HANDLER STM32_TIM17_HANDLER +#define ST_NUMBER STM32_TIM17_NUMBER +#define ST_CLOCK_SRC STM32_TIMCLK2 +#define ST_ENABLE_CLOCK() rccEnableTIM17(true) +#if defined(STM32F1XX) +#define ST_ENABLE_STOP() DBGMCU->CR |= DBGMCU_CR_DBG_TIM17_STOP +#elif defined(STM32L4XX) || defined(STM32L4XXP) || defined(STM32G4XX) || \ + defined(STM32L5XX) || defined(STM32WBXX) +#define ST_ENABLE_STOP() DBGMCU->APB2FZ |= DBGMCU_APB2FZ_DBG_TIM17_STOP +#elif defined(STM32H7XX) +#define ST_ENABLE_STOP() DBGMCU->APB2FZ1 |= DBGMCU_APB2FZ1_DBG_TIM17 +#else +#define ST_ENABLE_STOP() DBGMCU->APB2FZ |= DBGMCU_APB2_FZ_DBG_TIM17_STOP +#endif + #elif STM32_ST_USE_TIMER == 21 #if !STM32_HAS_TIM21 diff --git a/os/hal/ports/STM32/LLD/TIMv1/hal_st_lld.h b/os/hal/ports/STM32/LLD/TIMv1/hal_st_lld.h index 3cc2a4a0e..ad8b1d95c 100644 --- a/os/hal/ports/STM32/LLD/TIMv1/hal_st_lld.h +++ b/os/hal/ports/STM32/LLD/TIMv1/hal_st_lld.h @@ -50,7 +50,8 @@ * @brief TIMx unit (by number) to be used for free running operations. * @note You must select a 32 bits timer if a 32 bits @p systick_t type * is required. - * @note Timers 2, 3, 4, 5, 21 and 22 are supported. + * @note Timers 2, 3, 4, 5, 9, 10, 11, 12, 13, 14, 15, 16, 17, + * 21 and 22 are supported. */ #if !defined(STM32_ST_USE_TIMER) || defined(__DOXYGEN__) #define STM32_ST_USE_TIMER 2 @@ -114,7 +115,19 @@ #endif #if !defined(STM32_HAS_TIM14) -#define STM32_HAS_TIM14 FALSE +#define STM32_HAS_TIM14 FALSE +#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 !defined(STM32_HAS_TIM21) @@ -153,6 +166,9 @@ #define STM32_ST_USE_TIM12 FALSE #define STM32_ST_USE_TIM13 FALSE #define STM32_ST_USE_TIM14 FALSE +#define STM32_ST_USE_TIM15 FALSE +#define STM32_ST_USE_TIM16 FALSE +#define STM32_ST_USE_TIM17 FALSE #define STM32_ST_USE_TIM21 FALSE #define STM32_ST_USE_TIM22 FALSE @@ -181,6 +197,9 @@ #define STM32_ST_USE_TIM12 FALSE #define STM32_ST_USE_TIM13 FALSE #define STM32_ST_USE_TIM14 FALSE +#define STM32_ST_USE_TIM15 FALSE +#define STM32_ST_USE_TIM16 FALSE +#define STM32_ST_USE_TIM17 FALSE #define STM32_ST_USE_TIM21 FALSE #define STM32_ST_USE_TIM22 FALSE @@ -209,6 +228,9 @@ #define STM32_ST_USE_TIM12 FALSE #define STM32_ST_USE_TIM13 FALSE #define STM32_ST_USE_TIM14 FALSE +#define STM32_ST_USE_TIM15 FALSE +#define STM32_ST_USE_TIM16 FALSE +#define STM32_ST_USE_TIM17 FALSE #define STM32_ST_USE_TIM21 FALSE #define STM32_ST_USE_TIM22 FALSE @@ -237,6 +259,9 @@ #define STM32_ST_USE_TIM12 FALSE #define STM32_ST_USE_TIM13 FALSE #define STM32_ST_USE_TIM14 FALSE +#define STM32_ST_USE_TIM15 FALSE +#define STM32_ST_USE_TIM16 FALSE +#define STM32_ST_USE_TIM17 FALSE #define STM32_ST_USE_TIM21 FALSE #define STM32_ST_USE_TIM22 FALSE @@ -265,6 +290,9 @@ #define STM32_ST_USE_TIM12 FALSE #define STM32_ST_USE_TIM13 FALSE #define STM32_ST_USE_TIM14 FALSE +#define STM32_ST_USE_TIM15 FALSE +#define STM32_ST_USE_TIM16 FALSE +#define STM32_ST_USE_TIM17 FALSE #define STM32_ST_USE_TIM21 FALSE #define STM32_ST_USE_TIM22 FALSE @@ -293,6 +321,9 @@ #define STM32_ST_USE_TIM12 FALSE #define STM32_ST_USE_TIM13 FALSE #define STM32_ST_USE_TIM14 FALSE +#define STM32_ST_USE_TIM15 FALSE +#define STM32_ST_USE_TIM16 FALSE +#define STM32_ST_USE_TIM17 FALSE #define STM32_ST_USE_TIM21 FALSE #define STM32_ST_USE_TIM22 FALSE @@ -321,6 +352,9 @@ #define STM32_ST_USE_TIM12 FALSE #define STM32_ST_USE_TIM13 FALSE #define STM32_ST_USE_TIM14 FALSE +#define STM32_ST_USE_TIM15 FALSE +#define STM32_ST_USE_TIM16 FALSE +#define STM32_ST_USE_TIM17 FALSE #define STM32_ST_USE_TIM21 FALSE #define STM32_ST_USE_TIM22 FALSE @@ -349,6 +383,9 @@ #define STM32_ST_USE_TIM12 TRUE #define STM32_ST_USE_TIM13 FALSE #define STM32_ST_USE_TIM14 FALSE +#define STM32_ST_USE_TIM15 FALSE +#define STM32_ST_USE_TIM16 FALSE +#define STM32_ST_USE_TIM17 FALSE #define STM32_ST_USE_TIM21 FALSE #define STM32_ST_USE_TIM22 FALSE @@ -377,6 +414,9 @@ #define STM32_ST_USE_TIM12 FALSE #define STM32_ST_USE_TIM13 TRUE #define STM32_ST_USE_TIM14 FALSE +#define STM32_ST_USE_TIM15 FALSE +#define STM32_ST_USE_TIM16 FALSE +#define STM32_ST_USE_TIM17 FALSE #define STM32_ST_USE_TIM21 FALSE #define STM32_ST_USE_TIM22 FALSE @@ -405,9 +445,104 @@ #define STM32_ST_USE_TIM12 FALSE #define STM32_ST_USE_TIM13 FALSE #define STM32_ST_USE_TIM14 TRUE +#define STM32_ST_USE_TIM15 FALSE +#define STM32_ST_USE_TIM16 FALSE +#define STM32_ST_USE_TIM17 FALSE #define STM32_ST_USE_TIM21 FALSE #define STM32_ST_USE_TIM22 FALSE +#elif STM32_ST_USE_TIMER == 15 + +#if defined(STM32_TIM15_IS_USED) +#error "ST requires TIM15 but the timer is already used" +#else +#define STM32_TIM15_IS_USED +#endif + +#if defined(STM32_TIM15_SUPPRESS_ISR) +#define STM32_SYSTICK_SUPPRESS_ISR +#endif + +#define STM32_ST_TIM STM32_TIM15 +#define ST_LLD_NUM_ALARMS STM32_TIM15_CHANNELS +#define STM32_ST_USE_SYSTICK FALSE +#define STM32_ST_USE_TIM2 FALSE +#define STM32_ST_USE_TIM3 FALSE +#define STM32_ST_USE_TIM4 FALSE +#define STM32_ST_USE_TIM5 FALSE +#define STM32_ST_USE_TIM9 FALSE +#define STM32_ST_USE_TIM10 FALSE +#define STM32_ST_USE_TIM11 FALSE +#define STM32_ST_USE_TIM12 FALSE +#define STM32_ST_USE_TIM13 FALSE +#define STM32_ST_USE_TIM14 FALSE +#define STM32_ST_USE_TIM15 TRUE +#define STM32_ST_USE_TIM16 FALSE +#define STM32_ST_USE_TIM17 FALSE +#define STM32_ST_USE_TIM21 FALSE +#define STM32_ST_USE_TIM22 FALSE + +#elif STM32_ST_USE_TIMER == 16 + +#if defined(STM32_TIM16_IS_USED) +#error "ST requires TIM16 but the timer is already used" +#else +#define STM32_TIM16_IS_USED +#endif + +#if defined(STM32_TIM16_SUPPRESS_ISR) +#define STM32_SYSTICK_SUPPRESS_ISR +#endif + +#define STM32_ST_TIM STM32_TIM16 +#define ST_LLD_NUM_ALARMS STM32_TIM16_CHANNELS +#define STM32_ST_USE_SYSTICK FALSE +#define STM32_ST_USE_TIM2 FALSE +#define STM32_ST_USE_TIM3 FALSE +#define STM32_ST_USE_TIM4 FALSE +#define STM32_ST_USE_TIM5 FALSE +#define STM32_ST_USE_TIM9 FALSE +#define STM32_ST_USE_TIM10 FALSE +#define STM32_ST_USE_TIM11 FALSE +#define STM32_ST_USE_TIM12 FALSE +#define STM32_ST_USE_TIM13 FALSE +#define STM32_ST_USE_TIM14 FALSE +#define STM32_ST_USE_TIM15 FALSE +#define STM32_ST_USE_TIM16 TRUE +#define STM32_ST_USE_TIM17 FALSE +#define STM32_ST_USE_TIM21 FALSE +#define STM32_ST_USE_TIM22 FALSE + +#elif STM32_ST_USE_TIMER == 17 + +#if defined(STM32_TIM17_IS_USED) +#error "ST requires TIM17 but the timer is already used" +#else +#define STM32_TIM17_IS_USED +#endif + +#if defined(STM32_TIM17_SUPPRESS_ISR) +#define STM32_SYSTICK_SUPPRESS_ISR +#endif + +#define STM32_ST_TIM STM32_TIM17 +#define ST_LLD_NUM_ALARMS STM32_TIM17_CHANNELS +#define STM32_ST_USE_SYSTICK FALSE +#define STM32_ST_USE_TIM2 FALSE +#define STM32_ST_USE_TIM3 FALSE +#define STM32_ST_USE_TIM4 FALSE +#define STM32_ST_USE_TIM5 FALSE +#define STM32_ST_USE_TIM9 FALSE +#define STM32_ST_USE_TIM10 FALSE +#define STM32_ST_USE_TIM11 FALSE +#define STM32_ST_USE_TIM12 FALSE +#define STM32_ST_USE_TIM13 FALSE +#define STM32_ST_USE_TIM14 FALSE +#define STM32_ST_USE_TIM15 FALSE +#define STM32_ST_USE_TIM16 FALSE +#define STM32_ST_USE_TIM17 TRUE +#define STM32_ST_USE_TIM21 FALSE +#define STM32_ST_USE_TIM22 FALSE #elif STM32_ST_USE_TIMER == 21 #if defined(STM32_TIM21_IS_USED) @@ -433,6 +568,9 @@ #define STM32_ST_USE_TIM12 FALSE #define STM32_ST_USE_TIM13 FALSE #define STM32_ST_USE_TIM14 FALSE +#define STM32_ST_USE_TIM15 FALSE +#define STM32_ST_USE_TIM16 FALSE +#define STM32_ST_USE_TIM17 FALSE #define STM32_ST_USE_TIM21 TRUE #define STM32_ST_USE_TIM22 FALSE @@ -461,6 +599,9 @@ #define STM32_ST_USE_TIM12 FALSE #define STM32_ST_USE_TIM13 FALSE #define STM32_ST_USE_TIM14 FALSE +#define STM32_ST_USE_TIM15 FALSE +#define STM32_ST_USE_TIM16 FALSE +#define STM32_ST_USE_TIM17 FALSE #define STM32_ST_USE_TIM21 FALSE #define STM32_ST_USE_TIM22 TRUE @@ -491,6 +632,9 @@ #define STM32_ST_USE_TIM12 FALSE #define STM32_ST_USE_TIM13 FALSE #define STM32_ST_USE_TIM14 FALSE +#define STM32_ST_USE_TIM15 FALSE +#define STM32_ST_USE_TIM16 FALSE +#define STM32_ST_USE_TIM17 FALSE #define STM32_ST_USE_TIM21 FALSE #define STM32_ST_USE_TIM22 FALSE @@ -507,6 +651,9 @@ #define STM32_ST_USE_TIM12 FALSE #define STM32_ST_USE_TIM13 FALSE #define STM32_ST_USE_TIM14 FALSE +#define STM32_ST_USE_TIM15 FALSE +#define STM32_ST_USE_TIM16 FALSE +#define STM32_ST_USE_TIM17 FALSE #define STM32_ST_USE_TIM21 FALSE #define STM32_ST_USE_TIM22 FALSE