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

C++ I2C_CheckEvent函数代码示例

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

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



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

示例1: LM75_GetStatus

/**
  * @brief  Checks the LM75 status.
  * @param  None
  * @retval ErrorStatus: LM75 Status (ERROR or SUCCESS).
  */
ErrorStatus LM75_GetStatus(void)
{
  uint32_t I2C_TimeOut = I2C_TIMEOUT;

  /*!< Clear the LM75_I2C AF flag */
  I2C_ClearFlag(LM75_I2C, I2C_FLAG_AF);

  /*!< Enable LM75_I2C acknowledgement if it is already disabled by other function */
  I2C_AcknowledgeConfig(LM75_I2C, ENABLE);

  /*---------------------------- Transmission Phase ---------------------------*/

  /*!< Send LM75_I2C START condition */
  I2C_GenerateSTART(LM75_I2C, ENABLE);

  /*!< Test on LM75_I2C EV5 and clear it */
  while ((!I2C_GetFlagStatus(LM75_I2C,I2C_FLAG_SB)) && I2C_TimeOut)  /*!< EV5 */
  {
    I2C_TimeOut--;
  }
  if (I2C_TimeOut == 0)
  {
    return ERROR;
  }
  
  I2C_TimeOut = I2C_TIMEOUT;

  /*!< Send STLM75 slave address for write */
  I2C_Send7bitAddress(LM75_I2C, LM75_ADDR, I2C_Direction_Transmitter);

  while ((!I2C_CheckEvent(LM75_I2C, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED)) && I2C_TimeOut)/* EV6 */
  {
    I2C_TimeOut--;
  }

  if ((I2C_GetFlagStatus(LM75_I2C, I2C_FLAG_AF) != 0x00) || (I2C_TimeOut == 0))
  {
    return ERROR;
  }
  else
  {
    return SUCCESS;
  }
}
开发者ID:0x00f,项目名称:STM32F1-workarea,代码行数:49,代码来源:stm32_eval_i2c_tsensor.c


示例2: i2c_write

int i2c_write(i2c_t *obj, int address, const char *data, int length, int stop) {
    I2C_TypeDef *i2c = (I2C_TypeDef *)(obj->i2c);
    int timeout;
    int count;
  
/*
    // Wait until the bus is not busy anymore
    timeout = LONG_TIMEOUT;
    while (I2C_GetFlagStatus(i2c, I2C_FLAG_BUSY) == SET) {
        timeout--;
        if (timeout == 0) {
            return 0;
        }
    }
*/

    i2c_start(obj);

    // Send slave address for write
    I2C_Send7bitAddress(i2c, address, I2C_Direction_Transmitter);
  
    // Wait address is acknowledged
    timeout = FLAG_TIMEOUT;
    while (I2C_CheckEvent(i2c, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED) == ERROR) {
        timeout--;
        if (timeout == 0) {
            return 0;
        }
    }

    for (count = 0; count < length; count++) {
        if (i2c_byte_write(obj, data[count]) != 1) {
            i2c_stop(obj);
            return 0;
        }
    }

    // If not repeated start, send stop.
    if (stop) {
        i2c_stop(obj);
    }

    return count;
}
开发者ID:23chrischen,项目名称:mbed,代码行数:44,代码来源:i2c_api.c


示例3: I2C_Write

Status I2C_Write(I2C_TypeDef* I2Cx, const uint8_t* buf,  uint32_t nbyte, uint8_t SlaveAddress)
{
    __IO uint32_t Timeout = 0;

    /* Enable Error IT (used in all modes: DMA, Polling and Interrupts */
    //    I2Cx->CR2 |= I2C_IT_ERR;

    if (nbyte)
      {
	Timed(I2C_GetFlagStatus(I2Cx, I2C_FLAG_BUSY));

	// Intiate Start Sequence

	I2C_GenerateSTART(I2Cx, ENABLE);
	Timed(!I2C_CheckEvent(I2Cx, I2C_EVENT_MASTER_MODE_SELECT));

	// Send Address  EV5

	I2C_Send7bitAddress(I2Cx, SlaveAddress, I2C_Direction_Transmitter);
    //Timed(!I2C_CheckEvent(I2Cx, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED));

	// EV6

	// Write first byte EV8_1

	I2C_SendData(I2Cx, *buf++);

	while (--nbyte) {

	  // wait on BTF

      //Timed(!I2C_GetFlagStatus(I2Cx, I2C_FLAG_BTF));
	  I2C_SendData(I2Cx, *buf++);
	}

    //Timed(!I2C_GetFlagStatus(I2Cx, I2C_FLAG_BTF));
	I2C_GenerateSTOP(I2Cx, ENABLE);
    //Timed(I2C_GetFlagStatus(I2C1, I2C_FLAG_STOPF));
      }
    return Success;
 errReturn:
    return Error;
}
开发者ID:metropt,项目名称:stm32bookexercises,代码行数:43,代码来源:i2c.c


