Modified for compatibility with Rev.E. hardware

Fork of AkmSensor by AKM Development Platform

Committer:
masahikofukasawa
Date:
Fri May 13 23:52:37 2016 +0000
Revision:
6:c4401549d68f
Parent:
2:11fe67783c4c
Child:
10:5c69b067d88a
Added current sensor

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"
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 0:7a00359e701e 26 Status init();
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 6:c4401549d68f 36 void releaseTWI();
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 0:7a00359e701e 44
masahikofukasawa 0:7a00359e701e 45 uint8_t id;
masahikofukasawa 0:7a00359e701e 46 uint8_t subId;
masahikofukasawa 0:7a00359e701e 47 bool isEnabledBle;
masahikofukasawa 0:7a00359e701e 48 bool isEnabledUsb;
masahikofukasawa 0:7a00359e701e 49
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 uint8_t getId(PinName pin, uint8_t bits);
masahikofukasawa 0:7a00359e701e 58 void dataOut(char* str);
coisme 2:11fe67783c4c 59
coisme 2:11fe67783c4c 60 #ifdef REV_D
coisme 2:11fe67783c4c 61 int16_t getAdcData(MCP342X *mcp3428, MCP342X::AdcChannel ch, MCP342X::SampleSetting s);
coisme 2:11fe67783c4c 62 #endif
masahikofukasawa 0:7a00359e701e 63 };
masahikofukasawa 0:7a00359e701e 64
masahikofukasawa 0:7a00359e701e 65 #endif // AKMSENSORMANAGER_H