Speed testing IMUs
Dependencies: MadgwickAHRS mbed
Fork of IMU_serial by
TCA9548.h@3:c1902ecb30a7, 2016-10-06 (annotated)
- Committer:
- rctaduio
- Date:
- Thu Oct 06 17:35:14 2016 +0000
- Revision:
- 3:c1902ecb30a7
- Parent:
- 0:80a695ae3cc3
added todo comments
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rctaduio | 0:80a695ae3cc3 | 1 | #ifndef TCA9548_H |
rctaduio | 0:80a695ae3cc3 | 2 | #define TCA9548_H |
rctaduio | 0:80a695ae3cc3 | 3 | |
rctaduio | 0:80a695ae3cc3 | 4 | // Includes |
rctaduio | 0:80a695ae3cc3 | 5 | #include "mbed.h" |
rctaduio | 0:80a695ae3cc3 | 6 | |
rctaduio | 0:80a695ae3cc3 | 7 | |
rctaduio | 0:80a695ae3cc3 | 8 | //Constants |
rctaduio | 0:80a695ae3cc3 | 9 | |
rctaduio | 0:80a695ae3cc3 | 10 | |
rctaduio | 0:80a695ae3cc3 | 11 | |
rctaduio | 0:80a695ae3cc3 | 12 | class TCA9548 |
rctaduio | 0:80a695ae3cc3 | 13 | { |
rctaduio | 0:80a695ae3cc3 | 14 | //data members |
rctaduio | 0:80a695ae3cc3 | 15 | protected: |
rctaduio | 0:80a695ae3cc3 | 16 | |
rctaduio | 0:80a695ae3cc3 | 17 | public: |
rctaduio | 0:80a695ae3cc3 | 18 | |
rctaduio | 0:80a695ae3cc3 | 19 | |
rctaduio | 0:80a695ae3cc3 | 20 | private: |
rctaduio | 0:80a695ae3cc3 | 21 | uint8_t addr; |
rctaduio | 0:80a695ae3cc3 | 22 | |
rctaduio | 0:80a695ae3cc3 | 23 | //functions |
rctaduio | 0:80a695ae3cc3 | 24 | protected: |
rctaduio | 0:80a695ae3cc3 | 25 | |
rctaduio | 0:80a695ae3cc3 | 26 | public: |
rctaduio | 0:80a695ae3cc3 | 27 | |
rctaduio | 0:80a695ae3cc3 | 28 | TCA9548(uint8_t address = 0x70) |
rctaduio | 0:80a695ae3cc3 | 29 | { |
rctaduio | 0:80a695ae3cc3 | 30 | //MBED uses 8 bit address, most devices use 7 bit address, so need to shift |
rctaduio | 0:80a695ae3cc3 | 31 | addr = address << 1; |
rctaduio | 0:80a695ae3cc3 | 32 | } // end of constructor |
rctaduio | 0:80a695ae3cc3 | 33 | |
rctaduio | 0:80a695ae3cc3 | 34 | void setAddr(uint8_t address) |
rctaduio | 0:80a695ae3cc3 | 35 | { |
rctaduio | 0:80a695ae3cc3 | 36 | addr = address; |
rctaduio | 0:80a695ae3cc3 | 37 | } // end of setAddr |
rctaduio | 0:80a695ae3cc3 | 38 | |
rctaduio | 0:80a695ae3cc3 | 39 | void addrSelect(uint8_t ch) |
rctaduio | 0:80a695ae3cc3 | 40 | { |
rctaduio | 0:80a695ae3cc3 | 41 | //address range is 0-7 |
rctaduio | 0:80a695ae3cc3 | 42 | if (ch > 7) return; |
rctaduio | 0:80a695ae3cc3 | 43 | char ch_s[1]; |
rctaduio | 0:80a695ae3cc3 | 44 | ch_s[0] = 1 << ch; |
rctaduio | 0:80a695ae3cc3 | 45 | |
rctaduio | 0:80a695ae3cc3 | 46 | i2c.write(addr, ch_s, 1); |
rctaduio | 0:80a695ae3cc3 | 47 | |
rctaduio | 0:80a695ae3cc3 | 48 | } // end of addrSelect |
rctaduio | 0:80a695ae3cc3 | 49 | |
rctaduio | 0:80a695ae3cc3 | 50 | private: |
rctaduio | 0:80a695ae3cc3 | 51 | |
rctaduio | 0:80a695ae3cc3 | 52 | };// end of class |
rctaduio | 0:80a695ae3cc3 | 53 | |
rctaduio | 0:80a695ae3cc3 | 54 | |
rctaduio | 0:80a695ae3cc3 | 55 | |
rctaduio | 0:80a695ae3cc3 | 56 | |
rctaduio | 0:80a695ae3cc3 | 57 | |
rctaduio | 0:80a695ae3cc3 | 58 | #endif |