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

C++ I2C_DeInit函数代码示例

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

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



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

示例1: Codec_TIMEOUT_UserCallback

/**
  * @brief  Codec_TIMEOUT_UserCallback
  * @param  None
  * @retval None
  */
uint32_t Codec_TIMEOUT_UserCallback(void)
{
#if 0
  I2C_InitTypeDef I2C_InitStructure;
  
  LCD_ErrLog("> I2C Timeout error (CS43L22)\n");

  I2C_GenerateSTOP(I2C1, ENABLE);
  I2C_SoftwareResetCmd(I2C1, ENABLE);
  I2C_SoftwareResetCmd(I2C1, DISABLE);
    
  I2C_DeInit(I2C1);
  
  /* CODEC_I2C peripheral configuration */
  I2C_DeInit(I2C1);
  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(I2C1, ENABLE);  
  I2C_Init(I2C1, &I2C_InitStructure);  

  LCD_UsrLog("> I2C error recovered.\n");
#endif
  return 0;
}
开发者ID:MartinBspheroid,项目名称:LXR,代码行数:34,代码来源:usbd_usr.c


示例2: cpu_deinit_all

void cpu_deinit_all() {
//**    ADC_DeInit(LPC_ADC);
    CAN_DeInit(LPC_CAN1);
    CAN_DeInit(LPC_CAN2);
    EMAC_DeInit();
    EXTI_DeInit();
    I2C_DeInit(LPC_I2C0);
    I2C_DeInit(LPC_I2C1);
    I2C_DeInit(LPC_I2C2);
    I2S_DeInit(LPC_I2S);
    NVIC_DeInit();
    NVIC_SCBDeInit();
    PWM_DeInit(LPC_PWM1);
    QEI_DeInit(LPC_QEI);
//**    RIT_DeInit(LPC_RIT);
    RTC_DeInit(LPC_RTC);
    SPI_DeInit(LPC_SPI);
    SSP_DeInit(LPC_SSP0);
    SSP_DeInit(LPC_SSP1);
    UART_DeInit(LPC_UART0);
    UART_DeInit((LPC_UART_TypeDef *) LPC_UART1);
//**    UART_DeInit(LPC_UART2);
//**    UART_DeInit(LPC_UART3);
    TIM_DeInit(LPC_TIM0);
    TIM_DeInit(LPC_TIM1);
//**    TIM_DeInit(LPC_TIM2);
//**    TIM_DeInit(LPC_TIM3);
}
开发者ID:dtbinh,项目名称:M2,代码行数:28,代码来源:init.c


示例3: Init_I2C

void Init_I2C(void){

  I2C_InitTypeDef  I2C_InitStructure;
  GPIO_InitTypeDef GPIO_InitStructure;

  /* Enable I2C and GPIO clocks */
  RCC_APB1PeriphClockCmd(I2C_RCC_Periph, ENABLE);
  RCC_AHB1PeriphClockCmd(I2C_RCC_Port, ENABLE);
  /* Configure I2C pins: SCL and SDA */
  GPIO_InitStructure.GPIO_Pin =  I2C_SCL_Pin | I2C_SDA_Pin; 
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
  GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AF;
  GPIO_InitStructure.GPIO_OType=GPIO_OType_OD;
  GPIO_InitStructure.GPIO_PuPd=GPIO_PuPd_NOPULL;
  GPIO_Init(I2C_Port, &GPIO_InitStructure); 
      
  GPIO_PinAFConfig(GPIOB, GPIO_PinSource8, GPIO_AF_I2C1);
  GPIO_PinAFConfig(GPIOB, GPIO_PinSource7, GPIO_AF_I2C1);

  I2C_DeInit(I2C1);

  /* I2C configuration */
  I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;
  I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2;
  I2C_InitStructure.I2C_OwnAddress1 = 0x68<<1; 
  I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;
  I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
  I2C_InitStructure.I2C_ClockSpeed = I2C_Speed;

  /* Apply I2C configuration after enabling it */
  I2C_Init(I2C1, &I2C_InitStructure);
  /* I2C Peripheral Enable */  
  I2C_Cmd(I2C1, ENABLE);
}
开发者ID:srcnert,项目名称:My_Work_Place,代码行数:34,代码来源:i2c.c


示例4: iic_init

/*************************************************

名称:iic_init(void)
功能:iic外设2初始化(管脚配置 总线速度 数据位宽)
输入参数:无
输出参数:无
返回值:  无
**************************************************/
void iic_init(void)
{
  I2C_InitTypeDef  I2C_InitStructure;
  GPIO_InitTypeDef  GPIO_InitStructure; 

  RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1,ENABLE);
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);
    
  /* PB6,7 SCL and SDA */ 
  GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_6 | GPIO_Pin_7;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;
  GPIO_Init(GPIOB, &GPIO_InitStructure);
	
  I2C_DeInit(I2C1);
  I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;
  I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2;
  I2C_InitStructure.I2C_OwnAddress1 = 0x30;
  I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;
  I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
  I2C_InitStructure.I2C_ClockSpeed = 300000;  //200K

  I2C_Cmd(I2C1, ENABLE);
  I2C_Init(I2C1, &I2C_InitStructure);

  /*允许1字节1应答模式*/
  I2C_AcknowledgeConfig(I2C1, ENABLE);
}
开发者ID:52osworld,项目名称:4axis,代码行数:36,代码来源:iic.c


示例5: I2CHW_Reset

void I2CHW_Reset(void)
{
  __IO uint32_t Timeout;
  //uint8_t i;
  GPIO_InitTypeDef GPIO_InitStructure; 
  
  GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_9 | GPIO_Pin_8;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
  GPIO_Init(GPIOB, &GPIO_InitStructure);  
  
  I2C_DeInit(I2C1);
  RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C1, ENABLE);
  RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C1, DISABLE);  
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1, DISABLE);
 
  //  GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_9 | GPIO_Pin_8;
  //  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  //  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  //  GPIO_Init(GPIOB, &GPIO_InitStructure);
  //  
  //  GPIO_SetBits(GPIOB,GPIO_Pin_9);
  //  GPIO_SetBits(GPIOB,GPIO_Pin_8);
  //  Timeout=0x1ff;
  //  while(Timeout--);
  
  I2C_Configuration();
  Timeout=0x1ff;
  while(Timeout--);  
}    
开发者ID:003900107,项目名称:wpa900-V2-ai-V1.0,代码行数:30,代码来源:bsp.c


示例6: i2cSetup

void i2cSetup(uint32_t speed) {
	I2C_InitTypeDef i2cConfig;

	// GPIO Init
	RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);

	GPIO_PinAFConfig(GPIOB, GPIO_PinSource6, GPIO_AF_I2C1);
	GPIO_PinAFConfig(GPIOB, GPIO_PinSource9, GPIO_AF_I2C1);

	GPIO_Init(GPIOB, &(GPIO_InitTypeDef){GPIO_Pin_6, GPIO_Mode_AF, GPIO_Speed_50MHz, GPIO_OType_OD, GPIO_PuPd_NOPULL});
	GPIO_Init(GPIOB, &(GPIO_InitTypeDef){GPIO_Pin_9, GPIO_Mode_AF, GPIO_Speed_50MHz, GPIO_OType_OD, GPIO_PuPd_NOPULL});

	RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1, ENABLE);

	// I2C init
	I2C_StructInit(&i2cConfig);

	// TODO - Figure out why the speed isn't being set porperly
	i2cConfig.I2C_ClockSpeed = speed;

	i2cConfig.I2C_DutyCycle = I2C_DutyCycle_16_9;

	I2C_DeInit(I2C1);

	I2C_Init(I2C1, &i2cConfig);

	I2C_ITConfig(I2C1, I2C_IT_ERR, ENABLE);
	NVIC_EnableIRQ(I2C1_ER_IRQn);

	I2C_Cmd(I2C1, ENABLE);
}
开发者ID:alvarop,项目名称:silta,代码行数:31,代码来源:i2c.c


