13 #include <util/delay.h>
24 #define CC1101_DATA_LEN 60 // maximum length of received bytes
30 #define CC1101_IOCFG2 0x00 // (0x29) GDO2 Output Pin Configuration
31 #define CC1101_IOCFG1 0x01 // (0x2E) GDO1 Output Pin Configuration
32 #define CC1101_IOCFG0 0x02 // (0x3F) GDO0 Output Pin Configuration
33 #define CC1101_FIFOTHR 0x03 // (0x07) RX FIFO and TX FIFO Thresholds
34 #define CC1101_SYNC1 0x04 // (0xD3) Sync Word, High Byte
35 #define CC1101_SYNC0 0x05 // (0x91) Sync Word, Low Byte
36 #define CC1101_PKTLEN 0x06 // (0xFF) Packet Length
37 #define CC1101_PKTCTRL1 0x07 // (0x04) Packet Automation Control
38 #define CC1101_PKTCTRL0 0x08 // (0x45) Packet Automation Control
39 #define CC1101_ADDR 0x09 // (0x00) Device Address
40 #define CC1101_CHANNR 0x0A // (0x00) Channel Number
41 #define CC1101_FSCTRL1 0x0B // (0x0F) Frequency Synthesizer Control
42 #define CC1101_FSCTRL0 0x0C // (0x00) Frequency Synthesizer Control
43 #define CC1101_FREQ2 0x0D // (0x1E) Frequency Control Word, High Byte
44 #define CC1101_FREQ1 0x0E // (0xC4) Frequency Control Word, Middle Byte
45 #define CC1101_FREQ0 0x0F // (0xEC) Frequency Control Word, Low Byte
46 #define CC1101_MDMCFG4 0x10 // (0x8C) Modem Configuration
47 #define CC1101_MDMCFG3 0x11 // (0x22) Modem Configuration
48 #define CC1101_MDMCFG2 0x12 // (0x02) Modem Configuration
49 #define CC1101_MDMCFG1 0x13 // (0x22) Modem Configuration
50 #define CC1101_MDMCFG0 0x14 // (0xF8) Modem Configuration
51 #define CC1101_DEVIATN 0x15 // (0x47) Modem Deviation Setting
52 #define CC1101_MCSM2 0x16 // (0x07) Main Radio Control State Machine Configuration
53 #define CC1101_MCSM1 0x17 // (0x30) Main Radio Control State Machine Configuration
54 #define CC1101_MCSM0 0x18 // (0x04) Main Radio Control State Machine Configuration
55 #define CC1101_FOCCFG 0x19 // (0x36) Frequency Offset Compensation Configuration
56 #define CC1101_BSCFG 0x1A // (0x6C) Bit Synchronization Configuration
57 #define CC1101_AGCCTRL2 0x1B // (0x03) AGC Control
58 #define CC1101_AGCCTRL1 0x1C // (0x40) AGC Control
59 #define CC1101_AGCCTRL0 0x1D // (0x91) AGC Control
60 #define CC1101_WOREVT1 0x1E // (0x87) High Byte Event0 Timeout
61 #define CC1101_WOREVT0 0x1F // (0x6B) Low Byte Event0 Timeout
62 #define CC1101_WORCTRL 0x20 // (0xF8) Wake On Radio Control
63 #define CC1101_FREND1 0x21 // (0x56) Front End RX Configuration
64 #define CC1101_FREND0 0x22 // (0x10) Front End RX Configuration
65 #define CC1101_FSCAL3 0x23 // (0xA9) Frequency Synthesizer Calibration
66 #define CC1101_FSCAL2 0x24 // (0x0A) Frequency Synthesizer Calibration
67 #define CC1101_FSCAL1 0x25 // (0x20) Frequency Synthesizer Calibration
68 #define CC1101_FSCAL0 0x26 // (0x0D) Frequency Synthesizer Calibration
69 #define CC1101_RCCTRL1 0x27 // (0x41) RC Oscillator Configuration
70 #define CC1101_RCCTRL2 0x28 // (0x00) RC Oscillator Configuration
71 #define CC1101_FSTEST 0x29 // (0x59) Frequency Synthesizer Calibration Control
72 #define CC1101_PTEST 0x2A // (0x7F) Production Test
73 #define CC1101_AGCTEST 0x2B // (0x3F) AGC Test
74 #define CC1101_TEST2 0x2C // (0x88) Various Test Settings
75 #define CC1101_TEST1 0x2D // (0x31) Various Test Settings
76 #define CC1101_TEST0 0x2E // (0x0B) Various Test Settings
78 #define CC1101_PARTNUM 0x30 // (0x00) Readonly: Chip ID
79 #define CC1101_VERSION 0x31 // (0x04) Readonly: Chip ID
80 #define CC1101_FREQEST 0x32 // (0x00) Readonly: Frequency Offset Estimate from Demodulator
81 #define CC1101_LQI 0x33 // (0x00) Readonly: Demodulator Estimate for Link Quality
82 #define CC1101_RSSI 0x34 // (0x00) Readonly: Received Signal Strength Indication
83 #define CC1101_MARCSTATE 0x35 // (0x00) Readonly: Main Radio Control State Machine State
84 #define CC1101_WORTIME1 0x36 // (0x00) Readonly: High Byte of WOR Time
85 #define CC1101_WORTIME0 0x37 // (0x00) Readonly: Low Byte of WOR Time
86 #define CC1101_PKTSTATUS 0x38 // (0x00) Readonly: Current GDOx Status and Packet Status
87 #define CC1101_VCO_VC_DAC 0x39 // (0x00) Readonly: Current Setting from PLL Calibration Module
88 #define CC1101_TXBYTES 0x3A // (0x00) Readonly: Underflow and Number of Bytes
89 #define CC1101_RXBYTES 0x3B // (0x00) Readonly: Overflow and Number of Bytes
90 #define CC1101_RCCTRL1_STATUS 0x3C // (0x00) Readonly: Last RC Oscillator Calibration Result
91 #define CC1101_RCCTRL0_STATUS 0x3D // (0x00) Readonly: Last RC Oscillator Calibration Result
93 #define CC1101_PATABLE 0x3E // PATABLE address
94 #define CC1101_TXFIFO 0x3F // TX FIFO address
95 #define CC1101_RXFIFO 0x3F // RX FIFO address
97 #define CC1101_PA_TABLE0 0x40 // (0x00) PA table, entry 0
98 #define CC1101_PA_TABLE1 0x41 // (0x00) PA table, entry 1
99 #define CC1101_PA_TABLE2 0x42 // (0x00) PA table, entry 2
100 #define CC1101_PA_TABLE3 0x43 // (0x00) PA table, entry 3
101 #define CC1101_PA_TABLE4 0x44 // (0x00) PA table, entry 4
102 #define CC1101_PA_TABLE5 0x45 // (0x00) PA table, entry 5
103 #define CC1101_PA_TABLE6 0x46 // (0x00) PA table, entry 6
104 #define CC1101_PA_TABLE7 0x47 // (0x00) PA table, entry 7
107 #define READ_SINGLE 0x80 // type of transfers
108 #define READ_BURST 0xC0
109 #define WRITE_BURST 0x40
111 #define CC1101_CONFIG 0x80 // type of register
112 #define CC1101_STATUS 0xC0
114 #define CC1101_SRES 0x30 // reset CC1101 chip
115 #define CC1101_SFSTXON 0x31 // 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).
116 #define CC1101_SXOFF 0x32 // turn off crystal oscillator
117 #define CC1101_SCAL 0x33 // calibrate frequency synthesizer and turn it off. SCAL can be strobed from IDLE mode without setting manual calibration mode (MCSM0.FS_AUTOCAL=0)
118 #define CC1101_SRX 0x34 // enable RX. perform calibration first if coming from IDLE and MCSM0.FS_AUTOCAL=1
119 #define CC1101_STX 0x35 // 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
120 #define CC1101_SIDLE 0x36 // exit RX / TX, turn off frequency synthesizer and exit Wake-On-Radio mode if applicable
121 #define CC1101_SWOR 0x38 // start automatic RX polling sequence (Wake-on-Radio) as described in Section 19.5 if WORCTRL.RC_PD=0
122 #define CC1101_SPWD 0x39 // enter power down mode when CSn goes high
123 #define CC1101_SFRX 0x3A // flush the RX FIFO buffer. only issue SFRX in IDLE or RXFIFO_OVERFLOW states
124 #define CC1101_SFTX 0x3B // flush the TX FIFO buffer. only issue SFTX in IDLE or TXFIFO_UNDERFLOW states
125 #define CC1101_SWORRST 0x3C // reset real time clock to Event1 value
126 #define CC1101_SNOP 0x3D // no operation. may be used to get access to the chip status byte
128 #define MARCSTATE_SLEEP 0x00
129 #define MARCSTATE_IDLE 0x01
130 #define MARCSTATE_XOFF 0x02
131 #define MARCSTATE_VCOON_MC 0x03
132 #define MARCSTATE_REGON_MC 0x04
133 #define MARCSTATE_MANCAL 0x05
134 #define MARCSTATE_VCOON 0x06
135 #define MARCSTATE_REGON 0x07
136 #define MARCSTATE_STARTCAL 0x08
137 #define MARCSTATE_BWBOOST 0x09
138 #define MARCSTATE_FS_LOCK 0x0A
139 #define MARCSTATE_IFADCON 0x0B
140 #define MARCSTATE_ENDCAL 0x0C
141 #define MARCSTATE_RX 0x0D
142 #define MARCSTATE_RX_END 0x0E
143 #define MARCSTATE_RX_RST 0x0F
144 #define MARCSTATE_TXRX_SWITCH 0x10
145 #define MARCSTATE_RXFIFO_OFLOW 0x11
146 #define MARCSTATE_FSTXON 0x12
147 #define MARCSTATE_TX 0x13
148 #define MARCSTATE_TX_END 0x14
149 #define MARCSTATE_RXTX_SWITCH 0x15
150 #define MARCSTATE_TXFIFO_UFLOW 0x16
152 #define PA_LowPower 0x03 // PATABLE values
153 #define PA_Normal 0x50 // PATABLE values
154 #define PA_MaxPower 0xC0
159 uint8_t detectBurst(
void);
167 uint8_t sndData(uint8_t *buf, uint8_t burst);
168 uint8_t rcvData(uint8_t *buf);
170 void strobe(uint8_t cmd);
171 void readBurst(uint8_t * buf, uint8_t regAddr, uint8_t len);
172 void writeBurst(uint8_t regAddr, uint8_t* buf, uint8_t len);
173 uint8_t readReg(uint8_t regAddr, uint8_t regType);
174 void writeReg(uint8_t regAddr, uint8_t val);
Main class for implementation of the AskSin protocol stack. Every device needs exactly one instance o...
Definition: AS.h:39