Example #1
0
//=============================================================
// Synchronous WRITE (internal)
//-------------------------------------------------------------
uint	_MPUWrite(	byte	 Register, 
					byte*	 Buffer,
					uint	 BufLen )
	{
	if (!_MPU_Init)
		return MPU_NOTINIT;		// Not initialized...
	//-----------------------
	if (_MPU_Async)
		return MPU_ABSY;		// Asynchronous operation in progress...
	//*********************************************************
	uint	RC		= MPU_OK;
	uint	Count	= 0;
	//---------------------------------------------------------
RetryNACK:
	RC = I2CSyncWrite(_MPU_Addr, Register, Buffer, BufLen);
	switch (RC)
		{
		case I2CRC_OK:
			return MPU_OK;

		case I2CRC_NACK:
			Count++;
			if (Count < I2C_NACKRetry)
				goto RetryNACK;

		default:
			return	RC;			
		}
	}
//=============================================================
// Synchronous WRITE (internal)
//-------------------------------------------------------------
// <editor-fold defaultstate="collapsed" desc="_MPLWrite(...)">
uint	_MPLWrite(	byte	 Register, 
					byte*	 Buffer,
					uint	 BufLen )
	{
	if (!_MPL_Init)
		return MPL_NOTINIT;		// Not initialized...
	//-----------------------
	if (_MPL_Async)
		return MPL_ABSY;		// Asynchronous operation in progress...
	//*********************************************************
	return I2CSyncWrite(_MPL_Addr, Register, Buffer, BufLen);
	}