Modified for compatibility with Rev.E. hardware
Fork of AkmSensor by
akmhallswitch.h@23:50c98b286e41, 2017-04-13 (annotated)
- Committer:
- tkstreet
- Date:
- Thu Apr 13 22:15:54 2017 +0000
- Revision:
- 23:50c98b286e41
- Parent:
- 13:d008249f0359
- Child:
- 34:1ea3357c8d9a
Added documentation for all classes
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 | |
tkstreet | 23:50c98b286e41 | 8 | /** |
tkstreet | 23:50c98b286e41 | 9 | * Collection class for handling commands to all AKM Hall Switch modules. |
tkstreet | 23:50c98b286e41 | 10 | * Hall Swich Devices: |
tkstreet | 23:50c98b286e41 | 11 | * |
tkstreet | 23:50c98b286e41 | 12 | * Unipolar Switches: EM1771, EW453, EW652B, EW6672 |
tkstreet | 23:50c98b286e41 | 13 | * |
tkstreet | 23:50c98b286e41 | 14 | * Omnipolar Switches: EM1781, AK8788A, EM6781 |
tkstreet | 23:50c98b286e41 | 15 | * |
tkstreet | 23:50c98b286e41 | 16 | * Bipolar Latches: AK8771, EZ470, EZ471, EW432, EW612B, EW632 |
tkstreet | 23:50c98b286e41 | 17 | * |
tkstreet | 23:50c98b286e41 | 18 | * Dual Switches: AK8789, EM1791 |
tkstreet | 23:50c98b286e41 | 19 | * |
tkstreet | 23:50c98b286e41 | 20 | * One-Chip Encoders: AK8775, AK8779A, AK8779B, AK8776 |
tkstreet | 23:50c98b286e41 | 21 | */ |
masahikofukasawa | 0:7a00359e701e | 22 | class AkmHallSwitch : public AkmSensor |
masahikofukasawa | 0:7a00359e701e | 23 | { |
masahikofukasawa | 0:7a00359e701e | 24 | |
masahikofukasawa | 0:7a00359e701e | 25 | public: |
masahikofukasawa | 0:7a00359e701e | 26 | |
tkstreet | 23:50c98b286e41 | 27 | /** |
tkstreet | 23:50c98b286e41 | 28 | * Unipolar Switch Sub-IDs |
tkstreet | 23:50c98b286e41 | 29 | * |
tkstreet | 23:50c98b286e41 | 30 | * Primary ID = 0x01 |
tkstreet | 23:50c98b286e41 | 31 | */ |
masahikofukasawa | 0:7a00359e701e | 32 | typedef enum { |
tkstreet | 23:50c98b286e41 | 33 | SUB_ID_EM1771 = 0x01, /**< EM1771 = 0x01 */ |
tkstreet | 23:50c98b286e41 | 34 | SUB_ID_EW453 = 0x03, /**< EW453 = 0x03 */ |
tkstreet | 23:50c98b286e41 | 35 | SUB_ID_EW652B = 0x0C, /**< EW652B = 0x0C */ |
tkstreet | 23:50c98b286e41 | 36 | SUB_ID_EW6672 = 0x0D, /**< EW6672 = 0x0D */ |
masahikofukasawa | 0:7a00359e701e | 37 | } SubIdUnipolarSwitch; |
masahikofukasawa | 0:7a00359e701e | 38 | |
tkstreet | 23:50c98b286e41 | 39 | /** |
tkstreet | 23:50c98b286e41 | 40 | * Omnipolar Switch Sub-IDs |
tkstreet | 23:50c98b286e41 | 41 | * |
tkstreet | 23:50c98b286e41 | 42 | * Primary ID = 0x02 |
tkstreet | 23:50c98b286e41 | 43 | */ |
masahikofukasawa | 0:7a00359e701e | 44 | typedef enum { |
tkstreet | 23:50c98b286e41 | 45 | SUB_ID_EM1781 = 0x03, /**< EM1781 = 0x03 */ |
tkstreet | 23:50c98b286e41 | 46 | SUB_ID_AK8788A = 0x04, /**< AK8788A = 0x04 */ |
tkstreet | 23:50c98b286e41 | 47 | SUB_ID_EM6781 = 0x05, /**< EM6781 = 0x05 */ |
masahikofukasawa | 0:7a00359e701e | 48 | } SubIdOmnipolarSwitch; |
masahikofukasawa | 0:7a00359e701e | 49 | |
tkstreet | 23:50c98b286e41 | 50 | /** |
tkstreet | 23:50c98b286e41 | 51 | * Bipolar Latch Sub-IDs |
tkstreet | 23:50c98b286e41 | 52 | * |
tkstreet | 23:50c98b286e41 | 53 | * Primary ID = 0x03 |
tkstreet | 23:50c98b286e41 | 54 | */ |
masahikofukasawa | 0:7a00359e701e | 55 | typedef enum { |
tkstreet | 23:50c98b286e41 | 56 | SUB_ID_AK8771 = 0x01, /**< AK8771 = 0x01 */ |
tkstreet | 23:50c98b286e41 | 57 | SUB_ID_EZ470 = 0x03, /**< EZ470 = 0x03 */ |
tkstreet | 23:50c98b286e41 | 58 | SUB_ID_EZ471 = 0x04, /**< EZ471 = 0x04 */ |
tkstreet | 23:50c98b286e41 | 59 | SUB_ID_EW432 = 0x08, /**< EW432 = 0x08 */ |
tkstreet | 23:50c98b286e41 | 60 | SUB_ID_EW612B = 0x0C, /**< EW612B = 0x0C */ |
tkstreet | 23:50c98b286e41 | 61 | SUB_ID_EW632 = 0x0D, /**< EW632 = 0x0D */ |
masahikofukasawa | 0:7a00359e701e | 62 | } SubIdBipolarLatch; |
masahikofukasawa | 0:7a00359e701e | 63 | |
tkstreet | 23:50c98b286e41 | 64 | /** |
tkstreet | 23:50c98b286e41 | 65 | * Dual Output Switch Sub-IDs |
tkstreet | 23:50c98b286e41 | 66 | * |
tkstreet | 23:50c98b286e41 | 67 | * Primary ID = 0x04 |
tkstreet | 23:50c98b286e41 | 68 | */ |
masahikofukasawa | 0:7a00359e701e | 69 | typedef enum { |
tkstreet | 23:50c98b286e41 | 70 | SUB_ID_AK8789 = 0x03, /**< AK8789 = 0x03 */ |
tkstreet | 23:50c98b286e41 | 71 | SUB_ID_EM1791 = 0x04, /**< EM1791 = 0x04 */ |
masahikofukasawa | 0:7a00359e701e | 72 | } SubIdDualSwitch; |
masahikofukasawa | 0:7a00359e701e | 73 | |
tkstreet | 23:50c98b286e41 | 74 | /** |
tkstreet | 23:50c98b286e41 | 75 | * One-Chip Encoder Sub-IDs |
tkstreet | 23:50c98b286e41 | 76 | * |
tkstreet | 23:50c98b286e41 | 77 | * Primary ID = 0x05 |
tkstreet | 23:50c98b286e41 | 78 | */ |
masahikofukasawa | 0:7a00359e701e | 79 | typedef enum { |
tkstreet | 23:50c98b286e41 | 80 | SUB_ID_AK8775 = 0x01, /**< AK8775 = 0x01 */ |
tkstreet | 23:50c98b286e41 | 81 | SUB_ID_AK8779A = 0x0B, /**< AK8779A = 0x0B */ |
tkstreet | 23:50c98b286e41 | 82 | SUB_ID_AK8779B = 0x0C, /**< AK8779B = 0x0C */ |
tkstreet | 23:50c98b286e41 | 83 | SUB_ID_AK8776 = 0x0F, /**< AK8776 = 0x0F */ |
masahikofukasawa | 0:7a00359e701e | 84 | } SubIdOnechipEncoder; |
masahikofukasawa | 0:7a00359e701e | 85 | |
masahikofukasawa | 0:7a00359e701e | 86 | AkmHallSwitch(); |
tkstreet | 23:50c98b286e41 | 87 | virtual ~AkmHallSwitch(); |
masahikofukasawa | 0:7a00359e701e | 88 | |
masahikofukasawa | 0:7a00359e701e | 89 | /** |
tkstreet | 23:50c98b286e41 | 90 | * Process for intializing the selected sensor. |
masahikofukasawa | 0:7a00359e701e | 91 | * |
tkstreet | 23:50c98b286e41 | 92 | * @return Termination status type for debugging purposes. |
masahikofukasawa | 0:7a00359e701e | 93 | */ |
masahikofukasawa | 0:7a00359e701e | 94 | virtual AkmSensor::Status init(const uint8_t id, const uint8_t subid); |
tkstreet | 23:50c98b286e41 | 95 | |
tkstreet | 23:50c98b286e41 | 96 | /** |
tkstreet | 23:50c98b286e41 | 97 | * Simple flag process to determine if an event has occurred. |
tkstreet | 23:50c98b286e41 | 98 | * |
tkstreet | 23:50c98b286e41 | 99 | * @return TRUE if event has occurred, FALSE if not. |
tkstreet | 23:50c98b286e41 | 100 | */ |
masahikofukasawa | 0:7a00359e701e | 101 | virtual bool isEvent(); |
tkstreet | 23:50c98b286e41 | 102 | |
tkstreet | 23:50c98b286e41 | 103 | /** |
tkstreet | 23:50c98b286e41 | 104 | * Process abstraction for starting sensor operation. |
tkstreet | 23:50c98b286e41 | 105 | * |
tkstreet | 23:50c98b286e41 | 106 | * @return Termination status type for debugging purposes. |
tkstreet | 23:50c98b286e41 | 107 | */ |
masahikofukasawa | 0:7a00359e701e | 108 | virtual AkmSensor::Status startSensor(); |
tkstreet | 23:50c98b286e41 | 109 | |
tkstreet | 23:50c98b286e41 | 110 | /** |
tkstreet | 23:50c98b286e41 | 111 | * Process abstraction for starting sensor operation. |
tkstreet | 23:50c98b286e41 | 112 | * |
tkstreet | 23:50c98b286e41 | 113 | * @param sec Number of seconds of operation. |
tkstreet | 23:50c98b286e41 | 114 | * @return Termination status type for debugging purposes. |
tkstreet | 23:50c98b286e41 | 115 | */ |
masahikofukasawa | 0:7a00359e701e | 116 | virtual AkmSensor::Status startSensor(const float sec); |
tkstreet | 23:50c98b286e41 | 117 | |
tkstreet | 23:50c98b286e41 | 118 | /** |
tkstreet | 23:50c98b286e41 | 119 | * Process abstraction for stopping sensor operation. |
tkstreet | 23:50c98b286e41 | 120 | * |
tkstreet | 23:50c98b286e41 | 121 | * @return Termination status type for debugging purposes. |
tkstreet | 23:50c98b286e41 | 122 | */ |
masahikofukasawa | 0:7a00359e701e | 123 | virtual AkmSensor::Status stopSensor(); |
tkstreet | 23:50c98b286e41 | 124 | |
tkstreet | 23:50c98b286e41 | 125 | /** |
tkstreet | 23:50c98b286e41 | 126 | * Process abstraction for reading data from the sensor. |
tkstreet | 23:50c98b286e41 | 127 | * |
tkstreet | 23:50c98b286e41 | 128 | * @param msg Message object that will hold the sensor data. |
tkstreet | 23:50c98b286e41 | 129 | * @return Termination status type for debugging purposes. |
tkstreet | 23:50c98b286e41 | 130 | */ |
masahikofukasawa | 0:7a00359e701e | 131 | virtual AkmSensor::Status readSensorData(Message* msg); |
tkstreet | 23:50c98b286e41 | 132 | |
tkstreet | 23:50c98b286e41 | 133 | /** |
tkstreet | 23:50c98b286e41 | 134 | * Primary process for interfacing a sensor with the AKDP. When implemented |
tkstreet | 23:50c98b286e41 | 135 | * in sensor class, it will transfer commands between the the sensor control |
tkstreet | 23:50c98b286e41 | 136 | * class and AkmSensorManager. |
tkstreet | 23:50c98b286e41 | 137 | * |
tkstreet | 23:50c98b286e41 | 138 | * @param in Command message to be processed by sensor. |
tkstreet | 23:50c98b286e41 | 139 | * @param out Message returned from sensor. |
tkstreet | 23:50c98b286e41 | 140 | * @return Termination status type for debugging purposes. |
tkstreet | 23:50c98b286e41 | 141 | */ |
masahikofukasawa | 0:7a00359e701e | 142 | virtual Status requestCommand(Message* in, Message* out); |
tkstreet | 23:50c98b286e41 | 143 | |
tkstreet | 23:50c98b286e41 | 144 | /** |
tkstreet | 23:50c98b286e41 | 145 | * Get the name of the sensor in char format. |
tkstreet | 23:50c98b286e41 | 146 | * |
tkstreet | 23:50c98b286e41 | 147 | * @return Sensor name as a char array. |
tkstreet | 23:50c98b286e41 | 148 | */ |
masahikofukasawa | 13:d008249f0359 | 149 | virtual char* getSensorName(); |
masahikofukasawa | 13:d008249f0359 | 150 | |
tkstreet | 23:50c98b286e41 | 151 | /** |
tkstreet | 23:50c98b286e41 | 152 | * Callback function for a rising edge event on pin D0 |
tkstreet | 23:50c98b286e41 | 153 | */ |
masahikofukasawa | 0:7a00359e701e | 154 | void riseEventD0(); |
tkstreet | 23:50c98b286e41 | 155 | |
tkstreet | 23:50c98b286e41 | 156 | /** |
tkstreet | 23:50c98b286e41 | 157 | * Callback function for a falling edge event on pin D0 |
tkstreet | 23:50c98b286e41 | 158 | */ |
masahikofukasawa | 0:7a00359e701e | 159 | void fallEventD0(); |
tkstreet | 23:50c98b286e41 | 160 | |
tkstreet | 23:50c98b286e41 | 161 | /** |
tkstreet | 23:50c98b286e41 | 162 | * Callback function for a rising edge event on pin D1 |
tkstreet | 23:50c98b286e41 | 163 | */ |
masahikofukasawa | 0:7a00359e701e | 164 | void riseEventD1(); |
tkstreet | 23:50c98b286e41 | 165 | |
tkstreet | 23:50c98b286e41 | 166 | /** |
tkstreet | 23:50c98b286e41 | 167 | * Callback function for a falling edge event on pin D1 |
tkstreet | 23:50c98b286e41 | 168 | */ |
masahikofukasawa | 0:7a00359e701e | 169 | void fallEventD1(); |
masahikofukasawa | 0:7a00359e701e | 170 | |
masahikofukasawa | 0:7a00359e701e | 171 | private: |
masahikofukasawa | 0:7a00359e701e | 172 | bool event; |
masahikofukasawa | 0:7a00359e701e | 173 | uint8_t primaryId; |
masahikofukasawa | 0:7a00359e701e | 174 | uint8_t subId; |
masahikofukasawa | 13:d008249f0359 | 175 | char* sensorName; |
masahikofukasawa | 0:7a00359e701e | 176 | |
masahikofukasawa | 0:7a00359e701e | 177 | uint8_t d0; |
masahikofukasawa | 0:7a00359e701e | 178 | uint8_t d1; |
masahikofukasawa | 0:7a00359e701e | 179 | InterruptIn* sw0; |
masahikofukasawa | 0:7a00359e701e | 180 | InterruptIn* sw1; |
masahikofukasawa | 0:7a00359e701e | 181 | }; |
masahikofukasawa | 0:7a00359e701e | 182 | |
masahikofukasawa | 0:7a00359e701e | 183 | #endif |