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

Dependents:   HubsanTX

a7105txrx.cpp

Committer:
d34d
Date:
2014-09-01
Revision:
0:212eb977fe10
Child:
2:35a860dbaba5

File content as of revision 0:212eb977fe10:

#include "mbed.h"
#include "a7105txrx.h"

A7105::A7105(PinName mosi, PinName miso, PinName clk, PinName cs, uint32_t freqHz) :
        mSpiMaster(mosi, miso, clk), mChipSelect(cs) {
    mSpiMaster.frequency(freqHz);
    // Chip select is active low so set it to high until we are ready
    mChipSelect = 1;
}

A7105::~A7105() {}

uint8_t A7105::writeRegister(uint8_t regAddr, uint8_t value) {
    // assert CS
    mChipSelect = 0;
    // write register, most significant bit should be one to indicate a write
    mSpiMaster.write(regAddr | 0x80);
    // write value into register
    uint8_t ret = mSpiMaster.write(value);
    // de-assert CS
    mChipSelect = 1;
    
    return ret;
}

uint8_t A7105::readRegister(uint8_t regAddr) {
    // assert CS
    mChipSelect = 0;
    // write register and read value
    uint8_t ret = mSpiMaster.write(regAddr);
    // de-assert CS
    mChipSelect = 1;
    
    return ret;
}

uint8_t A7105::reset() {
    return writeRegister(MODE, 0x00);
}