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

C++ I2C_Cmd函数代码示例

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

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



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

示例1: I2C_Master_Initialise

/****************************************************************************************************
 * @fn      I2C_Master_Initialise
 *          Call this function to set up the I2C master to its initial standby state.
 *          Remember to enable interrupts from the main application after initializing the I2C.
 *
 * @param   none
 *
 * @return  none
 *
 ***************************************************************************************************/
void I2C_Master_Initialise(void)
{
    I2C_InitTypeDef   I2C_InitStructure;

    /* Configure the I2C interface */
    I2C_Cmd(I2C_SENSOR_BUS, ENABLE);

    I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;
    I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2;
    I2C_InitStructure.I2C_OwnAddress1 = 0; //Don't care in master mode
    I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;
    I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
    I2C_InitStructure.I2C_ClockSpeed = I2C_SENSOR_BUS_CLOCK;
    I2C_Init(I2C_SENSOR_BUS, &I2C_InitStructure);

    asyncXfer.i2c_txrx_status = I2C_TXRX_STATUS_PASSED;     //initialize last comm status
    /* Note: I2C bus event and error interrupts are enabled when tx is started */
}
开发者ID:crankycoder,项目名称:open-sensor-platform,代码行数:28,代码来源:i2c_driver.c


示例2: LM75_Init

/**
  * @brief  Initializes the LM75_I2C.
  * @param  None
  * @retval None
  */
void LM75_Init(void)
{

  LM75_LowLevel_Init();

  /* I2C DeInit */
  I2C_DeInit(LM75_I2C);

  /* I2C configuration */
  I2C_Init(LM75_I2C, LM75_I2C_SPEED, 0x00, I2C_Mode_SMBusHost,
           I2C_DutyCycle_2, I2C_Ack_Enable, I2C_AcknowledgedAddress_7bit);

  /*!< Enable SMBus Alert interrupt */
  I2C_ITConfig(LM75_I2C, I2C_IT_ERR, ENABLE);

  /*!< LM75_I2C Init */
  I2C_Cmd(LM75_I2C, ENABLE);
}
开发者ID:glockwork,项目名称:ev-stm8l151k6-emotor,代码行数:23,代码来源:stm8_eval_i2c_tsensor.c


示例3: I2C_Mode_Config

/*
 * 函数名:I2C_Mode_Config
 * 描述  :I2C 工作模式配置
 * 输入  :无
 * 输出  :无
 * 调用  :内部调用
 */
static void I2C_Mode_Config(void)
{
    /* Initialize the I2C1 according to the I2C_InitStructure members */
    I2C_InitTypeDef I2C_InitStructure;
    /* I2C 配置 */
    I2C_InitStructure.I2C_Mode = I2C_Mode_I2C ;
    //I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2;
    //I2C_InitStructure.I2C_OwnAddress1 = SlaveAddress;
    I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;
    I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
    I2C_InitStructure.I2C_ClockSpeed = 350000;
    /* I2C1 初始化 */
    I2C_Init(I2C1, &I2C_InitStructure);
    /* 使能 I2C1 */
    I2C_Cmd(I2C1, ENABLE);
    /*允许应答模式*/
    I2C_AcknowledgeConfig(I2C1, ENABLE);
}
开发者ID:LiuHuiGitHub,项目名称:STM32F103C8,代码行数:25,代码来源:I2C_MPU6050.c


示例4: P_I2C3_InitI2C

//--------------------------------------------------------------
// interne Funktion
// Init der I2C-Schnittstelle
//--------------------------------------------------------------
void P_I2C3_InitI2C(void)
{
  I2C_InitTypeDef  I2C_InitStructure;

  // I2C-Konfiguration
  I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;
  I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2;
  I2C_InitStructure.I2C_OwnAddress1 = 0x00;
  I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;
  I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
  I2C_InitStructure.I2C_ClockSpeed = I2C3_CLOCK_FRQ;

  // I2C enable
  I2C_Cmd(I2C3, ENABLE);

  // Init Struktur
  I2C_Init(I2C3, &I2C_InitStructure);
}
开发者ID:duvitech,项目名称:STM32F429i-Disco_OSC,代码行数:22,代码来源:stm32_ub_i2c3.c


示例5: platform_i2c_setup

/* I2C Functions */
u32 platform_i2c_setup( unsigned id, u32 speed )
{
	GPIO_InitTypeDef GPIO_InitStruct;
	I2C_InitTypeDef I2C_InitStruct;
	
	// enable APB1 peripheral clock for I2C1
	RCC_APB1PeriphClockCmd(i2c_rcc[id], ENABLE);
	// enable clock for SCL and SDA pins
	RCC_AHB1PeriphClockCmd(i2c_port_rcc[id], ENABLE);
	
	I2C_DeInit(i2c[id]);
	
	/* setup SCL and SDA pins
	 * You can connect I2C1 to two different
	 * pairs of pins:
	 * 1. SCL on PB6 and SDA on PB7 
	 * 2. SCL on PB8 and SDA on PB9
	 */
	GPIO_InitStruct.GPIO_Pin = i2c_scl_pin[id] | i2c_sda_pin[id]; // pins to use
	GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;		 // set pins to alternate function
	GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;		// set GPIO speed
	GPIO_InitStruct.GPIO_OType = GPIO_OType_OD;		// set output to open drain --> the line has to be only pulled low, not driven high
	GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_UP;		// enable pull up resistors
	GPIO_Init(i2c_port[id], &GPIO_InitStruct);			// init GPIO
	
	// Connect I2C1 pins to AF  
	GPIO_PinAFConfig(i2c_port[id], i2c_scl_pinsource[id], i2c_af[id]);	// SCL
	GPIO_PinAFConfig(i2c_port[id], i2c_sda_pinsource[id], i2c_af[id]); // SDA
	
	// configure I2C1 
	I2C_StructInit(&I2C_InitStruct);
	I2C_InitStruct.I2C_ClockSpeed = speed; 		//set speed (100kHz or 400kHz)
	I2C_InitStruct.I2C_Mode = I2C_Mode_I2C;			// I2C mode
	I2C_InitStruct.I2C_DutyCycle = I2C_DutyCycle_2;	// 50% duty cycle --> standard
	I2C_InitStruct.I2C_OwnAddress1 = 0x00;			// own address, not relevant in master mode
	I2C_InitStruct.I2C_Ack = I2C_Ack_Disable;		// disable acknowledge when reading (can be changed later on)
	I2C_InitStruct.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit; // set address length to 7 bit addresses
	I2C_Init(i2c[id], &I2C_InitStruct);				// init I2C1
	
	// enable I2C1
	I2C_Cmd(i2c[id], ENABLE);

	return speed;
}
开发者ID:ptLong,项目名称:ruuvitracker_fw,代码行数:45,代码来源:platform_i2c.c


示例6: i2cInit

void i2cInit(I2C_TypeDef *I2C)
{
    NVIC_InitTypeDef NVIC_InitStructure;
    GPIO_InitTypeDef GPIO_InitStructure;
    I2C_InitTypeDef I2C_InitStructure;

    // Init pins
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;
    GPIO_Init(GPIOB, &GPIO_InitStructure);

    I2Cx = I2C;

    // clock out stuff to make sure slaves arent stuck
    i2cUnstick();

    // Init I2C
    I2C_DeInit(I2Cx);
    I2C_StructInit(&I2C_InitStructure);

    I2C_ITConfig(I2Cx, I2C_IT_EVT | I2C_IT_ERR, DISABLE);       //Enable EVT and ERR interrupts - they are enabled by the first request
    I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;
    I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2;
    I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
    I2C_InitStructure.I2C_ClockSpeed = 400000;
    I2C_Cmd(I2Cx, ENABLE);
    I2C_Init(I2Cx, &I2C_InitStructure);

    NVIC_PriorityGroupConfig(0x500);

    // I2C ER Interrupt
    NVIC_InitStructure.NVIC_IRQChannel = I2C2_ER_IRQn;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
    NVIC_Init(&NVIC_InitStructure);

    // I2C EV Interrupt
    NVIC_InitStructure.NVIC_IRQChannel = I2C2_EV_IRQn;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
    NVIC_Init(&NVIC_InitStructure);

}
开发者ID:kh4,项目名称:openLRSngRX32_test,代码行数:44,代码来源:drv_i2c.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: sEE_LowLevel_DeInit

/**
  * @brief  DeInitializes peripherals used by the I2C EEPROM driver.
  * @param  None
  * @retval None
  */
