From 842bb64195f958b050867c50db66fc0aa413dafb Mon Sep 17 00:00:00 2001
From: QuakeGod <quakegod@sina.com>
Date: 星期六, 27 七月 2024 10:42:56 +0800
Subject: [PATCH] KBus upgrade

---
 KMini_CCT6/Src/BSP.c |   58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 56 insertions(+), 2 deletions(-)

diff --git a/KMini_CCT6/Src/BSP.c b/KMini_CCT6/Src/BSP.c
index 2740f3c..8edd679 100644
--- a/KMini_CCT6/Src/BSP.c
+++ b/KMini_CCT6/Src/BSP.c
@@ -141,7 +141,7 @@
   RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
   RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
 
-  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
+  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_ACR_LATENCY) != HAL_OK)
   {
     Error_Handler();
   }
@@ -701,6 +701,60 @@
   LL_USART_Enable(USART2);
 }
 
+/* USART3 init function */
+void MX_USART3_UART_Init(void)
+{
+
+
+  LL_USART_InitTypeDef USART_InitStruct = {0};
+  LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
+
+  /* Peripheral clock enable */
+  LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_USART3);
+  LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOB);	
+  
+  /**USART3 GPIO Configuration  
+  PB5   ------> USART3_DE
+  PB3   ------> USART3_TX
+  PB4   ------> USART3_RX 
+  */
+  GPIO_InitStruct.Pin = LL_GPIO_PIN_10|LL_GPIO_PIN_11;
+  GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
+  GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
+  GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
+  GPIO_InitStruct.Pull = LL_GPIO_PULL_UP;
+  GPIO_InitStruct.Alternate = LL_GPIO_AF_4;
+  LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
+
+
+  /* USART3 interrupt Init */
+  NVIC_SetPriority(USART3_6_IRQn, 0);
+  NVIC_EnableIRQ(USART3_6_IRQn);
+
+  USART_InitStruct.BaudRate = 230400;
+  USART_InitStruct.DataWidth = LL_USART_DATAWIDTH_8B;
+  USART_InitStruct.StopBits = LL_USART_STOPBITS_1;
+  USART_InitStruct.Parity = LL_USART_PARITY_NONE;
+  USART_InitStruct.TransferDirection = LL_USART_DIRECTION_TX_RX;
+  USART_InitStruct.HardwareFlowControl = LL_USART_HWCONTROL_NONE;
+  USART_InitStruct.OverSampling = LL_USART_OVERSAMPLING_8;
+  LL_USART_Init(USART3, &USART_InitStruct);
+
+/*
+  LL_USART_EnableDEMode(USART3);
+  LL_USART_SetDESignalPolarity(USART3, LL_USART_DE_POLARITY_LOW);
+//  LL_USART_SetDESignalPolarity(USART3, LL_USART_DE_POLARITY_HIGH);
+  LL_USART_SetDEAssertionTime(USART3, 3);
+  LL_USART_SetDEDeassertionTime(USART3, 3);
+  LL_USART_EnableOneBitSamp(USART3);
+//  LL_USART_EnableAutoBaudRate(USART3);
+//  LL_USART_SetAutoBaudRateMode(USART3, LL_USART_AUTOBAUD_DETECT_ON_FALLINGEDGE);
+*/
+  LL_USART_DisableOverrunDetect(USART3);
+  LL_USART_ConfigAsyncMode(USART3);
+  LL_USART_Enable(USART3);
+}
+
 
 /* USART5 init function */
 void MX_USART5_UART_Init(void)
@@ -732,7 +786,7 @@
   NVIC_SetPriority(USART3_6_IRQn, 0);
   NVIC_EnableIRQ(USART3_6_IRQn);
 
-  USART_InitStruct.BaudRate = 57600;
+  USART_InitStruct.BaudRate = 230400;
   USART_InitStruct.DataWidth = LL_USART_DATAWIDTH_8B;
   USART_InitStruct.StopBits = LL_USART_STOPBITS_1;
   USART_InitStruct.Parity = LL_USART_PARITY_NONE;

--
Gitblit v1.9.1