Modified for compatibility with Rev.E. hardware
Fork of AkmSensor by
ak09970ctrl.h@43:45225713cd58, 2017-11-08 (annotated)
- Committer:
- tkstreet
- Date:
- Wed Nov 08 21:56:17 2017 +0000
- Revision:
- 43:45225713cd58
- Parent:
- 39:3821886c902e
Moved all pin definitions to akdphwinfo header. Removed redundant library inclusions.
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 "akmsensor.h" |
masahikofukasawa | 10:5c69b067d88a | 6 | #include "ak09970.h" |
masahikofukasawa | 10:5c69b067d88a | 7 | |
tkstreet | 23:50c98b286e41 | 8 | /** |
tkstreet | 23:50c98b286e41 | 9 | * Class for handling commands issued to the AK09970. |
tkstreet | 23:50c98b286e41 | 10 | */ |
masahikofukasawa | 10:5c69b067d88a | 11 | class Ak09970Ctrl : public AkmSensor |
masahikofukasawa | 10:5c69b067d88a | 12 | { |
masahikofukasawa | 10:5c69b067d88a | 13 | |
masahikofukasawa | 10:5c69b067d88a | 14 | public: |
masahikofukasawa | 29:b488d2c89fba | 15 | |
masahikofukasawa | 29:b488d2c89fba | 16 | typedef AkmSensor base; |
masahikofukasawa | 10:5c69b067d88a | 17 | |
tkstreet | 23:50c98b286e41 | 18 | /** |
tkstreet | 23:50c98b286e41 | 19 | * Device Sub-ID (5-bit ID). |
tkstreet | 23:50c98b286e41 | 20 | */ |
tkstreet | 23:50c98b286e41 | 21 | typedef enum { |
tkstreet | 23:50c98b286e41 | 22 | SUB_ID_AK09970 = 0x03, /**< AK09970: ID = 03h */ |
masahikofukasawa | 10:5c69b067d88a | 23 | } SubIdSwitch; |
masahikofukasawa | 10:5c69b067d88a | 24 | |
masahikofukasawa | 10:5c69b067d88a | 25 | /** |
masahikofukasawa | 10:5c69b067d88a | 26 | * Constructor. |
masahikofukasawa | 10:5c69b067d88a | 27 | * |
masahikofukasawa | 10:5c69b067d88a | 28 | */ |
masahikofukasawa | 10:5c69b067d88a | 29 | Ak09970Ctrl(); |
masahikofukasawa | 10:5c69b067d88a | 30 | |
masahikofukasawa | 10:5c69b067d88a | 31 | /** |
masahikofukasawa | 10:5c69b067d88a | 32 | * Destructor. |
masahikofukasawa | 10:5c69b067d88a | 33 | * |
masahikofukasawa | 10:5c69b067d88a | 34 | */ |
masahikofukasawa | 10:5c69b067d88a | 35 | virtual ~Ak09970Ctrl(); |
tkstreet | 23:50c98b286e41 | 36 | |
tkstreet | 23:50c98b286e41 | 37 | /** |
tkstreet | 23:50c98b286e41 | 38 | * Process for intializing the selected sensor. |
tkstreet | 23:50c98b286e41 | 39 | * |
tkstreet | 23:50c98b286e41 | 40 | * @return Termination status type for debugging purposes. |
tkstreet | 23:50c98b286e41 | 41 | */ |
masahikofukasawa | 10:5c69b067d88a | 42 | virtual AkmSensor::Status init(const uint8_t id, const uint8_t subid); |
tkstreet | 23:50c98b286e41 | 43 | |
tkstreet | 23:50c98b286e41 | 44 | /** |
tkstreet | 23:50c98b286e41 | 45 | * Process abstraction for starting sensor operation. |
tkstreet | 23:50c98b286e41 | 46 | * |
tkstreet | 23:50c98b286e41 | 47 | * @return Termination status type for debugging purposes. |
tkstreet | 23:50c98b286e41 | 48 | */ |
masahikofukasawa | 10:5c69b067d88a | 49 | virtual AkmSensor::Status startSensor(); |
tkstreet | 23:50c98b286e41 | 50 | |
tkstreet | 23:50c98b286e41 | 51 | /** |
tkstreet | 23:50c98b286e41 | 52 | * Process abstraction for starting sensor operation. |
tkstreet | 23:50c98b286e41 | 53 | * |
tkstreet | 23:50c98b286e41 | 54 | * @param sec Number of seconds of operation. |
tkstreet | 23:50c98b286e41 | 55 | * @return Termination status type for debugging purposes. |
tkstreet | 23:50c98b286e41 | 56 | */ |
masahikofukasawa | 10:5c69b067d88a | 57 | virtual AkmSensor::Status startSensor(const float sec); |
tkstreet | 23:50c98b286e41 | 58 | |
tkstreet | 23:50c98b286e41 | 59 | /** |
tkstreet | 23:50c98b286e41 | 60 | * Process abstraction for stopping sensor operation. |
tkstreet | 23:50c98b286e41 | 61 | * |
tkstreet | 23:50c98b286e41 | 62 | * @return Termination status type for debugging purposes. |
tkstreet | 23:50c98b286e41 | 63 | */ |
masahikofukasawa | 10:5c69b067d88a | 64 | virtual AkmSensor::Status stopSensor(); |
tkstreet | 23:50c98b286e41 | 65 | |
tkstreet | 23:50c98b286e41 | 66 | /** |
tkstreet | 23:50c98b286e41 | 67 | * Process abstraction for reading data from the sensor. |
tkstreet | 23:50c98b286e41 | 68 | * |
tkstreet | 23:50c98b286e41 | 69 | * @param msg Message object that will hold the sensor data. |
tkstreet | 23:50c98b286e41 | 70 | * @return Termination status type for debugging purposes. |
tkstreet | 23:50c98b286e41 | 71 | */ |
masahikofukasawa | 10:5c69b067d88a | 72 | virtual AkmSensor::Status readSensorData(Message* msg); |
tkstreet | 23:50c98b286e41 | 73 | |
tkstreet | 23:50c98b286e41 | 74 | /** |
tkstreet | 23:50c98b286e41 | 75 | * Primary process for interfacing a sensor with the AKDP. When implemented |
tkstreet | 23:50c98b286e41 | 76 | * in sensor class, it will transfer commands between the the sensor control |
tkstreet | 23:50c98b286e41 | 77 | * class and AkmSensorManager. |
tkstreet | 23:50c98b286e41 | 78 | * |
tkstreet | 23:50c98b286e41 | 79 | * @param in Command message to be processed by sensor. |
tkstreet | 23:50c98b286e41 | 80 | * @param out Message returned from sensor. |
tkstreet | 23:50c98b286e41 | 81 | * @return Termination status type for debugging purposes. |
tkstreet | 23:50c98b286e41 | 82 | */ |
masahikofukasawa | 10:5c69b067d88a | 83 | virtual AkmSensor::Status requestCommand(Message* in, Message* out); |
tkstreet | 34:1ea3357c8d9a | 84 | |
tkstreet | 23:50c98b286e41 | 85 | /** |
tkstreet | 34:1ea3357c8d9a | 86 | * Set event flag. |
tkstreet | 23:50c98b286e41 | 87 | */ |
masahikofukasawa | 29:b488d2c89fba | 88 | virtual void setEvent(); |
masahikofukasawa | 10:5c69b067d88a | 89 | |
masahikofukasawa | 10:5c69b067d88a | 90 | private: |
masahikofukasawa | 10:5c69b067d88a | 91 | AK09970* ak09970; |
masahikofukasawa | 10:5c69b067d88a | 92 | |
masahikofukasawa | 10:5c69b067d88a | 93 | // hold settings for AK09970 |
masahikofukasawa | 10:5c69b067d88a | 94 | AK09970::Threshold threshold; |
masahikofukasawa | 10:5c69b067d88a | 95 | AK09970::OperationMode mode; |
masahikofukasawa | 10:5c69b067d88a | 96 | AK09970::SensorDriveMode sensorDriveMode; |
masahikofukasawa | 10:5c69b067d88a | 97 | AK09970::SensorMeasurementRange sensorMeasurementRange; |
masahikofukasawa | 10:5c69b067d88a | 98 | AK09970::ReadConfig readConfig; |
masahikofukasawa | 10:5c69b067d88a | 99 | AK09970::SwitchConfig switchConfig; |
masahikofukasawa | 10:5c69b067d88a | 100 | }; |
masahikofukasawa | 10:5c69b067d88a | 101 | |
masahikofukasawa | 10:5c69b067d88a | 102 | #endif |
masahikofukasawa | 10:5c69b067d88a | 103 |