#ifndef _SPI_H_
#define _SPI_H_

#include "defs.h"

// SPI Input
#define SI_DATA_OUT			0
#define SI_CLOCK			1
#define SI_PLOAD			2
#define SI_CLOCK_ENABLE		3

// SPI Output
#define SO_INPUT_ENABLE		0 // Set LOW to enable serial input
#define SO_CLOCK			1 // Strobe HIGH to move the data bit onto the chip
#define SO_DATA				2 // The input data bit to pass to the chip
#define SO_OUTPUT_ENABLE	3 // Set LOW to enable output update

#define PULSE_WIDTH_US		5 // Microsec

#define SET_PIN(port, bit) \
	PORT##port |= (1 << bit)
#define CLR_PIN(port, bit) \
	PORT##port &= ~(1 << bit)

extern void spiInit(void);

extern void spiWrite16(uint16 v);
extern uint8 spiRead8(void);
extern uint16 spiRead16(void);

#endif