13 Commits
20 changed files with 1043 additions and 84 deletions
+2
View File
@@ -1,4 +1,6 @@
.idea .idea
.vs
cmake-buid-debug cmake-buid-debug
+3 -1
View File
@@ -1,6 +1,8 @@
Microsoft Visual Studio Solution File, Format Version 11.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Atmel Studio Solution File, Format Version 11.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}") = "GccApplication3", "GccApplication3.cproj", "{94BBCABE-3E5B-448F-A40B-2B08DEF16444}" Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "GccApplication3", "GccApplication3.cproj", "{94BBCABE-3E5B-448F-A40B-2B08DEF16444}"
EndProject EndProject
Global Global
Binary file not shown.
+86
View 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.7.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\ATmega_DFP\1.7.374\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\ATmega_DFP\1.7.374\include\avr\iom328p.h</AbsolutePath>
<Attribute></Attribute>
<Category>header</Category>
<Condition>C</Condition>
<FileContentHash>4leX2H78R90/kvebBjYSOw==</FileContentHash>
<FileVersion></FileVersion>
<Name>include/avr/iom328p.h</Name>
<SelectString></SelectString>
<SourcePath></SourcePath>
</d4p1:anyType>
<d4p1:anyType i:type="FileInfo">
<AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.7.374\templates\main.c</AbsolutePath>
<Attribute>template</Attribute>
<Category>source</Category>
<Condition>C Exe</Condition>
<FileContentHash>KjvOcFWd++tbnsEMfVPd/w==</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\ATmega_DFP\1.7.374\templates\main.cpp</AbsolutePath>
<Attribute>template</Attribute>
<Category>source</Category>
<Condition>C Exe</Condition>
<FileContentHash>mkKaE95TOoATsuBGv6jmxg==</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\ATmega_DFP\1.7.374\gcc\dev\atmega328p</AbsolutePath>
<Attribute></Attribute>
<Category>libraryPrefix</Category>
<Condition>GCC</Condition>
<FileContentHash i:nil="true" />
<FileVersion></FileVersion>
<Name>gcc/dev/atmega328p</Name>
<SelectString></SelectString>
<SourcePath></SourcePath>
</d4p1:anyType>
</Files>
<PackName>ATmega_DFP</PackName>
<PackPath>C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.7.374/Atmel.ATmega_DFP.pdsc</PackPath>
<PackVersion>1.7.374</PackVersion>
<PresentInProject>true</PresentInProject>
<ReferenceConditionId>ATmega328P</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>
+44 -8
View File
@@ -2,7 +2,7 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<SchemaVersion>2.0</SchemaVersion> <SchemaVersion>2.0</SchemaVersion>
<ProjectVersion>6.2</ProjectVersion> <ProjectVersion>7.0</ProjectVersion>
<ToolchainName>com.Atmel.AVRGCC8.C</ToolchainName> <ToolchainName>com.Atmel.AVRGCC8.C</ToolchainName>
<ProjectGuid>{94bbcabe-3e5b-448f-a40b-2b08def16444}</ProjectGuid> <ProjectGuid>{94bbcabe-3e5b-448f-a40b-2b08def16444}</ProjectGuid>
<avrdevice>ATmega328P</avrdevice> <avrdevice>ATmega328P</avrdevice>
@@ -20,28 +20,31 @@
<OverrideVtor>false</OverrideVtor> <OverrideVtor>false</OverrideVtor>
<CacheFlash>true</CacheFlash> <CacheFlash>true</CacheFlash>
<ProgFlashFromRam>true</ProgFlashFromRam> <ProgFlashFromRam>true</ProgFlashFromRam>
<RamSnippetAddress /> <RamSnippetAddress>0x20000000</RamSnippetAddress>
<UncachedRange /> <UncachedRange />
<preserveEEPROM>true</preserveEEPROM> <preserveEEPROM>true</preserveEEPROM>
<OverrideVtorValue /> <OverrideVtorValue>exception_table</OverrideVtorValue>
<BootSegment>2</BootSegment> <BootSegment>2</BootSegment>
<eraseonlaunchrule>1</eraseonlaunchrule> <eraseonlaunchrule>1</eraseonlaunchrule>
<AsfFrameworkConfig> <AsfFrameworkConfig>
<framework-data xmlns=""> <framework-data>
<options /> <options />
<configurations /> <configurations />
<files /> <files />
<documentation help="" /> <documentation help="" />
<offline-documentation help="" /> <offline-documentation help="" />
<dependencies> <dependencies>
<content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.21.0" /> <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.44.1" />
</dependencies> </dependencies>
</framework-data> </framework-data>
</AsfFrameworkConfig> </AsfFrameworkConfig>
<ResetRule>0</ResetRule>
<EraseKey />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<ToolchainSettings> <ToolchainSettings>
<AvrGcc> <AvrGcc>
<avrgcc.common.Device>-mmcu=atmega328p -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.7.374\gcc\dev\atmega328p"</avrgcc.common.Device>
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex> <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss> <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep> <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
@@ -54,6 +57,11 @@
<Value>NDEBUG</Value> <Value>NDEBUG</Value>
</ListValues> </ListValues>
</avrgcc.compiler.symbols.DefSymbols> </avrgcc.compiler.symbols.DefSymbols>
<avrgcc.compiler.directories.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.7.374\include\</Value>
</ListValues>
</avrgcc.compiler.directories.IncludePaths>
<avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level> <avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers> <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum> <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
@@ -63,12 +71,18 @@
<Value>libm</Value> <Value>libm</Value>
</ListValues> </ListValues>
</avrgcc.linker.libraries.Libraries> </avrgcc.linker.libraries.Libraries>
</AvrGcc> <avrgcc.assembler.general.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.7.374\include\</Value>
</ListValues>
</avrgcc.assembler.general.IncludePaths>
</AvrGcc>
</ToolchainSettings> </ToolchainSettings>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<ToolchainSettings> <ToolchainSettings>
<AvrGcc> <AvrGcc>
<avrgcc.common.Device>-mmcu=atmega328p -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.7.374\gcc\dev\atmega328p"</avrgcc.common.Device>
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex> <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss> <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep> <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
@@ -81,6 +95,11 @@
<Value>DEBUG</Value> <Value>DEBUG</Value>
</ListValues> </ListValues>
</avrgcc.compiler.symbols.DefSymbols> </avrgcc.compiler.symbols.DefSymbols>
<avrgcc.compiler.directories.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.7.374\include\</Value>
</ListValues>
</avrgcc.compiler.directories.IncludePaths>
<avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level> <avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers> <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum> <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
@@ -91,8 +110,13 @@
<Value>libm</Value> <Value>libm</Value>
</ListValues> </ListValues>
</avrgcc.linker.libraries.Libraries> </avrgcc.linker.libraries.Libraries>
<avrgcc.assembler.general.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.7.374\include\</Value>
</ListValues>
</avrgcc.assembler.general.IncludePaths>
<avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel> <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>
</AvrGcc> </AvrGcc>
</ToolchainSettings> </ToolchainSettings>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@@ -102,6 +126,12 @@
<Compile Include="calculator.h"> <Compile Include="calculator.h">
<SubType>compile</SubType> <SubType>compile</SubType>
</Compile> </Compile>
<Compile Include="func.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="func.h">
<SubType>compile</SubType>
</Compile>
<Compile Include="keyboard.c"> <Compile Include="keyboard.c">
<SubType>compile</SubType> <SubType>compile</SubType>
</Compile> </Compile>
@@ -111,6 +141,12 @@
<Compile Include="main.c"> <Compile Include="main.c">
<SubType>compile</SubType> <SubType>compile</SubType>
</Compile> </Compile>
<Compile Include="spi_master.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="spi_master.h">
<SubType>compile</SubType>
</Compile>
<Compile Include="timer.c"> <Compile Include="timer.c">
<SubType>compile</SubType> <SubType>compile</SubType>
</Compile> </Compile>
+20
View File
@@ -0,0 +1,20 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Atmel Studio Solution File, Format Version 11.00
Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "GccApplication3", "GccApplication3_6_2(1).cproj", "{94BBCABE-3E5B-448F-A40B-2B08DEF16444}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|AVR = Debug|AVR
Release|AVR = Release|AVR
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{94BBCABE-3E5B-448F-A40B-2B08DEF16444}.Debug|AVR.ActiveCfg = Debug|AVR
{94BBCABE-3E5B-448F-A40B-2B08DEF16444}.Debug|AVR.Build.0 = Debug|AVR
{94BBCABE-3E5B-448F-A40B-2B08DEF16444}.Release|AVR.ActiveCfg = Release|AVR
{94BBCABE-3E5B-448F-A40B-2B08DEF16444}.Release|AVR.Build.0 = Release|AVR
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
+140
View File
@@ -0,0 +1,140 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
<ProjectVersion>6.2</ProjectVersion>
<ToolchainName>com.Atmel.AVRGCC8.C</ToolchainName>
<ProjectGuid>{94bbcabe-3e5b-448f-a40b-2b08def16444}</ProjectGuid>
<avrdevice>ATmega328P</avrdevice>
<avrdeviceseries>none</avrdeviceseries>
<OutputType>Executable</OutputType>
<Language>C</Language>
<OutputFileName>$(MSBuildProjectName)</OutputFileName>
<OutputFileExtension>.elf</OutputFileExtension>
<OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>
<AssemblyName>GccApplication3</AssemblyName>
<Name>GccApplication3</Name>
<RootNamespace>GccApplication3</RootNamespace>
<ToolchainFlavour>Native</ToolchainFlavour>
<KeepTimersRunning>true</KeepTimersRunning>
<OverrideVtor>false</OverrideVtor>
<CacheFlash>true</CacheFlash>
<ProgFlashFromRam>true</ProgFlashFromRam>
<RamSnippetAddress />
<UncachedRange />
<preserveEEPROM>true</preserveEEPROM>
<OverrideVtorValue />
<BootSegment>2</BootSegment>
<eraseonlaunchrule>1</eraseonlaunchrule>
<AsfFrameworkConfig>
<framework-data xmlns="">
<options />
<configurations />
<files />
<documentation help="" />
<offline-documentation help="" />
<dependencies>
<content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.21.0" />
</dependencies>
</framework-data>
</AsfFrameworkConfig>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<ToolchainSettings>
<AvrGcc>
<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>
</ListValues>
</avrgcc.compiler.symbols.DefSymbols>
<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.linker.libraries.Libraries>
<ListValues>
<Value>libm</Value>
</ListValues>
</avrgcc.linker.libraries.Libraries>
</AvrGcc>
</ToolchainSettings>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<ToolchainSettings>
<AvrGcc>
<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.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.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>
</AvrGcc>
</ToolchainSettings>
</PropertyGroup>
<ItemGroup>
<Compile Include="calculator.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="calculator.h">
<SubType>compile</SubType>
</Compile>
<Compile Include="func.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="func.h">
<SubType>compile</SubType>
</Compile>
<Compile Include="keyboard.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="keyboard.h">
<SubType>compile</SubType>
</Compile>
<Compile Include="main.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="spi_master.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="spi_master.h">
<SubType>compile</SubType>
</Compile>
<Compile Include="timer.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="timer.h">
<SubType>compile</SubType>
</Compile>
<Compile Include="uart.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="uart.h">
<SubType>compile</SubType>
</Compile>
</ItemGroup>
<Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />
</Project>
+20
View File
@@ -0,0 +1,20 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Atmel Studio Solution File, Format Version 11.00
Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "GccApplication3", "GccApplication3_6_2.cproj", "{94BBCABE-3E5B-448F-A40B-2B08DEF16444}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|AVR = Debug|AVR
Release|AVR = Release|AVR
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{94BBCABE-3E5B-448F-A40B-2B08DEF16444}.Debug|AVR.ActiveCfg = Debug|AVR
{94BBCABE-3E5B-448F-A40B-2B08DEF16444}.Debug|AVR.Build.0 = Debug|AVR
{94BBCABE-3E5B-448F-A40B-2B08DEF16444}.Release|AVR.ActiveCfg = Release|AVR
{94BBCABE-3E5B-448F-A40B-2B08DEF16444}.Release|AVR.Build.0 = Release|AVR
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Binary file not shown.
+86
View 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.2.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\ATmega_DFP\1.2.209\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\ATmega_DFP\1.2.209\include\avr\iom328p.h</AbsolutePath>
<Attribute></Attribute>
<Category>header</Category>
<Condition>C</Condition>
<FileContentHash>UMk4QUzkkuShabuoYtNl/Q==</FileContentHash>
<FileVersion></FileVersion>
<Name>include/avr/iom328p.h</Name>
<SelectString></SelectString>
<SourcePath></SourcePath>
</d4p1:anyType>
<d4p1:anyType i:type="FileInfo">
<AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.209\templates\main.c</AbsolutePath>
<Attribute>template</Attribute>
<Category>source</Category>
<Condition>C Exe</Condition>
<FileContentHash>GD1k8YYhulqRs6FD1B2Hog==</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\ATmega_DFP\1.2.209\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\ATmega_DFP\1.2.209\gcc\dev\atmega328p</AbsolutePath>
<Attribute></Attribute>
<Category>libraryPrefix</Category>
<Condition>GCC</Condition>
<FileContentHash i:nil="true" />
<FileVersion></FileVersion>
<Name>gcc/dev/atmega328p</Name>
<SelectString></SelectString>
<SourcePath></SourcePath>
</d4p1:anyType>
</Files>
<PackName>ATmega_DFP</PackName>
<PackPath>C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.209/Atmel.ATmega_DFP.pdsc</PackPath>
<PackVersion>1.2.209</PackVersion>
<PresentInProject>true</PresentInProject>
<ReferenceConditionId>ATmega328P</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>
+164
View File
@@ -0,0 +1,164 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
<ProjectVersion>7.0</ProjectVersion>
<ToolchainName>com.Atmel.AVRGCC8.C</ToolchainName>
<ProjectGuid>{94bbcabe-3e5b-448f-a40b-2b08def16444}</ProjectGuid>
<avrdevice>ATmega328P</avrdevice>
<avrdeviceseries>none</avrdeviceseries>
<OutputType>Executable</OutputType>
<Language>C</Language>
<OutputFileName>$(MSBuildProjectName)</OutputFileName>
<OutputFileExtension>.elf</OutputFileExtension>
<OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>
<AssemblyName>GccApplication3</AssemblyName>
<Name>GccApplication3</Name>
<RootNamespace>GccApplication3</RootNamespace>
<ToolchainFlavour>Native</ToolchainFlavour>
<KeepTimersRunning>true</KeepTimersRunning>
<OverrideVtor>false</OverrideVtor>
<CacheFlash>true</CacheFlash>
<ProgFlashFromRam>true</ProgFlashFromRam>
<RamSnippetAddress />
<UncachedRange />
<preserveEEPROM>true</preserveEEPROM>
<OverrideVtorValue />
<BootSegment>2</BootSegment>
<eraseonlaunchrule>1</eraseonlaunchrule>
<AsfFrameworkConfig>
<framework-data>
<options />
<configurations />
<files />
<documentation help="" />
<offline-documentation help="" />
<dependencies>
<content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.34.1" />
</dependencies>
</framework-data>
</AsfFrameworkConfig>
<ResetRule>0</ResetRule>
<EraseKey />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<ToolchainSettings>
<AvrGcc>
<avrgcc.common.Device>-mmcu=atmega328p -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.2.209\gcc\dev\atmega328p"</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>NDEBUG</Value>
</ListValues>
</avrgcc.compiler.symbols.DefSymbols>
<avrgcc.compiler.directories.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.2.209\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.linker.libraries.Libraries>
<ListValues>
<Value>libm</Value>
</ListValues>
</avrgcc.linker.libraries.Libraries>
<avrgcc.assembler.general.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.2.209\include</Value>
</ListValues>
</avrgcc.assembler.general.IncludePaths>
</AvrGcc>
</ToolchainSettings>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<ToolchainSettings>
<AvrGcc>
<avrgcc.common.Device>-mmcu=atmega328p -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.2.209\gcc\dev\atmega328p"</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\ATmega_DFP\1.2.209\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\ATmega_DFP\1.2.209\include</Value>
</ListValues>
</avrgcc.assembler.general.IncludePaths>
<avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>
</AvrGcc>
</ToolchainSettings>
</PropertyGroup>
<ItemGroup>
<Compile Include="calculator.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="calculator.h">
<SubType>compile</SubType>
</Compile>
<Compile Include="func.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="func.h">
<SubType>compile</SubType>
</Compile>
<Compile Include="keyboard.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="keyboard.h">
<SubType>compile</SubType>
</Compile>
<Compile Include="main.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="spi_master.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="spi_master.h">
<SubType>compile</SubType>
</Compile>
<Compile Include="timer.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="timer.h">
<SubType>compile</SubType>
</Compile>
<Compile Include="uart.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="uart.h">
<SubType>compile</SubType>
</Compile>
</ItemGroup>
<Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />
</Project>
+4 -5
View File
@@ -8,9 +8,8 @@
* Хромова Полина * Хромова Полина
## Части задачи ## Части задачи
- GPIO + GPIO в контексте Atmega328. Pull up, Pull down (Кристина Бочкина/Полина Хромова) - GPIO + GPIO в контексте Atmega328. Pull up, Pull down (Михаил Батухтин/Уткин Никита)
- Реализация клавиатуры (Кристина Бочкина/Полина Хромова) - Физическая реализация клавиатуры (Кристина Бочкина/Полина Хромова)
- SPI интерфейс + SPI у Atmega328 (Никита Уткин) - SPI интерфейс + SPI у Atmega328 (Кристина Бочкина)
- Программная реализация клавиатуры (Полина Хромова)
- Архитектура ПО (Михаил Батухтин) - Архитектура ПО (Михаил Батухтин)
+3
View File
@@ -127,6 +127,9 @@ void handleCalc(struct calculator *calc, int input) {
case 14: case 14:
clearCalc(calc); clearCalc(calc);
break; break;
case 13:
clearCalc(calc);
break;
} }
break; break;
} }
+3 -3
View File
@@ -23,13 +23,13 @@ enum calculator_op {
}; };
struct calculator { struct calculator {
// 1 ÷èñëî // 1 ÷èñëî
int num1; long num1;
// 2 ÷èñëî // 2 ÷èñëî
int num2; long num2;
// 3 îïåðàöèÿ // 3 îïåðàöèÿ
enum calculator_op operation; enum calculator_op operation;
// 4 ðåçóëüòàò // 4 ðåçóëüòàò
int result; long result;
// 5 ñîñòîÿíèå àòîìàòà // 5 ñîñòîÿíèå àòîìàòà
enum calculator_state state; enum calculator_state state;
}; };
+96
View File
@@ -0,0 +1,96 @@
/*
* delay.c
*
* Created: 03.06.2023 12:34:55
* Author: Admin
*/
#include "func.h"
void delay() {
for(volatile long i = 0; i < 1000; i++){};
}
int count_digits(long number) {
int count = 0;
if (number == 0) {
return 1;
}
if (number < 0) {
number = -number;
}
while (number > 0) {
number /= 10;
count++;
}
return count;
}
void split_digits(long number, long* digits, int size) {
int digit;
int index = 0;
if (number == 0) {
digits[0] = 0;
return;
}
if (number < 0) {
number = -number;
}
while (number > 0 && index < size) {
digit = number % 10;
digits[index] = digit;
number /= 10;
index++;
}
}
static char map(char c) {
//if (c >= 0 && c <= 9)
//return c - 0x27;
//else
//return 0x01;
switch (c) {
case 0x30:
return 0x09;
case 0x31:
return 0x0a;
case 0x32:
return 0x0b;
case 0x33:
return 0x0c;
case 0x34:
return 0x0d;
case 0x35:
return 0x0e;
case 0x36:
return 0x0f;
case 0x37:
return 0x10;
case 0x38:
return 0x11;
case 0x39:
return 0x12;
case 0x2d:
return 0x06;
}
}
void map_digits(char* arr, char *digits, int size) {
int idx = 0;
for (int i = 0; i < size; i++) {
arr[idx] = map(digits[i]);
idx++;
}
}
void prepare_data(char *arr, long number, int size) {
long digits[12];
split_digits(number, digits, size);
map_digits(arr, digits, size);
}
+13
View File
@@ -0,0 +1,13 @@
/*
* delay.h
*
* Created: 03.06.2023 12:35:06
* Author: Admin
*/
void delay();
void split_digits(long number, long* digits, int size);
int count_digits(long number);
void map_digits(char* arr, char *digits, int size);
void prepare_data(char *arr, long number, int size);
+2 -2
View File
@@ -9,6 +9,7 @@
#include <stdio.h> #include <stdio.h>
#include "keyboard.h" #include "keyboard.h"
#include "timer.h" #include "timer.h"
#include "func.h"
#define MASK_PIND 0b11110000 #define MASK_PIND 0b11110000
@@ -18,7 +19,7 @@ void get_physical_keys(struct key *keys) {
uint8_t row; uint8_t row;
for (int i = 0; i < KEYS_AMOUNT / 4; i++) { for (int i = 0; i < KEYS_AMOUNT / 4; i++) {
PORTC &= ~(1 << i); PORTC &= ~(1 << i);
for(volatile long i = 0; i < 1000; i++){}; delay();
row = PIND & MASK_PIND; row = PIND & MASK_PIND;
if (row & (1 << 4)) keys[i * 4].physical = false; else keys[i * 4].physical = true; if (row & (1 << 4)) keys[i * 4].physical = false; else keys[i * 4].physical = true;
if (row & (1 << 5)) keys[i * 4 + 1].physical = false; else keys[i * 4 + 1].physical = true; if (row & (1 << 5)) keys[i * 4 + 1].physical = false; else keys[i * 4 + 1].physical = true;
@@ -38,7 +39,6 @@ void get_logical_keys(struct key *undc_keys) {
} }
} else { } else {
undc_keys[i].time = timestamp; undc_keys[i].time = timestamp;
} }
} }
} }
+11 -4
View File
@@ -5,7 +5,7 @@
#include "timer.h" #include "timer.h"
#include "keyboard.h" #include "keyboard.h"
#include "uart.h" #include "uart.h"
#include "calculator.h" #include "spi_master.h"
void setup_registers() { void setup_registers() {
MCUCR &= ~(1 << 4); // PUD MCUCR &= ~(1 << 4); // PUD
@@ -21,6 +21,7 @@ void setup_registers() {
void setup() { void setup() {
USART_Init(MYUBRR); USART_Init(MYUBRR);
SPI_MasterInit();
setup_timer(); setup_timer();
setup_registers(); setup_registers();
} }
@@ -46,10 +47,16 @@ int main(void) {
get_event(&keys[i], &up, &down); get_event(&keys[i], &up, &down);
if (down) if (down)
{ {
printf("%d", keys[i].button); //printf("button %d\r\n", keys[i].button);
handleCalc(&calc, keys[i].button); handleCalc(&calc, keys[i].button);
printf("num1: %d | num2: %d | result: %d | operation: %d | state: %d", output_on_display(&calc);
calc.num1, calc.num2, calc.result, calc.operation, calc.state); //printf("-----\r\n");
//printf("%ld\r\n", calc.num1);
//printf("%ld\r\n", calc.num2);
//printf("%ld\r\n", calc.result);
//printf("%d\r\n", calc.operation);
//printf("%d\r\n", calc.state);
} }
} }
} }
+267
View File
@@ -0,0 +1,267 @@
#include <avr/interrupt.h>
#include <avr/io.h>
#include <string.h>
#include <util/delay.h>
#include "spi_master.h"
#include "func.h"
#include <stdlib.h>
#define MAX_DIGITS 12
#define F_CPU 16000000UL
#define DELAY_MS 2000
void output_on_display(struct calculator *calc)
{
char buffer[32];
switch (calc->state)
{
case NUMBER_FIRST:
{
size_t b_size = display_all_clear(0, buffer);
SPI_MasterTransmit(buffer, b_size);
b_size = display_set_page(0x01, buffer);
SPI_MasterTransmit(buffer, b_size);
transmit_num(calc->num1, buffer);
break;
}
case NUMBER_SECOND:
{
size_t b_size = display_all_clear(0, buffer);
SPI_MasterTransmit(buffer, b_size);
b_size = display_set_page(0x01, buffer);
SPI_MasterTransmit(buffer, b_size);
transmit_num(calc->num1, buffer);
char symbol[] = {0x01};
// Îïåðàöèÿ
switch (calc->operation)
{
case NO_OP:
break;
case ADD:
symbol[0] = 0x04;
break;
case SUB:
symbol[0] = 0x06;
break;
case DIV:
symbol[0] = 0x08;
break;
case MUL:
symbol[0] = 0x03;
break;
}
b_size = display_add_simbol(symbol, 1, buffer);
SPI_MasterTransmit(buffer, b_size);
b_size = display_set_page(0x02, buffer);
SPI_MasterTransmit(buffer, b_size);
transmit_num(calc->num2, buffer);
break;
}
case RESULT:
{
size_t b_size = display_all_clear(0, buffer);
SPI_MasterTransmit(buffer, b_size);
b_size = display_set_page(0x01, buffer);
SPI_MasterTransmit(buffer, b_size);
transmit_num(calc->num1, buffer);
char symbol[] = {0x01};
// Îïåðàöèÿ
switch (calc->operation)
{
case NO_OP:
break;
case ADD:
symbol[0] = 0x04;
break;
case SUB:
symbol[0] = 0x06;
break;
case DIV:
symbol[0] = 0x08;
break;
case MUL:
symbol[0] = 0x03;
break;
}
b_size = display_add_simbol(symbol, 1, buffer);
SPI_MasterTransmit(buffer, b_size);
b_size = display_set_page(0x02, buffer);
SPI_MasterTransmit(buffer, b_size);
transmit_num(calc->num2, buffer);
// ðåçóëüòàò
b_size = display_set_page(0x03, buffer);
SPI_MasterTransmit(buffer, b_size);
symbol[0] = 0x15;
b_size = display_add_simbol(symbol, 1, buffer);
SPI_MasterTransmit(buffer, b_size);
transmit_num(calc->result, buffer);
break;
}
default:
display_all_clear(0, buffer);
}
}
void transmit_num(long number, char *buffer) {
char number_buffer[MAX_DIGITS];
char mapped_digits[MAX_DIGITS];
ltoa(number, number_buffer, 10);
map_digits(mapped_digits, number_buffer, strlen(number_buffer));
size_t b_size = display_add_simbol(mapped_digits, strlen(number_buffer), buffer);
SPI_MasterTransmit(buffer, b_size);
}
void SPI_MasterInit(void)
{
/* Íàñòðîéêà MOSI è SCK êàê âûõîä,
âñå îñòàëüíûå ñèãíàëû êàê âõîä: */
SPI_DDRX = (1 << SPI_MOSI) | (1 << SPI_SCK) | (1 << SPI_SS) | (0 << SPI_MISO);
/* Ðàçðåøèòü ðàáîòó SPI, ðåæèì Master,
óñòàíîâèòü ñêîðîñòü òàêòîâ fck/16: */
SPCR = (1 << SPE) | (1 << MSTR) | (0 << CPOL) | (0 << CPHA) | (1 << SPR1);
SPI_PORTX |= (1 << SPI_SS);
}
void SPI_MasterTransmit(char *buffer, size_t length)
{
SPI_PORTX &= ~(1 << SPI_SS);
for (int i = 0; i < length; i++)
{
SPDR = buffer[i];
while (!(SPSR & (1 << SPIF)))
{
// îæèäàíèå çàâåðøåíèÿ ïåðåäà÷è
}
}
SPI_PORTX |= (1 << SPI_SS);
_delay_ms(DELAY_MS);
}
char crc8(char *data, int len) {
char crc = 0x00;
while (len--) {
crc ^= *data++;
for (int i = 0; i < 8; i++) {
if (crc & 0x80) {
crc = (crc << 1) ^ 0x07;
} else {
crc <<= 1;
}
}
}
return crc;
}
//î÷èùåíèå ýêðàía
size_t display_all_clear(char color, char *buffer)
{
buffer[0] = 0x01;
buffer[1] = color;
buffer[2] = crc8(buffer, 2);
return 3;
}
//âûáîð òî÷êè
size_t display_set_page(char point, char *buffer)
{
buffer[0] = 0x02;
buffer[1] = point;
buffer[2] = crc8(buffer, 2);
return 3;
}
//äîáàâëåíèå íîâîãî ñèìâîëà è åãî ïàðàìåòðîâ
size_t display_add_simbol(char *str, size_t str_len, char *buffer)
{
size_t idx = 0;
buffer[idx] = 0x03;
idx++;
for (int i = 0; i < str_len; i++)
{
buffer[idx] = str[i];
idx++;
}
buffer[idx] = crc8(buffer, idx);
idx++;
return idx;
}
//óäàëåíèå ñèìâîëà è åãî ïàðàìåòðîâ
size_t display_del_simbol(char number, char *buffer)
{
buffer[0] = 0x04;
buffer[1] = number;
buffer[2] = crc8(buffer, 2);
return 3;
}
//çàêðàøèâàíèå ïèêñåëÿ
size_t display_draw_pixel(char x, char y, char color, uint8_t *buffer)
{
buffer[0] = 0x05;
buffer[1] = x;
buffer[2] = y;
buffer[3] = color;
buffer[4] = crc8(buffer, 4);
return 5;
}
//ðèñóåò ëèíèþ
size_t display_draw_line(char x1, char y1, char x2, char y2, char color, char *buffer)
{
buffer[0] = 0x06;
buffer[1] = x1;
buffer[2] = y1;
buffer[3] = x2;
buffer[4] = y2;
buffer[5] = color;
buffer[6] = crc8(buffer, 6);
return 7;
}
//ðèñóåò êðóã
size_t display_draw_circle(char x, char y, char r, char color, uint8_t *buffer)
{
buffer[0] = 0x07;
buffer[1] = x;
buffer[2] = y;
buffer[3] = r;
buffer[4] = color;
buffer[5] = crc8(buffer, 5);
return 6;
}
//ðèñóåò ïðÿìîóãîëüíèê
size_t display_draw_rectangle(char x, char y, char height, char width, char color, uint8_t *buffer)
{
buffer[0] = 0x08;
buffer[1] = x;
buffer[2] = y;
buffer[3] = height;
buffer[4] = width;
buffer[5] = color;
buffer[6] = crc8(buffer, 6);
return 7;
}
+18
View File
@@ -0,0 +1,18 @@
#define SPI_PORTX PORTB
#define SPI_DDRX DDRB
#define SPI_MISO 4
#define SPI_MOSI 3
#define SPI_SCK 5
#define SPI_SS 2
#include "calculator.h"
void output_on_display(struct calculator *calc);
void SPI_MasterInit(void);
void SPI_MasterTransmit(char *buffer, size_t length);
void transmit_num(long number, char *buffer);
size_t display_all_clear(char color, char *buffer);
size_t display_add_simbol(char *str, size_t str_len, char *buffer);
size_t display_draw_line(char x1, char y1, char x2, char y2, char color, char *buffer);
size_t display_del_simbol(char number, char *buffer);
size_t display_set_page(char point, char *buffer);