Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of RD117_MBED by
algorithm.cpp File Reference
****************************************************** More...
Go to the source code of this file.
Functions | |
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) |
Calculate the heart rate and SpO2 level. | |
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) |
Find peaks. | |
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) |
Find peaks above n_min_height. | |
void | maxim_remove_close_peaks (int32_t *pn_locs, int32_t *pn_npks, int32_t *pn_x, int32_t n_min_distance) |
Remove peaks. | |
void | maxim_sort_ascend (int32_t *pn_x, int32_t n_size) |
Sort array. | |
void | maxim_sort_indices_descend (int32_t *pn_x, int32_t *pn_indx, int32_t n_size) |
Sort indices. |
Detailed Description
******************************************************
Project: MAXREFDES117# Filename: algorithm.cpp Description: This module calculates the heart rate/SpO2 level
--------------------------------------------------------------------
This code follows the following naming conventions:
char ch_pmod_value char (array) s_pmod_s_string[16] float f_pmod_value int32_t n_pmod_value int32_t (array) an_pmod_value[16] int16_t w_pmod_value int16_t (array) aw_pmod_value[16] uint16_t uw_pmod_value uint16_t (array) auw_pmod_value[16] uint8_t uch_pmod_value uint8_t (array) auch_pmod_buffer[16] uint32_t un_pmod_value int32_t * pn_pmod_value
-------------------------------------------------------------------------
Definition in file algorithm.cpp.
Function Documentation
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 | ||
) |
Find peaks.
- Details
- Find at most MAX_NUM peaks above MIN_HEIGHT separated by at least MIN_DISTANCE
- Return values:
-
None
Definition at line 254 of file algorithm.cpp.
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 | ||
) |
Calculate the heart rate and SpO2 level.
- Details
- By detecting peaks of PPG cycle and corresponding AC/DC of red/infra-red signal, the ratio for the SPO2 is computed. Since this algorithm is aiming for Arm M0/M3. formaula for SPO2 did not achieve the accuracy due to register overflow. Thus, accurate SPO2 is precalculated and save longo uch_spo2_table[] per each ratio.
- Parameters:
-
[in] *pun_ir_buffer - IR sensor data buffer [in] n_ir_buffer_length - IR sensor data buffer length [in] *pun_red_buffer - Red sensor data buffer [out] *pn_spo2 - Calculated SpO2 value [out] *pch_spo2_valid - 1 if the calculated SpO2 value is valid [out] *pn_heart_rate - Calculated heart rate value [out] *pch_hr_valid - 1 if the calculated heart rate value is valid
- Return values:
-
None
Definition at line 62 of file algorithm.cpp.
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 | ||
) |
Find peaks above n_min_height.
- Details
- Find all peaks above MIN_HEIGHT
- Return values:
-
None
Definition at line 268 of file algorithm.cpp.
void maxim_remove_close_peaks | ( | int32_t * | pn_locs, |
int32_t * | pn_npks, | ||
int32_t * | pn_x, | ||
int32_t | n_min_distance | ||
) |
Remove peaks.
- Details
- Remove peaks separated by less than MIN_DISTANCE
- Return values:
-
None
Definition at line 299 of file algorithm.cpp.
void maxim_sort_ascend | ( | int32_t * | pn_x, |
int32_t | n_size | ||
) |
Sort array.
- Details
- Sort array in ascending order (insertion sort algorithm)
- Return values:
-
None
Definition at line 328 of file algorithm.cpp.
void maxim_sort_indices_descend | ( | int32_t * | pn_x, |
int32_t * | pn_indx, | ||
int32_t | n_size | ||
) |
Sort indices.
- Details
- Sort indices according to descending order (insertion sort algorithm)
- Return values:
-
None
Definition at line 346 of file algorithm.cpp.
Generated on Wed Jul 13 2022 11:29:51 by
