inital commit with excersise from 2021-10-21
This commit is contained in:
commit
d48aedf507
151
.gitignore
vendored
Normal file
151
.gitignore
vendored
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
## Ignore Atmel/Visual Studio temporary files, build results, and
|
||||||
|
|
||||||
|
## files generated by popular Visual Studio add-ons.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# User-specific files
|
||||||
|
|
||||||
|
*.suo
|
||||||
|
|
||||||
|
*.user
|
||||||
|
|
||||||
|
*.userosscache
|
||||||
|
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
|
||||||
|
[Dd]ebug/
|
||||||
|
|
||||||
|
[Dd]ebugPublic/
|
||||||
|
|
||||||
|
[Rr]elease/
|
||||||
|
|
||||||
|
[Rr]eleases/
|
||||||
|
|
||||||
|
[Xx]64/
|
||||||
|
|
||||||
|
[Xx]86/
|
||||||
|
|
||||||
|
[Bb]uild/
|
||||||
|
|
||||||
|
bld/
|
||||||
|
|
||||||
|
[Bb]in/
|
||||||
|
|
||||||
|
[Oo]bj/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Atmel/Visual Studio cache/options directory
|
||||||
|
|
||||||
|
.vs/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
*_i.c
|
||||||
|
|
||||||
|
*_p.c
|
||||||
|
|
||||||
|
*_i.h
|
||||||
|
|
||||||
|
*.ilk
|
||||||
|
|
||||||
|
*.meta
|
||||||
|
|
||||||
|
*.obj
|
||||||
|
|
||||||
|
*.pch
|
||||||
|
|
||||||
|
*.pdb
|
||||||
|
|
||||||
|
*.pgc
|
||||||
|
|
||||||
|
*.pgd
|
||||||
|
|
||||||
|
*.rsp
|
||||||
|
|
||||||
|
*.sbr
|
||||||
|
|
||||||
|
*.tlb
|
||||||
|
|
||||||
|
*.tli
|
||||||
|
|
||||||
|
*.tlh
|
||||||
|
|
||||||
|
*.tmp
|
||||||
|
|
||||||
|
*.tmp_proj
|
||||||
|
|
||||||
|
*.log
|
||||||
|
|
||||||
|
*.vspscc
|
||||||
|
|
||||||
|
*.vssscc
|
||||||
|
|
||||||
|
.builds
|
||||||
|
|
||||||
|
*.pidb
|
||||||
|
|
||||||
|
*.svclog
|
||||||
|
|
||||||
|
*.scc
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Visual C++ cache files
|
||||||
|
|
||||||
|
ipch/
|
||||||
|
|
||||||
|
*.aps
|
||||||
|
|
||||||
|
*.ncb
|
||||||
|
|
||||||
|
*.opendb
|
||||||
|
|
||||||
|
*.opensdf
|
||||||
|
|
||||||
|
*.sdf
|
||||||
|
|
||||||
|
*.cachefile
|
||||||
|
|
||||||
|
*.VC.db
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Visual Studio profiler
|
||||||
|
|
||||||
|
*.psess
|
||||||
|
|
||||||
|
*.vsp
|
||||||
|
|
||||||
|
*.vspx
|
||||||
|
|
||||||
|
*.sap
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Visual Studio cache files
|
||||||
|
|
||||||
|
# files ending in .cache can be ignored
|
||||||
|
|
||||||
|
*.[Cc]ache
|
||||||
|
|
||||||
|
# but keep track of directories ending in .cache
|
||||||
|
|
||||||
|
!*.[Cc]ache/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Visual Studio 6 build log
|
||||||
|
|
||||||
|
*.plg
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Visual Studio 6 workspace options file
|
||||||
|
|
||||||
|
*.opt
|
22
EmbeddedSystemsTHM.atsln
Normal file
22
EmbeddedSystemsTHM.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}") = "EmbeddedSystemsTHM", "EmbeddedSystemsTHM\EmbeddedSystemsTHM.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|AVR = Debug|AVR
|
||||||
|
Release|AVR = Release|AVR
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.ActiveCfg = Debug|AVR
|
||||||
|
{DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.Build.0 = Debug|AVR
|
||||||
|
{DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.ActiveCfg = Release|AVR
|
||||||
|
{DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.Build.0 = Release|AVR
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
86
EmbeddedSystemsTHM/EmbeddedSystemsTHM.componentinfo.xml
Normal file
86
EmbeddedSystemsTHM/EmbeddedSystemsTHM.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.6.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.6.364\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.6.364\include\avr\iom1284p.h</AbsolutePath>
|
||||||
|
<Attribute></Attribute>
|
||||||
|
<Category>header</Category>
|
||||||
|
<Condition>C</Condition>
|
||||||
|
<FileContentHash>sBNrZHKciubwnkFlY7UYbg==</FileContentHash>
|
||||||
|
<FileVersion></FileVersion>
|
||||||
|
<Name>include/avr/iom1284p.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.6.364\templates\main.c</AbsolutePath>
|
||||||
|
<Attribute>template</Attribute>
|
||||||
|
<Category>source</Category>
|
||||||
|
<Condition>C Exe</Condition>
|
||||||
|
<FileContentHash>Ftfh3cO7UGdUPIQC2OseWw==</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.6.364\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.6.364\gcc\dev\atmega1284p</AbsolutePath>
|
||||||
|
<Attribute></Attribute>
|
||||||
|
<Category>libraryPrefix</Category>
|
||||||
|
<Condition>GCC</Condition>
|
||||||
|
<FileContentHash i:nil="true" />
|
||||||
|
<FileVersion></FileVersion>
|
||||||
|
<Name>gcc/dev/atmega1284p</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.6.364/Atmel.ATmega_DFP.pdsc</PackPath>
|
||||||
|
<PackVersion>1.6.364</PackVersion>
|
||||||
|
<PresentInProject>true</PresentInProject>
|
||||||
|
<ReferenceConditionId>ATmega1284P</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>
|
143
EmbeddedSystemsTHM/EmbeddedSystemsTHM.cproj
Normal file
143
EmbeddedSystemsTHM/EmbeddedSystemsTHM.cproj
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="14.0">
|
||||||
|
<PropertyGroup>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
<ProjectVersion>7.0</ProjectVersion>
|
||||||
|
<ToolchainName>com.Atmel.AVRGCC8.C</ToolchainName>
|
||||||
|
<ProjectGuid>dce6c7e3-ee26-4d79-826b-08594b9ad897</ProjectGuid>
|
||||||
|
<avrdevice>ATmega1284P</avrdevice>
|
||||||
|
<avrdeviceseries>none</avrdeviceseries>
|
||||||
|
<OutputType>Executable</OutputType>
|
||||||
|
<Language>C</Language>
|
||||||
|
<OutputFileName>$(MSBuildProjectName)</OutputFileName>
|
||||||
|
<OutputFileExtension>.elf</OutputFileExtension>
|
||||||
|
<OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>
|
||||||
|
<AssemblyName>EmbeddedSystemsTHM</AssemblyName>
|
||||||
|
<Name>EmbeddedSystemsTHM</Name>
|
||||||
|
<RootNamespace>EmbeddedSystemsTHM</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>
|
||||||
|
<ResetRule>0</ResetRule>
|
||||||
|
<eraseonlaunchrule>0</eraseonlaunchrule>
|
||||||
|
<EraseKey />
|
||||||
|
<avrtool>com.atmel.avrdbg.tool.simulator</avrtool>
|
||||||
|
<avrtoolserialnumber />
|
||||||
|
<avrdeviceexpectedsignature>0x1E9705</avrdeviceexpectedsignature>
|
||||||
|
<com_atmel_avrdbg_tool_simulator>
|
||||||
|
<ToolOptions xmlns="">
|
||||||
|
<InterfaceProperties>
|
||||||
|
</InterfaceProperties>
|
||||||
|
</ToolOptions>
|
||||||
|
<ToolType xmlns="">com.atmel.avrdbg.tool.simulator</ToolType>
|
||||||
|
<ToolNumber xmlns="">
|
||||||
|
</ToolNumber>
|
||||||
|
<ToolName xmlns="">Simulator</ToolName>
|
||||||
|
</com_atmel_avrdbg_tool_simulator>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||||
|
<ToolchainSettings>
|
||||||
|
<AvrGcc>
|
||||||
|
<avrgcc.common.Device>-mmcu=atmega1284p -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.6.364\gcc\dev\atmega1284p"</avrgcc.common.Device>
|
||||||
|
<avrgcc.common.optimization.RelaxBranches>True</avrgcc.common.optimization.RelaxBranches>
|
||||||
|
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
|
||||||
|
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
|
||||||
|
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
|
||||||
|
<avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
|
||||||
|
<avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
|
||||||
|
<avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
|
||||||
|
<avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
|
||||||
|
<avrgcc.compiler.symbols.DefSymbols>
|
||||||
|
<ListValues>
|
||||||
|
<Value>NDEBUG</Value>
|
||||||
|
</ListValues>
|
||||||
|
</avrgcc.compiler.symbols.DefSymbols>
|
||||||
|
<avrgcc.compiler.directories.IncludePaths>
|
||||||
|
<ListValues>
|
||||||
|
<Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.6.364\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.6.364\include\</Value>
|
||||||
|
</ListValues>
|
||||||
|
</avrgcc.assembler.general.IncludePaths>
|
||||||
|
</AvrGcc>
|
||||||
|
</ToolchainSettings>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||||
|
<ToolchainSettings>
|
||||||
|
<AvrGcc>
|
||||||
|
<avrgcc.common.Device>-mmcu=atmega1284p -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.6.364\gcc\dev\atmega1284p"</avrgcc.common.Device>
|
||||||
|
<avrgcc.common.optimization.RelaxBranches>True</avrgcc.common.optimization.RelaxBranches>
|
||||||
|
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
|
||||||
|
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
|
||||||
|
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
|
||||||
|
<avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
|
||||||
|
<avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
|
||||||
|
<avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
|
||||||
|
<avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
|
||||||
|
<avrgcc.compiler.symbols.DefSymbols>
|
||||||
|
<ListValues>
|
||||||
|
<Value>DEBUG</Value>
|
||||||
|
</ListValues>
|
||||||
|
</avrgcc.compiler.symbols.DefSymbols>
|
||||||
|
<avrgcc.compiler.directories.IncludePaths>
|
||||||
|
<ListValues>
|
||||||
|
<Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.6.364\include\</Value>
|
||||||
|
</ListValues>
|
||||||
|
</avrgcc.compiler.directories.IncludePaths>
|
||||||
|
<avrgcc.compiler.optimization.level>Optimize debugging experience (-Og)</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.6.364\include\</Value>
|
||||||
|
</ListValues>
|
||||||
|
</avrgcc.assembler.general.IncludePaths>
|
||||||
|
<avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>
|
||||||
|
</AvrGcc>
|
||||||
|
</ToolchainSettings>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Led.c">
|
||||||
|
<SubType>compile</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Led.h">
|
||||||
|
<SubType>compile</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="main.c">
|
||||||
|
<SubType>compile</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Taster.c">
|
||||||
|
<SubType>compile</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Taster.h">
|
||||||
|
<SubType>compile</SubType>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />
|
||||||
|
</Project>
|
62
EmbeddedSystemsTHM/Led.c
Normal file
62
EmbeddedSystemsTHM/Led.c
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
#include <avr/io.h>
|
||||||
|
|
||||||
|
void Led_init(void){
|
||||||
|
DDRB = 0xFF; // Set all bits in the B Data-Direction Register to output
|
||||||
|
PORTB = 0x00; // Set all bits in the PORT B Register to low to turn all LEDs off
|
||||||
|
}
|
||||||
|
|
||||||
|
void Led1_On(void){
|
||||||
|
PORTB |= (1<<7); // Set the bit for LED_1 to hight to turn it on
|
||||||
|
}
|
||||||
|
void Led1_Off(void){
|
||||||
|
PORTB &= ~(1<<7); // Set the bit for LED_1 to low to turn it off
|
||||||
|
}
|
||||||
|
|
||||||
|
void Led2_On(void){
|
||||||
|
PORTB |= (1<<6);
|
||||||
|
}
|
||||||
|
void Led2_Off(void){
|
||||||
|
PORTB &= ~(1<<6);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Led3_On(void){
|
||||||
|
PORTB |= (1<<5);
|
||||||
|
}
|
||||||
|
void Led3_Off(void){
|
||||||
|
PORTB &= ~(1<<5);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Led4_On(void){
|
||||||
|
PORTB |= (1<<4);
|
||||||
|
}
|
||||||
|
void Led4_Off(void){
|
||||||
|
PORTB &= ~(1<<4);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Led5_On(void){
|
||||||
|
PORTB |= (1<<3);
|
||||||
|
}
|
||||||
|
void Led5_Off(void){
|
||||||
|
PORTB &= ~(1<<3);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Led6_On(void){
|
||||||
|
PORTB |= (1<<2);
|
||||||
|
}
|
||||||
|
void Led6_Off(void){
|
||||||
|
PORTB &= ~(1<<2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Led7_On(void){
|
||||||
|
PORTB |= (1<<1);
|
||||||
|
}
|
||||||
|
void Led7_Off(void){
|
||||||
|
PORTB &= ~(1<<1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Led8_On(void){
|
||||||
|
PORTB |= (1<<0);
|
||||||
|
}
|
||||||
|
void Led8_Off(void){
|
||||||
|
PORTB &= ~(1<<0);
|
||||||
|
}
|
37
EmbeddedSystemsTHM/Led.h
Normal file
37
EmbeddedSystemsTHM/Led.h
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#ifndef LED_H_
|
||||||
|
#define LED_H_
|
||||||
|
#include <avr/io.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
Initialisiert die Hardware für die Led
|
||||||
|
*/
|
||||||
|
void Led_init(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
Funktionen schalten entsprechende LEDs ein oder aus.
|
||||||
|
*/
|
||||||
|
void Led1_On(void);
|
||||||
|
void Led1_Off(void);
|
||||||
|
|
||||||
|
void Led2_On(void);
|
||||||
|
void Led2_Off(void);
|
||||||
|
|
||||||
|
void Led3_On(void);
|
||||||
|
void Led3_Off(void);
|
||||||
|
|
||||||
|
void Led4_On(void);
|
||||||
|
void Led4_Off(void);
|
||||||
|
|
||||||
|
void Led5_On(void);
|
||||||
|
void Led5_Off(void);
|
||||||
|
|
||||||
|
void Led6_On(void);
|
||||||
|
void Led6_Off(void);
|
||||||
|
|
||||||
|
void Led7_On(void);
|
||||||
|
void Led7_Off(void);
|
||||||
|
|
||||||
|
void Led8_On(void);
|
||||||
|
void Led8_Off(void);
|
||||||
|
|
||||||
|
#endif /* LED_H_ */
|
22
EmbeddedSystemsTHM/Taster.c
Normal file
22
EmbeddedSystemsTHM/Taster.c
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#include <avr/io.h>
|
||||||
|
|
||||||
|
void Taster_init(void){
|
||||||
|
DDRD &= ~(7<<5); // Set bit 5-7 of Data Direction Register D as input
|
||||||
|
DDRC &= ~(1<<2); // Set bit 2 of Data Direction Register B as input
|
||||||
|
|
||||||
|
PORTD &= ~(7<<5); // Initialize bit 5-7 of PORTD as low
|
||||||
|
PORTC &= ~(1<<2); // Initialize bit 2 of PORTC as low
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t Taster1_get(void){
|
||||||
|
return PORTD&(1<<7);
|
||||||
|
}
|
||||||
|
uint8_t Taster2_get(void){
|
||||||
|
return PORTD&(1<<6);
|
||||||
|
}
|
||||||
|
uint8_t Taster3_get(void){
|
||||||
|
return PORTD&(1<<5);
|
||||||
|
}
|
||||||
|
uint8_t Taster4_get(void){
|
||||||
|
return PORTC&(1<<2);
|
||||||
|
}
|
21
EmbeddedSystemsTHM/Taster.h
Normal file
21
EmbeddedSystemsTHM/Taster.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#ifndef TASTER_H_
|
||||||
|
#define TASTER_H_
|
||||||
|
|
||||||
|
#include <avr/io.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
Initialisiert die Hardware für die Taster
|
||||||
|
*/
|
||||||
|
void Taster_init(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
Gibt den aktuellen Status der Tasten aus.
|
||||||
|
Rückgabewert 0 = Taster nicht gedr<EFBFBD>ckt, 1 = Taster gedr<EFBFBD>ckt.
|
||||||
|
*/
|
||||||
|
uint8_t Taster1_get(void);
|
||||||
|
uint8_t Taster2_get(void);
|
||||||
|
uint8_t Taster3_get(void);
|
||||||
|
uint8_t Taster4_get(void);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* TASTER_H_ */
|
58
EmbeddedSystemsTHM/main.c
Normal file
58
EmbeddedSystemsTHM/main.c
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* EmbeddedSystemProject.c
|
||||||
|
*
|
||||||
|
* Created: 21/10/2021 16:55:21
|
||||||
|
* Author : n0x
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Led.h"
|
||||||
|
#include "Taster.h"
|
||||||
|
#include <util/delay.h>
|
||||||
|
#ifdef F_CPU
|
||||||
|
#define F_CPU 1000000
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
// Initialize the LEDs and Buttons
|
||||||
|
Led_init();
|
||||||
|
Taster_init();
|
||||||
|
|
||||||
|
|
||||||
|
int counter = 0;
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
_delay_ms(50);
|
||||||
|
|
||||||
|
/* Programmieren Sie ein Lauflicht. Nutzen Sie dazu die in „Led.h“ deklarierten
|
||||||
|
* Funktionen.
|
||||||
|
* 2.Schreiben Sie ein Programm mit folgenden Funktionen:
|
||||||
|
* Wenn Taste 1 gedrückt wird, wird die Variable „Counter“ inkrementiert.
|
||||||
|
* Wird Taste 2 gedrückt wird, wird die Variable „Counter“ dekrementiert.
|
||||||
|
* Variable „Counter“ soll sich dabei zwischen 0 und 8 bewegen.
|
||||||
|
* Der Inhalt des Wertes soll mit Hilfe der LEDs angezeigt werden.
|
||||||
|
* 0 = keine LED an, 1 = LED1 an, 2 = LED1+LED2 an, usw.
|
||||||
|
* 8 = alle LEDs an.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Check if counter needs to be incremented
|
||||||
|
if (Taster1_get()) counter++;
|
||||||
|
|
||||||
|
// Check if counter needs to be decremented
|
||||||
|
if (Taster2_get()) counter--;
|
||||||
|
|
||||||
|
// Keep counter within boundaries (0-8)
|
||||||
|
counter = (counter + 9) % 9;
|
||||||
|
|
||||||
|
// Set the LEDs according to the counter
|
||||||
|
counter >= 1 ? Led1_On() : Led1_Off();
|
||||||
|
counter >= 2 ? Led2_On() : Led2_Off();
|
||||||
|
counter >= 3 ? Led3_On() : Led3_Off();
|
||||||
|
counter >= 4 ? Led4_On() : Led4_Off();
|
||||||
|
counter >= 5 ? Led5_On() : Led5_Off();
|
||||||
|
counter >= 6 ? Led6_On() : Led6_Off();
|
||||||
|
counter >= 7 ? Led7_On() : Led7_Off();
|
||||||
|
counter >= 8 ? Led8_On() : Led8_Off();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user