LPUART1 on STM32H7 Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
geebee
Posts: 33
Joined: Thu Dec 06, 2018 10:22 pm
Has thanked: 4 times
Been thanked: 15 times

LPUART1 on STM32H7  Topic is solved

Postby geebee » Thu Jul 09, 2020 3:33 pm

I attached the necessary changes on the most recent stable 20.3 branch. Also, in the process of adding the ISR init/deinit I found a bug where UART8 is not set up correctly (typo, UART5 is done twice), which is also fixed in these files. This was tested on STM32H743. Diff below.
Thanks!

GB

Code: Select all

diff --git a/os/hal/ports/STM32/STM32H7xx/hal_lld.h b/os/hal/ports/STM32/STM32H7xx/hal_lld.h
index 466c3fdc8..9867fa435 100644
--- a/os/hal/ports/STM32/STM32H7xx/hal_lld.h
+++ b/os/hal/ports/STM32/STM32H7xx/hal_lld.h
@@ -2615,7 +2615,7 @@
 /**
  * @brief   LPUART1 clock.
  */
-#define STM32_LPUART1CLK            STM32_PCLK1
+#define STM32_LPUART1CLK            STM32_PCLK4^M
 
 #elif STM32_LPUART1SEL == STM32_LPUART1SEL_PLL2_Q_CK
 #define STM32_LPUART1CLK            STM32_PLL2_Q_CK
diff --git a/os/hal/ports/STM32/STM32H7xx/stm32_isr.c b/os/hal/ports/STM32/STM32H7xx/stm32_isr.c
index 97cb7606c..8ed4d72fc 100644
--- a/os/hal/ports/STM32/STM32H7xx/stm32_isr.c
+++ b/os/hal/ports/STM32/STM32H7xx/stm32_isr.c
@@ -141,7 +141,8 @@ void irqInit(void) {
   uart5_irq_init();
   usart6_irq_init();
   uart7_irq_init();
-  uart5_irq_init();
+  uart8_irq_init();^M
+  lpuart1_irq_init();^M
 }
 
 /**
@@ -190,7 +191,8 @@ void irqDeinit(void) {
   uart5_irq_deinit();
   usart6_irq_deinit();
   uart7_irq_deinit();
-  uart5_irq_deinit();
+  uart8_irq_deinit();^M
+  lpuart1_irq_deinit();^M
 }
 
 /** @} */
diff --git a/os/hal/ports/STM32/STM32H7xx/stm32_isr.h b/os/hal/ports/STM32/STM32H7xx/stm32_isr.h
index df3c6dc78..e9b776ab2 100644
--- a/os/hal/ports/STM32/STM32H7xx/stm32_isr.h
+++ b/os/hal/ports/STM32/STM32H7xx/stm32_isr.h
@@ -56,6 +56,7 @@
 #define STM32_USART6_SUPPRESS_ISR
 #define STM32_UART7_SUPPRESS_ISR
 #define STM32_UART8_SUPPRESS_ISR
+#define STM32_LPUART1_SUPPRESS_ISR^M
 /** @} */
 
 /**
@@ -289,6 +290,7 @@
 #define STM32_USART6_HANDLER                Vector15C
 #define STM32_UART7_HANDLER                 Vector188
 #define STM32_UART8_HANDLER                 Vector18C
+#define STM32_LPUART1_HANDLER               Vector278^M
 
 #define STM32_USART1_NUMBER                 37
 #define STM32_USART2_NUMBER                 38
@@ -298,6 +300,7 @@
 #define STM32_USART6_NUMBER                 71
 #define STM32_UART7_NUMBER                  82
 #define STM32_UART8_NUMBER                  83
+#define STM32_LPUART1_NUMBER                142^M
 
 /*
  * USB/OTG units.
diff --git a/os/hal/ports/STM32/STM32H7xx/stm32_rcc.h b/os/hal/ports/STM32/STM32H7xx/stm32_rcc.h
index 6d289d13d..3866c5522 100644
--- a/os/hal/ports/STM32/STM32H7xx/stm32_rcc.h
+++ b/os/hal/ports/STM32/STM32H7xx/stm32_rcc.h
@@ -1687,6 +1687,29 @@
  * @api
  */
 #define rccResetUART8() rccResetAPB1L(RCC_APB1LRSTR_UART8RST)
+^M
+/**^M
+ * @brief   Enables the LPUART1 peripheral clock.^M
+ *^M
+ * @param[in] lp        low power enable flag^M
+ *^M
+ * @api^M
+ */^M
+#define rccEnableLPUART1(lp) rccEnableAPB4(RCC_APB4ENR_LPUART1EN, lp)^M
+^M
+/**^M
+ * @brief   Disables the LPUART1 peripheral clock.^M
+ *^M
+ * @api^M
+ */^M
+#define rccDisableLPUART1() rccDisableAPB4(RCC_APB4ENR_LPUART1EN)^M
+^M
+/**^M
+ * @brief   Resets the LPUART1 peripheral.^M
+ *^M
+ * @api^M
+ */^M
+#define rccResetLPUART1() rccResetAPB4(RCC_APB4RSTR_LPUART1RST)^M
 /** @} */
 
 /**
diff --git a/os/hal/ports/STM32/STM32H7xx/stm32_registry.h b/os/hal/ports/STM32/STM32H7xx/stm32_registry.h
index 9d94200e6..ea879ebba 100644
--- a/os/hal/ports/STM32/STM32H7xx/stm32_registry.h
+++ b/os/hal/ports/STM32/STM32H7xx/stm32_registry.h
@@ -258,7 +258,7 @@
 #define STM32_HAS_USART6                    TRUE
 #define STM32_HAS_UART7                     TRUE
 #define STM32_HAS_UART8                     TRUE
-#define STM32_HAS_LPUART1                   FALSE
+#define STM32_HAS_LPUART1                   TRUE^M
 
 /* USB attributes.*/
 #define STM32_OTG_STEPPING                  2

Attachments
stm32h7_lpuart1.zip
(22.24 KiB) Downloaded 149 times

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: LPUART1 on STM32H7

Postby Giovanni » Wed Jul 22, 2020 4:47 pm

Thanks, fixed as bug #1113.

Giovanni

Thomas V
Posts: 1
Joined: Fri Apr 23, 2021 12:22 pm

Re: LPUART1 on STM32H7

Postby Thomas V » Fri Apr 23, 2021 1:16 pm

Great finding and patch. However the bugfix #1113 is not applied on STM32H7xx/stm32_rcc.h on master anymore

The fix was reverted in bugfix #1127:
https://github.com/ChibiOS/ChibiOS/comm ... db58d02e2c

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: LPUART1 on STM32H7

Postby Giovanni » Fri Apr 23, 2021 4:36 pm

Hi,

Very strange, I committed the fix again and reopened the ticket for 20.3.4.

Giovanni


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 3 guests