GDP group 24 node core
Dependencies: EthernetInterface SDFileSystem mbed-rtos mbed snail MbedJSONValue
sensorinterface.h@14:bc0e2fa25f94, 2015-01-13 (annotated)
- Committer:
- jakehodges
- Date:
- Tue Jan 13 22:48:25 2015 +0000
- Revision:
- 14:bc0e2fa25f94
- Parent:
- 8:fd531fe7637b
- Child:
- 16:3ac37613f849
- Child:
- 18:e68c8551d12c
Implement individual reading size. Add readyLine.rise interrupt.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Trumple | 0:fcab3b154e49 | 1 | #ifndef SENSORINTERFACE_H |
Trumple | 0:fcab3b154e49 | 2 | |
Trumple | 0:fcab3b154e49 | 3 | #define SENSORINTERFACE_H |
Trumple | 0:fcab3b154e49 | 4 | |
Trumple | 0:fcab3b154e49 | 5 | #include "mbed.h" |
Trumple | 0:fcab3b154e49 | 6 | #include <map> |
Trumple | 0:fcab3b154e49 | 7 | #include <vector> |
Trumple | 0:fcab3b154e49 | 8 | |
jakehodges | 14:bc0e2fa25f94 | 9 | #define I2C_TYPE_HEADER 'T' |
jakehodges | 14:bc0e2fa25f94 | 10 | #define I2C_TYPE_REQUEST 'R' |
jakehodges | 14:bc0e2fa25f94 | 11 | #define I2C_TYPE_DATA 'D' |
jakehodges | 14:bc0e2fa25f94 | 12 | #define I2C_TYPE_PACKET_SIZE 4 |
jakehodges | 14:bc0e2fa25f94 | 13 | |
Trumple | 0:fcab3b154e49 | 14 | #define DEBUG |
Trumple | 0:fcab3b154e49 | 15 | |
Trumple | 0:fcab3b154e49 | 16 | struct sensor |
Trumple | 0:fcab3b154e49 | 17 | { |
Trumple | 0:fcab3b154e49 | 18 | char type; |
jakehodges | 14:bc0e2fa25f94 | 19 | char packetSize; |
jakehodges | 3:71b090ec5c69 | 20 | char readingSize; |
Trumple | 0:fcab3b154e49 | 21 | }; |
Trumple | 0:fcab3b154e49 | 22 | |
Trumple | 0:fcab3b154e49 | 23 | |
Trumple | 0:fcab3b154e49 | 24 | struct d_reply |
Trumple | 0:fcab3b154e49 | 25 | { |
Trumple | 0:fcab3b154e49 | 26 | char type; |
jakehodges | 3:71b090ec5c69 | 27 | vector<char> readings; |
Trumple | 0:fcab3b154e49 | 28 | }; |
Trumple | 0:fcab3b154e49 | 29 | |
Trumple | 0:fcab3b154e49 | 30 | |
Trumple | 0:fcab3b154e49 | 31 | class sensorinterface |
Trumple | 0:fcab3b154e49 | 32 | { |
Trumple | 0:fcab3b154e49 | 33 | public: |
Trumple | 8:fd531fe7637b | 34 | map<char, sensor> sensors; |
Trumple | 0:fcab3b154e49 | 35 | sensorinterface(); |
Trumple | 0:fcab3b154e49 | 36 | void requestData(); |
Trumple | 0:fcab3b154e49 | 37 | bool isDataWaiting(); |
Trumple | 0:fcab3b154e49 | 38 | d_reply readData(); |
Trumple | 0:fcab3b154e49 | 39 | private: |
Trumple | 0:fcab3b154e49 | 40 | map<char, sensor>::iterator currentSensor; |
Trumple | 0:fcab3b154e49 | 41 | int update(); |
Trumple | 0:fcab3b154e49 | 42 | void error(int); |
jakehodges | 3:71b090ec5c69 | 43 | sensor& findType(sensor& s, int address); |
Trumple | 0:fcab3b154e49 | 44 | int sendRequest(char address); |
jakehodges | 14:bc0e2fa25f94 | 45 | void readySet(); |
jakehodges | 14:bc0e2fa25f94 | 46 | void readyUnset(); |
Trumple | 0:fcab3b154e49 | 47 | bool ready; |
Trumple | 0:fcab3b154e49 | 48 | |
Trumple | 0:fcab3b154e49 | 49 | I2C i2c; |
Trumple | 0:fcab3b154e49 | 50 | InterruptIn readyLine; |
Trumple | 0:fcab3b154e49 | 51 | }; |
Trumple | 0:fcab3b154e49 | 52 | #endif |