Squashed 'features/FEATURE_COMMON_PAL/sal-stack-nanostack-eventloop/' content from commit 1fc996d9f

git-subtree-dir: features/FEATURE_COMMON_PAL/sal-stack-nanostack-eventloop
git-subtree-split: 1fc996d9f5190b644b28589fb93b86479725b47f
pull/4345/head
Seppo Takalo 2017-05-18 11:45:57 +03:00
commit dcfe6c8f37
24 changed files with 2841 additions and 0 deletions

234
.cproject Normal file
View File

@ -0,0 +1,234 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="cdt.managedbuild.toolchain.gnu.cross.base.1189539176">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.cross.base.1189539176" moduleId="org.eclipse.cdt.core.settings" name="ArmCC Cortex-M3">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.ui.ArmCC Error Parser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="" artifactName="eventOS" buildProperties="" description="" errorParsers="org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.CWDLocator;org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.ui.ArmCC Error Parser;org.eclipse.cdt.core.VCErrorParser" id="cdt.managedbuild.toolchain.gnu.cross.base.1189539176" name="ArmCC Cortex-M3" parent="org.eclipse.cdt.build.core.emptycfg" postannouncebuildStep="" postbuildStep="" preannouncebuildStep="" prebuildStep="">
<folderInfo id="cdt.managedbuild.toolchain.gnu.cross.base.1189539176.1169351817" name="/" resourcePath="">
<toolChain errorParsers="" id="cdt.managedbuild.toolchain.gnu.cross.base.367759647" name="Cross GCC" superClass="cdt.managedbuild.toolchain.gnu.cross.base">
<option id="cdt.managedbuild.option.gnu.cross.prefix.660991130" name="Prefix" superClass="cdt.managedbuild.option.gnu.cross.prefix"/>
<option id="cdt.managedbuild.option.gnu.cross.path.331710635" name="Path" superClass="cdt.managedbuild.option.gnu.cross.path"/>
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.targetPlatform.gnu.cross.1196089708" isAbstract="false" osList="all" superClass="cdt.managedbuild.targetPlatform.gnu.cross"/>
<builder buildPath="${workspace_loc:/eventOS}/" errorParsers="org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.CWDLocator" id="cdt.managedbuild.builder.gnu.cross.836533860" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="cdt.managedbuild.builder.gnu.cross"/>
<tool errorParsers="" id="cdt.managedbuild.tool.gnu.cross.c.compiler.499691915" name="Cross GCC Compiler" superClass="cdt.managedbuild.tool.gnu.cross.c.compiler">
<option id="gnu.c.compiler.option.include.paths.1009581990" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${ARMCC_INCLUDE}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/libService/libService}&quot;"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.490997078" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.cross.cpp.compiler.146498331" name="Cross G++ Compiler" superClass="cdt.managedbuild.tool.gnu.cross.cpp.compiler"/>
<tool errorParsers="org.eclipse.cdt.core.GLDErrorParser" id="cdt.managedbuild.tool.gnu.cross.c.linker.559644121" name="Cross GCC Linker" superClass="cdt.managedbuild.tool.gnu.cross.c.linker">
<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.1546200009" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
<tool id="cdt.managedbuild.tool.gnu.cross.cpp.linker.756120679" name="Cross G++ Linker" superClass="cdt.managedbuild.tool.gnu.cross.cpp.linker"/>
<tool id="cdt.managedbuild.tool.gnu.cross.archiver.360501954" name="Cross GCC Archiver" superClass="cdt.managedbuild.tool.gnu.cross.archiver"/>
<tool errorParsers="org.eclipse.cdt.core.GASErrorParser" id="cdt.managedbuild.tool.gnu.cross.assembler.1933431042" name="Cross GCC Assembler" superClass="cdt.managedbuild.tool.gnu.cross.assembler">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1501463266" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
<cconfiguration id="cdt.managedbuild.toolchain.gnu.cross.base.1189539176.535362087">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.cross.base.1189539176.535362087" moduleId="org.eclipse.cdt.core.settings" name="ArmCC Cortex-M0">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.ui.ArmCC Error Parser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="" artifactName="eventOS" buildProperties="" description="" errorParsers="org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.CWDLocator;org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.ui.ArmCC Error Parser;org.eclipse.cdt.core.VCErrorParser" id="cdt.managedbuild.toolchain.gnu.cross.base.1189539176.535362087" name="ArmCC Cortex-M0" parent="org.eclipse.cdt.build.core.emptycfg" postannouncebuildStep="" postbuildStep="" preannouncebuildStep="" prebuildStep="">
<folderInfo id="cdt.managedbuild.toolchain.gnu.cross.base.1189539176.535362087." name="/" resourcePath="">
<toolChain errorParsers="" id="cdt.managedbuild.toolchain.gnu.cross.base.1138059958" name="Cross GCC" superClass="cdt.managedbuild.toolchain.gnu.cross.base">
<option id="cdt.managedbuild.option.gnu.cross.prefix.2105129213" name="Prefix" superClass="cdt.managedbuild.option.gnu.cross.prefix"/>
<option id="cdt.managedbuild.option.gnu.cross.path.1568321385" name="Path" superClass="cdt.managedbuild.option.gnu.cross.path"/>
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.targetPlatform.gnu.cross.282790878" isAbstract="false" osList="all" superClass="cdt.managedbuild.targetPlatform.gnu.cross"/>
<builder buildPath="${workspace_loc:/eventOS}/" enabledIncrementalBuild="true" errorParsers="org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.CWDLocator" id="cdt.managedbuild.builder.gnu.cross.1363458610" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="cdt.managedbuild.builder.gnu.cross"/>
<tool errorParsers="" id="cdt.managedbuild.tool.gnu.cross.c.compiler.435164393" name="Cross GCC Compiler" superClass="cdt.managedbuild.tool.gnu.cross.c.compiler">
<option id="gnu.c.compiler.option.include.paths.241649509" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${ARMCC_INCLUDE}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/libService/libService}&quot;"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1949795978" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.cross.cpp.compiler.527027148" name="Cross G++ Compiler" superClass="cdt.managedbuild.tool.gnu.cross.cpp.compiler"/>
<tool errorParsers="org.eclipse.cdt.core.GLDErrorParser" id="cdt.managedbuild.tool.gnu.cross.c.linker.128423528" name="Cross GCC Linker" superClass="cdt.managedbuild.tool.gnu.cross.c.linker">
<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.1297698567" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
<tool id="cdt.managedbuild.tool.gnu.cross.cpp.linker.180972500" name="Cross G++ Linker" superClass="cdt.managedbuild.tool.gnu.cross.cpp.linker"/>
<tool id="cdt.managedbuild.tool.gnu.cross.archiver.1580602139" name="Cross GCC Archiver" superClass="cdt.managedbuild.tool.gnu.cross.archiver"/>
<tool errorParsers="org.eclipse.cdt.core.GASErrorParser" id="cdt.managedbuild.tool.gnu.cross.assembler.2001265995" name="Cross GCC Assembler" superClass="cdt.managedbuild.tool.gnu.cross.assembler">
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.2135227594" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
</tool>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
<cconfiguration id="0.2056004298.141662914.2121498000">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.2056004298.141662914.2121498000" moduleId="org.eclipse.cdt.core.settings" name="GCC Cortex-M3">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="eventOS" buildProperties="" description="" id="0.2056004298.141662914.2121498000" name="GCC Cortex-M3" parent="org.eclipse.cdt.build.core.prefbase.cfg">
<folderInfo id="0.2056004298.141662914.2121498000." name="/" resourcePath="">
<toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.918568439" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
<targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.918568439.1607495802" name=""/>
<builder id="org.eclipse.cdt.build.core.settings.default.builder.1058540032" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
<tool id="org.eclipse.cdt.build.core.settings.holder.libs.1807153236" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
<tool id="org.eclipse.cdt.build.core.settings.holder.1080063132" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1969769389" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
<tool id="org.eclipse.cdt.build.core.settings.holder.1385174078" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1768833971" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
<tool id="org.eclipse.cdt.build.core.settings.holder.991434917" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder">
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1850008051" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
<cconfiguration id="0.2056004298.141662914.2121498000.642060230">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.2056004298.141662914.2121498000.642060230" moduleId="org.eclipse.cdt.core.settings" name="GCC Cortex-M0">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="eventOS" buildProperties="" description="" id="0.2056004298.141662914.2121498000.642060230" name="GCC Cortex-M0" parent="org.eclipse.cdt.build.core.prefbase.cfg">
<folderInfo id="0.2056004298.141662914.2121498000.642060230." name="/" resourcePath="">
<toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.387353475" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
<targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.387353475.888485765" name=""/>
<builder id="org.eclipse.cdt.build.core.settings.default.builder.48511333" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
<tool id="org.eclipse.cdt.build.core.settings.holder.libs.770690623" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
<tool id="org.eclipse.cdt.build.core.settings.holder.798622084" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1838730947" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
<tool id="org.eclipse.cdt.build.core.settings.holder.1622459001" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1547926363" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
<tool id="org.eclipse.cdt.build.core.settings.holder.1687578706" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder">
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1372610724" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
<cconfiguration id="0.2056004298.141662914.1517984773.801758434.1788862897">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.2056004298.141662914.1517984773.801758434.1788862897" moduleId="org.eclipse.cdt.core.settings" name="GCC Native">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration buildProperties="" description="" id="0.2056004298.141662914.1517984773.801758434.1788862897" name="GCC Native" parent="org.eclipse.cdt.build.core.prefbase.cfg">
<folderInfo id="0.2056004298.141662914.1517984773.801758434.1788862897." name="/" resourcePath="">
<toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.1101544598" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
<targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.1101544598.1141380045" name=""/>
<builder enabledIncrementalBuild="true" id="org.eclipse.cdt.build.core.settings.default.builder.1381778143" incrementalBuildTarget="all" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
<tool id="org.eclipse.cdt.build.core.settings.holder.libs.225856136" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
<tool id="org.eclipse.cdt.build.core.settings.holder.224867602" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.107634360" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
<tool id="org.eclipse.cdt.build.core.settings.holder.1754316635" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.2029105652" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
<tool id="org.eclipse.cdt.build.core.settings.holder.356296733" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder">
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.75316590" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="eventOS.null.931576544" name="eventOS"/>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="refreshScope" versionNumber="2">
<configuration configurationName="ArmCC Cortex-M3">
<resource resourceType="PROJECT" workspacePath="/event_loop"/>
</configuration>
<configuration configurationName="GCC Cortex-M0"/>
<configuration configurationName="ArmCC Cortex-M0"/>
<configuration configurationName="GCC Native"/>
<configuration configurationName="GCC Cortex-M3"/>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.cross.base.1189539176;cdt.managedbuild.toolchain.gnu.cross.base.1189539176.1169351817;cdt.managedbuild.tool.gnu.cross.c.compiler.1945983959;cdt.managedbuild.tool.gnu.c.compiler.input.2069091467">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.lib.debug.1529538572;cdt.managedbuild.config.gnu.cross.lib.debug.1529538572.;cdt.managedbuild.tool.gnu.cross.c.compiler.859614738;cdt.managedbuild.tool.gnu.c.compiler.input.1960426387">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.cross.base.1189539176;cdt.managedbuild.toolchain.gnu.cross.base.1189539176.1169351817;cdt.managedbuild.tool.gnu.cross.c.compiler.896320276;cdt.managedbuild.tool.gnu.c.compiler.input.1344565279">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.cross.base.1189539176;cdt.managedbuild.toolchain.gnu.cross.base.1189539176.1169351817;cdt.managedbuild.tool.gnu.cross.c.compiler.499691915;cdt.managedbuild.tool.gnu.c.compiler.input.490997078">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="0.2056004298.141662914.2121498000">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.lib.release.1360582973;cdt.managedbuild.config.gnu.cross.lib.release.1360582973.;cdt.managedbuild.tool.gnu.cross.c.compiler.59710629;cdt.managedbuild.tool.gnu.c.compiler.input.260467457">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
</storageModule>
</cproject>

