Modified for compatibility with Rev.E. hardware
Fork of AkmSensor by
akmakd.h@23:50c98b286e41, 2017-04-13 (annotated)
- Committer:
- tkstreet
- Date:
- Thu Apr 13 22:15:54 2017 +0000
- Revision:
- 23:50c98b286e41
- Parent:
- 13:d008249f0359
- Child:
- 24:1d37438f31a9
Added documentation for all classes
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
masahikofukasawa | 0:7a00359e701e | 1 | #ifndef AKMAKD_H |
masahikofukasawa | 0:7a00359e701e | 2 | #define AKMAKD_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 | #include "akmecompass.h" |
masahikofukasawa | 0:7a00359e701e | 8 | |
tkstreet | 23:50c98b286e41 | 9 | /** |
tkstreet | 23:50c98b286e41 | 10 | * Collection class for handling commands to all of the specialty AKM |
tkstreet | 23:50c98b286e41 | 11 | * daughter board adapter modules. |
tkstreet | 23:50c98b286e41 | 12 | * |
tkstreet | 23:50c98b286e41 | 13 | * 3-Axis Electronic Compass Devices: AK8963C, AK8963N, AK09911C, AK09912C, |
tkstreet | 23:50c98b286e41 | 14 | * AK09915C, AK09915D, AK09916C, AK09916D, AK09970 |
tkstreet | 23:50c98b286e41 | 15 | */ |
masahikofukasawa | 0:7a00359e701e | 16 | class AkmAkd : public AkmSensor |
masahikofukasawa | 0:7a00359e701e | 17 | { |
masahikofukasawa | 0:7a00359e701e | 18 | |
masahikofukasawa | 0:7a00359e701e | 19 | public: |
masahikofukasawa | 0:7a00359e701e | 20 | |
tkstreet | 23:50c98b286e41 | 21 | /** |
tkstreet | 23:50c98b286e41 | 22 | * List of daughter board adapter devices (5-bit Sub-IDs). Primary ID = 0Fh |
tkstreet | 23:50c98b286e41 | 23 | */ |
tkstreet | 23:50c98b286e41 | 24 | typedef enum { |
tkstreet | 23:50c98b286e41 | 25 | SUB_ID_AK8963N = 0x1A, /**< AK8963N: ID = 1Ah (26) */ |
tkstreet | 23:50c98b286e41 | 26 | SUB_ID_AK8963C = 0x1C, /**< AK8963C: ID = 1Ch (28) */ |
tkstreet | 23:50c98b286e41 | 27 | SUB_ID_AK09911C = 0x0A, /**< AK09911C: ID = 0Ah (10) */ |
tkstreet | 23:50c98b286e41 | 28 | SUB_ID_AK09912C = 0x09, /**< AK09912C: ID = 09h (9) */ |
tkstreet | 23:50c98b286e41 | 29 | SUB_ID_AK09915C = 0x0D, /**< AK09915C: ID = 0Dh (13) */ |
tkstreet | 23:50c98b286e41 | 30 | SUB_ID_AK09916C = 0x0E, /**< AK09916C: ID = 0Eh (14) */ |
tkstreet | 23:50c98b286e41 | 31 | SUB_ID_AK09916D = 0x0F, /**< AK09916D: ID = 0Fh (15) */ |
tkstreet | 23:50c98b286e41 | 32 | SUB_ID_AK09915D = 0x10, /**< AK09915D: ID = 10h (16) */ |
masahikofukasawa | 0:7a00359e701e | 33 | } SubIdAkd; |
masahikofukasawa | 0:7a00359e701e | 34 | |
masahikofukasawa | 0:7a00359e701e | 35 | /** |
masahikofukasawa | 0:7a00359e701e | 36 | * Constructor. |
masahikofukasawa | 0:7a00359e701e | 37 | * |
masahikofukasawa | 0:7a00359e701e | 38 | */ |
masahikofukasawa | 0:7a00359e701e | 39 | AkmAkd(); |
masahikofukasawa | 0:7a00359e701e | 40 | |
masahikofukasawa | 0:7a00359e701e | 41 | /** |
masahikofukasawa | 0:7a00359e701e | 42 | * Destructor. |
masahikofukasawa | 0:7a00359e701e | 43 | * |
masahikofukasawa | 0:7a00359e701e | 44 | */ |
masahikofukasawa | 0:7a00359e701e | 45 | virtual ~AkmAkd(); |
tkstreet | 23:50c98b286e41 | 46 | |
tkstreet | 23:50c98b286e41 | 47 | /** |
tkstreet | 23:50c98b286e41 | 48 | * Process for intializing the selected sensor. |
tkstreet | 23:50c98b286e41 | 49 | * |
tkstreet | 23:50c98b286e41 | 50 | * @return Termination status type for debugging purposes. |
tkstreet | 23:50c98b286e41 | 51 | */ |
masahikofukasawa | 0:7a00359e701e | 52 | virtual AkmSensor::Status init(const uint8_t id, const uint8_t subid); |
tkstreet | 23:50c98b286e41 | 53 | |
tkstreet | 23:50c98b286e41 | 54 | /** |
tkstreet | 23:50c98b286e41 | 55 | * Simple flag process to determine if an event has occurred. |
tkstreet | 23:50c98b286e41 | 56 | * |
tkstreet | 23:50c98b286e41 | 57 | * @return TRUE if event has occurred, FALSE if not. |
tkstreet | 23:50c98b286e41 | 58 | */ |
masahikofukasawa | 0:7a00359e701e | 59 | virtual bool isEvent(); |
tkstreet | 23:50c98b286e41 | 60 | |
tkstreet | 23:50c98b286e41 | 61 | /** |
tkstreet | 23:50c98b286e41 | 62 | * Process abstraction for starting sensor operation. |
tkstreet | 23:50c98b286e41 | 63 | * |
tkstreet | 23:50c98b286e41 | 64 | * @return Termination status type for debugging purposes. |
tkstreet | 23:50c98b286e41 | 65 | */ |
masahikofukasawa | 0:7a00359e701e | 66 | virtual AkmSensor::Status startSensor(); |
tkstreet | 23:50c98b286e41 | 67 | |
tkstreet | 23:50c98b286e41 | 68 | /** |
tkstreet | 23:50c98b286e41 | 69 | * Process abstraction for starting sensor operation. |
tkstreet | 23:50c98b286e41 | 70 | * |
tkstreet | 23:50c98b286e41 | 71 | * @param sec Number of seconds of operation. |
tkstreet | 23:50c98b286e41 | 72 | * @return Termination status type for debugging purposes. |
tkstreet | 23:50c98b286e41 | 73 | */ |
masahikofukasawa | 0:7a00359e701e | 74 | virtual AkmSensor::Status startSensor(const float sec); |
tkstreet | 23:50c98b286e41 | 75 | |
tkstreet | 23:50c98b286e41 | 76 | /** |
tkstreet | 23:50c98b286e41 | 77 | * Process abstraction for stopping sensor operation. |
tkstreet | 23:50c98b286e41 | 78 | * |
tkstreet | 23:50c98b286e41 | 79 | * @return Termination status type for debugging purposes. |
tkstreet | 23:50c98b286e41 | 80 | */ |
masahikofukasawa | 0:7a00359e701e | 81 | virtual AkmSensor::Status stopSensor(); |
tkstreet | 23:50c98b286e41 | 82 | |
tkstreet | 23:50c98b286e41 | 83 | /** |
tkstreet | 23:50c98b286e41 | 84 | * Process abstraction for reading data from the sensor. |
tkstreet | 23:50c98b286e41 | 85 | * |
tkstreet | 23:50c98b286e41 | 86 | * @param msg Message object that will hold the sensor data. |
tkstreet | 23:50c98b286e41 | 87 | * @return Termination status type for debugging purposes. |
tkstreet | 23:50c98b286e41 | 88 | */ |
masahikofukasawa | 0:7a00359e701e | 89 | virtual AkmSensor::Status readSensorData(Message* msg); |
tkstreet | 23:50c98b286e41 | 90 | |
tkstreet | 23:50c98b286e41 | 91 | /** |
tkstreet | 23:50c98b286e41 | 92 | * Primary process for interfacing a sensor with the AKDP. When implemented |
tkstreet | 23:50c98b286e41 | 93 | * in sensor class, it will transfer commands between the the sensor control |
tkstreet | 23:50c98b286e41 | 94 | * class and AkmSensorManager. |
tkstreet | 23:50c98b286e41 | 95 | * |
tkstreet | 23:50c98b286e41 | 96 | * @param in Command message to be processed by sensor. |
tkstreet | 23:50c98b286e41 | 97 | * @param out Message returned from sensor. |
tkstreet | 23:50c98b286e41 | 98 | * @return Termination status type for debugging purposes. |
tkstreet | 23:50c98b286e41 | 99 | */ |
masahikofukasawa | 0:7a00359e701e | 100 | virtual Status requestCommand(Message* in, Message* out); |
tkstreet | 23:50c98b286e41 | 101 | |
tkstreet | 23:50c98b286e41 | 102 | /** |
tkstreet | 23:50c98b286e41 | 103 | * Get the name of the sensor in char format. |
tkstreet | 23:50c98b286e41 | 104 | * |
tkstreet | 23:50c98b286e41 | 105 | * @return Sensor name as a char array. |
tkstreet | 23:50c98b286e41 | 106 | */ |
masahikofukasawa | 13:d008249f0359 | 107 | virtual char* getSensorName(); |
masahikofukasawa | 0:7a00359e701e | 108 | |
tkstreet | 23:50c98b286e41 | 109 | /** |
tkstreet | 23:50c98b286e41 | 110 | * Checks if data is ready or if there is a data overrun and store the |
tkstreet | 23:50c98b286e41 | 111 | * status in 'event'. |
tkstreet | 23:50c98b286e41 | 112 | */ |
masahikofukasawa | 0:7a00359e701e | 113 | void checkDRDY(); |
tkstreet | 23:50c98b286e41 | 114 | /** |
tkstreet | 23:50c98b286e41 | 115 | * Forces a data ready state by setting 'event' to TRUE. |
tkstreet | 23:50c98b286e41 | 116 | */ |
masahikofukasawa | 0:7a00359e701e | 117 | void detectDRDY(); |
tkstreet | 23:50c98b286e41 | 118 | /** |
tkstreet | 23:50c98b286e41 | 119 | * For AK8963, returns the type of sensor. |
tkstreet | 23:50c98b286e41 | 120 | */ |
masahikofukasawa | 0:7a00359e701e | 121 | int getSensorType(); |
masahikofukasawa | 0:7a00359e701e | 122 | |
masahikofukasawa | 0:7a00359e701e | 123 | private: |
masahikofukasawa | 0:7a00359e701e | 124 | bool event; |
masahikofukasawa | 0:7a00359e701e | 125 | uint8_t primaryId; |
masahikofukasawa | 0:7a00359e701e | 126 | uint8_t subId; |
masahikofukasawa | 13:d008249f0359 | 127 | char* sensorName; |
masahikofukasawa | 0:7a00359e701e | 128 | |
masahikofukasawa | 0:7a00359e701e | 129 | Ticker ticker; |
masahikofukasawa | 0:7a00359e701e | 130 | AkmECompass* compass; |
masahikofukasawa | 0:7a00359e701e | 131 | InterruptIn* drdy; |
masahikofukasawa | 9:6fa3e7b17c27 | 132 | AkmECompass::OperationMode mode; |
masahikofukasawa | 9:6fa3e7b17c27 | 133 | AkmECompass::Nsf nsf; |
masahikofukasawa | 9:6fa3e7b17c27 | 134 | AkmECompass::Sdr sdr; |
masahikofukasawa | 0:7a00359e701e | 135 | }; |
masahikofukasawa | 0:7a00359e701e | 136 | |
masahikofukasawa | 0:7a00359e701e | 137 | #endif |