Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
attinykurs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
simenpf
attinykurs
Commits
3f2d896a
Commit
3f2d896a
authored
Feb 23, 2019
by
BuildTools
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Session 3 ported. Oled reset tin is NC(I think), so OLED is acting strange, but working.
parent
8de5c12b
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
268 additions
and
268 deletions
+268
-268
Session3-LF/Task1_LF/Task1_LF/Task1_LF.componentinfo.xml
Session3-LF/Task1_LF/Task1_LF/Task1_LF.componentinfo.xml
+15
-15
Session3-LF/Task1_LF/Task1_LF/Task1_LF.cproj
Session3-LF/Task1_LF/Task1_LF/Task1_LF.cproj
+83
-80
Session3-LF/Task1_LF/Task1_LF/adc.c
Session3-LF/Task1_LF/Task1_LF/adc.c
+2
-3
Session3-LF/Task1_LF/Task1_LF/main.c
Session3-LF/Task1_LF/Task1_LF/main.c
+2
-2
Session3-LF/Task1_LF/Task1_LF/uart.c
Session3-LF/Task1_LF/Task1_LF/uart.c
+28
-11
Session3-LF/Task1_LF/Task1_LF/uart.h
Session3-LF/Task1_LF/Task1_LF/uart.h
+4
-1
Session3-LF/Task2_LF/Task2_LF/Task2_LF.componentinfo.xml
Session3-LF/Task2_LF/Task2_LF/Task2_LF.componentinfo.xml
+15
-15
Session3-LF/Task2_LF/Task2_LF/Task2_LF.cproj
Session3-LF/Task2_LF/Task2_LF/Task2_LF.cproj
+97
-81
Session3-LF/Task2_LF/Task2_LF/display.c
Session3-LF/Task2_LF/Task2_LF/display.c
+3
-12
Session3-LF/Task2_LF/Task2_LF/main.c
Session3-LF/Task2_LF/Task2_LF/main.c
+0
-2
Session3-LF/Task2_LF/Task2_LF/spi.c
Session3-LF/Task2_LF/Task2_LF/spi.c
+11
-21
Session3-LF/Task2_LF/Task2_LF/spi.h
Session3-LF/Task2_LF/Task2_LF/spi.h
+1
-1
Session3/Task1/main.c
Session3/Task1/main.c
+1
-4
Session3/Task2/display.c
Session3/Task2/display.c
+3
-13
Session3/Task2/main.c
Session3/Task2/main.c
+3
-3
Session3/Task2/spi.h
Session3/Task2/spi.h
+0
-4
No files found.
Session3-LF/Task1_LF/Task1_LF/Task1_LF.componentinfo.xml
View file @
3f2d896a
...
...
@@ -9,13 +9,13 @@
<CSub></CSub>
<CVariant></CVariant>
<CVendor>
Atmel
</CVendor>
<CVersion>
1.
1
.0
</CVersion>
<DefaultRepoPath>
D:/Atmel
\7.0\Packs
</DefaultRepoPath>
<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>
D:/Atmel\7.0\Packs\atmel\ATtiny_DFP\1.1.102
\include
</AbsolutePath>
<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>
...
...
@@ -26,29 +26,29 @@
<SourcePath></SourcePath>
</d4p1:anyType>
<d4p1:anyType
i:type=
"FileInfo"
>
<AbsolutePath>
D:/Atmel\7.0\Packs\atmel\ATtiny_DFP\1.1.102\include\avr\iotn817
.h
</AbsolutePath>
<AbsolutePath>
C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.209\include\avr\iom4809
.h
</AbsolutePath>
<Attribute></Attribute>
<Category>
header
</Category>
<Condition>
C
</Condition>
<FileContentHash>
GzsE/dwQAz37AkZENa/sH
g==
</FileContentHash>
<FileContentHash>
mWiFIOAGwUPlW0rYsXcjk
g==
</FileContentHash>
<FileVersion></FileVersion>
<Name>
include/avr/io
tn817
.h
</Name>
<Name>
include/avr/io
m4809
.h
</Name>
<SelectString></SelectString>
<SourcePath></SourcePath>
</d4p1:anyType>
<d4p1:anyType
i:type=
"FileInfo"
>
<AbsolutePath>
D:/Atmel\7.0\Packs\atmel\ATtiny_DFP\1.1.102
\templates\main.c
</AbsolutePath>
<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>
TQP/y9cNoVvAMzruFBs53A
==
</FileContentHash>
<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>
D:/Atmel\7.0\Packs\atmel\ATtiny_DFP\1.1.102
\templates\main.cpp
</AbsolutePath>
<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>
...
...
@@ -59,22 +59,22 @@
<SourcePath></SourcePath>
</d4p1:anyType>
<d4p1:anyType
i:type=
"FileInfo"
>
<AbsolutePath>
D:/Atmel\7.0\Packs\atmel\ATtiny_DFP\1.1.102\gcc\dev\attiny817
</AbsolutePath>
<AbsolutePath>
C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.209\gcc\dev\atmega4809
</AbsolutePath>
<Attribute></Attribute>
<Category>
libraryPrefix
</Category>
<Condition>
GCC
</Condition>
<FileContentHash
i:nil=
"true"
/>
<FileVersion></FileVersion>
<Name>
gcc/dev/at
tiny817
</Name>
<Name>
gcc/dev/at
mega4809
</Name>
<SelectString></SelectString>
<SourcePath></SourcePath>
</d4p1:anyType>
</Files>
<PackName>
AT
tiny
_DFP
</PackName>
<PackPath>
D:/Atmel/7.0/Packs/atmel/ATtiny_DFP/1.1.102/Atmel.ATtiny
_DFP.pdsc
</PackPath>
<PackVersion>
1.
1.102
</PackVersion>
<PackName>
AT
mega
_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>
AT
tiny817
</ReferenceConditionId>
<ReferenceConditionId>
AT
mega4809
</ReferenceConditionId>
<RteComponents
xmlns:d4p1=
"http://schemas.microsoft.com/2003/10/Serialization/Arrays"
>
<d4p1:string></d4p1:string>
</RteComponents>
...
...
Session3-LF/Task1_LF/Task1_LF/Task1_LF.cproj
View file @
3f2d896a
...
...
@@ -5,7 +5,7 @@
<ProjectVersion>
7.0
</ProjectVersion>
<ToolchainName>
com.Atmel.AVRGCC8.C
</ToolchainName>
<ProjectGuid>
dce6c7e3-ee26-4d79-826b-08594b9ad897
</ProjectGuid>
<avrdevice>
AT
tiny817
</avrdevice>
<avrdevice>
AT
mega4809
</avrdevice>
<avrdeviceseries>
none
</avrdeviceseries>
<OutputType>
Executable
</OutputType>
<Language>
C
</Language>
...
...
@@ -27,18 +27,19 @@
<BootSegment>
2
</BootSegment>
<eraseonlaunchrule>
0
</eraseonlaunchrule>
<AsfFrameworkConfig>
<framework-data
xmlns=
""
>
<options
/>
<configurations
/>
<files
/>
<documentation
help=
""
/>
<offline-documentation
help=
""
/>
<dependencies>
<content-extension
eid=
"atmel.asf"
uuidref=
"Atmel.ASF"
version=
"3.32.0
"
/>
</dependencies>
</framework-data>
<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>
<avrtool>
com.atmel.avrdbg.tool.edbg
</avrtool>
<avrtool>
</avrtool>
<avrtoolserialnumber>
ATML2654041800000542
</avrtoolserialnumber>
<avrdeviceexpectedsignature>
0x1E9320
</avrdeviceexpectedsignature>
<avrtoolinterface>
UPDI
</avrtoolinterface>
...
...
@@ -54,83 +55,85 @@
<ToolName>
EDBG
</ToolName>
</com_atmel_avrdbg_tool_edbg>
<avrtoolinterfaceclock>
100000
</avrtoolinterfaceclock>
<ResetRule>
0
</ResetRule>
<EraseKey
/>
</PropertyGroup>
<PropertyGroup
Condition=
" '$(Configuration)' == 'Release' "
>
<ToolchainSettings>
<AvrGcc>
<avrgcc.common.Device>
-mmcu=attiny817 -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\gcc\dev\attiny817
"
</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.1.102
\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.1.102
\include
</Value>
</ListValues>
</avrgcc.assembler.general.IncludePaths>
</AvrGcc>
<avrgcc.common.Device>
-mmcu=atmega4809 -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.2.209\gcc\dev\atmega4809
"
</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=attiny817 -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\gcc\dev\attiny817
"
</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.1.102
\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.1.102
\include
</Value>
</ListValues>
</avrgcc.assembler.general.IncludePaths>
<avrgcc.assembler.debugging.DebugLevel>
Default (-Wa,-g)
</avrgcc.assembler.debugging.DebugLevel>
</AvrGcc>
<avrgcc.common.Device>
-mmcu=atmega4809 -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.2.209\gcc\dev\atmega4809
"
</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>
...
...
Session3-LF/Task1_LF/Task1_LF/adc.c
View file @
3f2d896a
...
...
@@ -10,12 +10,11 @@
void
adc_init
(){
ADC0
.
CTRLA
|=
(
ADC_RESSEL_8BIT_gc
);
//Set resolution, we choose 8 bits
ADC0
.
CTRLB
|=
(
ADC_SAMP
L
NUM_ACC4_gc
);
//OPTIONAL: We can use multiple samples if we like, example here with 4
ADC0
.
CTRLB
|=
(
ADC_SAMPNUM_ACC4_gc
);
//OPTIONAL: We can use multiple samples if we like, example here with 4
//More samples gives a better result but takes longer
ADC0
.
CTRLC
|=
(
ADC_REFSEL_VDDREF_gc
);
//We select to use the supply voltage (VDD) as voltage reference
ADC0
.
CTRLC
|=
(
ADC_PRESC_DIV2_gc
);
//ADC clock prescaler, best accuracy when run below 2MHz. (Here div2 ~1.46 MHz)
ADC0
.
CTRLA
|=
(
ADC_ENABLE_bm
);
//Enable the ADC
}
...
...
@@ -28,7 +27,7 @@ uint8_t adc_read(uint8_t channel){
ADC0
.
COMMAND
|=
(
ADC_STCONV_bm
);
//Start a conversion
while
(
!
(
ADC0
.
INTFLAGS
&
ADC_RESRDY_bm
)){
while
(
!
(
ADC0
.
INTFLAGS
&
ADC_RESRDY_bm
)){
//Wait for the results ready flag to be set
}
return
ADC0
.
RESL
;
//Return 8 bit result
...
...
Session3-LF/Task1_LF/Task1_LF/main.c
View file @
3f2d896a
...
...
@@ -16,7 +16,7 @@
#include "uart.h"
#define LIGHT
6 // Light sensor is connected to ADC channel 6 (which is on port A pin 6
)
#define LIGHT
0x01 // Light sensor is connected to ADC channel 1 (which is on port D pin 1
)
uint8_t
data
=
0
;
...
...
@@ -37,7 +37,7 @@ int main(void)
data
=
adc_read
(
LIGHT
);
//Read the analog voltage on channel 6, connected to light sensor
//The light sensor returns the ones complement (the opposite) of the brightness:
data
=
0xff
-
data
;
data
=
0xff
-
data
;
printf
(
"Light intensity is currently %d brightness points!
\r\n
"
,
data
);
//Print out the value neatly using printf
/*
...
...
Session3-LF/Task1_LF/Task1_LF/uart.c
View file @
3f2d896a
...
...
@@ -14,15 +14,25 @@
void
uart_init
(
unsigned
long
baud
){
//From chapter 24.3 in datasheet
PORTB
.
OUTSET
|=
(
1
<<
PIN2_bp
);
PORTB
.
DIRSET
|=
(
1
<<
PIN2_bp
);
//Setting up TX pin as high output
USART0
.
BAUD
=
baud
;
//Set baudrate
//USART.CTRLC CMODE bits default to: async, 1 stop bit, 8 bit character size
USART0
.
CTRLB
|=
(
1
<<
USART_RXEN_bp
)
|
(
1
<<
USART_TXEN_bp
);
//Enable RX and TX
//From chapter 22.3.1 in datasheet
TX_PORT
.
OUTSET
=
(
1
<<
TX_PIN
);
//Setting up TX pin as output
TX_PORT
.
DIRSET
=
(
1
<<
TX_PIN
);
//Setting up TX pin as output
USART0
.
CTRLA
|=
(
1
<<
USART_RXCIE_bp
);
//Enable interupts on RX
//Set baud rate register
USART3
.
BAUDL
=
(
uint8_t
)
baud
;
//Set baud rate without shifting to get the 8 low bits
USART3
.
BAUDH
=
(
uint8_t
)(
baud
>>
8
);
//Shift register right by 8 bits to get the 8 high bits
//USART.CTRLC CMODE bits default to async, 1 stop bit, 8 bit character size
//Since all bits are default 0 we only need to change the character size part
USART3
.
CTRLC
=
(
0x3
<<
USART_CHSIZE0_bp
);
//Enable RX and TX
USART3
.
CTRLB
=
(
1
<<
USART_RXEN_bp
)
|
(
1
<<
USART_TXEN_bp
);
//Enable interrupts on incoming data
USART3
.
CTRLA
|=
(
1
<<
USART_RXCIE_bp
);
fdevopen
(
uart_transmit
,
NULL
);
//This allows us to use printf instead of writing a single character at a time
//It also allows for easily printing variable values: printf("X is currently: %d \n", x_var);
...
...
@@ -32,10 +42,17 @@ void uart_init(unsigned long baud){
// function to transmit data
int
uart_transmit
(
char
data
,
FILE
*
stream
){
while
(
!
(
USART0
.
STATUS
&
(
1
<<
USART_DREIF_bp
))){
//Wait for ongoing transmission to finish (if there is one)
}
USART0
.
TXDATAL
=
data
;
//Put new data in register
//In this function we will be send data.
//First we should check that there isn't already data being sent
// if there is, we should probably wait for it to finish first
while
(
!
(
USART3
.
STATUS
&
(
1
<<
USART_DREIF_bp
))){
//wait for previous transmit to finish
};
//Put our new data into tx data register
USART3
.
TXDATAL
=
data
;
return
0
;
}
...
...
Session3-LF/Task1_LF/Task1_LF/uart.h
View file @
3f2d896a
...
...
@@ -10,9 +10,12 @@
#define UART_H_
#include <stdio.h> //Required for the FILE* type to be recognzed in the uart_transmit prototype
#define TX_PORT PORTB
#define TX_PIN 0
void
uart_init
(
unsigned
long
baud
);
int
uart_transmit
(
char
data
,
FILE
*
stream
);
int
uart_transmit
(
char
data
,
FILE
*
stream
);
#endif
/* UART_H_ */
\ No newline at end of file
Session3-LF/Task2_LF/Task2_LF/Task2_LF.componentinfo.xml
View file @
3f2d896a
...
...
@@ -9,13 +9,13 @@
<CSub></CSub>
<CVariant></CVariant>
<CVendor>
Atmel
</CVendor>
<CVersion>
1.
1
.0
</CVersion>
<DefaultRepoPath>
D:/Atmel
\7.0\Packs
</DefaultRepoPath>
<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>
D:/Atmel\7.0\Packs\atmel\ATtiny_DFP\1.1.102
\include
</AbsolutePath>
<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>
...
...
@@ -26,29 +26,29 @@
<SourcePath></SourcePath>
</d4p1:anyType>
<d4p1:anyType
i:type=
"FileInfo"
>
<AbsolutePath>
D:/Atmel\7.0\Packs\atmel\ATtiny_DFP\1.1.102\include\avr\iotn817
.h
</AbsolutePath>
<AbsolutePath>
C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.209\include\avr\iom4809
.h
</AbsolutePath>
<Attribute></Attribute>
<Category>
header
</Category>
<Condition>
C
</Condition>
<FileContentHash>
GzsE/dwQAz37AkZENa/sH
g==
</FileContentHash>
<FileContentHash>
mWiFIOAGwUPlW0rYsXcjk
g==
</FileContentHash>
<FileVersion></FileVersion>
<Name>
include/avr/io
tn817
.h
</Name>
<Name>
include/avr/io
m4809
.h
</Name>
<SelectString></SelectString>
<SourcePath></SourcePath>
</d4p1:anyType>
<d4p1:anyType
i:type=
"FileInfo"
>
<AbsolutePath>
D:/Atmel\7.0\Packs\atmel\ATtiny_DFP\1.1.102
\templates\main.c
</AbsolutePath>
<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>
RtJJIrracgoBJUhAmsGN5
g==
</FileContentHash>
<FileContentHash>
GD1k8YYhulqRs6FD1B2Ho
g==
</FileContentHash>
<FileVersion></FileVersion>
<Name>
templates/main.c
</Name>
<SelectString>
Main file (.c)
</SelectString>
<SourcePath></SourcePath>
</d4p1:anyType>
<d4p1:anyType
i:type=
"FileInfo"
>
<AbsolutePath>
D:/Atmel\7.0\Packs\atmel\ATtiny_DFP\1.1.102
\templates\main.cpp
</AbsolutePath>
<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>
...
...
@@ -59,22 +59,22 @@
<SourcePath></SourcePath>
</d4p1:anyType>
<d4p1:anyType
i:type=
"FileInfo"
>
<AbsolutePath>
D:/Atmel\7.0\Packs\atmel\ATtiny_DFP\1.1.102\gcc\dev\attiny817
</AbsolutePath>
<AbsolutePath>
C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.209\gcc\dev\atmega4809
</AbsolutePath>
<Attribute></Attribute>
<Category>
libraryPrefix
</Category>
<Condition>
GCC
</Condition>
<FileContentHash
i:nil=
"true"
/>
<FileVersion></FileVersion>
<Name>
gcc/dev/at
tiny817
</Name>
<Name>
gcc/dev/at
mega4809
</Name>
<SelectString></SelectString>
<SourcePath></SourcePath>
</d4p1:anyType>
</Files>
<PackName>
AT
tiny
_DFP
</PackName>
<PackPath>
D:/Atmel/7.0/Packs/atmel/ATtiny_DFP/1.1.102/Atmel.ATtiny
_DFP.pdsc
</PackPath>
<PackVersion>
1.
1.102
</PackVersion>
<PackName>
AT
mega
_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>
AT
tiny817
</ReferenceConditionId>
<ReferenceConditionId>
AT
mega4809
</ReferenceConditionId>
<RteComponents
xmlns:d4p1=
"http://schemas.microsoft.com/2003/10/Serialization/Arrays"
>
<d4p1:string></d4p1:string>
</RteComponents>
...
...
Session3-LF/Task2_LF/Task2_LF/Task2_LF.cproj
View file @
3f2d896a
...
...
@@ -5,7 +5,7 @@
<ProjectVersion>
7.0
</ProjectVersion>
<ToolchainName>
com.Atmel.AVRGCC8.C
</ToolchainName>
<ProjectGuid>
dce6c7e3-ee26-4d79-826b-08594b9ad897
</ProjectGuid>
<avrdevice>
AT
tiny817
</avrdevice>
<avrdevice>
AT
mega4809
</avrdevice>
<avrdeviceseries>
none
</avrdeviceseries>
<OutputType>
Executable
</OutputType>
<Language>
C
</Language>
...
...
@@ -20,103 +20,119 @@
<OverrideVtor>
false
</OverrideVtor>
<CacheFlash>
true
</CacheFlash>
<ProgFlashFromRam>
true
</ProgFlashFromRam>
<RamSnippetAddress
/
>
<RamSnippetAddress
>
0x20000000
</RamSnippetAddress
>
<UncachedRange
/>
<preserveEEPROM>
true
</preserveEEPROM>
<OverrideVtorValue
/
>
<OverrideVtorValue
>
exception_table
</OverrideVtorValue
>
<BootSegment>
2
</BootSegment>
<eraseonlaunchrule>
0
</eraseonlaunchrule>
<AsfFrameworkConfig>
<framework-data
xmlns=
""
>
<options
/>
<configurations
/>
<files
/>
<documentation
help=
""
/>
<offline-documentation
help=
""
/>
<dependencies>
<content-extension
eid=
"atmel.asf"
uuidref=
"Atmel.ASF"
version=
"3.32.0
"
/>
</dependencies>
</framework-data>
<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
/>
<avrtool>
com.atmel.avrdbg.tool.nedbg
</avrtool>
<avrtoolserialnumber>
ATML3094051800000374
</avrtoolserialnumber>
<avrdeviceexpectedsignature>
0x1E9651
</avrdeviceexpectedsignature>
<avrtoolinterface>
UPDI
</avrtoolinterface>
<com_atmel_avrdbg_tool_nedbg>
<ToolOptions>
<InterfaceProperties>
<UpdiClock>
750000
</UpdiClock>
</InterfaceProperties>
<InterfaceName>
UPDI
</InterfaceName>
</ToolOptions>
<ToolType>
com.atmel.avrdbg.tool.nedbg
</ToolType>
<ToolNumber>
ATML3094051800000374
</ToolNumber>
<ToolName>
nEDBG
</ToolName>
</com_atmel_avrdbg_tool_nedbg>
<avrtoolinterfaceclock>
750000
</avrtoolinterfaceclock>
</PropertyGroup>
<PropertyGroup
Condition=
" '$(Configuration)' == 'Release' "
>
<ToolchainSettings>
<AvrGcc>
<avrgcc.common.Device>
-mmcu=attiny817 -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\gcc\dev\attiny817
"
</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.1.102
\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.1.102
\include
</Value>
</ListValues>
</avrgcc.assembler.general.IncludePaths>
</AvrGcc>
<avrgcc.common.Device>
-mmcu=atmega4809 -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.2.209\gcc\dev\atmega4809
"
</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=attiny817 -B "%24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\gcc\dev\attiny817
"
</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>