reg_map_cc2500 = { 0x00 : ("IOCFG2", "GDO2 output pin configuration"), 0x01 : ("IOCFG1", "GDO1 output pin configuration"), 0x02 : ("IOCFG0", "GDO0 output pin configuration"), 0x03 : ("FIFOTHR", "RX FIFO and TX FIFO thresholds"), 0x04 : ("SYNC1", "Sync word, high byte"), 0x05 : ("SYNC0", "Sync word, low byte"), 0x06 : ("PKTLEN", "Packet length"), 0x07 : ("PKTCTRL1", "Packet automation control"), 0x08 : ("PKTCTRL0", "Packet automation control"), 0x09 : ("ADDR", "Device address"), 0x0A : ("CHANNR", "Channel number"), 0x0B : ("FSCTRL1", "Frequency synthesizer control"), 0x0C : ("FSCTRL0", "Frequency synthesizer control"), 0x0D : ("FREQ2", "Frequency control word, high byte"), 0x0E : ("FREQ1", "Frequency control word, middle byte"), 0x0F : ("FREQ0", "Frequency control word, low byte"), 0x10 : ("MDMCFG4", "Modem configuration"), 0x11 : ("MDMCFG3", "Modem configuration"), 0x12 : ("MDMCFG2", "Modem configuration"), 0x13 : ("MDMCFG1", "Modem configuration"), 0x14 : ("MDMCFG0", "Modem configuration"), 0x15 : ("DEVIATN", "Modem deviation setting"), 0x16 : ("MCSM2", "Main Radio Control State Machine configuration"), 0x17 : ("MCSM1", "Main Radio Control State Machine configuration"), 0x18 : ("MCSM0", "Main Radio Control State Machine configuration"), 0x19 : ("FOCCFG", "Frequency Offset Compensation configuration"), 0x1A : ("BSCFG", "Bit Synchronization configuration"), 0x1B : ("AGCTRL2", "AGC control"), 0x1C : ("AGCTRL1", "AGC control"), 0x1D : ("AGCTRL0", "AGC control"), 0x1E : ("WOREVT1", "High byte Event 0 timeout"), 0x1F : ("WOREVT0", "Low byte Event 0 timeout"), 0x20 : ("WORCTRL", "Wake On Radio control"), 0x21 : ("FREND1", "Front end RX configuration"), 0x22 : ("FREND0", "Front end TX configuration"), 0x23 : ("FSCAL3", "Frequency synthesizer calibration"), 0x24 : ("FSCAL2", "Frequency synthesizer calibration"), 0x25 : ("FSCAL1", "Frequency synthesizer calibration"), 0x26 : ("FSCAL0", "Frequency synthesizer calibration"), 0x27 : ("RCCTRL1", "RC oscillator configuration"), 0x28 : ("RCCTRL0", "RC oscillator configuration"), 0x29 : ("FSTEST", "Frequency synthesizer calibration control"), 0x2A : ("PTEST", "Production test"), 0x2B : ("AGCTEST", "AGC test"), 0x2C : ("TEST2", "Various test settings"), 0x2D : ("TEST1", "Various test settings"), 0x2E : ("TEST0", "Various test settings"), 0x30 : ("SRES", "Reset chip."), 0x31 : ("SFSTXON", "Enable and calibrate frequency synthesizer (if MCSM0.FS_AUTOCAL=1). If in RX (with CCA): Go to a wait state where only the synthesizer is running (for quick RX / TX turnaround)."), 0x32 : ("SXOFF", "Turn off crystal oscillator."), 0x33 : ("SCAL", "Calibrate frequency synthesizer and turn it off. SCAL can be strobed from IDLE mode without setting manual calibration mode (MCSM0.FS_AUTOCAL=0)"), 0x34 : ("SRX", "Enable RX. Perform calibration first if coming from IDLE and MCSM0.FS_AUTOCAL=1."), 0x35 : ("STX", "In IDLE state: Enable TX. Perform calibration first if MCSM0.FS_AUTOCAL=1. If in RX state and CCA is enabled: Only go to TX if channel is clear."), 0x36 : ("SIDLE", "Exit RX / TX, turn off frequency synthesizer and exit Wake-On-Radio mode if applicable."), 0x38 : ("SWOR", "Start automatic RX polling sequence (Wake-on-Radio) as described in Section 19.5 if WORCTRL.RC_PD=0."), 0x39 : ("SPWD", "Enter power down mode when CSn goes high."), 0x3A : ("SFRX", "Flush the RX FIFO buffer. Only issue SFRX in IDLE or RXFIFO_OVERFLOW states."), 0x3B : ("SFTX", "Flush the TX FIFO buffer. Only issue SFTX in IDLE or TXFIFO_UNDERFLOW states."), 0x3C : ("SWORRST", "Reset real time clock to Event1 value."), 0x3D : ("SNOP", "No operation. May be used to get access to the chip status byte."), 0x3F : ("FIFO", "FIFO access"), 0xF0 : ("PARTNUM", "CC2500 part number"), 0xF1 : ("VERSION", "Current version number"), 0xF2 : ("FREQEST", "Frequency offset estimate"), 0xF3 : ("LQI", "Demodulator estimate for Link Quality"), 0xF4 : ("RSSI", "Received signal strength indication"), 0xF5 : ("MARCSTATE", "Control state machine state"), 0xF6 : ("WORTIME1", "High byte of WOR timer"), 0xF7 : ("WORTIME0", "Low byte of WOR timer"), 0xF8 : ("PKTSTATUS", "Current GDOx status and packet status"), 0xF9 : ("VCO_VC_DAC", "Current setting from PLL calibration module"), 0xFA : ("TXBYTES", "Underflow and number of bytes in the TX FIFO"), 0xFB : ("RXBYTES", "Overflow and number of bytes in the RX FIFO"), 0xFC : ("RCCTRL1_STATUS", "Last RC oscillator calibration result"), 0xFD : ("RCCTRL0_STATUS", "Last RC oscillator calibration result"), } BURST = 0x40 READ = 0x80 def register_name(reg): def_name = ("%02X" % reg, "Unknown") if reg < 0xF0 or reg > 0xFE: reg = reg & ~(BURST | READ) return reg_map_cc2500.get(reg, def_name)[0] def dump_command(packet_id, command, status, data_out, data_in): if packet_id == -1: return mnemonic = [] if (command & BURST) and (command < 0xF0 or command > 0xFE): mnemonic.append("Burst") if (command & READ): mnemonic.append("Read") else: mnemonic.append("Write") mnemonic.append(register_name(command)) if (command & READ): mnemonic += map(lambda x: "%02X" % x, data_in) else: mnemonic += map(lambda x: "%02X" % x, data_out) print packet_id, " ".join(mnemonic) def process_file(f): packet_id = -1 # SPI exchange parameters command = -1 status = -1 data_out = [] data_in = [] count = 0 for line in f: line = line.strip() if len(line) == 0 or line[0] == '#': continue parts = line.split(',') if len(parts) != 4 or parts[1] == 'Packet ID' or parts[1] == '': continue if packet_id != int(parts[1]): dump_command(packet_id, command, status, data_out, data_in) command = int(parts[2], 16) status = int(parts[3], 16) packet_id = int(parts[1]) data_out = [] data_in = [] else: data_out.append(int(parts[2], 16)) data_in.append(int(parts[3], 16)) dump_command(packet_id, command, status, data_out, data_in) def main(argv): for fn in argv: f = file(fn) process_file(f) if __name__ == '__main__': import sys main(sys.argv[1:])