summaryrefslogtreecommitdiff
path: root/software/hhd70dongle/c1101lib.c
diff options
context:
space:
mode:
authorBernhard Tittelbach <xro@realraum.at>2012-05-19 20:12:42 +0000
committerBernhard Tittelbach <xro@realraum.at>2012-05-19 20:12:42 +0000
commita72fc32daf434dc7ad59e4065c18332ddd7f67b0 (patch)
treed6189b31a46fc68f1ff52f2bb75c82867ff428e2 /software/hhd70dongle/c1101lib.c
parentenable/disable PA and LNA (diff)
first attempt at RX/TX w/ 2 dongles
git-svn-id: https://svn.spreadspace.org/mur.sat@440 7de4ea59-55d0-425e-a1af-a3118ea81d4c
Diffstat (limited to 'software/hhd70dongle/c1101lib.c')
-rw-r--r--software/hhd70dongle/c1101lib.c37
1 files changed, 25 insertions, 12 deletions
diff --git a/software/hhd70dongle/c1101lib.c b/software/hhd70dongle/c1101lib.c
index 30bb94c..61780d5 100644
--- a/software/hhd70dongle/c1101lib.c
+++ b/software/hhd70dongle/c1101lib.c
@@ -134,6 +134,8 @@ int spi_c1101_read_rxfifo(int leave_num_bytes, char *buffer, int maxlen)
if (spi_c1101_write_byte_ok_get_status(SPIC1101_ADDR_RXBYTES) < 0)
return -1;
num_available = spi_read_byte();
+ if (num_available == 0)
+ return 0;
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)
@@ -202,8 +204,8 @@ void c1101_init(void)
spi_c1101_dump_registers_to_usb();
//enable analog temperature sensor on GDO0
spi_c1101_write_register(SPIC1101_ADDR_IOCFG0, 0x80);
- //enable RX FIFO interrupt (i.e. GPO1 pulls high if >= FIFOTHR bytes are in RX FIFO)
- spi_c1101_write_register(SPIC1101_ADDR_IOCFG1, 0);
+ //enable RX FIFO interrupt (i.e. GPO2 pulls high if >= FIFOTHR bytes are in RX FIFO)
+ spi_c1101_write_register(SPIC1101_ADDR_IOCFG2, 0);
// FIFOTHR RX FIFO and TX FIFO Thresholds
// pull GPO high (interrupt) if more than 12 bytes in rx buffer (or less than 53 in tx)
spi_c1101_write_register(SPIC1101_ADDR_FIFOTHR, 2);
@@ -268,16 +270,6 @@ void c1101_setFrequency(uint32_t freq, uint8_t freq_offset, uint8_t if_freq)
spi_c1101_write_register(SPIC1101_ADDR_CHANNR, 0);
}
-char c1101_getVersion(void)
-{
- return spi_c1101_read_register(SPIC1101_ADDR_VERSION);
-}
-
-char c1101_getPartNum(void)
-{
- return spi_c1101_read_register(SPIC1101_ADDR_PARTNUM);
-}
-
char c1101_putToSleep(void)
{
return spi_c1101_strobe_command(SPIC1101_ADDR_SPWD);
@@ -425,7 +417,28 @@ void c1101_transmitData(char *buffer, unsigned int len)
//disable Power Amplifier
hhd70_pa_disable();
+ hhd70_lna_enable();
+}
+void c1101_recieveData(void)
+{
+ uint8_t const max_len=255;
+ char recv_data[256];
+ uint8_t num_recv = 0;
+ uint8_t num_recv_total = 0;
+ uint8_t num_leave_in_fifo = 1;
+ do
+ {
+ num_recv = spi_c1101_read_rxfifo( num_leave_in_fifo, recv_data+num_recv_total, max_len - num_recv_total);
+ num_recv_total += num_recv;
+
+ //variable packet length:
+ //don't read last byte in fifo unless packet has finished receiving
+ num_leave_in_fifo = (recv_data[0] - num_recv_total < 64)? 0 : 1;
+ } while (num_recv > 0);
+ recv_data[num_recv_total]=0;
+ usb_rawhid_send((uint8_t*)"RX: Data Recieved:",255);
+ usb_rawhid_send((uint8_t*)recv_data,255);
}
//max returned: 64 bytes