diff options
-rw-r--r-- | software/hhd70dongle/c1101lib.c | 28 | ||||
-rw-r--r-- | software/hhd70dongle/c1101lib.h | 3 | ||||
-rw-r--r-- | 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<<DDB5); while (!usb_configured()) /* wait */ ; - //int8_t r = usb_rawhid_recv(read_buffer, 0); + //int8_t r = usb_rawhid_recv(read_buffer, 0); //usb_rawhid_send(write_buffer, 23); - + usb_rawhid_send((uint8_t*)"hhd70dongle ready",17); - + _delay_ms(500); c1101_init(); - - for(;;) + + for(;;) { _delay_ms(250); led_toggle(); usb_rawhid_recv(read_buffer,20); if (read_buffer[0] == 'r') reset(); - usb_rawhid_send((uint8_t*)"temp c1101:",255); - debug_sprint_int16hex(write_buffer, adc_read(ADCMUX_ADC12)); - usb_rawhid_send(write_buffer,255); - _delay_ms(250); - usb_rawhid_send((uint8_t*)"temp atmega:",255); - debug_sprint_int16hex(write_buffer, c1101_measureTemp()); - usb_rawhid_send(write_buffer,255); - _delay_ms(250); //~ usb_rawhid_send((uint8_t*)"c1101 partnum:",255); //~ debug_sprint_int16hex(write_buffer, c1101_getPartNum()); //~ usb_rawhid_send(write_buffer,255); @@ -103,21 +95,40 @@ int main(void) usb_rawhid_send((uint8_t*)"c1101 rx bytes:",255); debug_sprint_int16hex(write_buffer, spi_c1101_read_register(SPIC1101_ADDR_RXBYTES)); usb_rawhid_send(write_buffer,255); - usb_rawhid_send((uint8_t*)"c1101 IOCFG2:",255); - debug_sprint_int16hex(write_buffer, spi_c1101_read_register(SPIC1101_ADDR_IOCFG2)); - usb_rawhid_send(write_buffer,255); - usb_rawhid_send((uint8_t*)"c1101 IOCFG1:",255); - debug_sprint_int16hex(write_buffer, spi_c1101_read_register(SPIC1101_ADDR_IOCFG1)); - usb_rawhid_send(write_buffer,255); - usb_rawhid_send((uint8_t*)"c1101 IOCFG0:",255); - debug_sprint_int16hex(write_buffer, spi_c1101_read_register(SPIC1101_ADDR_IOCFG0)); - usb_rawhid_send(write_buffer,255); - usb_rawhid_send((uint8_t*)"c1101 FIFOTHR:",255); - debug_sprint_int16hex(write_buffer, spi_c1101_read_register(SPIC1101_ADDR_FIFOTHR)); - usb_rawhid_send(write_buffer,255); + //usb_rawhid_send((uint8_t*)"c1101 IOCFG2:",255); + //debug_sprint_int16hex(write_buffer, spi_c1101_read_register(SPIC1101_ADDR_IOCFG2)); + //usb_rawhid_send(write_buffer,255); + //usb_rawhid_send((uint8_t*)"c1101 IOCFG1:",255); + //debug_sprint_int16hex(write_buffer, spi_c1101_read_register(SPIC1101_ADDR_IOCFG1)); + //usb_rawhid_send(write_buffer,255); + //usb_rawhid_send((uint8_t*)"c1101 IOCFG0:",255); + //debug_sprint_int16hex(write_buffer, spi_c1101_read_register(SPIC1101_ADDR_IOCFG0)); + //usb_rawhid_send(write_buffer,255); + //usb_rawhid_send((uint8_t*)"c1101 FIFOTHR:",255); + //debug_sprint_int16hex(write_buffer, spi_c1101_read_register(SPIC1101_ADDR_FIFOTHR)); + //usb_rawhid_send(write_buffer,255); usb_rawhid_send((uint8_t*)"c1101 PKTLEN:",255); debug_sprint_int16hex(write_buffer, spi_c1101_read_register(SPIC1101_ADDR_PKTLEN)); usb_rawhid_send(write_buffer,255); spi_c1101_dump_registers_to_usb(); + write_buffer[0]='T'; + write_buffer[1]='e'; + write_buffer[2]='m'; + write_buffer[3]='p'; + write_buffer[4]='s'; + write_buffer[5]=':'; + usb_rawhid_send((uint8_t*)"temp c1101:",255); + debug_sprint_int16hex(write_buffer+6, adc_read(ADCMUX_ADC12)); + usb_rawhid_send(write_buffer+6,255); + _delay_ms(250); + usb_rawhid_send((uint8_t*)"temp atmega:",255); + debug_sprint_int16hex(write_buffer+10, c1101_measureTemp()); + usb_rawhid_send(write_buffer+10,255); + _delay_ms(250); + usb_rawhid_send((uint8_t*)"TX Data: String",255); + c1101_transmitData("OE6EOF test mur.sat GFSK r:9k6 fdev:3mhz 1234567890123456789012345678901234567890 End of Test",93); + _delay_ms(100); + usb_rawhid_send((uint8_t*)"TX Data: Temps",255); + c1101_transmitData((char*) write_buffer,14); } } |