summaryrefslogtreecommitdiff
path: root/software/hhd70dongle
diff options
context:
space:
mode:
authorBernhard Tittelbach <xro@realraum.at>2012-05-19 04:42:04 +0000
committerBernhard Tittelbach <xro@realraum.at>2012-05-19 04:42:04 +0000
commit1efcdb813bc35ce3fd8d16950f9cb38f4d9c99f6 (patch)
tree2a5e9f529d6015f6ba5983cc71da420b77541620 /software/hhd70dongle
parentdebug code makes code too slow, causing FIFO underrun -> commented out (diff)
rewrite read_rxfifo. next: write interrupt handler for GPO1
git-svn-id: https://svn.spreadspace.org/mur.sat@436 7de4ea59-55d0-425e-a1af-a3118ea81d4c
Diffstat (limited to 'software/hhd70dongle')
-rw-r--r--software/hhd70dongle/c1101lib.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/software/hhd70dongle/c1101lib.c b/software/hhd70dongle/c1101lib.c
index 0578099..a29974e 100644
--- a/software/hhd70dongle/c1101lib.c
+++ b/software/hhd70dongle/c1101lib.c
@@ -125,21 +125,37 @@ void spi_c1101_dump_registers_to_usb(void)
spi_cs_disable();
}
-//note: currently this function reads at most 15 bytes
int spi_c1101_read_rxfifo(int leave_num_bytes, char *buffer, int maxlen)
{
+ int num_read = 0;
+ uint8_t num_available = 0;
+ spi_cs_enable();
+ spi_c1101_wait_chip_rdy();
+ if (spi_c1101_write_byte_ok_get_status(SPIC1101_ADDR_RXBYTES) < 0)
+ return -1;
+ num_available = spi_read_byte();
+ if (spi_c1101_write_byte_ok_get_status(SPIC1101_ADDR_FIFO_READ_BURST) < 0)
+ return -1;
+ while (maxlen-- > 0 && num_available - num_read > leave_num_bytes)
+ {
+ buffer[num_read++] = spi_read_byte();
+ }
+ spi_cs_disable();
+ return num_read;
+}
+
+//note: currently this function reads at most 15 bytes
+int spi_c1101_read_rxfifo_max15(int leave_num_bytes, char *buffer, int maxlen)
+{
int16_t sb;
int num_read = 0;
- int num_fifo_available = 0;
spi_cs_enable();
spi_c1101_wait_chip_rdy();
sb = spi_c1101_write_byte_ok_get_status(SPIC1101_ADDR_FIFO_READ_BURST);
if (sb < 0)
return -1;
- num_fifo_available = SPIC1101_SB_FIFO_BYTES_AVAILABLE(sb);
- //note if num_fifo_available == 15 then 15 or more bytes are available
- //FIXTHIS
- while (maxlen-- && num_fifo_available - num_read <= leave_num_bytes)
+ //note if SPIC1101_SB_FIFO_BYTES_AVAILABLE(sb) == 15 then 15 or more bytes are available
+ while (maxlen-- > 0 && SPIC1101_SB_FIFO_BYTES_AVAILABLE(sb) - num_read > leave_num_bytes)
{
//hope this works !!
buffer[num_read++] = spi_read_byte();