Modified for compatibility with Rev.E. hardware

Fork of AkmSensor by AKM Development Platform

Committer:
masahikofukasawa
Date:
Thu May 26 21:56:45 2016 +0000
Revision:
7:e269411568c9
Parent:
4:af13b985c689
Child:
11:cef8dc1cf010
5/26/2016 Japan Demo Version; Modified For: SPI

Who changed what in which revision?

UserRevisionLine numberNew contents of line
masahikofukasawa 0:7a00359e701e 1 #ifndef AKMSENSOR_H
masahikofukasawa 0:7a00359e701e 2 #define AKMSENSOR_H
masahikofukasawa 0:7a00359e701e 3
masahikofukasawa 0:7a00359e701e 4 #include "mbed.h"
masahikofukasawa 0:7a00359e701e 5 #include "Message.h"
masahikofukasawa 0:7a00359e701e 6
masahikofukasawa 0:7a00359e701e 7 // SPI
masahikofukasawa 0:7a00359e701e 8 #define SPI_SCK P0_8 //SPI, SCK
masahikofukasawa 0:7a00359e701e 9 #define SPI_MISO P0_9 //SPI, MISO
masahikofukasawa 0:7a00359e701e 10 #define SPI_MOSI P0_10 //SPI, MOSI
masahikofukasawa 4:af13b985c689 11 #define SPI_CS P0_11 //SPI, CS
masahikofukasawa 7:e269411568c9 12 #define SPI_DRDY P0_7 //SPI, DRDY
masahikofukasawa 0:7a00359e701e 13
masahikofukasawa 0:7a00359e701e 14 // I2C
masahikofukasawa 0:7a00359e701e 15 #define I2C_SCL P0_8 //I2C, SCL
masahikofukasawa 0:7a00359e701e 16 #define I2C_SDA P0_10 //I2C, SDA
masahikofukasawa 0:7a00359e701e 17
masahikofukasawa 0:7a00359e701e 18 // Digital Port
masahikofukasawa 0:7a00359e701e 19 #define DIGITAL_D0 P0_11
masahikofukasawa 0:7a00359e701e 20 #define DIGITAL_D1 P0_9
masahikofukasawa 0:7a00359e701e 21
masahikofukasawa 0:7a00359e701e 22 // DRDY Port
masahikofukasawa 7:e269411568c9 23 #define I2C_DRDY P0_11
masahikofukasawa 0:7a00359e701e 24
masahikofukasawa 0:7a00359e701e 25 // Analog In
masahikofukasawa 0:7a00359e701e 26 #define ANALOG_IN_PIN P0_5 //P05
masahikofukasawa 0:7a00359e701e 27
masahikofukasawa 0:7a00359e701e 28 #define I2C_SPEED_100KHZ 100000
masahikofukasawa 0:7a00359e701e 29 #define I2C_SPEED_400KHZ 400000
masahikofukasawa 0:7a00359e701e 30
masahikofukasawa 0:7a00359e701e 31
masahikofukasawa 0:7a00359e701e 32 class AkmSensor
masahikofukasawa 0:7a00359e701e 33 {
masahikofukasawa 0:7a00359e701e 34
masahikofukasawa 0:7a00359e701e 35 public:
masahikofukasawa 0:7a00359e701e 36 typedef enum {
masahikofukasawa 0:7a00359e701e 37 SUCCESS = 0,
masahikofukasawa 0:7a00359e701e 38 ERROR_DOESNT_SUPPORT,
masahikofukasawa 0:7a00359e701e 39 ERROR,
masahikofukasawa 0:7a00359e701e 40 } Status;
masahikofukasawa 0:7a00359e701e 41
masahikofukasawa 0:7a00359e701e 42 typedef enum {
masahikofukasawa 0:7a00359e701e 43 AKM_PRIMARY_ID_AKD_SPI = 0x0,
masahikofukasawa 0:7a00359e701e 44 AKM_PRIMARY_ID_UNIPOLAR = 0x1,
masahikofukasawa 0:7a00359e701e 45 AKM_PRIMARY_ID_OMNIPOLAR = 0x2,
masahikofukasawa 0:7a00359e701e 46 AKM_PRIMARY_ID_LATCH = 0x3,
masahikofukasawa 0:7a00359e701e 47 AKM_PRIMARY_ID_DUAL_OUTPUT = 0x4,
masahikofukasawa 0:7a00359e701e 48 AKM_PRIMARY_ID_ONECHIP_ENCODER = 0x5,
masahikofukasawa 0:7a00359e701e 49 AKM_PRIMARY_ID_TBD1 = 0x6,
masahikofukasawa 0:7a00359e701e 50 AKM_PRIMARY_ID_TBD2 = 0x7,
masahikofukasawa 0:7a00359e701e 51 AKM_PRIMARY_ID_LINEAR_SENSOR_LEGACY = 0x8,
masahikofukasawa 0:7a00359e701e 52 AKM_PRIMARY_ID_CURRENT_SENSOR = 0x9,
masahikofukasawa 0:7a00359e701e 53 AKM_PRIMARY_ID_MISC_ANALOG = 0xA,
masahikofukasawa 0:7a00359e701e 54 AKM_PRIMARY_ID_LINEAR_SENSOR = 0xB,
masahikofukasawa 4:af13b985c689 55 AKM_PRIMARY_ID_TBD3 = 0xC,
masahikofukasawa 4:af13b985c689 56 AKM_PRIMARY_ID_IR_SENSOR = 0xD,
masahikofukasawa 0:7a00359e701e 57 AKM_PRIMARY_ID_ANGLE_SENSOR = 0xE,
masahikofukasawa 0:7a00359e701e 58 AKM_PRIMARY_ID_AKD_I2C = 0xF,
masahikofukasawa 0:7a00359e701e 59 } SensorPrimaryId;
masahikofukasawa 0:7a00359e701e 60
masahikofukasawa 0:7a00359e701e 61 AkmSensor(){}
masahikofukasawa 0:7a00359e701e 62 virtual ~AkmSensor(){}
masahikofukasawa 0:7a00359e701e 63 virtual Status init(const uint8_t id, const uint8_t subid) = 0;
masahikofukasawa 0:7a00359e701e 64 virtual bool isEvent() = 0;
masahikofukasawa 0:7a00359e701e 65 virtual Status startSensor() = 0;
masahikofukasawa 0:7a00359e701e 66 virtual Status startSensor(const float sec) = 0;
masahikofukasawa 0:7a00359e701e 67 virtual Status stopSensor() = 0;
masahikofukasawa 0:7a00359e701e 68 virtual Status readSensorData(Message* msg) = 0;
masahikofukasawa 0:7a00359e701e 69 virtual Status requestCommand(Message* in, Message* out) = 0;
masahikofukasawa 0:7a00359e701e 70
masahikofukasawa 0:7a00359e701e 71 private:
masahikofukasawa 0:7a00359e701e 72
masahikofukasawa 0:7a00359e701e 73 };
masahikofukasawa 0:7a00359e701e 74
masahikofukasawa 0:7a00359e701e 75 #endif