inital commit with excersise from 2021-10-21
commit
d48aedf507
@ -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
|
@ -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>
|
@ -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);
|
||||||
|
}
|
@ -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);
|
||||||
|
}
|
@ -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