Commit 4581531c authored by Petter Breedveld's avatar Petter Breedveld

flyttet OLED til EXT3

parent 54e2f77a
......@@ -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);
}
}
......@@ -5,11 +5,11 @@
#define F_CPU 3333333UL
#define DSP_MODE_bm 1<<7
#define DSP_MODE_PORT PORTB
#define DSP_MODE_bm 1<<5
#define DSP_MODE_PORT PORTC
#define DSP_RST_bm 1<<4
#define DSP_RST_PORT PORTA
#define DSP_RST_bm 1<<5
#define DSP_RST_PORT PORTB
// System headers
......
......@@ -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 =
{
......
......@@ -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;
SPI_PORT.OUTSET = SS_bm; //Set SS high -> OLED inactive
SS_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
SPI_PORT.OUTCLR = SS_bm;
SS_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
SPI_PORT.OUTSET = SS_bm;
SS_PORT.OUTSET = SS_bm;
}
......@@ -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 EXT1 header
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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment