MAX32620HSP (MAXREFDES100) RPC Example for Graphical User Interface

Dependencies:   USBDevice

Fork of HSP_Release by Jerry Bradshaw

This is an example program for the MAX32620HSP (MAXREFDES100 Health Sensor Platform). It demonstrates all the features of the platform and works with a companion graphical user interface (GUI) to help evaluate/configure/monitor the board. Go to the MAXREFDES100 product page and click on "design resources" to download the companion software. The GUI connects to the board through an RPC interface on a virtual serial port over the USB interface.

The RPC interface provides access to all the features of the board and is available to interface with other development environments such Matlab. This firmware provides realtime data streaming through the RPC interface over USB, and also provides the ability to log the data to flash for untethered battery operation. The data logging settings are configured through the GUI, and the GUI also provides the interface to download logged data.

Details on the RPC interface can be found here: HSP RPC Interface Documentation

Windows

With this program loaded, the MAX32620HSP will appear on your computer as a serial port. On Mac and Linux, this will happen by default. For Windows, you need to install a driver: HSP serial port windows driver

For more details about this platform and how to use it, see the MAXREFDES100 product page.

Files at this revision

API Documentation at this revision

Comitter:
jbradshaw
Date:
Fri Apr 21 12:12:30 2017 -0500
Parent:
0:e4a10ed6eb92
Child:
2:d483f896c7a9
Commit message:
Flash device is now fully utilized for datalog of sensor data

Changed in this revision

HSP/Devices/BMP280/BMP280/BMP280.cpp Show annotated file Show diff for this revision Revisions of this file
HSP/Devices/BMP280/BMP280/BMP280.h Show annotated file Show diff for this revision Revisions of this file
HSP/Devices/HspLed/HspLed/HspLed.cpp Show annotated file Show diff for this revision Revisions of this file
HSP/Devices/HspLed/HspLed/HspLed.h Show annotated file Show diff for this revision Revisions of this file
HSP/Devices/HspLed/HspLed_RPC.cpp Show annotated file Show diff for this revision Revisions of this file
HSP/Devices/LIS2DH/LIS2DH/LIS2DH.cpp Show annotated file Show diff for this revision Revisions of this file
HSP/Devices/LIS2DH/LIS2DH/LIS2DH.h Show annotated file Show diff for this revision Revisions of this file
HSP/Devices/LIS2DH/LIS2DH_RPC.cpp Show annotated file Show diff for this revision Revisions of this file
HSP/Devices/MAX14720/MAX14720/MAX14720.cpp Show annotated file Show diff for this revision Revisions of this file
HSP/Devices/MAX14720/MAX14720/MAX14720.h Show annotated file Show diff for this revision Revisions of this file
HSP/Devices/MAX14720/MAX14720_RPC.cpp Show annotated file Show diff for this revision Revisions of this file
HSP/Devices/MAX30001/MAX30001/MAX30001.cpp Show annotated file Show diff for this revision Revisions of this file
HSP/Devices/MAX30001/MAX30001/MAX30001.h Show annotated file Show diff for this revision Revisions of this file
HSP/Devices/MAX30001/MAX30001_RPC.cpp Show annotated file Show diff for this revision Revisions of this file
HSP/Devices/MAX30001/MAX30001_helper.cpp Show annotated file Show diff for this revision Revisions of this file
HSP/Devices/MAX30101/MAX30101/MAX30101.cpp Show annotated file Show diff for this revision Revisions of this file
HSP/Devices/MAX30101/MAX30101/MAX30101.h Show annotated file Show diff for this revision Revisions of this file
HSP/Devices/MAX30101/MAX30101_RPC.cpp Show annotated file Show diff for this revision Revisions of this file
HSP/Devices/MAX30101/MAX30101_helper.cpp Show annotated file Show diff for this revision Revisions of this file
HSP/Devices/MAX30205/MAX30205/MAX30205.cpp Show annotated file Show diff for this revision Revisions of this file
HSP/Devices/MAX30205/MAX30205/MAX30205.h Show annotated file Show diff for this revision Revisions of this file
HSP/Devices/PushButton/PushButton.cpp Show annotated file Show diff for this revision Revisions of this file
HSP/Devices/S25FS256/S25FS512.cpp Show annotated file Show diff for this revision Revisions of this file
HSP/Devices/S25FS256/S25FS512.h Show annotated file Show diff for this revision Revisions of this file
HSP/Devices/S25FS256/S25FS512_RPC.cpp Show annotated file Show diff for this revision Revisions of this file
HSP/Devices/S25FS256/S25FS512_RPC.h Show annotated file Show diff for this revision Revisions of this file
HSP/Hsp_BLE/BluetoothLE/BluetoothLE.cpp Show annotated file Show diff for this revision Revisions of this file
HSP/Hsp_BLE/BluetoothLE/Characteristic.h Show annotated file Show diff for this revision Revisions of this file
HSP/Hsp_BLE/HspBLE.cpp Show annotated file Show diff for this revision Revisions of this file
HSP/Interfaces/I2C_RPC.cpp Show annotated file Show diff for this revision Revisions of this file
HSP/LoggingService/DataLoggingService.cpp Show annotated file Show diff for this revision Revisions of this file
HSP/LoggingService/Logging.cpp Show annotated file Show diff for this revision Revisions of this file
HSP/LoggingService/Logging_RPC.cpp Show annotated file Show diff for this revision Revisions of this file
HSP/QuadSPI/QuadSpi.h Show annotated file Show diff for this revision Revisions of this file
HSP/RpcServer/RpcServer.cpp Show annotated file Show diff for this revision Revisions of this file
HSP/RpcServer/StringHelper.cpp Show annotated file Show diff for this revision Revisions of this file
HSP/RpcServer/StringInOut.cpp Show annotated file Show diff for this revision Revisions of this file
HSP/RpcServer/StringInOut.h Show annotated file Show diff for this revision Revisions of this file
HSP/System/Peripherals.cpp Show annotated file Show diff for this revision Revisions of this file
HSP/System/Peripherals.h Show annotated file Show diff for this revision Revisions of this file
HSP/Test/Test_BMP280.cpp Show annotated file Show diff for this revision Revisions of this file
HSP/Test/Test_BMP280.h Show annotated file Show diff for this revision Revisions of this file
HSP/Test/Test_LIS2DH.cpp Show annotated file Show diff for this revision Revisions of this file
HSP/Test/Test_MAX30001.cpp Show annotated file Show diff for this revision Revisions of this file
HSP/Test/Test_MAX30101.cpp Show annotated file Show diff for this revision Revisions of this file
HSP/Test/Test_S25FS512.cpp Show annotated file Show diff for this revision Revisions of this file
HSP/main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/HSP/Devices/BMP280/BMP280/BMP280.cpp	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/Devices/BMP280/BMP280/BMP280.cpp	Fri Apr 21 12:12:30 2017 -0500
@@ -30,20 +30,21 @@
  * ownership rights.
  *******************************************************************************
  */
-
-
 #include "mbed.h"
 #include "BMP280.h"
 
 //******************************************************************************
 BMP280::BMP280(PinName sda, PinName scl, int slaveAddress) : 
         slaveAddress(slaveAddress) {
+
   i2c = new I2C(sda, scl);
   isOwner = true;
 }
+
 //******************************************************************************
 BMP280::BMP280(I2C *i2c, int slaveAddress) : 
         slaveAddress(slaveAddress) {
+
   this->i2c = i2c;
   isOwner = false;
 
@@ -51,8 +52,10 @@
   loggingEnabled = 0;
   loggingSampleRate = 5;
 }
+
 //******************************************************************************
 BMP280::~BMP280(void) {
+
   if (isOwner == true) {
     delete i2c;
   }
@@ -61,17 +64,19 @@
 //******************************************************************************
 int BMP280::init(BMP280::bmp280_osrs_P_t Osrs_p, BMP280::bmp280_osrs_T_t Osrs_t,
                  BMP280::bmp280_FILT_t Filter, BMP280::bmp280_MODE_t Mode,
-                 BMP280::bmp280_TSB_t T_sb)
+                 BMP280::bmp280_TSB_t T_sb) {
 
-{
-  char reg;
   char raw_Tn[6];
   char raw_Pn[20];
+  
+  bmp280_ctrl_meas_t ctrl_meas;
+  bmp280_config_t    config;
 
-  // Read all the temp coeffecients from the BMP280 memory. It will be used in
-  // calculation
-  reg = 0x88;
-  if (reg_read(reg, raw_Tn, 6) != 0) {
+  ///
+  /// Read all the temp coeffecients from the BMP280 memory. It will be used in
+  /// calculation
+  ///
+  if (reg_read(BMP280_CALIB00, raw_Tn, 6) != 0) { 
     return -1;
   }
 
@@ -79,10 +84,11 @@
   dig_T2 = (((int16_t)raw_Tn[3]) << 8) | raw_Tn[2];
   dig_T3 = (((int16_t)raw_Tn[5]) << 8) | raw_Tn[4];
 
-  // Read all the press coeffecients from the BMP280 memory. It will be used in
-  // calculation
-  reg = 0x8E;
-  if (reg_read(reg, raw_Pn, 20) != 0) {
+  ///
+  /// Read all the press coeffecients from the BMP280 memory. It will be used in
+  /// calculation
+  ///
+  if (reg_read((BMP280_REG_map_t)(BMP280_CALIB00+6) /*reg*/, raw_Pn, 20) != 0) {
     return -1;
   }
 
@@ -100,32 +106,32 @@
   wait(1.0 / 10.0);
 
   /****/
-  if (reg_read(BMP280_CTRL_MEAS, &bmp280_ctrl_meas.all, 1) != 0) {
+  if (reg_read(BMP280_CTRL_MEAS, &ctrl_meas.all, 1) != 0) {
     return -1;
   }
 
-  bmp280_ctrl_meas.bit.osrs_p = Osrs_p;
-  bmp280_ctrl_meas.bit.osrs_t = Osrs_t;
+  ctrl_meas.bit.osrs_p = Osrs_p;
+  ctrl_meas.bit.osrs_t = Osrs_t;
 
-  bmp280_ctrl_meas.bit.mode = Mode;
+  ctrl_meas.bit.mode = Mode;
 
-  if (reg_write(BMP280_CTRL_MEAS, bmp280_ctrl_meas.all) != 0) {
+  if (reg_write(BMP280_CTRL_MEAS, ctrl_meas.all) != 0) {
     return -1;
   }
 
   /****/
 
-  if (reg_read(BMP280_CONFIG, &bmp280_config.all, 1) != 0) {
+  if (reg_read(BMP280_CONFIG, &config.all, 1) != 0) {
     return -1;
   }
 
-  bmp280_config.bit.filter = Filter;
+  config.bit.filter = Filter;
 
   if (Mode == 0b11) {
-    bmp280_config.bit.t_sb = T_sb;
+    config.bit.t_sb = T_sb;
   }
 
-  if (reg_write(BMP280_CONFIG, bmp280_config.all) != 0) {
+  if (reg_write(BMP280_CONFIG, config.all) != 0) {
     return -1;
   }
 
@@ -134,11 +140,13 @@
 
 //******************************************************************************
 float BMP280::ToFahrenheit(float temperature) {
-  return temperature * 9 / 5 + 32;
+
+  return temperature * (9 / 5.0f) + 32;
 }
 
 //******************************************************************************
 int BMP280::ReadCompDataRaw2(char *bmp280_rawData) {
+
   int i;
   char data[6];
   float temp;
@@ -157,13 +165,8 @@
 
 //******************************************************************************
 int BMP280::ReadCompDataRaw(char *bmp280_rawData) {
-  char reg;
-  char rxbytes;
 
-  reg = BMP280_PRESS_MSB;
-  rxbytes = 6;
-
-  if (reg_read(reg, bmp280_rawData, rxbytes) != 0) {
+  if (reg_read(BMP280_PRESS_MSB, bmp280_rawData, 6) != 0) {
     return -1;
   }
   return 0;
@@ -171,6 +174,7 @@
 
 //******************************************************************************
 void BMP280::ToFloat(char *bmp280_rawData, float *Temp_degC, float *Press_Pa) {
+
   bmp280_rawPress = (uint32_t)(bmp280_rawData[0] << 12) |
                     (bmp280_rawData[1] << 4) | (bmp280_rawData[2] >> 4);
 
@@ -183,6 +187,7 @@
 
 //******************************************************************************
 int BMP280::ReadCompData(float *Temp_degC, float *Press_Pa) {
+
   char bmp280_rawData[6];
 
   if (ReadCompDataRaw(bmp280_rawData) != 0) {
@@ -193,39 +198,45 @@
 }
 
 //******************************************************************************
-int BMP280::reg_write(char reg, char value) {
+int BMP280::reg_write(BMP280_REG_map_t reg, char value) {
+
   int result;
   char cmdData[2] = {(char)reg, value};
   result = i2c->write(slaveAddress, cmdData, 2);
-  if (result != 0)
+  if (result != 0) {
     return -1;
+  }
   return 0;
 }
 
 //******************************************************************************
-int BMP280::reg_read(char reg, char *value, char number) {
+int BMP280::reg_read(BMP280_REG_map_t reg, char *value, char number) {
+
   int result;
   char cmdData[1] = {(char)reg};
 
   result = i2c->write(slaveAddress, cmdData, 1);
-  if (result != 0)
+  if (result != 0) {
     return -1;
+  }
   result = i2c->read(slaveAddress, value, number);
-  if (result != 0)
+  if (result != 0) {
     return -1;
+  }
   return 0;
 }
 
 //******************************************************************************
 int BMP280::Sleep(void) {
-  // Configure the I2C interface
+  
+  bmp280_ctrl_meas_t ctrl_meas;
 
-  if (reg_read(BMP280_CTRL_MEAS, &bmp280_ctrl_meas.all, 1) != 0) {
+  if (reg_read(BMP280_CTRL_MEAS, &ctrl_meas.all, 1) != 0) {
     return -1;
   }
-  bmp280_ctrl_meas.bit.mode = 0b00; // put everything to sleep mode...
+  ctrl_meas.bit.mode = 0b00; // put everything to sleep mode...
 
-  if (reg_write(BMP280_CTRL_MEAS, bmp280_ctrl_meas.all) != 0) {
+  if (reg_write(BMP280_CTRL_MEAS, ctrl_meas.all) != 0) {
     return -1;
   }
   return 0;
@@ -233,11 +244,13 @@
 
 //******************************************************************************
 void BMP280::Reset(void) {
+
   reg_write(BMP280_RESET, 0xB6); // Initiate a Soft Reset
 }
 
 //******************************************************************************
 int BMP280::Detect(void) {
+
   if (reg_read(BMP280_ID, &bmp280_id, 1) != 0) {
     return -1;
   }
@@ -250,6 +263,7 @@
 
 //******************************************************************************
 int BMP280::ReadId(void) {
+
   if (reg_read(BMP280_ID, &bmp280_id, 1) != 0) {
     return -1;
   }
@@ -258,37 +272,39 @@
 
 //******************************************************************************
 float BMP280::compensate_T_float(int32_t adc_T) {
+
   float var1, var2, T;
   var1 =
-      (((float)adc_T) / 16384.0 - ((float)dig_T1) / 1024.0) * ((float)dig_T2);
+      (((float)adc_T) / 16384.0f - ((float)dig_T1) / 1024.0f) * ((float)dig_T2);
 
-  var2 = ((((float)adc_T) / 131072.0 - ((float)dig_T1) / 8192.0) *
-          (((float)adc_T) / 131072.0 - ((float)dig_T1) / 8192.0)) *
+  var2 = ((((float)adc_T) / 131072.0f - ((float)dig_T1) / 8192.0f) *
+          (((float)adc_T) / 131072.0f - ((float)dig_T1) / 8192.0f)) *
          ((float)dig_T3);
 
   t_fine = (int32_t)(var1 + var2);
 
-  T = (var1 + var2) / 5120.0;
+  T = (var1 + var2) / 5120.0f;
 
   return T;
 }
 
 //******************************************************************************
 float BMP280::compensate_P_float(int32_t adc_P) {
+
   float var1, var2, p;
-  var1 = ((float)t_fine / 2.0) - 64000.0;
-  var2 = var1 * var1 * ((float)dig_P6) / 32768.0;
-  var2 = var2 + var1 * ((float)dig_P5) * 2.0;
-  var2 = (var2 / 4.0) + (((float)dig_P4) * 65536.0);
-  var1 = (((float)dig_P3) * var1 * var1 / 524288.0 + ((float)dig_P2) * var1) / 524288.0;
-  var1 = (1.0 + var1 / 32768.0) * ((float)dig_P1);
-  if (var1 == 0.0) {
+  var1 = ((float)t_fine / 2.0f) - 64000.0f;
+  var2 = var1 * var1 * ((float)dig_P6) / 32768.0f;
+  var2 = var2 + var1 * ((float)dig_P5) * 2.0f;
+  var2 = (var2 / 4.0f) + (((float)dig_P4) * 65536.0f);
+  var1 = (((float)dig_P3) * var1 * var1 / 524288.0f + ((float)dig_P2) * var1) / 524288.0f;
+  var1 = (1.0f + var1 / 32768.0f) * ((float)dig_P1);
+  if (var1 == 0.0f) {
     return 0; // avoid exception caused by division by zero
   }
-  p = 1048576.0 - (float)adc_P;
-  p = (p - (var2 / 4096.0)) * 6250.0 / var1;
-  var1 = ((float)dig_P9) * p * p / 2147483648.0;
-  var2 = p * ((float)dig_P8) / 32768.0;
-  p = p + (var1 + var2 + ((float)dig_P7)) / 16.0;
+  p = 1048576.0f - (float)adc_P;
+  p = (p - (var2 / 4096.0f)) * 6250.0f / var1;
+  var1 = ((float)dig_P9) * p * p / 2147483648.0f;
+  var2 = p * ((float)dig_P8) / 32768.0f;
+  p = p + (var1 + var2 + ((float)dig_P7)) / 16.0f;
   return p;
 }
--- a/HSP/Devices/BMP280/BMP280/BMP280.h	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/Devices/BMP280/BMP280/BMP280.h	Fri Apr 21 12:12:30 2017 -0500
@@ -1,5 +1,5 @@
 /*******************************************************************************
-* Copyright (C) 2015 Maxim Integrated Products, Inc., All Rights Reserved.
+* Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
@@ -32,32 +32,6 @@
 /**
  * Bosch BMP280 Digital Pressure Sensor
  *
- * @code
- * #include <stdio.h>
- * #include "mbed.h"
- * #include "xxx.h"
- *
- * I2C i2c(I2C_SDA, I2C_SCL);
- * xxx xxx(&i2c);
- *
- * int main(void) {
- *	   printf("Initialized xxx\n");
- *     while(1) {
- *         if (xxx.init() != 0) {
- *             printf("Error communicating with xxx\n");
- *         } else {
- *             printf("Initialized xxx\n");
- *             break;
- *         }
- *         wait(1);
- *     }
- *
- *     while(1) {
- *         printf("");
- *         wait(1);
- *     }
- * }
- * @endcode
  */
 
 #ifndef BMP280_H_
@@ -65,46 +39,45 @@
 
 #include "mbed.h"
 
-#define BMP280_READID       (0x58)
-
-#define BMP280_TEMP_XLSB    (0xFC)
-#define BMP280_TEMP_LSB     (0xFB)
-#define BMP280_TEMP_MSB     (0xFA)
-
-#define BMP280_PRESS_XLSB   (0xF9)
-#define BMP280_PRESS_LSB    (0xF8)
-#define BMP280_PRESS_MSB    (0xF7)
-
-#define BMP280_CONFIG       (0xF5)
-#define BMP280_CTRL_MEAS    (0xF4)
-#define BMP280_STATUS       (0xF3)
-#define BMP280_RESET        (0xE0)
-#define BMP280_ID           (0xD0)
-
-// calib25-calib00: 0xA1-0x88
-#define BMP280_CALIB25      (0xA1) // Beginning address
-#define BMP280_CALIB00      (0x88) // Ending address
-
-#define BMP280_REGISTER_CHIPID    (0xD0)
-#define BMP280_REGISTER_VERSION   (0xD1)
-#define BMP280_REGISTER_SOFTRESET (0xE0)
-
-#define BMP280_REGISTER_CAL26     (0xE1) // R calibration stored in 0xE1-0xF0
-
-#define BMP280_REGISTER_CONTROL      (0xF4)
-#define BMP280_REGISTER_CONFIG       (0xF5)
-#define BMP280_REGISTER_PRESSUREDATA (0xF7)
-#define BMP280_REGISTER_TEMPDATA     (0xFA)
-
 /**
  * @brief Bosch BMP280 Digital Pressure Sensor
  */
 class BMP280 {
 
 public:
+
+  typedef enum {  ///< BMP280 Register addresses
+	
+    BMP280_READID     = 0x58,
+    BMP280_TEMP_XLSB  = 0xFC,
+    BMP280_TEMP_LSB   = 0xFB,
+    BMP280_TEMP_MSB   = 0xFA,
+    BMP280_PRESS_XLSB = 0xF9,
+    BMP280_PRESS_LSB  = 0xF8,
+    BMP280_PRESS_MSB  = 0xF7,
+    BMP280_CONFIG     = 0xF5,
+    BMP280_CTRL_MEAS  = 0xF4,
+    BMP280_STATUS     = 0xF3,
+    BMP280_RESET      = 0xE0,
+    BMP280_ID         = 0xD0,
+    ///< calib25-calib00: 0xA1-0x88
+    BMP280_CALIB25    = 0xA1, ///< Beginning address
+    BMP280_CALIB00    = 0x88, ///< Ending address
+
+    BMP280_REGISTER_CHIPID       = 0xD0,
+    BMP280_REGISTER_VERSION      = 0xD1,
+    BMP280_REGISTER_SOFTRESET    = 0xE0,
+    BMP280_REGISTER_CAL26        = 0xE1, // R calibration stored in 0xE1-0xF0
+    BMP280_REGISTER_CONTROL      = 0xF4,
+    BMP280_REGISTER_CONFIG       = 0xF5,
+    BMP280_REGISTER_PRESSUREDATA = 0xF7,
+    BMP280_REGISTER_TEMPDATA     = 0xFA,	
+    	
+  } BMP280_REG_map_t;
+	
+
   /**
-   * BMP280 constructor.
-   *
+   * @brief BMP280 constructor.
    * @param sda mbed pin to use for SDA line of I2C interface.
    * @param scl mbed pin to use for SCL line of I2C interface.
    * @param slaveAddress Slave Address of the device.
@@ -112,8 +85,7 @@
   BMP280(PinName sda, PinName scl, int slaveAddress);
 
   /**
-   * BMP280 constructor.
-   *
+   * @brief BMP280 constructor.
    * @param i2c I2C object to use.
    * @param slaveAddress Slave Address of the device.
    */
@@ -123,55 +95,37 @@
   char loggingSampleRate;
 
   /**
-  * Write a device register
+  * @brief Write a device register
   */
   int writeReg(char reg, char value);
   /**
-  * Read a device register
+  * @brief Read a device register
   */
   int readReg(char reg, char *value);
-
-  /// @brief TEMP_XLSB (0xFC)
-  char bmp280_temp_xlsb; // Lower 4-bits are all 0's
-
-  /// @brief TEMP_LSB (0xFB)
-  char bmp280_temp_lsb;
-
-  /// @brief TEMP_MSB (0xFA)
-  char bmp280_temp_msb;
-
-  /// @brief PRESS_XLSB (0xF9)
-  char bmp280_press_xlsb; // Lower 4-bits are all 0's
-
-  /// @brief PRESS_LSB (0xF8)
-  char bmp280_press_lsb;
-
-  /// @brief PRESS_MSB (0xF7)
-  char bmp280_press_msb;
-
-  /// @brief CONFIG_REG (0xF5)
-  union bmp280_config_reg {
+  
+  ///< @brief CONFIG_REG (0xF5)
+  typedef union bmp280_config_reg {
     char all;
     struct {
       char spi3w_en : 1;
       char reserved : 1;
-      char filter : 3;
-      char t_sb : 3;
+      char filter   : 3;
+      char t_sb     : 3;
     } bit;
-  } bmp280_config;
+  } bmp280_config_t;
 
-  /// @brief CTRL_MEAS (0xF4)
-  union bmp280_ctrl_meas {
+  ///< @brief CTRL_MEAS (0xF4)
+  typedef union bmp280_ctrl_meas {
     char all;
     struct {
-      char mode : 2;
+      char mode   : 2;
       char osrs_p : 3;
       char osrs_t : 3;
     } bit;
-  } bmp280_ctrl_meas;
+  } bmp280_ctrl_meas_t;
 
-  /// @brief STATUS (0xF3)
-  union bmp280_status {
+  ///< @brief STATUS (0xF3)
+  typedef union bmp280_status {
     char all;
     struct {
       char im_update : 1;
@@ -179,65 +133,66 @@
       char measuring : 1;
       char reserved2 : 4;
     } bit;
-  } bmp280_status;
+  } bmp280_status_t;
 
-  /// @brief  RESET (0xE0)
+
+  ///< @brief  RESET (0xE0)
   char bmp280_reset;
 
-  /// @brief  ID (0xD0)
+  ///< @brief  ID (0xD0)
   char bmp280_id;
 
   typedef enum {
     SKIPPED_P = 0,
-    OVERSAMPLING_X1_P = 1,
-    OVERSAMPLING_X2_P = 2,
-    OVERSAMPLING_X4_P = 3,
-    OVERSAMPLING_X8_P = 4,
+    OVERSAMPLING_X1_P  = 1,
+    OVERSAMPLING_X2_P  = 2,
+    OVERSAMPLING_X4_P  = 3,
+    OVERSAMPLING_X8_P  = 4,
     OVERSAMPLING_X16_P = 5
   } bmp280_osrs_P_t;
 
   typedef enum {
     SKIPPED_T = 0,
-    OVERSAMPLING_X1_T = 1,
-    OVERSAMPLING_X2_T = 2,
-    OVERSAMPLING_X4_T = 3,
-    OVERSAMPLING_X8_T = 4,
+    OVERSAMPLING_X1_T  = 1,
+    OVERSAMPLING_X2_T  = 2,
+    OVERSAMPLING_X4_T  = 3,
+    OVERSAMPLING_X8_T  = 4,
     OVERSAMPLING_X16_T = 5
   } bmp280_osrs_T_t;
 
   typedef enum {
     FILT_OFF = 1,
-    FILT_2 = 2,
-    FILT_3 = 4,
-    FILT_4 = 8,
-    FILT_5 = 16
+    FILT_2   = 2,
+    FILT_3   = 4,
+    FILT_4   = 8,
+    FILT_5   = 16
   } bmp280_FILT_t;
 
   typedef enum {
-    SLEEP_MODE = 0,
+    SLEEP_MODE  = 0,
     FORCED_MODE = 1,
     NORMAL_MODE = 3
   } bmp280_MODE_t;
 
   typedef enum {
-    T_0_5 = 0,
+    T_0_5  = 0,
     T_62_5 = 1,
-    T_125 = 2,
-    T_250 = 3,
-    T_500 = 4,
+    T_125  = 2,
+    T_250  = 3,
+    T_500  = 4,
     T_1000 = 5,
     T_2000 = 6,
     T_4000 = 7
   } bmp280_TSB_t;
 
-  /// @brief calib25... calib00  (0xA1...0x88)
+  ///< @brief calib25... calib00  (0xA1...0x88)
   char bmp280_Calib[26];
 
-  uint16_t dig_T1;
-  int16_t dig_T2;
-  int16_t dig_T3;
+  uint16_t dig_T1; ///< Unique temp coeffs. read from the chip
+  int16_t  dig_T2;
+  int16_t  dig_T3;
 
-  uint16_t dig_P1;
+  uint16_t dig_P1; ///< Unique Press. coeffs. read from the chip
   int16_t dig_P2;
   int16_t dig_P3;
   int16_t dig_P4;
@@ -246,33 +201,31 @@
   int16_t dig_P7;
   int16_t dig_P8;
   int16_t dig_P9;
-
-  int32_t t_fine; // This is calculated int the temperature to be used by the
-                  // pressure
+                 
+  int32_t t_fine; ///< This is calculated int the temperature to be used by the
+                  ///< pressure
 
   int32_t bmp280_rawPress;
   int32_t bmp280_rawTemp;
 
-  float Temp_degC; //  Deg C.
-  float Press_Pa;  //   Pascal.
+  float Temp_degC;
+  float Press_Pa; 
 
   /**
-   * BMP280 constructor.
-   *
+   * @brief BMP280 constructor.
    * @param sda mbed pin to use for SDA line of I2C interface.
    * @param scl mbed pin to use for SCL line of I2C interface.
    */
   BMP280(PinName sda, PinName scl);
 
   /**
-   * BMP280 constructor.
-   *
+   * @brief BMP280 constructor.
    * @param i2c I2C object to use.
    */
   BMP280(I2C *i2c);
 
   /**
-   * BMP280 destructor.
+   * @brief BMP280 destructor.
    */
   ~BMP280(void);
 
@@ -319,7 +272,7 @@
    *  @param value- Data written to the register
    *  @returns 0-if no error.  A non-zero value indicates an error.
    */
-  int reg_write(char reg, char value);
+  int reg_write(BMP280_REG_map_t reg, char value);
 
   /**
    * @brief This function allows writing to a register.
@@ -327,7 +280,7 @@
    * @params *value- Pointer to the value read from the register (output)
    * @returns 0-if no error.  A non-zero value indicates an error.
    */
-  int reg_read(char reg, char *value, char number);
+  int reg_read(BMP280_REG_map_t reg, char *value, char number);
 
   /**
    * @brief Performs a soft reset on the BMP280
@@ -407,11 +360,17 @@
   int ReadId(void);
 
 private:
-  /// I2C pointer
+  /**
+   * @brief I2C pointer
+   */
   I2C *i2c;
-  /// Is this object the owner of the I2C object
+  /**
+   * @brief Is this object the owner of the I2C object
+   */
   bool isOwner;
-  /// Device slave address
+  /**
+   * @brief Device slave address
+   */
   int slaveAddress;
 };
 
--- a/HSP/Devices/HspLed/HspLed/HspLed.cpp	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/Devices/HspLed/HspLed/HspLed.cpp	Fri Apr 21 12:12:30 2017 -0500
@@ -38,22 +38,19 @@
 
 //*******************************************************************************
 HspLed::HspLed(PinName ledPin) : 
-      redLed(LED_RED, 0), isStarted(false), timerIntervalLast(-1), timerInterval(500) {
+ timerInterval(500), timerIntervalLast(-1), redLed(LED_RED, 0), isStarted(false) {
 }
 
-
 //*******************************************************************************
 void HspLed::state(int state) { 
   redLed.write(state); 
 }
 
-
 //*******************************************************************************
 void HspLed::toggle(void) { 
   state(!redLed.read()); 
 }
 
-
 //*******************************************************************************
 void HspLed::setMode(eMode mode) { 
   this->mode = mode; 
@@ -81,7 +78,6 @@
   start();
 }
 
-
 //*******************************************************************************
 void HspLed::off(void) {
   mode = eLedOff;
@@ -89,7 +85,6 @@
   start();
 }
 
-
 //*******************************************************************************
 void HspLed::patternToLed(void) {
   uint32_t bit;
@@ -100,7 +95,6 @@
   bitPattern = bitPattern | (bit << 31);
 }
 
-
 //*******************************************************************************
 void HspLed::service(void) {
   switch (mode) {
--- a/HSP/Devices/HspLed/HspLed/HspLed.h	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/Devices/HspLed/HspLed/HspLed.h	Fri Apr 21 12:12:30 2017 -0500
@@ -38,32 +38,6 @@
 /**
  * Driver for the HSP Led, supports different blink rates and patterns
  *
- * @code
- * #include <stdio.h>
- * #include "mbed.h"
- * #include "xxx.h"
- *
- * I2C i2c(I2C_SDA, I2C_SCL);
- * xxx xxx(&i2c);
- *
- * int main(void) {
- *	   printf("Initialized xxx\n");
- *     while(1) {
- *         if (xxx.init() != 0) {
- *             printf("Error communicating with xxx\n");
- *         } else {
- *             printf("Initialized xxx\n");
- *             break;
- *         }
- *         wait(1);
- *     }
- *
- *     while(1) {
- *         printf("");
- *         wait(1);
- *     }
- * }
- * @endcode
  */
 
 class HspLed {
@@ -77,7 +51,7 @@
     eLedOff,
     eLedPeriod,
     eLedPattern
-  } eMode;
+  } eMode_t;
   /// define the values that turn the LED on or off at the pin
   #define HSP_LED_ON 0
   #define HSP_LED_OFF 1
@@ -88,7 +62,7 @@
   HspLed(PinName ledPin);
   
   /**
-  * Blink the HSP LED at a set time interval
+  * @brief Blink the HSP LED at a set time interval
   * @param mSeconds Number of seconds to set the timer interval
   */
   void blink(uint32_t mSeconds);
@@ -118,51 +92,71 @@
 private:
 
   /**
-  * Set the mode of the LED, the mode include blinking at a set rate or blinking
-  * according to a pattern
+  * @brief Set the mode of the LED, the mode include blinking at a set rate or blinking
+  * @brief according to a pattern
   * @param mode Mode to set the LED to
   */
-  void setMode(eMode state);
+  void setMode(eMode_t state);
   
   /**
-  * Toggle the state of the LED
+  * @brief Toggle the state of the LED
   */
   void toggle(void);
 
   /**
-  * Start the LED blinking or rotating through a pattern
+  * @brief Start the LED blinking or rotating through a pattern
   */
   void start(void);
 
   /**
-  * Stop blinking or rotating through a pattern
+  * @brief Stop blinking or rotating through a pattern
   */
   void stop(void);
   
   /**
-  * Write the LED pin to a state
+  * @brief Write the LED pin to a state
   * @param state A one or zero value to write to the LED pin
   */  
   void state(int state);
 
-  /*
+  /**
   * @brief Single step through the pattern and output to the LED
   */
   void patternToLed(void);
 
-  /// timer interval in mS
+  /**
+   * @brief timer interval in mS
+   */
   float timerInterval;
-  /// last timer interval set to... used to prevent resetting the timer to the same value
+  
+  /**
+   * @brief last timer interval set to... used to prevent resetting the timer to the same value
+   */
   float timerIntervalLast;
-  /// local state of the pattern to rotate through
+ 
+  /** 
+   * @brief local state of the pattern to rotate through
+   */ 
   uint32_t bitPattern;
-  /// current mode of the LED
-  eMode mode;
-  /// the LED digital output
+ 
+  /**
+   * @brief current mode of the LED
+   */
+  eMode_t mode;
+ 
+  /**
+   * @brief the LED digital output
+   */
   DigitalOut redLed;
-  /// Timer service used to update the LED
+ 
+  /**
+   * @brief Timer service used to update the LED
+   */
   Ticker ticker;
-  /// Flag to indicate if the timer has been started
+ 
+  /**
+   * @brief Flag to indicate if the timer has been started
+   */
   bool isStarted;
 };
 
--- a/HSP/Devices/HspLed/HspLed_RPC.cpp	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/Devices/HspLed/HspLed_RPC.cpp	Fri Apr 21 12:12:30 2017 -0500
@@ -44,6 +44,7 @@
   return 0;
 }
 
+//******************************************************************************
 int Led_Off(char argStrs[32][32], char replyStrs[32][32]) {
   uint32_t reply[1];
   Peripherals::hspLed()->off();
@@ -52,6 +53,7 @@
   return 0;
 }
 
+//******************************************************************************
 int Led_BlinkHz(char argStrs[32][32], char replyStrs[32][32]) {
   uint32_t args[1];
   uint32_t reply[1];
@@ -62,6 +64,7 @@
   return 0;
 }
 
+//******************************************************************************
 int Led_BlinkPattern(char argStrs[32][32], char replyStrs[32][32]) {
   uint32_t args[2];
   uint32_t reply[1];
--- a/HSP/Devices/LIS2DH/LIS2DH/LIS2DH.cpp	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/Devices/LIS2DH/LIS2DH/LIS2DH.cpp	Fri Apr 21 12:12:30 2017 -0500
@@ -36,11 +36,11 @@
 #include "Peripherals.h"
 
 void lis2dh_int_handler(void);
-/** buffer array to hold fifo contents for packetizing
-*/
+ /** 
+  * @brief buffer array to hold fifo contents for packetizing
+  */
 uint32_t lis2dh_buffer[LIS2DH_MAX_DATA_SIZE];
 
-static int debug_int_count = 0;
 int16_t motion_cached[3];
 LIS2DH *LIS2DH::instance = NULL;
 
@@ -70,26 +70,29 @@
 }
 
 //******************************************************************************
-int LIS2DH::writeReg(char reg, char value) {
+int LIS2DH::writeReg(LIS2DH_REG_map_t reg, char value) {
   int result;
   char cmdData[2] = {(char)reg, value};
   result = i2c->write(slaveAddress, cmdData, 2);
-  if (result != 0)
+  if (result != 0) {
     return -1;
+  }
   return 0;
 }
 
 //******************************************************************************
-int LIS2DH::readReg(char reg, char *value) {
+int LIS2DH::readReg(LIS2DH_REG_map_t reg, char *value) {
   int result;
   char cmdData[1] = {(char)reg};
 
   result = i2c->write(slaveAddress, cmdData, 1);
-  if (result != 0)
+  if (result != 0) {
     return -1;
+  }
   result = i2c->read(slaveAddress, value, 1);
-  if (result != 0)
+  if (result != 0) {
     return -1;
+  }
   return 0;
 }
 
@@ -104,8 +107,8 @@
 }
 
 //******************************************************************************
-//  Interrupt handler, this empties the hardware fifo and packetizes it for
-//  streaming
+///  Interrupt handler, this empties the hardware fifo and packetizes it for
+///  streaming
 void LIS2DH::int_handler(void) {
   char fifo_src;
   int16_t valueX;
@@ -125,8 +128,9 @@
     lis2dh_buffer[index++] = valueZ;
     readReg(LIS2DH_FIFO_SRC_REG, &fifo_src);
     num++;
-    if (num >= 32)
+    if (num >= 32) {
       break;
+    }
   }
   motion_cached[0] = valueX;
   motion_cached[1] = valueY;
@@ -143,60 +147,80 @@
 
 //******************************************************************************
 void LIS2DH::configure_interrupt(void) {
-  // interrupt enabled on INT1, interrupt active low
-  lis2dh_ctrl_reg6.all = 0;
-  lis2dh_ctrl_reg6.bit.I2_INT1 = 1;      // interrupt 1 function enabled on int1 pin
-  lis2dh_ctrl_reg6.bit.H_LACTIVE = 1;    // interrupt active low
-  writeReg(LIS2DH_CTRL_REG6, lis2dh_ctrl_reg6.all);
+  
+  lis2dh_ctrl_reg6_t ctrl_reg6;
+  ///< interrupt enabled on INT1, interrupt active low
+  ctrl_reg6.all = 0;
+  ctrl_reg6.bit.I2_INT1 = 1;      ///< interrupt 1 function enabled on int1 pin
+  ctrl_reg6.bit.H_LACTIVE = 1;    ///< interrupt active low
+  writeReg(LIS2DH_CTRL_REG6, ctrl_reg6.all);
 }
 
 //******************************************************************************
 int LIS2DH::initStart(int dataRate, int fifoThreshold) {
+  
+  lis2dh_ctrl_reg5_t     ctrl_reg5;
+  lis2dh_fifo_ctrl_reg_t fifo_ctrl_reg;
+  lis2dh_ctrl_reg1_t     ctrl_reg1;
+  lis2dh_ctrl_reg3_t     ctrl_reg3;
+  
   __disable_irq();
 
   configure_interrupt();
-
-  // enable FIFO
-  lis2dh_ctrl_reg5.all = 0x0;
-  lis2dh_ctrl_reg5.bit.FIFO_EN = 0x1;
-  if (writeReg(LIS2DH_CTRL_REG5, lis2dh_ctrl_reg5.all) == -1) {
+  ///
+  /// enable FIFO
+  ///
+  ctrl_reg5.all = 0x0;
+  ctrl_reg5.bit.FIFO_EN = 0x1;
+  if (writeReg(LIS2DH_CTRL_REG5, ctrl_reg5.all) == -1) {
+    __enable_irq();
+    return -1;
+  }
+  
+  ///
+  /// set FIFO to stream mode, trigger select INT1
+  ///
+  fifo_ctrl_reg.all = 0x0;
+  fifo_ctrl_reg.bit.FTH = fifoThreshold;
+  fifo_ctrl_reg.bit.FM = LIS2DH_FIFOMODE_STREAM;
+  fifo_ctrl_reg.bit.TR = 0x0;
+  if (writeReg(LIS2DH_FIFO_CTRL_REG, fifo_ctrl_reg.all) == -1) {
     __enable_irq();
     return -1;
   }
 
-  // set FIFO to stream mode, trigger select INT1
-  lis2dh_fifo_ctrl_reg.all = 0x0;
-  lis2dh_fifo_ctrl_reg.bit.FTH = fifoThreshold;
-  lis2dh_fifo_ctrl_reg.bit.FM = LIS2DH_FIFOMODE_STREAM;
-  lis2dh_fifo_ctrl_reg.bit.TR = 0x0;
-  if (writeReg(LIS2DH_FIFO_CTRL_REG, lis2dh_fifo_ctrl_reg.all) == -1) {
-    __enable_irq();
-    return -1;
-  }
-
-  // set HR (high resolution)
+  ///
+  /// set HR (high resolution)
+  ///
   if (writeReg(LIS2DH_CTRL_REG4, 0x8) == -1) {
     __enable_irq();
     return -1;
   }
 
-  // set the data rate, enable all axis
+  ///
+  /// set the data rate, enable all axis
+  ///
   dataRate = dataRate & 0xF;
-  if (dataRate > 0x9) dataRate = 0x9;
-  lis2dh_ctrl_reg1.bit.ODR = dataRate; // set the data rate
-  lis2dh_ctrl_reg1.bit.LPen = 0x0;     // disable low power mode
-  lis2dh_ctrl_reg1.bit.Zen = 0x1;      // enable z
-  lis2dh_ctrl_reg1.bit.Yen = 0x1;      // enable y
-  lis2dh_ctrl_reg1.bit.Xen = 0x1;      // enable x
-  if (writeReg(LIS2DH_CTRL_REG1, lis2dh_ctrl_reg1.all) == -1) {
+  if (dataRate > 0x9) {
+    dataRate = 0x9;
+  }
+  
+  ctrl_reg1.bit.ODR = dataRate; ///< set the data rate
+  ctrl_reg1.bit.LPen = 0x0;     ///< disable low power mode
+  ctrl_reg1.bit.Zen = 0x1;      ///< enable z
+  ctrl_reg1.bit.Yen = 0x1;      ///< enable y
+  ctrl_reg1.bit.Xen = 0x1;      ///< enable x
+  if (writeReg(LIS2DH_CTRL_REG1, ctrl_reg1.all) == -1) {
     __enable_irq();
     return -1;
   }
 
-  // enable watermark interrupt
-  lis2dh_ctrl_reg3.all = 0x00;
-  lis2dh_ctrl_reg3.bit.I1_WTM = 0x1;
-  if (writeReg(LIS2DH_CTRL_REG3, lis2dh_ctrl_reg3.all) == -1) {
+  ///
+  /// enable watermark interrupt
+  ///
+  ctrl_reg3.all = 0x00;
+  ctrl_reg3.bit.I1_WTM = 0x1;
+  if (writeReg(LIS2DH_CTRL_REG3, ctrl_reg3.all) == -1) {
     __enable_irq();
     return -1;
   }
@@ -209,9 +233,14 @@
 int LIS2DH::detect(char *detected) {
   char val;
   *detected = 0;
-  if (readReg(LIS2DH_WHO_AM_I, &val) == -1)
+  if (readReg(LIS2DH_WHO_AM_I, &val) == -1) {
     return -1;
-  if (val == LIS2DH_ID) *detected = 1;
+  }
+  
+  if (val == LIS2DH_ID) {
+    *detected = 1;
+  }
+  
   return 0;
 }
 
@@ -232,7 +261,7 @@
 
   reg = LIS2DH_OUT_X_L;
   for (i = 0; i < 6; i++) {
-    if (readReg(reg, &values[i]) != 0) {
+    if (readReg((LIS2DH_REG_map_t)reg, &values[i]) != 0) {
       return -1;
     }
     reg++;
@@ -248,7 +277,6 @@
 }
 
 //******************************************************************************
-// 0x33 = read ID
 char LIS2DH::readId(void) {
   char val;
   readReg(LIS2DH_WHO_AM_I, &val);
@@ -268,9 +296,11 @@
 //******************************************************************************
 void LIS2DHIntHandler(void) {
   char value;
-  // read the data rate axis enable register, if this is zero then just return,
-  // we are not ready for interrupts
-  LIS2DH::instance->readReg(LIS2DH_CTRL_REG1, &value);
+  ///
+  /// read the data rate axis enable register, if this is zero then just return,
+  /// we are not ready for interrupts
+  ///
+  LIS2DH::instance->readReg(LIS2DH::LIS2DH_CTRL_REG1, &value);
   if (value == 0x0) {
     return;
   }
--- a/HSP/Devices/LIS2DH/LIS2DH/LIS2DH.h	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/Devices/LIS2DH/LIS2DH/LIS2DH.h	Fri Apr 21 12:12:30 2017 -0500
@@ -39,77 +39,10 @@
 /**
  * Driver for the LIS2DH on the HSP Platform
  *
- * @code
- * #include <stdio.h>
- * #include "mbed.h"
- * #include "xxx.h"
- *
- * I2C i2c(I2C_SDA, I2C_SCL);
- * xxx xxx(&i2c);
- *
- * int main(void) {
- *	   printf("Initialized xxx\n");
- *     while(1) {
- *         if (xxx.init() != 0) {
- *             printf("Error communicating with xxx\n");
- *         } else {
- *             printf("Initialized xxx\n");
- *             break;
- *         }
- *         wait(1);
- *     }
- *
- *     while(1) {
- *         printf("");
- *         wait(1);
- *     }
- * }
- * @endcode
  */
 
 void LIS2DHIntHandler(void);
 
-#define LIS2DH_READID 0x33
-
-/// @brief LIS2DH Register addresses
-#define LIS2DH_STATUS_REG_AUX  0x07
-#define LIS2DH_OUT_TEMP_L      0x0C
-#define LIS2DH_OUT_TEMP_H      0x0D
-#define LIS2DH_INT_COUNTER_REG 0x0E
-#define LIS2DH_WHO_AM_I        0x0F
-#define LIS2DH_TEMP_CFG_REG    0x1F
-#define LIS2DH_CTRL_REG1       0x20
-#define LIS2DH_CTRL_REG2       0x21
-#define LIS2DH_CTRL_REG3       0x22
-#define LIS2DH_CTRL_REG4       0x23
-#define LIS2DH_CTRL_REG5       0x24
-#define LIS2DH_CTRL_REG6       0x25
-#define LIS2DH_REFERENCE       0x26
-#define LIS2DH_STATUS_REG2     0x27
-#define LIS2DH_OUT_X_L         0x28
-#define LIS2DH_OUT_X_H         0x29
-#define LIS2DH_OUT_Y_L         0x2A
-#define LIS2DH_OUT_Y_H         0x2B
-#define LIS2DH_OUT_Z_L         0x2C
-#define LIS2DH_OUT_Z_H         0x2D
-#define LIS2DH_FIFO_CTRL_REG   0x2E
-#define LIS2DH_FIFO_SRC_REG    0x2F
-#define LIS2DH_INT1_CFG        0x30
-#define LIS2DH_INT1_SRC        0x31
-#define LIS2DH_INT1_THS        0x32
-#define LIS2DH_INT1_DURATION   0x33
-#define LIS2DH_INT2_CFG        0x34
-#define LIS2DH_INT2_SRC        0x35
-#define LIS2DH_INT2_THS        0x36
-#define LIS2DH_INT2_DURATION   0x37
-#define LIS2DH_CLICK_CFG       0x38
-#define LIS2DH_CLICK_SRC       0x39
-#define LIS2DH_CLICK_THS       0x3A
-#define LIS2DH_TIME_LIMIT      0x3B
-#define LIS2DH_TIME_LATENCY    0x3C
-#define LIS2DH_TIME_WINDOW     0x3D
-#define LIS2DH_Act_THS         0x3E
-#define LIS2DH_Act_DUR         0x3F
 
 #define LIS2DH_DATARATE_1HZ    0x1
 #define LIS2DH_DATARATE_10HZ   0x2
@@ -137,8 +70,54 @@
 
 class LIS2DH {
 public:
-  /// @brief STATUS_AUX (07h)
-  union lis2dh_status_aux_reg {
+
+  typedef enum {  ///< LIS2DH registers
+  
+    LIS2DH_READID          = 0x33,  	
+    LIS2DH_STATUS_REG_AUX  = 0x07,
+    LIS2DH_OUT_TEMP_L      = 0x0C,
+    LIS2DH_OUT_TEMP_H      = 0x0D,
+    LIS2DH_INT_COUNTER_REG = 0x0E,
+    LIS2DH_WHO_AM_I        = 0x0F,
+    LIS2DH_TEMP_CFG_REG    = 0x1F,
+    LIS2DH_CTRL_REG1       = 0x20,
+    LIS2DH_CTRL_REG2       = 0x21,
+    LIS2DH_CTRL_REG3       = 0x22,
+    LIS2DH_CTRL_REG4       = 0x23,
+    LIS2DH_CTRL_REG5       = 0x24,
+    LIS2DH_CTRL_REG6       = 0x25,
+    LIS2DH_REFERENCE       = 0x26,
+    LIS2DH_STATUS_REG2     = 0x27,
+    LIS2DH_OUT_X_L         = 0x28,
+    LIS2DH_OUT_X_H         = 0x29,
+    LIS2DH_OUT_Y_L         = 0x2A,
+    LIS2DH_OUT_Y_H         = 0x2B,
+    LIS2DH_OUT_Z_L         = 0x2C,
+    LIS2DH_OUT_Z_H         = 0x2D,
+    LIS2DH_FIFO_CTRL_REG   = 0x2E,
+    LIS2DH_FIFO_SRC_REG    = 0x2F,
+    LIS2DH_INT1_CFG        = 0x30,
+    LIS2DH_INT1_SRC        = 0x31,
+    LIS2DH_INT1_THS        = 0x32,
+    LIS2DH_INT1_DURATION   = 0x33,
+    LIS2DH_INT2_CFG        = 0x34,
+    LIS2DH_INT2_SRC        = 0x35,
+    LIS2DH_INT2_THS        = 0x36,
+    LIS2DH_INT2_DURATION   = 0x37,
+    LIS2DH_CLICK_CFG       = 0x38,
+    LIS2DH_CLICK_SRC       = 0x39,
+    LIS2DH_CLICK_THS       = 0x3A,
+    LIS2DH_TIME_LIMIT      = 0x3B,
+    LIS2DH_TIME_LATENCY    = 0x3C,
+    LIS2DH_TIME_WINDOW     = 0x3D,
+    LIS2DH_Act_THS         = 0x3E,
+    LIS2DH_Act_DUR         = 0x3F,
+  	
+  	}LIS2DH_REG_map_t;
+
+
+  ///< @brief STATUS_AUX (07h)
+  typedef union lis2dh_status_aux_reg {
     char all;
     struct {
       char reserved3 : 2;
@@ -147,40 +126,20 @@
       char TOR       : 1;
       char reserved1 : 1;
     } bit;
-  } lis2dh_status_aux;
-
-  /// @brief OUT_TEMP_L (0Ch)
-  union lis2dh_out_temp_l_reg {
-    char all;
-  } lis2dh_out_temp_l;
-
-  /// @brief OUT_TEMP_H (0Dh)
-  union lis2dh_out_temp_h_reg {
-    char all;
-  } lis2dh_out_temp_h;
+  } lis2dh_status_aux_t;
 
-  /// @brief INT_COUNTER (0Eh)
-  union lis2dh_int_counter_reg {
-    char all;
-  } lis2dh_int_counter;
-
-  /// @brief WHO_AM_I (0Fh)
-  union lis2dh_who_am_i_reg {
-    char all;
-  } lis2dh_who_am_i;
-
-  /// @brief TEMP_CFG_REG (1Fh)
-  union lis2dh_temp_cfg_reg {
+  ///< @brief TEMP_CFG_REG (1Fh)
+  typedef union lis2dh_temp_cfg_reg {
     char all;
     struct {
       char reserved1 : 6;
       char TEMP_EN0  : 1;
       char TEMP_EN1  : 1;
     } bit;
-  } lis2dh_temp_cfg;
+  } lis2dh_temp_cfg_t;
 
-  /// @brief CTRL_REG1 (20h)
-  union lis2dh_ctrl_reg1_reg {
+  ///< @brief CTRL_REG1 (20h)
+  typedef union lis2dh_ctrl_reg1_reg {
     char all;
     struct {
       char Xen  : 1;
@@ -189,10 +148,10 @@
       char LPen : 1;
       char ODR  : 4;
     } bit;
-  } lis2dh_ctrl_reg1;
+  } lis2dh_ctrl_reg1_t;
 
-  /// @brief CTRL_REG1 (21h)
-  union lis2dh_ctrl_reg2_reg {
+  ///< @brief CTRL_REG1 (21h)
+  typedef union lis2dh_ctrl_reg2_reg {
     char all;
     struct {
       char HPIS    : 3;
@@ -201,10 +160,10 @@
       char HPCF    : 2;
       char HPM     : 2;
     } bit;
-  } lis2dh_ctrl_reg2;
+  } lis2dh_ctrl_reg2_t;
 
-  /// @brief CTRL_REG3 (22h)
-  union lis2dh_ctrl_reg3_reg {
+  ///< @brief CTRL_REG3 (22h)
+  typedef union lis2dh_ctrl_reg3_reg {
     char all;
     struct {
       char reserved   : 1;
@@ -214,10 +173,10 @@
       char I1_AOI     : 1;
       char I1_CLICK   : 1;
     } bit;
-  } lis2dh_ctrl_reg3;
+  } lis2dh_ctrl_reg3_t;
 
-  /// @brief CTRL_REG4 (23h)
-  union lis2dh_ctrl_reg4_reg {
+  ///< @brief CTRL_REG4 (23h)
+  typedef union lis2dh_ctrl_reg4_reg {
     char all;
     struct {
       char SIM : 1;
@@ -227,10 +186,10 @@
       char BLE : 1;
       char BDU : 1;
     } bit;
-  } lis2dh_ctrl_reg4;
+  } lis2dh_ctrl_reg4_t;
 
-  /// @brief CTRL_REG5 (24h)
-  union lis2dh_ctrl_reg5_reg {
+  ///< @brief CTRL_REG5 (24h)
+  typedef union lis2dh_ctrl_reg5_reg {
     char all;
     struct {
       char D4D_INT2 : 1;
@@ -241,10 +200,10 @@
       char FIFO_EN  : 1;
       char BOOT     : 1;
     } bit;
-  } lis2dh_ctrl_reg5;
+  } lis2dh_ctrl_reg5_t;
 
-  /// @brief CTRL_REG6 (25h)
-  union lis2dh_ctrl_reg6_reg {
+  ///< @brief CTRL_REG6 (25h)
+  typedef union lis2dh_ctrl_reg6_reg {
     char all;
     struct {
       char reserved1 : 1;
@@ -256,15 +215,15 @@
       char I2_INT1   : 1;
       char I2_CLICKen: 1;
     } bit;
-  } lis2dh_ctrl_reg6;
+  } lis2dh_ctrl_reg6_t;
 
-  /// @brief REFERENCE (26h)
-  union lis2dh_reference_reg {
+  ///< @brief REFERENCE (26h)
+  typedef union lis2dh_reference_reg {
     char all;
   } lis2dh_reference;
 
-  /// @brief STATUS_REG (27h)
-  union lis2dh_status_reg_ {
+  ///< @brief STATUS_REG (27h)
+  typedef union lis2dh_status_reg_ {
     char all;
     struct {
       char XDA   : 1;
@@ -276,50 +235,21 @@
       char ZOR   : 1;
       char ZYXOR : 1;
     } bit;
-  } lis2dh_status_reg;
-
-  /// @brief OUT_X_L (28h)
-  union lis2dh_out_x_l_ {
-    char all;
-  } lis2dh_out_x_l;
+  } lis2dh_status_reg_t;
 
-  /// @brief OUT_X_H (29h)
-  union lis2dh_out_x_h_ {
-    char all;
-  } lis2dh_out_x_h;
-
-  /// @brief OUT_Y_L (2Ah)
-  union lis2dh_out_y_l_ {
-    char all;
-  } lis2dh_out_y_l;
 
-  /// @brief OUT_Y_H (2Bh)
-  union lis2dh_out_y_h_ {
-    char all;
-  } lis2dh_out_y_h;
-
-  /// @brief OUT_Z_L (2Ch)
-  union lis2dh_out_z_l_ {
-    char all;
-  } lis2dh_out_z_l;
-
-  /// @brief OUT_Z_H (2Dh)
-  union lis2dh_out_z_h_ {
-    char all;
-  } lis2dh_out_z_h;
-
-  /// @brief FIFO_CTRL_REG (2Eh)
-  union lis2dh_fifo_ctrl_reg_ {
+  ///< @brief FIFO_CTRL_REG (2Eh)
+  typedef union lis2dh_fifo_ctrl_reg_ {
     char all;
     struct {
       char FTH : 5;
       char TR  : 1;
       char FM  : 2;
     } bit;
-  } lis2dh_fifo_ctrl_reg;
+  } lis2dh_fifo_ctrl_reg_t;
 
-  /// @brief FIFO_CTRL_REG (2Fh)
-  union lis2dh_fifo_src_reg_ {
+  ///< @brief FIFO_CTRL_REG (2Fh)
+  typedef union lis2dh_fifo_src_reg_ {
     char all;
     struct {
       char FSS       : 5;
@@ -327,10 +257,10 @@
       char OVRN_FIFO : 1;
       char WTM       : 1;
     } bit;
-  } lis2dh_fifo_src_reg;
+  } lis2dh_fifo_src_reg_t;
 
-  /// @brief INT1_CFG (30h)
-  union lis2dh_int1_cfg_reg_ {
+  ///< @brief INT1_CFG (30h)
+  typedef union lis2dh_int1_cfg_reg_ {
     char all;
     struct {
       char XLIE_XDOWNE : 1;
@@ -342,10 +272,10 @@
       char SIXD        : 1;
       char AOI         : 1;
     } bit;
-  } lis2dh_int1_cfg;
+  } lis2dh_int1_cfg_t;
 
-  /// @brief INT1_SRC (31h)
-  union lis2dh_int1_src_reg_ {
+  ///< @brief INT1_SRC (31h)
+  typedef union lis2dh_int1_src_reg_ {
     char all;
     struct {
       char XL : 1;
@@ -357,20 +287,11 @@
       char IA : 1;
       char reserved : 1;
     } bit;
-  } lis2dh_int1_src;
+  } lis2dh_int1_src_t;
 
-  /// @brief INT1_THS (32h)
-  union lis2dh_int1_ths_reg_ {
-    char all;
-  } lis2dh_int1_ths;
 
-  /// @brief INT1_DURATION (33h)
-  union lis2dh_int1_duration_reg_ {
-    char all;
-  } lis2dh_int1_duration;
-
-  /// @brief INT2_CFG (34h)
-  union lis2dh_int2_cfg_reg_ {
+  ///< @brief INT2_CFG (34h)
+  typedef union lis2dh_int2_cfg_reg_ {
     char all;
     struct {
       char XLIE : 1;
@@ -382,10 +303,10 @@
       char SIX6 : 1;
       char AOI  : 1;
     } bit;
-  } lis2dh_int2_cfg;
+  } lis2dh_int2_cfg_t;
 
-  /// @brief INT2_SRC (35h)
-  union lis2dh_int2_src_reg_ {
+  ///< @brief INT2_SRC (35h)
+  typedef union lis2dh_int2_src_reg_ {
     char all;
     struct {
       char XL       : 1;
@@ -397,52 +318,54 @@
       char IA       : 1;
       char reserved : 1;
     } bit;
-  } lis2dh_int2_src;
+  } lis2dh_int2_src_t;
 
-  /// @brief INT2_THS (36h)
-  union lis2dh_int2_ths_reg_ {
-    char all;
-  } lis2dh_int2_ths;
 
-  /// @brief INT2_DURATION (37h)
-  union lis2dh_int2_duration_reg_ {
-    char all;
-  } lis2dh_int2_duration;
 
   LIS2DH(PinName sda, PinName scl, int slaveAddress);
   LIS2DH(I2C *i2c, int slaveAddress);
   ~LIS2DH(void);
 
-  /** @brief Initialize the device
-  */
+  /** 
+   * @brief Initialize the device
+   */
   void init(void);
-  /** @brief Interrupt handler
-  */
+  /** 
+   * @brief Interrupt handler
+   */
   void int_handler(void);
-  /** @brief Get motion data from the device fifo
-  */
+  /** 
+   * @brief Get motion data from the device fifo
+   */
   int get_motion_fifo(short *valueX, short *valueY, short *valueZ);
-  /** @brief Get the last cached motion values (cached from a previous interrupt
+  /** 
+   * @brief Get the last cached motion values (cached from a previous interrupt
    * event)
-  */
+   */
   int get_motion_cached(int16_t *valueX, int16_t *valueY, int16_t *valueZ);
-  /** @brief Star Interrupts
-  */
+  /** 
+   * @brief Star Interrupts
+   */
   int initStart(int dataRate, int fifoThreshold);
-  /** @brief Stop interrupts
-  */
+  /** 
+   * @brief Stop interrupts
+   */
   void stop(void);
-  /** @brief Read device register
-  */
-  int readReg(char reg, char *value);
-  /** @brief Write device regsiter
-  */
-  int writeReg(char reg, char value);
-  /** @brief Detect if device exists
-  */
+  /** 
+   * @brief Read device register
+   */
+  int readReg(LIS2DH_REG_map_t reg, char *value);
+  /** 
+   * @brief Write device regsiter
+   */
+  int writeReg(LIS2DH_REG_map_t reg, char value);
+  /** 
+   * @brief Detect if device exists
+   */
   int detect(char *detected);
-  /** @brief Read the device ID
-  */
+  /** 
+   * @brief Read the device ID
+   */
   char readId(void);
 
   static LIS2DH *instance;
@@ -451,11 +374,11 @@
   /** @brief
   */
   void configure_interrupt(void);
-  /// I2C pointer
+  ///< I2C pointer
   I2C *i2c;
-  /// Is this object the owner of the I2C object
+  ///< Is this object the owner of the I2C object
   bool isOwner;
-  /// Device slave address
+  ///< Device slave address
   int slaveAddress;
 };
 
--- a/HSP/Devices/LIS2DH/LIS2DH_RPC.cpp	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/Devices/LIS2DH/LIS2DH_RPC.cpp	Fri Apr 21 12:12:30 2017 -0500
@@ -46,7 +46,7 @@
   uint8_t reply[1];
   ProcessArgs(argStrs, args, sizeof(args));
   LIS2DH *lis2dh = Peripherals::lis2dh();
-  lis2dh->readReg(args[0], (char *)reply);
+  lis2dh->readReg((LIS2DH::LIS2DH_REG_map_t)args[0], (char *)reply);
   FormatReply(reply, sizeof(reply), replyStrs);
   return 0;
 }
@@ -57,7 +57,7 @@
   uint8_t reply[1];
   ProcessArgs(argStrs, args, sizeof(args));
   LIS2DH *lis2dh = Peripherals::lis2dh();
-  lis2dh->writeReg(args[0], args[1]); // pass in the register address
+  lis2dh->writeReg((LIS2DH::LIS2DH_REG_map_t)args[0], args[1]); ///< pass in the register address
   reply[0] = 0x80;
   FormatReply(reply, sizeof(reply), replyStrs);
   return 0;
@@ -70,8 +70,9 @@
   uint8_t reply[1];
   ProcessArgs(argStrs, args, sizeof(args));
   LIS2DH *lis2dh = Peripherals::lis2dh();
-  if (args[0] >= LIS2DH_DATARATE_200HZ)
+  if (args[0] >= LIS2DH_DATARATE_200HZ) {
     highDataRate = 1;
+  }
   lis2dh->initStart(args[0], args[1]);
   reply[0] = 0x80;
   FormatReply(reply, sizeof(reply), replyStrs);
--- a/HSP/Devices/MAX14720/MAX14720/MAX14720.cpp	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/Devices/MAX14720/MAX14720/MAX14720.cpp	Fri Apr 21 12:12:30 2017 -0500
@@ -100,7 +100,9 @@
   boostEn = mode;
   data = (boostEn << 3) | (boostEMI << 1) | (boostInd);
   result = writeReg(REG_BOOST_CFG, data);
-  if (result == MAX14720_ERROR) return result;
+  if (result == MAX14720_ERROR) {
+    return result;
+  }
   return 0;
 }
 
@@ -108,6 +110,7 @@
 int MAX14720::boostSetVoltage(int mV) {
   int result;
   char data;
+  result = MAX14720_NO_ERROR;
   if ((MAX14720_BOOST_MIN_MV <= mV) && (mV <= MAX14720_BOOST_MAX_MV)) {
     boostMillivolts = mV;
     data = (mV - MAX14720_BOOST_MIN_MV) / MAX14720_BOOST_STEP_MV;
@@ -117,14 +120,20 @@
   if (boostEn == BOOST_ENABLED) {
     result = writeReg(REG_BOOST_CFG, 0x00);
   }
-  if (result == MAX14720_ERROR) return result;
+  if (result == MAX14720_ERROR) {
+    return result;
+  }
   result = writeReg(REG_BOOST_VSET, data);
-  if (result == MAX14720_ERROR) return result;
+  if (result == MAX14720_ERROR) {
+    return result;
+  }
   if (boostEn == BOOST_ENABLED) {
     data = (boostEn << 3) | (boostEMI << 1) | (boostInd);
     result = writeReg(REG_BOOST_CFG, data);
   }
-  if (result == MAX14720_ERROR) return result;
+  if (result == MAX14720_ERROR) {
+    return result;
+  }
   return 0;
 }
 
@@ -134,10 +143,14 @@
   char data;
   data = (clkDivEn << 7) | (clkDivSet);
   result = writeReg(REG_BOOST_CDIV, data);
-  if (result == MAX14720_ERROR) return result;
+  if (result == MAX14720_ERROR) {
+    return result;
+  }
   data = (boostISet);
   result = writeReg(REG_BOOST_ISET, data);
-  if (result == MAX14720_ERROR)return result;
+  if (result == MAX14720_ERROR) {
+    return result;
+  }
   if ((MAX14720_BOOST_MIN_MV <= boostMillivolts) &&
       (boostMillivolts <= MAX14720_BOOST_MAX_MV)) {
     data = (boostMillivolts - MAX14720_BOOST_MIN_MV) / MAX14720_BOOST_STEP_MV;
@@ -145,18 +158,26 @@
     return MAX14720_ERROR;
   }
   result = writeReg(REG_BOOST_VSET, data);
-  if (result == MAX14720_ERROR) return result;
+  if (result == MAX14720_ERROR) {
+    return result;
+  }
   data = (buckMd << 1) | (buckFst);
   result = writeReg(REG_BUCK_CFG, data);
-  if (result == MAX14720_ERROR) return result;
+  if (result == MAX14720_ERROR) {
+    return result;
+  }
   data = (boostHysOff << 7) | (boostPasDsc << 6) | (boostActDsc << 5) |
          (buckPasDsc << 2) | (buckActDsc << 1) | (buckFScl);
   result = writeReg(REG_BBB_EXTRA, data);
-  if (result == MAX14720_ERROR) return result;
+  if (result == MAX14720_ERROR) {
+    return result;
+  }
   // Write Boost Enable Register Last
   data = (boostEn << 3) | (boostEMI << 1) | (boostInd);
   result = writeReg(REG_BOOST_CFG, data);
-  if (result == MAX14720_ERROR) return result;
+  if (result == MAX14720_ERROR) {
+    return result;
+  }
   return 0;
 }
 
@@ -164,7 +185,9 @@
 int MAX14720::monSet(monCfg_t monCfg) {
   int result;
   result = writeReg(REG_MON_CFG, monCfg);
-  if (result == MAX14720_ERROR) return result;
+  if (result == MAX14720_ERROR) {
+    return result;
+  }
   return 0;
 }
 
@@ -172,7 +195,9 @@
 int MAX14720::shutdown() {
   int result;
   result = writeReg(REG_PWR_OFF, 0xB2);
-  if (result == MAX14720_ERROR) return result;
+  if (result == MAX14720_ERROR) {
+    return result;
+  }
   return 0;
 }
 
@@ -181,7 +206,9 @@
   int result;
   char cmdData[2] = {(char)reg, value};
   result = i2c->write(slaveAddress, cmdData, 2);
-  if (result != 0) return MAX14720_ERROR;
+  if (result != 0) {
+    return MAX14720_ERROR;
+  }
   return MAX14720_NO_ERROR;
 }
 
@@ -191,8 +218,12 @@
   char cmdData[1] = {(char)reg};
 
   result = i2c->write(slaveAddress, cmdData, 1);
-  if (result != 0) return MAX14720_ERROR;
+  if (result != 0) {
+    return MAX14720_ERROR;
+  }
   result = i2c->read(slaveAddress, value, 1);
-  if (result != 0) return MAX14720_ERROR;
+  if (result != 0) {
+    return MAX14720_ERROR;
+  }
   return MAX14720_NO_ERROR;
 }
--- a/HSP/Devices/MAX14720/MAX14720/MAX14720.h	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/Devices/MAX14720/MAX14720/MAX14720.h	Fri Apr 21 12:12:30 2017 -0500
@@ -93,30 +93,30 @@
   *@details Enumerated MAX14720 register addresses
   */
   typedef enum {
-    REG_CHIP_ID = 0x00,    ///< Chip ID
-    REG_CHIP_REV = 0x01,   ///< Chip Revision
-    REG_BOOST_CDIV = 0x03, ///< Boost Clock Divider
-    REG_BOOST_ISET = 0x04, ///< Boost Peak Current
-    REG_BOOST_VSET = 0x05, ///< Boost Voltage Setting
-    REG_BOOST_CFG = 0x06,  ///< Boost Configuration
-    REG_BUCK_VSET = 0x07,  ///< Buck Voltage Setting
-    REG_BUCK_CFG = 0x08,   ///< Buck Configuration
-    REG_BUCK_ISET = 0x09,  ///< Buck Peak Current and Settings
-    REG_LDO_VSET = 0x0A,   ///< LDO Voltage Setting
-    REG_LDO_CFG = 0x0B,    ///< LDO Configuration
-    REG_SWITCH_CFG = 0x0C, ///< Switch Configuration
-    REG_BAT_TIME = 0x0D,   ///< Battery Impedance Timing
-    REG_BAT_CFG = 0x0E,    ///< Battery Impedance Configuration
-    REG_BAT_BCV = 0x0F,    ///< Battery Cell Voltage
-    REG_BAT_OCV = 0x10,    ///< Open Cell Voltage
-    REG_BAT_LCV = 0x11,    ///< Loaded Cell Voltage
-    REG_MON_CFG = 0x19,    ///< Monitor Multiplexer Configuration
-    REG_BOOT_CFG = 0x1A,   ///< Boot Configuration
-    REG_PIN_STAT = 0x1B,   ///< Pin Status
-    REG_BBB_EXTRA = 0x1C,  ///< Buck/Buck-Boost Extra
-    REG_HANDSHK = 0x1D,    ///< Power-On Handshake
-    REG_UVLO_CFG = 0x1E,   ///< Under-Voltage Lock Out
-    REG_PWR_OFF = 0x1F,    ///< Power Off Command
+    REG_CHIP_ID    = 0x00,    ///< Chip ID
+    REG_CHIP_REV   = 0x01,    ///< Chip Revision
+    REG_BOOST_CDIV = 0x03,    ///< Boost Clock Divider
+    REG_BOOST_ISET = 0x04,    ///< Boost Peak Current
+    REG_BOOST_VSET = 0x05,    ///< Boost Voltage Setting
+    REG_BOOST_CFG  = 0x06,    ///< Boost Configuration
+    REG_BUCK_VSET  = 0x07,    ///< Buck Voltage Setting
+    REG_BUCK_CFG   = 0x08,    ///< Buck Configuration
+    REG_BUCK_ISET  = 0x09,    ///< Buck Peak Current and Settings
+    REG_LDO_VSET   = 0x0A,    ///< LDO Voltage Setting
+    REG_LDO_CFG    = 0x0B,    ///< LDO Configuration
+    REG_SWITCH_CFG = 0x0C,    ///< Switch Configuration
+    REG_BAT_TIME   = 0x0D,    ///< Battery Impedance Timing
+    REG_BAT_CFG    = 0x0E,    ///< Battery Impedance Configuration
+    REG_BAT_BCV    = 0x0F,    ///< Battery Cell Voltage
+    REG_BAT_OCV    = 0x10,    ///< Open Cell Voltage
+    REG_BAT_LCV    = 0x11,    ///< Loaded Cell Voltage
+    REG_MON_CFG    = 0x19,    ///< Monitor Multiplexer Configuration
+    REG_BOOT_CFG   = 0x1A,    ///< Boot Configuration
+    REG_PIN_STAT   = 0x1B,    ///< Pin Status
+    REG_BBB_EXTRA  = 0x1C,    ///< Buck/Buck-Boost Extra
+    REG_HANDSHK    = 0x1D,    ///< Power-On Handshake
+    REG_UVLO_CFG   = 0x1E,    ///< Under-Voltage Lock Out
+    REG_PWR_OFF    = 0x1F,    ///< Power Off Command
   } registers_t;
 
   /**
@@ -306,11 +306,11 @@
       buckFScl;          /// Buck Fet Scaling
 
 private:
-  /// I2C pointer
+  /// @brief I2C pointer
   I2C *i2c;
-  /// Is this object the owner of the I2C object
+  /// @brief Is this object the owner of the I2C object
   bool isOwner;
-  /// Device slave address
+  /// @brief Device slave address
   int slaveAddress;
 };
 
--- a/HSP/Devices/MAX14720/MAX14720_RPC.cpp	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/Devices/MAX14720/MAX14720_RPC.cpp	Fri Apr 21 12:12:30 2017 -0500
@@ -86,12 +86,9 @@
 int MAX14720_ReadReg(char argStrs[32][32], char replyStrs[32][32]) {
   uint8_t args[1];
   uint8_t reply[1];
-  char address;
-  char value;
-
   ProcessArgs(argStrs, args, sizeof(args));
   // Peripherals::max14720()->readReg((MAX14720::MAX14720_REG_map_t)address,&value);
-  reply[0] = (char)value;
+  reply[0] = 0;
   FormatReply(reply, sizeof(reply), replyStrs);
   return 0;
 }
@@ -108,7 +105,6 @@
   uint8_t reply[1];
 
   ProcessArgs(argStrs, args, sizeof(args));
-  // Peripherals::max14720()->writeReg((MAX14720::MAX14720_REG_map_t)args[0],args[1]);
   reply[0] = 0x80;
   FormatReply(reply, sizeof(reply), replyStrs);
   return 0;
--- a/HSP/Devices/MAX30001/MAX30001/MAX30001.cpp	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/Devices/MAX30001/MAX30001/MAX30001.cpp	Fri Apr 21 12:12:30 2017 -0500
@@ -1,4 +1,3 @@
-
 /*******************************************************************************
  * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
  *
@@ -34,6 +33,7 @@
 
 #include "mbed.h"
 #include "MAX30001.h"
+#include "pwrseq_regs.h"
 
 MAX30001 *MAX30001::instance = NULL;
 
@@ -44,6 +44,7 @@
   spi_owner = true;
   functionpointer.attach(&spiHandler);
   onDataAvailableCallback = NULL;
+  xferFlag = 0;
   instance = this;
 }
 
@@ -54,6 +55,7 @@
   spi_owner = false;
   functionpointer.attach(&spiHandler);
   onDataAvailableCallback = NULL;
+  xferFlag = 0;
   instance = this;
 }
 
@@ -65,154 +67,213 @@
 }
 
 //******************************************************************************
-int MAX30001::max30001_Rbias_FMSTR_Init(uint8_t En_rbias, uint8_t Rbiasv,
-                                        uint8_t Rbiasp, uint8_t Rbiasn,
-                                        uint8_t Fmstr) {
-  if (max30001_reg_read(CNFG_GEN, &max30001_cnfg_gen.all) == -1) {
+void MAX30001::FCLK_MaximOnly(void){
+ 
+  // Use RTC crystal clock for MAX30001 FCLK
+/*
+  mxc_pwrseq_reg0_t pwr_reg0;
+  mxc_pwrseq_reg4_t pwr_reg4;
+ 
+  // Set the port pin connected to the MAX30001 FCLK pin as an output
+  GPIO_SetOutMode(MAX30001_INT_PORT_FCLK, MAX30001_INT_PIN_FCLK, MXC_E_GPIO_OUT_MODE_NORMAL);
+ 
+  // Enable Real Time Clock in Run and Sleep modes
+  pwr_reg0 = MXC_PWRSEQ->reg0_f;
+  pwr_reg0.pwr_rtcen_run = 1;
+  pwr_reg0.pwr_rtcen_slp = 1;
+  MXC_PWRSEQ->reg0_f = pwr_reg0;
+ 
+  // Enable the RTC clock output path on P1.7
+  pwr_reg4 = MXC_PWRSEQ->reg4_f;
+  pwr_reg4.pwr_pseq_32k_en = 1;
+  MXC_PWRSEQ->reg4_f = pwr_reg4;
+*/
+ 
+  #define PORT_FCLK 1
+  #define PIN_FCLK  7
+ 
+  // Set the Port pin connected to the MAX30001 FCLK pin as an output
+  uint32_t temp = MXC_GPIO->out_mode[PORT_FCLK];  // Port 1
+  
+  //    temp = (temp & ~(0xF << (pin * 4))) | (val << (pin * 4));
+                               /* pin 7 */      /* NORMAL MODE */
+  temp = (temp & ~(0xF << (PIN_FCLK * 4))) | (MXC_V_GPIO_OUT_MODE_NORMAL << (PIN_FCLK * 4));
+  
+ 
+//    temp = (temp & ~(0xF << (7 * 4))) | (5 << (7 * 4));
+  
+  MXC_GPIO->out_mode[PORT_FCLK] = temp;
+  
+  
+  // Enable Real Time Clock in Run and Sleep Modes
+  MXC_PWRSEQ->reg0 = MXC_PWRSEQ->reg0 | MXC_F_PWRSEQ_REG0_PWR_RTCEN_RUN |  MXC_F_PWRSEQ_REG0_PWR_RTCEN_SLP;
+  
+  // Enable the RTC clock output path on P1.7
+  MXC_PWRSEQ->reg4 = MXC_PWRSEQ->reg4 | MXC_F_PWRSEQ_REG4_PWR_PSEQ_32K_EN;
+    
+}
+ 
+
+//******************************************************************************
+int MAX30001::Rbias_FMSTR_Init(uint8_t En_rbias, uint8_t Rbiasv,
+                               uint8_t Rbiasp, uint8_t Rbiasn,
+                               uint8_t Fmstr) {
+                                        	
+  max30001_cnfg_gen_t cnfg_gen;                                        	
+                                        	
+  if (reg_read(CNFG_GEN, &cnfg_gen.all) == -1) {
     return -1;
   }
 
-  max30001_cnfg_gen.bit.en_rbias = En_rbias;
-  max30001_cnfg_gen.bit.rbiasv   = Rbiasv;
-  max30001_cnfg_gen.bit.rbiasp   = Rbiasp;
-  max30001_cnfg_gen.bit.rbiasn   = Rbiasn;
-  max30001_cnfg_gen.bit.fmstr    = Fmstr;
+  cnfg_gen.bit.en_rbias = En_rbias;
+  cnfg_gen.bit.rbiasv   = Rbiasv;
+  cnfg_gen.bit.rbiasp   = Rbiasp;
+  cnfg_gen.bit.rbiasn   = Rbiasn;
+  cnfg_gen.bit.fmstr    = Fmstr;
 
-  if (max30001_reg_write(CNFG_GEN, max30001_cnfg_gen.all) == -1) {
+  if (reg_write(CNFG_GEN, cnfg_gen.all) == -1) {
     return -1;
   }
   return 0;
 }
 
 //******************************************************************************
-int MAX30001::max30001_CAL_InitStart(uint8_t En_Vcal, uint8_t Vmode,
-                                     uint8_t Vmag, uint8_t Fcal, uint16_t Thigh,
-                                     uint8_t Fifty) {
-  // CNFG_CAL
-  if (max30001_reg_read(CNFG_CAL, &max30001_cnfg_cal.all) == -1) {
+int MAX30001::CAL_InitStart(uint8_t En_Vcal, uint8_t Vmode,
+                            uint8_t Vmag, uint8_t Fcal, uint16_t Thigh,
+                            uint8_t Fifty) {
+             
+  max30001_cnfg_cal_t cnfg_cal;
+                  
+  ///< CNFG_CAL
+  if (reg_read(CNFG_CAL, &cnfg_cal.all) == -1) {
     return -1;
   }
 
-  max30001_cnfg_cal.bit.vmode = Vmode;
-  max30001_cnfg_cal.bit.vmag  = Vmag;
-  max30001_cnfg_cal.bit.fcal  = Fcal;
-  max30001_cnfg_cal.bit.thigh = Thigh;
-  max30001_cnfg_cal.bit.fifty = Fifty;
+  cnfg_cal.bit.vmode = Vmode;
+  cnfg_cal.bit.vmag  = Vmag;
+  cnfg_cal.bit.fcal  = Fcal;
+  cnfg_cal.bit.thigh = Thigh;
+  cnfg_cal.bit.fifty = Fifty;
 
-  if (max30001_reg_write(CNFG_CAL, max30001_cnfg_cal.all) == -1) {
+  if (reg_write(CNFG_CAL, cnfg_cal.all) == -1) {
     return -1;
   }
 
-  // RTOS uses a 32768HZ clock.  32768ticks represents 1secs.  1sec/10 =
-  // 100msecs.
+  /// @brief RTOS uses a 32768HZ clock.  32768ticks represents 1secs.  1sec/10 =
+  ///        100msecs.
   wait(1.0 / 10.0);
 
-  if (max30001_reg_read(CNFG_CAL, &max30001_cnfg_cal.all) == -1) {
+  if (reg_read(CNFG_CAL, &cnfg_cal.all) == -1) {
     return -1;
   }
 
-  max30001_cnfg_cal.bit.en_vcal = En_Vcal;
+  cnfg_cal.bit.en_vcal = En_Vcal;
 
-  if (max30001_reg_write(CNFG_CAL, max30001_cnfg_cal.all) == -1) {
+  if (reg_write(CNFG_CAL, cnfg_cal.all) == -1) {
     return -1;
   }
 
-  // RTOS uses a 32768HZ clock.  32768ticks represents 1secs.  1sec/10 =
-  // 100msecs.
+  /// @brief RTOS uses a 32768HZ clock.  32768ticks represents 1secs.  1sec/10 =
+  ///        100msecs.
   wait(1.0 / 10.0);
 
   return 0;
 }
 
 //******************************************************************************
-int MAX30001::max30001_CAL_Stop(void) {
+int MAX30001::CAL_Stop(void) {
 
-  if (max30001_reg_read(CNFG_CAL, &max30001_cnfg_cal.all) == -1) {
+  max30001_cnfg_cal_t cnfg_cal;
+
+  if (reg_read(CNFG_CAL, &cnfg_cal.all) == -1) {
     return -1;
   }
 
-  max30001_cnfg_cal.bit.en_vcal = 0; // Disable VCAL, all other settings are left unaffected
+  cnfg_cal.bit.en_vcal = 0; // Disable VCAL, all other settings are left unaffected
 
-  if (max30001_reg_write(CNFG_CAL, max30001_cnfg_cal.all) == -1) {
+  if (reg_write(CNFG_CAL, cnfg_cal.all) == -1) {
     return -1;
   }
 
   return 0;
 }
 //******************************************************************************
-//******************************************************************************
-int MAX30001::max30001_INT_assignment(max30001_intrpt_Location_t en_enint_loc,     max30001_intrpt_Location_t en_eovf_loc,  max30001_intrpt_Location_t en_fstint_loc,
-		                      max30001_intrpt_Location_t en_dcloffint_loc, max30001_intrpt_Location_t en_bint_loc,  max30001_intrpt_Location_t en_bovf_loc,
-		                      max30001_intrpt_Location_t en_bover_loc,     max30001_intrpt_Location_t en_bundr_loc, max30001_intrpt_Location_t en_bcgmon_loc,
-		                      max30001_intrpt_Location_t en_pint_loc,      max30001_intrpt_Location_t en_povf_loc,  max30001_intrpt_Location_t en_pedge_loc,
-		                      max30001_intrpt_Location_t en_lonint_loc,    max30001_intrpt_Location_t en_rrint_loc, max30001_intrpt_Location_t en_samp_loc,
-		                      max30001_intrpt_type_t  intb_Type,           max30001_intrpt_type_t int2b_Type)
+int MAX30001::INT_assignment(max30001_intrpt_Location_t en_enint_loc,     max30001_intrpt_Location_t en_eovf_loc,  max30001_intrpt_Location_t en_fstint_loc,
+		                     max30001_intrpt_Location_t en_dcloffint_loc, max30001_intrpt_Location_t en_bint_loc,  max30001_intrpt_Location_t en_bovf_loc,
+		                     max30001_intrpt_Location_t en_bover_loc,     max30001_intrpt_Location_t en_bundr_loc, max30001_intrpt_Location_t en_bcgmon_loc,
+		                     max30001_intrpt_Location_t en_pint_loc,      max30001_intrpt_Location_t en_povf_loc,  max30001_intrpt_Location_t en_pedge_loc,
+		                     max30001_intrpt_Location_t en_lonint_loc,    max30001_intrpt_Location_t en_rrint_loc, max30001_intrpt_Location_t en_samp_loc,
+		                     max30001_intrpt_type_t  intb_Type,           max30001_intrpt_type_t int2b_Type)
 
 
 {
-  // INT1
+  
+  max30001_en_int_t en_int;
+  max30001_en_int2_t en_int2;
+  
+  ///< INT1
 
-  if (max30001_reg_read(EN_INT, &max30001_en_int.all) == -1) {
+  if (reg_read(EN_INT, &en_int.all) == -1) {
     return -1;
   }
 
   // max30001_en_int2.bit.en_pint       = 0b1;  // Keep this off...
 
-  max30001_en_int.bit.en_eint = 0b1 & en_enint_loc;
-  max30001_en_int.bit.en_eovf = 0b1 & en_eovf_loc;
-  max30001_en_int.bit.en_fstint = 0b1 & en_fstint_loc;
+  en_int.bit.en_eint   = 0b1 & en_enint_loc;
+  en_int.bit.en_eovf   = 0b1 & en_eovf_loc;
+  en_int.bit.en_fstint = 0b1 & en_fstint_loc;
 
-  max30001_en_int.bit.en_dcloffint = 0b1 & en_dcloffint_loc;
-  max30001_en_int.bit.en_bint = 0b1 & en_bint_loc;
-  max30001_en_int.bit.en_bovf = 0b1 & en_bovf_loc;
+  en_int.bit.en_dcloffint = 0b1 & en_dcloffint_loc;
+  en_int.bit.en_bint      = 0b1 & en_bint_loc;
+  en_int.bit.en_bovf      = 0b1 & en_bovf_loc;
 
-  max30001_en_int.bit.en_bover = 0b1 & en_bover_loc;
-  max30001_en_int.bit.en_bundr = 0b1 & en_bundr_loc;
-  max30001_en_int.bit.en_bcgmon = 0b1 & en_bcgmon_loc;
+  en_int.bit.en_bover  = 0b1 & en_bover_loc;
+  en_int.bit.en_bundr  = 0b1 & en_bundr_loc;
+  en_int.bit.en_bcgmon = 0b1 & en_bcgmon_loc;
 
-  max30001_en_int.bit.en_pint = 0b1 & en_pint_loc;
-  max30001_en_int.bit.en_povf = 0b1 & en_povf_loc;
-  max30001_en_int.bit.en_pedge = 0b1 & en_pedge_loc;
+  en_int.bit.en_pint   = 0b1 & en_pint_loc;
+  en_int.bit.en_povf   = 0b1 & en_povf_loc;
+  en_int.bit.en_pedge  = 0b1 & en_pedge_loc;
 
-  max30001_en_int.bit.en_lonint = 0b1 & en_lonint_loc;
-  max30001_en_int.bit.en_rrint = 0b1 & en_rrint_loc;
-  max30001_en_int.bit.en_samp = 0b1 & en_samp_loc;
+  en_int.bit.en_lonint = 0b1 & en_lonint_loc;
+  en_int.bit.en_rrint  = 0b1 & en_rrint_loc;
+  en_int.bit.en_samp   = 0b1 & en_samp_loc;
 
-  max30001_en_int.bit.intb_type = int2b_Type;
+  en_int.bit.intb_type = int2b_Type;
 
-  if (max30001_reg_write(EN_INT, max30001_en_int.all) == -1) {
+  if (reg_write(EN_INT, en_int.all) == -1) {
     return -1;
   }
 
-  // INT2
+  ///< INT2
 
-  if (max30001_reg_read(EN_INT2, &max30001_en_int2.all) == -1) {
+  if (reg_read(EN_INT2, &en_int2.all) == -1) {
     return -1;
   }
 
-  max30001_en_int2.bit.en_eint   = 0b1 & (en_enint_loc >> 1);
-  max30001_en_int2.bit.en_eovf   = 0b1 & (en_eovf_loc >> 1);
-  max30001_en_int2.bit.en_fstint = 0b1 & (en_fstint_loc >> 1);
+  en_int2.bit.en_eint   = 0b1 & (en_enint_loc >> 1);
+  en_int2.bit.en_eovf   = 0b1 & (en_eovf_loc >> 1);
+  en_int2.bit.en_fstint = 0b1 & (en_fstint_loc >> 1);
 
-  max30001_en_int2.bit.en_dcloffint = 0b1 & (en_dcloffint_loc >> 1);
-  max30001_en_int2.bit.en_bint      = 0b1 & (en_bint_loc >> 1);
-  max30001_en_int2.bit.en_bovf      = 0b1 & (en_bovf_loc >> 1);
+  en_int2.bit.en_dcloffint = 0b1 & (en_dcloffint_loc >> 1);
+  en_int2.bit.en_bint      = 0b1 & (en_bint_loc >> 1);
+  en_int2.bit.en_bovf      = 0b1 & (en_bovf_loc >> 1);
 
-  max30001_en_int2.bit.en_bover  = 0b1 & (en_bover_loc >> 1);
-  max30001_en_int2.bit.en_bundr  = 0b1 & (en_bundr_loc >> 1);
-  max30001_en_int2.bit.en_bcgmon = 0b1 & (en_bcgmon_loc >> 1);
+  en_int2.bit.en_bover  = 0b1 & (en_bover_loc >> 1);
+  en_int2.bit.en_bundr  = 0b1 & (en_bundr_loc >> 1);
+  en_int2.bit.en_bcgmon = 0b1 & (en_bcgmon_loc >> 1);
 
-  max30001_en_int2.bit.en_pint  = 0b1 & (en_pint_loc >> 1);
-  max30001_en_int2.bit.en_povf  = 0b1 & (en_povf_loc >> 1);
-  max30001_en_int2.bit.en_pedge = 0b1 & (en_pedge_loc >> 1);
+  en_int2.bit.en_pint  = 0b1 & (en_pint_loc >> 1);
+  en_int2.bit.en_povf  = 0b1 & (en_povf_loc >> 1);
+  en_int2.bit.en_pedge = 0b1 & (en_pedge_loc >> 1);
 
-  max30001_en_int2.bit.en_lonint = 0b1 & (en_lonint_loc >> 1);
-  max30001_en_int2.bit.en_rrint  = 0b1 & (en_rrint_loc >> 1);
-  max30001_en_int2.bit.en_samp   = 0b1 & (en_samp_loc >> 1);
+  en_int2.bit.en_lonint = 0b1 & (en_lonint_loc >> 1);
+  en_int2.bit.en_rrint  = 0b1 & (en_rrint_loc >> 1);
+  en_int2.bit.en_samp   = 0b1 & (en_samp_loc >> 1);
 
-  max30001_en_int2.bit.intb_type = intb_Type;
+  en_int2.bit.intb_type = intb_Type;
 
-  if (max30001_reg_write(EN_INT2, max30001_en_int2.all) == -1) {
+  if (reg_write(EN_INT2, en_int2.all) == -1) {
     return -1;
   }
 
@@ -220,40 +281,268 @@
 }
 
 //******************************************************************************
-int MAX30001::max30001_ECG_InitStart(uint8_t En_ecg, uint8_t Openp,
-                                     uint8_t Openn, uint8_t Pol,
-                                     uint8_t Calp_sel, uint8_t Caln_sel,
-                                     uint8_t E_fit, uint8_t Rate, uint8_t Gain,
-                                     uint8_t Dhpf, uint8_t Dlpf) {
+int MAX30001::ECG_InitStart(uint8_t En_ecg, uint8_t Openp,
+                            uint8_t Openn, uint8_t Pol,
+                            uint8_t Calp_sel, uint8_t Caln_sel,
+                            uint8_t E_fit, uint8_t Rate, uint8_t Gain,
+                            uint8_t Dhpf, uint8_t Dlpf) {
 
-  // CNFG_EMUX
+  max30001_cnfg_emux_t cnfg_emux;
+  max30001_cnfg_gen_t  cnfg_gen;
+  max30001_status_t    status;
+  max30001_mngr_int_t  mngr_int;
+  max30001_cnfg_ecg_t  cnfg_ecg;
+  
+  ///< CNFG_EMUX
 
-  if (max30001_reg_read(CNFG_EMUX, &max30001_cnfg_emux.all) == -1) {
+  if (reg_read(CNFG_EMUX, &cnfg_emux.all) == -1) {
     return -1;
   }
 
-  max30001_cnfg_emux.bit.openp    = Openp;
-  max30001_cnfg_emux.bit.openn    = Openn;
-  max30001_cnfg_emux.bit.pol      = Pol;
-  max30001_cnfg_emux.bit.calp_sel = Calp_sel;
-  max30001_cnfg_emux.bit.caln_sel = Caln_sel;
+  cnfg_emux.bit.openp    = Openp;
+  cnfg_emux.bit.openn    = Openn;
+  cnfg_emux.bit.pol      = Pol;
+  cnfg_emux.bit.calp_sel = Calp_sel;
+  cnfg_emux.bit.caln_sel = Caln_sel;
 
-  if (max30001_reg_write(CNFG_EMUX, max30001_cnfg_emux.all) == -1) {
+  if (reg_write(CNFG_EMUX, cnfg_emux.all) == -1) {
     return -1;
   }
 
   /**** ENABLE CHANNELS ****/
-  // CNFG_GEN
+  ///< CNFG_GEN
+
+  if (reg_read(CNFG_GEN, &cnfg_gen.all) == -1) {
+    return -1;
+  }
+
+  cnfg_gen.bit.en_ecg = En_ecg; // 0b1
+
+  ///< fmstr is default
+
+  if (reg_write(CNFG_GEN, cnfg_gen.all) == -1) {
+    return -1;
+  }
+
+  ///< Wait for PLL Lock & References to settle down 
+
+  max30001_timeout = 0;
+
+  do {
+    if (reg_read(STATUS, &status.all) == -1) {// Wait and spin for PLL to lock...
+    
+      return -1;
+    }
+  } while (status.bit.pllint == 1 && max30001_timeout++ <= 1000);
+
+  ///< MNGR_INT
+
+  if (reg_read(MNGR_INT, &mngr_int.all) == -1) {
+    return -1;
+  }
+
+  mngr_int.bit.e_fit = E_fit; // 31
+
+  if (reg_write(MNGR_INT, mngr_int.all) == -1) {
+    return -1;
+  }
+
+  ///< CNFG_ECG
+
+  if (reg_read(CNFG_ECG, &cnfg_ecg.all) == -1) {
+    return -1;
+  }
+
+  cnfg_ecg.bit.rate = Rate; 
+  cnfg_ecg.bit.gain = Gain;
+  cnfg_ecg.bit.dhpf = Dhpf;
+  cnfg_ecg.bit.dlpf = Dlpf;
 
-  if (max30001_reg_read(CNFG_GEN, &max30001_cnfg_gen.all) == -1) {
+  if (reg_write(CNFG_ECG, cnfg_ecg.all) == -1) {
+    return -1;
+  }
+
+  return 0;
+}
+
+//******************************************************************************
+int MAX30001::ECGFast_Init(uint8_t Clr_Fast, uint8_t Fast, uint8_t Fast_Th) {
+  
+  max30001_mngr_int_t mngr_int;
+  max30001_mngr_dyn_t mngr_dyn;
+  
+  if (reg_read(MNGR_INT, &mngr_int.all) == -1) {
+    return -1;
+  }
+
+  mngr_int.bit.clr_fast = Clr_Fast;
+
+  if (reg_write(MNGR_INT, mngr_int.all) == -1) {
+    return -1;
+  }
+
+  if (reg_read(MNGR_DYN, &mngr_dyn.all) == -1) {
+    return -1;
+  }
+
+  mngr_dyn.bit.fast = Fast;
+  mngr_dyn.bit.fast_th = Fast_Th;
+
+  if (reg_write(MNGR_INT, mngr_dyn.all) == -1) {
+    return -1;
+  }
+
+  return 0;
+}
+
+//******************************************************************************
+int MAX30001::Stop_ECG(void) {
+
+  max30001_cnfg_gen_t cnfg_gen;
+
+  if (reg_read(CNFG_GEN, &cnfg_gen.all) == -1) {
+    return -1;
+  }
+
+  cnfg_gen.bit.en_ecg = 0; ///< Stop ECG
+
+  ///< fmstr is default
+
+  if (reg_write(CNFG_GEN, cnfg_gen.all) == -1) {
     return -1;
   }
 
-  max30001_cnfg_gen.bit.en_ecg = En_ecg; // 0b1
+  return 0;
+}
+
+//******************************************************************************
+int MAX30001::PACE_InitStart(uint8_t En_pace, uint8_t Clr_pedge,
+                             uint8_t Pol, uint8_t Gn_diff_off,
+                             uint8_t Gain, uint8_t Aout_lbw,
+                             uint8_t Aout, uint8_t Dacp,
+                             uint8_t Dacn) {
+
+  /**** SET MASTER FREQUENCY, ENABLE CHANNELS ****/
+
+   max30001_cnfg_gen_t  cnfg_gen;
+   max30001_status_t    status;
+   max30001_mngr_int_t  mngr_int;
+   max30001_cnfg_pace_t cnfg_pace;
+
+  ///< CNFG_GEN
+
+  if (reg_read(CNFG_GEN, &cnfg_gen.all) == -1) {
+    return -1;
+  }
+
+  cnfg_gen.bit.en_pace = En_pace; // 0b1;
+
+  if (reg_write(CNFG_GEN, cnfg_gen.all) == -1) {
+    return -1;
+  }
+
+  /**** Wait for PLL Lock & References to settle down ****/
+  max30001_timeout = 0;
+
+  do {
+    if (reg_read(STATUS, &status.all) ==
+        -1) // Wait and spin for PLL to lock...
+    {
+      return -1;
+    }
+
+  } while (status.bit.pllint == 1 && max30001_timeout++ <= 1000);
+
+  ///< MNGR_INT
+
+  if (reg_read(MNGR_INT, &mngr_int.all) == -1) {
+    return -1;
+  }
+
+  mngr_int.bit.clr_pedge = Clr_pedge; // 0b0;
+
+  if (reg_write(MNGR_INT, mngr_int.all) == -1) {
+    return -1;
+  }
+
+  ///< CNFG_PACE
+
+  reg_read(CNFG_PACE, &cnfg_pace.all);
+
+  cnfg_pace.bit.pol         = Pol;         
+  cnfg_pace.bit.gn_diff_off = Gn_diff_off;
+  cnfg_pace.bit.gain        = Gain;
+  cnfg_pace.bit.aout_lbw    = Aout_lbw;
+  cnfg_pace.bit.aout        = Aout;
+  cnfg_pace.bit.dacp        = Dacp;
+  cnfg_pace.bit.dacn        = Dacn;
 
-  // fmstr is default
+  reg_write(CNFG_PACE, cnfg_pace.all);
+
+  return 0;
+}
+
+//******************************************************************************
+int MAX30001::Stop_PACE(void) {
+
+  max30001_cnfg_gen_t cnfg_gen;
+
+  if (reg_read(CNFG_GEN, &cnfg_gen.all) == -1) {
+    return -1;
+  }
+
+  cnfg_gen.bit.en_pace = 0; ///< Stop PACE
+
+  if (reg_write(CNFG_GEN, cnfg_gen.all) == -1) {
+    return -1;
+  }
+
+  return 0;
+}
+
+//******************************************************************************
+int MAX30001::BIOZ_InitStart(
+    uint8_t En_bioz, uint8_t Openp, uint8_t Openn, uint8_t Calp_sel,
+    uint8_t Caln_sel, uint8_t CG_mode, uint8_t B_fit, uint8_t Rate,
+    uint8_t Ahpf, uint8_t Ext_rbias, uint8_t Gain, uint8_t Dhpf, uint8_t Dlpf,
+    uint8_t Fcgen, uint8_t Cgmon, uint8_t Cgmag, uint8_t Phoff) {
 
-  if (max30001_reg_write(CNFG_GEN, max30001_cnfg_gen.all) == -1) {
+  max30001_cnfg_bmux_t cnfg_bmux;
+  max30001_cnfg_gen_t  cnfg_gen;
+  max30001_status_t    status;
+  max30001_mngr_int_t  mngr_int;
+  max30001_cnfg_bioz_t cnfg_bioz;
+  
+  
+  // CNFG_BMUX
+
+  if (reg_read(CNFG_BMUX, &cnfg_bmux.all) == -1) {
+    return -1;
+  }
+
+  cnfg_bmux.bit.openp    = Openp;
+  cnfg_bmux.bit.openn    = Openn;
+  cnfg_bmux.bit.calp_sel = Calp_sel;
+  cnfg_bmux.bit.caln_sel = Caln_sel;
+  cnfg_bmux.bit.cg_mode  = CG_mode;
+
+  if (reg_write(CNFG_BMUX, cnfg_bmux.all) == -1) {
+    return -1;
+  }
+
+  /**** SET MASTER FREQUENCY, ENABLE CHANNELS ****/
+
+  ///< CNFG_GEN
+
+  if (reg_read(CNFG_GEN, &cnfg_gen.all) == -1) {
+    return -1;
+  }
+
+  cnfg_gen.bit.en_bioz = En_bioz;
+
+  ///< fmstr is default
+
+  if (reg_write(CNFG_GEN, cnfg_gen.all) == -1) {
     return -1;
   }
 
@@ -262,62 +551,44 @@
   max30001_timeout = 0;
 
   do {
-    if (max30001_reg_read(STATUS, &max30001_status.all) == -1) // Wait and spin for PLL to lock...
-    {
+    if (reg_read(STATUS, &status.all) == -1) { // Wait and spin for PLL to lock...
       return -1;
     }
-  } while (max30001_status.bit.pllint == 1 && max30001_timeout++ <= 1000);
 
-  // MNGR_INT
-
-  if (max30001_reg_read(MNGR_INT, &max30001_mngr_int.all) == -1) {
-    return -1;
-  }
+  } while (status.bit.pllint == 1 && max30001_timeout++ <= 1000);
 
-  max30001_mngr_int.bit.e_fit = E_fit; // 31
+  /**** Start of CNFG_BIOZ ****/
 
-  if (max30001_reg_write(MNGR_INT, max30001_mngr_int.all) == -1) {
-    return -1;
-  }
+  ///< MNGR_INT
 
-  // CNFG_ECG
-
-  if (max30001_reg_read(CNFG_ECG, &max30001_cnfg_ecg.all) == -1) {
+  if (reg_read(MNGR_INT, &mngr_int.all) == -1) {
     return -1;
   }
 
-  max30001_cnfg_ecg.bit.rate = Rate; 
-  max30001_cnfg_ecg.bit.gain = Gain;
-  max30001_cnfg_ecg.bit.dhpf = Dhpf;
-  max30001_cnfg_ecg.bit.dlpf = Dlpf;
+  mngr_int.bit.b_fit = B_fit; //;
 
-  if (max30001_reg_write(CNFG_ECG, max30001_cnfg_ecg.all) == -1) {
+  if (reg_write(MNGR_INT, mngr_int.all) == -1) {
+    return -1;
+  }
+
+  ///< CNFG_BIOZ
+
+  if (reg_read(CNFG_BIOZ, &cnfg_bioz.all) == -1) {
     return -1;
   }
 
-  return 0;
-}
-
-//******************************************************************************
-int MAX30001::max30001_ECGFast_Init(uint8_t Clr_Fast, uint8_t Fast, uint8_t Fast_Th) {
-  if (max30001_reg_read(MNGR_INT, &max30001_mngr_int.all) == -1) {
-    return -1;
-  }
-
-  max30001_mngr_int.bit.clr_fast = Clr_Fast;
+  cnfg_bioz.bit.rate      = Rate;
+  cnfg_bioz.bit.ahpf      = Ahpf;
+  cnfg_bioz.bit.ext_rbias = Ext_rbias;
+  cnfg_bioz.bit.gain      = Gain;
+  cnfg_bioz.bit.dhpf      = Dhpf;
+  cnfg_bioz.bit.dlpf      = Dlpf;
+  cnfg_bioz.bit.fcgen     = Fcgen;
+  cnfg_bioz.bit.cgmon     = Cgmon;
+  cnfg_bioz.bit.cgmag     = Cgmag;
+  cnfg_bioz.bit.phoff     = Phoff;
 
-  if (max30001_reg_write(MNGR_INT, max30001_mngr_int.all) == -1) {
-    return -1;
-  }
-
-  if (max30001_reg_read(MNGR_DYN, &max30001_mngr_dyn.all) == -1) {
-    return -1;
-  }
-
-  max30001_mngr_dyn.bit.fast = Fast;
-  max30001_mngr_dyn.bit.fast_th = Fast_Th;
-
-  if (max30001_reg_write(MNGR_INT, max30001_mngr_int.all) == -1) {
+  if (reg_write(CNFG_BIOZ, cnfg_bioz.all) == -1) {
     return -1;
   }
 
@@ -325,94 +596,19 @@
 }
 
 //******************************************************************************
-int MAX30001::max30001_Stop_ECG(void) {
-
-  if (max30001_reg_read(CNFG_GEN, &max30001_cnfg_gen.all) == -1) {
-    return -1;
-  }
-
-  max30001_cnfg_gen.bit.en_ecg = 0; // Stop ECG
-
-  // fmstr is default
-
-  if (max30001_reg_write(CNFG_GEN, max30001_cnfg_gen.all) == -1) {
-    return -1;
-  }
-
-  return 0;
-}
+int MAX30001::Stop_BIOZ(void) {
 
-//******************************************************************************
-int MAX30001::max30001_PACE_InitStart(uint8_t En_pace, uint8_t Clr_pedge,
-                                      uint8_t Pol, uint8_t Gn_diff_off,
-                                      uint8_t Gain, uint8_t Aout_lbw,
-                                      uint8_t Aout, uint8_t Dacp,
-                                      uint8_t Dacn) {
-
-  /**** SET MASTER FREQUENCY, ENABLE CHANNELS ****/
+  max30001_cnfg_gen_t cnfg_gen;
+  
+  ///< CNFG_GEN
 
-  // CNFG_GEN
-
-  if (max30001_reg_read(CNFG_GEN, &max30001_cnfg_gen.all) == -1) {
-    return -1;
-  }
-
-  max30001_cnfg_gen.bit.en_pace = En_pace; // 0b1;
-
-  if (max30001_reg_write(CNFG_GEN, max30001_cnfg_gen.all) == -1) {
+  if (reg_read(CNFG_GEN, &cnfg_gen.all) == -1) {
     return -1;
   }
 
-  /**** Wait for PLL Lock & References to settle down ****/
-  max30001_timeout = 0;
-
-  do {
-    if (max30001_reg_read(STATUS, &max30001_status.all) ==
-        -1) // Wait and spin for PLL to lock...
-    {
-      return -1;
-    }
-
-  } while (max30001_status.bit.pllint == 1 && max30001_timeout++ <= 1000);
-
-  // MNGR_INT
-
-  if (max30001_reg_read(MNGR_INT, &max30001_mngr_int.all) == -1) {
-    return -1;
-  }
-
-  max30001_mngr_int.bit.clr_pedge = Clr_pedge; // 0b0;
-
-  if (max30001_reg_write(MNGR_INT, max30001_mngr_int.all) == -1) {
-    return -1;
-  }
+  cnfg_gen.bit.en_bioz = 0; // Stop BIOZ
 
-  /* Put: CNFG_PACE */
-
-  max30001_reg_read(CNFG_PACE, &max30001_cnfg_pace.all);
-
-  max30001_cnfg_pace.bit.pol         = Pol;         
-  max30001_cnfg_pace.bit.gn_diff_off = Gn_diff_off;
-  max30001_cnfg_pace.bit.gain        = Gain;
-  max30001_cnfg_pace.bit.aout_lbw    = Aout_lbw;
-  max30001_cnfg_pace.bit.aout        = Aout;
-  max30001_cnfg_pace.bit.dacp        = Dacp;
-  max30001_cnfg_pace.bit.dacn        = Dacn;
-
-  max30001_reg_write(CNFG_PACE, max30001_cnfg_pace.all);
-
-  return 0;
-}
-//******************************************************************************
-int MAX30001::max30001_Stop_PACE(void) {
-
-  if (max30001_reg_read(CNFG_GEN, &max30001_cnfg_gen.all) == -1) {
-    return -1;
-  }
-
-  max30001_cnfg_gen.bit.en_pace = 0; // Stop PACE
-
-  if (max30001_reg_write(CNFG_GEN, max30001_cnfg_gen.all) == -1) {
+  if (reg_write(CNFG_GEN, cnfg_gen.all) == -1) {
     return -1;
   }
 
@@ -420,105 +616,75 @@
 }
 
 //******************************************************************************
-int MAX30001::max30001_BIOZ_InitStart(
-    uint8_t En_bioz, uint8_t Openp, uint8_t Openn, uint8_t Calp_sel,
-    uint8_t Caln_sel, uint8_t CG_mode, uint8_t B_fit, uint8_t Rate,
-    uint8_t Ahpf, uint8_t Ext_rbias, uint8_t Gain, uint8_t Dhpf, uint8_t Dlpf,
-    uint8_t Fcgen, uint8_t Cgmon, uint8_t Cgmag, uint8_t Phoff) {
-
-  // CNFG_BMUX
-
-  if (max30001_reg_read(CNFG_BMUX, &max30001_cnfg_bmux.all) == -1) {
-    return -1;
-  }
-
-  max30001_cnfg_bmux.bit.openp    = Openp;       // 0b1;
-  max30001_cnfg_bmux.bit.openn    = Openn;       // 0b1;
-  max30001_cnfg_bmux.bit.calp_sel = Calp_sel; // 0b10;
-  max30001_cnfg_bmux.bit.caln_sel = Caln_sel; // 0b11;
-  max30001_cnfg_bmux.bit.cg_mode  = CG_mode;   // 0b00;
+int MAX30001::BIOZ_InitBist(uint8_t En_bist, uint8_t Rnom,
+                            uint8_t Rmod, uint8_t Fbist) {
 
-  if (max30001_reg_write(CNFG_BMUX, max30001_cnfg_bmux.all) == -1) {
-    return -1;
-  }
-
-  /**** SET MASTER FREQUENCY, ENABLE CHANNELS ****/
-
-  // CNFG_GEN
+  max30001_cnfg_bmux_t cnfg_bmux;
 
-  if (max30001_reg_read(CNFG_GEN, &max30001_cnfg_gen.all) == -1) {
-    return -1;
-  }
+  ///< CNFG_BMUX
 
-  max30001_cnfg_gen.bit.en_bioz = En_bioz;
-
-  // fmstr is default
-
-  if (max30001_reg_write(CNFG_GEN, max30001_cnfg_gen.all) == -1) {
+  if (reg_read(CNFG_BMUX, &cnfg_bmux.all) == -1) {
     return -1;
   }
 
-  /**** Wait for PLL Lock & References to settle down ****/
-
-  max30001_timeout = 0;
-
-  do {
-    if (max30001_reg_read(STATUS, &max30001_status.all) ==
-        -1) // Wait and spin for PLL to lock...
-    {
-      return -1;
-    }
-
-  } while (max30001_status.bit.pllint == 1 && max30001_timeout++ <= 1000);
-
-  /**** Start of CNFG_BIOZ ****/
-
-  // MNGR_INT
-
-  if (max30001_reg_read(MNGR_INT, &max30001_mngr_int.all) == -1) {
-    return -1;
-  }
-
-  max30001_mngr_int.bit.b_fit = B_fit; //;
+  cnfg_bmux.bit.en_bist = En_bist;
+  cnfg_bmux.bit.rnom = Rnom;
+  cnfg_bmux.bit.rmod = Rmod;
+  cnfg_bmux.bit.fbist = Fbist;
 
-  if (max30001_reg_write(MNGR_INT, max30001_mngr_int.all) == -1) {
-    return -1;
-  }
-
-  // CNFG_BIOZ
-
-  if (max30001_reg_read(CNFG_BIOZ, &max30001_cnfg_bioz.all) == -1) {
-    return -1;
-  }
-
-  max30001_cnfg_bioz.bit.rate      = Rate;
-  max30001_cnfg_bioz.bit.ahpf      = Ahpf;
-  max30001_cnfg_bioz.bit.ext_rbias = Ext_rbias;
-  max30001_cnfg_bioz.bit.gain      = Gain;
-  max30001_cnfg_bioz.bit.dhpf      = Dhpf;
-  max30001_cnfg_bioz.bit.dlpf      = Dlpf;
-  max30001_cnfg_bioz.bit.fcgen     = Fcgen;
-  max30001_cnfg_bioz.bit.cgmon     = Cgmon;
-  max30001_cnfg_bioz.bit.cgmag     = Cgmag;
-  max30001_cnfg_bioz.bit.phoff     = Phoff;
-
-  if (max30001_reg_write(CNFG_BIOZ, max30001_cnfg_bioz.all) == -1) {
+  if (reg_write(CNFG_BMUX, cnfg_bmux.all) == -1) {
     return -1;
   }
 
   return 0;
 }
+//******************************************************************************
+int MAX30001::RtoR_InitStart(uint8_t En_rtor, uint8_t Wndw,
+                             uint8_t Gain, uint8_t Pavg, uint8_t Ptsf,
+                             uint8_t Hoff, uint8_t Ravg, uint8_t Rhsf,
+                             uint8_t Clr_rrint) {
 
-//******************************************************************************
-int MAX30001::max30001_Stop_BIOZ(void) {
+  max30001_mngr_int_t mngr_int;
+  max30001_cnfg_rtor1_t cnfg_rtor1;
+  max30001_cnfg_rtor2_t cnfg_rtor2;
 
-  if (max30001_reg_read(CNFG_GEN, &max30001_cnfg_gen.all) == -1) {
+  ///< MNGR_INT
+  if (reg_read(MNGR_INT, &mngr_int.all) == -1) {
+    return -1;
+  }
+
+  mngr_int.bit.clr_rrint = Clr_rrint; 
+  ///< 0b01 & 0b00 are for interrupt mode...
+  ///< 0b10 is for monitoring mode... it just overwrites the data...
+
+  if (reg_write(MNGR_INT, mngr_int.all) == -1) {
     return -1;
   }
 
-  max30001_cnfg_gen.bit.en_bioz = 0; // Stop BIOZ
+  ///< RTOR1
+  if (reg_read(CNFG_RTOR1, &cnfg_rtor1.all) == -1) {
+    return -1;
+  }
+
+  cnfg_rtor1.bit.wndw = Wndw;
+  cnfg_rtor1.bit.gain = Gain;
+  cnfg_rtor1.bit.en_rtor = En_rtor;
+  cnfg_rtor1.bit.pavg = Pavg;
+  cnfg_rtor1.bit.ptsf = Ptsf;
 
-  if (max30001_reg_write(CNFG_GEN, max30001_cnfg_gen.all) == -1) {
+  if (reg_write(CNFG_RTOR1, cnfg_rtor1.all) == -1) {
+    return -1;
+  }
+  
+  ///< RTOR2
+  if (reg_read(CNFG_RTOR2, &cnfg_rtor2.all) == -1) {
+    return -1;
+  }
+  cnfg_rtor2.bit.hoff = Hoff;
+  cnfg_rtor2.bit.ravg = Ravg;
+  cnfg_rtor2.bit.rhsf = Rhsf;
+
+  if (reg_write(CNFG_RTOR2, cnfg_rtor2.all) == -1) {
     return -1;
   }
 
@@ -526,70 +692,17 @@
 }
 
 //******************************************************************************
-int MAX30001::max30001_BIOZ_InitBist(uint8_t En_bist, uint8_t Rnom,
-                                     uint8_t Rmod, uint8_t Fbist) {
-
-  // CNFG_BMUX
-
-  if (max30001_reg_read(CNFG_BMUX, &max30001_cnfg_bmux.all) == -1) {
-    return -1;
-  }
-
-  max30001_cnfg_bmux.bit.en_bist = En_bist;
-  max30001_cnfg_bmux.bit.rnom = Rnom;
-  max30001_cnfg_bmux.bit.rmod = Rmod;
-  max30001_cnfg_bmux.bit.fbist = Fbist;
+int MAX30001::Stop_RtoR(void) {
 
-  if (max30001_reg_write(CNFG_BMUX, max30001_cnfg_bmux.all) == -1) {
-    return -1;
-  }
+  max30001_cnfg_rtor1_t cnfg_rtor1;
 
-  return 0;
-}
-//******************************************************************************
-int MAX30001::max30001_RtoR_InitStart(uint8_t En_rtor, uint8_t Wndw,
-                                      uint8_t Gain, uint8_t Pavg, uint8_t Ptsf,
-                                      uint8_t Hoff, uint8_t Ravg, uint8_t Rhsf,
-                                      uint8_t Clr_rrint) {
-
-  // MNGR_INT
-
-  if (max30001_reg_read(MNGR_INT, &max30001_mngr_int.all) == -1) {
+  if (reg_read(CNFG_RTOR1, &cnfg_rtor1.all) == -1) {
     return -1;
   }
 
-  max30001_mngr_int.bit.clr_rrint =
-      Clr_rrint; // 0b01 & 0b00 are for interrupt mode...
-  // 0b10 is for monitoring mode... it just overwrites the data...
-
-  if (max30001_reg_write(MNGR_INT, max30001_mngr_int.all) == -1) {
-    return -1;
-  }
-
-  // RTOR1
-  if (max30001_reg_read(CNFG_RTOR1, &max30001_cnfg_rtor1.all) == -1) {
-    return -1;
-  }
+  cnfg_rtor1.bit.en_rtor = 0; ///< Stop RtoR
 
-  max30001_cnfg_rtor1.bit.wndw = Wndw;
-  max30001_cnfg_rtor1.bit.gain = Gain;
-  max30001_cnfg_rtor1.bit.en_rtor = En_rtor;
-  max30001_cnfg_rtor1.bit.pavg = Pavg;
-  max30001_cnfg_rtor1.bit.ptsf = Ptsf;
-
-  if (max30001_reg_write(CNFG_RTOR1, max30001_cnfg_rtor1.all) == -1) {
-    return -1;
-  }
-  // RTOR2
-
-  if (max30001_reg_read(CNFG_RTOR2, &max30001_cnfg_rtor2.all) == -1) {
-    return -1;
-  }
-  max30001_cnfg_rtor2.bit.hoff = Hoff;
-  max30001_cnfg_rtor2.bit.ravg = Ravg;
-  max30001_cnfg_rtor2.bit.rhsf = Rhsf;
-
-  if (max30001_reg_write(CNFG_RTOR2, max30001_cnfg_rtor2.all) == -1) {
+  if (reg_write(CNFG_RTOR1, cnfg_rtor1.all) == -1) {
     return -1;
   }
 
@@ -597,15 +710,29 @@
 }
 
 //******************************************************************************
-int MAX30001::max30001_Stop_RtoR(void) {
+int MAX30001::PLL_lock(void) {
+  ///< Spin to see PLLint become zero to indicate a lock.
+
+  max30001_status_t status;
+
+  max30001_timeout = 0;
+
+  do {
+    if (reg_read(STATUS, &status.all) == -1) { ///< Wait and spin for PLL to lock...
 
-  if (max30001_reg_read(CNFG_RTOR1, &max30001_cnfg_rtor1.all) == -1) {
-    return -1;
-  }
+      return -1;
+    }
+
+  } while (status.bit.pllint == 1 && max30001_timeout++ <= 1000);
 
-  max30001_cnfg_rtor1.bit.en_rtor = 0; // Stop RtoR
+  return 0;
+}
 
-  if (max30001_reg_write(CNFG_RTOR1, max30001_cnfg_rtor1.all) == -1) {
+//******************************************************************************
+int MAX30001::sw_rst(void) {
+  ///< SW reset for the MAX30001 chip
+
+  if (reg_write(SW_RST, 0x000000) == -1) {
     return -1;
   }
 
@@ -613,53 +740,23 @@
 }
 
 //******************************************************************************
-int MAX30001::max30001_PLL_lock(void) {
-  // Spin to see PLLint become zero to indicate a lock.
-
-  max30001_timeout = 0;
-
-  do {
-    if (max30001_reg_read(STATUS, &max30001_status.all) ==
-        -1) // Wait and spin for PLL to lock...
-    {
-      return -1;
-    }
-
-  } while (max30001_status.bit.pllint == 1 && max30001_timeout++ <= 1000);
-
-  return 0;
-}
-
-//******************************************************************************
-int MAX30001::max30001_sw_rst(void) {
-  // SW reset for the MAX30001 chip
-
-  if (max30001_reg_write(SW_RST, 0x000000) == -1) {
-    return -1;
-  }
-
-  return 0;
-}
-
-//******************************************************************************
-int MAX30001::max30001_synch(void) { // For synchronization
-  if (max30001_reg_write(SYNCH, 0x000000) == -1) {
+int MAX30001::synch(void) { ///< For synchronization
+  if (reg_write(SYNCH, 0x000000) == -1) {
     return -1;
   }
   return 0;
 }
 
 //******************************************************************************
-int MAX30001::max300001_fifo_rst(void) { // Resets the FIFO
-  if (max30001_reg_write(FIFO_RST, 0x000000) == -1) {
+int MAX30001::fifo_rst(void) { ///< Resets the FIFO
+  if (reg_write(FIFO_RST, 0x000000) == -1) {
     return -1;
   }
   return 0;
 }
 
 //******************************************************************************
-// int MAX30001::max30001_reg_write(uint8_t addr, uint32_t data)
-int MAX30001::max30001_reg_write(MAX30001_REG_map_t addr, uint32_t data) {
+int MAX30001::reg_write(MAX30001_REG_map_t addr, uint32_t data) {
 
   uint8_t result[4];
   uint8_t data_array[4];
@@ -681,9 +778,8 @@
 }
 
 //******************************************************************************
-// int MAX30001::max30001_reg_read(uint8_t addr, uint32_t *return_data)
-int MAX30001::max30001_reg_read(MAX30001_REG_map_t addr,
-                                uint32_t *return_data) {
+int MAX30001::reg_read(MAX30001_REG_map_t addr,
+                       uint32_t *return_data) {
   uint8_t result[4];
   uint8_t data_array[1];
   int32_t success = 0;
@@ -700,22 +796,24 @@
 }
 
 //******************************************************************************
-int MAX30001::max30001_Enable_DcLeadOFF_Init(int8_t En_dcloff, int8_t Ipol,
-                                             int8_t Imag, int8_t Vth) {
-  //  the leads are not touching the body
+int MAX30001::Enable_DcLeadOFF_Init(int8_t En_dcloff, int8_t Ipol,
+                                    int8_t Imag, int8_t Vth) {
+  ///<  the leads are not touching the body
 
-  // CNFG_EMUX, Set ECGP and ECGN for external hook up...
+  max30001_cnfg_gen_t cnfg_gen;
 
-  if (max30001_reg_read(CNFG_GEN, &max30001_cnfg_gen.all) == -1) {
+  ///< CNFG_EMUX, Set ECGP and ECGN for external hook up...
+
+  if (reg_read(CNFG_GEN, &cnfg_gen.all) == -1) {
     return -1;
   }
 
-  max30001_cnfg_gen.bit.en_dcloff = En_dcloff;
-  max30001_cnfg_gen.bit.ipol = Ipol;
-  max30001_cnfg_gen.bit.imag = Imag;
-  max30001_cnfg_gen.bit.vth = Vth;
+  cnfg_gen.bit.en_dcloff = En_dcloff;
+  cnfg_gen.bit.ipol = Ipol;
+  cnfg_gen.bit.imag = Imag;
+  cnfg_gen.bit.vth = Vth;
 
-  if (max30001_reg_write(CNFG_GEN, max30001_cnfg_gen.all) == -1) {
+  if (reg_write(CNFG_GEN, cnfg_gen.all) == -1) {
     return -1;
   }
 
@@ -723,14 +821,18 @@
 }
 
 //******************************************************************************
-int MAX30001::max30001_Disable_DcLeadOFF(void) {
-  if (max30001_reg_read(CNFG_GEN, &max30001_cnfg_gen.all) == -1) {
+int MAX30001::Disable_DcLeadOFF(void) {
+  
+  max30001_cnfg_gen_t cnfg_gen;
+  
+  ///< CNFG_GEN
+  if (reg_read(CNFG_GEN, &cnfg_gen.all) == -1) {
     return -1;
   }
 
-  max30001_cnfg_gen.bit.en_dcloff = 0; // Turned off the dc lead off.
+  cnfg_gen.bit.en_dcloff = 0; // Turned off the dc lead off.
 
-  if (max30001_reg_write(CNFG_GEN, max30001_cnfg_gen.all) == -1) {
+  if (reg_write(CNFG_GEN, cnfg_gen.all) == -1) {
     return -1;
   }
 
@@ -738,30 +840,32 @@
 }
 
 //******************************************************************************
-int MAX30001::max30001_BIOZ_Enable_ACLeadOFF_Init(uint8_t En_bloff,
-                                                  uint8_t Bloff_hi_it,
-                                                  uint8_t Bloff_lo_it) {
+int MAX30001::BIOZ_Enable_ACLeadOFF_Init(uint8_t En_bloff, uint8_t Bloff_hi_it,
+                                         uint8_t Bloff_lo_it) {
 
-  // CNFG_GEN
-  if (max30001_reg_read(CNFG_GEN, &max30001_cnfg_gen.all) == -1) {
+  max30001_cnfg_gen_t cnfg_gen;
+  max30001_mngr_dyn_t mngr_dyn;
+
+  ///< CNFG_GEN
+  if (reg_read(CNFG_GEN, &cnfg_gen.all) == -1) {
     return -1;
   }
 
-  max30001_cnfg_gen.bit.en_bloff = En_bloff;
+  cnfg_gen.bit.en_bloff = En_bloff;
 
-  if (max30001_reg_write(CNFG_GEN, max30001_cnfg_gen.all) == -1) {
+  if (reg_write(CNFG_GEN, cnfg_gen.all) == -1) {
     return -1;
   }
 
-  // MNGR_DYN
-  if (max30001_reg_read(MNGR_DYN, &max30001_mngr_dyn.all) == -1) {
+  ///< MNGR_DYN
+  if (reg_read(MNGR_DYN, &mngr_dyn.all) == -1) {
     return -1;
   }
 
-  max30001_mngr_dyn.bit.bloff_hi_it = Bloff_hi_it;
-  max30001_mngr_dyn.bit.bloff_lo_it = Bloff_lo_it;
+  mngr_dyn.bit.bloff_hi_it = Bloff_hi_it;
+  mngr_dyn.bit.bloff_lo_it = Bloff_lo_it;
 
-  if (max30001_reg_write(MNGR_DYN, max30001_mngr_dyn.all) == -1) {
+  if (reg_write(MNGR_DYN, mngr_dyn.all) == -1) {
     return -1;
   }
 
@@ -769,15 +873,18 @@
 }
 
 //******************************************************************************
-int MAX30001::max30001_BIOZ_Disable_ACleadOFF(void) {
-  // CNFG_GEN
-  if (max30001_reg_read(CNFG_GEN, &max30001_cnfg_gen.all) == -1) {
+int MAX30001::BIOZ_Disable_ACleadOFF(void) {
+
+  max30001_cnfg_gen_t cnfg_gen;
+  
+  ///< CNFG_GEN
+  if (reg_read(CNFG_GEN, &cnfg_gen.all) == -1) {
     return -1;
   }
 
-  max30001_cnfg_gen.bit.en_bloff = 0b0; // Turns of the BIOZ AC Lead OFF feature
+  cnfg_gen.bit.en_bloff = 0b0; // Turns of the BIOZ AC Lead OFF feature
 
-  if (max30001_reg_write(CNFG_GEN, max30001_cnfg_gen.all) == -1) {
+  if (reg_write(CNFG_GEN, cnfg_gen.all) == -1) {
     return -1;
   }
 
@@ -785,70 +892,73 @@
 }
 
 //******************************************************************************
-int MAX30001::max30001_BIOZ_Enable_BCGMON(void) {
-  // CNFG_BIOZ
-  if (max30001_reg_read(CNFG_BIOZ, &max30001_cnfg_bioz.all) == -1) {
-    return -1;
-  }
-
-  max30001_cnfg_bioz.bit.cgmon = 1;
-
-  if (max30001_reg_write(CNFG_BIOZ, max30001_cnfg_bioz.all) == -1) {
-    return -1;
-  }
-
-  max30001_reg_read(CNFG_BIOZ, &max30001_cnfg_bioz.all);
-
-  return 0;
-}
-
-#if 1
-//******************************************************************************
-int MAX30001::max30001_Enable_LeadON(int8_t Channel) // Channel: ECG = 0b01, BIOZ = 0b10, Disable = 0b00
-{
-
-  if (max30001_reg_read(CNFG_GEN, &max30001_cnfg_gen.all) == -1) {
+int MAX30001::BIOZ_Enable_BCGMON(void) {
+  
+  max30001_cnfg_bioz_t cnfg_bioz;
+  
+  ///< CNFG_BIOZ
+  if (reg_read(CNFG_BIOZ, &cnfg_bioz.all) == -1) {
     return -1;
   }
 
-  max30001_cnfg_gen.bit.en_ecg  = 0b0;
-  max30001_cnfg_gen.bit.en_bioz = 0b0;
-  max30001_cnfg_gen.bit.en_pace = 0b0;
-
-  max30001_cnfg_gen.bit.en_ulp_lon = Channel; // BIOZ ULP lead on detection...
-
-  if (max30001_reg_write(CNFG_GEN, max30001_cnfg_gen.all) == -1) {
-    return -1;
-  }
-
-  max30001_reg_read(CNFG_GEN, &max30001_cnfg_gen.all);
+  cnfg_bioz.bit.cgmon = 1;
 
-  max30001_reg_read(STATUS, &max30001_status.all);
-
-  return 0;
-}
-//******************************************************************************
-int MAX30001::max30001_Disable_LeadON(void) {
-
-  if (max30001_reg_read(CNFG_GEN, &max30001_cnfg_gen.all) == -1) {
-    return -1;
-  }
-
-  max30001_cnfg_gen.bit.en_ulp_lon = 0b0;
-
-  if (max30001_reg_write(CNFG_GEN, max30001_cnfg_gen.all) == -1) {
+  if (reg_write(CNFG_BIOZ, cnfg_bioz.all) == -1) {
     return -1;
   }
 
   return 0;
 }
-#endif
+
+
 //******************************************************************************
-#define LEADOFF_SERVICE_TIME 0x2000 // 0x1000 = 1 second
+int MAX30001::Enable_LeadON(int8_t Channel) // Channel: ECG = 0b01, BIOZ = 0b10, Disable = 0b00
+{
+  
+  max30001_cnfg_gen_t cnfg_gen;
+
+  ///< CNFG_GEN
+  if (reg_read(CNFG_GEN, &cnfg_gen.all) == -1) {
+    return -1;
+  }
+
+  cnfg_gen.bit.en_ecg  = 0b0;
+  cnfg_gen.bit.en_bioz = 0b0;
+  cnfg_gen.bit.en_pace = 0b0;
+
+  cnfg_gen.bit.en_ulp_lon = Channel; ///< BIOZ ULP lead on detection...
+
+  if (reg_write(CNFG_GEN, cnfg_gen.all) == -1) {
+    return -1;
+  }
+
+  return 0;
+}
+
+//******************************************************************************
+int MAX30001::Disable_LeadON(void) {
+
+  max30001_cnfg_gen_t cnfg_gen;
+  ///< CNFG_GEN
+  if (reg_read(CNFG_GEN, &cnfg_gen.all) == -1) {
+    return -1;
+  }
+
+  cnfg_gen.bit.en_ulp_lon = 0b0;
+
+  if (reg_write(CNFG_GEN, cnfg_gen.all) == -1) {
+    return -1;
+  }
+
+  return 0;
+}
+
+//******************************************************************************
+#define LEADOFF_SERVICE_TIME 0x2000 ///< 0x1000 = 1 second
 #define LEADOFF_NUMSTATES 2
 uint32_t leadoffState = 0;
 uint32_t max30001_LeadOffoldTime = 0;
-void MAX30001::max30001_ServiceLeadoff(uint32_t currentTime) {
+void MAX30001::ServiceLeadoff(uint32_t currentTime) {
 
   uint32_t delta_Time;
 
@@ -856,12 +966,12 @@
 
   if (delta_Time > LEADOFF_SERVICE_TIME) {
     switch (leadoffState) {
-    case 0: /* switch to ECG DC Lead OFF */
-      max30001_Enable_DcLeadOFF_Init(0b01, 0b0, 0b001, 0b00);
+    case 0: ///< switch to ECG DC Lead OFF
+      Enable_DcLeadOFF_Init(0b01, 0b0, 0b001, 0b00);
       break;
 
-    case 1: /* switch to BIOZ DC Lead OFF */
-      max30001_Enable_DcLeadOFF_Init(0b10, 0b0, 0b001, 0b00);
+    case 1: ///< switch to BIOZ DC Lead OFF
+      Enable_DcLeadOFF_Init(0b10, 0b0, 0b001, 0b00);
       break;
     }
 
@@ -876,7 +986,7 @@
 #define LEADON_NUMSTATES 2
 uint32_t leadOnState = 0;
 uint32_t max30001_LeadOnoldTime = 0;
-void MAX30001::max30001_ServiceLeadON(uint32_t currentTime) {
+void MAX30001::ServiceLeadON(uint32_t currentTime) {
 
   uint32_t delta_Time;
 
@@ -884,12 +994,12 @@
 
   if (delta_Time > LEADON_SERVICE_TIME) {
     switch (leadOnState) {
-    case 0: /* switch to ECG DC Lead ON */
-      max30001_Enable_LeadON(0b01);
+    case 0: ///< switch to ECG DC Lead ON
+      Enable_LeadON(0b01); 
       break;
 
-    case 1: /* switch to BIOZ DC Lead ON */
-      max30001_Enable_LeadON(0b10);
+    case 1: ///< switch to BIOZ DC Lead ON
+      Enable_LeadON(0b10);
       break;
     }
 
@@ -901,10 +1011,9 @@
 }
 
 //******************************************************************************
-int MAX30001::max30001_FIFO_LeadONOff_Read(void) {
+int MAX30001::FIFO_LeadONOff_Read(void) {
 
-  uint8_t result[32 * 3]; // 32words - 3bytes each
-
+  uint8_t result[32 * 3]; ///< 32words - 3bytes each
   uint8_t data_array[4];
   int32_t success = 0;
   int i, j;
@@ -925,17 +1034,31 @@
   static uint8_t bcgmon_OneShot = 0;
   static uint8_t acleadon_OneShot = 0;
 
+  max30001_mngr_int_t mngr_int;
+  max30001_cnfg_gen_t cnfg_gen;
+
   int8_t ret_val;
 
-  if (max30001_status.bit.eint == 1 || max30001_status.bit.pint == 1) {
+  etag = 0;
+  if (global_status.bit.eint == 1 || global_status.bit.pint == 1) {
     adr = ECG_FIFO_BURST;
     data_array[0] = ((adr << 1) & 0xff) | 1;
 
-    // The SPI routine only sends out data of 32 bytes in size.  Therefore the
-    // data is being read in
-    // smaller chunks in this routine...
+  ///< The SPI routine only sends out data of 32 bytes in size.  Therefore the
+  ///< data is being read in
+  ///<  smaller chunks in this routine...
+
+  ///< READ  mngr_int  AND cnfg_gen;
 
-    total_databytes = (max30001_mngr_int.bit.e_fit + 1) * 3;
+  if (reg_read(MNGR_INT, &mngr_int.all) == -1) {
+    return -1;
+  }
+  
+  if (reg_read(CNFG_GEN, &cnfg_gen.all) == -1) {
+    return -1;
+  }  
+
+    total_databytes = (mngr_int.bit.e_fit + 1) * 3;
 
     i_index = 0;
     loop_logic = 1;
@@ -949,15 +1072,15 @@
         loop_logic = 0;
       }
 
-      /* The extra 1 byte is for the extra byte that comes out of the SPI */
+      ///< The extra 1 byte is for the extra byte that comes out of the SPI
       success = SPI_Transmit(&data_array[0], 1, &result[i_index], (data_chunk + 1)); // Make a copy of the FIFO over here...
 
       if (success != 0) {
         return -1;
       }
 
-      /* This is important, because every transaction above creates an empty
-       * redundant data at result[0] */
+      ///< This is important, because every transaction above creates an empty
+      ///< redundant data at result[0]
       for (j = i_index; j < (data_chunk + i_index); j++) /* get rid of the 1 extra byte by moving the whole array up one */
       {
         result[j] = result[j + 1];
@@ -968,9 +1091,9 @@
 
     ReadAllPaceOnce = 0;
 
-    /* Put the content of the FIFO based on the EFIT value, We ignore the
-     * result[0] and start concatenating indexes: 1,2,3 - 4,5,6 - 7,8,9 -  */
-    for (i = 0, j = 0; i < max30001_mngr_int.bit.e_fit + 1; i++, j = j + 3) // index1=23-16 bit, index2=15-8 bit, index3=7-0 bit
+    ///< Put the content of the FIFO based on the EFIT value, We ignore the
+    ///< result[0] and start concatenating indexes: 1,2,3 - 4,5,6 - 7,8,9 - 
+    for (i = 0, j = 0; i < mngr_int.bit.e_fit + 1; i++, j = j + 3) ///< index1=23-16 bit, index2=15-8 bit, index3=7-0 bit
     {
       max30001_ECG_FIFO_buffer[i] = ((uint32_t)result[j] << 16) + (result[j + 1] << 8) + result[j + 2];
 
@@ -979,12 +1102,12 @@
 
       if (ptag != 0b111 && ReadAllPaceOnce == 0) {
 
-        ReadAllPaceOnce = 1; // This will prevent extra read of PACE, once group
-                             // 0-5 is read ONCE.
+        ReadAllPaceOnce = 1; ///< This will prevent extra read of PACE, once group
+                             ///< 0-5 is read ONCE.
 
         adr = PACE0_FIFO_BURST;
 
-        data_array[0] = ((adr << 1) & 0xff) | 1; // For Read Or with 1
+        data_array[0] = ((adr << 1) & 0xff) | 1; ///< For Read Or with 1
 
         success = SPI_Transmit(&data_array[0], 1, &result[0], 10);
 
@@ -994,7 +1117,7 @@
 
         adr = PACE1_FIFO_BURST;
 
-        data_array[0] = ((adr << 1) & 0xff) | 1; // For Read Or with 1
+        data_array[0] = ((adr << 1) & 0xff) | 1; ///< For Read Or with 1
 
         success = SPI_Transmit(&data_array[0], 1, &result[0], 10);
 
@@ -1004,7 +1127,7 @@
 
         adr = PACE2_FIFO_BURST;
 
-        data_array[0] = ((adr << 1) & 0xff) | 1; // For Read Or with 1
+        data_array[0] = ((adr << 1) & 0xff) | 1; ///< For Read Or with 1
 
         success = SPI_Transmit(&data_array[0], 1, &result[0], 10);
 
@@ -1014,7 +1137,7 @@
 
         adr = PACE3_FIFO_BURST;
 
-        data_array[0] = ((adr << 1) & 0xff) | 1; // For Read Or with 1
+        data_array[0] = ((adr << 1) & 0xff) | 1; ///< For Read Or with 1
 
         success = SPI_Transmit(&data_array[0], 1, &result[0], 10);
 
@@ -1024,7 +1147,7 @@
 
         adr = PACE4_FIFO_BURST;
 
-        data_array[0] = ((adr << 1) & 0xff) | 1; // For Read Or with 1
+        data_array[0] = ((adr << 1) & 0xff) | 1; ///< For Read Or with 1
 
         success = SPI_Transmit(&data_array[0], 1, &result[0], 10);
 
@@ -1034,7 +1157,7 @@
 
         adr = PACE5_FIFO_BURST;
 
-        data_array[0] = ((adr << 1) & 0xff) | 1; // For Read Or with 1
+        data_array[0] = ((adr << 1) & 0xff) | 1; ///< For Read Or with 1
 
         success = SPI_Transmit(&data_array[0], 1, &result[0], 10);
 
@@ -1042,51 +1165,49 @@
         max30001_PACE[16] = (uint32_t)(result[4] << 16) + (result[5] << 8) + result[6];
         max30001_PACE[17] = (uint32_t)(result[7] << 16) + (result[8] << 8) + result[9];
 
-        dataAvailable(MAX30001_DATA_PACE, max30001_PACE, 18); // Send out the Pace data once only
+        dataAvailable(MAX30001_DATA_PACE, max30001_PACE, 18); ///< Send out the Pace data once only
       }
     }
 
     if (etag != 0b110) {
 
-      dataAvailable(MAX30001_DATA_ECG, max30001_ECG_FIFO_buffer, (max30001_mngr_int.bit.e_fit + 1));
+      dataAvailable(MAX30001_DATA_ECG, max30001_ECG_FIFO_buffer, (mngr_int.bit.e_fit + 1));
     }
 
   } /* End of ECG init */
 
   /* RtoR */
 
-  if (max30001_status.bit.rrint == 1) {
-    if (max30001_reg_read(RTOR, &max30001_RtoR_data) == -1) {
+  if (global_status.bit.rrint == 1) {
+    if (reg_read(RTOR, &max30001_RtoR_data) == -1) {
       return -1;
     }
 
     max30001_RtoR_data = (0x00FFFFFF & max30001_RtoR_data) >> 10;
 
     hspValMax30001.R2R = (uint16_t)max30001_RtoR_data;
-    hspValMax30001.fmstr = (uint16_t)max30001_cnfg_gen.bit.fmstr;
+    hspValMax30001.fmstr = (uint16_t)cnfg_gen.bit.fmstr;
 
     dataAvailable(MAX30001_DATA_RTOR, &max30001_RtoR_data, 1);
   }
 
-  // Handling BIOZ data...
+  ///< Handling BIOZ data...
 
-  if (max30001_status.bit.bint == 1) {
+  if (global_status.bit.bint == 1) {
     adr = 0x22;
     data_array[0] = ((adr << 1) & 0xff) | 1;
 
-    /* [(BFIT+1)*3byte]+1extra byte due to the addr */
+    ///< [(BFIT+1)*3byte]+1extra byte due to the addr
 
-    if (SPI_Transmit(&data_array[0], 1, &result[0],((max30001_mngr_int.bit.b_fit + 1) * 3) + 1) == -1) // Make a copy of the FIFO over here...
-
-    {
+    if (SPI_Transmit(&data_array[0], 1, &result[0],((mngr_int.bit.b_fit + 1) * 3) + 1) == -1) { ///< Make a copy of the FIFO over here...
       return -1;
     }
 
     btag = 0b00000111 & result[3];
 
-    /* Put the content of the FIFO based on the BFIT value, We ignore the
-     * result[0] and start concatenating indexes: 1,2,3 - 4,5,6 - 7,8,9 -  */
-    for (i = 0, j = 0; i < max30001_mngr_int.bit.b_fit + 1; i++, j = j + 3) // index1=23-16 bit, index2=15-8 bit, index3=7-0 bit
+    ///< Put the content of the FIFO based on the BFIT value, We ignore the
+    ///< result[0] and start concatenating indexes: 1,2,3 - 4,5,6 - 7,8,9 -
+    for (i = 0, j = 0; i < mngr_int.bit.b_fit + 1; i++, j = j + 3) ///< index1=23-16 bit, index2=15-8 bit, index3=7-0 bit
     {
       max30001_BIOZ_FIFO_buffer[i] = ((uint32_t)result[j + 1] << 16) + (result[j + 2] << 8) + result[j + 3];
     }
@@ -1098,90 +1219,73 @@
 
   ret_val = 0;
 
-  if (max30001_status.bit.dcloffint == 1) // ECG/BIOZ Lead Off
-  {
+  if (global_status.bit.dcloffint == 1) { ///< ECG/BIOZ Lead Off
     dcloffint_OneShot = 1;
     max30001_DCLeadOff = 0;
-    max30001_DCLeadOff = max30001_DCLeadOff | (max30001_cnfg_gen.bit.en_dcloff << 8) | (max30001_status.all & 0x00000F);
+    max30001_DCLeadOff = max30001_DCLeadOff | (cnfg_gen.bit.en_dcloff << 8) | (global_status.all & 0x00000F);
     dataAvailable(MAX30001_DATA_LEADOFF_DC, &max30001_DCLeadOff, 1);
-    // Do a FIFO Reset
-    max30001_reg_write(FIFO_RST, 0x000000);
+    ///< Do a FIFO Reset
+    reg_write(FIFO_RST, 0x000000);
 
     ret_val = 0b100;
 
-  } else if (dcloffint_OneShot == 1 && max30001_status.bit.dcloffint == 0) // Just send once when it comes out of dc lead off
-  {
+  } else if (dcloffint_OneShot == 1 && global_status.bit.dcloffint == 0) { ///< Just send once when it comes out of dc lead off
     max30001_DCLeadOff = 0;
-    max30001_DCLeadOff = max30001_DCLeadOff | (max30001_cnfg_gen.bit.en_dcloff << 8) | (max30001_status.all & 0x00000F);
+    max30001_DCLeadOff = max30001_DCLeadOff | (cnfg_gen.bit.en_dcloff << 8) | (global_status.all & 0x00000F);
     dataAvailable(MAX30001_DATA_LEADOFF_DC, &max30001_DCLeadOff, 1);
     dcloffint_OneShot = 0;
   }
 
-  if (max30001_status.bit.bover == 1 || max30001_status.bit.bundr == 1) // BIOZ AC Lead Off
-  {
+  if (global_status.bit.bover == 1 || global_status.bit.bundr == 1) { ///< BIOZ AC Lead Off
     acloffint_OneShot = 1;
     max30001_ACLeadOff = 0;
     max30001_ACLeadOff =
-        max30001_ACLeadOff | ((max30001_status.all & 0x030000) >> 16);
+        max30001_ACLeadOff | ((global_status.all & 0x030000) >> 16);
     dataAvailable(MAX30001_DATA_LEADOFF_AC, &max30001_ACLeadOff, 1);
-    // Do a FIFO Reset
-    max30001_reg_write(FIFO_RST, 0x000000);
+    ///< Do a FIFO Reset
+    reg_write(FIFO_RST, 0x000000);
 
     ret_val = 0b1000;
-  } else if (acloffint_OneShot == 1 && max30001_status.bit.bover == 0 && max30001_status.bit.bundr == 0) // Just send once when it comes out of ac lead off
-  {
+  } else if (acloffint_OneShot == 1 && global_status.bit.bover == 0 && global_status.bit.bundr == 0) { ///< Just send once when it comes out of ac lead off
     max30001_ACLeadOff = 0;
-    max30001_ACLeadOff = max30001_ACLeadOff | ((max30001_status.all & 0x030000) >> 16);
+    max30001_ACLeadOff = max30001_ACLeadOff | ((global_status.all & 0x030000) >> 16);
     dataAvailable(MAX30001_DATA_LEADOFF_AC, &max30001_ACLeadOff, 1);
     acloffint_OneShot = 0;
   }
 
-  if (max30001_status.bit.bcgmon == 1) // BIOZ BCGMON check
-  {
+  if (global_status.bit.bcgmon == 1) {///< BIOZ BCGMON check
     bcgmon_OneShot = 1;
     max30001_bcgmon = 0;
-    max30001_bcgmon = max30001_bcgmon | ((max30001_status.all & 0x000030) >> 4);
+    max30001_bcgmon = max30001_bcgmon | ((global_status.all & 0x000030) >> 4);
     dataAvailable(MAX30001_DATA_BCGMON, &max30001_bcgmon, 1);
     // Do a FIFO Reset
-    max30001_reg_write(FIFO_RST, 0x000000);
+    reg_write(FIFO_RST, 0x000000);
 
     ret_val = 0b10000;
-  } else if (bcgmon_OneShot == 1 && max30001_status.bit.bcgmon == 0) {
+  } else if (bcgmon_OneShot == 1 && global_status.bit.bcgmon == 0) {
     max30001_bcgmon = 0;
-    max30001_bcgmon = max30001_bcgmon | ((max30001_status.all & 0x000030) >> 4);
+    max30001_bcgmon = max30001_bcgmon | ((global_status.all & 0x000030) >> 4);
     bcgmon_OneShot = 0;
     dataAvailable(MAX30001_DATA_BCGMON, &max30001_bcgmon, 1);
   }
 
-#if 0
-if(max30001_status.bit.lonint == 1)   // AC LeadON Check
-{
-	max30001_LeadOn = 0;
-	max30001_reg_read(STATUS,&max30001_status.all);        // Reading is important
-	max30001_LeadOn = max30001_LeadOn | (max30001_cnfg_gen.bit.en_ulp_lon << 8) | ((max30001_status.all & 0x000800) >> 11);  // 0b01 will mean ECG Lead On, 0b10 will mean BIOZ Lead On
-    // LEAD ON has been detected... Now take actions
-}
-#endif
-
-  if (max30001_status.bit.lonint == 1 &&
-      acleadon_OneShot == 0) // AC LeadON Check, when lead is on
-  {
+  if (global_status.bit.lonint == 1 && acleadon_OneShot == 0) {///< AC LeadON Check, when lead is on
     max30001_LeadOn = 0;
-    max30001_reg_read(STATUS, &max30001_status.all); // Reading is important
+    reg_read(STATUS, &global_status.all);
     max30001_LeadOn =
-        max30001_LeadOn | (max30001_cnfg_gen.bit.en_ulp_lon << 8) |
-        ((max30001_status.all & 0x000800) >>
-         11); // 0b01 will mean ECG Lead On, 0b10 will mean BIOZ Lead On
+        max30001_LeadOn | (cnfg_gen.bit.en_ulp_lon << 8) |
+        ((global_status.all & 0x000800) >>
+         11); ///< 0b01 will mean ECG Lead On, 0b10 will mean BIOZ Lead On
 
     // LEAD ON has been detected... Now take actions
     acleadon_OneShot = 1;
-    dataAvailable(MAX30001_DATA_ACLEADON, &max30001_LeadOn, 1); // One shot data will be sent...
-  } else if (max30001_status.bit.lonint == 0 && acleadon_OneShot == 1) {
+    dataAvailable(MAX30001_DATA_ACLEADON, &max30001_LeadOn, 1); ///< One shot data will be sent...
+  } else if (global_status.bit.lonint == 0 && acleadon_OneShot == 1) {
     max30001_LeadOn = 0;
-    max30001_reg_read(STATUS, &max30001_status.all);
+    reg_read(STATUS, &global_status.all);
     max30001_LeadOn =
-        max30001_LeadOn | (max30001_cnfg_gen.bit.en_ulp_lon << 8) | ((max30001_status.all & 0x000800) >> 11); // 0b01 will mean ECG Lead On, 0b10 will mean BIOZ Lead On
-    dataAvailable(MAX30001_DATA_ACLEADON, &max30001_LeadOn, 1); // One shot data will be sent...
+        max30001_LeadOn | (cnfg_gen.bit.en_ulp_lon << 8) | ((global_status.all & 0x000800) >> 11); ///< 0b01 will mean ECG Lead On, 0b10 will mean BIOZ Lead On
+    dataAvailable(MAX30001_DATA_ACLEADON, &max30001_LeadOn, 1); ///< One shot data will be sent...
     acleadon_OneShot = 0;
   }
 
@@ -1189,19 +1293,18 @@
 }
 
 //******************************************************************************
-
-int MAX30001::max30001_int_handler(void) {
+int MAX30001::int_handler(void) {
 
   static uint32_t InitReset = 0;
 
   int8_t return_value;
 
-  max30001_reg_read(STATUS, &max30001_status.all);
+  reg_read(STATUS, &global_status.all);
 
-  // Inital Reset and any FIFO over flow invokes a FIFO reset
-  if (InitReset == 0 || max30001_status.bit.eovf == 1 || max30001_status.bit.bovf == 1 || max30001_status.bit.povf == 1) {
-    // Do a FIFO Reset
-    max30001_reg_write(FIFO_RST, 0x000000);
+  ///< Inital Reset and any FIFO over flow invokes a FIFO reset
+  if (InitReset == 0 || global_status.bit.eovf == 1 || global_status.bit.bovf == 1 || global_status.bit.povf == 1) {
+    ///< Do a FIFO Reset
+    reg_write(FIFO_RST, 0x000000);
 
     InitReset++;
     return 2;
@@ -1209,69 +1312,61 @@
 
   return_value = 0;
 
-  // The four data handling goes on over here
-  if (max30001_status.bit.eint == 1 || max30001_status.bit.pint == 1 || max30001_status.bit.bint == 1 || max30001_status.bit.rrint == 1) {
-    return_value = return_value | max30001_FIFO_LeadONOff_Read();
+  ///< The four data handling goes on over here
+  if (global_status.bit.eint == 1 || global_status.bit.pint == 1 || global_status.bit.bint == 1 || global_status.bit.rrint == 1) {
+    return_value = return_value | FIFO_LeadONOff_Read();
   }
 
-  // ECG/BIOZ DC Lead Off test
-  if (max30001_status.bit.dcloffint == 1) {
-    return_value = return_value | max30001_FIFO_LeadONOff_Read();
+  ///< ECG/BIOZ DC Lead Off test
+  if (global_status.bit.dcloffint == 1) {
+    return_value = return_value | FIFO_LeadONOff_Read();
   }
 
-  // BIOZ AC Lead Off test
-  if (max30001_status.bit.bover == 1 || max30001_status.bit.bundr == 1) {
-    return_value = return_value | max30001_FIFO_LeadONOff_Read();
+  ///< BIOZ AC Lead Off test
+  if (global_status.bit.bover == 1 || global_status.bit.bundr == 1) {
+    return_value = return_value | FIFO_LeadONOff_Read();
   }
 
-  // BIOZ DRVP/N test using BCGMON.
-  if (max30001_status.bit.bcgmon == 1) {
-    return_value = return_value | max30001_FIFO_LeadONOff_Read();
+  ///< BIOZ DRVP/N test using BCGMON.
+  if (global_status.bit.bcgmon == 1) {
+    return_value = return_value | FIFO_LeadONOff_Read();
   }
 
-  if (max30001_status.bit.lonint == 1) // ECG Lead ON test: i.e. the leads are touching the body...
+  if (global_status.bit.lonint == 1) ///< ECG Lead ON test: i.e. the leads are touching the body...
   {
 
-    max30001_FIFO_LeadONOff_Read();
+    FIFO_LeadONOff_Read();
   }
 
   return return_value;
 }
 
-/// function pointer to the async callback
-static event_callback_t functionpointer;
-/// flag used to indicate an async xfer has taken place
-static volatile int xferFlag = 0;
+
+event_callback_t MAX30001::functionpointer;
+
 
-/**
-* @brief Callback handler for SPI async events
-* @param events description of event that occurred
-*/
-static void spiHandler(int events) { xferFlag = 1; }
+volatile int MAX30001::xferFlag = 0;
 
-/**
-* @brief Transmit and recieve QUAD SPI data
-* @param tx_buf pointer to transmit byte buffer
-* @param tx_size number of bytes to transmit
-* @param rx_buf pointer to the recieve buffer
-* @param rx_size number of bytes to recieve
-*/
+
+//******************************************************************************
 int MAX30001::SPI_Transmit(const uint8_t *tx_buf, uint32_t tx_size, uint8_t *rx_buf, uint32_t rx_size) {
   xferFlag = 0;
-  int i;
+  unsigned int i;
   for (i = 0; i < sizeof(buffer); i++) {
-    if (i < tx_size)
+    if (i < tx_size) {
       buffer[i] = tx_buf[i];
-    else
+    }
+    else {
       buffer[i] = 0xFF;
+    }
   }
-  spi->transfer<uint8_t>(buffer, (int)rx_size, rx_buf, (int)rx_size, spiHandler /* functionpointer */);
+  spi->transfer<uint8_t>(buffer, (int)rx_size, rx_buf, (int)rx_size, spiHandler);
   while (xferFlag == 0);
   return 0;
 }
 
 //******************************************************************************
-void MAX30001::max30001_ReadHeartrateData(max30001_t *_hspValMax30001) {
+void MAX30001::ReadHeartrateData(max30001_bledata_t *_hspValMax30001) {
   _hspValMax30001->R2R = hspValMax30001.R2R;
   _hspValMax30001->fmstr = hspValMax30001.fmstr;
 }
@@ -1281,37 +1376,35 @@
   onDataAvailableCallback = _onDataAvailable;
 }
 
-/**
-* @brief Used to notify an external function that interrupt data is available
-* @param id type of data available
-* @param buffer 32-bit buffer that points to the data
-* @param length length of 32-bit elements available
-*/
+//******************************************************************************
 void MAX30001::dataAvailable(uint32_t id, uint32_t *buffer, uint32_t length) {
   if (onDataAvailableCallback != NULL) {
     (*onDataAvailableCallback)(id, buffer, length);
   }
 }
 
-/**
-* @brief Callback handler for SPI async events
-* @param events description of event that occurred
-*/
-void MAX30001::spiHandler(int events) { xferFlag = 1; }
+//******************************************************************************
+void MAX30001::spiHandler(int events) {
+	 xferFlag = 1;
+}
 
 //******************************************************************************
 static int allowInterrupts = 0;
 
-void MAX30001Mid_IntB_Handler(void) {
-  if (allowInterrupts == 0) return;
-  MAX30001::instance->max30001_int_handler();
+void MAX30001::Mid_IntB_Handler(void) {
+  if (allowInterrupts == 0) {
+  	return;
+  	}
+  MAX30001::instance->int_handler();
 }
 
-void MAX30001Mid_Int2B_Handler(void) {
-  if (allowInterrupts == 0) return;
-  MAX30001::instance->max30001_int_handler();
+void MAX30001::Mid_Int2B_Handler(void) {  
+  if (allowInterrupts == 0) {
+  	return;
+  	}
+  MAX30001::instance->int_handler();
 }
 
-void MAX30001_AllowInterrupts(int state) { 
+void MAX30001::AllowInterrupts(int state) { 
 allowInterrupts = state; 
 }
--- a/HSP/Devices/MAX30001/MAX30001/MAX30001.h	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/Devices/MAX30001/MAX30001/MAX30001.h	Fri Apr 21 12:12:30 2017 -0500
@@ -1,52 +1,209 @@
 /*******************************************************************************
-* Copyright (C) 2015 Maxim Integrated Products, Inc., All Rights Reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a
-* copy of this software and associated documentation files (the "Software"),
-* to deal in the Software without restriction, including without limitation
-* the rights to use, copy, modify, merge, publish, distribute, sublicense,
-* and/or sell copies of the Software, and to permit persons to whom the
-* Software is furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included
-* in all copies or substantial portions of the Software.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-* IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
-* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-* OTHER DEALINGS IN THE SOFTWARE.
-*
-* Except as contained in this notice, the name of Maxim Integrated
-* Products, Inc. shall not be used except as stated in the Maxim Integrated
-* Products, Inc. Branding Policy.
-*
-* The mere transfer of this software does not imply any licenses
-* of trade secrets, proprietary technology, copyrights, patents,
-* trademarks, maskwork rights, or any other form of intellectual
-* property whatsoever. Maxim Integrated Products, Inc. retains all
-* ownership rights.
-*******************************************************************************/
-/*
- * max30001.h
+ * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of Maxim Integrated
+ * Products, Inc. shall not be used except as stated in the Maxim Integrated
+ * Products, Inc. Branding Policy.
+ *
+ * The mere transfer of this software does not imply any licenses
+ * of trade secrets, proprietary technology, copyrights, patents,
+ * trademarks, maskwork rights, or any other form of intellectual
+ * property whatsoever. Maxim Integrated Products, Inc. retains all
+ * ownership rights.
+ *******************************************************************************/
+/**
+ *
+ * Maxim Integrated MAX30001 ECG/BIOZ chip 
  *
- *  Created on: Oct 9, 2015
- *      Author: faisal.tariq
+ * @code
+ * #include "mbed.h"
+ * #include "MAX30001.h"
+ * 
+ * /// Initialization values for ECG_InitStart()
+ * #define EN_ECG     0b1
+ * #define OPENP      0b1
+ * #define OPENN      0b1
+ * #define POL        0b0
+ * #define CALP_SEL   0b10
+ * #define CALN_SEL   0b11
+ * #define E_FIT      31
+ * #define RATE       0b00
+ * #define GAIN       0b00
+ * #define DHPF       0b0
+ * #define DLPF       0b01
+ * 
+ * /// Initialization values for CAL_InitStart() 
+ * #define EN_VCAL  0b1
+ * #define VMODE    0b1
+ * #define VMAG     0b1
+ * #define FCAL     0b011
+ * #define THIGH    0x7FF
+ * #define FIFTY    0b0
+ * 
+ * /// Initializaton values for Rbias_FMSTR_Init()
+ * #define EN_RBIAS 0b01 
+ * #define RBIASV   0b10
+ * #define RBIASP   0b1
+ * #define RBIASN   0b1
+ * #define FMSTR    0b00
+ * 
+ * #define BUFFER_LENGTH 50
+ * 
+ * // @brief SPI Master 0 with SPI0_SS for use with MAX30001
+ * SPI spi(SPI0_MOSI, SPI0_MISO, SPI0_SCK, SPI0_SS); // used by MAX30001
+ * 
+ * //@brief ECG device
+ * MAX30001 max30001(&spi);
+ * InterruptIn max30001_InterruptB(P3_6);
+ * InterruptIn max30001_Interrupt2B(P4_5);
+ * //@brief PWM used as fclk for the MAX30001
+ * PwmOut pwmout(P1_7);
+ * 
+ * //@brief Creating a buffer to hold the data
+ * uint32_t ecgBuffer[BUFFER_LENGTH];
+ * int ecgIndex = 0;
+ * char data_trigger = 0;
+ * 
+ * 
+ * //
+ * // @brief Creates a packet that will be streamed via USB Serial
+ * //       the packet created will be inserted into a fifo to be streamed at a later time
+ * // @param id Streaming ID
+ * // @param buffer Pointer to a uint32 array that contains the data to include in the packet
+ * // @param number Number of elements in the buffer
+ * //
+ * void StreamPacketUint32_ecg(uint32_t id, uint32_t *buffer, uint32_t number) {
+ *   int i;
+ *   if (id == MAX30001_DATA_ECG) {
+ *     for (i = 0; i < number; i++) {
+ *       ecgBuffer[ecgIndex] = buffer[i];
+ *       ecgIndex++;
+ *       if (ecgIndex > BUFFER_LENGTH)
+ *         {
+ *         data_trigger = 1;
+ *         ecgIndex = 0;
+ *         }
+ *     }
+ *   }
+ *   if (id == MAX30001_DATA_BIOZ) {
+ *         /// Add code for reading BIOZ data
+ *   }
+ *   if (id == MAX30001_DATA_PACE) {
+ *         ///  Add code for reading Pace data
+ *   }
+ *   if (id == MAX30001_DATA_RTOR) {
+ *         /// Add code for reading RtoR data
+ *   }
+ * }
+ * 
+ * 
+ * int main() {
+ * 
+ *   uint32_t all;
+ * 
+ *   /// set NVIC priorities for GPIO to prevent priority inversion
+ *   NVIC_SetPriority(GPIO_P0_IRQn, 5);
+ *   NVIC_SetPriority(GPIO_P1_IRQn, 5);
+ *   NVIC_SetPriority(GPIO_P2_IRQn, 5);
+ *   NVIC_SetPriority(GPIO_P3_IRQn, 5);
+ *   NVIC_SetPriority(GPIO_P4_IRQn, 5);
+ *   NVIC_SetPriority(GPIO_P5_IRQn, 5);
+ *   NVIC_SetPriority(GPIO_P6_IRQn, 5);
+ *   // used by the MAX30001
+ *   NVIC_SetPriority(SPI1_IRQn, 0);
+ * 
+ * 
+ *   /// Setup interrupts and callback functions
+ *   max30001_InterruptB.disable_irq();
+ *   max30001_Interrupt2B.disable_irq();
+ * 
+ *   max30001_InterruptB.mode(PullUp);
+ *   max30001_InterruptB.fall(&MAX30001::Mid_IntB_Handler);
+ * 
+ *   max30001_Interrupt2B.mode(PullUp);
+ *   max30001_Interrupt2B.fall(&MAX30001::Mid_Int2B_Handler);
+ * 
+ *   max30001_InterruptB.enable_irq();
+ *   max30001_Interrupt2B.enable_irq();
+ * 
+ *   max30001.AllowInterrupts(1);
+ * 
+ *   // Configuring the FCLK for the ECG, set to 32.768KHZ
+ *   pwmout.period_us(31);
+ *   pwmout.write(0.5);     // 0-1 is 0-100%, 0.5 = 50% duty cycle.
+ *   max30001.sw_rst();     // Do a software reset of the MAX30001
+ *   
+ *   max30001.INT_assignment(MAX30001::MAX30001_INT_B,    MAX30001::MAX30001_NO_INT,   MAX30001::MAX30001_NO_INT,  //  en_enint_loc,      en_eovf_loc,   en_fstint_loc,
+ *                           MAX30001::MAX30001_INT_2B,   MAX30001::MAX30001_INT_2B,   MAX30001::MAX30001_NO_INT,  //  en_dcloffint_loc,  en_bint_loc,   en_bovf_loc,
+ *                           MAX30001::MAX30001_INT_2B,   MAX30001::MAX30001_INT_2B,   MAX30001::MAX30001_NO_INT,  //  en_bover_loc,      en_bundr_loc,  en_bcgmon_loc,
+ *                           MAX30001::MAX30001_INT_B,    MAX30001::MAX30001_NO_INT,   MAX30001::MAX30001_NO_INT,  //  en_pint_loc,       en_povf_loc,   en_pedge_loc,
+ *                           MAX30001::MAX30001_INT_2B,   MAX30001::MAX30001_INT_B,    MAX30001::MAX30001_NO_INT,  //  en_lonint_loc,     en_rrint_loc,  en_samp_loc,
+ *                           MAX30001::MAX30001_INT_ODNR, MAX30001::MAX30001_INT_ODNR);                            //  intb_Type,         int2b_Type)
+ * 
+ *   max30001.onDataAvailable(&StreamPacketUint32_ecg);  
+ * 
+ *   /// Set and Start the VCAL input
+ *   /// @brief NOTE VCAL must be set first if VCAL is to be used 
+ *     max30001.CAL_InitStart(EN_VCAL , VMODE, VMAG, FCAL, THIGH, FIFTY);
+ *           
+ *   /// ECG Initialization
+ *     max30001.ECG_InitStart(EN_ECG, OPENP, OPENN, POL, CALP_SEL, CALN_SEL, E_FIT, RATE, GAIN, DHPF, DLPF);
+ * 
+ *   /// @details The user can call any of the InitStart functions for Pace, BIOZ and RtoR
+ * 
+ * 
+ *   /// @brief Set Rbias & FMSTR over here
+ *       max30001.Rbias_FMSTR_Init(EN_RBIAS, RBIASV, RBIASP, RBIASN,FMSTR);
+ * 
+ *   max30001.synch();
+ * 
+ *   /// clear the status register for a clean start
+ *   max30001.reg_read(MAX30001::STATUS, &all);  
+ *   
+ *   printf("Please wait for data to start streaming\n");
+ *   fflush(stdout);
+ *     
+ *   while (1) {
+ *     if(data_trigger == 1){
+ *     printf("%ld ", ecgBuffer[ecgIndex]);  // Print the ECG data on a serial port terminal software
+ *     fflush(stdout);
+ *     }
+ *   }
+ * }
+ * @endcode 
+ *
  */
 
+
 #ifndef MAX30001_H_
 #define MAX30001_H_
 
 #include "mbed.h"
 
-#define mbed_COMPLIANT // Uncomment to Use timer for MAX30001 FCLK (for mbed)
-                       // Comment to use the RTC clock
+#define mbed_COMPLIANT ///< Uncomment to Use timer for MAX30001 FCLK (for mbed)
+                       ///< Comment to use the RTC clock
 
-#define ASYNC_SPI_BUFFER_SIZE (32 * 3) // Maximimum buffer size for async byte transfers
+#define ASYNC_SPI_BUFFER_SIZE (32 * 3) ///< Maximimum buffer size for async byte transfers
 
-// Defines for data callbacks
+///< Defines for data callbacks
 #define MAX30001_DATA_ECG        0x30
 #define MAX30001_DATA_PACE       0x31
 #define MAX30001_DATA_RTOR       0x32
@@ -68,7 +225,7 @@
 #define MAX30001_INT_PORT_FCLK   1
 #define MAX30001_INT_PIN_FCLK    7
 
-#define MAX30001_FUNC_SEL_TMR    2 // 0=FW Control, 1= Pulse Train, 2=Timer
+#define MAX30001_FUNC_SEL_TMR    2 ///< 0=FW Control, 1= Pulse Train, 2=Timer
 
 #define MAX30001_INDEX    3
 #define MAX30001_POLARITY 0
@@ -96,12 +253,12 @@
 void MAX30001_AllowInterrupts(int state);
 
 /**
-* Maxim Integrated MAX30001 ECG/BIOZ chip
+* @brief Maxim Integrated MAX30001 ECG/BIOZ chip
 */
 class MAX30001 {
 
 public:
-  typedef enum { // MAX30001 Register addresses
+  typedef enum { ///< MAX30001 Register addresses
     STATUS     = 0x01,
     EN_INT     = 0x02,
     EN_INT2    = 0x03,
@@ -163,7 +320,7 @@
   /**
    * @brief STATUS (0x01) 
    */
-  union max30001_status_reg {
+  typedef union max30001_status_reg {
     uint32_t all;
 
     struct {
@@ -201,14 +358,14 @@
 
     } bit;
 
-  } max30001_status;
+  } max30001_status_t;
 
   
   /**
    * @brief EN_INT (0x02) 
    */
 
-  union max30001_en_int_reg {
+  typedef union max30001_en_int_reg {
     uint32_t all;
 
     struct {
@@ -245,13 +402,13 @@
 
     } bit;
 
-  } max30001_en_int;
+  } max30001_en_int_t;
 
   
   /**
    * @brief EN_INT2 (0x03) 
    */  
-  union max30001_en_int2_reg {
+  typedef union max30001_en_int2_reg {
     uint32_t all;
 
     struct {
@@ -288,12 +445,12 @@
 
     } bit;
 
-  } max30001_en_int2;
+  } max30001_en_int2_t;
 
   /**
    * @brief MNGR_INT (0x04) 
    */  
-  union max30001_mngr_int_reg {
+  typedef union max30001_mngr_int_reg {
     uint32_t all;
 
     struct {
@@ -313,12 +470,12 @@
 
     } bit;
 
-  } max30001_mngr_int;
+  } max30001_mngr_int_t;
 
    /**
    * @brief MNGR_DYN (0x05) 
    */ 
-  union max30001_mngr_dyn_reg {
+  typedef union max30001_mngr_dyn_reg {
     uint32_t all;
 
     struct {
@@ -329,22 +486,13 @@
       uint32_t reserved    : 8;
     } bit;
 
-  } max30001_mngr_dyn;
-
-  // 0x08
-  // uint32_t max30001_sw_rst;
-
-  // 0x09
-  // uint32_t max30001_synch;
-
-  // 0x0A
-  // uint32_t max30001_fifo_rst;
+  } max30001_mngr_dyn_t;
 
   
    /**
    * @brief INFO (0x0F) 
    */
-  union max30001_info_reg {
+  typedef union max30001_info_reg {
     uint32_t all;
     struct {
       uint32_t serial    : 12;
@@ -356,12 +504,12 @@
       uint32_t reserved  : 8;
     } bit;
 
-  } max30001_info;
+  } max30001_info_t;
 
    /**
    * @brief CNFG_GEN (0x10) 
    */
-  union max30001_cnfg_gen_reg {
+  typedef union max30001_cnfg_gen_reg {
     uint32_t all;
     struct {
       uint32_t rbiasn     : 1;
@@ -382,13 +530,13 @@
       uint32_t reserved : 8;
     } bit;
 
-  } max30001_cnfg_gen;
+  } max30001_cnfg_gen_t;
 
   
    /**
    * @brief CNFG_CAL (0x12) 
    */  
-  union max30001_cnfg_cal_reg {
+  typedef union max30001_cnfg_cal_reg {
     uint32_t all;
     struct {
       uint32_t thigh     : 11;
@@ -402,12 +550,12 @@
       uint32_t reserved  : 8;
     } bit;
 
-  } max30001_cnfg_cal;
+  } max30001_cnfg_cal_t;
 
    /**
    * @brief CNFG_EMUX  (0x14) 
    */
-  union max30001_cnfg_emux_reg {
+  typedef union max30001_cnfg_emux_reg {
     uint32_t all;
     struct {
       uint32_t reserved1 : 16;
@@ -420,13 +568,13 @@
       uint32_t reserved : 8;
     } bit;
 
-  } max30001_cnfg_emux;
+  } max30001_cnfg_emux_t;
 
   
    /**
    * @brief CNFG_ECG   (0x15) 
    */  
-  union max30001_cnfg_ecg_reg {
+  typedef union max30001_cnfg_ecg_reg {
     uint32_t all;
     struct {
       uint32_t reserved1 : 12;
@@ -440,12 +588,12 @@
       uint32_t reserved  : 8;
     } bit;
 
-  } max30001_cnfg_ecg;
+  } max30001_cnfg_ecg_t;
 
    /**
    * @brief CNFG_BMUX   (0x17) 
    */  
-  union max30001_cnfg_bmux_reg {
+  typedef union max30001_cnfg_bmux_reg {
     uint32_t all;
     struct {
       uint32_t fbist     : 2;
@@ -461,15 +609,15 @@
       uint32_t openn     : 1;
       uint32_t openp     : 1;
       uint32_t reserved4 : 2;
-      uint32_t reserved : 8;
+      uint32_t reserved  : 8;
     } bit;
 
-  } max30001_cnfg_bmux;
+  } max30001_cnfg_bmux_t;
 
    /**
    * @brief CNFG_BIOZ   (0x18) 
    */ 
-  union max30001_bioz_reg {
+  typedef union max30001_bioz_reg {
     uint32_t all;
     struct {
       uint32_t phoff     : 4;
@@ -483,16 +631,16 @@
       uint32_t ext_rbias : 1;
       uint32_t ahpf      : 3;
       uint32_t rate      : 1;
-      uint32_t reserved : 8;
+      uint32_t reserved  : 8;
     } bit;
 
-  } max30001_cnfg_bioz;
+  } max30001_cnfg_bioz_t;
 
   
    /**
    * @brief CNFG_PACE   (0x1A) 
    */   
-  union max30001_cnfg_pace_reg {
+  typedef union max30001_cnfg_pace_reg {
     uint32_t all;
 
     struct {
@@ -509,12 +657,12 @@
       uint32_t reserved    : 8;
     } bit;
 
-  } max30001_cnfg_pace;
+  } max30001_cnfg_pace_t;
 
    /**
    * @brief CNFG_RTOR1   (0x1D) 
    */   
-  union max30001_cnfg_rtor1_reg {
+  typedef union max30001_cnfg_rtor1_reg {
     uint32_t all;
     struct {
       uint32_t reserved1 : 8;
@@ -524,15 +672,15 @@
       uint32_t en_rtor   : 1;
       uint32_t gain      : 4;
       uint32_t wndw      : 4;
-      uint32_t reserved : 8;
+      uint32_t reserved  : 8;
     } bit;
 
-  } max30001_cnfg_rtor1;
+  } max30001_cnfg_rtor1_t;
 
    /**
    * @brief CNFG_RTOR2 (0x1E) 
    */   
-  union max30001_cnfg_rtor2_reg {
+  typedef union max30001_cnfg_rtor2_reg {
     uint32_t all;
     struct {
       uint32_t reserved1 : 8;
@@ -545,14 +693,14 @@
       uint32_t reserved : 8;
     } bit;
 
-  } max30001_cnfg_rtor2;
+  } max30001_cnfg_rtor2_t;
 
   /*********************************************************************************/
 
   typedef enum {
-    MAX30001_NO_INT = 0, // No interrupt
-    MAX30001_INT_B  = 1,  // INTB selected for interrupt
-    MAX30001_INT_2B = 2  // INT2B selected for interrupt
+    MAX30001_NO_INT = 0, ///< No interrupt
+    MAX30001_INT_B  = 1, ///< INTB selected for interrupt
+    MAX30001_INT_2B = 2  ///< INT2B selected for interrupt
   } max30001_intrpt_Location_t;
 
   typedef enum {
@@ -562,60 +710,62 @@
     MAX30001_INT_ODNR     = 0b11
   } max30001_intrpt_type_t;
 
-  typedef enum {          // Input Polarity selection
-    MAX30001_NON_INV = 0, // Non-Inverted
-    MAX30001_INV     = 1      // Inverted
-  } max30001_emux_pol;
+  typedef enum {          ///< Input Polarity selection
+    MAX30001_NON_INV = 0, ///< Non-Inverted
+    MAX30001_INV     = 1  ///< Inverted
+  } max30001_emux_pol_t;
 
-  typedef enum {              // OPENP and OPENN setting
-    MAX30001_ECG_CON_AFE = 0, // ECGx is connected to AFE channel
-    MAX30001_ECG_ISO_AFE = 1  // ECGx is isolated from AFE channel
-  } max30001_emux_openx;
+  typedef enum {              ///< OPENP and OPENN setting
+    MAX30001_ECG_CON_AFE = 0, ///< ECGx is connected to AFE channel
+    MAX30001_ECG_ISO_AFE = 1  ///< ECGx is isolated from AFE channel
+  } max30001_emux_openx_t;
 
-  typedef enum {                // EMUX_CALP_SEL & EMUX_CALN_SEL
-    MAX30001_NO_CAL_SIG = 0b00, // No calibration signal is applied
-    MAX30001_INPT_VMID  = 0b01,  // Input is connected to VMID
-    MAX30001_INPT_VCALP = 0b10, // Input is connected to VCALP
-    MAX30001_INPT_VCALN = 0b11  // Input is connected to VCALN
-  } max30001_emux_calx_sel;
+  typedef enum {                ///< EMUX_CALP_SEL & EMUX_CALN_SEL
+    MAX30001_NO_CAL_SIG = 0b00, ///< No calibration signal is applied
+    MAX30001_INPT_VMID  = 0b01, ///< Input is connected to VMID
+    MAX30001_INPT_VCALP = 0b10, ///< Input is connected to VCALP
+    MAX30001_INPT_VCALN = 0b11  ///< Input is connected to VCALN
+  } max30001_emux_calx_sel_t;
 
-  typedef enum {                     // EN_ECG, EN_BIOZ, EN_PACE
-    MAX30001_CHANNEL_DISABLED = 0b0, //
+  typedef enum {                     ///< EN_ECG, EN_BIOZ, EN_PACE
+    MAX30001_CHANNEL_DISABLED = 0b0,
     MAX30001_CHANNEL_ENABLED = 0b1
-  } max30001_en_feature;
+  } max30001_en_feature_t;
 
   /*********************************************************************************/
   // Data
-  uint32_t max30001_ECG_FIFO_buffer[32]; // (303 for internal test)
-  uint32_t max30001_BIOZ_FIFO_buffer[8]; // (303 for internal test)
+  uint32_t max30001_ECG_FIFO_buffer[32]; ///< (303 for internal test)
+  uint32_t max30001_BIOZ_FIFO_buffer[8]; ///< (303 for internal test)
 
-  uint32_t max30001_PACE[18]; // Pace Data 0-5
+  uint32_t max30001_PACE[18]; ///< Pace Data 0-5
 
-  uint32_t max30001_RtoR_data; // This holds the RtoR data
+  uint32_t max30001_RtoR_data; ///< This holds the RtoR data
 
-  uint32_t max30001_DCLeadOff; // This holds the LeadOff data, Last 4 bits give
-                               // the status, BIT3=LOFF_PH, BIT2=LOFF_PL,
-                               // BIT1=LOFF_NH, BIT0=LOFF_NL
-                               // 8th and 9th bits tell Lead off is due to ECG or BIOZ.  
-                               // 0b01 = ECG Lead Off and 0b10 = BIOZ Lead off
+  uint32_t max30001_DCLeadOff; ///< This holds the LeadOff data, Last 4 bits give
+                               ///< the status, BIT3=LOFF_PH, BIT2=LOFF_PL,
+                               ///< BIT1=LOFF_NH, BIT0=LOFF_NL
+                               ///< 8th and 9th bits tell Lead off is due to ECG or BIOZ.  
+                               ///< 0b01 = ECG Lead Off and 0b10 = BIOZ Lead off
 
-  uint32_t max30001_ACLeadOff; // This gives the state of the BIOZ AC Lead Off
-                               // state.  BIT 1 = BOVER,   BIT 0 = BUNDR
+  uint32_t max30001_ACLeadOff; ///< This gives the state of the BIOZ AC Lead Off
+                               ///< state.  BIT 1 = BOVER,   BIT 0 = BUNDR
 
-  uint32_t max30001_bcgmon; // This holds the BCGMON data, BIT 1 = BCGMP, BIT0 =
-                            // BCGMN
+  uint32_t max30001_bcgmon; ///< This holds the BCGMON data, BIT 1 = BCGMP, BIT0 =
+                            ///< BCGMN
 
-  uint32_t max30001_LeadOn; // This holds the LeadOn data, BIT1 = BIOZ Lead ON,
-                            // BIT0 = ECG Lead ON, BIT8= Lead On Status Bit
+  uint32_t max30001_LeadOn; ///< This holds the LeadOn data, BIT1 = BIOZ Lead ON,
+                            ///< BIT0 = ECG Lead ON, BIT8= Lead On Status Bit
 
-  uint32_t max30001_timeout; // If the PLL does not respond, timeout and get out.
+  uint32_t max30001_timeout; ///< If the PLL does not respond, timeout and get out.
 
-  typedef struct { // Creating a structure for BLE data
+  typedef struct { ///< Creating a structure for BLE data
     int16_t R2R;
     int16_t fmstr;
-  } max30001_t;
+  } max30001_bledata_t;
 
-  max30001_t hspValMax30001; // R2R, FMSTR
+  max30001_bledata_t hspValMax30001; // R2R, FMSTR
+
+  max30001_status_t global_status;
 
   /**
   * @brief Constructor that accepts pin names for the SPI interface
@@ -636,7 +786,13 @@
    * MAX30001 destructor
    */
   ~MAX30001(void);
-
+  
+  /**
+   * @brief This function is MAXIM Proprietary.  It channels the RTC crystal
+   * @brief clock to P1.7.  Thus providing 32768Hz on FCLK pin of the MAX30001-3
+   */ 
+  void FCLK_MaximOnly(void);   
+  
   /**
    * @brief This function sets up the Resistive Bias mode and also selects the master clock frequency.
    * @brief Uses Register: CNFG_GEN-0x10
@@ -648,7 +804,7 @@
    * @returns 0-if no error.  A non-zero value indicates an error.
    *
   */
-  int max30001_Rbias_FMSTR_Init(uint8_t En_rbias, uint8_t Rbiasv,
+  int Rbias_FMSTR_Init(uint8_t En_rbias, uint8_t Rbiasv,
                                 uint8_t Rbiasp, uint8_t Rbiasn, uint8_t Fmstr);
 
   /**
@@ -665,14 +821,14 @@
    * @returns 0-if no error.  A non-zero value indicates an error.
    *
    */
-  int max30001_CAL_InitStart(uint8_t En_Vcal, uint8_t Vmode, uint8_t Vmag,
+  int CAL_InitStart(uint8_t En_Vcal, uint8_t Vmode, uint8_t Vmag,
                              uint8_t Fcal, uint16_t Thigh, uint8_t Fifty);
 
   /**
    * @brief This function disables the VCAL signal
    * @returns 0-if no error.  A non-zero value indicates an error.
    */
-  int max30001_CAL_Stop(void);
+  int CAL_Stop(void);
 
   /**
    * @brief This function handles the assignment of the two interrupt pins (INTB & INT2B) with various
@@ -685,7 +841,7 @@
    * @returns 0-if no error.  A non-zero value indicates an error.
    *
    */
-     int max30001_INT_assignment(max30001_intrpt_Location_t en_enint_loc,     max30001_intrpt_Location_t en_eovf_loc,  max30001_intrpt_Location_t en_fstint_loc,
+     int INT_assignment(max30001_intrpt_Location_t en_enint_loc,     max30001_intrpt_Location_t en_eovf_loc,  max30001_intrpt_Location_t en_fstint_loc,
 		                 max30001_intrpt_Location_t en_dcloffint_loc, max30001_intrpt_Location_t en_bint_loc,  max30001_intrpt_Location_t en_bovf_loc,
 		                 max30001_intrpt_Location_t en_bover_loc,     max30001_intrpt_Location_t en_bundr_loc, max30001_intrpt_Location_t en_bcgmon_loc,
 		                 max30001_intrpt_Location_t en_pint_loc,      max30001_intrpt_Location_t en_povf_loc,  max30001_intrpt_Location_t en_pedge_loc,
@@ -712,10 +868,10 @@
    * @returns 0-if no error.  A non-zero value indicates an error.
    *
    */
-  int max30001_ECG_InitStart(uint8_t En_ecg, uint8_t Openp, uint8_t Openn,
-                             uint8_t Pol, uint8_t Calp_sel, uint8_t Caln_sel,
-                             uint8_t E_fit, uint8_t Rate, uint8_t Gain,
-                             uint8_t Dhpf, uint8_t Dlpf);
+  int ECG_InitStart(uint8_t En_ecg, uint8_t Openp, uint8_t Openn,
+                    uint8_t Pol, uint8_t Calp_sel, uint8_t Caln_sel,
+                    uint8_t E_fit, uint8_t Rate, uint8_t Gain,
+                    uint8_t Dhpf, uint8_t Dlpf);
 
   /**
    * @brief For MAX30001/3 ONLY
@@ -727,7 +883,7 @@
    * @returns 0-if no error.  A non-zero value indicates an error.
    *
    */
-  int max30001_ECGFast_Init(uint8_t Clr_Fast, uint8_t Fast, uint8_t Fast_Th);
+  int ECGFast_Init(uint8_t Clr_Fast, uint8_t Fast, uint8_t Fast_Th);
 
   /**
   * @brief For MAX30001/3 ONLY
@@ -736,7 +892,7 @@
   * @returns 0-if no error.  A non-zero value indicates an error.
   *
   */
-  int max30001_Stop_ECG(void);
+  int Stop_ECG(void);
 
   /**
    *  @brief For MAX30001 ONLY
@@ -757,7 +913,7 @@
    *  @returns 0-if no error.  A non-zero value indicates an error <CNFG_PACE Register>
    *
    */
-  int max30001_PACE_InitStart(uint8_t En_pace, uint8_t Clr_pedge, uint8_t Pol,
+  int PACE_InitStart(uint8_t En_pace, uint8_t Clr_pedge, uint8_t Pol,
                               uint8_t Gn_diff_off, uint8_t Gain,
                               uint8_t Aout_lbw, uint8_t Aout, uint8_t Dacp,
                               uint8_t Dacn);
@@ -768,7 +924,7 @@
    *@returns 0-if no error.  A non-zero value indicates an error.
    *
    */
-  int max30001_Stop_PACE(void);
+  int Stop_PACE(void);
 
   /**
    * @brief For MAX30001/2 ONLY
@@ -794,7 +950,7 @@
    * @returns 0-if no error.  A non-zero value indicates an error.
    *
    */
-  int max30001_BIOZ_InitStart(uint8_t En_bioz, uint8_t Openp, uint8_t Openn,
+  int BIOZ_InitStart(uint8_t En_bioz, uint8_t Openp, uint8_t Openn,
                               uint8_t Calp_sel, uint8_t Caln_sel,
                               uint8_t CG_mode,
                               /* uint8_t En_bioz,*/ uint8_t B_fit, uint8_t Rate,
@@ -809,7 +965,7 @@
        * @returns 0-if no error.  A non-zero value indicates an error.
    *
    */
-  int max30001_Stop_BIOZ(void);
+  int Stop_BIOZ(void);
 
   /**
    * @brief For MAX30001/2 ONLY
@@ -821,7 +977,7 @@
    * @returns 0-if no error.  A non-zero value indicates an error.
    *
    */
-  int max30001_BIOZ_InitBist(uint8_t En_bist, uint8_t Rnom, uint8_t Rmod,
+  int BIOZ_InitBist(uint8_t En_bist, uint8_t Rnom, uint8_t Rmod,
                              uint8_t Fbist);
 
   /**
@@ -839,7 +995,7 @@
    * @returns 0-if no error.  A non-zero value indicates an error.
    *
    */
-  int max30001_RtoR_InitStart(uint8_t En_rtor, uint8_t Wndw, uint8_t Gain,
+  int RtoR_InitStart(uint8_t En_rtor, uint8_t Wndw, uint8_t Gain,
                               uint8_t Pavg, uint8_t Ptsf, uint8_t Hoff,
                               uint8_t Ravg, uint8_t Rhsf, uint8_t Clr_rrint);
 
@@ -849,21 +1005,21 @@
    * @returns 0-if no error.  A non-zero value indicates an error.
    *
    */
-  int max30001_Stop_RtoR(void);
+  int Stop_RtoR(void);
 
   /**
    * @brief This is a function that waits for the PLL to lock; once a lock is achieved it exits out. (For convenience only)
    * @returns 0-if no error.  A non-zero value indicates an error.
    *
    */
-  int max30001_PLL_lock(void);
+  int PLL_lock(void);
 
   /**
    * @brief This function causes the MAX30001 to reset.  Uses Register SW_RST-0x08
    * @return 0-if no error.  A non-zero value indicates an error.
    *
    */
-  int max30001_sw_rst(void);
+  int sw_rst(void);
 
   /**
    * @brief This function provides a SYNCH operation.  Uses Register SYCNH-0x09. Please refer to the data sheet for
@@ -871,14 +1027,14 @@
    * @returns 0-if no error.  A non-zero value indicates an error.
    *
    */
-  int max30001_synch(void);
+  int synch(void);
 
   /**
    * @brief This function performs a FIFO Reset.  Uses Register FIFO_RST-0x0A. Please refer to the data sheet
    * @brief for the details on how to use this.
    * @returns 0-if no error.  A non-zero value indicates an error.
    */
-  int max300001_fifo_rst(void);
+  int fifo_rst(void);
 
   /**
    *
@@ -887,7 +1043,7 @@
    * @returns 0-if no error.  A non-zero value indicates an error.
    *
    */
-  int max30001_int_handler(void);
+  int int_handler(void);
 
   /**
    * @brief This is function called from the max30001_int_handler() function and processes all the ECG, BIOZ, PACE
@@ -906,7 +1062,7 @@
    * @returns 0-if no error.  A non-zero value indicates an error.
    *
    */
-  int max30001_FIFO_LeadONOff_Read(void);
+  int FIFO_LeadONOff_Read(void);
 
   /**
    * @brief This function allows writing to a register.
@@ -915,7 +1071,7 @@
    * @returns 0-if no error.  A non-zero value indicates an error.
    *
    */
-  int max30001_reg_write(MAX30001_REG_map_t addr, uint32_t data);
+  int reg_write(MAX30001_REG_map_t addr, uint32_t data);
 
   /**
    * @brief This function allows reading from a register
@@ -924,7 +1080,7 @@
    * @returns 0-if no error.  A non-zero value indicates an error.
    *
    */
-  int max30001_reg_read(MAX30001_REG_map_t addr, uint32_t *return_data);
+  int reg_read(MAX30001_REG_map_t addr, uint32_t *return_data);
 
   /**
    * @brief This function enables the DC Lead Off detection. Either ECG or BIOZ can be detected, one at a time.
@@ -936,7 +1092,7 @@
    * @returns 0-if no error.  A non-zero value indicates an error.
    *
    */
-  int max30001_Enable_DcLeadOFF_Init(int8_t En_dcloff, int8_t Ipol, int8_t Imag,
+  int Enable_DcLeadOFF_Init(int8_t En_dcloff, int8_t Ipol, int8_t Imag,
                                      int8_t Vth);
 
   /**
@@ -944,7 +1100,7 @@
    * @returns 0-if no error.  A non-zero value indicates an error.
    *
    */
-  int max30001_Disable_DcLeadOFF(void);
+  int Disable_DcLeadOFF(void);
 
   /**
    * @brief This function sets up the BIOZ for AC Lead Off test.
@@ -955,7 +1111,7 @@
    * @returns 0-if no error.  A non-zero value indicates an error.
    *
    */
-  int max30001_BIOZ_Enable_ACLeadOFF_Init(uint8_t En_bloff, uint8_t Bloff_hi_it,
+  int BIOZ_Enable_ACLeadOFF_Init(uint8_t En_bloff, uint8_t Bloff_hi_it,
                                           uint8_t Bloff_lo_it);
 
   /**
@@ -964,7 +1120,7 @@
    * @returns 0-if no error.  A non-zero value indicates an error.
    *
    */
-  int max30001_BIOZ_Disable_ACleadOFF(void);
+  int BIOZ_Disable_ACleadOFF(void);
 
   /**
    * @brief This function enables the Current Gnerator Monitor
@@ -972,7 +1128,7 @@
    * @returns 0-if no error.  A non-zero value indicates an error.
    *
    */
-  int max30001_BIOZ_Enable_BCGMON(void);
+  int BIOZ_Enable_BCGMON(void);
 
   /**
    *
@@ -983,7 +1139,7 @@
    * @returns 0-if everything is good.  A non-zero value indicates an error.
    *
    */
-  int max30001_Enable_LeadON(int8_t Channel);
+  int Enable_LeadON(int8_t Channel);
 
   /**
    * @brief This function turns off the Lead ON feature, whichever one is active.  Also, retrieves the en_bioz,
@@ -991,7 +1147,7 @@
    * @param 0-if everything is good.  A non-zero value indicates an error.
    *
    */
-  int max30001_Disable_LeadON(void);
+  int Disable_LeadON(void);
 
   /**
    *
@@ -1000,7 +1156,7 @@
    * @param CurrentTime - This gets fed the time by RTC_GetValue function
    *
    */
-  void max30001_ServiceLeadON(uint32_t currentTime);
+  void ServiceLeadON(uint32_t currentTime);
 
   /**
    *
@@ -1009,7 +1165,7 @@
    * @param CurrentTime - This gets fed the time by RTC_GetValue function
    *
    */
-  void max30001_ServiceLeadoff(uint32_t currentTime);
+  void ServiceLeadoff(uint32_t currentTime);
 
   /**
    *
@@ -1017,7 +1173,7 @@
    * @param hspValMax30001 - Pointer to a structure where to store the values
    *
    */
-  void max30001_ReadHeartrateData(max30001_t *_hspValMax30001);
+  void ReadHeartrateData(max30001_bledata_t *_hspValMax30001);
 
   /**
    * @brief type definition for data interrupt
@@ -1029,13 +1185,62 @@
    */
   void onDataAvailable(PtrFunction _onDataAvailable);
 
+
+
+  /**
+   * @brief Preventive measure used to dismiss interrupts that fire too early during
+   * @brief initialization on INTB line
+   *
+   */
+  static void Mid_IntB_Handler(void);
+
+  /**
+   * @brief Preventive measure used to dismiss interrupts that fire too early during
+   * @brief initialization on INT2B line
+   *
+   */
+  static void Mid_Int2B_Handler(void);
+
+  /**
+   * @brief Allows Interrupts to be accepted as valid.
+   * @param state: 1-Allow interrupts, Any-Don't allow interrupts.
+   *
+   */
+  void AllowInterrupts(int state);
+
+
+  /// @brief function pointer to the async callback
+  static event_callback_t functionpointer;
+  
+  /// @brief flag used to indicate an async xfer has taken place
+  static volatile int xferFlag;
+
+  /**
+   * @brief Callback handler for SPI async events
+   * @param events description of event that occurred
+   */
+  static void spiHandler(int events);
+
+
   static MAX30001 *instance;
 
 private:
+
+  /**
+   * @brief Used to notify an external function that interrupt data is available
+   * @param id type of data available
+   * @param buffer 32-bit buffer that points to the data
+   * @param length length of 32-bit elements available
+   */
   void dataAvailable(uint32_t id, uint32_t *buffer, uint32_t length);
-  /// interrupt handler for async spi events
-  static void spiHandler(int events);
-  /// wrapper method to transmit and recieve SPI data
+  
+  /**
+   * @brief Transmit and recieve QUAD SPI data
+   * @param tx_buf pointer to transmit byte buffer
+   * @param tx_size number of bytes to transmit
+   * @param rx_buf pointer to the recieve buffer
+   * @param rx_size number of bytes to recieve
+   */
   int SPI_Transmit(const uint8_t *tx_buf, uint32_t tx_size, uint8_t *rx_buf,
                    uint32_t rx_size);
 
@@ -1046,31 +1251,11 @@
   /// buffer to use for async transfers
   uint8_t buffer[ASYNC_SPI_BUFFER_SIZE];
   /// function pointer to the async callback
-  event_callback_t functionpointer;
+ // event_callback_t functionpointer;
   /// callback function when interrupt data is available
   PtrFunction onDataAvailableCallback;
 
 }; // End of MAX30001 Class
 
-/**
- * @brief Preventive measure used to dismiss interrupts that fire too early during
- * @brief initialization on INTB line
- *
- */
-void MAX30001Mid_IntB_Handler(void);
-
-/**
- * @brief Preventive measure used to dismiss interrupts that fire too early during
- * @brief initialization on INT2B line
- *
- */
-void MAX30001Mid_Int2B_Handler(void);
-
-/**
- * @brief Allows Interrupts to be accepted as valid.
- * @param state: 1-Allow interrupts, Any-Don't allow interrupts.
- *
- */
-void MAX30001_AllowInterrupts(int state);
 
 #endif /* MAX30001_H_ */
--- a/HSP/Devices/MAX30001/MAX30001_RPC.cpp	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/Devices/MAX30001/MAX30001_RPC.cpp	Fri Apr 21 12:12:30 2017 -0500
@@ -32,6 +32,7 @@
  */
 
 #include <stdio.h>
+#include "USBSerial.h"
 #include "StringHelper.h"
 #include "MAX30001.h"
 #include "Streaming.h"
@@ -42,30 +43,23 @@
 #include "Peripherals.h"
 #include "DataLoggingService.h"
 
-/*static int startedEcg = 0;
-static int startedBioz = 0;
-static int startedCal = 0;
-static int startedPace = 0;
-static int startedRtor = 0;
-static void StopAll();
-*/
-
 extern int highDataRate;
+extern USBSerial *usbSerialPtr;
 
 uint32_t max30001_RegRead(MAX30001::MAX30001_REG_map_t addr) {
   uint32_t data;
-  Peripherals::max30001()->max30001_reg_read(addr, &data);
+  Peripherals::max30001()->reg_read(addr, &data);
   return data;
 }
 
+//******************************************************************************
 void max30001_RegWrite(MAX30001::MAX30001_REG_map_t addr, uint32_t data) {
-  Peripherals::max30001()->max30001_reg_write(addr, data);
+  Peripherals::max30001()->reg_write(addr, data);
 }
 
 int MAX30001_WriteReg(char argStrs[32][32], char replyStrs[32][32]) {
   uint32_t args[2];
   uint32_t reply[1];
-  uint32_t value;
   ProcessArgs32(argStrs, args, sizeof(args) / sizeof(uint32_t));
 
   max30001_RegWrite((MAX30001::MAX30001_REG_map_t)args[0], args[1]);
@@ -74,6 +68,7 @@
   return 0;
 }
 
+//******************************************************************************
 int MAX30001_ReadReg(char argStrs[32][32], char replyStrs[32][32]) {
   uint32_t args[1];
   uint32_t reply[1];
@@ -85,23 +80,25 @@
   return 0;
 }
 
+//******************************************************************************
 int MAX30001_Rbias_FMSTR_Init(char argStrs[32][32], char replyStrs[32][32]) {
   uint32_t args[5];
   uint32_t reply[1];
   uint32_t value;
   ProcessArgs32(argStrs, args, sizeof(args) / sizeof(uint32_t));
 
-  value = Peripherals::max30001()->max30001_Rbias_FMSTR_Init(args[0],  // En_rbias
-                                                             args[1],  // Rbiasv
-                                                             args[2],  // Rbiasp
-                                                             args[3],  // Rbiasn
-                                                             args[4]); // Fmstr
+  value = Peripherals::max30001()->Rbias_FMSTR_Init(args[0],  ///< En_rbias
+                                                    args[1],  ///< Rbiasv
+                                                    args[2],  ///< Rbiasp
+                                                    args[3],  ///< Rbiasn
+                                                    args[4]); ///< Fmstr
 
   reply[0] = value;
   FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs);
   return 0;
 }
 
+//******************************************************************************
 int MAX30001_CAL_InitStart(char argStrs[32][32], char replyStrs[32][32]) {
   uint32_t args[6];
   uint32_t reply[1];
@@ -109,74 +106,76 @@
   ProcessArgs32(argStrs, args, sizeof(args) / sizeof(uint32_t));
 
   // Peripherals::serial()->printf("MAX30001_CAL_InitStart 0 ");
-  value = Peripherals::max30001()->max30001_CAL_InitStart(args[0], // En_Vcal
-                                                          args[1], // Vmag
-                                                          args[2], // Fcal
-                                                          args[3], // Thigh
-                                                          args[4], // Fifty
-                                                          args[5]); // Vmode
+  value = Peripherals::max30001()->CAL_InitStart(args[0],  ///< En_Vcal
+                                                 args[1],  ///< Vmag
+                                                 args[2],  ///< Fcal
+                                                 args[3],  ///< Thigh
+                                                 args[4],  ///< Fifty
+                                                 args[5]); ///< Vmode
 
   reply[0] = value;
   FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs);
   return 0;
 }
 
+//******************************************************************************
 int MAX30001_ECG_InitStart(char argStrs[32][32], char replyStrs[32][32]) {
   uint32_t args[11];
   uint32_t reply[1];
   uint32_t value;
   ProcessArgs32(argStrs, args, sizeof(args) / sizeof(uint32_t));
 
-  // Peripherals::serial()->printf("MAX30001_ECG_InitStart 0 ");
-  value = Peripherals::max30001()->max30001_ECG_InitStart(args[0], // En_ecg
-                                                          args[1], // Openp
-                                                          args[2], // Openn
-                                                          args[3], // Pol
-                                                          args[4], // Calp_sel
-                                                          args[5], // Caln_sel
-                                                          args[6], // E_fit
-                                                          args[7], // Rate
-                                                          args[8], // Gain
-                                                          args[9], // Dhpf
-                                                          args[10]); // Dlpf
-  // Peripherals::serial()->printf("MAX30001_ECG_InitStart 1 ");
+  value = Peripherals::max30001()->ECG_InitStart(args[0], ///< En_ecg
+                                                 args[1], ///< Openp
+                                                 args[2], ///< Openn
+                                                 args[3], ///< Pol
+                                                 args[4], ///< Calp_sel
+                                                 args[5], ///< Caln_sel
+                                                 args[6], ///< E_fit
+                                                 args[7], ///< Rate
+                                                 args[8], ///< Gain
+                                                 args[9],   ///< Dhpf
+                                                 args[10]); ///< Dlpf
+
   MAX30001_Helper_SetStreamingFlag(eStreaming_ECG, 1);
   reply[0] = value;
   FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs);
   return 0;
 }
 
+//******************************************************************************
 int MAX30001_ECGFast_Init(char argStrs[32][32], char replyStrs[32][32]) {
   uint32_t args[3];
   uint32_t reply[1];
   uint32_t value;
   ProcessArgs32(argStrs, args, sizeof(args) / sizeof(uint32_t));
 
-  value = Peripherals::max30001()->max30001_ECGFast_Init(args[0], // Clr_Fast
-                                                         args[1], // Fast
-                                                         args[2]); // Fast_Th
+  value = Peripherals::max30001()->ECGFast_Init(args[0],  ///< Clr_Fast
+                                                args[1],  ///< Fast
+                                                args[2]); ///< Fast_Th
 
   reply[0] = value;
   FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs);
   return 0;
 }
 
+//******************************************************************************
 int MAX30001_PACE_InitStart(char argStrs[32][32], char replyStrs[32][32]) {
   uint32_t args[9];
   uint32_t reply[1];
   uint32_t value;
   ProcessArgs32(argStrs, args, sizeof(args) / sizeof(uint32_t));
 
-  value =
-      Peripherals::max30001()->max30001_PACE_InitStart(args[0], // En_pace
-                                                       args[1], // Clr_pedge
-                                                       args[2], // Pol
-                                                       args[3], // Gn_diff_off
-                                                       args[4], // Gain
-                                                       args[5], // Aout_lbw
-                                                       args[6], // Aout
-                                                       args[7], // Dacp
-                                                       args[8]); // Dacn
+  value = Peripherals::max30001()->PACE_InitStart(args[0],  ///< En_pace
+                                                  args[1],  ///< Clr_pedge
+                                                  args[2],  ///< Pol
+                                                  args[3],  ///< Gn_diff_off
+                                                  args[4],  ///< Gain
+                                                  args[5],  ///< Aout_lbw
+                                                  args[6],  ///< Aout
+                                                  args[7],  ///< Dacp
+                                                  args[8]); ///< Dacn
+
 
   MAX30001_Helper_SetStreamingFlag(eStreaming_PACE, 1);
   reply[0] = value;
@@ -184,29 +183,30 @@
   return 0;
 }
 
+//******************************************************************************
 int MAX30001_BIOZ_InitStart(char argStrs[32][32], char replyStrs[32][32]) {
   uint32_t args[17];
   uint32_t reply[1];
   uint32_t value;
   ProcessArgs32(argStrs, args, sizeof(args) / sizeof(uint32_t));
 
-  value = Peripherals::max30001()->max30001_BIOZ_InitStart(args[0], // En_bioz
-                                                           args[1], // Openp
-                                                           args[2], // Openn
-                                                           args[3], // Calp_sel
-                                                           args[4], // Caln_sel
-                                                           args[5], // CG_mode
-                                                           args[6], // B_fit
-                                                           args[7], // Rate
-                                                           args[8], // Ahpf
-                                                           args[9], // Ext_rbias
-                                                           args[10], // Gain
-                                                           args[11], // Dhpf
-                                                           args[12], // Dlpf
-                                                           args[13], // Fcgen
-                                                           args[14], // Cgmon
-                                                           args[15], // Cgmag
-                                                           args[16]); // Phoff
+  value = Peripherals::max30001()->BIOZ_InitStart(args[0],   ///< En_bioz
+                                                  args[1],   ///< Openp
+                                                  args[2],   ///< Openn
+                                                  args[3],   ///< Calp_sel
+                                                  args[4],   ///< Caln_sel
+                                                  args[5],   ///< CG_mode
+                                                  args[6],   ///< B_fit
+                                                  args[7],   ///< Rate
+                                                  args[8],   ///< Ahpf
+                                                  args[9],   ///< Ext_rbias
+                                                  args[10],  ///< Gain
+                                                  args[11],  ///< Dhpf
+                                                  args[12],  ///< Dlpf
+                                                  args[13],  ///< Fcgen
+                                                  args[14],  ///< Cgmon
+                                                  args[15],  ///< Cgmag
+                                                  args[16]); ///< Phoff
 
   MAX30001_Helper_SetStreamingFlag(eStreaming_BIOZ, 1);
   reply[0] = value;
@@ -214,21 +214,22 @@
   return 0;
 }
 
+//******************************************************************************
 int MAX30001_RtoR_InitStart(char argStrs[32][32], char replyStrs[32][32]) {
   uint32_t args[9];
   uint32_t reply[1];
   uint32_t value;
   ProcessArgs32(argStrs, args, sizeof(args) / sizeof(uint32_t));
 
-  value =  Peripherals::max30001()->max30001_RtoR_InitStart(args[0], // En_rtor
-                                                            args[1], // Wndw
-                                                            args[2], // Gain
-                                                            args[3], // Pavg
-                                                            args[4], // Ptsf
-                                                            args[5], // Hoff
-                                                            args[6], // Ravg
-                                                            args[7], // Rhsf
-                                                            args[8]); // Clr_rrint
+  value =  Peripherals::max30001()->RtoR_InitStart(args[0], ///< En_rtor
+                                                   args[1], ///< Wndw
+                                                   args[2], ///< Gain
+                                                   args[3], ///< Pavg
+                                                   args[4], ///< Ptsf
+                                                   args[5], ///< Hoff
+                                                   args[6], ///< Ravg
+                                                   args[7], ///< Rhsf
+                                                   args[8]); ///< Clr_rrint
 
   MAX30001_Helper_SetStreamingFlag(eStreaming_RtoR, 1);
   reply[0] = value;
@@ -236,46 +237,56 @@
   return 0;
 }
 
+//******************************************************************************
 int MAX30001_Stop_ECG(char argStrs[32][32], char replyStrs[32][32]) {
   uint32_t reply[1];
-  Peripherals::max30001()->max30001_Stop_ECG();
-  reply[0] = 0x80;
-  FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs);
-  return 0;
-}
-int MAX30001_Stop_PACE(char argStrs[32][32], char replyStrs[32][32]) {
-  uint32_t reply[1];
-  Peripherals::max30001()->max30001_Stop_PACE();
+  Peripherals::max30001()->Stop_ECG();
   reply[0] = 0x80;
   FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs);
   return 0;
 }
-int MAX30001_Stop_BIOZ(char argStrs[32][32], char replyStrs[32][32]) {
-  uint32_t reply[1];
-  Peripherals::max30001()->max30001_Stop_BIOZ();
-  reply[0] = 0x80;
-  FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs);
-  return 0;
-}
-int MAX30001_Stop_RtoR(char argStrs[32][32], char replyStrs[32][32]) {
+
+//******************************************************************************
+int MAX30001_Stop_PACE(char argStrs[32][32], char replyStrs[32][32]) {
   uint32_t reply[1];
-  Peripherals::max30001()->max30001_Stop_RtoR();
-  reply[0] = 0x80;
-  FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs);
-  return 0;
-}
-int MAX30001_Stop_Cal(char argStrs[32][32], char replyStrs[32][32]) {
-  uint32_t reply[1];
-  // max30001_Stop_Cal();
+  Peripherals::max30001()->Stop_PACE();
   reply[0] = 0x80;
   FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs);
   return 0;
 }
 
+//******************************************************************************
+int MAX30001_Stop_BIOZ(char argStrs[32][32], char replyStrs[32][32]) {
+  uint32_t reply[1];
+  Peripherals::max30001()->Stop_BIOZ();
+  reply[0] = 0x80;
+  FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs);
+  return 0;
+}
+
+//******************************************************************************
+int MAX30001_Stop_RtoR(char argStrs[32][32], char replyStrs[32][32]) {
+  uint32_t reply[1];
+  Peripherals::max30001()->Stop_RtoR();
+  reply[0] = 0x80;
+  FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs);
+  return 0;
+}
+
+//******************************************************************************
+int MAX30001_Stop_Cal(char argStrs[32][32], char replyStrs[32][32]) {
+
+  uint32_t reply[1];
+
+  reply[0] = 0x80;
+  FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs);
+  return 0;
+}
+
+//******************************************************************************
 void max30001_ServiceStreaming() {
-  char ch;
+  //char ch;
   uint32_t val;
-  USBSerial *usbSerial = Peripherals::usbSerial();
 
   fifo_clear(GetStreamOutFifo());
 
@@ -286,29 +297,30 @@
     if (fifo_empty(GetStreamOutFifo()) == 0) {
       fifo_get32(GetStreamOutFifo(), &val);
 
-      usbSerial->printf("%02X ", val);
+      usbSerialPtr->printf("%02X ", val);
 
     }
-    if (usbSerial->available()) {
-      ch = usbSerial->_getc();
+    if (usbSerialPtr->available()) {
+      usbSerialPtr->_getc();
 
       MAX30001_Helper_Stop();
       SetStreaming(FALSE);
-      fifo_clear(GetUSBIncomingFifo()); // clear USB serial incoming fifo
+      fifo_clear(GetUSBIncomingFifo()); ///< clear USB serial incoming fifo
       fifo_clear(GetStreamOutFifo());
     }
 
   }
 }
 
+//******************************************************************************
 int MAX30001_Start(char argStrs[32][32], char replyStrs[32][32]) {
   uint32_t reply[1];
   uint32_t all;
   fifo_clear(GetUSBIncomingFifo());
-  Peripherals::max30001()->max30001_synch();
-  //	max30001_ServiceStreaming();
+  Peripherals::max30001()->synch();
+  ///<	max30001_ServiceStreaming();
   highDataRate = 0;
-  Peripherals::max30001()->max30001_reg_read(MAX30001::STATUS, &all);
+  Peripherals::max30001()->reg_read(MAX30001::STATUS, &all);
   LoggingService_StartLoggingUsb();
 
   reply[0] = 0x80;
@@ -316,6 +328,7 @@
   return 0;
 }
 
+//******************************************************************************
 int MAX30001_Stop(char argStrs[32][32], char replyStrs[32][32]) {
   /*	uint32_t args[1];
           uint32_t reply[1];
@@ -327,34 +340,13 @@
   return 0;
 }
 
+//******************************************************************************
 int MAX30001_INT_assignment(char argStrs[32][32], char replyStrs[32][32]) {
   uint32_t args[17];
   uint32_t reply[1];
   ProcessArgs32(argStrs, args, sizeof(args) / sizeof(uint32_t));
-  /*
-  printf("MAX30001_INT_assignment ");
-  printf("%d ",args[0]);
-  printf("%d ",args[1]);
-  printf("%d ",args[2]);
-  printf("%d ",args[3]);
-  printf("%d ",args[4]);
-  printf("%d ",args[5]);
-  printf("%d ",args[6]);
-  printf("%d ",args[7]);
-  printf("%d ",args[8]);
-  printf("%d ",args[9]);
-  printf("%d ",args[10]);
-  printf("%d ",args[11]);
-  printf("%d ",args[12]);
-  printf("%d ",args[13]);
-  printf("%d ",args[14]);
-  printf("%d ",args[15]);
-  printf("%d ",args[16]);
-  printf("\n");
-  fflush(stdout);
-  */
 
-  Peripherals::max30001()->max30001_INT_assignment(
+  Peripherals::max30001()->INT_assignment(
       (MAX30001::max30001_intrpt_Location_t)args[0],
       (MAX30001::max30001_intrpt_Location_t)args[1],
       (MAX30001::max30001_intrpt_Location_t)args[2],
@@ -377,6 +369,7 @@
   return 0;
 }
 
+//******************************************************************************
 int MAX30001_StartTest(char argStrs[32][32], char replyStrs[32][32]) {
   uint32_t reply[1];
   // ProcessArgs32(argStrs, args, sizeof(args) / sizeof(uint32_t));
@@ -385,24 +378,24 @@
 
   /*** Set and Start the VCAL input ***/
   /* NOTE VCAL must be set first if VCAL is to be used */
-  Peripherals::max30001()->max30001_CAL_InitStart(0b1, 0b1, 0b1, 0b011, 0x7FF, 0b0);
+  Peripherals::max30001()->CAL_InitStart(0b1, 0b1, 0b1, 0b011, 0x7FF, 0b0);
 
   /**** ECG Initialization ****/
-  Peripherals::max30001()->max30001_ECG_InitStart(0b1, 0b1, 0b1, 0b0, 0b10, 0b11, 31, 0b00, 0b00, 0b0, 0b01);
+  Peripherals::max30001()->ECG_InitStart(0b1, 0b1, 0b1, 0b0, 0b10, 0b11, 31, 0b00, 0b00, 0b0, 0b01);
 
   /***** PACE Initialization ***/
-  Peripherals::max30001()->max30001_PACE_InitStart(0b1, 0b0, 0b0, 0b1, 0b000, 0b0, 0b00, 0b0, 0b0);
+  Peripherals::max30001()->PACE_InitStart(0b1, 0b0, 0b0, 0b1, 0b000, 0b0, 0b00, 0b0, 0b0);
 
   /**** BIOZ Initialization ****/
-  Peripherals::max30001()->max30001_BIOZ_InitStart(
+  Peripherals::max30001()->BIOZ_InitStart(
       0b1, 0b1, 0b1, 0b10, 0b11, 0b00, 7, 0b0, 0b111, 0b0, 0b10, 0b00, 0b00, 0b0001, 0b0, 0b111, 0b0000);
 
   /*** Set RtoR registers ***/
-  Peripherals::max30001()->max30001_RtoR_InitStart(
+  Peripherals::max30001()->RtoR_InitStart(
       0b1, 0b0011, 0b1111, 0b00, 0b0011, 0b000001, 0b00, 0b000, 0b01);
 
   /*** Set Rbias & FMSTR over here ****/
-  Peripherals::max30001()->max30001_Rbias_FMSTR_Init(0b01, 0b10, 0b1, 0b1, 0b00);
+  Peripherals::max30001()->Rbias_FMSTR_Init(0b01, 0b10, 0b1, 0b1, 0b00);
 
   /**** Interrupt Setting  ****/
 
@@ -413,7 +406,7 @@
   //     max30001_BIOZ_LeadOnOff();  Does not work yet...
 
   /**** Do a Synch ****/
-  Peripherals::max30001()->max30001_synch();
+  Peripherals::max30001()->synch();
 
   fifo_clear(GetUSBIncomingFifo());
   max30001_ServiceStreaming();
@@ -422,55 +415,31 @@
   FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs);
   return 0;
 }
-/*
-static void StopAll() {
-        if (startedEcg == 1) {
-                max30001_Stop_ECG();
-        }
-        if (startedCal == 1) {
-        }
-        if (startedBioz == 1) {
-                max30001_Stop_BIOZ();
-        }
-        if (startedPace == 1) {
-                max30001_Stop_PACE();
-        }
-        if (startedRtor == 1) {
-                max30001_Stop_RtoR();
-        }
-        startedEcg = 0;
-        startedBioz = 0;
-        startedCal = 0;
-        startedPace = 0;
-        startedRtor = 0;
-}
-*/
-/*
-// switch to ECG DC Lead ON
-max30001_Enable_LeadON(0b01);
-// switch to BIOZ DC Lead ON
-max30001_Enable_LeadON(0b10);
-*/
+
+//******************************************************************************
 int MAX30001_Enable_ECG_LeadON(char argStrs[32][32], char replyStrs[32][32]) {
   uint32_t reply[1];
-  // switch to ECG DC Lead ON
-  Peripherals::max30001()->max30001_Enable_LeadON(0b01);
+  ///< switch to ECG DC Lead ON
+  Peripherals::max30001()->Enable_LeadON(0b01);
   reply[0] = 0x80;
   FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs);
   return 0;
 }
+
+//******************************************************************************
 int MAX30001_Enable_BIOZ_LeadON(char argStrs[32][32], char replyStrs[32][32]) {
   uint32_t reply[1];
-  // switch to BIOZ DC Lead ON
-  Peripherals::max30001()->max30001_Enable_LeadON(0b10);
+  ///< switch to BIOZ DC Lead ON
+  Peripherals::max30001()->Enable_LeadON(0b10);
   reply[0] = 0x80;
   FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs);
   return 0;
 }
-// uint32_t max30001_LeadOn;     // This holds the LeadOn data, BIT1 = BIOZ Lead ON,  BIT0 = ECG Lead ON
+
+//******************************************************************************
 int MAX30001_Read_LeadON(char argStrs[32][32], char replyStrs[32][32]) {
   uint32_t reply[1];
-  // return the max30001_LeadOn var from the MAX30001 driver
+  ///< return the max30001_LeadOn var from the MAX30001 driver
   reply[0] = Peripherals::max30001()->max30001_LeadOn;
   FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs);
   return 0;
--- a/HSP/Devices/MAX30001/MAX30001_helper.cpp	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/Devices/MAX30001/MAX30001_helper.cpp	Fri Apr 21 12:12:30 2017 -0500
@@ -1,4 +1,3 @@
-
 /*******************************************************************************
  * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
  *
@@ -49,16 +48,16 @@
 
 void MAX30001_Helper_Stop(void) {
   if (flags[(uint32_t)eStreaming_ECG] == 1) {
-    Peripherals::max30001()->max30001_Stop_ECG();
+    Peripherals::max30001()->Stop_ECG();
   }
   if (flags[(uint32_t)eStreaming_PACE] == 1) {
-    Peripherals::max30001()->max30001_Stop_PACE();
+    Peripherals::max30001()->Stop_PACE();
   }
   if (flags[(uint32_t)eStreaming_BIOZ] == 1) {
-    Peripherals::max30001()->max30001_Stop_BIOZ();
+    Peripherals::max30001()->Stop_BIOZ();
   }
   if (flags[(uint32_t)eStreaming_RtoR] == 1) {
-    Peripherals::max30001()->max30001_Stop_RtoR();
+    Peripherals::max30001()->Stop_RtoR();
   }
   MAX30001_Helper_ClearStreamingFlags();
 }
@@ -73,7 +72,7 @@
 
 void MAX30001_Helper_StartSync(void) {
   if (MAX30001_AnyStreamingSet() == 1) {
-    Peripherals::max30001()->max30001_synch();
+    Peripherals::max30001()->synch();
   }
 }
 
@@ -102,12 +101,12 @@
 }
 
 void MAX30001_Helper_SetupInterrupts() {
-	Peripherals::max30001()->max30001_INT_assignment(MAX30001::MAX30001_INT_B,    MAX30001::MAX30001_NO_INT,   MAX30001::MAX30001_NO_INT,  //  en_enint_loc,      en_eovf_loc,   en_fstint_loc,
-                                                         MAX30001::MAX30001_INT_2B,   MAX30001::MAX30001_INT_2B,   MAX30001::MAX30001_NO_INT,  //  en_dcloffint_loc,  en_bint_loc,   en_bovf_loc,
-                                                         MAX30001::MAX30001_INT_2B,   MAX30001::MAX30001_INT_2B,   MAX30001::MAX30001_NO_INT,  //  en_bover_loc,      en_bundr_loc,  en_bcgmon_loc,
-                                                         MAX30001::MAX30001_INT_B,    MAX30001::MAX30001_NO_INT,   MAX30001::MAX30001_NO_INT,  //  en_pint_loc,       en_povf_loc,   en_pedge_loc,
-                                                         MAX30001::MAX30001_INT_2B,   MAX30001::MAX30001_INT_B,    MAX30001::MAX30001_NO_INT,  //  en_lonint_loc,     en_rrint_loc,  en_samp_loc,
-                                                         MAX30001::MAX30001_INT_ODNR, MAX30001::MAX30001_INT_ODNR);                            //  intb_Type,         int2b_Type)
+	Peripherals::max30001()->INT_assignment(MAX30001::MAX30001_INT_B,    MAX30001::MAX30001_NO_INT,   MAX30001::MAX30001_NO_INT,  ///<  en_enint_loc,      en_eovf_loc,   en_fstint_loc,
+                                            MAX30001::MAX30001_INT_2B,   MAX30001::MAX30001_INT_2B,   MAX30001::MAX30001_NO_INT,  ///<  en_dcloffint_loc,  en_bint_loc,   en_bovf_loc,
+                                            MAX30001::MAX30001_INT_2B,   MAX30001::MAX30001_INT_2B,   MAX30001::MAX30001_NO_INT,  ///<  en_bover_loc,      en_bundr_loc,  en_bcgmon_loc,
+                                            MAX30001::MAX30001_INT_B,    MAX30001::MAX30001_NO_INT,   MAX30001::MAX30001_NO_INT,  ///<  en_pint_loc,       en_povf_loc,   en_pedge_loc,
+                                            MAX30001::MAX30001_INT_2B,   MAX30001::MAX30001_INT_B,    MAX30001::MAX30001_NO_INT,  ///<  en_lonint_loc,     en_rrint_loc,  en_samp_loc,
+                                            MAX30001::MAX30001_INT_ODNR, MAX30001::MAX30001_INT_ODNR);                            ///<  intb_Type,         int2b_Type)
 }
 
 
@@ -115,8 +114,8 @@
 static uint8_t serialNumber[6];
 uint8_t *MAX30001_Helper_getVersion(void) {
   // read the id
-  Peripherals::max30001()->max30001_reg_read(MAX30001::INFO, (uint32_t *)serialNumber);
+  Peripherals::max30001()->reg_read(MAX30001::INFO, (uint32_t *)serialNumber);
   // read id twice because it needs to be read twice
-  Peripherals::max30001()->max30001_reg_read(MAX30001::INFO, (uint32_t *)serialNumber);
+  Peripherals::max30001()->reg_read(MAX30001::INFO, (uint32_t *)serialNumber);
   return serialNumber;
 }
--- a/HSP/Devices/MAX30101/MAX30101/MAX30101.cpp	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/Devices/MAX30101/MAX30101/MAX30101.cpp	Fri Apr 21 12:12:30 2017 -0500
@@ -1,4 +1,3 @@
-
 /*******************************************************************************
  * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
  *
@@ -77,56 +76,87 @@
   int loop = 1;
   static uint8_t cntr_int = 0;
 
+  max30101_Interrupt_Status_1_t   Interrupt_Status_1;
+  max30101_Interrupt_Status_2_t   Interrupt_Status_2;
+  max30101_mode_configuration_t   mode_configuration;
+  max30101_multiLED_mode_ctrl_1_t multiLED_mode_ctrl_1;
+  max30101_multiLED_mode_ctrl_2_t multiLED_mode_ctrl_2;
+  max30101_spo2_configuration_t   spo2_configuration;
+  max30101_fifo_configuration_t   fifo_configuration;
 
   cntr_int++;
 
   while (loop) {
-    if (i2c_reg_read(REG_INT_STAT_1, &max30101_Interrupt_Status_1.all) != 0) // Read Interrupt flag bits
-    {
+    if (i2c_reg_read(REG_INT_STAT_1, &Interrupt_Status_1.all) != 0) { ///< Read Interrupt flag bits
+      return -1;
+    }
+
+    if (i2c_reg_read(REG_INT_STAT_2, &Interrupt_Status_2.all) != 0) { ///< Read Interrupt flag bits
+      return -1;
+    }
+
+    /* Read all the relevant register bits */
+    if (i2c_reg_read(REG_MODE_CFG, &mode_configuration.all) != 0) {
       return -1;
     }
 
-    if (i2c_reg_read(REG_INT_STAT_2, &max30101_Interrupt_Status_2.all) != 0) // Read Interrupt flag bits
-    {
+
+    if (i2c_reg_read(REG_SLT2_SLT1, &multiLED_mode_ctrl_1.all) != 0) {
       return -1;
     }
+    
 
-    if (max30101_Interrupt_Status_1.bit.a_full) {
-      /* Read the sample(s) */
+    if (i2c_reg_read(REG_SLT4_SLT3, &multiLED_mode_ctrl_2.all) != 0) {
+      return -1;
+    }    
+    
+
+    if (i2c_reg_read(REG_SPO2_CFG, &spo2_configuration.all) != 0) {
+      return -1;
+    }  
+    
+
+    if (i2c_reg_read(REG_FIFO_CFG, &fifo_configuration.all) != 0) {
+      return -1;
+    }     
+    
+    
+
+    if (Interrupt_Status_1.bit.a_full) {
+      ///< Read the sample(s)
       char reg = REG_FIFO_DATA;
 
       num_active_led = 0;
 
-      if (max30101_mode_configuration.bit.mode == 0x02) // Heart Rate mode, i.e. 1 led
-      {
+     if (mode_configuration.bit.mode == 0x02) {///< Heart Rate mode, i.e. 1 led    
         num_active_led = 1;
-      } else if (max30101_mode_configuration.bit.mode == 0x03) // SpO2 mode, i.e. 2 led
-      {
+      } else if (mode_configuration.bit.mode == 0x03) { ///< SpO2 mode, i.e. 2 led
         num_active_led = 2;
-      } else if (max30101_mode_configuration.bit.mode == 0x07) // Multi-LED mode, i.e. 1-4 led
-      {
-        if (max30101_multiLED_mode_ctrl_1.bit.slot1 != 0) {
+      } else if (mode_configuration.bit.mode == 0x07) { ///< Multi-LED mode, i.e. 1-4 led
+        if (multiLED_mode_ctrl_1.bit.slot1 != 0) {
+          num_active_led++;
+        }
+
+        if (multiLED_mode_ctrl_1.bit.slot2 != 0) {
           num_active_led++;
         }
 
-        if (max30101_multiLED_mode_ctrl_1.bit.slot2 != 0) {
-          num_active_led++;
-        }
-
-        if (max30101_multiLED_mode_ctrl_2.bit.slot3 != 0) {
+        if (multiLED_mode_ctrl_2.bit.slot3 != 0) {
           num_active_led++;
         }
 
-        if (max30101_multiLED_mode_ctrl_2.bit.slot4 != 0) {
+        if (multiLED_mode_ctrl_2.bit.slot4 != 0) {
           num_active_led++;
         }
       }
-               // 3bytes/LED x Number of Active LED x FIFO level selected
-        rx_bytes =  3 * num_active_led * (32-max30101_fifo_configuration.bit.fifo_a_full);   
+               ///< 3bytes/LED x Number of Active LED x FIFO level selected
+        rx_bytes =  3 * num_active_led * (32-fifo_configuration.bit.fifo_a_full);   
 
       second_rx_bytes = rx_bytes;
-
-      /*  The FIFO Size is determined by the Sample size.  The number of bytes
+      
+      /**
+       * @brief: 
+       * The FIFO Size is determined by the Sample size.  The number of bytes
        * in a Sample is dictated by number of LED's
        *
        *   #LED Selected     Bytes in "1" sample
@@ -135,24 +165,22 @@
        *        3                  9
        *        4                  12
        *
-       *  The I2C API function limits the number of bytes to read to 256 (i.e.
-       * char).  Therefore, when set for
-       *  Multiple LED's and the FIFO size is set to 32.  It would mean there is
-       * more than 256 bytes.
+       *  The I2C API function limits the number of bytes to read, to 256 (i.e.
+       *  char).  Therefore, when set for Multiple LED's and the FIFO
+       *  size is set to 32.  It would mean there is more than 256 bytes.
        *  In that case two I2C reads have to be made.  However It is important
-       * to not that each "Sample"
-       *  must be read completely and reading only partial number of bytes from
-       * a sample will result in erroneous data.
+       *  to note that each "Sample" must be read completely and reading only
+       *  partial number of bytes from a sample will result in erroneous data.
+       * 
        *
        *  For example:
        *  Num of LED selected = 3 and FIFO size is set to 32 (i.e. 0 value in
-       * register), then the number of bytes
-       *  will be 3bytes/Led * 3led's * 32 = 288 bytes in all.  Since there are
-       * 3 LED's each sample will contain (3 * 3)
-       *  9bytes.  Therefore Sample 1 = 9bytes, Sample 2 = 18,... Sample 28 =
-       * 252.  Therefore the first
-       *  I2C read should be 252 bytes and the second read should be 288-252 =
-       * 36.
+       *  register), then the number of bytes will be
+       *  3bytes/Led * 3led's * 32 = 288 bytes in all.  Since there are
+       *  3 LED's each sample will contain (3 * 3) 9bytes.  
+       *  Therefore Sample 1 = 9bytes, Sample 2 = 18,... Sample 28 = 252. 
+       *  Therefore the first I2C read should be 252 bytes and the second
+       *  read should be 288-252 = 36.
        *
        *  It turns out that this size issue comes up only when number of LED
        * selected is 3 or 4 and choosing 252bytes
@@ -175,10 +203,8 @@
       for (i = 0; i < rx_bytes; i += 3) {
         sample = ((uint32_t)(max30101_rawData[i] & 0x03) << 16) | (max30101_rawData[i + 1] << 8) | max30101_rawData[i + 2];
 
-        // Right shift the data based on the LED_PW setting
-        sample = sample >>
-                 (3 -
-                  max30101_spo2_configuration.bit.led_pw); // 0=shift 3, 1=shift 2, 2=shift 1, 3=no shift
+        ///< Right shift the data based on the LED_PW setting
+        sample = sample >> (3 - spo2_configuration.bit.led_pw); // 0=shift 3, 1=shift 2, 2=shift 1, 3=no shift
 
         max30101_buffer[index++] = sample;
       }
@@ -186,19 +212,9 @@
       onDataAvailableCallback(MAX30101_OXIMETER_DATA + num_active_led, max30101_buffer, index);
     }
 
-// This interrupt handles the proximity interrupt, for future enhancements
-#if 0
-   if(max30101_Interrupt_Status_1.bit.prox_int)
-     {
-     max30101_mode_configuration.full=0;
-     max30101_mode_configuration.bit.mode=0x03;     // SpO2 mode
-     i2c_reg_write(REG_MODE_CFG, max30101_mode_configuration.full);
 
-     }
-#endif
-
-    // This interrupt handles the temperature interrupt
-    if (max30101_Interrupt_Status_2.bit.die_temp_rdy) {
+    ///< This interrupt handles the temperature interrupt
+    if (Interrupt_Status_2.bit.die_temp_rdy) {
       char reg;
 
       reg = REG_TINT;
@@ -211,19 +227,18 @@
         return -1;
       }
 
-      max30101_final_temp = (int8_t)temp_int + 0.0625 * temp_frac;
+      max30101_final_temp = (int8_t)temp_int + 0.0625f * temp_frac;
 
-      if (i2c_reg_write(REG_TEMP_EN, 0x00) != 0) // Die Temperature Config, Temp disable... after one read...
-      {
+      if (i2c_reg_write(REG_TEMP_EN, 0x00) != 0) { ///< Die Temperature Config, Temp disable... after one read...
         return -1;
       }
     }
 
-    if (i2c_reg_read(REG_INT_STAT_1, &max30101_Interrupt_Status_1.all) != 0) // Read Interrupt flag bits
-    {
+    if (i2c_reg_read(REG_INT_STAT_1, &Interrupt_Status_1.all) != 0) { ///< Read Interrupt flag bits
+
       return -1;
     }
-    if (max30101_Interrupt_Status_1.bit.a_full != 1) {
+    if (Interrupt_Status_1.bit.a_full != 1) {
       loop = 0;
     }
   }
@@ -241,77 +256,81 @@
 
   char status;
 
-  max30101_mode_configuration.all = 0;
-  max30101_mode_configuration.bit.reset = 1;
-  if (i2c_reg_write(REG_MODE_CFG, max30101_mode_configuration.all) != 0) // Reset the device, Mode = don't use...
+  max30101_mode_configuration_t  mode_configuration;
+  max30101_fifo_configuration_t  fifo_configuration;
+  max30101_spo2_configuration_t  spo2_configuration;
+  max30101_Interrupt_Enable_1_t  Interrupt_Enable_1;
+
+  mode_configuration.all = 0;
+  mode_configuration.bit.reset = 1;
+  if (i2c_reg_write(REG_MODE_CFG, mode_configuration.all) != 0) // Reset the device
   {
     return -1;
   }
 
-  /* Give it some settle time (100ms) */
-  wait(1.0 / 10.0); // Let things settle down a bit
+  ///< Give it some settle time (100ms)
+  wait(1.0 / 10.0); ///< Let things settle down a bit
 
-  max30101_fifo_configuration.all = 0;
-  max30101_fifo_configuration.bit.smp_ave = sample_avg; // Sample averaging;
-  max30101_fifo_configuration.bit.fifo_roll_over_en = 1; // FIFO Roll over enabled
-  max30101_fifo_configuration.bit.fifo_a_full = fifo_waterlevel_mark; // Interrupt when certain level is filled
-  if (i2c_reg_write(REG_FIFO_CFG, max30101_fifo_configuration.all) != 0) {
+  fifo_configuration.all = 0;
+  fifo_configuration.bit.smp_ave = sample_avg; ///< Sample averaging;
+  fifo_configuration.bit.fifo_roll_over_en = 1; ///< FIFO Roll over enabled
+  fifo_configuration.bit.fifo_a_full = fifo_waterlevel_mark; ///< Interrupt when certain level is filled
+
+  if (i2c_reg_write(REG_FIFO_CFG, fifo_configuration.all) != 0) {
     return -1;
   }
 
-  max30101_spo2_configuration.bit.spo2_adc_rge = 0x2; // ADC Range 8192 fullscale
-  max30101_spo2_configuration.bit.spo2_sr = sample_rate; // 100 Samp/sec.
-  max30101_spo2_configuration.bit.led_pw = pulse_width; // Pulse Width=411us and ADC Resolution=18
-  if (i2c_reg_write(REG_SPO2_CFG, max30101_spo2_configuration.all) != 0) {
+  spo2_configuration.bit.spo2_adc_rge = 0x2; ///< ADC Range 8192 fullscale
+  spo2_configuration.bit.spo2_sr = sample_rate; ///< 100 Samp/sec.
+  spo2_configuration.bit.led_pw = pulse_width; ///< Pulse Width=411us and ADC Resolution=18
+  if (i2c_reg_write(REG_SPO2_CFG, spo2_configuration.all) != 0) {
     return -1;
   }
 
-  max30101_led1_pa = red_led_current; // RED LED current
-  if (i2c_reg_write(REG_LED1_PA, max30101_led1_pa) != 0) {
+  if (i2c_reg_write(REG_LED1_PA, red_led_current) != 0) {
     return -1;
   }
 
-  max30101_led2_pa = ir_led_current; // IR LED current
-  if (i2c_reg_write(REG_LED2_PA, max30101_led2_pa) != 0) {
+  if (i2c_reg_write(REG_LED2_PA, ir_led_current) != 0) {
     return -1;
   }
 
   /************/
 
-  if (i2c_reg_read(REG_INT_STAT_1, &status) != 0) //  Clear INT1 by reading the status
+  if (i2c_reg_read(REG_INT_STAT_1, &status) != 0) ///<  Clear INT1 by reading the status
   {
     return -1;
   }
 
-  if (i2c_reg_read(REG_INT_STAT_2, &status) != 0) //  Clear INT2 by reading the status
+  if (i2c_reg_read(REG_INT_STAT_2, &status) != 0) ///<  Clear INT2 by reading the status
   {
     return -1;
   }
 
-  if (i2c_reg_write(REG_FIFO_W_PTR, 0x00) != 0) //  Clear FIFO ptr
+  if (i2c_reg_write(REG_FIFO_W_PTR, 0x00) != 0) ///<  Clear FIFO ptr
   {
     return -1;
   }
 
-  if (i2c_reg_write(REG_FIFO_OVF_CNT, 0x00) != 0) //  Clear FIFO ptr
+  if (i2c_reg_write(REG_FIFO_OVF_CNT, 0x00) != 0) ///<  Clear FIFO ptr
   {
     return -1;
   }
 
-  if (i2c_reg_write(REG_FIFO_R_PTR, 0x00) != 0) //  Clear FIFO ptr
+  if (i2c_reg_write(REG_FIFO_R_PTR, 0x00) != 0) ///<  Clear FIFO ptr
   {
     return -1;
   }
 
-  max30101_Interrupt_Enable_1.all = 0;
-  max30101_Interrupt_Enable_1.bit.a_full_en = 1; //  Enable FIFO almost full interrupt
-  if (i2c_reg_write(REG_INT_EN_1, max30101_Interrupt_Enable_1.all) != 0) {
+  Interrupt_Enable_1.all = 0;
+  Interrupt_Enable_1.bit.a_full_en = 1; ///<  Enable FIFO almost full interrupt
+  if (i2c_reg_write(REG_INT_EN_1, Interrupt_Enable_1.all) != 0) {
     return -1;
   }
 
-  max30101_mode_configuration.all = 0;
-  max30101_mode_configuration.bit.mode = 0x03; // SpO2 mode
-  if (i2c_reg_write(REG_MODE_CFG, max30101_mode_configuration.all) != 0) {
+  mode_configuration.all = 0;
+  mode_configuration.bit.mode = 0x03; ///< SpO2 mode
+  if (i2c_reg_write(REG_MODE_CFG, mode_configuration.all) != 0) {
     return -1;
   }
 
@@ -321,25 +340,30 @@
 //******************************************************************************
 int MAX30101::SpO2mode_stop(void) {
 
-  max30101_Interrupt_Enable_1.all = 0;
-  max30101_Interrupt_Enable_1.bit.a_full_en = 0; //  Disable FIFO almost full interrupt
-  if (i2c_reg_write(REG_INT_EN_1, max30101_Interrupt_Enable_1.all) != 0) {
+  max30101_Interrupt_Enable_1_t  Interrupt_Enable_1;
+  max30101_mode_configuration_t  mode_configuration;
+  uint8_t                      led1_pa;
+  uint8_t                      led2_pa;
+
+  Interrupt_Enable_1.all = 0;
+  Interrupt_Enable_1.bit.a_full_en = 0; ///<  Disable FIFO almost full interrupt
+  if (i2c_reg_write(REG_INT_EN_1, Interrupt_Enable_1.all) != 0) {
     return -1;
   }
 
-  max30101_mode_configuration.all = 0;
-  max30101_mode_configuration.bit.mode = 0x00; // SpO2 mode off
-  if (i2c_reg_write(REG_MODE_CFG, max30101_mode_configuration.all) != 0) {
+  mode_configuration.all = 0;
+  mode_configuration.bit.mode = 0x00; ///< SpO2 mode off
+  if (i2c_reg_write(REG_MODE_CFG, mode_configuration.all) != 0) {
     return -1;
   }
 
-  max30101_led1_pa = 0; // RED LED current, 0.0
-  if (i2c_reg_write(REG_LED1_PA, max30101_led1_pa) != 0) {
+  led1_pa = 0; ///< RED LED current, 0.0
+  if (i2c_reg_write(REG_LED1_PA, led1_pa) != 0) {
     return -1;
   }
 
-  max30101_led2_pa = 0; // IR LED current, 0.0
-  if (i2c_reg_write(REG_LED2_PA, max30101_led2_pa) != 0) {
+  led2_pa = 0; ///< IR LED current, 0.0
+  if (i2c_reg_write(REG_LED2_PA, led2_pa) != 0) {
     return -1;
   }
 
@@ -353,74 +377,78 @@
 
   /*uint8_t*/ char status;
 
-  max30101_mode_configuration.all = 0;
-  max30101_mode_configuration.bit.reset = 1;
-  if (i2c_reg_write(REG_MODE_CFG, max30101_mode_configuration.all) != 0) // Reset the device, Mode = don't use...
+  max30101_mode_configuration_t  mode_configuration;
+  max30101_fifo_configuration_t  fifo_configuration;
+  max30101_spo2_configuration_t  spo2_configuration;
+  max30101_Interrupt_Enable_1_t  Interrupt_Enable_1;
+
+  mode_configuration.all = 0;
+  mode_configuration.bit.reset = 1;
+  if (i2c_reg_write(REG_MODE_CFG, mode_configuration.all) != 0) ///< Reset the device, Mode = don't use...
   {
     return -1;
   }
 
-  /* Give it some settle time (100ms) */
-  wait(1.0 / 10.0); // Let things settle down a bit
+  ///< Give it some settle time (100ms)
+  wait(1.0 / 10.0); ///< Let things settle down a bit
 
-  max30101_fifo_configuration.all = 0;
-  max30101_fifo_configuration.bit.smp_ave = sample_avg; // Sample averaging;
-  max30101_fifo_configuration.bit.fifo_roll_over_en = 1; // FIFO Roll over enabled
-  max30101_fifo_configuration.bit.fifo_a_full = fifo_waterlevel_mark; // Interrupt when certain level is filled
-  if (i2c_reg_write(REG_FIFO_CFG, max30101_fifo_configuration.all) != 0) {
+  fifo_configuration.all = 0;
+  fifo_configuration.bit.smp_ave = sample_avg;  ///< Sample averaging;
+  fifo_configuration.bit.fifo_roll_over_en = 1; ///< FIFO Roll over enabled
+  fifo_configuration.bit.fifo_a_full = fifo_waterlevel_mark; ///< Interrupt when certain level is filled
+  if (i2c_reg_write(REG_FIFO_CFG, fifo_configuration.all) != 0) {
     return -1;
   }
 
-  max30101_spo2_configuration.bit.spo2_adc_rge = 0x2; // ADC Range 8192 fullscale
-  max30101_spo2_configuration.bit.spo2_sr = sample_rate; // 100 Samp/sec.
-  max30101_spo2_configuration.bit.led_pw = pulse_width; // Pulse Width=411us and ADC Resolution=18
-  if (i2c_reg_write(REG_SPO2_CFG, max30101_spo2_configuration.all) != 0) {
+  spo2_configuration.bit.spo2_adc_rge = 0x2;    ///< ADC Range 8192 fullscale
+  spo2_configuration.bit.spo2_sr = sample_rate; ///< 100 Samp/sec.
+  spo2_configuration.bit.led_pw = pulse_width;  ///< Pulse Width=411us and ADC Resolution=18
+  if (i2c_reg_write(REG_SPO2_CFG, spo2_configuration.all) != 0) {
     return -1;
   }
 
-  max30101_led1_pa = red_led_current; // RED LED current, 0.0
-  if (i2c_reg_write(REG_LED1_PA, max30101_led1_pa) != 0) {
+  if (i2c_reg_write(REG_LED1_PA, red_led_current) != 0) {
     return -1;
   }
 
   /************/
 
-  if (i2c_reg_read(REG_INT_STAT_1, &status) != 0) //  Clear INT1 by reading the status
+  if (i2c_reg_read(REG_INT_STAT_1, &status) != 0) ///<  Clear INT1 by reading the status
   {
     return -1;
   }
 
-  if (i2c_reg_read(REG_INT_STAT_2, &status) != 0) //  Clear INT2 by reading the status
+  if (i2c_reg_read(REG_INT_STAT_2, &status) != 0) ///< Clear INT2 by reading the status
   {
     return -1;
   }
 
-  if (i2c_reg_write(REG_FIFO_W_PTR, 0x00) != 0) //  Clear FIFO ptr
+  if (i2c_reg_write(REG_FIFO_W_PTR, 0x00) != 0) ///<  Clear FIFO ptr
   {
     return -1;
   }
 
-  if (i2c_reg_write(REG_FIFO_OVF_CNT, 0x00) != 0) //  Clear FIFO ptr
+  if (i2c_reg_write(REG_FIFO_OVF_CNT, 0x00) != 0) ///<  Clear FIFO ptr
   {
     return -1;
   }
 
-  if (i2c_reg_write(REG_FIFO_R_PTR, 0x00) != 0) //  Clear FIFO ptr
+  if (i2c_reg_write(REG_FIFO_R_PTR, 0x00) != 0) ///<  Clear FIFO ptr
   {
     return -1;
   }
 
-  max30101_Interrupt_Enable_1.all = 0;
-  max30101_Interrupt_Enable_1.bit.a_full_en = 1;
-  // max30101_Interrupt_Enable_1.bit.prox_int_en=0;   //  Enable Proximity
+  Interrupt_Enable_1.all = 0;
+  Interrupt_Enable_1.bit.a_full_en = 1;
+  
   // Interrupt
-  if (i2c_reg_write(REG_INT_EN_1, max30101_Interrupt_Enable_1.all) != 0) {
+  if (i2c_reg_write(REG_INT_EN_1, Interrupt_Enable_1.all) != 0) {
     return -1;
   }
 
-  max30101_mode_configuration.all = 0;
-  max30101_mode_configuration.bit.mode = 0x02; // HR mode
-  if (i2c_reg_write(REG_MODE_CFG, max30101_mode_configuration.all) != 0) {
+  mode_configuration.all = 0;
+  mode_configuration.bit.mode = 0x02; ///< HR mode
+  if (i2c_reg_write(REG_MODE_CFG, mode_configuration.all) != 0) {
     return -1;
   }
 
@@ -430,20 +458,22 @@
 //******************************************************************************
 int MAX30101::HRmode_stop(void) {
 
-  max30101_Interrupt_Enable_1.all = 0;
-  max30101_Interrupt_Enable_1.bit.a_full_en = 0; //  Disable FIFO almost full interrupt
-  if (i2c_reg_write(REG_INT_EN_1, max30101_Interrupt_Enable_1.all) != 0) {
+  max30101_Interrupt_Enable_1_t  Interrupt_Enable_1;
+  max30101_mode_configuration_t  mode_configuration;
+
+  Interrupt_Enable_1.all = 0;
+  Interrupt_Enable_1.bit.a_full_en = 0; ///< Disable FIFO almost full interrupt
+  if (i2c_reg_write(REG_INT_EN_1, Interrupt_Enable_1.all) != 0) {
     return -1;
   }
 
-  max30101_mode_configuration.all = 0;
-  max30101_mode_configuration.bit.mode = 0x00; // HR mode off
-  if (i2c_reg_write(REG_MODE_CFG, max30101_mode_configuration.all) != 0) {
+  mode_configuration.all = 0;
+  mode_configuration.bit.mode = 0x00; ///< HR mode off
+  if (i2c_reg_write(REG_MODE_CFG, mode_configuration.all) != 0) {
     return -1;
   }
 
-  max30101_led1_pa = 0; // RED LED current, 0.0
-  if (i2c_reg_write(REG_LED1_PA, max30101_led1_pa) != 0) {
+  if (i2c_reg_write(REG_LED1_PA, 0) != 0) {
     return -1;
   }
 
@@ -456,100 +486,105 @@
                              uint8_t red_led_current, uint8_t ir_led_current,
                              uint8_t green_led_current, uint8_t slot_1,
                              uint8_t slot_2, uint8_t slot_3, uint8_t slot_4) {
+
   char status;
-  max30101_mode_configuration.all = 0;
-  max30101_mode_configuration.bit.reset = 1;
-  if (i2c_reg_write(REG_MODE_CFG, max30101_mode_configuration.all) != 0) // Reset the device, Mode = don't use...
+  max30101_mode_configuration_t    mode_configuration;
+  max30101_fifo_configuration_t    fifo_configuration;
+  max30101_spo2_configuration_t    spo2_configuration;
+  max30101_multiLED_mode_ctrl_1_t  multiLED_mode_ctrl_1;
+  max30101_multiLED_mode_ctrl_2_t  multiLED_mode_ctrl_2;
+  max30101_Interrupt_Enable_1_t    Interrupt_Enable_1;
+  
+  mode_configuration.all = 0;
+  mode_configuration.bit.reset = 1;
+  if (i2c_reg_write(REG_MODE_CFG, mode_configuration.all) != 0) ///< Reset the device, Mode = don't use...
   {
     return -1;
   }
 
-  /* Give it some settle time (100ms) */ // Let things settle down a bit
+  /* Give it some settle time (100ms) */ ///< Let things settle down a bit
   wait(1.0 / 10.0);
 
-  max30101_fifo_configuration.all = 0;
-  max30101_fifo_configuration.bit.smp_ave = sample_avg; // Sample averaging;
-  max30101_fifo_configuration.bit.fifo_roll_over_en = 1; // FIFO Roll over enabled
-  max30101_fifo_configuration.bit.fifo_a_full =
-      fifo_waterlevel_mark; // Interrupt when certain level is filled
-  if (i2c_reg_write(REG_FIFO_CFG, max30101_fifo_configuration.all) != 0) {
+  fifo_configuration.all = 0;
+  fifo_configuration.bit.smp_ave = sample_avg; ///< Sample averaging;
+  fifo_configuration.bit.fifo_roll_over_en = 1; ///< FIFO Roll over enabled
+  fifo_configuration.bit.fifo_a_full =
+      fifo_waterlevel_mark; ///< Interrupt when certain level is filled
+  if (i2c_reg_write(REG_FIFO_CFG, fifo_configuration.all) != 0) {
     return -1;
   }
 
-  max30101_spo2_configuration.bit.spo2_adc_rge = 0x2; // ADC Range 8192 fullscale
-  max30101_spo2_configuration.bit.spo2_sr = sample_rate; // 100 Samp/sec.
-  max30101_spo2_configuration.bit.led_pw = pulse_width; // Pulse Width=411us and ADC Resolution=18
-  if (i2c_reg_write(REG_SPO2_CFG, max30101_spo2_configuration.all) != 0) {
-    return -1;
-  }
-
-  max30101_led1_pa = red_led_current; // RED LED current
-  if (i2c_reg_write(REG_LED1_PA, max30101_led1_pa) != 0) {
+  spo2_configuration.bit.spo2_adc_rge = 0x2;    ///< ADC Range 8192 fullscale
+  spo2_configuration.bit.spo2_sr = sample_rate; ///< 100 Samp/sec.
+  spo2_configuration.bit.led_pw = pulse_width;  ///< Pulse Width=411us and ADC Resolution=18
+  if (i2c_reg_write(REG_SPO2_CFG, spo2_configuration.all) != 0) {
     return -1;
   }
 
-  max30101_led2_pa = ir_led_current; // IR LED current
-  if (i2c_reg_write(REG_LED2_PA, max30101_led2_pa) != 0) {
+  if (i2c_reg_write(REG_LED1_PA, red_led_current) != 0) {
     return -1;
   }
 
-  max30101_led3_pa = green_led_current; // Green LED current
-  if (i2c_reg_write(REG_LED3_PA, max30101_led3_pa) != 0) {
+  if (i2c_reg_write(REG_LED2_PA, ir_led_current) != 0) {
+    return -1;
+  }
+
+  if (i2c_reg_write(REG_LED3_PA, green_led_current) != 0) {
     return -1;
   }
 
-  // 0x01=Red(LED1), 0x02=IR(LED2), 0x03=Green(LED3) : Use LEDn_PA to adjust the intensity
-  // 0x05=Red      , 0x06=IR      , 0x07=Green       : Use PILOT_PA to adjust the intensity DO NOT USE THIS ROW...
+  ///< 0x01=Red(LED1), 0x02=IR(LED2), 0x03=Green(LED3) : Use LEDn_PA to adjust the intensity
+  ///< 0x05=Red      , 0x06=IR      , 0x07=Green       : Use PILOT_PA to adjust the intensity DO NOT USE THIS ROW...
 
-  max30101_multiLED_mode_ctrl_1.bit.slot1 = slot_1;
-  max30101_multiLED_mode_ctrl_1.bit.slot2 = slot_2;
-  if (i2c_reg_write(REG_SLT2_SLT1, max30101_multiLED_mode_ctrl_1.all)) {
+  multiLED_mode_ctrl_1.bit.slot1 = slot_1;
+  multiLED_mode_ctrl_1.bit.slot2 = slot_2;
+  if (i2c_reg_write(REG_SLT2_SLT1, multiLED_mode_ctrl_1.all)) {
     return -1;
   }
 
-  max30101_multiLED_mode_ctrl_2.all = 0;
-  max30101_multiLED_mode_ctrl_2.bit.slot3 = slot_3;
-  max30101_multiLED_mode_ctrl_2.bit.slot4 = slot_4;
-  if (i2c_reg_write(REG_SLT4_SLT3, max30101_multiLED_mode_ctrl_2.all)) {
+  multiLED_mode_ctrl_2.all = 0;
+  multiLED_mode_ctrl_2.bit.slot3 = slot_3;
+  multiLED_mode_ctrl_2.bit.slot4 = slot_4;
+  if (i2c_reg_write(REG_SLT4_SLT3, multiLED_mode_ctrl_2.all)) {
     return -1;
   }
 
   /************/
 
-  if (i2c_reg_read(REG_INT_STAT_1, &status) != 0) //  Clear INT1 by reading the status
+  if (i2c_reg_read(REG_INT_STAT_1, &status) != 0) ///<  Clear INT1 by reading the status
   {
     return -1;
   }
 
-  if (i2c_reg_read(REG_INT_STAT_2, &status) != 0) //  Clear INT2 by reading the status
+  if (i2c_reg_read(REG_INT_STAT_2, &status) != 0) ///<  Clear INT2 by reading the status
   {
     return -1;
   }
 
-  if (i2c_reg_write(REG_FIFO_W_PTR, 0x00) != 0) //  Clear FIFO ptr
+  if (i2c_reg_write(REG_FIFO_W_PTR, 0x00) != 0) ///<  Clear FIFO ptr
   {
     return -1;
   }
 
-  if (i2c_reg_write(REG_FIFO_OVF_CNT, 0x00) != 0) //  Clear FIFO ptr
+  if (i2c_reg_write(REG_FIFO_OVF_CNT, 0x00) != 0) ///<  Clear FIFO ptr
   {
     return -1;
   }
 
-  if (i2c_reg_write(REG_FIFO_R_PTR, 0x00) != 0) //  Clear FIFO ptr
+  if (i2c_reg_write(REG_FIFO_R_PTR, 0x00) != 0) ///<  Clear FIFO ptr
   {
     return -1;
   }
 
-  max30101_Interrupt_Enable_1.all = 0;
-  max30101_Interrupt_Enable_1.bit.a_full_en = 1; //  Enable FIFO almost full interrupt
-  if (i2c_reg_write(REG_INT_EN_1, max30101_Interrupt_Enable_1.all) != 0) {
+  Interrupt_Enable_1.all = 0;
+  Interrupt_Enable_1.bit.a_full_en = 1; ///<  Enable FIFO almost full interrupt
+  if (i2c_reg_write(REG_INT_EN_1, Interrupt_Enable_1.all) != 0) {
     return -1;
   }
 
-  max30101_mode_configuration.all = 0;
-  max30101_mode_configuration.bit.mode = 0x07; // Multi-LED mode
-  if (i2c_reg_write(REG_MODE_CFG, max30101_mode_configuration.all) != 0) {
+  mode_configuration.all = 0;
+  mode_configuration.bit.mode = 0x07; ///< Multi-LED mode
+  if (i2c_reg_write(REG_MODE_CFG, mode_configuration.all) != 0) {
     return -1;
   }
 
@@ -559,30 +594,31 @@
 //******************************************************************************
 int MAX30101::Multimode_stop(void) {
 
-  max30101_Interrupt_Enable_1.all = 0;
-  max30101_Interrupt_Enable_1.bit.a_full_en = 0; //  Disable FIFO almost full interrupt
-  if (i2c_reg_write(REG_INT_EN_1, max30101_Interrupt_Enable_1.all) != 0) {
-    return -1;
-  }
+max30101_Interrupt_Enable_1_t  Interrupt_Enable_1;
+max30101_mode_configuration_t  mode_configuration;
+
 
-  max30101_mode_configuration.all = 0;
-  max30101_mode_configuration.bit.mode = 0x00; // Multi-LED mode off
-  if (i2c_reg_write(REG_MODE_CFG, max30101_mode_configuration.all) != 0) {
+  Interrupt_Enable_1.all = 0;
+  Interrupt_Enable_1.bit.a_full_en = 0; ///< Disable FIFO almost full interrupt
+  if (i2c_reg_write(REG_INT_EN_1, Interrupt_Enable_1.all) != 0) {
     return -1;
   }
 
-  max30101_led1_pa = 0; // RED LED current, 0.0
-  if (i2c_reg_write(REG_LED1_PA, max30101_led1_pa) != 0) {
+  mode_configuration.all = 0;
+  mode_configuration.bit.mode = 0x00; ///< Multi-LED mode off
+  if (i2c_reg_write(REG_MODE_CFG, mode_configuration.all) != 0) {
     return -1;
   }
 
-  max30101_led2_pa = 0; // IR LED current, 0.0
-  if (i2c_reg_write(REG_LED2_PA, max30101_led2_pa) != 0) {
+  if (i2c_reg_write(REG_LED1_PA, 0) != 0) {
     return -1;
   }
 
-  max30101_led3_pa = 0; // Green LED current, 0.0
-  if (i2c_reg_write(REG_LED3_PA, max30101_led3_pa) != 0) {
+  if (i2c_reg_write(REG_LED2_PA, 0) != 0) {
+    return -1;
+  }
+
+  if (i2c_reg_write(REG_LED3_PA, 0) != 0) {
     return -1;
   }
   return 0;
@@ -590,15 +626,13 @@
 
 //******************************************************************************
 int MAX30101::tempread(void) {
-  max30101_Interrupt_Enable_2.all = 0;
-  max30101_Interrupt_Enable_2.bit.die_temp_rdy_en = 1; // Enable the Temp Rdy;
-  if (i2c_reg_write(REG_INT_EN_2, 0x02) != 0) // Interrupt Enable 2, Temperature Interrupt
-  {
+   
+  if (i2c_reg_write(REG_INT_EN_2, 0x02) != 0) {///< Interrupt Enable 2, Temperature Interrupt
     return -1;
   }
 
-  if (i2c_reg_write(REG_TEMP_EN, 0x01) != 0) // Die Temperature Config, Temp enable...
-  {
+  if (i2c_reg_write(REG_TEMP_EN, 0x01) != 0) {///< Die Temperature Config, Temp enable...
+
     return -1;
   }
   return 0;
@@ -606,9 +640,10 @@
 
 //******************************************************************************
 int MAX30101::i2c_reg_write(MAX30101_REG_map_t reg, char value) {
+
   char cmdData[2] = {reg, value};
 
-  if (I2CM_Write(slaveAddress, NULL, 0, cmdData, 2) != 0 /*2*/) {
+  if (I2CM_Write(slaveAddress, NULL, 0, cmdData, 2) != 0) {
     return -1;
   }
 
@@ -624,16 +659,10 @@
   return 0;
 }
 
-/**
-* @brief Read from an I2C device
-* @param slaveAddress slave address to use with transaction
-* @param writeData pointer of data to write
-* @param writeCount number of data to write
-* @param readData pointer to buffer to read to
-* @param readCount number of bytes to read
-*/
+//******************************************************************************
 int MAX30101::I2CM_Read(int slaveAddress, char *writeData, char writeCount,
                         char *readData, char readCount) {
+
   if (writeData != NULL && writeCount != 0) {
     i2c->write(slaveAddress, writeData, writeCount, true);
   }
@@ -643,16 +672,10 @@
   return 0;
 }
 
-/**
-* @brief Write to an I2C device
-* @param slaveAddress slave address to use with transaction
-* @param writeData pointer of data to write
-* @param writeCount1 number of data to write
-* @param writeData2 pointer to buffer to read to
-* @param writeCount2 number of bytes to read
-*/
+//******************************************************************************
 int MAX30101::I2CM_Write(int slaveAddress, char *writeData1, char writeCount1,
                          char *writeData2, char writeCount2) {
+ 
   if (writeData1 != NULL && writeCount1 != 0) {
     i2c->write(slaveAddress, writeData1, writeCount1);
   }
@@ -664,16 +687,13 @@
 
 //******************************************************************************
 void MAX30101::onDataAvailable(DataCallbackFunction _onDataAvailable) {
+
   onDataAvailableCallback = _onDataAvailable;
 }
 
-/**
-* @brief Used to notify an external function that interrupt data is available
-* @param id type of data available
-* @param buffer 32-bit buffer that points to the data
-* @param length length of 32-bit elements available
-*/
+//******************************************************************************
 void MAX30101::dataAvailable(uint32_t id, uint32_t *buffer, uint32_t length) {
+
   if (onDataAvailableCallback != NULL) {
     (*onDataAvailableCallback)(id, buffer, length);
   }
@@ -681,23 +701,21 @@
 
 //******************************************************************************
 void MAX30101::onInterrupt(InterruptFunction _onInterrupt) {
+
   onInterruptCallback = _onInterrupt;
 }
 
-/**
-* @brief Executed on interrupt
-* @param id type of data available
-* @param buffer 32-bit buffer that points to the data
-* @param length length of 32-bit elements available
-*/
+//******************************************************************************
 void MAX30101::interruptPostCallback(void) {
+
   if (onInterruptCallback != NULL) {
+
     (*onInterruptCallback)();
   }
 }
 
-int max30101_enableInterrupts = 0;
-/**************************************************************************************************************/
-void MAX30101MidIntHandler(void) { 
-  MAX30101::instance->int_handler(); 
+//******************************************************************************
+void MAX30101::MidIntHandler(void) { 
+
+  MAX30101::instance->int_handler();
 }
--- a/HSP/Devices/MAX30101/MAX30101/MAX30101.h	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/Devices/MAX30101/MAX30101/MAX30101.h	Fri Apr 21 12:12:30 2017 -0500
@@ -1,5 +1,5 @@
 /*******************************************************************************
-/ * Copyright (C) 2015 Maxim Integrated Products, Inc., All Rights Reserved.
+/ * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -29,11 +29,107 @@
  * property whatsoever. Maxim Integrated Products, Inc. retains all
  * ownership rights.
  *******************************************************************************/
-/*
- * max30101.h
+/** 
+ * Maxim Integrated MAX30101 Oximeter chip
+ *  
+ * IMPORTANT: The code below will also need MAX14720.cpp and MAX14720.h
+ * 
+ * @code
+ * #include "mbed.h"
+ * #include "MAX14720.h"
+ * #include "MAX30101.h"
+ * 
+ * 
+ * /// define the HVOUT Boost Voltage default for the MAX14720 PMIC
+ * #define HVOUT_VOLTAGE 4500 // set to 4500 mV
+ * 
+ * /// define all I2C addresses
+ * #define MAX14720_I2C_SLAVE_ADDR (0x54)
+ * #define MAX30101_I2C_SLAVE_ADDR (0xAE)
+ * 
+ * /// Settings for the HR initialization
+ * #define FIFO_WATERLEVEL_MARK 15
+ * #define SAMPLE_AVG           2
+ * #define SAMPLE_RATE          1
+ * #define PULSE_WIDTH          2
+ * #define RED_LED_CURRENT      0x1F
+ *  
+ *  /// Buffer size for streaming data out.
+ * #define BUFFER_LENGTH 50 
+ * 
+ * 
+ * /// I2C Master 2
+ * I2C i2c2(I2C2_SDA, I2C2_SCL); // used by MAX14720, MAX30101, LIS2DH
+ * /// SPI Master 0 with SPI0_SS for use with MAX30001
+ *  SPI spi(SPI0_MOSI, SPI0_MISO, SPI0_SCK, SPI0_SS); // used by MAX30001
+ * 
+ * /// PMIC
+ * MAX14720 max14720(&i2c2, MAX14720_I2C_SLAVE_ADDR);
+ * /// Optical Oximeter
+ * MAX30101 max30101(&i2c2, MAX30101_I2C_SLAVE_ADDR);
+ * InterruptIn max30101_Interrupt(P4_0);
+ * 
+ * //@brief Creating a buffer to hold the data
+ * uint32_t oxiBuffer[BUFFER_LENGTH];
+ * int oxiIndex = 0;
+ * char data_trigger = 0;
+ *  
  *
- *  Created on: Aug 26, 2015
- *      Author: faisal.tariq
+ * //@brief Creates a packet that will be streamed via USB Serial
+ * //@brief the packet created will be inserted into a fifo to be streamed at a later time
+ * //@param id Streaming ID
+ * //@param buffer Pointer to a uint32 array that contains the data to include in the packet
+ * //@param number Number of elements in the buffer
+ * //
+ * void StreamPacketUint32_ex(uint32_t id, uint32_t *buffer, uint32_t number) {
+ *   int i;
+ *   if (id == MAX30101_OXIMETER_DATA + 1) {
+ * 
+ *     for (i = 0; i < number; i++) {
+ *       oxiBuffer[oxiIndex] = buffer[i];
+ *       oxiIndex++;
+ *           
+ *       if (oxiIndex > BUFFER_LENGTH)
+ *         {
+ *         data_trigger = 1;
+ *         oxiIndex = 0;
+ *         }
+ *     }
+ *   }
+ * }
+ * 
+ * int main() {
+ *   // hold results for returning functions
+ *   int result;
+ * 
+ *   // initialize HVOUT on the MAX14720 PMIC
+ *   result = max14720.init();
+ *   if (result == MAX14720_ERROR){
+ *     printf("Error initializing MAX14720");
+ *     }
+ *   max14720.boostEn = MAX14720::BOOST_ENABLED;
+ *   max14720.boostSetVoltage(HVOUT_VOLTAGE);
+ * 
+ *   // MAX30101 initialize interrupt
+ *   max30101.onDataAvailable(&StreamPacketUint32_ex);
+ *   max30101_Interrupt.fall(&MAX30101::MAX30101MidIntHandler);
+ *   
+ *   // This is the HR mode only (IR LED only)  
+ *   max30101.HRmode_init(FIFO_WATERLEVEL_MARK, SAMPLE_AVG, SAMPLE_RATE,PULSE_WIDTH, RED_LED_CURRENT); 
+ * 
+ *   printf("Please wait for data to start streaming\n");
+ *   fflush(stdout);
+ *   
+ *   while (1) {
+ *     if(data_trigger == 1)
+ *      {
+ *       printf("%ld ", oxiBuffer[oxiIndex]);  // Print the ECG data on a serial port terminal software
+ *       fflush(stdout);
+ *      }
+ *   } 
+ * }
+ * @endcode
+ *
  */
 
 #ifndef _MAX30101_H_
@@ -48,7 +144,7 @@
 
 #define CHUNK_SIZE 252
 
-// MAX30101 Register addresses
+///< MAX30101 Register addresses
 
 #define MAX30101_INT_PORT 4
 #define MAX30101_INT_PIN 0
@@ -59,13 +155,13 @@
 */
 class MAX30101 {
 public:
-  float max30101_final_temp;                         // Global declaration
-  uint32_t max30101_buffer[MAX30101_PROC_DATA_SIZE]; // final Processed data
-  char max30101_rawData[MAX30101_RAW_DATA_SIZE];     //  raw data from the chip
+  float max30101_final_temp;                         ///< Global declaration
+  uint32_t max30101_buffer[MAX30101_PROC_DATA_SIZE]; ///< final Processed data
+  char max30101_rawData[MAX30101_RAW_DATA_SIZE];     ///<  raw data from the chip
 
-  typedef enum { // MAX30101 Register addresses
+  typedef enum { ///< MAX30101 Register addresses
 
-    /*Status */
+    ///< Status
     REG_INT_STAT_1 = 0x00,
     REG_INT_STAT_2 = 0x01,
     REG_INT_EN_1   = 0x02,
@@ -75,7 +171,7 @@
     REG_FIFO_OVF_CNT = 0x05,
     REG_FIFO_R_PTR   = 0x06,
     REG_FIFO_DATA    = 0x07,
-    /* Configuration */
+    ///< Configuration
     REG_FIFO_CFG  = 0x08,
     REG_MODE_CFG  = 0x09,
     REG_SPO2_CFG  = 0x0A,
@@ -85,11 +181,11 @@
     REG_PILOT_PA  = 0x10,
     REG_SLT2_SLT1 = 0x11,
     REG_SLT4_SLT3 = 0x12,
-    /* Die Temp    */
+    ///< Die Temp
     REG_TINT    = 0x1F,
     REG_TFRAC   = 0x20,
     REG_TEMP_EN = 0x21,
-    /* Proximity Func */
+    ///< Proximity Func
     REG_PROX_INT_THR = 0x30,
     /* Part ID        */
     REG_REV_ID = 0xFE,
@@ -100,7 +196,7 @@
   /* STATUS */
   /**********/
   /// @brief STATUS1 (0x00)
-  union max30101_Interrupt_Status_1_reg {
+  typedef union max30101_Interrupt_Status_1_reg {
     char all;
     struct {
       char pwr_rdy  : 1;
@@ -110,185 +206,167 @@
       char ppg_rdy  : 1;
       char a_full   : 1;
     } bit;
-  } max30101_Interrupt_Status_1;
+  } max30101_Interrupt_Status_1_t;
 
   /// @brief STATUS2 (0x01)
-  union max30101_Interrupt_Status_2_reg {
+  typedef union max30101_Interrupt_Status_2_reg {
     char all;
     struct {
       char reserved1    : 1;
       char die_temp_rdy : 1;
       char reserved2    : 6;
     } bit;
-  } max30101_Interrupt_Status_2;
+  } max30101_Interrupt_Status_2_t;
 
   /// @brief INTERRUPT_ENABLE1 (0x02)
-  volatile union max30101_Interrupt_Enable_1_reg {
-    uint8_t all;
+  typedef union max30101_Interrupt_Enable_1_reg {
+    char all;
     struct {
-      uint8_t reserved1   : 4;
-      uint8_t prox_int_en : 1;
-      uint8_t alc_ovf_en  : 1;
-      uint8_t ppg_rdy_en  : 1;
-      uint8_t a_full_en   : 1;
+      char reserved1   : 4;
+      char prox_int_en : 1;
+      char alc_ovf_en  : 1;
+      char ppg_rdy_en  : 1;
+      char a_full_en   : 1;
     } bit;
-  } max30101_Interrupt_Enable_1;
+  } max30101_Interrupt_Enable_1_t;
 
   /// @brief INTERRUPT_ENABLE2 (0x03)
-  volatile union max30101_Interrupt_Enable_2_reg {
-    uint8_t all;
+  typedef union max30101_Interrupt_Enable_2_reg {
+    char all;
     struct {
-      uint8_t reserved1       : 1;
-      uint8_t die_temp_rdy_en : 1;
-      uint8_t reserved2       : 6;
+      char reserved1       : 1;
+      char die_temp_rdy_en : 1;
+      char reserved2       : 6;
     } bit;
-  } max30101_Interrupt_Enable_2;
+  } max30101_Interrupt_Enable_2_t;
 
   /*********/
   /* FIFO  */
   /*********/
   // 0x04
   /// @brief FIFO_WR_PTR (0x04)
-  volatile union max30101_fifo_wr_ptr_reg {
-    uint8_t all;
+  typedef union max30101_fifo_wr_ptr_reg {
+    char all;
     struct {
-      uint8_t fifo_wr_ptr : 5;
-      uint8_t reserved1   : 3;
+      char fifo_wr_ptr : 5;
+      char reserved1   : 3;
     } bit;
-  } max30101_fifo_wr_ptr;
+  } max30101_fifo_wr_ptr_t;
 
   /// @brief OVF_COUNTER (0x05)
-  volatile union max30101_ovf_counter_reg {
-    uint8_t all;
+  typedef union max30101_ovf_counter_reg {
+    char all;
     struct {
-      uint8_t fifo_ovf_counter : 5;
-      uint8_t reserved1        : 3;
+      char fifo_ovf_counter : 5;
+      char reserved1        : 3;
     } bit;
-  } max30101_ovf_counter_reg;
+  } max30101_ovf_counter_reg_t;
 
   /// @brief FIFO_READ_PTR (0x06)
-  volatile union max30101_fifo_rd_ptr_reg {
-    uint8_t all;
+  typedef union max30101_fifo_rd_ptr_reg {
+    char all;
     struct {
-      uint8_t fifo_rd_ptr : 5;
-      uint8_t reserved1   : 3;
+      char fifo_rd_ptr : 5;
+      char reserved1   : 3;
     } bit;
-  } max30101_fifo_rd_ptr;
-
-  // 0x07
-  uint8_t max30101_fifo_data;
+  } max30101_fifo_rd_ptr_t;
 
   /********************/
   /* Configuration    */
   /********************/
   // 0x08
   /// @brief FIFO_CONFIGURATION (0x08)
-  volatile union max30101_fifo_configuration_reg {
-    uint8_t all;
+  typedef union max30101_fifo_configuration_reg {
+    char all;
     struct {
-      uint8_t fifo_a_full       : 4;
-      uint8_t fifo_roll_over_en : 1;
-      uint8_t smp_ave           : 3;
+      char fifo_a_full       : 4;
+      char fifo_roll_over_en : 1;
+      char smp_ave           : 3;
     } bit;
-  } max30101_fifo_configuration;
+  } max30101_fifo_configuration_t;
 
   /// @brief MODE_CONFIGURATION (0x09)
-  volatile union max30101_mode_configuration_reg {
-    uint8_t all;
+  typedef union max30101_mode_configuration_reg {
+    char all;
     struct {
-      uint8_t mode      : 3;
-      uint8_t reserved1 : 3;
-      uint8_t reset     : 1;
-      uint8_t shdn      : 1;
+      char mode      : 3;
+      char reserved1 : 3;
+      char reset     : 1;
+      char shdn      : 1;
     } bit;
-  } max30101_mode_configuration;
+  } max30101_mode_configuration_t;
 
   /// @brief SPO2_CONGIGURATION (0x0A)
-  volatile union max30101_spo2_configuration_reg {
-    uint8_t all;
+  typedef union max30101_spo2_configuration_reg {
+    char all;
     struct {
-      uint8_t led_pw       : 2;
-      uint8_t spo2_sr      : 3;
-      uint8_t spo2_adc_rge : 2;
-      uint8_t reserved1    : 1;
+      char led_pw       : 2;
+      char spo2_sr      : 3;
+      char spo2_adc_rge : 2;
+      char reserved1    : 1;
     } bit;
-  } max30101_spo2_configuration;
-
-  /// @brief LED1_PA (0x0C)
-  uint8_t max30101_led1_pa;
-
-  /// @brief LED2_PA (0x0D)
-  uint8_t max30101_led2_pa;
-
-  /// @brief LED3_PA (0x0E)
-  uint8_t max30101_led3_pa;
+  } max30101_spo2_configuration_t;
 
-  /// @brief PILOT_PA (0x10)
-  uint8_t max30101_pilot_pa;
-
-  volatile union max30101_multiLED_mode_ctrl_1_reg {
-    uint8_t all;
+  typedef union max30101_multiLED_mode_ctrl_1_reg {
+    char all;
     struct {
-      uint8_t slot1     : 3;
-      uint8_t reserved  : 1;
-      uint8_t slot2     : 3;
-      uint8_t reserved1 : 1;
+      char slot1     : 3;
+      char reserved  : 1;
+      char slot2     : 3;
+      char reserved1 : 1;
     } bit;
-  } max30101_multiLED_mode_ctrl_1;
+  } max30101_multiLED_mode_ctrl_1_t;
 
-  volatile union max30101_multiLED_mode_ctrl_2_reg {
-    uint8_t all;
+  typedef union max30101_multiLED_mode_ctrl_2_reg {
+    char all;
     struct {
-      uint8_t slot3     : 3;
-      uint8_t reserved  : 1;
-      uint8_t slot4     : 3;
-      uint8_t reserved1 : 1;
+      char slot3     : 3;
+      char reserved  : 1;
+      char slot4     : 3;
+      char reserved1 : 1;
     } bit;
-  } max30101_multiLED_mode_ctrl_2;
+  } max30101_multiLED_mode_ctrl_2_t;
 
   /********************/
   /* Die Temperature  */
   /********************/
 
-  uint8_t max30101_tinit;
+  char max30101_tinit;
 
-  uint8_t max30101_tfrac;
+  char max30101_tfrac;
 
-  volatile union max30101_die_temp_config {
-    uint8_t all;
+  typedef union max30101_die_temp_config {
+    char all;
     struct {
-      uint8_t temp_en  : 1;
-      uint8_t reserved : 7;
+      char temp_en  : 1;
+      char reserved : 7;
     } bit;
-  } max30101_die_temp_config;
-  /*******************************/
+  } max30101_die_temp_config_t;
+
   /***** Function Prototypes *****/
-  /*******************************/
 
-  uint8_t max30101_prox_int_thresh;
+  char max30101_prox_int_thresh;
 
   /**
-  * MAX30101 constructor.
-  *
+  * @brief MAX30101 constructor.
   * @param sda mbed pin to use for SDA line of I2C interface.
   * @param scl mbed pin to use for SCL line of I2C interface.
   */
   MAX30101(PinName sda, PinName scl, int slaveAddress);
 
   /**
-  *  MAX30101 constructor.
-  *
+  * @brief MAX30101 constructor.
   * @param i2c I2C object to use.
   */
   MAX30101(I2C *i2c, int slaveAddress);
 
   /**
-  * MAX30101 destructor.
+  * @brief MAX30101 destructor.
   */
   ~MAX30101(void);
 
   /**
-       * @brief Allows reading from MAX30101 register
+   * @brief Allows reading from MAX30101 register
    * @param reg: is the register address, to read from (look at max30101.h and the
    *             data sheet for details)
    * @param value: is the pointer to the value read from the register
@@ -299,8 +377,7 @@
   /**
    * @brief Allows writing to MAX30101 register
    * @param reg: is the register address, to read from (look at max30101.h and
-   * the
-   *        data sheet for details)
+   * the data sheet for details)
    * @param value: is the value to write to the register
    * @returns  0-if if no error.  A non-zero value indicates an error.
    */
@@ -324,7 +401,7 @@
                     uint8_t red_led_current, uint8_t ir_led_current);
 
   /**
-   * @brief This function will stop the SpO2 mode and turn off all operating LEDâs.
+   * @brief This function will stop the SpO2 mode and turn off all operating LED�s.
    * @return  0-if if no error.  A non-zero value indicates an error.
    */
   int SpO2mode_stop(void);
@@ -398,6 +475,12 @@
    *@returns  0-if everything is good.  A non-zero value indicates an error.
    */
   int int_handler(void);
+  
+   /**
+  * @brief encapsulates the int_handler above
+  */
+  static void MidIntHandler(void);
+  
   /**
   * @brief type definition for data interrupt
   */
@@ -421,34 +504,65 @@
   static MAX30101 *instance;
 
 private:
-  /// called when interrupt data is available
+  /**
+   * @brief Used to notify an external function that interrupt data is available
+   * @param id type of data available
+   * @param buffer 32-bit buffer that points to the data
+   * @param length length of 32-bit elements available
+   */
   void dataAvailable(uint32_t id, uint32_t *buffer, uint32_t length);
-  /// callback function at the end of the interrupt
+
+
+  /**
+   * @brief Executed on interrupt (callback function at the end of the interrupt)
+   * @param id type of data available
+   * @param buffer 32-bit buffer that points to the data
+   * @param length length of 32-bit elements available
+   */
   void interruptPostCallback(void);
+
   /// callback function when interrupt data is available
   DataCallbackFunction onDataAvailableCallback;
+
   /// callback function when interrupt data is available
   InterruptFunction onInterruptCallback;
-  /// Read I2c wrapper method
+
+  /**
+   * @brief Read from an I2C device (Read I2c wrapper method)
+   * @param slaveAddress slave address to use with transaction
+   * @param writeData pointer of data to write
+   * @param writeCount number of data to write
+   * @param readData pointer to buffer to read to
+   * @param readCount number of bytes to read
+   */
+
   int I2CM_Read(int slaveAddress, char *writeData, char writeCount, char *readData, char readCount);
-  /// Write I2c wrapper method
+  
+  /**
+   * @brief Write to an I2C device (I2C wrapper method)
+   * @param slaveAddress slave address to use with transaction
+   * @param writeData1 pointer of data to write
+   * @param writeCount1 number of data to write
+   * @param writeData2 pointer to buffer to read to
+   * @param writeCount2 number of bytes to read
+   */
   int I2CM_Write(int slaveAddress, char *writeData1, char writeCount1, char *writeData2, char writeCount2);
-  /// pointer to I2C object
+
+  /// @brief pointer to I2C object
   I2C *i2c;
-  /// flag to track if this object is the owner (created) the I2C object
+
+  /// @brief flag to track if this object is the owner (created) the I2C object
   bool i2c_owner;
-  /// Device slave address
+
+  /// @brief Device slave address
   int slaveAddress;
 };
 
-/**
-*  @brief Resets the I2C block, when needed
-*/
+  /**
+   *  @brief Resets the I2C block, when needed
+   */
 extern void I2CM_Init_Reset(uint8_t index, int speed);
 
- /**
-  * @brief Used for debugging, if needed
-  */
-void MAX30101MidIntHandler(void);
+
 
 #endif /* _MAX30101_H_ */
--- a/HSP/Devices/MAX30101/MAX30101_RPC.cpp	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/Devices/MAX30101/MAX30101_RPC.cpp	Fri Apr 21 12:12:30 2017 -0500
@@ -47,7 +47,6 @@
 	uint8_t args[2];
 	uint8_t reply[1];
 	ProcessArgs(argStrs, args, sizeof(args));
-//	Peripherals::max30101()->writeReg(args[0] , args[1]);	// pass in the register address and the data
 	reply[0] = 0x80;
 	FormatReply(reply, sizeof(reply), replyStrs);
 	return 0;
@@ -57,9 +56,8 @@
 int MAX30101_ReadReg(char argStrs[32][32], char replyStrs[32][32]) {
 	uint8_t args[1];
 	uint8_t reply[1];
-	char value;
+	char value = 0;
 	ProcessArgs(argStrs, args, sizeof(args));
-//	Peripherals::max30101()->readReg(args[0] , &value, 1);
 	reply[0] = (uint8_t)value;
 	FormatReply(reply, sizeof(reply), replyStrs);
 	return 0;
@@ -69,11 +67,9 @@
 int MAX30101_COMMinit(char argStrs[32][32], char replyStrs[32][32])
 {
 	uint8_t args[4];
-	uint8_t return_value;
+	uint8_t return_value = 0;
 	ProcessArgs(argStrs,args,sizeof(args));
 
-	//return_value = max30101_COMMinit(args[0], args[1], args[2], args[3]);
-
 	strcpy(replyStrs[0],"80");
 	return return_value;
 }
@@ -82,11 +78,9 @@
 int MAX30101_SpO2mode_stop(char argStrs[32][32], char replyStrs[32][32])
 {
 	uint8_t args[4];
-	uint8_t return_value;
+	uint8_t return_value = 0;
 	ProcessArgs(argStrs,args,sizeof(args));
 
-	//lis2dh_Stop();
-	//max30101_SpO2mode_stop();
 	Peripherals::max30101()->SpO2mode_stop();
 
 	strcpy(replyStrs[0],"80");
@@ -99,7 +93,6 @@
 	uint8_t args[4];
 	ProcessArgs(argStrs,args,sizeof(args));
 
-	//lis2dh_Stop();
 	Peripherals::max30101()->HRmode_stop();
 
 	strcpy(replyStrs[0],"80");
@@ -112,7 +105,6 @@
 	uint8_t args[4];
 	ProcessArgs(argStrs,args,sizeof(args));
 
-	//lis2dh_Stop();
 	Peripherals::max30101()->Multimode_stop();
 
 	strcpy(replyStrs[0],"80");
@@ -121,8 +113,8 @@
 
 //******************************************************************************
 void ClearInOutFifos() {
-	fifo_clear(GetStreamOutFifo());		// clear stream out fifo
-	fifo_clear(GetUSBIncomingFifo());				// clear USB serial incoming fifo
+	fifo_clear(GetStreamOutFifo());	   ///< clear stream out fifo
+	fifo_clear(GetUSBIncomingFifo());  ///< clear USB serial incoming fifo
 }
 
 int highDataRate = 0;
@@ -181,7 +173,9 @@
 
 	ClearInOutFifos();
 	MAX30101_Helper_SetStreamingFlag(eStreaming_SPO2,1);
-	if (args[2] >= MAX30101_200HZ) highDataRate = 1;
+	if (args[2] >= MAX30101_200HZ) {
+      highDataRate = 1;
+    }
 	Peripherals::max30101()->SpO2mode_init(args[0], args[1], args[2], args[3], args[4], args[5]);
 
 	strcpy(replyStrs[0],"80");
@@ -218,7 +212,9 @@
 
 	ClearInOutFifos();
 	MAX30101_Helper_SetStreamingFlag(eStreaming_HR,1);
-	if (args[2] >= MAX30101_200HZ) highDataRate = 1;
+	if (args[2] >= MAX30101_200HZ) {
+      highDataRate = 1;
+    }
 	Peripherals::max30101()->HRmode_init(args[0], args[1], args[2], args[3], args[4]);
 	strcpy(replyStrs[0],"80");
 	return 0;
@@ -259,7 +255,9 @@
 
 	ClearInOutFifos();
 	MAX30101_Helper_SetStreamingFlag(eStreaming_MULTI, 1);
-	if (args[2] >= MAX30101_200HZ) highDataRate = 1;
+	if (args[2] >= MAX30101_200HZ) {
+      highDataRate = 1;
+    }
 	Peripherals::max30101()->Multimode_init(args[0], args[1], args[2],
 											args[3], args[4], args[5], args[6],
 											args[7], args[8], args[9], args[10]);
--- a/HSP/Devices/MAX30101/MAX30101_helper.cpp	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/Devices/MAX30101/MAX30101_helper.cpp	Fri Apr 21 12:12:30 2017 -0500
@@ -37,20 +37,18 @@
 #include "MAX30101.h"
 #include "Peripherals.h"
 
-// int8_t max30101_SpO2mode_stop(void);
-// int8_t max30101_HRmode_stop(void);
-// int8_t max30101_Multimode_stop(void);
-
 static uint8_t flags[3];
 
 uint8_t MAX30101_Helper_IsStreaming(eMAX30101Flags flag) {
   return flags[(uint32_t)flag];
 }
+//******************************************************************************
 
 void MAX30101_Helper_SetStreamingFlag(eMAX30101Flags flag, uint8_t state) {
   flags[(uint32_t)flag] = state;
 }
 
+//******************************************************************************
 void MAX30101_Helper_Stop(void) {
   if (flags[(uint32_t)eStreaming_HR] == 1) {
     Peripherals::max30101()->HRmode_stop();
@@ -64,6 +62,7 @@
   MAX30101_Helper_ClearStreamingFlags();
 }
 
+//******************************************************************************
 void MAX30101_Helper_ClearStreamingFlags(void) {
   uint32_t i;
   for (i = 0; i < 3; i++) {
@@ -71,4 +70,5 @@
   }
 }
 
+//******************************************************************************
 void MAX30101_OnInterrupt(void) { I2CM_Init_Reset(2, 1); }
--- a/HSP/Devices/MAX30205/MAX30205/MAX30205.cpp	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/Devices/MAX30205/MAX30205/MAX30205.cpp	Fri Apr 21 12:12:30 2017 -0500
@@ -59,7 +59,9 @@
   int result;
   char cmdData[2] = {(char)reg, value};
   result = i2c->write(slaveAddress, cmdData, 2);
-  if (result != 0) return -1;
+  if (result != 0){
+    return -1;
+  }
   return 0;
 }
 
@@ -70,7 +72,9 @@
   char lo = value & 0xFF;
   char cmdData[3] = {reg, hi, lo};
   result = i2c->write(slaveAddress, cmdData, 3);
-  if (result != 0) return -1;
+  if (result != 0) {
+    return -1;
+  }
   return 0;
 }
 
@@ -80,9 +84,13 @@
   char cmdData[1] = {reg};
 
   result = i2c->write(slaveAddress, cmdData, 1);
-  if (result != 0) return -1;
+  if (result != 0) {
+    return -1;
+  }
   result = i2c->read(slaveAddress, value, 1);
-  if (result != 0) return -1;
+  if (result != 0){
+    return -1;
+  }
   return 0;
 }
 
@@ -92,9 +100,13 @@
   char data[2];
   char cmdData[1] = {reg};
   result = i2c->write(slaveAddress, cmdData, 1);
-  if (result != 0) return -1;
+  if (result != 0) {
+    return -1;
+  }
   result = i2c->read(slaveAddress, data, 2);
-  if (result != 0) return -1;
+  if (result != 0) {
+    return -1;
+  }
   *value = (data[0] << 8) + data[1];
   return 0;
 }
--- a/HSP/Devices/MAX30205/MAX30205/MAX30205.h	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/Devices/MAX30205/MAX30205/MAX30205.h	Fri Apr 21 12:12:30 2017 -0500
@@ -36,45 +36,18 @@
 #include "mbed.h"
 
 /**
- * Driver for the MAX30205 on the HSP Platform
- *
- * @code
- * #include <stdio.h>
- * #include "mbed.h"
- * #include "xxx.h"
- *
- * I2C i2c(I2C_SDA, I2C_SCL);
- * xxx xxx(&i2c);
- *
- * int main(void) {
- *	   printf("Initialized xxx\n");
- *     while(1) {
- *         if (xxx.init() != 0) {
- *             printf("Error communicating with xxx\n");
- *         } else {
- *             printf("Initialized xxx\n");
- *             break;
- *         }
- *         wait(1);
- *     }
- *
- *     while(1) {
- *         printf("");
- *         wait(1);
- *     }
- * }
- * @endcode
+ * @brief Driver for the MAX30205 on the HSP Platform
  */
 
 class MAX30205 {
 public:
-  /// MAX30205 Register Addresses
+  ///< MAX30205 Register Addresses
   typedef enum Registers {
-    MAX30205_Temperature = 0x00,
+    MAX30205_Temperature   = 0x00,
     MAX30205_Configuration = 0x01,
-    MAX30205_THYST = 0x02,
-    MAX30205_TOS = 0x03
-  };
+    MAX30205_THYST         = 0x02,
+    MAX30205_TOS           = 0x03
+  } Registers_t;
 
   /**
   * @brief  Constructor using I2C PinNames
@@ -151,11 +124,17 @@
   float toFahrenheit(float temperatureC);
 
 private:
-  /// I2C pointer
+  /**
+   * @brief I2C pointer
+   */
   I2C *i2c;
-  /// Is this object the owner of the I2C object
+  /**
+   * @brief Is this object the owner of the I2C object
+   */
   bool isOwner;
-  /// Device slave address
+  /**
+   * @brief Device slave address
+   */
   int slaveAddress;
 };
 
--- a/HSP/Devices/PushButton/PushButton.cpp	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/Devices/PushButton/PushButton.cpp	Fri Apr 21 12:12:30 2017 -0500
@@ -46,22 +46,27 @@
   interruptButton.fall(&pb_hit_interrupt_fall);
 }
 
+//******************************************************************************
 bool PushButton::GetButtonFallState(void) { 
  return buttonFallState; 
 }
 
+//******************************************************************************
 void PushButton::SetButtonFallState(bool state) { 
  buttonFallState = state; 
 }
 
+//******************************************************************************
 void PushButton::clearButtonFallState(void) { 
  buttonFallState = false; 
 }
 
+//******************************************************************************
 int PushButton::Read(void) { 
  return interruptButton.read(); 
 }
 
+//******************************************************************************
 void pb_hit_interrupt_fall(void) {
   if (Peripherals::pushButton() != NULL)
     Peripherals::pushButton()->SetButtonFallState(true);
--- a/HSP/Devices/S25FS256/S25FS512.cpp	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/Devices/S25FS256/S25FS512.cpp	Fri Apr 21 12:12:30 2017 -0500
@@ -1,3 +1,4 @@
+
 /*******************************************************************************
  * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
  *
@@ -31,49 +32,24 @@
  *******************************************************************************
  */
 
-//
-// Flash Non-Volatile Memory
-// U27 S25FS512
-// Nimitz SPIM1
-//
-
 #include "mbed.h"
 #include "S25FS512.h"
 #include "QuadSpiInterface.h"
-
-#define IOMUX_IO_ENABLE              1
-
-#define S25FS512_SPI_PORT            1
-#define S25FS512_CS_PIN              0
-#define S25FS512_CS_POLARITY         0
-#define S25FS512_CS_ACTIVITY_DELAY   0
-#define S25FS512_CS_INACTIVITY_DELAY 0
-#define S25FS512_CLK_HI              4
-#define S25FS512_CLK_LOW             4
-#define S25FS512_ALT_CLK             0
-#define S25FS512_CLK_POLARITY        0
-#define S25FS512_CLK_PHASE           0
-#define S25FS512_WRITE               1
-#define S25FS512_READ                0
-
-#define INT_PORT_B 3
-#define INT_PIN_B 6
-
-uint8_t flashBuffer[257 + 10];
+//#include "DebugRoutines.h"
 
 //******************************************************************************
 S25FS512::S25FS512(QuadSpiInterface *_quadSpiInterface) {
-  this->quadSpiInterface = _quadSpiInterface;
+	this->quadSpiInterface = _quadSpiInterface;
 }
 
 //******************************************************************************
-S25FS512::~S25FS512(void) {
+S25FS512::~S25FS512()
+{
 }
 
 //******************************************************************************
-int S25FS512::init(void) {
+void S25FS512::init(void) {
   setQuadMode();
-  return 0;
 }
 
 //******************************************************************************
@@ -81,7 +57,7 @@
   uint8_t cmdArray[8];
   // Send WREN
   cmdArray[0] = 0x06;
-  wait_1mS();
+  //wait_ms(1);
   return reg_write_read_multiple_4Wire(cmdArray, 1, flashBuffer, 1);
 }
 
@@ -90,24 +66,25 @@
   uint8_t cmdArray[8];
   // Send WREN
   cmdArray[0] = 0x06;
-  wait_1mS();
+  //wait_ms(1);
   return reg_write_read_multiple_quad(cmdArray, 1, flashBuffer, 0);
 }
 
 //******************************************************************************
-int8_t S25FS512::reg_write_read_multiple_quad_last(uint8_t *bufferOut,
-                                                   uint8_t numberOut,
-                                                   uint8_t *bufferIn,
-                                                   uint8_t numberIn,
-                                                   uint8_t last) {
-  int32_t success = 0;
+int8_t S25FS512::reg_write_read_multiple_quad_last(uint8_t *bufferOut, uint8_t numberOut, uint8_t *bufferIn, uint8_t numberIn, uint8_t last) {
+	int32_t  success = 0;
+	//if (spiSlave.port != 1) {
+	//	while (1);
+	//}
+//	success = SPI_Transmit(&spiSlave, dataIn, numberIn, dataOut, numberOut, MXC_E_SPI_UNIT_BYTES, MXC_E_SPI_MODE_QUAD, 0, last);//MXC_E_SPI_MODE_QUAD
 
-  success = quadSpiInterface->SPI_Transmit( 
-                       bufferOut, numberOut, 
-                       bufferIn, numberIn, (int)last);
+	success = quadSpiInterface->SPI_Transmit(
+			bufferOut, numberOut,
+			bufferIn, numberIn,
+			(int)last);
 
-  if (success != 0) return -1;
-  return 0;
+	if (success != 0) return -1;
+	return 0;
 }
 
 //******************************************************************************
@@ -124,31 +101,27 @@
 }
 
 //******************************************************************************
-int8_t S25FS512::reg_write_read_multiple_quad(uint8_t *bufferOut,
-                                              uint8_t numberOut,
-                                              uint8_t *bufferIn,
-                                              uint8_t numberIn) {
-  int8_t ret;
-  ret = reg_write_read_multiple_quad_last(bufferOut, numberOut, bufferIn,
-                                          numberIn, 1);
-  return ret;
+int8_t S25FS512::reg_write_read_multiple_quad(uint8_t *bufferOut, uint8_t numberOut, uint8_t *bufferIn, uint8_t numberIn) {
+	int8_t ret;
+	ret = reg_write_read_multiple_quad_last(bufferOut,numberOut,bufferIn,numberIn,1);
+	return ret;
 }
 
 //******************************************************************************
 void S25FS512::readID(uint8_t *id) {
-  uint8_t cmd = 0x9F;
-  reg_write_read_multiple_quad(&cmd, 1, id, 4);
+    uint8_t cmd = 0x9F;
+    reg_write_read_multiple_quad(&cmd, 1, id, 4);
 }
 
 //******************************************************************************
 int8_t S25FS512::writeAnyRegister(uint32_t address, uint8_t data) {
-  uint8_t cmdArray[5];
-  cmdArray[0] = 0x71;
-  cmdArray[1] = (address >> 16) & 0xFF;
-  cmdArray[2] = (address >> 8) & 0xFF;
-  cmdArray[3] = (address >> 0) & 0xFF;
-  cmdArray[4] = data;
-  return reg_write_read_multiple_quad(cmdArray, 5, flashBuffer, 0);
+	uint8_t cmdArray[5];
+	cmdArray[0] = 0x71;
+	cmdArray[1] = (address >> 16) & 0xFF;
+	cmdArray[2] = (address >> 8) & 0xFF;
+	cmdArray[3] = (address >> 0) & 0xFF;
+	cmdArray[4] = data;
+	return reg_write_read_multiple_quad(cmdArray,5,flashBuffer,0);
 }
 
 int8_t S25FS512::writeAnyRegister4Wire(uint32_t address, uint8_t data) {
@@ -160,313 +133,361 @@
   cmdArray[4] = data;
   return reg_write_read_multiple_4Wire(cmdArray, 5, flashBuffer, 5);
 }
+//******************************************************************************
+int8_t 	S25FS512::writeRegisters(void) {
+	uint8_t cmdArray[3];
+	wait_ms(1);
+	cmdArray[0] = 0x01;
+	cmdArray[1] = 0x00;
+	cmdArray[2] = 0x02; // set Quad to 1
+	reg_write_read_multiple_quad(cmdArray,3,flashBuffer,0);
+	return 0;
+}
+
 
 //******************************************************************************
-int8_t S25FS512::writeRegisters(void) {
-  uint8_t cmdArray[3];
-  wait_1mS();
-  cmdArray[0] = 0x01;
-  cmdArray[1] = 0x00;
-  cmdArray[2] = 0x02; // set Quad to 1
-  reg_write_read_multiple_quad(cmdArray, 3, flashBuffer, 0);
-  return 0;
-}
-
-//******************************************************************************
-int8_t S25FS512::readAnyRegister(uint32_t address, uint8_t *data,
-                                 uint32_t length) {
-  uint8_t cmdArray[4];
-  cmdArray[0] = 0x65;
-  cmdArray[1] = (address >> 16) & 0xFF;
-  cmdArray[2] = (address >> 8) & 0xFF;
-  cmdArray[3] = (address >> 0) & 0xFF;
-  return reg_write_read_multiple_quad(cmdArray, 4, data, length);
+int8_t S25FS512::readAnyRegister(uint32_t address, uint8_t *data, uint32_t length) {
+	uint8_t cmdArray[4];
+	cmdArray[0] = 0x65;
+	cmdArray[1] = (address >> 16) & 0xFF;
+	cmdArray[2] = (address >> 8) & 0xFF;
+	cmdArray[3] = (address >> 0) & 0xFF;
+	return reg_write_read_multiple_quad(cmdArray,4,data,length);
 }
 
 //******************************************************************************
 int8_t S25FS512::bulkErase(void) {
-  uint8_t cmdArray[1];
-  cmdArray[0] = 0x60;
-  return reg_write_read_multiple_quad(cmdArray, 1, flashBuffer, 0);
+	uint8_t cmdArray[1];
+	cmdArray[0] = 0x60;
+	return reg_write_read_multiple_quad(cmdArray,1,flashBuffer,0);
 }
 
 //******************************************************************************
 int8_t S25FS512::pageProgram(uint32_t address, uint8_t *buffer) {
-  uint32_t i;
-  uint8_t cmdArray[5 + 256];
-  uint8_t *ptr;
+	uint32_t i;
+	uint8_t cmdArray[6 + 256];
+	uint8_t *ptr;
+
+	//for (i = 0; i < 256; i++) {
+	//	dataArray[i] = i;
+	//}
+	cmdArray[0] = 0x12; //0x02; //0x71;
+	cmdArray[1] = (address >> 24) & 0xFF;
+	cmdArray[2] = (address >> 16) & 0xFF;
+	cmdArray[3] = (address >> 8) & 0xFF;
+	cmdArray[4] = (address >> 0) & 0xFF;
+	for (i = 0; i < 256; i++) {
+		cmdArray[5 + i] = buffer[i];
+	}
+//	reg_write_read_multiple_quad(cmdArray,256 + 4,flashBuffer,256 + 4);
 
-  // for (i = 0; i < 256; i++) {
-  //	dataArray[i] = i;
-  //}
-  cmdArray[0] = 0x02; // 0x71;
-  //	cmdArray[1] = (address >> 24) & 0xFF;
-  cmdArray[1] = (address >> 16) & 0xFF;
-  cmdArray[2] = (address >> 8) & 0xFF;
-  cmdArray[3] = (address >> 0) & 0xFF;
-  for (i = 0; i < 256; i++) {
-    cmdArray[4 + i] = buffer[i];
-  }
-  //	reg_write_read_multiple_quad(cmdArray,256 + 4,flashBuffer,256 + 4);
+	ptr = cmdArray;
+	reg_write_read_multiple_quad_last(ptr,5 + 64,flashBuffer,0,0);
+	//wait_ms(1);
+	ptr += (5 + 64);
+	reg_write_read_multiple_quad_last(ptr,64,flashBuffer,0,0);
+	//wait_ms(1);
+	ptr += 64;
+	reg_write_read_multiple_quad_last(ptr,64,flashBuffer,0,0);
+	//wait_ms(1);
+	ptr += 64;
+	reg_write_read_multiple_quad_last(ptr,64,flashBuffer,0,1);
+	//wait_ms(1);
+	return 0;
+}
 
-  ptr = cmdArray;
-  reg_write_read_multiple_quad_last(ptr, 4 + 64, flashBuffer, 0, 0);
-  wait_1mS();
-  ptr += (4 + 64);
-  reg_write_read_multiple_quad_last(ptr, 64, flashBuffer, 0, 0);
-  wait_1mS();
-  ptr += 64;
-  reg_write_read_multiple_quad_last(ptr, 64, flashBuffer, 0, 0);
-  wait_1mS();
-  ptr += 64;
-  reg_write_read_multiple_quad_last(ptr, 64, flashBuffer, 0, 1);
-  wait_1mS();
-  return 0;
+//
+// read page 0 and assure that it is empty
+//
+void S25FS512::test_verifyPage0Empty(uint8_t *ptr, int currentPage, int pagesWrittenTo) {
+    uint8_t data[512];
+    bool pageEmpty;   
+    readPages_Helper(0, 0, data, 0);
+    pageEmpty = isPageEmpty(data);
+    if (pageEmpty == false) {
+      //PRINTD_2("ERROR: Page 0 is no longer empty!!!!!!!\r\n");
+	  //PRINTD_2("Page 0->\r\n");
+      //DebugRoutines::dumpBuffer(data, 256);
+	  //PRINTD_2("Page 0->\r\n");
+      readPages_Helper(0, 0, data, 0);
+      //DebugRoutines::dumpBuffer(data, 256);
+	  //PRINTD_2("Page 0->\r\n");
+      readPages_Helper(0, 0, data, 0);
+      //DebugRoutines::dumpBuffer(data, 256);
+	  if (ptr != NULL) {
+		//PRINTD_2("currentPage=%d ", (int)currentPage);
+		//PRINTD_2("pagesWrittenTo=%d\r\n", (int)pagesWrittenTo);
+		//PRINTD_2("Writing page data->\r\n");
+		//DebugRoutines::dumpBuffer(ptr, 256);
+	  }
+      while (1) ;
+    }
 }
 
 //******************************************************************************
-int8_t S25FS512::quadIoRead_Pages(uint32_t address, uint8_t *buffer,
-                                  uint32_t numberOfPages) {
-  uint8_t cmdArray[5];
-  uint8_t *ptr;
-  uint8_t last;
-  uint32_t i;
-
-  cmdArray[0] = 0xEB;
-  cmdArray[1] = (address >> 16) & 0xFF;
-  cmdArray[2] = (address >> 8) & 0xFF;
-  cmdArray[3] = (address >> 0) & 0xFF;
-  ptr = buffer;
-  last = 0;
-  // only send the command
-  reg_write_read_multiple_quad_last(cmdArray, 4, ptr, 0, 0);
-  wait_1mS();
-  reg_write_read_multiple_quad_last(cmdArray, 0, ptr, 5, 0);
-  wait_1mS();
-  for (i = 0; i < numberOfPages; i++) {
-    reg_write_read_multiple_quad_last(cmdArray, 0, ptr, 64, 0);
-    wait_1mS();
-    ptr += 64;
-    reg_write_read_multiple_quad_last(cmdArray, 0, ptr, 64, 0);
-    wait_1mS();
-    ptr += 64;
-    reg_write_read_multiple_quad_last(cmdArray, 0, ptr, 64, 0);
-    wait_1mS();
-    ptr += 64;
-    // check if this is the last page
-    if ((i + 1) == numberOfPages) {
-      last = 1;
-    }
-    reg_write_read_multiple_quad_last(cmdArray, 0, ptr, 64, last);
-    wait_1mS();
-    ptr += 64;
-  }
-  return 0;
+int8_t S25FS512::quadIoRead_Pages(uint32_t address, uint8_t *buffer, uint32_t numberOfPages) {
+	uint8_t cmdArray[5];
+	uint8_t *ptr;
+	uint8_t last;
+	uint32_t i;
+	cmdArray[0] = 0xEC; //0xEB;
+	cmdArray[1] = (address >> 24) & 0xFF;
+	cmdArray[2] = (address >> 16) & 0xFF;
+	cmdArray[3] = (address >> 8) & 0xFF;
+	cmdArray[4] = (address >> 0) & 0xFF;
+	//reg_write_read_multiple_quad(cmdArray,4,flashBuffer,32);
+/*	last = 0;
+	num = 0;
+	inc = 32;
+	while (num < number) {*/
+	ptr = buffer;
+	last = 0;
+	// only send the command
+	reg_write_read_multiple_quad_last(cmdArray, 5, ptr, 0, 0);
+	//wait_ms(1);
+	reg_write_read_multiple_quad_last(cmdArray, 0, ptr, 5, 0);
+	//wait_ms(1);
+	for (i = 0; i < numberOfPages; i++) {
+		reg_write_read_multiple_quad_last(cmdArray,0,ptr,64, 0);
+		//wait_ms(1);
+		ptr += 64;
+		reg_write_read_multiple_quad_last(cmdArray,0,ptr,64, 0);
+		//wait_ms(1);
+		ptr += 64;
+		reg_write_read_multiple_quad_last(cmdArray,0,ptr,64, 0);
+		//wait_ms(1);
+		ptr += 64;
+		// check if this is the last page
+		if ((i + 1) == numberOfPages) {
+			last = 1;
+		}
+		reg_write_read_multiple_quad_last(cmdArray,0,ptr,64, last);
+		//wait_ms(1);
+		ptr += 64;
+	}
+	return 0;
 }
 
 //******************************************************************************
 int8_t S25FS512::checkBusy(void) {
-  uint8_t cmdArray[5];
-  cmdArray[0] = 0x05;
-  reg_write_read_multiple_quad(cmdArray, 1, flashBuffer, 2);
-  return flashBuffer[1] & 0x1;
+	uint8_t cmdArray[5];
+	cmdArray[0] = 0x05;
+	reg_write_read_multiple_quad(cmdArray,1,flashBuffer,2);
+	return flashBuffer[1] & 0x1;
 }
 
 //******************************************************************************
 void S25FS512::waitTillNotBusy(void) {
-  while (checkBusy() == 1) {
-  }
+	while (checkBusy() == 1) {		}
 }
 
 //******************************************************************************
 int8_t S25FS512::sectorErase(uint32_t address) {
-  uint8_t cmdArray[5];
-  cmdArray[0] = 0xD8;
-  cmdArray[1] = (address >> 16) & 0xFF;
-  cmdArray[2] = (address >> 8) & 0xFF;
-  cmdArray[3] = (address >> 0) & 0xFF;
-  return reg_write_read_multiple_quad(cmdArray, 4, flashBuffer, 0);
+	uint8_t cmdArray[5];
+	cmdArray[0] = 0xDC; //0xD8;
+	cmdArray[1] = (address >> 24) & 0xFF;
+	cmdArray[2] = (address >> 16) & 0xFF;
+	cmdArray[3] = (address >> 8) & 0xFF;
+	cmdArray[4] = (address >> 0) & 0xFF;
+	return reg_write_read_multiple_quad(cmdArray,5,flashBuffer,0);
 }
 
 //******************************************************************************
 int8_t S25FS512::parameterSectorErase(uint32_t address) {
-  uint8_t cmdArray[5];
-  cmdArray[0] = 0x20;
-  cmdArray[1] = (address >> 16) & 0xFF;
-  cmdArray[2] = (address >> 8) & 0xFF;
-  cmdArray[3] = (address >> 0) & 0xFF;
-  reg_write_read_multiple_quad(cmdArray, 4, flashBuffer, 0);
-  return 0;
-}
-
-#define ONE_MS (32768 / 500)
-#define ONEHUNDRED_US (32768 / 1000)
-#define TEM_MS (32768 / 50)
-
-//******************************************************************************
-void S25FS512::wait_1mS(void) { 
- wait_ms(1); 
-}
-
-//******************************************************************************
-void S25FS512::wait_100uS(void) { 
-wait_us(100); 
-}
-
-//******************************************************************************
-void S25FS512::wait_10mS(void) { 
-wait_ms(10); 
+	uint8_t cmdArray[5];
+	cmdArray[0] = 0x21;     //0x20 (P4E), 0x21 (4P4E)
+	cmdArray[1] = (address >> 24) & 0xFF;
+	cmdArray[2] = (address >> 16) & 0xFF;
+	cmdArray[3] = (address >> 8) & 0xFF;
+	cmdArray[4] = (address >> 0) & 0xFF;
+	reg_write_read_multiple_quad(cmdArray,5,flashBuffer,0);
+	return 0;
 }
 
 //******************************************************************************
 int8_t S25FS512::readIdentification(uint8_t *dataArray, uint8_t length) {
-  // 4QIOR = 0x9F
-  uint8_t cmdArray[1];
-  cmdArray[0] = 0x9F; // read ID command
-  return reg_write_read_multiple_quad(cmdArray, 1, dataArray, length);
+	// 4QIOR = 0x9F
+	uint8_t cmdArray[1];
+	cmdArray[0] = 0x9F;	// read ID command
+	return reg_write_read_multiple_quad(cmdArray,1,dataArray,length);
 }
 
 //******************************************************************************
 uint8_t S25FS512::reset(void) {
-  uint8_t cmdArray[8];
-  wait_1mS();
-  cmdArray[0] = 0x66;
-  reg_write_read_multiple_quad(cmdArray, 1, flashBuffer, 0);
-  wait_1mS();
-  cmdArray[0] = 0x99;
-  reg_write_read_multiple_quad(cmdArray, 1, flashBuffer, 0);
-  return 0;
+	uint8_t cmdArray[8];
+	wait_ms(1);
+	cmdArray[0] = 0x66;
+	reg_write_read_multiple_quad(cmdArray,1,flashBuffer,0);
+	wait_ms(1);
+	cmdArray[0] = 0x99;
+	reg_write_read_multiple_quad(cmdArray,1,flashBuffer,0);
+	return 0;
 }
 
 //******************************************************************************
 uint8_t S25FS512::enableHWReset(void) {
-  uint8_t data[8];
-  wait_1mS();
-  // CR2V Configuration Register-2 Volatile
-  // bit 5
-  readAnyRegister(0x00800003, data, 8);
-  writeAnyRegister(0x00800003, 0x64);
-  return 0;
+	uint8_t data[8];
+	wait_ms(1);
+	// CR2V Configuration Register-2 Volatile
+	// bit 5
+	readAnyRegister(0x00800003,data, 8);
+	writeAnyRegister(0x00800003,0x64);
+	return 0;
 }
 
 //******************************************************************************
 uint8_t S25FS512::detect(void) {
-  uint8_t array[8];
-  uint8_t array2[8];
+	uint8_t array[8];
+	uint8_t array2[8];
+
+	// Send WREN
+	wren();
+	// Send WREN
+	wren();
+	// delay
+	wait_ms(1);
+	// Put into quad mode
+	//setQuadMode();
+
+	// Send WDIS
+//	array[0] = 0x04;
+//	test_reg_write_multiple_4wire(array,1);
+
+	// Send WREN
+	wren();
+	// delay
+	wait_ms(1);
 
-  // Send WREN
-  wren();
-  // Send WREN
-  wren();
-  // delay
-  wait_1mS();
-  // Send WREN
-  wren();
-  // delay
-  wait_1mS();
+	// Send write any register cmd
+	writeAnyRegister(0x0003, 0x48);
+/*
+	//
+	// try reading the ID by using 4 wire spi for the command and quad for reading
+	//
 
-  // Send write any register cmd
-  writeAnyRegister(0x0003, 0x48);
-  // delay
-  wait_1mS();
-  array[0] = 0x9F; // read ID command
-  reg_write_read_multiple_quad(array, 1, array2, 7);
-  return 0;
+	// send read id cmd
+	array[0] = 0x9F;
+	test_reg_write_multiple_4wire(array,1);
+	// send read id via quad
+	test_reg_read_multiple_quad(array,7);
+*/
+	// delay
+	wait_ms(1);
+	array[0] = 0x9F;	// read ID command
+	reg_write_read_multiple_quad(array,1,array2,7);
+
+/*
+	//uint8_t val[5];
+	uint32_t result;
+	test_reg_write(0x9F);
+	test_reg_read2(0x9F,&result);
+	test_reg_read3(0x9F,&result);
+	*/
+	return 0;
 }
 
 //******************************************************************************
 int S25FS512::setQuadMode(void) {
-  wait_1mS();
+  wait_ms(1);
   wren4Wire();
-  wait_1mS();
+  wait_ms(1);
   writeAnyRegister4Wire(0x800002, 0x02); // set Quad = 1
-  wait_1mS();
+  wait_ms(1);
   wren4Wire();
-  wait_1mS();
+  wait_ms(1);
   writeAnyRegister4Wire(0x800003, 0x48); // set 8 latency, set QPI 4-4-4
+  return 0;
 }
 
 //******************************************************************************
-uint32_t S25FS512::isPageEmpty(uint8_t *ptr) {
-  int i;
-  for (i = 0; i < 256; i++) {
-    if (ptr[i] != 0xFF)
-      return 0;
-  }
-  return 1;
+bool S25FS512::isPageEmpty(uint8_t *ptr) {
+	int i;
+	for (i = 0; i < 256; i++) {
+		if (ptr[i] != 0xFF) return false;
+	}
+	return true;
 }
 
 //******************************************************************************
 int8_t S25FS512::parameterSectorErase_Helper(uint32_t address) {
-  waitTillNotBusy();
-  wait_100uS();
-  wren();
-  wait_100uS();
-  parameterSectorErase(address);
-  wait_100uS();
-  waitTillNotBusy();
-  wait_100uS();
-  return 0;
+	waitTillNotBusy();
+	wait_us(100);
+	wren();
+	wait_us(100);
+	parameterSectorErase(address);
+	wait_us(100);
+	waitTillNotBusy();
+	wait_us(100);
+	return 0;
 }
 
 //******************************************************************************
 int8_t S25FS512::sectorErase_Helper(uint32_t address) {
-  waitTillNotBusy();
-  wait_100uS();
-  wren();
-  wait_100uS();
-  if (address < 0x8000) {
+	waitTillNotBusy();
+	wait_us(100);
+	wren();
+	wait_us(100);
+
+  if (address < 0x20000) { //0x8000) {
     parameterSectorErase(address);
   } else {
     sectorErase(address);
-  }
-  wait_100uS();
-  waitTillNotBusy();
-  wait_100uS();
-  return 0;
+  }  
+	//if (address < 0x20000) {
+		//parameterSectorErase(address);
+	//} else {
+		//sectorErase(address);
+	//}
+	wait_us(100);
+	waitTillNotBusy();
+	wait_us(100);
+	return 0;
 }
 
 //******************************************************************************
 int8_t S25FS512::bulkErase_Helper(void) {
-  waitTillNotBusy();
-  wait_100uS();
-  wren();
-  wait_100uS();
-  bulkErase();
-  wait_100uS();
-  waitTillNotBusy();
-  wait_100uS();
-  return 0;
+	waitTillNotBusy();
+	wait_us(100);
+	wren();
+	wait_us(100);
+	bulkErase();
+	wait_us(100);
+	waitTillNotBusy();
+	wait_us(100);
+	return 0;
 }
 
 //******************************************************************************
-// write a page worth of data (256 bytes) from buffer, offset defined where in
-// the buffer to begin write
-int8_t S25FS512::writePage_Helper(uint32_t pageNumber, uint8_t *buffer,
-                                  uint32_t offset) {
-  uint8_t *ptr;
-  waitTillNotBusy();
-  wait_1mS();
-  wren();
-  ptr = &buffer[offset];
-  wait_1mS();
-  pageProgram(pageNumber << 8, ptr);
-  wait_1mS();
-  return 0;
+// write a page worth of data (256 bytes) from buffer, offset defined where in the buffer to begin write
+int8_t S25FS512::writePage_Helper(uint32_t pageNumber, uint8_t *buffer, uint32_t offset) {
+	uint8_t *ptr;
+	waitTillNotBusy();
+	//wait_ms(1);
+	wren();
+	ptr = &buffer[offset];
+	//wait_ms(1);
+	pageProgram(pageNumber << 8,ptr);
+	wait_us(100);
+	waitTillNotBusy();
+
+	//wait_ms(1);
+	return 0;
 }
 
 //******************************************************************************
 // read pages from flash into buffer, offset defined where in the buffer use
-int8_t S25FS512::readPages_Helper(uint32_t startPageNumber,
-                                  uint32_t endPageNumber, uint8_t *buffer,
-                                  uint32_t offset) {
-  uint8_t *ptr;
-  uint32_t page;
-  ptr = &buffer[offset];
-  for (page = startPageNumber; page <= endPageNumber; page++) {
-    wait_100uS();
-    quadIoRead_Pages((uint32_t)(page << 8), (uint8_t *)ptr, 1);
-    ptr += 0x100;
-  }
-  return 0;
+int8_t S25FS512::readPages_Helper(uint32_t startPageNumber,uint32_t endPageNumber, uint8_t *buffer, uint32_t offset) {
+	int8_t status = 0;
+	uint8_t *ptr;
+	uint32_t page;
+	ptr = &buffer[offset];
+	waitTillNotBusy();
+	for (page = startPageNumber; page <= endPageNumber; page++) {
+		wait_us(100);
+		status = quadIoRead_Pages((uint32_t)(page << 8), (uint8_t *)ptr, 1);
+		ptr += 0x100;
+	}
+	return status;
 }
+
+
--- a/HSP/Devices/S25FS256/S25FS512.h	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/Devices/S25FS256/S25FS512.h	Fri Apr 21 12:12:30 2017 -0500
@@ -36,75 +36,116 @@
 #include "mbed.h"
 #include "QuadSpiInterface.h"
 
+
+#define IOMUX_IO_ENABLE              1
+
+#define S25FS512_SPI_PORT            1
+#define S25FS512_CS_PIN              0
+#define S25FS512_CS_POLARITY         0
+#define S25FS512_CS_ACTIVITY_DELAY   0
+#define S25FS512_CS_INACTIVITY_DELAY 0
+#define S25FS512_CLK_HI              4
+#define S25FS512_CLK_LOW             4
+#define S25FS512_ALT_CLK             0
+#define S25FS512_CLK_POLARITY        0
+#define S25FS512_CLK_PHASE           0
+#define S25FS512_WRITE               1
+#define S25FS512_READ                0
+
+///< Byte addresses for flash configuration
+#define Address_CR1NV   0x00000002
+#define Address_CR1V    0x00800002
+#define Address_CR2NV   0x00000003
+#define Address_CR2V    0x00800003
+
+#define INT_PORT_B 3
+#define INT_PIN_B 6
+
+
 class S25FS512 {
 public:
+
+  ///< @detail S25FS512 Commands
+  typedef enum{ 
+    Write_Reg              = 0x01,
+    Read_Status_Reg1       = 0x05,
+    Write_Enable           = 0x06,
+    Erase_4k               = 0x20,
+    Bulk_Erase             = 0x60,
+    Read_Any_Reg           = 0x65,
+    Software_Reset_Enable  = 0x66,
+    Write_Any_Reg          = 0x71,
+    Software_Reset         = 0x99,
+    Read_Id                = 0x9F,
+    Erase_64k_256k         = 0xD8,
+    Quad_IO_Read           = 0xEB,
+  } S25FS512_Commands_t;
+
   S25FS512(QuadSpiInterface *_quadSpiInterface);
   ~S25FS512(void);
 
   QuadSpiInterface *quadSpiInterface;
 
-  /** Initialize the driver
+  /** @brief Initialize the driver
   */
-  int init(void);
+  void init(void);
 
-  /** Detect the presence of the flash device
+  /** @brief Detect the presence of the flash device
   */
   uint8_t detect(void);
 
-  /** Read the identification of the flash
+  /** @brief Read the identification of the flash
   */
   int8_t readIdentification(uint8_t *dataArray, uint8_t length);
 
-  /** Bulk erase the flash device
+  /** @brief Bulk erase the flash device
   */
   int8_t bulkErase_Helper(void);
 
-  /** Erase Parameter Sectors
+  /** @brief Erase Parameter Sectors
   */
   int8_t parameterSectorErase_Helper(uint32_t address);
 
-  /** Write a Page
+  /** @brief Write a Page
   */
-  int8_t writePage_Helper(uint32_t pageNumber, uint8_t *buffer,
-                          uint32_t offset);
+  int8_t writePage_Helper(uint32_t pageNumber, uint8_t *buffer, uint32_t offset);
+  
+  /** @brief Read a Page 
+  */
+  int8_t readPages_Helper(uint32_t startPageNumber,uint32_t endPageNumber, uint8_t *buffer, uint32_t offset);
 
-  /** Read a Page
-  * @param
-  */
-  int8_t readPages_Helper(uint32_t startPageNumber, uint32_t endPageNumber,
-                          uint8_t *buffer, uint32_t offset);
-
-  /** Erase a Sector
+  /** @brief Erase a Sector 
   @param address Address of sector to erase
   */
+  int8_t sectorErase_Helper(uint32_t address);
 
-  int8_t sectorErase_Helper(uint32_t address);
-  /** Scans through byte pointer for a page worth of data to see if the page is all FFs
+  /** @brief Scans through byte pointer for a page worth of data to see if the page is all FFs
   @param ptr Byte pointer to buffer to scan
   @return Returns a 1 if the page is empty, 0 if it is not all FFs
   */
-  uint32_t isPageEmpty(uint8_t *ptr);
-  
-  /** Issue a software reset to the flash device
+  bool isPageEmpty(uint8_t *ptr);
+
+  /** @brief Issue a software reset to the flash device 
   */
-
   uint8_t reset(void);
-  /** Enable a hardware reset
+
+  /** @brief Enable a hardware reset
   */
-
   uint8_t enableHWReset(void);
-  /** Read the id byte of this device
+  
+  /** @brief Read the id byte of this device 
   */
-
   void readID(uint8_t *id);
 
+  void test_verifyPage0Empty(uint8_t *ptr, int currentPage, int pagesWrittenTo);
+
 private:
+  void disableInterrupt(uint8_t state);
   int8_t reg_write_read_multiple_quad_last(uint8_t *dataIn, uint8_t numberIn, uint8_t *dataOut, uint8_t numberOut, uint8_t last);
   int8_t reg_write_read_multiple_quad(uint8_t *dataIn, uint8_t numberIn, uint8_t *dataOut, uint8_t numberOut);
   int8_t reg_write_read_multiple_4Wire(uint8_t *bufferOut, uint8_t numberOut, uint8_t *bufferIn, uint8_t numberIn);
   uint8_t spiWriteRead (uint8_t writeNumber,uint8_t *writeData, uint8_t readNumber, uint8_t *readData);
   uint8_t spiWriteRead4Wire(uint8_t writeNumber,uint8_t *writeData, uint8_t readNumber, uint8_t *readData);
-
   int8_t writeAnyRegister(uint32_t address, uint8_t data);
   int8_t writeAnyRegister4Wire(uint32_t address, uint8_t data);
   int8_t writeRegisters(void);
@@ -120,8 +161,7 @@
   void waitTillNotBusy(void);
   int8_t sectorErase(uint32_t address);
   int8_t parameterSectorErase(uint32_t address);
-  void wait_1mS(void);
-  void wait_100uS(void);
-  void wait_10mS(void);
+
+  uint8_t flashBuffer[257 + 10];
 };
 #endif /* S25FS512_H_ */
--- a/HSP/Devices/S25FS256/S25FS512_RPC.cpp	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/Devices/S25FS256/S25FS512_RPC.cpp	Fri Apr 21 12:12:30 2017 -0500
@@ -45,6 +45,7 @@
   return 0;
 }
 
+//******************************************************************************
 int S25FS512_EnableHWReset(char argStrs[32][32], char replyStrs[32][32]) {
   uint32_t reply[1];
   Peripherals::s25FS512()->enableHWReset();
@@ -53,6 +54,7 @@
   return 0;
 }
 
+//******************************************************************************
 int S25FS512_SpiWriteRead(char argStrs[32][32], char replyStrs[32][32]) {
   uint8_t args[16];
   uint8_t reply[16];
@@ -67,6 +69,7 @@
   return 0;
 }
 
+//******************************************************************************
 int S25FS512_SpiWriteRead4Wire(char argStrs[32][32], char replyStrs[32][32]) {
   uint8_t args[16];
   uint8_t reply[16];
@@ -81,6 +84,7 @@
   return 0;
 }
 
+//******************************************************************************
 int S25FS512_ReadPage(char argStrs[32][32], char replyStrs[32][32]) {
   uint32_t args[2];
   uint32_t reply[1];
@@ -90,10 +94,10 @@
   return 0;
 }
 
+//******************************************************************************
 int S25FS512_ReadPagesBinary(char argStrs[32][32], char replyStrs[32][32]) {
   uint32_t args[2];
-  uint32_t reply[1];
-  uint8_t pageData[256];
+  uint8_t pageData[258];
 
   uint32_t startPage;
   uint32_t endPage;
@@ -104,13 +108,15 @@
   endPage = args[1];
   for (page = startPage; page <= endPage; page++) {
     Peripherals::s25FS512()->readPages_Helper(page, page, pageData, 0);
-    putBytes256Block(pageData, 1);
+    //putBytes256Block(pageData, 1);
+    pageData[sizeof(pageData) - 2] = 0x0D;
+    pageData[sizeof(pageData) - 1] = 0x0A;
+    putBytes(pageData, sizeof(pageData));
   }
-  reply[0] = 0x80;
-  FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs);
-  return 0;
+  return RPC_SKIP_CRLF;
 }
 
+//******************************************************************************
 int S25FS512_ReadId(char argStrs[32][32], char replyStrs[32][32]) {
   char str[32];
   uint8_t data[128];
--- a/HSP/Devices/S25FS256/S25FS512_RPC.h	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/Devices/S25FS256/S25FS512_RPC.h	Fri Apr 21 12:12:30 2017 -0500
@@ -34,6 +34,7 @@
 #define _S25FS512_RPC_H_
 
 #include "mbed.h"
+#define RPC_SKIP_CRLF 0x55
 
 int S25FS512_ReadPagesBinary(char argStrs[32][32], char replyStrs[32][32]);
 int S25FS512_ReadPage(char argStrs[32][32], char replyStrs[32][32]);
--- a/HSP/Hsp_BLE/BluetoothLE/BluetoothLE.cpp	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/Hsp_BLE/BluetoothLE/BluetoothLE.cpp	Fri Apr 21 12:12:30 2017 -0500
@@ -37,8 +37,8 @@
  * @brief Constructor for class
  */
 BluetoothLE::BluetoothLE(BLE *ble, int numberOfCharacteristics)
-    : ble(ble), runningIndex(0),
-      numberOfCharacteristics(numberOfCharacteristics) {
+    : ble(ble), numberOfCharacteristics(numberOfCharacteristics), runningIndex(0)
+       {
   characteristics = new Characteristic *[numberOfCharacteristics];
   gattCharacteristics = new GattCharacteristic *[numberOfCharacteristics];
 }
@@ -89,21 +89,11 @@
   ble->startAdvertising();
 }
 
-static const Gap::ConnectionParams_t paramsLowPower = {
-    400,    /**< Minimum Connection Interval in 1.25 ms units, see @ref BLE_GAP_CP_LIMITS.*/
-    400,    /**< Maximum Connection Interval in 1.25 ms units, see @ref BLE_GAP_CP_LIMITS.*/
-    60,     /**< Slave Latency in number of connection events, see @ref BLE_GAP_CP_LIMITS.*/
-    3100    /**< Connection Supervision Timeout in 10 ms units, see @ref BLE_GAP_CP_LIMITS.*/
-};
-
-static Gap::Handle_t connHandle = 0;
-
 /**
  * @brief Called on BLE connection
  */
 void BluetoothLE::connectionCallback(
     const Gap::ConnectionCallbackParams_t *params) {
-  connHandle = params->handle;
 }
 
 /**
--- a/HSP/Hsp_BLE/BluetoothLE/Characteristic.h	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/Hsp_BLE/BluetoothLE/Characteristic.h	Fri Apr 21 12:12:30 2017 -0500
@@ -77,7 +77,7 @@
   uint8_t *getPayloadBytes(void) { return payload.bytes; }
 
   void copyDataWritten(const GattWriteCallbackParams *params) {
-    int i = 0;
+    unsigned int i = 0;
     while (i < params->len && i < sizeof(dataWritten)) {
       dataWritten[i] = params->data[i];
       i++;
--- a/HSP/Hsp_BLE/HspBLE.cpp	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/Hsp_BLE/HspBLE.cpp	Fri Apr 21 12:12:30 2017 -0500
@@ -99,7 +99,7 @@
     bluetoothLE->initService(serialNumberPtr, deviceName, sizeof(deviceName),envServiceUUID);
 
   bluetoothLE->onDataWritten(&HspBLE::_onDataWritten);
-  ticker.attach(this, &HspBLE::tickerHandler, 1);
+  ticker.attach(callback(this, &HspBLE::tickerHandler), 1);
 }
 
 void HspBLE::_onDataWritten(int index) {
@@ -141,7 +141,7 @@
     data[1] = LOW_BYTE(uShort);
   } break;
   case CHARACTERISTIC_ACCELEROMETER: {
-    int i;
+    unsigned int i;
     uint8_t *bytePtr;
     int16_t acclPtr[3];
     Peripherals::lis2dh()->get_motion_cached(&acclPtr[0], &acclPtr[1],
@@ -151,7 +151,7 @@
       data[i] = bytePtr[i];
   } break;
   case CHARACTERISTIC_PRESSURE: {
-    int i;
+    unsigned int i;
     uint8_t *bytePtr;
     float temperature;
     float pressure;
@@ -164,12 +164,12 @@
       data[i + sizeof(float)] = bytePtr[i];
   } break;
   case CHARACTERISTIC_HEARTRATE: {
-    int i;
+    unsigned int i;
     uint8_t *bytePtr;
-    MAX30001::max30001_t heartrateData;
-    Peripherals::max30001()->max30001_ReadHeartrateData(&heartrateData);
+    MAX30001::max30001_bledata_t heartrateData;
+    Peripherals::max30001()->ReadHeartrateData(&heartrateData);
     bytePtr = reinterpret_cast<uint8_t *>(&heartrateData);
-    for (i = 0; i < sizeof(MAX30001::max30001_t); i++)
+    for (i = 0; i < sizeof(MAX30001::max30001_bledata_t); i++)
       data[i] = bytePtr[i];
   } break;
   }
--- a/HSP/Interfaces/I2C_RPC.cpp	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/Interfaces/I2C_RPC.cpp	Fri Apr 21 12:12:30 2017 -0500
@@ -59,9 +59,7 @@
   ProcessArgs(argStrs, args, writeNumber + 4);
   readNumber = args[writeNumber + 3];
 
-  if (instance == 1) {
-    i2c = Peripherals::i2c1();
-  }
+  i2c = Peripherals::i2c1();
   if (instance == 2) {
     i2c = Peripherals::i2c2();
   }
--- a/HSP/LoggingService/DataLoggingService.cpp	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/LoggingService/DataLoggingService.cpp	Fri Apr 21 12:12:30 2017 -0500
@@ -31,6 +31,7 @@
  *******************************************************************************
  */
 #include "mbed.h"
+#include "USBSerial.h"
 #include "Logging.h"
 #include "Streaming.h"
 #include "RpcServer.h"
@@ -90,6 +91,8 @@
 } eStartEvent;
 static eStartEvent startEvent;
 
+extern USBSerial *usbSerialPtr;
+
 /**
 * @brief Sets a flag to start USB logging (streaming)
 */
@@ -173,7 +176,7 @@
 * @brief Process a RPC command that is pointed to.
 * @param cmd RPC string to process
 */
-void ProcessCmd(char *cmd) {
+void ProcessCmd(const char *cmd) {
   char cmd_[256];
   char reply[512];
   strcpy(cmd_, cmd);
@@ -213,7 +216,7 @@
 
     index = sramIndex - 256;
     ptr = &PingPong_SRAM[index];
-    sprintf(str, "currentPage=%d", currentPage);
+    sprintf(str, "currentPage=%lu", currentPage);
     Peripherals::s25FS512()->writePage_Helper(currentPage, ptr, 0);
 
     // this page is no longer dirty
@@ -240,7 +243,7 @@
   if (sram_buffer_1_dirty == 1) {
     ptr += 256;
   }
-  printf("_LoggingServer_WriteDirtySramBufferToFlash:%d,%d\n",
+  printf("_LoggingServer_WriteDirtySramBufferToFlash:%lu,%lu\n",
          sram_buffer_0_dirty, sram_buffer_1_dirty);
   fflush(stdout);
   // s25fs512_WritePage_Helper(currentPage, ptr, 0);
@@ -254,7 +257,7 @@
 static void _LoggingServer_OutputToCdcAcm(uint32_t fifoData) {
   uint8_t *ptr;
   uint8_t str[16];
-  sprintf((char *)str, "%X ", fifoData);
+  sprintf((char *)str, "%X ", (unsigned int)fifoData);
   ptr = str;
   usb_block_index = 0;
   while (*ptr != 0) {
@@ -262,7 +265,7 @@
     ptr++;
     usb_block_index++;
   }
-  Peripherals::usbSerial()->writeBlock(usb_block, usb_block_index);
+  usbSerialPtr->writeBlock(usb_block, usb_block_index);
 }
 
 /**
@@ -285,14 +288,14 @@
   // Log to CDCACM
   //
   result = true;
-  sprintf((char *)str, "%X ", fifoData);
+  sprintf((char *)str, "%X ", (unsigned int)fifoData);
   ptr = str;
   while (*ptr != 0) {
     usb_block[usb_block_index] = *ptr;
     ptr++;
     usb_block_index++;
     if (usb_block_index >= 64) {
-      result = Peripherals::usbSerial()->writeBlock(usb_block, 64);
+      result = usbSerialPtr->writeBlock(usb_block, 64);
       usb_block_index = 0;
     }
   }
@@ -305,7 +308,7 @@
 static void _LoggingServer_OutputToCdcAcm_End(void) {
   if (usb_block_index == 0)
     return;
-  Peripherals::usbSerial()->writeBlock(usb_block, usb_block_index - 1);
+  usbSerialPtr->writeBlock(usb_block, usb_block_index - 1);
 }
 
 /**
@@ -363,7 +366,7 @@
 uint8_t LoggingService_ServiceRoutine(void) {
   uint32_t fifoData;
   uint32_t endPage;
-  USBSerial *usbSerial = Peripherals::usbSerial();
+  //USBSerial *usbSerial = Peripherals::usbSerial();
   // BMP280 *bmp280 = Peripherals::bmp280();
   bool buttonPressed;
   int packetBurstCount = 0;
@@ -451,8 +454,8 @@
   ServiceNonInterrupt_Init();
   ServiceNonInterrupt_StartTimer();
 
-  while (usbSerial->readable()) {
-    usbSerial->_getc();
+  while (usbSerialPtr->readable()) {
+    usbSerialPtr->_getc();
   }
   fifo_clear(GetUSBIncomingFifo()); // clear USB serial incoming fifo
   fifo_clear(GetStreamOutFifo());
@@ -461,10 +464,10 @@
   sram_buffer_1_dirty = 0;
 
 
-	if (loggingOutput == eLogToNothing) printf("eLogToNothing..."); fflush(stdout);
-	if (loggingOutput == eLogToFlash) printf("eLogToFlash..."); fflush(stdout);
-	if (loggingOutput == eLogtoUsb) printf("eLogtoUsb..."); fflush(stdout);
-	printf("highDataRate=%d...",highDataRate); fflush(stdout);
+  if (loggingOutput == eLogToNothing) { printf("eLogToNothing..."); fflush(stdout); }
+	if (loggingOutput == eLogToFlash) { printf("eLogToFlash..."); fflush(stdout); }
+	if (loggingOutput == eLogtoUsb) { printf("eLogtoUsb..."); fflush(stdout); }
+	printf("highDataRate=%u...",(unsigned int)highDataRate); fflush(stdout);
 
 
   Peripherals::timestampTimer()->reset();
@@ -474,6 +477,7 @@
   while (1) {
     if (loggingOutput == eLogToFlash) {
       // check if we are at the end of flash
+      endPage = Logging_GetLoggingEndPage();
       if (currentPage >= endPage) {
         BlinkEndOfDatalogging(); // blink for 3 seconds to signal end of logging
         break;
@@ -502,13 +506,13 @@
 
     if (startEvent == eStartEvent_RPC_TO_USB ||
         startEvent == eStartEvent_RPC_TO_FLASH) {
-      if (usbSerial->available()) {
+      if (usbSerialPtr->available()) {
         if (loggingOutput == eLogToFlash) {
           _LoggingServer_WriteDirtySramBufferToFlash();
         }
         wait(0.2f);
-        while (usbSerial->available()) {
-          usbSerial->_getc();
+        while (usbSerialPtr->available()) {
+          usbSerialPtr->_getc();
         }
         fifo_clear(GetUSBIncomingFifo()); // clear USB serial incoming fifo
         fifo_clear(GetStreamOutFifo());
--- a/HSP/LoggingService/Logging.cpp	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/LoggingService/Logging.cpp	Fri Apr 21 12:12:30 2017 -0500
@@ -39,8 +39,7 @@
 /// length of flash page as dictated by the device
 #define LENGTH_OF_FLASH_PAGE 256 // length of flash page in bytes
 /// size in bytes of the external flash device on the HSP platform
-#define SIZE_OF_EXTERNAL_FLASH                                                 \
-  (16777216 / 2) // length of external flash in bytes
+#define SIZE_OF_EXTERNAL_FLASH  0x2000000 // 33,554,432 Bytes
 /// start page of where the mission is defined
 #define MISSION_DEFINITION_START_PAGE 0x00
 /// end page of the mission
@@ -48,7 +47,7 @@
 /// page of where the logging data starts
 #define LOGGING_START_PAGE 0x12
 /// the last logging page
-#define LOGGING_END_PAGE (SIZE_OF_EXTERNAL_FLASH / LENGTH_OF_FLASH_PAGE)
+#define LOGGING_END_PAGE ((SIZE_OF_EXTERNAL_FLASH / LENGTH_OF_FLASH_PAGE) - 1)
 
 /// static flag to know if logging was started via RPC
 static bool startLoggingViaRpc = false;
--- a/HSP/LoggingService/Logging_RPC.cpp	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/LoggingService/Logging_RPC.cpp	Fri Apr 21 12:12:30 2017 -0500
@@ -181,7 +181,7 @@
   currentSector = 0;
   printf("Logging_EraseWrittenSectors ");
   fflush(stdout);
-  printf("pageNumber %d 0x%X ", pageNumber, pageNumber);
+  printf("pageNumber %d 0x%X ", (unsigned int)pageNumber, (unsigned int)pageNumber);
   fflush(stdout);
   printf("SECTOR_SIZE_4K %d 0x%X ...", SECTOR_SIZE_4K, SECTOR_SIZE_4K);
   fflush(stdout);
@@ -251,7 +251,7 @@
   }
   if (page > lastPage)
     page = lastPage;
-  printf("last page %d, 0x%X ", page, page);
+  printf("last page %d, 0x%X ", (unsigned int)page, (unsigned int)page);
   fflush(stdout);
   reply[0] = page;
   FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs);
--- a/HSP/QuadSPI/QuadSpi.h	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/QuadSPI/QuadSpi.h	Fri Apr 21 12:12:30 2017 -0500
@@ -63,7 +63,7 @@
    *  @returns
    *    none
   */
-  int write(int value);
+  virtual int write(int value);
 
   /** Read from the Quad SPI Slave and return the response
    *
--- a/HSP/RpcServer/RpcServer.cpp	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/RpcServer/RpcServer.cpp	Fri Apr 21 12:12:30 2017 -0500
@@ -49,7 +49,7 @@
 #include "Device_Logging.h"
 
 /// define the version string that is reported with a RPC "ReadVer" command
-#define FW_VERSION_STRING "HSP FW Version 3.0.0 10/14/16"
+#define FW_VERSION_STRING "HSP FW Version 3.0.1 4/21/16"
 
 char args[32][32];
 char results[32][32];
@@ -94,7 +94,7 @@
 
 //******************************************************************************
 int System_SystemCoreClock(char argStrs[32][32], char replyStrs[32][32]) {
-  sprintf(replyStrs[0], "SystemCoreClock = %d", SystemCoreClock);
+  sprintf(replyStrs[0], "SystemCoreClock = %d", (unsigned int)SystemCoreClock);
   strcpy(replyStrs[1], "\0");
   return 0;
 }
@@ -283,7 +283,7 @@
 }
 
 //******************************************************************************
-int CheckForDoubleQuote(char *str) {
+int CheckForDoubleQuote(const char *str) {
   int doubleQuoteFound;
   // scan through arguments, see if there is a double quote for a string
   // argument
@@ -299,7 +299,7 @@
 }
 
 //******************************************************************************
-void ExtractDoubleQuoteStr(char *src, char *dst) {
+void ExtractDoubleQuoteStr(const char *src, char *dst) {
   int start;
 
   dst[0] = 0;
@@ -328,7 +328,7 @@
 void RPC_call_test(void) {
   int doubleQuoteFound;
   char doubleQuoteStr[64];
-  char *request = "/Logging/AppendMissionCmd \"BMP280 InitStart 1\"";
+  const char *request = "/Logging/AppendMissionCmd \"BMP280 InitStart 1\"";
 
   // scan through arguments, see if there is a double quote for a string
   // argument
@@ -351,6 +351,7 @@
   int resultIndex;
   int doubleQuoteFound;
   struct RPC_registeredProcedure *procedurePtr;
+  int callResult;
 
   // clear out the reply
   reply[0] = 0;
@@ -410,10 +411,11 @@
     strcpy(objectName, MAX30001_NAME);
   }
 
+  callResult = 0;
   procedurePtr = RPC_lookup(objectName, methodName);
   if (procedurePtr != NULL) {
     // printf("RPC_call: %s processing\n",requestCpy);
-    procedurePtr->func(args, results);
+    callResult = procedurePtr->func(args, results);
   } else {
     printf("RPC_call: %s not found\n", requestCpy);
     // printf("Unable to lookup %s %s", objectName, methodName);
@@ -422,11 +424,13 @@
   // loop while (if) there are results to return
   resultIndex = 0;
   strcpy(reply, "\0");
-  while (results[resultIndex][0] != '\0') {
-    strcat(reply, results[resultIndex++]);
-    strcat(reply, " ");
+  if (callResult != RPC_SKIP_CRLF) { 
+    while (results[resultIndex][0] != '\0') {
+      strcat(reply, results[resultIndex++]);
+      strcat(reply, " ");
+    }
+    strcat(reply, "\r\n");
   }
-  strcat(reply, "\r\n");
 }
 
 //******************************************************************************
--- a/HSP/RpcServer/StringHelper.cpp	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/RpcServer/StringHelper.cpp	Fri Apr 21 12:12:30 2017 -0500
@@ -87,9 +87,9 @@
 * @returns Returns the converted number of type uint32
 */
 uint32_t ParseAsciiDecU32(char *str) {
-  uint32_t val;
-  sscanf(str, "%d", &val);
-  return val;
+  unsigned int val;
+  sscanf(str, "%u", &val);
+  return (uint32_t)val;
 }
 
 /**
@@ -98,9 +98,9 @@
 * @returns Returns the converted number of type uint32
 */
 uint32_t ParseAsciiHexU32(char *str) {
-  uint32_t val;
+  unsigned int val;
   sscanf(str, "%x", &val);
-  return val;
+  return (uint32_t)val;
 }
 
 /**
@@ -119,12 +119,12 @@
   strPtr = str;
   start = 0;
   for (i = 0; i < numberOf; i++) {
-    if ((start == 0) && (*ptr == '/"')) {
+    if ((start == 0) && (*ptr == '\"')) {
       start = 1;
       ptr++;
       continue;
     }
-    if ((start == 1) && (*ptr == '/"')) {
+    if ((start == 1) && (*ptr == '\"')) {
       break;
     }
     if (start == 1) {
@@ -216,7 +216,7 @@
 void FormatReply32(uint32_t *uint32Ptr, int numberOf, char reply[32][32]) {
   int i;
   for (i = 0; i < numberOf; i++) {
-    sprintf(reply[i], "%02X", uint32Ptr[i]);
+    sprintf(reply[i], "%02X", (unsigned int)uint32Ptr[i]);
   }
   strcpy(reply[i], "\0");
 }
--- a/HSP/RpcServer/StringInOut.cpp	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/RpcServer/StringInOut.cpp	Fri Apr 21 12:12:30 2017 -0500
@@ -43,13 +43,15 @@
 /// a flag that keeps track of the state of accumulating a string
 static int getLine_State = GETLINE_WAITING;
 
+extern USBSerial *usbSerialPtr;
+
 /**
 * @brief Place incoming USB characters into a fifo
 * @param data_IN buffer of characters
 * @param len length of data
 */
 int fifoIncomingChars(uint8_t data_IN[], unsigned int len) {
-  int i;
+  unsigned int i;
   for (i = 0; i < len; i++) {
     fifo_put8(GetUSBIncomingFifo(), data_IN[i]);
   }
@@ -94,12 +96,12 @@
 int getLine(char *lineBuffer, int bufferLength) {
   uint8_t ch;
 
-  USBSerial *serial = Peripherals::usbSerial();
+  //USBSerial *serial = Peripherals::usbSerial();
   if (getLine_State == GETLINE_DONE) {
     getLine_State = GETLINE_WAITING;
   }
-  if (serial->available() != 0) {
-    ch = serial->_getc();
+  if (usbSerialPtr->available() != 0) {
+    ch = usbSerialPtr->_getc();
     if (ch != 0x0A && ch != 0x0D) {
       lineBuffer[lineBuffer_index++] = ch;
     }
@@ -135,61 +137,44 @@
 }
 
 /**
-* @brief Output a string out the USB serial port
-* @param str output this str the USB channel
-*/
-int putStr(const char *str) {
-  Peripherals::usbSerial()->printf("%s", str); // fflush(stdout);
-  // uint8_t *ptr;
-  // uint8_t buffer[256];
-  // int index = 0;
-  /*	int length;
-          ptr = (uint8_t *)str;
-          length = strlen(str);
-
-          Peripherals::usbSerial()->writeBlock(ptr,length);	*/
-  return 0;
-}
-
-/**
 * @brief Outut an array of bytes out the USB serial port
 * @param data buffer to output
 * @param length length of buffer
 */
 int putBytes(uint8_t *data, uint32_t length) {
-  int sendThis = 64;
-  int sent = 0;
-  int thisLeft;
-  uint8_t *ptr = data;
-  if (length < 64)
-    sendThis = length;
-  do {
-    Peripherals::usbSerial()->writeBlock(ptr, sendThis);
-    sent += sendThis;
-    ptr += sendThis;
-    thisLeft = length - sent;
-    sendThis = 64;
-    if (thisLeft < 64)
-      sendThis = thisLeft;
-  } while (sent != length);
+  int sent;
+  int send;
+  bool status;
+  uint8_t *ptr;
+  ptr = data;
+  //
+  // break up the string into chunks
+  //
+  sent = 0;
+  do { 
+    send = MAX_PACKET_SIZE_EPBULK;
+    if ((sent + MAX_PACKET_SIZE_EPBULK) > (int)length) {
+      send = length - sent;
+    }
+    status = usbSerialPtr->writeBlock(ptr,send);
+    if (status != true) {
+      while (1) ;
+    }
+    sent += send;
+    ptr += send;
+  } while (sent < (int)length);
   return 0;
 }
 
 /**
-* @brief Outut 256 byte blocks out the USB serial using writeBlock bulk
-* transfers
-* @param data buffer of blocks to output
-* @param length length of 256-byte blocks
+* @brief Output a string out the USB serial port
+* @param str to output
 */
-int putBytes256Block(uint8_t *data, int numberBlocks) {
-  int i;
+int putStr(const char *str) {
+  int length;
   uint8_t *ptr;
-  ptr = data;
-  const int BLOCK_SIZE = 32;
-  const int FLASH_PAGE_SIZE = 256;
-  for (i = 0; i < numberBlocks * (FLASH_PAGE_SIZE / BLOCK_SIZE); i++) {
-    Peripherals::usbSerial()->writeBlock(ptr, BLOCK_SIZE);
-    ptr += BLOCK_SIZE;
-  }
+  ptr = (uint8_t *)str;
+  length = strlen(str);
+  putBytes(ptr, length);
   return 0;
 }
--- a/HSP/RpcServer/StringInOut.h	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/RpcServer/StringInOut.h	Fri Apr 21 12:12:30 2017 -0500
@@ -34,7 +34,6 @@
 #define _STRINGINOUT_H_
 
 #include "mbed.h"
-#include "USBSerial.h"
 
 /// indicates that a string up to a CRLF is being accumulated
 #define GETLINE_WAITING 1
@@ -89,6 +88,6 @@
 * @param data buffer of blocks to output
 * @param length length of 256-byte blocks
 */
-int putBytes256Block(uint8_t *data, int numberBlocks);
+//int putBytes256Block(uint8_t *data, int numberBlocks);
 
 #endif // _STRINGINOUT_H_
--- a/HSP/System/Peripherals.cpp	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/System/Peripherals.cpp	Fri Apr 21 12:12:30 2017 -0500
@@ -34,7 +34,7 @@
 
 I2C *Peripherals::mI2c1 = NULL;
 I2C *Peripherals::mI2c2 = NULL;
-USBSerial *Peripherals::mUSBSerial = NULL;
+//USBSerial *Peripherals::mUSBSerial = NULL;
 MAX30101 *Peripherals::mMAX30101 = NULL;
 MAX30001 *Peripherals::mMAX30001 = NULL;
 BMP280 *Peripherals::mBMP280 = NULL;
--- a/HSP/System/Peripherals.h	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/System/Peripherals.h	Fri Apr 21 12:12:30 2017 -0500
@@ -34,7 +34,7 @@
 #define _PERIPHERALS_H_
 
 #include "mbed.h"
-#include "USBSerial.h"
+//#include "USBSerial.h"
 #include "MAX30101.h"
 #include "HspLed.h"
 #include "MAX30205.h"
@@ -54,8 +54,8 @@
 */
 class Peripherals {
 public:
-    static USBSerial *setUSBSerial(USBSerial * device) { mUSBSerial = device; return device; }
-    static USBSerial *usbSerial(void) { return mUSBSerial; }
+    //static USBSerial *setUSBSerial(USBSerial * device) { mUSBSerial = device; return device; }
+    //static USBSerial *usbSerial(void) { return mUSBSerial; }
 
     static MAX30101 *max30101(void) { return mMAX30101; }
     static MAX30101 *setMAX30101(MAX30101 *device) { mMAX30101 = device; return device; }
@@ -105,7 +105,7 @@
 private:
     static I2C *mI2c1;
     static I2C *mI2c2;
-    static USBSerial *mUSBSerial;
+    //static USBSerial *mUSBSerial;
     static MAX30101 *mMAX30101;
     static MAX30001 *mMAX30001;
     static BMP280 *mBMP280;
--- a/HSP/Test/Test_BMP280.cpp	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/Test/Test_BMP280.cpp	Fri Apr 21 12:12:30 2017 -0500
@@ -47,7 +47,7 @@
   // read id test
   outputString("Read ID: ");
   readId = bmp280->ReadId();
-  if (readId == BMP280_READID)
+  if (readId == BMP280::BMP280_READID)
     pass = 1;
   else
     pass = 0;
--- a/HSP/Test/Test_BMP280.h	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/Test/Test_BMP280.h	Fri Apr 21 12:12:30 2017 -0500
@@ -43,4 +43,4 @@
 */
 void test_BMP280(void (*outputString)(const char *));
 
-#endif / _TEST_BMP280_H_ */
+#endif // _TEST_BMP280_H_ 
--- a/HSP/Test/Test_LIS2DH.cpp	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/Test/Test_LIS2DH.cpp	Fri Apr 21 12:12:30 2017 -0500
@@ -48,7 +48,7 @@
   // read id test @ 400kHz
   outputString("Read ID @ 400kHz: ");
   readId = lis2dh->readId();
-  if (readId == LIS2DH_READID)
+  if (readId == LIS2DH::LIS2DH_READID)
     pass = 1;
   else
     pass = 0;
--- a/HSP/Test/Test_MAX30001.cpp	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/Test/Test_MAX30001.cpp	Fri Apr 21 12:12:30 2017 -0500
@@ -35,11 +35,11 @@
 
 uint32_t testing_max30001 = 0;
 uint32_t testing_ecg_flags[4];
+#define TESTING_TIMEOUT_SECONDS 10
 
 //******************************************************************************
 void test_MAX30001(void (*outputString)(const char *)) {
   int totalPass = 1;
-  int pass;
   uint32_t foundEcg = 0;
   uint32_t foundBioz = 0;
   uint32_t foundPace = 0;
@@ -55,9 +55,9 @@
   max30001 = Peripherals::max30001();
 
   // read the id
-  max30001->max30001_reg_read(MAX30001::INFO, &id);
+  max30001->reg_read(MAX30001::INFO, &id);
   // read id twice because it needs to be read twice
-  max30001->max30001_reg_read(MAX30001::INFO, &id);
+  max30001->reg_read(MAX30001::INFO, &id);
   partVersion = id >> 12;
   partVersion = partVersion & 0x3;
 
@@ -74,7 +74,7 @@
     outputString("Testing MAX30003|");
     outputString("Only Testing ECG and RtoR|");
   }
-  sprintf(str2, "Device ID = 0x%06X|", id);
+  sprintf(str2, "Device ID = 0x%06X|", (unsigned int)id);
   outputString(str2);
 
   // clear testing flags
@@ -91,21 +91,21 @@
   if (partVersion == 3)
     outputString(
         "Start Streaming ECG, RtoR, CAL enabled, verifying streams...|");
-  // max30001_CAL_InitStart(0b1, 0b1, 0b1, 0b011, 0x7FF, 0b0);
-  max30001->max30001_CAL_InitStart(0b1, 0b1, 0b1, 0b011, 0x7FF, 0b0);
-  max30001->max30001_ECG_InitStart(0b1, 0b1, 0b1, 0b0, 0b10, 0b11, 0x1F, 0b00,
+  // CAL_InitStart(0b1, 0b1, 0b1, 0b011, 0x7FF, 0b0);
+  max30001->CAL_InitStart(0b1, 0b1, 0b1, 0b011, 0x7FF, 0b0);
+  max30001->ECG_InitStart(0b1, 0b1, 0b1, 0b0, 0b10, 0b11, 0x1F, 0b00,
                                    0b00, 0b0, 0b01);
   if (partVersion == 1)
-    max30001->max30001_PACE_InitStart(0b1, 0b0, 0b0, 0b1, 0x0, 0b0, 0b00, 0b0,
+    max30001->PACE_InitStart(0b1, 0b0, 0b0, 0b1, 0x0, 0b0, 0b00, 0b0,
                                       0b0);
   if (partVersion == 1)
-    max30001->max30001_BIOZ_InitStart(0b1, 0b1, 0b1, 0b10, 0b11, 0b00, 7, 0b0,
+    max30001->BIOZ_InitStart(0b1, 0b1, 0b1, 0b10, 0b11, 0b00, 7, 0b0,
                                       0b010, 0b0, 0b10, 0b00, 0b00, 2, 0b0,
                                       0b111, 0b0000);
-  max30001->max30001_RtoR_InitStart(0b1, 0b0011, 0b1111, 0b00, 0b0011, 0b000001,
+  max30001->RtoR_InitStart(0b1, 0b0011, 0b1111, 0b00, 0b0011, 0b000001,
                                     0b00, 0b000, 0b01);
-  max30001->max30001_Rbias_FMSTR_Init(0b01, 0b10, 0b1, 0b1, 0b00);
-  max30001->max30001_synch();
+  max30001->Rbias_FMSTR_Init(0b01, 0b10, 0b1, 0b1, 0b00);
+  max30001->synch();
 
   // look for each stream
   timer.start();
@@ -133,35 +133,35 @@
     if ((foundEcg == 1) && (foundRtoR == 1) && (partVersion == 3)) {
       break;
     }
-    if (timer.read() >= TESTING_MAX30001_TIMEOUT_SECONDS) {
+    if (timer.read() >= TESTING_TIMEOUT_SECONDS) {
       break;
     }
   }
   timer.stop();
   if (foundEcg == 0) {
     outputString("ECG Stream: FAIL|");
-    totalPass &= pass;
+    totalPass = 0;
   }
   if ((foundBioz == 0) && (partVersion == 1)) {
     outputString("Bioz Stream: FAIL|");
-    totalPass &= pass;
+    totalPass = 0;
   }
   if ((foundPace == 0) && (partVersion == 1)) {
     outputString("PACE Stream: FAIL|");
-    totalPass &= pass;
+    totalPass = 0;
   }
   if (foundRtoR == 0) {
     outputString("RtoR Stream: FAIL|");
-    totalPass &= pass;
+    totalPass = 0;
   }
 
   // stop all streams
-  max30001->max30001_Stop_ECG();
+  max30001->Stop_ECG();
   if (partVersion == 1)
-    max30001->max30001_Stop_PACE();
+    max30001->Stop_PACE();
   if (partVersion == 1)
-    max30001->max30001_Stop_BIOZ();
-  max30001->max30001_Stop_RtoR();
+    max30001->Stop_BIOZ();
+  max30001->Stop_RtoR();
   testing_max30001 = 0;
   // final results
   outputString("Result: ");
--- a/HSP/Test/Test_MAX30101.cpp	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/Test/Test_MAX30101.cpp	Fri Apr 21 12:12:30 2017 -0500
@@ -40,7 +40,6 @@
 void test_MAX30101(void (*outputString)(const char *)) {
   Timer timer;
   int totalPass = 1;
-  int pass;
   uint32_t foundHR = 0;
   uint32_t foundSPO2 = 0;
   uint32_t foundMULTI = 0;
@@ -77,7 +76,7 @@
   }
   if (foundHR == 0) {
     outputString("HR Stream: FAIL|");
-    totalPass &= pass;
+    totalPass = 0;
   }
   // stop stream
   max30101->HRmode_stop();
@@ -103,7 +102,7 @@
   }
   if (foundSPO2 == 0) {
     outputString("SPO2 Stream: FAIL|");
-    totalPass &= pass;
+    totalPass = 0;
   }
   // stop stream
   max30101->SpO2mode_stop();
@@ -129,7 +128,7 @@
   }
   if (foundMULTI == 0) {
     outputString("Multi Stream: FAIL|");
-    totalPass &= pass;
+    totalPass = 0;
   }
   // stop stream
   max30101->Multimode_stop();
--- a/HSP/Test/Test_S25FS512.cpp	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/Test/Test_S25FS512.cpp	Fri Apr 21 12:12:30 2017 -0500
@@ -33,13 +33,17 @@
 #include "Test_S25FS512.h"
 #include "Test_Utilities.h"
 
+
+#define SIZE_OF_EXTERNAL_FLASH  0x2000000 // 33,554,432 Bytes
+/// number of pages 
+#define NUMBER_OF_PAGES ((SIZE_OF_EXTERNAL_FLASH / 256) - 1)
+
 //******************************************************************************
 void test_S25FS512(void (*outputString)(const char *)) {
   char tempStr[32];
   uint8_t page[264];
   int totalPass = 1;
   int pass;
-  int status;
   int i;
   uint8_t data[128];
   S25FS512 *s25FS512;
@@ -64,6 +68,7 @@
   sprintf(tempStr, "(%02X%02X%02X%02X)|", data[1], data[2], data[3], data[4]);
   outputString(tempStr);
 
+  
   if (totalPass == 1) {
     // format sector 0
     outputString("Formatting Sector 0, ");
@@ -76,9 +81,9 @@
     _printPassFail(pass, 1, outputString);
     totalPass &= pass;
 
-    // fill page with pattern
+    // fill page with random pattern
     for (i = 0; i < 256; i++) {
-      page[i] = i;
+      page[i] =  i;
     }
     // write to page 0
     outputString("Writing Page 0 to pattern, ");
--- a/HSP/main.cpp	Tue Oct 25 15:22:11 2016 +0000
+++ b/HSP/main.cpp	Fri Apr 21 12:12:30 2017 -0500
@@ -114,6 +114,7 @@
 
 /// HSP BluetoothLE specific functions
 HspBLE hspBLE(&ble);
+USBSerial *usbSerialPtr;
 
 int main() {
   // hold results for returning funtcoins
@@ -162,7 +163,7 @@
   Peripherals::setMAX30205_bottom(&MAX30205_bottom);
   Peripherals::setBMP280(&bmp280);
   Peripherals::setLIS2DH(&lis2dh);
-  Peripherals::setUSBSerial(&usbSerial);
+  //Peripherals::setUSBSerial(&usbSerial);
   Peripherals::setTimestampTimer(&timestampTimer);
   Peripherals::setHspLed(&hspLed);
   Peripherals::setMAX30101(&max30101);
@@ -173,6 +174,7 @@
   Peripherals::setMAX14720(&max14720);
   Peripherals::setMAX30001(&max30001);
   Peripherals::setHspBLE(&hspBLE);
+  usbSerialPtr = &usbSerial;
 
   // init the S25FS256 external flash device
   printf("Init S25FS512...\n");
@@ -200,7 +202,7 @@
   fflush(stdout);
   max30101.onInterrupt(&MAX30101_OnInterrupt);
   max30101.onDataAvailable(&StreamPacketUint32);
-  max30101_Interrupt.fall(&MAX30101MidIntHandler);
+  max30101_Interrupt.fall(&MAX30101::MidIntHandler);
 
   //
   // MAX30001
@@ -210,19 +212,20 @@
   max30001_InterruptB.disable_irq();
   max30001_Interrupt2B.disable_irq();
   max30001_InterruptB.mode(PullUp);
-  max30001_InterruptB.fall(&MAX30001Mid_IntB_Handler);
+  max30001_InterruptB.fall(&MAX30001::Mid_IntB_Handler);
   max30001_Interrupt2B.mode(PullUp);
-  max30001_Interrupt2B.fall(&MAX30001Mid_Int2B_Handler);
+  max30001_Interrupt2B.fall(&MAX30001::Mid_Int2B_Handler);
   max30001_InterruptB.enable_irq();
   max30001_Interrupt2B.enable_irq();
-  MAX30001_AllowInterrupts(1);
+  max30001.AllowInterrupts(1);
   // Configuring the FCLK for the ECG, set to 32.768KHZ
   printf("Init MAX30001 PWM...\n");
   fflush(stdout);
-  pwmout.period_us(31);
-  pwmout.write(0.5);          // 0-1 is 0-100%, 0.5 = 50% duty cycle.
-  max30001.max30001_sw_rst(); // Do a software reset of the MAX30001
-    max30001.max30001_INT_assignment(MAX30001::MAX30001_INT_B,    MAX30001::MAX30001_NO_INT,   MAX30001::MAX30001_NO_INT,  //  en_enint_loc,      en_eovf_loc,   en_fstint_loc,
+  //pwmout.period_us(31);      
+  //pwmout.write(0.5);          // 0-1 is 0-100%, 0.5 = 50% duty cycle.
+  max30001.FCLK_MaximOnly();    // mbed does not provide the resolution necessary, so for now we have a specific solution...
+  max30001.sw_rst(); // Do a software reset of the MAX30001
+  max30001.INT_assignment(MAX30001::MAX30001_INT_B,    MAX30001::MAX30001_NO_INT,   MAX30001::MAX30001_NO_INT,  //  en_enint_loc,      en_eovf_loc,   en_fstint_loc,
                                      MAX30001::MAX30001_INT_2B,   MAX30001::MAX30001_INT_2B,   MAX30001::MAX30001_NO_INT,  //  en_dcloffint_loc,  en_bint_loc,   en_bovf_loc,
                                      MAX30001::MAX30001_INT_2B,   MAX30001::MAX30001_INT_2B,   MAX30001::MAX30001_NO_INT,  //  en_bover_loc,      en_bundr_loc,  en_bcgmon_loc,
                                      MAX30001::MAX30001_INT_B,    MAX30001::MAX30001_NO_INT,   MAX30001::MAX30001_NO_INT,  //  en_pint_loc,       en_povf_loc,   en_pedge_loc,