TEST
Dependencies: max32630fthr Adafruit_FeatherOLED USBDevice
Drivers/MaximSensor/MaximSensor.h@4:291477e8690d, 2020-04-19 (annotated)
- Committer:
- wwwarunraj
- Date:
- Sun Apr 19 11:19:57 2020 +0000
- Revision:
- 4:291477e8690d
- Parent:
- 1:f60eafbf009a
19/04
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gmehmet | 1:f60eafbf009a | 1 | /******************************************************************************* |
gmehmet | 1:f60eafbf009a | 2 | * Copyright (C) 2017 Maxim Integrated Products, Inc., All Rights Reserved. |
gmehmet | 1:f60eafbf009a | 3 | * |
gmehmet | 1:f60eafbf009a | 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
gmehmet | 1:f60eafbf009a | 5 | * copy of this software and associated documentation files (the "Software"), |
gmehmet | 1:f60eafbf009a | 6 | * to deal in the Software without restriction, including without limitation |
gmehmet | 1:f60eafbf009a | 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
gmehmet | 1:f60eafbf009a | 8 | * and/or sell copies of the Software, and to permit persons to whom the |
gmehmet | 1:f60eafbf009a | 9 | * Software is furnished to do so, subject to the following conditions: |
gmehmet | 1:f60eafbf009a | 10 | * |
gmehmet | 1:f60eafbf009a | 11 | * The above copyright notice and this permission notice shall be included |
gmehmet | 1:f60eafbf009a | 12 | * in all copies or substantial portions of the Software. |
gmehmet | 1:f60eafbf009a | 13 | * |
gmehmet | 1:f60eafbf009a | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
gmehmet | 1:f60eafbf009a | 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
gmehmet | 1:f60eafbf009a | 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
gmehmet | 1:f60eafbf009a | 17 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
gmehmet | 1:f60eafbf009a | 18 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
gmehmet | 1:f60eafbf009a | 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
gmehmet | 1:f60eafbf009a | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
gmehmet | 1:f60eafbf009a | 21 | * |
gmehmet | 1:f60eafbf009a | 22 | * Except as contained in this notice, the name of Maxim Integrated |
gmehmet | 1:f60eafbf009a | 23 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
gmehmet | 1:f60eafbf009a | 24 | * Products, Inc. Branding Policy. |
gmehmet | 1:f60eafbf009a | 25 | * |
gmehmet | 1:f60eafbf009a | 26 | * The mere transfer of this software does not imply any licenses |
gmehmet | 1:f60eafbf009a | 27 | * of trade secrets, proprietary technology, copyrights, patents, |
gmehmet | 1:f60eafbf009a | 28 | * trademarks, maskwork rights, or any other form of intellectual |
gmehmet | 1:f60eafbf009a | 29 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
gmehmet | 1:f60eafbf009a | 30 | * ownership rights. |
gmehmet | 1:f60eafbf009a | 31 | ******************************************************************************* |
gmehmet | 1:f60eafbf009a | 32 | */ |
gmehmet | 1:f60eafbf009a | 33 | |
gmehmet | 1:f60eafbf009a | 34 | #ifndef _MAXIMSENSOR_H_ |
gmehmet | 1:f60eafbf009a | 35 | #define _MAXIMSENSOR_H_ |
gmehmet | 1:f60eafbf009a | 36 | #include "mbed.h" |
gmehmet | 1:f60eafbf009a | 37 | #include <list> |
gmehmet | 1:f60eafbf009a | 38 | |
gmehmet | 1:f60eafbf009a | 39 | |
gmehmet | 1:f60eafbf009a | 40 | typedef struct { |
gmehmet | 1:f60eafbf009a | 41 | uint8_t addr; |
gmehmet | 1:f60eafbf009a | 42 | uint32_t val; |
gmehmet | 1:f60eafbf009a | 43 | } addr_val_pair; |
gmehmet | 1:f60eafbf009a | 44 | |
gmehmet | 1:f60eafbf009a | 45 | |
gmehmet | 1:f60eafbf009a | 46 | /** |
gmehmet | 1:f60eafbf009a | 47 | * @brief MaximSensor is Maxim Sensor base class. |
gmehmet | 1:f60eafbf009a | 48 | * @details MaximSensor includes base functions for to create new |
gmehmet | 1:f60eafbf009a | 49 | * sensor classes. All sensor classes should implement this class. |
gmehmet | 1:f60eafbf009a | 50 | */ |
gmehmet | 1:f60eafbf009a | 51 | class MaximSensor |
gmehmet | 1:f60eafbf009a | 52 | { |
gmehmet | 1:f60eafbf009a | 53 | public: |
gmehmet | 1:f60eafbf009a | 54 | /* PUBLIC FUNCTION DECLARATIONS */ |
gmehmet | 1:f60eafbf009a | 55 | /** |
gmehmet | 1:f60eafbf009a | 56 | * @brief Reads from register. |
gmehmet | 1:f60eafbf009a | 57 | * @details Reads specific Maxim Sensor register via SPI bus. |
gmehmet | 1:f60eafbf009a | 58 | * |
gmehmet | 1:f60eafbf009a | 59 | * @param[in] reg Beginning address of a register to be read. |
gmehmet | 1:f60eafbf009a | 60 | * @param[out] data Buffer space to save result value. |
gmehmet | 1:f60eafbf009a | 61 | * @param[in] len Number of consecutive bytes to be read. |
gmehmet | 1:f60eafbf009a | 62 | * |
gmehmet | 1:f60eafbf009a | 63 | * @returns 0 on success, negative error code on failure. |
gmehmet | 1:f60eafbf009a | 64 | */ |
gmehmet | 1:f60eafbf009a | 65 | virtual int readRegister(uint8_t reg, uint8_t *data, int len); |
gmehmet | 1:f60eafbf009a | 66 | |
gmehmet | 1:f60eafbf009a | 67 | /** |
gmehmet | 1:f60eafbf009a | 68 | * @brief Writes data to Maxim Sensor register. |
gmehmet | 1:f60eafbf009a | 69 | * @details Writes data to specific Maxim Sensor register via SPI bus. |
gmehmet | 1:f60eafbf009a | 70 | * |
gmehmet | 1:f60eafbf009a | 71 | * @param[in] reg Address of a register to be wrote. |
gmehmet | 1:f60eafbf009a | 72 | * @param[in] data Data to write on register. |
gmehmet | 1:f60eafbf009a | 73 | * |
gmehmet | 1:f60eafbf009a | 74 | * @returns 0 on success, negative error code on failure. |
gmehmet | 1:f60eafbf009a | 75 | */ |
gmehmet | 1:f60eafbf009a | 76 | virtual int writeRegister(uint8_t reg, const uint8_t data); |
gmehmet | 1:f60eafbf009a | 77 | |
gmehmet | 1:f60eafbf009a | 78 | /** |
gmehmet | 1:f60eafbf009a | 79 | * @brief Get Maxim Sensor part and revision info. |
gmehmet | 1:f60eafbf009a | 80 | * @details Reads Maxim Sensor part and revision info from device. |
gmehmet | 1:f60eafbf009a | 81 | * |
gmehmet | 1:f60eafbf009a | 82 | * @param[in] reg Beginning address of a register to be read. |
gmehmet | 1:f60eafbf009a | 83 | * @param[out] data Buffer space to save result value. |
gmehmet | 1:f60eafbf009a | 84 | * @param[in] len Number of consecutive bytes to be read. |
gmehmet | 1:f60eafbf009a | 85 | * |
gmehmet | 1:f60eafbf009a | 86 | * @returns 0 on success, negative error code on failure. |
gmehmet | 1:f60eafbf009a | 87 | */ |
gmehmet | 1:f60eafbf009a | 88 | virtual int get_part_info(uint8_t *part_id, uint8_t *rev_id); |
gmehmet | 1:f60eafbf009a | 89 | |
gmehmet | 1:f60eafbf009a | 90 | /** |
gmehmet | 1:f60eafbf009a | 91 | * @brief Enables Maxim Sensor. |
gmehmet | 1:f60eafbf009a | 92 | * @details Enable IRQ, enable LEDs, enable AGC |
gmehmet | 1:f60eafbf009a | 93 | * |
gmehmet | 1:f60eafbf009a | 94 | * @param[in] enable Any value to enable, 0 to disable. |
gmehmet | 1:f60eafbf009a | 95 | * |
gmehmet | 1:f60eafbf009a | 96 | * @returns 0 on success, negative error code on failure. |
gmehmet | 1:f60eafbf009a | 97 | */ |
gmehmet | 1:f60eafbf009a | 98 | virtual int sensor_enable(int enable); |
gmehmet | 1:f60eafbf009a | 99 | |
gmehmet | 1:f60eafbf009a | 100 | /** |
gmehmet | 1:f60eafbf009a | 101 | * @brief Enables AGC. |
gmehmet | 1:f60eafbf009a | 102 | * @details Enable Maxim Sensor automatic gain controller. |
gmehmet | 1:f60eafbf009a | 103 | * AGC automatically adjusts sampling rates and LED currents to save energy. |
gmehmet | 1:f60eafbf009a | 104 | * |
gmehmet | 1:f60eafbf009a | 105 | * @param[in] agc_enable Any value to enable, 0 to disable. |
gmehmet | 1:f60eafbf009a | 106 | * |
gmehmet | 1:f60eafbf009a | 107 | * @returns 0 on success, negative error code on failure. |
gmehmet | 1:f60eafbf009a | 108 | */ |
gmehmet | 1:f60eafbf009a | 109 | virtual int agc_enable(int agc_enable); |
gmehmet | 1:f60eafbf009a | 110 | |
gmehmet | 1:f60eafbf009a | 111 | /** |
gmehmet | 1:f60eafbf009a | 112 | * @brief Get sensor part name. |
gmehmet | 1:f60eafbf009a | 113 | * |
gmehmet | 1:f60eafbf009a | 114 | * @returns Sensor part name string. |
gmehmet | 1:f60eafbf009a | 115 | */ |
gmehmet | 1:f60eafbf009a | 116 | virtual const char *get_sensor_part_name(); |
gmehmet | 1:f60eafbf009a | 117 | |
gmehmet | 1:f60eafbf009a | 118 | /** |
gmehmet | 1:f60eafbf009a | 119 | * @brief Get sensor algorithm version. |
gmehmet | 1:f60eafbf009a | 120 | * |
gmehmet | 1:f60eafbf009a | 121 | * @returns Sensor algorithm version string. |
gmehmet | 1:f60eafbf009a | 122 | */ |
gmehmet | 1:f60eafbf009a | 123 | virtual const char *get_sensor_algo_ver(); |
gmehmet | 1:f60eafbf009a | 124 | |
gmehmet | 1:f60eafbf009a | 125 | /** |
gmehmet | 1:f60eafbf009a | 126 | * @brief Get sensor name. |
gmehmet | 1:f60eafbf009a | 127 | * |
gmehmet | 1:f60eafbf009a | 128 | * @returns Sensor name string. |
gmehmet | 1:f60eafbf009a | 129 | */ |
gmehmet | 1:f60eafbf009a | 130 | virtual const char *get_sensor_name(); |
gmehmet | 1:f60eafbf009a | 131 | |
gmehmet | 1:f60eafbf009a | 132 | /** |
gmehmet | 1:f60eafbf009a | 133 | * @brief Get sensor ID. |
gmehmet | 1:f60eafbf009a | 134 | * |
gmehmet | 1:f60eafbf009a | 135 | * @returns Sensor ID number. |
gmehmet | 1:f60eafbf009a | 136 | */ |
gmehmet | 1:f60eafbf009a | 137 | virtual unsigned char get_sensor_id(); |
gmehmet | 1:f60eafbf009a | 138 | |
gmehmet | 1:f60eafbf009a | 139 | /** |
gmehmet | 1:f60eafbf009a | 140 | * @brief Dump Maxim Sensor registers. |
gmehmet | 1:f60eafbf009a | 141 | * @details Print all Maxim Sensor register addresses and containing values. |
gmehmet | 1:f60eafbf009a | 142 | * |
gmehmet | 1:f60eafbf009a | 143 | * @param[in] reg_values Pointer to array of 256 addr_val_pairs |
gmehmet | 1:f60eafbf009a | 144 | * @returns 0 on success, negative error code on failure. |
gmehmet | 1:f60eafbf009a | 145 | */ |
gmehmet | 1:f60eafbf009a | 146 | virtual int dump_registers(addr_val_pair *reg_values)=0; |
gmehmet | 1:f60eafbf009a | 147 | |
gmehmet | 1:f60eafbf009a | 148 | // *********************** Maxim Sensor ECG Max30001 related functions *********************** |
gmehmet | 1:f60eafbf009a | 149 | virtual int MS_Max30001_ECG_InitStart(uint8_t En_ecg, uint8_t Openp, uint8_t Openn, |
gmehmet | 1:f60eafbf009a | 150 | uint8_t Pol, uint8_t Calp_sel, uint8_t Caln_sel, |
gmehmet | 1:f60eafbf009a | 151 | uint8_t E_fit, uint8_t Rate, uint8_t Gain, |
gmehmet | 1:f60eafbf009a | 152 | uint8_t Dhpf, uint8_t Dlpf); |
gmehmet | 1:f60eafbf009a | 153 | |
gmehmet | 1:f60eafbf009a | 154 | virtual int MS_Max30001_ECG_Stop(); |
gmehmet | 1:f60eafbf009a | 155 | |
gmehmet | 1:f60eafbf009a | 156 | // ECG Max30001 RtoR Initialization Function |
gmehmet | 1:f60eafbf009a | 157 | virtual int MS_Max30001_RtoR_InitStart(uint8_t En_rtor, uint8_t Wndw, uint8_t Gain, |
gmehmet | 1:f60eafbf009a | 158 | uint8_t Pavg, uint8_t Ptsf, uint8_t Hoff, |
gmehmet | 1:f60eafbf009a | 159 | uint8_t Ravg, uint8_t Rhsf, uint8_t Clr_rrint); |
gmehmet | 1:f60eafbf009a | 160 | |
gmehmet | 1:f60eafbf009a | 161 | virtual int MS_Max30001_RtoR_Stop(); |
gmehmet | 1:f60eafbf009a | 162 | |
gmehmet | 1:f60eafbf009a | 163 | // Max30001 Interrupt Assignment Function |
gmehmet | 1:f60eafbf009a | 164 | virtual int MS_max30001_INT_assignment(uint8_t en_enint_loc, uint8_t en_eovf_loc, uint8_t en_fstint_loc, |
gmehmet | 1:f60eafbf009a | 165 | uint8_t en_dcloffint_loc, uint8_t en_bint_loc, uint8_t en_bovf_loc, |
gmehmet | 1:f60eafbf009a | 166 | uint8_t en_bover_loc, uint8_t en_bundr_loc, uint8_t en_bcgmon_loc, |
gmehmet | 1:f60eafbf009a | 167 | uint8_t en_pint_loc, uint8_t en_povf_loc, uint8_t en_pedge_loc, |
gmehmet | 1:f60eafbf009a | 168 | uint8_t en_lonint_loc, uint8_t en_rrint_loc, uint8_t en_samp_loc, |
gmehmet | 1:f60eafbf009a | 169 | uint8_t intb_Type, uint8_t int2b_Type); |
gmehmet | 1:f60eafbf009a | 170 | |
gmehmet | 1:f60eafbf009a | 171 | virtual int MS_max30001readRegister(uint8_t addr, uint32_t *return_data); |
gmehmet | 1:f60eafbf009a | 172 | |
gmehmet | 1:f60eafbf009a | 173 | virtual int MS_max30001writeRegister(uint8_t addr, uint32_t data); |
gmehmet | 1:f60eafbf009a | 174 | |
gmehmet | 1:f60eafbf009a | 175 | virtual int MS_max30001sync(); |
gmehmet | 1:f60eafbf009a | 176 | |
gmehmet | 1:f60eafbf009a | 177 | // *********************** end of Maxim Sensor ECG Max30001 related functions **************** |
gmehmet | 1:f60eafbf009a | 178 | |
gmehmet | 1:f60eafbf009a | 179 | |
gmehmet | 1:f60eafbf009a | 180 | |
gmehmet | 1:f60eafbf009a | 181 | // *********************** Max30205 related functions *********************** |
gmehmet | 1:f60eafbf009a | 182 | |
gmehmet | 1:f60eafbf009a | 183 | |
gmehmet | 1:f60eafbf009a | 184 | // *********************** end of Max30205 related functions **************** |
gmehmet | 1:f60eafbf009a | 185 | |
gmehmet | 1:f60eafbf009a | 186 | |
gmehmet | 1:f60eafbf009a | 187 | }; |
gmehmet | 1:f60eafbf009a | 188 | |
gmehmet | 1:f60eafbf009a | 189 | #endif /* _MAXIMSENSOR_H_ */ |