Modified for compatibility with Rev.E. hardware

Fork of AkmSensor by AKM Development Platform

Committer:
tkstreet
Date:
Wed May 03 18:00:45 2017 +0000
Revision:
34:1ea3357c8d9a
Parent:
29:b488d2c89fba
Parent:
23:50c98b286e41
Child:
43:45225713cd58
Release RevD7.015.  Merged D7.014 with new documentation and updates to AP1017 driver.

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