Library for interfacing with the AMICCOM A7105 2.4GHz FSK/GFSK Transceiver.

Dependents:   HubsanTX

a7105txrx.h

Committer:
d34d
Date:
2014-09-01
Revision:
0:212eb977fe10
Child:
1:2ae040ee7239

File content as of revision 0:212eb977fe10:

#ifndef _A7105_TX_RX_H
#define _A7105_TX_RX_H

/******************************
 * Control register addresses *
 ******************************/
//! Mode register
#define MODE            0x00
//! Mode control register
#define MODE_CONTROL    0x01
//! Calibration control register
#define CALC            0x02
//! FIFO register 1
#define FIFO_1          0x03
//! FIFO register 2
#define FIFO_2          0x04
//! FIFO data register
#define FIFO_DATA       0x05
//! ID data register
#define ID_DATA         0x06
//! RC OSC register 1
#define RC_OSC_1        0x07
//! RC OSC register 2
#define RC_OSC_2        0x08
//! RC OSC register 3
#define RC_OSC_3        0x09
//! CKO pin control register
#define CKO             0x0A
//! GPIO1 pin control register
#define GPIO1           0x0B
//! GPIO2 pin control register
#define CPIO2           0x0C
//! Clock register
#define CLOCK           0x0D
//! Data rate register
#define DATA_RATE       0x0E
//! PLL register 1
#define PLL_1           0x0F
//! PLL register 2
#define PLL_2           0x10
//! PLL register 3
#define PLL_3           0x11
//! PLL register 4
#define PLL_4           0x12
//! PLL register 5
#define PLL_5           0x13
//! TX register 1
#define TX_1            0x14
//! TX register 2
#define TX_2            0x15
//! Delay register 1
#define DELAY_1         0x16
//! Delay register 2
#define DELAY_2         0x17
//! RX register
#define RX              0x18
//! RX gain register 1
#define RX_GAIN_1       0x19
//! RX gain register 2
#define RX_GAIN_2       0x1A
//! RX gain register 3
#define RX_GAIN_3       0x1B
//! RX gain register 4
#define RX_GAIN_4       0x1C
//! RSSI threshold register
#define RSSI_THRESHOLD  0x1D
//! ADC control register
#define ADC_CONTROL     0x1E
//! Code register 1
#define CODE_1          0x1F
//! Code register 2
#define CODE_2          0x20
//! Code register 3
#define CODE_3          0x21
//! IF calibration register 1
#define IF_CAL_1        0x22
//! IF calibration register 2
#define IF_CAL_2        0x23
//! VCO current calibration register
#define VCO_CUR_CAL     0x24
//! VCO single band calibration register 1
#define VCO_SBC_1       0x25
//! VCO single band calibration register 2
#define VCO_SBC_2       0x26
//! Battery detect register
#define BATTERY_DETECT  0x27
//! TX test register
#define TX_TEST         0x28
//! RX dem test register 1
#define RX_DEM_TEST_1   0x29
//! RX dem test register 2
#define RX_DEM_TEST_2   0x2A
//! Charge pump current register
#define CPC             0x2B
//! Crystal test register
#define XTAL_TEST       0x2C
//! PLL test register
#define PLL_TEST        0x2D
//! VCO test register 1
#define VCO_TEST_1      0x2E
//! VCO test register 2
#define VCO_TEST_2      0x2F
//! IFAT register
#define IFAT            0x30
//! RScale register
#define RSCALE          0x31
//! Filter test register
#define FILTER_TEST     0x32

/**
 * Class for interfacing with the AMICCOM A7105 2.4G FSK/GFSK Transceiver
 *
 * See the A7105 datasheet for complete documentation on this part
 * http://www.avantcom.com.tw/AVANTCOM/TC/DATA/PRODUCT/SOLVE/18_3.pdf
 */
class A7105 {
    public:
        /**
         * @param mosi Pin used to transmit data to the slave
         * @param miso Pin used to receive data from the slave
         * @param clk Pin used for the clock
         * @param cs Pin used for the chip select
         * @param freqHz Frequency used to clock data in and out
         */
        A7105(PinName mosi, PinName miso, PinName clk, PinName cs, uint32_t freqHz);
        ~A7105();
        
        /**
         * Writes a value to the given register
         *
         * @param regAddr Address of the register to write to
         * @param value Value to write into the register
         * @return Value returned from slave when writing the register
         */
        uint8_t writeRegister(uint8_t regAddr, uint8_t value);
        
        /**
         * Reads a value from the given register
         *
         * @param regAddr Address of the register to read
         * @return The value of the register
         */
        uint8_t readRegister(uint8_t regAddr);
        
        /**
         * Resets the A7105, putting it into standby mode.
         *
         * @return Value returned from the slave after writing 0x00 to the MODE register.
         */
        uint8_t reset();
        
    private:
        SPI         mSpiMaster;
        DigitalOut  mChipSelect;
};

#endif  // #ifndef _A7105_TX_RX_H