Merge remote-tracking branch 'origin/feature/Timer_triggered_messages' into development

# Conflicts:
#	examples/ArmTimerCallbacks/RTE/Device/STM32F401RETx/startup_stm32f401xe.s
#	examples/ArmTimerCallbacks/RTE/Device/STM32F401RETx/system_stm32f4xx.c
#	examples/FunctionInterruptSimulation/FunctionInterruptSimulation.cpp
#	examples/FunctionInterruptSimulation/vs2017/FunctionInterruptSimulation.sln
#	examples/FunctionInterruptSimulation/vs2017/FunctionInterruptSimulation.vcxproj
#	examples/FunctionInterruptSimulation/vs2017/FunctionInterruptSimulation.vcxproj.filters
#	test/codeblocks/ETL.cbp
#	test/codeblocks/ETL.depend
#	test/codeblocks/ETL.layout
#	test/test_cyclic_value.cpp
#	test/vs2017/etl.vcxproj
#	test/vs2017/etl.vcxproj.filters
This commit is contained in:
John Wellbelove 2017-10-18 09:02:25 +01:00
parent 53412f898f
commit 8455e108bc
129 changed files with 19666 additions and 1595 deletions

View File

@ -0,0 +1,274 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<ProjectOpt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_optx.xsd">
<SchemaVersion>1.0</SchemaVersion>
<Header>### uVision Project, (C) Keil Software</Header>
<Extensions>
<cExt>*.c</cExt>
<aExt>*.s*; *.src; *.a*</aExt>
<oExt>*.obj; *.o</oExt>
<lExt>*.lib</lExt>
<tExt>*.txt; *.h; *.inc</tExt>
<pExt>*.plm</pExt>
<CppX>*.cpp</CppX>
<nMigrate>0</nMigrate>
</Extensions>
<DaveTm>
<dwLowDateTime>0</dwLowDateTime>
<dwHighDateTime>0</dwHighDateTime>
</DaveTm>
<Target>
<TargetName>Target 1</TargetName>
<ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName>
<TargetOption>
<CLKADS>12000000</CLKADS>
<OPTTT>
<gFlags>1</gFlags>
<BeepAtEnd>1</BeepAtEnd>
<RunSim>0</RunSim>
<RunTarget>1</RunTarget>
<RunAbUc>0</RunAbUc>
</OPTTT>
<OPTHX>
<HexSelection>1</HexSelection>
<FlashByte>65535</FlashByte>
<HexRangeLowAddress>0</HexRangeLowAddress>
<HexRangeHighAddress>0</HexRangeHighAddress>
<HexOffset>0</HexOffset>
</OPTHX>
<OPTLEX>
<PageWidth>79</PageWidth>
<PageLength>66</PageLength>
<TabStop>8</TabStop>
<ListingPath>.\Listings\</ListingPath>
</OPTLEX>
<ListingPage>
<CreateCListing>1</CreateCListing>
<CreateAListing>1</CreateAListing>
<CreateLListing>1</CreateLListing>
<CreateIListing>0</CreateIListing>
<AsmCond>1</AsmCond>
<AsmSymb>1</AsmSymb>
<AsmXref>0</AsmXref>
<CCond>1</CCond>
<CCode>0</CCode>
<CListInc>0</CListInc>
<CSymb>0</CSymb>
<LinkerCodeListing>0</LinkerCodeListing>
</ListingPage>
<OPTXL>
<LMap>1</LMap>
<LComments>1</LComments>
<LGenerateSymbols>1</LGenerateSymbols>
<LLibSym>1</LLibSym>
<LLines>1</LLines>
<LLocSym>1</LLocSym>
<LPubSym>1</LPubSym>
<LXref>0</LXref>
<LExpSel>0</LExpSel>
</OPTXL>
<OPTFL>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<IsCurrentTarget>1</IsCurrentTarget>
</OPTFL>
<CpuCode>18</CpuCode>
<DebugOpt>
<uSim>0</uSim>
<uTrg>1</uTrg>
<sLdApp>1</sLdApp>
<sGomain>1</sGomain>
<sRbreak>1</sRbreak>
<sRwatch>1</sRwatch>
<sRmem>1</sRmem>
<sRfunc>1</sRfunc>
<sRbox>1</sRbox>
<tLdApp>1</tLdApp>
<tGomain>1</tGomain>
<tRbreak>1</tRbreak>
<tRwatch>1</tRwatch>
<tRmem>1</tRmem>
<tRfunc>0</tRfunc>
<tRbox>1</tRbox>
<tRtrace>1</tRtrace>
<sRSysVw>1</sRSysVw>
<tRSysVw>1</tRSysVw>
<sRunDeb>0</sRunDeb>
<sLrtime>0</sLrtime>
<bEvRecOn>1</bEvRecOn>
<nTsel>5</nTsel>
<sDll></sDll>
<sDllPa></sDllPa>
<sDlgDll></sDlgDll>
<sDlgPa></sDlgPa>
<sIfile></sIfile>
<tDll></tDll>
<tDllPa></tDllPa>
<tDlgDll></tDlgDll>
<tDlgPa></tDlgPa>
<tIfile></tIfile>
<pMon>STLink\ST-LINKIII-KEIL_SWO.dll</pMon>
</DebugOpt>
<TargetDriverDllRegistry>
<SetRegEntry>
<Number>0</Number>
<Key>ARMRTXEVENTFLAGS</Key>
<Name>-L70 -Z18 -C0 -M0 -T1</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<Key>DLGTARM</Key>
<Name>(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<Key>ARMDBGFLAGS</Key>
<Name></Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<Key>DLGUARM</Key>
<Name>(105=-1,-1,-1,-1,0)</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<Key>ST-LINKIII-KEIL_SWO</Key>
<Name>-U066CFF485550707267024134 -O207 -SF4000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P2 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC1000 -FN1 -FF0STM32F4xx_512.FLM -FS08000000 -FL080000 -FP0($$Device:STM32F401RETx$CMSIS\Flash\STM32F4xx_512.FLM)</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<Key>UL2CM3</Key>
<Name>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F4xx_512 -FS08000000 -FL080000 -FP0($$Device:STM32F401RETx$CMSIS\Flash\STM32F4xx_512.FLM))</Name>
</SetRegEntry>
</TargetDriverDllRegistry>
<Breakpoint/>
<WatchWindow1>
<Ww>
<count>0</count>
<WinNumber>1</WinNumber>
<ItemText>returnCode</ItemText>
</Ww>
<Ww>
<count>1</count>
<WinNumber>1</WinNumber>
<ItemText>short_toggle</ItemText>
</Ww>
<Ww>
<count>2</count>
<WinNumber>1</WinNumber>
<ItemText>timer</ItemText>
</Ww>
</WatchWindow1>
<Tracepoint>
<THDelay>0</THDelay>
</Tracepoint>
<DebugFlag>
<trace>0</trace>
<periodic>1</periodic>
<aLwin>1</aLwin>
<aCover>0</aCover>
<aSer1>0</aSer1>
<aSer2>0</aSer2>
<aPa>0</aPa>
<viewmode>1</viewmode>
<vrSel>0</vrSel>
<aSym>0</aSym>
<aTbox>0</aTbox>
<AscS1>0</AscS1>
<AscS2>0</AscS2>
<AscS3>0</AscS3>
<aSer3>0</aSer3>
<eProf>0</eProf>
<aLa>0</aLa>
<aPa1>0</aPa1>
<AscS4>0</AscS4>
<aSer4>0</aSer4>
<StkLoc>0</StkLoc>
<TrcWin>0</TrcWin>
<newCpu>0</newCpu>
<uProt>0</uProt>
</DebugFlag>
<LintExecutable></LintExecutable>
<LintConfigFile></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>
<DebugDescription>
<Enable>1</Enable>
<EnableLog>0</EnableLog>
<Protocol>2</Protocol>
<DbgClock>10000000</DbgClock>
</DebugDescription>
</TargetOption>
</Target>
<Group>
<GroupName>Source Group 1</GroupName>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>1</GroupNumber>
<FileNumber>1</FileNumber>
<FileType>8</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>.\main.cpp</PathWithFileName>
<FilenameWithoutPath>main.cpp</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>1</GroupNumber>
<FileNumber>2</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>.\etl_profile.h</PathWithFileName>
<FilenameWithoutPath>etl_profile.h</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
<GroupName>::Board Support</GroupName>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>1</RteFlg>
</Group>
<Group>
<GroupName>::CMSIS</GroupName>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>1</RteFlg>
</Group>
<Group>
<GroupName>::Device</GroupName>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>1</RteFlg>
</Group>
</ProjectOpt>

View File

@ -0,0 +1,469 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_projx.xsd">
<SchemaVersion>2.1</SchemaVersion>
<Header>### uVision Project, (C) Keil Software</Header>
<Targets>
<Target>
<TargetName>Target 1</TargetName>
<ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName>
<pCCUsed>5060528::V5.06 update 5 (build 528)::ARMCC</pCCUsed>
<uAC6>0</uAC6>
<TargetOption>
<TargetCommonOption>
<Device>STM32F401RETx</Device>
<Vendor>STMicroelectronics</Vendor>
<PackID>Keil.STM32F4xx_DFP.2.11.0</PackID>
<PackURL>http://www.keil.com/pack</PackURL>
<Cpu>IRAM(0x20000000,0x18000) IROM(0x08000000,0x80000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLE</Cpu>
<FlashUtilSpec></FlashUtilSpec>
<StartupFile></StartupFile>
<FlashDriverDll>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F4xx_512 -FS08000000 -FL080000 -FP0($$Device:STM32F401RETx$CMSIS\Flash\STM32F4xx_512.FLM))</FlashDriverDll>
<DeviceId>0</DeviceId>
<RegisterFile>$$Device:STM32F401RETx$Drivers\CMSIS\Device\ST\STM32F4xx\Include\stm32f4xx.h</RegisterFile>
<MemoryEnv></MemoryEnv>
<Cmp></Cmp>
<Asm></Asm>
<Linker></Linker>
<OHString></OHString>
<InfinionOptionDll></InfinionOptionDll>
<SLE66CMisc></SLE66CMisc>
<SLE66AMisc></SLE66AMisc>
<SLE66LinkerMisc></SLE66LinkerMisc>
<SFDFile>$$Device:STM32F401RETx$CMSIS\SVD\STM32F401xE.svd</SFDFile>
<bCustSvd>0</bCustSvd>
<UseEnv>0</UseEnv>
<BinPath></BinPath>
<IncludePath></IncludePath>
<LibPath></LibPath>
<RegisterFilePath></RegisterFilePath>
<DBRegisterFilePath></DBRegisterFilePath>
<TargetStatus>
<Error>0</Error>
<ExitCodeStop>0</ExitCodeStop>
<ButtonStop>0</ButtonStop>
<NotGenerated>0</NotGenerated>
<InvalidFlash>1</InvalidFlash>
</TargetStatus>
<OutputDirectory>.\Objects\</OutputDirectory>
<OutputName>ArmTimerCallbacks</OutputName>
<CreateExecutable>1</CreateExecutable>
<CreateLib>0</CreateLib>
<CreateHexFile>0</CreateHexFile>
<DebugInformation>1</DebugInformation>
<BrowseInformation>1</BrowseInformation>
<ListingPath>.\Listings\</ListingPath>
<HexFormatSelection>1</HexFormatSelection>
<Merge32K>0</Merge32K>
<CreateBatchFile>0</CreateBatchFile>
<BeforeCompile>
<RunUserProg1>0</RunUserProg1>
<RunUserProg2>0</RunUserProg2>
<UserProg1Name></UserProg1Name>
<UserProg2Name></UserProg2Name>
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
<nStopU1X>0</nStopU1X>
<nStopU2X>0</nStopU2X>
</BeforeCompile>
<BeforeMake>
<RunUserProg1>0</RunUserProg1>
<RunUserProg2>0</RunUserProg2>
<UserProg1Name></UserProg1Name>
<UserProg2Name></UserProg2Name>
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
<nStopB1X>0</nStopB1X>
<nStopB2X>0</nStopB2X>
</BeforeMake>
<AfterMake>
<RunUserProg1>0</RunUserProg1>
<RunUserProg2>0</RunUserProg2>
<UserProg1Name></UserProg1Name>
<UserProg2Name></UserProg2Name>
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
<nStopA1X>0</nStopA1X>
<nStopA2X>0</nStopA2X>
</AfterMake>
<SelectedForBatchBuild>0</SelectedForBatchBuild>
<SVCSIdString></SVCSIdString>
</TargetCommonOption>
<CommonProperty>
<UseCPPCompiler>0</UseCPPCompiler>
<RVCTCodeConst>0</RVCTCodeConst>
<RVCTZI>0</RVCTZI>
<RVCTOtherData>0</RVCTOtherData>
<ModuleSelection>0</ModuleSelection>
<IncludeInBuild>1</IncludeInBuild>
<AlwaysBuild>0</AlwaysBuild>
<GenerateAssemblyFile>0</GenerateAssemblyFile>
<AssembleAssemblyFile>0</AssembleAssemblyFile>
<PublicsOnly>0</PublicsOnly>
<StopOnExitCode>3</StopOnExitCode>
<CustomArgument></CustomArgument>
<IncludeLibraryModules></IncludeLibraryModules>
<ComprImg>1</ComprImg>
</CommonProperty>
<DllOption>
<SimDllName>SARMCM3.DLL</SimDllName>
<SimDllArguments> -REMAP -MPU</SimDllArguments>
<SimDlgDll>DCM.DLL</SimDlgDll>
<SimDlgDllArguments>-pCM4</SimDlgDllArguments>
<TargetDllName>SARMCM3.DLL</TargetDllName>
<TargetDllArguments> -MPU</TargetDllArguments>
<TargetDlgDll>TCM.DLL</TargetDlgDll>
<TargetDlgDllArguments>-pCM4</TargetDlgDllArguments>
</DllOption>
<DebugOption>
<OPTHX>
<HexSelection>1</HexSelection>
<HexRangeLowAddress>0</HexRangeLowAddress>
<HexRangeHighAddress>0</HexRangeHighAddress>
<HexOffset>0</HexOffset>
<Oh166RecLen>16</Oh166RecLen>
</OPTHX>
</DebugOption>
<Utilities>
<Flash1>
<UseTargetDll>1</UseTargetDll>
<UseExternalTool>0</UseExternalTool>
<RunIndependent>0</RunIndependent>
<UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
<Capability>1</Capability>
<DriverSelection>4096</DriverSelection>
</Flash1>
<bUseTDR>1</bUseTDR>
<Flash2>BIN\UL2CM3.DLL</Flash2>
<Flash3>"" ()</Flash3>
<Flash4></Flash4>
<pFcarmOut></pFcarmOut>
<pFcarmGrp></pFcarmGrp>
<pFcArmRoot></pFcArmRoot>
<FcArmLst>0</FcArmLst>
</Utilities>
<TargetArmAds>
<ArmAdsMisc>
<GenerateListings>0</GenerateListings>
<asHll>1</asHll>
<asAsm>1</asAsm>
<asMacX>1</asMacX>
<asSyms>1</asSyms>
<asFals>1</asFals>
<asDbgD>1</asDbgD>
<asForm>1</asForm>
<ldLst>0</ldLst>
<ldmm>1</ldmm>
<ldXref>1</ldXref>
<BigEnd>0</BigEnd>
<AdsALst>1</AdsALst>
<AdsACrf>1</AdsACrf>
<AdsANop>0</AdsANop>
<AdsANot>0</AdsANot>
<AdsLLst>1</AdsLLst>
<AdsLmap>1</AdsLmap>
<AdsLcgr>1</AdsLcgr>
<AdsLsym>1</AdsLsym>
<AdsLszi>1</AdsLszi>
<AdsLtoi>1</AdsLtoi>
<AdsLsun>1</AdsLsun>
<AdsLven>1</AdsLven>
<AdsLsxf>1</AdsLsxf>
<RvctClst>0</RvctClst>
<GenPPlst>0</GenPPlst>
<AdsCpuType>"Cortex-M4"</AdsCpuType>
<RvctDeviceName></RvctDeviceName>
<mOS>0</mOS>
<uocRom>0</uocRom>
<uocRam>0</uocRam>
<hadIROM>1</hadIROM>
<hadIRAM>1</hadIRAM>
<hadXRAM>0</hadXRAM>
<uocXRam>0</uocXRam>
<RvdsVP>2</RvdsVP>
<hadIRAM2>0</hadIRAM2>
<hadIROM2>0</hadIROM2>
<StupSel>8</StupSel>
<useUlib>0</useUlib>
<EndSel>0</EndSel>
<uLtcg>0</uLtcg>
<nSecure>0</nSecure>
<RoSelD>3</RoSelD>
<RwSelD>3</RwSelD>
<CodeSel>0</CodeSel>
<OptFeed>0</OptFeed>
<NoZi1>0</NoZi1>
<NoZi2>0</NoZi2>
<NoZi3>0</NoZi3>
<NoZi4>0</NoZi4>
<NoZi5>0</NoZi5>
<Ro1Chk>0</Ro1Chk>
<Ro2Chk>0</Ro2Chk>
<Ro3Chk>0</Ro3Chk>
<Ir1Chk>1</Ir1Chk>
<Ir2Chk>0</Ir2Chk>
<Ra1Chk>0</Ra1Chk>
<Ra2Chk>0</Ra2Chk>
<Ra3Chk>0</Ra3Chk>
<Im1Chk>1</Im1Chk>
<Im2Chk>0</Im2Chk>
<OnChipMemories>
<Ocm1>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm1>
<Ocm2>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm2>
<Ocm3>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm3>
<Ocm4>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm4>
<Ocm5>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm5>
<Ocm6>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm6>
<IRAM>
<Type>0</Type>
<StartAddress>0x20000000</StartAddress>
<Size>0x18000</Size>
</IRAM>
<IROM>
<Type>1</Type>
<StartAddress>0x8000000</StartAddress>
<Size>0x80000</Size>
</IROM>
<XRAM>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</XRAM>
<OCR_RVCT1>
<Type>1</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT1>
<OCR_RVCT2>
<Type>1</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT2>
<OCR_RVCT3>
<Type>1</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT3>
<OCR_RVCT4>
<Type>1</Type>
<StartAddress>0x8000000</StartAddress>
<Size>0x80000</Size>
</OCR_RVCT4>
<OCR_RVCT5>
<Type>1</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT5>
<OCR_RVCT6>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT6>
<OCR_RVCT7>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT7>
<OCR_RVCT8>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT8>
<OCR_RVCT9>
<Type>0</Type>
<StartAddress>0x20000000</StartAddress>
<Size>0x18000</Size>
</OCR_RVCT9>
<OCR_RVCT10>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT10>
</OnChipMemories>
<RvctStartVector></RvctStartVector>
</ArmAdsMisc>
<Cads>
<interw>1</interw>
<Optim>4</Optim>
<oTime>0</oTime>
<SplitLS>0</SplitLS>
<OneElfS>1</OneElfS>
<Strict>0</Strict>
<EnumInt>0</EnumInt>
<PlainCh>1</PlainCh>
<Ropi>0</Ropi>
<Rwpi>0</Rwpi>
<wLevel>2</wLevel>
<uThumb>0</uThumb>
<uSurpInc>0</uSurpInc>
<uC99>1</uC99>
<useXO>0</useXO>
<v6Lang>3</v6Lang>
<v6LangP>3</v6LangP>
<vShortEn>1</vShortEn>
<vShortWch>1</vShortWch>
<v6Lto>0</v6Lto>
<v6WtE>0</v6WtE>
<v6Rtti>0</v6Rtti>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath>..\..\src;..\ArmTimerCallbacks</IncludePath>
</VariousControls>
</Cads>
<Aads>
<interw>1</interw>
<Ropi>0</Ropi>
<Rwpi>0</Rwpi>
<thumb>0</thumb>
<SplitLS>0</SplitLS>
<SwStkChk>0</SwStkChk>
<NoWarn>0</NoWarn>
<uSurpInc>0</uSurpInc>
<useXO>0</useXO>
<uClangAs>0</uClangAs>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
</VariousControls>
</Aads>
<LDads>
<umfTarg>0</umfTarg>
<Ropi>0</Ropi>
<Rwpi>0</Rwpi>
<noStLib>0</noStLib>
<RepFail>1</RepFail>
<useFile>0</useFile>
<TextAddressRange>0x08000000</TextAddressRange>
<DataAddressRange>0x20000000</DataAddressRange>
<pXoBase></pXoBase>
<ScatterFile></ScatterFile>
<IncludeLibs></IncludeLibs>
<IncludeLibsPath></IncludeLibsPath>
<Misc></Misc>
<LinkerInputFile></LinkerInputFile>
<DisabledWarnings></DisabledWarnings>
</LDads>
</TargetArmAds>
</TargetOption>
<Groups>
<Group>
<GroupName>Source Group 1</GroupName>
<Files>
<File>
<FileName>main.cpp</FileName>
<FileType>8</FileType>
<FilePath>.\main.cpp</FilePath>
</File>
<File>
<FileName>etl_profile.h</FileName>
<FileType>5</FileType>
<FilePath>.\etl_profile.h</FilePath>
</File>
</Files>
</Group>
<Group>
<GroupName>::Board Support</GroupName>
</Group>
<Group>
<GroupName>::CMSIS</GroupName>
</Group>
<Group>
<GroupName>::Device</GroupName>
</Group>
</Groups>
</Target>
</Targets>
<RTE>
<apis>
<api Capiversion="1.0.0" Cclass="Board Support" Cgroup="Buttons" exclusive="0">
<package name="MDK-Middleware" schemaVersion="1.4" url="http://www.keil.com/pack/" vendor="Keil" version="7.4.1"/>
<targetInfos>
<targetInfo name="Target 1"/>
</targetInfos>
</api>
<api Capiversion="1.0.0" Cclass="Board Support" Cgroup="LED" exclusive="0">
<package name="MDK-Middleware" schemaVersion="1.4" url="http://www.keil.com/pack/" vendor="Keil" version="7.4.1"/>
<targetInfos>
<targetInfo name="Target 1"/>
</targetInfos>
</api>
</apis>
<components>
<component Cclass="CMSIS" Cgroup="CORE" Cvendor="ARM" Cversion="5.0.2" condition="ARMv6_7_8-M Device">
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="5.1.1"/>
<targetInfos>
<targetInfo name="Target 1"/>
</targetInfos>
</component>
<component Capiversion="1.00" Cbundle="NUCLEO-F401RE" Cclass="Board Support" Cgroup="Buttons" Cvendor="Keil" Cversion="1.1.0" condition="F401RE CMSIS Device">
<package name="STM32NUCLEO_BSP" schemaVersion="1.2" url="http://www.keil.com/pack/" vendor="Keil" version="1.6.0"/>
<targetInfos>
<targetInfo name="Target 1"/>
</targetInfos>
</component>
<component Capiversion="1.00" Cbundle="NUCLEO-F401RE" Cclass="Board Support" Cgroup="LED" Cvendor="Keil" Cversion="1.1.0" condition="F401RE CMSIS Device">
<package name="STM32NUCLEO_BSP" schemaVersion="1.2" url="http://www.keil.com/pack/" vendor="Keil" version="1.6.0"/>
<targetInfos>
<targetInfo name="Target 1"/>
</targetInfos>
</component>
<component Cclass="Device" Cgroup="Startup" Cvendor="Keil" Cversion="2.6.0" condition="STM32F4 CMSIS">
<package name="STM32F4xx_DFP" schemaVersion="1.3" url="http://www.keil.com/pack" vendor="Keil" version="2.11.0"/>
<targetInfos>
<targetInfo name="Target 1"/>
</targetInfos>
</component>
</components>
<files>
<file attr="config" category="source" condition="STM32F401xE_ARMCC" name="Drivers\CMSIS\Device\ST\STM32F4xx\Source\Templates\arm\startup_stm32f401xe.s" version="2.6.0">
<instance index="0">RTE\Device\STM32F401RETx\startup_stm32f401xe.s</instance>
<component Cclass="Device" Cgroup="Startup" Cvendor="Keil" Cversion="2.6.0" condition="STM32F4 CMSIS"/>
<package name="STM32F4xx_DFP" schemaVersion="1.3" url="http://www.keil.com/pack" vendor="Keil" version="2.11.0"/>
<targetInfos>
<targetInfo name="Target 1"/>
</targetInfos>
</file>
<file attr="config" category="source" name="Drivers\CMSIS\Device\ST\STM32F4xx\Source\Templates\system_stm32f4xx.c" version="2.6.0">
<instance index="0">RTE\Device\STM32F401RETx\system_stm32f4xx.c</instance>
<component Cclass="Device" Cgroup="Startup" Cvendor="Keil" Cversion="2.6.0" condition="STM32F4 CMSIS"/>
<package name="STM32F4xx_DFP" schemaVersion="1.3" url="http://www.keil.com/pack" vendor="Keil" version="2.11.0"/>
<targetInfos>
<targetInfo name="Target 1"/>
</targetInfos>
</file>
</files>
</RTE>
</Project>