示例4: AT24_Read

uint32_t AT24_Read(uint16_t Addr, uint8_t *pdata, int size)
{
  uint32_t Timeout;
   
  I2C_AcknowledgeConfig(I2C1, ENABLE);
    
  Timeout = I2C_TIMEOUT;   
  while(I2C_GetFlagStatus(I2C1, I2C_FLAG_BUSY)) { if((Timeout--) == 0) return 1; }
 
  I2C_GenerateSTART(I2C1, ENABLE);
 
  Timeout = I2C_TIMEOUT;   
  while(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_MODE_SELECT)) { if((Timeout--) == 0) return 1; }
 
  I2C_Send7bitAddress(I2C1, 0xA0, I2C_Direction_Transmitter);

  Timeout = I2C_TIMEOUT;   
  while(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED)) { if((Timeout--) == 0) return 1; }
 
  I2C_SendData(I2C1, (uint8_t)((Addr & 0xFF00) >> 8));
 
  Timeout = I2C_TIMEOUT;   
  while(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTED)) { if((Timeout--) == 0) return 1; }
 
  I2C_SendData(I2C1, (uint8_t)(Addr & 0x00FF));
 
  Timeout = I2C_TIMEOUT;   
  while(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTED)) { if((Timeout--) == 0) return 0; }
 
  I2C_GenerateSTART(I2C1, ENABLE);
 
  Timeout = I2C_TIMEOUT;   
  while(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_MODE_SELECT)) { if((Timeout--) == 0) return 1; }
 
  I2C_Send7bitAddress(I2C1, 0xA1, I2C_Direction_Receiver);
 
  while(size-- > 0)
  {
    Timeout = I2C_TIMEOUT;   
    while(!I2C_CheckEvent(I2C1,I2C_EVENT_MASTER_BYTE_RECEIVED))
    {
      if((Timeout--) == 0) return 1; 
    }
    *(pdata++) = I2C_ReceiveData(I2C1);
  }
  
  I2C_AcknowledgeConfig(I2C1, DISABLE);
  I2C_GenerateSTOP(I2C1, ENABLE);
  return 0;
}
开发者ID:TSURKOVSERGEY,项目名称:sdi,代码行数:50,代码来源:at24c512.c


示例5: ucI2C_ReadAck

uint8_t ucI2C_ReadAck(I2C_TypeDef* I2Cx) {
	uint8_t data;

	/* Enable ACK */
	I2Cx->CR1 |= I2C_CR1_ACK;

	/* Wait till not received */
	TM_I2C_Timeout = TM_I2C_TIMEOUT;
	while (!I2C_CheckEvent(I2Cx, I2C_EVENT_MASTER_BYTE_RECEIVED)) {
		if (--TM_I2C_Timeout == 0x00) {
			return 1;
		}
	}

	/* Read data */
	data = I2Cx->DR;

	/* Return data */
	return data;
}
开发者ID:torcek,项目名称:AUTOPILOT,代码行数:20,代码来源:I2C.c


示例6: sEE_I2C_DMA_TX_IRQHandler

/**
  * @brief  This function handles the DMA Tx Channel interrupt Handler.
  *     @note This function should be called in the
  *       DMA1_CHANNEL2_3_IRQHandler in the stm8l15x_it.c file.
  *
  *       // INTERRUPT_HANDLER(DMA1_CHANNEL2_3_IRQHandler, 3)
  *       // {
  *           // sEE_I2C_DMA_TX_IRQHandler();
  *       // }
  * @param  None
  * @retval None
  */
