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


C++ HAL_I2C_Init函数代码示例

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


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

示例1: SensorsTaskOSInit

void SensorsTaskOSInit(void)
{   
    osSemaphoreDef(i2cTransactSem);
        
    i2cSem = osSemaphoreCreate(osSemaphore(i2cTransactSem), 1);
    
    ALBI2CHandle.Instance              = ALB_I2C;
    ALBI2CHandle.Init.AddressingMode   = I2C_ADDRESSINGMODE_7BIT;
    ALBI2CHandle.Init.Timing           = I2C_TIMING_100KHZ;
    ALBI2CHandle.Init.DualAddressMode  = I2C_DUALADDRESS_DISABLED;
    ALBI2CHandle.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
    ALBI2CHandle.Init.GeneralCallMode  = I2C_GENERALCALL_DISABLED;
    ALBI2CHandle.Init.NoStretchMode    = I2C_NOSTRETCH_DISABLED;
    ALBI2CHandle.Init.OwnAddress1      = 0x00;
    ALBI2CHandle.Init.OwnAddress2      = 0x00;
    
    assert_param(HAL_I2C_Init(&ALBI2CHandle) == HAL_OK);
    
    SLBI2CHandle.Instance              = SLB_I2C;
    SLBI2CHandle.Init.AddressingMode   = I2C_ADDRESSINGMODE_7BIT;
    SLBI2CHandle.Init.Timing           = I2C_TIMING_100KHZ;
    SLBI2CHandle.Init.DualAddressMode  = I2C_DUALADDRESS_DISABLED;
    SLBI2CHandle.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
    SLBI2CHandle.Init.GeneralCallMode  = I2C_GENERALCALL_DISABLED;
    SLBI2CHandle.Init.NoStretchMode    = I2C_NOSTRETCH_DISABLED;
    SLBI2CHandle.Init.OwnAddress1      = 0x00;
    SLBI2CHandle.Init.OwnAddress2      = 0x00;
    
    assert_param(HAL_I2C_Init(&SLBI2CHandle) == HAL_OK);
}
开发者ID:project-reservoir,项目名称:project-dandelion,代码行数:30,代码来源:sensors.c

示例2: MX_I2C1_Init

/**
  * @brief I2C1 Initialization Function
  * @param None
  * @retval None
  */
static void MX_I2C1_Init(void)
{

  /* USER CODE BEGIN I2C1_Init 0 */

  /* USER CODE END I2C1_Init 0 */

  /* USER CODE BEGIN I2C1_Init 1 */

  /* USER CODE END I2C1_Init 1 */
  hi2c1.Instance = I2C1;
  hi2c1.Init.ClockSpeed = 400000;
  hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;
  hi2c1.Init.OwnAddress1 = 0;
  hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
  hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
  hi2c1.Init.OwnAddress2 = 0;
  hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
  hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
  if (HAL_I2C_Init(&hi2c1) != HAL_OK)
  {
    Error_Handler();
  }
  /* USER CODE BEGIN I2C1_Init 2 */

  /* USER CODE END I2C1_Init 2 */

}
开发者ID:RobertGawron,项目名称:GeigerMullerCounter,代码行数:33,代码来源:main.c

示例3: I2C_SHIELDS_Init

/**
 * @brief  Configures I2C interface
 * @param  None
 * @retval HAL status
 */
