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
examples/drvdiag/driver_wrapper/CN0216_Diag.cpp@24:dae7123d432a, 2016-05-18 (annotated)
- Committer:
- Adrian Suciu
- Date:
- Wed May 18 16:57:57 2016 +0300
- Revision:
- 24:dae7123d432a
Improved compatibility with Linux systems
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Adrian Suciu |
24:dae7123d432a | 1 | #include "mbed.h" |
| Adrian Suciu |
24:dae7123d432a | 2 | #include <stdio.h> |
| Adrian Suciu |
24:dae7123d432a | 3 | #include <vector> |
| Adrian Suciu |
24:dae7123d432a | 4 | #include <string> |
| Adrian Suciu |
24:dae7123d432a | 5 | |
| Adrian Suciu |
24:dae7123d432a | 6 | #include "CN0216_Diag.h" |
| Adrian Suciu |
24:dae7123d432a | 7 | |
| Adrian Suciu |
24:dae7123d432a | 8 | extern Serial pc; |
| Adrian Suciu |
24:dae7123d432a | 9 | extern vector<string> cmdbuffer; |
| Adrian Suciu |
24:dae7123d432a | 10 | |
| Adrian Suciu |
24:dae7123d432a | 11 | CN0216_Diag::CN0216_Diag(CN0216& cn) : dut(cn) |
| Adrian Suciu |
24:dae7123d432a | 12 | { |
| Adrian Suciu |
24:dae7123d432a | 13 | |
| Adrian Suciu |
24:dae7123d432a | 14 | } |
| Adrian Suciu |
24:dae7123d432a | 15 | |
| Adrian Suciu |
24:dae7123d432a | 16 | void CN0216_Diag::init(void) |
| Adrian Suciu |
24:dae7123d432a | 17 | { |
| Adrian Suciu |
24:dae7123d432a | 18 | uint16_t weight = strtol(cmdbuffer[1].c_str(), NULL, 10); |
| Adrian Suciu |
24:dae7123d432a | 19 | pc.printf("CN0216 initialized with %d calibration weight", weight); |
| Adrian Suciu |
24:dae7123d432a | 20 | dut.init(weight); |
| Adrian Suciu |
24:dae7123d432a | 21 | } |
| Adrian Suciu |
24:dae7123d432a | 22 | |
| Adrian Suciu |
24:dae7123d432a | 23 | void CN0216_Diag::calibrate(void) |
| Adrian Suciu |
24:dae7123d432a | 24 | { |
| Adrian Suciu |
24:dae7123d432a | 25 | uint8_t step = strtol(cmdbuffer[1].c_str(), NULL, 16); |
| Adrian Suciu |
24:dae7123d432a | 26 | pc.printf("Calibrating step %d ..", step); |
| Adrian Suciu |
24:dae7123d432a | 27 | dut.calibrate(static_cast<CN0216::CalibrationStep_t>(step)); |
| Adrian Suciu |
24:dae7123d432a | 28 | pc.printf(".. DONE", step); |
| Adrian Suciu |
24:dae7123d432a | 29 | } |
| Adrian Suciu |
24:dae7123d432a | 30 | |
| Adrian Suciu |
24:dae7123d432a | 31 | void CN0216_Diag::read_weight(void) |
| Adrian Suciu |
24:dae7123d432a | 32 | { |
| Adrian Suciu |
24:dae7123d432a | 33 | pc.printf("Read weight is %f", dut.read_weight()); |
| Adrian Suciu |
24:dae7123d432a | 34 | } |
| Adrian Suciu |
24:dae7123d432a | 35 |
CN0357 - Toxic gas measurement
CN0216 - Weight Scale