View File

@ -0,0 +1,392 @@
;******************** (C) COPYRIGHT 2016 STMicroelectronics ********************
;* File Name : startup_stm32f401xe.s
;* Author : MCD Application Team
;* Version : V2.6.0
;* Date : 04-November-2016
;* Description : STM32F401xe devices vector table for MDK-ARM toolchain.
;* This module performs:
;* - Set the initial SP
;* - Set the initial PC == Reset_Handler
;* - Set the vector table entries with the exceptions ISR address
;* - Branches to __main in the C library (which eventually
;* calls main()).
;* After Reset the CortexM4 processor is in Thread mode,
;* priority is Privileged, and the Stack is set to Main.
;* <<< Use Configuration Wizard in Context Menu >>>
;*******************************************************************************
;
;* Redistribution and use in source and binary forms, with or without modification,
;* are permitted provided that the following conditions are met:
;* 1. Redistributions of source code must retain the above copyright notice,
;* this list of conditions and the following disclaimer.
;* 2. Redistributions in binary form must reproduce the above copyright notice,
;* this list of conditions and the following disclaimer in the documentation
;* and/or other materials provided with the distribution.
;* 3. Neither the name of STMicroelectronics nor the names of its contributors
;* may be used to endorse or promote products derived from this software
;* without specific prior written permission.
;*
;* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
;* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
;* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
;* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
;* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
;* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
;* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
;* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
;* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
;* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;
;*******************************************************************************
; Amount of memory (in bytes) allocated for Stack
; Tailor this value to your application needs
; <h> Stack Configuration
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Stack_Size EQU 0x00000400
AREA STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem SPACE Stack_Size
__initial_sp
; <h> Heap Configuration
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Heap_Size EQU 0x00000200
AREA HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base
Heap_Mem SPACE Heap_Size
__heap_limit
PRESERVE8
THUMB
; Vector Table Mapped to Address 0 at Reset
AREA RESET, DATA, READONLY
EXPORT __Vectors
EXPORT __Vectors_End
EXPORT __Vectors_Size
__Vectors DCD __initial_sp ; Top of Stack
DCD Reset_Handler ; Reset Handler
DCD NMI_Handler ; NMI Handler
DCD HardFault_Handler ; Hard Fault Handler
DCD MemManage_Handler ; MPU Fault Handler
DCD BusFault_Handler ; Bus Fault Handler
DCD UsageFault_Handler ; Usage Fault Handler
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD SVC_Handler ; SVCall Handler
DCD DebugMon_Handler ; Debug Monitor Handler
DCD 0 ; Reserved
DCD PendSV_Handler ; PendSV Handler
DCD SysTick_Handler ; SysTick Handler
; External Interrupts
DCD WWDG_IRQHandler ; Window WatchDog
DCD PVD_IRQHandler ; PVD through EXTI Line detection
DCD TAMP_STAMP_IRQHandler ; Tamper and TimeStamps through the EXTI line
DCD RTC_WKUP_IRQHandler ; RTC Wakeup through the EXTI line
DCD FLASH_IRQHandler ; FLASH
DCD RCC_IRQHandler ; RCC
DCD EXTI0_IRQHandler ; EXTI Line0
DCD EXTI1_IRQHandler ; EXTI Line1
DCD EXTI2_IRQHandler ; EXTI Line2
DCD EXTI3_IRQHandler ; EXTI Line3
DCD EXTI4_IRQHandler ; EXTI Line4
DCD DMA1_Stream0_IRQHandler ; DMA1 Stream 0
DCD DMA1_Stream1_IRQHandler ; DMA1 Stream 1
DCD DMA1_Stream2_IRQHandler ; DMA1 Stream 2
DCD DMA1_Stream3_IRQHandler ; DMA1 Stream 3
DCD DMA1_Stream4_IRQHandler ; DMA1 Stream 4
DCD DMA1_Stream5_IRQHandler ; DMA1 Stream 5
DCD DMA1_Stream6_IRQHandler ; DMA1 Stream 6
DCD ADC_IRQHandler ; ADC1, ADC2 and ADC3s
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD EXTI9_5_IRQHandler ; External Line[9:5]s
DCD TIM1_BRK_TIM9_IRQHandler ; TIM1 Break and TIM9
DCD TIM1_UP_TIM10_IRQHandler ; TIM1 Update and TIM10
DCD TIM1_TRG_COM_TIM11_IRQHandler ; TIM1 Trigger and Commutation and TIM11
DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
DCD TIM2_IRQHandler ; TIM2
DCD TIM3_IRQHandler ; TIM3
DCD TIM4_IRQHandler ; TIM4
DCD I2C1_EV_IRQHandler ; I2C1 Event
DCD I2C1_ER_IRQHandler ; I2C1 Error
DCD I2C2_EV_IRQHandler ; I2C2 Event
DCD I2C2_ER_IRQHandler ; I2C2 Error
DCD SPI1_IRQHandler ; SPI1
DCD SPI2_IRQHandler ; SPI2
DCD USART1_IRQHandler ; USART1
DCD USART2_IRQHandler ; USART2
DCD 0 ; Reserved
DCD EXTI15_10_IRQHandler ; External Line[15:10]s
DCD RTC_Alarm_IRQHandler ; RTC Alarm (A and B) through EXTI Line
DCD OTG_FS_WKUP_IRQHandler ; USB OTG FS Wakeup through EXTI line
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD DMA1_Stream7_IRQHandler ; DMA1 Stream7
DCD 0 ; Reserved
DCD SDIO_IRQHandler ; SDIO
DCD TIM5_IRQHandler ; TIM5
DCD SPI3_IRQHandler ; SPI3
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD DMA2_Stream0_IRQHandler ; DMA2 Stream 0
DCD DMA2_Stream1_IRQHandler ; DMA2 Stream 1
DCD DMA2_Stream2_IRQHandler ; DMA2 Stream 2
DCD DMA2_Stream3_IRQHandler ; DMA2 Stream 3
DCD DMA2_Stream4_IRQHandler ; DMA2 Stream 4
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD OTG_FS_IRQHandler ; USB OTG FS
DCD DMA2_Stream5_IRQHandler ; DMA2 Stream 5
DCD DMA2_Stream6_IRQHandler ; DMA2 Stream 6
DCD DMA2_Stream7_IRQHandler ; DMA2 Stream 7
DCD USART6_IRQHandler ; USART6
DCD I2C3_EV_IRQHandler ; I2C3 event
DCD I2C3_ER_IRQHandler ; I2C3 error
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD FPU_IRQHandler ; FPU
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD SPI4_IRQHandler ; SPI4
__Vectors_End
__Vectors_Size EQU __Vectors_End - __Vectors
AREA |.text|, CODE, READONLY
; Reset handler
Reset_Handler PROC
EXPORT Reset_Handler [WEAK]
IMPORT SystemInit
IMPORT __main
LDR R0, =SystemInit
BLX R0
LDR R0, =__main
BX R0
ENDP
; Dummy Exception Handlers (infinite loops which can be modified)
NMI_Handler PROC
EXPORT NMI_Handler [WEAK]
B .
ENDP
HardFault_Handler\
PROC
EXPORT HardFault_Handler [WEAK]
B .
ENDP
MemManage_Handler\
PROC
EXPORT MemManage_Handler [WEAK]
B .
ENDP
BusFault_Handler\
PROC
EXPORT BusFault_Handler [WEAK]
B .
ENDP
UsageFault_Handler\
PROC
EXPORT UsageFault_Handler [WEAK]
B .
ENDP
SVC_Handler PROC
EXPORT SVC_Handler [WEAK]
B .
ENDP
DebugMon_Handler\
PROC
EXPORT DebugMon_Handler [WEAK]
B .
ENDP
PendSV_Handler PROC
EXPORT PendSV_Handler [WEAK]
B .
ENDP
SysTick_Handler PROC
EXPORT SysTick_Handler [WEAK]
B .
ENDP
Default_Handler PROC
EXPORT WWDG_IRQHandler [WEAK]
EXPORT PVD_IRQHandler [WEAK]
EXPORT TAMP_STAMP_IRQHandler [WEAK]
EXPORT RTC_WKUP_IRQHandler [WEAK]
EXPORT FLASH_IRQHandler [WEAK]
EXPORT RCC_IRQHandler [WEAK]
EXPORT EXTI0_IRQHandler [WEAK]
EXPORT EXTI1_IRQHandler [WEAK]
EXPORT EXTI2_IRQHandler [WEAK]
EXPORT EXTI3_IRQHandler [WEAK]
EXPORT EXTI4_IRQHandler [WEAK]
EXPORT DMA1_Stream0_IRQHandler [WEAK]
EXPORT DMA1_Stream1_IRQHandler [WEAK]
EXPORT DMA1_Stream2_IRQHandler [WEAK]
EXPORT DMA1_Stream3_IRQHandler [WEAK]
EXPORT DMA1_Stream4_IRQHandler [WEAK]
EXPORT DMA1_Stream5_IRQHandler [WEAK]
EXPORT DMA1_Stream6_IRQHandler [WEAK]
EXPORT ADC_IRQHandler [WEAK]
EXPORT EXTI9_5_IRQHandler [WEAK]
EXPORT TIM1_BRK_TIM9_IRQHandler [WEAK]
EXPORT TIM1_UP_TIM10_IRQHandler [WEAK]
EXPORT TIM1_TRG_COM_TIM11_IRQHandler [WEAK]
EXPORT TIM1_CC_IRQHandler [WEAK]
EXPORT TIM2_IRQHandler [WEAK]
EXPORT TIM3_IRQHandler [WEAK]
EXPORT TIM4_IRQHandler [WEAK]
EXPORT I2C1_EV_IRQHandler [WEAK]
EXPORT I2C1_ER_IRQHandler [WEAK]
EXPORT I2C2_EV_IRQHandler [WEAK]
EXPORT I2C2_ER_IRQHandler [WEAK]
EXPORT SPI1_IRQHandler [WEAK]
EXPORT SPI2_IRQHandler [WEAK]
EXPORT USART1_IRQHandler [WEAK]
EXPORT USART2_IRQHandler [WEAK]
EXPORT EXTI15_10_IRQHandler [WEAK]
EXPORT RTC_Alarm_IRQHandler [WEAK]
EXPORT OTG_FS_WKUP_IRQHandler [WEAK]
EXPORT DMA1_Stream7_IRQHandler [WEAK]
EXPORT SDIO_IRQHandler [WEAK]
EXPORT TIM5_IRQHandler [WEAK]
EXPORT SPI3_IRQHandler [WEAK]
EXPORT DMA2_Stream0_IRQHandler [WEAK]
EXPORT DMA2_Stream1_IRQHandler [WEAK]
EXPORT DMA2_Stream2_IRQHandler [WEAK]
EXPORT DMA2_Stream3_IRQHandler [WEAK]
EXPORT DMA2_Stream4_IRQHandler [WEAK]
EXPORT OTG_FS_IRQHandler [WEAK]
EXPORT DMA2_Stream5_IRQHandler [WEAK]
EXPORT DMA2_Stream6_IRQHandler [WEAK]
EXPORT DMA2_Stream7_IRQHandler [WEAK]
EXPORT USART6_IRQHandler [WEAK]
EXPORT I2C3_EV_IRQHandler [WEAK]
EXPORT I2C3_ER_IRQHandler [WEAK]
EXPORT FPU_IRQHandler [WEAK]
EXPORT SPI4_IRQHandler [WEAK]
WWDG_IRQHandler
PVD_IRQHandler
TAMP_STAMP_IRQHandler
RTC_WKUP_IRQHandler
FLASH_IRQHandler
RCC_IRQHandler
EXTI0_IRQHandler
EXTI1_IRQHandler
EXTI2_IRQHandler
EXTI3_IRQHandler
EXTI4_IRQHandler
DMA1_Stream0_IRQHandler
DMA1_Stream1_IRQHandler
DMA1_Stream2_IRQHandler
DMA1_Stream3_IRQHandler
DMA1_Stream4_IRQHandler
DMA1_Stream5_IRQHandler
DMA1_Stream6_IRQHandler
ADC_IRQHandler
EXTI9_5_IRQHandler
TIM1_BRK_TIM9_IRQHandler
TIM1_UP_TIM10_IRQHandler
TIM1_TRG_COM_TIM11_IRQHandler
TIM1_CC_IRQHandler
TIM2_IRQHandler
TIM3_IRQHandler
TIM4_IRQHandler
I2C1_EV_IRQHandler
I2C1_ER_IRQHandler
I2C2_EV_IRQHandler
I2C2_ER_IRQHandler
SPI1_IRQHandler
SPI2_IRQHandler
USART1_IRQHandler
USART2_IRQHandler
EXTI15_10_IRQHandler
RTC_Alarm_IRQHandler
OTG_FS_WKUP_IRQHandler
DMA1_Stream7_IRQHandler
SDIO_IRQHandler
TIM5_IRQHandler
SPI3_IRQHandler
DMA2_Stream0_IRQHandler
DMA2_Stream1_IRQHandler
DMA2_Stream2_IRQHandler
DMA2_Stream3_IRQHandler
DMA2_Stream4_IRQHandler
OTG_FS_IRQHandler
DMA2_Stream5_IRQHandler
DMA2_Stream6_IRQHandler
DMA2_Stream7_IRQHandler
USART6_IRQHandler
I2C3_EV_IRQHandler
I2C3_ER_IRQHandler
FPU_IRQHandler
SPI4_IRQHandler
B .
ENDP
ALIGN
;*******************************************************************************
; User Stack and Heap initialization
;*******************************************************************************
IF :DEF:__MICROLIB
EXPORT __initial_sp
EXPORT __heap_base
EXPORT __heap_limit
ELSE
IMPORT __use_two_region_memory
EXPORT __user_initial_stackheap
__user_initial_stackheap
LDR R0, = Heap_Mem
LDR R1, =(Stack_Mem + Stack_Size)
LDR R2, = (Heap_Mem + Heap_Size)
LDR R3, = Stack_Mem
BX LR
ALIGN
ENDIF
END
;************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE*****

View File