static HAL_StatusTypeDef I2C_SHIELDS_Init(void)
{
    HAL_StatusTypeDef ret_val = HAL_OK;
  
    if(HAL_I2C_GetState(&I2C_SHIELDS_Handle) == HAL_I2C_STATE_RESET)
    {
        /* I2C_SHIELDS peripheral configuration */
      //  I2C_SHIELDS_Handle.Init.ClockSpeed = NUCLEO_I2C_SHIELDS_SPEED;
      //  I2C_SHIELDS_Handle.Init.DutyCycle = I2C_DUTYCYCLE_2;
#ifdef STM32F401xE      
        I2C_SHIELDS_Handle.Init.ClockSpeed = NUCLEO_I2C_SHIELDS_SPEED;
        I2C_SHIELDS_Handle.Init.DutyCycle = I2C_DUTYCYCLE_2;
#endif
#ifdef STM32L053xx
        I2C_SHIELDS_Handle.Init.Timing = 0x0070D8FF;                            /*Refer AN4235-Application note Document*/
#endif        
        I2C_SHIELDS_Handle.Init.OwnAddress1 = 0x33;
        I2C_SHIELDS_Handle.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
        I2C_SHIELDS_Handle.Instance = NUCLEO_I2C_SHIELDS;

        /* Init the I2C */
        I2C_SHIELDS_MspInit();
        ret_val = HAL_I2C_Init(&I2C_SHIELDS_Handle);
    }
    
    return ret_val;
}
开发者ID:happain,项目名称:Demo_Mems,代码行数:32,代码来源:x_nucleo_iks01a1.c

示例4: MX_I2C2_Init

