/******************************************************************************
                        
Simple SPI Communication Functions.

*******************************************************************************/

#include <avr/io.h>

#ifndef SPI_H
#define SPI_H

//SPI PIN CONFIGURATIONS

#define SPI_PORT PORTB
#define SPI_DDR DDRB

	//PINS
#define SCK_POS PB7
#define MISO_POS PB6
#define MOSI_POS PB5
#define SS_POS PB4


/*#ifdef __AVR_ATmega8__
	#define SPI_PORT 	PORTB
	#define SPI_DDR 	DDRB

	//PINS
	#define SCK_POS 	PB5
	#define MISO_POS 	PB4
	#define MOSI_POS	PB3
	#define SS_POS		PB2
#endif
*/

//CS : Chip Select
//#define CS_PORT PORTB
//#define CS_DDR DDRB
//#define CS_POS PB4

#define CS_HIGH() SPI_PORT|=(1<<SS_POS)
#define CS_LOW() SPI_PORT&=(~(1<<SS_POS))

void SPIInit();
void SPIClose();
uint8_t SPIWrite(uint8_t spidata);

#endif
