Modified for compatibility with Rev.E. hardware

Fork of AkmSensor by AKM Development Platform

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?

UserRevisionLine numberNew contents of line
masahikofukasawa 11:cef8dc1cf010 1 #ifndef AKMANALOGSENSOR_H
masahikofukasawa 11:cef8dc1cf010 2 #define AKMANALOGSENSOR_H
masahikofukasawa 11:cef8dc1cf010 3
masahikofukasawa 11:cef8dc1cf010 4 #include "mbed.h"
masahikofukasawa 11:cef8dc1cf010 5 #include "SerialNano.h"
masahikofukasawa 11:cef8dc1cf010 6 #include "akmsensor.h"
masahikofukasawa 11:cef8dc1cf010 7 #include "mcp342x.h"
masahikofukasawa 11:cef8dc1cf010 8
tkstreet 23:50c98b286e41 9 /**
tkstreet 23:50c98b286e41 10 * Collection class for handling commands to all AKM Analog Sensor modules.
tkstreet 23:50c98b286e41 11 *
tkstreet 23:50c98b286e41 12 * List of Devices:
tkstreet 23:50c98b286e41 13 *
tkstreet 23:50c98b286e41 14 * Current Sensors: CQ3300, CQ3301, CQ3302, CQ3303, CQ330A, CQ330B, CQ330E,
tkstreet 23:50c98b286e41 15 * CQ330F, CQ330G, CQ330H
tkstreet 23:50c98b286e41 16 *
tkstreet 23:50c98b286e41 17 * Linear Sensors: EQ430L, EQ431L, EQ432L, EQ433L
tkstreet 23:50c98b286e41 18 *
tkstreet 23:50c98b286e41 19 * Angle Sensors: EM3242
tkstreet 23:50c98b286e41 20 *
tkstreet 23:50c98b286e41 21 * IR/CO2 Sensor: AK9710
tkstreet 23:50c98b286e41 22 */
masahikofukasawa 11:cef8dc1cf010 23 class AkmAnalogSensor : public AkmSensor
masahikofukasawa 11:cef8dc1cf010 24 {
masahikofukasawa 11:cef8dc1cf010 25
masahikofukasawa 11:cef8dc1cf010 26 public:
tkstreet 23:50c98b286e41 27
tkstreet 23:50c98b286e41 28 /**
tkstreet 23:50c98b286e41 29 * Sub-IDs for current sensor devices. Primary ID = 09h
tkstreet 23:50c98b286e41 30 */
masahikofukasawa 11:cef8dc1cf010 31 typedef enum {
tkstreet 23:50c98b286e41 32 SUB_ID_CQ3300 = 0x01, /**< CQ3300: ID = 01h */
tkstreet 23:50c98b286e41 33 SUB_ID_CQ3301 = 0x02, /**< CQ3301: ID = 02h */
tkstreet 23:50c98b286e41 34 SUB_ID_CQ3302 = 0x03, /**< CQ3302: ID = 03h */
tkstreet 23:50c98b286e41 35 SUB_ID_CQ3303 = 0x04, /**< CQ3303: ID = 04h */
tkstreet 23:50c98b286e41 36 SUB_ID_CQ330A = 0x05, /**< CQ330A: ID = 05h */
tkstreet 23:50c98b286e41 37 SUB_ID_CQ330B = 0x06, /**< CQ330B: ID = 06h */
tkstreet 23:50c98b286e41 38 SUB_ID_CQ330E = 0x07, /**< CQ330E: ID = 07h */
tkstreet 23:50c98b286e41 39 SUB_ID_CQ330F = 0x08, /**< CQ330F: ID = 08h */
tkstreet 23:50c98b286e41 40 SUB_ID_CQ330G = 0x09, /**< CQ330G: ID = 09h */
tkstreet 23:50c98b286e41 41 SUB_ID_CQ330H = 0x0A, /**< CQ330H: ID = 0Ah */
masahikofukasawa 13:d008249f0359 42 } SubIdCurrentSensor;
masahikofukasawa 13:d008249f0359 43
tkstreet 23:50c98b286e41 44 /**
tkstreet 23:50c98b286e41 45 * Sub-IDs for miscellaneous devices. Primary ID = 0Ah
tkstreet 23:50c98b286e41 46 */
masahikofukasawa 13:d008249f0359 47 typedef enum {
tkstreet 23:50c98b286e41 48 SUB_ID_EM3242 = 0x01, /**< EM3242: ID = 01h */
tkstreet 23:50c98b286e41 49 SUB_ID_AK9710 = 0x08, /**< AK9710: ID = 08h */
masahikofukasawa 13:d008249f0359 50 } SubIdMisc;
masahikofukasawa 13:d008249f0359 51
tkstreet 23:50c98b286e41 52 /**
tkstreet 23:50c98b286e41 53 * Sub-IDs for analog devices. Primary ID = 0Bh
tkstreet 23:50c98b286e41 54 */
masahikofukasawa 13:d008249f0359 55 typedef enum {
tkstreet 23:50c98b286e41 56 SUB_ID_EQ430L = 0x01, /**< EQ430L: ID = 01h */
tkstreet 23:50c98b286e41 57 SUB_ID_EQ431L = 0x02, /**< EQ */
tkstreet 23:50c98b286e41 58 SUB_ID_EQ432L = 0x03, /**< */
tkstreet 23:50c98b286e41 59 SUB_ID_EQ433L = 0x04, /**< */
masahikofukasawa 11:cef8dc1cf010 60 } SubIdLinearSensor;
masahikofukasawa 11:cef8dc1cf010 61
masahikofukasawa 11:cef8dc1cf010 62 /**
masahikofukasawa 11:cef8dc1cf010 63 * Constructor.
masahikofukasawa 11:cef8dc1cf010 64 *
masahikofukasawa 11:cef8dc1cf010 65 */
masahikofukasawa 11:cef8dc1cf010 66 AkmAnalogSensor();
masahikofukasawa 11:cef8dc1cf010 67
masahikofukasawa 11:cef8dc1cf010 68 /**
masahikofukasawa 11:cef8dc1cf010 69 * Destructor.
masahikofukasawa 11:cef8dc1cf010 70 *
masahikofukasawa 11:cef8dc1cf010 71 */
masahikofukasawa 11:cef8dc1cf010 72 virtual ~AkmAnalogSensor();
tkstreet 23:50c98b286e41 73
tkstreet 23:50c98b286e41 74 /**
tkstreet 23:50c98b286e41 75 * Process for intializing the selected sensor.
tkstreet 23:50c98b286e41 76 *
tkstreet 23:50c98b286e41 77 * @return Termination status type for debugging purposes.
tkstreet 23:50c98b286e41 78 */
masahikofukasawa 11:cef8dc1cf010 79 virtual AkmSensor::Status init(const uint8_t id, const uint8_t subid);
tkstreet 23:50c98b286e41 80
tkstreet 23:50c98b286e41 81 /**
tkstreet 23:50c98b286e41 82 * Simple flag process to determine if an event has occurred.
tkstreet 23:50c98b286e41 83 *
tkstreet 23:50c98b286e41 84 * @return TRUE if event has occurred, FALSE if not.
tkstreet 23:50c98b286e41 85 */
masahikofukasawa 11:cef8dc1cf010 86 virtual bool isEvent();
tkstreet 23:50c98b286e41 87
tkstreet 23:50c98b286e41 88 /**
tkstreet 23:50c98b286e41 89 * Process abstraction for starting sensor operation.
tkstreet 23:50c98b286e41 90 *
tkstreet 23:50c98b286e41 91 * @return Termination status type for debugging purposes.
tkstreet 23:50c98b286e41 92 */
masahikofukasawa 11:cef8dc1cf010 93 virtual AkmSensor::Status startSensor();
tkstreet 23:50c98b286e41 94
tkstreet 23:50c98b286e41 95 /**
tkstreet 23:50c98b286e41 96 * Process abstraction for starting sensor operation.
tkstreet 23:50c98b286e41 97 *
tkstreet 23:50c98b286e41 98 * @param sec Number of seconds of operation.
tkstreet 23:50c98b286e41 99 * @return Termination status type for debugging purposes.
tkstreet 23:50c98b286e41 100 */
masahikofukasawa 11:cef8dc1cf010 101 virtual AkmSensor::Status startSensor(const float sec);
tkstreet 23:50c98b286e41 102
tkstreet 23:50c98b286e41 103 /**
tkstreet 23:50c98b286e41 104 * Process abstraction for stopping sensor operation.
tkstreet 23:50c98b286e41 105 *
tkstreet 23:50c98b286e41 106 * @return Termination status type for debugging purposes.
tkstreet 23:50c98b286e41 107 */
masahikofukasawa 11:cef8dc1cf010 108 virtual AkmSensor::Status stopSensor();
tkstreet 23:50c98b286e41 109
tkstreet 23:50c98b286e41 110 /**
tkstreet 23:50c98b286e41 111 * Process abstraction for reading data from the sensor.
tkstreet 23:50c98b286e41 112 *
tkstreet 23:50c98b286e41 113 * @param msg Message object that will hold the sensor data.
tkstreet 23:50c98b286e41 114 * @return Termination status type for debugging purposes.
tkstreet 23:50c98b286e41 115 */
masahikofukasawa 11:cef8dc1cf010 116 virtual AkmSensor::Status readSensorData(Message* msg);
tkstreet 23:50c98b286e41 117
tkstreet 23:50c98b286e41 118 /**
tkstreet 23:50c98b286e41 119 * Primary process for interfacing a sensor with the AKDP. When implemented
tkstreet 23:50c98b286e41 120 * in sensor class, it will transfer commands between the the sensor control
tkstreet 23:50c98b286e41 121 * class and AkmSensorManager.
tkstreet 23:50c98b286e41 122 *
tkstreet 23:50c98b286e41 123 * @param in Command message to be processed by sensor.
tkstreet 23:50c98b286e41 124 * @param out Message returned from sensor.
tkstreet 23:50c98b286e41 125 * @return Termination status type for debugging purposes.
tkstreet 23:50c98b286e41 126 */
masahikofukasawa 11:cef8dc1cf010 127 virtual Status requestCommand(Message* in, Message* out);
tkstreet 23:50c98b286e41 128
tkstreet 23:50c98b286e41 129 /**
tkstreet 23:50c98b286e41 130 * Get the name of the sensor in char format.
tkstreet 23:50c98b286e41 131 *
tkstreet 23:50c98b286e41 132 * @return Sensor name as a char array.
tkstreet 23:50c98b286e41 133 */
masahikofukasawa 13:d008249f0359 134 virtual char* getSensorName();
masahikofukasawa 13:d008249f0359 135
tkstreet 23:50c98b286e41 136 /**
tkstreet 23:50c98b286e41 137 * Callback function for event handling.
tkstreet 23:50c98b286e41 138 */
masahikofukasawa 11:cef8dc1cf010 139 void eventCallback();
masahikofukasawa 11:cef8dc1cf010 140
masahikofukasawa 11:cef8dc1cf010 141 private:
masahikofukasawa 11:cef8dc1cf010 142 bool event;
masahikofukasawa 11:cef8dc1cf010 143 uint8_t primaryId;
masahikofukasawa 11:cef8dc1cf010 144 uint8_t subId;
masahikofukasawa 13:d008249f0359 145 char* sensorName;
masahikofukasawa 11:cef8dc1cf010 146
masahikofukasawa 11:cef8dc1cf010 147 Ticker ticker;
masahikofukasawa 11:cef8dc1cf010 148 AnalogIn* ain;
masahikofukasawa 11:cef8dc1cf010 149 MCP342X* mcp3428;
masahikofukasawa 11:cef8dc1cf010 150 float interval;
masahikofukasawa 11:cef8dc1cf010 151 };
masahikofukasawa 11:cef8dc1cf010 152
masahikofukasawa 11:cef8dc1cf010 153 #endif