• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ IdleI2C函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: XEEBeginRead

/*********************************************************************
 * Function:        XEE_RESULT XEEBeginRead(unsigned char control,
 *                                          XEE_ADDR address)
 *
 * PreCondition:    XEEInit() is already called.
 *
 * Input:           control - EEPROM control and address code.
 *                  address - Address at which read is to be performed.
 *
 * Output:          XEE_SUCCESS if successful
 *                  other value if failed.
 *
 * Side Effects:    None
 *
 * Overview:        Sets internal address counter to given address.
 *                  Puts EEPROM in sequential read mode.
 *
 * Note:            This function does not release I2C bus.
 *                  User must call XEEEndRead() when read is not longer
 *                  needed; I2C bus will released after XEEEndRead()
 *                  is called.
 ********************************************************************/
XEE_RESULT XEEBeginRead(unsigned char control, XEE_ADDR address )
{
    unsigned char r;

    r = XEESetAddr(control, address);
    if ( r != XEE_SUCCESS )
        return r;

    r = XEEClose();
    if ( r != XEE_SUCCESS )
        return r;


    IdleI2C();
    StartI2C();
    while( EEPROM_SPICON2bits.SEN );
    if ( PIR2bits.BCLIF )
        return XEE_BUS_COLLISION;

    if ( WriteI2C(control+1) )
        return XEE_BUS_COLLISION;

    IdleI2C();
    if ( !EEPROM_SPICON2bits.ACKSTAT )
        return XEE_SUCCESS;
    return XEE_NAK;
}
开发者ID:Cougar,项目名称:HomeAutomation,代码行数:49,代码来源:I2CEEPROM.c


示例2: LDByteWriteI2C

/*********************************************************************
* Function:        LDByteWriteI2C()
* Input:		Control Byte, 8 - bit address, data.
* Overview:		Write a byte to low density device at address LowAdd
********************************************************************/
unsigned int LDByteWriteI2C(unsigned char ControlByte, unsigned char LowAdd, unsigned char data)
{
	unsigned int ErrorCode1;
	unsigned int ErrorCode2;

	IdleI2C();						//Ensure Module is Idle	
	StartI2C();						//Generate Start COndition
	WriteI2C(ControlByte);			//Write Control byte
	IdleI2C();
	
	ErrorCode1 = ACKStatus();		//Return ACK Status
	
	WriteI2C(LowAdd);				//Write Low Address
	IdleI2C();

	ErrorCode2 = ACKStatus();		//Return ACK Status

	WriteI2C(data);					//Write Data
	IdleI2C();
	
	StopI2C();						//Initiate Stop Condition
	//EEAckPolling(ControlByte);		//Perform ACK polling
	if(ErrorCode1 == 0) { printf("ACK 1 not recieved"); }
	if(ErrorCode2 == 0) { printf("ACK 2 not recieved"); }
	//return(ErrorCode);
}
开发者ID:Jean-Emile,项目名称:Quadrocopter,代码行数:31,代码来源:I2C.c


示例3: i2c_write

static int
i2c_write(struct i2c_platform_data *adap, unsigned char *buf,
		     unsigned int len)
{
	int	i;
	u32	data;

	pr_debug("i2c_write\n");

	i = 0;
	while (i < len) {
		data = buf[i];
		if (MasterWriteI2C(adap, data))
			return -EIO;
		IdleI2C(adap);
		if (pic32_bus_readl(adap->base + PIC32_I2CxSTAT) &
		    I2CSTAT_ACKSTAT)
			return -EIO;
		i++;
	}

	StopI2C(adap);
	IdleI2C(adap);
	return 0;
}
开发者ID:03199618,项目名称:linux,代码行数:25,代码来源:sead3-pic32-i2c-drv.c


示例4: internalChangeAddressLine

void internalChangeAddressLine(unsigned char oldAddress, unsigned char value) {
  IdleI2C();
  StartI2C();
  MasterWriteI2C(oldAddress);
  IdleI2C();
  MasterWriteI2C(0);
  IdleI2C();
  MasterWriteI2C(value);
  IdleI2C();
  StopI2C();
  IdleI2C();
}
开发者ID:hternier,项目名称:cen-electronic,代码行数:12,代码来源:srf02.c


示例5: XEEWrite

