当前位置: 首页>>代码示例>>C++>>正文


C++ I2C_Stop函数代码示例

本文整理汇总了C++中I2C_Stop函数的典型用法代码示例。如果您正苦于以下问题:C++ I2C_Stop函数的具体用法?C++ I2C_Stop怎么用?C++ I2C_Stop使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了I2C_Stop函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: i2cWriteBuffer

bool i2cWriteBuffer(uint8_t addr, uint8_t reg, uint8_t len, uint8_t * data)
{
    int i;
    if (!I2C_Start())
        return false;
    I2C_SendByte(addr << 1 | I2C_Direction_Transmitter);
    if (!I2C_WaitAck()) 
    {
        I2C_Stop();
        return false;
    }
    I2C_SendByte(reg);
    I2C_WaitAck();
    for (i = 0; i < len; i++) 
    {
        I2C_SendByte(data[i]);
        if (!I2C_WaitAck()) 
        {
            I2C_Stop();
            return false;
        }
    }
    I2C_Stop();
    return true;
}
开发者ID:jiaohaitao,项目名称:9DOF_IMU,代码行数:25,代码来源:stm32_mpu_iic.c

示例2: I2C_SendByte

int I2C_SW::read_regs(uint8_t SlaveAddress, uint8_t startRegister, uint8_t*out, int count)
{
	int i;

	if (!I2C_Start()) {
			return -1;
	}

	I2C_SendByte(SlaveAddress&0xFE);

	if (!I2C_WaitAck()) {
			I2C_Stop();
			return -1;
	}

	I2C_SendByte(startRegister);
	I2C_WaitAck();

	I2C_Start();
	I2C_SendByte((SlaveAddress&0xFE)|0x01);
	I2C_WaitAck();

	for(i=0; i<count; i++)
	{
		out[i] = I2C_ReceiveByte();
		if (i==count-1)
			I2C_SendNoAck();
		else
			I2C_SendAck();
	}

	I2C_Stop();
	
	return 0;
}
开发者ID:dreamkeep,项目名称:Acantha,代码行数:35,代码来源:I2C_SW.cpp

示例3: i2cRead

bool i2cRead(I2CDevice device, uint8_t addr, uint8_t reg, uint8_t len, uint8_t *buf)
{
    UNUSED(device);
    
    if (!I2C_Start()) {
        return false;
    }
    I2C_SendByte(addr << 1 | I2C_Direction_Transmitter);
    if (!I2C_WaitAck()) {
        I2C_Stop();
        i2cErrorCount++;
        return false;
    }
    I2C_SendByte(reg);
    I2C_WaitAck();
    I2C_Start();
    I2C_SendByte(addr << 1 | I2C_Direction_Receiver);
    I2C_WaitAck();
    while (len) {
        *buf = I2C_ReceiveByte();
        if (len == 1) {
            I2C_NoAck();
        }
        else {
            I2C_Ack();
        }
        buf++;
        len--;
    }
    I2C_Stop();
    return true;
}
开发者ID:NZFez,项目名称:betaflight,代码行数:32,代码来源:bus_i2c_soft.c

示例4: readTemp

static unsigned int readTemp() {
	//int ret;
	unsigned long temp = 0;
	int cnt = 0;
	repeat: if (cnt++ > 100) {
		return -1;
	}
	I2C_Stop();
	mdelay(1);
	I2C_Start();
	if (I2C_Send(MLX90615_ADDR, 1) == -1)
		goto repeat;
	if (I2C_Send(0x27, 1) == -1)
		goto repeat;
	//I2C_Stop();

	I2C_Start();

	if (I2C_Send(MLX90615_ADDR | 1, 1) == -1)
		goto repeat;
	temp = IIC_Receive(1) | (IIC_Receive(1) << 8);
	IIC_Receive(1);
	I2C_Stop();
	/*	gTemp = temp;
	 gTemp = temp * 2 - 27315;*/
	return temp;

}
开发者ID:herochengm,项目名称:phyTemper,代码行数:28,代码来源:main.c

示例5: i2cWriteBuffer

