Arduino Uno
Wireless doorbell (Quhwa as identified by RTL_433)
CC1120 board: https://www.mikroe.com/ccrf-3-click

Arduino software serial, CC1120 transparent serial mode (SERIAL_RX on GPIO0)

sermon.jpg
Data output when doorbell button is pressed. To get correct looking data requires experimenting with different software serial bps settings also RSSI level threshold would be a good thing because there is continuos stream of data from serial_rx (noise...)

#include <SPI.h>
#include <SoftwareSerial.h>
#include "cc1120.h"

/*
 CHANBW
 8 kHz      0x19
 10 kHz     0x14
 12.5 kHz   0x10
 15.38 kHz  0x0D
 18.18 kHz  0x0B
 20 kHz     0x0A
 25 kHz     0x08
 28.5 kHz   0x07
 33.3 kHz   0x06
 40 kHz     0x05
 50 kHz     0x04
 66.66 kHz  0x03
 100 kHz    0x02
 
 433.92 MHz
 FREQ2 0x6C
 FREQ1 0x7A
 FREQ0 0xE1
*/

#define PRINT_INFO  1

SoftwareSerial softSerial(GDO0_PIN, TX_PIN);

struct cc_status {
 uint8_t res : 4;
 uint8_t state : 3;
 uint8_t chip_ready : 1;
};
union cc_st {
  struct cc_status ccst;
  uint8_t v;
};

union cc_st ccstatus;

void setup() {
  Serial.begin(1200);
  softSerial.begin(1200);
  pinMode(RESET_PIN, OUTPUT);
  pinMode(SS_PIN, OUTPUT);
  pinMode(GDO0_PIN, INPUT_PULLUP);
  pinMode(GDO2_PIN, INPUT);
  digitalWrite(SS_PIN, HIGH);
  digitalWrite(RESET_PIN, HIGH);

  SPI.begin();

  strobeSPI(SNOP);
#ifdef PRINT_INFO  
  printStatus();
#endif

  // Preamble off
  uint8_t v = readSPI(PREAMBLE_CFG0);
  bitClear(v, 5);
  writeSPI(PREAMBLE_CFG0, v);
  // Sync off
  v = readSPI(SYNC_CFG0);
  bitClear(v, 4);
  bitClear(v, 3);
  bitClear(v, 2);
  writeSPI(SYNC_CFG0, v);

  writeSPI(IOCFG0, SERIAL_RX);
  writeSPI(IOCFG2, SERIAL_CLK);
  writeSPI(SYNC_CFG1, SMARTRF_SETTING_SYNC_CFG1);
  writeSPI(MODCFG_DEV_E, SMARTRF_SETTING_MODCFG_DEV_E);
  writeSPI(DCFILT_CFG, SMARTRF_SETTING_DCFILT_CFG);
  writeSPI(PREAMBLE_CFG1, SMARTRF_SETTING_PREAMBLE_CFG1);
  writeSPI(IQIC, SMARTRF_SETTING_IQIC);
  writeSPI(CHAN_BW, SMARTRF_SETTING_CHAN_BW);
  writeSPI(MDMCFG0, SMARTRF_SETTING_MDMCFG0);
  writeSPI(MDMCFG1, SMARTRF_SETTING_MDMCFG1);
  writeSPI(AGC_REF, SMARTRF_SETTING_AGC_REF);
  writeSPI(AGC_CS_THR, SMARTRF_SETTING_AGC_CS_THR);
  writeSPI(AGC_CFG1, SMARTRF_SETTING_AGC_CFG1);
  writeSPI(FIFO_CFG, SMARTRF_SETTING_FIFO_CFG);
  writeSPI(FS_CFG, SMARTRF_SETTING_FS_CFG);
  writeSPI(PKT_CFG0, SMARTRF_SETTING_PKT_CFG0);
  writeSPI(PKT_CFG1, SMARTRF_SETTING_PKT_CFG1);
  writeSPI(PKT_CFG2, SMARTRF_SETTING_PKT_CFG2);
  writeSPI(PA_CFG2, SMARTRF_SETTING_PA_CFG2);

  writeExtAddrSPI(IF_MIX_CFG, SMARTRF_SETTING_IF_MIX_CFG);
  writeExtAddrSPI(FREQOFF_CFG, SMARTRF_SETTING_FREQOFF_CFG);
  writeExtAddrSPI(FREQ2, SMARTRF_SETTING_FREQ2);
  writeExtAddrSPI(FREQ1, SMARTRF_SETTING_FREQ1);
  writeExtAddrSPI(FREQ0, SMARTRF_SETTING_FREQ0);
  writeExtAddrSPI(FS_DIG1, SMARTRF_SETTING_FS_DIG1);
  writeExtAddrSPI(FS_DIG0, SMARTRF_SETTING_FS_DIG0);
  writeExtAddrSPI(FS_CAL1, SMARTRF_SETTING_FS_CAL1);
  writeExtAddrSPI(FS_CAL0, SMARTRF_SETTING_FS_CAL0);
  writeExtAddrSPI(FS_DIVTWO, SMARTRF_SETTING_FS_DIVTWO);
  writeExtAddrSPI(FS_DSM0, SMARTRF_SETTING_FS_DSM0);
  writeExtAddrSPI(FS_DVC0, SMARTRF_SETTING_FS_DVC0);
  writeExtAddrSPI(FS_PFD, SMARTRF_SETTING_FS_PFD);
  writeExtAddrSPI(FS_PRE, SMARTRF_SETTING_FS_PRE);
  writeExtAddrSPI(FS_REG_DIV_CML, SMARTRF_SETTING_FS_REG_DIV_CML);
  writeExtAddrSPI(FS_SPARE, SMARTRF_SETTING_FS_SPARE);
  writeExtAddrSPI(FS_VCO0, SMARTRF_SETTING_FS_VCO0);
  writeExtAddrSPI(XOSC5, SMARTRF_SETTING_XOSC5);
  writeExtAddrSPI(XOSC1, SMARTRF_SETTING_XOSC1);
  writeExtAddrSPI(SERIAL_STATUS, SMARTRF_SETTING_SERIAL_STATUS);

#ifdef PRINT_INFO
  v = readExtAddrSPI(PARTVERSION);
  Serial.print(F("PARTVERSION "));
  Serial.println(v, HEX);
  v = readExtAddrSPI(PARTNUMBER);
  Serial.print(F("PARTNUMBER "));
  Serial.println(v, HEX);
#endif

  strobeSPI(SRX);
  delay(50);
  v = readExtAddrSPI(MARCSTATE);
  Serial.print(F("MARCSTATE "));
  Serial.println(v, BIN);
}

void loop() {
  if (softSerial.available()) {
    char c = softSerial.read();
    uint8_t v = (uint8_t) c;
    Serial.println(v, BIN);
  }
}

void printStatus() {
  Serial.println();
  Serial.print(F("Chip ready: "));
  Serial.println(ccstatus.ccst.chip_ready, HEX);
  Serial.print(F("State: "));
  Serial.println(ccstatus.ccst.state, HEX);
  Serial.println();  
}

uint8_t readSPI(uint8_t addr) {
  digitalWrite(SS_PIN, LOW);
  ccstatus.v = SPI.transfer(R_BIT | addr);
  uint8_t v = SPI.transfer(0x00);
  digitalWrite(SS_PIN, HIGH);
  return v;
}

void writeSPI(uint8_t addr, uint8_t value) {
  digitalWrite(SS_PIN, LOW);
  ccstatus.v = SPI.transfer(addr);
  ccstatus.v = SPI.transfer(value);
  digitalWrite(SS_PIN, HIGH);
}

void strobeSPI(uint8_t cmd)
{
  digitalWrite(SS_PIN, LOW);
  ccstatus.v = SPI.transfer(R_BIT | cmd);
  digitalWrite(SS_PIN, HIGH);
}

uint8_t readExtAddrSPI(uint8_t addr) {
  uint8_t v;
  digitalWrite(SS_PIN, LOW);
  ccstatus.v = SPI.transfer(R_BIT | EXT_ADDR);
  SPI.transfer(addr);
  v = SPI.transfer(0xff);
  digitalWrite(SS_PIN, HIGH);
  return v;
}

void writeExtAddrSPI(uint8_t addr, uint8_t value) {
  digitalWrite(SS_PIN, LOW);
  ccstatus.v = SPI.transfer(EXT_ADDR);
  ccstatus.v = SPI.transfer(addr);
  ccstatus.v = SPI.transfer(value);
  digitalWrite(SS_PIN, HIGH);
}

 

/* Address Config = No address check */
/* Bit Rate = 1.2 */
/* Carrier Frequency = 433.954 */
/* Deviation = 3.997803 */
/* Device Address = 0 */
/* Manchester Enable = false */
/* Modulation Format = ASK/OOK */
/* PA Ramping = false */
/* Packet Bit Length = 0 */
/* Packet Length = 3 */
/* Packet Length Mode = Variable */
/* Performance Mode = High Performance */
/* RX Filter BW = 100.000000 */
/* Symbol rate = 1.2 */
/* TX Power = 12.5 */
/* Whitening = false */
/***************************************************************
 *  SmartRF Studio(tm) Export
 *
 *  Radio register settings specifed with C-code
 *  compatible #define statements.
 *
 *  RF device: CC1120
 *
 ***************************************************************/

#ifndef SMARTRF_CC1120_H
#define SMARTRF_CC1120_H

#define SMARTRF_RADIO_CC1120
//#define SMARTRF_SETTING_IOCFG3           0xB0
//#define SMARTRF_SETTING_IOCFG2           0x08
//#define SMARTRF_SETTING_IOCFG1           0xB0
//#define SMARTRF_SETTING_IOCFG0           0x09
//#define SMARTRF_SETTING_SYNC3            0xAA
//#define SMARTRF_SETTING_SYNC2            0xAA
//#define SMARTRF_SETTING_SYNC1            0xAA
//#define SMARTRF_SETTING_SYNC0            0xAA
#define SMARTRF_SETTING_SYNC_CFG1        0x1F
#define SMARTRF_SETTING_MODCFG_DEV_E     0x1B
#define SMARTRF_SETTING_DCFILT_CFG       0x1C
#define SMARTRF_SETTING_PREAMBLE_CFG1    0x00
#define SMARTRF_SETTING_IQIC             0xC6
#define SMARTRF_SETTING_CHAN_BW          0x02
#define SMARTRF_SETTING_MDMCFG1          0x06
#define SMARTRF_SETTING_MDMCFG0          0x4A
#define SMARTRF_SETTING_AGC_REF          0x20
#define SMARTRF_SETTING_AGC_CS_THR       0x19
#define SMARTRF_SETTING_AGC_CFG1         0x0A
#define SMARTRF_SETTING_FIFO_CFG         0x00
#define SMARTRF_SETTING_FS_CFG           0x14
#define SMARTRF_SETTING_PKT_CFG2         0x07
#define SMARTRF_SETTING_PKT_CFG1         0x00
#define SMARTRF_SETTING_PKT_CFG0         0x20
#define SMARTRF_SETTING_PA_CFG2          0x3C
#define SMARTRF_SETTING_IF_MIX_CFG       0x00
#define SMARTRF_SETTING_FREQOFF_CFG      0x23 // 0x22
#define SMARTRF_SETTING_FREQ2            0x6C
#define SMARTRF_SETTING_FREQ1            0x7A  
#define SMARTRF_SETTING_FREQ0            0xE1
#define SMARTRF_SETTING_FS_DIG1          0x00
#define SMARTRF_SETTING_FS_DIG0          0x5F
#define SMARTRF_SETTING_FS_CAL1          0x40
#define SMARTRF_SETTING_FS_CAL0          0x0E
#define SMARTRF_SETTING_FS_DIVTWO        0x03
#define SMARTRF_SETTING_FS_DSM0          0x33
#define SMARTRF_SETTING_FS_DVC0          0x17
#define SMARTRF_SETTING_FS_PFD           0x50
#define SMARTRF_SETTING_FS_PRE           0x6E
#define SMARTRF_SETTING_FS_REG_DIV_CML   0x14
#define SMARTRF_SETTING_FS_SPARE         0xAC
#define SMARTRF_SETTING_FS_VCO0          0xB4
#define SMARTRF_SETTING_XOSC5            0x0E
#define SMARTRF_SETTING_XOSC1            0x03
#define SMARTRF_SETTING_SERIAL_STATUS    0x08