6
.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
*.a
output/*
build
yotta_modules
yotta_targets
*.lib

82
.project Normal file
View File

@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>eventOS</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
<dictionary>
<key>?name?</key>
<value></value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.append_environment</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.autoBuildTarget</key>
<value>all</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildArguments</key>
<value></value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildCommand</key>
<value>make</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildLocation</key>
<value>${workspace_loc:/event_loop/Debug}</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
<value>clean</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.contents</key>
<value>org.eclipse.cdt.make.core.activeConfigSettings</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
<value>false</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.fullBuildTarget</key>
<value>all</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.stopOnError</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
<value>true</value>
</dictionary>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,67 @@
eclipse.preferences.version=1
org.eclipse.cdt.codan.checkers.errnoreturn=Warning
org.eclipse.cdt.codan.checkers.errnoreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},implicit\=>false}
org.eclipse.cdt.codan.checkers.errreturnvalue=Error
org.eclipse.cdt.codan.checkers.errreturnvalue.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.checkers.noreturn=Error
org.eclipse.cdt.codan.checkers.noreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},implicit\=>false}
org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation=Error
org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem=Error
org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem=Warning
org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem=Error
org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem=Warning
org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},no_break_comment\=>"no break",last_case_param\=>false,empty_case_param\=>false}
org.eclipse.cdt.codan.internal.checkers.CatchByReference=Warning
org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},unknown\=>false,exceptions\=>()}
org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem=Error
org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization=Warning
org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},skip\=>true}
org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem=Error
org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem=Error
org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.internal.checkers.InvalidArguments=Error
org.eclipse.cdt.codan.internal.checkers.InvalidArguments.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem=Error
org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem=Error
org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem=Error
org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem=Error
org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker=-Info
org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},pattern\=>"^[a-z]",macro\=>true,exceptions\=>()}
org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem=Warning
org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.internal.checkers.OverloadProblem=Error
org.eclipse.cdt.codan.internal.checkers.OverloadProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem=Error
org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem=Error
org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem=-Warning
org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem=-Warning
org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem=Warning
org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true,exceptions\=>()}
org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem=Warning
org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},paramNot\=>false}
org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem=Warning
org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},else\=>false,afterelse\=>false}
org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem=Error
org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem=Warning
org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true}
org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem=Warning
org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true}
org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem=Warning
org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true,exceptions\=>("@(\#)","$Id")}
org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem=Error
org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}

View File

@ -0,0 +1,65 @@
eclipse.preferences.version=1
environment/project/0.2056004298.141662914.1517984773.801758434.1788862897/CC/delimiter=;
environment/project/0.2056004298.141662914.1517984773.801758434.1788862897/CC/operation=append
environment/project/0.2056004298.141662914.1517984773.801758434.1788862897/CC/value=gcc
environment/project/0.2056004298.141662914.1517984773.801758434.1788862897/V/delimiter=;
environment/project/0.2056004298.141662914.1517984773.801758434.1788862897/V/operation=append
environment/project/0.2056004298.141662914.1517984773.801758434.1788862897/V/value=1
environment/project/0.2056004298.141662914.1517984773.801758434.1788862897/append=true
environment/project/0.2056004298.141662914.1517984773.801758434.1788862897/appendContributed=true
environment/project/0.2056004298.141662914.2121498000.642060230/CPU/delimiter=;
environment/project/0.2056004298.141662914.2121498000.642060230/CPU/operation=replace
environment/project/0.2056004298.141662914.2121498000.642060230/CPU/value=Cortex-M0
environment/project/0.2056004298.141662914.2121498000.642060230/DEBUG/delimiter=;
environment/project/0.2056004298.141662914.2121498000.642060230/DEBUG/operation=replace
environment/project/0.2056004298.141662914.2121498000.642060230/DEBUG/value=1
environment/project/0.2056004298.141662914.2121498000.642060230/PLATFORM/delimiter=;
environment/project/0.2056004298.141662914.2121498000.642060230/PLATFORM/operation=append
environment/project/0.2056004298.141662914.2121498000.642060230/PLATFORM/value=arm-unknown-linux-uclibcgnueabi-
environment/project/0.2056004298.141662914.2121498000.642060230/V/delimiter=;
environment/project/0.2056004298.141662914.2121498000.642060230/V/operation=append
environment/project/0.2056004298.141662914.2121498000.642060230/V/value=1
environment/project/0.2056004298.141662914.2121498000.642060230/append=true
environment/project/0.2056004298.141662914.2121498000.642060230/appendContributed=true
environment/project/0.2056004298.141662914.2121498000/CPU/delimiter=;
environment/project/0.2056004298.141662914.2121498000/CPU/operation=append
environment/project/0.2056004298.141662914.2121498000/CPU/value=Cortex-M3
environment/project/0.2056004298.141662914.2121498000/PLATFORM/delimiter=;
environment/project/0.2056004298.141662914.2121498000/PLATFORM/operation=append
environment/project/0.2056004298.141662914.2121498000/PLATFORM/value=arm-unknown-linux-uclibcgnueabi-
environment/project/0.2056004298.141662914.2121498000/V/delimiter=;
environment/project/0.2056004298.141662914.2121498000/V/operation=append
environment/project/0.2056004298.141662914.2121498000/V/value=1
environment/project/0.2056004298.141662914.2121498000/append=true
environment/project/0.2056004298.141662914.2121498000/appendContributed=true
environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1189539176.535362087/CC/delimiter=;
environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1189539176.535362087/CC/operation=replace
environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1189539176.535362087/CC/value=armcc
environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1189539176.535362087/CONFIG/delimiter=;
environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1189539176.535362087/CONFIG/operation=replace
environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1189539176.535362087/CONFIG/value=generic
environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1189539176.535362087/CPU/delimiter=;
environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1189539176.535362087/CPU/operation=replace
environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1189539176.535362087/CPU/value=Cortex-M0
environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1189539176.535362087/DEBUG/delimiter=;
environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1189539176.535362087/DEBUG/operation=replace
environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1189539176.535362087/DEBUG/value=1
environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1189539176.535362087/V/delimiter=;
environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1189539176.535362087/V/operation=append
environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1189539176.535362087/V/value=1
environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1189539176.535362087/append=true
environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1189539176.535362087/appendContributed=true
environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1189539176/CC/delimiter=;
environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1189539176/CC/operation=replace
environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1189539176/CC/value=armcc
environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1189539176/CPU/delimiter=;
environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1189539176/CPU/operation=append
environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1189539176/CPU/value=Cortex-M3
environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1189539176/DEBUG/delimiter=;
environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1189539176/DEBUG/operation=replace
environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1189539176/DEBUG/value=1
environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1189539176/V/delimiter=;
environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1189539176/V/operation=append
environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1189539176/V/value=1
environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1189539176/append=true
environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1189539176/appendContributed=true

2
LICENSE Normal file
View File

@ -0,0 +1,2 @@
Unless specifically indicated otherwise in a file, files are licensed
under the Apache 2.0 license, as can be found in: apache-2.0.txt

34
Makefile Normal file
View File

@ -0,0 +1,34 @@
# Define compiler toolchain with CC or PLATFORM variables
# Example (GCC toolchains)
# make PLATFORM=arm-linux-gnueabi-
# OR
# make CC=armcc AR=ArmAR
# OR
# make CC=iccarm
LIB = libeventOS.a
SRCS += \
source/event.c \
source/ns_timer.c \
source/system_timer.c\
source/ns_timeout.c
include ../libService/toolchain_rules.mk
override CFLAGS += -I nanostack-event-loop
#
# External sources from libService
#
SERVLIB_DIR := ../libService
override CFLAGS += -I$(SERVLIB_DIR)/libService
$(eval $(call generate_rules,$(LIB),$(SRCS)))
.PHONY: release
release:
7z a edtls-lib_$(VERSION).zip *.a *.lib include
.PHONY: deploy_to
deploy_to: all
tar --transform 's,^,event-loop/,' --append -f $(TO) *.a

56
apache-2.0.txt Normal file
View File

@ -0,0 +1,56 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
You must give any other recipients of the Work or Derivative Works a copy of this License; and
You must cause any modified files to carry prominent notices stating that You changed the files; and
You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS

13
mbed_lib.json Normal file
View File

@ -0,0 +1,13 @@
{
"name": "nanostack-eventloop",
"config": {
"use_platform_tick_timer": {
"help": "Use platform provided low resolution tick timer for eventloop",
"value": null
},
"exclude_highres_timer": {
"help": "Exclude high resolution timer from build",
"value": null
}
}
}

22
module.json Normal file
View File

@ -0,0 +1,22 @@
{
"name": "sal-stack-nanostack-eventloop",
"version": "1.1.0",
"description": "Event loop for 6LoWPAN stack",
"keywords": [],
"author": "Seppo Takalo <seppo.takalo@arm.com>",
"repository": {
"url": "git@github.com:ARMmbed/sal-stack-nanostack-eventloop.git",
"type": "git"
},
"homepage": "https://github.com/ARMmbed/sal-stack-nanostack-eventloop",
"license": "Apache-2.0",
"extraIncludes": [
"nanostack-event-loop"
],
"dependencies": {
"nanostack-libservice": "^3.0.0",
"mbed-6lowpan-eventloop-adaptor": "^1.0.0",
"minar": "^1.0.0"
},
"targetDependencies": {}
}

View File

@ -0,0 +1,32 @@
/*
* Copyright (c) 2014-2015 ARM Limited. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef EVENTOS_CALLBACK_TIMER_H_
#define EVENTOS_CALLBACK_TIMER_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "ns_types.h"
extern int8_t eventOS_callback_timer_register(void (*timer_interrupt_handler)(int8_t, uint16_t));
extern int8_t eventOS_callback_timer_unregister(int8_t ns_timer_id);
extern int8_t eventOS_callback_timer_stop(int8_t ns_timer_id);
extern int8_t eventOS_callback_timer_start(int8_t ns_timer_id, uint16_t slots);
#ifdef __cplusplus
}
#endif
#endif /* EVENTOS_CALLBACK_TIMER_H_ */

