/**
 * Initialises the accelerometer settings using the I2C protocol.
 *************************************************************************** */
void accelerometer_Init(void) { 
  /* Configure the accelerometer */
  uint8 registerWrite = MMA8451_CTRL_REG_1;
  uint8 configuration = MMA8451_F_READ_BIT_MASK|MMA8451_ACTIVE_BIT_MASK;
  GI2C1_WriteAddress(MMA8451_I2C_ADDRESS, &registerWrite, 1, &configuration,
      1);
}
/*
** ===================================================================
**     Method      :  MAG1_Write16bitBEValue (component MAG3110)
**
**     Description :
**         Writes a 16bit value to the device. Value is written in Big 
**         Endian.
**         This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
byte MAG1_Write16bitBEValue(byte addr, word value)
{
  union {
    uint8_t buf[2]; /* value on device is in big endian */
    uint16_t be;
  } val;

#if MAG1_CPU_IS_LITTLE_ENDIAN
  val.buf[0] = (uint8_t)(value);
  val.buf[1] = (uint8_t)(value>>8);
#else
  val.be = val; /* already in BE */
#endif
  return GI2C1_WriteAddress(MAG1_I2C_ADDR, &addr, sizeof(addr), &val.buf[0], sizeof(val.buf));
}
Exemple #3
0
/*
** ===================================================================
**     Method      :  GI2C1_WriteByteAddress8 (component GenericI2C)
**     Description :
**         Write a byte to the device using an 8bit memory address:
**         (S+i2cAddr+0), (memAddr), (data)...(data+P)
**     Parameters  :
**         NAME            - DESCRIPTION
**         i2cAddr         - I2C address of device
**         memAddr         - Device memory address
**         data            - Data value
**     Returns     :
**         ---             - Error code
** ===================================================================
*/
byte GI2C1_WriteByteAddress8(byte i2cAddr, byte memAddr, byte data)
{
  return GI2C1_WriteAddress(i2cAddr, &memAddr, sizeof(memAddr), &data, 1);
}