From fbe63f0ef8c97df4d0b9ef635e48ca33e1ecdc70 Mon Sep 17 00:00:00 2001 From: wangxujie Date: Wed, 25 Jun 2025 18:22:56 +0800 Subject: [PATCH] 111 --- Core/Inc/main.h | 29 +++-- Core/Src/freertos.c | 47 ++++--- Core/Src/main.c | 60 ++++----- MDK-ARM/semi-finished_product_testing.uvoptx | 48 ++++---- MDK-ARM/semi-finished_product_testing.uvprojx | 115 +++++++++--------- semi-finished_product_testing.ioc | 2 +- 6 files changed, 145 insertions(+), 156 deletions(-) diff --git a/Core/Inc/main.h b/Core/Inc/main.h index d1866fb..3c21ae4 100644 --- a/Core/Inc/main.h +++ b/Core/Inc/main.h @@ -23,8 +23,7 @@ #define __MAIN_H #ifdef __cplusplus -extern "C" -{ +extern "C" { #endif /* Includes ------------------------------------------------------------------*/ @@ -37,10 +36,10 @@ extern "C" #include "tcpserverc.h" #include "leds.h" #include - /* USER CODE END Includes */ +/* USER CODE END Includes */ - /* Exported types ------------------------------------------------------------*/ - /* USER CODE BEGIN ET */ +/* Exported types ------------------------------------------------------------*/ +/* USER CODE BEGIN ET */ extern uint8_t tcp_echo_flags_hart1; extern uint8_t tcp_echo_flags_hart2; extern uint8_t tcp_echo_flags_ble1; @@ -79,20 +78,20 @@ extern "C" #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 */ #define ENCODE_TIM8 1 @@ -196,7 +195,7 @@ extern "C" /* 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 41390f3..6911022 100644 --- a/Core/Src/freertos.c +++ b/Core/Src/freertos.c @@ -64,7 +64,6 @@ osThreadId dac_taskHandle; osThreadId adc_taskHandle; osThreadId gpio_di_do_taskHandle; osThreadId ec11_taskHandle; -osThreadId uart_forwardingHandle; /* Private function prototypes -----------------------------------------------*/ /* USER CODE BEGIN FunctionPrototypes */ @@ -81,18 +80,18 @@ extern struct tcp_pcb *server_pcb_control; extern void tcp_abort(struct tcp_pcb *pcb); /* USER CODE END FunctionPrototypes */ -void start_tcp_task(void const *argument); -void start_led_toggle_task(void const *argument); -void start_dac_task(void const *argument); -void start_adc_task(void const *argument); -void start_gpio_di_do_task(void const *argument); -void start_ec11_task(void const *argument); +void start_tcp_task(void const * argument); +void start_led_toggle_task(void const * argument); +void start_dac_task(void const * argument); +void start_adc_task(void const * argument); +void start_gpio_di_do_task(void const * argument); +void start_ec11_task(void const * argument); extern void MX_LWIP_Init(void); void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */ /* GetIdleTaskMemory prototype (linked to static allocation support) */ -void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize); +void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ); /* USER CODE BEGIN GET_IDLE_TASK_MEMORY */ static StaticTask_t xIdleTaskTCBBuffer; @@ -108,12 +107,11 @@ void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer, StackTyp /* USER CODE END GET_IDLE_TASK_MEMORY */ /** - * @brief FreeRTOS initialization - * @param None - * @retval None - */ -void MX_FREERTOS_Init(void) -{ + * @brief FreeRTOS initialization + * @param None + * @retval None + */ +void MX_FREERTOS_Init(void) { /* USER CODE BEGIN Init */ /* USER CODE END Init */ @@ -159,13 +157,10 @@ void MX_FREERTOS_Init(void) osThreadDef(ec11_task, start_ec11_task, osPriorityNormal, 0, 512); ec11_taskHandle = osThreadCreate(osThread(ec11_task), NULL); - /* definition and creation of uart_forwarding */ - osThreadDef(uart_forwarding, start_uart_forwarding, osPriorityRealtime, 0, 512); - uart_forwardingHandle = osThreadCreate(osThread(uart_forwarding), NULL); - /* USER CODE BEGIN RTOS_THREADS */ /* add threads, ... */ /* USER CODE END RTOS_THREADS */ + } /* USER CODE BEGIN Header_start_tcp_task */ @@ -175,7 +170,7 @@ void MX_FREERTOS_Init(void) * @retval None */ /* USER CODE END Header_start_tcp_task */ -void start_tcp_task(void const *argument) +void start_tcp_task(void const * argument) { /* init code for LWIP */ MX_LWIP_Init(); @@ -248,7 +243,7 @@ void start_tcp_task(void const *argument) * @retval None */ /* USER CODE END Header_start_led_toggle_task */ -void start_led_toggle_task(void const *argument) +void start_led_toggle_task(void const * argument) { /* USER CODE BEGIN start_led_toggle_task */ /* Infinite loop */ @@ -269,14 +264,14 @@ void start_led_toggle_task(void const *argument) * @retval None */ /* USER CODE END Header_start_dac_task */ -void start_dac_task(void const *argument) +void start_dac_task(void const * argument) { /* USER CODE BEGIN start_dac_task */ dac161s997_init(); /* Infinite loop */ for (;;) { - osThreadSuspend(adc_taskHandle); // 暂停ADC任务,防止DAC采集时产生干�????????,因为ADC和DAC采用的是同一路SPI,但是时序不�???????? + osThreadSuspend(adc_taskHandle); // 暂停ADC任务,防止DAC采集时产生干?????????,因为ADC和DAC采用的是同一路SPI,但是时序不????????? dac161s997_output(DAC161S997_1, current_buff[0]); dac161s997_output(DAC161S997_2, current_buff[1]); osThreadResume(adc_taskHandle); @@ -292,14 +287,14 @@ void start_dac_task(void const *argument) * @retval None */ /* USER CODE END Header_start_adc_task */ -void start_adc_task(void const *argument) +void start_adc_task(void const * argument) { /* USER CODE BEGIN start_adc_task */ ad7124_setup(); /* Infinite loop */ for (;;) { - osThreadSuspend(dac_taskHandle); // 暂停DAC任务,防止ADC采集时产生干�????????,因为ADC和DAC采用的是同一路SPI,但是时序不�???????? + osThreadSuspend(dac_taskHandle); // 暂停DAC任务,防止ADC采集时产生干?????????,因为ADC和DAC采用的是同一路SPI,但是时序不????????? uint8_t ch = 0; for (ch = STOP_NC_ADC; ch < AD7124_CHANNEL_EN_MAX; ch++) { @@ -319,7 +314,7 @@ void start_adc_task(void const *argument) * @retval None */ /* USER CODE END Header_start_gpio_di_do_task */ -void start_gpio_di_do_task(void const *argument) +void start_gpio_di_do_task(void const * argument) { /* USER CODE BEGIN start_gpio_di_do_task */ /* Infinite loop */ @@ -338,7 +333,7 @@ void start_gpio_di_do_task(void const *argument) * @retval None */ /* USER CODE END Header_start_ec11_task */ -void start_ec11_task(void const *argument) +void start_ec11_task(void const * argument) { /* USER CODE BEGIN start_ec11_task */ /* Infinite loop */ diff --git a/Core/Src/main.c b/Core/Src/main.c index 0b44638..ef4a9ca 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -97,9 +97,9 @@ extern ip4_addr_t ipaddr; /* 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 */ @@ -175,22 +175,22 @@ int main(void) } /** - * @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; @@ -205,8 +205,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; @@ -363,20 +364,19 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) /* USER CODE END 4 */ /** - * @brief Period elapsed callback in non blocking mode - * @note This function is called when TIM4 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 TIM4 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 == TIM4) - { + if (htim->Instance == TIM4) { HAL_IncTick(); } /* USER CODE BEGIN Callback 1 */ @@ -385,9 +385,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 */ @@ -399,14 +399,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/semi-finished_product_testing.uvoptx b/MDK-ARM/semi-finished_product_testing.uvoptx index af2b709..1057547 100644 --- a/MDK-ARM/semi-finished_product_testing.uvoptx +++ b/MDK-ARM/semi-finished_product_testing.uvoptx @@ -1,4 +1,4 @@ - + 1.0 @@ -45,7 +45,7 @@ 79 66 8 - + 1 @@ -104,16 +104,16 @@ 0 0 6 - - - - - - - - - - + + + + + + + + + + STLink\ST-LINKIII-KEIL_SWO.dll @@ -130,7 +130,7 @@ 0 ARMDBGFLAGS - + 0 @@ -162,7 +162,7 @@ 0 1 ../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c - + \\semi_finished_product_testing\../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c\2413 @@ -280,19 +280,19 @@ 0 0 - - + + 0 0 0 - - - - - - - - + + + + + + + + 0 0 diff --git a/MDK-ARM/semi-finished_product_testing.uvprojx b/MDK-ARM/semi-finished_product_testing.uvprojx index cb9f4e2..c9f1ec7 100644 --- a/MDK-ARM/semi-finished_product_testing.uvprojx +++ b/MDK-ARM/semi-finished_product_testing.uvprojx @@ -1,10 +1,7 @@ - - - + + 2.1 -
### uVision Project, (C) Keil Software
- semi-finished_product_testing @@ -19,28 +16,28 @@ Keil.STM32F4xx_DFP.2.12.0 http://www.keil.com/pack IRAM(0x20000000-0x2001BFFF) IRAM2(0x2001C000-0x2001FFFF) IROM(0x8000000-0x80FFFFF) CLOCK(25000000) FPU2 CPUTYPE("Cortex-M4") TZ - - - + + + 0 - - - - - - - - - - + + + + + + + + + + $$Device:STM32F407VGTx$CMSIS\SVD\STM32F40x.svd 0 0 - - - - - + + + + + 0 0 @@ -55,15 +52,15 @@ 1 1 0 - + 1 0 0 0 0 - - + + 0 0 0 @@ -72,8 +69,8 @@ 0 0 - - + + 0 0 0 @@ -82,15 +79,15 @@ 0 0 - - + + 0 0 0 0 1 - + 0 @@ -104,8 +101,8 @@ 0 0 3 - - + + 0 @@ -139,10 +136,10 @@ 1 BIN\UL2V8M.DLL "" () - - - - + + + + 0 @@ -175,7 +172,7 @@ 0 0 "Cortex-M4" - + 0 0 0 @@ -309,7 +306,7 @@ 0x4000 - + 1 @@ -336,9 +333,9 @@ 0 0 - + USE_HAL_DRIVER,STM32F407xx - + ../Core/Inc;../LWIP/App;../LWIP/Target;../Middlewares/Third_Party/LwIP/src/include;../Middlewares/Third_Party/LwIP/system;../Drivers/STM32F4xx_HAL_Driver/Inc;../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy;../Middlewares/Third_Party/FreeRTOS/Source/include;../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS;../Middlewares/Third_Party/FreeRTOS/Source/portable/RVDS/ARM_CM4F;../Drivers/BSP/Components/lan8742;../Middlewares/Third_Party/LwIP/src/include/netif/ppp;../Drivers/CMSIS/Device/ST/STM32F4xx/Include;../Middlewares/Third_Party/LwIP/src/include/lwip;../Middlewares/Third_Party/LwIP/src/include/lwip/apps;../Middlewares/Third_Party/LwIP/src/include/lwip/priv;../Middlewares/Third_Party/LwIP/src/include/lwip/prot;../Middlewares/Third_Party/LwIP/src/include/netif;../Middlewares/Third_Party/LwIP/src/include/compat/posix;../Middlewares/Third_Party/LwIP/src/include/compat/posix/arpa;../Middlewares/Third_Party/LwIP/src/include/compat/posix/net;../Middlewares/Third_Party/LwIP/src/include/compat/posix/sys;../Middlewares/Third_Party/LwIP/src/include/compat/stdc;../Middlewares/Third_Party/LwIP/system/arch;../Drivers/CMSIS/Include;../User/application/inc;../User/board/inc;../User/driver;../User/system @@ -354,9 +351,9 @@ 0 1 - - - + + + ../Core/Inc @@ -367,15 +364,15 @@ 0 1 0 - - - - - - - - - + + + + + + + + + @@ -1141,20 +1138,18 @@ - - + - + - + - + - @@ -1163,5 +1158,5 @@ -
+ diff --git a/semi-finished_product_testing.ioc b/semi-finished_product_testing.ioc index d61edac..38066d7 100644 --- a/semi-finished_product_testing.ioc +++ b/semi-finished_product_testing.ioc @@ -117,7 +117,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,0,512,start_dac_task,Default,NULL,Dynamic,NULL,NULL;adc_task,-1,128,start_adc_task,Default,NULL,Dynamic,NULL,NULL;gpio_di_do_task,0,128,start_gpio_di_do_task,Default,NULL,Dynamic,NULL,NULL;ec11_task,0,512,start_ec11_task,Default,NULL,Dynamic,NULL,NULL;uart_forwarding,3,512,start_uart_forwarding,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;gpio_di_do_task,0,128,start_gpio_di_do_task,Default,NULL,Dynamic,NULL,NULL;ec11_task,0,512,start_ec11_task,Default,NULL,Dynamic,NULL,NULL FREERTOS.configENABLE_FPU=1 FREERTOS.configMAX_PRIORITIES=32 FREERTOS.configMAX_TASK_NAME_LEN=24