Browse Source

FanStateMonitor

master
zhaohe 2 years ago
parent
commit
1b7a90d65a
  1. 113
      app/Core/Src/gpio.c
  2. 8
      app/Core/Src/tim.c
  3. 92
      app/MDK-ARM/app.uvoptx
  4. 210
      app/MDK-ARM/app.uvprojx
  5. 130
      app/app.ioc
  6. 2
      dep/libiflytop_micro
  7. 47
      src/device_io_service.cpp
  8. 6
      src/device_io_service.hpp
  9. 16
      src/fan_state_monitor.cpp
  10. 19
      src/fan_state_monitor.hpp

113
app/Core/Src/gpio.c

@ -55,100 +55,58 @@ void MX_GPIO_Init(void)
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOD_CLK_ENABLE();
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_0|GPIO_PIN_2|GPIO_PIN_3, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_8|GPIO_PIN_10, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_11|GPIO_PIN_12, GPIO_PIN_SET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6, GPIO_PIN_RESET);
/*Configure GPIO pins : PE2 PE3 PE4 PE5
PE6 PE7 PE13 PE14
PE6 PE7 PE8 PE10
PE11 PE12 PE13 PE14
PE15 PE0 PE1 */
GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5
|GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_13|GPIO_PIN_14
|GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_10
|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14
|GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
/*Configure GPIO pins : PC13 PC14 PC15 PC8
PC10 PC11 PC12 */
GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_8
|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12;
/*Configure GPIO pins : PC13 PC14 PC15 PC0
PC1 PC2 PC3 PC4
PC5 PC6 PC7 PC10
PC11 PC12 */
GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_0
|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4
|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_10
|GPIO_PIN_11|GPIO_PIN_12;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
/*Configure GPIO pins : PC0 PC2 PC3 */
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_2|GPIO_PIN_3;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
/*Configure GPIO pins : PC1 PC4 PC5 PC6
PC7 */
GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6
|GPIO_PIN_7;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
/*Configure GPIO pins : PA0 PA1 PA2 PA3
PA8 PA15 */
PA4 PA8 PA15 */
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
|GPIO_PIN_8|GPIO_PIN_15;
|GPIO_PIN_4|GPIO_PIN_8|GPIO_PIN_15;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/*Configure GPIO pin : PA4 */
GPIO_InitStruct.Pin = GPIO_PIN_4;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/*Configure GPIO pin : PB1 */
GPIO_InitStruct.Pin = GPIO_PIN_1;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/*Configure GPIO pins : PB2 PB10 PB11 PB12
PB13 PB14 PB15 PB4
PB5 PB8 PB9 */
GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12
|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_4
|GPIO_PIN_5|GPIO_PIN_8|GPIO_PIN_9;
/*Configure GPIO pins : PB0 PB1 PB2 PB10
PB11 PB12 PB13 PB14
PB15 PB4 PB5 PB8
PB9 */
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_10
|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14
|GPIO_PIN_15|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_8
|GPIO_PIN_9;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/*Configure GPIO pins : PE8 PE10 PE11 PE12 */
GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
/*Configure GPIO pins : PD8 PD9 PD10 PD11
PD12 PD13 PD15 */
PD12 PD13 PD15 PD0
PD1 PD2 PD3 PD4
PD5 PD6 PD7 */
GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11
|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_15;
|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_15|GPIO_PIN_0
|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4
|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
@ -161,21 +119,6 @@ void MX_GPIO_Init(void)
GPIO_InitStruct.Alternate = GPIO_AF0_MCO;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
/*Configure GPIO pins : PD0 PD1 PD2 PD3
PD7 */
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
|GPIO_PIN_7;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
/*Configure GPIO pins : PD4 PD5 PD6 */
GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
}
/* USER CODE BEGIN 2 */

8
app/Core/Src/tim.c

@ -436,16 +436,16 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* timHandle)
/* USER CODE END TIM3_MspPostInit 0 */
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
/**TIM3 GPIO Configuration
PB0 ------> TIM3_CH3
PC8 ------> TIM3_CH3
*/
GPIO_InitStruct.Pin = GPIO_PIN_0;
GPIO_InitStruct.Pin = GPIO_PIN_8;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF2_TIM3;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
/* USER CODE BEGIN TIM3_MspPostInit 1 */

92
app/MDK-ARM/app.uvoptx

