summaryrefslogtreecommitdiff
path: root/software
diff options
context:
space:
mode:
authorBernhard Tittelbach <xro@realraum.at>2012-05-19 03:47:26 +0000
committerBernhard Tittelbach <xro@realraum.at>2012-05-19 03:47:26 +0000
commitf20cbac5870ff8495669db3a38af812ff69b804a (patch)
treefdc38a065d3c8d22dfc309fead7e4029a30233ad /software
parentfix strobe command (diff)
more TX test, Carrier is there, but FIFO not emptied
git-svn-id: https://svn.spreadspace.org/mur.sat@433 7de4ea59-55d0-425e-a1af-a3118ea81d4c
Diffstat (limited to 'software')
-rw-r--r--software/hhd70dongle/c1101lib.c81
1 files changed, 61 insertions, 20 deletions
diff --git a/software/hhd70dongle/c1101lib.c b/software/hhd70dongle/c1101lib.c
index d2d0265..a80fa49 100644
--- a/software/hhd70dongle/c1101lib.c
+++ b/software/hhd70dongle/c1101lib.c
@@ -192,7 +192,9 @@ void c1101_init(void)
// 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);
// PKTCTRL0 Packet Automation Control
- spi_c1101_write_register(SPIC1101_ADDR_PKTCTRL0, 0b0000000010);
+ spi_c1101_write_register(SPIC1101_ADDR_PKTCTRL0, 0b0000000010); //crc disabled; use FIFOs; infinite packet length mode
+ //spi_c1101_write_register(SPIC1101_ADDR_PKTCTRL0, 0b0000000001); //crc disabled; use FIFOs; variable packet length mode (first TX FIFO byte must be length)
+ spi_c1101_write_register(SPIC1101_ADDR_PKTCTRL1, 0x00); //no address check, no append rssi and crc_ok to packet
// FSCTRL1 Frequency Synthesizer Control
spi_c1101_write_register(SPIC1101_ADDR_FSCTRL1, 0x06);
// FREQn Frequency Control Words
@@ -258,6 +260,12 @@ char c1101_getPartNum(void)
return spi_c1101_read_register(SPIC1101_ADDR_PARTNUM);
}
+char c1101_putToSleep(void)
+{
+ return spi_c1101_strobe_command(SPIC1101_ADDR_SPWD);
+}
+
+
uint16_t c1101_measureTemp(void)
{
uint16_t temp;
@@ -303,6 +311,20 @@ char c1101_getStatus(void)
return sb;
}
+char c1101_getMARCState(void)
+{
+ char sb=0;
+ sb = spi_c1101_read_register(SPIC1101_ADDR_MARCSTATE);
+ sb &= 0x1F;
+ //debug start
+ uint8_t debug_sb[6];
+ usb_rawhid_send((uint8_t*)"c1101 MARCSate:",255);
+ debug_sprint_int16hex(debug_sb, sb);
+ usb_rawhid_send(debug_sb,255);
+ //debug end
+ return sb;
+}
+
uint8_t c1101_getNumBytesInTXFifo(void)
{
return spi_c1101_read_register(SPIC1101_ADDR_TXBYTES);
@@ -310,38 +332,58 @@ uint8_t c1101_getNumBytesInTXFifo(void)
void c1101_transmitData(char *buffer, unsigned int len)
{
- //check TXBYTES.NUM_TXBYTES
- // never write more bytes than avaiblabe or doom ensues
+ uint8_t debug_sb[6];
uint8_t num_written = 0;
uint8_t mcsm1 = spi_c1101_read_register(SPIC1101_ADDR_MCSM1);
//configure state machine to automatically go to IDLE, once packet was transmitted
mcsm1 = (mcsm1 & 0b11111100) | 0b00;
spi_c1101_write_register(SPIC1101_ADDR_MCSM1, 0x18);
+ // flush TX Buffer
+ num_written = spi_c1101_strobe_command(SPIC1101_ADDR_SFTX);
+ usb_rawhid_send((uint8_t*)"Flush TX Fifo",255);
+ debug_sprint_int16hex(debug_sb, num_written);
+ usb_rawhid_send(debug_sb,255);
- uint8_t debug_sb[6];
- //fill buffer
- num_written = spi_c1101_write_txfifo(buffer, len);
- buffer += num_written;
- len -= num_written;
+ //~ //fill buffer
+ //~ num_written = spi_c1101_write_txfifo(buffer, len);
+ //~ buffer += num_written;
+ //~ len -= num_written;
- usb_rawhid_send((uint8_t*)"TX num written",255);
- debug_sprint_int16hex(debug_sb, num_written);
- usb_rawhid_send(debug_sb,255);
- usb_rawhid_send((uint8_t*)"TX len",255);
- debug_sprint_int16hex(debug_sb, len);
- usb_rawhid_send(debug_sb,255);
+ //~ usb_rawhid_send((uint8_t*)"TX num written",255);
+ //~ debug_sprint_int16hex(debug_sb, num_written);
+ //~ usb_rawhid_send(debug_sb,255);
+ //~ usb_rawhid_send((uint8_t*)"TX len",255);
+ //~ debug_sprint_int16hex(debug_sb, len);
+ //~ usb_rawhid_send(debug_sb,255);
- c1101_getStatus();
- usb_rawhid_send((uint8_t*)"TX bytes",255);
- debug_sprint_int16hex(debug_sb, c1101_getNumBytesInTXFifo());
- usb_rawhid_send(debug_sb,255);
+ //~ c1101_getStatus();
+ //~ usb_rawhid_send((uint8_t*)"TX bytes",255);
+ //~ debug_sprint_int16hex(debug_sb, c1101_getNumBytesInTXFifo());
+ //~ usb_rawhid_send(debug_sb,255);
//start transmitting
- spi_c1101_strobe_command(SPIC1101_ADDR_STX);
+ //num_written = spi_c1101_strobe_command(SPIC1101_ADDR_STX);
+ //~ num_written = spi_exchange_byte(SPIC1101_ADDR_STX);
+ //~ usb_rawhid_send((uint8_t*)"Strobe STX",255);
+ //~ debug_sprint_int16hex(debug_sb, num_written);
+ //~ usb_rawhid_send(debug_sb,255);
+
//keep buffer filled
+ uint8_t c1101_state=0;
do
{
+ c1101_state = c1101_getMARCState();
+ if (c1101_state == 1)
+ {
+ //from idle state, go to RX state
+ num_written = spi_c1101_strobe_command(SPIC1101_ADDR_STX);
+ usb_rawhid_send((uint8_t*)"Strobe STX",255);
+ debug_sprint_int16hex(debug_sb, num_written);
+ usb_rawhid_send(debug_sb,255);
+ }
+
+ c1101_getStatus();
num_written = spi_c1101_write_txfifo(buffer, len );
buffer += num_written;
len -= num_written;
@@ -352,7 +394,6 @@ void c1101_transmitData(char *buffer, unsigned int len)
usb_rawhid_send((uint8_t*)"TX2 len",255);
debug_sprint_int16hex(debug_sb, len);
usb_rawhid_send(debug_sb,255);
- c1101_getStatus();
usb_rawhid_send((uint8_t*)"TX2 bytes",255);
debug_sprint_int16hex(debug_sb, c1101_getNumBytesInTXFifo());
usb_rawhid_send(debug_sb,255);