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


C++ i2c_master_wait函数代码示例

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


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

示例1: i2c_master_readByte

/******************************************************************************
 * FunctionName : i2c_master_readByte
 * Description  : read Byte from i2c bus
 * Parameters   : NONE
 * Returns	  : uint8 - readed value
*******************************************************************************/
uint8 i2c_master_readByte(void)
{
	uint8 retVal = 0;
	uint8 k, i;

	i2c_master_setDC(1, m_nLastSCL);

	for (i = 0; i < 8; i++) {
		i2c_master_wait(I2C_SLEEP_TIME);
		i2c_master_setDC(1, 0);
		i2c_master_wait(I2C_SLEEP_TIME);// sda 1, scl 0
		i2c_master_setDC(1, 1);
		while(i2c_master_getCL()==0)
			;		// clock stretch
		i2c_master_wait(I2C_SLEEP_TIME);// sda 1, scl 1

		k = i2c_master_getDC();
		i2c_master_wait(I2C_SLEEP_TIME);

		//if (i == 7) {
		//	i2c_master_wait(5);   ////
		//}

		k <<= (7 - i);
		retVal |= k;
	}

	i2c_master_setDC(m_nLastSDA, 0);
	i2c_master_wait(I2C_SLEEP_TIME);// sda 1, scl 0

	return retVal;
}
开发者ID:alemoke,项目名称:esp8266-frankenstein,代码行数:38,代码来源:i2c_master.c

示例2: i2c_master_writeByte

/******************************************************************************
 * FunctionName : i2c_master_writeByte
 * Description  : write wrdata value(one byte) into i2c
 * Parameters   : uint8 wrdata - write value
 * Returns	  : NONE
*******************************************************************************/
void i2c_master_writeByte(uint8 wrdata)
{
	uint8 dat;
	sint8 i;
/*
	i2c_master_wait(I2C_SLEEP_TIME);
	i2c_master_setDC(m_nLastSDA, 0);
*/
	i2c_master_wait(I2C_SLEEP_TIME);

	for (i = 7; i >= 0; i--) {
		dat = wrdata >> i;
		i2c_master_setDC(dat, 0);
		i2c_master_wait(I2C_SLEEP_TIME);
		i2c_master_setDC(dat, 1);
		i2c_master_wait(I2C_SLEEP_TIME);
/*
		if (i == 0) {
			i2c_master_wait(5);   ////
		}
*/
		i2c_master_setDC(dat, 0);
		i2c_master_wait(I2C_SLEEP_TIME);
	}
}
开发者ID:alemoke,项目名称:esp8266-frankenstein,代码行数:31,代码来源:i2c_master.c

示例3: i2c_master_readByte

/******************************************************************************
 * FunctionName : i2c_master_readByte
 * Description  : read Byte from i2c bus
 * Parameters   : NONE
 * Returns	    : uint8 - readed value
*******************************************************************************/
uint8 ICACHE_FLASH_ATTR
i2c_master_readByte(void)
{
	uint8 retVal = 0;
	uint8 k, i;
	
	i2c_master_wait(I2C_DELAY);
	i2c_master_setDC(m_nLastSDA, 0); // sda 1, scl 0
	
	for (i = 0; i < 8; i++) {
		i2c_master_wait(I2C_DELAY);
		i2c_master_setDC(1, 0); // sda 1, scl 0
		i2c_master_setDC(1, 1); // sda 1, scl 1

		k = i2c_master_getDC();

		if (i == 7) {
			i2c_master_wait(I2C_DELAY);   // extra delay
		}
		
		k <<= (7 - i);
		retVal |= k;
	}
	
	i2c_master_setDC(1, 0); // sda 1, scl 0
	
	return retVal;
}
开发者ID:modSwap,项目名称:ESP8266,代码行数:34,代码来源:i2c_master.c

示例4: i2c_master_init

/******************************************************************************
 * FunctionName : i2c_master_init
 * Description  : initilize I2C bus to enable i2c operations
 * Parameters   : NONE
 * Returns      : NONE
*******************************************************************************/
void ICACHE_FLASH_ATTR
i2c_master_init(void)
{
    uint8 i;

    i2c_master_setDC(1, 0);
    i2c_master_wait(5);

    // when SCL = 0, toggle SDA to clear up
    i2c_master_setDC(0, 0) ;
    i2c_master_wait(5);
    i2c_master_setDC(1, 0) ;
    i2c_master_wait(5);

    // set data_cnt to max value
    for (i = 0; i < 28; i++) {
        i2c_master_setDC(1, 0);
        i2c_master_wait(5);	// sda 1, scl 0
        i2c_master_setDC(1, 1);
        i2c_master_wait(5);	// sda 1, scl 1
    }

    // reset all
    i2c_master_stop();
    return;
}
开发者ID:Daven005,项目名称:ESP8266,代码行数:32,代码来源:i2c_master.c