@ -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>4</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>Segger\JL2CM3.dll</pMon>
</DebugOpt>
<TargetDriverDllRegistry>
@ -135,7 +135,7 @@
<SetRegEntry>
<Number>0</Number>
<Key>ARMDBGFLAGS</Key>
<Name></Name>
<Name />
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
@ -172,7 +172,7 @@
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>..\..\src\umain.cpp</Filename>
<ExecCommand></ExecCommand>
<ExecCommand />
<Expression>\\app\../../src/umain.cpp\70</Expression>
</Bp>
<Bp>
@ -188,8 +188,8 @@
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>0</BreakIfRCount>
<Filename>..\..\dep\libtrinamic\IFLYTOP-TMC-API\tmc\ic\TMC4361A\TMC4361A.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
<ExecCommand />
<Expression />
</Bp>
<Bp>
<Number>2</Number>
@ -204,8 +204,8 @@
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>0</BreakIfRCount>
<Filename>..\..\dep\libtrinamic\IFLYTOP-TMC-API\tmc\ic\TMC4361A\TMC4361A.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
<ExecCommand />
<Expression />
</Bp>
<Bp>
<Number>3</Number>
@ -220,8 +220,8 @@
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>0</BreakIfRCount>
<Filename>..\..\dep\libtrinamic\IFLYTOP-TMC-API\tmc\ic\TMC4361A\TMC4361A.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
<ExecCommand />
<Expression />
</Bp>
<Bp>
<Number>4</Number>
@ -236,8 +236,8 @@
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>0</BreakIfRCount>
<Filename>..\..\dep\libtrinamic\IFLYTOP-TMC-API\tmc\ic\TMC4361A\TMC4361A.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
<ExecCommand />
<Expression />
</Bp>
<Bp>
<Number>5</Number>
@ -252,8 +252,8 @@
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>0</BreakIfRCount>
<Filename>..\..\dep\libtrinamic\IFLYTOP-TMC-API\tmc\ic\TMC4361A\TMC4361A.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
<ExecCommand />
<Expression />
</Bp>
<Bp>
<Number>6</Number>
@ -268,8 +268,8 @@
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>0</BreakIfRCount>
<Filename>..\..\dep\libtrinamic\IFLYTOP-TMC-API\tmc\ic\TMC4361A\TMC4361A.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
<ExecCommand />
<Expression />
</Bp>
<Bp>
<Number>7</Number>
@ -284,8 +284,8 @@
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>0</BreakIfRCount>
<Filename>..\..\dep\libtrinamic\src\ic\tmc4361A.cpp</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
<ExecCommand />
<Expression />
</Bp>
<Bp>
<Number>8</Number>
@ -300,8 +300,8 @@
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>0</BreakIfRCount>
<Filename>..\..\dep\libtrinamic\src\ic\tmc4361A.cpp</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
<ExecCommand />
<Expression />
</Bp>
<Bp>
<Number>9</Number>
@ -316,8 +316,8 @@
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>0</BreakIfRCount>
<Filename>..\..\dep\libtrinamic\src\ic\tmc4361A.cpp</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
<ExecCommand />
<Expression />
</Bp>
<Bp>
<Number>10</Number>
@ -332,8 +332,8 @@
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>0</BreakIfRCount>
<Filename>..\..\dep\libtrinamic\src\ic\tmc4361A.cpp</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
<ExecCommand />
<Expression />
</Bp>
<Bp>
<Number>11</Number>
@ -348,8 +348,8 @@
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>0</BreakIfRCount>
<Filename>..\..\dep\libtrinamic\src\ic\tmc4361A.cpp</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
<ExecCommand />
<Expression />
</Bp>
</Breakpoint>
<Tracepoint>
@ -381,19 +381,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>1</Enable>
<EnableFlashSeq>0</EnableFlashSeq>

210
app/MDK-ARM/app.uvprojx