void sEE_LowLevel_DeInit(void)
{
    GPIO_InitTypeDef  GPIO_InitStructure;
    NVIC_InitTypeDef NVIC_InitStructure;

    /* sEE_I2C Peripheral Disable */
    I2C_Cmd(sEE_I2C, DISABLE);

    /* sEE_I2C DeInit */
    I2C_DeInit(sEE_I2C);

    /*!< sEE_I2C Periph clock disable */
    RCC_APB1PeriphClockCmd(sEE_I2C_CLK, DISABLE);

    /*!< GPIO configuration */
    /*!< Configure sEE_I2C pins: SCL */
    GPIO_InitStructure.GPIO_Pin = sEE_I2C_SCL_PIN;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
    GPIO_Init(sEE_I2C_SCL_GPIO_PORT, &GPIO_InitStructure);

    /*!< Configure sEE_I2C pins: SDA */
    GPIO_InitStructure.GPIO_Pin = sEE_I2C_SDA_PIN;
    GPIO_Init(sEE_I2C_SDA_GPIO_PORT, &GPIO_InitStructure);

    /* Configure and enable I2C DMA TX Channel interrupt */
    NVIC_InitStructure.NVIC_IRQChannel = sEE_I2C_DMA_TX_IRQn;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = sEE_I2C_DMA_PREPRIO;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = sEE_I2C_DMA_SUBPRIO;
    NVIC_InitStructure.NVIC_IRQChannelCmd = DISABLE;
    NVIC_Init(&NVIC_InitStructure);

    /* Configure and enable I2C DMA RX Channel interrupt */
    NVIC_InitStructure.NVIC_IRQChannel = sEE_I2C_DMA_RX_IRQn;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = sEE_I2C_DMA_PREPRIO;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = sEE_I2C_DMA_SUBPRIO;
    NVIC_Init(&NVIC_InitStructure);

    /* Disable and Deinitialize the DMA channels */
    DMA_Cmd(sEE_I2C_DMA_CHANNEL_TX, DISABLE);
    DMA_Cmd(sEE_I2C_DMA_CHANNEL_RX, DISABLE);
    DMA_DeInit(sEE_I2C_DMA_CHANNEL_TX);
    DMA_DeInit(sEE_I2C_DMA_CHANNEL_RX);
}
开发者ID:richardtoller,项目名称:BD,代码行数:49,代码来源:stm32l152d_eval.c


示例9: sEE_Init

/**
  * @brief  Initializes peripherals used by the I2C EEPROM driver.
  * @param  None
  * @retval None
  */
void sEE_Init(void)
{
    sEE_LowLevel_Init();

    /*!< I2C configuration */
    /* sEE_I2C Peripheral Enable */
    I2C_Cmd(sEE_I2C, ENABLE);
    /* sEE_I2C configuration after enabling it */
    I2C_Init(sEE_I2C, I2C_SPEED, I2C_SLAVE_ADDRESS7, I2C_Mode_I2C, I2C_DutyCycle_2,
             I2C_Ack_Enable, I2C_AcknowledgedAddress_7bit);

    /* Enable the sEE_I2C peripheral DMA requests */
    I2C_DMACmd(sEE_I2C, ENABLE);

#if defined (sEE_M24C64_32)
    /*!< Select the EEPROM address according to the state of E0, E1, E2 pins */
    sEEAddress = sEE_HW_ADDRESS;
#endif /*!< sEE_M24C64_32 */
}
开发者ID:glockwork,项目名称:ev-stm8l151k6-emotor,代码行数:24,代码来源:stm8_eval_i2c_ee.c


示例10: ade7880_i2c_cfg

void ade7880_i2c_cfg(void)
{

	I2C_InitTypeDef I2C_InitStructure;

	I2C_DeInit(I2C2);
	I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;
	I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2;  
	I2C_InitStructure.I2C_OwnAddress1 = 0x01; 
	I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;  
	I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit; 
	I2C_InitStructure.I2C_ClockSpeed = 50000; 

	I2C_Init(I2C2, &I2C_InitStructure);   
	I2C_Cmd(I2C2, DISABLE);

 
	return;
}  
开发者ID:malooei,项目名称:yeejoin-workspace,代码行数:19,代码来源:board.c


示例11: Codec_CtrlInterface_Init

/**
  * @brief Initializes the Audio Codec control interface (I2C).
  * @param  None.
  * @retval None.
  */
