/*
*
* spi.c ( Firmware driver )
* v1.0 (25/05/2003)
*
* Routines for initialisation and use of the SPI
* for the PIC processor.
* Written by Philippe Corbes <philippe.corbes@laposte.net>
* This code is free for personal use.
* You need my agreement for a commercial use.
*
*/
#ifndef __SPI_C
#define __SPI_C
#include <pic.h>
void
spi_write(unsigned char txdata)
{
SSPBUF = txdata; // write out to buffer
while(!SSPIF); // wait for flag
SSPIF = 0; // clear flag
}
unsigned char
spi_read()
{
SSPBUF = 0; // load 0
while(!SSPIF); // wait for data received
SSPIF = 0; // handle flag
return SSPBUF; // return the value
}
#endif /* _SPI_C */