/* Send data with special length in master mode through the I2Cx peripheral.  */
void I2C_MasterWrite(I2C_TypeDef *I2Cx, u8 *pBuf, u8 len)
/* Send data with special length in master mode through the I2Cx peripheral.  */
void I2C_MasterWrite(I2C_TypeDef *I2Cx, u8 *pBuf, u8 len)
{
	u8 cnt = 0;
	assert_param(IS_I2C_ALL_PERIPH(I2Cx));
	for(cnt = 0; cnt < len; cnt++)
	{
		while((I2C_CheckFlagState(I2Cx, BIT_IC_STATUS_TFNF)) == 0);
		if(cnt >= len - 1)
		{
			I2Cx->IC_DATA_CMD = (*pBuf++) | (1 << 9);
		}
		else
		{
			I2Cx->IC_DATA_CMD = (*pBuf++);
		}
	}
	while((I2C_CheckFlagState(I2Cx, BIT_IC_STATUS_TFE)) == 0);
}