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.

Revision:
1:9490836294ea
Parent:
0:e4a10ed6eb92
--- 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;
 };