Maxim Integrated / Mbed OS MAXREFDES220_HEART_RATE_MONITOR

Dependencies:   USBDevice max32630fthr

Fork of MAXREFDES220# by Maxim Integrated

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MaximSensor.h Source File

MaximSensor.h

00001 /*******************************************************************************
00002 * Copyright (C) 2017 Maxim Integrated Products, Inc., All Rights Reserved.
00003 *
00004 * Permission is hereby granted, free of charge, to any person obtaining a
00005 * copy of this software and associated documentation files (the "Software"),
00006 * to deal in the Software without restriction, including without limitation
00007 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00008 * and/or sell copies of the Software, and to permit persons to whom the
00009 * Software is furnished to do so, subject to the following conditions:
00010 *
00011 * The above copyright notice and this permission notice shall be included
00012 * in all copies or substantial portions of the Software.
00013 *
00014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00015 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00016 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00017 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
00018 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00019 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00020 * OTHER DEALINGS IN THE SOFTWARE.
00021 *
00022 * Except as contained in this notice, the name of Maxim Integrated
00023 * Products, Inc. shall not be used except as stated in the Maxim Integrated
00024 * Products, Inc. Branding Policy.
00025 *
00026 * The mere transfer of this software does not imply any licenses
00027 * of trade secrets, proprietary technology, copyrights, patents,
00028 * trademarks, maskwork rights, or any other form of intellectual
00029 * property whatsoever. Maxim Integrated Products, Inc. retains all
00030 * ownership rights.
00031 *******************************************************************************
00032 */
00033 
00034 #ifndef _MAXIMSENSOR_H_
00035 #define _MAXIMSENSOR_H_
00036 #include "mbed.h"
00037 #include <list>
00038 
00039 
00040 typedef struct {
00041     uint8_t addr;
00042     uint32_t val;
00043 } addr_val_pair;
00044 
00045 
00046 /**
00047  * @brief   MaximSensor is Maxim Sensor base class.
00048  * @details MaximSensor includes base functions for to create new
00049  *  sensor classes. All sensor classes should implement this class.
00050  */
00051 class MaximSensor
00052 {
00053 public:
00054     /* PUBLIC FUNCTION DECLARATIONS */
00055     /**
00056     * @brief    Reads from register.
00057     * @details  Reads specific Maxim Sensor register via SPI bus.
00058     *
00059     * @param[in]    reg Beginning address of a register to be read.
00060     * @param[out]   data Buffer space to save result value.
00061     * @param[in]    len Number of consecutive bytes to be read.
00062     *
00063     * @returns  0 on success, negative error code on failure.
00064     */
00065     virtual int readRegister(uint8_t reg, uint8_t *data, int len);
00066 
00067     /**
00068     * @brief    Writes data to Maxim Sensor register.
00069     * @details  Writes data to specific Maxim Sensor register via SPI bus.
00070     *
00071     * @param[in]    reg Address of a register to be wrote.
00072     * @param[in]    data Data to write on register.
00073     *
00074     * @returns  0 on success, negative error code on failure.
00075     */
00076     virtual int writeRegister(uint8_t reg,  const uint8_t data);
00077 
00078     /**
00079     * @brief    Get Maxim Sensor part and revision info.
00080     * @details  Reads Maxim Sensor part and revision info from device.
00081     *
00082     * @param[in]    reg Beginning address of a register to be read.
00083     * @param[out]   data Buffer space to save result value.
00084     * @param[in]    len Number of consecutive bytes to be read.
00085     *
00086     * @returns  0 on success, negative error code on failure.
00087     */
00088     virtual int get_part_info(uint8_t *part_id, uint8_t *rev_id);
00089 
00090     /**
00091     * @brief    Enables Maxim Sensor.
00092     * @details  Enable IRQ, enable LEDs, enable AGC
00093     *
00094     * @param[in]    enable Any value to enable, 0 to disable.
00095     *
00096     * @returns  0 on success, negative error code on failure.
00097     */
00098     virtual int sensor_enable(int enable);
00099 
00100     /**
00101     * @brief    Enables AGC.
00102     * @details  Enable Maxim Sensor automatic gain controller.
00103     *   AGC automatically adjusts sampling rates and LED currents to save energy.
00104     *
00105     * @param[in]    agc_enable Any value to enable, 0 to disable.
00106     *
00107     * @returns  0 on success, negative error code on failure.
00108     */
00109     virtual int agc_enable(int agc_enable);
00110 
00111     /**
00112     * @brief    Get sensor part name.
00113     *
00114     * @returns  Sensor part name string.
00115     */
00116     virtual const char *get_sensor_part_name();
00117 
00118     /**
00119     * @brief    Get sensor name.
00120     *
00121     * @returns  Sensor name string.
00122     */
00123     virtual const char *get_sensor_name();
00124 
00125     /**
00126     * @brief    Dump Maxim Sensor registers.
00127     * @details  Print all Maxim Sensor register addresses and containing values.
00128     *
00129     * @param[in]    reg_values Pointer to array of 256 addr_val_pairs
00130     * @returns  0 on success, negative error code on failure.
00131     */
00132     virtual int dump_registers(addr_val_pair *reg_values)=0;
00133 
00134     // *********************** Maxim Sensor ECG Max30001 related functions ***********************
00135     virtual int MS_Max30001_ECG_InitStart(uint8_t En_ecg, uint8_t Openp, uint8_t Openn,
00136                          uint8_t Pol, uint8_t Calp_sel, uint8_t Caln_sel,
00137                                          uint8_t E_fit, uint8_t Rate, uint8_t Gain,
00138                                          uint8_t Dhpf, uint8_t Dlpf);
00139 
00140     virtual int MS_Max30001_ECG_Stop();
00141 
00142     // ECG Max30001 RtoR Initialization Function
00143     virtual  int MS_Max30001_RtoR_InitStart(uint8_t En_rtor, uint8_t Wndw, uint8_t Gain,
00144             uint8_t Pavg, uint8_t Ptsf, uint8_t Hoff,
00145             uint8_t Ravg, uint8_t Rhsf, uint8_t Clr_rrint);
00146 
00147     virtual int MS_Max30001_RtoR_Stop();
00148 
00149     // Max30001 Interrupt Assignment Function
00150     virtual int MS_max30001_INT_assignment(uint8_t en_enint_loc,     uint8_t en_eovf_loc,  uint8_t en_fstint_loc,
00151                                            uint8_t en_dcloffint_loc, uint8_t en_bint_loc,  uint8_t en_bovf_loc,
00152                                            uint8_t en_bover_loc,     uint8_t en_bundr_loc, uint8_t en_bcgmon_loc,
00153                                            uint8_t en_pint_loc,      uint8_t en_povf_loc,  uint8_t en_pedge_loc,
00154                                            uint8_t en_lonint_loc,    uint8_t en_rrint_loc, uint8_t en_samp_loc,
00155                                            uint8_t intb_Type,        uint8_t int2b_Type);
00156 
00157     virtual int MS_max30001readRegister(uint8_t addr, uint32_t *return_data);
00158 
00159     virtual int MS_max30001writeRegister(uint8_t addr, uint32_t data);
00160 
00161     virtual int MS_max30001sync();
00162 
00163     // *********************** end of Maxim Sensor ECG Max30001 related functions ****************
00164 
00165 
00166 
00167     // *********************** Max30205 related functions ***********************
00168 
00169 
00170     // *********************** end of Max30205 related functions ****************
00171 
00172 
00173 };
00174 
00175 #endif /* _MAXIMSENSOR_H_ */