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


C++ IS_I2C_ALL_INSTANCE函数代码示例

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


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

示例1: HAL_I2CEx_ConfigAnalogFilter

/**
  * @brief  Configures I2C Analog noise filter.
  * @param  hi2c : pointer to a I2C_HandleTypeDef structure that contains
  *                the configuration information for the specified I2Cx peripheral.
  * @param  AnalogFilter : new state of the Analog filter.
  * @retval HAL status
  */
HAL_StatusTypeDef HAL_I2CEx_ConfigAnalogFilter(I2C_HandleTypeDef *hi2c, uint32_t AnalogFilter)
{
    /* Check the parameters */
    assert_param(IS_I2C_ALL_INSTANCE(hi2c->Instance));
    assert_param(IS_I2C_ANALOG_FILTER(AnalogFilter));

    if((hi2c->State == HAL_I2C_STATE_BUSY) || (hi2c->State == HAL_I2C_STATE_MASTER_BUSY_TX) || (hi2c->State == HAL_I2C_STATE_MASTER_BUSY_RX)
            || (hi2c->State == HAL_I2C_STATE_SLAVE_BUSY_TX) || (hi2c->State == HAL_I2C_STATE_SLAVE_BUSY_RX))
    {
        return HAL_BUSY;
    }

    /* Process Locked */
    __HAL_LOCK(hi2c);

    hi2c->State = HAL_I2C_STATE_BUSY;

    /* Disable the selected I2C peripheral */
    __HAL_I2C_DISABLE(hi2c);

    /* Reset I2Cx ANOFF bit */
    hi2c->Instance->CR1 &= ~(I2C_CR1_ANFOFF);

    /* Set analog filter bit*/
    hi2c->Instance->CR1 |= AnalogFilter;

    __HAL_I2C_ENABLE(hi2c);

    hi2c->State = HAL_I2C_STATE_READY;

    /* Process Unlocked */
    __HAL_UNLOCK(hi2c);

    return HAL_OK;
}
开发者ID:welter,项目名称:STM32L476-radar,代码行数:42,代码来源:stm32l4xx_hal_i2c_ex.c

示例2: HAL_I2CEx_DisableWakeUp

/**
  * @brief  Disables I2C wakeup from stop mode.
  * @param  hi2c : pointer to a I2C_HandleTypeDef structure that contains
  *                the configuration information for the specified I2Cx peripheral.
  * @retval HAL status
  */
HAL_StatusTypeDef HAL_I2CEx_DisableWakeUp (I2C_HandleTypeDef *hi2c)
{
    /* Check the parameters */
    assert_param(IS_I2C_ALL_INSTANCE(hi2c->Instance));

    if((hi2c->State == HAL_I2C_STATE_BUSY) || (hi2c->State == HAL_I2C_STATE_MASTER_BUSY_TX) || (hi2c->State == HAL_I2C_STATE_MASTER_BUSY_RX)
            || (hi2c->State == HAL_I2C_STATE_SLAVE_BUSY_TX) || (hi2c->State == HAL_I2C_STATE_SLAVE_BUSY_RX))
    {
        return HAL_BUSY;
    }

    /* Process Locked */
    __HAL_LOCK(hi2c);

    hi2c->State = HAL_I2C_STATE_BUSY;

    /* Disable the selected I2C peripheral */
    __HAL_I2C_DISABLE(hi2c);

    /* Enable wakeup from stop mode */
    hi2c->Instance->CR1 &= ~(I2C_CR1_WUPEN);

    __HAL_I2C_ENABLE(hi2c);

    hi2c->State = HAL_I2C_STATE_READY;

    /* Process Unlocked */
    __HAL_UNLOCK(hi2c);

    return HAL_OK;
}
开发者ID:welter,项目名称:STM32L476-radar,代码行数:37,代码来源:stm32l4xx_hal_i2c_ex.c

示例3: I2C_GenerateSTOP

