Exemplo n.º 1
0
/*******************************************************************************
 * @fn          bspI2cWriteSingle
 *
 * @brief       Single byte write to an I2C device
 *
 * @param       data - byte to write
 *
 * @return      true if success
 */
bool bspI2cWriteSingle(uint8_t data)
{
  uint8_t d;

  d = data;

  return bspI2cWrite(&d, 1);
}
Exemplo n.º 2
0
//
//  Single write to an I2C device
//
bool bspI2cWriteSingle(uint8_t data)
{
    uint8_t d;

    // This is not optimal but is an implementation
    d = data;

    return bspI2cWrite(&d, 1);
}
/*******************************************************************************
* @fn          sensorWriteReg
* @brief       This function implements the I2C protocol to write to a sensor.
*              The sensor must be selected before this routine is called.
*
* @param       addr - which register to write
* @param       pBuf - pointer to buffer containing data to be written
* @param       nBytes - number of bytes to write
*
* @return      TRUE if successful write
*/
bool sensorWriteReg(uint8_t addr, uint8_t *pBuf, uint8_t nBytes)
{
    uint8_t i;
    uint8_t *p = buffer;

    /* Copy address and data to local buffer for burst write */
    *p++ = addr;
    for (i = 0; i < nBytes; i++)
    {
        *p++ = *pBuf++;
    }
    nBytes++;

    /* Send data */
    return bspI2cWrite(buffer,nBytes);
}