i2c_adc_ads7828
v2.0.2
Arduino library for TI ADS7828 I2C A/D converter.
|
Public Member Functions | |
ADS7828 (uint8_t) | |
Constructor with the following defaults: More... | |
ADS7828 (uint8_t, uint8_t) | |
ADS7828 (uint8_t, uint8_t, uint8_t) | |
ADS7828 (uint8_t, uint8_t, uint8_t, uint16_t, uint16_t) | |
uint8_t | address () |
Device address as defined by pins A1, A0. More... | |
ADS7828Channel * | channel (uint8_t) |
Return pointer to channel object. More... | |
uint8_t | commandByte () |
Return command byte for device object (PD1 PD0 bits only). More... | |
uint8_t | start () |
Initiate communication with device. More... | |
uint8_t | start (uint8_t) |
uint8_t | update () |
Update all unmasked channels on device. More... | |
uint8_t | update (uint8_t) |
Static Public Member Functions | |
static void | begin () |
Enable I2C communication. More... | |
static ADS7828 * | device (uint8_t) |
Return pointer to device object. More... | |
static uint8_t | updateAll () |
Update all unmasked channels on all registered devices. More... | |
Public Attributes | |
uint8_t | channelMask |
Each bit position containing a 1 represents a channel that is to be read via update() / updateAll(). More... | |
Private Member Functions | |
void | init (uint8_t, uint8_t, uint8_t, uint16_t, uint16_t) |
Common code for constructors. More... | |
uint16_t | read () |
Request and receive data from most-recent A/D conversion from device. More... | |
Static Private Member Functions | |
static uint16_t | read (uint8_t) |
Request and receive data from most-recent A/D conversion from device. More... | |
static uint8_t | start (uint8_t, uint8_t) |
Initiate communication with device. More... | |
static uint8_t | update (ADS7828 *) |
Initiate communication with device. More... | |
static uint8_t | update (ADS7828 *, uint8_t) |
Initiate communication with device. More... | |
Private Attributes | |
uint8_t | address_ |
Device address as defined by pins A1, A0. | |
ADS7828Channel | channels_ [8] |
Array of channel objects. | |
uint8_t | commandByte_ |
Command byte for device object (PD1 PD0 bits only). | |
Static Private Attributes | |
static ADS7828 * | devices_ [4] = {} |
Array of pointers to registered device objects. | |
static const uint8_t | BASE_ADDRESS_ = 0x48 |
Factory pre-set slave address. | |
Related Functions | |
(Note that these are not member functions.) | |
static const uint8_t | DIFFERENTIAL = 0 << 7 |
Configure channels to use differential inputs (Command byte SD=0). More... | |
static const uint8_t | SINGLE_ENDED = 1 << 7 |
Configure channels to use single-ended inputs (Command byte SD=1). More... | |
static const uint8_t | REFERENCE_OFF = 0 << 3 |
Configure channels to turn internal reference OFF between conversions (Command byte PD1=0). More... | |
static const uint8_t | REFERENCE_ON = 1 << 3 |
Configure channels to turn internal reference ON between conversions (Command byte PD1=1). More... | |
static const uint8_t | ADC_OFF = 0 << 2 |
Configure channels to turn A/D converter OFF between conversions (Command byte PD0=0). More... | |
static const uint8_t | ADC_ON = 1 << 2 |
Configure channels to turn A/D converter ON between conversions (Command byte PD0=1). More... | |
static const uint8_t | DEFAULT_CHANNEL_MASK = 0xFF |
Default channel mask used in ADS7828 constructor. | |
static const uint16_t | DEFAULT_MIN_SCALE = 0 |
Default scaling minimum value used in ADS7828 constructor. | |
static const uint16_t | DEFAULT_MAX_SCALE = 0xFFF |
Default scaling maximum value used in ADS7828 constructor. | |
ADS7828::ADS7828 | ( | uint8_t | address | ) |
Constructor with the following defaults:
address | device address (0..3) |
ADS7828::ADS7828 | ( | uint8_t | address, |
uint8_t | options | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
options | command byte bits SD, PD1, PD0 |
ADS7828::ADS7828 | ( | uint8_t | address, |
uint8_t | options, | ||
uint8_t | channelMask | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
channelMask | bit positions containing a 1 represent channels that are to be read via update() / updateAll() |
ADS7828::ADS7828 | ( | uint8_t | address, |
uint8_t | options, | ||
uint8_t | channelMask, | ||
uint16_t | min, | ||
uint16_t | max | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
min | minimum scaling value applied to value() |
max | maximum scaling value applied to value() |
uint8_t ADS7828::address | ( | ) |
Device address as defined by pins A1, A0.
0x00 | A1=0, A0=0 |
0x01 | A1=0, A0=1 |
0x02 | A1=1, A0=0 |
0x03 | A1=1, A0=1 |
ADS7828Channel * ADS7828::channel | ( | uint8_t | ch | ) |
Return pointer to channel object.
ch | channel number (0..7) |
uint8_t ADS7828::commandByte | ( | ) |
Return command byte for device object (PD1 PD0 bits only).
0x00 | Power Down Between A/D Converter Conversions |
0x04 | Internal Reference OFF and A/D Converter ON |
0x08 | Internal Reference ON and A/D Converter OFF |
0x0C | Internal Reference ON and A/D Converter ON |
uint8_t ADS7828::start | ( | ) |
Initiate communication with device.
ping
command
). 0 | success |
1 | length too long for buffer |
2 | address send, NACK received (device not on bus) |
3 | data send, NACK received |
4 | other twi error (lost bus arbitration, bus error, ...) |
uint8_t ADS7828::start | ( | uint8_t | ch | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
ch | channel number (0..7) |
0 | success |
1 | length too long for buffer |
2 | address send, NACK received (device not on bus) |
3 | data send, NACK received |
4 | other twi error (lost bus arbitration, bus error, ...) |
uint8_t ADS7828::update | ( | ) |
Update all unmasked channels on device.
loop()
in order to read data from device(s). uint8_t ADS7828::update | ( | uint8_t | ch | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
loop()
in order to read data from device(s).ch | channel number (0..7) |
0 | success |
1 | length too long for buffer |
2 | address send, NACK received (device not on bus) |
3 | data send, NACK received |
4 | other twi error (lost bus arbitration, bus error, ...) |
|
static |
Enable I2C communication.
setup()to
enable
I2C communication.
|
static |
Return pointer to device object.
address | device address (0..3) |
|
static |
Update all unmasked channels on all registered devices.
loop()
in order to read data from device(s). This is the most commonly-used device update function.
|
private |
Common code for constructors.
address | device address (0..3) |
options | command byte bits SD, PD1, PD0 |
channelMask | bit positions containing a 1 represent channels that are to be read via update() / updateAll() |
min | minimum scaling value applied to value() |
max | maximum scaling value applied to value() |
|
private |
Request and receive data from most-recent A/D conversion from device.
|
staticprivate |
Request and receive data from most-recent A/D conversion from device.
address | device address (0..3) |
|
staticprivate |
Initiate communication with device.
address | device address (0..3) |
command | command byte (0x00..0xFC) |
0 | success |
1 | length too long for buffer |
2 | address send, NACK received (device not on bus) |
3 | data send, NACK received |
4 | other twi error (lost bus arbitration, bus error, ...) |
|
staticprivate |
Initiate communication with device.
device | pointer to device object |
|
staticprivate |
Initiate communication with device.
device | pointer to device object |
ch | channel number (0..7) |
0 | success |
1 | length too long for buffer |
2 | address send, NACK received (device not on bus) |
3 | data send, NACK received |
4 | other twi error (lost bus arbitration, bus error, ...) |
|
related |
Configure channels to use differential inputs (Command byte SD=0).
Use either DIFFERENTIAL or SINGLE_ENDED in ADS7828 constructor; default is DIFFERENTIAL.
|
related |
Configure channels to use single-ended inputs (Command byte SD=1).
Use either DIFFERENTIAL or SINGLE_ENDED in ADS7828 constructor; default is DIFFERENTIAL.
|
related |
Configure channels to turn internal reference OFF between conversions (Command byte PD1=0).
Use either REFERENCE_OFF or REFERENCE_ON in ADS7828 constructor; default is REFERENCE_OFF.
|
related |
Configure channels to turn internal reference ON between conversions (Command byte PD1=1).
Use either REFERENCE_OFF or REFERENCE_ON in ADS7828 constructor; default is REFERENCE_OFF.
|
related |
|
related |
uint8_t ADS7828::channelMask |
Each bit position containing a 1 represents a channel that is to be read via update() / updateAll().