/**
 * @brief  产生停止信号
 * @code
 *     //使用i2c的1模块产生停止信号
 *     I2C_GenerateSTOP(HW_I2C1);
 * @endcode
 * @param  instance :I2C模块号 
 *         @arg HW_I2C0  :I2C0模块
 *         @arg HW_I2C1  :I2C1模块
 *         @arg HW_I2C2  :I2C2模块
 * @retval None
 */
void I2C_GenerateSTOP(uint32_t instance)
{
	/* param check */
    assert_param(IS_I2C_ALL_INSTANCE(instance));
	I2C_InstanceTable[instance]->C1 &= ~I2C_C1_MST_MASK;
    I2C_InstanceTable[instance]->C1 &= ~I2C_C1_TX_MASK;
}
开发者ID:liubins313,项目名称:rt-thread-1.2.0-k60,代码行数:19,代码来源:i2c.c

示例4: HAL_I2CEx_ConfigAnalogFilter

/**
  * @brief  Configures I2C Analog noise filter. 
  * @param  hi2c: pointer to a I2C_HandleTypeDef structure that contains
  *                the configuration information for the specified I2Cx peripheral.
  * @param  AnalogFilter: new state of the Analog filter.
  * @retval HAL status
  */
HAL_StatusTypeDef HAL_I2CEx_ConfigAnalogFilter(I2C_HandleTypeDef *hi2c, uint32_t AnalogFilter)
{
  /* Check the parameters */
  assert_param(IS_I2C_ALL_INSTANCE(hi2c->Instance));
  assert_param(IS_I2C_ANALOG_FILTER(AnalogFilter));
  
  if(hi2c->State == HAL_I2C_STATE_READY)
  {
    hi2c->State = HAL_I2C_STATE_BUSY;

    /* Disable the selected I2C peripheral */
    __HAL_I2C_DISABLE(hi2c);    

    /* Reset I2Cx ANOFF bit */
    hi2c->Instance->FLTR &= ~(I2C_FLTR_ANOFF);

    /* Disable the analog filter */
    hi2c->Instance->FLTR |= AnalogFilter;

    __HAL_I2C_ENABLE(hi2c); 

    hi2c->State = HAL_I2C_STATE_READY;

    return HAL_OK;
  }
  else
  {
    return HAL_BUSY;
  }
}
开发者ID:M2I-CySat,项目名称:CySat-SatelliteSoftware,代码行数:37,代码来源:stm32f4xx_hal_i2c_ex.c

示例5: I2C_WaitAck

/**
 * @brief  等待应答信号 
 * @note   此函数一般在使用SendData函数后调用 用于等待应答信号
 * @param  instance :I2C模块号 
 *         @arg HW_I2C0  :I2C0模块
 *         @arg HW_I2C1  :I2C1模块
 *         @arg HW_I2C2  :I2C2模块
 * @retval 0:接收到应答 1:没有应答 2:超时
 */
uint8_t I2C_WaitAck(uint32_t instance)
{
    uint32_t timeout = 0;
	/* param check */
    assert_param(IS_I2C_ALL_INSTANCE(instance));
    /* wait for transfer complete */
    timeout = 0;
    while (((I2C_InstanceTable[instance]->S & I2C_S_TCF_MASK) == 0) && (timeout < 5000))
    {
        timeout++;
        __NOP();
    }
    /* both TCF and IICIF indicate one byte trasnfer complete */
    timeout = 0;
    while (((I2C_InstanceTable[instance]->S & I2C_S_IICIF_MASK) == 0) && (timeout < 5000))
    {
        timeout++;
        __NOP();
    }
    /* IICIF is a W1C Reg, so clear it! */
    I2C_InstanceTable[instance]->S |= I2C_S_IICIF_MASK;
    if(timeout > 4990)
    {
        return 2;
    }
    /* see if we receive the ACK signal */
    if (I2C_InstanceTable[instance]->S & I2C_S_RXAK_MASK)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}
开发者ID:liubins313,项目名称:rt-thread-1.2.0-k60,代码行数:44,代码来源:i2c.c

示例6: LL_I2C_DeInit

/**
  * @brief  De-initialize the I2C registers to their default reset values.
  * @param  I2Cx I2C Instance.
  * @retval An ErrorStatus enumeration value:
  *          - SUCCESS: I2C registers are de-initialized
  *          - ERROR: I2C registers are not de-initialized
  */
