Modified for compatibility with Rev.E. hardware
Fork of AkmSensor by
akmsensor.h@4:af13b985c689, 2016-05-09 (annotated)
- Committer:
- masahikofukasawa
- Date:
- Mon May 09 16:59:33 2016 +0000
- Revision:
- 4:af13b985c689
- Parent:
- 1:b46b8653331f
- Child:
- 7:e269411568c9
Rev.D Masa
Who changed what in which revision?
User | Revision | Line number | New 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 | 0:7a00359e701e | 12 | |
masahikofukasawa | 0:7a00359e701e | 13 | // I2C |
masahikofukasawa | 0:7a00359e701e | 14 | #define I2C_SCL P0_8 //I2C, SCL |
masahikofukasawa | 0:7a00359e701e | 15 | #define I2C_SDA P0_10 //I2C, SDA |
masahikofukasawa | 0:7a00359e701e | 16 | |
masahikofukasawa | 0:7a00359e701e | 17 | // Digital Port |
masahikofukasawa | 0:7a00359e701e | 18 | #define DIGITAL_D0 P0_11 |
masahikofukasawa | 0:7a00359e701e | 19 | #define DIGITAL_D1 P0_9 |
masahikofukasawa | 0:7a00359e701e | 20 | |
masahikofukasawa | 0:7a00359e701e | 21 | // DRDY Port |
masahikofukasawa | 0:7a00359e701e | 22 | #define DRDY P0_11 |
masahikofukasawa | 0:7a00359e701e | 23 | |
masahikofukasawa | 0:7a00359e701e | 24 | // Analog In |
masahikofukasawa | 0:7a00359e701e | 25 | #define ANALOG_IN_PIN P0_5 //P05 |
masahikofukasawa | 0:7a00359e701e | 26 | |
masahikofukasawa | 0:7a00359e701e | 27 | #define I2C_SPEED_100KHZ 100000 |
masahikofukasawa | 0:7a00359e701e | 28 | #define I2C_SPEED_400KHZ 400000 |
masahikofukasawa | 0:7a00359e701e | 29 | |
masahikofukasawa | 0:7a00359e701e | 30 | |
masahikofukasawa | 0:7a00359e701e | 31 | class AkmSensor |
masahikofukasawa | 0:7a00359e701e | 32 | { |
masahikofukasawa | 0:7a00359e701e | 33 | |
masahikofukasawa | 0:7a00359e701e | 34 | public: |
masahikofukasawa | 0:7a00359e701e | 35 | typedef enum { |
masahikofukasawa | 0:7a00359e701e | 36 | SUCCESS = 0, |
masahikofukasawa | 0:7a00359e701e | 37 | ERROR_DOESNT_SUPPORT, |
masahikofukasawa | 0:7a00359e701e | 38 | ERROR, |
masahikofukasawa | 0:7a00359e701e | 39 | } Status; |
masahikofukasawa | 0:7a00359e701e | 40 | |
masahikofukasawa | 0:7a00359e701e | 41 | typedef enum { |
masahikofukasawa | 0:7a00359e701e | 42 | AKM_PRIMARY_ID_AKD_SPI = 0x0, |
masahikofukasawa | 0:7a00359e701e | 43 | AKM_PRIMARY_ID_UNIPOLAR = 0x1, |
masahikofukasawa | 0:7a00359e701e | 44 | AKM_PRIMARY_ID_OMNIPOLAR = 0x2, |
masahikofukasawa | 0:7a00359e701e | 45 | AKM_PRIMARY_ID_LATCH = 0x3, |
masahikofukasawa | 0:7a00359e701e | 46 | AKM_PRIMARY_ID_DUAL_OUTPUT = 0x4, |
masahikofukasawa | 0:7a00359e701e | 47 | AKM_PRIMARY_ID_ONECHIP_ENCODER = 0x5, |
masahikofukasawa | 0:7a00359e701e | 48 | AKM_PRIMARY_ID_TBD1 = 0x6, |
masahikofukasawa | 0:7a00359e701e | 49 | AKM_PRIMARY_ID_TBD2 = 0x7, |
masahikofukasawa | 0:7a00359e701e | 50 | AKM_PRIMARY_ID_LINEAR_SENSOR_LEGACY = 0x8, |
masahikofukasawa | 0:7a00359e701e | 51 | AKM_PRIMARY_ID_CURRENT_SENSOR = 0x9, |
masahikofukasawa | 0:7a00359e701e | 52 | AKM_PRIMARY_ID_MISC_ANALOG = 0xA, |
masahikofukasawa | 0:7a00359e701e | 53 | AKM_PRIMARY_ID_LINEAR_SENSOR = 0xB, |
masahikofukasawa | 4:af13b985c689 | 54 | AKM_PRIMARY_ID_TBD3 = 0xC, |
masahikofukasawa | 4:af13b985c689 | 55 | AKM_PRIMARY_ID_IR_SENSOR = 0xD, |
masahikofukasawa | 0:7a00359e701e | 56 | AKM_PRIMARY_ID_ANGLE_SENSOR = 0xE, |
masahikofukasawa | 0:7a00359e701e | 57 | AKM_PRIMARY_ID_AKD_I2C = 0xF, |
masahikofukasawa | 0:7a00359e701e | 58 | } SensorPrimaryId; |
masahikofukasawa | 0:7a00359e701e | 59 | |
masahikofukasawa | 0:7a00359e701e | 60 | AkmSensor(){} |
masahikofukasawa | 0:7a00359e701e | 61 | virtual ~AkmSensor(){} |
masahikofukasawa | 0:7a00359e701e | 62 | virtual Status init(const uint8_t id, const uint8_t subid) = 0; |
masahikofukasawa | 0:7a00359e701e | 63 | virtual bool isEvent() = 0; |
masahikofukasawa | 0:7a00359e701e | 64 | virtual Status startSensor() = 0; |
masahikofukasawa | 0:7a00359e701e | 65 | virtual Status startSensor(const float sec) = 0; |
masahikofukasawa | 0:7a00359e701e | 66 | virtual Status stopSensor() = 0; |
masahikofukasawa | 0:7a00359e701e | 67 | virtual Status readSensorData(Message* msg) = 0; |
masahikofukasawa | 0:7a00359e701e | 68 | virtual Status requestCommand(Message* in, Message* out) = 0; |
masahikofukasawa | 0:7a00359e701e | 69 | |
masahikofukasawa | 0:7a00359e701e | 70 | private: |
masahikofukasawa | 0:7a00359e701e | 71 | |
masahikofukasawa | 0:7a00359e701e | 72 | }; |
masahikofukasawa | 0:7a00359e701e | 73 | |
masahikofukasawa | 0:7a00359e701e | 74 | #endif |