#include <adc.h>
|
| AdcSpi (uint8_t sync_pin, uint8_t spi_bus_config_pin, uint8_t data_ready_pin, uint8_t bit_resolution, uint8_t reset_pin=0, uint8_t clock_divider=7, BitOrder bit_order=MSBFIRST, uint8_t spi_mode=SPI_MODE3) |
|
bool | Begin (void) |
|
double | ReadVoltage (uint8_t channel=0) |
|
uint8_t | ReadVoltage (uint8_t channel, byte previous_meas[], bool send) |
|
AdcSpi class
- Author
- Carlos Kometter
- Version
- 0.1
- Date
- 2018
- Copyright
- GNU Public License.
AdcSpi::AdcSpi |
( |
uint8_t |
sync_pin, |
|
|
uint8_t |
spi_bus_config_pin, |
|
|
uint8_t |
data_ready_pin, |
|
|
uint8_t |
bit_resolution, |
|
|
uint8_t |
reset_pin = 0 , |
|
|
uint8_t |
clock_divider = 7 , |
|
|
BitOrder |
bit_order = MSBFIRST , |
|
|
uint8_t |
spi_mode = SPI_MODE3 |
|
) |
| |
Constructor
- Parameters
-
[in] | sync_pin | The sync or chip select of the adc chip. Different than spi_bus_config_pin |
[in] | spi_bus_config_pin | The pin that identifies the bus. More than one adc can share the same pin. |
[in] | data_ready_pin | This pin tells whether the adc has finished measuring a voltage. |
[in] | bit_resolution | The bit resolution of the adc (eg. 16 for AD7734). |
[in] | clock_divider | Sets the spi frequency. spi_freq = clock_freq (84 MHz for arduino due) / clock_divider (default: 7) |
[in] | bit_order | Possible values:
- MSBFIRST Most significant bit first. (default)
- LSBFIRST Least significant bit first.
|
[in] | spi_mode | Possible values:
- SPI_MODE0
- SPI_MODE1
- SPI_MODE2
- SPI_MODE3 (default)
|
[in] | reset_pin | The reset pin for the dac pin. Set to 0 if not used. (default: 0) |
bool AdcSpi::Begin |
( |
void |
| ) |
|
Configures pins for SPI and initializes SPI communication. This function must be called before calling any other function.
Uses chip specifications (e.g. bit resolution, registers, range) to convert a set of bytes stored in a Message object to voltage. Each ADC has its own convertion function. Check the datasheet of each chip and override the function below accordingly.
- Parameters
-
[in] | message | Message object which stores the bytes for conversion. |
- Returns
- The measured voltage.
Implemented in AD7734.
- Parameters
-
[in] | channel | The channel to be read. |
- Returns
- Message object to read the data register.
Implemented in AD7734.
double AdcSpi::ReadVoltage |
( |
uint8_t |
channel = 0 | ) |
|
Read the voltage at one of the analog inputs of the adc.
- Parameters
-
[in] | channel | The analog input to be read. (default: 0) |
- Returns
- The voltage at the analog input.
uint8_t AdcSpi::ReadVoltage |
( |
uint8_t |
channel, |
|
|
byte |
previous_meas[], |
|
|
bool |
send |
|
) |
| |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This function takes of the dead time the adc is converting (meausering) a new voltage. During this dead time the arduino sends the previous measurement via serial.
- Parameters
-
[in] | channel | The analog input to be read. (default: 0) |
[in,out] | previous_meas[] | stores values of previous measurement to be sent vias spi. After the adc finishes converting the new voltage, it stores the new values. |
[in] | send | Possible values:
- true Content of previous_meas[] is sent via serial while the adc is converting current voltage.
- false Content of previous_meas[] is non sent via serial while the adc is converting current voltage.
|
- Returns
- The voltage at the analog input.
- Parameters
-
[in] | channel | The channel to start single conversion mode on dump mode. |
- Returns
- Message object to start single conversion mode on dump mode.
Implemented in AD7734.
The documentation for this class was generated from the following files:
- include/adc.h
- src/adc.cpp