uint32_t LL_I2C_DeInit(I2C_TypeDef *I2Cx)
{
  ErrorStatus status = SUCCESS;

  /* Check the I2C Instance I2Cx */
  assert_param(IS_I2C_ALL_INSTANCE(I2Cx));

  if (I2Cx == I2C1)
  {
    /* Force reset of I2C clock */
    LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_I2C1);

    /* Release reset of I2C clock */
    LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_I2C1);
  }
#if defined(I2C2)
  else if (I2Cx == I2C2)
  {
    /* Force reset of I2C clock */
    LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_I2C2);

    /* Release reset of I2C clock */
    LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_I2C2);

  }
#endif
  else
  {
    status = ERROR;
  }

  return status;
}
开发者ID:HakanYrm,项目名称:Fider,代码行数:40,代码来源:stm32f0xx_ll_i2c.c

示例7: I2C_Send7bitAddress

/**
 * @brief  i2c发送一个地址并设置数据方向
 * @code
 *     //使用i2c的1模块向地址为0x55的从机读取数据
 *    I2C_Send7bitAddress(HW_I2C1, 0x55, kI2C_Read);
 * @endcode
 * @param  instance :I2C模块号 
 *         @arg HW_I2C0  :I2C0模块
 *         @arg HW_I2C1  :I2C1模块
 *         @arg HW_I2C2  :I2C2模块
 * @param  address: 发送从机地址:0~127
 * @param  direction:  数据传输方向控制
 *         @arg kI2C_Read  : 主机读取
 *         @arg kI2C_Write : 主机发送
 * @retval None
 */
void I2C_Send7bitAddress(uint32_t instance, uint8_t address, I2C_Direction_Type direction)
{
	/* param check */
    assert_param(IS_I2C_ALL_INSTANCE(instance));
    address <<= 1;
	(kI2C_Write == direction)?((address &= 0xFE)):(address |= 0x01);
	I2C_InstanceTable[instance]->D = address;
}
开发者ID:liubins313,项目名称:rt-thread-1.2.0-k60,代码行数:24,代码来源:i2c.c

示例8: LL_I2C_Init

/**
  * @brief  Initialize the I2C registers according to the specified parameters in I2C_InitStruct.
  * @param  I2Cx I2C Instance.
  * @param  I2C_InitStruct pointer to a @ref LL_I2C_InitTypeDef structure.
  * @retval An ErrorStatus enumeration value:
  *          - SUCCESS: I2C registers are initialized
  *          - ERROR: Not applicable
  */
uint32_t LL_I2C_Init(I2C_TypeDef *I2Cx, LL_I2C_InitTypeDef *I2C_InitStruct)
{
  /* Check the I2C Instance I2Cx */
  assert_param(IS_I2C_ALL_INSTANCE(I2Cx));

  /* Check the I2C parameters from I2C_InitStruct */
  assert_param(IS_LL_I2C_PERIPHERAL_MODE(I2C_InitStruct->PeripheralMode));
  assert_param(IS_LL_I2C_ANALOG_FILTER(I2C_InitStruct->AnalogFilter));
  assert_param(IS_LL_I2C_DIGITAL_FILTER(I2C_InitStruct->DigitalFilter));
  assert_param(IS_LL_I2C_OWN_ADDRESS1(I2C_InitStruct->OwnAddress1));
  assert_param(IS_LL_I2C_TYPE_ACKNOWLEDGE(I2C_InitStruct->TypeAcknowledge));
  assert_param(IS_LL_I2C_OWN_ADDRSIZE(I2C_InitStruct->OwnAddrSize));

  /* Disable the selected I2Cx Peripheral */
  LL_I2C_Disable(I2Cx);

  /*---------------------------- I2Cx CR1 Configuration ------------------------
   * Configure the analog and digital noise filters with parameters :
   * - AnalogFilter: I2C_CR1_ANFOFF bit
   * - DigitalFilter: I2C_CR1_DNF[3:0] bits
   */
  LL_I2C_ConfigFilters(I2Cx, I2C_InitStruct->AnalogFilter, I2C_InitStruct->DigitalFilter);

  /*---------------------------- I2Cx TIMINGR Configuration --------------------
   * Configure the SDA setup, hold time and the SCL high, low period with parameter :
   * - Timing: I2C_TIMINGR_PRESC[3:0], I2C_TIMINGR_SCLDEL[3:0], I2C_TIMINGR_SDADEL[3:0],
   *           I2C_TIMINGR_SCLH[7:0] and I2C_TIMINGR_SCLL[7:0] bits
   */
  LL_I2C_SetTiming(I2Cx, I2C_InitStruct->Timing);

  /* Enable the selected I2Cx Peripheral */
  LL_I2C_Enable(I2Cx);

  /*---------------------------- I2Cx OAR1 Configuration -----------------------
   * Disable, Configure and Enable I2Cx device own address 1 with parameters :
   * - OwnAddress1:  I2C_OAR1_OA1[9:0] bits
   * - OwnAddrSize:  I2C_OAR1_OA1MODE bit
   */
  LL_I2C_DisableOwnAddress1(I2Cx);
  LL_I2C_SetOwnAddress1(I2Cx, I2C_InitStruct->OwnAddress1, I2C_InitStruct->OwnAddrSize);
  LL_I2C_EnableOwnAddress1(I2Cx);

  /*---------------------------- I2Cx MODE Configuration -----------------------
  * Configure I2Cx peripheral mode with parameter :
   * - PeripheralMode: I2C_CR1_SMBDEN and I2C_CR1_SMBHEN bits
   */
  LL_I2C_SetMode(I2Cx, I2C_InitStruct->PeripheralMode);

  /*---------------------------- I2Cx CR2 Configuration ------------------------
   * Configure the ACKnowledge or Non ACKnowledge condition
   * after the address receive match code or next received byte with parameter :
   * - TypeAcknowledge: I2C_CR2_NACK bit
   */
  LL_I2C_AcknowledgeNextData(I2Cx, I2C_InitStruct->TypeAcknowledge);

  return SUCCESS;
}
开发者ID:dinowchang,项目名称:stm32l4-template,代码行数:65,代码来源:stm32l4xx_ll_i2c.c

示例9: LL_I2C_Init

/**
  * @brief  Initialize the I2C registers according to the specified parameters in I2C_InitStruct.
  * @param  I2Cx I2C Instance.
  * @param  I2C_InitStruct pointer to a @ref LL_I2C_InitTypeDef structure.
  * @retval An ErrorStatus enumeration value:
  *          - SUCCESS: I2C registers are initialized
  *          - ERROR: Not applicable
  */
