Ejemplo n.º 1
0
/**
  * @brief  Returns the ADC injected channel conversion result
  * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
  * @param ADC_InjectedChannel: the converted ADC injected channel.
  *   This parameter can be one of the following values:
  * @arg ADC_InjectedChannel_1: Injected Channel1 selected
  * @arg ADC_InjectedChannel_2: Injected Channel2 selected
  * @arg ADC_InjectedChannel_3: Injected Channel3 selected
  * @arg ADC_InjectedChannel_4: Injected Channel4 selected
  * @retval : The Data conversion value.
  */
uint16_t ADC_GetInjectedConversionValue(ADC_TypeDef* ADCx, uint8_t ADC_InjectedChannel)
{
  /* Check the parameters */
  assert_param(IS_ADC_ALL_PERIPH(ADCx));
  assert_param(IS_ADC_INJECTED_CHANNEL(ADC_InjectedChannel));
  /* Returns the selected injected channel conversion data value */
  return (uint16_t) (*(__IO uint32_t*) (((*(uint32_t*)&ADCx) + ADC_InjectedChannel + JDR_Offset)));
}
Ejemplo n.º 2
0
/*******************************************************************************
* 函数名称: ADC_GetInjectedConversionValue
* 功能描述: 返回选中的注入信道的ADC转换结果。
* 输入参数: (1)ADCx:其中x可以是1、2或3,用来选择ADC外围模块.
*           (2)ADC_InjectedChannel:需要设置偏移值的ADC注入信道
*              ADC_InjectedChannel 指定了需要设置偏移值的ADC 注入信道:
*                       - ADC_InjectedChannel_1: 选择注入信道1
*                       - ADC_InjectedChannel_2: 选择注入信道2
*                       - ADC_InjectedChannel_3: 选择注入信道3
*                       - ADC_InjectedChannel_4: 选择注入信道4
* 输出参数: 无
* 返回参数: 数据转换结果.
*******************************************************************************/
u16 ADC_GetInjectedConversionValue(ADC_TypeDef* ADCx, u8 ADC_InjectedChannel)
{
  /* Check the parameters [检查参数] */
  assert_param(IS_ADC_ALL_PERIPH(ADCx));
  assert_param(IS_ADC_INJECTED_CHANNEL(ADC_InjectedChannel));

  /* Returns the selected injected channel conversion data value [返回选择的注入通道转换数据值]*/
  return (u16) (*(vu32*) (((*(u32*)&ADCx) + ADC_InjectedChannel + JDR_Offset)));
}
Ejemplo n.º 3
0
/**
  * @brief  Set the injected channels conversion value offset
  * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
  * @param ADC_InjectedChannel: the ADC injected channel to set its
  *   offset. 
  *   This parameter can be one of the following values:
  * @arg ADC_InjectedChannel_1: Injected Channel1 selected
  * @arg ADC_InjectedChannel_2: Injected Channel2 selected
  * @arg ADC_InjectedChannel_3: Injected Channel3 selected
  * @arg ADC_InjectedChannel_4: Injected Channel4 selected
  * @param Offset: the offset value for the selected ADC injected channel
  *   This parameter must be a 12bit value.
  * @retval : None
  */
void ADC_SetInjectedOffset(ADC_TypeDef* ADCx, uint8_t ADC_InjectedChannel, uint16_t Offset)
{
  /* Check the parameters */
  assert_param(IS_ADC_ALL_PERIPH(ADCx));
  assert_param(IS_ADC_INJECTED_CHANNEL(ADC_InjectedChannel));
  assert_param(IS_ADC_OFFSET(Offset));  
  /* Set the selected injected channel data offset */
  *((__IO uint32_t *)((*(uint32_t*)&ADCx) + ADC_InjectedChannel)) = (uint32_t)Offset;
}
Ejemplo n.º 4
0
/*******************************************************************************
* 函数名称: ADC_SetInjectedOffset
* 功能描述: 设置注入信道转换的偏移值。
* 输入参数: (1)ADCx:其中x可以是1、2或3,用来选择ADC外围模块.
*           (2)ADC_InjectedChannel:需要设置偏移值的ADC注入信道。
*                    ADC_InjectedChannel 指定了需要设置偏移值的ADC 注入信道:
*                       - ADC_InjectedChannel_1: 选择注入信道1
*                       - ADC_InjectedChannel_2: 选择注入信道2
*                       - ADC_InjectedChannel_3: 选择注入信道3
*                       - ADC_InjectedChannel_4: 选择注入信道4
*           (3)Offset:选中的ADC注入信道的偏移值。该参数是一个12位值
* 输出参数: 无
* 返回参数: 无
*******************************************************************************/
void ADC_SetInjectedOffset(ADC_TypeDef* ADCx, u8 ADC_InjectedChannel, u16 Offset)
{
  /* Check the parameters [检查参数] */
  assert_param(IS_ADC_ALL_PERIPH(ADCx));
  assert_param(IS_ADC_INJECTED_CHANNEL(ADC_InjectedChannel));
  assert_param(IS_ADC_OFFSET(Offset));  

  /* Set the selected injected channel data offset [设置选择的注入通道数据偏移]*/
  *((vu32 *)((*(u32*)&ADCx) + ADC_InjectedChannel)) = (u32)Offset;
}
Ejemplo n.º 5
0
/**
  * @brief  Returns the ADC injected channel conversion result
  * @param  ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
  * @param  ADC_InjectedChannel: the converted ADC injected channel.
  *   This parameter can be one of the following values:
  *     @arg ADC_InjectedChannel_1: Injected Channel1 selected
  *     @arg ADC_InjectedChannel_2: Injected Channel2 selected
  *     @arg ADC_InjectedChannel_3: Injected Channel3 selected
  *     @arg ADC_InjectedChannel_4: Injected Channel4 selected
  * @retval The Data conversion value.
  */
uint16_t ADC_GetInjectedConversionValue(ADC_TypeDef* ADCx, uint8_t ADC_InjectedChannel)
{
    __IO uint32_t tmp = 0;
  
  /* Check the parameters */
  assert_param(IS_ADC_ALL_PERIPH(ADCx));
  assert_param(IS_ADC_INJECTED_CHANNEL(ADC_InjectedChannel));

  tmp = (uint32_t)ADCx;
  tmp += ADC_InjectedChannel + JDR_OFFSET;
  
  /* Returns the selected injected channel conversion data value */
  return (uint16_t) (*(__IO uint32_t*)  tmp); 
}