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 AK9750CTRL_H
masahikofukasawa 10:5c69b067d88a 2 #define AK9750CTRL_H
masahikofukasawa 10:5c69b067d88a 3
masahikofukasawa 10:5c69b067d88a 4 #include "mbed.h"
masahikofukasawa 10:5c69b067d88a 5 #include "akmsensor.h"
masahikofukasawa 10:5c69b067d88a 6 #include "AK9750.h"
masahikofukasawa 10:5c69b067d88a 7
tkstreet 23:50c98b286e41 8 /**
tkstreet 23:50c98b286e41 9 * Class for handling commands issued to the AK9750/AK9753.
tkstreet 23:50c98b286e41 10 */
masahikofukasawa 10:5c69b067d88a 11 class Ak9750Ctrl : public AkmSensor
masahikofukasawa 10:5c69b067d88a 12 {
masahikofukasawa 10:5c69b067d88a 13
masahikofukasawa 10:5c69b067d88a 14 public:
masahikofukasawa 10:5c69b067d88a 15
tkstreet 23:50c98b286e41 16 /**
tkstreet 23:50c98b286e41 17 * Device Sub-IDs.
tkstreet 23:50c98b286e41 18 */
masahikofukasawa 10:5c69b067d88a 19 typedef enum {
tkstreet 23:50c98b286e41 20 SUB_ID_AK9750 = 0x01, /**< AK9750: ID = 01h */
tkstreet 23:50c98b286e41 21 SUB_ID_AK9753 = 0x03, /**< AK9753: ID = 03h */
masahikofukasawa 10:5c69b067d88a 22 } SubIdIrSensor;
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 Ak9750Ctrl();
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 ~Ak9750Ctrl();
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 * Causes a detecting of an interrupt by setting the event flag.
tkstreet 23:50c98b286e41 100 */
masahikofukasawa 10:5c69b067d88a 101 void detectINT();
masahikofukasawa 10:5c69b067d88a 102
masahikofukasawa 10:5c69b067d88a 103 private:
masahikofukasawa 10:5c69b067d88a 104 bool event;
masahikofukasawa 10:5c69b067d88a 105 uint8_t primaryId;
masahikofukasawa 10:5c69b067d88a 106 uint8_t subId;
masahikofukasawa 10:5c69b067d88a 107 AK9750* ak9750;
masahikofukasawa 10:5c69b067d88a 108 InterruptIn* interrupt;
masahikofukasawa 10:5c69b067d88a 109 Ticker ticker;
masahikofukasawa 13:d008249f0359 110 char* sensorName;
masahikofukasawa 10:5c69b067d88a 111
masahikofukasawa 10:5c69b067d88a 112 // hold settings
masahikofukasawa 10:5c69b067d88a 113 AK9750::OperationMode mode;
masahikofukasawa 10:5c69b067d88a 114 AK9750::DigitalFilter filter;
masahikofukasawa 10:5c69b067d88a 115 };
masahikofukasawa 10:5c69b067d88a 116
masahikofukasawa 10:5c69b067d88a 117 #endif