Compare commits

..

4 Commits

Author SHA1 Message Date
王绪洁 fbe63f0ef8 111 2025-06-25 18:22:56 +08:00
王绪洁 4d09e4ab4f 111 2025-06-25 18:03:02 +08:00
王绪洁 7e0b0a63a6 合并分支 2025-06-25 18:02:03 +08:00
wangxujie d343ec514c 备份,通讯卡死问题 2025-04-18 13:52:07 +08:00
12 changed files with 5568 additions and 5443 deletions

View File

@ -23,8 +23,7 @@
#define __MAIN_H
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/

View File

@ -111,8 +111,7 @@ void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer, StackTyp
* @param None
* @retval None
*/
void MX_FREERTOS_Init(void)
{
void MX_FREERTOS_Init(void) {
/* USER CODE BEGIN Init */
/* USER CODE END Init */
@ -161,6 +160,7 @@ void MX_FREERTOS_Init(void)
/* USER CODE BEGIN RTOS_THREADS */
/* add threads, ... */
/* USER CODE END RTOS_THREADS */
}
/* USER CODE BEGIN Header_start_tcp_task */
@ -271,7 +271,7 @@ void start_dac_task(void const *argument)
/* Infinite loop */
for (;;)
{
osThreadSuspend(adc_taskHandle); // 暂停ADC任务防止DAC采集时产生干<E7949F>????????,因为ADC和DAC采用的是同一路SPI但是时序不<E5BA8F>????????
osThreadSuspend(adc_taskHandle); // 暂停ADC任务防止DAC采集时产生干<E7949F><EFBFBD>?????????,因为ADC和DAC采用的是同一路SPI但是时序不<E5BA8F><EFBFBD>?????????
dac161s997_output(DAC161S997_1, current_buff[0]);
dac161s997_output(DAC161S997_2, current_buff[1]);
osThreadResume(adc_taskHandle);
@ -294,7 +294,7 @@ void start_adc_task(void const *argument)
/* Infinite loop */
for (;;)
{
osThreadSuspend(dac_taskHandle); // 暂停DAC任务防止ADC采集时产生干<E7949F>????????,因为ADC和DAC采用的是同一路SPI但是时序不<E5BA8F>????????
osThreadSuspend(dac_taskHandle); // 暂停DAC任务防止ADC采集时产生干<E7949F><EFBFBD>?????????,因为ADC和DAC采用的是同一路SPI但是时序不<E5BA8F><EFBFBD>?????????
uint8_t ch = 0;
for (ch = STOP_NC_ADC; ch < AD7124_CHANNEL_EN_MAX; ch++)
{

View File

@ -206,7 +206,8 @@ 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;
@ -375,8 +376,7 @@ 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 */

View File

@ -220,3 +220,4 @@ u32_t sio_tryread(sio_fd_t fd, u8_t *data, u32_t len)
return recved_bytes;
}
#endif /* MDK ARM Compiler */

View File

@ -315,6 +315,7 @@ static void low_level_init(struct netif *netif)
/* USER CODE END PHY_POST_CONFIG */
}
}
else
{
@ -460,6 +461,7 @@ static err_t low_level_output_arp_off(struct netif *netif, struct pbuf *q, const
/* USER CODE END 5 */
return errval;
}
#endif /* LWIP_ARP */
@ -872,3 +874,4 @@ void HAL_ETH_TxFreeCallback(uint32_t *buff)
/* USER CODE BEGIN 8 */
/* USER CODE END 8 */

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<?xml version="1.0" encoding="UTF-8"?>
<ProjectOpt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_optx.xsd">
<SchemaVersion>1.0</SchemaVersion>
@ -45,7 +45,7 @@
<PageWidth>79</PageWidth>
<PageLength>66</PageLength>
<TabStop>8</TabStop>
<ListingPath></ListingPath>
<ListingPath />
</OPTLEX>
<ListingPage>
<CreateCListing>1</CreateCListing>
@ -104,16 +104,16 @@
<bSchkAxf>0</bSchkAxf>
<bTchkAxf>0</bTchkAxf>
<nTsel>6</nTsel>
<sDll></sDll>
<sDllPa></sDllPa>
<sDlgDll></sDlgDll>
<sDlgPa></sDlgPa>
<sIfile></sIfile>
<tDll></tDll>
<tDllPa></tDllPa>
<tDlgDll></tDlgDll>
<tDlgPa></tDlgPa>
<tIfile></tIfile>
<sDll />
<sDllPa />
<sDlgDll />
<sDlgPa />
<sIfile />
<tDll />
<tDllPa />
<tDlgDll />
<tDlgPa />
<tIfile />
<pMon>STLink\ST-LINKIII-KEIL_SWO.dll</pMon>
</DebugOpt>
<TargetDriverDllRegistry>
@ -130,7 +130,7 @@
<SetRegEntry>
<Number>0</Number>
<Key>ARMDBGFLAGS</Key>
<Name></Name>
<Name />
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
@ -162,7 +162,7 @@
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c</Filename>
<ExecCommand></ExecCommand>
<ExecCommand />
<Expression>\\semi_finished_product_testing\../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c\2413</Expression>
</Bp>
</Breakpoint>
@ -280,19 +280,19 @@
<newCpu>0</newCpu>
<uProt>0</uProt>
</DebugFlag>
<LintExecutable></LintExecutable>
<LintConfigFile></LintConfigFile>
<LintExecutable />
<LintConfigFile />
<bLintAuto>0</bLintAuto>
<bAutoGenD>0</bAutoGenD>
<LntExFlags>0</LntExFlags>
<pMisraName></pMisraName>
<pszMrule></pszMrule>
<pSingCmds></pSingCmds>
<pMultCmds></pMultCmds>
<pMisraNamep></pMisraNamep>
<pszMrulep></pszMrulep>
<pSingCmdsp></pSingCmdsp>
<pMultCmdsp></pMultCmdsp>
<pMisraName />
<pszMrule />
<pSingCmds />
<pMultCmds />
<pMisraNamep />
<pszMrulep />
<pSingCmdsp />
<pMultCmdsp />
<DebugDescription>
<Enable>0</Enable>
<EnableFlashSeq>0</EnableFlashSeq>

View File

@ -1,10 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_projx.xsd">
<?xml version="1.0" encoding="UTF-8"?>
<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" noNamespaceSchemaLocation="project_projx.xsd">
<SchemaVersion>2.1</SchemaVersion>
<Header>### uVision Project, (C) Keil Software</Header>
<Targets>
<Target>
<TargetName>semi-finished_product_testing</TargetName>
@ -19,28 +16,28 @@
<PackID>Keil.STM32F4xx_DFP.2.12.0</PackID>
<PackURL>http://www.keil.com/pack</PackURL>
<Cpu>IRAM(0x20000000-0x2001BFFF) IRAM2(0x2001C000-0x2001FFFF) IROM(0x8000000-0x80FFFFF) CLOCK(25000000) FPU2 CPUTYPE("Cortex-M4") TZ</Cpu>
<FlashUtilSpec></FlashUtilSpec>
<StartupFile></StartupFile>
<FlashDriverDll></FlashDriverDll>
<FlashUtilSpec />
<StartupFile />
<FlashDriverDll />
<DeviceId>0</DeviceId>
<RegisterFile></RegisterFile>
<MemoryEnv></MemoryEnv>
<Cmp></Cmp>
<Asm></Asm>
<Linker></Linker>
<OHString></OHString>
<InfinionOptionDll></InfinionOptionDll>
<SLE66CMisc></SLE66CMisc>
<SLE66AMisc></SLE66AMisc>
<SLE66LinkerMisc></SLE66LinkerMisc>
<RegisterFile />
<MemoryEnv />
<Cmp />
<Asm />
<Linker />
<OHString />
<InfinionOptionDll />
<SLE66CMisc />
<SLE66AMisc />
<SLE66LinkerMisc />
<SFDFile>$$Device:STM32F407VGTx$CMSIS\SVD\STM32F40x.svd</SFDFile>
<bCustSvd>0</bCustSvd>
<UseEnv>0</UseEnv>
<BinPath></BinPath>
<IncludePath></IncludePath>
<LibPath></LibPath>
<RegisterFilePath></RegisterFilePath>
<DBRegisterFilePath></DBRegisterFilePath>
<BinPath />
<IncludePath />
<LibPath />
<RegisterFilePath />
<DBRegisterFilePath />
<TargetStatus>
<Error>0</Error>
<ExitCodeStop>0</ExitCodeStop>
@ -55,15 +52,15 @@
<CreateHexFile>1</CreateHexFile>
<DebugInformation>1</DebugInformation>
<BrowseInformation>0</BrowseInformation>
<ListingPath></ListingPath>
<ListingPath />
<HexFormatSelection>1</HexFormatSelection>
<Merge32K>0</Merge32K>
<CreateBatchFile>0</CreateBatchFile>
<BeforeCompile>
<RunUserProg1>0</RunUserProg1>
<RunUserProg2>0</RunUserProg2>
<UserProg1Name></UserProg1Name>
<UserProg2Name></UserProg2Name>
<UserProg1Name />
<UserProg2Name />
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
<nStopU1X>0</nStopU1X>
@ -72,8 +69,8 @@
<BeforeMake>
<RunUserProg1>0</RunUserProg1>
<RunUserProg2>0</RunUserProg2>
<UserProg1Name></UserProg1Name>
<UserProg2Name></UserProg2Name>
<UserProg1Name />
<UserProg2Name />
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
<nStopB1X>0</nStopB1X>
@ -82,15 +79,15 @@
<AfterMake>
<RunUserProg1>0</RunUserProg1>
<RunUserProg2>0</RunUserProg2>
<UserProg1Name></UserProg1Name>
<UserProg2Name></UserProg2Name>
<UserProg1Name />
<UserProg2Name />
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
<nStopA1X>0</nStopA1X>
<nStopA2X>0</nStopA2X>
</AfterMake>
<SelectedForBatchBuild>1</SelectedForBatchBuild>
<SVCSIdString></SVCSIdString>
<SVCSIdString />
</TargetCommonOption>
<CommonProperty>
<UseCPPCompiler>0</UseCPPCompiler>
@ -104,8 +101,8 @@
<AssembleAssemblyFile>0</AssembleAssemblyFile>
<PublicsOnly>0</PublicsOnly>
<StopOnExitCode>3</StopOnExitCode>
<CustomArgument></CustomArgument>
<IncludeLibraryModules></IncludeLibraryModules>
<CustomArgument />
<IncludeLibraryModules />
<ComprImg>0</ComprImg>
</CommonProperty>
<DllOption>
@ -139,10 +136,10 @@
<bUseTDR>1</bUseTDR>
<Flash2>BIN\UL2V8M.DLL</Flash2>
<Flash3>"" ()</Flash3>
<Flash4></Flash4>
<pFcarmOut></pFcarmOut>
<pFcarmGrp></pFcarmGrp>
<pFcArmRoot></pFcArmRoot>
<Flash4 />
<pFcarmOut />
<pFcarmGrp />
<pFcArmRoot />
<FcArmLst>0</FcArmLst>
</Utilities>
<TargetArmAds>
@ -175,7 +172,7 @@
<RvctClst>0</RvctClst>
<GenPPlst>0</GenPPlst>
<AdsCpuType>"Cortex-M4"</AdsCpuType>
<RvctDeviceName></RvctDeviceName>
<RvctDeviceName />
<mOS>0</mOS>
<uocRom>0</uocRom>
<uocRam>0</uocRam>
@ -309,7 +306,7 @@
<Size>0x4000</Size>
</OCR_RVCT10>
</OnChipMemories>
<RvctStartVector></RvctStartVector>
<RvctStartVector />
</ArmAdsMisc>
<Cads>
<interw>1</interw>
@ -336,9 +333,9 @@
<v6WtE>0</v6WtE>
<v6Rtti>0</v6Rtti>
<VariousControls>
<MiscControls></MiscControls>
<MiscControls />
<Define>USE_HAL_DRIVER,STM32F407xx</Define>
<Undefine></Undefine>
<Undefine />
<IncludePath>../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</IncludePath>
</VariousControls>
</Cads>
@ -354,9 +351,9 @@
<useXO>0</useXO>
<ClangAsOpt>1</ClangAsOpt>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<MiscControls />
<Define />
<Undefine />
<IncludePath>../Core/Inc</IncludePath>
</VariousControls>
</Aads>
@ -367,15 +364,15 @@
<noStLib>0</noStLib>
<RepFail>1</RepFail>
<useFile>0</useFile>
<TextAddressRange></TextAddressRange>
<DataAddressRange></DataAddressRange>
<pXoBase></pXoBase>
<ScatterFile></ScatterFile>
<IncludeLibs></IncludeLibs>
<IncludeLibsPath></IncludeLibsPath>
<Misc></Misc>
<LinkerInputFile></LinkerInputFile>
<DisabledWarnings></DisabledWarnings>
<TextAddressRange />
<DataAddressRange />
<pXoBase />
<ScatterFile />
<IncludeLibs />
<IncludeLibsPath />
<Misc />
<LinkerInputFile />
<DisabledWarnings />
</LDads>
</TargetArmAds>
</TargetOption>
@ -1141,7 +1138,6 @@
</Groups>
</Target>
</Targets>
<RTE>
<apis />
<components>
@ -1154,7 +1150,6 @@
</components>
<files />
</RTE>
<LayerInfo>
<Layers>
<Layer>
@ -1163,5 +1158,5 @@
</Layer>
</Layers>
</LayerInfo>
</Project>

View File

@ -1,3 +1,11 @@
/*
* @Author: wangxujie 390834610@qq.com
* @Date: 2025-02-19 08:33:14
* @LastEditors: wangxujie 390834610@qq.com
* @LastEditTime: 2025-04-18 13:36:18
* @FilePath: \Semi-finished product testing\User\application\inc\tcpserverc.h
* @Description: ,`customMade`, koroFileHeader查看配置 : https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
#ifndef _TCPECHO_H_
#define _TCPECHO_H_

View File

@ -370,7 +370,6 @@ void user_send_data_ble2(uint8_t *data, uint16_t len)
void user_send_data_control(uint8_t *data, uint16_t len)
{
tcp_write(server_pcb_control, data, len, 1);
}

View File

@ -0,0 +1,70 @@
# 开发环境说明
## 1. 硬件平台
- 主控芯片STM32F407xx系列ARM Cortex-M4F内核
- 外设芯片:
- ADCAD7124-8高精度模拟量输入
- DACDAC161S997高精度模拟量输出
- 以太网LAN8742网络通信
- LCD串口显示屏
- 编码器接口
## 2. 开发工具
### 主要IDE
- Keil MDK-ARM (MDK-ARM目录存在)
- 项目文件semi-finished_product_testing.uvprojx
- 编译配置semi-finished_product_testing.uvoptx
- Visual Studio Code (存在.vscode配置目录)
- 用于代码编辑和查看
### 编译工具
- ARMCC编译器 (ARM编译工具链)
- 启动文件startup_stm32f407xx.s
## 3. 软件框架
### 操作系统
- FreeRTOS实时操作系统
- 版本位于Middlewares/Third_Party/FreeRTOS/Source/
- 配置文件FreeRTOSConfig.h
### 驱动库
- STM32 HAL库 (Hardware Abstraction Layer)
- 位置Drivers/STM32F4xx_HAL_Driver/
- 包含各种外设驱动
### 网络协议栈
- LwIP (Lightweight IP)
- 位置Middlewares/Third_Party/LwIP/
- 支持TCP/IP协议
- MQTT支持
### BSP支持
- LAN8742网络驱动
- 位置Drivers/BSP/Components/lan8742/
## 4. 项目结构
```
项目主要目录:
├── Core/ # 核心应用代码
├── Drivers/ # 驱动程序
├── LWIP/ # 网络协议栈
├── MDK-ARM/ # Keil工程文件
└── Middlewares/ # 中间件(FreeRTOS/LwIP)
```
## 5. 开发规范
- 基于HAL库的驱动开发
- FreeRTOS多任务架构
- 模块化的设计结构
- 标准C语言开发规范
## 6. 调试方式
- ST-Link/J-Link调试器支持
- 串口调试
- 以太网远程调试
## 7. 项目文档
位于Documents/目录:
- 数据手册 (datasheet/)
- 项目文档 (project documents/)
- 原理图 (schematic diagram/)

55
simple_flow_chart.md Normal file
View File

@ -0,0 +1,55 @@
```mermaid
graph TB
%% 主要流程
Start[系统启动] --> Init[系统初始化]
Init --> Tasks[任务创建]
%% 主要任务分支
Tasks --> Network[网络通信]
Tasks --> DataAcq[数据采集]
Tasks --> DataOut[数据输出]
Tasks --> UserInterface[人机交互]
%% 网络通信详细
Network --> |TCP/IP|RemoteControl[远程控制]
RemoteControl --> |命令|CommandProcess[命令处理]
RemoteControl --> |数据|DataUpload[数据上传]
%% 数据采集详细
DataAcq --> |ADC|AnalogIn[模拟量输入]
DataAcq --> |GPIO|DigitalIn[数字量输入]
AnalogIn --> DataProcess[数据处理]
DigitalIn --> DataProcess
%% 数据输出详细
DataOut --> |DAC|AnalogOut[模拟量输出]
DataOut --> |GPIO|DigitalOut[数字量输出]
CommandProcess --> DataOut
%% 人机交互详细
UserInterface --> |LCD|Display[状态显示]
UserInterface --> |编码器|LocalControl[本地控制]
LocalControl --> DataOut
DataProcess --> Display
%% 通信协议
subgraph 通信协议
HART[HART协议]
BLE[蓝牙通信]
TCP[TCP/IP]
end
%% 硬件接口
subgraph 硬件接口
ADC[AD7124]
DAC[DAC161S997]
DIO[数字IO]
LCD[串口LCD]
ETH[以太网]
Encoder[编码器]
end
%% 数据流向
DataProcess --> |测量数据|DataUpload
CommandProcess --> |控制命令|DataOut
```