void sEE_I2C_DMA_TX_IRQHandler(void)
{
    /* Check if the DMA transfer is complete */
    if (DMA_GetFlagStatus(sEE_I2C_DMA_FLAG_TX_TC) != RESET)
    {
        /* Disable the DMA Tx Channel and Clear all its Flags */
        DMA_Cmd(sEE_I2C_DMA_CHANNEL_TX, DISABLE);
        DMA_ClearFlag(sEE_I2C_DMA_FLAG_TX_TC);

        /*!< Wait till all data have been physically transferred on the bus */
        while (!I2C_CheckEvent(sEE_I2C, I2C_EVENT_MASTER_BYTE_TRANSMITTED))
        {}

        /*!< Send STOP condition */
        I2C_GenerateSTOP(sEE_I2C, ENABLE);

        /* Reset the variable holding the number of data to be written */
        *sEEDataWritePointer = 0;
    }
}
开发者ID:glockwork,项目名称:ev-stm8l151k6-emotor,代码行数:32,代码来源:stm8_eval_i2c_ee.c


示例7: Temp_Read

	u8 Temp_Read(void)
	{
		
		 u8 MSB,LSB;
		 
		//等待I2C閒置
		while(I2C_GetFlagStatus(I2C1,I2C_FLAG_BUSY));
		I2C_AcknowledgeConfig(I2C1,ENABLE); 
		//啟動訊號
		I2C_GenerateSTART(I2C1,ENABLE);	
		while(I2C_CheckEvent(I2C1,I2C_EVENT_MASTER_MODE_SELECT)!=SUCCESS);

		//發送裝置位置
		I2C_Send7bitAddress(I2C1,0xF0,I2C_Direction_Transmitter);
		while(I2C_CheckEvent(I2C1,I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED)!=SUCCESS);
		I2C_Cmd(I2C1,ENABLE);

		//發送記憶體位置
		I2C_SendData(I2C1,0xE5);
		while(I2C_CheckEvent(I2C1,I2C_EVENT_MASTER_BYTE_TRANSMITTED)!=SUCCESS);

		//啟動訊號
		I2C_GenerateSTART(I2C1,ENABLE);	
		while(I2C_CheckEvent(I2C1,I2C_EVENT_MASTER_MODE_SELECT)!=SUCCESS);
		
		//發送裝置位置
		I2C_Send7bitAddress(I2C1,0xF0,I2C_Direction_Receiver);
		while(I2C_CheckEvent(I2C1,I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED)!=SUCCESS);

		//I2C_AcknowledgeConfig(I2C1,DISABLE); //ACK 關閉	
		MSB=I2C_ReceiveData(I2C1);
	
		while(I2C_CheckEvent(I2C1,I2C_EVENT_MASTER_BYTE_RECEIVED)!=SUCCESS);
		
		LSB=I2C_ReceiveData(I2C1);
	
		while(I2C_CheckEvent(I2C1,I2C_EVENT_MASTER_BYTE_RECEIVED)!=SUCCESS);
		
		 	//停止訊號
		I2C_GenerateSTOP(I2C1,ENABLE);
			
		USART_SendData(USART1,MSB);
	
	}
开发者ID:sss22213,项目名称:STM32-Remote-control-car,代码行数:44,代码来源:HTU21.c


示例8: sensor_read

uint8_t sensor_read(uint8_t sensor_address, uint8_t SUB)//read a byte from sensor
{ 
	uint8_t data;  

	/* Send START condition */ 
	I2C_GenerateSTART(I2C2, ENABLE); 

	/* Test on EV5 and clear it */ 
	while(!I2C_CheckEvent(I2C2, I2C_EVENT_MASTER_MODE_SELECT)); 

	/* In the case of a single data transfer disable ACK before reading the data */ 
    I2C_AcknowledgeConfig(I2C2, DISABLE); 

	/* Send EEPROM address for write */ 
	sensor_address=sensor_address|0x01;
	I2C_Send7bitAddress(I2C2, sensor_address, I2C_Direction_Transmitter); //0xD2

	/* Test on EV6 and clear it */ 
	while(!I2C_CheckEvent(I2C2, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED)); 

	/* Send the EEPROM's internal address to write to */ 
	I2C_SendData(I2C2, SUB);  

	/* Test on EV8 and clear it */ 
	while(!I2C_CheckEvent(I2C2, I2C_EVENT_MASTER_BYTE_TRANSMITTED)); 

	/* Send STRAT condition a second time */ 
	I2C_GenerateSTART(I2C2, ENABLE); 

	/* Test on EV5 and clear it */ 
	while(!I2C_CheckEvent(I2C2, I2C_EVENT_MASTER_MODE_SELECT)); 

	/* Send EEPROM address for read */ 
	I2C_Send7bitAddress(I2C2, sensor_address, I2C_Direction_Receiver); 

	/* Test on EV6 and clear it */ 
	while(!I2C_CheckEvent(I2C2, I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED)); 

	/* Send STOP Condition */ 
    I2C_GenerateSTOP(I2C2, ENABLE); 

	/* Test on EV7 and clear it */ 
	while(!I2C_CheckEvent(I2C2, I2C_EVENT_MASTER_BYTE_RECEIVED));    

	/* Read a byte from the EEPROM */ 
    data = I2C_ReceiveData(I2C2);   
	
	return data;   
} 
开发者ID:mainbody,项目名称:YellowDog,代码行数:49,代码来源:test.c


