For robots and stuff
Wireless/CC1101/CC1101.h@0:c5afea7b9057, 2014-12-28 (annotated)
- Committer:
- jjones646
- Date:
- Sun Dec 28 06:27:18 2014 +0000
- Revision:
- 0:c5afea7b9057
initial commit;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jjones646 | 0:c5afea7b9057 | 1 | /** |
jjones646 | 0:c5afea7b9057 | 2 | * @author Athanassios Mavrogeorgiadis |
jjones646 | 0:c5afea7b9057 | 3 | * @author TI CC1101 library developed by Athanassios Mavrogeorgiadis (tmav Electronics) as template based on TI C8051 SOURCE CODE swrc021f |
jjones646 | 0:c5afea7b9057 | 4 | * @section LICENSE |
jjones646 | 0:c5afea7b9057 | 5 | * |
jjones646 | 0:c5afea7b9057 | 6 | * Copyright (c) 2010 ARM Limited |
jjones646 | 0:c5afea7b9057 | 7 | * |
jjones646 | 0:c5afea7b9057 | 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
jjones646 | 0:c5afea7b9057 | 9 | * of this software and associated documentation files (the "Software"), to deal |
jjones646 | 0:c5afea7b9057 | 10 | * in the Software without restriction, including without limitation the rights |
jjones646 | 0:c5afea7b9057 | 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
jjones646 | 0:c5afea7b9057 | 12 | * copies of the Software, and to permit persons to whom the Software is |
jjones646 | 0:c5afea7b9057 | 13 | * furnished to do so, subject to the following conditions: |
jjones646 | 0:c5afea7b9057 | 14 | * |
jjones646 | 0:c5afea7b9057 | 15 | * The above copyright notice and this permission notice shall be included in |
jjones646 | 0:c5afea7b9057 | 16 | * all copies or substantial portions of the Software. |
jjones646 | 0:c5afea7b9057 | 17 | * |
jjones646 | 0:c5afea7b9057 | 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
jjones646 | 0:c5afea7b9057 | 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
jjones646 | 0:c5afea7b9057 | 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
jjones646 | 0:c5afea7b9057 | 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
jjones646 | 0:c5afea7b9057 | 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
jjones646 | 0:c5afea7b9057 | 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
jjones646 | 0:c5afea7b9057 | 24 | * THE SOFTWARE. |
jjones646 | 0:c5afea7b9057 | 25 | * |
jjones646 | 0:c5afea7b9057 | 26 | * @section DESCRIPTION |
jjones646 | 0:c5afea7b9057 | 27 | * |
jjones646 | 0:c5afea7b9057 | 28 | * CC1101 Low-Power Sub-1 GHz RF Transceiver CC1101. |
jjones646 | 0:c5afea7b9057 | 29 | * |
jjones646 | 0:c5afea7b9057 | 30 | * Datasheet: |
jjones646 | 0:c5afea7b9057 | 31 | * |
jjones646 | 0:c5afea7b9057 | 32 | * http://www.ti.com/lit/ds/symlink/cc1101.pdf |
jjones646 | 0:c5afea7b9057 | 33 | */ |
jjones646 | 0:c5afea7b9057 | 34 | |
jjones646 | 0:c5afea7b9057 | 35 | |
jjones646 | 0:c5afea7b9057 | 36 | #ifndef CC1101_H |
jjones646 | 0:c5afea7b9057 | 37 | #define CC1101_H |
jjones646 | 0:c5afea7b9057 | 38 | |
jjones646 | 0:c5afea7b9057 | 39 | |
jjones646 | 0:c5afea7b9057 | 40 | /** |
jjones646 | 0:c5afea7b9057 | 41 | * Includes |
jjones646 | 0:c5afea7b9057 | 42 | */ |
jjones646 | 0:c5afea7b9057 | 43 | #include "mbed.h" |
jjones646 | 0:c5afea7b9057 | 44 | #include "rtos.h" |
jjones646 | 0:c5afea7b9057 | 45 | #include "Radio.h" |
jjones646 | 0:c5afea7b9057 | 46 | #include "CC1101-Defines.h" |
jjones646 | 0:c5afea7b9057 | 47 | |
jjones646 | 0:c5afea7b9057 | 48 | |
jjones646 | 0:c5afea7b9057 | 49 | /** |
jjones646 | 0:c5afea7b9057 | 50 | * CC1101 Low-Power Sub-1 GHz RF Transceiver. |
jjones646 | 0:c5afea7b9057 | 51 | */ |
jjones646 | 0:c5afea7b9057 | 52 | class CC1101 : public Radio |
jjones646 | 0:c5afea7b9057 | 53 | { |
jjones646 | 0:c5afea7b9057 | 54 | public: |
jjones646 | 0:c5afea7b9057 | 55 | |
jjones646 | 0:c5afea7b9057 | 56 | /** |
jjones646 | 0:c5afea7b9057 | 57 | * Constructor. |
jjones646 | 0:c5afea7b9057 | 58 | * |
jjones646 | 0:c5afea7b9057 | 59 | * @param mosi mbed pin to use for MOSI line of SPI interface. |
jjones646 | 0:c5afea7b9057 | 60 | * @param miso mbed pin to use for MISO line of SPI interface. |
jjones646 | 0:c5afea7b9057 | 61 | * @param clk mbed pin to use for SCK line of SPI interface. |
jjones646 | 0:c5afea7b9057 | 62 | * @param csn mbed pin to use for the negated chip select line of SPI interface. |
jjones646 | 0:c5afea7b9057 | 63 | * @param interpt pin connected to an interrupt-capable input used for signaling that new radio data has been received |
jjones646 | 0:c5afea7b9057 | 64 | * @param tx_led the indicator led for when data is transmitted |
jjones646 | 0:c5afea7b9057 | 65 | * @param rx_led the indicator led for when data is received |
jjones646 | 0:c5afea7b9057 | 66 | * @param xosc oscillator frequency that the CC1101 operates from. Either 26MHz or 27MHz |
jjones646 | 0:c5afea7b9057 | 67 | */ |
jjones646 | 0:c5afea7b9057 | 68 | CC1101(PinName mosi, PinName miso, PinName clk, PinName csn, PinName tx_led, PinName rx_led, PinName interpt, unsigned int xosc = 27000000); |
jjones646 | 0:c5afea7b9057 | 69 | |
jjones646 | 0:c5afea7b9057 | 70 | |
jjones646 | 0:c5afea7b9057 | 71 | /** |
jjones646 | 0:c5afea7b9057 | 72 | * Default Constructor |
jjones646 | 0:c5afea7b9057 | 73 | */ |
jjones646 | 0:c5afea7b9057 | 74 | CC1101(); |
jjones646 | 0:c5afea7b9057 | 75 | |
jjones646 | 0:c5afea7b9057 | 76 | |
jjones646 | 0:c5afea7b9057 | 77 | /* |
jjones646 | 0:c5afea7b9057 | 78 | * Deconstructor |
jjones646 | 0:c5afea7b9057 | 79 | */ |
jjones646 | 0:c5afea7b9057 | 80 | virtual ~CC1101(); |
jjones646 | 0:c5afea7b9057 | 81 | |
jjones646 | 0:c5afea7b9057 | 82 | |
jjones646 | 0:c5afea7b9057 | 83 | uint16_t scan(void); |
jjones646 | 0:c5afea7b9057 | 84 | |
jjones646 | 0:c5afea7b9057 | 85 | void init(void); |
jjones646 | 0:c5afea7b9057 | 86 | |
jjones646 | 0:c5afea7b9057 | 87 | |
jjones646 | 0:c5afea7b9057 | 88 | /** |
jjones646 | 0:c5afea7b9057 | 89 | * Get the chip's version number. |
jjones646 | 0:c5afea7b9057 | 90 | */ |
jjones646 | 0:c5afea7b9057 | 91 | uint8_t version(void); |
jjones646 | 0:c5afea7b9057 | 92 | |
jjones646 | 0:c5afea7b9057 | 93 | void tiny_delay(void); |
jjones646 | 0:c5afea7b9057 | 94 | |
jjones646 | 0:c5afea7b9057 | 95 | |
jjones646 | 0:c5afea7b9057 | 96 | /** |
jjones646 | 0:c5afea7b9057 | 97 | * Implementation of setting device address |
jjones646 | 0:c5afea7b9057 | 98 | */ |
jjones646 | 0:c5afea7b9057 | 99 | virtual void address(uint8_t address); |
jjones646 | 0:c5afea7b9057 | 100 | |
jjones646 | 0:c5afea7b9057 | 101 | |
jjones646 | 0:c5afea7b9057 | 102 | /** |
jjones646 | 0:c5afea7b9057 | 103 | * Get the current state of the CC1101 state machine. |
jjones646 | 0:c5afea7b9057 | 104 | */ |
jjones646 | 0:c5afea7b9057 | 105 | uint8_t mode(void); |
jjones646 | 0:c5afea7b9057 | 106 | |
jjones646 | 0:c5afea7b9057 | 107 | |
jjones646 | 0:c5afea7b9057 | 108 | /** |
jjones646 | 0:c5afea7b9057 | 109 | * Read the contents of any CC1101's status register. |
jjones646 | 0:c5afea7b9057 | 110 | */ |
jjones646 | 0:c5afea7b9057 | 111 | uint8_t status(uint8_t); |
jjones646 | 0:c5afea7b9057 | 112 | |
jjones646 | 0:c5afea7b9057 | 113 | |
jjones646 | 0:c5afea7b9057 | 114 | /** |
jjones646 | 0:c5afea7b9057 | 115 | * Get the current setting that the CC1101 is operating in. |
jjones646 | 0:c5afea7b9057 | 116 | */ |
jjones646 | 0:c5afea7b9057 | 117 | uint8_t status(void); |
jjones646 | 0:c5afea7b9057 | 118 | |
jjones646 | 0:c5afea7b9057 | 119 | |
jjones646 | 0:c5afea7b9057 | 120 | /** |
jjones646 | 0:c5afea7b9057 | 121 | * Perform a soft-reset for the CC1101 |
jjones646 | 0:c5afea7b9057 | 122 | */ |
jjones646 | 0:c5afea7b9057 | 123 | void reset(void); |
jjones646 | 0:c5afea7b9057 | 124 | |
jjones646 | 0:c5afea7b9057 | 125 | |
jjones646 | 0:c5afea7b9057 | 126 | uint8_t strobe(uint8_t); |
jjones646 | 0:c5afea7b9057 | 127 | |
jjones646 | 0:c5afea7b9057 | 128 | |
jjones646 | 0:c5afea7b9057 | 129 | /** |
jjones646 | 0:c5afea7b9057 | 130 | * This function returns the RSSI value based from the last packet received |
jjones646 | 0:c5afea7b9057 | 131 | * |
jjones646 | 0:c5afea7b9057 | 132 | * @return Return the RSSI value. |
jjones646 | 0:c5afea7b9057 | 133 | */ |
jjones646 | 0:c5afea7b9057 | 134 | uint8_t rssi(void); |
jjones646 | 0:c5afea7b9057 | 135 | |
jjones646 | 0:c5afea7b9057 | 136 | |
jjones646 | 0:c5afea7b9057 | 137 | /** |
jjones646 | 0:c5afea7b9057 | 138 | * This function returns the LQI value based from the last packet received |
jjones646 | 0:c5afea7b9057 | 139 | * |
jjones646 | 0:c5afea7b9057 | 140 | * @return Return the LQI value. |
jjones646 | 0:c5afea7b9057 | 141 | */ |
jjones646 | 0:c5afea7b9057 | 142 | uint8_t lqi(void); |
jjones646 | 0:c5afea7b9057 | 143 | |
jjones646 | 0:c5afea7b9057 | 144 | |
jjones646 | 0:c5afea7b9057 | 145 | /** |
jjones646 | 0:c5afea7b9057 | 146 | * This function reads and returns the contents of the PARTNUM register on the CC1101. |
jjones646 | 0:c5afea7b9057 | 147 | */ |
jjones646 | 0:c5afea7b9057 | 148 | uint8_t partnum(void); |
jjones646 | 0:c5afea7b9057 | 149 | |
jjones646 | 0:c5afea7b9057 | 150 | |
jjones646 | 0:c5afea7b9057 | 151 | /** |
jjones646 | 0:c5afea7b9057 | 152 | * This function returns the operating frequency that the CC1101 is receiving/transmitting on. |
jjones646 | 0:c5afea7b9057 | 153 | */ |
jjones646 | 0:c5afea7b9057 | 154 | //virtual uint32_t freq(void); |
jjones646 | 0:c5afea7b9057 | 155 | virtual void freq(uint32_t); |
jjones646 | 0:c5afea7b9057 | 156 | |
jjones646 | 0:c5afea7b9057 | 157 | |
jjones646 | 0:c5afea7b9057 | 158 | /** |
jjones646 | 0:c5afea7b9057 | 159 | * This function is used to update the operating channel of the CC1101. |
jjones646 | 0:c5afea7b9057 | 160 | * |
jjones646 | 0:c5afea7b9057 | 161 | * @param channel Desired operating channel number. |
jjones646 | 0:c5afea7b9057 | 162 | */ |
jjones646 | 0:c5afea7b9057 | 163 | virtual void channel(uint8_t); |
jjones646 | 0:c5afea7b9057 | 164 | |
jjones646 | 0:c5afea7b9057 | 165 | |
jjones646 | 0:c5afea7b9057 | 166 | /** |
jjones646 | 0:c5afea7b9057 | 167 | * This function gets the value of a single specified CCxxx0 register. |
jjones646 | 0:c5afea7b9057 | 168 | * |
jjones646 | 0:c5afea7b9057 | 169 | * @param addr Value of the accessed CCxxx0 register |
jjones646 | 0:c5afea7b9057 | 170 | * @return Value of the accessed CCxxx0 register |
jjones646 | 0:c5afea7b9057 | 171 | */ |
jjones646 | 0:c5afea7b9057 | 172 | uint8_t read_reg(uint8_t); |
jjones646 | 0:c5afea7b9057 | 173 | |
jjones646 | 0:c5afea7b9057 | 174 | |
jjones646 | 0:c5afea7b9057 | 175 | /** |
jjones646 | 0:c5afea7b9057 | 176 | * This function reads multiple CCxxx0 register, using SPI burst access. |
jjones646 | 0:c5afea7b9057 | 177 | * |
jjones646 | 0:c5afea7b9057 | 178 | * @param addr Value of the accessed CCxxx0 register |
jjones646 | 0:c5afea7b9057 | 179 | * @param *buffer Pointer to a byte array which stores the values read from a |
jjones646 | 0:c5afea7b9057 | 180 | * corresponding range of CCxxx0 registers. |
jjones646 | 0:c5afea7b9057 | 181 | * @param count Number of bytes to be read from the subsequent CCxxx0 registers. |
jjones646 | 0:c5afea7b9057 | 182 | */ |
jjones646 | 0:c5afea7b9057 | 183 | void read_reg(uint8_t, uint8_t*, uint8_t); |
jjones646 | 0:c5afea7b9057 | 184 | |
jjones646 | 0:c5afea7b9057 | 185 | |
jjones646 | 0:c5afea7b9057 | 186 | /** |
jjones646 | 0:c5afea7b9057 | 187 | * Function for writing to a single CCxxx0 register |
jjones646 | 0:c5afea7b9057 | 188 | * |
jjones646 | 0:c5afea7b9057 | 189 | * @param addr Address of the first CCxxx0 register to be accessed. |
jjones646 | 0:c5afea7b9057 | 190 | * @param value Value to be written to the specified CCxxx0 register. |
jjones646 | 0:c5afea7b9057 | 191 | */ |
jjones646 | 0:c5afea7b9057 | 192 | void write_reg(uint8_t, uint8_t); |
jjones646 | 0:c5afea7b9057 | 193 | |
jjones646 | 0:c5afea7b9057 | 194 | |
jjones646 | 0:c5afea7b9057 | 195 | /** |
jjones646 | 0:c5afea7b9057 | 196 | * This function writes to multiple CCxxx0 register, using SPI burst access. |
jjones646 | 0:c5afea7b9057 | 197 | * |
jjones646 | 0:c5afea7b9057 | 198 | * @param addr Address of the first CCxxx0 register to be accessed. |
jjones646 | 0:c5afea7b9057 | 199 | * @param *buffer Array of bytes to be written into a corresponding range of |
jjones646 | 0:c5afea7b9057 | 200 | * CCxx00 registers, starting by the address specified in _addr_. |
jjones646 | 0:c5afea7b9057 | 201 | * @param count Number of bytes to be written to the subsequent CCxxx0 registers. |
jjones646 | 0:c5afea7b9057 | 202 | */ |
jjones646 | 0:c5afea7b9057 | 203 | void write_reg(uint8_t, uint8_t*, uint8_t); |
jjones646 | 0:c5afea7b9057 | 204 | |
jjones646 | 0:c5afea7b9057 | 205 | |
jjones646 | 0:c5afea7b9057 | 206 | /** |
jjones646 | 0:c5afea7b9057 | 207 | * This function can be used to transmit a packet with packet length up to 63 bytes. |
jjones646 | 0:c5afea7b9057 | 208 | * |
jjones646 | 0:c5afea7b9057 | 209 | * @param *txBuffer Pointer to a buffer containing the data that are going to be transmitted |
jjones646 | 0:c5afea7b9057 | 210 | * @param size The size of the txBuffer |
jjones646 | 0:c5afea7b9057 | 211 | */ |
jjones646 | 0:c5afea7b9057 | 212 | virtual void put_pck(uint8_t*, uint8_t, bool = false); |
jjones646 | 0:c5afea7b9057 | 213 | |
jjones646 | 0:c5afea7b9057 | 214 | |
jjones646 | 0:c5afea7b9057 | 215 | /** |
jjones646 | 0:c5afea7b9057 | 216 | * This function can be used to receive a packet of variable packet length (first byte in the packet |
jjones646 | 0:c5afea7b9057 | 217 | * must be the length byte). The packet length should not exceed the RX FIFO size. |
jjones646 | 0:c5afea7b9057 | 218 | * |
jjones646 | 0:c5afea7b9057 | 219 | * @param *rxBuffer Pointer to the buffer where the incoming data should be stored |
jjones646 | 0:c5afea7b9057 | 220 | * @param *length Pointer to a variable containing the size of the buffer where the incoming data should be |
jjones646 | 0:c5afea7b9057 | 221 | * stored. After this function returns, that variable holds the packet length. |
jjones646 | 0:c5afea7b9057 | 222 | * @return Return value is 1 if CRC OK or else 0 if CRC NOT OK (or no packet was put in the RX FIFO due to filtering) |
jjones646 | 0:c5afea7b9057 | 223 | */ |
jjones646 | 0:c5afea7b9057 | 224 | virtual bool get_pck(uint8_t*, uint8_t*); |
jjones646 | 0:c5afea7b9057 | 225 | |
jjones646 | 0:c5afea7b9057 | 226 | |
jjones646 | 0:c5afea7b9057 | 227 | /** |
jjones646 | 0:c5afea7b9057 | 228 | * This function flushes the RX FIFO buffer. |
jjones646 | 0:c5afea7b9057 | 229 | */ |
jjones646 | 0:c5afea7b9057 | 230 | void flush_rx(void); |
jjones646 | 0:c5afea7b9057 | 231 | |
jjones646 | 0:c5afea7b9057 | 232 | |
jjones646 | 0:c5afea7b9057 | 233 | /** |
jjones646 | 0:c5afea7b9057 | 234 | * This function flushes the TX FIFO buffer. |
jjones646 | 0:c5afea7b9057 | 235 | */ |
jjones646 | 0:c5afea7b9057 | 236 | void flush_tx(void); |
jjones646 | 0:c5afea7b9057 | 237 | |
jjones646 | 0:c5afea7b9057 | 238 | |
jjones646 | 0:c5afea7b9057 | 239 | /** |
jjones646 | 0:c5afea7b9057 | 240 | * This function change the state of CC1101 to RX mode. |
jjones646 | 0:c5afea7b9057 | 241 | */ |
jjones646 | 0:c5afea7b9057 | 242 | void rx_mode(void); |
jjones646 | 0:c5afea7b9057 | 243 | |
jjones646 | 0:c5afea7b9057 | 244 | |
jjones646 | 0:c5afea7b9057 | 245 | void tx_mode(void); |
jjones646 | 0:c5afea7b9057 | 246 | |
jjones646 | 0:c5afea7b9057 | 247 | void idle(void); |
jjones646 | 0:c5afea7b9057 | 248 | |
jjones646 | 0:c5afea7b9057 | 249 | virtual void powerUp(void); |
jjones646 | 0:c5afea7b9057 | 250 | |
jjones646 | 0:c5afea7b9057 | 251 | protected: |
jjones646 | 0:c5afea7b9057 | 252 | |
jjones646 | 0:c5afea7b9057 | 253 | DigitalOut *_csn; |
jjones646 | 0:c5afea7b9057 | 254 | /* |
jjones646 | 0:c5afea7b9057 | 255 | DigitalOut _tx_led; |
jjones646 | 0:c5afea7b9057 | 256 | DigitalOut _rx_led; |
jjones646 | 0:c5afea7b9057 | 257 | */ |
jjones646 | 0:c5afea7b9057 | 258 | // InterruptIn *_rx_int; |
jjones646 | 0:c5afea7b9057 | 259 | //RingBuffer rxBuf; |
jjones646 | 0:c5afea7b9057 | 260 | //Serial _pc; |
jjones646 | 0:c5afea7b9057 | 261 | |
jjones646 | 0:c5afea7b9057 | 262 | void calibrate(); |
jjones646 | 0:c5afea7b9057 | 263 | |
jjones646 | 0:c5afea7b9057 | 264 | private: |
jjones646 | 0:c5afea7b9057 | 265 | |
jjones646 | 0:c5afea7b9057 | 266 | //static void threadStarter(void const*); |
jjones646 | 0:c5afea7b9057 | 267 | |
jjones646 | 0:c5afea7b9057 | 268 | /* |
jjones646 | 0:c5afea7b9057 | 269 | static void led_tick(void const*); |
jjones646 | 0:c5afea7b9057 | 270 | |
jjones646 | 0:c5afea7b9057 | 271 | static void transmit_thread(void const*); |
jjones646 | 0:c5afea7b9057 | 272 | static void receive_thread(void const*); |
jjones646 | 0:c5afea7b9057 | 273 | //static void get_serial_data_thread(void const*); |
jjones646 | 0:c5afea7b9057 | 274 | */ |
jjones646 | 0:c5afea7b9057 | 275 | |
jjones646 | 0:c5afea7b9057 | 276 | void rssi(uint8_t); |
jjones646 | 0:c5afea7b9057 | 277 | /* |
jjones646 | 0:c5afea7b9057 | 278 | Thread _receive_thread; |
jjones646 | 0:c5afea7b9057 | 279 | Thread _transmit_thread; |
jjones646 | 0:c5afea7b9057 | 280 | Thread _tx_led_thread; |
jjones646 | 0:c5afea7b9057 | 281 | Thread _rx_led_thread; |
jjones646 | 0:c5afea7b9057 | 282 | //Thread _serial_thread; |
jjones646 | 0:c5afea7b9057 | 283 | */ |
jjones646 | 0:c5afea7b9057 | 284 | |
jjones646 | 0:c5afea7b9057 | 285 | void setup_spi(PinName = NC, PinName = NC, PinName = NC); |
jjones646 | 0:c5afea7b9057 | 286 | void setup_pins(PinName = NC, PinName = NC); |
jjones646 | 0:c5afea7b9057 | 287 | void setup_lights(void); |
jjones646 | 0:c5afea7b9057 | 288 | void setup_chip(void); |
jjones646 | 0:c5afea7b9057 | 289 | |
jjones646 | 0:c5afea7b9057 | 290 | void assign_modem_params(void); |
jjones646 | 0:c5afea7b9057 | 291 | void assign_packet_params(void); |
jjones646 | 0:c5afea7b9057 | 292 | void assign_if_freq(uint32_t); |
jjones646 | 0:c5afea7b9057 | 293 | void assign_channel_spacing(uint32_t); |
jjones646 | 0:c5afea7b9057 | 294 | void assign_baud_rate(uint32_t); |
jjones646 | 0:c5afea7b9057 | 295 | void set_rf_settings(void); |
jjones646 | 0:c5afea7b9057 | 296 | void assign_freq_offset(uint8_t); |
jjones646 | 0:c5afea7b9057 | 297 | |
jjones646 | 0:c5afea7b9057 | 298 | // ISR routine for new radio data received over the air |
jjones646 | 0:c5afea7b9057 | 299 | // void isr_receive(void); |
jjones646 | 0:c5afea7b9057 | 300 | void power_on_reset(void); |
jjones646 | 0:c5afea7b9057 | 301 | void put_rf_settings(void); |
jjones646 | 0:c5afea7b9057 | 302 | void compute_freq(void); |
jjones646 | 0:c5afea7b9057 | 303 | |
jjones646 | 0:c5afea7b9057 | 304 | |
jjones646 | 0:c5afea7b9057 | 305 | rf_settings_t rfSettings; |
jjones646 | 0:c5afea7b9057 | 306 | radio_state_t _mode; |
jjones646 | 0:c5afea7b9057 | 307 | pck_ctrl_t _pck_control; |
jjones646 | 0:c5afea7b9057 | 308 | modem_t _modem; |
jjones646 | 0:c5afea7b9057 | 309 | |
jjones646 | 0:c5afea7b9057 | 310 | uint32_t _crystal_freq; |
jjones646 | 0:c5afea7b9057 | 311 | uint32_t _carrier_freq; |
jjones646 | 0:c5afea7b9057 | 312 | uint8_t _offset_freq; |
jjones646 | 0:c5afea7b9057 | 313 | uint32_t _if_freq; |
jjones646 | 0:c5afea7b9057 | 314 | |
jjones646 | 0:c5afea7b9057 | 315 | uint32_t _final_freq; |
jjones646 | 0:c5afea7b9057 | 316 | uint32_t _baud_rate; |
jjones646 | 0:c5afea7b9057 | 317 | uint32_t _channel_spacing; |
jjones646 | 0:c5afea7b9057 | 318 | |
jjones646 | 0:c5afea7b9057 | 319 | uint8_t _lqi; |
jjones646 | 0:c5afea7b9057 | 320 | uint8_t _partnum; |
jjones646 | 0:c5afea7b9057 | 321 | uint8_t _chip_version; |
jjones646 | 0:c5afea7b9057 | 322 | |
jjones646 | 0:c5afea7b9057 | 323 | PinName _so; |
jjones646 | 0:c5afea7b9057 | 324 | PinName _si; |
jjones646 | 0:c5afea7b9057 | 325 | PinName _sck; |
jjones646 | 0:c5afea7b9057 | 326 | |
jjones646 | 0:c5afea7b9057 | 327 | // Variables used to calculate RSSI |
jjones646 | 0:c5afea7b9057 | 328 | uint8_t rssi_dec; |
jjones646 | 0:c5afea7b9057 | 329 | int16_t rssi_dBm; |
jjones646 | 0:c5afea7b9057 | 330 | //uint8_t rssi_offset[CC_NUMBER_OF_SUB_BANDS]; |
jjones646 | 0:c5afea7b9057 | 331 | |
jjones646 | 0:c5afea7b9057 | 332 | int16_t rssiTable[256]; |
jjones646 | 0:c5afea7b9057 | 333 | uint16_t channelNumber[256]; |
jjones646 | 0:c5afea7b9057 | 334 | uint8_t carrierSenseCounter; // Counter used to keep track on how many time CS has been asserted in one sub band |
jjones646 | 0:c5afea7b9057 | 335 | |
jjones646 | 0:c5afea7b9057 | 336 | uint8_t activeBand; // After the scanFreqBands() function has run, this variable will contain the sub band where |
jjones646 | 0:c5afea7b9057 | 337 | // the strongest signal was found |
jjones646 | 0:c5afea7b9057 | 338 | |
jjones646 | 0:c5afea7b9057 | 339 | uint16_t activeChannel; // After the scanFreqBands() function has run, this variable will contain the channel number |
jjones646 | 0:c5afea7b9057 | 340 | // where the strongest signal was found |
jjones646 | 0:c5afea7b9057 | 341 | |
jjones646 | 0:c5afea7b9057 | 342 | }; |
jjones646 | 0:c5afea7b9057 | 343 | #endif |