summaryrefslogtreecommitdiff
path: root/software/hhd70dongle
diff options
context:
space:
mode:
Diffstat (limited to 'software/hhd70dongle')
-rw-r--r--software/hhd70dongle/c1101lib.c11
-rw-r--r--software/hhd70dongle/hhd70dongle.c39
2 files changed, 24 insertions, 26 deletions
diff --git a/software/hhd70dongle/c1101lib.c b/software/hhd70dongle/c1101lib.c
index 1b463ab..88c5c2f 100644
--- a/software/hhd70dongle/c1101lib.c
+++ b/software/hhd70dongle/c1101lib.c
@@ -229,6 +229,7 @@ void c1101_init(void)
c1101_spi_write_register(SPIC1101_ADDR_DEVIATN, 0x07);
// MCSM0 Main Radio Control State Machine Configuration
c1101_spi_write_register(SPIC1101_ADDR_MCSM0, 0x18);
+ c1101_spi_write_register(SPIC1101_ADDR_MCSM1, 0b00111100); // State RX after recieving packet-> stay in RX; State TX after sending packet -> IDLE
// FOCCFG Frequency Offset Compensation Configuration
c1101_spi_write_register(SPIC1101_ADDR_FOCCFG, 0x16);
// WORCTRL Wake On Radio Control
@@ -344,11 +345,11 @@ void c1101_transmitData(char *buffer, unsigned int len)
{
uint8_t debug_sb[6];
uint8_t num_written = 0;
- uint8_t mcsm1 = c1101_spi_read_register(SPIC1101_ADDR_MCSM1);
- //configure state machine to automatically go to IDLE, once packet was transmitted
- mcsm1 = (mcsm1 & 0b11111100) | 0b00;
- c1101_spi_write_register(SPIC1101_ADDR_MCSM1, 0x18);
- c1101_spi_write_register(SPIC1101_ADDR_PKTCTRL0, 0b0000000001); //crc disabled; use FIFOs; variable packet length mode (first TX FIFO byte must be length)
+ //~ uint8_t mcsm1 = c1101_spi_read_register(SPIC1101_ADDR_MCSM1);
+ //~ //configure state machine to automatically go to IDLE, once packet was transmitted
+ //~ mcsm1 = (mcsm1 & 0b11111100) | 0b00;
+ //~ c1101_spi_write_register(SPIC1101_ADDR_MCSM1, 0x18);
+ //~ c1101_spi_write_register(SPIC1101_ADDR_PKTCTRL0, 0b0000000001); //crc disabled; use FIFOs; variable packet length mode (first TX FIFO byte must be length)
// flush TX FIFO
num_written = c1101_spi_strobe_command(SPIC1101_ADDR_SFTX);
usb_rawhid_send((uint8_t*)"Flush TX Fifo",255);
diff --git a/software/hhd70dongle/hhd70dongle.c b/software/hhd70dongle/hhd70dongle.c
index 9bf3e8b..0f216d2 100644
--- a/software/hhd70dongle/hhd70dongle.c
+++ b/software/hhd70dongle/hhd70dongle.c
@@ -60,13 +60,9 @@ int main(void)
led_init();
hhd70_init();
usb_init();
- // set PB5/ADC12 to INPUT (c1101 temp sensor)
- DDRB &= ~(1<<DDB5);
+ DDRB &= ~(1<<DDB5); // set PB5/ADC12 to INPUT (c1101 temp sensor)
while (!usb_configured()) /* wait */ ;
- //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);
@@ -74,31 +70,32 @@ int main(void)
hhd70_palna_rxmode();
for(;;)
{
+ c1101_spi_strobe_command(SPIC1101_ADDR_SRX); // enter RX - Mode
_delay_ms(1000);
usb_rawhid_recv(read_buffer,20);
if (read_buffer[0] == 'r')
reset();
- //~ if (hhd70_rx_data_available() == 1)
- //~ {
- //~ led_on();
- //~ usb_rawhid_send((uint8_t*)"RX: GDO2 pin HIGH",100);
- //~ usb_rawhid_send((uint8_t*)"c1101 rx bytes:",255);
- //~ debug_sprint_int16hex(write_buffer, c1101_spi_read_register(SPIC1101_ADDR_RXBYTES));
- //~ usb_rawhid_send(write_buffer,255);
- //~ c1101_recieveData();
- //~ led_off();
- //~ }
+ if (hhd70_rx_data_available() == 1)
+ {
+ led_on();
+ usb_rawhid_send((uint8_t*)"RX: GDO2 pin HIGH",100);
+ usb_rawhid_send((uint8_t*)"c1101 rx bytes:",255);
+ debug_sprint_int16hex(write_buffer, c1101_spi_read_register(SPIC1101_ADDR_RXBYTES));
+ usb_rawhid_send(write_buffer,255);
+ c1101_recieveData();
+ led_off();
+ }
usb_rawhid_send((uint8_t*)"c1101 rssi:",255);
debug_sprint_int16hex(write_buffer, c1101_spi_read_register(SPIC1101_ADDR_RSSI));
usb_rawhid_send(write_buffer,255);
- //~ usb_rawhid_send((uint8_t*)"c1101 tx bytes:",255);
- //~ debug_sprint_int16hex(write_buffer, c1101_spi_read_register(SPIC1101_ADDR_TXBYTES));
- //~ usb_rawhid_send(write_buffer,255);
- //~ usb_rawhid_send((uint8_t*)"c1101 rx bytes:",255);
- //~ debug_sprint_int16hex(write_buffer, c1101_spi_read_register(SPIC1101_ADDR_RXBYTES));
- //~ usb_rawhid_send(write_buffer,255);
+ usb_rawhid_send((uint8_t*)"c1101 tx bytes:",255);
+ debug_sprint_int16hex(write_buffer, c1101_spi_read_register(SPIC1101_ADDR_TXBYTES));
+ usb_rawhid_send(write_buffer,255);
+ usb_rawhid_send((uint8_t*)"c1101 rx bytes:",255);
+ debug_sprint_int16hex(write_buffer, c1101_spi_read_register(SPIC1101_ADDR_RXBYTES));
+ usb_rawhid_send(write_buffer,255);
c1101_spi_dump_registers_to_usb();
write_buffer[0]='T';
write_buffer[1]='e';