Library for interfacing with the AMICCOM A7105 2.4GHz FSK/GFSK Transceiver.
Diff: A7105.cpp
- Revision:
- 7:1b1d7e446aa4
- Parent:
- 6:44b04880717b
- Child:
- 8:033e328fb7c3
diff -r 44b04880717b -r 1b1d7e446aa4 A7105.cpp --- a/A7105.cpp Thu Jan 01 19:23:08 2015 +0000 +++ b/A7105.cpp Thu Jan 01 19:29:49 2015 +0000 @@ -12,46 +12,43 @@ uint8_t A7105::writeRegister(uint8_t regAddr, uint8_t value) { // assert CS - _cs = 0; + assertChipSelect(); // write register _spi.write(regAddr); // write value into register uint8_t ret = _spi.write(value); // de-assert CS - wait_us(1); - _cs = 1; + deassertChipSelect(); return ret; } uint8_t A7105::readRegister(uint8_t regAddr) { // assert CS - _cs = 0; + assertChipSelect(); // write register and read value _spi.write(_READ(regAddr)); uint8_t ret = _spi.write(0); // de-assert CS - wait_us(1); - _cs = 1; + deassertChipSelect(); return ret; } uint8_t A7105::strobe(enum A7105_State state) { // assert CS - _cs = 0; + assertChipSelect(); // write strobe command uint8_t ret = _spi.write(state); // de-assert CS - wait_us(1); - _cs = 1; + deassertChipSelect(); return ret; } void A7105::writeData(uint8_t* data, size_t len) { // assert CS - _cs = 0; + assertChipSelect(); _spi.write(A7105_RST_WRPTR); _spi.write(A7105_05_FIFO_DATA); for (size_t i = 0; i < len; i++) { @@ -59,8 +56,7 @@ } // de-assert CS - wait_us(1); - _cs = 1; + deassertChipSelect(); } void A7105::readData(uint8_t* buffer, size_t len) { @@ -72,15 +68,14 @@ void A7105::setId(uint32_t id) { // assert CS - _cs = 0; + assertChipSelect(); _spi.write(A7105_06_ID_DATA); _spi.write((uint8_t)(id >> 24) & 0xFF); _spi.write((uint8_t)(id >> 16) & 0xFF); _spi.write((uint8_t)(id >> 8) & 0xFF); _spi.write((uint8_t)id & 0xFF); // de-assert CS - wait_us(1); - _cs = 1; + deassertChipSelect(); } void A7105::setPower(int32_t power) {