Add christmas edition
This commit is contained in:
parent
2f1c7d9e82
commit
b62af486a7
74 changed files with 3422 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -5,4 +5,3 @@
|
|||
**/.vs
|
||||
**/bin
|
||||
.DS_Store
|
||||
christmas
|
||||
|
|
|
|||
19
christmas/AdAstra.atsln
Normal file
19
christmas/AdAstra.atsln
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Atmel Studio Solution File, Format Version 11.00
|
||||
VisualStudioVersion = 14.0.23107.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "AdAstra", "AdAstra\AdAstra.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Release|AVR = Release|AVR
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.ActiveCfg = Release|AVR
|
||||
{DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.Build.0 = Release|AVR
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
4
christmas/AdAstra/AdAstra.componentinfo.xml
Normal file
4
christmas/AdAstra/AdAstra.componentinfo.xml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Store xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="AtmelPackComponentManagement">
|
||||
<ProjectComponents />
|
||||
</Store>
|
||||
396
christmas/AdAstra/AdAstra.cproj
Normal file
396
christmas/AdAstra/AdAstra.cproj
Normal file
|
|
@ -0,0 +1,396 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="14.0">
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectVersion>7.0</ProjectVersion>
|
||||
<ToolchainName>com.Atmel.AVRGCC8.C</ToolchainName>
|
||||
<ProjectGuid>dce6c7e3-ee26-4d79-826b-08594b9ad897</ProjectGuid>
|
||||
<avrdevice>ATtiny85</avrdevice>
|
||||
<avrdeviceseries>none</avrdeviceseries>
|
||||
<OutputType>Executable</OutputType>
|
||||
<Language>C</Language>
|
||||
<OutputFileName>$(MSBuildProjectName)</OutputFileName>
|
||||
<OutputFileExtension>.elf</OutputFileExtension>
|
||||
<OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>
|
||||
<AssemblyName>TestProject</AssemblyName>
|
||||
<Name>TestProject</Name>
|
||||
<RootNamespace>TestProject</RootNamespace>
|
||||
<ToolchainFlavour>Native</ToolchainFlavour>
|
||||
<KeepTimersRunning>false</KeepTimersRunning>
|
||||
<OverrideVtor>false</OverrideVtor>
|
||||
<CacheFlash>false</CacheFlash>
|
||||
<ProgFlashFromRam>true</ProgFlashFromRam>
|
||||
<RamSnippetAddress>0x20000000</RamSnippetAddress>
|
||||
<UncachedRange />
|
||||
<preserveEEPROM>false</preserveEEPROM>
|
||||
<OverrideVtorValue>exception_table</OverrideVtorValue>
|
||||
<BootSegment>2</BootSegment>
|
||||
<ResetRule>0</ResetRule>
|
||||
<eraseonlaunchrule>0</eraseonlaunchrule>
|
||||
<EraseKey />
|
||||
<AsfFrameworkConfig>
|
||||
<framework-data>
|
||||
<options />
|
||||
<configurations />
|
||||
<files />
|
||||
<documentation help="" />
|
||||
<offline-documentation help="" />
|
||||
<dependencies>
|
||||
<content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.47.0" />
|
||||
</dependencies>
|
||||
</framework-data>
|
||||
</AsfFrameworkConfig>
|
||||
<avrtool>com.atmel.avrdbg.tool.ispmk2</avrtool>
|
||||
<avrtoolserialnumber>000200212345</avrtoolserialnumber>
|
||||
<avrdeviceexpectedsignature>0x1E930B</avrdeviceexpectedsignature>
|
||||
<avrtoolinterface>ISP</avrtoolinterface>
|
||||
<avrtoolinterfaceclock>125000</avrtoolinterfaceclock>
|
||||
<com_atmel_avrdbg_tool_ispmk2>
|
||||
<ToolOptions>
|
||||
<InterfaceProperties>
|
||||
<IspClock>125000</IspClock>
|
||||
</InterfaceProperties>
|
||||
<InterfaceName>ISP</InterfaceName>
|
||||
</ToolOptions>
|
||||
<ToolType>com.atmel.avrdbg.tool.ispmk2</ToolType>
|
||||
<ToolNumber>000200212345</ToolNumber>
|
||||
<ToolName>AVRISP mkII</ToolName>
|
||||
</com_atmel_avrdbg_tool_ispmk2>
|
||||
<com_atmel_avrdbg_tool_simulator>
|
||||
<ToolOptions xmlns="">
|
||||
<InterfaceProperties>
|
||||
</InterfaceProperties>
|
||||
<InterfaceName>
|
||||
</InterfaceName>
|
||||
</ToolOptions>
|
||||
<ToolType xmlns="">com.atmel.avrdbg.tool.simulator</ToolType>
|
||||
<ToolNumber xmlns="">
|
||||
</ToolNumber>
|
||||
<ToolName xmlns="">Simulator</ToolName>
|
||||
</com_atmel_avrdbg_tool_simulator>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<ToolchainSettings>
|
||||
<AvrGcc>
|
||||
<avrgcc.common.Device>-mmcu=attiny85 -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.3.229\gcc\dev\attiny85"</avrgcc.common.Device>
|
||||
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
|
||||
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
|
||||
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
|
||||
<avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
|
||||
<avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
|
||||
<avrgcc.compiler.general.SubroutinesFunctionPrologues>True</avrgcc.compiler.general.SubroutinesFunctionPrologues>
|
||||
<avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
|
||||
<avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
|
||||
<avrgcc.compiler.symbols.DefSymbols>
|
||||
<ListValues>
|
||||
<Value>NDEBUG</Value>
|
||||
</ListValues>
|
||||
</avrgcc.compiler.symbols.DefSymbols>
|
||||
<avrgcc.compiler.directories.IncludePaths>
|
||||
<ListValues>
|
||||
<Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.3.229\include</Value>
|
||||
<Value>../src/macros</Value>
|
||||
</ListValues>
|
||||
</avrgcc.compiler.directories.IncludePaths>
|
||||
<avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>
|
||||
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
|
||||
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
|
||||
<avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
|
||||
<avrgcc.compiler.warnings.ExtraWarnings>True</avrgcc.compiler.warnings.ExtraWarnings>
|
||||
<avrgcc.compiler.warnings.Undefined>True</avrgcc.compiler.warnings.Undefined>
|
||||
<avrgcc.linker.libraries.Libraries>
|
||||
<ListValues>
|
||||
<Value>libm</Value>
|
||||
</ListValues>
|
||||
</avrgcc.linker.libraries.Libraries>
|
||||
<avrgcc.assembler.general.IncludePaths>
|
||||
<ListValues>
|
||||
<Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.3.229\include</Value>
|
||||
</ListValues>
|
||||
</avrgcc.assembler.general.IncludePaths>
|
||||
</AvrGcc>
|
||||
</ToolchainSettings>
|
||||
<OutputFileName>ad_astra</OutputFileName>
|
||||
<OutputFileExtension>.elf</OutputFileExtension>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<ToolchainSettings>
|
||||
<AvrGcc>
|
||||
<avrgcc.common.Device>-mmcu=attiny85 -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.3.229\gcc\dev\attiny85"</avrgcc.common.Device>
|
||||
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
|
||||
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
|
||||
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
|
||||
<avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
|
||||
<avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
|
||||
<avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
|
||||
<avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
|
||||
<avrgcc.compiler.symbols.DefSymbols>
|
||||
<ListValues>
|
||||
<Value>DEBUG</Value>
|
||||
</ListValues>
|
||||
</avrgcc.compiler.symbols.DefSymbols>
|
||||
<avrgcc.compiler.directories.IncludePaths>
|
||||
<ListValues>
|
||||
<Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.3.229\include</Value>
|
||||
</ListValues>
|
||||
</avrgcc.compiler.directories.IncludePaths>
|
||||
<avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>
|
||||
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
|
||||
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
|
||||
<avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>
|
||||
<avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
|
||||
<avrgcc.linker.libraries.Libraries>
|
||||
<ListValues>
|
||||
<Value>libm</Value>
|
||||
</ListValues>
|
||||
</avrgcc.linker.libraries.Libraries>
|
||||
<avrgcc.assembler.general.IncludePaths>
|
||||
<ListValues>
|
||||
<Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.3.229\include</Value>
|
||||
</ListValues>
|
||||
</avrgcc.assembler.general.IncludePaths>
|
||||
<avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>
|
||||
</AvrGcc>
|
||||
</ToolchainSettings>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'WithUART' ">
|
||||
<ToolchainSettings>
|
||||
<AvrGcc>
|
||||
<avrgcc.common.Device>-mmcu=attiny85 -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.3.229\gcc\dev\attiny85"</avrgcc.common.Device>
|
||||
<avrgcc.common.optimization.RelaxBranches>True</avrgcc.common.optimization.RelaxBranches>
|
||||
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
|
||||
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
|
||||
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
|
||||
<avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
|
||||
<avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
|
||||
<avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
|
||||
<avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
|
||||
<avrgcc.compiler.symbols.DefSymbols>
|
||||
<ListValues>
|
||||
<Value>NDEBUG</Value>
|
||||
<Value>UART_ENABLED</Value>
|
||||
</ListValues>
|
||||
</avrgcc.compiler.symbols.DefSymbols>
|
||||
<avrgcc.compiler.directories.IncludePaths>
|
||||
<ListValues>
|
||||
<Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.3.229\include</Value>
|
||||
</ListValues>
|
||||
</avrgcc.compiler.directories.IncludePaths>
|
||||
<avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>
|
||||
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
|
||||
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
|
||||
<avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
|
||||
<avrgcc.compiler.warnings.ExtraWarnings>True</avrgcc.compiler.warnings.ExtraWarnings>
|
||||
<avrgcc.compiler.warnings.Undefined>True</avrgcc.compiler.warnings.Undefined>
|
||||
<avrgcc.linker.libraries.Libraries>
|
||||
<ListValues>
|
||||
<Value>libm</Value>
|
||||
</ListValues>
|
||||
</avrgcc.linker.libraries.Libraries>
|
||||
<avrgcc.assembler.general.IncludePaths>
|
||||
<ListValues>
|
||||
<Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.3.229\include</Value>
|
||||
</ListValues>
|
||||
</avrgcc.assembler.general.IncludePaths>
|
||||
</AvrGcc>
|
||||
</ToolchainSettings>
|
||||
<OutputFileName>ad_astra</OutputFileName>
|
||||
<OutputFileExtension>.elf</OutputFileExtension>
|
||||
<OutputPath>bin\WithUART\</OutputPath>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="src\driver\sleep\sleep.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\hardware_access\hardware_access.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\hardware_access\hardware_access.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\hardware_access\output_pins\output_pins.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\hardware_access\output_pins\output_pins.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\hardware_access\power_saving\power_saving.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\hardware_access\spi\spi.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\hardware_access\spi\spi.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\hardware_access\timing\timing.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\hardware_access\timing\timing.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\driver\display\display.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\driver\display\display.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\driver\infra\infra.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\driver\infra\infra.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\driver\sleep\sleep.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\macros\bitwise.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\macros\math.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\macros\null.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\main.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\mediator\mediator.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\mediator\mediator.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\objects\ai\ai.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\objects\ai\ai.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\objects\commands\commands.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\objects\commands\commands.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\objects\event_generator\event_generator.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\objects\event_generator\event_generator.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\objects\object.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\objects\object.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\objects\object_container\object_container.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\objects\object_container\object_container.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\objects\prototype.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\objects\types\asteroid\asteroid.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\objects\types\asteroid\asteroid.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\objects\types\astronaut\astronaut.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\objects\types\astronaut\astronaut.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\objects\types\background\background.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\objects\types\background\background.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\objects\types\bullet\bullet.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\objects\types\bullet\bullet.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\objects\types\spaceship\spaceship.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\objects\types\spaceship\spaceship.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\objects\types\sprites.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\objects\types\sprites.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\objects\types\text\text.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\objects\types\text\text.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\objects\types\text\texts.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\objects\types\text\texts.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\util\random\random.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\util\random\random.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\util\rectangle\rectangle.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\util\rectangle\rectangle.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\util\vec2\vec2.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\util\vec2\vec2.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="src" />
|
||||
<Folder Include="src\driver\" />
|
||||
<Folder Include="src\driver\display\" />
|
||||
<Folder Include="src\driver\infra\" />
|
||||
<Folder Include="src\driver\sleep\" />
|
||||
<Folder Include="src\hardware_access\" />
|
||||
<Folder Include="src\hardware_access\output_pins" />
|
||||
<Folder Include="src\hardware_access\power_saving\" />
|
||||
<Folder Include="src\hardware_access\spi\" />
|
||||
<Folder Include="src\hardware_access\timing\" />
|
||||
<Folder Include="src\macros\" />
|
||||
<Folder Include="src\mediator\" />
|
||||
<Folder Include="src\objects\" />
|
||||
<Folder Include="src\objects\ai\" />
|
||||
<Folder Include="src\objects\commands\" />
|
||||
<Folder Include="src\objects\event_generator\" />
|
||||
<Folder Include="src\objects\object_container\" />
|
||||
<Folder Include="src\objects\types\" />
|
||||
<Folder Include="src\objects\types\asteroid\" />
|
||||
<Folder Include="src\objects\types\astronaut\" />
|
||||
<Folder Include="src\objects\types\background\" />
|
||||
<Folder Include="src\objects\types\bullet\" />
|
||||
<Folder Include="src\objects\types\text" />
|
||||
<Folder Include="src\objects\types\spaceship\" />
|
||||
<Folder Include="src\util\" />
|
||||
<Folder Include="src\util\random\" />
|
||||
<Folder Include="src\util\rectangle\" />
|
||||
<Folder Include="src\util\vec2\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />
|
||||
</Project>
|
||||
86
christmas/AdAstra/AdAstra.xml
Normal file
86
christmas/AdAstra/AdAstra.xml
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Store xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="AtmelPackComponentManagement">
|
||||
<ProjectComponents>
|
||||
<ProjectComponent z:Id="i1" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/">
|
||||
<CApiVersion></CApiVersion>
|
||||
<CBundle></CBundle>
|
||||
<CClass>Device</CClass>
|
||||
<CGroup>Startup</CGroup>
|
||||
<CSub></CSub>
|
||||
<CVariant></CVariant>
|
||||
<CVendor>Atmel</CVendor>
|
||||
<CVersion>1.3.0</CVersion>
|
||||
<DefaultRepoPath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs</DefaultRepoPath>
|
||||
<DependentComponents xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" />
|
||||
<Description></Description>
|
||||
<Files xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
|
||||
<d4p1:anyType i:type="FileInfo">
|
||||
<AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.229\include</AbsolutePath>
|
||||
<Attribute></Attribute>
|
||||
<Category>include</Category>
|
||||
<Condition>C</Condition>
|
||||
<FileContentHash i:nil="true" />
|
||||
<FileVersion></FileVersion>
|
||||
<Name>include</Name>
|
||||
<SelectString></SelectString>
|
||||
<SourcePath></SourcePath>
|
||||
</d4p1:anyType>
|
||||
<d4p1:anyType i:type="FileInfo">
|
||||
<AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.229\include\avr\iotn85.h</AbsolutePath>
|
||||
<Attribute></Attribute>
|
||||
<Category>header</Category>
|
||||
<Condition>C</Condition>
|
||||
<FileContentHash>RcYmivGpgsCGGCzeWAIjcA==</FileContentHash>
|
||||
<FileVersion></FileVersion>
|
||||
<Name>include/avr/iotn85.h</Name>
|
||||
<SelectString></SelectString>
|
||||
<SourcePath></SourcePath>
|
||||
</d4p1:anyType>
|
||||
<d4p1:anyType i:type="FileInfo">
|
||||
<AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.229\templates\main.c</AbsolutePath>
|
||||
<Attribute>template</Attribute>
|
||||
<Category>source</Category>
|
||||
<Condition>C Exe</Condition>
|
||||
<FileContentHash>9ptzGqB00V1zM0TC00KMag==</FileContentHash>
|
||||
<FileVersion></FileVersion>
|
||||
<Name>templates/main.c</Name>
|
||||
<SelectString>Main file (.c)</SelectString>
|
||||
<SourcePath></SourcePath>
|
||||
</d4p1:anyType>
|
||||
<d4p1:anyType i:type="FileInfo">
|
||||
<AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.229\templates\main.cpp</AbsolutePath>
|
||||
<Attribute>template</Attribute>
|
||||
<Category>source</Category>
|
||||
<Condition>C Exe</Condition>
|
||||
<FileContentHash>YXFphlh0CtZJU+ebktABgQ==</FileContentHash>
|
||||
<FileVersion></FileVersion>
|
||||
<Name>templates/main.cpp</Name>
|
||||
<SelectString>Main file (.cpp)</SelectString>
|
||||
<SourcePath></SourcePath>
|
||||
</d4p1:anyType>
|
||||
<d4p1:anyType i:type="FileInfo">
|
||||
<AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.229\gcc\dev\attiny85</AbsolutePath>
|
||||
<Attribute></Attribute>
|
||||
<Category>libraryPrefix</Category>
|
||||
<Condition>GCC</Condition>
|
||||
<FileContentHash i:nil="true" />
|
||||
<FileVersion></FileVersion>
|
||||
<Name>gcc/dev/attiny85</Name>
|
||||
<SelectString></SelectString>
|
||||
<SourcePath></SourcePath>
|
||||
</d4p1:anyType>
|
||||
</Files>
|
||||
<PackName>ATtiny_DFP</PackName>
|
||||
<PackPath>C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.229/Atmel.ATtiny_DFP.pdsc</PackPath>
|
||||
<PackVersion>1.3.229</PackVersion>
|
||||
<PresentInProject>true</PresentInProject>
|
||||
<ReferenceConditionId>ATtiny85</ReferenceConditionId>
|
||||
<RteComponents xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
|
||||
<d4p1:string></d4p1:string>
|
||||
</RteComponents>
|
||||
<Status>Resolved</Status>
|
||||
<VersionMode>Fixed</VersionMode>
|
||||
<IsComponentInAtProject>true</IsComponentInAtProject>
|
||||
</ProjectComponent>
|
||||
</ProjectComponents>
|
||||
</Store>
|
||||
137
christmas/AdAstra/src/driver/display/display.c
Normal file
137
christmas/AdAstra/src/driver/display/display.c
Normal file
|
|
@ -0,0 +1,137 @@
|
|||
#include "display.h"
|
||||
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
#include "bitwise.h"
|
||||
#include "math.h"
|
||||
#include "../../hardware_access/hardware_access.h"
|
||||
|
||||
|
||||
static uint8_t const configuration[] PROGMEM = {
|
||||
0xD5, 0xF0, // set clock frequency
|
||||
0x8D, 0x14, // enable charge pump
|
||||
0x20, 0x00, // horizontal addressing mode
|
||||
0xD6, 0x01, // 2 times vertical zoom
|
||||
0x22, 0x00, 0x03, // only draw to the top half of the screen
|
||||
0xAF // display on
|
||||
};
|
||||
|
||||
static struct {
|
||||
uint8_t compositingBuffer[DISPLAY_WIDTH_IN_PIXELS];
|
||||
Rectangle compositingWindow;
|
||||
DrawFunction drawEverything;
|
||||
bool wasIntersection;
|
||||
} display;
|
||||
|
||||
static inline void commandMode() {
|
||||
setOutputPin(DISPLAY_DC_OUTPUT_PIN, false);
|
||||
}
|
||||
|
||||
static inline void dataMode() {
|
||||
setOutputPin(DISPLAY_DC_OUTPUT_PIN, true);
|
||||
}
|
||||
|
||||
void setDisplayContrast(uint8_t value) {
|
||||
commandMode();
|
||||
sendByteOnSPI(0x81);
|
||||
sendByteOnSPI(value);
|
||||
dataMode();
|
||||
}
|
||||
|
||||
void turnDisplayOnOff(bool shouldBeOn) {
|
||||
commandMode();
|
||||
sendByteOnSPI(0x8D | shouldBeOn); // set charge pump on/off
|
||||
sendByteOnSPI(0x10 | shouldBeOn << 2); // set charge pump on/off
|
||||
sendByteOnSPI(0xAE | shouldBeOn); // turn display sleep on/off
|
||||
dataMode();
|
||||
}
|
||||
|
||||
void initializeDisplay(DrawFunction drawEverything) {
|
||||
setOutputPin(DISPLAY_RESET_OUTPUT_PIN, false);
|
||||
for (volatile uint8_t i = 0; i != 255; i++)
|
||||
;
|
||||
// some time has to elapse before the next line gets called,
|
||||
// otherwise the display wont turn on
|
||||
setOutputPin(DISPLAY_RESET_OUTPUT_PIN, true);
|
||||
|
||||
for (uint8_t i = 0; i < sizeof(configuration); i++) {
|
||||
sendByteOnSPI(pgm_read_byte(configuration + i));
|
||||
}
|
||||
|
||||
display.drawEverything = drawEverything;
|
||||
setDisplayContrast(255);
|
||||
dataMode();
|
||||
}
|
||||
|
||||
void startIntersectionTest(Rectangle compositingWindow) {
|
||||
display.wasIntersection = false;
|
||||
display.compositingWindow = compositingWindow;
|
||||
}
|
||||
|
||||
bool endIntersectionTest() {
|
||||
for (uint8_t x = 0; x < DISPLAY_WIDTH_IN_PIXELS; x++) {
|
||||
display.compositingBuffer[x] = 0;
|
||||
}
|
||||
return display.wasIntersection;
|
||||
}
|
||||
|
||||
void drawFrame() {
|
||||
display.compositingWindow = DEFAULT_COMPOSITING_WINDOW;
|
||||
for (display.compositingWindow.position.y = 0; display.compositingWindow.position.y < DISPLAY_HEIGHT_IN_PIXELS; display.compositingWindow.position.y += 8) {
|
||||
display.drawEverything(display.compositingWindow);
|
||||
|
||||
for (uint8_t x = 0; x < DISPLAY_WIDTH_IN_PIXELS; x++) {
|
||||
sendByteOnSPI(display.compositingBuffer[x]);
|
||||
sendByteOnSPI(display.compositingBuffer[x]);
|
||||
display.compositingBuffer[x] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void compositePixelColumn(uint8_t x, uint8_t invertedMask, uint8_t fill) {
|
||||
if (display.compositingBuffer[x] & fill) {
|
||||
display.wasIntersection = true;
|
||||
}
|
||||
display.compositingBuffer[x] = (display.compositingBuffer[x] & (~invertedMask)) | fill;
|
||||
}
|
||||
|
||||
void drawBitmapFromProgMem(Rectangle boundingBox, uint16_t const bitmap[boundingBox.size.x][(boundingBox.size.y + 7) / 8], bool isMirrored) {
|
||||
boundingBox.position = substract(boundingBox.position, display.compositingWindow.position);
|
||||
|
||||
uint8_t spriteY = max(0, -boundingBox.position.y);
|
||||
uint8_t spriteYByte = spriteY >> 3;
|
||||
|
||||
for (uint8_t x = max(0, -boundingBox.position.x); x < boundingBox.size.x && boundingBox.position.x + x < DISPLAY_WIDTH_IN_PIXELS; x++) {
|
||||
uint8_t spriteX = isMirrored ? boundingBox.size.x - x - 1 : x;
|
||||
uint16_t currentPixelColumn = pgm_read_word(&bitmap[spriteX][spriteYByte]);
|
||||
|
||||
uint8_t fill, invertedMask;
|
||||
if (boundingBox.position.y >= 0) {
|
||||
fill = (currentPixelColumn & 0x00FF) << boundingBox.position.y;
|
||||
invertedMask = currentPixelColumn >> 8 << boundingBox.position.y;
|
||||
} else {
|
||||
uint16_t lowerPixelColumn = spriteYByte + 1 < (boundingBox.size.y + 7) / 8 ? pgm_read_word(&bitmap[spriteX][spriteYByte + 1]) : 0;
|
||||
uint8_t shift = spriteY % 8;
|
||||
uint8_t inverseShift = 8 - shift;
|
||||
|
||||
fill = ((currentPixelColumn & 0x00FF) >> shift) | ((lowerPixelColumn & 0x0FF) << inverseShift);
|
||||
invertedMask = (currentPixelColumn >> 8 >> shift) | (lowerPixelColumn >> 8 << inverseShift);
|
||||
}
|
||||
|
||||
compositePixelColumn(boundingBox.position.x + x, invertedMask, fill);
|
||||
}
|
||||
}
|
||||
|
||||
void drawFilledRectangle(Rectangle box, uint8_t invertedMask, uint8_t fill) {
|
||||
box.position = substract(box.position, display.compositingWindow.position);
|
||||
|
||||
uint8_t upperGapHeight = min(8, max(0, box.position.y));
|
||||
uint8_t lowerGapHeight = min(8, max(0, 8 - (box.position.y + box.size.y)));
|
||||
|
||||
uint8_t actualFill = (fill >> lowerGapHeight) & (fill << upperGapHeight);
|
||||
uint8_t actualInvertedMask = (invertedMask >> lowerGapHeight) & (invertedMask << upperGapHeight);
|
||||
|
||||
for (uint8_t x = max(0, box.position.x); x < box.position.x + box.size.x && x < DISPLAY_WIDTH_IN_PIXELS; x++) {
|
||||
compositePixelColumn(x, actualInvertedMask, actualFill);
|
||||
}
|
||||
}
|
||||
74
christmas/AdAstra/src/driver/display/display.h
Normal file
74
christmas/AdAstra/src/driver/display/display.h
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
#ifndef DISPLAY_H
|
||||
#define DISPLAY_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <avr/io.h>
|
||||
|
||||
#include "../../util/rectangle/rectangle.h"
|
||||
|
||||
|
||||
/*
|
||||
SPI driver for D096-12864
|
||||
*/
|
||||
|
||||
#define DISPLAY_RESET_OUTPUT_PIN PB0
|
||||
#define DISPLAY_DC_OUTPUT_PIN PB4
|
||||
|
||||
// A two-times downscaling is used for greater performance
|
||||
#define DISPLAY_WIDTH_IN_PIXELS 64
|
||||
#define DISPLAY_HEIGHT_IN_PIXELS 32
|
||||
|
||||
// To easily access the window size
|
||||
#define WINDOW ((Rectangle){(Vec2){0, 0}, (Vec2){DISPLAY_WIDTH_IN_PIXELS, DISPLAY_HEIGHT_IN_PIXELS}})
|
||||
|
||||
// To conserve RAM, drawing is done in chunks of DEFAULT_COMPOSITING_WINDOW size
|
||||
// instead of buffering the whole display and writing it out at once
|
||||
#define DEFAULT_COMPOSITING_WINDOW ((Rectangle){(Vec2){0, 0}, (Vec2){DISPLAY_WIDTH_IN_PIXELS, 8}})
|
||||
|
||||
typedef void (*DrawFunction)(Rectangle);
|
||||
|
||||
// Call DrawFunction n times after a call to drawFrame has been made
|
||||
void initializeDisplay(DrawFunction drawEverything);
|
||||
|
||||
// Set a the brightness of the display
|
||||
// Value can be any number between 0 and 255.
|
||||
void setDisplayContrast(uint8_t value);
|
||||
|
||||
// To conserve program memory, pixel based intersection test
|
||||
// is implemented here.
|
||||
// Calling draw functions after calling startIntersectionTest
|
||||
// will set a wasIntersection bit appropriately.
|
||||
|
||||
// Clear buffer and wasIntersection bit
|
||||
void startIntersectionTest();
|
||||
|
||||
// Make the display go to / return from sleep
|
||||
void turnDisplayOnOff(bool shouldBeOn);
|
||||
|
||||
// Return wasIntersection bit
|
||||
bool endIntersectionTest();
|
||||
|
||||
// Initiate a draw sequence
|
||||
void drawFrame();
|
||||
|
||||
// Draw a sprite of size boundingBox.size at boundingBox.position from bitmap
|
||||
// if isMirrored then mirror around the vertical axis
|
||||
// Bitmap's data is interpreted the following way:
|
||||
/*
|
||||
Each 16 bit word corresponds to an 8 pixel high column.
|
||||
(These columns are laid out horizontally from left to right. Unfortunately,
|
||||
the display uses this addressing mode.) The higher 8 bits of the word is the
|
||||
inverted mask and the lower 8 bits are the fill bits.
|
||||
newPixelColumn = oldPixelColumn & ~invertedMask | fill;
|
||||
|
||||
This seemingly weird layout is used to take advantage of SIMD operations
|
||||
and speed up the drawing process significantly.
|
||||
*/
|
||||
void drawBitmapFromProgMem(Rectangle boundingBox, uint16_t const bitmap[boundingBox.size.x][(boundingBox.size.y + 7) / 8], bool isMirrored);
|
||||
|
||||
// Draw a one byte repeated texture covering the parameter box
|
||||
// for a white rectangle use these arguments: invertedMask: don't care, fill: 0xFF
|
||||
// for a black rectangle use these arguments: invertedMask: 0xFF, fill: 0x00
|
||||
void drawFilledRectangle(Rectangle box, uint8_t invertedMask, uint8_t fill);
|
||||
|
||||
#endif
|
||||
144
christmas/AdAstra/src/driver/infra/infra.c
Normal file
144
christmas/AdAstra/src/driver/infra/infra.c
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
#include "infra.h"
|
||||
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
|
||||
#include "bitwise.h"
|
||||
#include "../../hardware_access/hardware_access.h"
|
||||
|
||||
|
||||
// (0.5625 + (0.5625 + 1.6875) / 2) / 1000 / timer interval
|
||||
#define MEAN_OF_0_1_BIT_TIMES 53
|
||||
// 9 / 2 / 1000 / timer interval
|
||||
#define MAYBE_ONE_CHECK_TIME 141
|
||||
// some large value
|
||||
#define TIMEOUT 254
|
||||
|
||||
typedef enum {
|
||||
idle, maybeLeadingOne, leadingOneConfirmed, activeFirstBit, active, timingOut
|
||||
} ProtocolState;
|
||||
|
||||
typedef enum {
|
||||
noMatch, foundStartingByte, significantByte, waitingForEndOfCommand, waitingForRepeat
|
||||
} CommandState;
|
||||
|
||||
static struct {
|
||||
uint8_t current;
|
||||
uint8_t bitPosition;
|
||||
ProtocolState protocolState;
|
||||
CommandState commandState;
|
||||
OnCommandReceived onCommandReceived;
|
||||
} infra;
|
||||
|
||||
|
||||
static void saveCurrentByte() {
|
||||
uint8_t byte = infra.current;
|
||||
infra.current = 0;
|
||||
infra.bitPosition = 0;
|
||||
|
||||
if (byte == INFRA_ADDRESS) {
|
||||
infra.commandState = foundStartingByte;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (infra.commandState) {
|
||||
case foundStartingByte:
|
||||
infra.commandState = significantByte;
|
||||
break;
|
||||
case significantByte:
|
||||
infra.onCommandReceived(byte);
|
||||
infra.commandState = waitingForEndOfCommand;
|
||||
break;
|
||||
case waitingForEndOfCommand:
|
||||
if (byte == 0) {
|
||||
infra.commandState = waitingForRepeat;
|
||||
}
|
||||
break;
|
||||
case waitingForRepeat:
|
||||
if (byte == 0) {
|
||||
infra.onCommandReceived(REPEAT_CODE);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void saveBit(uint8_t bit) {
|
||||
infra.current <<= 1;
|
||||
infra.current |= bit;
|
||||
if (++infra.bitPosition == 8) {
|
||||
saveCurrentByte();
|
||||
}
|
||||
}
|
||||
|
||||
static inline uint8_t isIrOff() {
|
||||
return getBit(PINB, IR_PIN);
|
||||
}
|
||||
|
||||
static inline uint8_t isIrOn() {
|
||||
return !isIrOff();
|
||||
}
|
||||
|
||||
ISR(PCINT0_vect) {
|
||||
switch (infra.protocolState) {
|
||||
case idle:
|
||||
if (isIrOn()) {
|
||||
enableTimerB(MAYBE_ONE_CHECK_TIME);
|
||||
infra.protocolState = maybeLeadingOne;
|
||||
}
|
||||
break;
|
||||
case maybeLeadingOne:
|
||||
infra.protocolState = idle;
|
||||
break;
|
||||
case leadingOneConfirmed:
|
||||
if (isIrOff()) {
|
||||
infra.protocolState = activeFirstBit;
|
||||
}
|
||||
break;
|
||||
case activeFirstBit:
|
||||
case timingOut:
|
||||
if (isIrOn()) {
|
||||
infra.protocolState = active;
|
||||
enableTimerB(MEAN_OF_0_1_BIT_TIMES);
|
||||
}
|
||||
break;
|
||||
case active:
|
||||
if (isIrOn()) {
|
||||
saveBit(1);
|
||||
enableTimerB(MEAN_OF_0_1_BIT_TIMES);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ISR(TIM0_COMPB_vect) {
|
||||
switch (infra.protocolState) {
|
||||
case maybeLeadingOne:
|
||||
if (isIrOn()) {
|
||||
infra.protocolState = leadingOneConfirmed;
|
||||
}
|
||||
disableTimerB();
|
||||
break;
|
||||
case active:
|
||||
saveBit(0);
|
||||
infra.protocolState = timingOut;
|
||||
enableTimerB(TIMEOUT);
|
||||
break;
|
||||
case timingOut:
|
||||
infra.protocolState = idle;
|
||||
saveCurrentByte();
|
||||
disableTimerB();
|
||||
break;
|
||||
default:
|
||||
disableTimerB();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void initializeInfra(OnCommandReceived onCommandReceived) {
|
||||
setBit(PORTB, IR_PIN); // enable pull-up
|
||||
setBit(PCMSK, IR_PIN); // specific pin change interrupt enable
|
||||
setBit(GIMSK, PCIE); // global on pin change interrupt enable;
|
||||
infra.onCommandReceived = onCommandReceived;
|
||||
}
|
||||
24
christmas/AdAstra/src/driver/infra/infra.h
Normal file
24
christmas/AdAstra/src/driver/infra/infra.h
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#ifndef INFRA_H
|
||||
#define INFRA_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <avr/io.h>
|
||||
|
||||
|
||||
/*
|
||||
Custom NEC implementation using a TSOP4838
|
||||
*/
|
||||
|
||||
#define INFRA_ADDRESS 255
|
||||
#define IR_PIN PB3
|
||||
#define REPEAT_CODE 1
|
||||
|
||||
typedef void (*OnCommandReceived)(uint8_t);
|
||||
typedef void (*OnReceiveStarted)();
|
||||
|
||||
// Initialize infra and call onCommandReceived with every received byte
|
||||
// Call onCommandReceived with the argument REPEAT_CODE if a repeat code
|
||||
// has been received.
|
||||
void initializeInfra(OnCommandReceived onCommandReceived);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,120 @@
|
|||
#include "redundant_storage.h"
|
||||
|
||||
#include "../../hardware_access/hardware_access.h"
|
||||
|
||||
#define offsetof(type, member) __builtin_offsetof (type, member)
|
||||
|
||||
#define OBJECT_VALIDITY_MASK (0b00111111)
|
||||
#define IS_USING_PAGE_A_BIT 6
|
||||
#define IS_VALID_BIT 7
|
||||
#define METADATA_REDUNDANCY 4
|
||||
|
||||
typedef struct {
|
||||
uint8_t redundantBufferA[REDUNDANT_BUFFER_SIZE];
|
||||
uint8_t redundantBufferB[REDUNDANT_BUFFER_SIZE];
|
||||
uint8_t metadata[METADATA_REDUNDANCY];
|
||||
} MemoryLayout;
|
||||
|
||||
static volatile struct {
|
||||
MemoryLayout buffer;
|
||||
uint8_t saveIndex;
|
||||
uint8_t* savePointer;
|
||||
uint8_t loadIndex;
|
||||
uint8_t* loadPointer;
|
||||
uint8_t validMetadata;
|
||||
bool isEEPROMWriting;
|
||||
} storage;
|
||||
|
||||
static inline bool isUsingPageA() {
|
||||
return getBit(storage.validMetadata, IS_USING_PAGE_A_BIT);
|
||||
}
|
||||
|
||||
bool isValid() {
|
||||
return getBit(storage.validMetadata, IS_VALID_BIT);
|
||||
}
|
||||
|
||||
static inline void fixMetadata() {
|
||||
uint8_t a = storage.buffer.metadata[0];
|
||||
uint8_t b = storage.buffer.metadata[1];
|
||||
uint8_t c = storage.buffer.metadata[2];
|
||||
uint8_t d = storage.buffer.metadata[3];
|
||||
|
||||
if (a == b || a == c || a == d) {
|
||||
storage.validMetadata = a;
|
||||
} else if (b == c || b == d) {
|
||||
storage.validMetadata = b;
|
||||
} else {
|
||||
storage.validMetadata = c;
|
||||
}
|
||||
}
|
||||
|
||||
void initializeRedundantStorage() {
|
||||
for (uint8_t i = 0; i < sizeof(MemoryLayout); i++) {
|
||||
((uint8_t*)&storage.buffer)[i] = loadSavedByteEEPROM(i);
|
||||
}
|
||||
|
||||
fixMetadata();
|
||||
}
|
||||
|
||||
void invalidateEEPROM() {
|
||||
for (uint8_t i = 0; i < sizeof(MemoryLayout); i++) {
|
||||
((uint8_t*)&storage.buffer)[i] = 0;
|
||||
}
|
||||
|
||||
storage.validMetadata = 0;
|
||||
}
|
||||
|
||||
void onEEPROMWriteFinished(__attribute__((unused)) uint8_t* _) {
|
||||
storage.isEEPROMWriting = false;
|
||||
}
|
||||
|
||||
bool startSchedulingObjectsForSaving() {
|
||||
if (storage.isEEPROMWriting) {
|
||||
return false;
|
||||
}
|
||||
|
||||
toggleBit(storage.validMetadata, IS_USING_PAGE_A_BIT);
|
||||
storage.validMetadata &= ~OBJECT_VALIDITY_MASK;
|
||||
storage.saveIndex = 0;
|
||||
storage.savePointer = isUsingPageA() ?
|
||||
storage.buffer.redundantBufferA
|
||||
: storage.buffer.redundantBufferB;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void scheduleNextObjectForSave(uint8_t* object, uint8_t size) {
|
||||
setBit(storage.validMetadata, storage.saveIndex);
|
||||
storage.saveIndex++;
|
||||
for (uint8_t i = 0; i < size; i++) {
|
||||
*storage.savePointer = object[i];
|
||||
storage.savePointer++;
|
||||
}
|
||||
}
|
||||
|
||||
void saveScheduledObjects() {
|
||||
setBit(storage.validMetadata, IS_VALID_BIT);
|
||||
|
||||
for (uint8_t i = 0; i < METADATA_REDUNDANCY; i++) {
|
||||
storage.buffer.metadata[i] = storage.validMetadata;
|
||||
}
|
||||
|
||||
storage.isEEPROMWriting = true;
|
||||
asyncWriteEEPROM((uint8_t*)&storage.buffer, onEEPROMWriteFinished);
|
||||
}
|
||||
|
||||
bool loadNextObject(uint8_t* holder, uint8_t size) {
|
||||
if (storage.loadIndex++ == 0) {
|
||||
storage.loadPointer = isUsingPageA() ?
|
||||
storage.buffer.redundantBufferA
|
||||
: storage.buffer.redundantBufferB;
|
||||
}
|
||||
|
||||
if (getBit(storage.validMetadata, storage.loadIndex - 1)) {
|
||||
for (uint8_t i = 0; i < size; i++) {
|
||||
holder[i] = *storage.loadPointer++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef REDUNDANT_STORAGE_H
|
||||
#define REDUNDANT_STORAGE_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <avr/io.h>
|
||||
|
||||
|
||||
#define REDUNDANT_BUFFER_SIZE 24
|
||||
|
||||
void initializeRedundantStorage();
|
||||
|
||||
bool isValid();
|
||||
void invalidateEEPROM();
|
||||
|
||||
bool startSchedulingObjectsForSaving();
|
||||
void scheduleNextObjectForSave(uint8_t* object, uint8_t size);
|
||||
void saveScheduledObjects();
|
||||
|
||||
// Returns is loaded object valid
|
||||
bool loadNextObject(uint8_t* holder, uint8_t size);
|
||||
|
||||
#endif
|
||||
39
christmas/AdAstra/src/driver/sleep/sleep.c
Normal file
39
christmas/AdAstra/src/driver/sleep/sleep.c
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#include "sleep.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/sleep.h>
|
||||
|
||||
#include "bitwise.h"
|
||||
#include "../../hardware_access/hardware_access.h"
|
||||
|
||||
|
||||
#define TICKS_IN_MILISECOND 31
|
||||
|
||||
volatile int8_t milisecondsSinceFrameStart;
|
||||
|
||||
void startFrameLoop(FrameFunction function, uint8_t frameLengthInMilliseconds) {
|
||||
sleep_enable();
|
||||
|
||||
uint8_t previousFrameTime = 0;
|
||||
while (function(previousFrameTime)) {
|
||||
previousFrameTime = milisecondsSinceFrameStart;
|
||||
|
||||
while (milisecondsSinceFrameStart < frameLengthInMilliseconds) {
|
||||
clearBit(MCUCR, SM1); // idle mode
|
||||
sleep_cpu();
|
||||
}
|
||||
|
||||
milisecondsSinceFrameStart = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void powerOff() {
|
||||
setBit(MCUCR, SM1); // power-down mode
|
||||
sleep_cpu();
|
||||
}
|
||||
|
||||
ISR(TIM0_COMPA_vect) {
|
||||
milisecondsSinceFrameStart++;
|
||||
enableTimerA(TICKS_IN_MILISECOND);
|
||||
}
|
||||
16
christmas/AdAstra/src/driver/sleep/sleep.h
Normal file
16
christmas/AdAstra/src/driver/sleep/sleep.h
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#ifndef SLEEP_H
|
||||
#define SLEEP_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <avr/io.h>
|
||||
|
||||
// FrameFunction gets previousFrameTime (in milliseconds) as argument
|
||||
typedef bool (*FrameFunction)(uint8_t);
|
||||
|
||||
// Shut down the machine
|
||||
void powerOff();
|
||||
|
||||
// Call function every frameLengthInMilliseconds while it returns true
|
||||
void startFrameLoop(FrameFunction function, uint8_t frameLengthInMilliseconds);
|
||||
|
||||
#endif
|
||||
75
christmas/AdAstra/src/hardware_access/eeprom/eeprom.c
Normal file
75
christmas/AdAstra/src/hardware_access/eeprom/eeprom.c
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
#include "eeprom.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/eeprom.h>
|
||||
|
||||
#include "bitwise.h"
|
||||
|
||||
|
||||
uint8_t memory[STORAGE_SIZE] EEMEM;
|
||||
|
||||
static volatile struct {
|
||||
uint8_t* buffer;
|
||||
uint8_t positon;
|
||||
bool isWriting;
|
||||
OnEEPROMFinished onFinished;
|
||||
} eeprom;
|
||||
|
||||
uint8_t loadByteEEPROM(uint8_t* address) {
|
||||
while(getBit(EECR, EEPE)) {}
|
||||
|
||||
EEAR = (uint16_t)address;
|
||||
setBit(EECR, EERE);
|
||||
return EEDR;
|
||||
}
|
||||
|
||||
uint8_t loadSavedByteEEPROM(uint8_t address) {
|
||||
return loadByteEEPROM(memory + address);
|
||||
}
|
||||
|
||||
uint16_t loadWordEEPROM(uint16_t const* address) {
|
||||
uint16_t high = ((uint16_t)loadByteEEPROM((uint8_t*)address + 1)) << 8;
|
||||
uint16_t low = (uint16_t)loadByteEEPROM((uint8_t*)address);
|
||||
return high | low;
|
||||
}
|
||||
|
||||
static inline void saveByteEEPROM(uint8_t* address, uint8_t byte) {
|
||||
if (byte != loadByteEEPROM(address)) {
|
||||
EEDR = byte;
|
||||
setBit(EECR, EEMPE);
|
||||
setBit(EECR, EEPE);
|
||||
}
|
||||
}
|
||||
|
||||
void enableWritingEEPROM() {
|
||||
modifyBit(EECR, EERIE, eeprom.isWriting);
|
||||
}
|
||||
|
||||
void disableWritingEEPROM() {
|
||||
clearBit(EECR, EERIE); // clear eeprom ready interrupt enable
|
||||
}
|
||||
|
||||
bool asyncWriteEEPROM(uint8_t* buffer, OnEEPROMFinished onFinished) {
|
||||
if (eeprom.isWriting) {
|
||||
return false;
|
||||
}
|
||||
|
||||
eeprom.buffer = buffer;
|
||||
eeprom.onFinished = onFinished;
|
||||
eeprom.positon = 0;
|
||||
eeprom.isWriting = true;
|
||||
setBit(EECR, EERIE); // set eeprom ready interrupt
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ISR(EE_RDY_vect) {
|
||||
saveByteEEPROM(memory + eeprom.positon, eeprom.buffer[eeprom.positon]);
|
||||
|
||||
if (++eeprom.positon == STORAGE_SIZE) {
|
||||
clearBit(EECR, EERIE);
|
||||
eeprom.isWriting = false;
|
||||
eeprom.onFinished(eeprom.buffer);
|
||||
}
|
||||
}
|
||||
15
christmas/AdAstra/src/hardware_access/eeprom/eeprom.h
Normal file
15
christmas/AdAstra/src/hardware_access/eeprom/eeprom.h
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#ifndef EEPROM_H
|
||||
#define EEPROM_H
|
||||
|
||||
#include <avr/io.h>
|
||||
|
||||
|
||||
#define STORAGE_SIZE 52
|
||||
|
||||
typedef void (*OnEEPROMFinished)(uint8_t*);
|
||||
|
||||
inline void initializeEEPROM() {
|
||||
EECR = 0; // atomic write
|
||||
}
|
||||
|
||||
#endif
|
||||
12
christmas/AdAstra/src/hardware_access/hardware_access.c
Normal file
12
christmas/AdAstra/src/hardware_access/hardware_access.c
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#include "hardware_access.h"
|
||||
|
||||
#include <avr/interrupt.h>
|
||||
|
||||
|
||||
void initializeHardwareAccess() {
|
||||
sei();
|
||||
initializePowerSaving();
|
||||
initializeSPI();
|
||||
initializeTiming();
|
||||
initializeOutputPins();
|
||||
}
|
||||
39
christmas/AdAstra/src/hardware_access/hardware_access.h
Normal file
39
christmas/AdAstra/src/hardware_access/hardware_access.h
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#ifndef HARDWARE_ACCESS_H
|
||||
#define HARDWARE_ACCESS_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <avr/io.h>
|
||||
#include "bitwise.h"
|
||||
|
||||
#include "power_saving/power_saving.h"
|
||||
#include "spi/spi.h"
|
||||
#include "timing/timing.h"
|
||||
#include "output_pins/output_pins.h"
|
||||
|
||||
|
||||
/*
|
||||
This module contains the lowest level functions to manipulate the hardware.
|
||||
You only have to include this header file which serves as a facade.
|
||||
The sub-modules' implementation can be freely changed as long as they
|
||||
still implement these functions.
|
||||
*/
|
||||
|
||||
// Initialize every hardware element at once
|
||||
void initializeHardwareAccess();
|
||||
|
||||
// Enable interrupt OCCRA for TIMER0 with a modulo of triggerInterruptInXTicks
|
||||
void enableTimerA(uint8_t triggerInterruptInXTicks);
|
||||
|
||||
// Enable interrupt OCCRB for TIMER0B with a modulo of triggerInterruptInXTicks
|
||||
void enableTimerB(uint8_t triggerInterruptInXTicks);
|
||||
void disableTimerB();
|
||||
|
||||
// Send a single byte on the built-in SPI interface
|
||||
// The transfer is done in a serial manner to achieve
|
||||
// greater throughput.
|
||||
void sendByteOnSPI(uint8_t byte);
|
||||
|
||||
// Set the value of an output pin
|
||||
void setOutputPin(uint8_t id, bool value);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
#include "output_pins.h"
|
||||
#include "bitwise.h"
|
||||
|
||||
#include <avr/io.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
|
||||
void setOutputPin(uint8_t id, bool value) {
|
||||
setBit(DDRB, id);
|
||||
modifyBit(PORTB, id, value);
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
#ifndef GPIO_OUTPUT_PINS_H
|
||||
#define GPIO_OUTPUT_PINS_H
|
||||
|
||||
|
||||
inline void initializeOutputPins() {}
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
#ifndef POWER_SAVING_H
|
||||
#define POWER_SAVING_H
|
||||
|
||||
#include <avr/io.h>
|
||||
#include "bitwise.h"
|
||||
|
||||
|
||||
inline void initializePowerSaving() {
|
||||
setBit(ACSR, ACD); // disable ADC to save power
|
||||
PRR = BV(PRTIM1) | BV(PRADC); // disable power to timer1 and ADC
|
||||
}
|
||||
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue