uint8_t spi_num;
struct pio cs_pin; /* SPI CS pin, used as chip select */
struct pio miso_pin; /* SPI MISO pin, used to monitor "device ready" from CC1101 chip */
+ /* Config */
+ uint8_t crc_calc; /* Wether CRC calc is set or not */
/* Signal indication */
uint8_t rx_sig_strength; /* Received signal strength indication */
uint8_t link_quality; /* link quality */
};
static struct cc1101_device cc1101 = {
+ .crc_calc = 1, /* CRC Calc is ON by default */
.rx_sig_strength = 0,
.link_quality = 0,
};
cc1101.rx_sig_strength = st_buff[0];
/* CRC error */
- if (!(cc1101.link_quality & CC1101_CRC_OK)) {
- cc1101_flush_rx_fifo();
- return -CC1101_ERR_CRC;
+ if (cc1101.crc_calc == 1) {
+ if (!(cc1101.link_quality & CC1101_CRC_OK)) {
+ cc1101_flush_rx_fifo();
+ return -CC1101_ERR_CRC;
+ }
}
/* Overflow ? */
if (rx_status & CC1101_RX_FIFO_OVERFLOW) {
cc1101_send_cmd(CC1101_CMD(state_idle));
}
-/* Write / send all the configuration register values to the CC1101 chip */
-void cc1101_config(void)
-{
- int i = 0;
- cc1101_send_cmd(CC1101_CMD(state_idle));
- /* Write RF initial settings to CC1101 */
- for (i = 0; i < sizeof(rf_init_settings); i += 2) {
- cc1101_write_reg(rf_init_settings[i], rf_init_settings[i + 1]);
- }
- /* Write PA Table value */
- cc1101_write_reg(CC1101_PATABLE, paTable[0]);
-}
-
/* Update CC1101 config
* Arguments are the settings table which is a table of address and value pairs,
* and the table length, which must be even.
* Move to idle state for all cases, easier. */
cc1101_send_cmd(CC1101_CMD(state_idle));
for (i = 0; i < len; i += 2) {
+ if (settings[i] == CC1101_REGS(pkt_ctrl[1])) {
+ cc1101.crc_calc = ((rf_init_settings[i + 1] & 0x04) ? 1 : 0);
+ }
cc1101_write_reg(settings[i], settings[i + 1]);
}
}
/* Change PA Table value */
-void cc1101_set_patable(uint8_t val)
+void cc1101_set_patable(uint8_t* values, uint8_t len)
{
- cc1101_write_reg(CC1101_PATABLE, val);
+ if (len == 1) {
+ cc1101_write_reg(CC1101_PATABLE, values[0]);
+ } else {
+ cc1101_write_burst_reg(CC1101_PATABLE, values, len);
+ }
}
+/* Write / send all the configuration register values to the CC1101 chip */
+void cc1101_config(void)
+{
+ /* Write RF initial settings to CC1101 */
+ cc1101_update_config(rf_init_settings, sizeof(rf_init_settings));
+ /* Write PA Table value */
+ cc1101_set_patable(paTable, 1);
+}
+
+