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
4581531c
Commit
4581531c
authored
Mar 15, 2017
by
Petter Breedveld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
flyttet OLED til EXT3
parent
54e2f77a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
22 deletions
+36
-22
Debugger_Demo/Debugger_Demo/main.c
Debugger_Demo/Debugger_Demo/main.c
+8
-6
Session3-LF/Task2_LF/Task2_LF/display.c
Session3-LF/Task2_LF/Task2_LF/display.c
+4
-4
Session3-LF/Task2_LF/Task2_LF/main.c
Session3-LF/Task2_LF/Task2_LF/main.c
+13
-0
Session3-LF/Task2_LF/Task2_LF/spi.c
Session3-LF/Task2_LF/Task2_LF/spi.c
+10
-11
Session3/Task2/main.c
Session3/Task2/main.c
+1
-1
No files found.
Debugger_Demo/Debugger_Demo/main.c
View file @
4581531c
...
...
@@ -4,13 +4,14 @@
*/
#define F_CPU 3333333UL
#define BAUD_9600 ((4UL*F_CPU)/9600)
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdio.h>
#define F_CPU 3333333UL
#define BAUD_9600 ((4UL*F_CPU)/9600)
#include <util/delay.h>
int
uart_transmit
(
char
data
,
FILE
*
stream
){
...
...
@@ -48,12 +49,13 @@ ISR(USART0_RXC_vect){
int
main
(
void
)
{
uart_init
(
BAUD_
9600
);
uart_init
(
9600
);
while
(
1
)
{
uart_transmit
(
'O'
,
NULL
);
_delay_ms
(
1000
);
}
}
Session3-LF/Task2_LF/Task2_LF/display.c
View file @
4581531c
...
...
@@ -5,11 +5,11 @@
#define F_CPU 3333333UL
#define DSP_MODE_bm 1<<
7
#define DSP_MODE_PORT PORT
B
#define DSP_MODE_bm 1<<
5
#define DSP_MODE_PORT PORT
C
#define DSP_RST_bm 1<<
4
#define DSP_RST_PORT PORT
A
#define DSP_RST_bm 1<<
5
#define DSP_RST_PORT PORT
B
// System headers
...
...
Session3-LF/Task2_LF/Task2_LF/main.c
View file @
4581531c
...
...
@@ -11,6 +11,19 @@
#include "display.h"
/*
In this exercise you will write a driver for the SPI module. You will connect the OLED screen to the EXT3 header
and use your SPI driver to write bitmaps and text to the screen.
A finished driver for the screen is provided (display.c), as as a font for it. These build uppon the SPI driver.
You can read display.h to see what functions you can use with the screen.
No help beyond the function headers is provided. To start, it's recommend you:
a) glance over the chapter on SPI in the ATtiny817 datasheet
b) find out what pins of the ATtiny the screen is connected to
*/
const
uint8_t
bitmap
[
512
]
PROGMEM
=
{
...
...
Session3-LF/Task2_LF/Task2_LF/spi.c
View file @
4581531c
...
...
@@ -9,18 +9,14 @@
// Project headers
#include "spi.h"
// In this file, you will need to write the contents of the SPI communication routines.
// You need to setup SPI communication in SPI_MasterInit() and
// transmit data in SPI_MasterTransmit(...).
//
// HINT: Check out the , and as always:
// RTFD
//Oled is connected to alternate SPI pins
#define MOSI_bm 1<<2 //on port C
#define SCK_bm 1<<0 //on port C
#define SS_bm 1<<3 //on port
C
#define SS_bm 1<<3 //on port
A
#define SPI_PORT PORTC //We can now use SPI_PORT.DIR, .OUT etc.
#define SS_PORT PORTA //SS is on a different port
//We could also have defined bit positions for MOSI, SCL and SS.
...
...
@@ -31,11 +27,14 @@ void SPI_MasterInit()
// Initialize the SPI port as master
// You will need to set MOSI, SCK, SS (slave select) as outputs
//Connect OLED to EXT3
PORTMUX
.
CTRLB
|=
PORTMUX_SPI0_bm
;
//To use alternative SPI pins
SPI_PORT
.
DIR
|=
MOSI_bm
|
SCK_bm
|
SS_bm
;
//Set pins as output
SPI_PORT
.
DIR
|=
MOSI_bm
|
SCK_bm
;
//Set pins as output
SS_PORT
.
DIR
|=
SS_bm
;
S
PI
_PORT
.
OUTSET
=
SS_bm
;
//Set SS high -> OLED inactive
S
S
_PORT
.
OUTSET
=
SS_bm
;
//Set SS high -> OLED inactive
// Now enable SPI, Master and set clock rate
...
...
@@ -52,7 +51,7 @@ void SPI_MasterInit()
void
SPI_MasterTransmit
(
char
cData
)
{
// First select the correct slave by setting its slave select (SS) LOW
S
PI
_PORT
.
OUTCLR
=
SS_bm
;
S
S
_PORT
.
OUTCLR
=
SS_bm
;
// Then start the transmission by assigning the data to the SPI data register
SPI0
.
DATA
=
cData
;
...
...
@@ -65,5 +64,5 @@ void SPI_MasterTransmit(char cData)
SPI0
.
DATA
;
//Dummy read to clear flag
// Finally set the slave select bit HIGH before leaving the function
S
PI
_PORT
.
OUTSET
=
SS_bm
;
S
S
_PORT
.
OUTSET
=
SS_bm
;
}
Session3/Task2/main.c
View file @
4581531c
...
...
@@ -12,7 +12,7 @@
#include "display.h"
/*
In this exercise you will write a driver for the SPI module. You will connect the OLED screen to the EXT
1
header
In this exercise you will write a driver for the SPI module. You will connect the OLED screen to the EXT
3
header
and use your SPI driver to write bitmaps and text to the screen.
A finished driver for the screen is provided (display.c), as as a font for it. These build uppon the SPI driver.
You can read display.h to see what functions you can use with the screen.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment