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
libraries/cn0357/cn0357.h@1:c1f0670bb370, 2016-03-30 (annotated)
- Committer:
- Suciu
- Date:
- Wed Mar 30 17:35:04 2016 +0300
- Revision:
- 1:c1f0670bb370
- Child:
- 3:1a8c14043a4e
Added CN0357-example project and related drivers
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Suciu |
1:c1f0670bb370 | 1 | /** |
| Suciu |
1:c1f0670bb370 | 2 | * @file CN0357.h |
| Suciu |
1:c1f0670bb370 | 3 | * @brief Header file for CN0357 toxic gas sensor shield |
| Suciu |
1:c1f0670bb370 | 4 | * @version V0.1 |
| Suciu |
1:c1f0670bb370 | 5 | * @author ADI |
| Suciu |
1:c1f0670bb370 | 6 | * @date March 2015 |
| Suciu |
1:c1f0670bb370 | 7 | **/ |
| Suciu |
1:c1f0670bb370 | 8 | |
| Suciu |
1:c1f0670bb370 | 9 | #ifndef CN0357_H |
| Suciu |
1:c1f0670bb370 | 10 | #define CN0357_H |
| Suciu |
1:c1f0670bb370 | 11 | |
| Suciu |
1:c1f0670bb370 | 12 | #include "mbed.h" |
| Suciu |
1:c1f0670bb370 | 13 | #include "ad7790.h" |
| Suciu |
1:c1f0670bb370 | 14 | #include "ad5270.h" |
| Suciu |
1:c1f0670bb370 | 15 | |
| Suciu |
1:c1f0670bb370 | 16 | /** |
| Suciu |
1:c1f0670bb370 | 17 | * @brief EVAL-CN0357 toxic gas sensor shield |
| Suciu |
1:c1f0670bb370 | 18 | */ |
| Suciu |
1:c1f0670bb370 | 19 | class CN0357 |
| Suciu |
1:c1f0670bb370 | 20 | { |
| Suciu |
1:c1f0670bb370 | 21 | public: |
| Suciu |
1:c1f0670bb370 | 22 | |
| Suciu |
1:c1f0670bb370 | 23 | /// CN0357 shield jumper configuration |
| Suciu |
1:c1f0670bb370 | 24 | typedef enum { |
| Suciu |
1:c1f0670bb370 | 25 | INTERNAL_AD7790 = 0, ///< The shield's AD7790 is used |
| Suciu |
1:c1f0670bb370 | 26 | EXTERNAL_ADC ///< Sensor analog output is routed to A1 pin of the shield |
| Suciu |
1:c1f0670bb370 | 27 | } JumperConfig_t; |
| Suciu |
1:c1f0670bb370 | 28 | |
| Suciu |
1:c1f0670bb370 | 29 | CN0357(PinName CSAD7790=D8, PinName CSAD5270=D6, PinName MOSI=SPI_MOSI,PinName MISO=SPI_MISO,PinName SCK=SPI_SCK); |
| Suciu |
1:c1f0670bb370 | 30 | void init(float range, float sensitivity,JumperConfig_t jp = INTERNAL_AD7790, uint8_t mode_val = _DEFAULT_MODE_VAL, uint8_t filter_val = _DEFAULT_FILTER_VAL); |
| Suciu |
1:c1f0670bb370 | 31 | |
| Suciu |
1:c1f0670bb370 | 32 | uint8_t read_adc_status(void); |
| Suciu |
1:c1f0670bb370 | 33 | uint16_t read_sensor(void); |
| Suciu |
1:c1f0670bb370 | 34 | float read_sensor_voltage(void); |
| Suciu |
1:c1f0670bb370 | 35 | float data_to_voltage(uint16_t data); |
| Suciu |
1:c1f0670bb370 | 36 | float calc_ppm(float adcVoltage); |
| Suciu |
1:c1f0670bb370 | 37 | float read_ppm(void); |
| Suciu |
1:c1f0670bb370 | 38 | |
| Suciu |
1:c1f0670bb370 | 39 | void set_RDAC_value(float resistor_val); |
| Suciu |
1:c1f0670bb370 | 40 | float get_RDAC_value(void); |
| Suciu |
1:c1f0670bb370 | 41 | float set_sensor_parameters(float range, float sensitivity); |
| Suciu |
1:c1f0670bb370 | 42 | float get_sensor_range(void); |
| Suciu |
1:c1f0670bb370 | 43 | float get_sensor_sensitivity(void); |
| Suciu |
1:c1f0670bb370 | 44 | |
| Suciu |
1:c1f0670bb370 | 45 | |
| Suciu |
1:c1f0670bb370 | 46 | AD7790 ad7790; ///< AD7790 instance - can be used for manual overriding |
| Suciu |
1:c1f0670bb370 | 47 | AD5270 ad5270; ///< AD5270 instance - can be used for manual overriding |
| Suciu |
1:c1f0670bb370 | 48 | |
| Suciu |
1:c1f0670bb370 | 49 | private: |
| Suciu |
1:c1f0670bb370 | 50 | const static int _RESET = 0xff; |
| Suciu |
1:c1f0670bb370 | 51 | const static int _DEFAULT_MODE_VAL = 0x00; |
| Suciu |
1:c1f0670bb370 | 52 | const static int _DEFAULT_FILTER_VAL = 0x07; |
| Suciu |
1:c1f0670bb370 | 53 | float _sensor_sensitivity; |
| Suciu |
1:c1f0670bb370 | 54 | float _sensor_range; |
| Suciu |
1:c1f0670bb370 | 55 | float _RDACvalue; |
| Suciu |
1:c1f0670bb370 | 56 | void _rdac_init(float resistanceValue); |
| Suciu |
1:c1f0670bb370 | 57 | void _AD7790_init(uint8_t mode_val, uint8_t filter_val); |
| Suciu |
1:c1f0670bb370 | 58 | |
| Suciu |
1:c1f0670bb370 | 59 | |
| Suciu |
1:c1f0670bb370 | 60 | }; |
| Suciu |
1:c1f0670bb370 | 61 | |
| Suciu |
1:c1f0670bb370 | 62 | #endif // CN0357_H |
CN0357 - Toxic gas measurement
CN0216 - Weight Scale