1
0
mirror of synced 2024-11-22 09:14:24 +01:00
avr_demo/tpic6b595_spi/spi.c

27 lines
521 B
C
Raw Normal View History

2011-11-20 18:11:58 +01:00
/*
* spi.c
*
* Copyright 2011 Mika Tuupola
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*
*/
#include "digital.h"
#include "spi.h"
void spi_init(void) {
pin_mode(SPI_SCK, OUTPUT);
pin_mode(SPI_MOSI, OUTPUT);
pin_mode(SPI_SS, OUTPUT); /* Must be output in Master mode. */
spi_set_msb();
spi_set_master();
spi_enable();
}
uint8_t spi_transfer(volatile uint8_t data) {
SPDR = data;
loop_until_bit_is_set(SPSR, SPIF);
return SPDR;
}