aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/ports/STM32/LLD/COMPv1/hal_comp_lld.c
diff options
context:
space:
mode:
Diffstat (limited to 'os/hal/ports/STM32/LLD/COMPv1/hal_comp_lld.c')
-rw-r--r--os/hal/ports/STM32/LLD/COMPv1/hal_comp_lld.c37
1 files changed, 23 insertions, 14 deletions
diff --git a/os/hal/ports/STM32/LLD/COMPv1/hal_comp_lld.c b/os/hal/ports/STM32/LLD/COMPv1/hal_comp_lld.c
index a54290e..a768897 100644
--- a/os/hal/ports/STM32/LLD/COMPv1/hal_comp_lld.c
+++ b/os/hal/ports/STM32/LLD/COMPv1/hal_comp_lld.c
@@ -35,11 +35,15 @@
/*===========================================================================*/
#ifndef COMP_CSR_EN
-#define COMP_CSR_EN COMP_CSR_COMPxEN
+ #define COMP_CSR_EN COMP_CSR_COMPxEN
#endif
#ifndef COMP_CSR_POLARITY
-#define COMP_CSR_POLARITY COMP_CSR_COMPxPOL
+ #ifdef COMP_CSR_COMPxPOL
+ #define COMP_CSR_POLARITY COMP_CSR_COMPxPOL
+ #else
+ #define COMP_CSR_POLARITY COMP_CSR_COMPxPOLARITY // L0
+ #endif
#endif
/*===========================================================================*/
@@ -133,7 +137,7 @@ void comp_lld_init(void) {
COMPD1.reg = COMP1;
COMPD1.reg->CSR = 0;
#if STM32_COMP_USE_INTERRUPTS
- nvicEnableVector(COMP1_2_3_IRQn, STM32_COMP_1_2_3_IRQ_PRIORITY);
+ nvicEnableVector(STM32_COMP1_IRQn, STM32_COMP_1_2_3_IRQ_PRIORITY);
#endif
#endif
@@ -143,7 +147,7 @@ void comp_lld_init(void) {
COMPD2.reg = COMP2;
COMPD2.reg->CSR = 0;
#if STM32_COMP_USE_INTERRUPTS
- nvicEnableVector(COMP1_2_3_IRQn, STM32_COMP_1_2_3_IRQ_PRIORITY);
+ nvicEnableVector(STM32_COMP2_IRQn, STM32_COMP_1_2_3_IRQ_PRIORITY);
#endif
#endif
@@ -153,7 +157,7 @@ void comp_lld_init(void) {
COMPD3.reg = COMP3;
COMPD3.reg->CSR = 0;
#if STM32_COMP_USE_INTERRUPTS
- nvicEnableVector(COMP1_2_3_IRQn, STM32_COMP_1_2_3_IRQ_PRIORITY);
+ nvicEnableVector(STM32_COMP3_IRQn, STM32_COMP_1_2_3_IRQ_PRIORITY);
#endif
#endif
@@ -163,7 +167,7 @@ void comp_lld_init(void) {
COMPD4.reg = COMP4;
COMPD4.reg->CSR = 0;
#if STM32_COMP_USE_INTERRUPTS
- nvicEnableVector(COMP4_5_6_IRQn, STM32_COMP_1_2_3_IRQ_PRIORITY);
+ nvicEnableVector(STM32_COMP4_IRQn, STM32_COMP_4_5_6_IRQ_PRIORITY);
#endif
#endif
@@ -173,7 +177,7 @@ void comp_lld_init(void) {
COMPD5.reg = COMP5;
COMPD5.reg->CSR = 0;
#if STM32_COMP_USE_INTERRUPTS
- nvicEnableVector(COMP4_5_6_IRQn, STM32_COMP_1_2_3_IRQ_PRIORITY);
+ nvicEnableVector(STM32_COMP5_IRQn, STM32_COMP_4_5_6_IRQ_PRIORITY);
#endif
#endif
@@ -183,7 +187,7 @@ void comp_lld_init(void) {
COMPD6.reg = COMP6;
COMPD6.reg->CSR = 0;
#if STM32_COMP_USE_INTERRUPTS
- nvicEnableVector(COMP4_5_6_IRQn, STM32_COMP_1_2_3_IRQ_PRIORITY);
+ nvicEnableVector(STM32_COMP6_IRQn, STM32_COMP_4_5_6_IRQ_PRIORITY);
#endif
#endif
@@ -193,7 +197,7 @@ void comp_lld_init(void) {
COMPD7.reg = COMP7;
COMPD7.reg->CSR = 0;
#if STM32_COMP_USE_INTERRUPTS
- nvicEnableVector(COMP7_IRQn, STM32_COMP_7_IRQ_PRIORITY);
+ nvicEnableVector(STM32_COMP7_IRQn, STM32_COMP_7_IRQ_PRIORITY);
#endif
#endif
@@ -201,12 +205,13 @@ void comp_lld_init(void) {
#if STM32_COMP_USE_INTERRUPTS
+#if STM32_COMP_USE_COMP1 || STM32_COMP_USE_COMP2 || STM32_COMP_USE_COMP3
/**
* @brief COMP1, COMP2, COMP3 interrupt handler.
*
* @isr
*/
-OSAL_IRQ_HANDLER(Vector140) {
+OSAL_IRQ_HANDLER(COMP1_2_3_IRQHandler) {
uint32_t pr;
OSAL_IRQ_PROLOGUE();
@@ -229,13 +234,15 @@ OSAL_IRQ_HANDLER(Vector140) {
OSAL_IRQ_EPILOGUE();
}
+#endif
+#if STM32_COMP_USE_COMP4 || STM32_COMP_USE_COMP5 || STM32_COMP_USE_COMP6
/**
* @brief COMP4, COMP5, COMP6 interrupt handler.
*
* @isr
*/
-OSAL_IRQ_HANDLER(Vector144) {
+OSAL_IRQ_HANDLER(COMP4_5_6_IRQHandler) {
uint32_t pr;
OSAL_IRQ_PROLOGUE();
@@ -261,13 +268,15 @@ OSAL_IRQ_HANDLER(Vector144) {
OSAL_IRQ_EPILOGUE();
}
+#endif
+#if STM32_COMP_USE_COMP7
/**
* @brief COMP7 interrupt handler.
*
* @isr
*/
-OSAL_IRQ_HANDLER(Vector148) {
+OSAL_IRQ_HANDLER(COMP7_IRQHandler) {
uint32_t pr2;
OSAL_IRQ_PROLOGUE();
@@ -275,13 +284,13 @@ OSAL_IRQ_HANDLER(Vector148) {
pr2 = EXTI->PR2;
pr2 = EXTI->IMR & (1U << 1);
EXTI->PR2 = pr2;
-#if STM32_COMP_USE_COMP7
+
if (pr2 & (1U << 1) && COMPD7.config->cb != NULL)
COMPD7.config->cb(&COMPD7);
-#endif
OSAL_IRQ_EPILOGUE();
}
+#endif
/**
* @brief Configures and activates an EXT channel (used by comp)