MAX11200 ADC Arduino library
#include "max11200.h"
#include "SPI.h"
Max11210 sensor(SPI, PIN_SPI_SS, PIN_SPI_MISO);
Where
- SPI is the instance of the SPI driver class,
- PIN_SPI_SS is the peripheral select pin connected to MAX11200 and
- PIN_SPI_MISO is the MISO pin of SPI
You shall call sensor.begin(); to initialize the sensor in the Arduino setup() function.
First check if the data acquisition has completed yet by calling _sensor.waitForReady(t); where t is a wait timeout in milliseconds. If waitForReady returns true, you can call sensor.analogReadUnsigned() or sensor.analogReadSigned() depending on the application configuration.
After initialization with begin() you can set up the max11200 parameters with the following APIs:
-
sensor.config(val); where val is the desired value of the CTRL1 register of the device. Check max11200.h for the pre-defined values. Example: sensor.config(Max11210::linef|Max11210::ub);
-
sensor.setRate(rate); will set the conversion rate. Check max11200.h for the pre-defined values. Example: sensor.setRate(Max11210::rate::rate120sps);
You can configure the digital IO pins of the device with the pinMode(pin,direction) method. Example: sensor.pinMode(Max11210::dPin::gpio4,Max11210::dMode::output);
Then get or set the digital values via the digitalWrite and digitalRead APIs. Example: sensor.digitalWrite(Max11210::dPin::gpio4,Max11210::dVal::low);
Only the self calibration is implemented and it is called by the begin() method at startup. If needed, the self calibration can be triggered via calling the calibrateSelf() method.