summaryrefslogtreecommitdiff
path: root/software/hhd70dongle/spi.c
diff options
context:
space:
mode:
authorBernhard Tittelbach <xro@realraum.at>2012-05-17 06:14:31 +0000
committerBernhard Tittelbach <xro@realraum.at>2012-05-17 06:14:31 +0000
commit3933e444d919d33475e8f9c05c54e24a9a127061 (patch)
tree3f3de3238c6622fae29038a7c8034542a915fd6f /software/hhd70dongle/spi.c
parentdebugging test attempts (diff)
make SPI work by understanding how it actually works
git-svn-id: https://svn.spreadspace.org/mur.sat@419 7de4ea59-55d0-425e-a1af-a3118ea81d4c
Diffstat (limited to 'software/hhd70dongle/spi.c')
-rw-r--r--software/hhd70dongle/spi.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/software/hhd70dongle/spi.c b/software/hhd70dongle/spi.c
index e676fbf..85831d1 100644
--- a/software/hhd70dongle/spi.c
+++ b/software/hhd70dongle/spi.c
@@ -69,26 +69,24 @@ void spi_cs_disable(void)
PORTB |= (1<<CS);
}
-//synchronous
void spi_write_byte(char byte)
{
SPDR = byte; //Load byte to Data register
while(!(SPSR & (1<<SPIF))); // Wait for transmission complete
}
-//~ void spi_write(char* data, unsigned int len)
-//~ {
- //~ for (unsigned int c=0; c<len; c++)
- //~ spi_write_byte(data[c]);
-//~ }
-
-//MSB first
char spi_read_byte(void)
{
while(SPI_PINB_REG & (1<<MISO)); /* wait for CC1101 to get ready... */
return SPSR;
}
+char spi_exchange_byte(char byte)
+{
+ spi_write_byte(byte);
+ return spi_read_byte();
+}
+
//~ void spi_read(unsigned int maxlen, char *data, unsigned int *len)
//~ {
//~ PORTB |= (1<<CS);