XEE_RESULT XEEWrite(unsigned char val)
{
    IdleI2C();                  // ensure module is idle

    if ( WriteI2C( val ) )   // data byte for EEPROM
        return XEE_BUS_COLLISION;          // set error for write collision

    IdleI2C();
    if ( !EEPROM_SPICON2bits.ACKSTAT )
        return XEE_SUCCESS;
    return XEE_NAK;
}
开发者ID:Cougar,项目名称:HomeAutomation,代码行数:12,代码来源:I2CEEPROM.c


示例6: LDPageWriteI2C

/*********************************************************************
* Function:        LDPageWriteI2C()
* Input:			ControlByte, LowAdd, *wrptr.
* Overview:		Write a page of data from array pointed to be wrptr
*				starting at LowAdd
* Note:			LowAdd must start on a page boundary
********************************************************************/
unsigned int LDPageWriteI2C(unsigned char ControlByte, unsigned char LowAdd, unsigned char *wrptr)
{
	IdleI2C();					//wait for bus Idle
	StartI2C();					//Generate Start condition
	WriteI2C(ControlByte);		//send controlbyte for a write
	IdleI2C();					//wait for bus Idle
	WriteI2C(LowAdd);			//send low address
	IdleI2C();					//wait for bus Idle
	putstringI2C(wrptr);		//send data
	IdleI2C();					//wait for bus Idle
	StopI2C();					//Generate Stop
	return(0);
}
开发者ID:Jean-Emile,项目名称:Quadrocopter,代码行数:20,代码来源:I2C.c


示例7: writeSRF02Command

void writeSRF02Command(char addr, char reg, char cmd) {
    StartI2C();
    // Wait till Start sequence is completed
    IdleI2C();
    MasterWriteI2C(addr);
    IdleI2C();
    MasterWriteI2C(reg);
    IdleI2C();
    // command
    MasterWriteI2C(cmd);
    IdleI2C();
    StopI2C();
}
开发者ID:hternier,项目名称:cen-electronic,代码行数:13,代码来源:srf02.c


示例8: XEEIsBusy

/*********************************************************************
 * Function:        XEE_RESULT XEEIsBusy(unsigned char control)
 *
 * PreCondition:    XEEInit() is already called.
 *
 * Input:           control     - EEPROM control and address code.
 *
 * Output:          XEE_READY if EEPROM is not busy
 *                  XEE_BUSY if EEPROM is busy
 *                  other value if failed.
 *
 * Side Effects:    None
 *
 * Overview:        Requests ack from EEPROM.
 *
 * Note:            None
 ********************************************************************/
XEE_RESULT XEEIsBusy(unsigned char control)
{
    XEE_RESULT r;

    IdleI2C();                      // ensure module is idle
    StartI2C();                     // initiate START condition
    while ( EEPROM_SPICON2bits.SEN );      // wait until start condition is over
    if ( PIR2bits.BCLIF )           // test for bus collision
    {
        return XEE_BUS_COLLISION;                // return with Bus Collision error
    }

    else
    {
        if ( WriteI2C( control ) )    // write byte - R/W bit should be 0
            return XEE_BUS_COLLISION;              // set error for write collision

        IdleI2C();                    // ensure module is idle
        if ( PIR2bits.BCLIF )         // test for bus collision
            return XEE_BUS_COLLISION;              // return with Bus Collision error

        if ( !EEPROM_SPICON2bits.ACKSTAT )
            r = XEE_READY;
        else
            r = XEE_BUSY;

#if 0
        while ( EEPROM_SPICON2bits.ACKSTAT ) // test for ACK condition received
        {
            RestartI2C();               // initiate Restart condition
            while ( EEPROM_SPICON2bits.RSEN ); // wait until re-start condition is over
            if ( PIR2bits.BCLIF )       // test for bus collision
                return XEE_BUS_COLLISION;            // return with Bus Collision error

            if ( WriteI2C( control ) )  // write byte - R/W bit should be 0
                return XEE_BUS_COLLISION;            // set error for write collision

            IdleI2C();                  // ensure module is idle
        }
#endif
    }


    StopI2C();                      // send STOP condition
    while ( EEPROM_SPICON2bits.PEN );      // wait until stop condition is over
    if ( PIR2bits.BCLIF )           // test for bus collision
        return XEE_BUS_COLLISION;                // return with Bus Collision error

    return r;
    //return XEE_READY;                   // return with no error
}
开发者ID:Cougar,项目名称:HomeAutomation,代码行数:68,代码来源:I2CEEPROM.c


示例9: setRelayStates

