Modified for compatibility with Rev.E. hardware
Fork of AkmSensor by
Diff: akmsensor.h
- Revision:
- 0:7a00359e701e
- Child:
- 1:b46b8653331f
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/akmsensor.h Thu Apr 28 21:12:04 2016 +0000 @@ -0,0 +1,74 @@ +#ifndef AKMSENSOR_H +#define AKMSENSOR_H + +#include "mbed.h" +#include "Message.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_4 //SPI, CS + +// 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 DRDY P0_11 + +// Analog In +#define ANALOG_IN_PIN P0_5 //P05 + +#define I2C_SPEED_100KHZ 100000 +#define I2C_SPEED_400KHZ 400000 + + +class AkmSensor +{ + +public: + typedef enum { + SUCCESS = 0, + ERROR_DOESNT_SUPPORT, + 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_LINEAR_SENSOR_LEGACY = 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_TBD4 = 0xD, + AKM_PRIMARY_ID_ANGLE_SENSOR = 0xE, + AKM_PRIMARY_ID_AKD_I2C = 0xF, + } SensorPrimaryId; + + AkmSensor(){} + virtual ~AkmSensor(){} + virtual Status init(const uint8_t id, const uint8_t subid) = 0; + virtual bool isEvent() = 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; + +private: + +}; + +#endif