Пример #1
0
//****************************************************************************//
//
//  ReadRegisterRegion
//
//  Parameters:
//    *outputPointer -- Pass &variable (base address of) to save read data to
//    offset -- register to read
//    length -- number of bytes to read
//
//  Note:  Does not know if the target memory space is an array or not, or
//    if there is the array is big enough.  if the variable passed is only
//    two bytes long and 3 bytes are requested, this will over-write some
//    other memory!
//
//****************************************************************************//
status_t readRegisterRegion(uint8_t *outputPointer , uint8_t offset, uint8_t length)
{
	status_t returnError = IMU_SUCCESS;

  I2C_readBytes(I2CAddress, offset, length, outputPointer,0);

  return returnError;
}
Пример #2
0
//****************************************************************************//
//
//  readRegisterInt16
//
//  Parameters:
//    *outputPointer -- Pass &variable (base address of) to save read data to
//    offset -- register to read
//
//****************************************************************************//
status_t readRegisterInt16( int16_t* outputPointer, uint8_t offset )
{
  status_t returnError = IMU_SUCCESS;
	uint8_t myBuffer[2];
	I2C_readBytes(I2CAddress, offset, 2, myBuffer,0);
	*outputPointer = ((int16_t)(myBuffer[0]) | (int16_t)(myBuffer[1]<< 8));

	return returnError;
}
Пример #3
0
void getMotion6(int* ax, int* ay, int* az, int* gx, int* gy, int* gz)
{
    I2C_readBytes(devAddr, MPU6050_RA_ACCEL_XOUT_H, 14, buffer);
    *ax = (((int)buffer[0]) << 8) | buffer[1];
    *ay = (((int)buffer[2]) << 8) | buffer[3];
    *az = (((int)buffer[4]) << 8) | buffer[5];
    *gx = (((int)buffer[8]) << 8) | buffer[9];
    *gy = (((int)buffer[10]) << 8) | buffer[11];
    *gz = (((int)buffer[12]) << 8) | buffer[13];
}
Пример #4
0
I2C_Status_TypeDef  MS561101BA_readPROM(uint8_t *buffer)
{
    uint8_t i;
    uint8_t command;
    I2C_Status_TypeDef status_Com;
    for(i=0; i<6; i++)
    {
        command = MS561101BA_PROM_BASE_ADDR + (2*i);
        status_Com = I2C_readBytes(MS561101BA_ADDR_CSB_LOW,command,2,(buffer + (i*2)),TIMEOUT_I2C);
        if(status_Com != I2C_STATUS_SUCCESS) return status_Com;
    }
    return status_Com;
}
Пример #5
0
Uint8 TPS65070_reg_read(Uint32 instance, Uint8 regOffset, Uint8 *buf )
{
    Uint32 status = E_PASS;

	if(instance >= TPS_MAX_NUM_DEVICES) return E_FAIL;

    status = I2C_writeBytes(tpsConfigObj[instance].hI2cInfo,1u, &regOffset);

    if(status != E_PASS){
		status = I2C_readBytes(tpsConfigObj[instance].hI2cInfo,1u, buf);
	}
    
    return status;
}
Пример #6
0
// H* registers
void AK8975_getHeading(int16_t *x, int16_t *y, int16_t *z) {
	if(ChronographRead(ChronMAG)>= AK8975_READ_DELAY)
  {
		ChronographSet(ChronMAG);
		I2C_readBytes(devAddr, AK8975_RA_HXL, 6, buffer, 0);
		hx = (((int16_t)buffer[1]) << 8) | buffer[0];
		hy = (((int16_t)buffer[3]) << 8) | buffer[2];
    hz = (((int16_t)buffer[5]) << 8) | buffer[4];
		
    I2C_writeByte(devAddr, AK8975_RA_CNTL, AK8975_MODE_SINGLE);
    //DelayMsec(10);
    //while(!AK8975_getDataReady());
	}
	*x = hx;
  *y = hy;
  *z = hz;
    
}
Пример #7
0
//Get conversion called after startConversion
I2C_Status_TypeDef  MS561101BA_getConversion(uint8_t *buffer)
{
    return I2C_readBytes(MS561101BA_ADDR_CSB_LOW,0,MS561101BA_D1D2_SIZE,buffer,TIMEOUT_I2C);
}
Пример #8
0
int8_t I2C_readByte(uint8_t devAddr, uint8_t regAddr, uint8_t *data, uint16_t timeout)
{
	return I2C_readBytes(devAddr, regAddr, 1, data, timeout);
}
Пример #9
0
// ASA* registers
void AK8975_getAdjustment(int8_t *x, int8_t *y, int8_t *z) {
    I2C_readBytes(devAddr, AK8975_RA_ASAX, 3, buffer,0);
    *x = buffer[0];
    *y = buffer[1];
    *z = buffer[2];
}
Пример #10
0
int16_t AK8975_getHeadingZ() {
    I2C_writeByte(devAddr, AK8975_RA_CNTL, AK8975_MODE_SINGLE);
    DelayMsec(8);
    I2C_readBytes(devAddr, AK8975_RA_HZL, 2, buffer,0);
    return (((int16_t)buffer[1]) << 8) | buffer[0];
}
Пример #11
0
void I2C_readByte(uint8_t devAddr, uint8_t regAddr, uint8_t *data){
	
	I2C_readBytes(devAddr, regAddr, 1, data);
}
Пример #12
0
/**
  * @brief  Read the specified register from the chip.
  * @param  RegName: specifies the register to be read.
  *              This member can be one of the following values:  
  * @retval status communication.
  */
I2C_Status_TypeDef I2C_readReg(uint8_t devAddr, uint8_t RegName,uint8_t *RegValue,uint32_t timeout)
{   
    return I2C_readBytes(devAddr,RegName,2,RegValue,timeout);//length = 1 is not run, so I use 2.
}
Пример #13
0
unsigned int getFIFOCount()
{
    I2C_readBytes(devAddr, MPU6050_RA_FIFO_COUNTH, 2, buffer);
    return (((unsigned int)buffer[0]) << 8) | buffer[1];
}
Пример #14
0
void getFIFOBytes(unsigned char *d, unsigned char length)
{
    I2C_readBytes(devAddr, MPU6050_RA_FIFO_R_W, length, d);
}
Пример #15
0
void readMemoryBlock(unsigned char *d, unsigned int dataSize, unsigned char bank, unsigned char address)
{
    I2C_readBytes(devAddr, MPU6050_RA_MEM_R_W, dataSize ,d);
}