Modified for compatibility with Rev.E. hardware
Fork of AkmSensor by
ak7401ctrl.h@43:45225713cd58, 2017-11-08 (annotated)
- Committer:
- tkstreet
- Date:
- Wed Nov 08 21:56:17 2017 +0000
- Revision:
- 43:45225713cd58
- Parent:
- 34:1ea3357c8d9a
- Child:
- 48:427bdb7bf31b
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 AK7401CTRL_H |
masahikofukasawa | 10:5c69b067d88a | 2 | #define AK7401CTRL_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 "ak7401.h" |
tkstreet | 43:45225713cd58 | 8 | //#include "akdp_debug.h" |
masahikofukasawa | 10:5c69b067d88a | 9 | |
tkstreet | 23:50c98b286e41 | 10 | /** |
tkstreet | 23:50c98b286e41 | 11 | * Class for handling commands issued to the AK7401. |
tkstreet | 23:50c98b286e41 | 12 | */ |
masahikofukasawa | 10:5c69b067d88a | 13 | class Ak7401Ctrl : public AkmSensor |
masahikofukasawa | 10:5c69b067d88a | 14 | { |
masahikofukasawa | 10:5c69b067d88a | 15 | |
masahikofukasawa | 10:5c69b067d88a | 16 | public: |
masahikofukasawa | 29:b488d2c89fba | 17 | |
masahikofukasawa | 29:b488d2c89fba | 18 | typedef AkmSensor base; |
masahikofukasawa | 10:5c69b067d88a | 19 | |
tkstreet | 23:50c98b286e41 | 20 | /** |
tkstreet | 23:50c98b286e41 | 21 | * Device Sub-ID. |
tkstreet | 23:50c98b286e41 | 22 | */ |
masahikofukasawa | 10:5c69b067d88a | 23 | typedef enum { |
tkstreet | 23:50c98b286e41 | 24 | SUB_ID_AK7401 = 0x02, /**< AK7401: ID = 02h */ |
masahikofukasawa | 10:5c69b067d88a | 25 | } SubIdAngleSensor; |
masahikofukasawa | 10:5c69b067d88a | 26 | |
masahikofukasawa | 10:5c69b067d88a | 27 | /** |
masahikofukasawa | 10:5c69b067d88a | 28 | * Constructor. |
masahikofukasawa | 10:5c69b067d88a | 29 | * |
masahikofukasawa | 10:5c69b067d88a | 30 | */ |
masahikofukasawa | 10:5c69b067d88a | 31 | Ak7401Ctrl(); |
masahikofukasawa | 10:5c69b067d88a | 32 | |
masahikofukasawa | 10:5c69b067d88a | 33 | /** |
masahikofukasawa | 10:5c69b067d88a | 34 | * Destructor. |
masahikofukasawa | 10:5c69b067d88a | 35 | * |
masahikofukasawa | 10:5c69b067d88a | 36 | */ |
masahikofukasawa | 10:5c69b067d88a | 37 | virtual ~Ak7401Ctrl(); |
tkstreet | 23:50c98b286e41 | 38 | |
tkstreet | 23:50c98b286e41 | 39 | /** |
tkstreet | 23:50c98b286e41 | 40 | * Process for intializing the selected sensor. |
tkstreet | 23:50c98b286e41 | 41 | * |
tkstreet | 23:50c98b286e41 | 42 | * @return Termination status type for debugging purposes. |
tkstreet | 23:50c98b286e41 | 43 | */ |
masahikofukasawa | 10:5c69b067d88a | 44 | virtual AkmSensor::Status init(const uint8_t id, const uint8_t subid); |
tkstreet | 23:50c98b286e41 | 45 | |
tkstreet | 23:50c98b286e41 | 46 | /** |
tkstreet | 23:50c98b286e41 | 47 | * Process abstraction for starting sensor operation. |
tkstreet | 23:50c98b286e41 | 48 | * |
tkstreet | 23:50c98b286e41 | 49 | * @return Termination status type for debugging purposes. |
tkstreet | 23:50c98b286e41 | 50 | */ |
masahikofukasawa | 10:5c69b067d88a | 51 | virtual AkmSensor::Status startSensor(); |
tkstreet | 23:50c98b286e41 | 52 | |
tkstreet | 23:50c98b286e41 | 53 | /** |
tkstreet | 23:50c98b286e41 | 54 | * Process abstraction for starting sensor operation. |
tkstreet | 23:50c98b286e41 | 55 | * |
tkstreet | 23:50c98b286e41 | 56 | * @param sec Number of seconds of operation. |
tkstreet | 23:50c98b286e41 | 57 | * @return Termination status type for debugging purposes. |
tkstreet | 23:50c98b286e41 | 58 | */ |
masahikofukasawa | 10:5c69b067d88a | 59 | virtual AkmSensor::Status startSensor(const float sec); |
tkstreet | 23:50c98b286e41 | 60 | |
tkstreet | 23:50c98b286e41 | 61 | /** |
tkstreet | 23:50c98b286e41 | 62 | * Process abstraction for stopping sensor operation. |
tkstreet | 23:50c98b286e41 | 63 | * |
tkstreet | 23:50c98b286e41 | 64 | * @return Termination status type for debugging purposes. |
tkstreet | 23:50c98b286e41 | 65 | */ |
masahikofukasawa | 10:5c69b067d88a | 66 | virtual AkmSensor::Status stopSensor(); |
tkstreet | 23:50c98b286e41 | 67 | |
tkstreet | 23:50c98b286e41 | 68 | /** |
tkstreet | 23:50c98b286e41 | 69 | * Process abstraction for reading data from the sensor. |
tkstreet | 23:50c98b286e41 | 70 | * |
tkstreet | 23:50c98b286e41 | 71 | * @param msg Message object that will hold the sensor data. |
tkstreet | 23:50c98b286e41 | 72 | * @return Termination status type for debugging purposes. |
tkstreet | 23:50c98b286e41 | 73 | */ |
masahikofukasawa | 10:5c69b067d88a | 74 | virtual AkmSensor::Status readSensorData(Message* msg); |
tkstreet | 23:50c98b286e41 | 75 | |
tkstreet | 23:50c98b286e41 | 76 | /** |
tkstreet | 23:50c98b286e41 | 77 | * Primary process for interfacing a sensor with the AKDP. When implemented |
tkstreet | 23:50c98b286e41 | 78 | * in sensor class, it will transfer commands between the the sensor control |
tkstreet | 23:50c98b286e41 | 79 | * class and AkmSensorManager. |
tkstreet | 23:50c98b286e41 | 80 | * |
tkstreet | 23:50c98b286e41 | 81 | * @param in Command message to be processed by sensor. |
tkstreet | 23:50c98b286e41 | 82 | * @param out Message returned from sensor. |
tkstreet | 23:50c98b286e41 | 83 | * @return Termination status type for debugging purposes. |
tkstreet | 23:50c98b286e41 | 84 | */ |
masahikofukasawa | 10:5c69b067d88a | 85 | virtual Status requestCommand(Message* in, Message* out); |
masahikofukasawa | 13:d008249f0359 | 86 | |
masahikofukasawa | 27:41aa9fb23a2f | 87 | private: |
masahikofukasawa | 10:5c69b067d88a | 88 | Ticker ticker; |
masahikofukasawa | 10:5c69b067d88a | 89 | AK7401* ak7401; |
masahikofukasawa | 10:5c69b067d88a | 90 | float interval; |
masahikofukasawa | 10:5c69b067d88a | 91 | }; |
masahikofukasawa | 10:5c69b067d88a | 92 | |
masahikofukasawa | 10:5c69b067d88a | 93 | #endif |