示例7: init_i2c

void init_i2c(void) {
	I2C_InitTypeDef I2C_InitStruct;
	GPIO_InitTypeDef GPIO_InitStruct;

	RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C2, ENABLE);
 	RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);

	GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;

	GPIO_InitStruct.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11; // SCL,SDA
	GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_OD;
	GPIO_Init(GPIOB, &GPIO_InitStruct);

	I2C_SoftwareResetCmd(I2C2, ENABLE);
	I2C_ITConfig(I2C2,I2C_IT_ERR,ENABLE);
	I2C_StructInit(&I2C_InitStruct);
	I2C_DeInit(I2C2);
	I2C_InitStruct.I2C_ClockSpeed = 100000;
	I2C_InitStruct.I2C_Ack = I2C_Ack_Enable;
	I2C_InitStruct.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
	I2C_InitStruct.I2C_Mode = I2C_Mode_I2C;
	I2C_InitStruct.I2C_DutyCycle = I2C_DutyCycle_2;
	I2C_InitStruct.I2C_OwnAddress1 = 0x00;
	I2C_Init(I2C2, &I2C_InitStruct);
	I2C_Cmd(I2C2, ENABLE);
}
开发者ID:John-Uzumaki,项目名称:stm32-player,代码行数:26,代码来源:radio.c


示例8: LM75_LowLevel_DeInit

/**
  * @brief  DeInitializes the LM75_I2C.
  * @param  None
  * @retval None
  */
void LM75_LowLevel_DeInit(void)
{
  GPIO_InitTypeDef  GPIO_InitStructure;

  /*!< Disable LM75_I2C */
  I2C_Cmd(LM75_I2C, DISABLE);
  /*!< DeInitializes the LM75_I2C */
  I2C_DeInit(LM75_I2C);
  
  /*!< LM75_I2C Periph clock disable */
  RCC_APB1PeriphClockCmd(LM75_I2C_CLK, DISABLE);
    
  /*!< Configure LM75_I2C pins: SCL */
  GPIO_InitStructure.GPIO_Pin = LM75_I2C_SCL_PIN;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
  GPIO_Init(LM75_I2C_SCL_GPIO_PORT, &GPIO_InitStructure);

  /*!< Configure LM75_I2C pins: SDA */
  GPIO_InitStructure.GPIO_Pin = LM75_I2C_SDA_PIN;
  GPIO_Init(LM75_I2C_SDA_GPIO_PORT, &GPIO_InitStructure);

  /*!< Configure LM75_I2C pin: SMBUS ALERT */
  GPIO_InitStructure.GPIO_Pin = LM75_I2C_SMBUSALERT_PIN;
  GPIO_Init(LM75_I2C_SMBUSALERT_GPIO_PORT, &GPIO_InitStructure);
}
开发者ID:Leon0820,项目名称:stm32,代码行数:30,代码来源:stm3210e_eval.c


示例9: TS751_LowLevel_DeInit

/**
  * @brief  DeInitializes the TS751_I2C.
  * @param  None
  * @retval None
  */
void TS751_LowLevel_DeInit(void)
{
  GPIO_InitTypeDef  GPIO_InitStructure;

  /* Disable TS751_I2C */
  I2C_Cmd(TS751_I2C, DISABLE);
  
  /* DeInitializes the TS751_I2C */
  I2C_DeInit(TS751_I2C);
  
  /* TS751_I2C Periph clock disable */
  RCC_APB1PeriphClockCmd(TS751_I2C_CLK, DISABLE);
    
  /* Configure TS751_I2C pins: SCL */
  GPIO_InitStructure.GPIO_Pin = TS751_I2C_SCL_PIN;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_Init(TS751_I2C_SCL_GPIO_PORT, &GPIO_InitStructure);

  /* Configure TS751_I2C pins: SDA */
  GPIO_InitStructure.GPIO_Pin = TS751_I2C_SDA_PIN;
  GPIO_Init(TS751_I2C_SDA_GPIO_PORT, &GPIO_InitStructure);

  /* Configure TS751_I2C pin: SMBUS ALERT */
  GPIO_InitStructure.GPIO_Pin = TS751_I2C_SMBUSALERT_PIN;
  GPIO_Init(TS751_I2C_SMBUSALERT_GPIO_PORT, &GPIO_InitStructure);
}
开发者ID:KHIEM2812,项目名称:auto_quad_fc,代码行数:32,代码来源:stm32303c_eval.c


