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@2:7ee26d7e2997, 2018-06-20 (annotated)
- Committer:
- hongu
- Date:
- Wed Jun 20 07:05:53 2018 +0000
- Revision:
- 2:7ee26d7e2997
- Parent:
- 0:b211ff96822b
- Child:
- 3:7c8d1aa80a9d
avoid from errors;
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 | 0:b211ff96822b | 13 | #define ADS1100_ADDR 0b1001 |
| hongu | 0:b211ff96822b | 14 | |
| hongu | 0:b211ff96822b | 15 | typedef union { |
| hongu | 2:7ee26d7e2997 | 16 | char UC; |
| hongu | 0:b211ff96822b | 17 | struct { |
| hongu | 0:b211ff96822b | 18 | unsigned char ST:1; //0 |
| hongu | 0:b211ff96822b | 19 | unsigned char RE:2; //must be 00 |
| hongu | 0:b211ff96822b | 20 | unsigned char SC:1; //0=continuous, 1=single |
| hongu | 0:b211ff96822b | 21 | unsigned char DR:2; //00=128SPS, 01=32SPS, 10=16SPS, 11=8SPS |
| hongu | 0:b211ff96822b | 22 | unsigned char PGA:2; //GAIN: 00=1, 01=2, 10=4, 11=8 |
| hongu | 0:b211ff96822b | 23 | } bit; |
| hongu | 0:b211ff96822b | 24 | } CONFIG; |
| hongu | 0:b211ff96822b | 25 | |
| hongu | 0:b211ff96822b | 26 | typedef union { |
| hongu | 0:b211ff96822b | 27 | uint16_t 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 | 2:7ee26d7e2997 | 39 | uint16_t get(); |
| hongu | 2:7ee26d7e2997 | 40 | |
| hongu | 2:7ee26d7e2997 | 41 | protected: |
| hongu | 2:7ee26d7e2997 | 42 | I2C _i2c; |
| hongu | 2:7ee26d7e2997 | 43 | CONFIG config; |
| hongu | 2:7ee26d7e2997 | 44 | RESULT result; |
| hongu | 2:7ee26d7e2997 | 45 | char buf[3]; |
| hongu | 2:7ee26d7e2997 | 46 | char address; |
| hongu | 2:7ee26d7e2997 | 47 | }; |
| hongu | 2:7ee26d7e2997 | 48 | #endif /* ADS1100_H_ */ |