View File

@ -0,0 +1,169 @@
/*
* Copyright (c) 2014-2015 ARM Limited. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef EVENTOS_EVENT_H_
#define EVENTOS_EVENT_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "ns_types.h"
#include "ns_list.h"
/**
* \enum arm_library_event_priority_e
* \brief Event Priority level.
*/
typedef enum arm_library_event_priority_e {
ARM_LIB_HIGH_PRIORITY_EVENT = 0, /**< High Priority Event (Function CB) */
ARM_LIB_MED_PRIORITY_EVENT = 1, /**< Medium Priority (Timer) */
ARM_LIB_LOW_PRIORITY_EVENT = 2, /*!*< Normal Event and ECC / Security */
} arm_library_event_priority_e;
/**
* \struct arm_event_s
* \brief Event structure.
*/
typedef struct arm_event_s {
int8_t receiver; /**< Event handler Tasklet ID */
int8_t sender; /**< Event sender Tasklet ID */
uint8_t event_type; /**< This will be typecast arm_library_event_type_e, arm_internal_event_type_e or application specific define */
uint8_t event_id; /**< Timer ID, NWK interface ID or application specific ID */
void *data_ptr; /**< Application could share data pointer tasklet to tasklet */
arm_library_event_priority_e priority;
uint32_t event_data;
} arm_event_t;
/* Backwards compatibility */
typedef arm_event_t arm_event_s;
/**
* \struct arm_event_storage
* \brief Event structure storage, including list link.
@startuml
partition "Event loop" {
(*) -->[event created] "UNQUEUED"
"UNQUEUED" -->[event_core_write()] "QUEUED"
"QUEUED" -->[event_core_read()] "RUNNING"
"RUNNING" ->[event_core_free_push()] "UNQUEUED"
}
partition "system_timer.c" {
"UNQUEUED:timer" -->[eventOS_event_send_timer_allocated()] "QUEUED"
}
@enduml
*/
typedef struct arm_event_storage {
arm_event_s data;
enum {
ARM_LIB_EVENT_STARTUP_POOL,
ARM_LIB_EVENT_DYNAMIC,
ARM_LIB_EVENT_USER,
ARM_LIB_EVENT_TIMER,
} allocator;
enum {
ARM_LIB_EVENT_UNQUEUED,
ARM_LIB_EVENT_QUEUED,
ARM_LIB_EVENT_RUNNING,
} state;
ns_list_link_t link;
} arm_event_storage_t;
/**
* \brief Send event to event scheduler.
*
* \param event pointer to pushed event.
*
* Event data is copied by the call, and this copy persists until the
* recipient's callback function returns. The callback function is passed
* a pointer to a copy of the data, not the original pointer.
*
* \return 0 Event push OK
* \return -1 Memory allocation Fail
*/
extern int8_t eventOS_event_send(const arm_event_t *event);
/* Alternate names for timer function from eventOS_event_timer.h;
* implementations may one day merge */
#define eventOS_event_send_at(event, at) eventOS_event_timer_request_at(event, at)
#define eventOS_event_send_in(event, in) eventOS_event_timer_request_in(event, in)
#define eventOS_event_send_after(event, after) eventOS_event_timer_request_after(event, after)
#define eventOS_event_send_every(event, every) eventOS_event_timer_request_every(event, every)
/**
* \brief Send user-allocated event to event scheduler.
*
* \param event pointer to pushed event storage.
*
* The event structure is not copied by the call, the event system takes
* ownership and it is threaded directly into the event queue. This avoids the
* possibility of event sending failing due to memory exhaustion.
*
* event->data must be filled in on entry - the rest of the structure (link and
* allocator) need not be.
*
* The structure must remain valid until the recipient is called - the
* event system passes ownership to the receiving event handler, who may then
* invalidate it, or send it again.
*
* The recipient receives a pointer to the arm_event_t data member of the
* event - it can use NS_CONTAINER_OF() to get a pointer to the original
* event passed to this call, or to its outer container.
*
* It is a program error to send a user-allocated event to a non-existent task.
*/
extern void eventOS_event_send_user_allocated(arm_event_storage_t *event);
/**
* \brief Event handler callback register
*
* Function will register and allocate unique event id handler
*
* \param handler_func_ptr function pointer for event handler
* \param init_event_type generated event type for init purpose
*
* \return >= 0 Unique event ID for this handler
* \return < 0 Register fail
*
* */
extern int8_t eventOS_event_handler_create(void (*handler_func_ptr)(arm_event_t *), uint8_t init_event_type);
/**
* Cancel an event.
*
* Queued events are removed from the event-loop queue and/or the timer queue.
*
* Passing a NULL pointer is allowed, and does nothing.
*
* Event pointers are valid from the time they are queued until the event
* has finished running or is cancelled.
*
* Cancelling a currently-running event is only useful to stop scheduling
* it if it is on a periodic timer; it has no other effect.
*
* Cancelling an already-cancelled or already-run single-shot event
* is undefined behaviour.
*
* \param event Pointer to event handle or NULL.
*/
extern void eventOS_cancel(arm_event_storage_t *event);
#ifdef __cplusplus
}
#endif
#endif /* EVENTOS_EVENT_H_ */

View File

@ -0,0 +1,255 @@
/*
* Copyright (c) 2014-2015 ARM Limited. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef EVENTOS_EVENT_TIMER_H_
#define EVENTOS_EVENT_TIMER_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "ns_types.h"
#include "eventOS_event.h"
struct arm_event_s;
typedef struct sys_timer_struct_s sys_timer_struct_t;
/* 100 Hz ticker, so 10 milliseconds per tick */
#define EVENTOS_EVENT_TIMER_HZ 100
static inline uint32_t eventOS_event_timer_ticks_to_ms(uint32_t ticks)
{
NS_STATIC_ASSERT(1000 % EVENTOS_EVENT_TIMER_HZ == 0, "Assuming whole number of ms per tick")
return ticks * (1000 / EVENTOS_EVENT_TIMER_HZ);
}
/* Convert ms to ticks, rounding up (so 9ms = 1 tick, 10ms = 1 tick, 11ms = 2 ticks) */
static inline uint32_t eventOS_event_timer_ms_to_ticks(uint32_t ms)
{
NS_STATIC_ASSERT(1000 % EVENTOS_EVENT_TIMER_HZ == 0, "Assuming whole number of ms per tick")
return (ms + (1000 / EVENTOS_EVENT_TIMER_HZ) - 1) / (1000 / EVENTOS_EVENT_TIMER_HZ);
}
/**
* Read current timer tick count.
*
* Can be used as a monotonic time source, and to schedule events with
* eventOS_event_timer_send.
*
* Note that the value will wrap, so take care on comparisons.
*
* \return tick count.
*/
extern uint32_t eventOS_event_timer_ticks(void);
/* Comparison macros handling wrap efficiently (assuming a conventional compiler
* which converts 0x80000000 to 0xFFFFFFFF to negative when casting to int32_t).
*/
#define TICKS_AFTER(a, b) ((int32_t) ((a)-(b)) > 0)
#define TICKS_BEFORE(a, b) ((int32_t) ((a)-(b)) < 0)
#define TICKS_AFTER_OR_AT(a, b) ((int32_t) ((a)-(b)) >= 0)
#define TICKS_BEFORE_OR_AT(a, b) ((int32_t) ((a)-(b)) <= 0)
/**
* Send an event after time expired (in milliseconds)
*
* Note that the current implementation has the "feature" that rounding
* varies depending on the precise timing requested:
* 0-20 ms => 2 x 10ms tick
* 21-29 ms => 3 x 10ms tick
* 30-39 ms => 4 x 10ms tick
* 40-49 ms => 5 x 10ms tick
* ... etc
*
* For improved flexibility on the event, and for more control of time,
* you should use eventOS_event_timer_request_at().
*
* \param event_id event_id for event
* \param event_type event_type for event
* \param tasklet_id receiver for event
* \param time time to sleep in milliseconds
*
* \return 0 on success
* \return -1 on error (invalid tasklet_id or allocation failure)
*
* */
extern int8_t eventOS_event_timer_request(uint8_t event_id, uint8_t event_type, int8_t tasklet_id, uint32_t time);
/**
* Send an event at specified time
*
* The event will be sent when eventOS_event_timer_ticks() reaches the
* specified value.
*
* If the specified time is in the past (ie "at" is before or at the current
* tick value), the event will be sent immediately.
*
* Can also be invoked using the eventOS_event_send_at() macro in eventOS_event.h
*
* \param event event to send
* \param at absolute tick time to run event at
*
* \return pointer to timer structure on success
* \return NULL on error (invalid tasklet_id or allocation failure)
*
*/
extern arm_event_storage_t *eventOS_event_timer_request_at(const struct arm_event_s *event, uint32_t at);
/**
* Send an event in a specified time
*
* The event will be sent in the specified number of ticks - to
* be precise, it is equivalent to requesting an event at
*
* eventOS_event_timer_ticks() + ticks
*
* Because of timer granularity, the elapsed time between issuing the request
* and it running may be up to 1 tick less than the specified time.
*
* eg requesting 2 ticks will cause the event to be sent on the second tick from
* now. If requested just after a tick, the delay will be nearly 2 ticks, but if
* requested just before a tick, the delay will be just over 1 tick.
*
* If `in` is <= 0, the event will be sent immediately.
*
* Can also be invoked using the eventOS_event_send_in() macro in eventOS_event.h
*
* \param event event to send
* \param in tick delay for event
*
* \return pointer to timer structure on success
* \return NULL on error (invalid tasklet_id or allocation failure)
*
*/
extern arm_event_storage_t *eventOS_event_timer_request_in(const struct arm_event_s *event, int32_t in);
/**
* Send an event after a specified time
*
* The event will be sent after the specified number of ticks - to
* be precise, it is equivalent to requesting an event at
*
* eventOS_event_timer_ticks() + ticks + 1
*
* Because of timer granularity, the elapsed time between issuing the request
* and it running may be up to 1 tick more than the specified time.
*
* eg requesting 2 ticks will cause the event to be sent on the third tick from
* now. If requested just after a tick, the delay will be nearly 3 ticks, but if
* requested just before a tick, the delay will be just over 2 ticks.
*
* If `after` is < 0, the event will be sent immediately. If it is 0, the event
* is sent on the next tick.
*
* Can also be invoked using the eventOS_event_send_after() macro in eventOS_event.h
*
* \param event event to send
* \param after tick delay for event
*
* \return pointer to timer structure on success
* \return NULL on error (invalid tasklet_id or allocation failure)
*
*/
#define eventOS_event_timer_request_after(event, after) \
eventOS_event_timer_request_in(event, (after) + 1)
/**
* Send an event periodically
*
* The event will be sent repeatedly using the specified ticks period.
*
* The first call is sent at
*
* eventOS_event_timer_ticks() + ticks
*
* Subsequent events will be sent at N*ticks from the initial time.
*
* Period will be maintained while the device is awake, regardless of delays to
* event scheduling. If an event has not been delivered and completed by the
* next scheduled time, the next event will be sent immediately when it
* finishes. This could cause a continuous stream of events if unable to keep
* up with the period.
*
* Can also be invoked using the eventOS_event_send_every() macro in eventOS_event.h
*
* \param event event to send
* \param period period for event
*
* \return pointer to timer structure on success
* \return NULL on error (invalid tasklet_id or allocation failure)
*
*/
extern arm_event_storage_t *eventOS_event_timer_request_every(const struct arm_event_s *event, int32_t period);
/**
* Cancel an event timer
*
* This cancels a pending timed event, matched by event_id and tasklet_id.
*
* \param event_id event_id for event
* \param tasklet_id receiver for event
*
* \return 0 on success
* \return -1 on error (event not found)
*
* */
extern int8_t eventOS_event_timer_cancel(uint8_t event_id, int8_t tasklet_id);
/**
* System Timer shortest time in milli seconds
*
* \param ticks Time in 10 ms resolution
*
* \return none
*
* */
extern uint32_t eventOS_event_timer_shortest_active_timer(void);
/** Timeout structure. Not to be modified by user */
typedef struct timeout_entry_t timeout_t;
/** Request timeout callback.
*
* Create timeout request for specific callback.
*
* \param ms timeout in milliseconds. Maximum range is same as for eventOS_event_timer_request().
* \param callback function to call after timeout
* \param arg arquement to pass to callback
* \return pointer to timeout structure or NULL on errors
*/
timeout_t *eventOS_timeout_ms(void (*callback)(void *), uint32_t ms, void *arg);
/** Request periodic callback.
*
* Create timeout request for specific callback. Called periodically until eventOS_timeout_cancel() is called.
*
* \param every period in milliseconds. Maximum range is same as for eventOS_event_timer_request().
* \param callback function to call after timeout
* \param arg arquement to pass to callback
* \return pointer to timeout structure or NULL on errors
*/
timeout_t *eventOS_timeout_every_ms(void (*callback)(void *), uint32_t every, void *arg);
/** Cancell timeout request.
*
* \param t timeout request id.
*/
void eventOS_timeout_cancel(timeout_t *t);
#ifdef __cplusplus
}
#endif
#endif /* EVENTOS_EVENT_TIMER_H_ */