示例9: I2C_Read_Buf

 uint32_t I2C_Read_Buf(uint8_t* buf_ptr, uint32_t len){
	 uint32_t nbytes = 0;
	 I2C_AcknowledgeConfig(I2Cx, ENABLE);

	     for (nbytes = 0; nbytes < (int) len; nbytes++) {
	         /* Send NACK on the last byte */
	         if (nbytes == ((int) len - 1)) {
	             I2C_AcknowledgeConfig(I2Cx, DISABLE);

	             /* Send STOP Condition */
	             I2C_GenerateSTOP(I2Cx, ENABLE);
	         }

	         while(!I2C_CheckEvent(I2Cx, I2C_EVENT_MASTER_BYTE_RECEIVED)){}

	         /* Read a byte from the slave */
	         buf_ptr[nbytes] = I2C_ReceiveData(I2Cx);
	     }

	 return nbytes;
 }
开发者ID:arpaterson,项目名称:blink,代码行数:21,代码来源:i2c.c


示例10: ITG3200_read_burst

void ITG3200_read_burst(I2C_TypeDef * I2Cx, uint8_t devwrite ,uint8_t * data_out, uint8_t nBytes){

     // I2C_read_burst(I2Cx, slave_addr,ITG3200_XOUT_H, data_out, nBytes);

    I2C_start(I2Cx, devwrite, I2C_Direction_Transmitter);
    I2C_SendData(I2Cx,ITG3200_XOUT_H);
    while (I2C_GetFlagStatus(I2Cx, I2C_FLAG_BTF) == RESET);
    I2C_stop(I2Cx);
    I2C_start(I2Cx,devwrite, I2C_Direction_Receiver);
    I2C_AcknowledgeConfig(I2Cx, ENABLE);

    for(int i= 0; i < nBytes;  i++) {

      while( !I2C_CheckEvent(I2Cx, I2C_EVENT_MASTER_BYTE_RECEIVED) );
        data_out[i] = I2C_ReceiveData(I2Cx);
      }
      //set the stack pointer to X MSB
      //I2C_SendData(I2Cx,HMC8883_DATA_OUT_X_MSB_REG_ADDR);
      I2C_AcknowledgeConfig(I2Cx, DISABLE);
      I2C_stop(I2Cx);
}
开发者ID:stevelibre,项目名称:Mission-Control-Fw,代码行数:21,代码来源:ITG3200.c


示例11: readEndByteI2C

/**
	*************************************************************************************
  * @brief  read one byte without acknowledge and end conversation
  * @param  None
  * @retval the received byte
	**************************************************************************************
  */
static uint8_t readEndByteI2C(void){
	
	/* buffer for the received byte */
	uint8_t ReceivedByte;
	
	/* disabe acknowledge of received data */
	I2C_AcknowledgeConfig(I2C, DISABLE);
	
	/* wait until one byte has been received */
	while( !I2C_CheckEvent(I2C, I2C_EVENT_MASTER_BYTE_RECEIVED) );
	
	
	/* read data from I2C data register and return data byte */
	ReceivedByte = I2C_ReceiveData(I2C);
	
	/* send stop condition */
	I2C_GenerateSTOP(I2C, ENABLE);
	
	/* return value */
	return ReceivedByte;
}
开发者ID:Ben-Kaniobi,项目名称:eurobot_core,代码行数:28,代码来源:i2c.c


示例12: i2c_read

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

    if (length == 0) return 0;

    i2c_start(obj);

    // Send slave address for read
    I2C_Send7bitAddress(i2c, address, I2C_Direction_Receiver);

    // Wait address is acknowledged
    timeout = FLAG_TIMEOUT;
    while (I2C_CheckEvent(i2c, I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED) == ERROR) {
        timeout--;
        if (timeout == 0) {
            return 0;
        }
    }

    // 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:GvoOjeda,项目名称:mbed,代码行数:40,代码来源:i2c_api.c


