Radio Structures in OOP

Dependencies:   mbed mbed-rtos

Committer:
jjones646
Date:
Sat Jan 03 04:35:32 2015 +0000
Revision:
3:dc7e9c6bc26c
Parent:
2:7d523bdd2f50
Child:
5:146523a0d1f4
updating with threaded tasks for communication classes

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jjones646 2:7d523bdd2f50 1 #ifndef CC1101_RADIO_H
jjones646 2:7d523bdd2f50 2 #define CC1101_RADIO_H
jjones646 2:7d523bdd2f50 3
jjones646 2:7d523bdd2f50 4 #include "mbed.h"
jjones646 2:7d523bdd2f50 5 #include "CommLink.h"
jjones646 2:7d523bdd2f50 6 #include "cmsis_os.h"
jjones646 2:7d523bdd2f50 7 #include "RTP.h"
jjones646 3:dc7e9c6bc26c 8 //#include "ThreadHelper.h"
jjones646 3:dc7e9c6bc26c 9 #include "CC1101-Defines.h"
jjones646 3:dc7e9c6bc26c 10
jjones646 3:dc7e9c6bc26c 11 #define CCXXX1_DEBUG_MODE 0
jjones646 2:7d523bdd2f50 12
jjones646 2:7d523bdd2f50 13 class CC1101 : public CommLink
jjones646 2:7d523bdd2f50 14 {
jjones646 2:7d523bdd2f50 15 public:
jjones646 2:7d523bdd2f50 16 // Default constructor
jjones646 2:7d523bdd2f50 17 CC1101();
jjones646 3:dc7e9c6bc26c 18 CC1101(PinName mosi, PinName miso, PinName sck, PinName cs, PinName = NC);
jjones646 2:7d523bdd2f50 19
jjones646 2:7d523bdd2f50 20 // Deconstructor
jjones646 2:7d523bdd2f50 21 virtual ~CC1101();
jjones646 2:7d523bdd2f50 22
jjones646 2:7d523bdd2f50 23 // These must have implementations in the CC1101 class since it is a derived class of the base class CommLink
jjones646 2:7d523bdd2f50 24 virtual uint32_t reset(void);
jjones646 2:7d523bdd2f50 25 virtual uint32_t selfTest(void);
jjones646 2:7d523bdd2f50 26 virtual bool isConnected(void);
jjones646 2:7d523bdd2f50 27
jjones646 3:dc7e9c6bc26c 28 // Set/Get the chip's operating channel
jjones646 2:7d523bdd2f50 29 void channel(uint16_t);
jjones646 3:dc7e9c6bc26c 30 uint16_t channel(void);
jjones646 3:dc7e9c6bc26c 31
jjones646 3:dc7e9c6bc26c 32 // Set/Get the chip's datarate (baudrate)
jjones646 3:dc7e9c6bc26c 33 uint16_t datarate(void);
jjones646 3:dc7e9c6bc26c 34
jjones646 3:dc7e9c6bc26c 35 void address(uint8_t);
jjones646 2:7d523bdd2f50 36
jjones646 3:dc7e9c6bc26c 37 // The NOP command used to get the CC1101's status byte
jjones646 3:dc7e9c6bc26c 38 uint8_t status(void);
jjones646 3:dc7e9c6bc26c 39 uint8_t status(uint8_t);
jjones646 3:dc7e9c6bc26c 40 uint8_t lqi(void);
jjones646 3:dc7e9c6bc26c 41 uint8_t version(void);
jjones646 3:dc7e9c6bc26c 42 int16_t rssi(void);
jjones646 3:dc7e9c6bc26c 43
jjones646 3:dc7e9c6bc26c 44 int32_t powerUp(void);
jjones646 2:7d523bdd2f50 45
jjones646 2:7d523bdd2f50 46 protected:
jjones646 3:dc7e9c6bc26c 47 virtual int32_t sendData(uint8_t*, uint8_t);
jjones646 3:dc7e9c6bc26c 48 virtual int32_t getData(uint8_t*, uint8_t*);
jjones646 3:dc7e9c6bc26c 49
jjones646 3:dc7e9c6bc26c 50 // Reading/Writing registers
jjones646 3:dc7e9c6bc26c 51 void write_reg(uint8_t, uint8_t);
jjones646 3:dc7e9c6bc26c 52 void write_reg(uint8_t, uint8_t*, uint8_t);
jjones646 3:dc7e9c6bc26c 53 uint8_t read_reg(uint8_t);
jjones646 3:dc7e9c6bc26c 54 void read_reg(uint8_t, uint8_t*, uint8_t);
jjones646 3:dc7e9c6bc26c 55
jjones646 3:dc7e9c6bc26c 56 uint8_t strobe(uint8_t);
jjones646 3:dc7e9c6bc26c 57
jjones646 3:dc7e9c6bc26c 58 void tx_mode(void);
jjones646 3:dc7e9c6bc26c 59 void rx_mode(void);
jjones646 3:dc7e9c6bc26c 60
jjones646 3:dc7e9c6bc26c 61 void flush_tx(void);
jjones646 3:dc7e9c6bc26c 62 void flush_rx(void);
jjones646 3:dc7e9c6bc26c 63
jjones646 3:dc7e9c6bc26c 64 void idle(void);
jjones646 3:dc7e9c6bc26c 65
jjones646 3:dc7e9c6bc26c 66 void freq(uint32_t);
jjones646 3:dc7e9c6bc26c 67 void datarate(uint32_t); // set data rate
jjones646 2:7d523bdd2f50 68
jjones646 2:7d523bdd2f50 69 private:
jjones646 3:dc7e9c6bc26c 70 void setup(void);
jjones646 2:7d523bdd2f50 71
jjones646 3:dc7e9c6bc26c 72 void calibrate(void);
jjones646 3:dc7e9c6bc26c 73 void tiny_delay(void);
jjones646 3:dc7e9c6bc26c 74 void rssi(uint8_t);
jjones646 3:dc7e9c6bc26c 75 uint8_t mode(void);
jjones646 3:dc7e9c6bc26c 76
jjones646 3:dc7e9c6bc26c 77 void assign_modem_params(void);
jjones646 3:dc7e9c6bc26c 78 void assign_packet_params(void);
jjones646 3:dc7e9c6bc26c 79 void assign_if_freq(uint32_t);
jjones646 3:dc7e9c6bc26c 80 void assign_channel_spacing(uint32_t);
jjones646 3:dc7e9c6bc26c 81 void set_rf_settings(void);
jjones646 3:dc7e9c6bc26c 82 //void assign_freq_offset(uint8_t);
jjones646 3:dc7e9c6bc26c 83
jjones646 3:dc7e9c6bc26c 84 void set_init_vars(void);
jjones646 3:dc7e9c6bc26c 85
jjones646 3:dc7e9c6bc26c 86 rf_settings_t rfSettings;
jjones646 3:dc7e9c6bc26c 87 radio_state_t _mode;
jjones646 3:dc7e9c6bc26c 88 pck_ctrl_t _pck_control;
jjones646 3:dc7e9c6bc26c 89 modem_t _modem;
jjones646 3:dc7e9c6bc26c 90
jjones646 3:dc7e9c6bc26c 91 uint16_t _channel;
jjones646 3:dc7e9c6bc26c 92 uint16_t _datarate;
jjones646 3:dc7e9c6bc26c 93 uint8_t _address;
jjones646 3:dc7e9c6bc26c 94 uint8_t _lqi;
jjones646 3:dc7e9c6bc26c 95 uint16_t _rssi;
jjones646 3:dc7e9c6bc26c 96 uint8_t _chip_version;
jjones646 3:dc7e9c6bc26c 97 uint32_t _base_freq;
jjones646 2:7d523bdd2f50 98 };
jjones646 2:7d523bdd2f50 99
jjones646 2:7d523bdd2f50 100 #endif // CC1101_RADIO_H
jjones646 2:7d523bdd2f50 101