@ -0,0 +1,763 @@
/**
******************************************************************************
* @file system_stm32f4xx.c
* @author MCD Application Team
* @version V2.6.0
* @date 04-November-2016
* @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File.
*
* This file provides two functions and one global variable to be called from
* user application:
* - SystemInit(): This function is called at startup just after reset and
* before branch to main program. This call is made inside
* the "startup_stm32f4xx.s" file.
*
* - SystemCoreClock variable: Contains the core clock (HCLK), it can be used
* by the user application to setup the SysTick
* timer or configure other parameters.
*
* - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must
* be called whenever the core clock is changed
* during program execution.
*
*
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT 2016 STMicroelectronics</center></h2>
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of STMicroelectronics nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************
*/
/** @addtogroup CMSIS
* @{
*/
/** @addtogroup stm32f4xx_system
* @{
*/
/** @addtogroup STM32F4xx_System_Private_Includes
* @{
*/
#include "stm32f4xx.h"
#if !defined (HSE_VALUE)
#define HSE_VALUE ((uint32_t)25000000) /*!< Default value of the External oscillator in Hz */
#endif /* HSE_VALUE */
#if !defined (HSI_VALUE)
#define HSI_VALUE ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/
#endif /* HSI_VALUE */
/**
* @}
*/
/** @addtogroup STM32F4xx_System_Private_TypesDefinitions
* @{
*/
/**
* @}
*/
/** @addtogroup STM32F4xx_System_Private_Defines
* @{
*/
/************************* Miscellaneous Configuration ************************/
/*!< Uncomment the following line if you need to use external SRAM or SDRAM as data memory */
#if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)\
|| defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\
|| defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx)
/* #define DATA_IN_ExtSRAM */
#endif /* STM32F40xxx || STM32F41xxx || STM32F42xxx || STM32F43xxx || STM32F469xx || STM32F479xx ||\
STM32F412Zx || STM32F412Vx */
#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\
|| defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
/* #define DATA_IN_ExtSDRAM */
#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx ||\
STM32F479xx */
/*!< Uncomment the following line if you need to relocate your vector Table in
Internal SRAM. */
/* #define VECT_TAB_SRAM */
#define VECT_TAB_OFFSET 0x00 /*!< Vector Table base offset field.
This value must be a multiple of 0x200. */
/******************************************************************************/
/**
* @}
*/
/** @addtogroup STM32F4xx_System_Private_Macros
* @{
*/
/**
* @}
*/
/** @addtogroup STM32F4xx_System_Private_Variables
* @{
*/
/* This variable is updated in three ways:
1) by calling CMSIS function SystemCoreClockUpdate()
2) by calling HAL API function HAL_RCC_GetHCLKFreq()
3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency
Note: If you use this function to configure the system clock; then there
is no need to call the 2 first functions listed above, since SystemCoreClock
variable is updated automatically.
*/
uint32_t SystemCoreClock = 16000000;
const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
const uint8_t APBPrescTable[8] = {0, 0, 0, 0, 1, 2, 3, 4};
/**
* @}
*/
/** @addtogroup STM32F4xx_System_Private_FunctionPrototypes
* @{
*/
#if defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM)
static void SystemInit_ExtMemCtl(void);
#endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */
/**
* @}
*/
/** @addtogroup STM32F4xx_System_Private_Functions
* @{
*/
/**
* @brief Setup the microcontroller system
* Initialize the FPU setting, vector table location and External memory
* configuration.
* @param None
* @retval None
*/
void SystemInit(void)
{
/* FPU settings ------------------------------------------------------------*/
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */
#endif
/* Reset the RCC clock configuration to the default reset state ------------*/
/* Set HSION bit */
RCC->CR |= (uint32_t)0x00000001;
/* Reset CFGR register */
RCC->CFGR = 0x00000000;
/* Reset HSEON, CSSON and PLLON bits */
RCC->CR &= (uint32_t)0xFEF6FFFF;
/* Reset PLLCFGR register */
RCC->PLLCFGR = 0x24003010;
/* Reset HSEBYP bit */
RCC->CR &= (uint32_t)0xFFFBFFFF;
/* Disable all interrupts */
RCC->CIR = 0x00000000;
#if defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM)
SystemInit_ExtMemCtl();
#endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */
/* Configure the Vector Table location add offset address ------------------*/
#ifdef VECT_TAB_SRAM
SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
#else
SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
#endif
}
/**
* @brief Update SystemCoreClock variable according to Clock Register Values.
* The SystemCoreClock variable contains the core clock (HCLK), it can
* be used by the user application to setup the SysTick timer or configure
* other parameters.
*
* @note Each time the core clock (HCLK) changes, this function must be called
* to update SystemCoreClock variable value. Otherwise, any configuration
* based on this variable will be incorrect.
*
* @note - The system frequency computed by this function is not the real
* frequency in the chip. It is calculated based on the predefined
* constant and the selected clock source:
*
* - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*)
*
* - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**)
*
* - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**)
* or HSI_VALUE(*) multiplied/divided by the PLL factors.
*
* (*) HSI_VALUE is a constant defined in stm32f4xx_hal_conf.h file (default value
* 16 MHz) but the real value may vary depending on the variations
* in voltage and temperature.
*
* (**) HSE_VALUE is a constant defined in stm32f4xx_hal_conf.h file (its value
* depends on the application requirements), user has to ensure that HSE_VALUE
* is same as the real frequency of the crystal used. Otherwise, this function
* may have wrong result.
*
* - The result of this function could be not correct when using fractional
* value for HSE crystal.
*
* @param None
* @retval None
*/
void SystemCoreClockUpdate(void)
{
uint32_t tmp = 0, pllvco = 0, pllp = 2, pllsource = 0, pllm = 2;
/* Get SYSCLK source -------------------------------------------------------*/
tmp = RCC->CFGR & RCC_CFGR_SWS;
switch (tmp)
{
case 0x00: /* HSI used as system clock source */
SystemCoreClock = HSI_VALUE;
break;
case 0x04: /* HSE used as system clock source */
SystemCoreClock = HSE_VALUE;
break;
case 0x08: /* PLL used as system clock source */
/* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N
SYSCLK = PLL_VCO / PLL_P
*/
pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22;
pllm = RCC->PLLCFGR & RCC_PLLCFGR_PLLM;
if (pllsource != 0)
{
/* HSE used as PLL clock source */
pllvco = (HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
}
else
{
/* HSI used as PLL clock source */
pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
}
pllp = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLP) >>16) + 1 ) *2;
SystemCoreClock = pllvco/pllp;
break;
default:
SystemCoreClock = HSI_VALUE;
break;
}
/* Compute HCLK frequency --------------------------------------------------*/
/* Get HCLK prescaler */
tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)];
/* HCLK frequency */
SystemCoreClock >>= tmp;
}
#if defined (DATA_IN_ExtSRAM) && defined (DATA_IN_ExtSDRAM)
#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\
|| defined(STM32F469xx) || defined(STM32F479xx)
/**
* @brief Setup the external memory controller.
* Called in startup_stm32f4xx.s before jump to main.
* This function configures the external memories (SRAM/SDRAM)
* This SRAM/SDRAM will be used as program data memory (including heap and stack).
* @param None
* @retval None
*/
void SystemInit_ExtMemCtl(void)
{
__IO uint32_t tmp = 0x00;
register uint32_t tmpreg = 0, timeout = 0xFFFF;
register __IO uint32_t index;
/* Enable GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH and GPIOI interface clock */
RCC->AHB1ENR |= 0x000001F8;
/* Delay after an RCC peripheral clock enabling */
tmp = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOCEN);
/* Connect PDx pins to FMC Alternate function */
GPIOD->AFR[0] = 0x00CCC0CC;
GPIOD->AFR[1] = 0xCCCCCCCC;
/* Configure PDx pins in Alternate function mode */
GPIOD->MODER = 0xAAAA0A8A;
/* Configure PDx pins speed to 100 MHz */
GPIOD->OSPEEDR = 0xFFFF0FCF;
/* Configure PDx pins Output type to push-pull */
GPIOD->OTYPER = 0x00000000;
/* No pull-up, pull-down for PDx pins */
GPIOD->PUPDR = 0x00000000;
/* Connect PEx pins to FMC Alternate function */
GPIOE->AFR[0] = 0xC00CC0CC;
GPIOE->AFR[1] = 0xCCCCCCCC;
/* Configure PEx pins in Alternate function mode */
GPIOE->MODER = 0xAAAA828A;
/* Configure PEx pins speed to 100 MHz */
GPIOE->OSPEEDR = 0xFFFFC3CF;
/* Configure PEx pins Output type to push-pull */
GPIOE->OTYPER = 0x00000000;
/* No pull-up, pull-down for PEx pins */
GPIOE->PUPDR = 0x00000000;
/* Connect PFx pins to FMC Alternate function */
GPIOF->AFR[0] = 0xCCCCCCCC;
GPIOF->AFR[1] = 0xCCCCCCCC;
/* Configure PFx pins in Alternate function mode */
GPIOF->MODER = 0xAA800AAA;
/* Configure PFx pins speed to 50 MHz */
GPIOF->OSPEEDR = 0xAA800AAA;
/* Configure PFx pins Output type to push-pull */
GPIOF->OTYPER = 0x00000000;
/* No pull-up, pull-down for PFx pins */
GPIOF->PUPDR = 0x00000000;
/* Connect PGx pins to FMC Alternate function */
GPIOG->AFR[0] = 0xCCCCCCCC;
GPIOG->AFR[1] = 0xCCCCCCCC;
/* Configure PGx pins in Alternate function mode */
GPIOG->MODER = 0xAAAAAAAA;
/* Configure PGx pins speed to 50 MHz */
GPIOG->OSPEEDR = 0xAAAAAAAA;
/* Configure PGx pins Output type to push-pull */
GPIOG->OTYPER = 0x00000000;
/* No pull-up, pull-down for PGx pins */
GPIOG->PUPDR = 0x00000000;
/* Connect PHx pins to FMC Alternate function */
GPIOH->AFR[0] = 0x00C0CC00;
GPIOH->AFR[1] = 0xCCCCCCCC;
/* Configure PHx pins in Alternate function mode */
GPIOH->MODER = 0xAAAA08A0;
/* Configure PHx pins speed to 50 MHz */
GPIOH->OSPEEDR = 0xAAAA08A0;
/* Configure PHx pins Output type to push-pull */
GPIOH->OTYPER = 0x00000000;
/* No pull-up, pull-down for PHx pins */
GPIOH->PUPDR = 0x00000000;
/* Connect PIx pins to FMC Alternate function */
GPIOI->AFR[0] = 0xCCCCCCCC;
GPIOI->AFR[1] = 0x00000CC0;
/* Configure PIx pins in Alternate function mode */
GPIOI->MODER = 0x0028AAAA;
/* Configure PIx pins speed to 50 MHz */
GPIOI->OSPEEDR = 0x0028AAAA;
/* Configure PIx pins Output type to push-pull */
GPIOI->OTYPER = 0x00000000;
/* No pull-up, pull-down for PIx pins */
GPIOI->PUPDR = 0x00000000;
/*-- FMC Configuration -------------------------------------------------------*/
/* Enable the FMC interface clock */
RCC->AHB3ENR |= 0x00000001;
/* Delay after an RCC peripheral clock enabling */
tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN);
FMC_Bank5_6->SDCR[0] = 0x000019E4;
FMC_Bank5_6->SDTR[0] = 0x01115351;
/* SDRAM initialization sequence */
/* Clock enable command */
FMC_Bank5_6->SDCMR = 0x00000011;
tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
while((tmpreg != 0) && (timeout-- > 0))
{
tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
}
/* Delay */
for (index = 0; index<1000; index++);
/* PALL command */
FMC_Bank5_6->SDCMR = 0x00000012;
timeout = 0xFFFF;
while((tmpreg != 0) && (timeout-- > 0))
{
tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
}
/* Auto refresh command */
FMC_Bank5_6->SDCMR = 0x00000073;
timeout = 0xFFFF;
while((tmpreg != 0) && (timeout-- > 0))
{
tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
}
/* MRD register program */
FMC_Bank5_6->SDCMR = 0x00046014;
timeout = 0xFFFF;
while((tmpreg != 0) && (timeout-- > 0))
{
tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
}
/* Set refresh count */
tmpreg = FMC_Bank5_6->SDRTR;
FMC_Bank5_6->SDRTR = (tmpreg | (0x0000027C<<1));
/* Disable write protection */
tmpreg = FMC_Bank5_6->SDCR[0];
FMC_Bank5_6->SDCR[0] = (tmpreg & 0xFFFFFDFF);
#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
/* Configure and enable Bank1_SRAM2 */
FMC_Bank1->BTCR[2] = 0x00001011;
FMC_Bank1->BTCR[3] = 0x00000201;
FMC_Bank1E->BWTR[2] = 0x0fffffff;
#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
#if defined(STM32F469xx) || defined(STM32F479xx)
/* Configure and enable Bank1_SRAM2 */
FMC_Bank1->BTCR[2] = 0x00001091;
FMC_Bank1->BTCR[3] = 0x00110212;
FMC_Bank1E->BWTR[2] = 0x0fffffff;
#endif /* STM32F469xx || STM32F479xx */
(void)(tmp);
}
#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
#elif defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM)
/**
* @brief Setup the external memory controller.
* Called in startup_stm32f4xx.s before jump to main.
* This function configures the external memories (SRAM/SDRAM)
* This SRAM/SDRAM will be used as program data memory (including heap and stack).
* @param None
* @retval None
*/
void SystemInit_ExtMemCtl(void)
{
__IO uint32_t tmp = 0x00;
#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\
|| defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
#if defined (DATA_IN_ExtSDRAM)
register uint32_t tmpreg = 0, timeout = 0xFFFF;
register __IO uint32_t index;
#if defined(STM32F446xx)
/* Enable GPIOA, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG interface
clock */
RCC->AHB1ENR |= 0x0000007D;
#else
/* Enable GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH and GPIOI interface
clock */
RCC->AHB1ENR |= 0x000001F8;
#endif /* STM32F446xx */
/* Delay after an RCC peripheral clock enabling */
tmp = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOCEN);
#if defined(STM32F446xx)
/* Connect PAx pins to FMC Alternate function */
GPIOA->AFR[0] |= 0xC0000000;
GPIOA->AFR[1] |= 0x00000000;
/* Configure PDx pins in Alternate function mode */
GPIOA->MODER |= 0x00008000;
/* Configure PDx pins speed to 50 MHz */
GPIOA->OSPEEDR |= 0x00008000;
/* Configure PDx pins Output type to push-pull */
GPIOA->OTYPER |= 0x00000000;
/* No pull-up, pull-down for PDx pins */
GPIOA->PUPDR |= 0x00000000;
/* Connect PCx pins to FMC Alternate function */
GPIOC->AFR[0] |= 0x00CC0000;
GPIOC->AFR[1] |= 0x00000000;
/* Configure PDx pins in Alternate function mode */
GPIOC->MODER |= 0x00000A00;
/* Configure PDx pins speed to 50 MHz */
GPIOC->OSPEEDR |= 0x00000A00;
/* Configure PDx pins Output type to push-pull */
GPIOC->OTYPER |= 0x00000000;
/* No pull-up, pull-down for PDx pins */
GPIOC->PUPDR |= 0x00000000;
#endif /* STM32F446xx */
/* Connect PDx pins to FMC Alternate function */
GPIOD->AFR[0] = 0x000000CC;
GPIOD->AFR[1] = 0xCC000CCC;
/* Configure PDx pins in Alternate function mode */
GPIOD->MODER = 0xA02A000A;
/* Configure PDx pins speed to 50 MHz */
GPIOD->OSPEEDR = 0xA02A000A;
/* Configure PDx pins Output type to push-pull */
GPIOD->OTYPER = 0x00000000;
/* No pull-up, pull-down for PDx pins */
GPIOD->PUPDR = 0x00000000;
/* Connect PEx pins to FMC Alternate function */
GPIOE->AFR[0] = 0xC00000CC;
GPIOE->AFR[1] = 0xCCCCCCCC;
/* Configure PEx pins in Alternate function mode */
GPIOE->MODER = 0xAAAA800A;
/* Configure PEx pins speed to 50 MHz */
GPIOE->OSPEEDR = 0xAAAA800A;
/* Configure PEx pins Output type to push-pull */
GPIOE->OTYPER = 0x00000000;
/* No pull-up, pull-down for PEx pins */
GPIOE->PUPDR = 0x00000000;
/* Connect PFx pins to FMC Alternate function */
GPIOF->AFR[0] = 0xCCCCCCCC;
GPIOF->AFR[1] = 0xCCCCCCCC;
/* Configure PFx pins in Alternate function mode */
GPIOF->MODER = 0xAA800AAA;
/* Configure PFx pins speed to 50 MHz */
GPIOF->OSPEEDR = 0xAA800AAA;
/* Configure PFx pins Output type to push-pull */
GPIOF->OTYPER = 0x00000000;
/* No pull-up, pull-down for PFx pins */
GPIOF->PUPDR = 0x00000000;
/* Connect PGx pins to FMC Alternate function */
GPIOG->AFR[0] = 0xCCCCCCCC;
GPIOG->AFR[1] = 0xCCCCCCCC;
/* Configure PGx pins in Alternate function mode */
GPIOG->MODER = 0xAAAAAAAA;
/* Configure PGx pins speed to 50 MHz */
GPIOG->OSPEEDR = 0xAAAAAAAA;
/* Configure PGx pins Output type to push-pull */
GPIOG->OTYPER = 0x00000000;
/* No pull-up, pull-down for PGx pins */
GPIOG->PUPDR = 0x00000000;
#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\
|| defined(STM32F469xx) || defined(STM32F479xx)
/* Connect PHx pins to FMC Alternate function */
GPIOH->AFR[0] = 0x00C0CC00;
GPIOH->AFR[1] = 0xCCCCCCCC;
/* Configure PHx pins in Alternate function mode */
GPIOH->MODER = 0xAAAA08A0;
/* Configure PHx pins speed to 50 MHz */
GPIOH->OSPEEDR = 0xAAAA08A0;
/* Configure PHx pins Output type to push-pull */
GPIOH->OTYPER = 0x00000000;
/* No pull-up, pull-down for PHx pins */
GPIOH->PUPDR = 0x00000000;
/* Connect PIx pins to FMC Alternate function */
GPIOI->AFR[0] = 0xCCCCCCCC;
GPIOI->AFR[1] = 0x00000CC0;
/* Configure PIx pins in Alternate function mode */
GPIOI->MODER = 0x0028AAAA;
/* Configure PIx pins speed to 50 MHz */
GPIOI->OSPEEDR = 0x0028AAAA;
/* Configure PIx pins Output type to push-pull */
GPIOI->OTYPER = 0x00000000;
/* No pull-up, pull-down for PIx pins */
GPIOI->PUPDR = 0x00000000;
#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
/*-- FMC Configuration -------------------------------------------------------*/
/* Enable the FMC interface clock */
RCC->AHB3ENR |= 0x00000001;
/* Delay after an RCC peripheral clock enabling */
tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN);
/* Configure and enable SDRAM bank1 */
#if defined(STM32F446xx)
FMC_Bank5_6->SDCR[0] = 0x00001954;
#else
FMC_Bank5_6->SDCR[0] = 0x000019E4;
#endif /* STM32F446xx */
FMC_Bank5_6->SDTR[0] = 0x01115351;
/* SDRAM initialization sequence */
/* Clock enable command */
FMC_Bank5_6->SDCMR = 0x00000011;
tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
while((tmpreg != 0) && (timeout-- > 0))
{
tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
}
/* Delay */
for (index = 0; index<1000; index++);
/* PALL command */
FMC_Bank5_6->SDCMR = 0x00000012;
timeout = 0xFFFF;
while((tmpreg != 0) && (timeout-- > 0))
{
tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
}
/* Auto refresh command */
#if defined(STM32F446xx)
FMC_Bank5_6->SDCMR = 0x000000F3;
#else
FMC_Bank5_6->SDCMR = 0x00000073;
#endif /* STM32F446xx */
timeout = 0xFFFF;
while((tmpreg != 0) && (timeout-- > 0))
{
tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
}
/* MRD register program */
#if defined(STM32F446xx)
FMC_Bank5_6->SDCMR = 0x00044014;
#else
FMC_Bank5_6->SDCMR = 0x00046014;
#endif /* STM32F446xx */
timeout = 0xFFFF;
while((tmpreg != 0) && (timeout-- > 0))
{
tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
}
/* Set refresh count */
tmpreg = FMC_Bank5_6->SDRTR;
#if defined(STM32F446xx)
FMC_Bank5_6->SDRTR = (tmpreg | (0x0000050C<<1));
#else
FMC_Bank5_6->SDRTR = (tmpreg | (0x0000027C<<1));
#endif /* STM32F446xx */
/* Disable write protection */
tmpreg = FMC_Bank5_6->SDCR[0];
FMC_Bank5_6->SDCR[0] = (tmpreg & 0xFFFFFDFF);
#endif /* DATA_IN_ExtSDRAM */
#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */
#if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)\
|| defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\
|| defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx)
#if defined(DATA_IN_ExtSRAM)
/*-- GPIOs Configuration -----------------------------------------------------*/
/* Enable GPIOD, GPIOE, GPIOF and GPIOG interface clock */
RCC->AHB1ENR |= 0x00000078;
/* Delay after an RCC peripheral clock enabling */
tmp = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIODEN);
/* Connect PDx pins to FMC Alternate function */
GPIOD->AFR[0] = 0x00CCC0CC;
GPIOD->AFR[1] = 0xCCCCCCCC;
/* Configure PDx pins in Alternate function mode */
GPIOD->MODER = 0xAAAA0A8A;
/* Configure PDx pins speed to 100 MHz */
GPIOD->OSPEEDR = 0xFFFF0FCF;
/* Configure PDx pins Output type to push-pull */
GPIOD->OTYPER = 0x00000000;
/* No pull-up, pull-down for PDx pins */
GPIOD->PUPDR = 0x00000000;
/* Connect PEx pins to FMC Alternate function */
GPIOE->AFR[0] = 0xC00CC0CC;
GPIOE->AFR[1] = 0xCCCCCCCC;
/* Configure PEx pins in Alternate function mode */
GPIOE->MODER = 0xAAAA828A;
/* Configure PEx pins speed to 100 MHz */
GPIOE->OSPEEDR = 0xFFFFC3CF;
/* Configure PEx pins Output type to push-pull */
GPIOE->OTYPER = 0x00000000;
/* No pull-up, pull-down for PEx pins */
GPIOE->PUPDR = 0x00000000;
/* Connect PFx pins to FMC Alternate function */
GPIOF->AFR[0] = 0x00CCCCCC;
GPIOF->AFR[1] = 0xCCCC0000;
/* Configure PFx pins in Alternate function mode */
GPIOF->MODER = 0xAA000AAA;
/* Configure PFx pins speed to 100 MHz */
GPIOF->OSPEEDR = 0xFF000FFF;
/* Configure PFx pins Output type to push-pull */
GPIOF->OTYPER = 0x00000000;
/* No pull-up, pull-down for PFx pins */
GPIOF->PUPDR = 0x00000000;
/* Connect PGx pins to FMC Alternate function */
GPIOG->AFR[0] = 0x00CCCCCC;
GPIOG->AFR[1] = 0x000000C0;
/* Configure PGx pins in Alternate function mode */
GPIOG->MODER = 0x00085AAA;
/* Configure PGx pins speed to 100 MHz */
GPIOG->OSPEEDR = 0x000CAFFF;
/* Configure PGx pins Output type to push-pull */
GPIOG->OTYPER = 0x00000000;
/* No pull-up, pull-down for PGx pins */
GPIOG->PUPDR = 0x00000000;
/*-- FMC/FSMC Configuration --------------------------------------------------*/
/* Enable the FMC/FSMC interface clock */
RCC->AHB3ENR |= 0x00000001;
#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
/* Delay after an RCC peripheral clock enabling */
tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN);
/* Configure and enable Bank1_SRAM2 */
FMC_Bank1->BTCR[2] = 0x00001011;
FMC_Bank1->BTCR[3] = 0x00000201;
FMC_Bank1E->BWTR[2] = 0x0fffffff;
#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
#if defined(STM32F469xx) || defined(STM32F479xx)
/* Delay after an RCC peripheral clock enabling */
tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN);
/* Configure and enable Bank1_SRAM2 */
FMC_Bank1->BTCR[2] = 0x00001091;
FMC_Bank1->BTCR[3] = 0x00110212;
FMC_Bank1E->BWTR[2] = 0x0fffffff;
#endif /* STM32F469xx || STM32F479xx */
#if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx)|| defined(STM32F417xx)\
|| defined(STM32F412Zx) || defined(STM32F412Vx)
/* Delay after an RCC peripheral clock enabling */
tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FSMCEN);
/* Configure and enable Bank1_SRAM2 */
FSMC_Bank1->BTCR[2] = 0x00001011;
FSMC_Bank1->BTCR[3] = 0x00000201;
FSMC_Bank1E->BWTR[2] = 0x0FFFFFFF;
#endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F412Zx || STM32F412Vx */
#endif /* DATA_IN_ExtSRAM */
#endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx ||\
STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx || STM32F412Zx || STM32F412Vx */
(void)(tmp);
}
#endif /* DATA_IN_ExtSRAM && DATA_IN_ExtSDRAM */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@ -0,0 +1,21 @@
/*
* Auto generated Run-Time-Environment Component Configuration File
* *** Do not modify ! ***
*
* Project: 'ArmTimerCallbacks'
* Target: 'Target 1'
*/
#ifndef RTE_COMPONENTS_H
#define RTE_COMPONENTS_H
/*
* Define the Device Header File:
*/
#define CMSIS_device_header "stm32f4xx.h"
#define RTE_DEVICE_STARTUP_STM32F4XX /* Device Startup for STM32F4 */
#endif /* RTE_COMPONENTS_H */