示例10: Mems_Init

/*******************************************************************************
* Function Name  : Mems_Init
* Description    : It inits mems 
* Input          : None
* Output         : status
* Return         : None
*******************************************************************************/
int8u Mems_Init(void)
{  
  int8u ret = 0;
  
  // GPIO assignments
  // PA1: SC2SDA (Serial Data)
  // PA2: SC2SCL (Serial Clock)

  //-----SC2 I2C Master GPIO configuration

  TIM2_CCER &= 0xFFFFEEEE;
  SC2_MODE =  SC2_MODE_I2C;
  GPIO_PACFGL &= 0xFFFFF00F;
  GPIO_PACFGL |= 0x00000DD0;
  
  SC2_RATELIN =  14;   // generates standard 100kbps or 400kbps
  SC2_RATEEXP =  1;    // 3 yields 100kbps; 1 yields 400kbps
  SC2_TWICTRL1 =  0;   // start from a clean state
  SC2_TWICTRL2 =  0;   // start from a clean state  
  
  ret = I2C_MEMS_Init();
  
  fullscale_state = MEMS_LOW_RANGE;

//Add later if really needed  
#ifdef ST_DBG  
  if (!ret)
   I2C_DeInit(MEMS_I2C);
#endif
  
  return ret;
}/* end Mems_Init */
开发者ID:kincki,项目名称:contiki,代码行数:39,代码来源:mems.c


示例11: I2cInit

void I2cInit( void )
{
    I2C_DeInit( I2C_INTERFACE );

    I2cGpioConfig( );
    I2cConfig( );
}
开发者ID:2thetop,项目名称:SX1272RF1BAS-STM32,代码行数:7,代码来源:i2c.c


示例12: vhI2C_initI2C1

void vhI2C_initI2C1(void)
{
	I2C_InitTypeDef I2C_InitStruct;

	/* 		I2C1
	 * setup SCL and SDA pins
	 * SCL = PB8
	 * SDA = PB9
	 */

	/* Deinit and reset the I2C to avoid it locking up */
    I2C_DeInit(I2C1 );
    I2C_SoftwareResetCmd(I2C1, ENABLE);
    I2C_SoftwareResetCmd(I2C1, DISABLE);

	I2C_InitStruct.I2C_ClockSpeed = I2C1_clockSpeed; 		// I2C1_clockSpeed [Hz]
	I2C_InitStruct.I2C_Mode = I2C_Mode_I2C;					// I2C mode
	I2C_InitStruct.I2C_DutyCycle = I2C_DutyCycle_2;			// 50% duty cycle --> standard
	I2C_InitStruct.I2C_OwnAddress1 = I2C1_ownAddress;		// own address, not relevant in master mode
	I2C_InitStruct.I2C_Ack = I2C_Ack_Disable;
	I2C_InitStruct.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit; // set address length to 7 bit addresses
	I2C_Init(I2C1, &I2C_InitStruct);						// init I2C1

	I2C_Cmd(I2C1, ENABLE);
}
开发者ID:torcek,项目名称:AUTOPILOT,代码行数:25,代码来源:I2C.c


示例13: I2C_Configuration

