|
#pragma language=extended
#include
#include
#include "spi.h"void SPI_master_init( void )
{
// MOSI, SCK, SS output
DDRB |= (1<PORTB |= 0x01; // SS = hi
SPCR = (1<SPSR = (1< } unsigned int SPI_transfer
(
unsigned int OutData
)
{
unsigned int InData;
PORTB &= 0xfe; //SS = lowSPDR = (unsigned char)(OutData>>8);
while(!(SPSR & (1<InData = SPDR;
InData <<=8;
SPDR = (unsigned char)(0x00ff&OutData);
while(!(SPSR & (1<InData |= SPDR;
PORTB |= 0x01; //SS = hi
return( InData );
}
E-mail: info@telesys.ru