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

C++ I2CStart函数代码示例

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

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



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

示例1: ImuRead

void ImuRead(ImuRegisters & r, bool bDoMag)
{
I2CStart( 0x68,false,2);
I2CSend(0x3B);//59
I2CStop(20);

rv=I2CReadBuf(0x68, (PBYTE)&r, 14);

if(bDoMag)
{

I2CStart(MAGADDR,false,2);
I2CSend(0x03);
I2CStop(20);
rv2=I2CReadBuf(MAGADDR, (PBYTE)&r.mx, 6);

I2CStart(MAGADDR,false,2);
I2CSend(0x0A);
I2CSend(0x01);
I2CStop(20);
}
else
{
 r.mx=0;
 r.my=0;
 r.mz=0;
}

}
开发者ID:pbreed,项目名称:SBCAR,代码行数:29,代码来源:imu.cpp


示例2: communications

void communications() {
    I2CStart();
    I2CPut(0xb0);
    I2CPut('U');
    I2CStart();
    I2CPut(0xb1);
    I2CPut('Y');
    I2CStop();
}
开发者ID:syisrael,项目名称:lb2,代码行数:9,代码来源:i2cmastertest+-+Copy.c


示例3: main

void main()
{
/* Buffer where we will read/write our data */
	unsigned char I2CData[] = {0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x09, 0x00};
	unsigned char i;
	/* Initialize I2C Port */
	I2CInit();
	/* Send Start condition */
	I2CStart();
	/* Send DS1307 slave address with write operation */
	I2CSend(0xD0);
	/* Send subaddress 0x00, we are writing to this location */
	I2CSend(0x00);

	/* Loop to write 8 bytes */
	for (i = 0; i < 8; i++)
 {
		/* send I2C data one by one */
		//I2CSend(I2CInitval[i]);
I2CSend(I2CData[i]);
	}

	/* Send a stop condition - as transfer finishes */
	I2CStop();

	/* We will now read data from DS1307 */
	/* Reading for a memory based device always starts with a dummy write */
	/* Send a start condition */
	I2CStart();
	/* Send slave address with write */
	I2CSend(0xD0);
	/* Send address for dummy write operation */
	/* this address is actually where we are going to read from */
	I2CSend(0x00);

	/* Send a repeated start, after a dummy write to start reading */
	I2CRestart();
	/* send slave address with read bit set */
	I2CSend(0xD1);
	/* Loop to read 8 bytes from I2C slave */
	for (i = 8; i > 0; i--) {
		/* read a byte */
		I2CData[i] = I2CRead();
		/* ACK if its not the last byte to read */
		/* if its the last byte then send a NAK */
		if (i - 1)
			I2CAck();
		else
			I2CNak();
	}
	/* Send stop */
	I2CStop();
	/* end of program */
	while(1);
}
开发者ID:adinovus,项目名称:pic,代码行数:55,代码来源:i2c.c


示例4: WriteReg

void WriteReg(BYTE rg, BYTE val)
{
I2CStart( 0x68,false,2);
I2CSend(rg);
I2CSend(val);
I2CStop(20);
}
开发者ID:pbreed,项目名称:SBCAR,代码行数:7,代码来源:imu.cpp


示例5: i2c_recv

char i2c_recv(char addr, char count)
{
  char byteptr, byte_in;

  if (I2CStart()) return 1;
  i2cError = 0;
  byteptr = 0;

  byte_in = addr | 0x01;

  if (ByteOutI2C(byte_in))
    {
      if (i2cError == I2CERR_NAK) I2CStop();
      return i2cError;
    }

  while(count)
    {
      count-=1;
      if (count) {
	byte_in = I2CByteIn(0);
      } else {
	byte_in = I2CByteIn(1);   /* No ACK during last byte */
      }
      i2cReceiveBuffer[byteptr] = byte_in;
      byteptr++;
    }

  I2CStop();

  return (i2cError ? 1 : 0);
}
开发者ID:TronicLabs,项目名称:sdcc,代码行数:32,代码来源:i2c390.c


示例6: I2CSendStop

char I2CSendStop(char addr, char count, char send_stop)
{
  char byteptr, byte_out;

  if (I2CStart()) return 1;
  i2cError = 0;

  byte_out = addr & 0xfe;     /* Ensure that it's a write address */
  count++;                    /* Include slave address to byte count */
  byteptr = 0;
  while(count)
    {
      if (ByteOutI2C(byte_out))
        {
	  if (i2cError == I2CERR_NAK && send_stop) I2CStop();
	  return i2cError;
        }
      byte_out = i2cTransmitBuffer[byteptr];
      byteptr++;
      count--;
    }

  if (send_stop) I2CStop();
  return 0;
}
开发者ID:TronicLabs,项目名称:sdcc,代码行数:25,代码来源:i2c390.c


示例7: I2C_startTransfer

BOOL I2C_startTransfer(I2C_MODULE I2C_ID, BOOL restart){
    I2C_STATUS  status;

// Send the Start (or Restart) signal
    if(restart){
        if(I2CRepeatStart(I2C_ID) != I2C_SUCCESS){
            #ifdef DEBUG
            printf("Error: Bus collision during transfer Start at Read\n");
            #endif
            return FALSE;
        }
    }
    else{
    // Wait for the bus to be idle, then start the transfer
        while( !I2CBusIsIdle(I2C_ID) );
        if(I2CStart(I2C_ID) != I2C_SUCCESS){
            #ifdef DEBUG
            printf("Error: Bus collision during transfer Start at Write\n");
            #endif
            return FALSE;
        }
    }
    // Wait for the signal to complete
    do{
        status = I2CGetStatus(I2C_ID);
    }
    while (!(status & I2C_START) );

    return TRUE;
}
开发者ID:sdajani,项目名称:sdp,代码行数:30,代码来源:I2C.c


示例8: DS2482WriteConfig

unsigned char DS2482WriteConfig(unsigned char config)
{

    unsigned char read_config;

    I2CStart();
    I2CSendAddress(DS2482_I2C_ADDR, I2C_Direction_Transmitter);
    I2CWrite(DS2482_CMD_WCFG);
    I2CWrite(config | (~config << 4));
    I2CRestart();
    I2CSendAddress(DS2482_I2C_ADDR, I2C_Direction_Receiver);
    I2CNotAck();
    I2CStop();
    read_config = I2CRead();

    // check for failure due to incorrect read back
    if (config != read_config)
    {
        DS2482Reset();
        return false;
    }

    return true;

}
开发者ID:luismaduro,项目名称:uCLibraries,代码行数:25,代码来源:DS2482.c


示例9: OneWireWriteByte

void OneWireWriteByte(unsigned char sendbyte)
{
    unsigned char status;
    int poll_count = 0;

    I2CStart();
    I2CSendAddress(DS2482_I2C_ADDR, I2C_Direction_Transmitter);
    I2CWrite(DS2482_CMD_1WWB);
    I2CWrite(sendbyte);
    I2CRestart();
    I2CSendAddress(DS2482_I2C_ADDR, I2C_Direction_Receiver);
    I2CAck();

    do
    {
        status = I2CRead();
    }
    while ((status & DS2482_STATUS_1WB) && (poll_count++ < POLL_LIMIT));

    I2CNotAck();
    I2CStop();
    status = I2CRead();

    if (poll_count >= POLL_LIMIT)
        DS2482Reset();

}
开发者ID:luismaduro,项目名称:uCLibraries,代码行数:27,代码来源:DS2482.c


示例10: ks0066Init

void ks0066Init(void)
{
	I2CStart(PCF8574_ADDR, I2C_WRITE);

	i2cData &= ~PCF8574_BL_LINE;
	i2cData &= ~PCF8574_E_LINE;
	i2cData &= ~PCF8574_RW_LINE;
	i2cData &= ~PCF8574_RS_LINE;

	ks0066SetData(KS0066_FUNCTION | KS0066_8BIT);	/* Init data */
	ks0066WriteStrob();
	delay_ms(20);
	ks0066WriteStrob();
	delay_ms(5);
	ks0066WriteStrob();
	delay_us(120);
	ks0066WriteStrob();

	i2cData &= ~PCF8574_RW_LINE;
	i2cData &= ~PCF8574_RS_LINE;

	ks0066SetData(KS0066_FUNCTION);
	ks0066WriteStrob();

	I2CStop();

	ks0066WriteCommand(KS0066_FUNCTION | KS0066_2LINES);
	ks0066WriteCommand(KS0066_DISPLAY | KS0066_DISPAY_ON);
	ks0066WriteCommand(KS0066_CLEAR);
	delay_ms(2);
	ks0066WriteCommand(KS0066_SET_MODE | KS0066_INC_ADDR);

	return;
}
开发者ID:nilluchko,项目名称:projects-stm32,代码行数:34,代码来源:ks0066.c


示例11: TM1651_Init

void TM1651_Init(uint8_t backlight)
{
   I2CStart();
 I2CWritebyte(0x88|  backlight);			 //显示控制命令,开显示,脉冲宽度为11/16 0x08表示显示0|0x08|0x00
	//脉冲宽度 1/16-0b000 2/16-0b001 4/16-0b010 10/16-0b011 12/16-0b101 13/16-0b110 14/16-0b111
 I2CStop();
} 
开发者ID:Williamzhangtw,项目名称:8586S,代码行数:7,代码来源:TM1651.c


示例12: StartTransfer

/****** I2C Driver implementation *******/
static bool StartTransfer(I2C_MODULE i2c_id, bool restart)
{
    I2C_STATUS status;

    // Send the Start (or Restart) signal
    if (restart)
    {
        I2CRepeatStart(i2c_id);
    }
    else
    {
        // Wait for the bus to be idle, then start the transfer
        while (!I2CBusIsIdle(i2c_id));

        if (I2CStart(i2c_id) != I2C_SUCCESS)
        {
            //DBPRINTF("Error: Bus collision during transfer Start\n");
            return FALSE;
        }
    }

    // Wait for the signal to complete
    do
    {
        status = I2CGetStatus(i2c_id);

    } while (!(status & I2C_START));

    return TRUE;
}
开发者ID:ALLTERCO,项目名称:mongoose-iot,代码行数:31,代码来源:hal_pic32mx695f512h_i2c.c


示例13: i2c_Start

//==============================================================================
BOOL i2c_Start(UINT8 restart )
{
    I2C_STATUS  status;

    // Send the Start (or Restart) signal
    if(restart)
    {
        //I2CRepeatStart(EEPROM_I2C_BUS);
        I2C1CONbits.RSEN = 1;
    }
    else
    {
        // Wait for the bus to be idle, then start the transfer
        while( !I2CBusIsIdle(EEPROM_I2C_BUS) );

        if(I2CStart(EEPROM_I2C_BUS) != I2C_SUCCESS)
        {
            DBPRINTF("Error: Bus collision during transfer Start\n");
            return FALSE;
        }
    }

    // Wait for the signal to complete
    do
    {
        status = I2CGetStatus(EEPROM_I2C_BUS);
    } while ( !(status & I2C_START) );


    return TRUE;
}
开发者ID:Mopus,项目名称:tweeq-MPLABX-Examples,代码行数:32,代码来源:TweeqLib.c


示例14: tda731xSetSpeakers

void tda731xSetSpeakers(void)
{
	int8_t spFrontLeft = 0;
	int8_t spFrontRight = 0;

	int8_t spRearLeft = 0;
	int8_t spRearRight = 0;

	if (sndPar[MODE_SND_BALANCE].value > 0) {
		spFrontLeft -= sndPar[MODE_SND_BALANCE].value;
		spRearLeft -= sndPar[MODE_SND_BALANCE].value;
	} else {
		spFrontRight += sndPar[MODE_SND_BALANCE].value;
		spRearRight += sndPar[MODE_SND_BALANCE].value;
	}
	if (sndPar[MODE_SND_FRONTREAR].value > 0) {
		spRearLeft -= sndPar[MODE_SND_FRONTREAR].value;
		spRearRight -= sndPar[MODE_SND_FRONTREAR].value;
	} else {
		spFrontLeft += sndPar[MODE_SND_FRONTREAR].value;
		spFrontRight += sndPar[MODE_SND_FRONTREAR].value;
	}

	I2CStart(TDA731X_I2C_ADDR);
	I2CWriteByte(TDA731X_SP_REAR_LEFT | -spRearLeft);
	I2CWriteByte(TDA731X_SP_REAR_RIGHT | -spRearRight);
	I2CWriteByte(TDA731X_SP_FRONT_LEFT | -spFrontLeft);
	I2CWriteByte(TDA731X_SP_FRONT_RIGHT | -spFrontRight);
	I2CStop();

	return;
}
开发者ID:WiseLord,项目名称:volmatrix,代码行数:32,代码来源:tda731x.c


示例15: transaction

/*
 Sends a start to begin i2c transaction (with no strings attached)
 */
void sendStart(I2C_MODULE i2c){
        while( ! I2CBusIsIdle(i2c));
        DelayMs(2);                     // timing for ADXL345
        I2CStart(i2c);
        while( ! (I2CGetStatus(i2c) & I2C_START) );
        I2CClearStatus(i2c, I2C_START);
}
开发者ID:conorpp,项目名称:school,代码行数:10,代码来源:main.c


示例16: AT24_read

uint8_t AT24_read(struct eeprom_data *data) {
	uint8_t ret = ESUCCESS;
	uint8_t counter = 0;
	uint8_t *p;
	struct eeprom_data *tmp = (struct eeprom_data *)malloc(sizeof(tmp));

	memset(tmp, 0, EEPROM_MU_WR_SIZE);

	// Send EEPROM's i2c address + raise read flag
	ret = I2CStart(at24_addr | TW_READ);
	if (ret > 0)
		return ret;

	// Read one page
	do {
		if (counter + 1 == EEPROM_MU_WR_SIZE)
			ret = I2CReadByte(p, I2C_NOACK);
		else
			ret = I2CReadByte(p, I2C_ACK);

		if (ret > 0)
			return EEEPDATAREAD;
		tmp += *p++;
		counter++;
	} while (counter != EEPROM_MU_WR_SIZE);
	I2CStop();

	data = tmp;
	return ESUCCESS;
}
开发者ID:gerbert,项目名称:ws2,代码行数:30,代码来源:24c32.c


示例17: transfer_start

int transfer_start(I2C_MODULE port, I2C_7_BIT_ADDRESS address, UINT8 rw)
{
    I2C_STATUS status;
    int result = 0;

    while(!I2CBusIsIdle(port));

    if(I2CStart(port) != I2C_SUCCESS)
        return -1;

    do {
        status = I2CGetStatus(port);
    } while(!(status & I2C_START));

    /* Send address */
    address.rw = rw;
    result = transmit_byte(port, address.byte);
    if(result < 0)
        return result;

    if(!I2CByteWasAcknowledged(port))
        return -1;
    
    return result;
}
开发者ID:alveshenrique,项目名称:TCC_Project_MGC3130,代码行数:25,代码来源:gestic_custom.c


示例18: DS1307Write

uint8_t DS1307Write(uint8_t address,uint8_t data)
{
	uint8_t res;	//result
	
	//Start
	I2CStart();
	
	//SLA+W
	res=I2CWriteByte(0b11010000);	//DS1307 address + W
	
	//Error
	if(!res)	return FALSE;
	
	//Now send the address of required register
	res=I2CWriteByte(address);
	
	//Error
	if(!res)	return FALSE;
	
	//Now write the value
	res=I2CWriteByte(data);
	
	//Error
	if(!res)	return FALSE;
	
	//STOP
	I2CStop();
	
	return TRUE;
}
开发者ID:ariejan,项目名称:ClockMeister2100,代码行数:30,代码来源:ds1307.c


示例19: I2CWriteStatus

/*写SD2200状态寄存器命令*/
void I2CWriteStatus(void)
{		
	if(!I2CStart())return;
	I2CSendByte(0x60,1);      //发送SD2200状态寄存器_1命令
	if(!I2CWaitAck()){I2CStop();return;}   
//	I2CSendByte(0x03,0);      //IC进行复位初始化,24小时制
	I2CSendByte(0x02,0);      //IC不进行复位初始化,24小时制
	I2CWaitAck();
	I2CStop();        
	I2CStart();
	I2CSendByte(0x62,1);      //发送SD2200状态寄存器_2命令
	I2CWaitAck();   
	I2CSendByte(0x00,0);      //清TEST位,禁止中断输出
	I2CWaitAck();
	I2CStop();        
}
开发者ID:vvdeng,项目名称:MinerStaffManagerSystem,代码行数:17,代码来源:sd2200.c


示例20: TM1650_CMD

void TM1650_CMD(uchar data)
{
	I2CStart();
	I2CWrByte(data);
	I2Cask();
	I2CStop();
}
开发者ID:sparrow1058,项目名称:zwatch,代码行数:7,代码来源:tm1650.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ I2CStop函数代码示例发布时间:2022-05-30
下一篇:
C++ I2CMasterControl函数代码示例发布时间: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