Modified for compatibility with Rev.E. hardware

Fork of AkmSensor by AKM Development Platform

Committer:
tkstreet
Date:
Tue May 01 21:31:15 2018 +0000
Revision:
49:c8f8946129b6
Parent:
43:45225713cd58
Modified for Rev.E. compatibility.

Who changed what in which revision?

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