第一次实验-上课示例
This commit is contained in:
parent
ffc675c5b3
commit
b0ebd03d19
20
exp1/Core/Inc/variable.h
Normal file
20
exp1/Core/Inc/variable.h
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#include <stdint.h>
|
||||||
|
#ifndef __VARIABLE_H
|
||||||
|
#define __VARIABLE_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint8_t mMilSecCount; // 毫秒计数
|
||||||
|
uint8_t bTenMilSecOk; // 10毫秒标志位
|
||||||
|
uint8_t mTimeCount; // 秒计数
|
||||||
|
uint8_t bTimeOk; // 秒标志位
|
||||||
|
} stSysTickTimer;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __VARIABLE_H */
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
/* Private includes ----------------------------------------------------------*/
|
/* Private includes ----------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN Includes */
|
/* USER CODE BEGIN Includes */
|
||||||
|
#include "variable.h"
|
||||||
/* USER CODE END Includes */
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
/* Private typedef -----------------------------------------------------------*/
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
@ -43,7 +43,9 @@
|
|||||||
/* Private variables ---------------------------------------------------------*/
|
/* Private variables ---------------------------------------------------------*/
|
||||||
|
|
||||||
/* USER CODE BEGIN PV */
|
/* USER CODE BEGIN PV */
|
||||||
|
stSysTickTimer sSysTickTimer = {
|
||||||
|
0, 0, 0, 0
|
||||||
|
};
|
||||||
/* USER CODE END PV */
|
/* USER CODE END PV */
|
||||||
|
|
||||||
/* Private function prototypes -----------------------------------------------*/
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
@ -97,6 +99,15 @@ int main(void)
|
|||||||
/* USER CODE END WHILE */
|
/* USER CODE END WHILE */
|
||||||
|
|
||||||
/* USER CODE BEGIN 3 */
|
/* USER CODE BEGIN 3 */
|
||||||
|
if (sSysTickTimer.bTenMilSecOk) {
|
||||||
|
sSysTickTimer.bTenMilSecOk = 0;
|
||||||
|
}
|
||||||
|
if (sSysTickTimer.bTimeOk) {
|
||||||
|
sSysTickTimer.bTimeOk = 0;
|
||||||
|
HAL_GPIO_TogglePin(TickClock_LED_GPIO_Port, TickClock_LED_Pin);
|
||||||
|
}
|
||||||
|
// HAL_GPIO_TogglePin(TickClock_LED_GPIO_Port, TickClock_LED_Pin);
|
||||||
|
// HAL_Delay(100);
|
||||||
}
|
}
|
||||||
/* USER CODE END 3 */
|
/* USER CODE END 3 */
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "stm32g4xx_it.h"
|
#include "stm32g4xx_it.h"
|
||||||
/* Private includes ----------------------------------------------------------*/
|
/* Private includes ----------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN Includes */
|
/* USER CODE BEGIN Includes */
|
||||||
|
#include "variable.h"
|
||||||
/* USER CODE END Includes */
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
/* Private typedef -----------------------------------------------------------*/
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
@ -57,7 +58,7 @@
|
|||||||
/* External variables --------------------------------------------------------*/
|
/* External variables --------------------------------------------------------*/
|
||||||
|
|
||||||
/* USER CODE BEGIN EV */
|
/* USER CODE BEGIN EV */
|
||||||
|
extern stSysTickTimer sSysTickTimer;
|
||||||
/* USER CODE END EV */
|
/* USER CODE END EV */
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
@ -187,7 +188,14 @@ void SysTick_Handler(void)
|
|||||||
/* USER CODE END SysTick_IRQn 0 */
|
/* USER CODE END SysTick_IRQn 0 */
|
||||||
HAL_IncTick();
|
HAL_IncTick();
|
||||||
/* USER CODE BEGIN SysTick_IRQn 1 */
|
/* USER CODE BEGIN SysTick_IRQn 1 */
|
||||||
|
if (++sSysTickTimer.mMilSecCount >= 10) {
|
||||||
|
sSysTickTimer.mMilSecCount = 0;
|
||||||
|
sSysTickTimer.bTenMilSecOk = 1;
|
||||||
|
if (++sSysTickTimer.mTimeCount >= 100) {
|
||||||
|
sSysTickTimer.mTimeCount = 0;
|
||||||
|
sSysTickTimer.bTimeOk = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
/* USER CODE END SysTick_IRQn 1 */
|
/* USER CODE END SysTick_IRQn 1 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" noNamespaceSchemaLocation="project_projx.xsd">
|
<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_projx.xsd">
|
||||||
|
|
||||||
<SchemaVersion>2.1</SchemaVersion>
|
<SchemaVersion>2.1</SchemaVersion>
|
||||||
|
|
||||||
<Header>### uVision Project, (C) Keil Software</Header>
|
<Header>### uVision Project, (C) Keil Software</Header>
|
||||||
|
|
||||||
<Targets>
|
<Targets>
|
||||||
<Target>
|
<Target>
|
||||||
<TargetName>exp1</TargetName>
|
<TargetName>exp1</TargetName>
|
||||||
@ -16,28 +19,28 @@
|
|||||||
<PackID>Keil.STM32G4xx_DFP.1.5.0</PackID>
|
<PackID>Keil.STM32G4xx_DFP.1.5.0</PackID>
|
||||||
<PackURL>https://www.keil.com/pack/</PackURL>
|
<PackURL>https://www.keil.com/pack/</PackURL>
|
||||||
<Cpu>IRAM(0x20000000-0x2001FFFF) IROM(0x8000000-0x801FFFF) CLOCK(8000000) FPU2 CPUTYPE("Cortex-M4") TZ</Cpu>
|
<Cpu>IRAM(0x20000000-0x2001FFFF) IROM(0x8000000-0x801FFFF) CLOCK(8000000) FPU2 CPUTYPE("Cortex-M4") TZ</Cpu>
|
||||||
<FlashUtilSpec />
|
<FlashUtilSpec></FlashUtilSpec>
|
||||||
<StartupFile />
|
<StartupFile></StartupFile>
|
||||||
<FlashDriverDll />
|
<FlashDriverDll></FlashDriverDll>
|
||||||
<DeviceId>0</DeviceId>
|
<DeviceId>0</DeviceId>
|
||||||
<RegisterFile />
|
<RegisterFile></RegisterFile>
|
||||||
<MemoryEnv />
|
<MemoryEnv></MemoryEnv>
|
||||||
<Cmp />
|
<Cmp></Cmp>
|
||||||
<Asm />
|
<Asm></Asm>
|
||||||
<Linker />
|
<Linker></Linker>
|
||||||
<OHString />
|
<OHString></OHString>
|
||||||
<InfinionOptionDll />
|
<InfinionOptionDll></InfinionOptionDll>
|
||||||
<SLE66CMisc />
|
<SLE66CMisc></SLE66CMisc>
|
||||||
<SLE66AMisc />
|
<SLE66AMisc></SLE66AMisc>
|
||||||
<SLE66LinkerMisc />
|
<SLE66LinkerMisc></SLE66LinkerMisc>
|
||||||
<SFDFile>$$Device:STM32G473CBTx$CMSIS\SVD\STM32G473xx.svd</SFDFile>
|
<SFDFile>$$Device:STM32G473CBTx$CMSIS\SVD\STM32G473xx.svd</SFDFile>
|
||||||
<bCustSvd>0</bCustSvd>
|
<bCustSvd>0</bCustSvd>
|
||||||
<UseEnv>0</UseEnv>
|
<UseEnv>0</UseEnv>
|
||||||
<BinPath />
|
<BinPath></BinPath>
|
||||||
<IncludePath />
|
<IncludePath></IncludePath>
|
||||||
<LibPath />
|
<LibPath></LibPath>
|
||||||
<RegisterFilePath />
|
<RegisterFilePath></RegisterFilePath>
|
||||||
<DBRegisterFilePath />
|
<DBRegisterFilePath></DBRegisterFilePath>
|
||||||
<TargetStatus>
|
<TargetStatus>
|
||||||
<Error>0</Error>
|
<Error>0</Error>
|
||||||
<ExitCodeStop>0</ExitCodeStop>
|
<ExitCodeStop>0</ExitCodeStop>
|
||||||
@ -52,15 +55,15 @@
|
|||||||
<CreateHexFile>1</CreateHexFile>
|
<CreateHexFile>1</CreateHexFile>
|
||||||
<DebugInformation>1</DebugInformation>
|
<DebugInformation>1</DebugInformation>
|
||||||
<BrowseInformation>1</BrowseInformation>
|
<BrowseInformation>1</BrowseInformation>
|
||||||
<ListingPath />
|
<ListingPath></ListingPath>
|
||||||
<HexFormatSelection>1</HexFormatSelection>
|
<HexFormatSelection>1</HexFormatSelection>
|
||||||
<Merge32K>0</Merge32K>
|
<Merge32K>0</Merge32K>
|
||||||
<CreateBatchFile>0</CreateBatchFile>
|
<CreateBatchFile>0</CreateBatchFile>
|
||||||
<BeforeCompile>
|
<BeforeCompile>
|
||||||
<RunUserProg1>0</RunUserProg1>
|
<RunUserProg1>0</RunUserProg1>
|
||||||
<RunUserProg2>0</RunUserProg2>
|
<RunUserProg2>0</RunUserProg2>
|
||||||
<UserProg1Name />
|
<UserProg1Name></UserProg1Name>
|
||||||
<UserProg2Name />
|
<UserProg2Name></UserProg2Name>
|
||||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||||
<nStopU1X>0</nStopU1X>
|
<nStopU1X>0</nStopU1X>
|
||||||
@ -69,8 +72,8 @@
|
|||||||
<BeforeMake>
|
<BeforeMake>
|
||||||
<RunUserProg1>0</RunUserProg1>
|
<RunUserProg1>0</RunUserProg1>
|
||||||
<RunUserProg2>0</RunUserProg2>
|
<RunUserProg2>0</RunUserProg2>
|
||||||
<UserProg1Name />
|
<UserProg1Name></UserProg1Name>
|
||||||
<UserProg2Name />
|
<UserProg2Name></UserProg2Name>
|
||||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||||
<nStopB1X>0</nStopB1X>
|
<nStopB1X>0</nStopB1X>
|
||||||
@ -79,15 +82,15 @@
|
|||||||
<AfterMake>
|
<AfterMake>
|
||||||
<RunUserProg1>0</RunUserProg1>
|
<RunUserProg1>0</RunUserProg1>
|
||||||
<RunUserProg2>1</RunUserProg2>
|
<RunUserProg2>1</RunUserProg2>
|
||||||
<UserProg1Name />
|
<UserProg1Name></UserProg1Name>
|
||||||
<UserProg2Name />
|
<UserProg2Name></UserProg2Name>
|
||||||
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
|
||||||
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
|
||||||
<nStopA1X>0</nStopA1X>
|
<nStopA1X>0</nStopA1X>
|
||||||
<nStopA2X>0</nStopA2X>
|
<nStopA2X>0</nStopA2X>
|
||||||
</AfterMake>
|
</AfterMake>
|
||||||
<SelectedForBatchBuild>1</SelectedForBatchBuild>
|
<SelectedForBatchBuild>1</SelectedForBatchBuild>
|
||||||
<SVCSIdString />
|
<SVCSIdString></SVCSIdString>
|
||||||
</TargetCommonOption>
|
</TargetCommonOption>
|
||||||
<CommonProperty>
|
<CommonProperty>
|
||||||
<UseCPPCompiler>0</UseCPPCompiler>
|
<UseCPPCompiler>0</UseCPPCompiler>
|
||||||
@ -101,8 +104,8 @@
|
|||||||
<AssembleAssemblyFile>0</AssembleAssemblyFile>
|
<AssembleAssemblyFile>0</AssembleAssemblyFile>
|
||||||
<PublicsOnly>0</PublicsOnly>
|
<PublicsOnly>0</PublicsOnly>
|
||||||
<StopOnExitCode>3</StopOnExitCode>
|
<StopOnExitCode>3</StopOnExitCode>
|
||||||
<CustomArgument />
|
<CustomArgument></CustomArgument>
|
||||||
<IncludeLibraryModules />
|
<IncludeLibraryModules></IncludeLibraryModules>
|
||||||
<ComprImg>0</ComprImg>
|
<ComprImg>0</ComprImg>
|
||||||
</CommonProperty>
|
</CommonProperty>
|
||||||
<DllOption>
|
<DllOption>
|
||||||
@ -135,11 +138,11 @@
|
|||||||
</Flash1>
|
</Flash1>
|
||||||
<bUseTDR>1</bUseTDR>
|
<bUseTDR>1</bUseTDR>
|
||||||
<Flash2>BIN\UL2V8M.DLL</Flash2>
|
<Flash2>BIN\UL2V8M.DLL</Flash2>
|
||||||
<Flash3 />
|
<Flash3></Flash3>
|
||||||
<Flash4 />
|
<Flash4></Flash4>
|
||||||
<pFcarmOut />
|
<pFcarmOut></pFcarmOut>
|
||||||
<pFcarmGrp />
|
<pFcarmGrp></pFcarmGrp>
|
||||||
<pFcArmRoot />
|
<pFcArmRoot></pFcArmRoot>
|
||||||
<FcArmLst>0</FcArmLst>
|
<FcArmLst>0</FcArmLst>
|
||||||
</Utilities>
|
</Utilities>
|
||||||
<TargetArmAds>
|
<TargetArmAds>
|
||||||
@ -172,7 +175,7 @@
|
|||||||
<RvctClst>0</RvctClst>
|
<RvctClst>0</RvctClst>
|
||||||
<GenPPlst>0</GenPPlst>
|
<GenPPlst>0</GenPPlst>
|
||||||
<AdsCpuType>"Cortex-M4"</AdsCpuType>
|
<AdsCpuType>"Cortex-M4"</AdsCpuType>
|
||||||
<RvctDeviceName />
|
<RvctDeviceName></RvctDeviceName>
|
||||||
<mOS>0</mOS>
|
<mOS>0</mOS>
|
||||||
<uocRom>0</uocRom>
|
<uocRom>0</uocRom>
|
||||||
<uocRam>0</uocRam>
|
<uocRam>0</uocRam>
|
||||||
@ -306,7 +309,7 @@
|
|||||||
<Size>0x0</Size>
|
<Size>0x0</Size>
|
||||||
</OCR_RVCT10>
|
</OCR_RVCT10>
|
||||||
</OnChipMemories>
|
</OnChipMemories>
|
||||||
<RvctStartVector />
|
<RvctStartVector></RvctStartVector>
|
||||||
</ArmAdsMisc>
|
</ArmAdsMisc>
|
||||||
<Cads>
|
<Cads>
|
||||||
<interw>1</interw>
|
<interw>1</interw>
|
||||||
@ -333,9 +336,9 @@
|
|||||||
<v6WtE>0</v6WtE>
|
<v6WtE>0</v6WtE>
|
||||||
<v6Rtti>0</v6Rtti>
|
<v6Rtti>0</v6Rtti>
|
||||||
<VariousControls>
|
<VariousControls>
|
||||||
<MiscControls />
|
<MiscControls></MiscControls>
|
||||||
<Define>USE_HAL_DRIVER,STM32G473xx</Define>
|
<Define>USE_HAL_DRIVER,STM32G473xx</Define>
|
||||||
<Undefine />
|
<Undefine></Undefine>
|
||||||
<IncludePath>../Core/Inc;../Drivers/STM32G4xx_HAL_Driver/Inc;../Drivers/STM32G4xx_HAL_Driver/Inc/Legacy;../Drivers/CMSIS/Device/ST/STM32G4xx/Include;../Drivers/CMSIS/Include</IncludePath>
|
<IncludePath>../Core/Inc;../Drivers/STM32G4xx_HAL_Driver/Inc;../Drivers/STM32G4xx_HAL_Driver/Inc/Legacy;../Drivers/CMSIS/Device/ST/STM32G4xx/Include;../Drivers/CMSIS/Include</IncludePath>
|
||||||
</VariousControls>
|
</VariousControls>
|
||||||
</Cads>
|
</Cads>
|
||||||
@ -351,10 +354,10 @@
|
|||||||
<useXO>0</useXO>
|
<useXO>0</useXO>
|
||||||
<ClangAsOpt>1</ClangAsOpt>
|
<ClangAsOpt>1</ClangAsOpt>
|
||||||
<VariousControls>
|
<VariousControls>
|
||||||
<MiscControls />
|
<MiscControls></MiscControls>
|
||||||
<Define />
|
<Define></Define>
|
||||||
<Undefine />
|
<Undefine></Undefine>
|
||||||
<IncludePath />
|
<IncludePath></IncludePath>
|
||||||
</VariousControls>
|
</VariousControls>
|
||||||
</Aads>
|
</Aads>
|
||||||
<LDads>
|
<LDads>
|
||||||
@ -364,15 +367,15 @@
|
|||||||
<noStLib>0</noStLib>
|
<noStLib>0</noStLib>
|
||||||
<RepFail>1</RepFail>
|
<RepFail>1</RepFail>
|
||||||
<useFile>0</useFile>
|
<useFile>0</useFile>
|
||||||
<TextAddressRange />
|
<TextAddressRange></TextAddressRange>
|
||||||
<DataAddressRange />
|
<DataAddressRange></DataAddressRange>
|
||||||
<pXoBase />
|
<pXoBase></pXoBase>
|
||||||
<ScatterFile />
|
<ScatterFile></ScatterFile>
|
||||||
<IncludeLibs />
|
<IncludeLibs></IncludeLibs>
|
||||||
<IncludeLibsPath />
|
<IncludeLibsPath></IncludeLibsPath>
|
||||||
<Misc />
|
<Misc></Misc>
|
||||||
<LinkerInputFile />
|
<LinkerInputFile></LinkerInputFile>
|
||||||
<DisabledWarnings />
|
<DisabledWarnings></DisabledWarnings>
|
||||||
</LDads>
|
</LDads>
|
||||||
</TargetArmAds>
|
</TargetArmAds>
|
||||||
</TargetOption>
|
</TargetOption>
|
||||||
@ -410,6 +413,11 @@
|
|||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>../Core/Src/stm32g4xx_hal_msp.c</FilePath>
|
<FilePath>../Core/Src/stm32g4xx_hal_msp.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>variable.h</FileName>
|
||||||
|
<FileType>5</FileType>
|
||||||
|
<FilePath>..\Core\Inc\variable.h</FilePath>
|
||||||
|
</File>
|
||||||
</Files>
|
</Files>
|
||||||
</Group>
|
</Group>
|
||||||
<Group>
|
<Group>
|
||||||
@ -508,17 +516,18 @@
|
|||||||
</Groups>
|
</Groups>
|
||||||
</Target>
|
</Target>
|
||||||
</Targets>
|
</Targets>
|
||||||
|
|
||||||
<RTE>
|
<RTE>
|
||||||
<apis />
|
<apis/>
|
||||||
<components>
|
<components>
|
||||||
<component Cclass="CMSIS" Cgroup="CORE" Cvendor="ARM" Cversion="5.6.0" condition="ARMv6_7_8-M Device">
|
<component Cclass="CMSIS" Cgroup="CORE" Cvendor="ARM" Cversion="5.6.0" condition="ARMv6_7_8-M Device">
|
||||||
<package name="CMSIS" schemaVersion="1.7.7" url="http://www.keil.com/pack/" vendor="ARM" version="5.9.0" />
|
<package name="CMSIS" schemaVersion="1.7.7" url="http://www.keil.com/pack/" vendor="ARM" version="5.9.0"/>
|
||||||
<targetInfos>
|
<targetInfos>
|
||||||
<targetInfo name="exp1" />
|
<targetInfo name="exp1"/>
|
||||||
</targetInfos>
|
</targetInfos>
|
||||||
</component>
|
</component>
|
||||||
</components>
|
</components>
|
||||||
<files />
|
<files/>
|
||||||
</RTE>
|
</RTE>
|
||||||
</Project>
|
|
||||||
|
|
||||||
|
</Project>
|
||||||
|
Loading…
Reference in New Issue
Block a user