Modified for compatibility with Rev.E. hardware
Fork of AkmSensor by
akmsensor.h
- Committer:
- masahikofukasawa
- Date:
- 2017-03-17
- Revision:
- 29:b488d2c89fba
- Parent:
- 27:41aa9fb23a2f
- Child:
- 34:1ea3357c8d9a
File content as of revision 29:b488d2c89fba:
#ifndef AKMSENSOR_H #define AKMSENSOR_H #include "mbed.h" #include "Message.h" //#include "debug.h" // SPI #define SPI_SCK P0_8 //SPI, SCK #define SPI_MISO P0_9 //SPI, MISO #define SPI_MOSI P0_10 //SPI, MOSI #define SPI_CS P0_11 //SPI, CS #define SPI_DRDY P0_7 //SPI, DRDY // I2C #define I2C_SCL P0_8 //I2C, SCL #define I2C_SDA P0_10 //I2C, SDA // Digital Port #define DIGITAL_D0 P0_11 #define DIGITAL_D1 P0_9 // DRDY Port #define I2C_DRDY P0_11 // Analog In #define ANALOG_IN_PIN P0_5 //P05 #define I2C_SPEED_100KHZ 100000 #define I2C_SPEED_400KHZ 400000 #define SENSOR_SAMPLING_RATE 0.1 // 10Hz class AkmSensor { public: typedef enum { SUCCESS = 0, ERROR, } Status; typedef enum { AKM_PRIMARY_ID_AKD_SPI = 0x0, AKM_PRIMARY_ID_UNIPOLAR = 0x1, AKM_PRIMARY_ID_OMNIPOLAR = 0x2, AKM_PRIMARY_ID_LATCH = 0x3, AKM_PRIMARY_ID_DUAL_OUTPUT = 0x4, AKM_PRIMARY_ID_ONECHIP_ENCODER = 0x5, AKM_PRIMARY_ID_TBD1 = 0x6, AKM_PRIMARY_ID_TBD2 = 0x7, AKM_PRIMARY_ID_DEMO = 0x8, AKM_PRIMARY_ID_CURRENT_SENSOR = 0x9, AKM_PRIMARY_ID_MISC_ANALOG = 0xA, AKM_PRIMARY_ID_LINEAR_SENSOR = 0xB, AKM_PRIMARY_ID_TBD3 = 0xC, AKM_PRIMARY_ID_IR_SENSOR = 0xD, AKM_PRIMARY_ID_ANGLE_SENSOR = 0xE, AKM_PRIMARY_ID_AKD_I2C = 0xF, } SensorPrimaryId; virtual ~AkmSensor(){}; virtual Status init(const uint8_t id, const uint8_t subid) = 0; virtual Status startSensor() = 0; virtual Status startSensor(const float sec) = 0; virtual Status stopSensor() = 0; virtual Status readSensorData(Message* msg) = 0; virtual Status requestCommand(Message* in, Message* out) = 0; virtual void setEvent(){ // MSG("#setEvent called.\r\n"); event = true; } void clearEvent(){ // MSG("#clearEvent called.\r\n"); event = false; } bool isEvent(){ return event; } char* getSensorName(){ return sensorName; }; int getPrimaryId(){ return primaryId; }; int getSecondaryId(){ return subId; }; private: bool event; protected: uint8_t primaryId; uint8_t subId; char* sensorName; AkmSensor(){ event = false; primaryId = 0; subId = 0; sensorName = ""; }; }; #endif