Modified for compatibility with Rev.E. hardware
Fork of AkmSensor by
akmsensormanager.h@29:b488d2c89fba, 2017-03-17 (annotated)
- Committer:
- masahikofukasawa
- Date:
- Fri Mar 17 23:29:20 2017 +0000
- Revision:
- 29:b488d2c89fba
- Parent:
- 27:41aa9fb23a2f
- Child:
- 34:1ea3357c8d9a
Modified for multi sensor demo.
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 | 29:b488d2c89fba | 11 | #include "akmakd.h" |
masahikofukasawa | 0:7a00359e701e | 12 | |
masahikofukasawa | 0:7a00359e701e | 13 | #define ANALOG_SENSOR_ID P0_4 |
masahikofukasawa | 0:7a00359e701e | 14 | #define ANALOG_SENSOR_ID_SUB P0_5 |
masahikofukasawa | 29:b488d2c89fba | 15 | #define MAX_SENSOR_NUM 2 |
masahikofukasawa | 0:7a00359e701e | 16 | |
masahikofukasawa | 0:7a00359e701e | 17 | class AkmSensorManager { |
masahikofukasawa | 29:b488d2c89fba | 18 | |
masahikofukasawa | 29:b488d2c89fba | 19 | public: |
masahikofukasawa | 0:7a00359e701e | 20 | |
masahikofukasawa | 0:7a00359e701e | 21 | typedef enum { |
masahikofukasawa | 0:7a00359e701e | 22 | SUCCESS = 0, |
masahikofukasawa | 0:7a00359e701e | 23 | ERROR, |
masahikofukasawa | 0:7a00359e701e | 24 | } Status; |
masahikofukasawa | 0:7a00359e701e | 25 | |
masahikofukasawa | 13:d008249f0359 | 26 | AkmSensorManager(SerialNano* com); |
masahikofukasawa | 10:5c69b067d88a | 27 | Status init(uint8_t id, uint8_t subid); |
masahikofukasawa | 13:d008249f0359 | 28 | void setBleUartService(UARTService* service); |
masahikofukasawa | 0:7a00359e701e | 29 | void setEventConnected(); |
masahikofukasawa | 0:7a00359e701e | 30 | void setEventDisconnected(); |
masahikofukasawa | 0:7a00359e701e | 31 | Status commandReceived(char* buf); |
masahikofukasawa | 0:7a00359e701e | 32 | bool isEvent(); |
masahikofukasawa | 0:7a00359e701e | 33 | Status processEvent(); |
masahikofukasawa | 13:d008249f0359 | 34 | char* getSensorName(); |
masahikofukasawa | 13:d008249f0359 | 35 | |
masahikofukasawa | 0:7a00359e701e | 36 | void processCommand(); |
masahikofukasawa | 0:7a00359e701e | 37 | Status throwMessage(const Message *msg); |
masahikofukasawa | 10:5c69b067d88a | 38 | // void releaseTWI(); |
masahikofukasawa | 10:5c69b067d88a | 39 | uint8_t getId(PinName pin, uint8_t bits); |
masahikofukasawa | 29:b488d2c89fba | 40 | void detectDRDY(); |
masahikofukasawa | 29:b488d2c89fba | 41 | |
masahikofukasawa | 29:b488d2c89fba | 42 | private: |
masahikofukasawa | 0:7a00359e701e | 43 | |
masahikofukasawa | 27:41aa9fb23a2f | 44 | AkmSensor* sensor[MAX_SENSOR_NUM]; |
masahikofukasawa | 0:7a00359e701e | 45 | SerialNano* serial; |
masahikofukasawa | 0:7a00359e701e | 46 | UARTService* uartService; |
masahikofukasawa | 0:7a00359e701e | 47 | Message msg; |
masahikofukasawa | 16:d85be9bafb80 | 48 | Timeout t; |
masahikofukasawa | 0:7a00359e701e | 49 | |
masahikofukasawa | 29:b488d2c89fba | 50 | InterruptIn* interrupt; |
masahikofukasawa | 29:b488d2c89fba | 51 | |
masahikofukasawa | 10:5c69b067d88a | 52 | uint8_t primaryId; |
masahikofukasawa | 0:7a00359e701e | 53 | uint8_t subId; |
masahikofukasawa | 29:b488d2c89fba | 54 | uint8_t sensorIndex; |
masahikofukasawa | 29:b488d2c89fba | 55 | uint8_t sensorNum; |
masahikofukasawa | 0:7a00359e701e | 56 | bool isEnabledBle; |
masahikofukasawa | 0:7a00359e701e | 57 | bool isEnabledUsb; |
masahikofukasawa | 29:b488d2c89fba | 58 | |
masahikofukasawa | 0:7a00359e701e | 59 | bool eventCommandReceived; |
masahikofukasawa | 0:7a00359e701e | 60 | bool eventConnected; |
masahikofukasawa | 0:7a00359e701e | 61 | bool eventDisconnected; |
masahikofukasawa | 29:b488d2c89fba | 62 | char userCommand[20]; |
masahikofukasawa | 0:7a00359e701e | 63 | |
masahikofukasawa | 29:b488d2c89fba | 64 | AkmAkd::InterruptMode drdyType; |
masahikofukasawa | 0:7a00359e701e | 65 | |
masahikofukasawa | 27:41aa9fb23a2f | 66 | bool checkAkmSensor(); |
masahikofukasawa | 0:7a00359e701e | 67 | void dataOut(char* str); |
coisme | 2:11fe67783c4c | 68 | int16_t getAdcData(MCP342X *mcp3428, MCP342X::AdcChannel ch, MCP342X::SampleSetting s); |
masahikofukasawa | 16:d85be9bafb80 | 69 | void dummyCallbackForCommandReceived(); |
masahikofukasawa | 27:41aa9fb23a2f | 70 | char* my_strcat(char* str1, char* str2); |
masahikofukasawa | 0:7a00359e701e | 71 | }; |
masahikofukasawa | 0:7a00359e701e | 72 | |
masahikofukasawa | 0:7a00359e701e | 73 | #endif // AKMSENSORMANAGER_H |