feat: 完成TCP2UART透传核心集成
集成CH390驱动、LwIP协议栈和FreeRTOS多任务透传框架,确保TCP Server/Client与UART链路按配置稳定联动。
This commit is contained in:
+81
-3
@@ -24,6 +24,11 @@
|
||||
#include "task.h"
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
#include "uart_trans.h"
|
||||
#include "config.h"
|
||||
|
||||
/* External functions from freertos.c */
|
||||
extern void notify_ch390_interrupt_from_isr(void);
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
@@ -295,7 +300,12 @@ void SPI1_IRQHandler(void)
|
||||
void USART1_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN USART1_IRQn 0 */
|
||||
|
||||
/* Handle IDLE interrupt for configuration */
|
||||
if (__HAL_UART_GET_FLAG(&huart1, UART_FLAG_IDLE))
|
||||
{
|
||||
__HAL_UART_CLEAR_IDLEFLAG(&huart1);
|
||||
config_uart_idle_handler();
|
||||
}
|
||||
/* USER CODE END USART1_IRQn 0 */
|
||||
HAL_UART_IRQHandler(&huart1);
|
||||
/* USER CODE BEGIN USART1_IRQn 1 */
|
||||
@@ -309,7 +319,12 @@ void USART1_IRQHandler(void)
|
||||
void USART2_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN USART2_IRQn 0 */
|
||||
|
||||
/* Handle IDLE interrupt for Server transparent transmission */
|
||||
if (__HAL_UART_GET_FLAG(&huart2, UART_FLAG_IDLE))
|
||||
{
|
||||
__HAL_UART_CLEAR_IDLEFLAG(&huart2);
|
||||
uart_trans_idle_handler(UART_CHANNEL_SERVER);
|
||||
}
|
||||
/* USER CODE END USART2_IRQn 0 */
|
||||
HAL_UART_IRQHandler(&huart2);
|
||||
/* USER CODE BEGIN USART2_IRQn 1 */
|
||||
@@ -323,7 +338,12 @@ void USART2_IRQHandler(void)
|
||||
void USART3_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN USART3_IRQn 0 */
|
||||
|
||||
/* Handle IDLE interrupt for Client transparent transmission */
|
||||
if (__HAL_UART_GET_FLAG(&huart3, UART_FLAG_IDLE))
|
||||
{
|
||||
__HAL_UART_CLEAR_IDLEFLAG(&huart3);
|
||||
uart_trans_idle_handler(UART_CHANNEL_CLIENT);
|
||||
}
|
||||
/* USER CODE END USART3_IRQn 0 */
|
||||
HAL_UART_IRQHandler(&huart3);
|
||||
/* USER CODE BEGIN USART3_IRQn 1 */
|
||||
@@ -332,5 +352,63 @@ void USART3_IRQHandler(void)
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
/**
|
||||
* @brief This function handles EXTI0 interrupt (CH390D INT pin).
|
||||
*/
|
||||
void EXTI0_IRQHandler(void)
|
||||
{
|
||||
/* Clear interrupt flag */
|
||||
if (__HAL_GPIO_EXTI_GET_IT(GPIO_PIN_0))
|
||||
{
|
||||
__HAL_GPIO_EXTI_CLEAR_IT(GPIO_PIN_0);
|
||||
|
||||
/* Notify LwIP task */
|
||||
notify_ch390_interrupt_from_isr();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief HAL UART TX Complete callback
|
||||
*/
|
||||
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
|
||||
{
|
||||
if (huart == &huart2)
|
||||
{
|
||||
uart_trans_tx_cplt_handler(UART_CHANNEL_SERVER);
|
||||
}
|
||||
else if (huart == &huart3)
|
||||
{
|
||||
uart_trans_tx_cplt_handler(UART_CHANNEL_CLIENT);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief HAL UART RX Complete callback
|
||||
*/
|
||||
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
|
||||
{
|
||||
if (huart == &huart2)
|
||||
{
|
||||
uart_trans_rx_cplt_handler(UART_CHANNEL_SERVER);
|
||||
}
|
||||
else if (huart == &huart3)
|
||||
{
|
||||
uart_trans_rx_cplt_handler(UART_CHANNEL_CLIENT);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief HAL UART RX Half Complete callback
|
||||
*/
|
||||
void HAL_UART_RxHalfCpltCallback(UART_HandleTypeDef *huart)
|
||||
{
|
||||
if (huart == &huart2)
|
||||
{
|
||||
uart_trans_rx_half_cplt_handler(UART_CHANNEL_SERVER);
|
||||
}
|
||||
else if (huart == &huart3)
|
||||
{
|
||||
uart_trans_rx_half_cplt_handler(UART_CHANNEL_CLIENT);
|
||||
}
|
||||
}
|
||||
/* USER CODE END 1 */
|
||||
|
||||
Reference in New Issue
Block a user