Beispiel #1
0
void rdabt_iic_rf_read_data(unsigned char regaddr, unsigned short *data, unsigned char datalen)
{
#ifdef I2C_BASED_ON_GPIO
     gpio_i2c_rdabt_rf_read_data((RDABT_RF_ADDR<<1),regaddr, data,datalen);
#else

	UINT8 Data_half[2];
	UINT8 i=0;
	
	hal_I2cSendRawByte(g_btdI2cBusId,(RDABT_RF_ADDR<<1),I2C_MASTER_WR | I2C_MASTER_STA);
	hal_I2cSendRawByte(g_btdI2cBusId,regaddr,I2C_MASTER_WR);
	hal_I2cSendRawByte(g_btdI2cBusId,((RDABT_RF_ADDR<<1)|1),I2C_MASTER_WR | I2C_MASTER_STA);

	for(i=0;i<datalen-1;i++,data++)//data
	{	
		Data_half[0]=hal_I2cReadRawByte(g_btdI2cBusId,I2C_MASTER_RD);
		Data_half[1]=hal_I2cReadRawByte(g_btdI2cBusId,I2C_MASTER_RD);

		(*data)=Data_half[0]<<8;
		(*data)|=Data_half[1];
	}

	Data_half[0]=hal_I2cReadRawByte(g_btdI2cBusId,I2C_MASTER_RD);
	Data_half[1]=hal_I2cReadRawByte(g_btdI2cBusId,I2C_MASTER_RD | I2C_MASTER_ACK | I2C_MASTER_STO);

	(*data)=Data_half[0]<<8;
	(*data)|=Data_half[1];
#endif
//	SXS_TRACE(TSTDOUT, "rdabt_iic_rf_read_data: %d\n.");
}
Beispiel #2
0
PRIVATE UINT8 camerap_ReadReg(UINT8 Addr)
{
#ifdef I2C_BASED_ON_GPIO
    char data[1];
    gpio_i2c_write_data(gSensorInfo.i2caddress,&Addr,1, (unsigned char *)&data, 0);
    return(gpio_i2c_read_data(gSensorInfo.i2caddress,&Addr,0, data, 1));
#else
    if (hal_I2cSendRawByte(g_camdI2cBusId, ((gSensorInfo.i2caddress<<1) & 0xfe), PHASE2_WR_PH1) == HAL_ERR_RESOURCE_BUSY)   
    {
        return(0x1f);
    }
    if (hal_I2cSendRawByte(g_camdI2cBusId, Addr, PHASE2_WR_PH2) == HAL_ERR_RESOURCE_BUSY)
    {
        return(0x1e);
    }

    if (hal_I2cSendRawByte(g_camdI2cBusId, ((gSensorInfo.i2caddress<<1) | 0x01), PHASE2_RD_PH1) == HAL_ERR_RESOURCE_BUSY)

    {
        return(0x1d);
    }

    return(hal_I2cReadRawByte(g_camdI2cBusId, PHASE2_RD_PH2));
#endif
}
Beispiel #3
0
UINT8 rdabt_iic_core_read_data(unsigned int Regiter, unsigned int *pData, unsigned char datalen)
{
//	HAL_ERR_T halErr = HAL_ERR_RESOURCE_BUSY;
#ifdef I2C_BASED_ON_GPIO
     gpio_i2c_rdabt_core_read_data(RDABT_CORE_ADDR<<1,Regiter, pData,datalen);
#else
	UINT8 Data_half[4];
	UINT8 i,j;

	hal_I2cSendRawByte(g_btdI2cBusId,(RDABT_CORE_ADDR<<1),I2C_MASTER_WR | I2C_MASTER_STA);
	hal_I2cSendRawByte(g_btdI2cBusId,Regiter>>24,I2C_MASTER_WR);
	hal_I2cSendRawByte(g_btdI2cBusId,Regiter>>16,I2C_MASTER_WR);
	hal_I2cSendRawByte(g_btdI2cBusId,Regiter>>8,I2C_MASTER_WR);
	hal_I2cSendRawByte(g_btdI2cBusId,Regiter,I2C_MASTER_WR);
	hal_I2cSendRawByte(g_btdI2cBusId,((RDABT_CORE_ADDR<<1)|1),I2C_MASTER_WR | I2C_MASTER_STA);

	for(j=0;j<datalen-1;j++,pData++)//data
	{	
		for(i=0;i<4;i++)
		{
			Data_half[i]=hal_I2cReadRawByte(g_btdI2cBusId,I2C_MASTER_RD);
		}
		(*pData)=Data_half[3];
		(*pData)|=Data_half[2]<<8;
		(*pData)|=Data_half[1]<<16;
		(*pData)|=Data_half[0]<<24;
		//	 SXS_TRACE(TSTDOUT, "Read I2C: %d\n.",halErr);
	}
	for(i=0;i<3;i++)
	{
		Data_half[i]=hal_I2cReadRawByte(g_btdI2cBusId,I2C_MASTER_RD);
	}
	Data_half[3]=hal_I2cReadRawByte(g_btdI2cBusId,I2C_MASTER_RD | I2C_MASTER_ACK | I2C_MASTER_STO);
	(*pData)=Data_half[3];
	(*pData)|=Data_half[2]<<8;
	(*pData)|=Data_half[1]<<16;
	(*pData)|=Data_half[0]<<24;
#endif
    SXS_TRACE(TSTDOUT, "Read I2C: 0x%x\n.",*pData);
	
	return TRUE;
}