A collection of Analog Devices drivers for the mbed platform

For additional information check out the mbed page of the Analog Devices wiki: https://wiki.analog.com/resources/tools-software/mbed-drivers-all

Committer:
Adrian Suciu
Date:
Fri Apr 29 17:34:07 2016 +0300
Revision:
17:b8356808e8ad
Parent:
13:66c8e4ce4ff1
Child:
18:7d35420ff4aa
Fixed code style and added doxygen tags

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Adrian Suciu 13:66c8e4ce4ff1 1
Adrian Suciu 13:66c8e4ce4ff1 2 #include "mbed.h"
Adrian Suciu 13:66c8e4ce4ff1 3 #include "AD7791.h"
Adrian Suciu 13:66c8e4ce4ff1 4
Adrian Suciu 13:66c8e4ce4ff1 5 #ifndef CN0216_H_
Adrian Suciu 13:66c8e4ce4ff1 6 #define CN0216_H_
Adrian Suciu 13:66c8e4ce4ff1 7
Adrian Suciu 13:66c8e4ce4ff1 8 class CN0216
Adrian Suciu 13:66c8e4ce4ff1 9 {
Adrian Suciu 13:66c8e4ce4ff1 10 public:
Adrian Suciu 17:b8356808e8ad 11 typedef enum {
Adrian Suciu 17:b8356808e8ad 12 ZERO_SCALE_CALIBRATION, ///< Calibration of the zero scale value
Adrian Suciu 17:b8356808e8ad 13 FULL_SCALE_CALIBRATION, ///< Calibration of the full scale value
Adrian Suciu 17:b8356808e8ad 14 COMPUTE_UNITS_PER_BIT ///< Units per LSB computation
Adrian Suciu 17:b8356808e8ad 15 } CalibrationStep_t;
Adrian Suciu 13:66c8e4ce4ff1 16
Adrian Suciu 17:b8356808e8ad 17 CN0216(PinName CSAD7791 = D8, PinName MOSI = SPI_MOSI, PinName MISO = SPI_MISO, PinName SCK = SPI_SCK);
Adrian Suciu 17:b8356808e8ad 18 void init(float cal_weight = _DEFAULT_CAL_WEIGHT, uint8_t mode_val = _DEFAULT_MODE_VAL, uint8_t filter_val = _DEFAULT_FILTER_VAL);
Adrian Suciu 17:b8356808e8ad 19 void calibrate(CalibrationStep_t cal);
Adrian Suciu 17:b8356808e8ad 20 float compute_weight(uint32_t data);
Adrian Suciu 17:b8356808e8ad 21 uint32_t read_u32();
Adrian Suciu 17:b8356808e8ad 22 float read_weight();
Adrian Suciu 13:66c8e4ce4ff1 23
Adrian Suciu 13:66c8e4ce4ff1 24 private:
Adrian Suciu 13:66c8e4ce4ff1 25
Adrian Suciu 17:b8356808e8ad 26 const static int _NUMBER_OF_SAMPLES = 20; ///< Number of samples used in calibration
Adrian Suciu 17:b8356808e8ad 27 const static int _DEFAULT_MODE_VAL = AD7791::MD1 | AD7791::MD0; // POWERDOWN MODE
Adrian Suciu 17:b8356808e8ad 28 const static int _DEFAULT_FILTER_VAL = AD7791::FS0 | AD7791::FS1 | AD7791::FS2;
Adrian Suciu 17:b8356808e8ad 29 const static int _DEFAULT_CAL_WEIGHT = 1000.0;
Adrian Suciu 13:66c8e4ce4ff1 30
Adrian Suciu 17:b8356808e8ad 31 AD7791 ad7791;
Adrian Suciu 17:b8356808e8ad 32 float _cal_weight;
Adrian Suciu 17:b8356808e8ad 33 uint32_t _zero_scale_value;
Adrian Suciu 17:b8356808e8ad 34 uint32_t _full_scale_value;
Adrian Suciu 17:b8356808e8ad 35 float _weight_units_per_bit;
Adrian Suciu 17:b8356808e8ad 36
Adrian Suciu 13:66c8e4ce4ff1 37 };
Adrian Suciu 13:66c8e4ce4ff1 38
Adrian Suciu 13:66c8e4ce4ff1 39 #endif