void setRelayStates(int relayStates) {
    StartI2C();
    IdleI2C();
    while(I2CCONbits.SEN);
    MasterWriteI2C(writeAddr);
    IdleI2C();
    // send the register
    MasterWriteI2C(RLY08_REGISTER_RELAY_STATES);
    IdleI2C();
    // send the value
    MasterWriteI2C(relayStates);
    IdleI2C();
    StopI2C();
}
开发者ID:Aveline67,项目名称:cen-electronic,代码行数:14,代码来源:rly08.c


示例10: sendRLY08Command

void sendRLY08Command(int command) {
    StartI2C();
    IdleI2C();
    while(I2CCONbits.SEN);
    MasterWriteI2C(writeAddr);
    IdleI2C();
    // send the register
    MasterWriteI2C(RLY08_REGISTER_COMMAND);
    IdleI2C();
    // send the value
    MasterWriteI2C(command);
    IdleI2C();
    StopI2C();
}
开发者ID:Aveline67,项目名称:cen-electronic,代码行数:14,代码来源:rly08.c


示例11: ReadI2C

int16_t ReadI2C (void)
{
	int i;
	static int16_t retval = 0;
	
	
	if (IdleI2C () != 1)
	{
		return ERREUR_I2C_IDLE;
	}
	
	I2C1CONbits.RCEN = 1;

	for (i=TIMEOUT_I2C; i>0; i--)
	{
		if(I2C1STATbits.RBF)
			break;
		
		if ((i-1) <= 0)
			return ERREUR_I2C_READ;
	}
	
	retval = (int16_t)I2C1RCV;
	
	return retval;
}
开发者ID:kaostheory78,项目名称:Carte-Strategie,代码行数:26,代码来源:i2c_plvl.c


示例12: WriteI2C

int16_t WriteI2C (uint8_t byte)
{
	int i;
	
	if (IdleI2C () != 1)
	{
		return ERREUR_I2C_IDLE;
	}
	
	I2C1TRN = byte;
	
	for (i=TIMEOUT_I2C; i>0; i--)
	{
		if (!I2C1STATbits.TBF)
		{
			break;
		}
		else
		{
			if (i == 0)
				return ERREUR_I2C_WRITE;
		}
	}
	
	return 1;
}
开发者ID:kaostheory78,项目名称:Carte-Strategie,代码行数:26,代码来源:i2c_plvl.c


示例13: RestartI2C

int16_t RestartI2C (void)
{
	int i;
	
	if (IdleI2C () != 1)
	{
		return ERREUR_I2C_IDLE;
	}
	
	I2C1CONbits.RSEN = 1;
	
	for (i=TIMEOUT_I2C; i>0; i--)
	{
		if (!I2C1CONbits.RSEN)
		{
			break;
		}
		else
		{
			if (i == 0)
				return ERREUR_I2C_RESTART;
		}
	}
	
	return 1;
}
开发者ID:kaostheory78,项目名称:Carte-Strategie,代码行数:26,代码来源:i2c_plvl.c


示例14: StopI2C

int16_t StopI2C (void)
{
	int i;
	
	if (IdleI2C () != 1)
	{
		return ERREUR_I2C_IDLE;
	}
	
	I2C1CONbits.PEN = 1;
	
	for (i=TIMEOUT_I2C; i>0; i--)
	{
		if (!I2C1CONbits.PEN)
		{
			break;
		}
		else
		{
			if (i == 0)
				return ERREUR_I2C_STOP;
		}
	}
	
	return 1;
}
开发者ID:kaostheory78,项目名称:Carte-Strategie,代码行数:26,代码来源:i2c_plvl.c


示例15: SendChar

void SendChar(unsigned char data) {

    IdleI2C();
    StartI2C();
    IdleI2C();
    putcI2C(OLED_address); //send address
    IdleI2C();
    putcI2C(0x40); //send data incomming
    IdleI2C();
    putcI2C(data);
    IdleI2C();
   // WriteI2C(0x40);
    //WriteI2C(data);
    StopI2C();

}
开发者ID:papinusret,项目名称:OLED_SSD1306,代码行数:16,代码来源:SS1306.c


示例16: LDSequentialReadI2C

