1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#include <avr/io.h> #include <util/delay.h> #include <spi.h> void receive(uint8_t data); int main() { DDRB |= _BV(DDB1); spi_receive = receive; spi_init(SPI_MODE_SLAVE); SREG |= _BV(7); while (1) { } } void receive(uint8_t data) { if (data) PORTB |= _BV(PORTB1); else PORTB &= ~_BV(PORTB1); }