88 lines
2.4 KiB
C
88 lines
2.4 KiB
C
#ifndef _HX3695_SPO2_AGC_H_
|
||
#define _HX3695_SPO2_AGC_H_
|
||
#include <stdint.h>
|
||
#include <stdbool.h>
|
||
|
||
#define CAL_FLG_LED_DR 0x01
|
||
#define CAL_FLG_LED_DAC 0x02
|
||
#define CAL_FLG_AMB_DAC 0x04
|
||
#define CAL_FLG_RF 0x08
|
||
|
||
#define AGC_SWI_LED0 1 //LED<45>Ƿ<EFBFBD><C7B7><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>
|
||
#define AGC_SWI_LED1 1
|
||
#define AGC_SWI_LED2 1
|
||
#define AGC_SWI_LED3 0
|
||
|
||
#define AGC_CUR_INIT_LED0 64 //LED<45><44><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>
|
||
#define AGC_CUR_INIT_LED1 64
|
||
#define AGC_CUR_INIT_LED2 64
|
||
#define AGC_CUR_INIT_LED3 64
|
||
|
||
#define AGC_CUR_MAX_LED0 450 //LED<45><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
#define AGC_CUR_MAX_LED1 255
|
||
#define AGC_CUR_MAX_LED2 255
|
||
#define AGC_CUR_MAX_LED3 255
|
||
#define AGC_CUR_MAX_LED1N 450
|
||
|
||
#define AGC_RF_LED0 3 //LED<45><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0=10k,1=20k,2=50k,3=100k,4=150k,5=200k,6=500k,7=1M
|
||
#define AGC_RF_LED1 3
|
||
#define AGC_RF_LED2 3
|
||
#define AGC_RF_LED3 0
|
||
#define AGC_RF_LED1N 5
|
||
|
||
#define AGC_IDAC_TARGET_LED0 20 //<2F><><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>offset
|
||
#define AGC_IDAC_TARGET_LED1 160
|
||
#define AGC_IDAC_TARGET_LED2 160
|
||
#define AGC_IDAC_TARGET_LED3 0
|
||
#define AGC_IDAC_TARGET_LED1N 20
|
||
|
||
#define AGC_DELAY_COUNT_SET 4 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ,N<><4E><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
||
|
||
typedef enum {
|
||
sCalStart,
|
||
sCalCur,
|
||
sCalOffset1,
|
||
sCalOffset2,
|
||
sCalFinish,
|
||
sCalErr,
|
||
} agc_state_t;
|
||
|
||
typedef struct {
|
||
uint8_t FLAG;
|
||
uint16_t LED0_IDAC;
|
||
uint16_t LED1_IDAC;
|
||
uint16_t LED2_IDAC;
|
||
uint16_t LED3_IDAC;
|
||
uint16_t AMB0_IDAC;
|
||
uint16_t AMB1_IDAC;
|
||
uint16_t AMB2_IDAC;
|
||
uint16_t AMB3_IDAC;
|
||
uint16_t LED0_CUR;
|
||
uint16_t LED1_CUR;
|
||
uint16_t LED2_CUR;
|
||
uint16_t LED3_CUR;
|
||
uint8_t LED0_RF;
|
||
uint8_t LED1_RF;
|
||
uint8_t LED2_RF;
|
||
uint8_t LED3_RF;
|
||
uint32_t LED0_STEP;
|
||
uint32_t LED1_STEP;
|
||
uint32_t LED2_STEP;
|
||
uint32_t LED3_STEP;
|
||
uint8_t CAL_DELAY_CNT;
|
||
agc_state_t STATE;
|
||
} agc_set_t;
|
||
|
||
void hx3695_agc_reset(void);
|
||
void Init_PPG_Calibration_Routine(agc_set_t *calR);
|
||
void Restart_PPG_Calibration_Routine(agc_set_t *calR);
|
||
void PPG_Calibration_Routine(ppg_sensor_data_t *ppg_sensor_data, agc_set_t *calR, int32_t amb0_val, int32_t led0_val, \
|
||
int32_t amb1_val, int32_t led1_val, int32_t amb2_val, int32_t led2_val, int32_t amb3_val, int32_t led3_val);
|
||
void hx3695_agc_process(ppg_sensor_data_t *ppg_sensor);
|
||
void hx3695_cal_init(void);
|
||
void hx3695_recal_init(void);
|
||
void hx3695_cal_off(void);
|
||
void hx3695_agc_updata_reg(agc_set_t *calR);
|
||
|
||
#endif
|