初级会员
- 积分
- 157
- 金钱
- 157
- 注册时间
- 2015-11-2
- 在线时间
- 50 小时
|
发表于 2016-11-3 09:31:02
|
显示全部楼层
[mw_shl_code=c,true]int maxim_MAX30102_ReadI2C_FIFO(uint8_t REG_Address,uint8_t *Word_Data,uint8_t count)
{
uint8_t i=0;
uint8_t no=count;
uint8_t data1, data2;
IIC_Start();
IIC_Send_Byte(I2C_WRITE_ADDR); //·¢ËíÆ÷¼tμØÖ·+D′Ãüáî
if(IIC_Wait_Ack()) //μè′yó|′e
{
goto RESTATE;
}
IIC_Send_Byte(REG_Address); //D′¼Ä′æÆ÷μØÖ·
if(IIC_Wait_Ack()) //μè′yó|′e
{
goto RESTATE;
}
IIC_Start();
IIC_Send_Byte(I2C_READ_ADDR); //·¢ËíÆ÷¼tμØÖ·+¶á
if(IIC_Wait_Ack()) //μè′yó|′e
{
goto RESTATE;
}
while(no)
{
if(1==no)
Word_Data=IIC_Read_Byte(0);
else
Word_Data=IIC_Read_Byte(1);
no--;
i++;
}
IIC_Stop();
return 1;
RESTATE:
IIC_Stop();
return 0;
}
int maxim_max30102_read_fifo(uint32_t *un_red_led, uint32_t *un_ir_led)
/**
* \brief Read a set of samples from the MAX30102 FIFO register
* \par Details
* This function reads a set of samples from the MAX30102 FIFO register
*
* \param[out] *un_red_led - pointer that stores the red LED reading data
* \param[out] *un_ir_led - pointer that stores the IR LED reading data
*
* \retval true on success
*/
{
uint32_t un_temp;
unsigned char uch_temp;
*un_red_led=0;
*un_ir_led=0;
unsigned char ch_i2c_data[6];
//read and clear status register
un_temp=MAX30102_ReadI2C(REG_INTR_STATUS_1);
un_temp=MAX30102_ReadI2C(REG_INTR_STATUS_2);
un_temp=0;
if(maxim_MAX30102_ReadI2C_FIFO(REG_FIFO_DATA, ch_i2c_data, 6)!=1)
{
return false;
}
un_temp =(unsigned char) ch_i2c_data[0];
un_temp<<=16;
*un_red_led+=un_temp;
un_temp =(unsigned char) ch_i2c_data[1];
un_temp<<=8;
*un_red_led+=un_temp;
un_temp =(unsigned char) ch_i2c_data[2];
*un_red_led+=un_temp;
un_temp=0;
un_temp=(unsigned char) ch_i2c_data[3];
un_temp<<=16;
*un_ir_led+=un_temp;
un_temp=(unsigned char) ch_i2c_data[4];
un_temp<<=8;
*un_ir_led+=un_temp;
un_temp=(unsigned char) ch_i2c_data[5];
*un_ir_led+=un_temp;
*un_red_led&=0x03FFFF; //Mask MSB [23:18]
*un_ir_led&=0x03FFFF; //Mask MSB [23:18]
return true;
}
[/mw_shl_code] |
|