This commit is contained in:
王绪洁 2025-03-26 16:42:51 +08:00
parent 8241229bb8
commit f8afd039dc
5 changed files with 5143 additions and 5048 deletions

View File

@ -192,7 +192,7 @@ void start_led_toggle_task(void const *argument)
uart_lcd_ecll_control_current_out(); uart_lcd_ecll_control_current_out();
vTaskDelay(500); vTaskDelay(500);
} }
/* USER CODE END start_led_toggle_task */ /* USER CODE END start_led_toggle_task */
} }

View File

@ -87,9 +87,9 @@ extern ip4_addr_t ipaddr;
/* USER CODE END 0 */ /* USER CODE END 0 */
/** /**
* @brief The application entry point. * @brief The application entry point.
* @retval int * @retval int
*/ */
int main(void) int main(void)
{ {
/* USER CODE BEGIN 1 */ /* USER CODE BEGIN 1 */
@ -127,7 +127,7 @@ int main(void)
MX_TIM8_Init(); MX_TIM8_Init();
/* USER CODE BEGIN 2 */ /* USER CODE BEGIN 2 */
/*串å<EFBFBD>£DMA接收中æ­*/ /*DMA INIT*/
// start // start
HAL_UARTEx_ReceiveToIdle_DMA(&huart4, lcd_uart4.rx_data_temp, ARRAY_LEN(lcd_uart4.rx_data_temp)); HAL_UARTEx_ReceiveToIdle_DMA(&huart4, lcd_uart4.rx_data_temp, ARRAY_LEN(lcd_uart4.rx_data_temp));
#if (BLE2_USART6 == 1) #if (BLE2_USART6 == 1)
@ -138,11 +138,12 @@ int main(void)
HAL_UARTEx_ReceiveToIdle_DMA(&huart2, hart2_uart2.rx_data_temp, ARRAY_LEN(hart2_uart2.rx_data_temp)); HAL_UARTEx_ReceiveToIdle_DMA(&huart2, hart2_uart2.rx_data_temp, ARRAY_LEN(hart2_uart2.rx_data_temp));
HAL_UARTEx_ReceiveToIdle_DMA(&huart1, usb_uart1.rx_data_temp, ARRAY_LEN(usb_uart1.rx_data_temp)); HAL_UARTEx_ReceiveToIdle_DMA(&huart1, usb_uart1.rx_data_temp, ARRAY_LEN(usb_uart1.rx_data_temp));
// end // end
hart_ht1200m_reset(); // HART模å<C2A1>—å¤<C3A5>ä½<C3A4> hart_ht1200m_reset(); // HT1200M reset
HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_1); // HARTæ—¶éŸä¿¡å<C2A1>· HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_1); // HART CLK
HAL_TIM_Encoder_Start(&htim1, TIM_CHANNEL_ALL); // æ—转ç¼ç <C3A7>器信å<C2A1>? HAL_TIM_Encoder_Start(&htim1, TIM_CHANNEL_ALL); // rotary encoder
HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_3); // buzzer
#if (ENCODE_TIM8 == 1) #if (ENCODE_TIM8 == 1)
HAL_TIM_Encoder_Start(&htim8, TIM_CHANNEL_ALL); // ç¼ç <C3A7>å™? HAL_TIM_Encoder_Start(&htim8, TIM_CHANNEL_ALL);
#endif #endif
/* USER CODE END 2 */ /* USER CODE END 2 */
@ -164,22 +165,22 @@ int main(void)
} }
/** /**
* @brief System Clock Configuration * @brief System Clock Configuration
* @retval None * @retval None
*/ */
void SystemClock_Config(void) void SystemClock_Config(void)
{ {
RCC_OscInitTypeDef RCC_OscInitStruct = {0}; RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
/** Configure the main internal regulator output voltage /** Configure the main internal regulator output voltage
*/ */
__HAL_RCC_PWR_CLK_ENABLE(); __HAL_RCC_PWR_CLK_ENABLE();
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
/** Initializes the RCC Oscillators according to the specified parameters /** 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.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON; RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
@ -194,9 +195,8 @@ void SystemClock_Config(void)
} }
/** Initializes the CPU, AHB and APB buses clocks /** Initializes the CPU, AHB and APB buses clocks
*/ */
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
@ -328,19 +328,20 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
/* USER CODE END 4 */ /* USER CODE END 4 */
/** /**
* @brief Period elapsed callback in non blocking mode * @brief Period elapsed callback in non blocking mode
* @note This function is called when TIM4 interrupt took place, inside * @note This function is called when TIM4 interrupt took place, inside
* HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment * HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment
* a global variable "uwTick" used as application time base. * a global variable "uwTick" used as application time base.
* @param htim : TIM handle * @param htim : TIM handle
* @retval None * @retval None
*/ */
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{ {
/* USER CODE BEGIN Callback 0 */ /* USER CODE BEGIN Callback 0 */
/* USER CODE END Callback 0 */ /* USER CODE END Callback 0 */
if (htim->Instance == TIM4) { if (htim->Instance == TIM4)
{
HAL_IncTick(); HAL_IncTick();
} }
/* USER CODE BEGIN Callback 1 */ /* USER CODE BEGIN Callback 1 */
@ -349,9 +350,9 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
} }
/** /**
* @brief This function is executed in case of error occurrence. * @brief This function is executed in case of error occurrence.
* @retval None * @retval None
*/ */
void Error_Handler(void) void Error_Handler(void)
{ {
/* USER CODE BEGIN Error_Handler_Debug */ /* USER CODE BEGIN Error_Handler_Debug */
@ -363,14 +364,14 @@ void Error_Handler(void)
/* USER CODE END Error_Handler_Debug */ /* 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 * @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred. * where the assert_param error has occurred.
* @param file: pointer to the source file name * @param file: pointer to the source file name
* @param line: assert_param error line source number * @param line: assert_param error line source number
* @retval None * @retval None
*/ */
void assert_failed(uint8_t *file, uint32_t line) void assert_failed(uint8_t *file, uint32_t line)
{ {
/* USER CODE BEGIN 6 */ /* USER CODE BEGIN 6 */

View File

@ -148,7 +148,72 @@
<Name>-U090F00028316303030303032 -O2254 -SF1000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8004 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC800 -FN1 -FF0STM32F4xx_1024.FLM -FS08000000 -FL0100000 -FP0($$Device:STM32F407VGTx$CMSIS\Flash\STM32F4xx_1024.FLM)</Name> <Name>-U090F00028316303030303032 -O2254 -SF1000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8004 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC800 -FN1 -FF0STM32F4xx_1024.FLM -FS08000000 -FL0100000 -FP0($$Device:STM32F407VGTx$CMSIS\Flash\STM32F4xx_1024.FLM)</Name>
</SetRegEntry> </SetRegEntry>
</TargetDriverDllRegistry> </TargetDriverDllRegistry>
<Breakpoint/> <Breakpoint>
<Bp>
<Number>0</Number>
<Type>0</Type>
<LineNumber>250</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134301072</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>..\User\application\src\tcpserverc.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\semi_finished_product_testing\../User/application/src/tcpserverc.c\250</Expression>
</Bp>
<Bp>
<Number>1</Number>
<Type>0</Type>
<LineNumber>243</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134301048</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>..\User\application\src\tcpserverc.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\semi_finished_product_testing\../User/application/src/tcpserverc.c\243</Expression>
</Bp>
<Bp>
<Number>2</Number>
<Type>0</Type>
<LineNumber>264</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134301000</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>..\User\application\src\tcpserverc.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\semi_finished_product_testing\../User/application/src/tcpserverc.c\264</Expression>
</Bp>
<Bp>
<Number>3</Number>
<Type>0</Type>
<LineNumber>115</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134238880</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>../LWIP/App/lwip.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\semi_finished_product_testing\../LWIP/App/lwip.c\115</Expression>
</Bp>
</Breakpoint>
<WatchWindow1> <WatchWindow1>
<Ww> <Ww>
<count>0</count> <count>0</count>
@ -323,7 +388,12 @@
<Ww> <Ww>
<count>34</count> <count>34</count>
<WinNumber>1</WinNumber> <WinNumber>1</WinNumber>
<ItemText>linear_enc</ItemText> <ItemText>linear_enc,0x0A</ItemText>
</Ww>
<Ww>
<count>35</count>
<WinNumber>1</WinNumber>
<ItemText>tcp_rx_data</ItemText>
</Ww> </Ww>
</WatchWindow1> </WatchWindow1>
<MemoryWindow1> <MemoryWindow1>
@ -416,7 +486,7 @@
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>2</FileNumber> <FileNumber>2</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>../Core/Src/main.c</PathWithFileName> <PathWithFileName>../Core/Src/main.c</PathWithFileName>
@ -536,7 +606,7 @@
<Group> <Group>
<GroupName>Application/User/LWIP/Target</GroupName> <GroupName>Application/User/LWIP/Target</GroupName>
<tvExp>0</tvExp> <tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel> <cbSel>0</cbSel>
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
@ -556,7 +626,7 @@
<Group> <Group>
<GroupName>Application/User/LWIP/App</GroupName> <GroupName>Application/User/LWIP/App</GroupName>
<tvExp>0</tvExp> <tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel> <cbSel>0</cbSel>
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
@ -576,7 +646,7 @@
<Group> <Group>
<GroupName>Drivers/BSP/Components</GroupName> <GroupName>Drivers/BSP/Components</GroupName>
<tvExp>0</tvExp> <tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel> <cbSel>0</cbSel>
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
@ -968,7 +1038,7 @@
<Group> <Group>
<GroupName>Middlewares/LwIP</GroupName> <GroupName>Middlewares/LwIP</GroupName>
<tvExp>0</tvExp> <tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel> <cbSel>0</cbSel>
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
@ -1968,7 +2038,7 @@
<GroupNumber>10</GroupNumber> <GroupNumber>10</GroupNumber>
<FileNumber>126</FileNumber> <FileNumber>126</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>1</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\User\board\src\linear_encoder.c</PathWithFileName> <PathWithFileName>..\User\board\src\linear_encoder.c</PathWithFileName>
@ -2000,7 +2070,7 @@
<GroupNumber>11</GroupNumber> <GroupNumber>11</GroupNumber>
<FileNumber>128</FileNumber> <FileNumber>128</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>1</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\User\application\src\communication_protocol.c</PathWithFileName> <PathWithFileName>..\User\application\src\communication_protocol.c</PathWithFileName>

View File

@ -14,7 +14,7 @@
#include "user_lib.h" #include "user_lib.h"
#include "communication_protocol.h" #include "communication_protocol.h"
#include "user_gpio.h" #include "user_gpio.h"
#include "tim.h"
struct tcp_pcb *server_pcb_hart1 = NULL; struct tcp_pcb *server_pcb_hart1 = NULL;
struct tcp_pcb *server_pcb_hart2 = NULL; struct tcp_pcb *server_pcb_hart2 = NULL;
struct tcp_pcb *server_pcb_ble1 = NULL; struct tcp_pcb *server_pcb_ble1 = NULL;
@ -50,9 +50,11 @@ static err_t tcpecho_recv_hart1(void *arg, struct tcp_pcb *tpcb, struct pbuf *p,
dma_usart_send(&huart5, hart1_uart5.tx_data, p->tot_len); dma_usart_send(&huart5, hart1_uart5.tx_data, p->tot_len);
} }
pbuf_free(p); pbuf_free(p);
HAL_TIM_PWM_Stop(&htim3, TIM_CHANNEL_3); // 停止蜂鸣器PWM输出用于关闭蜂鸣器发声
} }
else if (err == ERR_OK) // 检测到对方主动关闭连接时也会调用recv函数此时p为空 else if (err == ERR_OK) // 检测到对方主动关闭连接时也会调用recv函数此时p为空
{ {
HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_3);
return tcp_close(tpcb); return tcp_close(tpcb);
} }
return ERR_OK; return ERR_OK;
@ -74,9 +76,11 @@ static err_t tcpecho_recv_hart2(void *arg, struct tcp_pcb *tpcb, struct pbuf *p,
} }
pbuf_free(p); pbuf_free(p);
HAL_TIM_PWM_Stop(&htim3, TIM_CHANNEL_3); // 停止蜂鸣器PWM输出用于关闭蜂鸣器发声
} }
else if (err == ERR_OK) // 检测到对方主动关闭连接时也会调用recv函数此时p为空 else if (err == ERR_OK) // 检测到对方主动关闭连接时也会调用recv函数此时p为空
{ {
HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_3);
return tcp_close(tpcb); return tcp_close(tpcb);
} }
return ERR_OK; return ERR_OK;
@ -121,9 +125,11 @@ static err_t tcpecho_recv_ble2(void *arg, struct tcp_pcb *tpcb, struct pbuf *p,
dma_usart_send(&huart3, ble2_uart3.tx_data, p->tot_len); dma_usart_send(&huart3, ble2_uart3.tx_data, p->tot_len);
} }
pbuf_free(p); pbuf_free(p);
HAL_TIM_PWM_Stop(&htim3, TIM_CHANNEL_3); // 停止蜂鸣器PWM输出用于关闭蜂鸣器发声
} }
else if (err == ERR_OK) // 检测到对方主动关闭连接时也会调用recv函数此时p为空 else if (err == ERR_OK) // 检测到对方主动关闭连接时也会调用recv函数此时p为空
{ {
HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_3);
return tcp_close(tpcb); return tcp_close(tpcb);
} }
return ERR_OK; return ERR_OK;
@ -221,9 +227,11 @@ static err_t tcpecho_recv_control(void *arg, struct tcp_pcb *tpcb, struct pbuf *
/*3. 对要发送的数据进行校验,组包,返回数据*/ /*3. 对要发送的数据进行校验,组包,返回数据*/
} }
pbuf_free(p); pbuf_free(p);
HAL_TIM_PWM_Stop(&htim3, TIM_CHANNEL_3); // 停止蜂鸣器PWM输出用于关闭蜂鸣器发声
} }
else if (err == ERR_OK) // 检测到对方主动关闭连接时也会调用recv函数此时p为空 else if (err == ERR_OK) // 检测到对方主动关闭连接时也会调用recv函数此时p为空
{ {
HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_3);
return tcp_close(tpcb); return tcp_close(tpcb);
} }