You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
145 lines
2.9 KiB
145 lines
2.9 KiB
#ifndef _MAX30102_H
|
|
#define _MAX30102_H
|
|
|
|
#include "msp_iicMx.h"/////
|
|
#include "c_type51.h"/////
|
|
#include "TTSS_task.h"/////
|
|
///#include "bsp_lora_jx.h"
|
|
#include "bsp_oled.h"
|
|
#define MAX30102_Device_address 0xAE
|
|
|
|
//register addresses
|
|
#define REG_INTR_STATUS_1 0x00
|
|
#define REG_INTR_STATUS_2 0x01
|
|
#define REG_INTR_ENABLE_1 0x02
|
|
#define REG_INTR_ENABLE_2 0x03
|
|
#define REG_FIFO_WR_PTR 0x04
|
|
#define REG_OVF_COUNTER 0x05
|
|
#define REG_FIFO_RD_PTR 0x06
|
|
#define REG_FIFO_DATA 0x07
|
|
#define REG_FIFO_CONFIG 0x08
|
|
#define REG_MODE_CONFIG 0x09
|
|
#define REG_SPO2_CONFIG 0x0A
|
|
#define REG_LED1_PA 0x0C
|
|
#define REG_LED2_PA 0x0D
|
|
#define REG_PILOT_PA 0x10
|
|
#define REG_MULTI_LED_CTRL1 0x11
|
|
#define REG_MULTI_LED_CTRL2 0x12
|
|
#define REG_TEMP_INTR 0x1F
|
|
#define REG_TEMP_FRAC 0x20
|
|
#define REG_TEMP_CONFIG 0x21
|
|
#define REG_PROX_INT_THRESH 0x30
|
|
#define REG_REV_ID 0xFE
|
|
#define REG_PART_ID 0xFF
|
|
#define SAMPLES_PER_SECOND 100 //检测频率
|
|
|
|
|
|
|
|
#define D_m32_mode_HR 0x02
|
|
#define D_m32_mode_SPO2 0x03
|
|
|
|
uint8 Max30102_reset(void);
|
|
void L2_max30102_init(void);
|
|
void max30102_read_fifo(void);
|
|
|
|
typedef struct
|
|
{
|
|
TS_task task;
|
|
}TS_task_m32_;
|
|
extern TS_task_m32_ ts_task_m32;
|
|
|
|
extern void L2_task_m32_register(void);
|
|
extern void L2_task_m32_handle(TS_task_m32_ *s);
|
|
/*
|
|
BYTE 1 FIFO_DATA[17]
|
|
FIFO_DATA[16]
|
|
|
|
BYTE 2 FIFO_DATA[15]
|
|
FIFO_DATA[14]
|
|
FIFO_DATA[13]
|
|
FIFO_DATA[12]
|
|
FIFO_DATA[11]
|
|
FIFO_DATA[10]
|
|
FIFO_DATA[9]
|
|
FIFO_DATA[8]
|
|
|
|
BYTE 3 FIFO_DATA[7]
|
|
FIFO_DATA[6]
|
|
FIFO_DATA[5]
|
|
FIFO_DATA[4]
|
|
FIFO_DATA[3]
|
|
FIFO_DATA[2]
|
|
FIFO_DATA[1]
|
|
FIFO_DATA[0]
|
|
*/
|
|
typedef struct
|
|
{
|
|
u8 RED2;
|
|
u8 RED1;
|
|
u8 RED0;
|
|
u8 IR2;
|
|
u8 IR1;
|
|
u8 IR0;
|
|
}TS_m32fifo_;
|
|
|
|
typedef struct
|
|
{
|
|
TS_m32fifo_ dfifo[33];
|
|
uint32 red;
|
|
uint32 ir;
|
|
u8 mode;
|
|
u8 u81;
|
|
u16 u162;
|
|
u32 u322;
|
|
u8 send[32];////需要传输的数据 暂定32
|
|
|
|
u8 fifo_ok;////在fifo数据读取完后的空档期,可以用来执行其他任务,否则会丢失数据
|
|
|
|
u8 havefigle;///= 1 手指放入判定
|
|
|
|
u8 havefigle_n;///= 1 手指放入判定
|
|
|
|
|
|
|
|
|
|
uint32 hr_s,hr_i,hr;
|
|
U8 hr_out;////心跳的输出
|
|
U16 hr_out2;////心跳的输出
|
|
|
|
U16 hr_out2_temp;////心跳的输出
|
|
|
|
/// u32 u32a;
|
|
u16 u16b;
|
|
u16 u16d;
|
|
u16 u16out_c;///
|
|
u8 s,s2;
|
|
u8 HRok,SPO2ok,fifook,datok;
|
|
|
|
uint32 cashe[3];
|
|
uint32 i,ac,dc,ac2,dc2;
|
|
uint32 fifo_ir,fifo_red;
|
|
uint32 IR_out2,RED_out2,IR_max,IR_min,RED_max,RED_min;
|
|
uint32 sum,sum2;
|
|
|
|
float ac_ir,dc_ir,ac_red,dc_red,R2,SPO2;
|
|
U16 SPO2_out;//// 的输出
|
|
U16 SPO2_out_temp;
|
|
|
|
|
|
U8 SPO2_ok;////
|
|
U8 hr_ok;////
|
|
|
|
|
|
}TS_max30102_;
|
|
extern TS_max30102_ ts_max30102;
|
|
|
|
|
|
#define L1_max30102_WB(reg,dat) L2_IICMx_WriteCmd(D_iicch_max13102,MAX30102_Device_address,reg,dat)
|
|
|
|
#define IIC_Read_Byte(adr,reg) L2_IICMx_Read1Reg1D(D_iicch_max13102,adr,reg)
|
|
|
|
#define L1_max30102_Read(adr,reg) L2_IICMx_Read1Reg1D(D_iicch_max13102,MAX30102_Device_address,reg)
|
|
|
|
#define L1_max30102_Read_Array(reg,dat,n) L2_IICMx_ReadReg(D_iicch_max13102,MAX30102_Device_address,reg,dat,n)
|
|
|
|
#endif
|
|
|