示例13: I2C_ReadSByte1

void I2C_ReadSByte1(u8 id,u16 addr ,u8* pBuffer,u16 no)
{
    if(no==0)
		return;	
	while(I2C_GetFlagStatus(I2C2, I2C_FLAG_BUSY));		
	/*允许1字节1应答模式*/
	I2C_AcknowledgeConfig(I2C2, ENABLE);
	/* 发送起始位 */
    I2C_GenerateSTART(I2C2, ENABLE);
    while(!I2C_CheckEvent(I2C2, I2C_EVENT_MASTER_MODE_SELECT));/*EV5,主模式*/	
    /*发送器件地址(写)*/
    I2C_Send7bitAddress(I2C2,  id&0xfe, I2C_Direction_Transmitter);
    while (!I2C_CheckEvent(I2C2, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED));
	
	/*发送地址*/
	I2C_SendData(I2C2, addr>>8);
    while (!I2C_CheckEvent(I2C2, I2C_EVENT_MASTER_BYTE_TRANSMITTED));/*数据已发送*/		
	I2C_SendData(I2C2, addr);
    while (!I2C_CheckEvent(I2C2, I2C_EVENT_MASTER_BYTE_TRANSMITTED));/*数据已发送*/		
	
	/*起始位*/
	I2C_GenerateSTART(I2C2, ENABLE);
	while(!I2C_CheckEvent(I2C2, I2C_EVENT_MASTER_MODE_SELECT));	
	/*器件读*/
	I2C_Send7bitAddress(I2C2, id|I2C_READ, I2C_Direction_Receiver);
	while(!I2C_CheckEvent(I2C2, I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED));
    while (no)
    {
		if(no==1)
		{
     		I2C_AcknowledgeConfig(I2C2, DISABLE);	//最后一位后要关闭应答的
    		I2C_GenerateSTOP(I2C2, ENABLE);			//发送停止位
		}	    
		while(!I2C_CheckEvent(I2C2, I2C_EVENT_MASTER_BYTE_RECEIVED)); /* EV7 */
	    *pBuffer = I2C_ReceiveData(I2C2);
	    pBuffer++;
	    /* Decrement the read bytes counter */
	    no--;
    }
	//再次允许应答模式
	I2C_AcknowledgeConfig(I2C2, ENABLE);
}
开发者ID:qiurenguo2014,项目名称:youjiesun,代码行数:42,代码来源:bsp_i2c.c


示例14: i2cRead

void i2cRead(uint8_t device, uint8_t address, uint8_t *data, uint8_t length)
{
	i2cSendAddress(device, READ, address);

	int i;
	for(i = 0; i<length; i++)
	{
		/* Test on EV7 and clear it */
		while(!I2C_CheckEvent(I2C_BUS, I2C_EVENT_MASTER_BYTE_RECEIVED));

		*data = I2C_ReceiveData(I2C_BUS);
		data++;

		 /* Disable Acknowledgement */
        if(!(i < (length - 1)))
            I2C_AcknowledgeConfig(I2C_BUS, DISABLE);

	}

    /* Send STOP Condition */
    I2C_GenerateSTOP(I2C_BUS, ENABLE);
}
开发者ID:Tostikoning,项目名称:GeekCopter,代码行数:22,代码来源:i2c.c


示例15: read8