View File

@ -0,0 +1,52 @@
/*----------------------------------------------------------------------------
* Name: Retarget.c
* Purpose: 'Retarget' layer for target-dependent low level functions
* Note(s):
*----------------------------------------------------------------------------
* This file is part of the uVision/ARM development tools.
* This software may only be used under the terms of a valid, current,
* end user licence from KEIL for a compatible version of KEIL software
* development tools. Nothing else gives you the right to use this software.
*
* This software is supplied "AS IS" without warranties of any kind.
*
* Copyright (c) 2011 Keil - An ARM Company. All rights reserved.
*----------------------------------------------------------------------------*/
#include <stdio.h>
#include <rt_misc.h>
#include "Serial.h"
//#pragma import(__use_no_semihosting_swi)
//struct __FILE { int handle; /* Add whatever you need here */ };
FILE __stdout;
FILE __stdin;
int fputc(int c, FILE *f) {
return (SER_PutChar(c));
}
int fgetc(FILE *f) {
return (SER_GetChar());
}
int ferror(FILE *f) {
/* Your implementation of ferror */
return EOF;
}
void _ttywrch(int c) {
SER_PutChar(c);
}
void _sys_exit(int return_code) {
label: goto label; /* endless loop */
}

View File

@ -0,0 +1,98 @@
/*----------------------------------------------------------------------------
* Name: Serial.c
* Purpose: Low Level Serial Routines
* Note(s): possible defines select the used communication interface:
* __DBG_ITM - ITM SWO interface
* - USART2 interface (default)
*----------------------------------------------------------------------------
* This file is part of the uVision/ARM development tools.
* This software may only be used under the terms of a valid, current,
* end user licence from KEIL for a compatible version of KEIL software
* development tools. Nothing else gives you the right to use this software.
*
* This software is supplied "AS IS" without warranties of any kind.
*
* Copyright (c) 2014 Keil - An ARM Company. All rights reserved.
*----------------------------------------------------------------------------*/
#include "stm32f4xx.h" // Device header
#include "Serial.h"
#ifdef __DBG_ITM
volatile int ITM_RxBuffer; /* CMSIS Debug Input */
#endif
/*----------------------------------------------------------------------------
Define USART
*----------------------------------------------------------------------------*/
#define USARTx USART2
/*----------------------------------------------------------------------------
Define Baudrate setting (BRR) for USART
*----------------------------------------------------------------------------*/
#define __DIV(__PCLK, __BAUD) ((__PCLK*25)/(4*__BAUD))
#define __DIVMANT(__PCLK, __BAUD) (__DIV(__PCLK, __BAUD)/100)
#define __DIVFRAQ(__PCLK, __BAUD) (((__DIV(__PCLK, __BAUD) - (__DIVMANT(__PCLK, __BAUD) * 100)) * 16 + 50) / 100)
#define __USART_BRR(__PCLK, __BAUD) ((__DIVMANT(__PCLK, __BAUD) << 4)|(__DIVFRAQ(__PCLK, __BAUD) & 0x0F))
/*----------------------------------------------------------------------------
Initialize UART pins, Baudrate
*----------------------------------------------------------------------------*/
void SER_Initialize (void) {
#ifdef __DBG_ITM
ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* CMSIS Debug Input */
#else
RCC->AHB1ENR |= ( 1ul << 0); /* Enable GPIOA clock */
RCC->APB1ENR |= ( 1ul << 17); /* Enable USART#2 clock */
/* Configure PA3 to USART2_RX, PA2 to USART2_TX */
GPIOA->AFR[0] &= ~((15ul << 4* 3) | (15ul << 4* 2) );
GPIOA->AFR[0] |= (( 7ul << 4* 3) | ( 7ul << 4* 2) );
GPIOA->MODER &= ~(( 3ul << 2* 3) | ( 3ul << 2* 2) );
GPIOA->MODER |= (( 2ul << 2* 3) | ( 2ul << 2* 2) );
USARTx->BRR = __USART_BRR(12000000ul, 115200ul); /* 115200 baud @ 12MHz */
USARTx->CR3 = 0x0000; /* no flow control */
USARTx->CR2 = 0x0000; /* 1 stop bit */
USARTx->CR1 = (( 1ul << 2) | /* enable RX */
( 1ul << 3) | /* enable TX */
( 0ul << 12) | /* 1 start bit, 8 data bits */
( 1ul << 13) ); /* enable USART */
#endif
}
/*----------------------------------------------------------------------------
Write character to Serial Port
*----------------------------------------------------------------------------*/
int SER_PutChar (int ch) {
#ifdef __DBG_ITM
ITM_SendChar (ch & 0xFF);
#else
while (!(USARTx->SR & 0x0080));
USARTx->DR = (ch & 0xFF);
#endif
return (ch);
}
/*----------------------------------------------------------------------------
Read character from Serial Port
*----------------------------------------------------------------------------*/
int SER_GetChar (void) {
#ifdef __DBG_ITM
if (ITM_CheckChar())
return ITM_ReceiveChar();
#else
if (USARTx->SR & 0x0020)
return (USARTx->DR);
#endif
return (-1);
}

View File

@ -0,0 +1,23 @@
/*----------------------------------------------------------------------------
* Name: Serial.h
* Purpose: Low level serial definitions
* Note(s):
*----------------------------------------------------------------------------
* This file is part of the uVision/ARM development tools.
* This software may only be used under the terms of a valid, current,
* end user licence from KEIL for a compatible version of KEIL software
* development tools. Nothing else gives you the right to use this software.
*
* This software is supplied "AS IS" without warranties of any kind.
*
* Copyright (c) 2014 Keil - An ARM Company. All rights reserved.
*----------------------------------------------------------------------------*/
#ifndef SERIAL_H
#define SERIAL_H
extern void SER_Initialize(void);
extern int SER_GetChar (void);
extern int SER_PutChar (int c);
#endif

View File

@ -0,0 +1,21 @@
#ifndef __ETL_PROFILE_H__
#define __ETL_PROFILE_H__
#define ETL_THROW_EXCEPTIONS
#define ETL_VERBOSE_ERRORS
#define ETL_CHECK_PUSH_POP
#define ETL_ISTRING_REPAIR_ENABLE
#define ETL_IVECTOR_REPAIR_ENABLE
#define ETL_IDEQUE_REPAIR_ENABLE
#define ETL_IN_UNIT_TEST
#if (__CC_ARM == 1)
// ARM5 compiler
#include "profiles/armv5.h"
#else
// ARM6 compiler
#include "profiles/armv6.h"
#endif
#endif

View File

