/* Read data with special length in master mode through the USIx peripheral under in-house IP.  */
u8 USI_I2C_MasterRead(USI_TypeDef *USIx, u8 *pBuf, u8 len)
/* Read data with special length in master mode through the USIx peripheral under in-house IP.  */
u8 USI_I2C_MasterRead(USI_TypeDef *USIx, u8 *pBuf, u8 len)
{
	u8 cnt = 0;
	assert_param(IS_USI_I2C_ALL_PERIPH(USIx));
	for(cnt = 0; cnt < len; cnt++)
	{
		if(cnt >= len - 1)
		{
			USIx->TX_FIFO_WRITE = 0x0003 << 8;
		}
		else
		{
			USIx->TX_FIFO_WRITE = 0x0001 << 8;
		}		while((USI_I2C_CheckRXFIFOState(USIx, USI_RXFIFO_EMPTY)) == 1) {
			if(USI_I2C_GetRawINT(USIx) & USI_I2C_TX_ABRT_RSTS) {
				USI_I2C_ClearAllINT(USIx);
				return cnt;
			}
		}
		*pBuf++ = (u8)USIx->RX_FIFO_READ;
	}
	return cnt;
}