Radio Structures in OOP

Dependencies:   mbed mbed-rtos

drivers/CC1101/CC1101.h

Committer:
jjones646
Date:
2015-01-14
Revision:
5:146523a0d1f4
Parent:
3:dc7e9c6bc26c
Child:
6:4a3dbfbc30f1

File content as of revision 5:146523a0d1f4:

#ifndef CC1101_RADIO_H
#define CC1101_RADIO_H

#include "mbed.h"
#include "CommLink.h"
#include "cmsis_os.h"
#include "RTP.h"
//#include "ThreadHelper.h"
#include "CC1101-Defines.h"

#define CCXXX1_DEBUG_MODE 0

class CC1101 : public CommLink
{
public:
    // Default constructor
    CC1101();
    CC1101(PinName mosi, PinName miso, PinName sck, PinName cs, PinName int_pin = NC);
    
    // Deconstructor
    virtual ~CC1101();

    // These must have implementations in the CC1101 class since it is a derived class of the base class CommLink
    virtual uint32_t reset(void);
    virtual uint32_t selfTest(void);
    virtual bool isConnected(void);
    
    // Set/Get the chip's operating channel
    void channel(uint16_t);
    uint16_t channel(void);
    
    // Set/Get the chip's datarate (baudrate)
    uint16_t datarate(void);
    
    void address(uint8_t);
    
    // The NOP command used to get the CC1101's status byte
    uint8_t status(void);
    uint8_t status(uint8_t);
    uint8_t lqi(void);
    uint8_t version(void);
    int16_t rssi(void);
    
    int32_t powerUp(void);
    
protected:
    virtual int32_t sendData(uint8_t*, uint8_t);
    virtual int32_t getData(uint8_t*, uint8_t*);
    
    // Reading/Writing registers
    void write_reg(uint8_t, uint8_t);
    void write_reg(uint8_t, uint8_t*, uint8_t);
    uint8_t read_reg(uint8_t);
    void read_reg(uint8_t, uint8_t*, uint8_t);
    
    uint8_t strobe(uint8_t);
    
    void tx_mode(void);
    void rx_mode(void);
    
    void flush_tx(void);
    void flush_rx(void);
    
    void idle(void);
    
    void freq(uint32_t);
    void datarate(uint32_t);    // set data rate
    void put_rf_settings(void);
    void init(void);
    
private:
    void setup(void);

    void calibrate(void);
    void tiny_delay(void);
    void rssi(uint8_t);
    uint8_t mode(void);
    
    void assign_modem_params(void);
    void assign_packet_params(void);
    void assign_if_freq(uint32_t);
    void assign_channel_spacing(uint32_t);
    void set_rf_settings(void);
    void set_init_vars(void);
    void power_on_reset(void);
    
    rf_settings_t rfSettings;
    radio_state_t      _mode;
    pck_ctrl_t  _pck_control;
    modem_t     _modem;

    uint16_t    _channel;
    uint16_t    _datarate;
    uint8_t     _address;
    uint8_t     _lqi;
    uint16_t    _rssi;
    uint8_t     _chip_version;
    uint32_t    _base_freq;
};

#endif  // CC1101_RADIO_H