bool i2cWriteBuffer(I2CDevice device, uint8_t addr, uint8_t reg, uint8_t len, uint8_t * data)
{
    UNUSED(device);
    
    int i;
    if (!I2C_Start()) {
        i2cErrorCount++;
        return false;
    }
    I2C_SendByte(addr << 1 | I2C_Direction_Transmitter);
    if (!I2C_WaitAck()) {
        I2C_Stop();
        return false;
    }
    I2C_SendByte(reg);
    I2C_WaitAck();
    for (i = 0; i < len; i++) {
        I2C_SendByte(data[i]);
        if (!I2C_WaitAck()) {
            I2C_Stop();
            i2cErrorCount++;
            return false;
        }
    }
    I2C_Stop();
    return true;
}
开发者ID:NZFez,项目名称:betaflight,代码行数:27,代码来源:bus_i2c_soft.c

示例6: I2C_SendAddr

// send address via IIC.
BOOL I2C_SendAddr(BYTE DevAddr, WORD Addr, BYTE ReadWriteFlag, BYTE I2cDevice)
{	
	I2C_Start(I2cDevice);
	if(!I2C_WriteByte(DevAddr, I2cDevice))
	{
		WaitMs(EEPROM_WRITE_TIME); // Wairt for Programming-time.
		I2C_Start(I2cDevice);
		if(!I2C_WriteByte(DevAddr, I2cDevice))// | PageAddr))
		{
			I2C_Stop(I2cDevice);
			return FALSE;
		}
	}
	
   	if(!I2C_WriteByte((BYTE)Addr, I2cDevice))
	{
	 	I2C_Stop(I2cDevice);
		return FALSE;
	}
	
	if(ReadWriteFlag == IIC_READ)
	{
		I2C_Start(I2cDevice);
		if(!I2C_WriteByte((DevAddr | IIC_READ), I2cDevice))
		{
		 	I2C_Stop(I2cDevice);
			return FALSE;
		}
	}
	
	return TRUE;
}
开发者ID:BarryChen,项目名称:au6210_oem_bt168,代码行数:33,代码来源:test.c

示例7: BU9792_Refresh

//************************************************************
//BU9792 refresh display
unsigned char BU9792_Refresh(unsigned char * Src, unsigned int Len) {
	unsigned char temp = 0, i;

	Len = Len;
	//I2C_Stop(I2C_BUS_0);

	I2C_Start(I2C_BUS_0);

	while (I2C_WriteByte(BU9799_ADDR, I2C_BUS_0) && (temp < 218)) {
		I2C_Stop(I2C_BUS_0);
		DelayMs(1);
		I2C_Start(I2C_BUS_0);
		temp++;
	}

	if (temp >= 218) {
		I2C_Stop(I2C_BUS_0);
		return (0xff);
	}

	//I2C_WriteByte(LCD_ICSET_M|0x80,I2C_BUS_0) ;	/*high address*/
	I2C_WriteByte(LCD_ICSET_M | 0x80, I2C_BUS_0); /* 高地址 */

	//I2C_WriteByte(0x00,I2C_BUS_0) ;				/*send data low address*/
	I2C_WriteByte(0x00, I2C_BUS_0); /* 发送数据低地址*/

	for (i = 0; i < 18; i++) {
		//I2C_WriteByte(*Src++,I2C_BUS_0) ;			/*send device address*/
		I2C_WriteByte(*Src++, I2C_BUS_0); /* 发送器件地址 */
	}

	I2C_Stop(I2C_BUS_0);

	return 0;
}
开发者ID:bnthang,项目名称:single-phase-multy-tarriff,代码行数:37,代码来源:BU9792_Driver.c

示例8: i2cRead

bool i2cRead(uint8_t addr, uint8_t reg, uint8_t len, uint8_t *buf)
{
    if (!I2C_Start())
        return false;
    I2C_SendByte(addr << 1 | I2C_Direction_Transmitter);
    if (!I2C_WaitAck()) {
        I2C_Stop();
        return false;
    }
    I2C_SendByte(reg);
    I2C_WaitAck();
    I2C_Start();
    I2C_SendByte(addr << 1 | I2C_Direction_Receiver);
    I2C_WaitAck();
    while (len) {
        *buf = I2C_ReceiveByte();
        if (len == 1)
            I2C_NoAck();
        else
            I2C_Ack();
        buf++;
        len--;
    }
    I2C_Stop();
    return true;
}
开发者ID:AlienWiiBF,项目名称:baseflight,代码行数:26,代码来源:drv_i2c_soft.c

示例9: InitTempSensor