static void Codec_CtrlInterface_Init(void)
{
  I2C_InitTypeDef I2C_InitStructure;
  
  /* Enable the CODEC_I2C peripheral clock */
  RCC_APB1PeriphClockCmd(CODEC_I2C_CLK, ENABLE);
  
  /* CODEC_I2C peripheral configuration */
  I2C_DeInit(CODEC_I2C);
  I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;
  I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2;
  I2C_InitStructure.I2C_OwnAddress1 = 0x33;
  I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;
  I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
  I2C_InitStructure.I2C_ClockSpeed = I2C_SPEED;
  /* Enable the I2C peripheral */
  I2C_Cmd(CODEC_I2C, ENABLE);  
  I2C_Init(CODEC_I2C, &I2C_InitStructure); 
}
开发者ID:Ghanyy,项目名称:PTM-STM32F4,代码行数:24,代码来源:stm3210c_usb_audio_codec.c


示例12: I2C_Initialise

void I2C_Initialise()
{
    I2C_InitTypeDef I2C_InitStruct;
    
    RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C1, ENABLE);
	RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C1, DISABLE);
    
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1, ENABLE);

	I2C_InitStruct.I2C_Ack = I2C_Ack_Enable;
	I2C_InitStruct.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
	I2C_InitStruct.I2C_ClockSpeed = 100000;
	I2C_InitStruct.I2C_DutyCycle = I2C_DutyCycle_2;
	I2C_InitStruct.I2C_Mode = I2C_Mode_I2C;
	I2C_InitStruct.I2C_OwnAddress1 = 0x00;
	I2C_Init(I2C1, &I2C_InitStruct);

	I2C_Cmd(I2C1, ENABLE);
}
开发者ID:fwjensen,项目名称:STM32_init,代码行数:19,代码来源:10-DOF_IUM.c


示例13: i2cInit

void i2cInit(I2C_TypeDef *I2C)
{
    NVIC_InitTypeDef nvic;
    I2C_InitTypeDef i2c;
    gpio_config_t gpio;

    RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C2 | RCC_APB2Periph_GPIOB, ENABLE);

    // Init pins
    gpio.pin = Pin_10 | Pin_11;
    gpio.speed = Speed_2MHz;
    gpio.mode = Mode_AF_OD;
    gpioInit(GPIOB, &gpio);

    I2Cx = I2C;

    // clock out stuff to make sure slaves arent stuck
    i2cUnstick();

    // Init I2C
    I2C_DeInit(I2Cx);
    I2C_StructInit(&i2c);

    I2C_ITConfig(I2Cx, I2C_IT_EVT | I2C_IT_ERR, DISABLE);               // Enable EVT and ERR interrupts - they are enabled by the first request
    i2c.I2C_Mode = I2C_Mode_I2C;
    i2c.I2C_DutyCycle = I2C_DutyCycle_2;
    i2c.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
    i2c.I2C_ClockSpeed = 400000;
    I2C_Cmd(I2Cx, ENABLE);
    I2C_Init(I2Cx, &i2c);

    // I2C ER Interrupt
    nvic.NVIC_IRQChannel = I2C2_ER_IRQn;
    nvic.NVIC_IRQChannelPreemptionPriority = 0;
    nvic.NVIC_IRQChannelSubPriority = 0;
    nvic.NVIC_IRQChannelCmd = ENABLE;
    NVIC_Init(&nvic);

    // I2C EV Interrupt
    nvic.NVIC_IRQChannel = I2C2_EV_IRQn;
    nvic.NVIC_IRQChannelPreemptionPriority = 0;
    NVIC_Init(&nvic);
}
开发者ID:Reini60,项目名称:cleanflight,代码行数:43,代码来源:bus_i2c_stm32f10x.c


示例14: i2cInit

void i2cInit(I2C_TypeDef* I2Cx)
{
    chSemObjectInit(&i2c1_semI, 1);
    chSemObjectInit(&i2c1_semS, 1);

    I2C_InitTypeDef I2C_InitStructure;

    I2C_StructInit(&I2C_InitStructure);
    I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;
    I2C_InitStructure.I2C_AnalogFilter = I2C_AnalogFilter_Disable;
    I2C_InitStructure.I2C_DigitalFilter = 0x00;
    I2C_InitStructure.I2C_OwnAddress1 = 0x00;
    I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;
    I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
    I2C_InitStructure.I2C_Timing = 0x0070D8FF;
    I2C_Init(I2Cx, &I2C_InitStructure);

    I2C_Cmd(I2Cx, ENABLE);
}
开发者ID:eos1d3,项目名称:OpenTCS,代码行数:19,代码来源:communications.c


示例15: i2c_frequency

void i2c_frequency(i2c_t *obj, int hz) {
    I2C_TypeDef *i2c = (I2C_TypeDef *)(obj->i2c);
    I2C_InitTypeDef I2C_InitStructure;

    if ((hz != 0) && (hz <= 400000)) {
        I2C_DeInit(i2c);

        // I2C configuration
        I2C_InitStructure.I2C_Mode                = I2C_Mode_I2C;
        I2C_InitStructure.I2C_DutyCycle           = I2C_DutyCycle_2;
        I2C_InitStructure.I2C_OwnAddress1         = 0;
        I2C_InitStructure.I2C_Ack                 = I2C_Ack_Enable;
        I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
        I2C_InitStructure.I2C_ClockSpeed          = hz;
        I2C_Init(i2c, &I2C_InitStructure);

        I2C_Cmd(i2c, ENABLE);
    }
}
开发者ID:GvoOjeda,项目名称:mbed,代码行数:19,代码来源:i2c_api.c


示例16: I2C1_Configuration

void I2C1_Configuration(void){

	I2C_InitTypeDef  I2C_InitStructure;

	I2C_DeInit(I2C1);

  	/* I2C1 configuration ------------------------------------------------------*/
  	I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;
  	I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2;
  	I2C_InitStructure.I2C_OwnAddress1 = I2C2_ADDRESS7;
  	I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;
  	I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
  	I2C_InitStructure.I2C_ClockSpeed = I2C_CLOCK;
  	I2C_Init(I2C1, &I2C_InitStructure);

  	I2C_ITConfig(I2C1, I2C_IT_EVT, ENABLE);

  	I2C_Cmd(I2C1, ENABLE);
}
开发者ID:franzflasch,项目名称:stm32f1-base-platform,代码行数:19,代码来源:stm32_configuration.c


示例17: LM75_LowLevel_DeInit

/**
  * @brief  DeInitializes the LM75_I2C.
  * @param  None
  * @retval None
  */
void LM75_LowLevel_DeInit(void)
{
  /*!< Disable LM75_I2C */
  I2C_Cmd(LM75_I2C, DISABLE);
  /*!< DeInitializes the LM75_I2C */
  I2C_DeInit(LM75_I2C);

  /*!< LM75_I2C Periph clock disable */
  CLK_PeripheralClockConfig(LM75_I2C_CLK, DISABLE);

  /*!< Configure LM75_I2C pins: SCL */
  GPIO_Init(LM75_I2C_SCL_GPIO_PORT, LM75_I2C_SCL_PIN, GPIO_Mode_In_PU_No_IT);

  /*!< Configure LM75_I2C pins: SDA */
  GPIO_Init(LM75_I2C_SDA_GPIO_PORT, LM75_I2C_SDA_PIN, GPIO_Mode_In_PU_No_IT);

  /*!< Configure LM75_I2C pin: SMBUS ALERT */
  GPIO_Init(LM75_I2C_SMBUSALERT_GPIO_PORT, LM75_I2C_SMBUSALERT_PIN, GPIO_Mode_In_FL_No_IT);
}
开发者ID:fm0597,项目名称:WSN_NodeDriver,代码行数:24,代码来源:stm8l1528_eval.c


示例18: I2C_LowLevel_Init