@ -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>app</TargetName>
@ -19,28 +16,28 @@
<PackID>Keil.STM32F4xx_DFP.2.16.0</PackID>
<PackURL>http://www.keil.com/pack/</PackURL>
<Cpu>IRAM(0x20000000-0x2001BFFF) IRAM2(0x2001C000-0x2001FFFF) IROM(0x8000000-0x807FFFF) 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:STM32F407VETx$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>1</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>
@ -338,7 +335,7 @@
<VariousControls>
<MiscControls>--diag_suppress=381 --diag_suppress=1 --diag_suppress=177 --diag_suppress=111 --diag_suppress=1295</MiscControls>
<Define>USE_HAL_DRIVER,STM32F407xx</Define>
<Undefine></Undefine>
<Undefine />
<IncludePath>../Core/Inc;../Drivers/STM32F4xx_HAL_Driver/Inc;../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy;../Drivers/CMSIS/Device/ST/STM32F4xx/Include;../Drivers/CMSIS/Include;../../dep;../../src;../../dep/libtrinamic/IFLYTOP-TMC-API</IncludePath>
</VariousControls>
</Cads>
@ -354,10 +351,10 @@
<useXO>0</useXO>
<ClangAsOpt>1</ClangAsOpt>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
<MiscControls />
<Define />
<Undefine />
<IncludePath />
</VariousControls>
</Aads>
<LDads>
@ -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>
@ -420,8 +417,6 @@
<AssembleAssemblyFile>2</AssembleAssemblyFile>
<PublicsOnly>2</PublicsOnly>
<StopOnExitCode>11</StopOnExitCode>
<CustomArgument></CustomArgument>
<IncludeLibraryModules></IncludeLibraryModules>
<ComprImg>1</ComprImg>
</CommonProperty>
<FileArmAds>
@ -449,12 +444,6 @@
<v6Lto>2</v6Lto>
<v6WtE>2</v6WtE>
<v6Rtti>2</v6Rtti>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
</FileOption>
@ -476,8 +465,6 @@
<AssembleAssemblyFile>2</AssembleAssemblyFile>
<PublicsOnly>2</PublicsOnly>
<StopOnExitCode>11</StopOnExitCode>
<CustomArgument></CustomArgument>
<IncludeLibraryModules></IncludeLibraryModules>
<ComprImg>1</ComprImg>
</CommonProperty>
<FileArmAds>
@ -505,12 +492,6 @@
<v6Lto>2</v6Lto>
<v6WtE>2</v6WtE>
<v6Rtti>2</v6Rtti>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
</FileOption>
@ -532,8 +513,6 @@
<AssembleAssemblyFile>2</AssembleAssemblyFile>
<PublicsOnly>2</PublicsOnly>
<StopOnExitCode>11</StopOnExitCode>
<CustomArgument></CustomArgument>
<IncludeLibraryModules></IncludeLibraryModules>
<ComprImg>1</ComprImg>
</CommonProperty>
<FileArmAds>
@ -561,12 +540,6 @@
<v6Lto>2</v6Lto>
<v6WtE>2</v6WtE>
<v6Rtti>2</v6Rtti>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
</FileOption>
@ -588,8 +561,6 @@
<AssembleAssemblyFile>2</AssembleAssemblyFile>
<PublicsOnly>2</PublicsOnly>
<StopOnExitCode>11</StopOnExitCode>
<CustomArgument></CustomArgument>
<IncludeLibraryModules></IncludeLibraryModules>
<ComprImg>1</ComprImg>
</CommonProperty>
<FileArmAds>
@ -617,12 +588,6 @@
<v6Lto>2</v6Lto>
<v6WtE>2</v6WtE>
<v6Rtti>2</v6Rtti>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
</FileOption>
@ -644,8 +609,6 @@
<AssembleAssemblyFile>2</AssembleAssemblyFile>
<PublicsOnly>2</PublicsOnly>
<StopOnExitCode>11</StopOnExitCode>
<CustomArgument></CustomArgument>
<IncludeLibraryModules></IncludeLibraryModules>
<ComprImg>1</ComprImg>
</CommonProperty>
<FileArmAds>
@ -673,12 +636,6 @@
<v6Lto>2</v6Lto>
<v6WtE>2</v6WtE>
<v6Rtti>2</v6Rtti>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
</FileOption>
@ -700,8 +657,6 @@
<AssembleAssemblyFile>2</AssembleAssemblyFile>
<PublicsOnly>2</PublicsOnly>
<StopOnExitCode>11</StopOnExitCode>
<CustomArgument></CustomArgument>
<IncludeLibraryModules></IncludeLibraryModules>
<ComprImg>1</ComprImg>
</CommonProperty>
<FileArmAds>
@ -729,12 +684,6 @@
<v6Lto>2</v6Lto>
<v6WtE>2</v6WtE>
<v6Rtti>2</v6Rtti>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
</FileOption>
@ -776,8 +725,6 @@
<AssembleAssemblyFile>2</AssembleAssemblyFile>
<PublicsOnly>2</PublicsOnly>
<StopOnExitCode>11</StopOnExitCode>
<CustomArgument></CustomArgument>
<IncludeLibraryModules></IncludeLibraryModules>
<ComprImg>1</ComprImg>
</CommonProperty>
<FileArmAds>
@ -805,12 +752,6 @@
<v6Lto>2</v6Lto>
<v6WtE>2</v6WtE>
<v6Rtti>2</v6Rtti>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
</FileOption>
@ -897,8 +838,6 @@
<AssembleAssemblyFile>2</AssembleAssemblyFile>
<PublicsOnly>2</PublicsOnly>
<StopOnExitCode>11</StopOnExitCode>
<CustomArgument></CustomArgument>
<IncludeLibraryModules></IncludeLibraryModules>
<ComprImg>1</ComprImg>
</CommonProperty>
<FileArmAds>
@ -926,12 +865,6 @@
<v6Lto>2</v6Lto>
<v6WtE>2</v6WtE>
<v6Rtti>2</v6Rtti>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
</FileOption>
@ -953,8 +886,6 @@
<AssembleAssemblyFile>2</AssembleAssemblyFile>
<PublicsOnly>2</PublicsOnly>
<StopOnExitCode>11</StopOnExitCode>
<CustomArgument></CustomArgument>
<IncludeLibraryModules></IncludeLibraryModules>
<ComprImg>1</ComprImg>
</CommonProperty>
<FileArmAds>
@ -982,12 +913,6 @@
<v6Lto>2</v6Lto>
<v6WtE>2</v6WtE>
<v6Rtti>2</v6Rtti>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
</FileOption>
@ -1009,8 +934,6 @@
<AssembleAssemblyFile>2</AssembleAssemblyFile>
<PublicsOnly>2</PublicsOnly>
<StopOnExitCode>11</StopOnExitCode>
<CustomArgument></CustomArgument>
<IncludeLibraryModules></IncludeLibraryModules>
<ComprImg>1</ComprImg>
</CommonProperty>
<FileArmAds>
@ -1038,12 +961,6 @@
<v6Lto>2</v6Lto>
<v6WtE>2</v6WtE>
<v6Rtti>2</v6Rtti>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
</FileOption>
@ -1065,8 +982,6 @@
<AssembleAssemblyFile>2</AssembleAssemblyFile>
<PublicsOnly>2</PublicsOnly>
<StopOnExitCode>11</StopOnExitCode>
<CustomArgument></CustomArgument>
<IncludeLibraryModules></IncludeLibraryModules>
<ComprImg>1</ComprImg>
</CommonProperty>
<FileArmAds>
@ -1094,12 +1009,6 @@
<v6Lto>2</v6Lto>
<v6WtE>2</v6WtE>
<v6Rtti>2</v6Rtti>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
</FileOption>
@ -1121,8 +1030,6 @@
<AssembleAssemblyFile>2</AssembleAssemblyFile>
<PublicsOnly>2</PublicsOnly>
<StopOnExitCode>11</StopOnExitCode>
<CustomArgument></CustomArgument>
<IncludeLibraryModules></IncludeLibraryModules>
<ComprImg>1</ComprImg>
</CommonProperty>
<FileArmAds>
@ -1150,12 +1057,6 @@
<v6Lto>2</v6Lto>
<v6WtE>2</v6WtE>
<v6Rtti>2</v6Rtti>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
</FileOption>
@ -1288,18 +1189,17 @@
</Groups>
</Target>
</Targets>
<RTE>
<apis/>
<apis />
<components>
<component Cclass="CMSIS" Cgroup="CORE" Cvendor="ARM" Cversion="4.3.0" condition="CMSIS Core">
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="4.5.0"/>
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="4.5.0" />
<targetInfos>
<targetInfo name="app"/>
<targetInfo name="app" />
</targetInfos>
</component>
</components>
<files/>
<files />
</RTE>
</Project>

