Well people, this is what I have done... I think it's full of
mistakes, but as I don't have any SPI device, I cannot test it. Send
comment, opinions and so on.. thanks
Ezequiel
#define SPI_SPCR (*((volatile unsigned char *) 0xE0020000))
#define SPI_SPSR (*((volatile unsigned char *) 0xE0020004))
#define SPI_SPDR (*((volatile unsigned char *) 0xE0020008))
#define SPI_SPCCR (*((volatile unsigned char *) 0xE002000C))
#define SPI_SPTCR (*((volatile unsigned char *) 0xE0020010))
#define SPI_SPTSR (*((volatile unsigned char *) 0xE0020014))
#define SPI_SPTOR (*((volatile unsigned char *) 0xE0020018))
#define SPI_SPINT (*((volatile unsigned char *) 0xE002001C))
unsigned char spi_transfer (unsigned char spi_dataout)
{
unsigned char spi_datain,temp;
SPI_SPDR = spi_dataout; // Send Byte
while (!(SPI_SPSR & 0x80)) {} // Wait until SPIF = 1
temp = SPI_SPSR; // read Status Register
datain = SPI_SPDR; // Get Byte
return datain;
}Message
SPI Transfer Code
2005-01-10 by acetoel
Attachments
- No local attachments were found for this message.