TEST
Dependencies: max32630fthr Adafruit_FeatherOLED USBDevice
Drivers/MaximSensor/MaximSensor.cpp@4:291477e8690d, 2020-04-19 (annotated)
- Committer:
- wwwarunraj
- Date:
- Sun Apr 19 11:19:57 2020 +0000
- Revision:
- 4:291477e8690d
- Parent:
- 3:2fe2ff1ca0dc
19/04
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Emre.Eken@IST-LT-36262.maxim-ic.internal | 3:2fe2ff1ca0dc | 1 | /******************************************************************************* |
Emre.Eken@IST-LT-36262.maxim-ic.internal | 3:2fe2ff1ca0dc | 2 | * Copyright (C) Maxim Integrated Products, Inc., All rights Reserved. |
Emre.Eken@IST-LT-36262.maxim-ic.internal | 3:2fe2ff1ca0dc | 3 | * |
Emre.Eken@IST-LT-36262.maxim-ic.internal | 3:2fe2ff1ca0dc | 4 | * This software is protected by copyright laws of the United States and |
Emre.Eken@IST-LT-36262.maxim-ic.internal | 3:2fe2ff1ca0dc | 5 | * of foreign countries. This material may also be protected by patent laws |
Emre.Eken@IST-LT-36262.maxim-ic.internal | 3:2fe2ff1ca0dc | 6 | * and technology transfer regulations of the United States and of foreign |
Emre.Eken@IST-LT-36262.maxim-ic.internal | 3:2fe2ff1ca0dc | 7 | * countries. This software is furnished under a license agreement and/or a |
Emre.Eken@IST-LT-36262.maxim-ic.internal | 3:2fe2ff1ca0dc | 8 | * nondisclosure agreement and may only be used or reproduced in accordance |
Emre.Eken@IST-LT-36262.maxim-ic.internal | 3:2fe2ff1ca0dc | 9 | * with the terms of those agreements. Dissemination of this information to |
Emre.Eken@IST-LT-36262.maxim-ic.internal | 3:2fe2ff1ca0dc | 10 | * any party or parties not specified in the license agreement and/or |
Emre.Eken@IST-LT-36262.maxim-ic.internal | 3:2fe2ff1ca0dc | 11 | * nondisclosure agreement is expressly prohibited. |
Emre.Eken@IST-LT-36262.maxim-ic.internal | 3:2fe2ff1ca0dc | 12 | * |
Emre.Eken@IST-LT-36262.maxim-ic.internal | 3:2fe2ff1ca0dc | 13 | * The above copyright notice and this permission notice shall be included |
Emre.Eken@IST-LT-36262.maxim-ic.internal | 3:2fe2ff1ca0dc | 14 | * in all copies or substantial portions of the Software. |
Emre.Eken@IST-LT-36262.maxim-ic.internal | 3:2fe2ff1ca0dc | 15 | * |
Emre.Eken@IST-LT-36262.maxim-ic.internal | 3:2fe2ff1ca0dc | 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
Emre.Eken@IST-LT-36262.maxim-ic.internal | 3:2fe2ff1ca0dc | 17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
Emre.Eken@IST-LT-36262.maxim-ic.internal | 3:2fe2ff1ca0dc | 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
Emre.Eken@IST-LT-36262.maxim-ic.internal | 3:2fe2ff1ca0dc | 19 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
Emre.Eken@IST-LT-36262.maxim-ic.internal | 3:2fe2ff1ca0dc | 20 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
Emre.Eken@IST-LT-36262.maxim-ic.internal | 3:2fe2ff1ca0dc | 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
Emre.Eken@IST-LT-36262.maxim-ic.internal | 3:2fe2ff1ca0dc | 22 | * OTHER DEALINGS IN THE SOFTWARE. |
Emre.Eken@IST-LT-36262.maxim-ic.internal | 3:2fe2ff1ca0dc | 23 | * |
Emre.Eken@IST-LT-36262.maxim-ic.internal | 3:2fe2ff1ca0dc | 24 | * Except as contained in this notice, the name of Maxim Integrated |
Emre.Eken@IST-LT-36262.maxim-ic.internal | 3:2fe2ff1ca0dc | 25 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
Emre.Eken@IST-LT-36262.maxim-ic.internal | 3:2fe2ff1ca0dc | 26 | * Products, Inc. Branding Policy. |
Emre.Eken@IST-LT-36262.maxim-ic.internal | 3:2fe2ff1ca0dc | 27 | * |
Emre.Eken@IST-LT-36262.maxim-ic.internal | 3:2fe2ff1ca0dc | 28 | * The mere transfer of this software does not imply any licenses |
Emre.Eken@IST-LT-36262.maxim-ic.internal | 3:2fe2ff1ca0dc | 29 | * of trade secrets, proprietary technology, copyrights, patents, |
Emre.Eken@IST-LT-36262.maxim-ic.internal | 3:2fe2ff1ca0dc | 30 | * trademarks, maskwork rights, or any other form of intellectual |
Emre.Eken@IST-LT-36262.maxim-ic.internal | 3:2fe2ff1ca0dc | 31 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
Emre.Eken@IST-LT-36262.maxim-ic.internal | 3:2fe2ff1ca0dc | 32 | * ownership rights. |
Emre.Eken@IST-LT-36262.maxim-ic.internal | 3:2fe2ff1ca0dc | 33 | ******************************************************************************* |
Emre.Eken@IST-LT-36262.maxim-ic.internal | 3:2fe2ff1ca0dc | 34 | */ |
Emre.Eken@IST-LT-36262.maxim-ic.internal | 3:2fe2ff1ca0dc | 35 | |
gmehmet | 1:f60eafbf009a | 36 | #include "MaximSensor.h" |
gmehmet | 1:f60eafbf009a | 37 | #include "Peripherals.h" |
gmehmet | 1:f60eafbf009a | 38 | |
gmehmet | 1:f60eafbf009a | 39 | /* PUBLIC FUNCTION DECLARATIONS */ |
gmehmet | 1:f60eafbf009a | 40 | /** |
gmehmet | 1:f60eafbf009a | 41 | * @brief Reads from register. |
gmehmet | 1:f60eafbf009a | 42 | * @details Reads specific Maxim Sensor register via SPI bus. |
gmehmet | 1:f60eafbf009a | 43 | * |
gmehmet | 1:f60eafbf009a | 44 | * @param[in] reg Beginning address of a register to be read. |
gmehmet | 1:f60eafbf009a | 45 | * @param[out] data Buffer space to save result value. |
gmehmet | 1:f60eafbf009a | 46 | * @param[in] len Number of consecutive bytes to be read. |
gmehmet | 1:f60eafbf009a | 47 | * |
gmehmet | 1:f60eafbf009a | 48 | * @returns 0 on success, negative error code on failure. |
gmehmet | 1:f60eafbf009a | 49 | */ |
gmehmet | 1:f60eafbf009a | 50 | int MaximSensor::readRegister(uint8_t reg, uint8_t *data, int len){ |
gmehmet | 1:f60eafbf009a | 51 | pr_err("Empty function is called"); |
gmehmet | 1:f60eafbf009a | 52 | return -1; |
gmehmet | 1:f60eafbf009a | 53 | } |
gmehmet | 1:f60eafbf009a | 54 | |
gmehmet | 1:f60eafbf009a | 55 | /** |
gmehmet | 1:f60eafbf009a | 56 | * @brief Writes data to Maxim Sensor register. |
gmehmet | 1:f60eafbf009a | 57 | * @details Writes data to specific Maxim Sensor register via SPI bus. |
gmehmet | 1:f60eafbf009a | 58 | * |
gmehmet | 1:f60eafbf009a | 59 | * @param[in] reg Address of a register to be wrote. |
gmehmet | 1:f60eafbf009a | 60 | * @param[in] data Data to write on register. |
gmehmet | 1:f60eafbf009a | 61 | * |
gmehmet | 1:f60eafbf009a | 62 | * @returns 0 on success, negative error code on failure. |
gmehmet | 1:f60eafbf009a | 63 | */ |
gmehmet | 1:f60eafbf009a | 64 | int MaximSensor::writeRegister(uint8_t reg, const uint8_t data){ |
gmehmet | 1:f60eafbf009a | 65 | pr_err("Empty function is called"); |
gmehmet | 1:f60eafbf009a | 66 | return -1; |
gmehmet | 1:f60eafbf009a | 67 | } |
gmehmet | 1:f60eafbf009a | 68 | |
gmehmet | 1:f60eafbf009a | 69 | /** |
gmehmet | 1:f60eafbf009a | 70 | * @brief Get Maxim Sensor part and revision info. |
gmehmet | 1:f60eafbf009a | 71 | * @details Reads Maxim Sensor part and revision info from device. |
gmehmet | 1:f60eafbf009a | 72 | * |
gmehmet | 1:f60eafbf009a | 73 | * @param[in] reg Beginning address of a register to be read. |
gmehmet | 1:f60eafbf009a | 74 | * @param[out] data Buffer space to save result value. |
gmehmet | 1:f60eafbf009a | 75 | * @param[in] len Number of consecutive bytes to be read. |
gmehmet | 1:f60eafbf009a | 76 | * |
gmehmet | 1:f60eafbf009a | 77 | * @returns 0 on success, negative error code on failure. |
gmehmet | 1:f60eafbf009a | 78 | */ |
gmehmet | 1:f60eafbf009a | 79 | int MaximSensor::get_part_info(uint8_t *part_id, uint8_t *rev_id){ |
gmehmet | 1:f60eafbf009a | 80 | pr_err("Empty function is called"); |
gmehmet | 1:f60eafbf009a | 81 | return -1; |
gmehmet | 1:f60eafbf009a | 82 | } |
gmehmet | 1:f60eafbf009a | 83 | |
gmehmet | 1:f60eafbf009a | 84 | /** |
gmehmet | 1:f60eafbf009a | 85 | * @brief Enables Maxim Sensor. |
gmehmet | 1:f60eafbf009a | 86 | * @details Enable IRQ, enable LEDs, enable AGC |
gmehmet | 1:f60eafbf009a | 87 | * |
gmehmet | 1:f60eafbf009a | 88 | * @param[in] enable Any value to enable, 0 to disable. |
gmehmet | 1:f60eafbf009a | 89 | * |
gmehmet | 1:f60eafbf009a | 90 | * @returns 0 on success, negative error code on failure. |
gmehmet | 1:f60eafbf009a | 91 | */ |
gmehmet | 1:f60eafbf009a | 92 | int MaximSensor::sensor_enable(int enable){ |
gmehmet | 1:f60eafbf009a | 93 | pr_err("Empty function is called"); |
gmehmet | 1:f60eafbf009a | 94 | return -1; |
gmehmet | 1:f60eafbf009a | 95 | } |
gmehmet | 1:f60eafbf009a | 96 | |
gmehmet | 1:f60eafbf009a | 97 | /** |
gmehmet | 1:f60eafbf009a | 98 | * @brief Enables AGC. |
gmehmet | 1:f60eafbf009a | 99 | * @details Enable Maxim Sensor automatic gain controller. |
gmehmet | 1:f60eafbf009a | 100 | * AGC automatically adjusts sampling rates and LED currents to save energy. |
gmehmet | 1:f60eafbf009a | 101 | * |
gmehmet | 1:f60eafbf009a | 102 | * @param[in] agc_enable Any value to enable, 0 to disable. |
gmehmet | 1:f60eafbf009a | 103 | * |
gmehmet | 1:f60eafbf009a | 104 | * @returns 0 on success, negative error code on failure. |
gmehmet | 1:f60eafbf009a | 105 | */ |
gmehmet | 1:f60eafbf009a | 106 | int MaximSensor::agc_enable(int agc_enable){ |
gmehmet | 1:f60eafbf009a | 107 | pr_err("Empty function is called"); |
gmehmet | 1:f60eafbf009a | 108 | return -1; |
gmehmet | 1:f60eafbf009a | 109 | } |
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 | const char *MaximSensor::get_sensor_part_name(){ |
gmehmet | 1:f60eafbf009a | 117 | pr_err("Empty function is called"); |
gmehmet | 1:f60eafbf009a | 118 | return ""; |
gmehmet | 1:f60eafbf009a | 119 | } |
gmehmet | 1:f60eafbf009a | 120 | #if 0 |
gmehmet | 1:f60eafbf009a | 121 | int dump_registers(addr_val_pair *reg_values) { |
gmehmet | 1:f60eafbf009a | 122 | pr_err("Empty function is called"); |
gmehmet | 1:f60eafbf009a | 123 | return 0; |
gmehmet | 1:f60eafbf009a | 124 | } |
gmehmet | 1:f60eafbf009a | 125 | #endif |
gmehmet | 1:f60eafbf009a | 126 | /** |
gmehmet | 1:f60eafbf009a | 127 | * @brief Get sensor name. |
gmehmet | 1:f60eafbf009a | 128 | * |
gmehmet | 1:f60eafbf009a | 129 | * @returns Sensor name string. |
gmehmet | 1:f60eafbf009a | 130 | */ |
gmehmet | 1:f60eafbf009a | 131 | const char *MaximSensor::get_sensor_name(){ |
gmehmet | 1:f60eafbf009a | 132 | pr_err("Empty function is called"); |
gmehmet | 1:f60eafbf009a | 133 | return ""; |
gmehmet | 1:f60eafbf009a | 134 | } |
gmehmet | 1:f60eafbf009a | 135 | |
gmehmet | 1:f60eafbf009a | 136 | |
gmehmet | 1:f60eafbf009a | 137 | /** |
gmehmet | 1:f60eafbf009a | 138 | * @brief Get sensor ID. |
gmehmet | 1:f60eafbf009a | 139 | * |
gmehmet | 1:f60eafbf009a | 140 | * @returns Sensor ID number. |
gmehmet | 1:f60eafbf009a | 141 | */ |
gmehmet | 1:f60eafbf009a | 142 | unsigned char MaximSensor::get_sensor_id() { |
gmehmet | 1:f60eafbf009a | 143 | |
gmehmet | 1:f60eafbf009a | 144 | // Base class returns 255 |
gmehmet | 1:f60eafbf009a | 145 | return( 255 ); |
gmehmet | 1:f60eafbf009a | 146 | |
gmehmet | 1:f60eafbf009a | 147 | } |
gmehmet | 1:f60eafbf009a | 148 | |
gmehmet | 1:f60eafbf009a | 149 | |
gmehmet | 1:f60eafbf009a | 150 | /** |
gmehmet | 1:f60eafbf009a | 151 | * @brief Get sensor name. |
gmehmet | 1:f60eafbf009a | 152 | * |
gmehmet | 1:f60eafbf009a | 153 | * @returns Sensor name string. |
gmehmet | 1:f60eafbf009a | 154 | */ |
gmehmet | 1:f60eafbf009a | 155 | const char *MaximSensor::get_sensor_algo_ver(){ |
gmehmet | 1:f60eafbf009a | 156 | pr_err("Empty function is called"); |
gmehmet | 1:f60eafbf009a | 157 | return ""; |
gmehmet | 1:f60eafbf009a | 158 | } |
gmehmet | 1:f60eafbf009a | 159 | |
gmehmet | 1:f60eafbf009a | 160 | int MaximSensor::MS_Max30001_ECG_InitStart(uint8_t En_ecg, uint8_t Openp, uint8_t Openn, |
gmehmet | 1:f60eafbf009a | 161 | uint8_t Pol, uint8_t Calp_sel, uint8_t Caln_sel, |
gmehmet | 1:f60eafbf009a | 162 | uint8_t E_fit, uint8_t Rate, uint8_t Gain, |
gmehmet | 1:f60eafbf009a | 163 | uint8_t Dhpf, uint8_t Dlpf){ |
gmehmet | 1:f60eafbf009a | 164 | pr_err("Empty function is called"); |
gmehmet | 1:f60eafbf009a | 165 | return -1; |
gmehmet | 1:f60eafbf009a | 166 | } |
gmehmet | 1:f60eafbf009a | 167 | |
gmehmet | 1:f60eafbf009a | 168 | int MaximSensor::MS_Max30001_ECG_Stop(){ |
gmehmet | 1:f60eafbf009a | 169 | pr_err("Empty function is called"); |
gmehmet | 1:f60eafbf009a | 170 | return -1; |
gmehmet | 1:f60eafbf009a | 171 | } |
gmehmet | 1:f60eafbf009a | 172 | |
gmehmet | 1:f60eafbf009a | 173 | int MaximSensor::MS_Max30001_RtoR_InitStart(uint8_t En_rtor, uint8_t Wndw, uint8_t Gain, |
gmehmet | 1:f60eafbf009a | 174 | uint8_t Pavg, uint8_t Ptsf, uint8_t Hoff, |
gmehmet | 1:f60eafbf009a | 175 | uint8_t Ravg, uint8_t Rhsf, uint8_t Clr_rrint){ |
gmehmet | 1:f60eafbf009a | 176 | pr_err("Empty function is called"); |
gmehmet | 1:f60eafbf009a | 177 | return -1; |
gmehmet | 1:f60eafbf009a | 178 | } |
gmehmet | 1:f60eafbf009a | 179 | |
gmehmet | 1:f60eafbf009a | 180 | int MaximSensor::MS_Max30001_RtoR_Stop(){ |
gmehmet | 1:f60eafbf009a | 181 | pr_err("Empty function is called"); |
gmehmet | 1:f60eafbf009a | 182 | return -1; |
gmehmet | 1:f60eafbf009a | 183 | } |
gmehmet | 1:f60eafbf009a | 184 | |
gmehmet | 1:f60eafbf009a | 185 | // Max30001 Interrupt Assignment Function |
gmehmet | 1:f60eafbf009a | 186 | int MaximSensor::MS_max30001_INT_assignment(uint8_t en_enint_loc, uint8_t en_eovf_loc, uint8_t en_fstint_loc, |
gmehmet | 1:f60eafbf009a | 187 | uint8_t en_dcloffint_loc, uint8_t en_bint_loc, uint8_t en_bovf_loc, |
gmehmet | 1:f60eafbf009a | 188 | uint8_t en_bover_loc, uint8_t en_bundr_loc, uint8_t en_bcgmon_loc, |
gmehmet | 1:f60eafbf009a | 189 | uint8_t en_pint_loc, uint8_t en_povf_loc, uint8_t en_pedge_loc, |
gmehmet | 1:f60eafbf009a | 190 | uint8_t en_lonint_loc, uint8_t en_rrint_loc, uint8_t en_samp_loc, |
gmehmet | 1:f60eafbf009a | 191 | uint8_t intb_Type, uint8_t int2b_Type){ |
gmehmet | 1:f60eafbf009a | 192 | pr_err("Empty function is called"); |
gmehmet | 1:f60eafbf009a | 193 | return -1; |
gmehmet | 1:f60eafbf009a | 194 | } |
gmehmet | 1:f60eafbf009a | 195 | |
gmehmet | 1:f60eafbf009a | 196 | int MaximSensor::MS_max30001readRegister(uint8_t addr, uint32_t *return_data){ |
gmehmet | 1:f60eafbf009a | 197 | pr_err("Empty function is called"); |
gmehmet | 1:f60eafbf009a | 198 | return -1; |
gmehmet | 1:f60eafbf009a | 199 | } |
gmehmet | 1:f60eafbf009a | 200 | |
gmehmet | 1:f60eafbf009a | 201 | int MaximSensor::MS_max30001writeRegister(uint8_t addr, uint32_t data){ |
gmehmet | 1:f60eafbf009a | 202 | pr_err("Empty function is called"); |
gmehmet | 1:f60eafbf009a | 203 | return -1; |
gmehmet | 1:f60eafbf009a | 204 | } |
gmehmet | 1:f60eafbf009a | 205 | |
gmehmet | 1:f60eafbf009a | 206 | int MaximSensor::MS_max30001sync(){ |
gmehmet | 1:f60eafbf009a | 207 | pr_err("Empty MS_max30001sync is called"); |
gmehmet | 1:f60eafbf009a | 208 | return -1; |
gmehmet | 1:f60eafbf009a | 209 | } |