summaryrefslogtreecommitdiff
path: root/software/hhd70dongle/c1101lib.c
diff options
context:
space:
mode:
authorBernhard Tittelbach <xro@realraum.at>2012-05-17 06:14:34 +0000
committerBernhard Tittelbach <xro@realraum.at>2012-05-17 06:14:34 +0000
commit195ea8d1af2745228c8d4a5c893ae0c8e27ba96c (patch)
tree2d1db8aba809dd155462413d4edde4fb565dbbf4 /software/hhd70dongle/c1101lib.c
parentmake SPI work by correcting register typo ;-) (diff)
fix CHP_RDY check, waiting and so on
git-svn-id: https://svn.spreadspace.org/mur.sat@421 7de4ea59-55d0-425e-a1af-a3118ea81d4c
Diffstat (limited to 'software/hhd70dongle/c1101lib.c')
-rw-r--r--software/hhd70dongle/c1101lib.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/software/hhd70dongle/c1101lib.c b/software/hhd70dongle/c1101lib.c
index 57ee7eb..2376e91 100644
--- a/software/hhd70dongle/c1101lib.c
+++ b/software/hhd70dongle/c1101lib.c
@@ -43,18 +43,22 @@
int16_t spi_c1101_write_byte_ok_get_status(char data)
{
- uint8_t debug_sb[6];
+ //~ uint8_t debug_sb[6];
char sb;
unsigned int attempts = 0;
do
{
sb = spi_exchange_byte(data);
- usb_rawhid_send((uint8_t*)"spi byte exchanged ",255);
- debug_sprint_int16hex(debug_sb, sb);
- usb_rawhid_send(debug_sb,255);
+ //Note: content of returned StatusByte is actually context depenedant on sent command
+ // i.e. we won't get Fifo Byte count or overflow status on normal command and so on
+ // e.g. we only get TX Fifo Free Byte count while writing to TX Fifo
+ // thus it makes sense to only check for CHIP_RDY here
+ //~ usb_rawhid_send((uint8_t*)"spi byte exchanged ",255);
+ //~ debug_sprint_int16hex(debug_sb, sb);
+ //~ usb_rawhid_send(debug_sb,255);
if (attempts++ > SPIC1101_MAX_WAIT)
return -1;
- } while ( SPIC1101_SB_CHIPRDY(sb) == 0 );
+ } while ( SPIC1101_SB_CHIP_NOT_RDY(sb) );
return sb;
}
@@ -72,15 +76,6 @@ int16_t spi_c1101_read_register(char address)
return -1;
_delay_ms(10); //FIXME: propably don't need this
rbyte = spi_read_byte();
- uint8_t debug_sb[6];
- debug_sprint_int16hex(debug_sb, rbyte);
- usb_rawhid_send(debug_sb,255);
- rbyte = spi_read_byte();
- debug_sprint_int16hex(debug_sb, rbyte);
- usb_rawhid_send(debug_sb,255);
- rbyte = spi_read_byte();
- debug_sprint_int16hex(debug_sb, rbyte);
- usb_rawhid_send(debug_sb,255);
spi_cs_disable();
return rbyte;
}