Modified for compatibility with Rev.E. hardware

Fork of AkmSensor by AKM Development Platform

Committer:
tkstreet
Date:
Mon Apr 17 22:58:39 2017 +0000
Revision:
26:4e436b0cbaf8
Parent:
25:76c11ab5060e
Child:
36:aafd15b3291b
Added comments to AP1017 control classes

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tkstreet 25:76c11ab5060e 1 #ifndef AP1017CTRL_H
tkstreet 25:76c11ab5060e 2 #define AP1017CTRL_H
tkstreet 25:76c11ab5060e 3
tkstreet 25:76c11ab5060e 4 #include "mbed.h"
tkstreet 25:76c11ab5060e 5 #include "akmsensor.h"
tkstreet 25:76c11ab5060e 6 #include "AP1017.h"
tkstreet 25:76c11ab5060e 7
tkstreet 25:76c11ab5060e 8 #define SubIdAp1017 0x01
tkstreet 25:76c11ab5060e 9
tkstreet 26:4e436b0cbaf8 10 /**
tkstreet 26:4e436b0cbaf8 11 * Class for handling commands issued to the AP1017 motor driver.
tkstreet 26:4e436b0cbaf8 12 */
tkstreet 25:76c11ab5060e 13 class Ap1017Ctrl : public AkmSensor
tkstreet 25:76c11ab5060e 14 {
tkstreet 25:76c11ab5060e 15 public:
tkstreet 25:76c11ab5060e 16
tkstreet 25:76c11ab5060e 17 /**
tkstreet 25:76c11ab5060e 18 * Device Sub-ID.
tkstreet 25:76c11ab5060e 19 */
tkstreet 25:76c11ab5060e 20 typedef enum {
tkstreet 25:76c11ab5060e 21 SUB_ID_AP1017 = 0x01, /**< AP1017: ID = 01h */
tkstreet 25:76c11ab5060e 22 } SubIdMotorDriver;
tkstreet 25:76c11ab5060e 23
tkstreet 25:76c11ab5060e 24 // Constructors and Destructors
tkstreet 25:76c11ab5060e 25 Ap1017Ctrl();
tkstreet 25:76c11ab5060e 26 virtual ~Ap1017Ctrl();
tkstreet 25:76c11ab5060e 27
tkstreet 25:76c11ab5060e 28 // Public Member Functions
tkstreet 25:76c11ab5060e 29 /**
tkstreet 25:76c11ab5060e 30 * Process for intializing the selected sensor.
tkstreet 25:76c11ab5060e 31 *
tkstreet 25:76c11ab5060e 32 * @return Termination status type for debugging purposes.
tkstreet 25:76c11ab5060e 33 */
tkstreet 25:76c11ab5060e 34 virtual AkmSensor::Status init(const uint8_t id, const uint8_t subid);
tkstreet 25:76c11ab5060e 35
tkstreet 25:76c11ab5060e 36 /**
tkstreet 25:76c11ab5060e 37 * Simple flag process to determine if an event has occurred.
tkstreet 25:76c11ab5060e 38 *
tkstreet 25:76c11ab5060e 39 * @return TRUE if event has occurred, FALSE if not.
tkstreet 25:76c11ab5060e 40 */
tkstreet 25:76c11ab5060e 41 virtual bool isEvent();
tkstreet 25:76c11ab5060e 42
tkstreet 25:76c11ab5060e 43 /**
tkstreet 25:76c11ab5060e 44 * Process abstraction for starting sensor operation.
tkstreet 25:76c11ab5060e 45 *
tkstreet 25:76c11ab5060e 46 * @return Termination status type for debugging purposes.
tkstreet 25:76c11ab5060e 47 */
tkstreet 25:76c11ab5060e 48 virtual AkmSensor::Status startSensor();
tkstreet 25:76c11ab5060e 49
tkstreet 25:76c11ab5060e 50 /**
tkstreet 25:76c11ab5060e 51 * Process abstraction for starting sensor operation.
tkstreet 25:76c11ab5060e 52 *
tkstreet 25:76c11ab5060e 53 * @param sec Number of seconds of operation.
tkstreet 25:76c11ab5060e 54 * @return Termination status type for debugging purposes.
tkstreet 25:76c11ab5060e 55 */
tkstreet 25:76c11ab5060e 56 virtual AkmSensor::Status startSensor(const float sec);
tkstreet 25:76c11ab5060e 57
tkstreet 25:76c11ab5060e 58 /**
tkstreet 25:76c11ab5060e 59 * Process abstraction for stopping sensor operation.
tkstreet 25:76c11ab5060e 60 *
tkstreet 25:76c11ab5060e 61 * @return Termination status type for debugging purposes.
tkstreet 25:76c11ab5060e 62 */
tkstreet 25:76c11ab5060e 63 virtual AkmSensor::Status stopSensor();
tkstreet 25:76c11ab5060e 64
tkstreet 25:76c11ab5060e 65 /**
tkstreet 25:76c11ab5060e 66 * Process abstraction for reading data from the sensor.
tkstreet 25:76c11ab5060e 67 *
tkstreet 25:76c11ab5060e 68 * @param msg Message object that will hold the sensor data.
tkstreet 25:76c11ab5060e 69 * @return Termination status type for debugging purposes.
tkstreet 25:76c11ab5060e 70 */
tkstreet 25:76c11ab5060e 71 virtual AkmSensor::Status readSensorData(Message* msg);
tkstreet 25:76c11ab5060e 72
tkstreet 25:76c11ab5060e 73 /**
tkstreet 25:76c11ab5060e 74 * Primary process for interfacing a sensor with the AKDP. When implemented
tkstreet 25:76c11ab5060e 75 * in sensor class, it will transfer commands between the the sensor control
tkstreet 25:76c11ab5060e 76 * class and AkmSensorManager.
tkstreet 25:76c11ab5060e 77 *
tkstreet 25:76c11ab5060e 78 * @param in Command message to be processed by sensor.
tkstreet 25:76c11ab5060e 79 * @param out Message returned from sensor.
tkstreet 25:76c11ab5060e 80 * @return Termination status type for debugging purposes.
tkstreet 25:76c11ab5060e 81 */
tkstreet 25:76c11ab5060e 82 virtual Status requestCommand(Message* in, Message* out);
tkstreet 25:76c11ab5060e 83
tkstreet 25:76c11ab5060e 84 /**
tkstreet 25:76c11ab5060e 85 * Get the name of the sensor in char format.
tkstreet 25:76c11ab5060e 86 *
tkstreet 25:76c11ab5060e 87 * @return Sensor name as a char array.
tkstreet 25:76c11ab5060e 88 */
tkstreet 25:76c11ab5060e 89 virtual char* getSensorName();
tkstreet 26:4e436b0cbaf8 90
tkstreet 26:4e436b0cbaf8 91 /**
tkstreet 26:4e436b0cbaf8 92 * Interrupt handler occurring at regular intervals.
tkstreet 26:4e436b0cbaf8 93 */
tkstreet 26:4e436b0cbaf8 94 void timerCallback();
tkstreet 25:76c11ab5060e 95
tkstreet 25:76c11ab5060e 96 private:
tkstreet 25:76c11ab5060e 97 bool event;
tkstreet 25:76c11ab5060e 98 uint8_t primaryId;
tkstreet 25:76c11ab5060e 99 uint8_t subId;
tkstreet 25:76c11ab5060e 100 char* sensorName;
tkstreet 25:76c11ab5060e 101
tkstreet 25:76c11ab5060e 102 AP1017* ap1017;
tkstreet 26:4e436b0cbaf8 103 Ticker ticker; // Timer interrupt handler object
tkstreet 26:4e436b0cbaf8 104 float interval; // Timer interrupt interval
tkstreet 25:76c11ab5060e 105
tkstreet 25:76c11ab5060e 106 };
tkstreet 25:76c11ab5060e 107
tkstreet 25:76c11ab5060e 108 #endif