From cbd3c39dc4a119a65c0aae047504b6c69ed08215 Mon Sep 17 00:00:00 2001 From: Bernhard Tittelbach Date: Sat, 19 May 2012 00:32:43 +0000 Subject: TX test git-svn-id: https://svn.spreadspace.org/mur.sat@430 7de4ea59-55d0-425e-a1af-a3118ea81d4c --- software/hhd70dongle/c1101lib.c | 28 ++++++++++++++--- software/hhd70dongle/c1101lib.h | 3 +- software/hhd70dongle/hhd70dongle.c | 63 ++++++++++++++++++++++---------------- 3 files changed, 62 insertions(+), 32 deletions(-) diff --git a/software/hhd70dongle/c1101lib.c b/software/hhd70dongle/c1101lib.c index 3ccd86b..60a3b4d 100644 --- a/software/hhd70dongle/c1101lib.c +++ b/software/hhd70dongle/c1101lib.c @@ -299,13 +299,33 @@ char c1101_getStatus(void) } -//max len: 64 bytes -void c1101_writeTXFifo(char *buffer, unsigned int len) +void c1101_transmitData(char *buffer, unsigned int len) { //check TXBYTES.NUM_TXBYTES // never write more bytes than avaiblabe or doom ensues - - + 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); + //fill buffer + do + { + num_written = spi_c1101_write_txfifo(buffer, len); + buffer += num_written; + len -= num_written; + } while (num_written > 0); + //start transmitting + spi_c1101_strobe_command(SPIC1101_ADDR_STX); + //keep buffer filled + do + { + num_written = spi_c1101_write_txfifo(buffer, len); + buffer += num_written; + len -= num_written; + if (num_written == 0 && len > 0) + _delay_ms(1); + } while (len > 0); } //max returned: 64 bytes diff --git a/software/hhd70dongle/c1101lib.h b/software/hhd70dongle/c1101lib.h index da4eb7c..db97b70 100644 --- a/software/hhd70dongle/c1101lib.h +++ b/software/hhd70dongle/c1101lib.h @@ -142,8 +142,7 @@ uint16_t c1101_measureTemp(void); void spi_c1101_dump_registers_to_usb(void); void c1101_setFrequency(uint32_t freq, uint8_t freq_offset, uint8_t if_freq); -//max len: 64 bytes -void c1101_writeTXFifo(char *buffer, unsigned int len); +void c1101_transmitData(char *buffer, unsigned int len); //max returned: 64 bytes int c1101_readRXFifo(char *buffer); diff --git a/software/hhd70dongle/hhd70dongle.c b/software/hhd70dongle/hhd70dongle.c index ffef466..acb3d2f 100644 --- a/software/hhd70dongle/hhd70dongle.c +++ b/software/hhd70dongle/hhd70dongle.c @@ -54,7 +54,7 @@ uint8_t write_buffer[64]; // buffer for writing usb signals // * safely save state in eeprom (2 memory regions, only use the one with the "written successfully bit" which is written last) int main(void) -{ +{ CPU_PRESCALE(0); led_init(); spi_init(); @@ -63,29 +63,21 @@ int main(void) DDRB &= ~(1<