uint32_t LL_I2C_Init(I2C_TypeDef *I2Cx, LL_I2C_InitTypeDef *I2C_InitStruct)
{
  LL_RCC_ClocksTypeDef rcc_clocks;

  /* Check the I2C Instance I2Cx */
  assert_param(IS_I2C_ALL_INSTANCE(I2Cx));

  /* Check the I2C parameters from I2C_InitStruct */
  assert_param(IS_LL_I2C_PERIPHERAL_MODE(I2C_InitStruct->PeripheralMode));
  assert_param(IS_LL_I2C_CLOCK_SPEED(I2C_InitStruct->ClockSpeed));
  assert_param(IS_LL_I2C_DUTY_CYCLE(I2C_InitStruct->DutyCycle));
  assert_param(IS_LL_I2C_OWN_ADDRESS1(I2C_InitStruct->OwnAddress1));
  assert_param(IS_LL_I2C_TYPE_ACKNOWLEDGE(I2C_InitStruct->TypeAcknowledge));
  assert_param(IS_LL_I2C_OWN_ADDRSIZE(I2C_InitStruct->OwnAddrSize));

  /* Disable the selected I2Cx Peripheral */
  LL_I2C_Disable(I2Cx);

  /* Retrieve Clock frequencies */
  LL_RCC_GetSystemClocksFreq(&rcc_clocks);

  /*---------------------------- I2Cx SCL Clock Speed Configuration ------------
   * Configure the SCL speed :
   * - ClockSpeed: I2C_CR2_FREQ[5:0], I2C_TRISE_TRISE[5:0], I2C_CCR_FS,
   *           and I2C_CCR_CCR[11:0] bits
   * - DutyCycle: I2C_CCR_DUTY[7:0] bits
   */
  LL_I2C_ConfigSpeed(I2Cx, rcc_clocks.PCLK1_Frequency, I2C_InitStruct->ClockSpeed, I2C_InitStruct->DutyCycle);

  /*---------------------------- I2Cx OAR1 Configuration -----------------------
   * Disable, Configure and Enable I2Cx device own address 1 with parameters :
   * - OwnAddress1:  I2C_OAR1_ADD[9:8], I2C_OAR1_ADD[7:1] and I2C_OAR1_ADD0 bits
   * - OwnAddrSize:  I2C_OAR1_ADDMODE bit
   */
  LL_I2C_SetOwnAddress1(I2Cx, I2C_InitStruct->OwnAddress1, I2C_InitStruct->OwnAddrSize);

  /*---------------------------- I2Cx MODE Configuration -----------------------
  * Configure I2Cx peripheral mode with parameter :
   * - PeripheralMode: I2C_CR1_SMBUS, I2C_CR1_SMBTYPE and I2C_CR1_ENARP bits
   */
  LL_I2C_SetMode(I2Cx, I2C_InitStruct->PeripheralMode);

  /* Enable the selected I2Cx Peripheral */
  LL_I2C_Enable(I2Cx);

  /*---------------------------- I2Cx CR2 Configuration ------------------------
   * Configure the ACKnowledge or Non ACKnowledge condition
   * after the address receive match code or next received byte with parameter :
   * - TypeAcknowledge: I2C_CR2_NACK bit
   */
  LL_I2C_AcknowledgeNextData(I2Cx, I2C_InitStruct->TypeAcknowledge);

  return SUCCESS;
}
开发者ID:amassou2017,项目名称:Arduino_Core_STM32,代码行数:62,代码来源:stm32f2xx_ll_i2c.c

示例10: I2C_Init

/**
 * @brief  初始化I2C模块
 * @note 需要其它函数配合使用
 * @code
 *     //使用i2c的1模块 通信速度为48000hz
 *     I2C_InitTypeDef I2C_InitStruct1; //申请一个结构体
 *     I2C_InitStruct1.baudrate = HW_I2C1; //选择i2c的1模块
 *     I2C_InitStruct1.instance = 48000;   //设置通信速度48000
 *     I2C_Init(&I2C_InitStruct1);
 * @endcode
 * @param  I2C_InitStruct :i2c初始化配置结构体
 * @retval None
 */
void I2C_Init(I2C_InitTypeDef* I2C_InitStruct)
{
	/* param check */
    assert_param(IS_I2C_ALL_INSTANCE(I2C_InitStruct->instance));
    uint32_t freq;
    SIM->SCGC4 |= SIM_I2CClockGateTable[I2C_InitStruct->instance];
    /* disable first */
    I2C_InstanceTable[I2C_InitStruct->instance]->C1 &= ~I2C_C1_IICEN_MASK;
    /* set baudrate */
    CLOCK_GetClockFrequency(kBusClock, &freq);
    I2C_SetBaudrate(I2C_InitStruct->instance, freq, I2C_InitStruct->baudrate);
    /* enable i2c */
    I2C_InstanceTable[I2C_InitStruct->instance]->C1 |= I2C_C1_IICEN_MASK;
}
开发者ID:liubins313,项目名称:rt-thread-1.2.0-k60,代码行数:27,代码来源:i2c.c

示例11: HAL_I2CEx_DigitalFilter_Config

/**
  * @brief  Configures I2C Digital noise filter. 
  * @param  hi2c : pointer to a I2C_HandleTypeDef structure that contains
  *                the configuration information for the specified I2Cx peripheral.
  * @param  DigitalFilter : Coefficient of digital noise filter between 0x00 and 0x0F.
  * @retval HAL status
  */
