Modified for compatibility with Rev.E. hardware
Fork of AkmSensor by
akmsensormanager.h@16:d85be9bafb80, 2017-01-04 (annotated)
- Committer:
- masahikofukasawa
- Date:
- Wed Jan 04 00:52:30 2017 +0000
- Revision:
- 16:d85be9bafb80
- Parent:
- 15:1238993fd75f
- Child:
- 24:1d37438f31a9
- Child:
- 27:41aa9fb23a2f
Rev012. Modified for using the latest BLE_API, nRF51822 and mbed libs.
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" |
masahikofukasawa | 12:c06cd8b76358 | 9 | #include "ble/BLE.h" |
coisme | 2:11fe67783c4c | 10 | #include "mcp342x.h" |
masahikofukasawa | 0:7a00359e701e | 11 | |
masahikofukasawa | 0:7a00359e701e | 12 | #define ANALOG_SENSOR_ID P0_4 |
masahikofukasawa | 0:7a00359e701e | 13 | #define ANALOG_SENSOR_ID_SUB P0_5 |
masahikofukasawa | 0:7a00359e701e | 14 | |
masahikofukasawa | 0:7a00359e701e | 15 | class AkmSensorManager { |
masahikofukasawa | 0:7a00359e701e | 16 | public: |
masahikofukasawa | 0:7a00359e701e | 17 | |
masahikofukasawa | 0:7a00359e701e | 18 | typedef enum { |
masahikofukasawa | 0:7a00359e701e | 19 | SUCCESS = 0, |
masahikofukasawa | 0:7a00359e701e | 20 | ERROR, |
masahikofukasawa | 0:7a00359e701e | 21 | } Status; |
masahikofukasawa | 0:7a00359e701e | 22 | |
masahikofukasawa | 13:d008249f0359 | 23 | AkmSensorManager(SerialNano* com); |
masahikofukasawa | 10:5c69b067d88a | 24 | Status init(uint8_t id, uint8_t subid); |
masahikofukasawa | 13:d008249f0359 | 25 | void setBleUartService(UARTService* service); |
masahikofukasawa | 0:7a00359e701e | 26 | void setEventConnected(); |
masahikofukasawa | 0:7a00359e701e | 27 | void setEventDisconnected(); |
masahikofukasawa | 0:7a00359e701e | 28 | Status commandReceived(char* buf); |
masahikofukasawa | 0:7a00359e701e | 29 | bool isEvent(); |
masahikofukasawa | 0:7a00359e701e | 30 | Status processEvent(); |
masahikofukasawa | 13:d008249f0359 | 31 | char* getSensorName(); |
masahikofukasawa | 13:d008249f0359 | 32 | |
masahikofukasawa | 0:7a00359e701e | 33 | void processCommand(); |
masahikofukasawa | 0:7a00359e701e | 34 | Status throwMessage(const Message *msg); |
masahikofukasawa | 10:5c69b067d88a | 35 | // void releaseTWI(); |
masahikofukasawa | 10:5c69b067d88a | 36 | uint8_t getId(PinName pin, uint8_t bits); |
masahikofukasawa | 0:7a00359e701e | 37 | |
masahikofukasawa | 0:7a00359e701e | 38 | private: |
masahikofukasawa | 0:7a00359e701e | 39 | |
masahikofukasawa | 0:7a00359e701e | 40 | AkmSensor* sensor; |
masahikofukasawa | 0:7a00359e701e | 41 | SerialNano* serial; |
masahikofukasawa | 0:7a00359e701e | 42 | UARTService* uartService; |
masahikofukasawa | 0:7a00359e701e | 43 | Message msg; |
masahikofukasawa | 16:d85be9bafb80 | 44 | Timeout t; |
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 | int16_t getAdcData(MCP342X *mcp3428, MCP342X::AdcChannel ch, MCP342X::SampleSetting s); |
masahikofukasawa | 16:d85be9bafb80 | 59 | void dummyCallbackForCommandReceived(); |
masahikofukasawa | 0:7a00359e701e | 60 | }; |
masahikofukasawa | 0:7a00359e701e | 61 | |
masahikofukasawa | 0:7a00359e701e | 62 | #endif // AKMSENSORMANAGER_H |