View File

@ -0,0 +1,173 @@
/*
* Copyright (c) 2014-2015 ARM Limited. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef EVENTOS_SCHEDULER_H_
#define EVENTOS_SCHEDULER_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "ns_types.h"
/* Compatibility with older ns_types.h */
#ifndef NS_NORETURN
#define NS_NORETURN
#endif
/**
* \brief Initialise event scheduler.
*
*/
extern void eventOS_scheduler_init(void);
/**
* Process one event from event queue.
* Do not call this directly from application. Requires to be public so that simulator can call this.
* Use eventOS_scheduler_run() or eventOS_scheduler_run_until_idle().
* \return true If there was event processed, false if the event queue was empty.
*/
bool eventOS_scheduler_dispatch_event(void);
/**
* \brief Process events until no more events to process.
*/
extern void eventOS_scheduler_run_until_idle(void);
/**
* \brief Start Event scheduler.
* Loops forever processing events from the queue.
* Calls eventOS_scheduler_idle() whenever event queue is empty.
*/
NS_NORETURN extern void eventOS_scheduler_run(void);
/**
* \brief Disable Event scheduler Timers
*
* \return 0 Timer Stop OK
* \return -1 Timer Stop Fail
*
* */
int eventOS_scheduler_timer_stop(void);
/**
* \brief Synch Event scheduler timer after sleep
*
* \param sleep_ticks time in milli seconds
*
* \return 0 Timer Synch OK
* \return -1 Timer Synch & Start Fail
*
* */
int eventOS_scheduler_timer_synch_after_sleep(uint32_t sleep_ticks);
/**
* \brief Read current active Tasklet ID
*
* This function not return valid information called inside interrupt
*
* \return curret active tasklet id
*
* */
extern int8_t eventOS_scheduler_get_active_tasklet(void);
/**
* \brief Set manually Active Tasklet ID
*
* \param tasklet requested tasklet ID
*
* */
extern void eventOS_scheduler_set_active_tasklet(int8_t tasklet);
/**
* \brief Event scheduler loop idle Callback.
* Note! This method is called only by eventOS_scheduler_run, needs to be
* ported for the platform only if you are using eventOS_scheduler_run().
*/
extern void eventOS_scheduler_idle(void);
/**
* \brief This function will be called when stack enter idle state and start
* waiting signal.
*
* Note! This method is called only by reference implementation of idle. Needs
* to be ported for the platform only if you are using reference implementation.
*/
extern void eventOS_scheduler_wait(void);
/**
* \brief This function will be called when stack receives an event.
*/
extern void eventOS_scheduler_signal(void);
/**
* \brief This function will be called when stack can enter deep sleep state in detected time.
*
* Note! This method is called only by reference implementation of idle. Needs to be
* ported for the platform only if you are using reference implementation.
*
* \param sleep_time_ms Time in milliseconds to sleep
* \return time slept in milliseconds
*/
extern uint32_t eventOS_scheduler_sleep(uint32_t sleep_time_ms);
/**
* \brief Lock a thread against the event loop thread
*
* This method can be provided by multi-threaded platforms to allow
* mutual exclusion with the event loop thread, for cases where
* code wants to work with both the event loop and other threads.
*
* A typical platform implementation would claim the same mutex
* before calling eventOS_scheduler_run() or
* eventOS_scheduler_dispatch(), and release it during
* eventOS_scheduler_idle().
*
* The mutex must count - nested calls from one thread return
* immediately. Thus calling this from inside an event callback
* is harmless.
*/
extern void eventOS_scheduler_mutex_wait(void);
/**
* \brief Release the event loop mutex
*
* Release the mutex claimed with eventOS_scheduler_mutex_wait(),
* allowing the event loop to continue processing.
*/
extern void eventOS_scheduler_mutex_release(void);
/**
* \brief Check if the current thread owns the event mutex
*
* Check if the calling thread owns the scheduler mutex.
* This allows the ownership to be asserted if a function
* requires the mutex to be locked externally.
*
* The function is only intended as a debugging aid for
* users of eventOS_scheduler_mutex_wait() - it is not
* used by the event loop core itself.
*
* If the underlying mutex system does not support it,
* this may be implemented to always return true.
*
* \return true if the current thread owns the mutex
*/
extern bool eventOS_scheduler_mutex_am_owner(void);
#ifdef __cplusplus
}
#endif
#endif /* EVENTOS_SCHEDULER_H_ */

View File

@ -0,0 +1,95 @@
/*
* Copyright (c) 2014-2015 ARM Limited. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ARM_HAL_TIMER_H_
#define ARM_HAL_TIMER_H_
#include "eventloop_config.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifndef NS_EXCLUDE_HIGHRES_TIMER
/**
* \brief This function perform timer init.
*/
extern void platform_timer_enable(void);
/**
* \brief This function is API for set Timer interrupt handler for stack
*
* \param new_fp Function pointer for stack giving timer handler
*
*/
typedef void (*platform_timer_cb)(void);
extern void platform_timer_set_cb(platform_timer_cb new_fp);
/**
* \brief This function is API for stack timer start
*
* \param slots define how many 50us slot time period will be started
*
*/
extern void platform_timer_start(uint16_t slots);
/**
* \brief This function is API for stack timer stop
*
*/
extern void platform_timer_disable(void);
/**
* \brief This function is API for stack timer to read active timer remaining slot count
*
* \return 50us time slot remaining
*/
extern uint16_t platform_timer_get_remaining_slots(void);
#endif // NS_EXCLUDE_HIGHRES_TIMER
#ifdef NS_EVENTLOOP_USE_TICK_TIMER
/**
* \brief This function is API for registering low resolution tick timer callback. Also does
* any necessary initialization of the tick timer.
*
* \return -1 for failure, success otherwise
*/
extern int8_t platform_tick_timer_register(void (*tick_timer_cb_handler)(void));
/**
* \brief This function is API for starting the low resolution tick timer. The callback
* set with platform_tick_timer_register gets called periodically until stopped
* by calling platform_tick_timer_stop.
*
* \param period_ms define how many milliseconds time period will be started
* \return -1 for failure, success otherwise
*/
extern int8_t platform_tick_timer_start(uint32_t period_ms);
/**
* \brief This function is API for stopping the low resolution tick timer
*
* \return -1 for failure, success otherwise
*/
extern int8_t platform_tick_timer_stop(void);
#endif // NS_EVENTLOOP_USE_TICK_TIMER
#ifdef __cplusplus
}
#endif
#endif /* ARM_HAL_TIMER_H_ */

View File