/*******************************************************************************
* Function Name  : I2C_Configuration
* Description    : I2C Configuration
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void I2C_Configuration(void)
{
  I2C_InitTypeDef  I2C_InitStructure; 
  GPIO_InitTypeDef  GPIO_InitStructure; 

  /* Configure I2C1 pins: SCL and SDA */
  GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_6 | GPIO_Pin_7;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;
  GPIO_Init(GPIOB, &GPIO_InitStructure);

  /* I2C configuration */
  I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;
  I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2;
  I2C_InitStructure.I2C_OwnAddress1 = I2C1_SLAVE_ADDRESS7;
  I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;
  I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
  I2C_InitStructure.I2C_ClockSpeed = I2C_Speed;
  
  I2C_DeInit(I2C1);
  /* I2C Peripheral Enable */
  I2C_Cmd(I2C1, ENABLE);
  /* Apply I2C configuration after enabling it */
  I2C_Init(I2C1, &I2C_InitStructure);
}
开发者ID:Paolo-Maffei,项目名称:lxyppc-tetrix,代码行数:32,代码来源:i2c_ee.c


示例14: i2c_frequency

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

    // Disable the Fast Mode Plus capability
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); // Enable SYSCFG clock
    SYSCFG_I2CFastModePlusConfig(SYSCFG_I2CFastModePlus_I2C1, DISABLE);
    SYSCFG_I2CFastModePlusConfig(SYSCFG_I2CFastModePlus_I2C2, DISABLE);

    /*
       Values calculated with I2C_Timing_Configuration_V1.0.1.xls file (see AN4235)
       * Standard mode (up to 100 kHz)
       * Fast Mode (up to 400 kHz)
       * Fast Mode Plus (up to 1 MHz)
       Below values obtained with:
       - I2C clock source = 8 MHz (HSI clock per default)
       - Analog filter delay = ON
       - Digital filter coefficient = 0
       - Rise time = 100 ns
       - Fall time = 10ns
    */
    switch (hz) {
        case 100000:
            tim = 0x00201D2B; // Standard mode
            break;
        case 200000:
            tim = 0x0010021E; // Fast Mode
            break;
        case 400000:
            tim = 0x0010020A; // Fast Mode
            break;
        case 1000000:
            tim = 0x00100001; // Fast Mode Plus
            // Enable the Fast Mode Plus capability
            if (obj->i2c == I2C_1) {
                SYSCFG_I2CFastModePlusConfig(SYSCFG_I2CFastModePlus_I2C1, ENABLE);
            }
            if (obj->i2c == I2C_2) {
                SYSCFG_I2CFastModePlusConfig(SYSCFG_I2CFastModePlus_I2C2, ENABLE);
            }
            break;
        default:
            error("Only 100kHz, 200kHz, 400kHz and 1MHz I2C frequencies are supported.");
            break;
    }

    // I2C configuration
    I2C_DeInit(i2c);
    I2C_InitStructure.I2C_Mode                = I2C_Mode_I2C;
    I2C_InitStructure.I2C_AnalogFilter        = I2C_AnalogFilter_Enable;
    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              = tim;
    I2C_Init(i2c, &I2C_InitStructure);

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


示例15: mchf_hw_i2c2_init

