Modified for compatibility with Rev.E. hardware

Fork of AkmSensor by AKM Development Platform

Committer:
masahikofukasawa
Date:
Fri Aug 12 00:04:48 2016 +0000
Revision:
13:d008249f0359
Parent:
12:c06cd8b76358
Child:
15:1238993fd75f
Ver008. Modified for faster BLE connection, and sensor name in the BLE device name.

Who changed what in which revision?

UserRevisionLine numberNew 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
coisme 2:11fe67783c4c 11 #ifdef REV_D
coisme 2:11fe67783c4c 12 #include "mcp342x.h"
coisme 2:11fe67783c4c 13 #endif
masahikofukasawa 0:7a00359e701e 14
masahikofukasawa 0:7a00359e701e 15 #define ANALOG_SENSOR_ID P0_4
masahikofukasawa 0:7a00359e701e 16 #define ANALOG_SENSOR_ID_SUB P0_5
masahikofukasawa 0:7a00359e701e 17
masahikofukasawa 0:7a00359e701e 18 class AkmSensorManager {
masahikofukasawa 0:7a00359e701e 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 0:7a00359e701e 40
masahikofukasawa 0:7a00359e701e 41 private:
masahikofukasawa 0:7a00359e701e 42
masahikofukasawa 0:7a00359e701e 43 AkmSensor* sensor;
masahikofukasawa 0:7a00359e701e 44 SerialNano* serial;
masahikofukasawa 0:7a00359e701e 45 UARTService* uartService;
masahikofukasawa 0:7a00359e701e 46 Message msg;
masahikofukasawa 0:7a00359e701e 47
masahikofukasawa 10:5c69b067d88a 48 uint8_t primaryId;
masahikofukasawa 0:7a00359e701e 49 uint8_t subId;
masahikofukasawa 0:7a00359e701e 50 bool isEnabledBle;
masahikofukasawa 0:7a00359e701e 51 bool isEnabledUsb;
masahikofukasawa 0:7a00359e701e 52 bool eventCommandReceived;
masahikofukasawa 0:7a00359e701e 53 bool eventConnected;
masahikofukasawa 0:7a00359e701e 54 bool eventDisconnected;
masahikofukasawa 0:7a00359e701e 55
masahikofukasawa 0:7a00359e701e 56 char userCommand[20];
masahikofukasawa 0:7a00359e701e 57
masahikofukasawa 0:7a00359e701e 58 AkmSensor* getAkmSensor();
masahikofukasawa 0:7a00359e701e 59 void dataOut(char* str);
coisme 2:11fe67783c4c 60
coisme 2:11fe67783c4c 61 #ifdef REV_D
coisme 2:11fe67783c4c 62 int16_t getAdcData(MCP342X *mcp3428, MCP342X::AdcChannel ch, MCP342X::SampleSetting s);
coisme 2:11fe67783c4c 63 #endif
masahikofukasawa 0:7a00359e701e 64 };
masahikofukasawa 0:7a00359e701e 65
masahikofukasawa 0:7a00359e701e 66 #endif // AKMSENSORMANAGER_H