Yu anning
/
LPC_MAX30102
the MAX30102 driver for LPC1768 board
Embed:
(wiki syntax)
Show/hide line numbers
algorithm.h
Go to the documentation of this file.
00001 /** \file algorithm.h ****************************************************** 00002 * 00003 * Project: MAXREFDES117# 00004 * Filename: algorithm.h 00005 * Description: This module is the heart rate/SpO2 calculation algorithm header file 00006 * 00007 * Revision History: 00008 *\n 1-18-2016 Rev 01.00 SK Initial release. 00009 *\n 00010 * 00011 * -------------------------------------------------------------------- 00012 * 00013 * This code follows the following naming conventions: 00014 * 00015 *\n char ch_pmod_value 00016 *\n char (array) s_pmod_s_string[16] 00017 *\n float f_pmod_value 00018 *\n int32_t n_pmod_value 00019 *\n int32_t (array) an_pmod_value[16] 00020 *\n int16_t w_pmod_value 00021 *\n int16_t (array) aw_pmod_value[16] 00022 *\n uint16_t uw_pmod_value 00023 *\n uint16_t (array) auw_pmod_value[16] 00024 *\n uint8_t uch_pmod_value 00025 *\n uint8_t (array) auch_pmod_buffer[16] 00026 *\n uint32_t un_pmod_value 00027 *\n int32_t * pn_pmod_value 00028 * 00029 * ------------------------------------------------------------------------- */ 00030 /******************************************************************************* 00031 * Copyright (C) 2015 Maxim Integrated Products, Inc., All Rights Reserved. 00032 * 00033 * Permission is hereby granted, free of charge, to any person obtaining a 00034 * copy of this software and associated documentation files (the "Software"), 00035 * to deal in the Software without restriction, including without limitation 00036 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00037 * and/or sell copies of the Software, and to permit persons to whom the 00038 * Software is furnished to do so, subject to the following conditions: 00039 * 00040 * The above copyright notice and this permission notice shall be included 00041 * in all copies or substantial portions of the Software. 00042 * 00043 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00044 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00045 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00046 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES 00047 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00048 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00049 * OTHER DEALINGS IN THE SOFTWARE. 00050 * 00051 * Except as contained in this notice, the name of Maxim Integrated 00052 * Products, Inc. shall not be used except as stated in the Maxim Integrated 00053 * Products, Inc. Branding Policy. 00054 * 00055 * The mere transfer of this software does not imply any licenses 00056 * of trade secrets, proprietary technology, copyrights, patents, 00057 * trademarks, maskwork rights, or any other form of intellectual 00058 * property whatsoever. Maxim Integrated Products, Inc. retains all 00059 * ownership rights. 00060 ******************************************************************************* 00061 */ 00062 #ifndef ALGORITHM_H_ 00063 #define ALGORITHM_H_ 00064 00065 #include "mbed.h" 00066 00067 #define true 1 00068 #define false 0 00069 #define FS 100 00070 #define BUFFER_SIZE (FS* 5) 00071 #define HR_FIFO_SIZE 7 00072 #define MA4_SIZE 4 // DO NOT CHANGE 00073 #define HAMMING_SIZE 5// DO NOT CHANGE 00074 #define min(x,y) ((x) < (y) ? (x) : (y)) 00075 00076 const uint16_t auw_hamm[31]={ 41, 276, 512, 276, 41 }; //Hamm= long16(512* hamming(5)'); 00077 //uch_spo2_table is computed as -45.060*ratioAverage* ratioAverage + 30.354 *ratioAverage + 94.845 ; 00078 const uint8_t uch_spo2_table[184]={ 95, 95, 95, 96, 96, 96, 97, 97, 97, 97, 97, 98, 98, 98, 98, 98, 99, 99, 99, 99, 00079 99, 99, 99, 99, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 00080 100, 100, 100, 100, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 98, 98, 97, 97, 00081 97, 97, 96, 96, 96, 96, 95, 95, 95, 94, 94, 94, 93, 93, 93, 92, 92, 92, 91, 91, 00082 90, 90, 89, 89, 89, 88, 88, 87, 87, 86, 86, 85, 85, 84, 84, 83, 82, 82, 81, 81, 00083 80, 80, 79, 78, 78, 77, 76, 76, 75, 74, 74, 73, 72, 72, 71, 70, 69, 69, 68, 67, 00084 66, 66, 65, 64, 63, 62, 62, 61, 60, 59, 58, 57, 56, 56, 55, 54, 53, 52, 51, 50, 00085 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 31, 30, 29, 00086 28, 27, 26, 25, 23, 22, 21, 20, 19, 17, 16, 15, 14, 12, 11, 10, 9, 7, 6, 5, 00087 3, 2, 1 } ; 00088 static int32_t an_dx[ BUFFER_SIZE-MA4_SIZE]; // delta 00089 static int32_t an_x[ BUFFER_SIZE]; //ir 00090 static int32_t an_y[ BUFFER_SIZE]; //red 00091 00092 00093 void maxim_heart_rate_and_oxygen_saturation(uint32_t *pun_ir_buffer , int32_t n_ir_buffer_length, uint32_t *pun_red_buffer , int32_t *pn_spo2, int8_t *pch_spo2_valid , int32_t *pn_heart_rate , int8_t *pch_hr_valid); 00094 void maxim_find_peaks( int32_t *pn_locs, int32_t *pn_npks, int32_t *pn_x, int32_t n_size, int32_t n_min_height, int32_t n_min_distance, int32_t n_max_num ); 00095 void maxim_peaks_above_min_height( int32_t *pn_locs, int32_t *pn_npks, int32_t *pn_x, int32_t n_size, int32_t n_min_height ); 00096 void maxim_remove_close_peaks( int32_t *pn_locs, int32_t *pn_npks, int32_t *pn_x, int32_t n_min_distance ); 00097 void maxim_sort_ascend( int32_t *pn_x, int32_t n_size ); 00098 void maxim_sort_indices_descend( int32_t *pn_x, int32_t *pn_indx, int32_t n_size); 00099 00100 #endif /* ALGORITHM_H_ */
Generated on Mon Aug 1 2022 16:46:04 by 1.7.2