示例5: i2c_master_start

/******************************************************************************
 * FunctionName : i2c_master_start
 * Description  : set i2c to send state
 * Parameters   : NONE
 * Returns	  : NONE
*******************************************************************************/
void i2c_master_start(void)
{
	i2c_master_setDC(1, m_nLastSCL);
	i2c_master_wait(I2C_SLEEP_TIME);
	i2c_master_setDC(1, 1);
	i2c_master_wait(I2C_SLEEP_TIME);// sda 1, scl 1
	i2c_master_setDC(0, 1);
	i2c_master_wait(I2C_SLEEP_TIME);// sda 0, scl 1
}
开发者ID:alemoke,项目名称:esp8266-frankenstein,代码行数:15,代码来源:i2c_master.c

示例6: i2c_master_start

/******************************************************************************
 * FunctionName : i2c_master_start
 * Description  : set i2c to send state
 * Parameters   : NONE
 * Returns      : NONE
*******************************************************************************/
void ICACHE_FLASH_ATTR
i2c_master_start(void)
{
    i2c_master_setDC(1, m_nLastSCL);
    i2c_master_wait(5);
    i2c_master_setDC(1, 1);
    i2c_master_wait(5);	// sda 1, scl 1
    i2c_master_setDC(0, 1);
    i2c_master_wait(5);	// sda 0, scl 1
}
开发者ID:Daven005,项目名称:ESP8266,代码行数:16,代码来源:i2c_master.c

示例7: i2c_master_stop

/******************************************************************************
 * FunctionName : i2c_master_stop
 * Description  : set i2c to stop sending state
 * Parameters   : NONE
 * Returns      : NONE
*******************************************************************************/
void ICACHE_FLASH_ATTR
i2c_master_stop(void)
{
    i2c_master_wait(I2C_DELAY_FULL);

    i2c_master_setDC(0, m_nLastSCL);
    i2c_master_wait(I2C_DELAY_FULL);	// sda 0
    i2c_master_setDC(0, 1);
    i2c_master_wait(I2C_DELAY_FULL);	// sda 0, scl 1
    i2c_master_setDC(1, 1);
    i2c_master_wait(I2C_DELAY_FULL);	// sda 1, scl 1
}
开发者ID:hcheung92,项目名称:WiFiYaala,代码行数:18,代码来源:led_i2c_master.c

示例8: i2c_master_stop

/******************************************************************************
 * FunctionName : i2c_master_stop
 * Description  : set i2c to stop sending state
 * Parameters   : NONE
 * Returns      : NONE
*******************************************************************************/
void ICACHE_RAM_ATTR
i2c_master_stop(void)
{
    i2c_master_wait(5);

    i2c_master_setDC(0, m_nLastSCL);
    i2c_master_wait(5);	// sda 0
    i2c_master_setDC(0, 1);
    i2c_master_wait(5);	// sda 0, scl 1
    i2c_master_setDC(1, 1);
    i2c_master_wait(5);	// sda 1, scl 1
}
开发者ID:RobinLin,项目名称:Espruino,代码行数:18,代码来源:i2c_master.c

示例9: i2c_master_setAck

/******************************************************************************
 * FunctionName : i2c_master_setAck
 * Description  : set ack to i2c bus as level value
 * Parameters   : uint8 level - 0 or 1
 * Returns      : NONE
*******************************************************************************/
void ICACHE_FLASH_ATTR
i2c_master_setAck(uint8 level)
{
    i2c_master_setDC(level, 0);
    i2c_master_wait(2);	// sda level, scl 0
    i2c_master_setDC(level, 1);
    i2c_master_wait(4);	// sda level, scl 1
    i2c_master_setDC(level, 0);
    i2c_master_wait(2);	// sda level, scl 0
    i2c_master_setDC(1, 0);
    i2c_master_wait(2);
}
开发者ID:nkolban,项目名称:Espruino,代码行数:18,代码来源:i2c_master.c

示例10: i2c_master_setAck

/******************************************************************************
 * FunctionName : i2c_master_setAck
 * Description  : set ack to i2c bus as level value
 * Parameters   : uint8 level - 0 or 1
 * Returns	  : NONE
*******************************************************************************/
void i2c_master_setAck(uint8 level)
{
	i2c_master_setDC(m_nLastSDA, 0);
	i2c_master_wait(I2C_SLEEP_TIME);
	i2c_master_setDC(level, 0);
	i2c_master_wait(I2C_SLEEP_TIME);// sda level, scl 0
	i2c_master_setDC(level, 1);
	i2c_master_wait(8);// sda level, scl 1
	i2c_master_setDC(level, 0);
	i2c_master_wait(I2C_SLEEP_TIME);// sda level, scl 0
	i2c_master_setDC(1, 0);
	i2c_master_wait(I2C_SLEEP_TIME);
}
开发者ID:alemoke,项目名称:esp8266-frankenstein,代码行数:19,代码来源:i2c_master.c

