Modified for compatibility with Rev.E. hardware

Fork of AkmSensor by AKM Development Platform

Revision:
23:50c98b286e41
Parent:
22:f44f1018081e
Child:
34:1ea3357c8d9a
--- a/akmsensor.h	Mon Apr 10 23:02:52 2017 +0000
+++ b/akmsensor.h	Thu Apr 13 22:15:54 2017 +0000
@@ -4,30 +4,32 @@
 #include "mbed.h"
 #include "Message.h"
 
-// SPI
-#define SPI_SCK                          P0_8       //SPI, SCK
-#define SPI_MISO                         P0_9       //SPI, MISO
+// SPI Pin Number Definitions
+#define SPI_SCK                          P0_8       // SPI, SCK 
+#define SPI_MISO                         P0_9       // SPI, MISO
 #define SPI_MOSI                         P0_10      //SPI, MOSI
 #define SPI_CS                           P0_11      //SPI, CS
 #define SPI_DRDY                         P0_7       //SPI, DRDY
 
-// I2C
+// I2C Pin Number Definitions
 #define I2C_SCL                          P0_8       //I2C, SCL
 #define I2C_SDA                          P0_10      //I2C, SDA
 
-// Digital Port
+// Digital Port Pin Number Definitions
 #define DIGITAL_D0                       P0_11      
 #define DIGITAL_D1                       P0_9
 
-// DRDY Port
+// DRDY Port Pin Number Definitions
 #define I2C_DRDY                         P0_11
 
-// Analog In
+// Analog In Pin Number Definitions
 #define ANALOG_IN_PIN                    P0_5       //P05
 
+// I2C Speed Standards
 #define I2C_SPEED_100KHZ                100000
 #define I2C_SPEED_400KHZ                400000
 
+// Sampling rate for ADC
 #define SENSOR_SAMPLING_RATE            0.1         // 10Hz
 
 /**
@@ -37,40 +39,100 @@
 {
 
 public:
+    /**
+     * Error type for debugging purposes.
+     */
     typedef enum {
-        SUCCESS = 0,
-        ERROR,
+        SUCCESS = 0,            /**< Successful termination (0) */
+        ERROR,                  /**< Error during execution (1) */
 //        ERROR_DOESNT_SUPPORT,
     } Status;
     
+    /**
+     * Primary IDs for the major categories of sensors.
+     */
     typedef enum {
-        AKM_PRIMARY_ID_AKD_SPI              = 0x0,
-        AKM_PRIMARY_ID_UNIPOLAR             = 0x1,
-        AKM_PRIMARY_ID_OMNIPOLAR            = 0x2,
-        AKM_PRIMARY_ID_LATCH                = 0x3,
-        AKM_PRIMARY_ID_DUAL_OUTPUT          = 0x4,
-        AKM_PRIMARY_ID_ONECHIP_ENCODER      = 0x5,
-        AKM_PRIMARY_ID_TBD1                 = 0x6,
-        AKM_PRIMARY_ID_TBD2                 = 0x7,
-        AKM_PRIMARY_ID_LINEAR_SENSOR_LEGACY = 0x8,
-        AKM_PRIMARY_ID_CURRENT_SENSOR       = 0x9,
-        AKM_PRIMARY_ID_MISC_ANALOG          = 0xA,
-        AKM_PRIMARY_ID_LINEAR_SENSOR        = 0xB,
-        AKM_PRIMARY_ID_MOTOR_DRIVER         = 0xC,
-        AKM_PRIMARY_ID_IR_SENSOR            = 0xD,
-        AKM_PRIMARY_ID_ANGLE_SENSOR         = 0xE,
-        AKM_PRIMARY_ID_AKD_I2C              = 0xF,
+        AKM_PRIMARY_ID_AKD_SPI              = 0x0,      /**< AKD SPI Devices */
+        AKM_PRIMARY_ID_UNIPOLAR             = 0x1,      /**< Unipolar Switches */
+        AKM_PRIMARY_ID_OMNIPOLAR            = 0x2,      /**< Omnipolar Switches */
+        AKM_PRIMARY_ID_LATCH                = 0x3,      /**< Bipolar Latches */
+        AKM_PRIMARY_ID_DUAL_OUTPUT          = 0x4,      /**< Dual Output Switches */
+        AKM_PRIMARY_ID_ONECHIP_ENCODER      = 0x5,      /**< One-Chip Encoders */
+        AKM_PRIMARY_ID_TBD1                 = 0x6,      /**< Undefined */
+        AKM_PRIMARY_ID_TBD2                 = 0x7,      /**< Undefined */
+        AKM_PRIMARY_ID_LINEAR_SENSOR_LEGACY = 0x8,      /**< Linear Sensors (Legacy) */
+        AKM_PRIMARY_ID_CURRENT_SENSOR       = 0x9,      /**< Current Sensors */
+        AKM_PRIMARY_ID_MISC_ANALOG          = 0xA,      /**< Analog Devices */
+        AKM_PRIMARY_ID_LINEAR_SENSOR        = 0xB,      /**< Linear Sensors */
+        AKM_PRIMARY_ID_MOTOR_DRIVER         = 0xC,      /**< Motor Drivers */
+        AKM_PRIMARY_ID_IR_SENSOR            = 0xD,      /**< IR Sensors */
+        AKM_PRIMARY_ID_ANGLE_SENSOR         = 0xE,      /**< Angle Sensors */
+        AKM_PRIMARY_ID_AKD_I2C              = 0xF,      /**< AKD I2C Devices */
     } SensorPrimaryId;
 
     AkmSensor(){}
     virtual ~AkmSensor(){}
+
+    /**
+     * Process for intializing the selected sensor.
+     *
+     * @return Termination status type for debugging purposes.
+     */
     virtual Status init(const uint8_t id, const uint8_t subid) = 0;
+    
+    /**
+     * Simple flag process to determine if an event has occurred.
+     *
+     * @return TRUE if event has occurred, FALSE if not.
+     */
     virtual bool isEvent() = 0;
+    
+    /**
+     * Process abstraction for starting sensor operation.
+     *
+     * @return Termination status type for debugging purposes.
+     */
     virtual Status startSensor() = 0;
+    
+    /**
+     * Process abstraction for starting sensor operation.
+     *
+     * @param sec Number of seconds of operation.
+     * @return Termination status type for debugging purposes.
+     */
     virtual Status startSensor(const float sec) = 0;
+    
+    /**
+     * Process abstraction for stopping sensor operation.
+     *
+     * @return Termination status type for debugging purposes.
+     */
     virtual Status stopSensor() = 0;
+    
+    /**
+     * Process abstraction for reading data from the sensor.
+     *
+     * @param msg Message object that will hold the sensor data.
+     * @return Termination status type for debugging purposes.
+     */
     virtual Status readSensorData(Message* msg) = 0;
+    
+    /**
+     * Primary process for interfacing a sensor with the AKDP.  When implemented
+     * in sensor class, it will transfer commands between the the sensor control
+     * class and AkmSensorManager. 
+     *
+     * @param in Command message to be processed by sensor.
+     * @param out Message returned from sensor.
+     * @return Termination status type for debugging purposes.
+     */
     virtual Status requestCommand(Message* in, Message* out) = 0;
+    
+    /**
+     * Get the name of the sensor in char format.
+     *
+     * @return Sensor name as a char array.
+     */
     virtual char* getSensorName() = 0;
 
 private: