From 722202c477817732716c29f00b37f754b7abf3a6 Mon Sep 17 00:00:00 2001 From: Bernhard Tittelbach Date: Fri, 22 Jun 2012 02:19:00 +0000 Subject: rx detect works, still receiving mostly noise git-svn-id: https://svn.spreadspace.org/mur.sat@550 7de4ea59-55d0-425e-a1af-a3118ea81d4c --- software/hhd70dongle/c1101lib.c | 15 ++++++--------- software/hhd70dongle/c1101lib.h | 6 ++++++ software/hhd70dongle/hhd70.c | 5 +++-- software/hhd70dongle/hhd70dongle.c | 30 ++++++++++++++++++++++++------ 4 files changed, 39 insertions(+), 17 deletions(-) (limited to 'software') diff --git a/software/hhd70dongle/c1101lib.c b/software/hhd70dongle/c1101lib.c index b0eed03..690d148 100644 --- a/software/hhd70dongle/c1101lib.c +++ b/software/hhd70dongle/c1101lib.c @@ -226,10 +226,11 @@ void c1101_init(void) //enable analog temperature sensor on GDO0 c1101_spi_write_register(SPIC1101_ADDR_IOCFG0, 0x80); //enable RX FIFO interrupt (i.e. GPO2 pulls high if >= FIFOTHR bytes are in RX FIFO) - c1101_spi_write_register(SPIC1101_ADDR_IOCFG2, 0); + c1101_spi_write_register(SPIC1101_ADDR_IOCFG2, 0x41 ); //0x40, 0x42, 0x44, 0x47 // 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) - c1101_spi_write_register(SPIC1101_ADDR_FIFOTHR, 2); + //c1101_spi_write_register(SPIC1101_ADDR_FIFOTHR, 2); //assert at 12 bytes in RX Fifo and 53 in TX Fifo + c1101_spi_write_register(SPIC1101_ADDR_FIFOTHR, 0); //assert at 4 bytes in RX Fifo and 61 in TX Fifo // PKTCTRL0 Packet Automation Control //c1101_spi_write_register(SPIC1101_ADDR_PKTCTRL0, 0b0000000010); //crc disabled; use FIFOs; infinite packet length mode c1101_spi_write_register(SPIC1101_ADDR_PKTCTRL0, 0b0000000001); //crc disabled; use FIFOs; variable packet length mode (first TX FIFO byte must be length) @@ -263,6 +264,9 @@ void c1101_init(void) c1101_spi_write_register(SPIC1101_ADDR_FSCAL2, 0x2A); c1101_spi_write_register(SPIC1101_ADDR_FSCAL1, 0x00); c1101_spi_write_register(SPIC1101_ADDR_FSCAL0, 0x1F); + //FREN0 TX Power: + c1101_spi_write_register(SPIC1101_ADDR_FREND0, 0x10); //should be set using RF-Studio !!, for now, only use PA-Table Entry[0] no power ramping !! (FIXME: but should maybe be used) + c1101_spi_write_register(SPIC1101_ADDR_PATABLE_WRITE, 0xC0); //write PATABLE[0] only, rest needs to be written in Burst-Mode ! set to max power 10dBm // note: for now: assume f_xosc to be 26 Mhz // for ~433.125 Mhz -> freq = 1091741, freq_offset = 0 @@ -335,13 +339,6 @@ char c1101_getStatus(void) hhd70_c1101_wait_chip_rdy(); sb = c1101_spi_write_byte_ok_get_status(SPIC1101_ADDR_SNOP); hhd70_spi_cs_disable(); - //debug start - char debug_sb[6]; - CDC_Device_SendString(&VirtualSerial_CDC_Interface,"c1101 status:\r\n"); - debug_sprint_int16hex(debug_sb, sb); - CDC_Device_SendString(&VirtualSerial_CDC_Interface,debug_sb); - CDC_Device_SendString(&VirtualSerial_CDC_Interface,"\r\n"); - //debug end c1101_handleStatusByte(sb); return sb; } diff --git a/software/hhd70dongle/c1101lib.h b/software/hhd70dongle/c1101lib.h index 3b819da..4dad8a6 100644 --- a/software/hhd70dongle/c1101lib.h +++ b/software/hhd70dongle/c1101lib.h @@ -119,6 +119,12 @@ #define SPIC1101_ADDR_FIFO_WRITE 0x3F #define SPIC1101_ADDR_FIFO_WRITE_BURST (0x3F | 0x40) +#define SPIC1101_ADDR_PATABLE_READ (0x3E | 0x80) +#define SPIC1101_ADDR_PATABLE_READ_BURST (0x3E | 0x80 | 0xC0) +#define SPIC1101_ADDR_PATABLE_WRITE 0x3E +#define SPIC1101_ADDR_PATABLE_WRITE_BURST (0x3E | 0x40) + + #define SPIC1101_SB_CHIP_NOT_RDY(x) (x & 0b10000000) #define SPIC1101_SB_IDLE(x) (x & 0b01110000) == 0 #define SPIC1101_SB_RXMODE(x) (x & 0b01110000) == 0b0010000 diff --git a/software/hhd70dongle/hhd70.c b/software/hhd70dongle/hhd70.c index 6b2ce5f..9b79797 100644 --- a/software/hhd70dongle/hhd70.c +++ b/software/hhd70dongle/hhd70.c @@ -37,7 +37,7 @@ void hhd70_init(void) { //configure Direction of SS / PB0 , MOSI and SCLK as Output to drive CS of CC1101 SPI_DDR = (1< 0) + //~ { + //~ led_on(); + //~ CDC_Device_SendString(&VirtualSerial_CDC_Interface,"RX Buffer Non-Empty\r\n"); + //~ c1101_recieveData(); + //~ led_off(); + //~ } + + CDC_Device_SendString(&VirtualSerial_CDC_Interface,"c1101 status byte: "); + debug_sprint_int16hex(write_buffer, c1101_getStatus()); + CDC_Device_SendString(&VirtualSerial_CDC_Interface,write_buffer); + CDC_Device_SendString(&VirtualSerial_CDC_Interface,"\r\n"); + + //~ c1101_spi_dump_registers_to_usb(); write_buffer[0]='T'; write_buffer[1]='e'; write_buffer[2]='m'; -- cgit v1.2.3