hr_algo.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*******************************************************************************
  2. * @file hr_algo.h
  3. * @author MEMS Application Team
  4. * @version V1.0
  5. * @date 2021-5-25
  6. * @brief hr algorithm api
  7. *******************************************************************************/
  8. #ifndef _HR_ALGO_H
  9. #define _HR_ALGO_H
  10. /******************************************************************************/
  11. //includes
  12. /******************************************************************************/
  13. #include <stdint.h>
  14. #include <stdarg.h>
  15. #include <sys/printk.h>
  16. #include <sensor_hal.h>
  17. #include <sensor_algo_common.h>
  18. /******************************************************************************/
  19. //constants
  20. /******************************************************************************/
  21. /* run mode */
  22. typedef enum {
  23. HB = 0,
  24. SPO2,
  25. HRV,
  26. HR_WEAR,
  27. } hr_mode_e;
  28. /* wear status */
  29. typedef enum {
  30. WEAR = 0,
  31. UNWEAR,
  32. } hr_wear_e;
  33. /******************************************************************************/
  34. //typedef
  35. /******************************************************************************/
  36. #ifdef __CC_ARM /* ARM Compiler */
  37. #pragma anon_unions
  38. #endif
  39. /* hr result handler */
  40. typedef void (*wear_handler_t)(uint8_t wearing_state, bool check);
  41. typedef void (*hb_handler_t)(uint8_t hb_val, uint8_t hb_lvl_val, uint16_t rr_val);
  42. typedef void (*spo2_handler_t)(uint8_t spo2_val, uint8_t spo2_lvl_val, uint8_t hb_val,
  43. uint8_t hb_lvl_val, uint16_t rr_val[4], uint8_t rr_lvl_val,
  44. uint8_t rr_cnt, uint16_t spo2_r_val);
  45. typedef void (*hrv_handler_t)(uint16_t *rr_val_arr, uint8_t rr_val_cnt, uint8_t rr_lvl);
  46. /* os api */
  47. typedef struct {
  48. /* User handler */
  49. wear_handler_t wear_handler;
  50. hb_handler_t hb_handler;
  51. spo2_handler_t spo2_handler;
  52. hrv_handler_t hrv_handler;
  53. } hr_os_api_t;
  54. /******************************************************************************/
  55. //function
  56. /******************************************************************************/
  57. /* Init sensor algo */
  58. extern int hr_algo_init(const hr_os_api_t *api);
  59. /* Start hr sensor */
  60. extern int hr_algo_start(int mode);
  61. /* Stop hr sensor */
  62. extern int hr_algo_stop(void);
  63. /* Process data through call-back handler */
  64. extern int hr_algo_process(void);
  65. #endif /* _HR_ALGO_H */