I2C_Status InitTempSensor(uint8_t index)
{        
    I2C_Status retVal = I2C_OK;
    
    // Write the config values into the TX buffer
    i2cTxBuffer[0] = TMP102_CONFIG_1_VAL;
    i2cTxBuffer[1] = TMP102_CONFIG_2_VAL;
    
    taskENTER_CRITICAL();
    
    // TODO: log something if the sensor fails to initialize
    do
    {
        // I2C Write
        I2C_Start(SLB_I2C, GetTmp102Addr(index), 0);
        retVal = I2C_WriteByte(SLB_I2C, TMP102_CONFIG_ADDR);
        if(retVal != I2C_OK)
        {
            break;
        }
        retVal = I2C_WaitForTX(SLB_I2C);
        if(retVal != I2C_OK)
        {
            break;
        }
        I2C_Stop(SLB_I2C);
        
        // I2C Write
        I2C_Start(SLB_I2C, GetTmp102Addr(index), 0);
        retVal = I2C_WriteBytes(SLB_I2C, i2cTxBuffer, 2);
        if(retVal != I2C_OK)
        {
            break;
        }
        retVal = I2C_WaitForTX(SLB_I2C);
        if(retVal != I2C_OK)
        {
            break;
        }
        I2C_Stop(SLB_I2C);
        
        // I2C Read
        I2C_Start(SLB_I2C, GetTmp102Addr(index), 1);
        
        if((retVal = I2C_ReadBytes(SLB_I2C, i2cRxBuffer, 2)) != I2C_OK)
        {
            break;
        }
        
        I2C_Stop(SLB_I2C);
        
    }while(0);
    
    taskEXIT_CRITICAL();
    
    return retVal;
}
开发者ID:project-reservoir,项目名称:project-dandelion,代码行数:57,代码来源:sensors.c

示例10: MPU6050_WriteByte

/********************单字节写入***********************/
uint8_t MPU6050_WriteByte(uint8_t SlaveAddress,uint8_t REG_Address,uint8_t REG_data)		   
{
	if(!I2C_Start())return 0;
    I2C_SendByte(SlaveAddress);   //发送设备地址+写信号//I2C_SendByte(((REG_Address & 0x0700) >>7) | SlaveAddress & 0xFFFE);//设置高起始地址+器件地址 
    if(!I2C_WaitAck()){I2C_Stop(); return 0;}
    I2C_SendByte(REG_Address );   //设置低起始地址      
    if(!I2C_WaitAck()){I2C_Stop(); return 0;}//I2C_WaitAck();	
    I2C_SendByte(REG_data);
    if(!I2C_WaitAck()){I2C_Stop(); return 0;}//I2C_WaitAck();   
    I2C_Stop(); 
    return 1;
}
开发者ID:Niugge,项目名称:2016.01.20,代码行数:13,代码来源:MPU6050.c

示例11: Single_Write

uint16_t Single_Write(unsigned char SlaveAddress,unsigned char REG_Address,unsigned char REG_data)		     //void
{
  	if(!I2C_Start())return FALSE;
    I2C_SendByte(SlaveAddress);   //发送设备地址+写信号//I2C_SendByte(((REG_Address & 0x0700) >>7) | SlaveAddress & 0xFFFE);//设置高起始地址+器件地址 
    if(!I2C_WaitAck()){I2C_Stop(); return FALSE;}
    I2C_SendByte(REG_Address );   //设置低起始地址      
    I2C_WaitAck();	
    I2C_SendByte(REG_data);
    I2C_WaitAck();   
    I2C_Stop(); 
    delay5ms();
    return TRUE;
}
开发者ID:sqrgj,项目名称:All-In-One-Chassis,代码行数:13,代码来源:myi2c.c

示例12: Single_Write

bool Single_Write(unsigned char SlaveAddress,unsigned char REG_Address,unsigned char REG_data)		     //void
{
  	if(!I2C_Start())return FALSE;
    I2C_SendByte(SlaveAddress);   //发送设备地址+写信号
    if(!I2C_WaitAck()){I2C_Stop(); return FALSE;}
    I2C_SendByte(REG_Address );   //设置低起始地址      
    I2C_WaitAck();	
    I2C_SendByte(REG_data);
    I2C_WaitAck();   
    I2C_Stop(); 
    delay5ms();
    return TRUE;
}
开发者ID:HapCoderWei,项目名称:MiniQ,代码行数:13,代码来源:ioi2c.c

示例13: BU9792_Init

