algorithm.h 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /** \file algorithm.h ******************************************************
  2. *
  3. * Project: MAXREFDES117#
  4. * Filename: algorithm.h
  5. * Description: This module is the heart rate/SpO2 calculation algorithm header file
  6. *
  7. * Revision History:
  8. *\n 1-18-2016 Rev 01.00 SK Initial release.
  9. *\n
  10. *
  11. * --------------------------------------------------------------------
  12. *
  13. * This code follows the following naming conventions:
  14. *
  15. *\n char ch_pmod_value
  16. *\n char (array) s_pmod_s_string[16]
  17. *\n float f_pmod_value
  18. *\n int32_t n_pmod_value
  19. *\n int32_t (array) an_pmod_value[16]
  20. *\n int16_t w_pmod_value
  21. *\n int16_t (array) aw_pmod_value[16]
  22. *\n uint16_t uw_pmod_value
  23. *\n uint16_t (array) auw_pmod_value[16]
  24. *\n uint8_t uch_pmod_value
  25. *\n uint8_t (array) auch_pmod_buffer[16]
  26. *\n uint32_t un_pmod_value
  27. *\n int32_t * pn_pmod_value
  28. *
  29. * ------------------------------------------------------------------------- */
  30. /*******************************************************************************
  31. * Copyright (C) 2015 Maxim Integrated Products, Inc., All Rights Reserved.
  32. *
  33. * Permission is hereby granted, free of charge, to any person obtaining a
  34. * copy of this software and associated documentation files (the "Software"),
  35. * to deal in the Software without restriction, including without limitation
  36. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  37. * and/or sell copies of the Software, and to permit persons to whom the
  38. * Software is furnished to do so, subject to the following conditions:
  39. *
  40. * The above copyright notice and this permission notice shall be included
  41. * in all copies or substantial portions of the Software.
  42. *
  43. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  44. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  45. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  46. * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
  47. * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  48. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  49. * OTHER DEALINGS IN THE SOFTWARE.
  50. *
  51. * Except as contained in this notice, the name of Maxim Integrated
  52. * Products, Inc. shall not be used except as stated in the Maxim Integrated
  53. * Products, Inc. Branding Policy.
  54. *
  55. * The mere transfer of this software does not imply any licenses
  56. * of trade secrets, proprietary technology, copyrights, patents,
  57. * trademarks, maskwork rights, or any other form of intellectual
  58. * property whatsoever. Maxim Integrated Products, Inc. retains all
  59. * ownership rights.
  60. *******************************************************************************
  61. */
  62. #ifndef ALGORITHM_H_
  63. #define ALGORITHM_H_
  64. #include <stdint.h>
  65. #define true 1
  66. #define false 0
  67. #define FS 100
  68. #define BUFFER_SIZE (FS* 5)
  69. #define HR_FIFO_SIZE 7
  70. #define MA4_SIZE 4 // DO NOT CHANGE
  71. #define HAMMING_SIZE 5// DO NOT CHANGE
  72. #define min(x,y) ((x) < (y) ? (x) : (y))
  73. 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);
  74. 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 );
  75. 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 );
  76. void maxim_remove_close_peaks( int32_t *pn_locs, int32_t *pn_npks, int32_t *pn_x, int32_t n_min_distance );
  77. void maxim_sort_ascend( int32_t *pn_x, int32_t n_size );
  78. void maxim_sort_indices_descend( int32_t *pn_x, int32_t *pn_indx, int32_t n_size);
  79. #endif /* ALGORITHM_H_ */