diff --git a/Core/Src/main.c b/Core/Src/main.c index 1e1520c..dd83493 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -38,7 +38,7 @@ /* Private define ------------------------------------------------------------*/ /* USER CODE BEGIN PD */ -#define HOST_USE_DMA 1 +// #define HOST_USE_DMA 1 /* USER CODE END PD */ /* Private macro -------------------------------------------------------------*/ @@ -67,6 +67,7 @@ void SystemClock_Config(void); void transDataToHost(uint8_t *data, uint16_t len) { // 开启uart3 dma + elog_hexdump("transDataToHost", 16, data, len); HAL_GPIO_WritePin(DIR1_GPIO_Port, DIR1_Pin, GPIO_PIN_SET); #ifdef HOST_USE_DMA HAL_UART_Transmit_DMA(&huart1, data, len); @@ -83,13 +84,18 @@ void transDataToMotorValve(uint8_t *data, uint16_t len) HAL_GPIO_WritePin(DIR2_GPIO_Port, DIR2_Pin, GPIO_PIN_SET); // HAL_Delay(100); // HAL_UART_Transmit_DMA(&huart2, data, len); - HAL_UART_Transmit(&huart2, data, len, 100); + HAL_UART_Transmit(&huart2, data, len, 1000); HAL_GPIO_WritePin(DIR2_GPIO_Port, DIR2_Pin, GPIO_PIN_RESET); - // HAL_Delay(100); + // HAL_Delay(10); } uint8_t readDataFromMotorValve(uint8_t *data, uint16_t len, uint32_t timeout) { + // while (huart2.RxState != HAL_UART_STATE_READY) + // { + // HAL_Delay(10); + // } + return HAL_UART_Receive(&huart2, data, len, timeout); } @@ -160,31 +166,33 @@ int main(void) // 执行一次HTTP客户端测试 // http_test_request(); HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_RESET); + HAL_Delay(5000); printf("Init success!\r\n"); initCTLSystem(); // runPumpDemo(); - runValveDemo(); + // runValveDemo(); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ + uint32_t count = HAL_GetTick(); while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ - http_server_task(); + // http_server_task(); if (hostRxEnd == 1) { - printf("hostRxLen: %d\r\n", hostRxLen); + log_d("hostRxLen: %d", hostRxLen); + elog_hexdump("hostRxBuf", 16, hostRxBuf, hostRxLen); ProcessHostCommand(hostRxBuf, hostRxLen); hostRxEnd = 0; HAL_UART_Receive_DMA(&huart1, hostRxBuf, HOST_BUFFER_SIZE); } - static uint32_t count = 0; - if(count++ > 5000*2) { - count = 0; + if(HAL_GetTick() - count > 1000) { + count = HAL_GetTick(); updateSystemStatus(); // runPumpDemo(); // runValveDemo(); diff --git a/Core/motor b/Core/motor index 6dcc87a..7e47936 160000 --- a/Core/motor +++ b/Core/motor @@ -1 +1 @@ -Subproject commit 6dcc87aa594ab9151e33bf1a6c20ba27e5fdf909 +Subproject commit 7e47936f435ead61dad799f5729bfbfec01583b0