aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBoris-Chengbiao Zhou <bobo1239@web.de>2023-06-17 16:43:34 +0200
committerKevinOConnor <kevin@koconnor.net>2023-06-20 12:05:32 -0400
commit623ebf2fb163e01f84a9b6c533a13c91b7c700a0 (patch)
tree00211a0b656b2eba9d2821b7a37546948eeb2d76 /src
parent2ae3dd2f78ddcae98df445ace4f24c9931c35564 (diff)
downloadkutter-623ebf2fb163e01f84a9b6c533a13c91b7c700a0.tar.gz
kutter-623ebf2fb163e01f84a9b6c533a13c91b7c700a0.tar.xz
kutter-623ebf2fb163e01f84a9b6c533a13c91b7c700a0.zip
hc32f460: Use correct USART for PH2/PB10 pins
This fixes serial communication when selecting the PH2/PB10 pins. The chip datasheet (not reference manual) assigns pins to one of two communication function groups (`Func_Grp1/2`). Pins in group 1 have access to USART1/2 while group 2 has access to USART3/4. PH2/PB10 belong to group 2 so we now correctly use USART3 for them. Signed-off-by: Boris-Chengbiao Zhou <bobo1239@web.de>
Diffstat (limited to 'src')
-rw-r--r--src/hc32f460/serial.c37
1 files changed, 28 insertions, 9 deletions
diff --git a/src/hc32f460/serial.c b/src/hc32f460/serial.c
index 94d581d9..7cf4b6dd 100644
--- a/src/hc32f460/serial.c
+++ b/src/hc32f460/serial.c
@@ -28,6 +28,7 @@
#define USART_RX_PIN (Pin15)
#define USART_TX_PORT (PortA)
#define USART_TX_PIN (Pin09)
+ #define USART_NUM 1
#elif CONFIG_HC32F460_SERIAL_PC0_PC1
DECL_CONSTANT_STR("RESERVE_PINS_serial", "PC0,PC1");
@@ -35,6 +36,7 @@
#define USART_RX_PIN (Pin00)
#define USART_TX_PORT (PortC)
#define USART_TX_PIN (Pin01)
+ #define USART_NUM 1
#elif CONFIG_HC32F460_SERIAL_PA3_PA2
DECL_CONSTANT_STR("RESERVE_PINS_serial", "PA3,PA2");
@@ -42,6 +44,7 @@
#define USART_RX_PIN (Pin03)
#define USART_TX_PORT (PortA)
#define USART_TX_PIN (Pin02)
+ #define USART_NUM 1
#elif CONFIG_HC32F460_SERIAL_PH2_PB10
DECL_CONSTANT_STR("RESERVE_PINS_serial", "PH2,PB10");
@@ -49,6 +52,7 @@
#define USART_RX_PIN (Pin02)
#define USART_TX_PORT (PortB)
#define USART_TX_PIN (Pin10)
+ #define USART_NUM 3
#elif CONFIG_HC32F460_SERIAL_PA7_PA8
DECL_CONSTANT_STR("RESERVE_PINS_serial", "PA7,PA8");
@@ -56,6 +60,7 @@
#define USART_RX_PIN (Pin07)
#define USART_TX_PORT (PortA)
#define USART_TX_PIN (Pin08)
+ #define USART_NUM 1
#elif CONFIG_HC32F460_SERIAL_PA13_PA14
DECL_CONSTANT_STR("RESERVE_PINS_serial", "PA13,PA14");
@@ -63,20 +68,34 @@
#define USART_RX_PIN (Pin13)
#define USART_TX_PORT (PortA)
#define USART_TX_PIN (Pin14)
+ #define USART_NUM 1
+#endif
+
+#if (USART_NUM == 1)
+ // use USART 1 for serial connection
+ #define USARTx M4_USART1
+
+ #define USART_RX_FUNC Func_Usart1_Rx
+ #define USART_TX_FUNC Func_Usart1_Tx
+ #define USART_RI_NUM INT_USART1_RI
+ #define USART_TI_NUM INT_USART1_TI
+ #define USART_EI_NUM INT_USART1_EI
+ #define USART_TCI_NUM INT_USART1_TCI
+#elif (USART_NUM == 3)
+ // use USART 3 for serial connection
+ #define USARTx M4_USART3
+
+ #define USART_RX_FUNC Func_Usart3_Rx
+ #define USART_TX_FUNC Func_Usart3_Tx
+ #define USART_RI_NUM INT_USART3_RI
+ #define USART_TI_NUM INT_USART3_TI
+ #define USART_EI_NUM INT_USART3_EI
+ #define USART_TCI_NUM INT_USART3_TCI
#endif
-// use USART 1 for serial connection
-#define USARTx M4_USART1
#define USART_ENABLE (PWC_FCG1_PERIPH_USART1 | PWC_FCG1_PERIPH_USART2 | \
PWC_FCG1_PERIPH_USART3 | PWC_FCG1_PERIPH_USART4)
-#define USART_RX_FUNC Func_Usart1_Rx
-#define USART_TX_FUNC Func_Usart1_Tx
-#define USART_RI_NUM INT_USART1_RI
-#define USART_TI_NUM INT_USART1_TI
-#define USART_EI_NUM INT_USART1_EI
-#define USART_TCI_NUM INT_USART1_TCI
-
void
serialError(void)