Analog Devices AD7124-8 - 8-Channel, Low Noise, Low Power, 24-Bit, Sigma-Delta ADC with PGA and Reference

Dependents:   CN0398 CN0391 CN0398_arduino

Files at this revision

API Documentation at this revision

Comitter:
adisuciu
Date:
Tue Nov 08 09:38:35 2016 +0000
Parent:
1:4a4194a5a8ed
Child:
5:5fa802deb471
Commit message:
Fixed for mbed online compiler(array initialization not allowed within class)

Changed in this revision

AD7124.cpp Show annotated file Show diff for this revision Revisions of this file
AD7124.h Show annotated file Show diff for this revision Revisions of this file
AD7124_regs.h Show diff for this revision Revisions of this file
--- 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
--- a/AD7124.h	Mon Oct 24 16:03:43 2016 +0000
+++ b/AD7124.h	Tue Nov 08 09:38:35 2016 +0000
@@ -49,7 +49,6 @@
 #define AD7790_H
 
 #include "mbed.h"
-#include "AD7124_regs.h"
 
 /**
  * Comment this line if you want to turn off the debug mode.
@@ -61,6 +60,8 @@
 /**
  * @brief Analog Devices AD7790 SPI 16-bit Buffered Sigma-Delta ADC
  */
+ 
+
 class AD7124
 {
 public:
@@ -125,15 +126,15 @@
         AD7124_REG_NO
     };
     
-        /*! Device register info */
+    /*! Device register info */
+
+
     typedef struct _ad7124_st_reg {
         int32_t addr;
         int32_t value;
         int32_t size;
         int32_t rw;
     } ad7124_st_reg;
-
-
     /*! Array holding the info for the ad7124 registers - address, initial value,
     size and access type. */
     ad7124_st_reg ad7124_regs[57];