@ -0,0 +1,56 @@
/*
* Copyright (c) 2014-2015 ARM Limited. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef EVENTLOOP_CONFIG_H_
#define EVENTLOOP_CONFIG_H_
/*
* Options can be picked up from mbed-cli JSON configuration, or from
* Yotta JSON configuration, or from a user configuration file - see below.
*
* Undefine all internal flags before evaluating the configuration.
*/
/* Use platform-provided low-resolution tick timer for eventloop (requires "platform_tick_timer" API) */
#undef NS_EVENTLOOP_USE_TICK_TIMER
/* Exclude high resolution timer from build (removes need for "platform_timer" API) */
#undef NS_EXCLUDE_HIGHRES_TIMER
/*
* mbedOS 5 specific configuration flag mapping to internal flags
*/
#ifdef MBED_CONF_NANOSTACK_EVENTLOOP_USE_PLATFORM_TICK_TIMER
#define NS_EVENTLOOP_USE_TICK_TIMER 1
#endif
#ifdef MBED_CONF_NANOSTACK_EVENTLOOP_EXCLUDE_HIGHRES_TIMER
#define NS_EXCLUDE_HIGHRES_TIMER 1
#endif
/*
* For mbedOS 3 and minar use platform tick timer by default, highres timers should come from eventloop adaptor
*/
#ifdef YOTTA_CFG_MINAR
#define NS_EVENTLOOP_USE_TICK_TIMER 1
#endif
/*
* Include the user config file if defined
*/
#ifdef NS_EVENTLOOP_USER_CONFIG_FILE
#include NS_EVENTLOOP_USER_CONFIG_FILE
#endif
#endif /* EVENTLOOP_CONFIG_H_ */

401
source/event.c Normal file
View File

@ -0,0 +1,401 @@
/*
* Copyright (c) 2014-2015 ARM Limited. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <string.h>
#include "ns_types.h"
#include "ns_list.h"
#include "eventOS_event.h"
#include "eventOS_scheduler.h"
#include "timer_sys.h"
#include "nsdynmemLIB.h"
#include "ns_timer.h"
#include "event.h"
#include "platform/arm_hal_interrupt.h"
typedef struct arm_core_tasklet {
int8_t id; /**< Event handler Tasklet ID */
void (*func_ptr)(arm_event_s *);
ns_list_link_t link;
} arm_core_tasklet_t;
static NS_LIST_DEFINE(arm_core_tasklet_list, arm_core_tasklet_t, link);
static NS_LIST_DEFINE(event_queue_active, arm_event_storage_t, link);
static NS_LIST_DEFINE(free_event_entry, arm_event_storage_t, link);
// Statically allocate initial pool of events.
#define STARTUP_EVENT_POOL_SIZE 10
static arm_event_storage_t startup_event_pool[STARTUP_EVENT_POOL_SIZE];
/** Curr_tasklet tell to core and platform which task_let is active, Core Update this automatic when switch Tasklet. */
int8_t curr_tasklet = 0;
static arm_core_tasklet_t *tasklet_dynamically_allocate(void);
static arm_event_storage_t *event_dynamically_allocate(void);
static arm_event_storage_t *event_core_get(void);
static void event_core_write(arm_event_storage_t *event);
static arm_core_tasklet_t *event_tasklet_handler_get(uint8_t tasklet_id)
{
ns_list_foreach(arm_core_tasklet_t, cur, &arm_core_tasklet_list) {
if (cur->id == tasklet_id) {
return cur;
}
}
return NULL;
}
bool event_tasklet_handler_id_valid(uint8_t tasklet_id)
{
return event_tasklet_handler_get(tasklet_id);
}
// XXX this can return 0, but 0 seems to mean "none" elsewhere? Or at least
// curr_tasklet is reset to 0 in various places.
static int8_t tasklet_get_free_id(void)
{
/*(Note use of uint8_t to avoid overflow if we reach 0x7F)*/
for (uint8_t i = 0; i <= INT8_MAX; i++) {
if (!event_tasklet_handler_get(i)) {
return i;
}
}
return -1;
}
int8_t eventOS_event_handler_create(void (*handler_func_ptr)(arm_event_s *), uint8_t init_event_type)
{
arm_event_storage_t *event_tmp;
// XXX Do we really want to prevent multiple tasklets with same function?
ns_list_foreach(arm_core_tasklet_t, cur, &arm_core_tasklet_list) {
if (cur->func_ptr == handler_func_ptr) {
return -1;
}
}
//Allocate new
arm_core_tasklet_t *new = tasklet_dynamically_allocate();
if (!new) {
return -2;
}
event_tmp = event_core_get();
if (!event_tmp) {
ns_dyn_mem_free(new);
return -2;
}
//Fill in tasklet; add to list
new->id = tasklet_get_free_id();
new->func_ptr = handler_func_ptr;
ns_list_add_to_end(&arm_core_tasklet_list, new);
//Queue "init" event for the new task
event_tmp->data.receiver = new->id;
event_tmp->data.sender = 0;
event_tmp->data.event_type = init_event_type;
event_tmp->data.event_data = 0;
event_core_write(event_tmp);
return new->id;
}
int8_t eventOS_event_send(const arm_event_t *event)
{
if (event_tasklet_handler_get(event->receiver)) {
arm_event_storage_t *event_tmp = event_core_get();
if (event_tmp) {
event_tmp->data = *event;
event_core_write(event_tmp);
return 0;
}
}
return -1;
}
void eventOS_event_send_user_allocated(arm_event_storage_t *event)
{
event->allocator = ARM_LIB_EVENT_USER;
event_core_write(event);
}
void eventOS_event_send_timer_allocated(arm_event_storage_t *event)
{
event->allocator = ARM_LIB_EVENT_TIMER;
event_core_write(event);
}
void eventOS_event_cancel_critical(arm_event_storage_t *event)
{
ns_list_remove(&event_queue_active, event);
}
static arm_event_storage_t *event_dynamically_allocate(void)
{
arm_event_storage_t *event = ns_dyn_mem_temporary_alloc(sizeof(arm_event_storage_t));
if (event) {
event->allocator = ARM_LIB_EVENT_DYNAMIC;
}
return event;
}
static arm_core_tasklet_t *tasklet_dynamically_allocate(void)
{
return ns_dyn_mem_alloc(sizeof(arm_core_tasklet_t));
}
arm_event_storage_t *event_core_get(void)
{
arm_event_storage_t *event;
platform_enter_critical();
event = ns_list_get_first(&free_event_entry);
if (event) {
ns_list_remove(&free_event_entry, event);
} else {
event = event_dynamically_allocate();
}
if (event) {
event->data.data_ptr = NULL;
event->data.priority = ARM_LIB_LOW_PRIORITY_EVENT;
}
platform_exit_critical();
return event;
}
void event_core_free_push(arm_event_storage_t *free)
{
free->state = ARM_LIB_EVENT_UNQUEUED;
switch (free->allocator) {
case ARM_LIB_EVENT_STARTUP_POOL:
platform_enter_critical();
ns_list_add_to_start(&free_event_entry, free);
platform_exit_critical();
break;
case ARM_LIB_EVENT_DYNAMIC:
// Free all dynamically allocated events.
ns_dyn_mem_free(free);
break;
case ARM_LIB_EVENT_TIMER:
// Hand it back to the timer system
timer_sys_event_free(free);
break;
case ARM_LIB_EVENT_USER:
default:
break;
}
}
static arm_event_storage_t *event_core_read(void)
{
platform_enter_critical();
arm_event_storage_t *event = ns_list_get_first(&event_queue_active);
if (event) {
event->state = ARM_LIB_EVENT_RUNNING;
ns_list_remove(&event_queue_active, event);
}
platform_exit_critical();
return event;
}
void event_core_write(arm_event_storage_t *event)
{
platform_enter_critical();
bool added = false;
ns_list_foreach(arm_event_storage_t, event_tmp, &event_queue_active) {
// note enum ordering means we're checking if event_tmp is LOWER priority than event
if (event_tmp->data.priority > event->data.priority) {
ns_list_add_before(&event_queue_active, event_tmp, event);
added = true;
break;
}
}
if (!added) {
ns_list_add_to_end(&event_queue_active, event);
}
event->state = ARM_LIB_EVENT_QUEUED;
/* Wake From Idle */
platform_exit_critical();
eventOS_scheduler_signal();
}
// Requires lock to be held
arm_event_storage_t *eventOS_event_find_by_id_critical(uint8_t tasklet_id, uint8_t event_id)
{
ns_list_foreach(arm_event_storage_t, cur, &event_queue_active) {
if (cur->data.receiver == tasklet_id && cur->data.event_id == event_id) {
return cur;
}
}
return NULL;
}
/**
*
* \brief Initialize Nanostack Core.
*
* Function Initialize Nanostack Core, Socket Interface,Buffer memory and Send Init event to all Tasklett which are Defined.
*
*/
void eventOS_scheduler_init(void)
{
/* Reset Event List variables */
ns_list_init(&free_event_entry);
ns_list_init(&event_queue_active);
ns_list_init(&arm_core_tasklet_list);
//Add first 10 entries to "free" list
for (unsigned i = 0; i < (sizeof(startup_event_pool) / sizeof(startup_event_pool[0])); i++) {
startup_event_pool[i].allocator = ARM_LIB_EVENT_STARTUP_POOL;
ns_list_add_to_start(&free_event_entry, &startup_event_pool[i]);
}
/* Init Generic timer module */
timer_sys_init(); //initialize timer
/* Set Tasklett switcher to Idle */
curr_tasklet = 0;
}
int8_t eventOS_scheduler_get_active_tasklet(void)
{
return curr_tasklet;
}
void eventOS_scheduler_set_active_tasklet(int8_t tasklet)
{
curr_tasklet = tasklet;
}
int eventOS_scheduler_timer_stop(void)
{
timer_sys_disable();
if (ns_timer_sleep() != 0) {
return 1;
}
return 0;
}
int eventOS_scheduler_timer_synch_after_sleep(uint32_t sleep_ticks)
{
//Update MS to 10ms ticks
sleep_ticks /= 10;
sleep_ticks++;
system_timer_tick_update(sleep_ticks);
if (timer_sys_wakeup() == 0) {
return 0;
}
return -1;
}
/**
*
* \brief Infinite Event Read Loop.
*
* Function Read and handle Cores Event and switch/enable tasklet which are event receiver. WhenEvent queue is empty it goes to sleep
*
*/
bool eventOS_scheduler_dispatch_event(void)
{
curr_tasklet = 0;
arm_event_storage_t *cur_event = event_core_read();
if (!cur_event) {
return false;
}
curr_tasklet = cur_event->data.receiver;
arm_core_tasklet_t *tasklet = event_tasklet_handler_get(curr_tasklet);
/* Do not bother with check for NULL - tasklets cannot be deleted,
* and user-facing API eventOS_event_send() has already checked the tasklet
* exists, so there is no possible issue there.
*
* For eventOS_event_send_user_allocated(), it would be a non-recoverable
* error to not deliver the message - we have to have a receiver to pass
* ownership to. If the lookup fails, let it crash. We want the send call
* itself to return void to simplify logic.
*/
/* Tasklet Scheduler Call */
tasklet->func_ptr(&cur_event->data);
event_core_free_push(cur_event);
/* Set Current Tasklet to Idle state */
curr_tasklet = 0;
return true;
}
void eventOS_scheduler_run_until_idle(void)
{
while (eventOS_scheduler_dispatch_event());
}
/**
*
* \brief Infinite Event Read Loop.
*
* Function Read and handle Cores Event and switch/enable tasklet which are event receiver. WhenEvent queue is empty it goes to sleep
*
*/
NS_NORETURN void eventOS_scheduler_run(void)
{
while (1) {
if (!eventOS_scheduler_dispatch_event()) {
eventOS_scheduler_idle();
}
}
}
void eventOS_cancel(arm_event_storage_t *event)
{
if (!event) {
return;
}
platform_enter_critical();
/*
* Notify timer of cancellation.
*/
if (event->allocator == ARM_LIB_EVENT_TIMER) {
timer_sys_event_cancel_critical(event);
}
/*
* Remove event from the list,
* Only queued can be removed, unqued are either timers or stale pointers
* RUNNING cannot be removed, we are currenly "in" that event.
*/
if (event->state == ARM_LIB_EVENT_QUEUED) {
eventOS_event_cancel_critical(event);
}
/*
* Push back to "free" state
*/
if (event->state != ARM_LIB_EVENT_RUNNING) {
event_core_free_push(event);
}
platform_exit_critical();
}

