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/ad5270/AD5270.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 AD5270.h |
| Suciu |
1:c1f0670bb370 | 3 | * @brief Header file for AD5270 rheostat |
| 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 AD5270_H |
| Suciu |
1:c1f0670bb370 | 10 | #define AD5270_H |
| Suciu |
1:c1f0670bb370 | 11 | |
| Suciu |
1:c1f0670bb370 | 12 | #include "mbed.h" |
| Suciu |
1:c1f0670bb370 | 13 | |
| Suciu |
1:c1f0670bb370 | 14 | /** |
| Suciu |
1:c1f0670bb370 | 15 | * @brief Analog Devices AD5270 SPI Digital Rheostat class |
| Suciu |
1:c1f0670bb370 | 16 | */ |
| Suciu |
1:c1f0670bb370 | 17 | class AD5270 |
| Suciu |
1:c1f0670bb370 | 18 | { |
| Suciu |
1:c1f0670bb370 | 19 | public: |
| Suciu |
1:c1f0670bb370 | 20 | |
| Suciu |
1:c1f0670bb370 | 21 | /// AD5270 commands |
| Suciu |
1:c1f0670bb370 | 22 | typedef enum { |
| Suciu |
1:c1f0670bb370 | 23 | NO_OP = 0x00, ///< No data |
| Suciu |
1:c1f0670bb370 | 24 | NO_OP_cmd = 0x0000, ///< 16 bit no data |
| Suciu |
1:c1f0670bb370 | 25 | WRITE_RDAC = 0x04, ///< Write to the RDAC Register |
| Suciu |
1:c1f0670bb370 | 26 | READ_RDAC = 0x08, ///< Read from the RDAC Register |
| Suciu |
1:c1f0670bb370 | 27 | STORE_50TP = 0x0C, ///< Write to the RDAC to memory |
| Suciu |
1:c1f0670bb370 | 28 | SW_RST = 0x10, ///< Software reset to last memory location |
| Suciu |
1:c1f0670bb370 | 29 | READ_50TP_CONTENTS = 0x14, ///< Read the last memory contents |
| Suciu |
1:c1f0670bb370 | 30 | READ_50TP_ADDRESS = 0x18, ///< Read the last memory address |
| Suciu |
1:c1f0670bb370 | 31 | WRITE_CTRL_REG = 0x1C, ///< Write to the control Register |
| Suciu |
1:c1f0670bb370 | 32 | READ_CTRL_REG = 0x20, ///< Read from the control Register |
| Suciu |
1:c1f0670bb370 | 33 | SW_SHUTDOWN = 0x24, ///< Software shutdown (0) - Normal, (1) - Shutdown |
| Suciu |
1:c1f0670bb370 | 34 | HI_Zupper = 0x80, ///< Get the SDO line ready for High Z |
| Suciu |
1:c1f0670bb370 | 35 | HI_Zlower = 0x01, ///< Puts AD5270 into High Z mode |
| Suciu |
1:c1f0670bb370 | 36 | HI_Z_Cmd = 0x8001 ///< Puts AD5270 into High Z mode*/ |
| Suciu |
1:c1f0670bb370 | 37 | } AD5270Commands_t; |
| Suciu |
1:c1f0670bb370 | 38 | |
| Suciu |
1:c1f0670bb370 | 39 | AD5270(PinName CS=SPI_CS, float max_resistance = 20000.0, PinName MOSI=SPI_MOSI,PinName MISO=SPI_MISO,PinName SCK=SPI_SCK); |
| Suciu |
1:c1f0670bb370 | 40 | void set_SDO_HiZ(void); |
| Suciu |
1:c1f0670bb370 | 41 | void frequency(int hz); |
| Suciu |
1:c1f0670bb370 | 42 | uint16_t calc_RDAC(float resistance); |
| Suciu |
1:c1f0670bb370 | 43 | uint16_t write_cmd(uint8_t command, uint16_t data = 0x00); |
| Suciu |
1:c1f0670bb370 | 44 | uint16_t write_reg(uint16_t data); |
| Suciu |
1:c1f0670bb370 | 45 | float get_max_resistance(void); |
| Suciu |
1:c1f0670bb370 | 46 | |
| Suciu |
1:c1f0670bb370 | 47 | SPI ad5270; ///< SPI instance of the AD5270 |
| Suciu |
1:c1f0670bb370 | 48 | DigitalOut cs; ///< DigitalOut instance for the chipselect of the AD5270 |
| Suciu |
1:c1f0670bb370 | 49 | |
| Suciu |
1:c1f0670bb370 | 50 | private: |
| Suciu |
1:c1f0670bb370 | 51 | const static int _RESET = 0xff; |
| Suciu |
1:c1f0670bb370 | 52 | const static int _DUMMY_BYTE = 0xAA; |
| Suciu |
1:c1f0670bb370 | 53 | float _max_resistance; |
| Suciu |
1:c1f0670bb370 | 54 | }; |
| Suciu |
1:c1f0670bb370 | 55 | |
| Suciu |
1:c1f0670bb370 | 56 | #endif |
CN0357 - Toxic gas measurement
CN0216 - Weight Scale