Modified for compatibility with Rev.E. hardware
Fork of AkmSensor by
ak09970ctrl.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:
- 34:1ea3357c8d9a
Added documentation for all classes
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
masahikofukasawa | 10:5c69b067d88a | 1 | #ifndef AK09970CTRL_H |
masahikofukasawa | 10:5c69b067d88a | 2 | #define AK09970CTRL_H |
masahikofukasawa | 10:5c69b067d88a | 3 | |
masahikofukasawa | 10:5c69b067d88a | 4 | #include "mbed.h" |
masahikofukasawa | 10:5c69b067d88a | 5 | #include "SerialNano.h" |
masahikofukasawa | 10:5c69b067d88a | 6 | #include "akmsensor.h" |
masahikofukasawa | 10:5c69b067d88a | 7 | #include "ak09970.h" |
masahikofukasawa | 10:5c69b067d88a | 8 | |
tkstreet | 23:50c98b286e41 | 9 | /** |
tkstreet | 23:50c98b286e41 | 10 | * Class for handling commands issued to the AK09970. |
tkstreet | 23:50c98b286e41 | 11 | */ |
masahikofukasawa | 10:5c69b067d88a | 12 | class Ak09970Ctrl : public AkmSensor |
masahikofukasawa | 10:5c69b067d88a | 13 | { |
masahikofukasawa | 10:5c69b067d88a | 14 | |
masahikofukasawa | 10:5c69b067d88a | 15 | public: |
masahikofukasawa | 10:5c69b067d88a | 16 | |
tkstreet | 23:50c98b286e41 | 17 | /** |
tkstreet | 23:50c98b286e41 | 18 | * Device Sub-ID (5-bit ID). |
tkstreet | 23:50c98b286e41 | 19 | */ |
tkstreet | 23:50c98b286e41 | 20 | typedef enum { |
tkstreet | 23:50c98b286e41 | 21 | SUB_ID_AK09970 = 0x03, /**< AK09970: ID = 03h */ |
masahikofukasawa | 10:5c69b067d88a | 22 | } SubIdSwitch; |
masahikofukasawa | 10:5c69b067d88a | 23 | |
masahikofukasawa | 10:5c69b067d88a | 24 | /** |
masahikofukasawa | 10:5c69b067d88a | 25 | * Constructor. |
masahikofukasawa | 10:5c69b067d88a | 26 | * |
masahikofukasawa | 10:5c69b067d88a | 27 | */ |
masahikofukasawa | 10:5c69b067d88a | 28 | Ak09970Ctrl(); |
masahikofukasawa | 10:5c69b067d88a | 29 | |
masahikofukasawa | 10:5c69b067d88a | 30 | /** |
masahikofukasawa | 10:5c69b067d88a | 31 | * Destructor. |
masahikofukasawa | 10:5c69b067d88a | 32 | * |
masahikofukasawa | 10:5c69b067d88a | 33 | */ |
masahikofukasawa | 10:5c69b067d88a | 34 | virtual ~Ak09970Ctrl(); |
tkstreet | 23:50c98b286e41 | 35 | |
tkstreet | 23:50c98b286e41 | 36 | /** |
tkstreet | 23:50c98b286e41 | 37 | * Process for intializing the selected sensor. |
tkstreet | 23:50c98b286e41 | 38 | * |
tkstreet | 23:50c98b286e41 | 39 | * @return Termination status type for debugging purposes. |
tkstreet | 23:50c98b286e41 | 40 | */ |
masahikofukasawa | 10:5c69b067d88a | 41 | virtual AkmSensor::Status init(const uint8_t id, const uint8_t subid); |
tkstreet | 23:50c98b286e41 | 42 | |
tkstreet | 23:50c98b286e41 | 43 | /** |
tkstreet | 23:50c98b286e41 | 44 | * Simple flag process to determine if an event has occurred. |
tkstreet | 23:50c98b286e41 | 45 | * |
tkstreet | 23:50c98b286e41 | 46 | * @return TRUE if event has occurred, FALSE if not. |
tkstreet | 23:50c98b286e41 | 47 | */ |
masahikofukasawa | 10:5c69b067d88a | 48 | virtual bool isEvent(); |
tkstreet | 23:50c98b286e41 | 49 | |
tkstreet | 23:50c98b286e41 | 50 | /** |
tkstreet | 23:50c98b286e41 | 51 | * Process abstraction for starting sensor operation. |
tkstreet | 23:50c98b286e41 | 52 | * |
tkstreet | 23:50c98b286e41 | 53 | * @return Termination status type for debugging purposes. |
tkstreet | 23:50c98b286e41 | 54 | */ |
masahikofukasawa | 10:5c69b067d88a | 55 | virtual AkmSensor::Status startSensor(); |
tkstreet | 23:50c98b286e41 | 56 | |
tkstreet | 23:50c98b286e41 | 57 | /** |
tkstreet | 23:50c98b286e41 | 58 | * Process abstraction for starting sensor operation. |
tkstreet | 23:50c98b286e41 | 59 | * |
tkstreet | 23:50c98b286e41 | 60 | * @param sec Number of seconds of operation. |
tkstreet | 23:50c98b286e41 | 61 | * @return Termination status type for debugging purposes. |
tkstreet | 23:50c98b286e41 | 62 | */ |
masahikofukasawa | 10:5c69b067d88a | 63 | virtual AkmSensor::Status startSensor(const float sec); |
tkstreet | 23:50c98b286e41 | 64 | |
tkstreet | 23:50c98b286e41 | 65 | /** |
tkstreet | 23:50c98b286e41 | 66 | * Process abstraction for stopping sensor operation. |
tkstreet | 23:50c98b286e41 | 67 | * |
tkstreet | 23:50c98b286e41 | 68 | * @return Termination status type for debugging purposes. |
tkstreet | 23:50c98b286e41 | 69 | */ |
masahikofukasawa | 10:5c69b067d88a | 70 | virtual AkmSensor::Status stopSensor(); |
tkstreet | 23:50c98b286e41 | 71 | |
tkstreet | 23:50c98b286e41 | 72 | /** |
tkstreet | 23:50c98b286e41 | 73 | * Process abstraction for reading data from the sensor. |
tkstreet | 23:50c98b286e41 | 74 | * |
tkstreet | 23:50c98b286e41 | 75 | * @param msg Message object that will hold the sensor data. |
tkstreet | 23:50c98b286e41 | 76 | * @return Termination status type for debugging purposes. |
tkstreet | 23:50c98b286e41 | 77 | */ |
masahikofukasawa | 10:5c69b067d88a | 78 | virtual AkmSensor::Status readSensorData(Message* msg); |
tkstreet | 23:50c98b286e41 | 79 | |
tkstreet | 23:50c98b286e41 | 80 | /** |
tkstreet | 23:50c98b286e41 | 81 | * Primary process for interfacing a sensor with the AKDP. When implemented |
tkstreet | 23:50c98b286e41 | 82 | * in sensor class, it will transfer commands between the the sensor control |
tkstreet | 23:50c98b286e41 | 83 | * class and AkmSensorManager. |
tkstreet | 23:50c98b286e41 | 84 | * |
tkstreet | 23:50c98b286e41 | 85 | * @param in Command message to be processed by sensor. |
tkstreet | 23:50c98b286e41 | 86 | * @param out Message returned from sensor. |
tkstreet | 23:50c98b286e41 | 87 | * @return Termination status type for debugging purposes. |
tkstreet | 23:50c98b286e41 | 88 | */ |
tkstreet | 23:50c98b286e41 | 89 | virtual Status requestCommand(Message* in, Message* out); |
tkstreet | 23:50c98b286e41 | 90 | |
tkstreet | 23:50c98b286e41 | 91 | /** |
tkstreet | 23:50c98b286e41 | 92 | * Get the name of the sensor in char format. |
tkstreet | 23:50c98b286e41 | 93 | * |
tkstreet | 23:50c98b286e41 | 94 | * @return Sensor name as a char array. |
tkstreet | 23:50c98b286e41 | 95 | */ |
masahikofukasawa | 13:d008249f0359 | 96 | virtual char* getSensorName(); |
masahikofukasawa | 10:5c69b067d88a | 97 | |
tkstreet | 23:50c98b286e41 | 98 | /** |
tkstreet | 23:50c98b286e41 | 99 | * If data is ready or data overrun has occurred, the event flag is set. |
tkstreet | 23:50c98b286e41 | 100 | */ |
masahikofukasawa | 10:5c69b067d88a | 101 | void checkINT(); |
tkstreet | 23:50c98b286e41 | 102 | /** |
tkstreet | 23:50c98b286e41 | 103 | * Causes the detecting of an interrupt by setting the event flag. |
tkstreet | 23:50c98b286e41 | 104 | */ |
masahikofukasawa | 10:5c69b067d88a | 105 | void detectINT(); |
masahikofukasawa | 10:5c69b067d88a | 106 | |
masahikofukasawa | 10:5c69b067d88a | 107 | private: |
masahikofukasawa | 10:5c69b067d88a | 108 | bool event; |
masahikofukasawa | 10:5c69b067d88a | 109 | uint8_t primaryId; |
masahikofukasawa | 10:5c69b067d88a | 110 | uint8_t subId; |
masahikofukasawa | 10:5c69b067d88a | 111 | AK09970* ak09970; |
masahikofukasawa | 13:d008249f0359 | 112 | char* sensorName; |
masahikofukasawa | 10:5c69b067d88a | 113 | |
masahikofukasawa | 10:5c69b067d88a | 114 | // hold settings for AK09970 |
masahikofukasawa | 10:5c69b067d88a | 115 | AK09970::Threshold threshold; |
masahikofukasawa | 10:5c69b067d88a | 116 | AK09970::OperationMode mode; |
masahikofukasawa | 10:5c69b067d88a | 117 | AK09970::SensorDriveMode sensorDriveMode; |
masahikofukasawa | 10:5c69b067d88a | 118 | AK09970::SensorMeasurementRange sensorMeasurementRange; |
masahikofukasawa | 10:5c69b067d88a | 119 | AK09970::ReadConfig readConfig; |
masahikofukasawa | 10:5c69b067d88a | 120 | AK09970::SwitchConfig switchConfig; |
masahikofukasawa | 10:5c69b067d88a | 121 | |
masahikofukasawa | 10:5c69b067d88a | 122 | InterruptIn* sw; |
masahikofukasawa | 10:5c69b067d88a | 123 | }; |
masahikofukasawa | 10:5c69b067d88a | 124 | |
masahikofukasawa | 10:5c69b067d88a | 125 | #endif |
masahikofukasawa | 10:5c69b067d88a | 126 |