34
source/event.h Normal file
View File

@ -0,0 +1,34 @@
/*
* Copyright (c) 2017 ARM Limited. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef NS_EVENT_H_
#define NS_EVENT_H_
#ifdef __cplusplus
extern "C" {
#endif
bool event_tasklet_handler_id_valid(uint8_t tasklet_id);
void eventOS_event_send_timer_allocated(arm_event_storage_t *event);
// This requires lock to be held
arm_event_storage_t *eventOS_event_find_by_id_critical(uint8_t tasklet_id, uint8_t event_id);
#ifdef __cplusplus
}
#endif
#endif /*NS_EVENT_H_*/

View File

@ -0,0 +1,71 @@
/*
* Copyright (c) 2016 ARM Limited, All Rights Reserved
*/
// Include before mbed.h to properly get UINT*_C()
#include "ns_types.h"
#include "platform/arm_hal_timer.h"
#include "platform/arm_hal_interrupt.h"
#if defined(NS_EVENTLOOP_USE_TICK_TIMER) && defined(YOTTA_CFG_MINAR)
#include "minar/minar.h"
#include "mbed-drivers/mbed.h"
#include "core-util/FunctionPointer.h"
#include "core-util/Event.h"
#define TICK_TIMER_ID 1
using minar::Scheduler;
using minar::milliseconds;
using minar::callback_handle_t;
using namespace mbed::util;
static callback_handle_t sys_timer_handle;
static void (*tick_timer_callback)(void);
void timer_callback(void const *funcArgument)
{
(void)funcArgument;
if (NULL != tick_timer_callback) {
tick_timer_callback();
}
}
// Low precision platform tick timer
int8_t platform_tick_timer_register(void (*tick_timer_cb_handler)(void))
{
tick_timer_callback = tick_timer_cb_handler;
return TICK_TIMER_ID;
}
int8_t platform_tick_timer_start(uint32_t period_ms)
{
int8_t retval = -1;
if (sys_timer_handle != NULL) {
return 0; // Timer already started already so return success
}
Event e = FunctionPointer1<void, void const *>(timer_callback).bind(NULL);
if (e != NULL) {
sys_timer_handle = Scheduler::postCallback(e).period(milliseconds(period_ms)).getHandle();
if (sys_timer_handle != NULL) {
retval = 0;
}
}
return retval;
}
int8_t platform_tick_timer_stop(void)
{
int8_t retval = -1;
if (sys_timer_handle != NULL) {
Scheduler::cancelCallback(sys_timer_handle);
sys_timer_handle = NULL;
retval = 0;
}
return retval;
}
#endif // defined(NS_EVENTLOOP_USE_TICK_TIMER) && defined(YOTTA_CFG)

115
source/ns_timeout.c Normal file
View File