HAL_StatusTypeDef HAL_I2CEx_DigitalFilter_Config(I2C_HandleTypeDef * hi2c,
						 uint32_t DigitalFilter)
{
	uint32_t tmpreg = 0;

	/* Check the parameters */
	assert_param(IS_I2C_ALL_INSTANCE(hi2c->Instance));
	assert_param(IS_I2C_DIGITAL_FILTER(DigitalFilter));

	if ((hi2c->State == HAL_I2C_STATE_BUSY)
	    || (hi2c->State == HAL_I2C_STATE_MASTER_BUSY_TX)
	    || (hi2c->State == HAL_I2C_STATE_MASTER_BUSY_RX)
	    || (hi2c->State == HAL_I2C_STATE_SLAVE_BUSY_TX)
	    || (hi2c->State == HAL_I2C_STATE_SLAVE_BUSY_RX)) {
		return HAL_BUSY;
	}

	/* Process Locked */
	__HAL_LOCK(hi2c);

	hi2c->State = HAL_I2C_STATE_BUSY;

	/* Disable the selected I2C peripheral */
	__HAL_I2C_DISABLE(hi2c);

	/* Get the old register value */
	tmpreg = hi2c->Instance->CR1;

	/* Reset I2Cx DNF bits [11:8] */
	tmpreg &= ~(I2C_CR1_DFN);

	/* Set I2Cx DNF coefficient */
	tmpreg |= DigitalFilter << 8;

	/* Store the new register value */
	hi2c->Instance->CR1 = tmpreg;

	__HAL_I2C_ENABLE(hi2c);

	hi2c->State = HAL_I2C_STATE_READY;

	/* Process Unlocked */
	__HAL_UNLOCK(hi2c);

	return HAL_OK;
}
开发者ID:nvdl,项目名称:pymite,代码行数:53,代码来源:stm32f0xx_hal_i2c_ex.c

示例12: I2C_TransferConfig

/**
  * @brief  Handles I2Cx communication when starting transfer or during transfer (TC or TCR flag are set).
  * @param  hi2c: I2C handle.
  * @param  DevAddress: Specifies the slave address to be programmed.
  * @param  Size: Specifies the number of bytes to be programmed.
  *   This parameter must be a value between 0 and 255.
  * @param  Mode: New state of the I2C START condition generation.
  *   This parameter can be a value of @ref I2C_RELOAD_END_MODE.
  * @param  Request: New state of the I2C START condition generation.
  *   This parameter can be a value of I2C_START_STOP_MODE.
  * @retval None
  */
static void I2C_TransferConfig(I2C_HandleTypeDef *hi2c,  uint16_t DevAddress, uint8_t Size, uint32_t Mode, uint32_t Request)
{
  uint32_t tmpreg = 0;

  /* Check the parameters */
  assert_param(IS_I2C_ALL_INSTANCE(hi2c->Instance));
  assert_param(IS_TRANSFER_MODE(Mode));
  assert_param(IS_TRANSFER_REQUEST(Request));

  /* Get the CR2 register value */
  tmpreg = hi2c->Instance->CR2;

  /* clear tmpreg specific bits */
  tmpreg &= (uint32_t)~((uint32_t)(I2C_CR2_SADD | I2C_CR2_NBYTES | I2C_CR2_RELOAD | I2C_CR2_AUTOEND | I2C_CR2_RD_WRN | I2C_CR2_START | I2C_CR2_STOP));

  /* update tmpreg */
  tmpreg |= (uint32_t)(((uint32_t)DevAddress & I2C_CR2_SADD) | (((uint32_t)Size << 16 ) & I2C_CR2_NBYTES) | \
            (uint32_t)Mode | (uint32_t)Request);

  /* update CR2 register */
  hi2c->Instance->CR2 = tmpreg;
}
开发者ID:MorgothCreator,项目名称:mSdk,代码行数:34,代码来源:twi_interface.c

示例13: HAL_I2CEx_ConfigDigitalFilter

/**
  * @brief  Configures I2C Digital noise filter. 
  * @param  hi2c: pointer to a I2C_HandleTypeDef structure that contains
  *                the configuration information for the specified I2Cx peripheral.
  * @param  DigitalFilter: Coefficient of digital noise filter between 0x00 and 0x0F.
  * @retval HAL status
  */