//************************************************************
//BU9792 initialization
unsigned char BU9792_Init(void) {
	unsigned char temp = 0, i;

	//BU9792_Set(LCD_OFF);					//turn off display first
	BU9792_Set(LCD_OFF);					//先关闭显示

	//I2C_Stop(I2C_BUS_0);

	I2C_Start(I2C_BUS_0);

	while (I2C_WriteByte(BU9799_ADDR, I2C_BUS_0) && (temp < 3)) {
		I2C_Stop(I2C_BUS_0);
		DelayMs(1);
		I2C_Start(I2C_BUS_0);
		temp++;
	}

	if (temp >= 3) {
		I2C_Stop(I2C_BUS_0);
		return (0xff);
	}

	//I2C_WriteByte(LCD_ICSET|0x80,I2C_BUS_0) ;				//reset
	I2C_WriteByte(LCD_ICSET | 0x80, I2C_BUS_0);				//复位

	//I2C_WriteByte(LCD_POWER_NORMAL|0x80,I2C_BUS_0) ;		//normal power consumption
	I2C_WriteByte(LCD_POWER_NORMAL | 0x80, I2C_BUS_0);		//正常功耗

	// I2C_WriteByte(LCD_BLINK_OFF|0x80,I2C_BUS_0) ;			//turn off flicker
	I2C_WriteByte(LCD_BLINK_OFF | 0x80, I2C_BUS_0);			//关闭闪烁

	I2C_WriteByte(LCD_PIXEL_NORMAL | 0x80, I2C_BUS_0);		//

	I2C_WriteByte(LCD_ICSET_M | 0x80, I2C_BUS_0);			//

	//I2C_WriteByte(0x00,I2C_BUS_0) ;						/*send data low address*/
	I2C_WriteByte(0x00, I2C_BUS_0); /* 发送数据低地址*/

	for (i = 0; i < 18; i++) {
		// I2C_WriteByte(0xff,I2C_BUS_0) ;					/* send device address
		I2C_WriteByte(0xff, I2C_BUS_0); /* 发送器件地址 */
	}
	I2C_Stop(I2C_BUS_0);

	//BU9792_Set(LCD_ON);							//start LCD
	BU9792_Set(LCD_ON);							//开启LCD

	return 0;

}
开发者ID:bnthang,项目名称:single-phase-multy-tarriff,代码行数:52,代码来源:BU9792_Driver.c

示例14: address

/* -------------------------------------------------------------------
    Name: I2C_TxRepeat -
    Purpose: To transmit the same data to I2C slave device repeatly via I2C.
    Passed:
        UB8  bSLA   = I2C slave address.
        UW16 wREG   = I2C register address.
        UB8  bCNT   = The number of data which will be transmitted
            excluding slave and register address (bCNT: 1..255).
        UB8  bDATA  = The repeated data.
    Returns: None.
    Notes:
   ------------------------------------------------------------------- */
void I2C_TxRepeat (
UB8  bSLA,          /* BITEK slave address */
UW16 wREG,          /* BITEK register address */
UB8  bCNT,          /* The number of data which will be transmitted */
UB8  bDATA          /* The repeated DATA */
)
{
    UB8 bIdx;

    if (bCNT == 0)
        return;

    I2C_Start();

    I2C_TxData(bSLA | (((wREG) >> 7) & 0x1E));

    I2C_GetACK();


    I2C_TxData(wREG);
    I2C_GetACK();


    /* --------------------------------
        Write Data
       -------------------------------- */
    for (bIdx = bCNT; bIdx; bIdx--)
    {
        I2C_TxData(bDATA);
        I2C_GetACK();
    } /* for */


    I2C_Stop();
} /* I2C_TxRepeat */
开发者ID:github188,项目名称:NT9665X_GMD_V18,代码行数:47,代码来源:BIT1612M.c

示例15: initRTCmodule

unsigned char initRTCmodule(unsigned char devADDR){
    unsigned char btemp;
    
    Nop();
    Nop();
//    
    I2C_Close();
    I2C_Init(39);    // I2C 100 KHZ, 16 MHZ OSC (see note in "myI2C.c")
    Nop();
    Nop();
// 
    I2C_Start();
    I2C_Idle();
    btemp = I2C_WriteByte(devADDR);
    Nop();
    Nop();
    Nop();
    if (btemp != 0){
        Nop();
        Nop();
        I2C_Stop();
        I2C_Close();
        return 0xFF;
    } else {
        btemp = DS3231_GetInfo(0x0F);
        Nop();
        Nop();        
        return btemp;
    };
}
开发者ID:recog006,项目名称:rpcMPLABX,代码行数:30,代码来源:DS3231.c


注:本文中的I2C_Stop函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。