@ -0,0 +1,147 @@
#include <stdio.h>
extern "C"
{
#include "Board_LED.h" // ::Board Support:LED
#include "Board_Buttons.h" // ::Board Support:Buttons
#include "stm32f4xx.h" // Device header
}
#include "function.h"
#include "callback_timer.h"
const int N_TIMERS = 4;
etl::callback_timer<N_TIMERS> callback_timer;
etl::timer::id::type short_toggle;
etl::timer::id::type long_toggle;
etl::timer::id::type start_timers;
etl::timer::id::type swap_timers;
/*----------------------------------------------------------------------------
* SystemCoreClockConfigure: configure SystemCoreClock using HSI
(HSE is not populated on Nucleo board)
*----------------------------------------------------------------------------*/
void SystemCoreClockConfigure(void) {
RCC->CR |= ((uint32_t)RCC_CR_HSION); // Enable HSI
while ((RCC->CR & RCC_CR_HSIRDY) == 0); // Wait for HSI Ready
RCC->CFGR = RCC_CFGR_SW_HSI; // HSI is system clock
while ((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_HSI); // Wait for HSI used as system clock
FLASH->ACR = FLASH_ACR_PRFTEN; // Enable Prefetch Buffer
FLASH->ACR |= FLASH_ACR_ICEN; // Instruction cache enable
FLASH->ACR |= FLASH_ACR_DCEN; // Data cache enable
FLASH->ACR |= FLASH_ACR_LATENCY_5WS; // Flash 5 wait state
RCC->CFGR |= RCC_CFGR_HPRE_DIV1; // HCLK = SYSCLK
RCC->CFGR |= RCC_CFGR_PPRE1_DIV4; // APB1 = HCLK/4
RCC->CFGR |= RCC_CFGR_PPRE2_DIV2; // APB2 = HCLK/2
RCC->CR &= ~RCC_CR_PLLON; // Disable PLL
// PLL configuration: VCO = HSI/M * N, Sysclk = VCO/P
RCC->PLLCFGR = ( 16ul | // PLL_M = 16
(384ul << 6) | // PLL_N = 384
( 3ul << 16) | // PLL_P = 8
(RCC_PLLCFGR_PLLSRC_HSI) | // PLL_SRC = HSI
( 8ul << 24) ); // PLL_Q = 8
RCC->CR |= RCC_CR_PLLON; // Enable PLL
while((RCC->CR & RCC_CR_PLLRDY) == 0) __NOP(); // Wait till PLL is ready
RCC->CFGR &= ~RCC_CFGR_SW; // Select PLL as system clock source
RCC->CFGR |= RCC_CFGR_SW_PLL;
while ((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_PLL); // Wait till PLL is system clock src
}
void StartTimers()
{
callback_timer.start(short_toggle);
callback_timer.start(swap_timers);
}
void SwapTimers()
{
static bool state = false;
if (!state)
{
callback_timer.stop(short_toggle);
callback_timer.start(long_toggle);
}
else
{
callback_timer.start(short_toggle);
callback_timer.stop(long_toggle);
}
state = !state;
callback_timer.start(swap_timers);
}
void LedToggle()
{
static bool state = false;
if (state)
{
LED_On(0);
}
else
{
LED_Off(0);
}
state = !state;
}
int main()
{
SystemCoreClockConfigure(); // configure HSI as System Clock
SystemCoreClockUpdate();
LED_Initialize();
Buttons_Initialize();
// The LEDs will start flashing fast after 2 seconds.
// After another 5 seconds they will start flashing slower.
short_toggle = callback_timer.register_timer(LedToggle, 50, etl::timer::mode::REPEATING);
long_toggle = callback_timer.register_timer(LedToggle, 100, etl::timer::mode::REPEATING);
start_timers = callback_timer.register_timer(StartTimers, 2000, etl::timer::mode::SINGLE_SHOT);
swap_timers = callback_timer.register_timer(SwapTimers, 1500, etl::timer::mode::SINGLE_SHOT);
SysTick_Config(SystemCoreClock / 1000);
callback_timer.enable(true);
callback_timer.start(start_timers);
while (true)
{
__NOP();
}
}
extern "C"
{
void SysTick_Handler()
{
const uint32_t TICK = 1;
static uint32_t nticks = TICK;
if (callback_timer.tick(nticks))
{
nticks = TICK;
}
else
{
nticks += TICK;
}
}
}

View File

@ -0,0 +1,48 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2017 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef __ETL_PROFILE_H__
#define __ETL_PROFILE_H__
#define ETL_THROW_EXCEPTIONS
#define ETL_VERBOSE_ERRORS
#define ETL_CHECK_PUSH_POP
#define ETL_ISTRING_REPAIR_ENABLE
#define ETL_IVECTOR_REPAIR_ENABLE
#define ETL_IDEQUE_REPAIR_ENABLE
#define ETL_IN_UNIT_TEST
#ifdef _MSC_VER
#include "profiles/msvc_x86.h"
#else
#include "profiles/gcc_windows_x86.h"
#endif
#endif

View File

@ -1,3 +0,0 @@
#define ETL_THROW_EXCEPTIONS
#define ETL_VERBOSE_ERRORS

View File

@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26730.16
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FunctionInterruptSimulation", "FunctionInterruptSimulation.vcxproj", "{2873A2D7-5112-4941-83AA-F98751BE5289}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FunctionInterruptSimulation", "FunctionInterruptSimulation.vcxproj", "{5157DB15-C255-4E47-9FB1-AF388437F90F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -13,19 +13,19 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2873A2D7-5112-4941-83AA-F98751BE5289}.Debug|x64.ActiveCfg = Debug|x64
{2873A2D7-5112-4941-83AA-F98751BE5289}.Debug|x64.Build.0 = Debug|x64
{2873A2D7-5112-4941-83AA-F98751BE5289}.Debug|x86.ActiveCfg = Debug|Win32
{2873A2D7-5112-4941-83AA-F98751BE5289}.Debug|x86.Build.0 = Debug|Win32
{2873A2D7-5112-4941-83AA-F98751BE5289}.Release|x64.ActiveCfg = Release|x64
{2873A2D7-5112-4941-83AA-F98751BE5289}.Release|x64.Build.0 = Release|x64
{2873A2D7-5112-4941-83AA-F98751BE5289}.Release|x86.ActiveCfg = Release|Win32
{2873A2D7-5112-4941-83AA-F98751BE5289}.Release|x86.Build.0 = Release|Win32
{5157DB15-C255-4E47-9FB1-AF388437F90F}.Debug|x64.ActiveCfg = Debug|x64
{5157DB15-C255-4E47-9FB1-AF388437F90F}.Debug|x64.Build.0 = Debug|x64
{5157DB15-C255-4E47-9FB1-AF388437F90F}.Debug|x86.ActiveCfg = Debug|Win32
{5157DB15-C255-4E47-9FB1-AF388437F90F}.Debug|x86.Build.0 = Debug|Win32
{5157DB15-C255-4E47-9FB1-AF388437F90F}.Release|x64.ActiveCfg = Release|x64
{5157DB15-C255-4E47-9FB1-AF388437F90F}.Release|x64.Build.0 = Release|x64
{5157DB15-C255-4E47-9FB1-AF388437F90F}.Release|x86.ActiveCfg = Release|Win32
{5157DB15-C255-4E47-9FB1-AF388437F90F}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C8193019-E546-4904-A25F-27FC525CC526}
SolutionGuid = {260225EB-60CB-44CC-A60C-16A23BBC10EB}
EndGlobalSection
EndGlobal

View File

@ -18,9 +18,15 @@
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\FunctionInterruptSimulation.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\etl_profile.h" />
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{2873A2D7-5112-4941-83AA-F98751BE5289}</ProjectGuid>
<ProjectGuid>{5157DB15-C255-4E47-9FB1-AF388437F90F}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>FunctionInterruptSimulation</RootNamespace>
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
@ -89,6 +95,7 @@
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>../../../src</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -97,12 +104,12 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>../../../src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>../../../src</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -143,12 +150,6 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\FunctionInterruptSimulation.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\etl_user.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>

View File

@ -20,7 +20,7 @@
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\etl_user.h">
<ClInclude Include="..\etl_profile.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>

View File

@ -0,0 +1,164 @@
#include "queue.h"
#include "message_router.h"
#include <iostream>
#include <string>
//*****************************************************************************
// The messages.
//*****************************************************************************
struct Message1 : public etl::message<1>
{
Message1(int i_)
: i(i_)
{
}
int i;
};
struct Message2 : public etl::message<2>
{
Message2(double d_)
: d(d_)
{
}
double d;
};
struct Message3 : public etl::message<3>
{
Message3(const std::string& s_)
: s(s_)
{
}
std::string s;
};
struct Message4 : public etl::message<4>
{
};
//*****************************************************************************
// The message router.
// Handles message types Message1, Message2, Message3.
//*****************************************************************************
class Router : public etl::message_router<Router, Message1, Message2, Message3>
{
public:
typedef etl::message_router<Router, Message1, Message2, Message3> Base_t;
using Base_t::receive;
//***************************************************************************
Router()
: message_router(1)
{
}
//***************************************************************************
// Override the base class's receive function.
void receive(etl::imessage_router& sender_, const etl::imessage& msg_)
{
if (accepts(msg_))
{
// Place in queue.
queue.emplace(&sender_, msg_);
std::cout << "Queueing message " << int(msg_.message_id) << std::endl;
}
else
{
std::cout << "Ignoring message " << int(msg_.message_id) << std::endl;
}
}
//***************************************************************************
void process_queue()
{
while (!queue.empty())
{
Item& item = queue.front();
etl::imessage& msg = item.packet.get();
etl::imessage_router& sender = *item.sender;
std::cout << "Processing message " << int(msg.message_id) << std::endl;
// Call the base class's receive function.
// This will route it to the correct on_receive handler.
Base_t::receive(sender, msg);
queue.pop();
}
}
//***************************************************************************
void on_receive(etl::imessage_router& sender, const Message1& msg)
{
std::cout << " Received message " << int(msg.message_id) << " : '" << msg.i << "'" << std::endl;
}
//***************************************************************************
void on_receive(etl::imessage_router& sender, const Message2& msg)
{
std::cout << " Received message " << int(msg.message_id) << " : '" << msg.d << "'" << std::endl;
}
//***************************************************************************
void on_receive(etl::imessage_router& sender, const Message3& msg)
{
std::cout << " Received message " << int(msg.message_id) << " : '" << msg.s << "'" << std::endl;
}
//***************************************************************************
void on_receive_unknown(etl::imessage_router& sender, const etl::imessage& msg)
{
std::cout << " Received unknown message " << int(msg.message_id) << std::endl;
}
private:
struct Item
{
Item(etl::imessage_router* sender_, const etl::imessage& msg_)
: sender(sender_),
packet(msg_)
{
}
etl::imessage_router* sender;
message_packet packet;
};
etl::queue<Item, 10> queue;
};
//*****************************************************************************
// The test application.
//*****************************************************************************
int main()
{
Router router;
Message1 m1(1);
Message2 m2(1.2);
Message3 m3("Hello");
etl::send_message(router, m1);
etl::send_message(router, Message1(2));
etl::send_message(router, m2);
etl::send_message(router, Message2(3.4));
etl::send_message(router, m3);
etl::send_message(router, Message3("World"));
etl::send_message(router, Message4());
std::cout << std::endl;
router.process_queue();
return 0;
}

View File

@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26730.10
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QueuedMessageRouter", "QueuedMessageRouter.vcxproj", "{2BB47D48-5EFC-4C38-B2BE-002172F00E3B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2BB47D48-5EFC-4C38-B2BE-002172F00E3B}.Debug|x64.ActiveCfg = Debug|x64
{2BB47D48-5EFC-4C38-B2BE-002172F00E3B}.Debug|x64.Build.0 = Debug|x64
{2BB47D48-5EFC-4C38-B2BE-002172F00E3B}.Debug|x86.ActiveCfg = Debug|Win32
{2BB47D48-5EFC-4C38-B2BE-002172F00E3B}.Debug|x86.Build.0 = Debug|Win32
{2BB47D48-5EFC-4C38-B2BE-002172F00E3B}.Release|x64.ActiveCfg = Release|x64
{2BB47D48-5EFC-4C38-B2BE-002172F00E3B}.Release|x64.Build.0 = Release|x64
{2BB47D48-5EFC-4C38-B2BE-002172F00E3B}.Release|x86.ActiveCfg = Release|Win32
{2BB47D48-5EFC-4C38-B2BE-002172F00E3B}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {98B87835-6672-45D4-95BF-CC5C22C87D2C}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,157 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{2BB47D48-5EFC-4C38-B2BE-002172F00E3B}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>QueuedMessageRouter</RootNamespace>
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>../../../src;../vs2017</AdditionalIncludeDirectories>
<PrecompiledHeaderFile />
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\QueuedMessageRouter.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="etl_profile.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\QueuedMessageRouter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="etl_profile.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -0,0 +1,48 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2017 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef __ETL_PROFILE_H__
#define __ETL_PROFILE_H__
#define ETL_THROW_EXCEPTIONS
#define ETL_VERBOSE_ERRORS
#define ETL_CHECK_PUSH_POP
#define ETL_ISTRING_REPAIR_ENABLE
#define ETL_IVECTOR_REPAIR_ENABLE
#define ETL_IDEQUE_REPAIR_ENABLE
#define ETL_IN_UNIT_TEST
#ifdef _MSC_VER
#include "profiles/msvc_x86.h"
#else
#include "profiles/gcc_windows_x86.h"
#endif
#endif

View File

@ -1,9 +1,9 @@
name=Embedded Template Library
version=9.6.1
version=10.0.0
author= John Wellbelove <john.wellbelove@etlcpp.com>
maintainer=John Wellbelove <john.wellbelove@etlcpp.com>
sentence=A C++ template library tailored for embedded systems.
paragraph=Requires some support from STL. See http://andybrown.me.uk/2011/01/15/the-standard-template-library-stl-for-avr-with-c-streams/
paragraph=Requires some support from STL. See http://andybrown.me.uk/2011/01/15/the-standard-template-library-stl-for-avr-with-c-streams/ or https://github.com/mike-matera/ArduinoSTL.git for Arduino.
category=Other
url=http://www.etlcpp.com/
url=https://www.etlcpp.com/
architectures=*

View File

@ -43,6 +43,7 @@ SOFTWARE.
#include <iterator>
#include <stdint.h>
#include "platform.h"
#include "iterator.h"
#include "type_traits.h"

View File

@ -33,6 +33,7 @@ SOFTWARE.
#include <stdint.h>
#include "platform.h"
#include "type_traits.h"
#include "static_assert.h"

View File

@ -36,6 +36,7 @@ SOFTWARE.
#include <algorithm>
#include <stddef.h>
#include "platform.h"
#include "exception.h"
#include "type_traits.h"
#include "parameter_type.h"

51
src/atomic.h Normal file
View File

@ -0,0 +1,51 @@
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2017 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef __ETL_ATOMIC__
#define __ETL_ATOMIC__
#include "platform.h"
#if ETL_ATOMIC_SUPPORTED == 1
#include <atomic>
namespace etl
{
typedef std::atomic<uint32_t> atomic_uint32_t;
}
#elif defined(ETL_COMPILER_ARM)
#include "atomic/atomic_arm.h"
#elif defined(ETL_COMPILER_GCC)
#include "atomic/atomic_gcc.h"
#elif defined(ETL_COMPILER_MSVC)
#include "atomic/atomic_windows.h"
#else
#warning NO ATOMIC SUPPORT DEFINED!
#endif
#endif

613
src/atomic/atomic_arm.h Normal file
View File

@ -0,0 +1,613 @@
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2017 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef __ETL_ATOMIC_ARM__
#define __ETL_ATOMIC_ARM__
#include "../platform.h"
#include "../type_traits.h"
#include "../char_traits.h"
#include "../static_assert.h"
#include "../nullptr.h"
#include <stdint.h>
namespace etl
{
//***************************************************************************
// Atomic type for pre C++11 GCC compilers that support the builtin 'fetch' functions.
// Only integral and pointer types are supported.
//***************************************************************************
template <typename T>
class atomic
{
public:
STATIC_ASSERT(etl::is_integral<T>::value, "Only integral types are supported");
atomic()
: value(0)
{
}
atomic(T v)
: value(v)
{
}
// Assignment
T operator =(T v)
{
__sync_lock_test_and_set(&value, v);
return v;
}
T operator =(T v) volatile
{
__sync_lock_test_and_set(&value, v);
return v;
}
// Pre-increment
T operator ++()
{
return fetch_add(1) + 1;
}
T operator ++() volatile
{
return fetch_add(1) + 1;
}
// Post-increment
T operator ++(int)
{
return fetch_add(1);
}
T operator ++(int) volatile
{
return fetch_add(1);
}
// Pre-decrement
T operator --()
{
return fetch_sub(1) + 1;
}
T operator --() volatile
{
return fetch_sub(1) + 1;
}
// Post-decrement
T operator --(int)
{
return fetch_sub(1);
}
T operator --(int) volatile
{
return fetch_sub(1);
}
// Add
T operator +=(T v)
{
return fetch_add(v) + v;
}
T operator +=(T v) volatile
{
return fetch_add(v) + v;
}
// Subtract
T operator -=(T v)
{
return fetch_sub(v) - v;
}
T operator -=(T v) volatile
{
return fetch_sub(v) - v;
}
// And
T operator &=(T v)
{
return fetch_and(v) & v;
}
T operator &=(T v) volatile
{
return fetch_and(v) & v;
}
// Or
T operator |=(T v)
{
return fetch_or(v) | v;
}
T operator |=(T v) volatile
{
return fetch_or(v) | v;
}
// Exclusive or
T operator ^=(T v)
{
return fetch_xor(v) ^ v;
}
T operator ^=(T v) volatile
{
return fetch_xor(v) ^ v;
}
// Conversion operator
operator T () const
{
return __sync_fetch_and_add(const_cast<T*>(&value), 0);
}
operator T() volatile const
{
return __sync_fetch_and_add(const_cast<T*>(&value), 0);
}
// Is lock free?
bool is_lock_free() const
{
return true;
}
bool is_lock_free() const volatile
{
return true;
}
// Store
void store(T v)
{
__sync_lock_test_and_set(&value, v);
}
void store(T v) volatile
{
__sync_lock_test_and_set(&value, v);
}
// Load
T load()
{
return __sync_fetch_and_add(&value, 0);
}
T load() volatile
{
return __sync_fetch_and_add(&value, 0);
}
// Fetch add
T fetch_add(T v)
{
return __sync_fetch_and_add(&value, v);
}
T fetch_add(T v) volatile
{
return __sync_fetch_and_add(&value, v);
}
// Fetch subtract
T fetch_sub(T v)
{
return __sync_fetch_and_sub(&value, v);
}
T fetch_sub(T v) volatile
{
return __sync_fetch_and_sub(&value, v);
}
// Fetch or
T fetch_or(T v)
{
return __sync_fetch_and_or(&value, v);
}
T fetch_or(T v) volatile
{
return __sync_fetch_and_or(&value, v);
}
// Fetch and
T fetch_and(T v)
{
return __sync_fetch_and_and(&value, v);
}
T fetch_and(T v) volatile
{
return __sync_fetch_and_and(&value, v);
}
// Fetch exclusive or
T fetch_xor(T v)
{
return __sync_fetch_and_xor(&value, v);
}
T fetch_xor(T v) volatile
{
return __sync_fetch_and_xor(&value, v);
}
// Exchange
T exchange(T v)
{
return __sync_lock_test_and_set(&value, v);
}
T exchange(T v) volatile
{
return __sync_lock_test_and_set(&value, v);
}
// Compare exchange weak
bool compare_exchange_weak(T& expected, T desired)
{
return __sync_bool_compare_and_swap(&value, expected, desired);
}
bool compare_exchange_weak(T& expected, T desired) volatile
{
return __sync_bool_compare_and_swap(&value, expected, desired);
}
// Compare exchange strong
bool compare_exchange_strong(T& expected, T desired)
{
T old = expected;
while (!compare_exchange_weak(old, desired))
{
if (memcmp(&old, &expected, sizeof(T)))
{
expected = old;
return false;
}
}
return true;
}
bool compare_exchange_strong(T& expected, T desired) volatile
{
T old = expected;
while (!compare_exchange_weak(old, desired))
{
if (memcmp(&old, &expected, sizeof(T)))
{
expected = old;
return false;
}
}
return true;
}
private:
atomic& operator =(const atomic&);
atomic& operator =(const atomic&) volatile;
T value;
};
//***************************************************************************
// Specialisation for pointers.
//***************************************************************************
template <typename T>
class atomic<T*>
{
public:
atomic()
: value(nullptr)
{
}
atomic(T v)
: value(v)
{
}
// Assignment
T operator =(T* v)
{
__sync_lock_test_and_set(&value, v);
return v;
}
T operator =(T* v) volatile
{
__sync_lock_test_and_set(&value, v);
return v;
}
// Pre-increment
T operator ++()
{
return fetch_add(1) + 1;
}
T operator ++() volatile
{
return fetch_add(1) + 1;
}
// Post-increment
T operator ++(int)
{
return fetch_add(1);
}
T operator ++(int) volatile
{
return fetch_add(1);
}
// Pre-decrement
T operator --()
{
return fetch_sub(1) + 1;
}
T operator --() volatile
{
return fetch_sub(1) + 1;
}
// Post-decrement
T operator --(int)
{
return fetch_sub(1);
}
T operator --(int) volatile
{
return fetch_sub(1);
}
// Add
T* operator +=(std::ptrdiff_t v)
{
return fetch_add(v) + v;
}
T* operator +=(std::ptrdiff_t v) volatile
{
return fetch_add(v) + v;
}
// Subtract
T* operator -=(std::ptrdiff_t v)
{
return fetch_sub(v) - v;
}
T* operator -=(std::ptrdiff_t v) volatile
{
return fetch_sub(v) - v;
}
// Conversion operator
operator T () const
{
return __sync_fetch_and_add(const_cast<T**>(&value), 0);
}
operator T() volatile const
{
return __sync_fetch_and_add(const_cast<T**>(&value), 0);
}
// Is lock free?
bool is_lock_free() const
{
return true;
}
bool is_lock_free() const volatile
{
return true;
}
// Store
void store(T v)
{
__sync_lock_test_and_set(&value, v);
}
void store(T v) volatile
{
__sync_lock_test_and_set(&value, v);
}
// Load
T load()
{
return __sync_fetch_and_add(&value, 0);
}
T load() volatile
{
return __sync_fetch_and_add(&value, 0);
}
// Fetch add
T* fetch_add(std::ptrdiff_t v)
{
return __sync_fetch_and_add(&value, v);
}
T* fetch_add(std::ptrdiff_t v) volatile
{
return __sync_fetch_and_add(&value, v);
}
// Fetch subtract
T* fetch_sub(std::ptrdiff_t v)
{
return __sync_fetch_and_sub(&value, v);
}
T* fetch_sub(std::ptrdiff_t v) volatile
{
return __sync_fetch_and_sub(&value, v);
}
// Exchange
T exchange(T v)
{
return __sync_lock_test_and_set(&value, v);
}
T exchange(T v) volatile
{
return __sync_lock_test_and_set(&value, v);
}
// Compare exchange weak
bool compare_exchange_weak(T& expected, T desired)
{
return __sync_bool_compare_and_swap(&value, expected, desired);
}
bool compare_exchange_weak(T& expected, T desired) volatile
{
return __sync_bool_compare_and_swap(&value, expected, desired);
}
// Compare exchange strong
bool compare_exchange_strong(T& expected, T desired)
{
T old = expected;
while (!compare_exchange_weak(old, desired))
{
if (memcmp(&old, &expected, sizeof(T)))
{
expected = old;
return false;
}
}
return true;
}
bool compare_exchange_strong(T& expected, T desired) volatile
{
T old = expected;
while (!compare_exchange_weak(old, desired))
{
if (memcmp(&old, &expected, sizeof(T)))
{
expected = old;
return false;
}
}
return true;
}
private:
atomic& operator =(const atomic&);
atomic& operator =(const atomic&) volatile;
T* value;
};
typedef etl::atomic<char> atomic_char;
typedef etl::atomic<signed char> atomic_schar;
typedef etl::atomic<unsigned char> atomic_uchar;
typedef etl::atomic<short> atomic_short;
typedef etl::atomic<unsigned short> atomic_ushort;
typedef etl::atomic<int> atomic_int;
typedef etl::atomic<unsigned int> atomic_uint;
typedef etl::atomic<long> atomic_long;
typedef etl::atomic<unsigned long> atomic_ulong;
typedef etl::atomic<long long> atomic_llong;
typedef etl::atomic<unsigned long long> atomic_ullong;
typedef etl::atomic<wchar_t> atomic_wchar_t;
typedef etl::atomic<char16_t> atomic_char16_t;
typedef etl::atomic<char32_t> atomic_char32_t;
typedef etl::atomic<uint8_t> atomic_uint8_t;
typedef etl::atomic<int8_t> atomic_int8_t;
typedef etl::atomic<uint16_t> atomic_uint16_t;
typedef etl::atomic<int16_t> atomic_int16_t;
typedef etl::atomic<uint32_t> atomic_uint32_t;
typedef etl::atomic<int32_t> atomic_int32_t;
typedef etl::atomic<uint64_t> atomic_uint64_t;
typedef etl::atomic<int64_t> atomic_int64_t;
typedef etl::atomic<int_least8_t> atomic_int_least8_t;
typedef etl::atomic<uint_least8_t> atomic_uint_least8_t;
typedef etl::atomic<int_least16_t> atomic_int_least16_t;
typedef etl::atomic<uint_least16_t> atomic_uint_least16_t;
typedef etl::atomic<int_least32_t> atomic_int_least32_t;
typedef etl::atomic<uint_least32_t> atomic_uint_least32_t;
typedef etl::atomic<int_least64_t> atomic_int_least64_t;
typedef etl::atomic<uint_least64_t> atomic_uint_least64_t;
typedef etl::atomic<int_fast8_t> atomic_int_fast8_t;
typedef etl::atomic<uint_fast8_t> atomic_uint_fast8_t;
typedef etl::atomic<int_fast16_t> atomic_int_fast16_t;
typedef etl::atomic<uint_fast16_t> atomic_uint_fast16_t;
typedef etl::atomic<int_fast32_t> atomic_int_fast32_t;
typedef etl::atomic<uint_fast32_t> atomic_uint_fast32_t;
typedef etl::atomic<int_fast64_t> atomic_int_fast64_t;
typedef etl::atomic<uint_fast64_t> atomic_uint_fast64_t;
typedef etl::atomic<intptr_t> atomic_intptr_t;
typedef etl::atomic<uintptr_t> atomic_uintptr_t;
typedef etl::atomic<size_t> atomic_size_t;
typedef etl::atomic<ptrdiff_t> atomic_ptrdiff_t;
typedef etl::atomic<intmax_t> atomic_intmax_t;
typedef etl::atomic<uintmax_t> atomic_uintmax_t;
}
#endif

613
src/atomic/atomic_gcc.h Normal file
View File

@ -0,0 +1,613 @@
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2017 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef __ETL_ATOMIC_GCC__
#define __ETL_ATOMIC_GCC__
#include "../platform.h"
#include "../type_traits.h"
#include "../char_traits.h"
#include "../static_assert.h"
#include "../nullptr.h"
#include <stdint.h>
namespace etl
{
//***************************************************************************
// Atomic type for pre C++11 GCC compilers that support the builtin 'fetch' functions.
// Only integral and pointer types are supported.
//***************************************************************************
template <typename T>
class atomic
{
public:
STATIC_ASSERT(etl::is_integral<T>::value, "Only integral types are supported");
atomic()
: value(0)
{
}
atomic(T v)
: value(v)
{
}
// Assignment
T operator =(T v)
{
__sync_lock_test_and_set(&value, v);
return v;
}
T operator =(T v) volatile
{
__sync_lock_test_and_set(&value, v);
return v;
}
// Pre-increment
T operator ++()
{
return fetch_add(1) + 1;
}
T operator ++() volatile
{
return fetch_add(1) + 1;
}
// Post-increment
T operator ++(int)
{
return fetch_add(1);
}
T operator ++(int) volatile
{
return fetch_add(1);
}
// Pre-decrement
T operator --()
{
return fetch_sub(1) + 1;
}
T operator --() volatile
{
return fetch_sub(1) + 1;
}
// Post-decrement
T operator --(int)
{
return fetch_sub(1);
}
T operator --(int) volatile
{
return fetch_sub(1);
}
// Add
T operator +=(T v)
{
return fetch_add(v) + v;
}
T operator +=(T v) volatile
{
return fetch_add(v) + v;
}
// Subtract
T operator -=(T v)
{
return fetch_sub(v) - v;
}
T operator -=(T v) volatile
{
return fetch_sub(v) - v;
}
// And
T operator &=(T v)
{
return fetch_and(v) & v;
}
T operator &=(T v) volatile
{
return fetch_and(v) & v;
}
// Or
T operator |=(T v)
{
return fetch_or(v) | v;
}
T operator |=(T v) volatile
{
return fetch_or(v) | v;
}
// Exclusive or
T operator ^=(T v)
{
return fetch_xor(v) ^ v;
}
T operator ^=(T v) volatile
{
return fetch_xor(v) ^ v;
}
// Conversion operator
operator T () const
{
return __sync_fetch_and_add(const_cast<T*>(&value), 0);
}
operator T() volatile const
{
return __sync_fetch_and_add(const_cast<T*>(&value), 0);
}
// Is lock free?
bool is_lock_free() const
{
return true;
}
bool is_lock_free() const volatile
{
return true;
}
// Store
void store(T v)
{
__sync_lock_test_and_set(&value, v);
}
void store(T v) volatile
{
__sync_lock_test_and_set(&value, v);
}
// Load
T load()
{
return __sync_fetch_and_add(&value, 0);
}
T load() volatile
{
return __sync_fetch_and_add(&value, 0);
}
// Fetch add
T fetch_add(T v)
{
return __sync_fetch_and_add(&value, v);
}
T fetch_add(T v) volatile
{
return __sync_fetch_and_add(&value, v);
}
// Fetch subtract
T fetch_sub(T v)
{
return __sync_fetch_and_sub(&value, v);
}
T fetch_sub(T v) volatile
{
return __sync_fetch_and_sub(&value, v);
}
// Fetch or
T fetch_or(T v)
{
return __sync_fetch_and_or(&value, v);
}
T fetch_or(T v) volatile
{
return __sync_fetch_and_or(&value, v);
}
// Fetch and
T fetch_and(T v)
{
return __sync_fetch_and_and(&value, v);
}
T fetch_and(T v) volatile
{
return __sync_fetch_and_and(&value, v);
}
// Fetch exclusive or
T fetch_xor(T v)
{
return __sync_fetch_and_xor(&value, v);
}
T fetch_xor(T v) volatile
{
return __sync_fetch_and_xor(&value, v);
}
// Exchange
T exchange(T v)
{
return __sync_lock_test_and_set(&value, v);
}
T exchange(T v) volatile
{
return __sync_lock_test_and_set(&value, v);
}
// Compare exchange weak
bool compare_exchange_weak(T& expected, T desired)
{
return __sync_bool_compare_and_swap(&value, expected, desired);
}
bool compare_exchange_weak(T& expected, T desired) volatile
{
return __sync_bool_compare_and_swap(&value, expected, desired);
}
// Compare exchange strong
bool compare_exchange_strong(T& expected, T desired)
{
T old = expected;
while (!compare_exchange_weak(old, desired))
{
if (memcmp(&old, &expected, sizeof(T)))
{
expected = old;
return false;
}
}
return true;
}
bool compare_exchange_strong(T& expected, T desired) volatile
{
T old = expected;
while (!compare_exchange_weak(old, desired))
{
if (memcmp(&old, &expected, sizeof(T)))
{
expected = old;
return false;
}
}
return true;
}
private:
atomic& operator =(const atomic&);
atomic& operator =(const atomic&) volatile;
T value;
};
//***************************************************************************
// Specialisation for pointers.
//***************************************************************************
template <typename T>
class atomic<T*>
{
public:
atomic()
: value(nullptr)
{
}
atomic(T v)
: value(v)
{
}
// Assignment
T operator =(T* v)
{
__sync_lock_test_and_set(&value, v);
return v;
}
T operator =(T* v) volatile
{
__sync_lock_test_and_set(&value, v);
return v;
}
// Pre-increment
T operator ++()
{
return fetch_add(1) + 1;
}
T operator ++() volatile
{
return fetch_add(1) + 1;
}
// Post-increment
T operator ++(int)
{
return fetch_add(1);
}
T operator ++(int) volatile
{
return fetch_add(1);
}
// Pre-decrement
T operator --()
{
return fetch_sub(1) + 1;
}
T operator --() volatile
{
return fetch_sub(1) + 1;
}
// Post-decrement
T operator --(int)
{
return fetch_sub(1);
}
T operator --(int) volatile
{
return fetch_sub(1);
}
// Add
T* operator +=(std::ptrdiff_t v)
{
return fetch_add(v) + v;
}
T* operator +=(std::ptrdiff_t v) volatile
{
return fetch_add(v) + v;
}
// Subtract
T* operator -=(std::ptrdiff_t v)
{
return fetch_sub(v) - v;
}
T* operator -=(std::ptrdiff_t v) volatile
{
return fetch_sub(v) - v;
}
// Conversion operator
operator T () const
{
return __sync_fetch_and_add(const_cast<T**>(&value), 0);
}
operator T() volatile const
{
return __sync_fetch_and_add(const_cast<T**>(&value), 0);
}
// Is lock free?
bool is_lock_free() const
{
return true;
}
bool is_lock_free() const volatile
{
return true;
}
// Store
void store(T v)
{
__sync_lock_test_and_set(&value, v);
}
void store(T v) volatile
{
__sync_lock_test_and_set(&value, v);
}
// Load
T load()
{
return __sync_fetch_and_add(&value, 0);
}
T load() volatile
{
return __sync_fetch_and_add(&value, 0);
}
// Fetch add
T* fetch_add(std::ptrdiff_t v)
{
return __sync_fetch_and_add(&value, v);
}
T* fetch_add(std::ptrdiff_t v) volatile
{
return __sync_fetch_and_add(&value, v);
}
// Fetch subtract
T* fetch_sub(std::ptrdiff_t v)
{
return __sync_fetch_and_sub(&value, v);
}
T* fetch_sub(std::ptrdiff_t v) volatile
{
return __sync_fetch_and_sub(&value, v);
}
// Exchange
T exchange(T v)
{
return __sync_lock_test_and_set(&value, v);
}
T exchange(T v) volatile
{
return __sync_lock_test_and_set(&value, v);
}
// Compare exchange weak
bool compare_exchange_weak(T& expected, T desired)
{
return __sync_bool_compare_and_swap(&value, expected, desired);
}
bool compare_exchange_weak(T& expected, T desired) volatile
{
return __sync_bool_compare_and_swap(&value, expected, desired);
}
// Compare exchange strong
bool compare_exchange_strong(T& expected, T desired)
{
T old = expected;
while (!compare_exchange_weak(old, desired))
{
if (memcmp(&old, &expected, sizeof(T)))
{
expected = old;
return false;
}
}
return true;
}
bool compare_exchange_strong(T& expected, T desired) volatile
{
T old = expected;
while (!compare_exchange_weak(old, desired))
{
if (memcmp(&old, &expected, sizeof(T)))
{
expected = old;
return false;
}
}
return true;
}
private:
atomic& operator =(const atomic&);
atomic& operator =(const atomic&) volatile;
T* value;
};
typedef etl::atomic<char> atomic_char;
typedef etl::atomic<signed char> atomic_schar;
typedef etl::atomic<unsigned char> atomic_uchar;
typedef etl::atomic<short> atomic_short;
typedef etl::atomic<unsigned short> atomic_ushort;
typedef etl::atomic<int> atomic_int;
typedef etl::atomic<unsigned int> atomic_uint;
typedef etl::atomic<long> atomic_long;
typedef etl::atomic<unsigned long> atomic_ulong;
typedef etl::atomic<long long> atomic_llong;
typedef etl::atomic<unsigned long long> atomic_ullong;
typedef etl::atomic<wchar_t> atomic_wchar_t;
typedef etl::atomic<char16_t> atomic_char16_t;
typedef etl::atomic<char32_t> atomic_char32_t;
typedef etl::atomic<uint8_t> atomic_uint8_t;
typedef etl::atomic<int8_t> atomic_int8_t;
typedef etl::atomic<uint16_t> atomic_uint16_t;
typedef etl::atomic<int16_t> atomic_int16_t;
typedef etl::atomic<uint32_t> atomic_uint32_t;
typedef etl::atomic<int32_t> atomic_int32_t;
typedef etl::atomic<uint64_t> atomic_uint64_t;
typedef etl::atomic<int64_t> atomic_int64_t;
typedef etl::atomic<int_least8_t> atomic_int_least8_t;
typedef etl::atomic<uint_least8_t> atomic_uint_least8_t;
typedef etl::atomic<int_least16_t> atomic_int_least16_t;
typedef etl::atomic<uint_least16_t> atomic_uint_least16_t;
typedef etl::atomic<int_least32_t> atomic_int_least32_t;
typedef etl::atomic<uint_least32_t> atomic_uint_least32_t;
typedef etl::atomic<int_least64_t> atomic_int_least64_t;
typedef etl::atomic<uint_least64_t> atomic_uint_least64_t;
typedef etl::atomic<int_fast8_t> atomic_int_fast8_t;
typedef etl::atomic<uint_fast8_t> atomic_uint_fast8_t;
typedef etl::atomic<int_fast16_t> atomic_int_fast16_t;
typedef etl::atomic<uint_fast16_t> atomic_uint_fast16_t;
typedef etl::atomic<int_fast32_t> atomic_int_fast32_t;
typedef etl::atomic<uint_fast32_t> atomic_uint_fast32_t;
typedef etl::atomic<int_fast64_t> atomic_int_fast64_t;
typedef etl::atomic<uint_fast64_t> atomic_uint_fast64_t;
typedef etl::atomic<intptr_t> atomic_intptr_t;
typedef etl::atomic<uintptr_t> atomic_uintptr_t;
typedef etl::atomic<size_t> atomic_size_t;
typedef etl::atomic<ptrdiff_t> atomic_ptrdiff_t;
typedef etl::atomic<intmax_t> atomic_intmax_t;
typedef etl::atomic<uintmax_t> atomic_uintmax_t;
}
#endif

104
src/atomic/atomic_windows.h Normal file
View File

@ -0,0 +1,104 @@
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2017 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef __ETL_ATOMIC_WINDOWS__
#define __ETL_ATOMIC_WINDOWS__
#include "../platform.h"
#include <stdint.h>
#include <Windows.h>
namespace etl
{
class atomic_uint32_t
{
public:
atomic_uint32_t()
{
InterlockedExchange(&value, 0);
}
atomic_uint32_t(uint32_t v)
{
InterlockedExchange(&value, v);
}
atomic_uint32_t& operator =(uint32_t v)
{
InterlockedExchange(&value, v);
return *this;
}
atomic_uint32_t& operator ++()
{
InterlockedIncrement(&value);
return *this;
}
volatile atomic_uint32_t& operator ++() volatile
{
InterlockedIncrement(&value);
return *this;
}
atomic_uint32_t& operator --()
{
InterlockedDecrement(&value);
return *this;
}
volatile atomic_uint32_t& operator --() volatile
{
InterlockedDecrement(&value);
return *this;
}
operator uint32_t () const
{
return InterlockedAdd((volatile long*)&value, 0);
}
operator uint32_t() volatile const
{
return InterlockedAdd((volatile long*)&value, 0);
}
private:
uint32_t value;
};
}
#endif

View File

@ -38,6 +38,7 @@ SOFTWARE.
#include <limits>
#include <assert.h>
#include "platform.h"
#include "type_traits.h"
#include "integral_limits.h"
#include "static_assert.h"

View File

@ -31,6 +31,7 @@ SOFTWARE.
#ifndef __ETL_BLOOM_FILTER__
#define __ETL_BLOOM_FILTER__
#include "platform.h"
#include "parameter_type.h"
#include "bitset.h"
#include "type_traits.h"

684
src/callback_timer.h Normal file
View File

@ -0,0 +1,684 @@
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2017 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef __ETL_CALLBACK_TIMER__
#define __ETL_CALLBACK_TIMER__
#include <stdint.h>
#include <algorithm>
#include "platform.h"
#include "nullptr.h"
#include "function.h"
#include "static_assert.h"
#include "timer.h"
#include "atomic.h"
#undef ETL_FILE
#define ETL_FILE "42"
namespace etl
{
//*************************************************************************
/// The configuration of a timer.
struct callback_timer_data
{
//*******************************************
callback_timer_data()
: p_callback(nullptr),
period(0),
delta(etl::timer::state::INACTIVE),
id(etl::timer::id::NO_TIMER),
previous(etl::timer::id::NO_TIMER),
next(etl::timer::id::NO_TIMER),
repeating(true),
is_c_callback(true)
{
}
//*******************************************
/// C function callback
//*******************************************
callback_timer_data(etl::timer::id::type id_,
void (*p_callback_)(),
uint32_t period_,
bool repeating_)
: p_callback(reinterpret_cast<void*>(p_callback_)),
period(period_),
delta(etl::timer::state::INACTIVE),
id(id_),
previous(etl::timer::id::NO_TIMER),
next(etl::timer::id::NO_TIMER),
repeating(repeating_),
is_c_callback(true)
{
}
//*******************************************
/// ETL function callback
//*******************************************
callback_timer_data(etl::timer::id::type id_,
etl::ifunction<void>& callback_,
uint32_t period_,
bool repeating_)
: p_callback(reinterpret_cast<void*>(&callback_)),
period(period_),
delta(etl::timer::state::INACTIVE),
id(id_),
previous(etl::timer::id::NO_TIMER),
next(etl::timer::id::NO_TIMER),
repeating(repeating_),
is_c_callback(false)
{
}
//*******************************************
/// Returns true if the timer is active.
//*******************************************
bool is_active() const
{
return delta != etl::timer::state::INACTIVE;
}
//*******************************************
/// Sets the timer to the inactive state.
//*******************************************
void set_inactive()
{
delta = etl::timer::state::INACTIVE;
}
void* p_callback;
uint32_t period;
uint32_t delta;
etl::timer::id::type id;
uint_least8_t previous;
uint_least8_t next;
bool repeating;
bool is_c_callback;
private:
// Disabled.
callback_timer_data(const callback_timer_data& other);
callback_timer_data& operator =(const callback_timer_data& other);
};
namespace __private_callback_timer__
{
//*************************************************************************
/// A specialised intrusive linked list for timer data.
//*************************************************************************
class list
{
public:
//*******************************
list(etl::callback_timer_data* ptimers_)
: head(etl::timer::id::NO_TIMER),
tail(etl::timer::id::NO_TIMER),
current(etl::timer::id::NO_TIMER),
ptimers(ptimers_)
{
}
//*******************************
bool empty() const
{
return head == etl::timer::id::NO_TIMER;
}
//*******************************
// Inserts the timer at the correct delta position
//*******************************
void insert(etl::timer::id::type id_)
{
etl::callback_timer_data& timer = ptimers[id_];
if (head == etl::timer::id::NO_TIMER)
{
// No entries yet.
head = id_;
tail = id_;
timer.previous = etl::timer::id::NO_TIMER;
timer.next = etl::timer::id::NO_TIMER;
}
else
{
// We already have entries.
etl::timer::id::type test_id = begin();
while (test_id != etl::timer::id::NO_TIMER)
{
etl::callback_timer_data& test = ptimers[test_id];
// Find the correct place to insert.
if (timer.delta <= test.delta)
{
if (test.id == head)
{
head = timer.id;
}
// Insert before test.
timer.previous = test.previous;
test.previous = timer.id;
timer.next = test.id;
// Adjust the next delta to compensate.
test.delta -= timer.delta;
if (timer.previous != etl::timer::id::NO_TIMER)
{
ptimers[timer.previous].next = timer.id;
}
break;
}
else
{
timer.delta -= test.delta;
}
test_id = next(test_id);
}
// Reached the end?
if (test_id == etl::timer::id::NO_TIMER)
{
// Tag on to the tail.
ptimers[tail].next = timer.id;
timer.previous = tail;
timer.next = etl::timer::id::NO_TIMER;
tail = timer.id;
}
}
}
//*******************************
void remove(etl::timer::id::type id_, bool has_expired)
{
etl::callback_timer_data& timer = ptimers[id_];
if (head == id_)
{
head = timer.next;
}
else
{
ptimers[timer.previous].next = timer.next;
}
if (tail == id_)
{
tail = timer.previous;
}
else
{
ptimers[timer.next].previous = timer.previous;
}
if (!has_expired)
{
// Adjust the next delta.
if (timer.next != etl::timer::id::NO_TIMER)
{
ptimers[timer.next].delta += timer.delta;
}
}
timer.previous = etl::timer::id::NO_TIMER;
timer.next = etl::timer::id::NO_TIMER;
timer.delta = etl::timer::state::INACTIVE;
}
//*******************************
etl::callback_timer_data& front()
{
return ptimers[head];
}
//*******************************
etl::timer::id::type begin()
{
current = head;
return current;
}
//*******************************
etl::timer::id::type previous(etl::timer::id::type last)
{
current = ptimers[last].previous;
return current;
}
//*******************************
etl::timer::id::type next(etl::timer::id::type last)
{
current = ptimers[last].next;
return current;
}
//*******************************
void clear()
{
etl::timer::id::type id = begin();
while (id != etl::timer::id::NO_TIMER)
{
etl::callback_timer_data& timer = ptimers[id];
id = next(id);
timer.next = etl::timer::id::NO_TIMER;
}
head = etl::timer::id::NO_TIMER;
tail = etl::timer::id::NO_TIMER;
current = etl::timer::id::NO_TIMER;
}
private:
etl::timer::id::type head;
etl::timer::id::type tail;
etl::timer::id::type current;
etl::callback_timer_data* const ptimers;
};
}
//***************************************************************************
/// Interface for callback timer
//***************************************************************************
class icallback_timer
{
public:
//*******************************************
/// Register a timer.
//*******************************************
etl::timer::id::type register_timer(void (*p_callback_)(),
uint32_t period_,
bool repeating_)
{
etl::timer::id::type id = etl::timer::id::NO_TIMER;
disable_timer_updates();
bool is_space = (registered_timers < MAX_TIMERS);
if (is_space)
{
// Search for the free space.
for (uint_least8_t i = 0; i < MAX_TIMERS; ++i)
{
etl::callback_timer_data& timer = timer_array[i];
if (timer.id == etl::timer::id::NO_TIMER)
{
// Create in-place.
new (&timer) callback_timer_data(i, p_callback_, period_, repeating_);
++registered_timers;
id = i;
break;
}
}
}
enable_timer_updates();
return id;
}
//*******************************************
/// Register a timer.
//*******************************************
etl::timer::id::type register_timer(etl::ifunction<void>& callback_,
uint32_t period_,
bool repeating_)
{
etl::timer::id::type id = etl::timer::id::NO_TIMER;
disable_timer_updates();
bool is_space = (registered_timers < MAX_TIMERS);
if (is_space)
{
// Search for the free space.
for (uint_least8_t i = 0; i < MAX_TIMERS; ++i)
{
etl::callback_timer_data& timer = timer_array[i];
if (timer.id == etl::timer::id::NO_TIMER)
{
// Create in-place.
new (&timer) callback_timer_data(i, callback_, period_, repeating_);
++registered_timers;
id = i;
break;
}
}
}
enable_timer_updates();
return id;
}
//*******************************************
/// Unregister a timer.
//*******************************************
bool unregister_timer(etl::timer::id::type id_)
{
bool result = false;
if (id_ != etl::timer::id::NO_TIMER)
{
disable_timer_updates();
etl::callback_timer_data& timer = timer_array[id_];
if (timer.id != etl::timer::id::NO_TIMER)
{
if (timer.is_active())
{
active_list.remove(timer.id, false);
// Reset in-place.
new (&timer) callback_timer_data();
--registered_timers;
result = true;
}
}
enable_timer_updates();
}
return result;
}
//*******************************************
/// Enable/disable the timer.
//*******************************************
void enable(bool state_)
{
enabled = state_;
}
//*******************************************
/// Get the enable/disable state.
//*******************************************
bool is_running() const
{
return enabled;
}
//*******************************************
/// Clears the timer of data.
//*******************************************
void clear()
{
disable_timer_updates();
active_list.clear();
for (int i = 0; i < MAX_TIMERS; ++i)
{
new (&timer_array[i]) callback_timer_data();
}
registered_timers = 0;
tick_count = 0;
enable_timer_updates();
}
//*******************************************
// Called by the timer service to indicate the
// amount of time that has elapsed since the
// last call to 'tick'.
//*******************************************
bool tick(uint32_t count)
{
if (enabled)
{
tick_count += count;
if (process_semaphore == 0)
{
// We have something to do?
while (!active_list.empty() && (tick_count >= active_list.front().delta))
{
etl::callback_timer_data& timer = active_list.front();
tick_count -= timer.delta;
active_list.remove(timer.id, true);
if (timer.repeating)
{
timer.delta = timer.period;
active_list.insert(timer.id);
}
if (timer.p_callback != nullptr)
{
if (timer.is_c_callback)
{
reinterpret_cast<void (*)()>(timer.p_callback)();
}
else
{
(*reinterpret_cast<etl::ifunction<void>*>(timer.p_callback))();
}
}
}
}
}
return enabled;
}
//*******************************************
/// Starts a timer.
//*******************************************
bool start(etl::timer::id::type id_, bool immediate_ = false)
{
bool result = false;
disable_timer_updates();
// Valid timer id?
if (id_ != etl::timer::id::NO_TIMER)
{
etl::callback_timer_data& timer = timer_array[id_];
// Registered timer?
if (timer.id != etl::timer::id::NO_TIMER)
{
// Has a valid period.
if (timer.period != etl::timer::state::INACTIVE)
{
if (timer.is_active())
{
active_list.remove(timer.id, false);
}
timer.delta = tick_count;
if (!immediate_)
{
timer.delta += timer.period;
}
active_list.insert(timer.id);
result = true;
}
}
}
enable_timer_updates();
return result;
}
//*******************************************
/// Stops a timer.
//*******************************************
bool stop(etl::timer::id::type id_)
{
bool result = false;
disable_timer_updates();
// Valid timer id?
if (id_ != etl::timer::id::NO_TIMER)
{
etl::callback_timer_data& timer = timer_array[id_];
// Registered timer?
if (timer.id != etl::timer::id::NO_TIMER)
{
if (timer.is_active())
{
active_list.remove(timer.id, false);
result = true;
}
}
}
enable_timer_updates();
return result;
}
//*******************************************
/// Sets a timer's period.
//*******************************************
bool set_period(etl::timer::id::type id_, uint32_t period_)
{
if (stop(id_))
{
timer_array[id_].period = period_;
return start(id_);
}
return false;
}
//*******************************************
/// Sets a timer's mode.
//*******************************************
bool set_mode(etl::timer::id::type id_, bool repeating_)
{
if (stop(id_))
{
timer_array[id_].repeating = repeating_;
return start(id_);
}
return false;
}
protected:
//*******************************************
/// Constructor.
//*******************************************
icallback_timer(callback_timer_data* const timer_array_, const uint_least8_t MAX_TIMERS_)
: timer_array(timer_array_),
active_list(timer_array_),
enabled(false),
process_semaphore(0),
tick_count(0),
registered_timers(0),
MAX_TIMERS(MAX_TIMERS_)
{
}
private:
//*******************************************
/// Enable timer callback events.
//*******************************************
void enable_timer_updates()
{
--process_semaphore;
}
//*******************************************
/// Disable timer callback events.
//*******************************************
void disable_timer_updates()
{
++process_semaphore;
}
// The array of timer data structures.
callback_timer_data* const timer_array;
// The list of active timers.
__private_callback_timer__::list active_list;
volatile bool enabled;
volatile etl::timer_semaphore_t process_semaphore;
volatile uint32_t tick_count;
volatile uint_least8_t registered_timers;
public:
const uint_least8_t MAX_TIMERS;
};
//***************************************************************************
/// The callback timer
//***************************************************************************
template <const uint_least8_t MAX_TIMERS_>
class callback_timer : public etl::icallback_timer
{
public:
STATIC_ASSERT(MAX_TIMERS_ <= 254, "No more than 254 timers are allowed");
//*******************************************
/// Constructor.
//*******************************************
callback_timer()
: icallback_timer(timer_array, MAX_TIMERS_)
{
}
private:
callback_timer_data timer_array[MAX_TIMERS_];
};
}
#undef ETL_FILE
#endif

View File

@ -29,6 +29,7 @@ SOFTWARE.
#include <stdint.h>
#include "platform.h"
#include "binary.h"
#include "frame_check_sequence.h"

View File

@ -31,6 +31,8 @@ SOFTWARE.
#ifndef __ETL_CONSTANT__
#define __ETL_CONSTANT__
#include "platform.h"
//*****************************************************************************
///\defgroup constant constant
///\ingroup utilities

View File

@ -34,6 +34,8 @@ SOFTWARE.
#include <stddef.h>
#include <iterator>
#include "platform.h"
///\defgroup container container
///\ingroup utilities

View File

@ -30,6 +30,8 @@ SOFTWARE.
#include <stdint.h>
#include "platform.h"
namespace etl
{
//***************************************************************************

View File

@ -30,6 +30,8 @@ SOFTWARE.
#include <stdint.h>
#include "platform.h"
namespace etl
{
//***************************************************************************

View File

@ -30,6 +30,8 @@ SOFTWARE.
#include <stdint.h>
#include "platform.h"
namespace etl
{
//***************************************************************************

View File

@ -30,6 +30,8 @@ SOFTWARE.
#include <stdint.h>
#include "platform.h"
namespace etl
{
//***************************************************************************

View File

@ -30,6 +30,8 @@ SOFTWARE.
#include <stdint.h>
#include "platform.h"
namespace etl
{
//***************************************************************************

View File

@ -39,6 +39,7 @@ SOFTWARE.
#include <algorithm>
#include "platform.h"
#include "static_assert.h"
#include "exception.h"
#include "static_assert.h"

View File

@ -33,6 +33,7 @@ SOFTWARE.
#include <stdint.h>
#include "platform.h"
#include "static_assert.h"
namespace etl

View File

@ -36,6 +36,7 @@ SOFTWARE.
#include <iterator>
#include <algorithm>
#include "platform.h"
#include "container.h"
#include "alignment.h"
#include "array.h"

View File

@ -33,6 +33,7 @@ SOFTWARE.
#include <stdint.h>
#include "platform.h"
#include "enum_type.h"
///\defgroup endian endian

View File

@ -31,6 +31,8 @@ SOFTWARE.
#ifndef __ETL_ENUM_TYPE__
#define __ETL_ENUM_TYPE__
#include "platform.h"
///\defgroup enum_type enum_type
/// Smart enumerations.<br>
/// A method of declaring enumerations that allow grouping within a structure.

View File

@ -28,6 +28,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "platform.h"
#include "error_handler.h"
#include "nullptr.h"

View File

@ -38,6 +38,7 @@ SOFTWARE.
#include <assert.h>
#include "platform.h"
#include "exception.h"
#include "function.h"

View File

@ -31,6 +31,8 @@ SOFTWARE.
#ifndef __ETL_EXCEPTION__
#define __ETL_EXCEPTION__
#include "platform.h"
///\defgroup exception exception
/// The base class for all ETL exceptions.
///\ingroup utilities

View File

@ -33,6 +33,8 @@ SOFTWARE.
#include <stddef.h>
#include "platform.h"
///\defgroup factorial factorial
/// fibonacci<N> : Calculates the Nth factorial value.
///\ingroup maths

View File

@ -31,6 +31,7 @@ SOFTWARE.
#include <stdint.h>
#include "platform.h"
#include "error_handler.h"
#include "exception.h"
#include "largest.h"

View File

@ -33,6 +33,8 @@ SOFTWARE.
#include <stddef.h>
#include "platform.h"
///\defgroup fibonacci fibonacci
/// fibonacci<N> : Calculates the Nth Fibonacci value.
///\ingroup maths

View File

@ -33,6 +33,8 @@ SOFTWARE.
#include <iterator>
#include "platform.h"
///\defgroup iterator Iterator types
namespace etl

View File

@ -36,6 +36,7 @@ SOFTWARE.
#include <functional>
#include <stddef.h>
#include "platform.h"
#include "pool.h"
#include "container.h"
#include "exception.h"

View File

@ -53,6 +53,7 @@ SOFTWARE.
#include <stdint.h>
#include "platform.h"
#include "array.h"
#include "nullptr.h"
#include "error_handler.h"

View File

@ -65,6 +65,7 @@ cog.outl("//********************************************************************
#include <stdint.h>
#include "platform.h"
#include "array.h"
#include "nullptr.h"
#include "error_handler.h"

View File

@ -31,6 +31,8 @@ SOFTWARE.
#ifndef __ETL_FUNCTION__
#define __ETL_FUNCTION__
#include "platform.h"
//*****************************************************************************
///\defgroup function function
/// A set of wrapper templates to allow a member or static function to be called

View File

@ -31,6 +31,8 @@ SOFTWARE.
#ifndef __ETL_FUNCTIONAL__
#define __ETL_FUNCTIONAL__
#include "platform.h"
///\defgroup functional functional
///\ingroup utilities

View File

@ -34,6 +34,8 @@ SOFTWARE.
#include <stdint.h>
#include <stdlib.h>
#include "platform.h"
// The default hash calculation.
#include "fnv_1.h"
#include "type_traits.h"

View File

@ -35,6 +35,7 @@ SOFTWARE.
#ifndef __ETL_ICACHE__
#define __ETL_ICACHE__
#include "platform.h"
#include "function.h"
#include "nullptr.h"

View File

@ -34,6 +34,7 @@ SOFTWARE.
#include <stdint.h>
#include <utility>
#include "platform.h"
#include "exception.h"
#include "error_handler.h"

View File

@ -31,6 +31,8 @@ SOFTWARE.
#ifndef __ETL_INSTANCE_COUNT__
#define __ETL_INSTANCE_COUNT__
#include "platform.h"
///\defgroup instance_count instance count
///\ingroup utilities

View File

@ -34,8 +34,8 @@ SOFTWARE.
#include <limits.h>
#include <stddef.h>
#include "type_traits.h"
#include "platform.h"
#include "type_traits.h"
#ifdef ETL_COMPILER_MICROSOFT
#undef min

View File

@ -34,6 +34,7 @@ SOFTWARE.
#include <assert.h>
#include <utility>
#include "platform.h"
#include "nullptr.h"
#include "type_traits.h"
#include "exception.h"

View File

@ -33,6 +33,7 @@ SOFTWARE.
#include <stddef.h>
#include "platform.h"
#include "type_traits.h"
#include "error_handler.h"
#include "intrusive_links.h"

View File

@ -33,6 +33,7 @@ SOFTWARE.
#include <stddef.h>
#include "platform.h"
#include "type_traits.h"
#include "error_handler.h"
#include "intrusive_links.h"

View File

@ -38,6 +38,7 @@ SOFTWARE.
#include <stdint.h>
#include <iterator>
#include "platform.h"
#include "nullptr.h"
#include "parameter_type.h"

View File

@ -33,6 +33,7 @@ SOFTWARE.
#include <iterator>
#include "platform.h"
#include "type_traits.h"
///\defgroup iterator iterator

View File

@ -56,6 +56,7 @@ SOFTWARE.
///\defgroup largest largest
///\ingroup utilities
#include "platform.h"
#include "type_traits.h"
#include "smallest.h"
#include "static_assert.h"

View File

@ -68,6 +68,7 @@ cog.outl("//********************************************************************
///\defgroup largest largest
///\ingroup utilities
#include "platform.h"
#include "type_traits.h"
#include "smallest.h"
#include "static_assert.h"

View File

@ -33,6 +33,8 @@ SOFTWARE.
#include <stddef.h>
#include "platform.h"
///\defgroup log log
/// log<N, BASE> : Calculates logs to any base, rounded down to the nearest integer.<br>
/// log2<N> : Calculates logs to base 2, rounded down to the nearest integer.<br>

View File

@ -34,6 +34,7 @@ SOFTWARE.
#include <iterator>
#include <algorithm>
#include "platform.h"
#include "type_traits.h"
///\defgroup memory memory

View File

@ -31,6 +31,7 @@ SOFTWARE.
#include <stdint.h>
#include "platform.h"
#include "error_handler.h"
#include "exception.h"
#include "message_types.h"

View File

@ -32,6 +32,7 @@ SOFTWARE.
#include <stdint.h>
#include <algorithm>
#include "platform.h"
#include "algorithm.h"
#include "vector.h"
#include "nullptr.h"

View File

@ -53,6 +53,7 @@ SOFTWARE.
#include <stdint.h>
#include "platform.h"
#include "message.h"
#include "message_types.h"
#include "alignment.h"

View File

@ -65,6 +65,7 @@ cog.outl("//********************************************************************
#include <stdint.h>
#include "platform.h"
#include "message.h"
#include "message_types.h"
#include "alignment.h"

651
src/message_timer.h Normal file
View File

@ -0,0 +1,651 @@
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2017 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef __ETL_MESSAGE_TIMER__
#define __ETL_MESSAGE_TIMER__
#include <stdint.h>
#include <algorithm>
#include "platform.h"
#include "nullptr.h"
#include "message_types.h"
#include "message.h"
#include "message_router.h"
#include "message_bus.h"
#include "static_assert.h"
#include "timer.h"
#undef ETL_FILE
#define ETL_FILE "41"
namespace etl
{
//*************************************************************************
/// The configuration of a timer.
struct message_timer_data
{
//*******************************************
message_timer_data()
: p_message(nullptr),
p_router(nullptr),
period(0),
delta(etl::timer::state::INACTIVE),
destination_router_id(etl::imessage_bus::ALL_MESSAGE_ROUTERS),
id(etl::timer::id::NO_TIMER),
previous(etl::timer::id::NO_TIMER),
next(etl::timer::id::NO_TIMER),
repeating(true)
{
}
//*******************************************
message_timer_data(etl::timer::id::type id_,
const etl::imessage& message_,
etl::imessage_router& irouter_,
uint32_t period_,
bool repeating_,
etl::message_router_id_t destination_router_id_)
: p_message(&message_),
p_router(&irouter_),
period(period_),
delta(etl::timer::state::INACTIVE),
id(id_),
previous(etl::timer::id::NO_TIMER),
next(etl::timer::id::NO_TIMER),
repeating(repeating_)
{
if (irouter_.get_message_router_id() == etl::imessage_router::MESSAGE_BUS)
{
destination_router_id = destination_router_id_;
}
else
{
destination_router_id = etl::imessage_bus::ALL_MESSAGE_ROUTERS;
}
}
//*******************************************
/// Returns true if the timer is active.
//*******************************************
bool is_active() const
{
return delta != etl::timer::state::INACTIVE;
}
//*******************************************
/// Sets the timer to the inactive state.
//*******************************************
void set_inactive()
{
delta = etl::timer::state::INACTIVE;
}
const etl::imessage* p_message;
etl::imessage_router* p_router;
uint32_t period;
uint32_t delta;
etl::message_router_id_t destination_router_id;
etl::timer::id::type id;
uint_least8_t previous;
uint_least8_t next;
bool repeating;
private:
// Disabled.
message_timer_data(const message_timer_data& other);
message_timer_data& operator =(const message_timer_data& other);
};
namespace __private_message_timer__
{
//*************************************************************************
/// A specialised intrusive linked list for timer data.
//*************************************************************************
class list
{
public:
//*******************************
list(etl::message_timer_data* ptimers_)
: head(etl::timer::id::NO_TIMER),
tail(etl::timer::id::NO_TIMER),
current(etl::timer::id::NO_TIMER),
ptimers(ptimers_)
{
}
//*******************************
bool empty() const
{
return head == etl::timer::id::NO_TIMER;
}
//*******************************
// Inserts the timer at the correct delta position
//*******************************
void insert(etl::timer::id::type id_)
{
etl::message_timer_data& timer = ptimers[id_];
if (head == etl::timer::id::NO_TIMER)
{
// No entries yet.
head = id_;
tail = id_;
timer.previous = etl::timer::id::NO_TIMER;
timer.next = etl::timer::id::NO_TIMER;
}
else
{
// We already have entries.
etl::timer::id::type test_id = begin();
while (test_id != etl::timer::id::NO_TIMER)
{
etl::message_timer_data& test = ptimers[test_id];
// Find the correct place to insert.
if (timer.delta <= test.delta)
{
if (test.id == head)
{
head = timer.id;
}
// Insert before test.
timer.previous = test.previous;
test.previous = timer.id;
timer.next = test.id;
// Adjust the next delta to compensate.
test.delta -= timer.delta;
if (timer.previous != etl::timer::id::NO_TIMER)
{
ptimers[timer.previous].next = timer.id;
}
break;
}
else
{
timer.delta -= test.delta;
}
test_id = next(test_id);
}
// Reached the end?
if (test_id == etl::timer::id::NO_TIMER)
{
// Tag on to the tail.
ptimers[tail].next = timer.id;
timer.previous = tail;
timer.next = etl::timer::id::NO_TIMER;
tail = timer.id;
}
}
}
//*******************************
void remove(etl::timer::id::type id_, bool has_expired)
{
etl::message_timer_data& timer = ptimers[id_];
if (head == id_)
{
head = timer.next;
}
else
{
ptimers[timer.previous].next = timer.next;
}
if (tail == id_)
{
tail = timer.previous;
}
else
{
ptimers[timer.next].previous = timer.previous;
}
if (!has_expired)
{
// Adjust the next delta.
if (timer.next != etl::timer::id::NO_TIMER)
{
ptimers[timer.next].delta += timer.delta;
}
}
timer.previous = etl::timer::id::NO_TIMER;
timer.next = etl::timer::id::NO_TIMER;
timer.delta = etl::timer::state::INACTIVE;
}
//*******************************
etl::message_timer_data& front()
{
return ptimers[head];
}
//*******************************
etl::timer::id::type begin()
{
current = head;
return current;
}
//*******************************
etl::timer::id::type previous(etl::timer::id::type last)
{
current = ptimers[last].previous;
return current;
}
//*******************************
etl::timer::id::type next(etl::timer::id::type last)
{
current = ptimers[last].next;
return current;
}
//*******************************
void clear()
{
etl::timer::id::type id = begin();
while (id != etl::timer::id::NO_TIMER)
{
etl::message_timer_data& timer = ptimers[id];
id = next(id);
timer.next = etl::timer::id::NO_TIMER;
}
head = etl::timer::id::NO_TIMER;
tail = etl::timer::id::NO_TIMER;
current = etl::timer::id::NO_TIMER;
}
private:
etl::timer::id::type head;
etl::timer::id::type tail;
etl::timer::id::type current;
etl::message_timer_data* const ptimers;
};
}
//***************************************************************************
/// Interface for message timer
//***************************************************************************
class imessage_timer
{
public:
//*******************************************
/// Register a timer.
//*******************************************
etl::timer::id::type register_timer(const etl::imessage& message_,
etl::imessage_router& router_,
uint32_t period_,
bool repeating_,
etl::message_router_id_t destination_router_id_ = etl::imessage_router::ALL_MESSAGE_ROUTERS)
{
etl::timer::id::type id = etl::timer::id::NO_TIMER;
disable_timer_updates();
bool is_space = (registered_timers < MAX_TIMERS);
if (is_space)
{
// There's no point adding null message routers.
if (router_.get_message_router_id() != etl::imessage_router::NULL_MESSAGE_ROUTER)
{
// Search for the free space.
for (uint_least8_t i = 0; i < MAX_TIMERS; ++i)
{
etl::message_timer_data& timer = timer_array[i];
if (timer.id == etl::timer::id::NO_TIMER)
{
// Create in-place.
new (&timer) message_timer_data(i, message_, router_, period_, repeating_, destination_router_id_);
++registered_timers;
id = i;
break;
}
}
}
}
enable_timer_updates();
return id;
}
//*******************************************
/// Unregister a timer.
//*******************************************
bool unregister_timer(etl::timer::id::type id_)
{
bool result = false;
if (id_ != etl::timer::id::NO_TIMER)
{
disable_timer_updates();
etl::message_timer_data& timer = timer_array[id_];
if (timer.id != etl::timer::id::NO_TIMER)
{
if (timer.is_active())
{
active_list.remove(timer.id, true);
// Reset in-place.
new (&timer) message_timer_data();
--registered_timers;
result = true;
}
}
enable_timer_updates();
}
return result;
}
//*******************************************
/// Enable/disable the timer.
//*******************************************
void enable(bool state_)
{
enabled = state_;
}
//*******************************************
/// Get the enable/disable state.
//*******************************************
bool is_running() const
{
return enabled;
}
//*******************************************
/// Clears the timer of data.
//*******************************************
void clear()
{
disable_timer_updates();
active_list.clear();
for (int i = 0; i < MAX_TIMERS; ++i)
{
new (&timer_array[i]) message_timer_data();
}
registered_timers = 0;
tick_count = 0;
enable_timer_updates();
}
//*******************************************
// Called by the timer service to indicate the
// amount of time that has elapsed since the
// last call to 'tick'.
//*******************************************
bool tick(uint32_t count)
{
if (enabled)
{
tick_count += count;
if (process_semaphore == 0)
{
// We have something to do?
while (!active_list.empty() && (tick_count >= active_list.front().delta))
{
etl::message_timer_data& timer = active_list.front();
tick_count -= timer.delta;
active_list.remove(timer.id, true);
if (timer.repeating)
{
timer.delta = timer.period;
active_list.insert(timer.id);
}
if (timer.p_router != nullptr)
{
if (timer.p_router->get_message_router_id() == etl::imessage_router::MESSAGE_BUS)
{
// Send to a message bus.
etl::imessage_bus& bus = static_cast<etl::imessage_bus&>(*(timer.p_router));
bus.receive(timer.destination_router_id, *(timer.p_message));
}
else
{
// Send to a router.
timer.p_router->receive(*(timer.p_message));
}
}
}
}
}
return enabled;
}
//*******************************************
/// Starts a timer.
//*******************************************
bool start(etl::timer::id::type id_, bool immediate_ = false)
{
bool result = false;
disable_timer_updates();
// Valid timer id?
if (id_ != etl::timer::id::NO_TIMER)
{
etl::message_timer_data& timer = timer_array[id_];
// Registered timer?
if (timer.id != etl::timer::id::NO_TIMER)
{
// Has a valid period.
if (timer.period != etl::timer::state::INACTIVE)
{
if (timer.is_active())
{
active_list.remove(timer.id, false);
}
timer.delta = tick_count;
if (!immediate_)
{
timer.delta += timer.period;
}
active_list.insert(timer.id);
result = true;
}
}
}
enable_timer_updates();
return result;
}
//*******************************************
/// Stops a timer.
//*******************************************
bool stop(etl::timer::id::type id_)
{
bool result = false;
disable_timer_updates();
// Valid timer id?
if (id_ != etl::timer::id::NO_TIMER)
{
etl::message_timer_data& timer = timer_array[id_];
// Registered timer?
if (timer.id != etl::timer::id::NO_TIMER)
{
if (timer.is_active())
{
active_list.remove(timer.id, false);
result = true;
}
}
}
enable_timer_updates();
return result;
}
//*******************************************
/// Sets a timer's period.
//*******************************************
bool set_period(etl::timer::id::type id_, uint32_t period_)
{
if (stop(id_))
{
timer_array[id_].period = period_;
return start(id_);
}
return false;
}
//*******************************************
/// Sets a timer's mode.
//*******************************************
bool set_mode(etl::timer::id::type id_, bool repeating_)
{
if (stop(id_))
{
timer_array[id_].repeating = repeating_;
return start(id_);
}
return false;
}
protected:
//*******************************************
/// Constructor.
//*******************************************
imessage_timer(message_timer_data* const timer_array_, const uint_least8_t MAX_TIMERS_)
: timer_array(timer_array_),
active_list(timer_array_),
enabled(false),
process_semaphore(0),
tick_count(0),
registered_timers(0),
MAX_TIMERS(MAX_TIMERS_)
{
}
private:
//*******************************************
/// Enable timer callback events.
//*******************************************
void enable_timer_updates()
{
--process_semaphore;
}
//*******************************************
/// Disable timer callback events.
//*******************************************
void disable_timer_updates()
{
++process_semaphore;
}
// The array of timer data structures.
message_timer_data* const timer_array;
// The list of active timers.
__private_message_timer__::list active_list;
volatile bool enabled;
volatile etl::timer_semaphore_t process_semaphore;
volatile uint32_t tick_count;
volatile uint_least8_t registered_timers;
public:
const uint_least8_t MAX_TIMERS;
};
//***************************************************************************
/// The message timer
//***************************************************************************
template <uint_least8_t MAX_TIMERS_>
class message_timer : public etl::imessage_timer
{
public:
STATIC_ASSERT(MAX_TIMERS_ <= 254, "No more than 254 timers are allowed");
//*******************************************
/// Constructor.
//*******************************************
message_timer()
: imessage_timer(timer_array, MAX_TIMERS_)
{
}
private:
message_timer_data timer_array[MAX_TIMERS_];
};
}
#undef ETL_FILE
#endif

View File

@ -31,6 +31,8 @@ SOFTWARE.
#include <stdint.h>
#include "platform.h"
namespace etl
{
/// Allow alternative type for message id.

View File

@ -31,6 +31,8 @@ SOFTWARE.
#ifndef __ETL_NUMERIC__
#define __ETL_NUMERIC__
#include "platform.h"
///\defgroup numeric numeric
///\ingroup utilities

View File

@ -52,6 +52,8 @@ SOFTWARE.
//*****************************************************************************
#include <algorithm>
#include "platform.h"
#include "vector.h"
#include "exception.h"
#include "error_handler.h"

View File

@ -31,6 +31,7 @@ SOFTWARE.
#ifndef __ETL_PARAMETER__
#define __ETL_PARAMETER__
#include "platform.h"
#include "type_traits.h"
namespace etl

View File

@ -5,7 +5,7 @@ The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
http://www.etlcpp.com
https://www.etlcpp.com
Copyright(c) 2016 jwellbelove
@ -28,70 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include <stdint.h>
#include <limits.h>
// Define the compiler.
#if defined(__IAR_SYSTEMS_ICC__)
#define ETL_COMPILER_IAR
#elif defined(__KEIL__) && !defined(__GNUC__)
#define ETL_COMPILER_KEIL
#elif defined(__ghs__)
#define ETL_COMPILER_GREEN_HILLS
#elif defined(__INTEL_COMPILER)
#define ETL_COMPILER_INTEL
#elif defined(_MSC_VER)
#define ETL_COMPILER_MICROSOFT
#elif defined(__GNUC__)
#define ETL_COMPILER_GCC
#elif defined(__TI_COMPILER_VERSION__)
#define ETL_COMPILER_TI
#elif defined(_MRI)
#define ETL_COMPILER_MICROTEC
#elif defined(__HIGHC__)
#define ETL_COMPILER_METAWARE_HIGH
#elif defined(__llvm__)
#define ETL_COMPILER_LLVM
#elif defined(__KCC_VERSION)
#define ETL_COMPILER_KAI
#elif defined(_COMO__)
#define ETL_COMPILER_COMEAU
#elif defined(__BORLANDC__)
#define ETL_COMPILER_BORLAND
#elif defined(__CC_ARM)
#define ETL_COMPILER_ARM
#elif defined(__MRC__)
#define ETL_COMPILER_MPW
#else
#define ETL_COMPILER_GENERIC
#endif
#if (__cplusplus >= 201103L) || (!defined(ARDUINO) && (defined(ETL_COMPILER_MICROSOFT) && (_MSC_VER >= 1600)))
#define ETL_CPP11_SUPPORTED 1
#else
#define ETL_CPP11_SUPPORTED 0
#endif
#if (__cplusplus >= 201402L) || (!defined(ARDUINO) && (defined(ETL_COMPILER_MICROSOFT) && (_MSC_VER >= 1900)))
#define ETL_CPP14_SUPPORTED 1
#else
#define ETL_CPP14_SUPPORTED 0
#endif
#if (ETL_CPP11_SUPPORTED)
#define ETL_NO_NULLPTR_SUPPORT 0
#define ETL_NO_LARGE_CHAR_SUPPORT 0
#else
#define ETL_NO_NULLPTR_SUPPORT 1
#define ETL_NO_LARGE_CHAR_SUPPORT 1
#endif
// Check to see if the compiler supports C++11 'is_trivially_xxx' traits.
#if (ETL_CPP14_SUPPORTED)
#define ETL_C11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED 1
#else
#define ETL_C11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED 0
#endif
#ifndef __ETL_PLATFORM__
#define __ETL_PLATFORM__
// Some targets do not support 8bit types.
#define ETL_8BIT_SUPPORT (CHAR_BIT == 8)
@ -101,3 +39,7 @@ SOFTWARE.
#else
#define ETL_DEBUG 0
#endif
#include "etl_profile.h"
#endif

View File

@ -31,11 +31,11 @@ SOFTWARE.
#ifndef __ETL_POOL__
#define __ETL_POOL__
#include "platform.h"
#include "alignment.h"
#include "array.h"
#include "container.h"
#include "integral_limits.h"
#include "platform.h"
#include "nullptr.h"
#include "alignment.h"
#include "error_handler.h"

View File

@ -33,6 +33,8 @@ SOFTWARE.
#include <stddef.h>
#include <stdint.h>
#include "platform.h"
#include "log.h"
///\defgroup power power

View File

@ -28,6 +28,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "../platform.h"
#include "pvoidvector.h"
namespace etl

View File

@ -37,6 +37,7 @@ SOFTWARE.
#include <stddef.h>
#include "../platform.h"
#include "../exception.h"
#include "../error_handler.h"
#include "../debug_count.h"

View File

@ -0,0 +1,50 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2017 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef __ETL_ARDUINO__
#define __ETL_ARDUINO__
//*****************************************************************************
// Arduino
//*****************************************************************************
#include <limits.h>
#define ETL_TARGET_DEVICE_ARM
#define ETL_TARGET_OS_NONE
#define ETL_COMPILER_GCC
#define ETL_CPP11_SUPPORTED 0
#define ETL_CPP14_SUPPORTED 0
#define ETL_NO_NULLPTR_SUPPORT 1
#define ETL_NO_LARGE_CHAR_SUPPORT 1
#define ETL_C11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED 0
#define ETL_ATOMIC_SUPPORTED 0
#endif

50
src/profiles/armv5.h Normal file
View File

@ -0,0 +1,50 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2017 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef __ETL_ARMV5__
#define __ETL_ARMV5__
//*****************************************************************************
// ARM Compiler Version 5
//*****************************************************************************
#include <limits.h>
#define ETL_TARGET_DEVICE_ARM
#define ETL_TARGET_OS_NONE
#define ETL_COMPILER_ARM
#define ETL_CPP11_SUPPORTED 0
#define ETL_CPP14_SUPPORTED 0
#define ETL_NO_NULLPTR_SUPPORT 1
#define ETL_NO_LARGE_CHAR_SUPPORT 1
#define ETL_C11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED 0
#define ETL_ATOMIC_SUPPORTED 0
#endif

50
src/profiles/armv6.h Normal file
View File

@ -0,0 +1,50 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2017 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef __ETL_ARMV6__
#define __ETL_ARMV6__
//*****************************************************************************
// ARM Compiler Version 6
//*****************************************************************************
#include <limits.h>
#define ETL_TARGET_DEVICE_ARM
#define ETL_TARGET_OS_NONE
#define ETL_COMPILER_LLVM
#define ETL_CPP11_SUPPORTED 1
#define ETL_CPP14_SUPPORTED 0
#define ETL_NO_NULLPTR_SUPPORT 0
#define ETL_NO_LARGE_CHAR_SUPPORT 0
#define ETL_C11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED 1
#define ETL_ATOMIC_SUPPORTED 1
#endif

50
src/profiles/cpp03.h Normal file
View File

@ -0,0 +1,50 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2017 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef __ETL_CPP03__
#define __ETL_CPP03__
//*****************************************************************************
// Generic C++03
//*****************************************************************************
#include <limits.h>
#define ETL_TARGET_DEVICE_GENERIC
#define ETL_TARGET_OS_NONE
#define ETL_COMPILER_GENERIC
#define ETL_CPP11_SUPPORTED 0
#define ETL_CPP14_SUPPORTED 0
#define ETL_NO_NULLPTR_SUPPORT 1
#define ETL_NO_LARGE_CHAR_SUPPORT 1
#define ETL_C11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED 0
#define ETL_ATOMIC_SUPPORTED 0
#endif

50
src/profiles/cpp11.h Normal file
View File

@ -0,0 +1,50 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2017 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef __ETL_CPP11__
#define __ETL_CPP11__
//*****************************************************************************
// Generic C++11
//*****************************************************************************
#include <limits.h>
#define ETL_TARGET_DEVICE_GENERIC
#define ETL_TARGET_OS_NONE
#define ETL_COMPILER_GENERIC
#define ETL_CPP11_SUPPORTED 1
#define ETL_CPP14_SUPPORTED 0
#define ETL_NO_NULLPTR_SUPPORT 0
#define ETL_NO_LARGE_CHAR_SUPPORT 0
#define ETL_C11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED 1
#define ETL_ATOMIC_SUPPORTED 1
#endif

50
src/profiles/cpp14.h Normal file
View File

@ -0,0 +1,50 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2017 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef __ETL_CPP14__
#define __ETL_CPP14__
//*****************************************************************************
// Generic C++14
//*****************************************************************************
#include <limits.h>
#define ETL_TARGET_DEVICE_GENERIC
#define ETL_TARGET_OS_NONE
#define ETL_COMPILER_GENERIC
#define ETL_CPP11_SUPPORTED 1
#define ETL_CPP14_SUPPORTED 1
#define ETL_NO_NULLPTR_SUPPORT 0
#define ETL_NO_LARGE_CHAR_SUPPORT 0
#define ETL_C11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED 1
#define ETL_ATOMIC_SUPPORTED 1
#endif

View File

@ -0,0 +1,50 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2017 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef __ETL_GCC__
#define __ETL_GCC__
//*****************************************************************************
// GCC
//*****************************************************************************
#include <limits.h>
#define ETL_TARGET_DEVICE_GENERIC
#define ETL_TARGET_OS_NONE
#define ETL_COMPILER_GCC
#define ETL_CPP11_SUPPORTED (__cplusplus >= 201103L)
#define ETL_CPP14_SUPPORTED (__cplusplus >= 201402L)
#define ETL_NO_NULLPTR_SUPPORT !ETL_CPP11_SUPPORTED
#define ETL_NO_LARGE_CHAR_SUPPORT !ETL_CPP11_SUPPORTED
#define ETL_C11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED ETL_CPP14_SUPPORTED
#define ETL_ATOMIC_SUPPORTED ETL_CPP11_SUPPORTED
#endif

View File

@ -0,0 +1,50 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2017 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef __ETL_GCC__
#define __ETL_GCC__
//*****************************************************************************
// GCC
//*****************************************************************************
#include <limits.h>
#define ETL_TARGET_DEVICE_X86
#define ETL_TARGET_OS_LINUX
#define ETL_COMPILER_GCC
#define ETL_CPP11_SUPPORTED (__cplusplus >= 201103L)
#define ETL_CPP14_SUPPORTED (__cplusplus >= 201402L)
#define ETL_NO_NULLPTR_SUPPORT !ETL_CPP11_SUPPORTED
#define ETL_NO_LARGE_CHAR_SUPPORT !ETL_CPP11_SUPPORTED
#define ETL_C11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED ETL_CPP14_SUPPORTED
#define ETL_ATOMIC_SUPPORTED ETL_CPP11_SUPPORTED
#endif

View File

@ -0,0 +1,50 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2017 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef __ETL_GCC__
#define __ETL_GCC__
//*****************************************************************************
// GCC
//*****************************************************************************
#include <limits.h>
#define ETL_TARGET_DEVICE_X86
#define ETL_TARGET_OS_WINDOWS
#define ETL_COMPILER_GCC
#define ETL_CPP11_SUPPORTED (__cplusplus >= 201103L)
#define ETL_CPP14_SUPPORTED (__cplusplus >= 201402L)
#define ETL_NO_NULLPTR_SUPPORT !ETL_CPP11_SUPPORTED
#define ETL_NO_LARGE_CHAR_SUPPORT !ETL_CPP11_SUPPORTED
#define ETL_C11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED ETL_CPP14_SUPPORTED
#define ETL_ATOMIC_SUPPORTED ETL_CPP11_SUPPORTED
#endif

50
src/profiles/msvc_x86.h Normal file
View File

@ -0,0 +1,50 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2017 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef __ETL_MSVC__
#define __ETL_MSVC__
//*****************************************************************************
// Microsoft Visual Studio
//*****************************************************************************
#include <limits.h>
#define ETL_TARGET_DEVICE_X86
#define ETL_TARGET_OS_WINDOWS
#define ETL_COMPILER_MICROSOFT
#define ETL_CPP11_SUPPORTED (_MSC_VER >= 1600)
#define ETL_CPP14_SUPPORTED (_MSC_VER >= 1900)
#define ETL_NO_NULLPTR_SUPPORT !ETL_CPP11_SUPPORTED
#define ETL_NO_LARGE_CHAR_SUPPORT !ETL_CPP11_SUPPORTED
#define ETL_C11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED ETL_CPP14_SUPPORTED
#define ETL_ATOMIC_SUPPORTED ETL_CPP11_SUPPORTED
#endif

50
src/profiles/ticc.h Normal file
View File

@ -0,0 +1,50 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2017 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef __ETL_TICC__
#define __ETL_TICC__
//*****************************************************************************
// Texas Instruments Code Composer
//*****************************************************************************
#include <limits.h>
#define ETL_TARGET_DEVICE_GENERIC
#define ETL_TARGET_OS_NONE
#define ETL_COMPILER_TI
#define ETL_CPP11_SUPPORTED 0
#define ETL_CPP14_SUPPORTED 0
#define ETL_NO_NULLPTR_SUPPORT 1
#define ETL_NO_LARGE_CHAR_SUPPORT 1
#define ETL_C11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED 0
#define ETL_ATOMIC_SUPPORTED 0
#endif

View File

@ -34,6 +34,7 @@ SOFTWARE.
#include <stddef.h>
#include <stdint.h>
#include "platform.h"
#include "container.h"
#include "alignment.h"
#include "array.h"

View File

@ -33,6 +33,7 @@ SOFTWARE.
#include <stdint.h>
#include "platform.h"
#include "enum_type.h"
///\defgroup radix radix

View File

@ -28,6 +28,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#include "platform.h"
#include "random.h"
namespace etl

View File

@ -33,6 +33,8 @@ SOFTWARE.
#include <stdint.h>
#include "platform.h"
namespace etl
{
//***************************************************************************

Some files were not shown because too many files have changed in this diff Show More