Modified for compatibility with Rev.E. hardware
Fork of AkmSensor by
akmsensormanager.h@11:cef8dc1cf010, 2016-07-22 (annotated)
- Committer:
- masahikofukasawa
- Date:
- Fri Jul 22 22:54:11 2016 +0000
- Revision:
- 11:cef8dc1cf010
- Parent:
- 10:5c69b067d88a
- Child:
- 12:c06cd8b76358
RevD7_004
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
masahikofukasawa | 0:7a00359e701e | 1 | #ifndef AKMSENSORMANAGER_H |
masahikofukasawa | 0:7a00359e701e | 2 | #define AKMSENSORMANAGER_H |
masahikofukasawa | 0:7a00359e701e | 3 | |
masahikofukasawa | 0:7a00359e701e | 4 | #include "mbed.h" |
masahikofukasawa | 0:7a00359e701e | 5 | #include "SerialNano.h" |
masahikofukasawa | 0:7a00359e701e | 6 | #include "akmsensor.h" |
masahikofukasawa | 0:7a00359e701e | 7 | #include "Message.h" |
coisme | 2:11fe67783c4c | 8 | #include "debug.h" |
coisme | 2:11fe67783c4c | 9 | |
coisme | 2:11fe67783c4c | 10 | #ifdef REV_D |
coisme | 2:11fe67783c4c | 11 | #include "mcp342x.h" |
coisme | 2:11fe67783c4c | 12 | #endif |
masahikofukasawa | 0:7a00359e701e | 13 | |
masahikofukasawa | 0:7a00359e701e | 14 | #define ANALOG_SENSOR_ID P0_4 |
masahikofukasawa | 0:7a00359e701e | 15 | #define ANALOG_SENSOR_ID_SUB P0_5 |
masahikofukasawa | 0:7a00359e701e | 16 | |
masahikofukasawa | 0:7a00359e701e | 17 | class AkmSensorManager { |
masahikofukasawa | 0:7a00359e701e | 18 | public: |
masahikofukasawa | 0:7a00359e701e | 19 | |
masahikofukasawa | 0:7a00359e701e | 20 | typedef enum { |
masahikofukasawa | 0:7a00359e701e | 21 | SUCCESS = 0, |
masahikofukasawa | 0:7a00359e701e | 22 | ERROR, |
masahikofukasawa | 0:7a00359e701e | 23 | } Status; |
masahikofukasawa | 0:7a00359e701e | 24 | |
masahikofukasawa | 0:7a00359e701e | 25 | AkmSensorManager(SerialNano* com, UARTService* service); |
masahikofukasawa | 10:5c69b067d88a | 26 | Status init(uint8_t id, uint8_t subid); |
masahikofukasawa | 0:7a00359e701e | 27 | void setEventConnected(); |
masahikofukasawa | 0:7a00359e701e | 28 | void setEventDisconnected(); |
masahikofukasawa | 0:7a00359e701e | 29 | Status commandReceived(char* buf); |
masahikofukasawa | 0:7a00359e701e | 30 | bool isEvent(); |
masahikofukasawa | 0:7a00359e701e | 31 | Status processEvent(); |
masahikofukasawa | 0:7a00359e701e | 32 | |
masahikofukasawa | 0:7a00359e701e | 33 | |
masahikofukasawa | 0:7a00359e701e | 34 | void processCommand(); |
masahikofukasawa | 0:7a00359e701e | 35 | Status throwMessage(const Message *msg); |
masahikofukasawa | 10:5c69b067d88a | 36 | // void releaseTWI(); |
masahikofukasawa | 10:5c69b067d88a | 37 | uint8_t getId(PinName pin, uint8_t bits); |
masahikofukasawa | 0:7a00359e701e | 38 | |
masahikofukasawa | 0:7a00359e701e | 39 | private: |
masahikofukasawa | 0:7a00359e701e | 40 | |
masahikofukasawa | 0:7a00359e701e | 41 | AkmSensor* sensor; |
masahikofukasawa | 0:7a00359e701e | 42 | SerialNano* serial; |
masahikofukasawa | 0:7a00359e701e | 43 | UARTService* uartService; |
masahikofukasawa | 0:7a00359e701e | 44 | Message msg; |
masahikofukasawa | 0:7a00359e701e | 45 | |
masahikofukasawa | 10:5c69b067d88a | 46 | uint8_t primaryId; |
masahikofukasawa | 0:7a00359e701e | 47 | uint8_t subId; |
masahikofukasawa | 0:7a00359e701e | 48 | bool isEnabledBle; |
masahikofukasawa | 0:7a00359e701e | 49 | bool isEnabledUsb; |
masahikofukasawa | 0:7a00359e701e | 50 | bool eventCommandReceived; |
masahikofukasawa | 0:7a00359e701e | 51 | bool eventConnected; |
masahikofukasawa | 0:7a00359e701e | 52 | bool eventDisconnected; |
masahikofukasawa | 0:7a00359e701e | 53 | |
masahikofukasawa | 0:7a00359e701e | 54 | char userCommand[20]; |
masahikofukasawa | 0:7a00359e701e | 55 | |
masahikofukasawa | 0:7a00359e701e | 56 | AkmSensor* getAkmSensor(); |
masahikofukasawa | 0:7a00359e701e | 57 | void dataOut(char* str); |
coisme | 2:11fe67783c4c | 58 | |
coisme | 2:11fe67783c4c | 59 | #ifdef REV_D |
coisme | 2:11fe67783c4c | 60 | int16_t getAdcData(MCP342X *mcp3428, MCP342X::AdcChannel ch, MCP342X::SampleSetting s); |
coisme | 2:11fe67783c4c | 61 | #endif |
masahikofukasawa | 0:7a00359e701e | 62 | }; |
masahikofukasawa | 0:7a00359e701e | 63 | |
masahikofukasawa | 0:7a00359e701e | 64 | #endif // AKMSENSORMANAGER_H |