short read8(I2C_TypeDef* I2Cx){
	uint8_t msb=0, lsb=0;
	unsigned char dummy1;
	unsigned short data;

	I2C_AcknowledgeConfig(I2Cx, ENABLE);
	while(I2C_GetFlagStatus(I2Cx, I2C_FLAG_BUSY));

	I2C_GenerateSTART(I2Cx, ENABLE);
	while(!I2C_GetFlagStatus(I2Cx, I2C_FLAG_SB));
	while(!I2C_CheckEvent(I2Cx, I2C_EVENT_MASTER_MODE_SELECT));

	I2C_Send7bitAddress(I2Cx,0x6B<<1,I2C_Direction_Transmitter);
	while(!I2C_CheckEvent(I2Cx, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED));

	I2C_SendData(I2Cx,0x28);
	while(!I2C_GetFlagStatus(I2Cx,I2C_FLAG_TXE));
	while(!I2C_CheckEvent(I2Cx, I2C_EVENT_MASTER_BYTE_TRANSMITTED));

	I2C_GenerateSTART(I2Cx, ENABLE);
	while(!I2C_GetFlagStatus(I2Cx, I2C_FLAG_SB));

	I2C_Send7bitAddress(I2Cx, 0x6B<<1, I2C_Direction_Receiver);
	while (!I2C_CheckEvent(I2Cx, I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED));

	msb = I2C_ReceiveData(I2Cx);
	while(!I2C_CheckEvent(I2Cx, I2C_EVENT_MASTER_BYTE_RECEIVED));

	I2C_NACKPositionConfig(I2Cx, I2C_NACKPosition_Current);
	I2C_AcknowledgeConfig(I2Cx, DISABLE);

	lsb = I2C_ReceiveData(I2Cx);
	while(!I2C_CheckEvent(I2Cx, I2C_EVENT_MASTER_BYTE_RECEIVED));

	//dummy1 = I2C_ReceiveData(I2Cx);
	//while(!I2C_CheckEvent(I2Cx, I2C_EVENT_MASTER_BYTE_RECEIVED));

	I2C_GenerateSTOP(I2Cx, ENABLE);
	while(I2C_GetFlagStatus(I2Cx, I2C_FLAG_STOPF));


	data  = msb<<8;
	data |= lsb;

	return data;
}
开发者ID:fwjensen,项目名称:C_examplecode_using_STM32F407,代码行数:46,代码来源:I2C_for_gyro_L3GD20H.c


示例16: eeprom_write_int_addr

void eeprom_write_int_addr(uint16_t addr,uint32_t data)
{
    eeprom_prelude();
    I2C_SendData(I2C1,  (uint8_t)addr>>8);
    while( !I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTED) );
    I2C_SendData(I2C1, (uint8_t)addr&0xff);
    while( !I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTED) );
    I2C_SendData(I2C1, (uint8_t)(data>>24));
    while( !I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTED) );
    I2C_SendData(I2C1, (uint8_t)((data>>16)&0xff));
    while( !I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTED) );
    I2C_SendData(I2C1, (uint8_t)((data>>8 )&0xff));
    while( !I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTED) );
    I2C_SendData(I2C1, (uint8_t)((data    )&0xff));
    while( !I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTED) );
    I2C_GenerateSTOP(I2C1,ENABLE);
}
开发者ID:SanderDemeester,项目名称:STM32L100C-Discovery,代码行数:17,代码来源:24lc.c


示例17: I2C_start

uint8_t i2c::readNack(uint8_t address,  bool readMore = true)
{
	uint8_t data;

	if(started  == false)
	{
		started = true;
		I2C_start(I2Cx, address, I2C_Direction_Receiver);
	}
	
	
	I2C_AcknowledgeConfig(I2Cx, ENABLE); // enable acknowledge of recieved data
	I2C_GenerateSTOP(I2Cx, ENABLE);
	
	// wait until one byte has been received
	while( !I2C_CheckEvent(I2Cx, I2C_EVENT_MASTER_BYTE_RECEIVED) );
	
	return I2C_ReceiveData(I2Cx); // read data from I2C data register and return data byte
	
	
	
	started = false;
}
开发者ID:bmaxfie,项目名称:Cerulean-Hardware,代码行数:23,代码来源:i2c.cpp


示例18: i2c_sendData

int i2c_sendData(I2C_TypeDef* I2Cx,int data){
  I2C_SendData(I2Cx, data);
  //usart_printf(USARTx,"Sending data:%d\n\r",data);      
  int timeout;
        uint8_t flag1=0,flag2=0;
        /* Test on I2C1 EV8 and clear it */
        timeout = I2C_TIMEOUT_MAX; /* Initialize timeout value */
         
        while(!I2C_CheckEvent(I2Cx, I2C_EVENT_MASTER_BYTE_TRANSMITTING))
        {
             
          /* If the timeout delay is exeeded, exit with error code */
          if ((timeout--) == 0) {
            flag1 = I2Cx->SR1;
           flag2 = I2Cx->SR2;
           usart_printf(USARTx,"Flag1:%04x \n\r Flag2:%04x\n\r",flag1,flag2);
           usart_printf(USARTx,"Failing at sending data");
            return -3;
            
          }
        }  
return 0;
}
开发者ID:raymoss,项目名称:ProjectFalcon,代码行数:23,代码来源:my_i2c.c


