diff --git a/Core/Inc/main.h b/Core/Inc/main.h
index f143d8f..6e65f84 100644
--- a/Core/Inc/main.h
+++ b/Core/Inc/main.h
@@ -23,7 +23,8 @@
#define __MAIN_H
#ifdef __cplusplus
-extern "C" {
+extern "C"
+{
#endif
/* Includes ------------------------------------------------------------------*/
@@ -40,17 +41,17 @@ extern "C" {
/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */
-extern uint8_t tcp_echo_flags_hart1; // 标志位,连接成功?1
-extern uint8_t tcp_echo_flags_hart2; // 标志位,连接成功?1
+extern uint8_t tcp_echo_flags_hart1;
+extern uint8_t tcp_echo_flags_hart2;
extern uint8_t tcp_echo_flags_ble1;
extern uint8_t tcp_echo_flags_ble2;
#define ARRAY_LEN(arr) (sizeof(arr)) / (sizeof(arr[0]))
typedef struct
{
- uint16_t rx_num; // 接收到数据个?
- uint8_t rx_data[512]; // 接收到数据区
- uint8_t rx_data_temp[512]; // 接收到数据缓冲区
- uint8_t tx_data[512]; // 发?数据区
+ uint16_t rx_num;
+ uint8_t rx_data[512];
+ uint8_t rx_data_temp[512];
+ uint8_t tx_data[512];
} uart_t;
extern uart_t lcd_uart4;
@@ -70,20 +71,20 @@ extern uart_t hart2_uart2;
#define LOCAL_PORT 5001
-/* USER CODE END ET */
+ /* USER CODE END ET */
-/* Exported constants --------------------------------------------------------*/
-/* USER CODE BEGIN EC */
+ /* Exported constants --------------------------------------------------------*/
+ /* USER CODE BEGIN EC */
-/* USER CODE END EC */
+ /* USER CODE END EC */
-/* Exported macro ------------------------------------------------------------*/
-/* USER CODE BEGIN EM */
+ /* Exported macro ------------------------------------------------------------*/
+ /* USER CODE BEGIN EM */
-/* USER CODE END EM */
+ /* USER CODE END EM */
-/* Exported functions prototypes ---------------------------------------------*/
-void Error_Handler(void);
+ /* Exported functions prototypes ---------------------------------------------*/
+ void Error_Handler(void);
/* USER CODE BEGIN EFP */
@@ -170,7 +171,7 @@ void Error_Handler(void);
/* USER CODE BEGIN Private defines */
#define TRUE 0
#define FAIL -1
-/* USER CODE END Private defines */
+ /* USER CODE END Private defines */
#ifdef __cplusplus
}
diff --git a/Core/Src/freertos.c b/Core/Src/freertos.c
index 2d613b5..3dd719b 100644
--- a/Core/Src/freertos.c
+++ b/Core/Src/freertos.c
@@ -27,6 +27,7 @@
/* USER CODE BEGIN Includes */
#include "dac161s997.h"
#include "ad7124.h"
+#include "usart.h"
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
@@ -36,7 +37,7 @@
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
-
+// extern UART_HandleTypeDef huart5;
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
@@ -147,8 +148,20 @@ void start_tcp_task(void const *argument)
/* Infinite loop */
for (;;)
{
- osThreadTerminate(NULL);
- osDelay(1);
+ // osThreadTerminate(NULL);
+ // if (tcp_send_flags_hart1 == 1)
+ // {
+ // user_send_data_hart1(hart1_uart5.rx_data, hart1_uart5.rx_num);
+ // tcp_send_flags_hart1 = 0;
+ // }
+ // if (tcp_send_flags_hart2 == 1)
+ // {
+ // user_send_data_hart2(hart2_uart2.rx_data, hart2_uart2.rx_num);
+ // tcp_send_flags_hart2 = 0;
+ // }
+
+ vTaskDelay(1);
+ // osDelay(1);
}
/* USER CODE END start_tcp_task */
}
@@ -167,7 +180,7 @@ void start_led_toggle_task(void const *argument)
for (;;)
{
HAL_GPIO_TogglePin(LED2_G_GPIO_Port, LED2_G_Pin);
- vTaskDelay(1000);
+ vTaskDelay(500);
}
/* USER CODE END start_led_toggle_task */
}
@@ -188,7 +201,7 @@ void start_dac_task(void const *argument)
{
dac161s997_output(DAC161S997_1, 12.0f);
dac161s997_output(DAC161S997_2, 12.0f);
- vTaskDelay(200);
+ vTaskDelay(100);
}
/* USER CODE END start_dac_task */
}
@@ -208,6 +221,14 @@ void start_adc_task(void const *argument)
for (;;)
{
ad7124_get_analog(STOP_NC_ADC);
+ if (huart5.RxState == HAL_UART_STATE_READY)
+ {
+ HAL_UARTEx_ReceiveToIdle_DMA(&huart5, hart1_uart5.rx_data_temp, ARRAY_LEN(hart1_uart5.rx_data_temp));
+ }
+ if (huart2.RxState == HAL_UART_STATE_READY)
+ {
+ HAL_UARTEx_ReceiveToIdle_DMA(&huart2, hart2_uart2.rx_data_temp, ARRAY_LEN(hart2_uart2.rx_data_temp));
+ }
vTaskDelay(1000);
}
/* USER CODE END start_adc_task */
diff --git a/Core/Src/main.c b/Core/Src/main.c
index 006ba4e..5395b65 100644
--- a/Core/Src/main.c
+++ b/Core/Src/main.c
@@ -71,10 +71,12 @@ uart_t ble2_uart3 = {0};
uart_t hart2_uart2 = {0};
uart_t hart1_uart5 = {0};
float current_buff[2] = {12.0f, 12.0f};
+
uint8_t tcp_echo_flags_hart1 = 0;
uint8_t tcp_echo_flags_hart2 = 0;
uint8_t tcp_echo_flags_ble1 = 0;
uint8_t tcp_echo_flags_ble2 = 0;
+
/* USER CODE END 0 */
/**
@@ -223,6 +225,7 @@ void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size)
memcpy(hart1_uart5.rx_data, hart1_uart5.rx_data_temp, Size);
if (tcp_echo_flags_hart1 == 1)
{
+ // tcp_send_flags_hart1 = 1;
user_send_data_hart1(hart1_uart5.rx_data, Size);
}
HAL_UARTEx_ReceiveToIdle_DMA(&huart5, hart1_uart5.rx_data_temp, ARRAY_LEN(hart1_uart5.rx_data_temp));
@@ -235,6 +238,7 @@ void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size)
memcpy(hart2_uart2.rx_data, hart2_uart2.rx_data_temp, Size);
if (tcp_echo_flags_hart2 == 1)
{
+ // tcp_send_flags_hart2 = 1;
user_send_data_hart2(hart2_uart2.rx_data, Size);
}
HAL_UARTEx_ReceiveToIdle_DMA(&huart2, hart2_uart2.rx_data_temp, ARRAY_LEN(hart2_uart2.rx_data_temp));
@@ -283,10 +287,10 @@ void Error_Handler(void)
{
/* USER CODE BEGIN Error_Handler_Debug */
/* User can add his own implementation to report the HAL error return state */
- __disable_irq();
- while (1)
- {
- }
+ // __disable_irq();
+ // while (1)
+ // {
+ // }
/* USER CODE END Error_Handler_Debug */
}
diff --git a/Core/Src/usart.c b/Core/Src/usart.c
index 30d4c74..81529ee 100644
--- a/Core/Src/usart.c
+++ b/Core/Src/usart.c
@@ -21,7 +21,6 @@
#include "usart.h"
/* USER CODE BEGIN 0 */
-#include "ht1200m.h"
/* USER CODE END 0 */
UART_HandleTypeDef huart4;
diff --git a/MDK-ARM/TEST2.uvoptx b/MDK-ARM/TEST2.uvoptx
index fc6b511..612233e 100644
--- a/MDK-ARM/TEST2.uvoptx
+++ b/MDK-ARM/TEST2.uvoptx
@@ -225,6 +225,11 @@
1
osThread(lwip_task)
+
+ 15
+ 1
+ hart1_uart5
+
diff --git a/User/application/src/tcpserverc.c b/User/application/src/tcpserverc.c
index c2822e5..0710ea4 100644
--- a/User/application/src/tcpserverc.c
+++ b/User/application/src/tcpserverc.c
@@ -19,6 +19,7 @@ extern uint8_t tcp_echo_flags_hart1;
extern uint8_t tcp_echo_flags_hart2;
extern uint8_t tcp_echo_flags_ble1;
extern uint8_t tcp_echo_flags_ble2;
+
/*接收回调函数*/
static err_t tcpecho_recv_hart1(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err)
{ // 对应接收数据连接的控制块 接收到的数据