summaryrefslogtreecommitdiff
path: root/lib/cc1101.h
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2015-02-24 23:30:46 +0100
committerChristian Pointner <equinox@spreadspace.org>2015-02-24 23:30:46 +0100
commitee8c6c58ac3ee7f0aaa4dc36ceea5b6e07e86c00 (patch)
tree1bceb1511552fe342b4d5562bedffc3c34edc2fc /lib/cc1101.h
parentmoved usb-ajar to realraum github repo (diff)
added minimal version of cc1101 lib from mur.sat
Diffstat (limited to 'lib/cc1101.h')
-rw-r--r--lib/cc1101.h144
1 files changed, 144 insertions, 0 deletions
diff --git a/lib/cc1101.h b/lib/cc1101.h
new file mode 100644
index 0000000..48454b6
--- /dev/null
+++ b/lib/cc1101.h
@@ -0,0 +1,144 @@
+/*
+ * spreadspace avr utils
+ *
+ *
+ * Copyright (C) 2013-2015 Christian Pointner <equinox@spreadspace.org>
+ *
+ * This file is part of spreadspace avr utils.
+ *
+ * spreadspace avr utils is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * spreadspace avr utils is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with spreadspace avr utils. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef SPREADAVR_cc1101_h_INCLUDED
+#define SPREADAVR_cc1101_h_INCLUDED
+
+typedef enum { unknown, sleep, idle, xoff, mancal, fs_wakeup, calibrate, settling, rx, txrx_settling,
+ rxfifo_overflow, fstxon, tx, rxtx_settling, txfifo_underflow } cc1101_state_t;
+char* cc1101_state_to_string(cc1101_state_t);
+
+#define CC1101_FREQ_CORR(xtal) ((float)(xtal/65536.0))
+
+typedef struct {
+ void (*spi_cs_enable)(void);
+ void (*spi_cs_disable)(void);
+ uint8_t (*spi_read_miso)(void);
+ void (*spi_write_byte)(const uint8_t);
+ uint8_t (*spi_read_byte)(void);
+ uint8_t (*spi_transfer_byte)(const uint8_t);
+ float freq_corr;
+} cc1101_driver_conf_t;
+
+// high level interface
+
+void cc1101_init(cc1101_driver_conf_t conf);
+void cc1101_reg_init(void);
+void cc1101_soft_reset(void);
+
+void cc1101_powerdown(void);
+void cc1101_idle(void);
+void cc1101_osc_off(void);
+void cc1101_calibrate(void);
+void cc1101_fasttxon(void);
+void cc1101_rx(void);
+void cc1101_tx(void);
+cc1101_state_t cc1101_get_state(void);
+
+uint32_t cc1101_get_freq_hz(void);
+void cc1101_set_freq_hz(uint32_t hz);
+
+
+// normalized register access
+
+uint8_t cc1101_get_iocfg0(void);
+void cc1101_set_iocfg0(uint8_t iocfg);
+uint8_t cc1101_get_iocfg1(void);
+void cc1101_set_iocfg1(uint8_t iocfg);
+uint8_t cc1101_get_iocfg2(void);
+void cc1101_set_iocfg2(uint8_t iocfg);
+
+uint8_t cc1101_get_fifothr(void);
+void cc1101_set_fifothr(uint8_t fifothr);
+
+uint16_t cc1101_get_sync(void);
+void cc1101_set_sync(uint16_t sync);
+uint8_t cc1101_get_pktlen(void);
+void cc1101_set_pktlen(uint8_t len);
+uint16_t cc1101_get_pktctrl(void);
+void cc1101_set_pktctrl(uint16_t ctrl);
+uint8_t cc1101_get_addr(void);
+void cc1101_set_addr(uint8_t addr);
+
+uint8_t cc1101_get_channr(void);
+void cc1101_set_channr(uint8_t nr);
+uint8_t cc1101_get_iffreq(void);
+void cc1101_set_iffreq(uint8_t iffreq);
+uint8_t cc1101_get_freq_offset(void);
+void cc1101_set_freq_offset(uint8_t freqoff);
+uint32_t cc1101_get_freq(void);
+void cc1101_set_freq(uint32_t freq);
+uint64_t cc1101_get_modemcfg(void);
+void cc1101_set_modemcfg(uint64_t cfg);
+uint8_t cc1101_get_deviatn(void);
+void cc1101_set_deviatn(uint8_t dev);
+
+uint32_t cc1101_get_mcsm(void);
+void cc1101_set_mcsm(uint32_t cfg);
+
+uint8_t cc1101_get_foccfg(void);
+void cc1101_set_foccfg(uint8_t cfg);
+uint8_t cc1101_get_bscfg(void);
+void cc1101_set_bscfg(uint8_t cfg);
+uint32_t cc1101_get_agcctrl(void);
+void cc1101_set_agcctrl(uint32_t ctrl);
+uint16_t cc1101_get_worevt(void);
+void cc1101_set_worevt(uint16_t timeout);
+uint8_t cc1101_get_worctrl(void);
+void cc1101_set_worctrl(uint8_t ctrl);
+
+uint16_t cc1101_get_frend(void);
+void cc1101_set_frend(uint16_t cfg);
+uint32_t cc1101_get_fscal(void);
+void cc1101_set_fscal(uint32_t cal);
+uint16_t cc1101_get_rcctrl(void);
+void cc1101_set_rcctrl(uint16_t ctrl);
+
+uint8_t cc1101_get_fstest(void);
+void cc1101_set_fstest(uint8_t test);
+uint8_t cc1101_get_ptest(void);
+void cc1101_set_ptest(uint8_t test);
+uint8_t cc1101_get_agctest(void);
+void cc1101_set_agctest(uint8_t test);
+uint8_t cc1101_get_test0(void);
+void cc1101_set_test0(uint8_t test);
+uint8_t cc1101_get_test1(void);
+void cc1101_set_test1(uint8_t test);
+uint8_t cc1101_get_test2(void);
+void cc1101_set_test2(uint8_t test);
+
+uint8_t cc1101_get_partnum(void);
+uint8_t cc1101_get_chip_version(void);
+uint8_t cc1101_get_freq_offset_est(void);
+uint8_t cc1101_get_lqi(void);
+int8_t cc1101_get_rssi(void);
+uint8_t cc1101_get_marcstate(void);
+uint16_t cc1101_get_wortime(void);
+uint8_t cc1101_get_pkt_status(void);
+uint8_t cc1101_get_tx_bytes(void);
+uint8_t cc1101_get_rx_bytes(void);
+uint8_t cc1101_get_rcctrl0_status(void);
+uint8_t cc1101_get_rcctrl1_status(void);
+
+void cc1101_dump_register(void);
+
+#endif