130
app/app.ioc

@ -42,52 +42,30 @@ Mcu.Name=STM32F407V(E-G)Tx
Mcu.Package=LQFP100
Mcu.Pin0=PH0-OSC_IN
Mcu.Pin1=PH1-OSC_OUT
Mcu.Pin10=PC4
Mcu.Pin11=PC5
Mcu.Pin12=PB0
Mcu.Pin13=PB1
Mcu.Pin14=PE8
Mcu.Pin15=PE9
Mcu.Pin16=PE10
Mcu.Pin17=PE11
Mcu.Pin18=PE12
Mcu.Pin19=PD14
Mcu.Pin2=PC0
Mcu.Pin20=PC6
Mcu.Pin21=PC7
Mcu.Pin22=PC9
Mcu.Pin23=PA9
Mcu.Pin24=PA10
Mcu.Pin25=PA11
Mcu.Pin26=PA12
Mcu.Pin27=PA13
Mcu.Pin28=PA14
Mcu.Pin29=PD0
Mcu.Pin3=PC1
Mcu.Pin30=PD1
Mcu.Pin31=PD2
Mcu.Pin32=PD3
Mcu.Pin33=PD4
Mcu.Pin34=PD5
Mcu.Pin35=PD6
Mcu.Pin36=PD7
Mcu.Pin37=PB3
Mcu.Pin38=PB6
Mcu.Pin39=PB7
Mcu.Pin4=PC2
Mcu.Pin40=VP_CRC_VS_CRC
Mcu.Pin41=VP_RNG_VS_RNG
Mcu.Pin42=VP_SYS_VS_Systick
Mcu.Pin43=VP_TIM1_VS_ClockSourceINT
Mcu.Pin44=VP_TIM3_VS_ClockSourceINT
Mcu.Pin45=VP_TIM6_VS_ClockSourceINT
Mcu.Pin46=VP_TIM7_VS_ClockSourceINT
Mcu.Pin5=PC3
Mcu.Pin6=PA4
Mcu.Pin7=PA5
Mcu.Pin8=PA6
Mcu.Pin9=PA7
Mcu.PinsNb=47
Mcu.Pin10=PA10
Mcu.Pin11=PA11
Mcu.Pin12=PA12
Mcu.Pin13=PA13
Mcu.Pin14=PA14
Mcu.Pin15=PB3
Mcu.Pin16=PB6
Mcu.Pin17=PB7
Mcu.Pin18=VP_CRC_VS_CRC
Mcu.Pin19=VP_RNG_VS_RNG
Mcu.Pin2=PA5
Mcu.Pin20=VP_SYS_VS_Systick
Mcu.Pin21=VP_TIM1_VS_ClockSourceINT
Mcu.Pin22=VP_TIM3_VS_ClockSourceINT
Mcu.Pin23=VP_TIM6_VS_ClockSourceINT
Mcu.Pin24=VP_TIM7_VS_ClockSourceINT
Mcu.Pin3=PA6
Mcu.Pin4=PA7
Mcu.Pin5=PE9
Mcu.Pin6=PD14
Mcu.Pin7=PC8
Mcu.Pin8=PC9
Mcu.Pin9=PA9
Mcu.PinsNb=25
Mcu.ThirdPartyNb=0
Mcu.UserConstants=
Mcu.UserName=STM32F407VETx
@ -119,8 +97,6 @@ PA13.Mode=Serial_Wire
PA13.Signal=SYS_JTMS-SWDIO
PA14.Mode=Serial_Wire
PA14.Signal=SYS_JTCK-SWCLK
PA4.Locked=true
PA4.Signal=GPIO_Output
PA5.Locked=true
PA5.Mode=Full_Duplex_Master
PA5.Signal=SPI1_SCK
@ -133,13 +109,6 @@ PA7.Signal=SPI1_MOSI
PA9.Locked=true
PA9.Mode=Asynchronous
PA9.Signal=USART1_TX
PB0.GPIOParameters=GPIO_ModeDefaultPP,GPIO_PuPd
PB0.GPIO_ModeDefaultPP=GPIO_MODE_AF_PP
PB0.GPIO_PuPd=GPIO_PULLDOWN
PB0.Locked=true
PB0.Signal=S_TIM3_CH3
PB1.Locked=true
PB1.Signal=GPIO_Output
PB3.Locked=true
PB3.Signal=S_TIM2_CH2
PB6.Locked=true
@ -148,55 +117,16 @@ PB6.Signal=I2C1_SCL
PB7.Locked=true
PB7.Mode=I2C
PB7.Signal=I2C1_SDA
PC0.Locked=true
PC0.Signal=GPIO_Output
PC1.Locked=true
PC1.Signal=GPIO_Input
PC2.Locked=true
PC2.Signal=GPIO_Output
PC3.Locked=true
PC3.Signal=GPIO_Output
PC4.Locked=true
PC4.Signal=GPIO_Input
PC5.Locked=true
PC5.Signal=GPIO_Input
PC6.Locked=true
PC6.Signal=GPIO_Input
PC7.Locked=true
PC7.Signal=GPIO_Input
PC8.GPIOParameters=GPIO_ModeDefaultPP,GPIO_PuPd
PC8.GPIO_ModeDefaultPP=GPIO_MODE_AF_PP
PC8.GPIO_PuPd=GPIO_PULLDOWN
PC8.Locked=true
PC8.Signal=S_TIM3_CH3
PC9.Locked=true
PC9.Mode=Clock-out-2
PC9.Signal=RCC_MCO_2
PD0.Locked=true
PD0.Signal=GPIO_Input
PD1.Locked=true
PD1.Signal=GPIO_Input
PD14.Locked=true
PD14.Signal=S_TIM4_CH3
PD2.Locked=true
PD2.Signal=GPIO_Input
PD3.Locked=true
PD3.Signal=GPIO_Input
PD4.Locked=true
PD4.Signal=GPIO_Output
PD5.Locked=true
PD5.Signal=GPIO_Output
PD6.Locked=true
PD6.Signal=GPIO_Output
PD7.Locked=true
PD7.Signal=GPIO_Input
PE10.Locked=true
PE10.Signal=GPIO_Output
PE11.GPIOParameters=PinState
PE11.Locked=true
PE11.PinState=GPIO_PIN_SET
PE11.Signal=GPIO_Output
PE12.GPIOParameters=PinState
PE12.Locked=true
PE12.PinState=GPIO_PIN_SET
PE12.Signal=GPIO_Output
PE8.Locked=true
PE8.Signal=GPIO_Output
PE9.GPIOParameters=GPIO_ModeDefaultPP,GPIO_PuPd
PE9.GPIO_ModeDefaultPP=GPIO_MODE_AF_PP
PE9.GPIO_PuPd=GPIO_PULLDOWN
@ -234,7 +164,7 @@ ProjectManager.StackSize=0x400
ProjectManager.TargetToolchain=MDK-ARM V5.32
ProjectManager.ToolChainLocation=
ProjectManager.UnderRoot=false
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_USART1_UART_Init-USART1-false-HAL-true,4-MX_TIM2_Init-TIM2-false-HAL-true,5-MX_TIM3_Init-TIM3-false-HAL-true,6-MX_TIM4_Init-TIM4-false-HAL-true,7-MX_CRC_Init-CRC-false-HAL-true,8-MX_RNG_Init-RNG-false-HAL-true,9-MX_TIM7_Init-TIM7-false-HAL-true,10-MX_SPI1_Init-SPI1-false-HAL-true,11-MX_TIM6_Init-TIM6-false-HAL-true,12-MX_TIM1_Init-TIM1-false-HAL-true,13-MX_CAN1_Init-CAN1-false-HAL-true
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_USART1_UART_Init-USART1-false-HAL-true,4-MX_TIM2_Init-TIM2-false-HAL-true,5-MX_TIM3_Init-TIM3-false-HAL-true,6-MX_TIM4_Init-TIM4-false-HAL-true,7-MX_CRC_Init-CRC-false-HAL-true,8-MX_RNG_Init-RNG-false-HAL-true,9-MX_TIM7_Init-TIM7-false-HAL-true,10-MX_SPI1_Init-SPI1-false-HAL-true,11-MX_TIM6_Init-TIM6-false-HAL-true,12-MX_TIM1_Init-TIM1-false-HAL-true,13-MX_CAN1_Init-CAN1-false-HAL-true,14-MX_I2C1_Init-I2C1-false-HAL-true
RCC.48MHZClocksFreq_Value=48000000
RCC.AHBFreq_Value=144000000
RCC.APB1CLKDivider=RCC_HCLK_DIV4