//*----------------------------------------------------------------------------
//* Function Name       : mchf_hw_i2c2_init
//* Object              :
//* Object              :
//* Input Parameters    :
//* Output Parameters   :
//* Functions called    :
//*----------------------------------------------------------------------------
void mchf_hw_i2c2_init(void)
{
	GPIO_InitTypeDef GPIO_InitStructure;
	I2C_InitTypeDef I2C_InitStructure;

	// CODEC_I2C SCL and SDA pins configuration
	GPIO_InitStructure.GPIO_Pin   = I2C2_SCL_PIN|I2C2_SDA_PIN;
	GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_AF;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_25MHz;
	GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;

	GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_UP;		// we also have ext pullups
	GPIO_Init(I2C2_SCL_GPIO, &GPIO_InitStructure);

	// Connect pins to I2C peripheral
	GPIO_PinAFConfig(I2C2_SCL_GPIO, I2C2_SCL_PINSRC, CODEC_I2C_GPIO_AF);
	GPIO_PinAFConfig(I2C2_SDA_GPIO, I2C2_SDA_PINSRC, CODEC_I2C_GPIO_AF);

	// Enable the CODEC_I2C peripheral clock
	RCC_APB1PeriphClockCmd(I2C2_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 			= I2C2_SPEED;

	// Enable the I2C peripheral
	I2C_Cmd (CODEC_I2C, ENABLE);
	I2C_Init(CODEC_I2C, &I2C_InitStructure);
}
开发者ID:n8ohu,项目名称:mcHF-SDR,代码行数:42,代码来源:mchf_hw_i2c2.c


示例16: CODEC_I2C_Configuration

/*******************************************************************************
* Function Name  : I2Cx_GPIO_Config
* Description    : 
* Input          : None
* Output         : None
* Return         : None
* Attention		 : None
*******************************************************************************/
void CODEC_I2C_Configuration(void)
{
	I2C_InitTypeDef  I2C_InitStructure;
	GPIO_InitTypeDef  GPIO_InitStructure;
	/* If the I2C peripheral is already enabled, don't reconfigure it */	

	RCC_AHB1PeriphClockCmd(I2C_x_SDA_GPIO_CLK | I2C_x_SCL_GPIO_CLK,ENABLE);
	
	RCC_APB1PeriphClockCmd(I2C_x_CLK,ENABLE);
	
	GPIO_PinAFConfig(I2C_x_SDA_GPIO_PORT, I2C_x_SDA_SOURCE, I2C_x_SDA_AF);
	GPIO_PinAFConfig(I2C_x_SCL_GPIO_PORT, I2C_x_SCL_SOURCE, I2C_x_SCL_AF);
	
	GPIO_InitStructure.GPIO_Pin =  I2C_x_SDA_PIN | I2C_x_SCL_PIN;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
	GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
	GPIO_Init(I2C_x_SDA_GPIO_PORT, &GPIO_InitStructure);
	
	I2C_DeInit(I2C_x);
	I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;
	I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2;
	I2C_InitStructure.I2C_OwnAddress1 = I2Cx_SLAVE_ADDRESS7;
	I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;
	I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
	I2C_InitStructure.I2C_ClockSpeed = I2Cx_SPEED;
	
	I2C_Init(I2C_x, &I2C_InitStructure);
	
	//I2C_AcknowledgeConfig(I2C_x, ENABLE);

	I2C_Cmd(I2C_x, ENABLE);	
}
开发者ID:jack3k3,项目名称:User,代码行数:42,代码来源:I2C.c


示例17: System_I2CConfig

/**
* @fn		void System_I2CConfig(void)
* @brief
*	@li		I2C 설정한다. 
* @remarks
* @param	void 
* @return	void			
*/
void System_I2CConfig(void)
{
	GPIO_InitTypeDef GPIO_InitStruct;
	I2C_InitTypeDef I2C_InitStructure;

	/* 클럭 활성화 */
	RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1, ENABLE);
	
	/* I2C1 포트 초기화 */
	GPIO_InitStruct.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7;						// SDA/SCL : Alternate function Open drain
	GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_OD;
	GPIO_Init(GPIOB, &GPIO_InitStruct);	/* I2C 포트 초기화 */	


	/* I2C_InitStructure 초기화 */
	I2C_DeInit(I2C1);
	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 = 100000;
	I2C_Init(I2C1, &I2C_InitStructure);

	I2C_Cmd(I2C1,ENABLE);


//	I2C_SendData(I2C1, 0x34);



}
开发者ID:ajugurikang,项目名称:cortex_class_ref,代码行数:41,代码来源:system.c


示例18: 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);
  
  /* If the I2C peripheral is already enabled, don't reconfigure it */
  if (CODEC_I2C->CR1 & I2C_CR1_PE)
  {  
    /* 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);  
    
    /* Initialize the I2C peripheral */
    I2C_Init(CODEC_I2C, &I2C_InitStructure);
  }
}
开发者ID:Amalinda,项目名称:ruuvitracker_fw,代码行数:31,代码来源:stm324xg_usb_audio_codec.c


