Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
ADS1100.h@3:7c8d1aa80a9d, 2018-07-02 (annotated)
- Committer:
- hongu
- Date:
- Mon Jul 02 13:25:18 2018 +0000
- Revision:
- 3:7c8d1aa80a9d
- Parent:
- 2:7ee26d7e2997
last commit ... maybe
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| hongu | 2:7ee26d7e2997 | 1 | //********************** |
| hongu | 0:b211ff96822b | 2 | // ADS1100.h for mbed |
| hongu | 0:b211ff96822b | 3 | // |
| hongu | 0:b211ff96822b | 4 | // Each ADS1100 is marked with "ADx". |
| hongu | 0:b211ff96822b | 5 | // Please write the 'x' to the "addr" argument. |
| hongu | 0:b211ff96822b | 6 | // |
| hongu | 0:b211ff96822b | 7 | // (C)Copyright 2018 All rights reserved by K.Hongu |
| hongu | 0:b211ff96822b | 8 | //********************** |
| hongu | 0:b211ff96822b | 9 | |
| hongu | 0:b211ff96822b | 10 | #ifndef ADS1100_H_ |
| hongu | 0:b211ff96822b | 11 | #define ADS1100_H_ |
| hongu | 0:b211ff96822b | 12 | |
| hongu | 3:7c8d1aa80a9d | 13 | #define ADS1100_ADDR 0b10010000 |
| hongu | 0:b211ff96822b | 14 | |
| hongu | 0:b211ff96822b | 15 | typedef union { |
| hongu | 2:7ee26d7e2997 | 16 | char UC; |
| hongu | 0:b211ff96822b | 17 | struct { |
| hongu | 3:7c8d1aa80a9d | 18 | unsigned char PGA:2; //GAIN: 00=1, 01=2, 10=4, 11=8 |
| hongu | 3:7c8d1aa80a9d | 19 | unsigned char DR:2; //00=128SPS, 01=32SPS, 10=16SPS, 11=8SPS |
| hongu | 0:b211ff96822b | 20 | unsigned char SC:1; //0=continuous, 1=single |
| hongu | 3:7c8d1aa80a9d | 21 | unsigned char RE:2; //must be 00 |
| hongu | 3:7c8d1aa80a9d | 22 | unsigned char ST:1; //0 |
| hongu | 0:b211ff96822b | 23 | } bit; |
| hongu | 0:b211ff96822b | 24 | } CONFIG; |
| hongu | 0:b211ff96822b | 25 | |
| hongu | 0:b211ff96822b | 26 | typedef union { |
| hongu | 3:7c8d1aa80a9d | 27 | short S; |
| hongu | 0:b211ff96822b | 28 | struct { |
| hongu | 2:7ee26d7e2997 | 29 | char UB; //upper Byte (8bit) |
| hongu | 2:7ee26d7e2997 | 30 | char LB; //lpper Byte (8bit) |
| hongu | 2:7ee26d7e2997 | 31 | } byte; |
| hongu | 0:b211ff96822b | 32 | } RESULT; |
| hongu | 0:b211ff96822b | 33 | |
| hongu | 2:7ee26d7e2997 | 34 | class ADS1100{ |
| hongu | 2:7ee26d7e2997 | 35 | public: |
| hongu | 2:7ee26d7e2997 | 36 | ADS1100 (PinName sda, PinName scl, char addr); |
| hongu | 2:7ee26d7e2997 | 37 | ADS1100 (I2C& p_i2c, char addr); |
| hongu | 2:7ee26d7e2997 | 38 | void init(char addr); |
| hongu | 3:7c8d1aa80a9d | 39 | void init(); |
| hongu | 3:7c8d1aa80a9d | 40 | short get(); |
| hongu | 3:7c8d1aa80a9d | 41 | // char get(); |
| hongu | 2:7ee26d7e2997 | 42 | |
| hongu | 2:7ee26d7e2997 | 43 | protected: |
| hongu | 2:7ee26d7e2997 | 44 | I2C _i2c; |
| hongu | 2:7ee26d7e2997 | 45 | CONFIG config; |
| hongu | 2:7ee26d7e2997 | 46 | RESULT result; |
| hongu | 2:7ee26d7e2997 | 47 | char buf[3]; |
| hongu | 2:7ee26d7e2997 | 48 | char address; |
| hongu | 2:7ee26d7e2997 | 49 | }; |
| hongu | 2:7ee26d7e2997 | 50 | #endif /* ADS1100_H_ */ |