avr-st7735/spi.c

12 lines
255 B
C
Raw Permalink Normal View History

2016-12-05 14:56:09 +01:00
#include "spi.h"
void spi_init(void) {
2016-12-05 14:56:09 +01:00
// Set MOSI and SCK, SS/CS output, all others input
DDRB = (1<<PB3) | (1<<PB5) | (1<<PB2);
// Enable SPI, Master, set clock rate fck/4, mode 0
2016-12-05 14:56:09 +01:00
SPCR = (1<<SPE) | (1<<MSTR);
// Set SS/CS
PORTB |= (1 << PB2);
}