release library with one example
authorMatthieu Chevrier <matthieu.chevrier@ti.com>
Tue, 12 Mar 2019 14:52:48 +0000 (15:52 +0100)
committerMatthieu Chevrier <matthieu.chevrier@ti.com>
Tue, 12 Mar 2019 14:52:48 +0000 (15:52 +0100)
.gitignore
ADS1220/ADS1220.cpp [new file with mode: 0644]
ADS1220/ADS1220.h [new file with mode: 0644]
ADS1220/example/TIDA647_2wire/TIDA647_2wire.ino [new file with mode: 0644]
ADS1220/keywords.txt [new file with mode: 0644]
README.md

index 8bcfcc5b9563dbaa7e9a5c0517bae47fff47b177..ee0c41b70910a07cd8edc1dc00f414e73a57d032 100644 (file)
@@ -1,2 +1,4 @@
 *.tar.gz
-*.zip
\ No newline at end of file
+*.zip
+*.pub
+*.ppk
\ No newline at end of file
diff --git a/ADS1220/ADS1220.cpp b/ADS1220/ADS1220.cpp
new file mode 100644 (file)
index 0000000..f934ef7
--- /dev/null
@@ -0,0 +1,201 @@
+/* --COPYRIGHT--,BSD
+ * Copyright (c) 2015, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * --/COPYRIGHT--*/
+
+/*******************************************************************************
+ *
+ * ADS1220.cpp
+ *
+ * Hardware abstraction layer for the ADS1220
+ *
+ * Aug 2015
+ * M. Chevrier
+ *
+ *
+ ******************************************************************************/
+
+#include <SPI.h>
+#include <ADS1220.h>
+
+
+
+ADS1220::ADS1220(int ads1220_cs_pin)
+{
+       //pinMode(pin, OUTPUT);
+       _ads1220_cs = ads1220_cs_pin;
+}
+
+void ADS1220::init (unsigned char inputMux, unsigned char opMode,
+                    unsigned char conversionMode, unsigned char dataRate, unsigned char gainLevel, unsigned char pgaBypass,
+                    unsigned char routeIDAC1, unsigned char routeIDAC2, unsigned char idacCurrent)
+
+{
+
+    unsigned char config[4];
+
+    config[0] = inputMux + gainLevel + pgaBypass;
+    config[1] = dataRate + opMode + conversionMode + ADS1220_TEMP_SENSOR_OFF + ADS1220_BURN_OUT_CURRENT_OFF;
+    config[2] = ADS1220_FIR_50_60 + ADS1220_VREF_EXT_REF0_PINS + ADS1220_LOW_SIDE_POWER_OPEN + idacCurrent;
+    config[3] = routeIDAC1 + routeIDAC2 + ADS1220_DRDY_ON_DRDY_ONLY;
+
+    ADS1220_Write_Regs (config, ADS1220_CONFIG_0_REG, 4);
+}
+
+void ADS1220::ADS1220_initfull(unsigned char inputMux, unsigned char gainLevel, unsigned char pgaBypass,
+                                       unsigned char dataRate, unsigned char opMode, unsigned char conversionMode,  unsigned char temp_sensor_onoff, unsigned char burnout_current,
+                                       unsigned char fir_50_60, unsigned char vref, unsigned char low_side_switch, unsigned char idacCurrent, 
+                    unsigned char routeIDAC1, unsigned char routeIDAC2, unsigned char drdy )
+{
+       //FIXME: here we are still hard coding the FIR_50_60, ...
+
+       unsigned char config[4];
+
+    config[0] = inputMux + gainLevel + pgaBypass;
+    config[1] = dataRate + opMode + conversionMode + temp_sensor_onoff + burnout_current;
+    config[2] = fir_50_60 + vref + low_side_switch + idacCurrent;
+    config[3] = routeIDAC1 + routeIDAC2 + drdy;
+
+    ADS1220_Write_Regs (config, ADS1220_CONFIG_0_REG, 4);
+       
+}
+
+void ADS1220::ADS1220_next_read_internal_temp()
+{
+       unsigned char config[4];
+       unsigned char conf_reg_1;
+       ADS1220_Read_Regs(config, ADS1220_CONFIG_1_REG,1);
+       conf_reg1_backup = config[1];
+       config[0] =  config[1]+ADS1220_TEMP_SENSOR_ON ;
+       //config[0] = ADS1220_DATA_RATE_20SPS + ADS1220_OP_MODE_NORMAL + ADS1220_CONVERSION_CONTINUOUS + ADS1220_TEMP_SENSOR_ON + ADS1220_BURN_OUT_CURRENT_OFF;
+       ADS1220_Write_Regs (config, ADS1220_CONFIG_1_REG, 1);
+}
+
+void ADS1220::ADS1220_restore_after_internal_temp_read()
+{
+       unsigned char config[4];
+       ADS1220_Read_Regs(config, ADS1220_CONFIG_1_REG,1);
+       config[0] = config[1] & ~(ADS1220_TEMP_SENSOR_ON);
+//     config[0] = ADS1220_DATA_RATE_20SPS + ADS1220_OP_MODE_NORMAL + ADS1220_CONVERSION_CONTINUOUS + ADS1220_TEMP_SENSOR_OFF + ADS1220_BURN_OUT_CURRENT_OFF;
+       ADS1220_Write_Regs (config, ADS1220_CONFIG_1_REG, 1);
+}
+
+long ADS1220::InternalTemp(long ADCCode_24b)
+{
+       return (ADCCode_24b>>10)*0.03125;
+}
+
+void ADS1220::ADS1220_Reset (void)
+{
+       static unsigned char Rcv_Data[8];
+    unsigned char cmd = ADS1220_RESET_CMD;
+       
+       _SPI_write (&cmd, Rcv_Data, 1);
+}
+
+
+void ADS1220::ADS1220_Start (void)
+{
+       static unsigned char Rcv_Data[8];
+
+    unsigned char cmd = ADS1220_START_CMD;
+    _SPI_write (&cmd, Rcv_Data, 1);
+}
+
+void ADS1220::ADS1220_Powerdown (void)
+{
+       static unsigned char Rcv_Data[8];
+       
+    unsigned char cmd = ADS1220_POWERDOWN_CMD;
+    _SPI_write (&cmd, Rcv_Data, 1);
+}
+
+
+void ADS1220::ADS1220_Send_Read_Data_Command (void)
+{
+       unsigned char Rcv_Data[8];
+       
+    unsigned char cmd = ADS1220_RDATA_CMD;
+    _SPI_write (&cmd, Rcv_Data, 1);
+}
+
+void ADS1220::ADS1220_Get_Conversion_Data (unsigned char *conversionData)
+{
+
+    //unsigned char outData[3] = {0xff, 0xff, 0xff};
+       unsigned char outData[3] = {0xaa, 0xaa, 0xaa};
+
+    _SPI_write (outData, conversionData, 3);    // 3 Bytes of Conversion Data
+
+}
+
+void ADS1220::ADS1220_Read_Regs (unsigned char *readValues, unsigned char startReg, unsigned char length)
+{
+    unsigned char outData[5] = {0x55, 0x55, 0x55, 0x55, 0x55};
+
+    outData[0] = ADS1220_READ_CMD(startReg,length);
+
+    _SPI_write (outData, readValues, length+1);    // Add 1 to length for command byte
+
+}
+
+void ADS1220::ADS1220_Write_Regs (unsigned char *writeValues, unsigned char startReg, unsigned char length)
+{
+    unsigned char outData[5];
+    unsigned char i;
+       unsigned char Rcv_Data[8];
+
+    outData[0] = ADS1220_WRITE_CMD(startReg,length);
+
+    for (i=0; i<length; i++)
+    {
+        outData[i+1] = writeValues[i];
+    }
+
+    _SPI_write (outData, Rcv_Data, length+1);    // Add 1 to length for command byte
+
+}
+
+void ADS1220::_SPI_write (unsigned char *outData, unsigned char *inData, unsigned char length)
+{
+unsigned char i;
+       delay(1);
+    digitalWrite(_ads1220_cs, LOW);
+    delay(1);
+    for (i=0; i<length; i++)
+    {
+        inData[i] = SPI.transfer(outData[i]);
+    }
+       delay(1);
+    digitalWrite(_ads1220_cs, LOW);
+       
+}
+
+
diff --git a/ADS1220/ADS1220.h b/ADS1220/ADS1220.h
new file mode 100644 (file)
index 0000000..fe88afe
--- /dev/null
@@ -0,0 +1,241 @@
+/* --COPYRIGHT--,BSD
+ * Copyright (c) 2015, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * --/COPYRIGHT--*/
+/*******************************************************************************
+ *
+ * ADS1220.h
+ *
+ * Hardware abstraction layer for the ADS1220
+ *
+ * August 2015
+ * M. Chevrier
+ *
+ *
+ ******************************************************************************/
+
+#ifndef ADS1220_H_
+#define ADS1220_H_
+
+
+#define ADS1220_RESET_CMD          0x06
+#define ADS1220_WREG_CMD           0x40
+#define ADS1220_RREG_CMD           0x20
+#define ADS1220_RDATA_CMD          0x10
+#define ADS1220_START_CMD          0x08
+#define ADS1220_POWERDOWN_CMD      0x02
+
+
+#define ADS1220_WRITE_CMD(reg,len)     (ADS1220_WREG_CMD + (reg << 2) + (len-1))
+#define ADS1220_READ_CMD(reg,len)      (ADS1220_RREG_CMD + (reg << 2) + (len-1))
+
+
+#define ADS1220_CONFIG_0_REG      0
+#define ADS1220_CONFIG_1_REG      1
+#define ADS1220_CONFIG_2_REG      2
+#define ADS1220_CONFIG_3_REG      3
+
+
+// Configuration Register 0 Settings  00h
+#define ADS1220_MUX_MASK          0xf0
+#define ADS1220_MUX_SHIFT         4
+
+#define ADS1220_MUX_AIN0_AIN1     (0x0 << ADS1220_MUX_SHIFT)
+#define ADS1220_MUX_AIN0_AIN2     (0x1 << ADS1220_MUX_SHIFT)
+#define ADS1220_MUX_AIN0_AIN3     (0x2 << ADS1220_MUX_SHIFT)
+#define ADS1220_MUX_AIN1_AIN2     (0x3 << ADS1220_MUX_SHIFT)
+#define ADS1220_MUX_AIN1_AIN3     (0x4 << ADS1220_MUX_SHIFT)
+#define ADS1220_MUX_AIN2_AIN3     (0x5 << ADS1220_MUX_SHIFT)
+#define ADS1220_MUX_AIN1_AIN0     (0x6 << ADS1220_MUX_SHIFT)
+#define ADS1220_MUX_AIN3_AIN2     (0x7 << ADS1220_MUX_SHIFT)
+#define ADS1220_MUX_AIN0_AVSS     (0x8 << ADS1220_MUX_SHIFT)
+#define ADS1220_MUX_AIN1_AVSS     (0x9 << ADS1220_MUX_SHIFT)
+#define ADS1220_MUX_AIN2_AVSS     (0xa << ADS1220_MUX_SHIFT)
+#define ADS1220_MUX_AIN3_AVSS     (0xb << ADS1220_MUX_SHIFT)
+#define ADS1220_MUX_REFPmREFN     (0xc << ADS1220_MUX_SHIFT)
+#define ADS1220_MUX_AVDDmAVSS     (0xd << ADS1220_MUX_SHIFT)
+#define ADS1220_MUX_SHORTED       (0xe << ADS1220_MUX_SHIFT)
+
+
+#define ADS1220_GAIN_MASK         0xe
+#define ADS1220_GAIN_SHIFT        1
+
+#define ADS1220_GAIN_1            (0x0 << ADS1220_GAIN_SHIFT)
+#define ADS1220_GAIN_2            (0x1 << ADS1220_GAIN_SHIFT)
+#define ADS1220_GAIN_4            (0x2 << ADS1220_GAIN_SHIFT)
+#define ADS1220_GAIN_8            (0x3 << ADS1220_GAIN_SHIFT)
+#define ADS1220_GAIN_16           (0x4 << ADS1220_GAIN_SHIFT)
+#define ADS1220_GAIN_32           (0x5 << ADS1220_GAIN_SHIFT)
+#define ADS1220_GAIN_64           (0x6 << ADS1220_GAIN_SHIFT)
+#define ADS1220_GAIN_128          (0x7 << ADS1220_GAIN_SHIFT)
+
+#define ADS1220_PGA_BYPASS        1
+#define ADS1220_USE_PGA           0
+
+
+// Configuration Register 1 Settings   01h
+
+#define ADS1220_DATA_RATE_MASK    0xe0
+#define ADS1220_DATA_RATE_SHIFT   5
+
+#define ADS1220_DATA_RATE_20SPS   (0 << ADS1220_DATA_RATE_SHIFT)
+#define ADS1220_DATA_RATE_45SPS   (1 << ADS1220_DATA_RATE_SHIFT)
+#define ADS1220_DATA_RATE_90SPS   (2 << ADS1220_DATA_RATE_SHIFT)
+#define ADS1220_DATA_RATE_175SPS  (3 << ADS1220_DATA_RATE_SHIFT)
+#define ADS1220_DATA_RATE_330SPS  (4 << ADS1220_DATA_RATE_SHIFT)
+#define ADS1220_DATA_RATE_600SPS  (5 << ADS1220_DATA_RATE_SHIFT)
+#define ADS1220_DATA_RATE_1000SPS (6 << ADS1220_DATA_RATE_SHIFT)
+
+#define ADS1220_OP_MODE_MASK      0x18
+#define ADS1220_OP_MODE_SHIFT     3
+
+#define ADS1220_OP_MODE_NORMAL    (0 << ADS1220_OP_MODE_SHIFT)
+#define ADS1220_OP_MODE_DUTY      (1 << ADS1220_OP_MODE_SHIFT)
+#define ADS1220_OP_MODE_TURBO     (2 << ADS1220_OP_MODE_SHIFT)
+
+#define ADS1220_CONVERSION_MODE_MASK     0x4
+#define ADS1220_CONVERSION_SINGLE_SHOT   0x0
+#define ADS1220_CONVERSION_CONTINUOUS    0x4
+
+#define ADS1220_TEMP_SENSOR_MASK         0x2
+#define ADS1220_TEMP_SENSOR_ON           0x2
+#define ADS1220_TEMP_SENSOR_OFF          0x0
+
+#define ADS1220_BURN_OUT_MASK            0x1
+#define ADS1220_BURN_OUT_CURRENT_ON      0x1
+#define ADS1220_BURN_OUT_CURRENT_OFF     0x0
+
+// Configuration Register 2 Settings   02h
+
+#define ADS1220_VREF_MASK                0xc0
+#define ADS1220_VREF_SHIFT               6
+
+#define ADS1220_VREF_INTERNAL            (0 << ADS1220_VREF_SHIFT)
+#define ADS1220_VREF_EXT_REF0_PINS       (1 << ADS1220_VREF_SHIFT)
+#define ADS1220_VREF_EXT_REF1_PINS       (2 << ADS1220_VREF_SHIFT)
+#define ADS1220_VREF_AVDD                (3 << ADS1220_VREF_SHIFT)
+
+#define ADS1220_FIR_FILTER_MASK          0x30
+#define ADS1220_FIR_FILTER_SHIFT         4
+
+#define ADS1220_FIR_NONE                 (0 << ADS1220_FIR_FILTER_SHIFT)
+#define ADS1220_FIR_50_60                (1 << ADS1220_FIR_FILTER_SHIFT)
+#define ADS1220_FIR_50                   (2 << ADS1220_FIR_FILTER_SHIFT)
+#define ADS1220_FIR_60                   (3 << ADS1220_FIR_FILTER_SHIFT)
+
+#define ADS1220_LOW_SIDE_POWER_MASK      0x04
+#define ADS1220_LOW_SIDE_POWER_OPEN      0x00
+#define ADS1220_LOW_SIDE_POWER_CLOSES    0x04
+
+#define ADS1220_IDAC_CURRENT_MASK        0x07
+#define ADS1220_IDAC_CURRENT_SHIFT       0
+
+#define ADS1220_IDAC_CURRENT_OFF         (0 << ADS1220_IDAC_CURRENT_SHIFT)
+#define ADS1220_IDAC_CURRENT_10_UA       (1 << ADS1220_IDAC_CURRENT_SHIFT)
+#define ADS1220_IDAC_CURRENT_50_UA       (2 << ADS1220_IDAC_CURRENT_SHIFT)
+#define ADS1220_IDAC_CURRENT_100_UA      (3 << ADS1220_IDAC_CURRENT_SHIFT)
+#define ADS1220_IDAC_CURRENT_250_UA      (4 << ADS1220_IDAC_CURRENT_SHIFT)
+#define ADS1220_IDAC_CURRENT_500_UA      (5 << ADS1220_IDAC_CURRENT_SHIFT)
+#define ADS1220_IDAC_CURRENT_1000_UA     (6 << ADS1220_IDAC_CURRENT_SHIFT)
+#define ADS1220_IDAC_CURRENT_1500_UA     (7 << ADS1220_IDAC_CURRENT_SHIFT)
+
+// Configuration Register 3 Settings   03h
+
+#define ADS1220_IDAC1_MUX_MASK           0xe0
+#define ADS1220_IDAC1_MUX_SHIFT          5
+
+#define ADS1220_IDAC1_DISABLED           (0 << ADS1220_IDAC1_MUX_SHIFT)
+#define ADS1220_IDAC1_AIN0               (1 << ADS1220_IDAC1_MUX_SHIFT)
+#define ADS1220_IDAC1_AIN1               (2 << ADS1220_IDAC1_MUX_SHIFT)
+#define ADS1220_IDAC1_AIN2               (3 << ADS1220_IDAC1_MUX_SHIFT)
+#define ADS1220_IDAC1_AIN3               (4 << ADS1220_IDAC1_MUX_SHIFT)
+#define ADS1220_IDAC1_REFP0              (5 << ADS1220_IDAC1_MUX_SHIFT)
+#define ADS1220_IDAC1_REFN0              (6 << ADS1220_IDAC1_MUX_SHIFT)
+
+#define ADS1220_IDAC2_MUX_MASK           0x1c
+#define ADS1220_IDAC2_MUX_SHIFT          2
+
+#define ADS1220_IDAC2_DISABLED           (0 << ADS1220_IDAC2_MUX_SHIFT)
+#define ADS1220_IDAC2_AIN0               (1 << ADS1220_IDAC2_MUX_SHIFT)
+#define ADS1220_IDAC2_AIN1               (2 << ADS1220_IDAC2_MUX_SHIFT)
+#define ADS1220_IDAC2_AIN2               (3 << ADS1220_IDAC2_MUX_SHIFT)
+#define ADS1220_IDAC2_AIN3               (4 << ADS1220_IDAC2_MUX_SHIFT)
+#define ADS1220_IDAC2_REFP0              (5 << ADS1220_IDAC2_MUX_SHIFT)
+#define ADS1220_IDAC2_REFN0              (6 << ADS1220_IDAC2_MUX_SHIFT)
+
+#define ADS1220_DOUT_DRDY_MASK           0x2
+#define ADS1220_DRDY_ON_DOUT_DRDY        0x2
+#define ADS1220_DRDY_ON_DRDY_ONLY        0x0
+
+
+
+
+class ADS1220 {
+public:
+    void init(unsigned char inputMux, unsigned char opMode,
+                    unsigned char conversionMode, unsigned char dataRate, unsigned char gainLevel, unsigned char pgaBypass,
+                    unsigned char routeIDAC1, unsigned char routeIDAC2, unsigned char idacCurrent);
+       ADS1220(int ads1220_cs_pin);
+       void ADS1220_initfull(unsigned char inputMux, unsigned char gainLevel, unsigned char pgaBypass,
+                                       unsigned char dataRate, unsigned char opMode, unsigned char conversionMode,  unsigned char temp_sensor_onoff, unsigned char burnout_current,
+                                       unsigned char fir_50_60, unsigned char vref, unsigned char low_side_switch, unsigned char idacCurrent, 
+                    unsigned char routeIDAC1, unsigned char routeIDAC2, unsigned char drdy );
+
+       void ADS1220_Reset (void);
+                                       /*
+       void ADS1220_Offset_Calibrate_Data (unsigned char *tempData);
+*/
+       void ADS1220_Start (void);
+       void ADS1220_Powerdown (void);
+       void ADS1220_Write_Regs (unsigned char *writeValues, unsigned char startReg, unsigned char length);
+       void ADS1220_Read_Regs (unsigned char *readValues, unsigned char startReg, unsigned char length);
+       void ADS1220_Send_Read_Data_Command (void);
+       void ADS1220_Get_Conversion_Data (unsigned char *conversionData);
+       void ADS1220_Get_Conversion_Data_Calibrated (unsigned char *conversionData);
+       
+       void ADS1220_next_read_internal_temp(void);
+       void ADS1220_restore_after_internal_temp_read(void);
+       
+       long InternalTemp(long ADCCode_24b);
+       
+       void _SPI_write (unsigned char *outData, unsigned char *inData, unsigned char length);
+
+       static unsigned char RcvData[8];
+       
+       int _ads1220_cs ;
+       
+private:
+       long conf_reg1_backup;  //use to store configuration register one settings when switching to temp sensing
+
+};
+
+
+#endif /* ADS1220_H_ */
\ No newline at end of file
diff --git a/ADS1220/example/TIDA647_2wire/TIDA647_2wire.ino b/ADS1220/example/TIDA647_2wire/TIDA647_2wire.ino
new file mode 100644 (file)
index 0000000..4716348
--- /dev/null
@@ -0,0 +1,160 @@
+/* --COPYRIGHT--,BSD
+ * Copyright (c) 2015, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * *  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * *  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * *  Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * --/COPYRIGHT--*/
+
+/*******************************************************************************
+ *
+ * TIDA_00647_UART.ino
+ *
+ * Demo to send the TIDA_00647 Data via a UART 
+ *
+ * Aug 2015
+ * MCV (Matt-CHV)
+ *
+ *
+ ******************************************************************************/
+
+#include <SPI.h>
+#include <ADS1220.h>
+#define LED RED_LED
+#define RDY P3_0
+#define CS P1_3
+
+ADS1220 myADS1220_647(CS);
+
+volatile int count = 0;
+volatile int temp = 0;
+
+volatile static unsigned char tempData[3];
+
+void setup() {
+  //Delay to allow power supplies to settle and power-up reset to complete; minimum of 50 μs;
+  delay(1);  
+  //Configure the SPI interface of the microcontroller to SPI mode 1 (CPOL = 0, CPHA = 1);
+    SPI.begin();                     // SCK, MOSI set to LOW
+    SPI.setDataMode(SPI_MODE1);      // SPI mode 1 config
+    SPI.setBitOrder(MSBFIRST);
+    SPI.setClockDivider(128);        // SPI clock frequency
+    //If the CS pin is not tied low permanently, configure the microcontroller GPIO connected to CS as an output;
+    pinMode(CS, OUTPUT);
+    digitalWrite(CS, HIGH);
+    //Configure the microcontroller GPIO connected to the DRDY pin as a falling edge triggered interrupt input;
+    pinMode(RDY, INPUT_PULLUP);
+    attachInterrupt(RDY, counting, FALLING); // Interrupt is fired whenever button is pressed
+
+    //Set CS to the device low;
+    digitalWrite(CS, LOW);
+    //Delay for a minimum of td(CSSC);
+    delay(1);
+    //send the RESET command
+    myADS1220_647.ADS1220_Reset();
+    //delay
+    delay(1);
+    //Write the respective register configuration with the WREG command (43h, 08h, 04h, 10h, and 00h);
+  //    myADS1220_647.init (ADS1220_MUX_AIN0_AIN1, ADS1220_OP_MODE_NORMAL,             ADS1220_CONVERSION_CONTINUOUS, ADS1220_DATA_RATE_20SPS, ADS1220_GAIN_16, ADS1220_USE_PGA,             ADS1220_IDAC1_AIN3, ADS1220_IDAC2_AIN2, ADS1220_IDAC_CURRENT_250_UA);
+    myADS1220_647.ADS1220_initfull(ADS1220_MUX_AIN0_AIN1, ADS1220_GAIN_16, ADS1220_USE_PGA,
+                                       ADS1220_DATA_RATE_20SPS, ADS1220_OP_MODE_NORMAL, ADS1220_CONVERSION_CONTINUOUS,  ADS1220_TEMP_SENSOR_OFF, ADS1220_BURN_OUT_CURRENT_OFF,
+                                       ADS1220_FIR_50_60, ADS1220_VREF_EXT_REF0_PINS, ADS1220_LOW_SIDE_POWER_OPEN, ADS1220_IDAC_CURRENT_250_UA, 
+                                        ADS1220_IDAC1_AIN3, ADS1220_IDAC2_AIN2, ADS1220_DRDY_ON_DRDY_ONLY);
+    //readback or delay
+    delay(1);
+    myADS1220_647.ADS1220_Start();
+    //Delay for a minimum of td(SCCS);
+    delay(1);
+    //clear /CS to high
+    digitalWrite(CS, HIGH);
+    
+    pinMode(LED, OUTPUT);   
+    digitalWrite(LED, HIGH);
+    Serial.begin(9600);     // opens serial port, sets data rate to 9600 bps
+
+
+}
+
+long Resistor(long adc_code)
+{
+  float Vin, Rin;
+  float Vrefp = 3.24e3*250e-6*2;
+  Vin = adc_code *Vrefp/(8388607)/16;
+  Rin = Vin/250e-6;
+  return Rin;
+}
+
+long Temperature(long adc_code)
+{
+  float Vin, Tin;
+
+  Vin = adc_code >> 10;
+  Tin = Vin*0.03125;
+  return Tin;
+}
+
+void loop() {
+    float * data;
+    long code;
+    float res;
+   
+    delay(100);
+    digitalWrite(LED, HIGH);
+    delay(100);
+    digitalWrite(LED, LOW);
+  
+    if (count>0 )
+    {
+
+    myADS1220_647.ADS1220_Get_Conversion_Data ((unsigned char *)tempData);
+
+    code = (((long)tempData[0] << 16) + ((long)tempData[1] << 8) + (long)tempData[2]);
+    Serial.println(code);
+
+      if (temp==0 && count>0) {
+        Serial.print("Resistor");
+        res = Resistor(code);
+        Serial.println(res);
+        count = 0;
+        temp=1;
+        myADS1220_647.ADS1220_next_read_internal_temp();
+      }
+      if (temp==1 && count> 0) {
+        Serial.print("Temp");
+        res = myADS1220_647.InternalTemp(code);
+        Serial.println(res);
+        count = 0;
+        temp=0;
+        myADS1220_647.ADS1220_restore_after_internal_temp_read();
+      }
+    }
+}
+
+void counting()
+{
+  count+=1;
+}
diff --git a/ADS1220/keywords.txt b/ADS1220/keywords.txt
new file mode 100644 (file)
index 0000000..544a737
--- /dev/null
@@ -0,0 +1,145 @@
+##################################################
+# Syntax Coloring Map For ADS1220
+##################################################
+
+#######################################
+# Datatypes (KEYWORD1)
+#######################################
+
+ADS1220        KEYWORD1
+
+#######################################
+# Methods and Functions (KEYWORD2)
+#######################################
+
+init   KEYWORD2
+ADS1220_initfull       KEYWORDS2
+ADS1220_Reset  KEYWORDS2
+ADS1220_Offset_Calibrate_Data  KEYWORDS2
+ADS1220_Start  KEYWORDS2
+ADS1220_Powerdown      KEYWORDS2
+ADS1220_Write_Regs     KEYWORDS2
+ADS1220_Read_Regs      KEYWORDS2
+ADS1220_Send_Read_Data_Command KEYWORDS2
+ADS1220_Get_Conversion_Data    KEYWORDS2
+ADS1220_Get_Conversion_Data_Calibrated KEYWORDS2
+ADS1220_next_read_internal_temp        KEYWORDS2
+ADS1220_restore_after_internal_temp_read       KEYWORDS2
+InternalTemp   KEYWORDS2
+_SPI_write     KEYWORDS2
+
+
+#######################################
+# Constants (LITERAL1)
+#######################################
+ADS1220_RESET_CMD      KEYWORD3
+ADS1220_WREG_CMD       KEYWORD3
+ADS1220_RREG_CMD       KEYWORD3
+ADS1220_RDATA_CMD      KEYWORD3
+ADS1220_START_CMD      KEYWORD3
+ADS1220_POWERDOWN_CMD  KEYWORD3
+ADS1220_WRITE_CMD(reg,len)     KEYWORD3
+ADS1220_READ_CMD(reg,len)      KEYWORD3
+ADS1220_CONFIG_0_REG   KEYWORD3
+ADS1220_CONFIG_1_REG   KEYWORD3
+ADS1220_CONFIG_2_REG   KEYWORD3
+ADS1220_CONFIG_3_REG   KEYWORD3
+ADS1220_MUX_MASK       KEYWORD3
+ADS1220_MUX_SHIFT      KEYWORD3
+ADS1220_MUX_AIN0_AIN1  KEYWORD3
+ADS1220_MUX_AIN0_AIN2  KEYWORD3
+ADS1220_MUX_AIN0_AIN3  KEYWORD3
+ADS1220_MUX_AIN1_AIN2  KEYWORD3
+ADS1220_MUX_AIN1_AIN3  KEYWORD3
+ADS1220_MUX_AIN2_AIN3  KEYWORD3
+ADS1220_MUX_AIN1_AIN0  KEYWORD3
+ADS1220_MUX_AIN3_AIN2  KEYWORD3
+ADS1220_MUX_AIN0_AVSS  KEYWORD3
+ADS1220_MUX_AIN1_AVSS  KEYWORD3
+ADS1220_MUX_AIN2_AVSS  KEYWORD3
+ADS1220_MUX_AIN3_AVSS  KEYWORD3
+ADS1220_MUX_REFPmREFN  KEYWORD3
+ADS1220_MUX_AVDDmAVSS  KEYWORD3
+ADS1220_MUX_SHORTED    KEYWORD3
+ADS1220_GAIN_MASK      KEYWORD3
+ADS1220_GAIN_SHIFT     KEYWORD3
+ADS1220_GAIN_1 KEYWORD3
+ADS1220_GAIN_2 KEYWORD3
+ADS1220_GAIN_4 KEYWORD3
+ADS1220_GAIN_8 KEYWORD3
+ADS1220_GAIN_16        KEYWORD3
+ADS1220_GAIN_32        KEYWORD3
+ADS1220_GAIN_64        KEYWORD3
+ADS1220_GAIN_128       KEYWORD3
+ADS1220_PGA_BYPASS     KEYWORD3
+ADS1220_USE_PGA        KEYWORD3
+ADS1220_DATA_RATE_MASK KEYWORD3
+ADS1220_DATA_RATE_SHIFT        KEYWORD3
+ADS1220_DATA_RATE_20SPS        KEYWORD3
+ADS1220_DATA_RATE_45SPS        KEYWORD3
+ADS1220_DATA_RATE_90SPS        KEYWORD3
+ADS1220_DATA_RATE_175SPS       KEYWORD3
+ADS1220_DATA_RATE_330SPS       KEYWORD3
+ADS1220_DATA_RATE_600SPS       KEYWORD3
+ADS1220_DATA_RATE_1000SPS      KEYWORD3
+ADS1220_OP_MODE_MASK   KEYWORD3
+ADS1220_OP_MODE_SHIFT  KEYWORD3
+ADS1220_OP_MODE_NORMAL KEYWORD3
+ADS1220_OP_MODE_DUTY   KEYWORD3
+ADS1220_OP_MODE_TURBO  KEYWORD3
+ADS1220_CONVERSION_MODE_MASK   KEYWORD3
+ADS1220_CONVERSION_SINGLE_SHOT KEYWORD3
+ADS1220_CONVERSION_CONTINUOUS  KEYWORD3
+ADS1220_TEMP_SENSOR_MASK       KEYWORD3
+ADS1220_TEMP_SENSOR_ON KEYWORD3
+ADS1220_TEMP_SENSOR_OFF        KEYWORD3
+ADS1220_BURN_OUT_MASK  KEYWORD3
+ADS1220_BURN_OUT_CURRENT_ON    KEYWORD3
+ADS1220_BURN_OUT_CURRENT_OFF   KEYWORD3
+ADS1220_VREF_MASK      KEYWORD3
+ADS1220_VREF_SHIFT     KEYWORD3
+ADS1220_VREF_INTERNAL  KEYWORD3
+ADS1220_VREF_EXT_REF0_PINS     KEYWORD3
+ADS1220_VREF_EXT_REF1_PINS     KEYWORD3
+ADS1220_VREF_AVDD      KEYWORD3
+ADS1220_FIR_FILTER_MASK        KEYWORD3
+ADS1220_FIR_FILTER_SHIFT       KEYWORD3
+ADS1220_FIR_NONE       KEYWORD3
+ADS1220_FIR_50_60      KEYWORD3
+ADS1220_FIR_50 KEYWORD3
+ADS1220_FIR_60 KEYWORD3
+ADS1220_LOW_SIDE_POWER_MASK    KEYWORD3
+ADS1220_LOW_SIDE_POWER_OPEN    KEYWORD3
+ADS1220_LOW_SIDE_POWER_CLOSES  KEYWORD3
+ADS1220_IDAC_CURRENT_MASK      KEYWORD3
+ADS1220_IDAC_CURRENT_SHIFT     KEYWORD3
+ADS1220_IDAC_CURRENT_OFF       KEYWORD3
+ADS1220_IDAC_CURRENT_10_UA     KEYWORD3
+ADS1220_IDAC_CURRENT_50_UA     KEYWORD3
+ADS1220_IDAC_CURRENT_100_UA    KEYWORD3
+ADS1220_IDAC_CURRENT_250_UA    KEYWORD3
+ADS1220_IDAC_CURRENT_500_UA    KEYWORD3
+ADS1220_IDAC_CURRENT_1000_UA   KEYWORD3
+ADS1220_IDAC_CURRENT_1500_UA   KEYWORD3
+ADS1220_IDAC1_MUX_MASK KEYWORD3
+ADS1220_IDAC1_MUX_SHIFT        KEYWORD3
+ADS1220_IDAC1_DISABLED KEYWORD3
+ADS1220_IDAC1_AIN0     KEYWORD3
+ADS1220_IDAC1_AIN1     KEYWORD3
+ADS1220_IDAC1_AIN2     KEYWORD3
+ADS1220_IDAC1_AIN3     KEYWORD3
+ADS1220_IDAC1_REFP0    KEYWORD3
+ADS1220_IDAC1_REFN0    KEYWORD3
+ADS1220_IDAC2_MUX_MASK KEYWORD3
+ADS1220_IDAC2_MUX_SHIFT        KEYWORD3
+ADS1220_IDAC2_DISABLED KEYWORD3
+ADS1220_IDAC2_AIN0     KEYWORD3
+ADS1220_IDAC2_AIN1     KEYWORD3
+ADS1220_IDAC2_AIN2     KEYWORD3
+ADS1220_IDAC2_AIN3     KEYWORD3
+ADS1220_IDAC2_REFP0    KEYWORD3
+ADS1220_IDAC2_REFN0    KEYWORD3
+ADS1220_DOUT_DRDY_MASK KEYWORD3
+ADS1220_DRDY_ON_DOUT_DRDY      KEYWORD3
+ADS1220_DRDY_ON_DRDY_ONLY      KEYWORD3
+
index e21a261e011f786bba8255e58b6233910bf8bb03..6e6a9d1b5ad889fedf4da4a18493420a2cc4a665 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,3 +1,11 @@
 # TIDA-00647 Energia Library
 
-## Energia Install
\ No newline at end of file
+## Energia Install
+follow Energia [online](http://energia.nu/download/) instructions
+
+## Import the ADS1220 library in Energia
+TL;DR : In Energia import the folder where the README is located as the Sketchbook location.
+
+Alternatively refer to either: 
+* [TIDA-00647](http://www.ti.com/tool/TIDA-00647) User's Guide 
+* Energia [libraries](https://energia.nu/guide/libraries/) online page
\ No newline at end of file