/******************************************************************************
                        
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 PORTA
#define CS_DDR DDRA
#define CS_POS PA0

#define CS_HIGH() CS_PORT|=(1<<CS_POS)
#define CS_LOW() CS_PORT&=(~(1<<CS_POS))

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

#endif
