示例#1
0
unsigned char writeMemoryBlock(const unsigned char *d, unsigned int dataSize, unsigned char bank, unsigned char address, unsigned char verify, unsigned char useProgMem)
{
    setMemoryBank(bank, false, false);
    setMemoryStartAddress(address);       // startaddress = 0 so start writing every DMP bank from the beginning

    I2C_writeBytes(devAddr,0x6f , dataSize, (unsigned char*) d);
    return true;
}
示例#2
0
unsigned char writeProgMemoryBlock(const unsigned char *d, unsigned int dataSize, unsigned char bank, unsigned char address, unsigned char verify)
{
    int i;
    for (i = 0; i < 7; i ++)
    {
        setMemoryBank(i, false, false); // bank number  = i
        setMemoryStartAddress(0);       // startaddress = 0 so start writing every DMP bank from the beginning

        I2C_writeBytes(devAddr,0x6f , 256, (unsigned char*) &d[i*256]);
    }

    // DMP bank 7 gets only 137 bytes:

    setMemoryBank(7, false, false); // bank number  = 7
    setMemoryStartAddress(0);       // startaddress = 0 so start writing also this DMP bank from the beginning

    I2C_writeBytes(devAddr, 0x6f , 137, (unsigned char*) &d[i*256]);

    return true; // end of writeDMPMemory reached
}
示例#3
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;
}
示例#4
0
Uint32 TPS65070_reg_write(Uint32 instance, Uint8 regOffset, Uint8 regVal)
{

  Uint32  status  = E_PASS;
  Uint8   buf[2];

  if(instance >= TPS_MAX_NUM_DEVICES) return E_FAIL; 

  buf[0] = regOffset;
  buf[1] = regVal;

  status = I2C_writeBytes(tpsConfigObj[instance].hI2cInfo, 2u, buf);    

  return status;
}
示例#5
0
unsigned char writeDMPConfigurationSet(const unsigned char *d, unsigned int dataSize, unsigned char useProgMem)
{
    unsigned char special;
    unsigned int i;
    // config set dmpConfig is a long string of blocks with the following structure:
    // [bank] [offset] [length] [byte[0], byte[1], ..., byte[length]]
    unsigned char bank, offset, length;

    for (i = 0; i < MPU6050_DMP_CONFIG_SIZE;)
    {
        bank   = pgm_read_byte(dmpConfig + i++); // pgm_read_byte() is a macro that reads a byte of d stored in a specified address(PROGMEM area)
        offset = pgm_read_byte(dmpConfig + i++);
        length = pgm_read_byte(dmpConfig + i++);

        if (length > 0) // regular block of data to write
        {
            setMemoryBank(bank, false, false); // bank number  = bank
            setMemoryStartAddress(offset);     // startaddress = offset from the beginning (0) of the bank

            I2C_writeBytes(devAddr,0x6f , length, (unsigned char*) &dmpConfig[i]);

            i = i + length;
        }
        else // length = 0; special instruction to write
        {
            // NOTE: this kind of behavior (what and when to do certain things)
            // is totally undocumented. This code is in here based on observed
            // behavior only, and exactly why (or even whether) it has to be here
            // is anybody's guess for now.
            special = pgm_read_byte(dmpConfig + i++);
            if (special == 0x01)
            {
                // enable DMP-related interrupts (ZeroMotion, FIFOBufferOverflow, DMP)
                I2C_writeByte(devAddr, 0x38, 0x32); 	// write 00110010: ZMOT_EN, FIFO_OFLOW_EN, DMP_INT_EN true
                // by the way: this sets all other interrupt enables to false
            }
        }
    }
    return true;
}
示例#6
0
void AK8975_setAdjustment(int8_t x, int8_t y, int8_t z) {
    buffer[0] = x;
    buffer[1] = y;
    buffer[2] = z;
    I2C_writeBytes(devAddr, AK8975_RA_ASAX, 3, buffer);
}