// Pins
#define GDO0_PIN        2
#define TX_PIN          3
#define GDO2_PIN        4
#define RESET_PIN       7
#define SS_PIN          10

#define SERIAL_CLK      0x08
#define SERIAL_RX       0x09

#define R_BIT           0x80

// CC1120 registers
#define IOCFG3          0x00
#define IOCFG2          0x01
#define IOCFG1          0x02
#define IOCFG0          0x03
#define SYNC3           0x04
#define SYNC2           0x05
#define SYNC1           0x06
#define SYNC0           0x07
#define SYNC_CFG1       0x08
#define SYNC_CFG0       0x09
#define DEVIATION_M     0x0A
#define MODCFG_DEV_E    0x0B
#define DCFILT_CFG      0x0C
#define PREAMBLE_CFG1   0x0D
#define PREAMBLE_CFG0   0x0E
#define FREQ_IF_CFG     0x0F
#define IQIC            0x10
#define CHAN_BW         0x11
#define MDMCFG1         0x12
#define MDMCFG0         0x13
#define SYMBOL_RATE2    0x14
#define SYMBOL_RATE1    0x15
#define SYMBOL_RATE0    0x16
#define AGC_REF         0x17
#define AGC_CS_THR      0x18
#define AGC_GAIN_ADJUST 0x19
#define AGC_CFG3        0x1A
#define AGC_CFG2        0x1B
#define AGC_CFG1        0x1C
#define AGC_CFG0        0x1D
#define FIFO_CFG        0x1E
#define DEV_ADDR        0x1F
#define SETTLING_CFG    0x20
#define FS_CFG          0x21
#define WOR_CFG1        0x22
#define WOR_CFG0        0x23
#define WOR_EVENT0_MSB  0x24
#define WOR_EVENT0_LSB  0x25
#define PKT_CFG2        0x26
#define PKT_CFG1        0x27
#define PKT_CFG0        0x28
#define RFEND_CFG1      0x29
#define RFEND_CFG2      0x2A
#define PA_CFG2         0x2B
#define PA_CFG1         0x2C
#define PA_CFG0         0x2D
#define PKT_LEN         0x2E
#define EXT_ADDR        0x2F
#define FIFO            0x3F

// Extended register space
#define IF_MIX_CFG        0x00
#define FREQOFF_CFG       0x01
#define FREQ2             0x0C
#define FREQ1             0x0D
#define FREQ0             0x0E
#define FS_DIG1           0x12
#define FS_DIG0           0x13
#define FS_CAL1           0x16
#define FS_CAL0           0x17
#define FS_DIVTWO         0x19
#define FS_DSM0           0x1B
#define FS_DVC0           0x1D
#define FS_PFD            0x1F
#define FS_PRE            0x20
#define FS_REG_DIV_CML    0x21
#define FS_SPARE          0x22
#define FS_VCO0           0x27
#define XOSC5             0x32
#define XOSC1             0x36
#define RSSI1             0x71
#define RSSI0             0x72
#define MARCSTATE         0x73
#define PARTNUMBER        0x8F
#define PARTVERSION       0x90
#define SERIAL_STATUS     0x91
#define MODEM_STATUS1     0x92
#define MODEM_STATUS0     0x93
#define MARC_STATUS1      0x94
#define MARC_STATUS0      0x95
#define NUM_RXBYTES       0xD7
#define FIFO_NUM_RXBYTES  0xD9

// CC1120 command strobes
#define SRES            0x30
#define SFSTXON         0x31
#define SXOFF           0x32
#define SCAL            0x33
#define SRX             0x34
#define STX             0x35
#define SIDLE           0x36
#define SAFC            0x37
#define SWOR            0x38
#define SPWD            0x39
#define SFRX            0x3A
#define SFTX            0x3B
#define SWORRST         0x3C
#define SNOP            0x3D

#endif // CC1120_H