ADS1100 I2C 16bit ADC driver
Embed:
(wiki syntax)
Show/hide line numbers
ADS1100.h
00001 #ifndef ADS1100_H 00002 #define ADS1100_H 00003 00004 #include "mbed.h" 00005 00006 class ADS1100{ 00007 00008 public: 00009 enum state{ 00010 I2C_ADDR = 0x90, //I2C adress 00011 }; 00012 00013 00014 /** Create ADC1100 instance 00015 * @param *i2c initialized I2C bus to use 00016 * @param ad <0,7> marking code number for addr 00017 */ 00018 ADS1100(I2C* i2c, char ad); 00019 00020 /** Read outputCode 00021 * @return signed 16bit output code 00022 */ 00023 short read_s16(void); 00024 00025 /** Read output 00026 * @param vdd proportional factor defualt=1.0 00027 * @return vdd*code/codemax*gain 00028 */ 00029 float read(float vdd=1.0); 00030 00031 /** Configure ADS1100 00032 * @param single true for single converion mode false for continuous 00033 * @param rate can be 8,16,32,128 sample per sencods 00034 * @param gain can be 1,2,4,8 00035 */ 00036 void config(bool single, char rate, char gain); 00037 00038 /** Read registers 00039 * @param output cofig reg 00040 * @return s16 code 00041 */ 00042 short readReg(char* config); 00043 00044 /** Initiate a conversion (single mode) 00045 */ 00046 void startConvert(void); 00047 00048 /** Check if converstion finished (continuous mode) 00049 * @return bool true if busy 00050 */ 00051 bool busy(void); 00052 00053 private: 00054 I2C* _i2c; 00055 char _addr; 00056 char _config; 00057 short _minCode; 00058 char _gain; 00059 }; 00060 00061 #endif
Generated on Wed Jul 13 2022 14:22:43 by 1.7.2