2
dep/libiflytop_micro

@ -1 +1 @@
Subproject commit 8a21b347ee6436e79cdc404bd3082946deade41f
Subproject commit b85d8c6f872e7d3465d2b6d75d7ef8802eb1feab

47
src/device_io_service.cpp

@ -1,6 +1,6 @@
#include "device_io_service.hpp"
#include "libiflytop_micro/stm32/basic/stm32_clock_utils.hpp"
#include "libiflytop_micro/stm32/basic/stm32_hal_utils.hpp"
extern "C" {
int fputc(int ch, FILE *stream) {
uint8_t c = ch;
@ -14,13 +14,9 @@ namespace iflytop {
DeviceIoService deviceIoService;
}
void DeviceIoService::fanInit(int freq) {
void DeviceIoService::fanInit(int freq) {}
}
void DeviceIoService::fanSetDutyCycle(int fanIndex, uint16_t dutyCycle) {
}
void DeviceIoService::fanSetDutyCycle(int fanIndex, uint16_t dutyCycle) {}
bool *DeviceIoService::fanGetState(int fanIndex) { return &m_fanState[fanIndex]; }
/*******************************************************************************
@ -35,6 +31,10 @@ void DeviceIoService::peltier_hot_ctr_pwm(int pwm) {
__HAL_TIM_SET_COMPARE(&htim3, TIM_CHANNEL_3, pwm);
HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_3);
}
void DeviceIoService::peltier_init() { //
Stm32HalUtils::gpioInit(GPIOB, GPIO_PIN_1, GPIO_MODE_AF_PP, GPIO_PULLUP, GPIO_SPEED_FREQ_LOW, GPIO_PIN_RESET);
Stm32HalUtils::gpioInit(GPIOE, GPIO_PIN_10, GPIO_MODE_AF_PP, GPIO_PULLUP, GPIO_SPEED_FREQ_LOW, GPIO_PIN_RESET);
}
void DeviceIoService::peltier_set_pwm(int pwm) {
/**
* @brief
@ -76,6 +76,15 @@ void DeviceIoService::peltier_set_pwm(int pwm) {
/*******************************************************************************
* tmc芯片驱动相关 *
*******************************************************************************/
void DeviceIoService::tmc_init() {
Stm32HalUtils::gpioInit( //
GPIOA, GPIO_PIN_4, GPIO_MODE_OUTPUT_PP, GPIO_PULLUP, GPIO_SPEED_FREQ_LOW, GPIO_PIN_SET);
Stm32HalUtils::gpioInit( //
GPIOE, GPIO_PIN_12, GPIO_MODE_OUTPUT_PP, GPIO_PULLUP, GPIO_SPEED_FREQ_LOW, GPIO_PIN_SET);
Stm32HalUtils::gpioInit( //
GPIOE, GPIO_PIN_11, GPIO_MODE_OUTPUT_PP, GPIO_PULLUP, GPIO_SPEED_FREQ_LOW, GPIO_PIN_SET);
}
void DeviceIoService::tmc_motor_spi_select(int channel, bool state) { HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, state ? GPIO_PIN_SET : GPIO_PIN_RESET); }
void DeviceIoService::tmc_motor_spi_write_and_read(int channel, uint8_t *data, size_t length) {
if (channel == MOTOR_1_TMC4361A_CHANNEL) {
@ -93,30 +102,6 @@ void DeviceIoService::tmc_extern_clk_enable() {
*/
#endif
}
void port_tmc_nFREEZE_pin_set_state(uint8_t channel, bool state) {
if (channel == MOTOR_1_TMC4361A_CHANNEL) {
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_12, state ? GPIO_PIN_SET : GPIO_PIN_RESET);
}
}
void port_tmc_ENN_pin_set_state(uint8_t channel, bool state) {
if (channel == MOTOR_1_TMC2160_CHANNEL) {
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_11, state ? GPIO_PIN_SET : GPIO_PIN_RESET);
}
}
void port_tmc_nRESET_pin_set_state(uint8_t channel, bool state) {}
void port_tmc_extern_clk_enable() {
#if 1
/**
* @brief TMC使用的外部时钟在stm32cubemx中已经进行配置16MHZ
* https://iflytop1.feishu.cn/wiki/wikcnog3hFm6dGFLMRksnhLb7Aw
*/
#else
// HAL_TIM_Base_Start(&TMC4361A_CLK_TIMER);
HAL_TIM_PWM_Start(&htim8, TIM_CHANNEL_4);
#endif
}
void DeviceIoService::tmc_nFREEZE_pin_set_state(uint8_t channel, bool state) {
if (channel == MOTOR_1_TMC4361A_CHANNEL) {
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_12, state ? GPIO_PIN_SET : GPIO_PIN_RESET);

6
src/device_io_service.hpp

@ -24,21 +24,21 @@ class DeviceIoService : public IflytopMicroOS {
public:
DeviceIoService(/* args */) {}
~DeviceIoService() {}
/*******************************************************************************
* *
*******************************************************************************/
void fanInit(int freq);
void fanSetDutyCycle(int fanIndex, uint16_t dutyCycle);
bool *fanGetState(int fanIndex);
/*******************************************************************************
* *
*******************************************************************************/
void peltier_init();
void peltier_set_pwm(int pwm);
/*******************************************************************************
* tmc芯片驱动相关 *
*******************************************************************************/
void tmc_init();
void tmc_motor_spi_write_and_read(int channel, uint8_t *data, size_t length);
void tmc_extern_clk_enable();
void tmc_nFREEZE_pin_set_state(uint8_t channel, bool state);
@ -59,7 +59,7 @@ class DeviceIoService : public IflytopMicroOS {
void peltier_cold_ctr_pwm(int pwm);
// PB0 HOT_CTR_PWM0
void peltier_hot_ctr_pwm(int pwm);
void tmc_motor_spi_select(int channel, bool state);
};

16
src/fan_state_monitor.cpp

@ -1,13 +1,25 @@
#include "fan_state_monitor.hpp"
#include "libiflytop_micro/stm32/basic/basic.h"
#include "libiflytop_micro\stm32\basic\stm32_hal_utils.hpp"
using namespace iflytop;
#define TAG "FAN_STATE_MONITOR"
void FanStateMonitor::initialize(IflytopMicroOS* os, GPIO_TypeDef* FB_GPIOx, uint16_t FB_GPIO_Pin, bool* fanstate) {
//
m_fanstate = fanstate;
m_FB_GPIOx = FB_GPIOx;
m_FB_GPIO_Pin = FB_GPIO_Pin;
m_fanstate = fanstate;
m_os = os;
m_fanFBCount = 0;
m_lastPinState = GPIO_PIN_RESET;
m_lastCallTicket = 0;
m_fanOpenTicket = 0;
m_lastFanState = false;
m_fanError = false;
Stm32HalUtils::gpioInitAsInput(FB_GPIOx, FB_GPIO_Pin);
m_lastPinState = HAL_GPIO_ReadPin(m_FB_GPIOx, m_FB_GPIO_Pin);
}
void FanStateMonitor::doFanStateCheckPeriodicJob() {
/**

19
src/fan_state_monitor.hpp

@ -3,15 +3,15 @@
#include "main.h"
namespace iflytop {
class FanStateMonitor {
GPIO_TypeDef* m_FB_GPIOx; // 风扇反馈引脚
uint16_t m_FB_GPIO_Pin; // 风扇反馈引脚
bool* m_fanstate; // 风扇当前是否正在工作
IflytopMicroOS* m_os; // 系统基础方法
uint16_t m_fanFBCount; // 风扇反馈计数
GPIO_PinState m_lastPinState; // 上次风扇反馈引脚状态,用来实现风扇反馈计数逻辑
uint32_t m_lastCallTicket = 0; // 上次调用周期性任务的时间戳
uint32_t m_fanOpenTicket = 0; // 风扇打开的时间戳
bool m_lastFanState = false; // 上次风扇状态,用来实现捕获风扇打开事件
GPIO_TypeDef* m_FB_GPIOx; // 风扇反馈引脚
uint16_t m_FB_GPIO_Pin; // 风扇反馈引脚
bool* m_fanstate; // 风扇当前是否正在工作
IflytopMicroOS* m_os; // 系统基础方法
uint16_t m_fanFBCount; // 风扇反馈计数
GPIO_PinState m_lastPinState; // 上次风扇反馈引脚状态,用来实现风扇反馈计数逻辑
uint32_t m_lastCallTicket; // 上次调用周期性任务的时间戳
uint32_t m_fanOpenTicket; // 风扇打开的时间戳
bool m_lastFanState; // 上次风扇状态,用来实现捕获风扇打开事件
bool m_fanError; // 风扇故障标志位
@ -35,7 +35,6 @@ class FanStateMonitor {
/*******************************************************************************
* *
*******************************************************************************/
/**
* @brief ,
*/

Loading…
Cancel
Save