Modified for compatibility with Rev.E. hardware
Fork of AkmSensor by
akmhallswitch.h@13:d008249f0359, 2016-08-12 (annotated)
- Committer:
- masahikofukasawa
- Date:
- Fri Aug 12 00:04:48 2016 +0000
- Revision:
- 13:d008249f0359
- Parent:
- 6:c4401549d68f
- Child:
- 23:50c98b286e41
- Child:
- 27:41aa9fb23a2f
Ver008. Modified for faster BLE connection, and sensor name in the BLE device name.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
masahikofukasawa | 0:7a00359e701e | 1 | #ifndef AKMHALLSWITCH_H |
masahikofukasawa | 0:7a00359e701e | 2 | #define AKMHALLSWITCH_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 | |
masahikofukasawa | 0:7a00359e701e | 8 | class AkmHallSwitch : public AkmSensor |
masahikofukasawa | 0:7a00359e701e | 9 | { |
masahikofukasawa | 0:7a00359e701e | 10 | |
masahikofukasawa | 0:7a00359e701e | 11 | public: |
masahikofukasawa | 0:7a00359e701e | 12 | |
masahikofukasawa | 0:7a00359e701e | 13 | typedef enum { |
masahikofukasawa | 13:d008249f0359 | 14 | SUB_ID_EM1771 = 0x01, |
masahikofukasawa | 0:7a00359e701e | 15 | SUB_ID_EW453 = 0x03, |
masahikofukasawa | 6:c4401549d68f | 16 | SUB_ID_EW652B = 0x0C, |
masahikofukasawa | 0:7a00359e701e | 17 | SUB_ID_EW6672 = 0x0D, |
masahikofukasawa | 0:7a00359e701e | 18 | } SubIdUnipolarSwitch; |
masahikofukasawa | 0:7a00359e701e | 19 | |
masahikofukasawa | 0:7a00359e701e | 20 | typedef enum { |
masahikofukasawa | 13:d008249f0359 | 21 | SUB_ID_EM1781 = 0x03, |
masahikofukasawa | 13:d008249f0359 | 22 | SUB_ID_AK8788A = 0x04, |
masahikofukasawa | 13:d008249f0359 | 23 | SUB_ID_EM6781 = 0x05, |
masahikofukasawa | 0:7a00359e701e | 24 | } SubIdOmnipolarSwitch; |
masahikofukasawa | 0:7a00359e701e | 25 | |
masahikofukasawa | 0:7a00359e701e | 26 | typedef enum { |
masahikofukasawa | 13:d008249f0359 | 27 | SUB_ID_AK8771 = 0x01, |
masahikofukasawa | 0:7a00359e701e | 28 | SUB_ID_EZ470 = 0x03, |
masahikofukasawa | 0:7a00359e701e | 29 | SUB_ID_EZ471 = 0x04, |
masahikofukasawa | 0:7a00359e701e | 30 | SUB_ID_EW432 = 0x08, |
masahikofukasawa | 0:7a00359e701e | 31 | SUB_ID_EW612B = 0x0C, |
masahikofukasawa | 0:7a00359e701e | 32 | SUB_ID_EW632 = 0x0D, |
masahikofukasawa | 0:7a00359e701e | 33 | } SubIdBipolarLatch; |
masahikofukasawa | 0:7a00359e701e | 34 | |
masahikofukasawa | 0:7a00359e701e | 35 | typedef enum { |
masahikofukasawa | 0:7a00359e701e | 36 | SUB_ID_AK8789 = 0x03, |
masahikofukasawa | 0:7a00359e701e | 37 | SUB_ID_EM1791 = 0x04, |
masahikofukasawa | 0:7a00359e701e | 38 | } SubIdDualSwitch; |
masahikofukasawa | 0:7a00359e701e | 39 | |
masahikofukasawa | 0:7a00359e701e | 40 | typedef enum { |
masahikofukasawa | 0:7a00359e701e | 41 | SUB_ID_AK8775 = 0x01, |
masahikofukasawa | 0:7a00359e701e | 42 | SUB_ID_AK8779A = 0x0B, |
masahikofukasawa | 0:7a00359e701e | 43 | SUB_ID_AK8779B = 0x0C, |
masahikofukasawa | 13:d008249f0359 | 44 | SUB_ID_AK8776 = 0x0F, |
masahikofukasawa | 0:7a00359e701e | 45 | } SubIdOnechipEncoder; |
masahikofukasawa | 0:7a00359e701e | 46 | |
masahikofukasawa | 0:7a00359e701e | 47 | /** |
masahikofukasawa | 0:7a00359e701e | 48 | * Constructor. |
masahikofukasawa | 0:7a00359e701e | 49 | * |
masahikofukasawa | 0:7a00359e701e | 50 | */ |
masahikofukasawa | 0:7a00359e701e | 51 | AkmHallSwitch(); |
masahikofukasawa | 0:7a00359e701e | 52 | |
masahikofukasawa | 0:7a00359e701e | 53 | /** |
masahikofukasawa | 0:7a00359e701e | 54 | * Destructor. |
masahikofukasawa | 0:7a00359e701e | 55 | * |
masahikofukasawa | 0:7a00359e701e | 56 | */ |
masahikofukasawa | 0:7a00359e701e | 57 | virtual ~AkmHallSwitch(); |
masahikofukasawa | 0:7a00359e701e | 58 | virtual AkmSensor::Status init(const uint8_t id, const uint8_t subid); |
masahikofukasawa | 0:7a00359e701e | 59 | virtual bool isEvent(); |
masahikofukasawa | 0:7a00359e701e | 60 | virtual AkmSensor::Status startSensor(); |
masahikofukasawa | 0:7a00359e701e | 61 | virtual AkmSensor::Status startSensor(const float sec); |
masahikofukasawa | 0:7a00359e701e | 62 | virtual AkmSensor::Status stopSensor(); |
masahikofukasawa | 0:7a00359e701e | 63 | virtual AkmSensor::Status readSensorData(Message* msg); |
masahikofukasawa | 0:7a00359e701e | 64 | virtual Status requestCommand(Message* in, Message* out); |
masahikofukasawa | 13:d008249f0359 | 65 | virtual char* getSensorName(); |
masahikofukasawa | 13:d008249f0359 | 66 | |
masahikofukasawa | 0:7a00359e701e | 67 | void riseEventD0(); |
masahikofukasawa | 0:7a00359e701e | 68 | void fallEventD0(); |
masahikofukasawa | 0:7a00359e701e | 69 | void riseEventD1(); |
masahikofukasawa | 0:7a00359e701e | 70 | void fallEventD1(); |
masahikofukasawa | 0:7a00359e701e | 71 | |
masahikofukasawa | 0:7a00359e701e | 72 | private: |
masahikofukasawa | 0:7a00359e701e | 73 | bool event; |
masahikofukasawa | 0:7a00359e701e | 74 | uint8_t primaryId; |
masahikofukasawa | 0:7a00359e701e | 75 | uint8_t subId; |
masahikofukasawa | 13:d008249f0359 | 76 | char* sensorName; |
masahikofukasawa | 0:7a00359e701e | 77 | |
masahikofukasawa | 0:7a00359e701e | 78 | uint8_t d0; |
masahikofukasawa | 0:7a00359e701e | 79 | uint8_t d1; |
masahikofukasawa | 0:7a00359e701e | 80 | InterruptIn* sw0; |
masahikofukasawa | 0:7a00359e701e | 81 | InterruptIn* sw1; |
masahikofukasawa | 0:7a00359e701e | 82 | }; |
masahikofukasawa | 0:7a00359e701e | 83 | |
masahikofukasawa | 0:7a00359e701e | 84 | #endif |