void I2C_LowLevel_Init(void) {
    GPIO_InitTypeDef  GPIO_InitStructure;
    I2C_InitTypeDef   I2C_InitStructure;

    //Enable the i2c
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2Cx, ENABLE);
    //Reset the Peripheral
    RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2Cx, ENABLE);
    RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2Cx, DISABLE);

    //Enable the GPIOs for the SCL/SDA Pins
    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIO_SCL | RCC_AHB1Periph_GPIO_SDA, ENABLE);

    //Configure and initialize the GPIOs
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_SCL;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
    GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
    GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_UP;
    GPIO_Init(GPIO_SCL, &GPIO_InitStructure);

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_SDA;
    GPIO_Init(GPIO_SDA, &GPIO_InitStructure);

    //Connect GPIO pins to peripheral
    GPIO_PinAFConfig(GPIO_SCL, GPIO_PinSource_SCL, GPIO_AF_I2Cx);
    GPIO_PinAFConfig(GPIO_SDA, GPIO_PinSource_SDA, GPIO_AF_I2Cx);

    //Configure and Initialize the I2C
    I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;
    I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2;
    I2C_InitStructure.I2C_OwnAddress1 = 0x00; //We are the master. We don't need this
    I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;
    I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
    I2C_InitStructure.I2C_ClockSpeed = 50000;  //400kHz (Fast Mode) (

    //Initialize the Peripheral
    I2C_Init(I2Cx, &I2C_InitStructure);
    // I2C Peripheral Enable
    I2C_Cmd(I2Cx, ENABLE);

    return;
}
开发者ID:jtec,项目名称:flightcode,代码行数:43,代码来源:I2CLib.c


示例19: I2C_Local_Config

static void I2C_Local_Config(void)
{

	I2C_InitTypeDef  I2C_InitStructure;

	/* I2C configuration */
	I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;
	I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2;
	I2C_InitStructure.I2C_OwnAddress1 = I2C_OWN_ADDRESS;
	I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;
	I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
	I2C_InitStructure.I2C_ClockSpeed = I2C_SPEED;

	/* I2C Peripheral Enable */
	I2C_Cmd(I2C_PORT, ENABLE);
	/* Apply I2C configuration after enabling it */
	I2C_Init(I2C_PORT, &I2C_InitStructure);

}
开发者ID:ozwin,项目名称:erts-project,代码行数:19,代码来源:bsp.c


示例20: I2C_EE_INIT

/*********************************************
* Function Name  : I2C_EE_INIT
* Description    : init module I2C EEPROM
*********************************************/
void I2C_EE_INIT(void){
 
	GPIO_InitTypeDef GPIO_InitStruct; // this is for the GPIO pins used as I2C_SDA and I2C_SCL
	I2C_InitTypeDef I2C_InitStruct; // this is for the I2C initilization
 

	/* enable APB1 peripheral clock for I2C*/
	RCC_APB1PeriphClockCmd(I2C_EE_RCC , ENABLE);
  RCC_AHB1PeriphClockCmd(I2C_EE_RCC_PORT , ENABLE); 
 
	GPIO_PinAFConfig(I2C_EE_PORT, I2C_EE_SDA_SOURCE, I2C_EE_GPIO_AF); //
	GPIO_PinAFConfig(I2C_EE_PORT, I2C_EE_SCL_SOURCE, I2C_EE_GPIO_AF);
	
	GPIO_InitStruct.GPIO_Pin = GPIO_EE_Pin_SCL | GPIO_EE_Pin_SDA ; // Pins (I2C_SCL) and (I2C_SDA)
	GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF; // the pins are configured as alternate function so the USART peripheral has access to them
	GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;// this defines the IO speed and has nothing to do with the baudrate!
	GPIO_InitStruct.GPIO_OType = GPIO_OType_OD;// this defines the output type as open drain
	GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;// this activates the pullup resistors on the IO pins
	GPIO_Init(I2C_EE_PORT, &GPIO_InitStruct);// now all the values are passed to the GPIO_Init() 
 
	
	 /* Configure I2C */
	//I2C_DeInit(I2C);

	/* Enable the I2C peripheral */
	
	/* Set the I2C structure parameters */
	I2C_InitStruct.I2C_Mode = I2C_Mode_I2C;
	I2C_InitStruct.I2C_DutyCycle = I2C_DutyCycle_2;
	I2C_InitStruct.I2C_OwnAddress1 = 0xA0;
	I2C_InitStruct.I2C_Ack = I2C_Ack_Enable;
	I2C_InitStruct.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
	I2C_InitStruct.I2C_ClockSpeed = 100000;

	/* Initialize the I2C peripheral w/ selected parameters */
/*	I2C_Init(I2C_EE,&I2C_InitStruct);
	I2C_Cmd(I2C_EE, ENABLE);
	*/
	I2C_Cmd(I2C_EE, ENABLE);
	I2C_Init(I2C_EE, &I2C_InitStruct);

}
开发者ID:kvintagav,项目名称:Giraffe,代码行数:46,代码来源:eeprom.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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