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:
37:c76d2edf3426
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 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:
masahikofukasawa 29:b488d2c89fba 27
masahikofukasawa 29:b488d2c89fba 28 typedef AkmSensor base;
tkstreet 23:50c98b286e41 29
tkstreet 23:50c98b286e41 30 /**
tkstreet 23:50c98b286e41 31 * Sub-IDs for current sensor devices. Primary ID = 09h
tkstreet 23:50c98b286e41 32 */
masahikofukasawa 11:cef8dc1cf010 33 typedef enum {
tkstreet 23:50c98b286e41 34 SUB_ID_CQ3300 = 0x01, /**< CQ3300: ID = 01h */
tkstreet 23:50c98b286e41 35 SUB_ID_CQ3301 = 0x02, /**< CQ3301: ID = 02h */
tkstreet 23:50c98b286e41 36 SUB_ID_CQ3302 = 0x03, /**< CQ3302: ID = 03h */
tkstreet 23:50c98b286e41 37 SUB_ID_CQ3303 = 0x04, /**< CQ3303: ID = 04h */
tkstreet 23:50c98b286e41 38 SUB_ID_CQ330A = 0x05, /**< CQ330A: ID = 05h */
tkstreet 23:50c98b286e41 39 SUB_ID_CQ330B = 0x06, /**< CQ330B: ID = 06h */
tkstreet 23:50c98b286e41 40 SUB_ID_CQ330E = 0x07, /**< CQ330E: ID = 07h */
tkstreet 23:50c98b286e41 41 SUB_ID_CQ330F = 0x08, /**< CQ330F: ID = 08h */
tkstreet 23:50c98b286e41 42 SUB_ID_CQ330G = 0x09, /**< CQ330G: ID = 09h */
tkstreet 23:50c98b286e41 43 SUB_ID_CQ330H = 0x0A, /**< CQ330H: ID = 0Ah */
masahikofukasawa 13:d008249f0359 44 } SubIdCurrentSensor;
masahikofukasawa 13:d008249f0359 45
tkstreet 23:50c98b286e41 46 /**
tkstreet 23:50c98b286e41 47 * Sub-IDs for miscellaneous devices. Primary ID = 0Ah
tkstreet 23:50c98b286e41 48 */
masahikofukasawa 13:d008249f0359 49 typedef enum {
tkstreet 23:50c98b286e41 50 SUB_ID_EM3242 = 0x01, /**< EM3242: ID = 01h */
tkstreet 23:50c98b286e41 51 SUB_ID_AK9710 = 0x08, /**< AK9710: ID = 08h */
masahikofukasawa 13:d008249f0359 52 } SubIdMisc;
masahikofukasawa 13:d008249f0359 53
tkstreet 23:50c98b286e41 54 /**
tkstreet 23:50c98b286e41 55 * Sub-IDs for analog devices. Primary ID = 0Bh
tkstreet 23:50c98b286e41 56 */
masahikofukasawa 13:d008249f0359 57 typedef enum {
tkstreet 23:50c98b286e41 58 SUB_ID_EQ430L = 0x01, /**< EQ430L: ID = 01h */
tkstreet 23:50c98b286e41 59 SUB_ID_EQ431L = 0x02, /**< EQ */
tkstreet 23:50c98b286e41 60 SUB_ID_EQ432L = 0x03, /**< */
tkstreet 23:50c98b286e41 61 SUB_ID_EQ433L = 0x04, /**< */
masahikofukasawa 11:cef8dc1cf010 62 } SubIdLinearSensor;
masahikofukasawa 11:cef8dc1cf010 63
masahikofukasawa 11:cef8dc1cf010 64 /**
masahikofukasawa 11:cef8dc1cf010 65 * Constructor.
masahikofukasawa 11:cef8dc1cf010 66 *
masahikofukasawa 11:cef8dc1cf010 67 */
masahikofukasawa 11:cef8dc1cf010 68 AkmAnalogSensor();
masahikofukasawa 11:cef8dc1cf010 69
masahikofukasawa 11:cef8dc1cf010 70 /**
masahikofukasawa 11:cef8dc1cf010 71 * Destructor.
masahikofukasawa 11:cef8dc1cf010 72 *
masahikofukasawa 11:cef8dc1cf010 73 */
masahikofukasawa 11:cef8dc1cf010 74 virtual ~AkmAnalogSensor();
tkstreet 23:50c98b286e41 75
tkstreet 23:50c98b286e41 76 /**
tkstreet 23:50c98b286e41 77 * Process for intializing the selected sensor.
tkstreet 23:50c98b286e41 78 *
tkstreet 23:50c98b286e41 79 * @return Termination status type for debugging purposes.
tkstreet 23:50c98b286e41 80 */
masahikofukasawa 11:cef8dc1cf010 81 virtual AkmSensor::Status init(const uint8_t id, const uint8_t subid);
tkstreet 23:50c98b286e41 82
tkstreet 23:50c98b286e41 83 /**
tkstreet 23:50c98b286e41 84 * Process abstraction for starting sensor operation.
tkstreet 23:50c98b286e41 85 *
tkstreet 23:50c98b286e41 86 * @return Termination status type for debugging purposes.
tkstreet 23:50c98b286e41 87 */
masahikofukasawa 11:cef8dc1cf010 88 virtual AkmSensor::Status startSensor();
tkstreet 23:50c98b286e41 89
tkstreet 23:50c98b286e41 90 /**
tkstreet 23:50c98b286e41 91 * Process abstraction for starting sensor operation.
tkstreet 23:50c98b286e41 92 *
tkstreet 23:50c98b286e41 93 * @param sec Number of seconds of operation.
tkstreet 23:50c98b286e41 94 * @return Termination status type for debugging purposes.
tkstreet 23:50c98b286e41 95 */
masahikofukasawa 11:cef8dc1cf010 96 virtual AkmSensor::Status startSensor(const float sec);
tkstreet 23:50c98b286e41 97
tkstreet 23:50c98b286e41 98 /**
tkstreet 23:50c98b286e41 99 * Process abstraction for stopping sensor operation.
tkstreet 23:50c98b286e41 100 *
tkstreet 23:50c98b286e41 101 * @return Termination status type for debugging purposes.
tkstreet 23:50c98b286e41 102 */
masahikofukasawa 11:cef8dc1cf010 103 virtual AkmSensor::Status stopSensor();
tkstreet 23:50c98b286e41 104
tkstreet 23:50c98b286e41 105 /**
tkstreet 23:50c98b286e41 106 * Process abstraction for reading data from the sensor.
tkstreet 23:50c98b286e41 107 *
tkstreet 23:50c98b286e41 108 * @param msg Message object that will hold the sensor data.
tkstreet 23:50c98b286e41 109 * @return Termination status type for debugging purposes.
tkstreet 23:50c98b286e41 110 */
masahikofukasawa 11:cef8dc1cf010 111 virtual AkmSensor::Status readSensorData(Message* msg);
tkstreet 23:50c98b286e41 112
tkstreet 23:50c98b286e41 113 /**
tkstreet 23:50c98b286e41 114 * Primary process for interfacing a sensor with the AKDP. When implemented
tkstreet 23:50c98b286e41 115 * in sensor class, it will transfer commands between the the sensor control
tkstreet 23:50c98b286e41 116 * class and AkmSensorManager.
tkstreet 23:50c98b286e41 117 *
tkstreet 23:50c98b286e41 118 * @param in Command message to be processed by sensor.
tkstreet 23:50c98b286e41 119 * @param out Message returned from sensor.
tkstreet 23:50c98b286e41 120 * @return Termination status type for debugging purposes.
tkstreet 23:50c98b286e41 121 */
masahikofukasawa 11:cef8dc1cf010 122 virtual Status requestCommand(Message* in, Message* out);
masahikofukasawa 13:d008249f0359 123
masahikofukasawa 11:cef8dc1cf010 124 private:
masahikofukasawa 11:cef8dc1cf010 125 Ticker ticker;
masahikofukasawa 11:cef8dc1cf010 126 AnalogIn* ain;
masahikofukasawa 11:cef8dc1cf010 127 MCP342X* mcp3428;
masahikofukasawa 11:cef8dc1cf010 128 float interval;
masahikofukasawa 11:cef8dc1cf010 129 };
masahikofukasawa 11:cef8dc1cf010 130
masahikofukasawa 11:cef8dc1cf010 131 #endif