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/cn0357_diag.cpp@7:b62398a1d17a, 2016-04-20 (annotated)
- Committer:
- Adrian Suciu
- Date:
- Wed Apr 20 16:35:44 2016 +0300
- Revision:
- 7:b62398a1d17a
- Child:
- 8:6e96c6b3c83f
Added drvdiag tool
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Adrian Suciu |
7:b62398a1d17a | 1 | #include "mbed.h" |
| Adrian Suciu |
7:b62398a1d17a | 2 | #include <stdio.h> |
| Adrian Suciu |
7:b62398a1d17a | 3 | #include <vector> |
| Adrian Suciu |
7:b62398a1d17a | 4 | #include <string> |
| Adrian Suciu |
7:b62398a1d17a | 5 | #include "CN0357_Diag.h" |
| Adrian Suciu |
7:b62398a1d17a | 6 | |
| Adrian Suciu |
7:b62398a1d17a | 7 | extern Serial pc; |
| Adrian Suciu |
7:b62398a1d17a | 8 | extern vector<string> cmdbuffer; |
| Adrian Suciu |
7:b62398a1d17a | 9 | |
| Adrian Suciu |
7:b62398a1d17a | 10 | CN0357_Diag::CN0357_Diag(CN0357& cn) : dut(cn) |
| Adrian Suciu |
7:b62398a1d17a | 11 | { |
| Adrian Suciu |
7:b62398a1d17a | 12 | |
| Adrian Suciu |
7:b62398a1d17a | 13 | } |
| Adrian Suciu |
7:b62398a1d17a | 14 | void CN0357_Diag::set_RDAC() |
| Adrian Suciu |
7:b62398a1d17a | 15 | { |
| Adrian Suciu |
7:b62398a1d17a | 16 | float res = strtof(cmdbuffer[1].c_str(), NULL); |
| Adrian Suciu |
7:b62398a1d17a | 17 | dut.set_RDAC_value(res); |
| Adrian Suciu |
7:b62398a1d17a | 18 | pc.printf("Wrote %f", res); |
| Adrian Suciu |
7:b62398a1d17a | 19 | |
| Adrian Suciu |
7:b62398a1d17a | 20 | } |
| Adrian Suciu |
7:b62398a1d17a | 21 | void CN0357_Diag::read_ppm(void) |
| Adrian Suciu |
7:b62398a1d17a | 22 | { |
| Adrian Suciu |
7:b62398a1d17a | 23 | pc.printf("Wrote %f", dut.read_ppm()); |
| Adrian Suciu |
7:b62398a1d17a | 24 | } |
| Adrian Suciu |
7:b62398a1d17a | 25 | |
| Adrian Suciu |
7:b62398a1d17a | 26 | void CN0357_Diag::set_sensor_param(void) |
| Adrian Suciu |
7:b62398a1d17a | 27 | { |
| Adrian Suciu |
7:b62398a1d17a | 28 | float range = strtof(cmdbuffer[1].c_str(), NULL); |
| Adrian Suciu |
7:b62398a1d17a | 29 | float sens = strtof(cmdbuffer[2].c_str(), NULL); |
| Adrian Suciu |
7:b62398a1d17a | 30 | sens = sens * pow(10, -9); |
| Adrian Suciu |
7:b62398a1d17a | 31 | pc.printf("Suggested RDAC val: %f ", dut.set_sensor_parameters(range, sens)); |
| Adrian Suciu |
7:b62398a1d17a | 32 | } |
CN0357 - Toxic gas measurement
CN0216 - Weight Scale