示例11: i2c_master_getAck

/******************************************************************************
 * FunctionName : i2c_master_getAck
 * Description  : confirm if peer send ack
 * Parameters   : NONE
 * Returns      : uint8 - ack value, 0 or 1
*******************************************************************************/
uint8 ICACHE_FLASH_ATTR
i2c_master_getAck(void)
{
    uint8 retVal;
    i2c_master_setDC(1, 0);
    i2c_master_wait(2);
    i2c_master_setDC(1, 1);
    i2c_master_wait(4);
    retVal = i2c_master_getDC();
    i2c_master_setDC(1, 0);
    i2c_master_wait(2);

    return !retVal; // 0->true->ACK, 1->false->NACK
}
开发者ID:nkolban,项目名称:Espruino,代码行数:20,代码来源:i2c_master.c

示例12: i2c_master_setAck

/******************************************************************************
 * FunctionName : i2c_master_setAck
 * Description  : set ack to i2c bus as level value
 * Parameters   : uint8 level - 0 or 1
 * Returns      : NONE
*******************************************************************************/
void ICACHE_FLASH_ATTR
i2c_master_setAck(uint8 level)
{
    i2c_master_setDC(m_nLastSDA, 0);
    i2c_master_wait(I2C_DELAY_FULL);
    i2c_master_setDC(level, 0);
    i2c_master_wait(I2C_DELAY_FULL);	// sda level, scl 0
    i2c_master_setDC(level, 1);
    i2c_master_wait(I2C_DELAY_LONG);	// sda level, scl 1
    i2c_master_setDC(level, 0);
    i2c_master_wait(I2C_DELAY_FULL);	// sda level, scl 0
    i2c_master_setDC(1, 0);
    i2c_master_wait(I2C_DELAY_FULL);
}
开发者ID:hcheung92,项目名称:WiFiYaala,代码行数:20,代码来源:led_i2c_master.c

示例13: i2c_master_setAck

/******************************************************************************
 * FunctionName : i2c_master_setAck
 * Description  : set ack to i2c bus as level value
 * Parameters   : uint8 level - 0 or 1
 * Returns      : NONE
*******************************************************************************/
void ICACHE_FLASH_ATTR
i2c_master_setAck(uint8 level)
{
    i2c_master_setDC(m_nLastSDA, 0);
    i2c_master_wait(5);
    i2c_master_setDC(level, 0);
    i2c_master_wait(5);	// sda level, scl 0
    i2c_master_setDC(level, 1);
    i2c_master_wait(8);	// sda level, scl 1
    i2c_master_setDC(level, 0);
    i2c_master_wait(5);	// sda level, scl 0
    i2c_master_setDC(1, 0);
    i2c_master_wait(5);
}
开发者ID:Daven005,项目名称:ESP8266,代码行数:20,代码来源:i2c_master.c

示例14: read_cb

LOCAL void ICACHE_FLASH_ATTR
read_cb(void)
{
	uint8_t ack, low, high;
	wdt_feed();
	os_printf("Time=%ld\n", system_get_time());
	i2c_master_start();
	i2c_master_writeByte(BH1750_ADDR);
	ack = i2c_master_getAck();
	if (ack)
	{
		os_printf("I2C:No ack after sending address\n");
		i2c_master_stop();
		return;
	}
	i2c_master_stop();
    i2c_master_wait(40000); // why?

    i2c_master_start();
    i2c_master_writeByte(BH1750_ADDR + 1);
    ack = i2c_master_getAck();
	if (ack)
	{
		os_printf("I2C:No ack after write command\n");
		i2c_master_stop();
		return;
	}
	low = i2c_master_readByte();
	high = i2c_master_readByte();
	i2c_master_setAck(1);
    i2c_master_stop();
	os_printf("I2C:read(L/H)=(0x%02x/0x%02x)\n", low, high);
}
开发者ID:alonewolfx2,项目名称:esp8266-sdk,代码行数:33,代码来源:user_main.c

示例15: i2c_master_getDC

/******************************************************************************
 * FunctionName : i2c_master_getDC
 * Description  : Internal used function -
 *					get i2c SDA bit value
 * Parameters   : NONE
 * Returns	  : uint8 - SDA bit value
*******************************************************************************/
LOCAL uint8 ICACHE_FLASH_ATTR
i2c_master_getDC(void)
{
	uint8 sda_out;
	sda_out = GPIO_INPUT_GET(GPIO_ID_PIN(I2C_MASTER_SDA_GPIO));
	i2c_master_wait(I2C_DELAY);
	return sda_out;
}
开发者ID:modSwap,项目名称:ESP8266,代码行数:15,代码来源:i2c_master.c


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