added AtmelStudio Project

This commit is contained in:
Dorian Zedler 2018-07-16 13:56:43 +02:00
parent e38d4bcb71
commit 95cc51ba7b
6 changed files with 342 additions and 88 deletions

Binary file not shown.

22
AtTiny_alarm_clock.atsln Normal file
View 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}") = "AtTiny_alarm_clock", "AtTiny_alarm_clock.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

View file

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="utf-8"?>
<Store xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="AtmelPackComponentManagement">
<ProjectComponents>
<ProjectComponent z:Id="i1" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/">
<CApiVersion></CApiVersion>
<CBundle></CBundle>
<CClass>Device</CClass>
<CGroup>Startup</CGroup>
<CSub></CSub>
<CVariant></CVariant>
<CVendor>Atmel</CVendor>
<CVersion>1.3.0</CVersion>
<DefaultRepoPath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs</DefaultRepoPath>
<DependentComponents xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" />
<Description></Description>
<Files xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d4p1:anyType i:type="FileInfo">
<AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.172\include</AbsolutePath>
<Attribute></Attribute>
<Category>include</Category>
<Condition>C</Condition>
<FileContentHash i:nil="true" />
<FileVersion></FileVersion>
<Name>include</Name>
<SelectString></SelectString>
<SourcePath></SourcePath>
</d4p1:anyType>
<d4p1:anyType i:type="FileInfo">
<AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.172\include\avr\iotn2313a.h</AbsolutePath>
<Attribute></Attribute>
<Category>header</Category>
<Condition>C</Condition>
<FileContentHash>S5kp0bTA63lv+OH62wjqfA==</FileContentHash>
<FileVersion></FileVersion>
<Name>include/avr/iotn2313a.h</Name>
<SelectString></SelectString>
<SourcePath></SourcePath>
</d4p1:anyType>
<d4p1:anyType i:type="FileInfo">
<AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.172\templates\main.c</AbsolutePath>
<Attribute>template</Attribute>
<Category>source</Category>
<Condition>C Exe</Condition>
<FileContentHash>2YdP1NP06ldLfwWqlY0byw==</FileContentHash>
<FileVersion></FileVersion>
<Name>templates/main.c</Name>
<SelectString>Main file (.c)</SelectString>
<SourcePath></SourcePath>
</d4p1:anyType>
<d4p1:anyType i:type="FileInfo">
<AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.172\templates\main.cpp</AbsolutePath>
<Attribute>template</Attribute>
<Category>source</Category>
<Condition>C Exe</Condition>
<FileContentHash>YXFphlh0CtZJU+ebktABgQ==</FileContentHash>
<FileVersion></FileVersion>
<Name>templates/main.cpp</Name>
<SelectString>Main file (.cpp)</SelectString>
<SourcePath></SourcePath>
</d4p1:anyType>
<d4p1:anyType i:type="FileInfo">
<AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATtiny_DFP\1.3.172\gcc\dev\attiny2313a</AbsolutePath>
<Attribute></Attribute>
<Category>libraryPrefix</Category>
<Condition>GCC</Condition>
<FileContentHash i:nil="true" />
<FileVersion></FileVersion>
<Name>gcc/dev/attiny2313a</Name>
<SelectString></SelectString>
<SourcePath></SourcePath>
</d4p1:anyType>
</Files>
<PackName>ATtiny_DFP</PackName>
<PackPath>C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATtiny_DFP/1.3.172/Atmel.ATtiny_DFP.pdsc</PackPath>
<PackVersion>1.3.172</PackVersion>
<PresentInProject>true</PresentInProject>
<ReferenceConditionId>ATtiny2313A</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>

128
AtTiny_alarm_clock.cproj Normal file
View file

@ -0,0 +1,128 @@
<?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>ATtiny2313A</avrdevice>
<avrdeviceseries>none</avrdeviceseries>
<OutputType>Executable</OutputType>
<Language>C</Language>
<OutputFileName>$(MSBuildProjectName)</OutputFileName>
<OutputFileExtension>.elf</OutputFileExtension>
<OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>
<AssemblyName>AtTiny_alarm_clock</AssemblyName>
<Name>AtTiny_alarm_clock</Name>
<RootNamespace>AtTiny_alarm_clock</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>
<ResetRule>0</ResetRule>
<eraseonlaunchrule>0</eraseonlaunchrule>
<EraseKey />
<AsfFrameworkConfig>
<framework-data xmlns="">
<options />
<configurations />
<files />
<documentation help="" />
<offline-documentation help="" />
<dependencies>
<content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.40.0" />
</dependencies>
</framework-data>
</AsfFrameworkConfig>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<ToolchainSettings>
<AvrGcc>
<avrgcc.common.Device>-mmcu=attiny2313a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.3.172\gcc\dev\attiny2313a"</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\ATtiny_DFP\1.3.172\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\ATtiny_DFP\1.3.172\include</Value>
</ListValues>
</avrgcc.assembler.general.IncludePaths>
</AvrGcc>
</ToolchainSettings>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<ToolchainSettings>
<AvrGcc>
<avrgcc.common.Device>-mmcu=attiny2313a -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.3.172\gcc\dev\attiny2313a"</avrgcc.common.Device>
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
<avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
<avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
<avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
<avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
<avrgcc.compiler.symbols.DefSymbols>
<ListValues>
<Value>DEBUG</Value>
</ListValues>
</avrgcc.compiler.symbols.DefSymbols>
<avrgcc.compiler.directories.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.3.172\include</Value>
</ListValues>
</avrgcc.compiler.directories.IncludePaths>
<avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
<avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>
<avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
<avrgcc.linker.libraries.Libraries>
<ListValues>
<Value>libm</Value>
</ListValues>
</avrgcc.linker.libraries.Libraries>
<avrgcc.assembler.general.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.3.172\include</Value>
</ListValues>
</avrgcc.assembler.general.IncludePaths>
<avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>
</AvrGcc>
</ToolchainSettings>
</PropertyGroup>
<ItemGroup>
<Compile Include="main.c">
<SubType>compile</SubType>
</Compile>
</ItemGroup>
<Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />
</Project>

94
main.c
View file

@ -1,100 +1,18 @@
/*
* GccApplication1.c
* AtTiny_alarm_clock.c
*
* Created: 10.07.2018 19:39:28
* Created: 16.07.2018 13:55:13
* Author : dozed
*/
#define button1 1234
#define button2 5678
#define button3 whatever
#include <avr/io.h>
typedef enum {CLOCK_INIT = 0, CLOCK_IDLE, CLOCK_ALARM, CLOCK_STOPWATCH_RUNNING, CLOCK_STOPWATCH_STOPPED, CLOCK_STOPWATCH_NOT_SET, CLOCK_USER_INPUT, CLOCK_SET_TIME} clock_state_e;
clock_state_e clock_old_state = NULL;
clock_state_e clock_state = CLOCK_INIT;
clock_state_e clock_new_state = CLOCK_INIT;
int counter = 0; //the counter variable that is being set by the interrupt
//variables for the alarm
bool alarm_active = false;
bool alarm_triggered = false;
int alarm_time = 0;
//variables for the stopwatch
bool stopwatch_running = false;
bool stopwatch_set = false
int stopwatch_started = 0;
int stopwatch_stopped = 0;
//other variables
int user_input = 0; //variable to store user input
int current_time = 0;
int main(void)
{
//-----------INIT----------------
//SETUP PINS (needs to be done)
//attach interrupt (needs to be done)
//-----------END INIT------------
while (1)
{
timer_state = timer_new_state;
switch(clock_state){
case CLOCK_INIT:
//do some init stuff...
lcd.init(); //I know, it's just c but I don't care
//INIT done -> change to IDLE
clock_new_state = CLOCK_IDLE;
break;
case CLOCK_IDLE:
//IDLE MODE
//print the IDLE Screen
lcd.goto(0,0);
lcd.print(counter /*do some claculations*/);
lcd.goto(0,1);
lcd.print("< current time >");
//check buttons
if(button_pressed(1)){
timer_new_state = CLOCK_ALARM;
}
else if(button_pressed(2){
//do something
}
else if(button_pressed(3)){
//do something
}
case CLOCK_ALARM:
//CLOCK ALARM
//check if the alarm time was set
if(user_input == 0){
alarm_time = user_input;
user_input = 0;
}
if(alarm_active){
lcd.goto(0,0);
lcd.print(current_time);
lcd.goto(0,1);
lcd.print("alarm >");
}
/* Replace with your application code */
while (1)
{
}
//do some other stuff (like checking if an alarm has been triggered)
}
}
bool button_pressed(int button_number)
{
bool button_state = /*check the state of the button here*/;
return(button_state);
}

100
main_old.c Normal file
View file

@ -0,0 +1,100 @@
/*
* GccApplication1.c
*
* Created: 10.07.2018 19:39:28
* Author : dozed
*/
#define button1 1234
#define button2 5678
#define button3 whatever
typedef enum {CLOCK_INIT = 0, CLOCK_IDLE, CLOCK_ALARM, CLOCK_STOPWATCH_RUNNING, CLOCK_STOPWATCH_STOPPED, CLOCK_STOPWATCH_NOT_SET, CLOCK_USER_INPUT, CLOCK_SET_TIME} clock_state_e;
clock_state_e clock_old_state = NULL;
clock_state_e clock_state = CLOCK_INIT;
clock_state_e clock_new_state = CLOCK_INIT;
int counter = 0; //the counter variable that is being set by the interrupt
//variables for the alarm
bool alarm_active = false;
bool alarm_triggered = false;
int alarm_time = 0;
//variables for the stopwatch
bool stopwatch_running = false;
bool stopwatch_set = false
int stopwatch_started = 0;
int stopwatch_stopped = 0;
//other variables
int user_input = 0; //variable to store user input
int current_time = 0;
int main(void)
{
//-----------INIT----------------
//SETUP PINS (needs to be done)
//attach interrupt (needs to be done)
//-----------END INIT------------
while (1)
{
timer_state = timer_new_state;
switch(clock_state){
case CLOCK_INIT:
//do some init stuff...
lcd.init(); //I know, it's just c but I don't care
//INIT done -> change to IDLE
clock_new_state = CLOCK_IDLE;
break;
case CLOCK_IDLE:
//IDLE MODE
//print the IDLE Screen
lcd.goto(0,0);
lcd.print(counter /*do some claculations*/);
lcd.goto(0,1);
lcd.print("< current time >");
//check buttons
if(button_pressed(1)){
timer_new_state = CLOCK_ALARM;
}
else if(button_pressed(2){
//do something
}
else if(button_pressed(3)){
//do something
}
case CLOCK_ALARM:
//CLOCK ALARM
//check if the alarm time was set
if(user_input == 0){
alarm_time = user_input;
user_input = 0;
}
if(alarm_active){
lcd.goto(0,0);
lcd.print(current_time);
lcd.goto(0,1);
lcd.print("alarm >");
}
}
//do some other stuff (like checking if an alarm has been triggered)
}
}
bool button_pressed(int button_number)
{
bool button_state = /*check the state of the button here*/;
return(button_state);
}