@ -0,0 +1,115 @@
/*
* Copyright (c) 2014-2015 ARM Limited. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "eventOS_event.h"
#include "eventOS_event_timer.h"
#include "nsdynmemLIB.h"
#include "ns_list.h"
#include "timer_sys.h"
#define STARTUP_EVENT 0
#define TIMER_EVENT 1
// Timeout structure, already typedefed to timeout_t
struct timeout_entry_t {
void (*callback)(void *);
void *arg;
arm_event_storage_t *event;
};
static int8_t timeout_tasklet_id = -1;
static void timeout_tasklet(arm_event_s *event)
{
if (TIMER_EVENT != event->event_type) {
return;
}
timeout_t *t = event->data_ptr;
arm_event_storage_t *storage = t->event;
sys_timer_struct_s *timer = NS_CONTAINER_OF(storage, sys_timer_struct_s, event);
t->callback(t->arg);
// Check if this was periodic timer
if (timer->period == 0) {
ns_dyn_mem_free(event->data_ptr);
}
}
static timeout_t *eventOS_timeout_at_(void (*callback)(void *), void *arg, uint32_t at, uint32_t period)
{
arm_event_storage_t *storage;
timeout_t *timeout = ns_dyn_mem_alloc(sizeof(timeout_t));
if (!timeout) {
return NULL;
}
timeout->callback = callback;
timeout->arg = arg;
// Start timeout taskled if it is not running
if (-1 == timeout_tasklet_id) {
timeout_tasklet_id = eventOS_event_handler_create(timeout_tasklet, STARTUP_EVENT);
if (timeout_tasklet_id < 0) {
timeout_tasklet_id = -1;
goto FAIL;
}
}
arm_event_t event = {
.receiver = timeout_tasklet_id,
.sender = timeout_tasklet_id,
.event_type = TIMER_EVENT,
.event_id = TIMER_EVENT,
.data_ptr = timeout
};
if (period)
storage = eventOS_event_timer_request_every(&event, period);
else
storage = eventOS_event_timer_request_at(&event, at);
timeout->event = storage;
if (storage)
return timeout;
FAIL:
ns_dyn_mem_free(timeout);
return NULL;
}
timeout_t *eventOS_timeout_ms(void (*callback)(void *), uint32_t ms, void *arg)
{
return eventOS_timeout_at_(callback, arg, eventOS_event_timer_ms_to_ticks(ms)+eventOS_event_timer_ticks(), 0);
}
timeout_t *eventOS_timeout_every_ms(void (*callback)(void *), uint32_t every, void *arg)
{
return eventOS_timeout_at_(callback, arg, 0, eventOS_event_timer_ms_to_ticks(every));
}
void eventOS_timeout_cancel(timeout_t *t)
{
if (!t)
return;
eventOS_cancel(t->event);
// Defer the freeing until returning from the callback
if (t->event->state != ARM_LIB_EVENT_RUNNING) {
ns_dyn_mem_free(t);
}
}

391
source/ns_timer.c Normal file
View File

@ -0,0 +1,391 @@
/*
* Copyright (c) 2014-2015 ARM Limited. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ns_types.h"
#include "ns_list.h"
#include "ns_timer.h"
#include "eventOS_callback_timer.h"
#include "platform/arm_hal_interrupt.h"
#include "platform/arm_hal_timer.h"
#include "nsdynmemLIB.h"
#ifndef NS_EXCLUDE_HIGHRES_TIMER
typedef enum ns_timer_state_e {
NS_TIMER_ACTIVE = 0, // Will run on the next HAL interrupt
NS_TIMER_HOLD, // Will run on a later HAL interrupt
NS_TIMER_RUN_INTERRUPT, // Running on the interrupt we're currently handling
NS_TIMER_STOP // Timer not scheduled ("start" not called since last callback)
} ns_timer_state_e;
typedef struct ns_timer_struct {
int8_t ns_timer_id;
ns_timer_state_e timer_state;
uint16_t slots;
uint16_t remaining_slots;
void (*interrupt_handler)(int8_t, uint16_t);
ns_list_link_t link;
} ns_timer_struct;
static NS_LIST_DEFINE(ns_timer_list, ns_timer_struct, link);
#define NS_TIMER_RUNNING 1
static uint8_t ns_timer_state = 0;
#ifdef ATMEGA256RFR2
#define COMPENSATION 3
#define COMPENSATION_TUNE 1
#else
#define COMPENSATION 0
#define COMPENSATION_TUNE 0
#endif
static void ns_timer_interrupt_handler(void);
static ns_timer_struct *ns_timer_get_pointer_to_timer_struct(int8_t timer_id);
static bool ns_timer_initialized = 0;
int8_t eventOS_callback_timer_register(void (*timer_interrupt_handler)(int8_t, uint16_t))
{
int8_t retval = -1;
if (!ns_timer_initialized) {
/*Set interrupt handler in HAL driver*/
platform_timer_set_cb(ns_timer_interrupt_handler);
ns_timer_initialized = 1;
}
/*Find first free timer ID in timer list*/
/*(Note use of uint8_t to avoid overflow if we reach 0x7F)*/
for (uint8_t i = 0; i <= INT8_MAX; i++) {
if (!ns_timer_get_pointer_to_timer_struct(i)) {
retval = i;
break;
}
}
if (retval == -1) {
return -1;
}
ns_timer_struct *new_timer = ns_dyn_mem_alloc(sizeof(ns_timer_struct));
if (!new_timer) {
return -1;
}
/*Initialise new timer*/
new_timer->ns_timer_id = retval;
new_timer->timer_state = NS_TIMER_STOP;
new_timer->remaining_slots = 0;
new_timer->interrupt_handler = timer_interrupt_handler;
// Critical section sufficient as long as list can't be reordered from
// interrupt, otherwise will need to cover whole routine
platform_enter_critical();
ns_list_add_to_end(&ns_timer_list, new_timer);
platform_exit_critical();
/*Return timer ID*/
return retval;
}
int8_t eventOS_callback_timer_unregister(int8_t ns_timer_id)
{
ns_timer_struct *current_timer;
current_timer = ns_timer_get_pointer_to_timer_struct(ns_timer_id);
if (!current_timer) {
return -1;
}
// Critical section sufficient as long as list can't be reordered from
// interrupt, otherwise will need to cover whole routine
platform_enter_critical();
ns_list_remove(&ns_timer_list, current_timer);
platform_exit_critical();
ns_dyn_mem_free(current_timer);
return 0;
}
static int8_t ns_timer_start_pl_timer(uint16_t pl_timer_start_slots)
{
/*Don't start timer with 0 slots*/
if (!pl_timer_start_slots) {
pl_timer_start_slots = 1;
}
/*Start HAL timer*/
platform_timer_start(pl_timer_start_slots);
/*Set HAL timer state to running*/
ns_timer_state |= NS_TIMER_RUNNING;
return 0;
}
int8_t ns_timer_sleep(void)
{
int8_t ret_val = -1;
if (ns_timer_state & NS_TIMER_RUNNING) {
/*Start HAL timer*/
platform_timer_disable();
/*Set HAL timer state to running*/
ns_timer_state &= ~NS_TIMER_RUNNING;
ret_val = 0;
}
return ret_val;
}
static int8_t ns_timer_get_next_running_to(void)
{
uint8_t hold_count = 0;
ns_timer_struct *first_timer = NULL;
/*Find hold-labelled timer with the least remaining slots*/
ns_list_foreach(ns_timer_struct, current_timer, &ns_timer_list) {
if (current_timer->timer_state == NS_TIMER_HOLD) {
if (!first_timer || current_timer->remaining_slots < first_timer->remaining_slots) {
first_timer = current_timer;
}
/*For optimisation, count the found timers*/
hold_count++;
}
}
if (!first_timer) {
return 0;
}
/*If hold-labelled timer found, set it active and start the HAL driver*/
hold_count--;
first_timer->timer_state = NS_TIMER_ACTIVE;
/*Compensate time spent in timer function*/
if (first_timer->remaining_slots > COMPENSATION) {
first_timer->remaining_slots -= COMPENSATION;
}
/*Start HAL timer*/
ns_timer_start_pl_timer(first_timer->remaining_slots);
/*Update other hold-labelled timers*/
ns_list_foreach(ns_timer_struct, current_timer, &ns_timer_list) {
if (hold_count == 0) { // early termination optimisation
break;
}
if (current_timer->timer_state == NS_TIMER_HOLD) {
if (current_timer->remaining_slots == first_timer->remaining_slots) {
current_timer->timer_state = NS_TIMER_ACTIVE;
} else {
current_timer->remaining_slots -= first_timer->remaining_slots;
/*Compensate time spent in timer function*/
if (current_timer->remaining_slots > COMPENSATION) {
current_timer->remaining_slots -= COMPENSATION;
}
}
hold_count--;
}
}
return 0;
}
static ns_timer_struct *ns_timer_get_pointer_to_timer_struct(int8_t timer_id)
{
/*Find timer with the given ID*/
ns_list_foreach(ns_timer_struct, current_timer, &ns_timer_list) {
if (current_timer->ns_timer_id == timer_id) {
return current_timer;
}
}
return NULL;
}
int8_t eventOS_callback_timer_start(int8_t ns_timer_id, uint16_t slots)
{
int8_t ret_val = 0;
uint16_t pl_timer_remaining_slots;
ns_timer_struct *timer;
platform_enter_critical();
/*Find timer to be activated*/
timer = ns_timer_get_pointer_to_timer_struct(ns_timer_id);
if (!timer) {
ret_val = -1;
goto exit;
}
// XXX this assumes the timer currently isn't running?
// Is event.c relying on this restarting HAL timer after ns_timer_sleep()?
/*If any timers are active*/
if (ns_timer_state & NS_TIMER_RUNNING) {
/*Get remaining slots of the currently activated timeout*/
pl_timer_remaining_slots = platform_timer_get_remaining_slots();
/*New timeout is shorter than currently enabled timeout*/
if (pl_timer_remaining_slots > slots) {
/*Start HAL timer*/
ns_timer_start_pl_timer(slots - 0);
ns_list_foreach(ns_timer_struct, current_timer, &ns_timer_list) {
/*Switch active timers to hold*/
if (current_timer->timer_state == NS_TIMER_ACTIVE) {
current_timer->timer_state = NS_TIMER_HOLD;
current_timer->remaining_slots = 0;
}
/*Update hold-labelled timers*/
if (current_timer->timer_state == NS_TIMER_HOLD) {
current_timer->remaining_slots += (pl_timer_remaining_slots - slots);
/*Compensate time spent in timer function*/
if (current_timer->remaining_slots > (COMPENSATION - COMPENSATION_TUNE)) {
current_timer->remaining_slots -= (COMPENSATION - COMPENSATION_TUNE);
}
}
}
/*Mark active and start the timer*/
timer->timer_state = NS_TIMER_ACTIVE;
timer->slots = slots;
timer->remaining_slots = slots;
}
/*New timeout is longer than currently enabled timeout*/
else if (pl_timer_remaining_slots < slots) {
/*Mark hold and update remaining slots*/
timer->timer_state = NS_TIMER_HOLD;
timer->slots = slots;
timer->remaining_slots = (slots - pl_timer_remaining_slots);
}
/*New timeout is equal to currently enabled timeout*/
else {
/*Mark it active and it will be handled in next interrupt*/
timer->timer_state = NS_TIMER_ACTIVE;
timer->slots = slots;
timer->remaining_slots = slots;
}
} else {
/*No timers running*/
timer->timer_state = NS_TIMER_HOLD;
timer->slots = slots;
timer->remaining_slots = slots;
/*Start next timeout*/
ns_timer_get_next_running_to();
}
exit:
platform_exit_critical();
return ret_val;
}
static void ns_timer_interrupt_handler(void)
{
uint8_t i = 0;
platform_enter_critical();
/*Clear timer running state*/
ns_timer_state &= ~NS_TIMER_RUNNING;
/*Mark active timers as NS_TIMER_RUN_INTERRUPT, interrupt functions are called at the end of this function*/
ns_list_foreach(ns_timer_struct, current_timer, &ns_timer_list) {
if (current_timer->timer_state == NS_TIMER_ACTIVE) {
current_timer->timer_state = NS_TIMER_RUN_INTERRUPT;
/*For optimisation, count the found timers*/
i++;
}
}
/*Start next timeout*/
ns_timer_get_next_running_to();
/*Call interrupt functions*/
ns_list_foreach(ns_timer_struct, current_timer, &ns_timer_list) {
if (i == 0) {
break;
}
if (current_timer->timer_state == NS_TIMER_RUN_INTERRUPT) {
current_timer->timer_state = NS_TIMER_STOP;
current_timer->interrupt_handler(current_timer->ns_timer_id, current_timer->slots);
i--;
}
}
platform_exit_critical();
}
int8_t eventOS_callback_timer_stop(int8_t ns_timer_id)
{
uint16_t pl_timer_remaining_slots;
bool active_timer_found = false;
ns_timer_struct *current_timer;
ns_timer_struct *first_timer = NULL;
int8_t retval = -1;
platform_enter_critical();
/*Find timer with given timer ID*/
current_timer = ns_timer_get_pointer_to_timer_struct(ns_timer_id);
if (!current_timer) {
goto exit;
}
retval = 0;
/*Check if already stopped*/
if (current_timer->timer_state == NS_TIMER_STOP) {
goto exit;
}
current_timer->timer_state = NS_TIMER_STOP;
current_timer->remaining_slots = 0;
/*Check if some timer is already active*/
ns_list_foreach(ns_timer_struct, curr_timer, &ns_timer_list) {
if (curr_timer->timer_state == NS_TIMER_ACTIVE) {
active_timer_found = true;
break;
}
}
/*If no active timers found, start one*/
if (!active_timer_found) {
pl_timer_remaining_slots = platform_timer_get_remaining_slots();
/*Find hold-labelled timer with the least remaining slots*/
ns_list_foreach(ns_timer_struct, cur_timer, &ns_timer_list) {
if (cur_timer->timer_state == NS_TIMER_HOLD) {
cur_timer->remaining_slots += pl_timer_remaining_slots;
if (!first_timer || cur_timer->remaining_slots < first_timer->remaining_slots) {
first_timer = cur_timer;
}
}
}
/*If hold-labelled timer found, set it active and start the HAL driver*/
if (first_timer) {
first_timer->timer_state = NS_TIMER_ACTIVE;
/*Start HAL timer*/
ns_timer_start_pl_timer(first_timer->remaining_slots);
/*If some of the other hold-labelled timers have the same remaining slots as the timer_tmp, mark them active*/
ns_list_foreach(ns_timer_struct, cur_timer, &ns_timer_list) {
if (cur_timer->timer_state == NS_TIMER_HOLD) {
if (cur_timer->remaining_slots == first_timer->remaining_slots) {
cur_timer->timer_state = NS_TIMER_ACTIVE;
} else {
cur_timer->remaining_slots -= first_timer->remaining_slots;
}
}
}
}
}
exit:
platform_exit_critical();
return retval;
}
#endif // NS_EXCLUDE_HIGHRES_TIMER

35
source/ns_timer.h Normal file
View File

@ -0,0 +1,35 @@
/*
* Copyright (c) 2014-2015 ARM Limited. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef NS_TIMER_H_
#define NS_TIMER_H_
#include "platform/eventloop_config.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifndef NS_EXCLUDE_HIGHRES_TIMER
extern int8_t ns_timer_sleep(void);
#else
#define ns_timer_sleep() ((int8_t) 0)
#endif
#ifdef __cplusplus
}
#endif
#endif /*NS_TIMER_H_*/

373
source/system_timer.c Normal file
View File

