Commit 3f2d896a authored by BuildTools's avatar BuildTools
Browse files

Session 3 ported. Oled reset tin is NC(I think), so OLED is acting strange, but working.

parent 8de5c12b
......@@ -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/sHg==</FileContentHash>
<FileContentHash>mWiFIOAGwUPlW0rYsXcjkg==</FileContentHash>
<FileVersion></FileVersion>
<Name>include/avr/iotn817.h</Name>
<Name>include/avr/iom4809.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/attiny817</Name>
<Name>gcc/dev/atmega4809</Name>
<SelectString></SelectString>
<SourcePath></SourcePath>
</d4p1:anyType>
</Files>
<PackName>ATtiny_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>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>ATtiny817</ReferenceConditionId>
<ReferenceConditionId>ATmega4809</ReferenceConditionId>
<RteComponents xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d4p1:string></d4p1:string>
</RteComponents>
......
......@@ -5,7 +5,7 @@
<ProjectVersion>7.0</ProjectVersion>
<ToolchainName>com.Atmel.AVRGCC8.C</ToolchainName>
<ProjectGuid>dce6c7e3-ee26-4d79-826b-08594b9ad897</ProjectGuid>
<avrdevice>ATtiny817</avrdevice>
<avrdevice>ATmega4809</avrdevice>
<avrdeviceseries>none</avrdeviceseries>
<OutputType>Executable</OutputType>
<Language>C</Language>
......@@ -27,18 +27,19 @@
<BootSegment>2</BootSegment>
<eraseonlaunchrule>0</eraseonlaunchrule>
<AsfFrameworkConfig>
<framework-data xmlns="">
<framework-data>
<options />
<configurations />
<files />
<documentation help="" />
<offline-documentation help="" />
<dependencies>
<content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.32.0" />
<content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.34.1" />
</dependencies>
</framework-data>
</framework-data>
</AsfFrameworkConfig>
<avrtool>com.atmel.avrdbg.tool.edbg</avrtool>
<avrtool>
</avrtool>
<avrtoolserialnumber>ATML2654041800000542</avrtoolserialnumber>
<avrdeviceexpectedsignature>0x1E9320</avrdeviceexpectedsignature>
<avrtoolinterface>UPDI</avrtoolinterface>
......@@ -54,11 +55,13 @@
<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.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>
......@@ -73,7 +76,7 @@
</avrgcc.compiler.symbols.DefSymbols>
<avrgcc.compiler.directories.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\include</Value>
<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>
......@@ -87,16 +90,16 @@
</avrgcc.linker.libraries.Libraries>
<avrgcc.assembler.general.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\include</Value>
<Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.2.209\include</Value>
</ListValues>
</avrgcc.assembler.general.IncludePaths>
</AvrGcc>
</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.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>
......@@ -111,7 +114,7 @@
</avrgcc.compiler.symbols.DefSymbols>
<avrgcc.compiler.directories.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\include</Value>
<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>
......@@ -126,11 +129,11 @@
</avrgcc.linker.libraries.Libraries>
<avrgcc.assembler.general.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\include</Value>
<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>
</AvrGcc>
</ToolchainSettings>
</PropertyGroup>
<ItemGroup>
......
......@@ -10,12 +10,11 @@
void adc_init(){
ADC0.CTRLA |= (ADC_RESSEL_8BIT_gc); //Set resolution, we choose 8 bits
ADC0.CTRLB |= (ADC_SAMPLNUM_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
}
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -10,6 +10,9 @@
#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);
......
......@@ -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/sHg==</FileContentHash>
<FileContentHash>mWiFIOAGwUPlW0rYsXcjkg==</FileContentHash>
<FileVersion></FileVersion>
<Name>include/avr/iotn817.h</Name>
<Name>include/avr/iom4809.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>RtJJIrracgoBJUhAmsGN5g==</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/attiny817</Name>
<Name>gcc/dev/atmega4809</Name>
<SelectString></SelectString>
<SourcePath></SourcePath>
</d4p1:anyType>
</Files>
<PackName>ATtiny_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>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>ATtiny817</ReferenceConditionId>
<ReferenceConditionId>ATmega4809</ReferenceConditionId>
<RteComponents xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d4p1:string></d4p1:string>
</RteComponents>
......
......@@ -5,7 +5,7 @@
<ProjectVersion>7.0</ProjectVersion>
<ToolchainName>com.Atmel.AVRGCC8.C</ToolchainName>
<ProjectGuid>dce6c7e3-ee26-4d79-826b-08594b9ad897</ProjectGuid>
<avrdevice>ATtiny817</avrdevice>
<avrdevice>ATmega4809</avrdevice>
<avrdeviceseries>none</avrdeviceseries>
<OutputType>Executable</OutputType>
<Language>C</Language>
......@@ -20,31 +20,47 @@
<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="">
<framework-data>
<options />
<configurations />
<files />
<documentation help="" />
<offline-documentation help="" />
<dependencies>
<content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.32.0" />
<content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.34.1" />
</dependencies>
</framework-data>
</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.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>
......@@ -59,7 +75,7 @@
</avrgcc.compiler.symbols.DefSymbols>
<avrgcc.compiler.directories.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\include</Value>
<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>
......@@ -73,16 +89,16 @@
</avrgcc.linker.libraries.Libraries>
<avrgcc.assembler.general.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\include</Value>
<Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.2.209\include</Value>
</ListValues>
</avrgcc.assembler.general.IncludePaths>
</AvrGcc>
</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.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>
......@@ -97,7 +113,7 @@
</avrgcc.compiler.symbols.DefSymbols>
<avrgcc.compiler.directories.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\include</Value>
<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>
......@@ -112,11 +128,11 @@
</avrgcc.linker.libraries.Libraries>
<avrgcc.assembler.general.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\ATtiny_DFP\1.1.102\include</Value>
<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>
</AvrGcc>
</ToolchainSettings>
</PropertyGroup>
<ItemGroup>
......
......@@ -15,21 +15,12 @@
#include "font8x8.h"
//From spi.h:
#ifndef EXT3 // for using EXT1 header:
#define DSP_MODE_bm (1 << 7)
#define DSP_MODE_PORT PORTB
#define DSP_MODE_bm (1 << 3)
#define DSP_MODE_PORT PORTC
#define DSP_RST_bm (1 << 4)
#define DSP_RST_PORT PORTA
#else //For using EXT3 header:
#define DSP_MODE_bm (1 << 5)
#define DSP_MODE_PORT PORTC
#define DSP_RST_bm (1 << 5)
#define DSP_RST_PORT PORTB
#endif /* EXT3 */
......
......@@ -50,8 +50,6 @@ const uint8_t bitmap[512] PROGMEM =
int main(void)
{
// The EXT header can be selected though a define in spi.h
DISP_init();
DISP_write_bitmap(bitmap); //Printing Bitmap
......
......@@ -20,41 +20,31 @@
#define MOSI_bm (1 << 2) //on port C
#define SCK_bm (1 << 0) //on port C
#define SPI_PORT PORTC //
#define MOSI_bm (1 << 4) //on port A
#define SCK_bm (1 << 6) //on port A
#define SPI_PORT PORTA //
#ifndef EXT3 // for using EXT1 header:
#define SS_bm (1 << 3)
#define SS_PORT PORTC
#define CS_bm (1 << 6) //on port C
#define CS_PORT PORTC //
#else // for using EXT3 header:
#define SS_bm (1 << 3)
#define SS_PORT PORTA
#endif /* EXT3 */
void SPI_MasterInit()
{
// Initialize the SPI port as master
// You will need to set MOSI, SCK, SS (slave select) as outputs
// You will need to set MOSI, SCK, CS (slave select) as outputs
PORTMUX.CTRLB |= (PORTMUX_SPI0_bm); //To use alternative SPI pins
SPI_PORT.DIRSET = (MOSI_bm) | (SCK_bm); //Set pins as output
SS_PORT.DIRSET = (SS_bm);
SS_PORT.OUTSET = (SS_bm); //Set SS high -> OLED inactive
CS_PORT.DIRSET = (CS_bm);
CS_PORT.OUTSET = (CS_bm); //Set CS high -> OLED inactive
// Now enable SPI, Master and set clock rate
SPI0.CTRLA |= (SPI_ENABLE_bm) | (SPI_MASTER_bm); //Default clock divisor of 4 is fine
//Make sure SS does not disable master mode
//Make sure CS does not disable master mode
SPI0.CTRLB |= (SPI_SSD_bm);
}
......@@ -62,7 +52,7 @@ void SPI_MasterInit()
void SPI_MasterTransmit(char cData)
{
// First select the correct slave by setting the slave select (SS) bit LOW
SS_PORT.OUTCLR = (SS_bm);
CS_PORT.OUTCLR = (CS_bm);
// Then start the transmission by assigning the data to the SPI data register
SPI0.DATA = cData;
......@@ -73,5 +63,5 @@ void SPI_MasterTransmit(char cData)
SPI0.DATA; //Dummy read to clear flag
// Finally set the slave select bit HIGH before leaving the function
SS_PORT.OUTSET = (SS_bm);
CS_PORT.OUTSET = (CS_bm);
}
......@@ -11,7 +11,7 @@
/*SPI and OLED will use EXT1 default, uncomment to use EXT3:
This define is used by spi.c and display.c to select the correct pins */
#define EXT3
// Function for initializing SPI
......
......@@ -12,16 +12,13 @@
/* In this exercice you will be writing an ADC driver.
You will use this to read the light sensor on the OI1 Xplained board.
Connect the board to the EXT1 Header of the ATtiny817
Connect the board to the EXT1 Header of the ATmega4809
We send the result of the measurement to the computer using UART.
A complete and working UART driver has been provided with the exercise
It has been setup so that you can use printf to print nicely formated text and variable values to the terminal
NOTE:
There is a jumper on the IO board that connects the RX and TX lines. Why could this be a problem?
What might happen if we leave it connected?
*/
int main(void)
......
......@@ -11,25 +11,15 @@
// Project headers
#include "display.h"
#include "spi.h"
#include "font8x8.h"
//From spi.h:
#ifndef EXT3 // for using EXT1 header:
#define DSP_MODE_bm (1 << 7)
#define DSP_MODE_PORT PORTB
#define DSP_MODE_bm (1 << 3)
#define DSP_MODE_PORT PORTC
#define DSP_RST_bm (1 << 4)
#define DSP_RST_PORT PORTA
#else //For using EXT3 header:
#define DSP_MODE_bm (1 << 5)
#define DSP_MODE_PORT PORTC
#define DSP_RST_bm (1 << 5)
#define DSP_RST_PORT PORTB