ADPD144RI - SPO2 data read EXAMPLE

Please share an example code for ADPD144RI read data from ESP32 or Arduino

  • Hi Subbu,

    I would suggest two change, since your are not using driver API's.

    • Please do check the available FIFO bytes before you are going to read the FIFO data.
    • In your FIFO read API enable FIFO clock before reading data (AdpdDrvRegWrite(REG_FIFO_CLK, FIFO_CLK_EN)).


    AdpdDrvGetParameter
    () This API will give the available bytes in the FIFO. we need to ensure that required data's are accumulated in FIFO before reading it.

    Regarding FIFO clear mechanism you can follow the data sheet sequence. In driver file we are following same sequence as mentioned in data sheet.

    Regards,

    Sathishkumar K

  • 1.

    The FIFO read API is modified to enable FIFO clock before reading
    AdpdDrvRegWrite(0x0010, 0x0001);
    AdpdDrvRegWrite(0x005f, 0x0001);
    AdpdDrvRegWrite(0x005f, 0x0001);
    AdpdDrvRegWrite(0x0010, 0x0002);

    #define ADPDDrv_SUCCESS (0)
    #define ADPDDrv_ERROR (-1)
    #define ADPD_I2C_ADDRESS (0x64)
    #include <uart_debug.h>
    
    void main(void)
    {
    uint32_t LoopCnt = 0;
    uint8_t value[16] = {0};
    uint16_t nAdpdFifoLevelSize = 64, nAdpdDataSetSize;
    uint16_t nLoopLim = 16;
    uint16_t nAdpdDataSetSize = 8;
    uint16_t nRetValue = 0;
    
    AdpdDrvInit();
    
    while (1) 
    {
    	nRetValue = AdpdDrvReadFifoData(&value[0], nAdpdDataSetSize);
    	if (nRetValue == ADPDDrv_SUCCESS)
    	{
    		for (LoopCnt = 0; LoopCnt < nLoopLim; LoopCnt += 2)
    		{
    			UART_Print("%u ", (value[LoopCnt] << 8) | value[LoopCnt + 1]);
    			nAdpdFifoLevelSize = nAdpdFifoLevelSize - nAdpdDataSetSize;
    		}
    	}
    }
    }
    
    int16_t AdpdDrvReadFifoData(uint8_t *pnData, uint16_t nDataSetSize)
    {
    	uint8_t nGetFifoData, nAddr;
    	nAddr = 0x60;
    
    	AdpdDrvRegWrite(0x0010, 0x0001);
    	AdpdDrvRegWrite(0x005f, 0x0001);
    	AdpdDrvRegWrite(0x005f, 0x0001);
    	AdpdDrvRegWrite(0x0010, 0x0002);
    
    	if (ADPD_I2C_TxRx((uint8_t *) &nAddr, pnData, nDataSetSize) != HAL_OK)
    		return ADPDDrv_ERROR;
    	return ADPDDrv_SUCCESS;
    }
    
    bool ADPD_I2C_TxRx(unsigned char* pTxData, unsigned char* pRxData, unsigned int Size) 
    { 
    	HAL_I2C_Master_Transmit(&hi2c2, (uint16_t)(ADPD_I2C_ADDRESS << 1), (uint8_t *)pTxData, Size, 100);
    	return (HAL_STATUS_t)HAL_I2C_Master_Receive(&hi2c2, (uint16_t)(ADPD_I2C_ADDRESS << 1), pRxData, Size, 100);
    }
    
    int16_t AdpdDrvRegWrite(uint16_t nAddr, uint16_t nRegValue)
    {
    	uint8_t anI2cData[3];
    	anI2cData[0] = (uint8_t)nAddr;
    	anI2cData[1] = (uint8_t)(nRegValue >> 8);
    	anI2cData[2] = (uint8_t)(nRegValue);
    
    	if (ADPD_I2C_Transmit((uint8_t *)anI2cData, 3) != ADI_HAL_OK)
    		return ADPDDrv_ERROR;
    
    	return ADPDDrv_SUCCESS;
    }
    
    AdpdDrvInit()
    {
    	//Init code
    }

    2.

    I will add the API to check the available FIFO bytes before reading the FIFO data. I will update this code and share.

  • I was having indefinite loop to read the data. This code was shared above.

    Now I have changed the indefinite loop - while (1) to read the fifo data, based on the bytes of data available to readdata size.
    Now after adding this API - AdpdDrvGetParameter(), I could only get 128-bytes of data.
    I could see only 4 reads and each read gets us 32 byte of Data (Total 128-BYTES) . After each read fifo reset is happening, but after the board is power cycled, We could still read the cached data and that is the same data we have received before power cycle.

    main_v3.rtf

  • Dear Glen,

    Yes, We have set the register 0x10 to 0x0002 after the configuration is loaded. Although, We have done this, the LEDs are not glowing. I have measured the 3V, 1.8V supplies, They are fine. 

    Can you share the sample data that is expected when We load the suggested configuration both in open condition and when finger is placed over the device.

    What is the maximum value of pulse width that we can set..?

  • Hi there,

    I have updated the code and attached as main_v3.rft, can run this code to get the data from FIFO

    3821.main_v3.rtf