
//https://github.com/simonbarker/pic-libraries

/*

Software SPI library functions

*/
#ifndef softwareSPI_h
#define softwareSPI_h

#include <stdio.h>
#include <stdlib.h>
#include <xc.h>

#define _XTAL_FREQ 16000000

#define read    1
#define write   0


#define sSPISCK   PORTAbits.RA2
#define sSPIMOSI  PORTAbits.RA1
#define sSPIMISO  PORTAbits.RA0
#define sSPICS    PORTAbits.RA3

unsigned char writeSPIByte(unsigned char transmit);
unsigned char sendSPIWord(unsigned char addr, unsigned char data, char RW);
int writeSPI24bits(unsigned short long setting);
int readSPIWord();
unsigned char readSPIByte();

#endif