EICU. Added support of single channel timers.
Tested in hardware with TIM11.
This commit is contained in:
parent
ceb3c861d5
commit
bfac876090
|
@ -56,6 +56,7 @@
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver exported variables. */
|
/* Driver exported variables. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief EICUD1 driver identifier.
|
* @brief EICUD1 driver identifier.
|
||||||
* @note The driver EICUD1 allocates the complex timer TIM1 when enabled.
|
* @note The driver EICUD1 allocates the complex timer TIM1 when enabled.
|
||||||
|
@ -120,6 +121,38 @@ EICUDriver EICUD9;
|
||||||
EICUDriver EICUD12;
|
EICUDriver EICUD12;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief EICUD10 driver identifier.
|
||||||
|
* @note The driver EICUD10 allocates the timer TIM10 when enabled.
|
||||||
|
*/
|
||||||
|
#if STM32_EICU_USE_TIM10 && !defined(__DOXYGEN__)
|
||||||
|
EICUDriver EICUD10;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief EICUD11 driver identifier.
|
||||||
|
* @note The driver EICUD11 allocates the timer TIM11 when enabled.
|
||||||
|
*/
|
||||||
|
#if STM32_EICU_USE_TIM11 && !defined(__DOXYGEN__)
|
||||||
|
EICUDriver EICUD11;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief EICUD13 driver identifier.
|
||||||
|
* @note The driver EICUD13 allocates the timer TIM13 when enabled.
|
||||||
|
*/
|
||||||
|
#if STM32_EICU_USE_TIM13 && !defined(__DOXYGEN__)
|
||||||
|
EICUDriver EICUD13;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief EICUD14 driver identifier.
|
||||||
|
* @note The driver EICUD14 allocates the timer TIM14 when enabled.
|
||||||
|
*/
|
||||||
|
#if STM32_EICU_USE_TIM14 && !defined(__DOXYGEN__)
|
||||||
|
EICUDriver EICUD14;
|
||||||
|
#endif
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver local variables and types. */
|
/* Driver local variables and types. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -635,6 +668,94 @@ OSAL_IRQ_HANDLER(STM32_TIM12_HANDLER) {
|
||||||
}
|
}
|
||||||
#endif /* STM32_EICU_USE_TIM12 */
|
#endif /* STM32_EICU_USE_TIM12 */
|
||||||
|
|
||||||
|
#if STM32_EICU_USE_TIM10
|
||||||
|
#if !defined(STM32_TIM10_HANDLER)
|
||||||
|
#error "STM32_TIM10_HANDLER not defined"
|
||||||
|
#endif
|
||||||
|
/**
|
||||||
|
* @brief TIM10 interrupt handler.
|
||||||
|
* @note It is assumed that the various sources are only activated if the
|
||||||
|
* associated callback pointer is not equal to @p NULL in order to not
|
||||||
|
* perform an extra check in a potentially critical interrupt handler.
|
||||||
|
*
|
||||||
|
* @isr
|
||||||
|
*/
|
||||||
|
OSAL_IRQ_HANDLER(STM32_TIM10_HANDLER) {
|
||||||
|
|
||||||
|
OSAL_IRQ_PROLOGUE();
|
||||||
|
|
||||||
|
eicu_lld_serve_interrupt(&EICUD10);
|
||||||
|
|
||||||
|
OSAL_IRQ_EPILOGUE();
|
||||||
|
}
|
||||||
|
#endif /* STM32_EICU_USE_TIM10 */
|
||||||
|
|
||||||
|
#if STM32_EICU_USE_TIM11
|
||||||
|
#if !defined(STM32_TIM11_HANDLER)
|
||||||
|
#error "STM32_TIM11_HANDLER not defined"
|
||||||
|
#endif
|
||||||
|
/**
|
||||||
|
* @brief TIM11 interrupt handler.
|
||||||
|
* @note It is assumed that the various sources are only activated if the
|
||||||
|
* associated callback pointer is not equal to @p NULL in order to not
|
||||||
|
* perform an extra check in a potentially critical interrupt handler.
|
||||||
|
*
|
||||||
|
* @isr
|
||||||
|
*/
|
||||||
|
OSAL_IRQ_HANDLER(STM32_TIM11_HANDLER) {
|
||||||
|
|
||||||
|
OSAL_IRQ_PROLOGUE();
|
||||||
|
|
||||||
|
eicu_lld_serve_interrupt(&EICUD11);
|
||||||
|
|
||||||
|
OSAL_IRQ_EPILOGUE();
|
||||||
|
}
|
||||||
|
#endif /* STM32_EICU_USE_TIM11 */
|
||||||
|
|
||||||
|
#if STM32_EICU_USE_TIM13
|
||||||
|
#if !defined(STM32_TIM13_HANDLER)
|
||||||
|
#error "STM32_TIM13_HANDLER not defined"
|
||||||
|
#endif
|
||||||
|
/**
|
||||||
|
* @brief TIM13 interrupt handler.
|
||||||
|
* @note It is assumed that the various sources are only activated if the
|
||||||
|
* associated callback pointer is not equal to @p NULL in order to not
|
||||||
|
* perform an extra check in a potentially critical interrupt handler.
|
||||||
|
*
|
||||||
|
* @isr
|
||||||
|
*/
|
||||||
|
OSAL_IRQ_HANDLER(STM32_TIM13_HANDLER) {
|
||||||
|
|
||||||
|
OSAL_IRQ_PROLOGUE();
|
||||||
|
|
||||||
|
eicu_lld_serve_interrupt(&EICUD13);
|
||||||
|
|
||||||
|
OSAL_IRQ_EPILOGUE();
|
||||||
|
}
|
||||||
|
#endif /* STM32_EICU_USE_TIM13 */
|
||||||
|
|
||||||
|
#if STM32_EICU_USE_TIM14
|
||||||
|
#if !defined(STM32_TIM14_HANDLER)
|
||||||
|
#error "STM32_TIM14_HANDLER not defined"
|
||||||
|
#endif
|
||||||
|
/**
|
||||||
|
* @brief TIM14 interrupt handler.
|
||||||
|
* @note It is assumed that the various sources are only activated if the
|
||||||
|
* associated callback pointer is not equal to @p NULL in order to not
|
||||||
|
* perform an extra check in a potentially critical interrupt handler.
|
||||||
|
*
|
||||||
|
* @isr
|
||||||
|
*/
|
||||||
|
OSAL_IRQ_HANDLER(STM32_TIM14_HANDLER) {
|
||||||
|
|
||||||
|
OSAL_IRQ_PROLOGUE();
|
||||||
|
|
||||||
|
eicu_lld_serve_interrupt(&EICUD14);
|
||||||
|
|
||||||
|
OSAL_IRQ_EPILOGUE();
|
||||||
|
}
|
||||||
|
#endif /* STM32_EICU_USE_TIM14 */
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver exported functions. */
|
/* Driver exported functions. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -692,6 +813,30 @@ void eicu_lld_init(void) {
|
||||||
eicuObjectInit(&EICUD12);
|
eicuObjectInit(&EICUD12);
|
||||||
EICUD12.tim = STM32_TIM12;
|
EICUD12.tim = STM32_TIM12;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if STM32_EICU_USE_TIM10
|
||||||
|
/* Driver initialization.*/
|
||||||
|
eicuObjectInit(&EICUD10);
|
||||||
|
EICUD10.tim = STM32_TIM10;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if STM32_EICU_USE_TIM11
|
||||||
|
/* Driver initialization.*/
|
||||||
|
eicuObjectInit(&EICUD11);
|
||||||
|
EICUD11.tim = STM32_TIM11;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if STM32_EICU_USE_TIM13
|
||||||
|
/* Driver initialization.*/
|
||||||
|
eicuObjectInit(&EICUD13);
|
||||||
|
EICUD13.tim = STM32_TIM13;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if STM32_EICU_USE_TIM14
|
||||||
|
/* Driver initialization.*/
|
||||||
|
eicuObjectInit(&EICUD14);
|
||||||
|
EICUD14.tim = STM32_TIM14;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -794,6 +939,42 @@ void eicu_lld_start(EICUDriver *eicup) {
|
||||||
eicup->channels = 2;
|
eicup->channels = 2;
|
||||||
eicup->clock = STM32_TIMCLK1;
|
eicup->clock = STM32_TIMCLK1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#if STM32_EICU_USE_TIM10
|
||||||
|
if (&EICUD10 == eicup) {
|
||||||
|
rccEnableTIM10(FALSE);
|
||||||
|
rccResetTIM10();
|
||||||
|
nvicEnableVector(STM32_TIM10_NUMBER, STM32_EICU_TIM10_IRQ_PRIORITY);
|
||||||
|
eicup->channels = 1;
|
||||||
|
eicup->clock = STM32_TIMCLK1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if STM32_EICU_USE_TIM11
|
||||||
|
if (&EICUD11 == eicup) {
|
||||||
|
rccEnableTIM11(FALSE);
|
||||||
|
rccResetTIM11();
|
||||||
|
nvicEnableVector(STM32_TIM11_NUMBER, STM32_EICU_TIM11_IRQ_PRIORITY);
|
||||||
|
eicup->channels = 1;
|
||||||
|
eicup->clock = STM32_TIMCLK1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if STM32_EICU_USE_TIM13
|
||||||
|
if (&EICUD13 == eicup) {
|
||||||
|
rccEnableTIM13(FALSE);
|
||||||
|
rccResetTIM13();
|
||||||
|
nvicEnableVector(STM32_TIM13_NUMBER, STM32_EICU_TIM13_IRQ_PRIORITY);
|
||||||
|
eicup->channels = 1;
|
||||||
|
eicup->clock = STM32_TIMCLK1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if STM32_EICU_USE_TIM14
|
||||||
|
if (&EICUD14 == eicup) {
|
||||||
|
rccEnableTIM14(FALSE);
|
||||||
|
rccResetTIM14();
|
||||||
|
nvicEnableVector(STM32_TIM14_NUMBER, STM32_EICU_TIM14_IRQ_PRIORITY);
|
||||||
|
eicup->channels = 1;
|
||||||
|
eicup->clock = STM32_TIMCLK1;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -920,6 +1101,30 @@ void eicu_lld_stop(EICUDriver *eicup) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#if STM32_EICU_USE_TIM10
|
||||||
|
if (&EICUD10 == eicup) {
|
||||||
|
nvicDisableVector(STM32_TIM10_NUMBER);
|
||||||
|
rccDisableTIM10(FALSE);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if STM32_EICU_USE_TIM11
|
||||||
|
if (&EICUD11 == eicup) {
|
||||||
|
nvicDisableVector(STM32_TIM11_NUMBER);
|
||||||
|
rccDisableTIM11(FALSE);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if STM32_EICU_USE_TIM13
|
||||||
|
if (&EICUD13 == eicup) {
|
||||||
|
nvicDisableVector(STM32_TIM13_NUMBER);
|
||||||
|
rccDisableTIM13(FALSE);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if STM32_EICU_USE_TIM14
|
||||||
|
if (&EICUD14 == eicup) {
|
||||||
|
nvicDisableVector(STM32_TIM14_NUMBER);
|
||||||
|
rccDisableTIM14(FALSE);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -25,6 +25,78 @@
|
||||||
|
|
||||||
#if HAL_USE_EICU || defined(__DOXYGEN__)
|
#if HAL_USE_EICU || defined(__DOXYGEN__)
|
||||||
|
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Temporal definitions to be moved in main repository. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define STM32_TIM10_NUMBER 25
|
||||||
|
#define STM32_TIM13_NUMBER 44
|
||||||
|
|
||||||
|
#define STM32_TIM10_HANDLER VectorA4
|
||||||
|
#define STM32_TIM13_HANDLER VectorF0
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the TIM10 peripheral clock.
|
||||||
|
* @note The @p lp parameter is ignored in this family.
|
||||||
|
*
|
||||||
|
* @param[in] lp low power enable flag
|
||||||
|
*
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
#define rccEnableTIM10(lp) rccEnableAPB2(RCC_APB2ENR_TIM10EN, lp)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Disables the TIM10 peripheral clock.
|
||||||
|
* @note The @p lp parameter is ignored in this family.
|
||||||
|
*
|
||||||
|
* @param[in] lp low power enable flag
|
||||||
|
*
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
#define rccDisableTIM10(lp) rccDisableAPB2(RCC_APB2ENR_TIM10EN, lp)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Resets the TIM10 peripheral.
|
||||||
|
*
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
#define rccResetTIM10() rccResetAPB2(RCC_APB2RSTR_TIM10RST)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the TIM13 peripheral clock.
|
||||||
|
* @note The @p lp parameter is ignored in this family.
|
||||||
|
*
|
||||||
|
* @param[in] lp low power enable flag
|
||||||
|
*
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
#define rccEnableTIM13(lp) rccEnableAPB1(RCC_APB1ENR_TIM13EN, lp)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Disables the TIM13 peripheral clock.
|
||||||
|
* @note The @p lp parameter is ignored in this family.
|
||||||
|
*
|
||||||
|
* @param[in] lp low power enable flag
|
||||||
|
*
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
#define rccDisableTIM13(lp) rccDisableAPB1(RCC_APB1ENR_TIM13EN, lp)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Resets the TIM13 peripheral.
|
||||||
|
*
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
#define rccResetTIM13() rccResetAPB1(RCC_APB1RSTR_TIM13RST)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver constants. */
|
/* Driver constants. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -164,6 +236,34 @@
|
||||||
#if !defined(STM32_EICU_TIM12_IRQ_PRIORITY) || defined(__DOXYGEN__)
|
#if !defined(STM32_EICU_TIM12_IRQ_PRIORITY) || defined(__DOXYGEN__)
|
||||||
#define STM32_EICU_TIM12_IRQ_PRIORITY 7
|
#define STM32_EICU_TIM12_IRQ_PRIORITY 7
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief EICUD10 interrupt priority level setting.
|
||||||
|
*/
|
||||||
|
#if !defined(STM32_EICU_TIM10_IRQ_PRIORITY) || defined(__DOXYGEN__)
|
||||||
|
#define STM32_EICU_TIM10_IRQ_PRIORITY 7
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief EICUD11 interrupt priority level setting.
|
||||||
|
*/
|
||||||
|
#if !defined(STM32_EICU_TIM11_IRQ_PRIORITY) || defined(__DOXYGEN__)
|
||||||
|
#define STM32_EICU_TIM11_IRQ_PRIORITY 7
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief EICUD13 interrupt priority level setting.
|
||||||
|
*/
|
||||||
|
#if !defined(STM32_EICU_TIM13_IRQ_PRIORITY) || defined(__DOXYGEN__)
|
||||||
|
#define STM32_EICU_TIM13_IRQ_PRIORITY 7
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief EICUD14 interrupt priority level setting.
|
||||||
|
*/
|
||||||
|
#if !defined(STM32_EICU_TIM14_IRQ_PRIORITY) || defined(__DOXYGEN__)
|
||||||
|
#define STM32_EICU_TIM14_IRQ_PRIORITY 7
|
||||||
|
#endif
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -202,10 +302,28 @@
|
||||||
#error "TIM12 not present in the selected device"
|
#error "TIM12 not present in the selected device"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if STM32_EICU_USE_TIM10 && !STM32_HAS_TIM10
|
||||||
|
#error "TIM10 not present in the selected device"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if STM32_EICU_USE_TIM11 && !STM32_HAS_TIM11
|
||||||
|
#error "TIM11 not present in the selected device"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if STM32_EICU_USE_TIM13 && !STM32_HAS_TIM13
|
||||||
|
#error "TIM13 not present in the selected device"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if STM32_EICU_USE_TIM14 && !STM32_HAS_TIM14
|
||||||
|
#error "TIM14 not present in the selected device"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !STM32_EICU_USE_TIM1 && !STM32_EICU_USE_TIM2 && \
|
#if !STM32_EICU_USE_TIM1 && !STM32_EICU_USE_TIM2 && \
|
||||||
!STM32_EICU_USE_TIM3 && !STM32_EICU_USE_TIM4 && \
|
!STM32_EICU_USE_TIM3 && !STM32_EICU_USE_TIM4 && \
|
||||||
!STM32_EICU_USE_TIM5 && !STM32_EICU_USE_TIM8 && \
|
!STM32_EICU_USE_TIM5 && !STM32_EICU_USE_TIM8 && \
|
||||||
!STM32_EICU_USE_TIM9 && !STM32_EICU_USE_TIM12
|
!STM32_EICU_USE_TIM9 && !STM32_EICU_USE_TIM12 && \
|
||||||
|
!STM32_EICU_USE_TIM10 && !STM32_EICU_USE_TIM11 && \
|
||||||
|
!STM32_EICU_USE_TIM13 && !STM32_EICU_USE_TIM14
|
||||||
#error "EICU driver activated but no TIM peripheral assigned"
|
#error "EICU driver activated but no TIM peripheral assigned"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -249,6 +367,26 @@
|
||||||
#error "Invalid IRQ priority assigned to TIM12"
|
#error "Invalid IRQ priority assigned to TIM12"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if STM32_EICU_USE_TIM10 && \
|
||||||
|
!CORTEX_IS_VALID_KERNEL_PRIORITY(STM32_EICU_TIM10_IRQ_PRIORITY)
|
||||||
|
#error "Invalid IRQ priority assigned to TIM10"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if STM32_EICU_USE_TIM11 && \
|
||||||
|
!CORTEX_IS_VALID_KERNEL_PRIORITY(STM32_EICU_TIM11_IRQ_PRIORITY)
|
||||||
|
#error "Invalid IRQ priority assigned to TIM11"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if STM32_EICU_USE_TIM13 && \
|
||||||
|
!CORTEX_IS_VALID_KERNEL_PRIORITY(STM32_EICU_TIM13_IRQ_PRIORITY)
|
||||||
|
#error "Invalid IRQ priority assigned to TIM13"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if STM32_EICU_USE_TIM14 && \
|
||||||
|
!CORTEX_IS_VALID_KERNEL_PRIORITY(STM32_EICU_TIM14_IRQ_PRIORITY)
|
||||||
|
#error "Invalid IRQ priority assigned to TIM14"
|
||||||
|
#endif
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver data structures and types. */
|
/* Driver data structures and types. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -451,6 +589,22 @@ extern EICUDriver EICUD9;
|
||||||
extern EICUDriver EICUD12;
|
extern EICUDriver EICUD12;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if STM32_EICU_USE_TIM10 && !defined(__DOXYGEN__)
|
||||||
|
extern EICUDriver EICUD10;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if STM32_EICU_USE_TIM11 && !defined(__DOXYGEN__)
|
||||||
|
extern EICUDriver EICUD11;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if STM32_EICU_USE_TIM13 && !defined(__DOXYGEN__)
|
||||||
|
extern EICUDriver EICUD13;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if STM32_EICU_USE_TIM14 && !defined(__DOXYGEN__)
|
||||||
|
extern EICUDriver EICUD14;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue