diff --git a/.vscode/settings.json b/.vscode/settings.json index f3ae402..2f51b86 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -37,6 +37,7 @@ "api.h": "c", "freertos.h": "c", "tcp.h": "c", - "cmsis_os.h": "c" + "cmsis_os.h": "c", + "freertosconfig.h": "c" } } \ No newline at end of file diff --git a/Core/Src/freertos.c b/Core/Src/freertos.c index 615f7ea..3f273af 100644 --- a/Core/Src/freertos.c +++ b/Core/Src/freertos.c @@ -119,11 +119,11 @@ void MX_FREERTOS_Init(void) led_taskHandle = osThreadCreate(osThread(led_task), NULL); /* definition and creation of dac_task */ - osThreadDef(dac_task, start_dac_task, osPriorityLow, 0, 512); + osThreadDef(dac_task, start_dac_task, osPriorityNormal, 0, 512); dac_taskHandle = osThreadCreate(osThread(dac_task), NULL); /* definition and creation of adc_task */ - osThreadDef(adc_task, start_adc_task, osPriorityLow, 0, 128); + osThreadDef(adc_task, start_adc_task, osPriorityBelowNormal, 0, 128); adc_taskHandle = osThreadCreate(osThread(adc_task), NULL); /* USER CODE BEGIN RTOS_THREADS */ @@ -147,6 +147,7 @@ void start_tcp_task(void const *argument) /* Infinite loop */ for (;;) { + osThreadTerminate(NULL); osDelay(1); } /* USER CODE END start_tcp_task */ @@ -166,7 +167,7 @@ void start_led_toggle_task(void const *argument) for (;;) { HAL_GPIO_TogglePin(LED2_G_GPIO_Port, LED2_G_Pin); - osDelay(1000); + vTaskDelay(1000); } /* USER CODE END start_led_toggle_task */ } @@ -187,7 +188,7 @@ void start_dac_task(void const *argument) { dac161s997_output(DAC161S997_1, 12.0f); dac161s997_output(DAC161S997_2, 12.0f); - osDelay(300); + vTaskDelay(300); } /* USER CODE END start_dac_task */ } @@ -207,7 +208,7 @@ void start_adc_task(void const *argument) for (;;) { ad7124_get_analog(STOP_NC_ADC); - osDelay(1000); + vTaskDelay(1000); } /* USER CODE END start_adc_task */ } diff --git a/Core/Src/main.c b/Core/Src/main.c index 8ab21c4..0f07a1d 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -78,9 +78,9 @@ uint8_t tcp_echo_flags_ble2 = 0; /* USER CODE END 0 */ /** - * @brief The application entry point. - * @retval int - */ + * @brief The application entry point. + * @retval int + */ int main(void) { /* USER CODE BEGIN 1 */ @@ -115,10 +115,6 @@ int main(void) MX_USART2_UART_Init(); MX_USART3_UART_Init(); /* USER CODE BEGIN 2 */ - // tcp_echo_init(); // 朝务器初始化 TCP_Client_Init(); // 客户端初始化 - // ad7124_setup(); // AD7124初始�??? - // dac161s997_init(); // DAC161S997初始�??? - // HAL_GPIO_WritePin(DO_EN_GPIO_Port, DO_EN_Pin, GPIO_PIN_SET); // DO输出使能 HAL_UARTEx_ReceiveToIdle_DMA(&huart4, lcd_uart4.rx_data_temp, ARRAY_LEN(lcd_uart4.rx_data_temp)); @@ -141,32 +137,28 @@ int main(void) /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ - // MX_LWIP_Process(); // ad7124_get_analog(STOP_NC_ADC); - - // dac161s997_output(DAC161S997_1, current_buff[0]); - // dac161s997_output(DAC161S997_2, current_buff[1]); } /* USER CODE END 3 */ } /** - * @brief System Clock Configuration - * @retval None - */ + * @brief System Clock Configuration + * @retval None + */ void SystemClock_Config(void) { RCC_OscInitTypeDef RCC_OscInitStruct = {0}; RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; /** Configure the main internal regulator output voltage - */ + */ __HAL_RCC_PWR_CLK_ENABLE(); __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); /** Initializes the RCC Oscillators according to the specified parameters - * in the RCC_OscInitTypeDef structure. - */ + * in the RCC_OscInitTypeDef structure. + */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; RCC_OscInitStruct.HSEState = RCC_HSE_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; @@ -181,8 +173,9 @@ void SystemClock_Config(void) } /** Initializes the CPU, AHB and APB buses clocks - */ - RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2; + */ + RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK + |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; @@ -227,20 +220,19 @@ void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size) /* USER CODE END 4 */ /** - * @brief Period elapsed callback in non blocking mode - * @note This function is called when TIM1 interrupt took place, inside - * HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment - * a global variable "uwTick" used as application time base. - * @param htim : TIM handle - * @retval None - */ + * @brief Period elapsed callback in non blocking mode + * @note This function is called when TIM1 interrupt took place, inside + * HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment + * a global variable "uwTick" used as application time base. + * @param htim : TIM handle + * @retval None + */ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) { /* USER CODE BEGIN Callback 0 */ /* USER CODE END Callback 0 */ - if (htim->Instance == TIM1) - { + if (htim->Instance == TIM1) { HAL_IncTick(); } /* USER CODE BEGIN Callback 1 */ @@ -249,9 +241,9 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) } /** - * @brief This function is executed in case of error occurrence. - * @retval None - */ + * @brief This function is executed in case of error occurrence. + * @retval None + */ void Error_Handler(void) { /* USER CODE BEGIN Error_Handler_Debug */ @@ -263,14 +255,14 @@ void Error_Handler(void) /* USER CODE END Error_Handler_Debug */ } -#ifdef USE_FULL_ASSERT +#ifdef USE_FULL_ASSERT /** - * @brief Reports the name of the source file and the source line number - * where the assert_param error has occurred. - * @param file: pointer to the source file name - * @param line: assert_param error line source number - * @retval None - */ + * @brief Reports the name of the source file and the source line number + * where the assert_param error has occurred. + * @param file: pointer to the source file name + * @param line: assert_param error line source number + * @retval None + */ void assert_failed(uint8_t *file, uint32_t line) { /* USER CODE BEGIN 6 */ diff --git a/MDK-ARM/TEST2.uvoptx b/MDK-ARM/TEST2.uvoptx index 16ea9c5..fc6b511 100644 --- a/MDK-ARM/TEST2.uvoptx +++ b/MDK-ARM/TEST2.uvoptx @@ -215,6 +215,16 @@ 1 ad7124_analog + + 13 + 1 + ad7124_analog[AD7124_CHANNEL_EN_MAX] + + + 14 + 1 + osThread(lwip_task) + diff --git a/TEST2.ioc b/TEST2.ioc index 27e5277..0364d14 100644 --- a/TEST2.ioc +++ b/TEST2.ioc @@ -73,7 +73,7 @@ ETH.IPParameters=MediaInterface ETH.MediaInterface=HAL_ETH_RMII_MODE FREERTOS.FootprintOK=true FREERTOS.IPParameters=Tasks01,configMAX_TASK_NAME_LEN,configENABLE_FPU,configMAX_PRIORITIES,FootprintOK -FREERTOS.Tasks01=lwip_task,2,512,start_tcp_task,Default,NULL,Dynamic,NULL,NULL;led_task,-2,128,start_led_toggle_task,Default,NULL,Dynamic,NULL,NULL;dac_task,-2,512,start_dac_task,Default,NULL,Dynamic,NULL,NULL;adc_task,-2,128,start_adc_task,Default,NULL,Dynamic,NULL,NULL +FREERTOS.Tasks01=lwip_task,2,512,start_tcp_task,Default,NULL,Dynamic,NULL,NULL;led_task,-2,128,start_led_toggle_task,Default,NULL,Dynamic,NULL,NULL;dac_task,0,512,start_dac_task,Default,NULL,Dynamic,NULL,NULL;adc_task,-1,128,start_adc_task,Default,NULL,Dynamic,NULL,NULL FREERTOS.configENABLE_FPU=1 FREERTOS.configMAX_PRIORITIES=32 FREERTOS.configMAX_TASK_NAME_LEN=24