Analog Devices AD7124-8 - 8-Channel, Low Noise, Low Power, 24-Bit, Sigma-Delta ADC with PGA and Reference
Dependents: CN0398 CN0391 CN0398_arduino
Diff: AD7124.cpp
- Revision:
- 4:502352a643e6
- Parent:
- 1:4a4194a5a8ed
--- a/AD7124.cpp Mon Oct 24 16:03:43 2016 +0000 +++ b/AD7124.cpp Tue Nov 08 09:38:35 2016 +0000 @@ -49,6 +49,7 @@ #include "mbed.h" #include "AD7124.h" + /** * @brief AD7790 constructor, sets CS pin and SPI format * @param CS - (optional)chip select of the AD7790 @@ -56,18 +57,8 @@ * @param MISO - (optional)pin of the SPI interface * @param SCK - (optional)pin of the SPI interface */ -AD7124::AD7124(PinName CS, - PinName MOSI, - PinName MISO, - PinName SCK) : - miso(MISO), ad7124(MOSI, MISO, SCK), cs(CS) -{ - cs = true; // cs is active low - ad7124.format(8, _SPI_MODE); - this->regs = ad7124_regs; - this->useCRC = false; - ad7124_st_reg ad7124_regs[] = { +const static AD7124::ad7124_st_reg ad7124_regs_init[57] = { {0x00, 0x00, 1, 2}, /* AD7124_Status */ {0x01, 0x0000, 2, 1}, /* AD7124_ADC_Control */ {0x02, 0x0000, 3, 2}, /* AD7124_Data */ @@ -125,8 +116,22 @@ {0x36, 0x500000, 3, 1}, /* AD7124_Gain_5 */ {0x37, 0x500000, 3, 1}, /* AD7124_Gain_6 */ {0x38, 0x500000, 3, 1}, /* AD7124_Gain_7 */ - }; -} + }; + +AD7124::AD7124(PinName CS, + PinName MOSI, + PinName MISO, + PinName SCK) : + miso(MISO), ad7124(MOSI, MISO, SCK), cs(CS) + +{ + cs = true; // cs is active low + ad7124.format(8, _SPI_MODE); + memcpy(ad7124_regs, ad7124_regs_init, 57 * sizeof(ad7124_st_reg)); + this->regs = ad7124_regs; + this->useCRC = false; + + } /** * @brief Set AD7790 SPI frequency