Skip to content

Commit

Permalink
Merge pull request #31 from EnhancedRadioDevices/master
Browse files Browse the repository at this point in the history
Read register command
  • Loading branch information
ps2 authored May 9, 2017
2 parents 4469b70 + 02a79b4 commit 820c00c
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@ Use this command to manually control the LEDs on the device.
Follow this command with the LED you want to configure (0 for green, 1 for blue) and the mode
(0 for off, 1 for on, 2 for auto).

### Read Register: 9

Use this command to read the current value of one of the major registers. See Major Registers section
for a list of available registers and their functions.

## Frequency Channel Selection

Each channel number corresponds to a different specific frequency. Channels start with 916.5 MHz at
Expand Down
117 changes: 116 additions & 1 deletion commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ CommandHandler handlers[] = {
/* 5 */ cmd_send_and_listen,
/* 6 */ cmd_update_register,
/* 7 */ cmd_reset,
/* 8 */ cmd_led
/* 8 */ cmd_led,
/* 9 */ cmd_read_register
};

void cmd_get_packet() {
Expand Down Expand Up @@ -102,6 +103,120 @@ void cmd_send_and_listen() {
}
}

void cmd_read_register() {
uint8_t addr;
uint8_t value;
addr = serial_rx_byte();
switch(addr) {
case 0x00:
value = SYNC1;
break;
case 0x01:
value = SYNC0;
break;
case 0x02:
value = PKTLEN;
break;
case 0x03:
value = PKTCTRL1;
break;
case 0x04:
value = PKTCTRL0;
break;
case 0x05:
value = ADDR;
break;
case 0x06:
value = CHANNR;
break;
case 0x07:
value = FSCTRL1;
break;
case 0x08:
value = FSCTRL0;
break;
case 0x09:
value = FREQ2;
break;
case 0x0A:
value = FREQ1;
break;
case 0x0B:
value = FREQ0;
break;
case 0x0C:
value = MDMCFG4;
break;
case 0x0D:
value = MDMCFG3;
break;
case 0x0E:
value = MDMCFG2;
break;
case 0x0F:
value = MDMCFG1;
break;
case 0x10:
value = MDMCFG0;
break;
case 0x11:
value = DEVIATN;
break;
case 0x12:
value = MCSM2;
break;
case 0x13:
value = MCSM1;
break;
case 0x14:
value = MCSM0;
break;
case 0x15:
value = FOCCFG;
break;
case 0x16:
value = BSCFG;
break;
case 0x17:
value = AGCCTRL2;
break;
case 0x18:
value = AGCCTRL1;
break;
case 0x19:
value = AGCCTRL0;
break;
case 0x1A:
value = FREND1;
break;
case 0x1B:
value = FREND0;
break;
case 0x1C:
value = FSCAL3;
break;
case 0x1D:
value = FSCAL2;
break;
case 0x1E:
value = FSCAL1;
break;
case 0x1F:
value = FSCAL0;
break;
case 0x20:
value = PA_TABLE1;
break;
case 0x21:
value = PA_TABLE0;
break;
default:
value = 0x5A;
}
serial_tx_byte(value);
serial_tx_byte(0);
}

void cmd_update_register() {
uint8_t addr;
uint8_t value;
Expand Down

0 comments on commit 820c00c

Please sign in to comment.