Modified for compatibility with Rev.E. hardware

Fork of AkmSensor by AKM Development Platform

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?

UserRevisionLine numberNew contents of line
masahikofukasawa 10:5c69b067d88a 1 #ifndef AK9752CTRL_H
masahikofukasawa 10:5c69b067d88a 2 #define AK9752CTRL_H
masahikofukasawa 10:5c69b067d88a 3
masahikofukasawa 10:5c69b067d88a 4 #include "mbed.h"
masahikofukasawa 10:5c69b067d88a 5 #include "akmsensor.h"
masahikofukasawa 10:5c69b067d88a 6 #include "AK9752.h"
masahikofukasawa 10:5c69b067d88a 7
tkstreet 23:50c98b286e41 8 /**
tkstreet 23:50c98b286e41 9 * Class for handling commands issued to the AK9752.
tkstreet 23:50c98b286e41 10 */
masahikofukasawa 10:5c69b067d88a 11 class Ak9752Ctrl : public AkmSensor
masahikofukasawa 10:5c69b067d88a 12 {
masahikofukasawa 10:5c69b067d88a 13
masahikofukasawa 10:5c69b067d88a 14 public:
tkstreet 23:50c98b286e41 15
tkstreet 23:50c98b286e41 16 /**
tkstreet 23:50c98b286e41 17 * Device Sub-ID
tkstreet 23:50c98b286e41 18 */
masahikofukasawa 10:5c69b067d88a 19 typedef enum {
tkstreet 23:50c98b286e41 20 SUB_ID_AK9752 = 0x02 /**< AK9752: 02h */
masahikofukasawa 10:5c69b067d88a 21 } SubIdAk9752;
masahikofukasawa 10:5c69b067d88a 22
masahikofukasawa 10:5c69b067d88a 23 /**
masahikofukasawa 10:5c69b067d88a 24 * Constructor.
masahikofukasawa 10:5c69b067d88a 25 *
masahikofukasawa 10:5c69b067d88a 26 */
masahikofukasawa 10:5c69b067d88a 27 Ak9752Ctrl();
masahikofukasawa 10:5c69b067d88a 28
masahikofukasawa 10:5c69b067d88a 29 /**
masahikofukasawa 10:5c69b067d88a 30 * Destructor.
masahikofukasawa 10:5c69b067d88a 31 *
masahikofukasawa 10:5c69b067d88a 32 */
masahikofukasawa 10:5c69b067d88a 33 virtual ~Ak9752Ctrl();
tkstreet 23:50c98b286e41 34
tkstreet 23:50c98b286e41 35 /**
tkstreet 23:50c98b286e41 36 * Process for intializing the selected sensor.
tkstreet 23:50c98b286e41 37 *
tkstreet 23:50c98b286e41 38 * @return Termination status type for debugging purposes.
tkstreet 23:50c98b286e41 39 */
masahikofukasawa 10:5c69b067d88a 40 virtual AkmSensor::Status init(const uint8_t id, const uint8_t subid);
tkstreet 23:50c98b286e41 41
tkstreet 23:50c98b286e41 42 /**
tkstreet 23:50c98b286e41 43 * Simple flag process to determine if an event has occurred.
tkstreet 23:50c98b286e41 44 *
tkstreet 23:50c98b286e41 45 * @return TRUE if event has occurred, FALSE if not.
tkstreet 23:50c98b286e41 46 */
masahikofukasawa 10:5c69b067d88a 47 virtual bool isEvent();
tkstreet 23:50c98b286e41 48
tkstreet 23:50c98b286e41 49 /**
tkstreet 23:50c98b286e41 50 * Process abstraction for starting sensor operation.
tkstreet 23:50c98b286e41 51 *
tkstreet 23:50c98b286e41 52 * @return Termination status type for debugging purposes.
tkstreet 23:50c98b286e41 53 */
masahikofukasawa 10:5c69b067d88a 54 virtual AkmSensor::Status startSensor();
tkstreet 23:50c98b286e41 55
tkstreet 23:50c98b286e41 56 /**
tkstreet 23:50c98b286e41 57 * Process abstraction for starting sensor operation.
tkstreet 23:50c98b286e41 58 *
tkstreet 23:50c98b286e41 59 * @param sec Number of seconds of operation.
tkstreet 23:50c98b286e41 60 * @return Termination status type for debugging purposes.
tkstreet 23:50c98b286e41 61 */
masahikofukasawa 10:5c69b067d88a 62 virtual AkmSensor::Status startSensor(const float sec);
tkstreet 23:50c98b286e41 63
tkstreet 23:50c98b286e41 64 /**
tkstreet 23:50c98b286e41 65 * Process abstraction for stopping sensor operation.
tkstreet 23:50c98b286e41 66 *
tkstreet 23:50c98b286e41 67 * @return Termination status type for debugging purposes.
tkstreet 23:50c98b286e41 68 */
masahikofukasawa 10:5c69b067d88a 69 virtual AkmSensor::Status stopSensor();
tkstreet 23:50c98b286e41 70
tkstreet 23:50c98b286e41 71 /**
tkstreet 23:50c98b286e41 72 * Process abstraction for reading data from the sensor.
tkstreet 23:50c98b286e41 73 *
tkstreet 23:50c98b286e41 74 * @param msg Message object that will hold the sensor data.
tkstreet 23:50c98b286e41 75 * @return Termination status type for debugging purposes.
tkstreet 23:50c98b286e41 76 */
masahikofukasawa 10:5c69b067d88a 77 virtual AkmSensor::Status readSensorData(Message* msg);
tkstreet 23:50c98b286e41 78
tkstreet 23:50c98b286e41 79 /**
tkstreet 23:50c98b286e41 80 * Primary process for interfacing a sensor with the AKDP. When implemented
tkstreet 23:50c98b286e41 81 * in sensor class, it will transfer commands between the the sensor control
tkstreet 23:50c98b286e41 82 * class and AkmSensorManager.
tkstreet 23:50c98b286e41 83 *
tkstreet 23:50c98b286e41 84 * @param in Command message to be processed by sensor.
tkstreet 23:50c98b286e41 85 * @param out Message returned from sensor.
tkstreet 23:50c98b286e41 86 * @return Termination status type for debugging purposes.
tkstreet 23:50c98b286e41 87 */
tkstreet 23:50c98b286e41 88 virtual Status requestCommand(Message* in, Message* out);
tkstreet 23:50c98b286e41 89
tkstreet 23:50c98b286e41 90 /**
tkstreet 23:50c98b286e41 91 * Get the name of the sensor in char format.
tkstreet 23:50c98b286e41 92 *
tkstreet 23:50c98b286e41 93 * @return Sensor name as a char array.
tkstreet 23:50c98b286e41 94 */
masahikofukasawa 13:d008249f0359 95 virtual char* getSensorName();
masahikofukasawa 10:5c69b067d88a 96
tkstreet 23:50c98b286e41 97 /**
tkstreet 23:50c98b286e41 98 * Causes a detecting of an interrupt by setting the event flag.
tkstreet 23:50c98b286e41 99 */
masahikofukasawa 10:5c69b067d88a 100 void detectINT();
masahikofukasawa 10:5c69b067d88a 101
masahikofukasawa 10:5c69b067d88a 102 private:
masahikofukasawa 10:5c69b067d88a 103 bool event;
masahikofukasawa 10:5c69b067d88a 104 uint8_t primaryId;
masahikofukasawa 10:5c69b067d88a 105 uint8_t subId;
masahikofukasawa 10:5c69b067d88a 106 AK9752* ak9752;
masahikofukasawa 10:5c69b067d88a 107 InterruptIn* interrupt;
masahikofukasawa 10:5c69b067d88a 108 Ticker ticker;
masahikofukasawa 13:d008249f0359 109 char* sensorName;
masahikofukasawa 10:5c69b067d88a 110
masahikofukasawa 10:5c69b067d88a 111 // hold settings
masahikofukasawa 10:5c69b067d88a 112 AK9752::OperationMode mode;
masahikofukasawa 10:5c69b067d88a 113 AK9752::FcTmp fc_tmp;
masahikofukasawa 10:5c69b067d88a 114 AK9752::FcIr fc_ir;
masahikofukasawa 10:5c69b067d88a 115 };
masahikofukasawa 10:5c69b067d88a 116
masahikofukasawa 10:5c69b067d88a 117 #endif