53 lines
682 B
C
53 lines
682 B
C
#ifndef tinySPI_h
|
|
#define tinySPI_h
|
|
|
|
#include <stdint.h>
|
|
#include <avr/io.h>
|
|
#include <util/atomic.h>
|
|
#include "defines.h"
|
|
|
|
|
|
#ifdef __cplusplus
|
|
extern "C"{
|
|
#endif
|
|
|
|
#if defined (__AVR_ATmega32__)
|
|
|
|
#elif defined (__AVR_ATmega2560__)
|
|
#define SPI_PORT PORTB
|
|
#define SPI_DDR DDRB
|
|
|
|
#define SS_PIN PB0
|
|
#define SCK_PIN PB1
|
|
#define MOSI_PIN PB2
|
|
#define MISO_PIN PB3
|
|
|
|
#elif defined (__AVR_ATmega32U4__)
|
|
|
|
#define SPI_PORT PORTB
|
|
#define SPI_DDR DDRB
|
|
|
|
|
|
#define SS_PIN PB0
|
|
#define SCK_PIN PB1
|
|
#define MOSI_PIN PB2
|
|
#define MISO_PIN PB3
|
|
|
|
|
|
#endif
|
|
|
|
|
|
void spi_init_master(void);
|
|
void spi_init_slave(void);
|
|
|
|
uint8_t spi_transfer(uint8_t spiData);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
} // extern "C"
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|