Compare commits
19 Commits
terminal-s
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
d816a23138 | ||
b8370ddc0a | |||
|
a766efb8a9 | ||
|
987e25ab3e | ||
|
6e38ba1494 | ||
|
9d2b754941 | ||
|
f54397612f | ||
45fc52ffc1 | |||
a56e47eb7f | |||
17f212cf43 | |||
5fe0a6d3e4 | |||
5d5fd2172c | |||
4575d0c1d2 | |||
9b60c22f96 | |||
|
963d5c395b | ||
a184d3555e | |||
0fc4e86a7a | |||
|
ca656f2803 | ||
|
39731c5060 |
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,4 +1,9 @@
|
|||||||
.idea
|
.idea
|
||||||
|
.vs
|
||||||
|
|
||||||
|
|
||||||
cmake-buid-debug
|
cmake-buid-debug
|
||||||
|
|
||||||
# Executables
|
# Executables
|
||||||
*.exe
|
*.exe
|
||||||
|
Debug
|
22
GccApplication3.atsln
Normal file
22
GccApplication3.atsln
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
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}") = "GccApplication3", "GccApplication3.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
|
BIN
GccApplication3.atsuo
Normal file
BIN
GccApplication3.atsuo
Normal file
Binary file not shown.
86
GccApplication3.componentinfo.xml
Normal file
86
GccApplication3.componentinfo.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.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>
|
164
GccApplication3.cproj
Normal file
164
GccApplication3.cproj
Normal 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>0x20000000</RamSnippetAddress>
|
||||||
|
<UncachedRange />
|
||||||
|
<preserveEEPROM>true</preserveEEPROM>
|
||||||
|
<OverrideVtorValue>exception_table</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.44.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.7.374\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.7.374\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.7.374\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.7.374\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.7.374\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.7.374\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>
|
20
GccApplication3_6_2(1).atsln
Normal file
20
GccApplication3_6_2(1).atsln
Normal 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
GccApplication3_6_2(1).cproj
Normal file
140
GccApplication3_6_2(1).cproj
Normal 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
GccApplication3_6_2.atsln
Normal file
20
GccApplication3_6_2.atsln
Normal 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
|
BIN
GccApplication3_6_2.atsuo
Normal file
BIN
GccApplication3_6_2.atsuo
Normal file
Binary file not shown.
86
GccApplication3_6_2.componentinfo.xml
Normal file
86
GccApplication3_6_2.componentinfo.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.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
GccApplication3_6_2.cproj
Normal file
164
GccApplication3_6_2.cproj
Normal 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>
|
279
MASTER.ino
279
MASTER.ino
@ -1,279 +0,0 @@
|
|||||||
#include <avr/interrupt.h>
|
|
||||||
#include <avr/io.h>
|
|
||||||
|
|
||||||
#define SPI_PORTX PORTB
|
|
||||||
#define SPI_DDRX DDRB
|
|
||||||
|
|
||||||
#define SPI_MISO 4
|
|
||||||
#define SPI_MOSI 3
|
|
||||||
#define SPI_SCK 5
|
|
||||||
#define SPI_SS 2
|
|
||||||
|
|
||||||
enum calculator_state
|
|
||||||
{
|
|
||||||
NUMBER_FIRST,
|
|
||||||
NUMBER_SECOND,
|
|
||||||
RESULT
|
|
||||||
};
|
|
||||||
enum calculator_op
|
|
||||||
{
|
|
||||||
NO_OP, //0
|
|
||||||
ADD, // 1
|
|
||||||
SUB,
|
|
||||||
DIV,
|
|
||||||
MUL
|
|
||||||
};
|
|
||||||
struct calculator
|
|
||||||
{
|
|
||||||
// 1 число
|
|
||||||
int num1;
|
|
||||||
// 2 число
|
|
||||||
int num2;
|
|
||||||
// 3 операция
|
|
||||||
enum calculator_op operation;
|
|
||||||
// 4 результат
|
|
||||||
double result;
|
|
||||||
// 5 состояние атомата
|
|
||||||
enum calculator_state state;
|
|
||||||
};
|
|
||||||
|
|
||||||
void output_on_display(struct calculator * calc) {
|
|
||||||
char buffer[8];
|
|
||||||
switch (state) {
|
|
||||||
|
|
||||||
case NUMBER_FIRST:
|
|
||||||
size_t b_size = display_all_clear(0, &buffer[0]);
|
|
||||||
SPI_MasterTransmit(&buffer[0], b_size);
|
|
||||||
//первое число
|
|
||||||
char[12] string_num;
|
|
||||||
itoa(calc.num1, &string_num, 10);
|
|
||||||
b_size = display_add_simbol(&string_num, strlen(string_num), &buffer[0]);
|
|
||||||
SPI_MasterTransmit(&buffer[0], b_size);
|
|
||||||
break;
|
|
||||||
case NUMBER_SECOND:
|
|
||||||
size_t b_size = display_all_clear(0, &buffer[0]);
|
|
||||||
SPI_MasterTransmit(&buffer[0], b_size);
|
|
||||||
//первое число
|
|
||||||
b_size = display_add_simbol(&string_num, strlen(string_num), &buffer[0]);
|
|
||||||
SPI_MasterTransmit(&buffer[0], b_size);
|
|
||||||
// операция
|
|
||||||
switch (calc.operation) {
|
|
||||||
case NO_OP:
|
|
||||||
break;
|
|
||||||
case ADD:
|
|
||||||
b_size = display_add_simbol("+", 1, &buffer[0]);
|
|
||||||
SPI_MasterTransmit(&buffer[0], b_size);
|
|
||||||
break;
|
|
||||||
case SUB:
|
|
||||||
b_size = display_add_simbol("-", 1, &buffer[0]);
|
|
||||||
SPI_MasterTransmit(&buffer[0], b_size);
|
|
||||||
break;
|
|
||||||
case DIV:
|
|
||||||
b_size = display_add_simbol("/", 1, &buffer[0]);
|
|
||||||
SPI_MasterTransmit(&buffer[0], b_size);
|
|
||||||
break;
|
|
||||||
case MUL:
|
|
||||||
b_size = display_add_simbol("*", 1, &buffer[0]);
|
|
||||||
SPI_MasterTransmit(&buffer[0], b_size);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// второе число
|
|
||||||
char[12] string_num;
|
|
||||||
itoa(calc.num2, &string_num, 10);
|
|
||||||
b_size = display_add_simbol(&string_num, strlen(string_num), &buffer[0]);
|
|
||||||
SPI_MasterTransmit(&buffer[0], b_size);
|
|
||||||
break;
|
|
||||||
case RESULT:
|
|
||||||
size_t b_size = display_all_clear(0, size_buffer);
|
|
||||||
SPI_MasterTransmit(&buffer[0], b_size);
|
|
||||||
// первое число
|
|
||||||
b_size = display_add_simbol(&string_num, strlen(string_num), &buffer[0]);
|
|
||||||
SPI_MasterTransmit(&buffer[0], b_size);
|
|
||||||
// операция
|
|
||||||
switch (calc.operation) {
|
|
||||||
case NO_OP:
|
|
||||||
break;
|
|
||||||
case ADD:
|
|
||||||
b_size = display_add_simbol("+", 1, &buffer[0]);
|
|
||||||
SPI_MasterTransmit(&buffer[0], b_size);
|
|
||||||
break;
|
|
||||||
case SUB:
|
|
||||||
b_size = display_add_simbol("-", 1, &buffer[0]);
|
|
||||||
SPI_MasterTransmit(&buffer[0], b_size);
|
|
||||||
break;
|
|
||||||
case DIV:
|
|
||||||
b_size = display_add_simbol("/", 1, &buffer[0]);
|
|
||||||
SPI_MasterTransmit(&buffer[0], b_size);
|
|
||||||
break;
|
|
||||||
case MUL:
|
|
||||||
b_size = display_add_simbol("*", 1, &buffer[0]);
|
|
||||||
SPI_MasterTransmit(&buffer[0], b_size);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// второе число
|
|
||||||
b_size = display_add_simbol(&string_num, strlen(string_num), &buffer[0]);
|
|
||||||
SPI_MasterTransmit(&buffer[0], b_size);
|
|
||||||
// линия
|
|
||||||
b_size = display_draw_line( , , , , 0, &buffer[0]);
|
|
||||||
SPI_MasterTransmit(&buffer[0], b_size);
|
|
||||||
// результат
|
|
||||||
char[12] string_num;
|
|
||||||
itoa(calc.result, &string_num, 10);
|
|
||||||
b_size = display_add_simbol(&string_num, strlen(string_num), &buffer[0]);
|
|
||||||
SPI_MasterTransmit(&buffer[0], b_size);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
display_all_clear(0, size_buffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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 << SPR0);
|
|
||||||
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)));
|
|
||||||
Serial.println("Transmitede");
|
|
||||||
delay(2000);
|
|
||||||
}
|
|
||||||
SPI_PORTX |= (1 << SPI_SS);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
byte crc8(byte *data, int length) {
|
|
||||||
byte crc = 0x00;
|
|
||||||
byte poly = 0x07; //полином для CRC
|
|
||||||
for (int i = 0; i < length - 2; i++) {
|
|
||||||
crc ^= data[i]; //XOR текущего байта с CRC
|
|
||||||
for (int j = 0; j < length; j++) {
|
|
||||||
if (crc & 0x80) { //если старший бит CRC равен 1
|
|
||||||
crc = (crc << 1) ^ poly; //сдвигаем CRC на 1 бит влево и XOR с полиномом
|
|
||||||
} else {
|
|
||||||
crc <<= 1; //иначе просто сдвигаем на 1 бит влево
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return crc;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void setup() {
|
|
||||||
SPI_MasterInit();
|
|
||||||
Serial.begin(9600);
|
|
||||||
Serial.println("Arduino 1 starded");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void loop() {
|
|
||||||
char buffer[] = {'a', 't', 'g', '1', 0};
|
|
||||||
for (int y = 5; y < 21; y++) {
|
|
||||||
// buffer[0] = 0x06;
|
|
||||||
// buffer[1] = 3;
|
|
||||||
// buffer[2] = y;
|
|
||||||
// buffer[3] = 0x01;
|
|
||||||
// buffer[4] = crc8(&buffer[0], 4);
|
|
||||||
SPI_MasterTransmit(&buffer[0], 5);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//очищение экранa
|
|
||||||
size_t display_all_clear(char color, uint8_t* buffer, size_t *size_b) {
|
|
||||||
buffer[0] = 0x01;
|
|
||||||
buffer[1] = color;
|
|
||||||
buffer[2] = crc8(&buffer[0], 2);
|
|
||||||
// int a[17];
|
|
||||||
// size_t n = sizeof(a) / sizeof(a[0]);
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
//выбор точки
|
|
||||||
size_t display_set_page(char point, uint8_t* buffer) {
|
|
||||||
buffer[0] = 0x02;
|
|
||||||
buffer[1] = point;
|
|
||||||
buffer[2] = crc8(&buffer[0], 2);
|
|
||||||
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
//добавление нового символа и его параметров
|
|
||||||
size_t display_add_simbol(char* str, size_t str_len, uint8_t* buffer) {
|
|
||||||
size_t idx;
|
|
||||||
buffer[idx] = 0x04;
|
|
||||||
idx++;
|
|
||||||
for (int i = 0; i < str_len; i++) {
|
|
||||||
buffer[idx] = str;
|
|
||||||
idx++;
|
|
||||||
}
|
|
||||||
buffer[idx] = crc8(&buffer[0], idx);
|
|
||||||
idx++;
|
|
||||||
return idx;
|
|
||||||
}
|
|
||||||
|
|
||||||
//удаление символа и его параметров
|
|
||||||
size_t display_del_simbol(char number, uint8_t* buffer) {
|
|
||||||
buffer[0] = 0x05;
|
|
||||||
buffer[1] = number;
|
|
||||||
buffer[2] = crc8(&buffer[0], 2);
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
//закрашивание пикселя
|
|
||||||
size_t display_draw_pixel(char x, char y, char color, uint8_t* buffer) {
|
|
||||||
buffer[0] = 0x06;
|
|
||||||
buffer[1] = x;
|
|
||||||
buffer[2] = y;
|
|
||||||
buffer[3] = color;
|
|
||||||
buffer[4] = crc8(&buffer[0], 4);
|
|
||||||
return 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
//рисует линию
|
|
||||||
size_t display_draw_line(char x1, char y1, char x2, char y2, char color, uint8_t* buffer) {
|
|
||||||
buffer[0] = 0x07;
|
|
||||||
buffer[1] = x1;
|
|
||||||
buffer[2] = y1;
|
|
||||||
buffer[3] = x2;
|
|
||||||
buffer[4] = y2;
|
|
||||||
buffer[5] = color;
|
|
||||||
buffer[6] = crc8(&buffer[0], 6);
|
|
||||||
return 7;
|
|
||||||
}
|
|
||||||
|
|
||||||
//рисует круг
|
|
||||||
size_t display_draw_circle(char x, char y, char r, char color, uint8_t* buffer) {
|
|
||||||
buffer[0] = 0x08;
|
|
||||||
buffer[1] = x;
|
|
||||||
buffer[2] = y;
|
|
||||||
buffer[3] = r;
|
|
||||||
buffer[4] = color;
|
|
||||||
buffer[5] = crc8(&buffer[0], 5);
|
|
||||||
return 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
//рисует прямоугольник
|
|
||||||
size_t display_draw_rectangle(char x, char y, char height, char width, char color, uint8_t* buffer) {
|
|
||||||
buffer[0] = 0x09;
|
|
||||||
buffer[1] = x;
|
|
||||||
buffer[2] = y;
|
|
||||||
buffer[3] = height;
|
|
||||||
buffer[4] = widht;
|
|
||||||
buffer[5] = color;
|
|
||||||
buffer[6] = crc8(&buffer[0], 6);
|
|
||||||
return 7;
|
|
||||||
}
|
|
144
calculator.c
Normal file
144
calculator.c
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
#include "calculator.h"
|
||||||
|
|
||||||
|
void handleCalc(struct calculator *calc, int input) {
|
||||||
|
switch (calc->state) {
|
||||||
|
case NUMBER_FIRST:
|
||||||
|
switch (input) {
|
||||||
|
case 0:
|
||||||
|
calc->num1 = (calc->num1 * 10) + 7;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
calc->num1 = (calc->num1 * 10) + 8;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
calc->num1 = (calc->num1 * 10) + 9;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
calc->operation = DIV;
|
||||||
|
calc->state = NUMBER_SECOND;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
calc->num1 = (calc->num1 * 10) + 4;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
calc->num1 = (calc->num1 * 10) + 5;
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
calc->num1 = (calc->num1 * 10) + 6;
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
calc->operation = MUL;
|
||||||
|
calc->state = NUMBER_SECOND;
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
calc->num1 = (calc->num1 * 10) + 1;
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
calc->num1 = (calc->num1 * 10) + 2;
|
||||||
|
break;
|
||||||
|
case 10:
|
||||||
|
calc->num1 = (calc->num1 * 10) + 3;
|
||||||
|
break;
|
||||||
|
case 11:
|
||||||
|
calc->operation = SUB;
|
||||||
|
calc->state = NUMBER_SECOND;
|
||||||
|
break;
|
||||||
|
case 12:
|
||||||
|
calc->num1 = (calc->num1 * 10);
|
||||||
|
break;
|
||||||
|
case 13:
|
||||||
|
clearCalc(calc);
|
||||||
|
break;
|
||||||
|
case 14:
|
||||||
|
break;
|
||||||
|
case 15:
|
||||||
|
calc->operation = ADD;
|
||||||
|
calc->state = NUMBER_SECOND;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case NUMBER_SECOND:
|
||||||
|
switch (input) {
|
||||||
|
case 0:
|
||||||
|
calc->num2 = (calc->num2 * 10) + 7;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
calc->num2 = (calc->num2 * 10) + 8;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
calc->num2 = (calc->num2 * 10) + 9;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
calc->num2 = (calc->num2 * 10) + 4;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
calc->num2 = (calc->num2 * 10) + 5;
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
calc->num2 = (calc->num2 * 10) + 6;
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
calc->num2 = (calc->num2 * 10) + 1;
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
calc->num2 = (calc->num2 * 10) + 2;
|
||||||
|
break;
|
||||||
|
case 10:
|
||||||
|
calc->num2 = (calc->num2 * 10) + 3;
|
||||||
|
break;
|
||||||
|
case 11:
|
||||||
|
break;
|
||||||
|
case 12:
|
||||||
|
calc->num2 = (calc->num2 * 10);
|
||||||
|
break;
|
||||||
|
case 13:
|
||||||
|
clearCalc(calc);
|
||||||
|
break;
|
||||||
|
case 14:
|
||||||
|
switch (calc->operation) {
|
||||||
|
case ADD:
|
||||||
|
calc->result = calc->num1 + calc->num2;
|
||||||
|
calc->state = RESULT;
|
||||||
|
break;
|
||||||
|
case SUB:
|
||||||
|
calc->result = calc->num1 - calc->num2;
|
||||||
|
calc->state = RESULT;
|
||||||
|
break;
|
||||||
|
case MUL:
|
||||||
|
calc->result = calc->num1 * calc->num2;
|
||||||
|
calc->state = RESULT;
|
||||||
|
break;
|
||||||
|
case DIV:
|
||||||
|
calc->result = calc->num1 / calc->num2;
|
||||||
|
calc->state = RESULT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 15:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case RESULT:
|
||||||
|
switch (input) {
|
||||||
|
case 14:
|
||||||
|
clearCalc(calc);
|
||||||
|
break;
|
||||||
|
case 13:
|
||||||
|
clearCalc(calc);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void clearCalc(struct calculator *calc) {
|
||||||
|
calc->state = NUMBER_FIRST;
|
||||||
|
calc->operation = NO_OP;
|
||||||
|
calc->num1 = 0;
|
||||||
|
calc->num2 = 0;
|
||||||
|
calc->result = 0;
|
||||||
|
}
|
41
calculator.h
Normal file
41
calculator.h
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* calculator.h
|
||||||
|
*
|
||||||
|
* Created: 29.05.2023 12:01:39
|
||||||
|
* Author: mrnek
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef CALCULATOR_H_
|
||||||
|
#define CALCULATOR_H_
|
||||||
|
|
||||||
|
enum calculator_state {
|
||||||
|
NUMBER_FIRST,
|
||||||
|
NUMBER_SECOND,
|
||||||
|
RESULT
|
||||||
|
};
|
||||||
|
enum calculator_op {
|
||||||
|
NO_OP,
|
||||||
|
ADD,
|
||||||
|
SUB,
|
||||||
|
DIV,
|
||||||
|
MUL
|
||||||
|
};
|
||||||
|
struct calculator {
|
||||||
|
// 1 ÷èñëî
|
||||||
|
long num1;
|
||||||
|
// 2 ÷èñëî
|
||||||
|
long num2;
|
||||||
|
// 3 îïåðàöèÿ
|
||||||
|
enum calculator_op operation;
|
||||||
|
// 4 ðåçóëüòàò
|
||||||
|
long result;
|
||||||
|
// 5 ñîñòîÿíèå àòîìàòà
|
||||||
|
enum calculator_state state;
|
||||||
|
};
|
||||||
|
|
||||||
|
void clearCalc(struct calculator *calc);
|
||||||
|
|
||||||
|
void handleCalc(struct calculator *calc, int input);
|
||||||
|
|
||||||
|
#endif /* CALCULATOR_H_ */
|
96
func.c
Normal file
96
func.c
Normal 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
func.h
Normal file
13
func.h
Normal 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);
|
68
keyboard.c
Normal file
68
keyboard.c
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* core.c
|
||||||
|
*
|
||||||
|
* Created: 13.04.2023 14:28:40
|
||||||
|
* Author: mrnek
|
||||||
|
*/
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "keyboard.h"
|
||||||
|
#include "timer.h"
|
||||||
|
#include "func.h"
|
||||||
|
|
||||||
|
#define MASK_PIND 0b11110000
|
||||||
|
|
||||||
|
static void set_key_event(struct key *button);
|
||||||
|
|
||||||
|
void get_physical_keys(struct key *keys) {
|
||||||
|
uint8_t row;
|
||||||
|
for (int i = 0; i < KEYS_AMOUNT / 4; i++) {
|
||||||
|
PORTC &= ~(1 << i);
|
||||||
|
delay();
|
||||||
|
row = PIND & MASK_PIND;
|
||||||
|
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 << 6)) keys[i * 4 + 2].physical = false; else keys[i * 4 + 2].physical = true;
|
||||||
|
if (row & (1 << 7)) keys[i * 4 + 3].physical = false; else keys[i * 4 + 3].physical = true;
|
||||||
|
PORTC |= (1 << i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void get_logical_keys(struct key *undc_keys) {
|
||||||
|
unsigned long timestamp = get_millis();
|
||||||
|
for(int i = 0; i < KEYS_AMOUNT; i++) {
|
||||||
|
if (undc_keys[i].physical != undc_keys[i].logical) {
|
||||||
|
if (timestamp - undc_keys[i].time >= DEBOUNCE_MS_THRESHOLD) {
|
||||||
|
undc_keys[i].logical = undc_keys[i].physical;
|
||||||
|
set_key_event(&undc_keys[i]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
undc_keys[i].time = timestamp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void fill_buttons_names(struct key *buttons) {
|
||||||
|
for (int i = 0; i < KEYS_AMOUNT; i++) {
|
||||||
|
buttons[i].button = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/************************************************************************/
|
||||||
|
/* */
|
||||||
|
/************************************************************************/
|
||||||
|
static void set_key_event(struct key *button) {
|
||||||
|
if (button->logical == true) {
|
||||||
|
button->on_down = true;
|
||||||
|
} else {
|
||||||
|
button->on_up = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void get_event(struct key *button, bool *up, bool *down) {
|
||||||
|
*up = button->on_up;
|
||||||
|
*down = button->on_down;
|
||||||
|
button->on_up = false;
|
||||||
|
button->on_down = false;
|
||||||
|
}
|
27
keyboard.h
Normal file
27
keyboard.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#include <stdbool.h>
|
||||||
|
/*
|
||||||
|
* core.h
|
||||||
|
*
|
||||||
|
* Created: 13.04.2023 14:23:22
|
||||||
|
* Author: mrnek
|
||||||
|
*/
|
||||||
|
#define KEYS_AMOUNT 16
|
||||||
|
#define DEBOUNCE_MS_THRESHOLD 20
|
||||||
|
|
||||||
|
struct key {
|
||||||
|
char button;
|
||||||
|
unsigned long time;
|
||||||
|
bool physical;
|
||||||
|
bool logical;
|
||||||
|
bool on_down;
|
||||||
|
bool on_up;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void get_physical_keys(struct key *keys);
|
||||||
|
|
||||||
|
void get_logical_keys(struct key *undc_keys);
|
||||||
|
|
||||||
|
void fill_buttons_names(struct key *buttons);
|
||||||
|
|
||||||
|
void get_event(struct key *button, bool *up, bool *down);
|
85
main.c
Normal file
85
main.c
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
#include <avr/interrupt.h>
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "timer.h"
|
||||||
|
#include "keyboard.h"
|
||||||
|
#include "uart.h"
|
||||||
|
#include "spi_master.h"
|
||||||
|
|
||||||
|
void setup_registers() {
|
||||||
|
MCUCR &= ~(1 << 4); // PUD
|
||||||
|
MCUCR &= ~(1 << 5);
|
||||||
|
MCUCR &= ~(1 << 6);
|
||||||
|
MCUCR &= ~(1 << 7);
|
||||||
|
DDRD &= 0x0F;
|
||||||
|
PORTD |= 0xF0;
|
||||||
|
|
||||||
|
DDRC = 0b111111;
|
||||||
|
PORTC = 0b001111;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
USART_Init(MYUBRR);
|
||||||
|
SPI_MasterInit();
|
||||||
|
setup_timer();
|
||||||
|
setup_registers();
|
||||||
|
}
|
||||||
|
|
||||||
|
int up_amoumt = 0;
|
||||||
|
int down_amount = 0;
|
||||||
|
int diff = 0;
|
||||||
|
int diff_prev = 0;
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
setup();
|
||||||
|
puts("Hello\r\n");
|
||||||
|
struct key keys[KEYS_AMOUNT];
|
||||||
|
struct calculator calc;
|
||||||
|
clearCalc(&calc);
|
||||||
|
fill_buttons_names(keys);
|
||||||
|
while(1) {
|
||||||
|
get_physical_keys(keys);
|
||||||
|
get_logical_keys(keys);
|
||||||
|
|
||||||
|
for (int i = 0; i < KEYS_AMOUNT; i++) {
|
||||||
|
bool up, down;
|
||||||
|
get_event(&keys[i], &up, &down);
|
||||||
|
if (down)
|
||||||
|
{
|
||||||
|
//printf("button %d\r\n", keys[i].button);
|
||||||
|
handleCalc(&calc, keys[i].button);
|
||||||
|
output_on_display(&calc);
|
||||||
|
//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);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int puts(const char * __str){
|
||||||
|
int len = strlen(__str);
|
||||||
|
for(size_t i = 0; i < len; i++){
|
||||||
|
while (!(UCSR0A & (1<<UDREn)));
|
||||||
|
UDR0 = __str[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int printf( const char * format, ... )
|
||||||
|
{
|
||||||
|
char buffer[16];
|
||||||
|
va_list args;
|
||||||
|
va_start (args, format);
|
||||||
|
size_t s = vsprintf (buffer,format, args);
|
||||||
|
for(size_t i = 0; i < s; i++){
|
||||||
|
while (!(UCSR0A & (1<<UDREn)));
|
||||||
|
UDR0 = buffer[i];
|
||||||
|
}
|
||||||
|
va_end (args);
|
||||||
|
return s;
|
||||||
|
}
|
@ -1,39 +0,0 @@
|
|||||||
#include <avr/io.h>
|
|
||||||
#include <util/delay.h>
|
|
||||||
|
|
||||||
#define SPI_MISO 5
|
|
||||||
|
|
||||||
#define SPI_PORTX PORTB
|
|
||||||
#define SPI_DDRX DDRB
|
|
||||||
|
|
||||||
void SPI_SlaveInit(void)
|
|
||||||
{
|
|
||||||
/* Настройка ножки порта MISO как выход,
|
|
||||||
все остальные сигналы как вход: */
|
|
||||||
SPI_DDRX = (1 << SPI_MISO);
|
|
||||||
/* Разрешить работу SPI: */
|
|
||||||
SPCR = (1 << SPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
char SPI_SlaveReceive(void)
|
|
||||||
{
|
|
||||||
/* Ожидание завершения приема: */
|
|
||||||
while(!(SPSR & (1 << SPIF)));
|
|
||||||
/* Чтение принятых данных и возврат: */
|
|
||||||
return SPDR;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setup() {
|
|
||||||
SPI_SlaveInit();
|
|
||||||
Serial.begin(9600);
|
|
||||||
Serial.println("Arduino 2 started");
|
|
||||||
}
|
|
||||||
|
|
||||||
void loop() {
|
|
||||||
SPDR = 0;
|
|
||||||
char str[2];
|
|
||||||
str[0] = SPI_SlaveReceive(); // Прием данных
|
|
||||||
str[1] = '\n';
|
|
||||||
Serial.println(str);
|
|
||||||
|
|
||||||
}
|
|
@ -1,85 +0,0 @@
|
|||||||
#include <avr/interrupt.h>
|
|
||||||
#include <avr/io.h>
|
|
||||||
|
|
||||||
#define SPI_PORTX PORTB
|
|
||||||
#define SPI_DDRX DDRB
|
|
||||||
|
|
||||||
#define SPI_MISO 4
|
|
||||||
#define SPI_MOSI 3
|
|
||||||
#define SPI_SCK 5
|
|
||||||
#define SPI_SS 2
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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 << SPR0);
|
|
||||||
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)));
|
|
||||||
Serial.println("Transmitede");
|
|
||||||
delay(2000);
|
|
||||||
}
|
|
||||||
SPI_PORTX |= (1 << SPI_SS);
|
|
||||||
}
|
|
||||||
|
|
||||||
byte crc8(byte* data, int length) {
|
|
||||||
byte crc = 0x00;
|
|
||||||
byte poly = 0x07;
|
|
||||||
for (int i=0; i<length-2; i++){
|
|
||||||
crc ^= data[i];
|
|
||||||
for (int j=0; j<length; j++) {
|
|
||||||
if (crc & 0x80){
|
|
||||||
crc = (crc << 1) ^ poly;
|
|
||||||
}else{
|
|
||||||
crc <<= 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return crc;
|
|
||||||
}
|
|
||||||
/*void SPI_MasterTransmit(char cData)
|
|
||||||
{
|
|
||||||
Serial.println("SPI_MasterTransmitSPI_MasterTransmitSPI_MasterTransmit");
|
|
||||||
SPI_PORTX &= ~(1 << SPI_SS);
|
|
||||||
Запуск передачи данных:
|
|
||||||
SPDR = cData;
|
|
||||||
Ожидание завершения передачи:
|
|
||||||
while(!(SPSR & (1 << SPIF)));
|
|
||||||
Serial.println("Transmitede");
|
|
||||||
SPI_PORTX |= (1 << SPI_SS);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
void setup() {
|
|
||||||
SPI_MasterInit();
|
|
||||||
Serial.begin(9600);
|
|
||||||
Serial.println("Arduino 1 starded");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void loop() {
|
|
||||||
char buffer[] = {'a', 't', 'g', '1', 0};
|
|
||||||
for(int y=5; y<21; y++) {
|
|
||||||
buffer[0]=0x06;
|
|
||||||
buffer[1]=3;
|
|
||||||
buffer[2]=y;
|
|
||||||
buffer[3]=0x01;
|
|
||||||
buffer[4]=crc8;
|
|
||||||
SPI_MasterTransmit(&buffer[0], 5);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
267
spi_master.c
Normal file
267
spi_master.c
Normal 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
spi_master.h
Normal file
18
spi_master.h
Normal 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);
|
26
timer.c
Normal file
26
timer.c
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#include <avr/interrupt.h>
|
||||||
|
#include "timer.h"
|
||||||
|
/*
|
||||||
|
* timer.c
|
||||||
|
*
|
||||||
|
* Created: 13.04.2023 14:13:50
|
||||||
|
* Author: mrnek
|
||||||
|
*/
|
||||||
|
|
||||||
|
static unsigned long millis = 0;
|
||||||
|
|
||||||
|
void setup_timer() {
|
||||||
|
TCCR1B |= (1 << WGM12); // настраиваем режим CTC (Clear Timer on Compare Match)
|
||||||
|
OCR1A = 250; // задаем значение, при котором будет срабатывать прерывание (в данном случае 15999, так как Atmega328p работает на частоте 16 МГц и нужно получить прерывание раз в 1 мс)
|
||||||
|
TIMSK1 |= (1 << OCIE1A); // включаем прерывание по совпадению со значением регистра OCR1A
|
||||||
|
sei(); // разрешаем глобальные прерывания
|
||||||
|
TCCR1B |= (1 << CS11) | (1 << CS10); // запускаем таймер с предделителем 64 (16000000/64=250000)
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long get_millis() {
|
||||||
|
return millis;
|
||||||
|
}
|
||||||
|
|
||||||
|
ISR(TIMER1_COMPA_vect) {
|
||||||
|
++millis;
|
||||||
|
}
|
10
timer.h
Normal file
10
timer.h
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
/*
|
||||||
|
* timer.h
|
||||||
|
*
|
||||||
|
* Created: 13.04.2023 14:12:16
|
||||||
|
* Author: mrnek
|
||||||
|
*/
|
||||||
|
|
||||||
|
void setup_timer();
|
||||||
|
|
||||||
|
unsigned long get_millis();
|
28
uart.c
Normal file
28
uart.c
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* uart.c
|
||||||
|
*
|
||||||
|
* Created: 13.04.2023 15:32:02
|
||||||
|
* Author: mrnek
|
||||||
|
*/
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include "uart.h"
|
||||||
|
|
||||||
|
void USART_Init(unsigned int ubrr) {
|
||||||
|
/*Set baud rate */
|
||||||
|
UBRR0H = (unsigned char)(ubrr>>8);
|
||||||
|
UBRR0L = (unsigned char)ubrr;
|
||||||
|
UBRR0H = 0;
|
||||||
|
UBRR0L = 8;
|
||||||
|
/* Set frame format: 8data, 2stop bit */
|
||||||
|
UCSR0C = (1<<USBS0)|(3<<UCSZ00);
|
||||||
|
/* Enable receiver and transmitter */
|
||||||
|
UCSR0B = (1<<RXEN0)|(1<<TXEN0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void USART_Transmit(unsigned char data) {
|
||||||
|
/* Wait for empty transmit buffer */
|
||||||
|
while (!(UCSR0A & (1<<UDREn)))
|
||||||
|
;
|
||||||
|
/* Put data into buffer, sends the data */
|
||||||
|
UDR0 = data;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user