MAX32620HSP (MAXREFDES100) RPC Example for Graphical User Interface
Dependencies: USBDevice
Fork of HSP_Release by
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.
Diff: HSP/Devices/LIS2DH/LIS2DH/LIS2DH.h
- Revision:
- 1:9490836294ea
- Parent:
- 0:e4a10ed6eb92
--- 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;
};