示例19: ADXL345_read_burst

void ADXL345_read_burst(I2C_TypeDef * I2Cx, uint8_t devread, uint8_t * data_out, uint8_t nBytes ){

        //write mode byte to the fifo control register
          ADXL345_write_register(I2C1, ADXL345_FIFO_CONTROL_REG, devread, ADXL345_FIFO_MODE(ADXL345_FIFO_STREAM));

          I2C_start(I2Cx, devread, I2C_Direction_Transmitter);
          I2C_SendData(I2Cx, ADXL345_X_AXIS_DATA_REG0); 
          //send register address to be read from first (x0) the ADXL345 increments pointer 
          //to access follow up  registers automatically
       
          while (I2C_GetFlagStatus(I2Cx, I2C_FLAG_BTF) == RESET);
            I2C_stop(I2Cx);
            I2C_start(I2Cx,(uint8_t)ADXL345_SLAVE_READ_ADDR , I2C_Direction_Receiver);
            I2C_AcknowledgeConfig(I2Cx, ENABLE);

            for(int i = 0; i < nBytes-1; i++) {
            // wait until one byte has been received
             while( !I2C_CheckEvent(I2Cx, I2C_EVENT_MASTER_BYTE_RECEIVED) );
          // read data from I2C data register and return data byte
            data_out[i] = I2C_ReceiveData(I2Cx);
            }
         data_out[nBytes -1]  = ADXL345_read_nack(I2Cx, ADXL345_Z_AXIS_DATA_REG1, (uint8_t)ADXL345_SLAVE_READ_ADDR);
}
开发者ID:stevelibre,项目名称:Mission-Control-Fw,代码行数:23,代码来源:ADXL345.c


示例20: MPU6050_Read_Data

void MPU6050_Read_Data()
{
	uint8_t i;

	I2C_AcknowledgeConfig(I2C2, ENABLE);

    I2C_GenerateSTART(I2C2, ENABLE);
    while (!I2C_CheckEvent(I2C2, I2C_EVENT_MASTER_MODE_SELECT));

    I2C_Send7bitAddress(I2C2, MPU6050_I2C_ADDR, I2C_Direction_Transmitter);
    while (!I2C_CheckEvent(I2C2, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED));

    I2C_SendData(I2C2, MPU6050_ACCEL_XOUT_H);
    while (!I2C_CheckEvent(I2C2, I2C_EVENT_MASTER_BYTE_TRANSMITTED));

    I2C_GenerateSTART(I2C2, ENABLE);
    while (!I2C_CheckEvent(I2C2, I2C_EVENT_MASTER_MODE_SELECT));

    I2C_Send7bitAddress(I2C2, MPU6050_I2C_ADDR, I2C_Direction_Receiver);
    while (!I2C_CheckEvent(I2C2, I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED));

    for (i=0;i<14;i++)
    {
    	while (!I2C_CheckEvent(I2C2, I2C_EVENT_MASTER_BYTE_RECEIVED));
        MPU6050_Data_Buffer[i] = I2C_ReceiveData(I2C2);

        if (i == 12)
        {
        	I2C_NACKPositionConfig(I2C2, I2C_NACKPosition_Current);
            I2C_AcknowledgeConfig(I2C2, DISABLE);
        }
    }

    Acc_X = MPU6050_Data_Buffer[0]<<8 | MPU6050_Data_Buffer[1];
    Acc_Y = MPU6050_Data_Buffer[2]<<8 | MPU6050_Data_Buffer[3];
    Acc_Z = MPU6050_Data_Buffer[4]<<8 | MPU6050_Data_Buffer[5];

    Gyr_X = MPU6050_Data_Buffer[8]<<8  | MPU6050_Data_Buffer[9];
    Gyr_Y = MPU6050_Data_Buffer[10]<<8 | MPU6050_Data_Buffer[11];
    Gyr_Z = MPU6050_Data_Buffer[12]<<8 | MPU6050_Data_Buffer[13];

    Temp = MPU6050_Data_Buffer[6]<<8 | MPU6050_Data_Buffer[7];

    Temp = (float)((float)((int16_t)Temp/(float)340.0) + (float)36.53);
}
开发者ID:robot-maker,项目名称:STM32F407,代码行数:45,代码来源:MPU6050.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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