/*********************************************************************
* Function:        LDSequentialReadI2C()
* Input:			ControlByte, address, *rdptr, length.
* Overview:		Performs a sequential read of length bytes starting at address
*				and places data in array pointed to by *rdptr
********************************************************************/
unsigned int LDSequentialReadI2C(unsigned char ControlByte, unsigned char address, unsigned char *rdptr, unsigned char length)
{
	IdleI2C();						//Ensure Module is Idle
	StartI2C();						//Initiate start condition
	WriteI2C(ControlByte);			//write 1 byte
	IdleI2C();						//Ensure module is Idle
	WriteI2C(address);				//Write word address
	IdleI2C();						//Ensure module is idle
	RestartI2C();					//Generate I2C Restart Condition
	WriteI2C(ControlByte | 0x01);	//Write 1 byte - R/W bit should be 1 for read
	IdleI2C();						//Ensure bus is idle
	getsI2C(rdptr, length);			//Read in multiple bytes
	NotAckI2C();					//Send Not Ack
	StopI2C();						//Send stop condition
	return(0);
}
开发者ID:Jean-Emile,项目名称:Quadrocopter,代码行数:22,代码来源:I2C.c


示例17: readEEPROMexterna

char readEEPROMexterna (char endereco)
{

		//while(!DataRdyI2C());
		IdleI2C();
		StartI2C(); IdleI2C();
		WriteI2C(0xA0); IdleI2C();
		WriteI2C(0x00); IdleI2C();   //HB
		WriteI2C(endereco); IdleI2C();
		RestartI2C(); IdleI2C();
		WriteI2C(0xA1); IdleI2C();
		value = ReadI2C(); IdleI2C(); //Dados
		NotAckI2C(); IdleI2C();
		StopI2C();IdleI2C();
		return value;
}
开发者ID:tostasmistas,项目名称:SCE,代码行数:16,代码来源:memorias.c


示例18: XEEEndWrite

/*********************************************************************
 * Function:        XEE_RESULT XEEEndWrite(void)
 *
 * PreCondition:    XEEInit() && XEEBeginWrite() are already called.
 *
 * Input:           None
 *
 * Output:          XEE_SUCCESS if successful
 *                  other value if failed.
 *
 * Side Effects:    None
 *
 * Overview:        Instructs EEPROM to begin write cycle.
 *
 * Note:            Call this function after either page full of bytes
 *                  written or no more bytes are left to load.
 *                  This function initiates the write cycle.
 *                  User must call for XEEWait() to ensure that write
 *                  cycle is finished before calling any other
 *                  routine.
 ********************************************************************/
XEE_RESULT XEEEndWrite(void)
{
    IdleI2C();
    StopI2C();
    while(EEPROM_SPICON2bits.PEN);
    return XEE_SUCCESS;
}
开发者ID:Cougar,项目名称:HomeAutomation,代码行数:28,代码来源:I2CEEPROM.c


示例19: LDByteReadI2C

/*********************************************************************
* Function:        LDByteReadI2C()
* Input:		Control Byte, Address, *Data, Length.
* Overview:		Performs a low density read of Length bytes and stores in *Data array
*				starting at Address.
********************************************************************/
unsigned int LDByteReadI2C(unsigned char ControlByte, unsigned char Address, unsigned char *Data, unsigned char Length)
{
	IdleI2C();					//wait for bus Idle
	StartI2C();					//Generate Start Condition
	WriteI2C(ControlByte);		//Write Control Byte
	IdleI2C();					//wait for bus Idle
	WriteI2C(Address);			//Write start address
	IdleI2C();					//wait for bus Idle

	RestartI2C();				//Generate restart condition
	WriteI2C(ControlByte | 0x01);	//Write control byte for read
	IdleI2C();					//wait for bus Idle

	getsI2C(Data, Length);		//read Length number of bytes
	NotAckI2C();				//Send Not Ack
	StopI2C();					//Generate Stop
}
开发者ID:Jean-Emile,项目名称:Quadrocopter,代码行数:23,代码来源:I2C.c


示例20: EEPROM_read

void EEPROM_read(BYTE devaddr, DWORD addr, BYTE *data, BYTE size)
{
    // Dummy read to setup address
    IdleI2C();
    StartI2C();
    IdleI2C();
    // Dev address
    WriteI2C( devaddr << 1 );
    IdleI2C();
    // Memory address
    WriteI2C( addr >> 8 );
    IdleI2C();
    WriteI2C( addr & 0xFF );
    IdleI2C();
    
    EEPROM_read_seq(devaddr, data, size);
}
开发者ID:mori-br,项目名称:PIC18RADIO,代码行数:17,代码来源:eeprom.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ IfcPPException函数代码示例发布时间:2022-05-30
下一篇:
C++ Idle函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap