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


C++ i2c_start函数代码示例

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


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

示例1: ak7343_read

static int ak7343_read(struct i2c_client *client,
			unsigned long reg, unsigned long *val)
{
	unsigned long mfp_pin[2];
	unsigned long i2c0_mfps[] = {
		GPIO053_GPIO_53,		/* SCL */
		GPIO054_GPIO_54,		/* SDA */
	};
	unsigned long scl, sda;
	int ret = 0;
	scl = MFP_PIN_GPIO53;
	sda = MFP_PIN_GPIO54;
	i2c_lock_adapter(client->adapter);
	if (gpio_request(scl, "SCL")) {
		pr_err("Failed to request GPIO for SCL pin!\n");
		ret = -1;
		goto out0;
	}
	if (gpio_request(sda, "SDA")) {
		pr_err("Failed to request GPIO for SDA pin!\n");
		ret = -1;
		goto out1;
	};
	mfp_pin[0] = mfp_read(MFP_PIN_GPIO53);
	mfp_pin[1] = mfp_read(MFP_PIN_GPIO54);
	mfp_config(i2c0_mfps, ARRAY_SIZE(i2c0_mfps));
	i2c_start(scl, sda);
	if (i2c_sendbyte(scl, sda, (client->addr<<1) | 1) < 0) {
		ret = -1;
		goto out2;
	}
	if (i2c_sendbyte(scl, sda, (u8)reg) < 0) {
		ret = -1;
		goto out2;
	}
	if (i2c_rcvbyte(scl, sda, (u8 *)val) < 0) {
		ret = -1;
		goto out2;
	}
out2:
	i2c_stop(scl, sda);
	mfp_write(MFP_PIN_GPIO53, mfp_pin[0]);
	mfp_write(MFP_PIN_GPIO54, mfp_pin[1]);
	gpio_free(sda);
out1:
	gpio_free(scl);
out0:
	i2c_unlock_adapter(client->adapter);
	return ret;
}
开发者ID:AlexGreg,项目名称:android_kernel_samsung_lt02,代码行数:50,代码来源:ak7343.c

示例2: RTCRead

unsigned int8 RTCRead(unsigned int8 address)
{
    int1 nack;
    unsigned int8 value = 0;

	i2c_start();
    nack = i2c_write(PCF8583_WRITE);
    if (nack) {
     i2c_stop();
     printf("rtcread nack 1\n\r");
    } else {
     nack = i2c_write(address);
     if (!nack) {
      i2c_start();
      nack = i2c_write(PCF8583_READ);
      if (!nack) {
       value  = i2c_read();
      } else      printf("rtcread nack 3\n\r");
     } else      printf("rtcread nack 2\n\r");
     i2c_stop();
    }
    return value;
}
开发者ID:nocoolnicksleft,项目名称:DingDong500,代码行数:23,代码来源:Kopie+von+main.c

示例3: i2c_read_byte

// Read a byte, store in "value".
int8_t i2c_read_byte(uint8_t address, uint8_t *value)
{
  uint8_t ret=0;
  if (i2c_start()!=0)                                //I2C START
    return(1);                                  //Stop and return 0 if START fail
  ret |= i2c_write((address<<1)|I2C_READ_BIT);                // Write the I2C 7-bit address with R bit
  if (ret != 0)                                   // Returns 1 if failed
    return(1);

  *value = i2c_read(WITH_NACK);                           // Read byte from I2C Bus with NAK
  i2c_stop();                                     //I2C STOP
  return(0);                                      // Return success

}
开发者ID:DenAutonomePirat,项目名称:Firmwares,代码行数:15,代码来源:LT_I2C.cpp

示例4: doI2CWrite

void doI2CWrite(char** argv, char argc)
{
	if(argc == 3)
	{
		i2c_start();
		i2c_write(0x98);
		i2c_write(strtoint(argv[1]));
		i2c_write(strtoint(argv[2]));
		i2c_stop();
		printf("OK\n");
	}
	else
		printf("err: addr1 val1 addr2 val2\n");
}
开发者ID:esar,项目名称:hdmilight-v1,代码行数:14,代码来源:main.c

示例5: rtc_write_page

void rtc_write_page(uint8_t start_register, uint8_t *buffer, uint8_t size)
{
  uint8_t i;

  i2c_start(); // 1

  i2c_write(RTC_ADDRESS | I2C_WRITE); // 2+3
  i2c_write(start_register); // 4+5

  for(i = 0; i < size; i++)
    i2c_write(buffer[i]); // 8+9

  i2c_stop(); // 6
}
开发者ID:Otti0815,项目名称:picosafe_login,代码行数:14,代码来源:rtc.c

示例6: i2c_WriteBuffer

uint8_t i2c_WriteBuffer(uint8_t nAddress, uint8_t *pByte, uint8_t nLen)
{
    uint8_t stat = 0;

    stat = i2c_start( nAddress, TW_WRITE );
    while ( nLen && !stat) {

        stat = i2c_write( *pByte );
    }
    i2c_stop();

    return stat;

}
开发者ID:Paolo-Maffei,项目名称:Freebus-avr,代码行数:14,代码来源:fb_i2c_lib.c

示例7: read_mbbi

static long read_mbbi(mbbiRecord *prec) {

epicsMutexLock(mutex);
   i2c_start();
   i2c_write_byte(PCA9571_RD_ADDR);
   prec->rval = i2c_read_byte(ACK);
   i2c_stop();
epicsMutexUnlock(mutex);

   if(prec->rval == 255)
      prec->rval = 0;

   return(0);
}
开发者ID:gtortone,项目名称:XPort-ioc,代码行数:14,代码来源:devXPort.c

示例8: setCursor

void Lcd::write(uint8_t value)
{
    // If it is a new line, set the cursor to the next line (1,0)
    if (value == '\n')
        setCursor(1,0);
    else
    {
        i2c_start(m_i2cAddress);
        i2c_write(RAM_WRITE_CMD);
        i2c_write(value);
        i2c_stop ();
        delay_ms (m_charDelay);
    }
}
开发者ID:juansta,项目名称:intiController,代码行数:14,代码来源:lcd.cpp

示例9: accel_read

uint8 accel_read(uint8 reg_addr) {
    uint8 result;

    i2c_start();
    i2c_write((MMA7455_I2CADDR << 1) | I2C_WRITE);
    i2c_write(reg_addr);
    i2c_repeated_restart();
    i2c_write((MMA7455_I2CADDR << 1) | I2C_READ);
    result = i2c_read();
    i2c_nack();
    i2c_stop();

    return result;
}
开发者ID:jorticus,项目名称:zeitgeber-firmware,代码行数:14,代码来源:MMA7455.c

示例10: sendMD49commands

// Sende in Array MD49commands gesetzte Befehle für MD49 an AVR_Slave_DriveControl
// im Master-Transmitter-Mode
void sendMD49commands(void){
	uint8_t i;
	if(!(i2c_start(SLAVE_ADRESSE+I2C_WRITE))){		// Slave bereit zum schreiben?
		i2c_write(0x00);  							// Buffer Startadresse setzen
		for (i=0;i<15;i++){
			i2c_write(MD49commands[i]);
		}
		i2c_stop();       							// Zugriff beenden
	}
	else
	{
	//		/* Fehlerbehandlung... */
	}
}
开发者ID:Scheik,项目名称:Robot_AVR_Master,代码行数:16,代码来源:Robot_AVR_Master_main.c

示例11: show_version_msg

void show_version_msg()
{

  // show version message
  i2c_start(LCD_I2C_DEVICE_ID);
  i2c_tx(10);
  i2c_tx(2);
  i2c_tx(6);
  i=0;
  while (pgm_read_byte(&msg_version[i]) != '\0')
  i2c_tx(pgm_read_byte(&msg_version[i++])); 
  i2c_stop(); 	
	
}
开发者ID:marcelpost,项目名称:0053-AVR-Fuse-Resetter,代码行数:14,代码来源:avr-fuse-resetter.c

示例12: rtc_w

void rtc_w(void)
{

   i2c_start();          // issue start signal
   i2c_wb(0xA2);         // address PCF8563
   i2c_wb(0);            // start from word at address 0 (configuration word)
   i2c_wb(0x20);         // write $20 to config. (pause counter...)
   i2c_wb(0);            // write 0 to cents word
   i2c_wb(0x20);         // write $20 to seconds word
   i2c_wb(0x34);         // write $30 to minutes word
   i2c_wb(0x11);         // write $11 to hours word
   i2c_wb(0x24);         // write $24 to day word
   i2c_wb(0x04);         // write $04 to weekday
   i2c_wb(0x02);         // write $08 to month
   i2c_wb(0x14);         // write $08 to year
   i2c_stop();           // issue stop signal
   i2c_start();          // issue start signal
   i2c_wb(0xA2);         // address PCF8530
   i2c_wb(0);            // start from word at address 0
   i2c_wb(0);            // write 0 to config word (enable counting)
   i2c_stop();           // issue stop signal

}
开发者ID:lcgamboa,项目名称:picsimlab,代码行数:23,代码来源:rtc_w.c

示例13: i2c_read

int i2c_read(i2c_t *obj, int address, char *data, int length, int stop)
{
    I2C_TypeDef *i2c = (I2C_TypeDef *)(obj->i2c);
    I2cHandle.Instance = (I2C_TypeDef *)(obj->i2c);
    int timeout;
    int count;
    int value;

    i2c_start(obj);

    // Wait until SB flag is set
    timeout = FLAG_TIMEOUT;
    while (__HAL_I2C_GET_FLAG(&I2cHandle, I2C_FLAG_SB) == RESET) {
        timeout--;
        if (timeout == 0) {
            return -1;
        }
    }

    i2c->DR = __HAL_I2C_7BIT_ADD_READ(address);


    // Wait address is acknowledged
    timeout = FLAG_TIMEOUT;
    while (__HAL_I2C_GET_FLAG(&I2cHandle, I2C_FLAG_ADDR) == RESET) {
        timeout--;
        if (timeout == 0) {
            return -1;
        }
    }
    __HAL_I2C_CLEAR_ADDRFLAG(&I2cHandle);

    // Read all bytes except last one
    for (count = 0; count < (length - 1); count++) {
        value = i2c_byte_read(obj, 0);
        data[count] = (char)value;
    }

    // If not repeated start, send stop.
    // Warning: must be done BEFORE the data is read.
    if (stop) {
        i2c_stop(obj);
    }

    // Read the last byte
    value = i2c_byte_read(obj, 1);
    data[count] = (char)value;

    return length;
}
开发者ID:markus-ender-tridonic-com,项目名称:mbed-hal-st-stm32f4,代码行数:50,代码来源:i2c_api.c

示例14: I2C_EEIN

// le do endereco de 8 bits, com endereco de 8 bytes (2k bit max)
unsigned char I2C_EEIN (unsigned char address)
{
    unsigned char data;

    i2c_start();
    i2c_write(0xA0);
    i2c_write(address);
    i2c_repStart();
    i2c_write(0xA1);
    data=i2c_read(0);
    i2c_stop();
    return(data);

}
开发者ID:Sel2016,项目名称:microchip,代码行数:15,代码来源:main.c

示例15: motorcontrol_set_motors

/**
 * Set the speed of the motors
 *
 * @param motor_a Speed of motor 1
 * @param motor_b Speed of motor 2
 * @param motor_c Speed of motor 3
 * @param motor_d Speed of motor 4
 * @return If the setting was successful
 */
uint8_t motorcontrol_set_motors(uint8_t motor_a, uint8_t motor_b, uint8_t motor_c, uint8_t motor_d) {
#ifdef MOTORCONTROL_AVAILABLE
    if (i2c_start(I2C_ADDR_MOTORCONTROL + I2C_WRITE)) {
        i2c_write(MC_MOTOR_1_SPEED);
        i2c_write(motor_a);
        i2c_write(motor_b);
        i2c_write(motor_c);
        i2c_write(motor_d);
        i2c_stop();
        return 1;
    }
#endif /* MOTORCONTROL_AVAILABLE */
    return 0;
}
开发者ID:buyaka,项目名称:quadrofly,代码行数:23,代码来源:motorcom.c


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