示例19: i2c_frequency

void i2c_frequency(i2c_t *obj, int hz) {
    MBED_ASSERT((hz == 100000) || (hz == 200000) || (hz == 400000) || (hz == 1000000));
    I2C_TypeDef *i2c = (I2C_TypeDef *)(obj->i2c);
    I2C_InitTypeDef I2C_InitStructure;
    uint32_t tim = 0;

    // Disable the Fast Mode Plus capability
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); // Enable SYSCFG clock
    SYSCFG_I2CFastModePlusConfig(SYSCFG_I2CFastModePlus_I2C1, DISABLE);
    SYSCFG_I2CFastModePlusConfig(SYSCFG_I2CFastModePlus_I2C2, DISABLE);

    /*
       Values calculated with I2C_Timing_Configuration_V1.0.1.xls file (see AN4235)
       * Standard mode (up to 100 kHz)
       * Fast Mode (up to 400 kHz)
       * Fast Mode Plus (up to 1 MHz)
       Below values obtained with:
       - I2C clock source = 48 MHz (System Clock)
       - Analog filter delay = ON
       - Digital filter coefficient = 0
       - Rise time = 100 ns
       - Fall time = 10ns
    */
    switch (hz) {
      case 100000:
          tim = 0x10805E89; // Standard mode
          break;
      case 200000:
          tim = 0x00905E82; // Fast Mode
          break;
      case 400000:
          tim = 0x00901850; // Fast Mode
          break;
      case 1000000:
          tim = 0x00700818; // Fast Mode Plus
          // Enable the Fast Mode Plus capability
          if (obj->i2c == I2C_1) {
              SYSCFG_I2CFastModePlusConfig(SYSCFG_I2CFastModePlus_I2C1, ENABLE);
          }
          if (obj->i2c == I2C_2) {
              SYSCFG_I2CFastModePlusConfig(SYSCFG_I2CFastModePlus_I2C2, ENABLE);
          }
          break;
      default:
          break;
    }

    // I2C configuration
    I2C_DeInit(i2c);
    I2C_InitStructure.I2C_Mode                = I2C_Mode_I2C;
    I2C_InitStructure.I2C_AnalogFilter        = I2C_AnalogFilter_Enable;
    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              = tim;
    I2C_Init(i2c, &I2C_InitStructure);

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


示例20: i2c_configuration

static void i2c_configuration( void )
{
	GPIO_InitTypeDef	gpio_init_structure;
	I2C_InitTypeDef		i2c_init_structure;

	RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB, ENABLE);
	RCC_APB1PeriphClockCmd( RCC_APB1Periph_I2C1, ENABLE);

	/* PB6-I2C1_SCL、PB7-I2C1_SDA*/
	gpio_init_structure.GPIO_Pin = GPIO_Pin_6|GPIO_Pin_7;
	gpio_init_structure.GPIO_Speed = GPIO_Speed_10MHz;
	gpio_init_structure.GPIO_Mode = GPIO_Mode_AF_OD;  // 开漏输出;
	GPIO_Init( GPIOB, &gpio_init_structure);

	/*********** I2C periphral configuration **********/
	I2C_DeInit(I2C1);
	i2c_init_structure.I2C_Mode = I2C_Mode_I2C;
	i2c_init_structure.I2C_DutyCycle = I2C_DutyCycle_2;//快速模式时的占空比;
	i2c_init_structure.I2C_OwnAddress1 = I2C1_MPU6050;
	i2c_init_structure.I2C_Ack = I2C_Ack_Enable;
	i2c_init_structure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
	i2c_init_structure.I2C_ClockSpeed = I2C_SPEED;

	I2C_Cmd(I2C1, ENABLE);
	I2C_Init( I2C1, &i2c_init_structure);
	I2C_AcknowledgeConfig( I2C1, ENABLE);

	/************** I2C NVIC configuration *************************/  


}
开发者ID:cross-sky,项目名称:stm32,代码行数:31,代码来源:mpu6050.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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