From 195ea8d1af2745228c8d4a5c893ae0c8e27ba96c Mon Sep 17 00:00:00 2001 From: Bernhard Tittelbach Date: Thu, 17 May 2012 06:14:34 +0000 Subject: fix CHP_RDY check, waiting and so on git-svn-id: https://svn.spreadspace.org/mur.sat@421 7de4ea59-55d0-425e-a1af-a3118ea81d4c --- software/hhd70dongle/c1101lib.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'software/hhd70dongle/c1101lib.c') 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; } -- cgit v1.2.3