HAL_StatusTypeDef HAL_I2CEx_ConfigDigitalFilter(I2C_HandleTypeDef *hi2c, uint32_t DigitalFilter)
{
  uint16_t tmpreg = 0;

  /* Check the parameters */
  assert_param(IS_I2C_ALL_INSTANCE(hi2c->Instance));
  assert_param(IS_I2C_DIGITAL_FILTER(DigitalFilter));
  
  if(hi2c->State == HAL_I2C_STATE_READY)
  {
    hi2c->State = HAL_I2C_STATE_BUSY;
    
    /* Disable the selected I2C peripheral */
    __HAL_I2C_DISABLE(hi2c);  
    
    /* Get the old register value */
    tmpreg = hi2c->Instance->FLTR;
    
    /* Reset I2Cx DNF bit [3:0] */
    tmpreg &= ~(I2C_FLTR_DNF);
    
    /* Set I2Cx DNF coefficient */
    tmpreg |= DigitalFilter;
    
    /* Store the new register value */
    hi2c->Instance->FLTR = tmpreg;
    
    __HAL_I2C_ENABLE(hi2c); 
    
    hi2c->State = HAL_I2C_STATE_READY;
    
    return HAL_OK; 
  }
  else
  {
    return HAL_BUSY; 
  }
}  
开发者ID:M2I-CySat,项目名称:CySat-SatelliteSoftware,代码行数:45,代码来源:stm32f4xx_hal_i2c_ex.c

示例14: I2C_ITDMAConfig

/**
 * @brief  I2C模块中断或DMA功能设置
 * @param  instance :I2C模块号 
 *         @arg HW_I2C0  :I2C0模块
 *         @arg HW_I2C1  :I2C1模块
 *         @arg HW_I2C2  :I2C2模块
 * @param  config  :中断或DMA类型
 *         @arg kI2C_IT_Disable  :关闭中断 
 *         @arg kI2C_DMA_Disable :关闭DMA
 *         @arg kI2C_IT_BTC,     :开启发送完成中断
 *         @arg kI2C_DMA_BTC     :开启发送完成DMA功能
 * @retval None
 */
void I2C_ITDMAConfig(uint32_t instance, I2C_ITDMAConfig_Type config)
{
	/* param check */
    assert_param(IS_I2C_ALL_INSTANCE(instance));
    switch(config)
    {
        case kI2C_IT_Disable:
            NVIC_DisableIRQ(I2C_IRQnTable[instance]);
            I2C_InstanceTable[instance]->C1 &= ~I2C_C1_IICIE_MASK;
            break;
        case kI2C_DMA_Disable: 
            I2C_InstanceTable[instance]->C1 &= ~I2C_C1_DMAEN_MASK;
            break;
        case kI2C_IT_BTC:
            NVIC_EnableIRQ(I2C_IRQnTable[instance]);
            I2C_InstanceTable[instance]->C1 |= I2C_C1_IICIE_MASK;
            break;
        case kI2C_DMA_BTC:
            I2C_InstanceTable[instance]->C1 |= I2C_C1_DMAEN_MASK;
            break;
        default:
            break;
    }
}
开发者ID:liubins313,项目名称:rt-thread-1.2.0-k60,代码行数:37,代码来源:i2c.c

示例15: I2C_GenerateNAck

/**
 * @brief  产生 NACK 信号
 * @param  instance :I2C模块号 
 *         @arg HW_I2C0  :I2C0模块
 *         @arg HW_I2C1  :I2C1模块
 *         @arg HW_I2C2  :I2C2模块
 * @retval None
 */
void I2C_GenerateNAck(uint32_t instance)
{
	/* param check */
    assert_param(IS_I2C_ALL_INSTANCE(instance));
	I2C_InstanceTable[instance]->C1 |= I2C_C1_TXAK_MASK;
}
开发者ID:liubins313,项目名称:rt-thread-1.2.0-k60,代码行数:14,代码来源:i2c.c


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