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 16:19:00 2016 +0300
Revision:
13:66c8e4ce4ff1
Child:
17:b8356808e8ad
Added driver for AD7791 and example for CN0216

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Adrian Suciu 13:66c8e4ce4ff1 1 #include "mbed.h"
Adrian Suciu 13:66c8e4ce4ff1 2 #include <stdio.h>
Adrian Suciu 13:66c8e4ce4ff1 3 #include <vector>
Adrian Suciu 13:66c8e4ce4ff1 4 #include <string>
Adrian Suciu 13:66c8e4ce4ff1 5
Adrian Suciu 13:66c8e4ce4ff1 6 #include "cn0216_diag.h"
Adrian Suciu 13:66c8e4ce4ff1 7
Adrian Suciu 13:66c8e4ce4ff1 8 extern Serial pc;
Adrian Suciu 13:66c8e4ce4ff1 9 extern vector<string> cmdbuffer;
Adrian Suciu 13:66c8e4ce4ff1 10
Adrian Suciu 13:66c8e4ce4ff1 11 CN0216_Diag::CN0216_Diag(CN0216& cn) : dut(cn)
Adrian Suciu 13:66c8e4ce4ff1 12 {
Adrian Suciu 13:66c8e4ce4ff1 13
Adrian Suciu 13:66c8e4ce4ff1 14 }
Adrian Suciu 13:66c8e4ce4ff1 15
Adrian Suciu 13:66c8e4ce4ff1 16 void CN0216_Diag::init(void)
Adrian Suciu 13:66c8e4ce4ff1 17 {
Adrian Suciu 13:66c8e4ce4ff1 18 uint16_t weight = strtol(cmdbuffer[1].c_str(), NULL, 10);
Adrian Suciu 13:66c8e4ce4ff1 19 pc.printf("CN0216 initialized with %d calibration weight",weight);
Adrian Suciu 13:66c8e4ce4ff1 20 dut.init(weight);
Adrian Suciu 13:66c8e4ce4ff1 21 }
Adrian Suciu 13:66c8e4ce4ff1 22
Adrian Suciu 13:66c8e4ce4ff1 23 void CN0216_Diag::calibrate(void)
Adrian Suciu 13:66c8e4ce4ff1 24 {
Adrian Suciu 13:66c8e4ce4ff1 25 uint8_t step = strtol(cmdbuffer[1].c_str(), NULL, 16);
Adrian Suciu 13:66c8e4ce4ff1 26 pc.printf("Calibrating step %d ..",step);
Adrian Suciu 13:66c8e4ce4ff1 27 dut.calibrate(static_cast<CN0216::CalibrationStep_t>(step));
Adrian Suciu 13:66c8e4ce4ff1 28 pc.printf(".. DONE",step);
Adrian Suciu 13:66c8e4ce4ff1 29 }
Adrian Suciu 13:66c8e4ce4ff1 30
Adrian Suciu 13:66c8e4ce4ff1 31 void CN0216_Diag::read_weight(void)
Adrian Suciu 13:66c8e4ce4ff1 32 {
Adrian Suciu 13:66c8e4ce4ff1 33 pc.printf("Read weight is %f", dut.read_weight());
Adrian Suciu 13:66c8e4ce4ff1 34 }
Adrian Suciu 13:66c8e4ce4ff1 35