Improved EXTI support for STM32G4xx.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@13230 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
Giovanni Di Sirio 2019-12-29 16:27:43 +00:00
parent 50116fa76f
commit 96d568c3f9
10 changed files with 298 additions and 16 deletions

View File

@ -90,6 +90,14 @@
#define STM32_IRQ_EXTI4_PRIORITY 6
#define STM32_IRQ_EXTI5_9_PRIORITY 6
#define STM32_IRQ_EXTI10_15_PRIORITY 6
#define STM32_IRQ_EXTI164041_PRIORITY 6
#define STM32_IRQ_EXTI17_PRIORITY 6
#define STM32_IRQ_EXTI18_PRIORITY 6
#define STM32_IRQ_EXTI19_PRIORITY 6
#define STM32_IRQ_EXTI20_PRIORITY 6
#define STM32_IRQ_EXTI212229_PRIORITY 6
#define STM32_IRQ_EXTI30_32_PRIORITY 6
#define STM32_IRQ_EXTI33_PRIORITY 6
#define STM32_IRQ_TIM1_BRK_TIM15_PRIORITY 7
#define STM32_IRQ_TIM1_UP_TIM16_PRIORITY 7

View File

@ -96,6 +96,14 @@
#define STM32_IRQ_EXTI4_PRIORITY 6
#define STM32_IRQ_EXTI5_9_PRIORITY 6
#define STM32_IRQ_EXTI10_15_PRIORITY 6
#define STM32_IRQ_EXTI164041_PRIORITY 6
#define STM32_IRQ_EXTI17_PRIORITY 6
#define STM32_IRQ_EXTI18_PRIORITY 6
#define STM32_IRQ_EXTI19_PRIORITY 6
#define STM32_IRQ_EXTI20_PRIORITY 6
#define STM32_IRQ_EXTI212229_PRIORITY 6
#define STM32_IRQ_EXTI30_32_PRIORITY 6
#define STM32_IRQ_EXTI33_PRIORITY 6
#define STM32_IRQ_TIM1_BRK_TIM15_PRIORITY 7
#define STM32_IRQ_TIM1_UP_TIM16_PRIORITY 7
@ -211,6 +219,8 @@
#define STM32_ICU_USE_TIM5 FALSE
#define STM32_ICU_USE_TIM8 FALSE
#define STM32_ICU_USE_TIM15 FALSE
#define STM32_ICU_USE_TIM16 FALSE
#define STM32_ICU_USE_TIM17 FALSE
/*
* PWM driver system settings.
@ -225,6 +235,7 @@
#define STM32_PWM_USE_TIM15 FALSE
#define STM32_PWM_USE_TIM16 FALSE
#define STM32_PWM_USE_TIM17 FALSE
#define STM32_PWM_USE_TIM20 FALSE
/*
* RTC driver system settings.

View File

@ -51,14 +51,14 @@
/* Driver local functions. */
/*===========================================================================*/
static inline void exti10_exti40_41_irq_init(void) {
static inline void exti16_exti40_exti41_irq_init(void) {
#if defined(STM32_EXTI16_IS_USED) || defined(STM32_EXTI40_IS_USED) || \
defined(STM32_EXTI41_IS_USED)
nvicEnableVector(STM32_EXTI164041_NUMBER, STM32_IRQ_EXTI10_15_PRIORITY);
#endif
}
static inline void exti10_exti40_41_irq_deinit(void) {
static inline void exti16_exti40_exti41_irq_deinit(void) {
#if defined(STM32_EXTI16_IS_USED) || defined(STM32_EXTI40_IS_USED) || \
defined(STM32_EXTI41_IS_USED)
nvicDisableVector(STM32_EXTI164041_NUMBER);
@ -78,16 +78,20 @@ static inline void exti10_exti40_41_irq_deinit(void) {
* @isr
*/
OSAL_IRQ_HANDLER(STM32_EXTI164041_HANDLER) {
uint32_t pr1, pr2;
uint32_t pr;
OSAL_IRQ_PROLOGUE();
extiGetAndClearGroup1(1U << 16);
extiGetAndClearGroup2((1U << (40 - 32)) | (1U << (41 - 32)), pr2);
#if defined(STM32_EXTI16_IS_USED)
extiGetAndClearGroup1(1U << 16, pr);
exti_serve_irq(pr, 16);
#endif
exti_serve_irq(pr1, 16);
exti_serve_irq(pr2, (40 - 32));
exti_serve_irq(pr2, (41 - 32));
#if defined(STM32_EXTI40_IS_USED) || defined(STM32_EXTI41_IS_USED)
extiGetAndClearGroup2((1U << (40 - 32)) | (1U << (41 - 32)), pr);
exti_serve_irq(pr, (40 - 32));
exti_serve_irq(pr, (41 - 32));
#endif
OSAL_IRQ_EPILOGUE();
}

View File

@ -0,0 +1,100 @@
/*
ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* @file EXTIv1/stm32_exti21_22-29.inc
* @brief Shared EXTI21_22-29 handler.
*
* @addtogroup STM32_EXTI212229_HANDLER
* @{
*/
/*===========================================================================*/
/* Driver local definitions. */
/*===========================================================================*/
/*===========================================================================*/
/* Derived constants and error checks. */
/*===========================================================================*/
/* Priority settings checks.*/
#if !defined(STM32_IRQ_EXTI212229_PRIORITY)
#error "STM32_IRQ_EXTI212229_PRIORITY not defined in mcuconf.h"
#endif
#if !OSAL_IRQ_IS_VALID_PRIORITY(STM32_IRQ_EXTI212229_PRIORITY)
#error "Invalid IRQ priority assigned to STM32_IRQ_EXTI212229_PRIORITY"
#endif
/*===========================================================================*/
/* Driver exported variables. */
/*===========================================================================*/
/*===========================================================================*/
/* Driver local variables. */
/*===========================================================================*/
/*===========================================================================*/
/* Driver local functions. */
/*===========================================================================*/
static inline void exti21_exti22_exti29_irq_init(void) {
#if defined(STM32_EXTI21_IS_USED) || defined(STM32_EXTI22_IS_USED) || \
defined(STM32_EXTI29_IS_USED)
nvicEnableVector(STM32_EXTI212229_NUMBER, STM32_IRQ_EXTI212229_PRIORITY);
#endif
}
static inline void exti21_exti22_exti29_irq_deinit(void) {
#if defined(STM32_EXTI21_IS_USED) || defined(STM32_EXTI22_IS_USED) || \
defined(STM32_EXTI29_IS_USED)
nvicDisableVector(STM32_EXTI212229_NUMBER);
#endif
}
/*===========================================================================*/
/* Driver interrupt handlers. */
/*===========================================================================*/
#if defined(STM32_EXTI21_IS_USED) || defined(STM32_EXTI22_IS_USED) || \
defined(STM32_EXTI29_IS_USED) || defined(__DOXYGEN__)
#if !defined(STM32_DISABLE_EXTI212229_HANDLER)
/**
* @brief EXTI[21], EXTI[22], EXTI[29] interrupt handler.
*
* @isr
*/
OSAL_IRQ_HANDLER(STM32_EXTI212229_HANDLER) {
uint32_t pr;
OSAL_IRQ_PROLOGUE();
extiGetAndClearGroup1((1U << 21) | (1U << 22) | (1U << 29), pr);
exti_serve_irq(pr, 21);
exti_serve_irq(pr, 22);
exti_serve_irq(pr, 29);
OSAL_IRQ_EPILOGUE();
}
#endif
#endif
/*===========================================================================*/
/* Driver exported functions. */
/*===========================================================================*/
/** @} */

View File

@ -0,0 +1,105 @@
/*
ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* @file EXTIv1/stm32_exti30_32.inc
* @brief Shared EXTI30_32 handler.
*
* @addtogroup STM32_EXTI30_32_HANDLER
* @{
*/
/*===========================================================================*/
/* Driver local definitions. */
/*===========================================================================*/
/*===========================================================================*/
/* Derived constants and error checks. */
/*===========================================================================*/
/* Priority settings checks.*/
#if !defined(STM32_IRQ_EXTI30_32_PRIORITY)
#error "STM32_IRQ_EXTI30_32_PRIORITY not defined in mcuconf.h"
#endif
#if !OSAL_IRQ_IS_VALID_PRIORITY(STM32_IRQ_EXTI30_32_PRIORITY)
#error "Invalid IRQ priority assigned to STM32_IRQ_EXTI30_32_PRIORITY"
#endif
/*===========================================================================*/
/* Driver exported variables. */
/*===========================================================================*/
/*===========================================================================*/
/* Driver local variables. */
/*===========================================================================*/
/*===========================================================================*/
/* Driver local functions. */
/*===========================================================================*/
static inline void exti30_32_irq_init(void) {
#if defined(STM32_EXTI30_IS_USED) || defined(STM32_EXTI31_IS_USED) || \
defined(STM32_EXTI32_IS_USED)
nvicEnableVector(STM32_EXTI30_32_NUMBER, STM32_IRQ_EXTI30_32_PRIORITY);
#endif
}
static inline void exti30_32_irq_deinit(void) {
#if defined(STM32_EXTI30_IS_USED) || defined(STM32_EXTI31_IS_USED) || \
defined(STM32_EXTI32_IS_USED)
nvicDisableVector(STM32_EXTI30_32_NUMBER);
#endif
}
/*===========================================================================*/
/* Driver interrupt handlers. */
/*===========================================================================*/
#if defined(STM32_EXTI30_IS_USED) || defined(STM32_EXTI31_IS_USED) || \
defined(STM32_EXTI32_IS_USED) || defined(__DOXYGEN__)
#if !defined(STM32_DISABLE_EXTI30_32_HANDLER)
/**
* @brief EXTI[16], EXTI[40], EXTI[41] interrupt handler.
*
* @isr
*/
OSAL_IRQ_HANDLER(STM32_EXTI164041_HANDLER) {
uint32_t pr;
OSAL_IRQ_PROLOGUE();
#if defined(STM32_EXTI30_IS_USED) || defined(STM32_EXTI31_IS_USED)
extiGetAndClearGroup1((1U << 30) | (1U << 31), pr);
exti_serve_irq(pr, 30);
exti_serve_irq(pr, 31);
#endif
#if defined(STM32_EXTI32_IS_USED)
extiGetAndClearGroup2(1U << (32 - 32), pr);
exti_serve_irq(pr, (32 - 32));
#endif
OSAL_IRQ_EPILOGUE();
}
#endif
#endif
/*===========================================================================*/
/* Driver exported functions. */
/*===========================================================================*/
/** @} */

View File

@ -58,6 +58,14 @@
#include "stm32_exti4.inc"
#include "stm32_exti5_9.inc"
#include "stm32_exti10_15.inc"
#include "stm32_exti16-40_41.inc"
#include "stm32_exti17.inc"
#include "stm32_exti18.inc"
#include "stm32_exti19.inc"
#include "stm32_exti20.inc"
#include "stm32_exti21_22-29.inc"
#include "stm32_exti30_32.inc"
#include "stm32_exti33.inc"
#include "stm32_usart1.inc"
#include "stm32_usart2.inc"
@ -94,6 +102,13 @@ void irqInit(void) {
exti4_irq_init();
exti5_9_irq_init();
exti10_15_irq_init();
exti16_exti40_exti41_irq_init();
exti17_irq_init();
exti18_irq_init();
exti19_irq_init();
exti21_exti22_exti29_irq_init();
exti30_32_irq_init();
exti33_irq_init();
tim1_tim15_tim16_tim17_irq_init();
tim2_irq_init();
@ -127,6 +142,13 @@ void irqDeinit(void) {
exti4_irq_deinit();
exti5_9_irq_deinit();
exti10_15_irq_deinit();
exti16_exti40_exti41_irq_deinit();
exti17_irq_deinit();
exti18_irq_deinit();
exti19_irq_deinit();
exti21_exti22_exti29_irq_deinit();
exti30_32_irq_deinit();
exti33_irq_deinit();
tim1_tim15_tim16_tim17_irq_deinit();
tim2_irq_deinit();

View File

@ -120,13 +120,14 @@
#define STM32_EXTI4_HANDLER Vector68
#define STM32_EXTI5_9_HANDLER Vector9C
#define STM32_EXTI10_15_HANDLER VectorE0
#define STM32_EXTI164041HANDLER Vector44
#define STM32_EXTI17_HANDLER VectorE4
#define STM32_EXTI19_HANDLER Vector48
#define STM32_EXTI20_HANDLER Vector4C
#define STM32_EXTI212229_HANDLER Vector140
#define STM32_EXTI303132_HANDLER Vector144
#define STM32_EXTI33_HANDLER Vector148
#define STM32_EXTI164041_HANDLER Vector44 /* PVD PVM */
#define STM32_EXTI17_HANDLER VectorE4 /* RTC ALARM */
#define STM32_EXTI18_HANDLER VectorE8 /* USB WAKEUP */
#define STM32_EXTI19_HANDLER Vector48 /* RTC TAMP CSS */
#define STM32_EXTI20_HANDLER Vector4C /* RTC WAKEUP */
#define STM32_EXTI212229_HANDLER Vector140 /* COMP1..3 */
#define STM32_EXTI30_32_HANDLER Vector144 /* COMP4..6 */
#define STM32_EXTI33_HANDLER Vector148 /* COMP7 */
#define STM32_EXTI0_NUMBER 6
#define STM32_EXTI1_NUMBER 7
@ -137,10 +138,11 @@
#define STM32_EXTI10_15_NUMBER 40
#define STM32_EXTI164041_NUMBER 1
#define STM32_EXTI17_NUMBER 41
#define STM32_EXTI18_NUMBER 42
#define STM32_EXTI19_NUMBER 2
#define STM32_EXTI20_NUMBER 3
#define STM32_EXTI212229_NUMBER 64
#define STM32_EXTI303132_NUMBER 65
#define STM32_EXTI30_32_NUMBER 65
#define STM32_EXTI33_NUMBER 66
/*

View File

@ -96,6 +96,14 @@
#define STM32_IRQ_EXTI4_PRIORITY 6
#define STM32_IRQ_EXTI5_9_PRIORITY 6
#define STM32_IRQ_EXTI10_15_PRIORITY 6
#define STM32_IRQ_EXTI164041_PRIORITY 6
#define STM32_IRQ_EXTI17_PRIORITY 6
#define STM32_IRQ_EXTI18_PRIORITY 6
#define STM32_IRQ_EXTI19_PRIORITY 6
#define STM32_IRQ_EXTI20_PRIORITY 6
#define STM32_IRQ_EXTI212229_PRIORITY 6
#define STM32_IRQ_EXTI30_32_PRIORITY 6
#define STM32_IRQ_EXTI33_PRIORITY 6
#define STM32_IRQ_TIM1_BRK_TIM15_PRIORITY 7
#define STM32_IRQ_TIM1_UP_TIM16_PRIORITY 7
@ -211,6 +219,8 @@
#define STM32_ICU_USE_TIM5 FALSE
#define STM32_ICU_USE_TIM8 FALSE
#define STM32_ICU_USE_TIM15 FALSE
#define STM32_ICU_USE_TIM16 FALSE
#define STM32_ICU_USE_TIM17 FALSE
/*
* PWM driver system settings.
@ -225,6 +235,7 @@
#define STM32_PWM_USE_TIM15 FALSE
#define STM32_PWM_USE_TIM16 FALSE
#define STM32_PWM_USE_TIM17 FALSE
#define STM32_PWM_USE_TIM20 FALSE
/*
* RTC driver system settings.

View File

@ -101,6 +101,14 @@
#define STM32_IRQ_EXTI4_PRIORITY ${doc.STM32_IRQ_EXTI4_PRIORITY!"6"}
#define STM32_IRQ_EXTI5_9_PRIORITY ${doc.STM32_IRQ_EXTI5_9_PRIORITY!"6"}
#define STM32_IRQ_EXTI10_15_PRIORITY ${doc.STM32_IRQ_EXTI10_15_PRIORITY!"6"}
#define STM32_IRQ_EXTI164041_PRIORITY ${doc.STM32_IRQ_EXTI164041_PRIORITY!"6"}
#define STM32_IRQ_EXTI17_PRIORITY ${doc.STM32_IRQ_EXTI17_PRIORITY!"6"}
#define STM32_IRQ_EXTI18_PRIORITY ${doc.STM32_IRQ_EXTI18_PRIORITY!"6"}
#define STM32_IRQ_EXTI19_PRIORITY ${doc.STM32_IRQ_EXTI19_PRIORITY!"6"}
#define STM32_IRQ_EXTI20_PRIORITY ${doc.STM32_IRQ_EXTI20_PRIORITY!"6"}
#define STM32_IRQ_EXTI212229_PRIORITY ${doc.STM32_IRQ_EXTI212229_PRIORITY!"6"}
#define STM32_IRQ_EXTI30_32_PRIORITY ${doc.STM32_IRQ_EXTI30_32_PRIORITY!"6"}
#define STM32_IRQ_EXTI33_PRIORITY ${doc.STM32_IRQ_EXTI33_PRIORITY!"6"}
#define STM32_IRQ_TIM1_BRK_TIM15_PRIORITY ${doc.STM32_IRQ_TIM1_BRK_TIM15_PRIORITY!"7"}
#define STM32_IRQ_TIM1_UP_TIM16_PRIORITY ${doc.STM32_IRQ_TIM1_UP_TIM16_PRIORITY!"7"}

View File

@ -107,6 +107,14 @@
#define STM32_IRQ_EXTI4_PRIORITY ${doc.STM32_IRQ_EXTI4_PRIORITY!"6"}
#define STM32_IRQ_EXTI5_9_PRIORITY ${doc.STM32_IRQ_EXTI5_9_PRIORITY!"6"}
#define STM32_IRQ_EXTI10_15_PRIORITY ${doc.STM32_IRQ_EXTI10_15_PRIORITY!"6"}
#define STM32_IRQ_EXTI164041_PRIORITY ${doc.STM32_IRQ_EXTI164041_PRIORITY!"6"}
#define STM32_IRQ_EXTI17_PRIORITY ${doc.STM32_IRQ_EXTI17_PRIORITY!"6"}
#define STM32_IRQ_EXTI18_PRIORITY ${doc.STM32_IRQ_EXTI18_PRIORITY!"6"}
#define STM32_IRQ_EXTI19_PRIORITY ${doc.STM32_IRQ_EXTI19_PRIORITY!"6"}
#define STM32_IRQ_EXTI20_PRIORITY ${doc.STM32_IRQ_EXTI20_PRIORITY!"6"}
#define STM32_IRQ_EXTI212229_PRIORITY ${doc.STM32_IRQ_EXTI212229_PRIORITY!"6"}
#define STM32_IRQ_EXTI30_32_PRIORITY ${doc.STM32_IRQ_EXTI30_32_PRIORITY!"6"}
#define STM32_IRQ_EXTI33_PRIORITY ${doc.STM32_IRQ_EXTI33_PRIORITY!"6"}
#define STM32_IRQ_TIM1_BRK_TIM15_PRIORITY ${doc.STM32_IRQ_TIM1_BRK_TIM15_PRIORITY!"7"}
#define STM32_IRQ_TIM1_UP_TIM16_PRIORITY ${doc.STM32_IRQ_TIM1_UP_TIM16_PRIORITY!"7"}
@ -222,6 +230,8 @@
#define STM32_ICU_USE_TIM5 ${doc.STM32_ICU_USE_TIM5!"FALSE"}
#define STM32_ICU_USE_TIM8 ${doc.STM32_ICU_USE_TIM8!"FALSE"}
#define STM32_ICU_USE_TIM15 ${doc.STM32_ICU_USE_TIM15!"FALSE"}
#define STM32_ICU_USE_TIM16 ${doc.STM32_ICU_USE_TIM16!"FALSE"}
#define STM32_ICU_USE_TIM17 ${doc.STM32_ICU_USE_TIM17!"FALSE"}
/*
* PWM driver system settings.
@ -236,6 +246,7 @@
#define STM32_PWM_USE_TIM15 ${doc.STM32_PWM_USE_TIM15!"FALSE"}
#define STM32_PWM_USE_TIM16 ${doc.STM32_PWM_USE_TIM16!"FALSE"}
#define STM32_PWM_USE_TIM17 ${doc.STM32_PWM_USE_TIM17!"FALSE"}
#define STM32_PWM_USE_TIM20 ${doc.STM32_PWM_USE_TIM20!"FALSE"}
/*
* RTC driver system settings.