mbed library to interface a Texas Instruments' ADS7828, 12-bits, 8-channels, I2C interfaced ADC

Dependents:   ADS7828_demo

Committer:
frada
Date:
Tue Dec 30 14:41:54 2014 +0000
Revision:
2:2ff328d8e4dd
Parent:
1:19b0f0ba4d12
Child:
3:abbfd9c7f30c
-

Who changed what in which revision?

UserRevisionLine numberNew contents of line
frada 1:19b0f0ba4d12 1 /***************************************************************************
frada 1:19b0f0ba4d12 2 ADS7828.H
frada 1:19b0f0ba4d12 3 Header file for library ADS7828
frada 1:19b0f0ba4d12 4 The ADS7828 is a 12-bits, 8-channels, I2C-interfaced from Texas Instruments
frada 1:19b0f0ba4d12 5
frada 1:19b0f0ba4d12 6 (c) 2014 - By Francesco Adamo, Italy
frada 1:19b0f0ba4d12 7 *****************************************************************************/
frada 1:19b0f0ba4d12 8
frada 1:19b0f0ba4d12 9 #ifndef ADS7828_H
frada 1:19b0f0ba4d12 10 #define ADS7828_H
frada 1:19b0f0ba4d12 11
frada 1:19b0f0ba4d12 12 #include "mbed.h"
frada 1:19b0f0ba4d12 13
frada 1:19b0f0ba4d12 14 #define ADS7828_BASE_ADDRESS 0x90
frada 1:19b0f0ba4d12 15
frada 1:19b0f0ba4d12 16 // ADS7828 command codes
frada 1:19b0f0ba4d12 17 #define CH01_DIFF (uint8_t) (0x00 << 4) // CH0+, CH1-
frada 1:19b0f0ba4d12 18 #define CH23_DIFF (uint8_t) (0x01 << 4) // CH2+, CH2-
frada 1:19b0f0ba4d12 19 #define CH45_DIFF (uint8_t) (0x02 << 4) // CH4+, CH5-
frada 1:19b0f0ba4d12 20 #define CH67_DIFF (uint8_t) (0x03 << 4) // CH6+, CH7-
frada 1:19b0f0ba4d12 21 #define CH10_DIFF (uint8_t) (0x04 << 4) // CH1+, CH0-
frada 1:19b0f0ba4d12 22 #define CH32_DIFF (uint8_t) (0x05 << 4) // CH3+, CH2-
frada 1:19b0f0ba4d12 23 #define CH54_DIFF (uint8_t) (0x06 << 4) // CH5+, CH4-
frada 1:19b0f0ba4d12 24 #define CH76_DIFF (uint8_t) (0x07 << 4) // CH6+, CH6-
frada 1:19b0f0ba4d12 25
frada 1:19b0f0ba4d12 26 #define CH0_SE (uint8_t) (0x00 << 4)
frada 1:19b0f0ba4d12 27 #define CH2_SE (uint8_t) (0x01 << 4)
frada 1:19b0f0ba4d12 28 #define CH4_SE (uint8_t) (0x02 << 4)
frada 1:19b0f0ba4d12 29 #define CH6_SE (uint8_t) (0x03 << 4)
frada 1:19b0f0ba4d12 30 #define CH1_SE (uint8_t) (0x04 << 4)
frada 1:19b0f0ba4d12 31 #define CH3_SE (uint8_t) (0x05 << 4)
frada 1:19b0f0ba4d12 32 #define CH5_SE (uint8_t) (0x06 << 4)
frada 1:19b0f0ba4d12 33 #define CH7_SE (uint8_t) (0x07 << 4)
frada 1:19b0f0ba4d12 34
frada 1:19b0f0ba4d12 35 #define MODE_SE (uint8_t) (0x01 << 8)
frada 1:19b0f0ba4d12 36 #define MODE_DIFF (uint8_t) 0x00
frada 1:19b0f0ba4d12 37
frada 1:19b0f0ba4d12 38 #define MODE_POWER_DOWN_BETWEEN_CONVERSIONS (uint8_t) (0x00 << 2)
frada 1:19b0f0ba4d12 39 #define MODE_INTERNAL_REF_OFF_ADC_ON (uint8_t) (0x01 << 2)
frada 1:19b0f0ba4d12 40 #define MODE_INTERNAL_REF_ON_ADC_OFF (uint8_t) (0x02 << 2)
frada 1:19b0f0ba4d12 41 #define MODE_INTERNAL_REF_ON_ADC_ON (uint8_t) (0x03 << 2)
frada 1:19b0f0ba4d12 42
frada 1:19b0f0ba4d12 43
frada 1:19b0f0ba4d12 44 class ADS7828 {
frada 1:19b0f0ba4d12 45 private:
frada 1:19b0f0ba4d12 46 I2C _i2c;
frada 1:19b0f0ba4d12 47 char address;
frada 1:19b0f0ba4d12 48 double VFSR;
frada 1:19b0f0ba4d12 49
frada 1:19b0f0ba4d12 50 public:
frada 1:19b0f0ba4d12 51 ADS7828(PinName sda, PinName scl); // Constructor
frada 1:19b0f0ba4d12 52 ADS7828(PinName sda, PinName scl, int freq); // Constructor overload
frada 1:19b0f0ba4d12 53 ADS7828(PinName sda, PinName scl, int freq, char subAddress); // Constructor overload
frada 2:2ff328d8e4dd 54 ADS7828(PinName sda, PinName scl, int freq, char subAddress, double VREF); // Constructor overload
frada 1:19b0f0ba4d12 55
frada 1:19b0f0ba4d12 56 int readRawValue(char mode, char channel);
frada 1:19b0f0ba4d12 57 double readAnalogValue(char mode, char channel);
frada 1:19b0f0ba4d12 58 };
frada 1:19b0f0ba4d12 59
frada 1:19b0f0ba4d12 60 #endif //#ifndef ADS7828_H