A collection of Analog Devices drivers for the mbed platform

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers CN0216_Diag.cpp Source File

CN0216_Diag.cpp

00001 #include "mbed.h"
00002 #include <stdio.h>
00003 #include <vector>
00004 #include <string>
00005 
00006 #include "CN0216_Diag.h"
00007 
00008 extern Serial pc;
00009 extern vector<string> cmdbuffer;
00010 
00011 CN0216_Diag::CN0216_Diag(CN0216& cn) : dut(cn)
00012 {
00013 
00014 }
00015 
00016 void CN0216_Diag::init(void)
00017 {
00018     uint16_t weight = strtol(cmdbuffer[1].c_str(), NULL, 10);
00019     pc.printf("CN0216 initialized with %d calibration weight", weight);
00020     dut.init(weight);
00021 }
00022 
00023 void CN0216_Diag::calibrate(void)
00024 {
00025     uint8_t step = strtol(cmdbuffer[1].c_str(), NULL, 16);
00026     pc.printf("Calibrating step %d ..", step);
00027     dut.calibrate(static_cast<CN0216::CalibrationStep_t>(step));
00028     pc.printf(".. DONE", step);
00029 }
00030 
00031 void CN0216_Diag::read_weight(void)
00032 {
00033     pc.printf("Read weight is %f", dut.read_weight());
00034 }
00035