00001
00002
00003
00004
00005
00006
00007
00008
00037 #ifndef SPI_H_
00038 #define SPI_H_
00039
00040 #include <stdint.h>
00041
00042
00043 #if defined(__AVR_ATmega8__) || \
00044 defined(__AVR_ATmega48__) || \
00045 defined(__AVR_ATmega88__) || \
00046 defined(__AVR_ATmega168__)
00047 #define configure_pin_mosi() DDRB |= (1 << DDB3)
00048 #define configure_pin_sck() DDRB |= (1 << DDB5)
00049 #define configure_pin_ss() DDRB |= (1 << DDB2)
00050 #define configure_pin_miso() DDRB &= ~(1 << DDB4)
00051 #elif defined(__AVR_ATmega16__) || \
00052 defined(__AVR_ATmega32__)
00053 #define configure_pin_mosi() DDRB |= (1 << DDB5)
00054 #define configure_pin_sck() DDRB |= (1 << DDB7)
00055 #define configure_pin_ss() DDRB |= (1 << DDB4)
00056 #define configure_pin_miso() DDRB &= ~(1 << DDB6)
00057 #elif defined(__AVR_ATmega64__) || \
00058 defined(__AVR_ATmega128__) || \
00059 defined(__AVR_ATmega169__)
00060 #define configure_pin_mosi() DDRB |= (1 << DDB2)
00061 #define configure_pin_sck() DDRB |= (1 << DDB1)
00062 #define configure_pin_ss() DDRB |= (1 << DDB0)
00063 #define configure_pin_miso() DDRB &= ~(1 << DDB3)
00064 #else
00065 #error "no spi pin mapping available!"
00066 #endif
00067
00068
00069 extern uint8_t spi_init();
00070 extern uint8_t spi_set_maxspeed();
00071 extern uint8_t spi_read_byte();
00072 extern uint8_t spi_write_byte( int8_t byte );
00073
00078 #endif