avr-st7735/spi.c

12 lines
279 B
C
Raw 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
2019-02-28 00:04:33 +01:00
DDRB = (1<<PB3) | (1<<PB5) | (1<<PB2) | (1<<PB0);
// 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
2019-02-28 00:04:33 +01:00
PORTB |= (1 << PB2) | (1 << PB0);
2016-12-05 14:56:09 +01:00
}