Modified for compatibility with Rev.E. hardware
Fork of AkmSensor by
akmanalogsensor.h@49:c8f8946129b6, 2018-05-01 (annotated)
- 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?
User | Revision | Line number | New 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 "akmsensor.h" |
tkstreet | 49:c8f8946129b6 | 6 | //#include "mcp342x.h" |
masahikofukasawa | 11:cef8dc1cf010 | 7 | |
tkstreet | 23:50c98b286e41 | 8 | /** |
tkstreet | 23:50c98b286e41 | 9 | * Collection class for handling commands to all AKM Analog Sensor modules. |
tkstreet | 23:50c98b286e41 | 10 | * |
tkstreet | 23:50c98b286e41 | 11 | * List of Devices: |
tkstreet | 23:50c98b286e41 | 12 | * |
masahikofukasawa | 37:c76d2edf3426 | 13 | * Current Sensors CQ32xx: CQ3200, CQ3201, CQ3202, CQ3203, CQ3204, CQ320A, CQ320B, |
masahikofukasawa | 37:c76d2edf3426 | 14 | * |
masahikofukasawa | 37:c76d2edf3426 | 15 | * Current Sensors CQ33xx: CQ3300, CQ3301, CQ3302, CQ3303, CQ330A, CQ330B, CQ330E, |
masahikofukasawa | 37:c76d2edf3426 | 16 | * CQ330F, CQ330G, CQ330H, CQ330J |
tkstreet | 23:50c98b286e41 | 17 | * |
tkstreet | 23:50c98b286e41 | 18 | * Linear Sensors: EQ430L, EQ431L, EQ432L, EQ433L |
tkstreet | 23:50c98b286e41 | 19 | * |
tkstreet | 23:50c98b286e41 | 20 | * Angle Sensors: EM3242 |
tkstreet | 23:50c98b286e41 | 21 | * |
tkstreet | 23:50c98b286e41 | 22 | * IR/CO2 Sensor: AK9710 |
tkstreet | 23:50c98b286e41 | 23 | */ |
masahikofukasawa | 11:cef8dc1cf010 | 24 | class AkmAnalogSensor : public AkmSensor |
masahikofukasawa | 11:cef8dc1cf010 | 25 | { |
masahikofukasawa | 11:cef8dc1cf010 | 26 | |
masahikofukasawa | 11:cef8dc1cf010 | 27 | public: |
masahikofukasawa | 29:b488d2c89fba | 28 | |
masahikofukasawa | 29:b488d2c89fba | 29 | typedef AkmSensor base; |
tkstreet | 23:50c98b286e41 | 30 | |
tkstreet | 23:50c98b286e41 | 31 | /** |
masahikofukasawa | 37:c76d2edf3426 | 32 | * Sub-IDs for current sensor CQ32xx devices. Primary ID = 07h |
masahikofukasawa | 37:c76d2edf3426 | 33 | */ |
masahikofukasawa | 37:c76d2edf3426 | 34 | typedef enum { |
masahikofukasawa | 37:c76d2edf3426 | 35 | SUB_ID_CQ3200 = 0x01, /**< CQ3200: ID = 01h */ |
masahikofukasawa | 37:c76d2edf3426 | 36 | SUB_ID_CQ3201 = 0x02, /**< CQ3201: ID = 02h */ |
masahikofukasawa | 37:c76d2edf3426 | 37 | SUB_ID_CQ3202 = 0x03, /**< CQ3202: ID = 03h */ |
masahikofukasawa | 37:c76d2edf3426 | 38 | SUB_ID_CQ3203 = 0x04, /**< CQ3203: ID = 04h */ |
masahikofukasawa | 37:c76d2edf3426 | 39 | SUB_ID_CQ3204 = 0x05, /**< CQ3204: ID = 05h */ |
masahikofukasawa | 37:c76d2edf3426 | 40 | SUB_ID_CQ320A = 0x06, /**< CQ320A: ID = 06h */ |
masahikofukasawa | 37:c76d2edf3426 | 41 | SUB_ID_CQ320B = 0x07, /**< CQ320B: ID = 07h */ |
masahikofukasawa | 37:c76d2edf3426 | 42 | } SubIdCurrentSensor3v; |
masahikofukasawa | 37:c76d2edf3426 | 43 | |
masahikofukasawa | 37:c76d2edf3426 | 44 | /** |
masahikofukasawa | 37:c76d2edf3426 | 45 | * Sub-IDs for current sensor CQ33xx devices. Primary ID = 09h |
tkstreet | 23:50c98b286e41 | 46 | */ |
masahikofukasawa | 11:cef8dc1cf010 | 47 | typedef enum { |
tkstreet | 23:50c98b286e41 | 48 | SUB_ID_CQ3300 = 0x01, /**< CQ3300: ID = 01h */ |
tkstreet | 23:50c98b286e41 | 49 | SUB_ID_CQ3301 = 0x02, /**< CQ3301: ID = 02h */ |
tkstreet | 23:50c98b286e41 | 50 | SUB_ID_CQ3302 = 0x03, /**< CQ3302: ID = 03h */ |
tkstreet | 23:50c98b286e41 | 51 | SUB_ID_CQ3303 = 0x04, /**< CQ3303: ID = 04h */ |
tkstreet | 23:50c98b286e41 | 52 | SUB_ID_CQ330A = 0x05, /**< CQ330A: ID = 05h */ |
tkstreet | 23:50c98b286e41 | 53 | SUB_ID_CQ330B = 0x06, /**< CQ330B: ID = 06h */ |
tkstreet | 23:50c98b286e41 | 54 | SUB_ID_CQ330E = 0x07, /**< CQ330E: ID = 07h */ |
tkstreet | 23:50c98b286e41 | 55 | SUB_ID_CQ330F = 0x08, /**< CQ330F: ID = 08h */ |
tkstreet | 23:50c98b286e41 | 56 | SUB_ID_CQ330G = 0x09, /**< CQ330G: ID = 09h */ |
tkstreet | 23:50c98b286e41 | 57 | SUB_ID_CQ330H = 0x0A, /**< CQ330H: ID = 0Ah */ |
masahikofukasawa | 37:c76d2edf3426 | 58 | SUB_ID_CQ330J = 0x0B, /**< CQ330J: ID = 0Bh */ |
masahikofukasawa | 37:c76d2edf3426 | 59 | SUB_ID_CZ3813 = 0x0D, /**< CQ3813: ID = 0Dh */ |
masahikofukasawa | 37:c76d2edf3426 | 60 | SUB_ID_CZ3814 = 0x0E, /**< CQ3814: ID = 0Eh */ |
masahikofukasawa | 37:c76d2edf3426 | 61 | SUB_ID_CZ3815 = 0x0F, /**< CQ3815: ID = 0Fh */ |
masahikofukasawa | 37:c76d2edf3426 | 62 | } SubIdCurrentSensor5v; |
masahikofukasawa | 13:d008249f0359 | 63 | |
tkstreet | 23:50c98b286e41 | 64 | /** |
tkstreet | 23:50c98b286e41 | 65 | * Sub-IDs for miscellaneous devices. Primary ID = 0Ah |
tkstreet | 23:50c98b286e41 | 66 | */ |
masahikofukasawa | 13:d008249f0359 | 67 | typedef enum { |
tkstreet | 23:50c98b286e41 | 68 | SUB_ID_EM3242 = 0x01, /**< EM3242: ID = 01h */ |
tkstreet | 23:50c98b286e41 | 69 | SUB_ID_AK9710 = 0x08, /**< AK9710: ID = 08h */ |
masahikofukasawa | 13:d008249f0359 | 70 | } SubIdMisc; |
masahikofukasawa | 13:d008249f0359 | 71 | |
tkstreet | 23:50c98b286e41 | 72 | /** |
tkstreet | 23:50c98b286e41 | 73 | * Sub-IDs for analog devices. Primary ID = 0Bh |
tkstreet | 23:50c98b286e41 | 74 | */ |
masahikofukasawa | 13:d008249f0359 | 75 | typedef enum { |
tkstreet | 23:50c98b286e41 | 76 | SUB_ID_EQ430L = 0x01, /**< EQ430L: ID = 01h */ |
masahikofukasawa | 37:c76d2edf3426 | 77 | SUB_ID_EQ431L = 0x02, /**< EQ431L: ID = 02h */ |
masahikofukasawa | 37:c76d2edf3426 | 78 | SUB_ID_EQ432L = 0x03, /**< EQ432L: ID = 03h */ |
masahikofukasawa | 37:c76d2edf3426 | 79 | SUB_ID_EQ433L = 0x04, /**< EQ433L: ID = 04h */ |
masahikofukasawa | 11:cef8dc1cf010 | 80 | } SubIdLinearSensor; |
masahikofukasawa | 11:cef8dc1cf010 | 81 | |
masahikofukasawa | 11:cef8dc1cf010 | 82 | /** |
masahikofukasawa | 11:cef8dc1cf010 | 83 | * Constructor. |
masahikofukasawa | 11:cef8dc1cf010 | 84 | * |
masahikofukasawa | 11:cef8dc1cf010 | 85 | */ |
masahikofukasawa | 11:cef8dc1cf010 | 86 | AkmAnalogSensor(); |
masahikofukasawa | 11:cef8dc1cf010 | 87 | |
masahikofukasawa | 11:cef8dc1cf010 | 88 | /** |
masahikofukasawa | 11:cef8dc1cf010 | 89 | * Destructor. |
masahikofukasawa | 11:cef8dc1cf010 | 90 | * |
masahikofukasawa | 11:cef8dc1cf010 | 91 | */ |
masahikofukasawa | 11:cef8dc1cf010 | 92 | virtual ~AkmAnalogSensor(); |
tkstreet | 23:50c98b286e41 | 93 | |
tkstreet | 23:50c98b286e41 | 94 | /** |
tkstreet | 23:50c98b286e41 | 95 | * Process for intializing the selected sensor. |
tkstreet | 23:50c98b286e41 | 96 | * |
tkstreet | 23:50c98b286e41 | 97 | * @return Termination status type for debugging purposes. |
tkstreet | 23:50c98b286e41 | 98 | */ |
tkstreet | 49:c8f8946129b6 | 99 | virtual AkmSensor::Status init(const uint8_t p_id, const uint8_t s_id); |
tkstreet | 23:50c98b286e41 | 100 | |
tkstreet | 23:50c98b286e41 | 101 | /** |
tkstreet | 23:50c98b286e41 | 102 | * Process abstraction for starting sensor operation. |
tkstreet | 23:50c98b286e41 | 103 | * |
tkstreet | 23:50c98b286e41 | 104 | * @return Termination status type for debugging purposes. |
tkstreet | 23:50c98b286e41 | 105 | */ |
masahikofukasawa | 11:cef8dc1cf010 | 106 | virtual AkmSensor::Status startSensor(); |
tkstreet | 23:50c98b286e41 | 107 | |
tkstreet | 23:50c98b286e41 | 108 | /** |
tkstreet | 23:50c98b286e41 | 109 | * Process abstraction for starting sensor operation. |
tkstreet | 23:50c98b286e41 | 110 | * |
tkstreet | 23:50c98b286e41 | 111 | * @param sec Number of seconds of operation. |
tkstreet | 23:50c98b286e41 | 112 | * @return Termination status type for debugging purposes. |
tkstreet | 23:50c98b286e41 | 113 | */ |
masahikofukasawa | 11:cef8dc1cf010 | 114 | virtual AkmSensor::Status startSensor(const float sec); |
tkstreet | 23:50c98b286e41 | 115 | |
tkstreet | 23:50c98b286e41 | 116 | /** |
tkstreet | 23:50c98b286e41 | 117 | * Process abstraction for stopping sensor operation. |
tkstreet | 23:50c98b286e41 | 118 | * |
tkstreet | 23:50c98b286e41 | 119 | * @return Termination status type for debugging purposes. |
tkstreet | 23:50c98b286e41 | 120 | */ |
masahikofukasawa | 11:cef8dc1cf010 | 121 | virtual AkmSensor::Status stopSensor(); |
tkstreet | 23:50c98b286e41 | 122 | |
tkstreet | 23:50c98b286e41 | 123 | /** |
tkstreet | 23:50c98b286e41 | 124 | * Process abstraction for reading data from the sensor. |
tkstreet | 23:50c98b286e41 | 125 | * |
tkstreet | 23:50c98b286e41 | 126 | * @param msg Message object that will hold the sensor data. |
tkstreet | 23:50c98b286e41 | 127 | * @return Termination status type for debugging purposes. |
tkstreet | 23:50c98b286e41 | 128 | */ |
masahikofukasawa | 11:cef8dc1cf010 | 129 | virtual AkmSensor::Status readSensorData(Message* msg); |
tkstreet | 23:50c98b286e41 | 130 | |
tkstreet | 23:50c98b286e41 | 131 | /** |
tkstreet | 23:50c98b286e41 | 132 | * Primary process for interfacing a sensor with the AKDP. When implemented |
tkstreet | 23:50c98b286e41 | 133 | * in sensor class, it will transfer commands between the the sensor control |
tkstreet | 23:50c98b286e41 | 134 | * class and AkmSensorManager. |
tkstreet | 23:50c98b286e41 | 135 | * |
tkstreet | 23:50c98b286e41 | 136 | * @param in Command message to be processed by sensor. |
tkstreet | 23:50c98b286e41 | 137 | * @param out Message returned from sensor. |
tkstreet | 23:50c98b286e41 | 138 | * @return Termination status type for debugging purposes. |
tkstreet | 23:50c98b286e41 | 139 | */ |
masahikofukasawa | 11:cef8dc1cf010 | 140 | virtual Status requestCommand(Message* in, Message* out); |
masahikofukasawa | 13:d008249f0359 | 141 | |
masahikofukasawa | 11:cef8dc1cf010 | 142 | private: |
masahikofukasawa | 11:cef8dc1cf010 | 143 | Ticker ticker; |
masahikofukasawa | 11:cef8dc1cf010 | 144 | AnalogIn* ain; |
tkstreet | 49:c8f8946129b6 | 145 | AnalogIn* ain2; |
masahikofukasawa | 11:cef8dc1cf010 | 146 | float interval; |
masahikofukasawa | 11:cef8dc1cf010 | 147 | }; |
masahikofukasawa | 11:cef8dc1cf010 | 148 | |
masahikofukasawa | 11:cef8dc1cf010 | 149 | #endif |