GDP group 24 node core
Dependencies: EthernetInterface SDFileSystem mbed-rtos mbed snail MbedJSONValue
sensorinterface.h
- Committer:
- jakehodges
- Date:
- 2015-01-13
- Revision:
- 14:bc0e2fa25f94
- Parent:
- 8:fd531fe7637b
- Child:
- 16:3ac37613f849
- Child:
- 18:e68c8551d12c
File content as of revision 14:bc0e2fa25f94:
#ifndef SENSORINTERFACE_H #define SENSORINTERFACE_H #include "mbed.h" #include <map> #include <vector> #define I2C_TYPE_HEADER 'T' #define I2C_TYPE_REQUEST 'R' #define I2C_TYPE_DATA 'D' #define I2C_TYPE_PACKET_SIZE 4 #define DEBUG struct sensor { char type; char packetSize; char readingSize; }; struct d_reply { char type; vector<char> readings; }; class sensorinterface { public: map<char, sensor> sensors; sensorinterface(); void requestData(); bool isDataWaiting(); d_reply readData(); private: map<char, sensor>::iterator currentSensor; int update(); void error(int); sensor& findType(sensor& s, int address); int sendRequest(char address); void readySet(); void readyUnset(); bool ready; I2C i2c; InterruptIn readyLine; }; #endif