@ -0,0 +1,373 @@
/*
* Copyright (c) 2014-2015 ARM Limited. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ns_types.h"
#include "ns_list.h"
#include "timer_sys.h"
#include "platform/arm_hal_interrupt.h"
#include "platform/arm_hal_timer.h"
#include "nsdynmemLIB.h"
#include "eventOS_event.h"
#include "eventOS_event_timer.h"
#include "event.h"
#include "eventOS_callback_timer.h"
#include "ns_timer.h"
#ifndef ST_MAX
#define ST_MAX 6
#endif
static sys_timer_struct_s startup_sys_timer_pool[ST_MAX];
#define TIMER_SLOTS_PER_MS 20
NS_STATIC_ASSERT(1000 % EVENTOS_EVENT_TIMER_HZ == 0, "Need whole number of ms per tick")
#define TIMER_SYS_TICK_PERIOD (1000 / EVENTOS_EVENT_TIMER_HZ) // milliseconds
// timer_sys_ticks must be read in critical section to guarantee
// atomicity on 16-bit platforms
static volatile uint32_t timer_sys_ticks;
static NS_LIST_DEFINE(system_timer_free, sys_timer_struct_s, event.link);
static NS_LIST_DEFINE(system_timer_list, sys_timer_struct_s, event.link);
static sys_timer_struct_s *sys_timer_dynamically_allocate(void);
static void timer_sys_interrupt(void);
static void timer_sys_add(sys_timer_struct_s *timer);
#ifndef NS_EVENTLOOP_USE_TICK_TIMER
static int8_t platform_tick_timer_start(uint32_t period_ms);
/* Implement platform tick timer using eventOS timer */
// platform tick timer callback function
static void (*tick_timer_callback)(void);
static int8_t tick_timer_id = -1; // eventOS timer id for tick timer
// EventOS timer callback function
static void tick_timer_eventOS_callback(int8_t timer_id, uint16_t slots)
{
// Not interested in timer id or slots
(void)slots;
// Call the tick timer callback
if (tick_timer_callback != NULL && timer_id == tick_timer_id) {
platform_tick_timer_start(TIMER_SYS_TICK_PERIOD);
tick_timer_callback();
}
}
static int8_t platform_tick_timer_register(void (*tick_timer_cb)(void))
{
tick_timer_callback = tick_timer_cb;
tick_timer_id = eventOS_callback_timer_register(tick_timer_eventOS_callback);
return tick_timer_id;
}
static int8_t platform_tick_timer_start(uint32_t period_ms)
{
return eventOS_callback_timer_start(tick_timer_id, TIMER_SLOTS_PER_MS * period_ms);
}
static int8_t platform_tick_timer_stop(void)
{
return eventOS_callback_timer_stop(tick_timer_id);
}
#endif // !NS_EVENTLOOP_USE_TICK_TIMER
/*
* Initializes timers and starts system timer
*/
void timer_sys_init(void)
{
for (uint8_t i = 0; i < ST_MAX; i++) {
ns_list_add_to_start(&system_timer_free, &startup_sys_timer_pool[i]);
}
platform_tick_timer_register(timer_sys_interrupt);
platform_tick_timer_start(TIMER_SYS_TICK_PERIOD);
}
/*-------------------SYSTEM TIMER FUNCTIONS--------------------------*/
void timer_sys_disable(void)
{
platform_tick_timer_stop();
}
/*
* Starts ticking system timer interrupts every 10ms
*/
int8_t timer_sys_wakeup(void)
{
return platform_tick_timer_start(TIMER_SYS_TICK_PERIOD);
}
static void timer_sys_interrupt(void)
{
system_timer_tick_update(1);
}
/* * * * * * * * * */
static sys_timer_struct_s *sys_timer_dynamically_allocate(void)
{
return ns_dyn_mem_alloc(sizeof(sys_timer_struct_s));
}
static sys_timer_struct_s *timer_struct_get(void)
{
sys_timer_struct_s *timer;
platform_enter_critical();
timer = ns_list_get_first(&system_timer_free);
if (timer) {
ns_list_remove(&system_timer_free, timer);
} else {
timer = sys_timer_dynamically_allocate();
}
platform_exit_critical();
return timer;
}
void timer_sys_event_free(arm_event_storage_t *event)
{
platform_enter_critical();
sys_timer_struct_s *timer = NS_CONTAINER_OF(event, sys_timer_struct_s, event);
if (timer->period == 0) {
// Non-periodic - return to free list
ns_list_add_to_start(&system_timer_free, timer);
} else {
// Periodic - check due time of next launch
timer->launch_time += timer->period;
if (TICKS_BEFORE_OR_AT(timer->launch_time, timer_sys_ticks)) {
// next event is overdue - queue event now
eventOS_event_send_timer_allocated(&timer->event);
} else {
// add back to timer queue for the future
timer_sys_add(timer);
}
}
platform_exit_critical();
}
void timer_sys_event_cancel_critical(struct arm_event_storage *event)
{
sys_timer_struct_s *timer = NS_CONTAINER_OF(event, sys_timer_struct_s, event);
timer->period = 0;
// If its unqueued it is on my timer list, otherwise it is in event-loop.
if (event->state == ARM_LIB_EVENT_UNQUEUED) {
ns_list_remove(&system_timer_list, timer);
}
}
uint32_t eventOS_event_timer_ticks(void)
{
uint32_t ret_val;
// Enter/exit critical is a bit clunky, but necessary on 16-bit platforms,
// which won't be able to do an atomic 32-bit read.
platform_enter_critical();
ret_val = timer_sys_ticks;
platform_exit_critical();
return ret_val;
}
/* Called internally with lock held */
static void timer_sys_add(sys_timer_struct_s *timer)
{
uint32_t at = timer->launch_time;
// Find first timer scheduled to run after us, and insert before it.
// (This means timers scheduled for same time run in order of request)
ns_list_foreach(sys_timer_struct_s, t, &system_timer_list) {
if (TICKS_BEFORE(at, t->launch_time)) {
ns_list_add_before(&system_timer_list, t, timer);
return;
}
}
// Didn't insert before another timer, so must be last.
ns_list_add_to_end(&system_timer_list, timer);
}
/* Called internally with lock held */
static arm_event_storage_t *eventOS_event_timer_request_at_(const arm_event_t *event, uint32_t at, uint32_t period)
{
// Because we use user-allocated events, they must get delivered to avoid
// a leak. Previously this call queued timers for invalid tasks, then they
// would go undelivered. Now it returns an error.
if (!event_tasklet_handler_id_valid(event->receiver)) {
return NULL;
}
sys_timer_struct_s *timer = timer_struct_get();
if (!timer) {
return NULL;
}
timer->event.data = *event;
timer->event.allocator = ARM_LIB_EVENT_TIMER;
timer->event.state = ARM_LIB_EVENT_UNQUEUED;
timer->launch_time = at;
timer->period = period;
if (TICKS_BEFORE_OR_AT(at, timer_sys_ticks)) {
eventOS_event_send_timer_allocated(&timer->event);
} else {
timer_sys_add(timer);
}
return &timer->event;
}
arm_event_storage_t *eventOS_event_timer_request_at(const arm_event_t *event, uint32_t at)
{
platform_enter_critical();
arm_event_storage_t *ret = eventOS_event_timer_request_at_(event, at, 0);
platform_exit_critical();
return ret;
}
arm_event_storage_t *eventOS_event_timer_request_in(const arm_event_t *event, int32_t in)
{
platform_enter_critical();
arm_event_storage_t *ret = eventOS_event_timer_request_at_(event, timer_sys_ticks + in, 0);
platform_exit_critical();
return ret;
}
arm_event_storage_t *eventOS_event_timer_request_every(const arm_event_t *event, int32_t period)
{
if (period <= 0) {
return NULL;
}
platform_enter_critical();
arm_event_storage_t *ret = eventOS_event_timer_request_at_(event, timer_sys_ticks + period, period);
platform_exit_critical();
return ret;
}
int8_t eventOS_event_timer_request(uint8_t event_id, uint8_t event_type, int8_t tasklet_id, uint32_t time)
{
const arm_event_t event = {
.event_id = event_id,
.event_type = event_type,
.receiver = tasklet_id,
.sender = 0,
.data_ptr = NULL,
.event_data = 0,
.priority = ARM_LIB_MED_PRIORITY_EVENT,
};
// Legacy time behaviour preserved
// Note that someone wanting 20ms gets 2 ticks, thanks to this test. 30ms would be 4 ticks.
// And why shouldn't they be able to get a 1-tick callback?
if (time > 2 * TIMER_SYS_TICK_PERIOD) {
time /= TIMER_SYS_TICK_PERIOD;
// XXX Why this? Someone wanting 50ms shouldn't get 6 ticks. Round to nearest, maybe?
time++;
} else {
time = 2;
}
platform_enter_critical();
arm_event_storage_t *ret = eventOS_event_timer_request_at_(&event, timer_sys_ticks + time, 0);
platform_exit_critical();
return ret?0:-1;
}
int8_t eventOS_event_timer_cancel(uint8_t event_id, int8_t tasklet_id)
{
platform_enter_critical();
/* First check pending timers */
ns_list_foreach(sys_timer_struct_s, cur, &system_timer_list) {
if (cur->event.data.receiver == tasklet_id && cur->event.data.event_id == event_id) {
eventOS_cancel(&cur->event);
goto done;
}
}
/* No pending timer, so check for already-pending event */
arm_event_storage_t *event = eventOS_event_find_by_id_critical(tasklet_id, event_id);
if (event && event->allocator == ARM_LIB_EVENT_TIMER) {
eventOS_cancel(event);
goto done;
}
/* No match found */
platform_exit_critical();
return -1;
done:
platform_exit_critical();
return 0;
}
uint32_t eventOS_event_timer_shortest_active_timer(void)
{
uint32_t ret_val = 0;
platform_enter_critical();
sys_timer_struct_s *first = ns_list_get_first(&system_timer_list);
if (first == NULL) {
// Weird API has 0 for "no events"
ret_val = 0;
} else if (TICKS_BEFORE_OR_AT(first->launch_time, timer_sys_ticks)) {
// Which means an immediate/overdue event has to be 1
ret_val = 1;
} else {
ret_val = first->launch_time - timer_sys_ticks;
}
platform_exit_critical();
return eventOS_event_timer_ticks_to_ms(ret_val);
}
void system_timer_tick_update(uint32_t ticks)
{
platform_enter_critical();
//Keep runtime time
timer_sys_ticks += ticks;
ns_list_foreach_safe(sys_timer_struct_s, cur, &system_timer_list) {
if (TICKS_BEFORE_OR_AT(cur->launch_time, timer_sys_ticks)) {
// Unthread from our list
ns_list_remove(&system_timer_list, cur);
// Make it an event (can't fail - no allocation)
// event system will call our timer_sys_event_free on event delivery.
eventOS_event_send_timer_allocated(&cur->event);
} else {
// List is ordered, so as soon as we see a later event, we're done.
break;
}
}
platform_exit_critical();
}

60
source/timer_sys.h Normal file
View File

@ -0,0 +1,60 @@
/*
* Copyright (c) 2014-2015 ARM Limited. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _PL_NANO_TIMER_SYS_H_
#define _PL_NANO_TIMER_SYS_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "eventOS_event.h"
/* We borrow base event storage, including its list link, and add a time field */
typedef struct sys_timer_struct_s {
arm_event_storage_t event;
uint32_t launch_time; // tick value
uint32_t period;
} sys_timer_struct_s;
/**
* Initialize system timer
* */
extern void timer_sys_init(void);
extern uint32_t timer_get_runtime_ticks(void);
int8_t timer_sys_wakeup(void);
void timer_sys_disable(void);
void timer_sys_event_free(struct arm_event_storage *event);
// This require lock to be held
void timer_sys_event_cancel_critical(struct arm_event_storage *event);
/**
* System Timer update and synch after sleep
*
* \param ticks Time in 10 ms resolution
*
* \return none
*
* */
void system_timer_tick_update(uint32_t ticks);
#ifdef __cplusplus
}
#endif
#endif /*_PL_NANO_TIMER_SYS_H_*/