/* I2C2 init function */
void MX_I2C2_Init(void)
{

  hi2c2.Instance = I2C2;
  hi2c2.Init.Timing = 0x20303E5D;
  hi2c2.Init.OwnAddress1 = 0;
  hi2c2.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
  hi2c2.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
  hi2c2.Init.OwnAddress2 = 0;
  hi2c2.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
  hi2c2.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
  hi2c2.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
  if (HAL_I2C_Init(&hi2c2) != HAL_OK)
  {
    Error_Handler();
  }

    /**Configure Analogue filter 
    */
  if (HAL_I2CEx_ConfigAnalogFilter(&hi2c2, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
  {
    Error_Handler();
  }

}
开发者ID:cancui,项目名称:Atlas-Embedded-Software,代码行数:26,代码来源:i2c.c

示例5: VL6180x_Shield_I2C1_Init

void VL6180x_Shield_I2C1_Init(I2C_HandleTypeDef *hi2c1) {
    GPIO_InitTypeDef GPIO_InitStruct;
    /* Peripheral clock enable */
    __I2C1_CLK_ENABLE();

    /**I2C1 GPIO Configuration
     PB8     ------> I2C1_SCL	
     PB9     ------> I2C1_SDA
     */
    GPIO_InitStruct.Pin = GPIO_PIN_8 | GPIO_PIN_9;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
    GPIO_InitStruct.Alternate = GPIO_AF4_I2C1;
    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

    hi2c1->Instance = I2C1;
    hi2c1->Init.ClockSpeed = 400000;
    hi2c1->Init.DutyCycle = I2C_DUTYCYCLE_2;
    hi2c1->Init.OwnAddress1 = 0;
    hi2c1->Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
    hi2c1->Init.DualAddressMode = I2C_DUALADDRESS_DISABLED;
    hi2c1->Init.OwnAddress2 = 0;
    hi2c1->Init.GeneralCallMode = I2C_GENERALCALL_DISABLED;
    hi2c1->Init.NoStretchMode = I2C_NOSTRETCH_DISABLED;
    HAL_I2C_Init(hi2c1);
}
开发者ID:La-BlueFrog,项目名称:LBF-V2-SW-WIP,代码行数:27,代码来源:x_nucleo_ikp01a1.c

示例6: MX_I2C3_Init

/* I2C3 init function */
void MX_I2C3_Init(void)
{

	/*
	 * The following is the required sequence in master mode.
	 *
	 * Program the peripheral input clock in I2C_CR2 Register in order to generate correct
	 * timings
	 * Configure the clock control registers
	 * Configure the rise time register
	 * Program the I2C_CR1 register to enable the peripheral
	 * Set the START bit in the I2C_CR1 register to generate a Start condition
	 */

  hi2c3.Instance = I2C3;
  hi2c3.Init.ClockSpeed = 100000;
  hi2c3.Init.DutyCycle = I2C_DUTYCYCLE_2;
  hi2c3.Init.OwnAddress1 = 0;
  hi2c3.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
  hi2c3.Init.DualAddressMode = I2C_DUALADDRESS_DISABLED;
  hi2c3.Init.OwnAddress2 = 0;
  hi2c3.Init.GeneralCallMode = I2C_GENERALCALL_DISABLED;
  hi2c3.Init.NoStretchMode = I2C_NOSTRETCH_DISABLED;
  HAL_I2C_Init(&hi2c3);

}
开发者ID:thomaseliot,项目名称:CMR-Driver-Interface,代码行数:27,代码来源:main.c

示例7: initMPU

int initMPU(void){
	int initOkay = -1;
	HAL_I2C_StateTypeDef state;
	uint8_t tempByte = 13;
	uint8_t buffer[10] = {0,0,0,0,0,0,0,0,0,0};
	hnd.Instance = I2C1;
	hnd.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
	hnd.Init.ClockSpeed	= 400000;
	hnd.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
	hnd.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
	hnd.Init.DutyCycle = I2C_DUTYCYCLE_2;
	hnd.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
	hnd.Init.OwnAddress1 = 0x00;
	
	HAL_I2C_Init(&hnd);
	__HAL_I2C_ENABLE(&hnd);
	state = HAL_I2C_GetState(&hnd); 
	if(state == HAL_I2C_STATE_READY){
		initOkay = 0;
	}
	buffer[0]=MPU6050_RA_PWR_MGMT_1;
	buffer[1]=0x80;
	printf("READ: %u",SCCB_Read(MPU6050_RA_WHO_AM_I));
	printf("error: %u",HAL_I2C_GetError(&hnd));
	return initOkay;

}
开发者ID:RageFlo,项目名称:QuadSTM32,代码行数:27,代码来源:I2C_Treiber.c

示例8: mMPU1

CSensor::CSensor() : mMPU1(false, mHandle),
					 	 	 	      	  	  	  	  	 mMPU2(true, mHandle)
{
	mHandle.Instance = I2C1;
	__HAL_RCC_GPIOB_CLK_ENABLE();
	__HAL_RCC_I2C1_CLK_ENABLE();

	GPIO_InitTypeDef initPort;
	initPort.Pin 		= GPIO_PIN_6 | GPIO_PIN_7;
	initPort.Mode 		= GPIO_MODE_AF_OD;
	initPort.Pull 		= GPIO_PULLUP;
	initPort.Speed 		= GPIO_SPEED_FREQ_VERY_HIGH;
	initPort.Alternate 	= GPIO_AF4_I2C1;
	HAL_GPIO_Init(GPIOB, &initPort);

	mHandle.Init.ClockSpeed 		= 400000U;
	mHandle.Init.DutyCycle 			= I2C_DUTYCYCLE_2;
	mHandle.Init.OwnAddress2 		= 0x00U;
	mHandle.Init.OwnAddress1 		= 0x00U;
	mHandle.Init.AddressingMode 	= I2C_ADDRESSINGMODE_7BIT;
	mHandle.Init.DualAddressMode 	= I2C_DUALADDRESS_DISABLE;
	mHandle.Init.GeneralCallMode 	= I2C_GENERALCALL_DISABLE;
	mHandle.Init.NoStretchMode 		= I2C_NOSTRETCH_DISABLE;
	HAL_I2C_Init(&mHandle);

	if(false == (mMPU1.init() && mMPU2.init()))
	{
		//Error-Handler
	}
	mMPU1.writeRegister(MPU6050::CONFIG, static_cast<UInt8>(ELowPass::BANDWIDTH_44));
	mMPU2.writeRegister(MPU6050::CONFIG, static_cast<UInt8>(ELowPass::BANDWIDTH_44));
}
开发者ID:HSKA-CuBa,项目名称:CuBa_git,代码行数:32,代码来源:CSensor.cpp

示例9: I2C_EXPBD_Init

/**
 * @brief  Configures I2C interface
 * @retval HAL status
 */
static HAL_StatusTypeDef I2C_EXPBD_Init(void)
{
    HAL_StatusTypeDef ret_val = HAL_OK;

    if(HAL_I2C_GetState(&I2C_EXPBD_Handle) == HAL_I2C_STATE_RESET)
    {
        /* I2C_EXPBD peripheral configuration */
#if ((defined (USE_STM32F4XX_NUCLEO)) || (defined (USE_STM32L1XX_NUCLEO)))
        I2C_EXPBD_Handle.Init.ClockSpeed = NUCLEO_I2C_EXPBD_SPEED;
        I2C_EXPBD_Handle.Init.DutyCycle = I2C_DUTYCYCLE_2;
#endif

#if (defined (USE_STM32L0XX_NUCLEO))
        I2C_EXPBD_Handle.Init.Timing = NUCLEO_I2C_EXPBD_TIMING_400KHZ;                            /* 400KHz */
#endif
        I2C_EXPBD_Handle.Init.OwnAddress1 = 0x33;
        I2C_EXPBD_Handle.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
        I2C_EXPBD_Handle.Instance = NUCLEO_I2C_EXPBD;

        /* Init the I2C */
        I2C_EXPBD_MspInit();
        ret_val = HAL_I2C_Init(&I2C_EXPBD_Handle);
    }

    return ret_val;
}
开发者ID:adibacco,项目名称:contiki,代码行数:30,代码来源:x_nucleo_iks01a1.c

示例10: i2c_frequency

void i2c_frequency(i2c_t *obj, int hz) {
    MBED_ASSERT((hz == 100000) || (hz == 400000) || (hz == 1000000));
    I2cHandle.Instance = (I2C_TypeDef *)(obj->i2c);

    // Common settings: I2C clock = 32 MHz, Analog filter = ON, Digital filter coefficient = 0
    switch (hz) {
        case 100000:
            I2cHandle.Init.Timing = 0x20602938; // Standard mode with Rise Time = 400ns and Fall Time = 100ns
            break;
        case 400000:
            I2cHandle.Init.Timing = 0x00B0122A; // Fast mode with Rise Time = 250ns and Fall Time = 100ns
            break;
        case 1000000:
            I2cHandle.Init.Timing = 0x0030040E; // Fast mode Plus with Rise Time = 60ns and Fall Time = 100ns
            break;
        default:
            break;
    }

    // I2C configuration
    I2cHandle.Init.AddressingMode   = I2C_ADDRESSINGMODE_7BIT;
    I2cHandle.Init.DualAddressMode  = I2C_DUALADDRESS_DISABLED;
    I2cHandle.Init.GeneralCallMode  = I2C_GENERALCALL_DISABLED;
    I2cHandle.Init.NoStretchMode    = I2C_NOSTRETCH_DISABLED;
    I2cHandle.Init.OwnAddress1      = 0;
    I2cHandle.Init.OwnAddress2      = 0;
    I2cHandle.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
    HAL_I2C_Init(&I2cHandle);
}
开发者ID:GvoOjeda,项目名称:mbed,代码行数:29,代码来源:i2c_api.c

示例11: LBF_I2C1_Init

/*******************************************************************************
 * @brief  : Initialise et configure le peripherique I2C #2
 * @param  : Aucun.
 * @return : Rien.
 ******************************************************************************/
void LBF_I2C1_Init (uint32_t I2C1_Speed)
{
// Following settings assume I2C1 core clock (=APB1 clock in Default LimiFrog setting)
// is 8MHz and target I2C1 speed is 100KHz
// TODO Find a way to ensure I2C2 clock remains 8MHz if STM32L4 core clock modified

#define I2C1_PRESC	0x1   // tPRESC = (PRESC+1) x tI2C2CLK  -- 0.25us / 4MHz
#define I2C1_SCLL  	0x13   // tSCLL = (SCLL+1) x tPRESC  --  5us
#define I2C1_SCLH 	0x0F   // tSCLH = (SCLH+1) x tPRESC  --  4us
#define I2C1_SDADEL 	0x2   // tSDADEL = SDADEL x tPRESC  -- 0.5us
#define I2C1_SCLDEL	0x4   // tSCLDEL = (SCLDEL+1) x tPRESC  -- 1.25us
// I2C speed: 400KHz,
//  defined by tSCL = tSCLL + tSCLH + tSYNC1 + tSYNC2 ~ 2.5us  (400KHz)
//  where tSYNC1 and tSYNC2 are delays introduced by the analog and/or digital noise filters and resync mechasinsms -- refer to Ref Manual I2C section (I2C master mode)
// SCLDEL defines setup time: SDA stable before SCL rising edge
// SDADEL defines hold time: SDA stable after SCL *falling* edge (as per I2C spec?)

  hi2c1.Instance = I2C1;
  hi2c1.Init.Timing = ((uint32_t)I2C1_PRESC ) << 28
		    | ((uint32_t)I2C1_SCLDEL ) << 20
		    | ((uint32_t)I2C1_SDADEL ) << 16
		    | ((uint32_t)I2C1_SCLH ) << 8
		    | ((uint32_t)I2C1_SCLL )  ;
      //Contents of the I2C_TIMINGR_register value
  hi2c1.Init.OwnAddress1 = 0;
  hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
  hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLED;
  hi2c1.Init.OwnAddress2 = 0;
  hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLED;
  hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLED; 
  HAL_I2C_Init(&hi2c1);

}
开发者ID:La-BlueFrog,项目名称:L4-LimiFrog-SW-WIP,代码行数:38,代码来源:LBF_I2C1_Init.c

示例12: MX_I2C1_Init

/* I2C1 init function */
static void MX_I2C1_Init(void)
{

  hi2c1.Instance = I2C1;
  hi2c1.Init.Timing = 0x2000090E;
  hi2c1.Init.OwnAddress1 = 0;
  hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
  hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
  hi2c1.Init.OwnAddress2 = 0;
  hi2c1.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
  hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
  hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
  if (HAL_I2C_Init(&hi2c1) != HAL_OK)
  {
    _Error_Handler(__FILE__, __LINE__);
  }

    /**Configure Analogue filter
    */
  if (HAL_I2CEx_ConfigAnalogFilter(&hi2c1, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
  {
    _Error_Handler(__FILE__, __LINE__);
  }

    /**Configure Digital filter
    */
  if (HAL_I2CEx_ConfigDigitalFilter(&hi2c1, 0) != HAL_OK)
  {
    _Error_Handler(__FILE__, __LINE__);
  }

}
开发者ID:b-o-r-m-a-l-e-y,项目名称:Canon_timer,代码行数:33,代码来源:main.c

示例13: i2c_hal_intialization

void i2c_hal_intialization()
{
 /*------------------- Initialization I2C bus -------------------*/
    /*---------- Setup GPIOB - I2C1 port --------------*/

    __GPIOB_CLK_ENABLE(); // Enable clock source for GPIOB

    I2C1_GPIO_struct.Pin = I2C1_SDA|I2C1_SCL;
    I2C1_GPIO_struct.Mode = GPIO_MODE_AF_OD;
    I2C1_GPIO_struct.Pull = GPIO_PULLUP;
    I2C1_GPIO_struct.Speed = GPIO_SPEED_HIGH;
    I2C1_GPIO_struct.Alternate = GPIO_AF4_I2C1;
    HAL_GPIO_Init(GPIOB, & I2C1_GPIO_struct);

    /*------------------- Setup I2C1 -------------------*/

    __I2C1_CLK_ENABLE(); // Enable clock source for I2C peripherals

    I2C1_struct.Instance = I2C1;
    I2C1_struct.Init.ClockSpeed = 400000;
    I2C1_struct.Init.DutyCycle = I2C_DUTYCYCLE_2;
    I2C1_struct.Init.OwnAddress1 = 0;
    I2C1_struct.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
    I2C1_struct.Init.DualAddressMode = I2C_DUALADDRESS_DISABLED;
    I2C1_struct.Init.OwnAddress2 = 0;
    I2C1_struct.Init.GeneralCallMode = I2C_GENERALCALL_DISABLED;
    I2C1_struct.Init.NoStretchMode = I2C_NOSTRETCH_DISABLED;
    HAL_I2C_Init(&I2C1_struct);
}
开发者ID:DavidHladky,项目名称:NUCLEO-F411-I2C-BMP180,代码行数:29,代码来源:i2c_hal.c

示例14: i2c_frequency

void i2c_frequency(i2c_t *obj, int hz)
{
    MBED_ASSERT((hz > 0) && (hz <= 400000));
    I2cHandle.Instance = (I2C_TypeDef *)(obj->i2c);
    int timeout;

    // wait before init
    timeout = LONG_TIMEOUT;
    while ((__HAL_I2C_GET_FLAG(&I2cHandle, I2C_FLAG_BUSY)) && (timeout-- != 0));

    // I2C configuration
    I2cHandle.Init.AddressingMode  = I2C_ADDRESSINGMODE_7BIT;
    I2cHandle.Init.ClockSpeed      = hz;
    I2cHandle.Init.DualAddressMode = I2C_DUALADDRESS_DISABLED;
    I2cHandle.Init.DutyCycle       = I2C_DUTYCYCLE_2;
    I2cHandle.Init.GeneralCallMode = I2C_GENERALCALL_DISABLED;
    I2cHandle.Init.NoStretchMode   = I2C_NOSTRETCH_DISABLED;
    I2cHandle.Init.OwnAddress1     = 0;
    I2cHandle.Init.OwnAddress2     = 0;
    HAL_I2C_Init(&I2cHandle);
    if (obj->slave) {
        /* Enable Address Acknowledge */
        I2cHandle.Instance->CR1 |= I2C_CR1_ACK;
    }

}
开发者ID:LMESTM,项目名称:mbed-hal-st-stm32f4,代码行数:26,代码来源:i2c_api.c

示例15: TWI_open

/**
  * @brief  Initializes peripherals used by the I2C EEPROM driver.
  * @param  None
  * @retval None
  */
bool TWI_open(new_twi* TwiStruct)
{
	if(!TwiStruct)
		return false;
	  I2C_HandleTypeDef *I2cHandle = calloc(1, sizeof(I2C_HandleTypeDef));
	  if(!I2cHandle)
		  return false;
	   //I2C_InitTypeDef  I2C_InitStructure;
	  TwiStruct->udata = (void *)I2cHandle;
	  sEE_LowLevel_Init(TwiStruct);
/*##-1- Configure the I2C peripheral #######################################*/
	  I2cHandle->Instance             = sEE_I2C[TwiStruct->TwiNr];

	  I2cHandle->Init.AddressingMode  = I2C_ADDRESSINGMODE_7BIT;
	  I2cHandle->Init.Timing      		= I2C_TIMING;
	  I2cHandle->Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
	  //I2cHandle->Init.DutyCycle       = I2C_DUTYCYCLE_2;
	  I2cHandle->Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
	  I2cHandle->Init.NoStretchMode   = I2C_NOSTRETCH_DISABLE;
	  I2cHandle->Init.OwnAddress1     = TwiStruct->MasterSlaveAddr;
	  //I2cHandle.Init.OwnAddress2     = 0xFF;

	  if(HAL_I2C_Init(I2cHandle) != HAL_OK)
	  {
		  /* Initialization Error */
		  return false;
	  }
	  return true;
}
开发者ID:MorgothCreator,项目名称:mSdk,代码行数:34,代码来源:twi_interface.c


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