⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stm32f10x_tim1.c

📁 STM32F RFID通讯源代码(支持双向发送接收)
💻 C
📖 第 1 页 / 共 5 页
字号:
  tmpcr1 = TIM1->CR1;

  /* Reset the CMS and DIR Bits */
  tmpcr1 &= CR1_CounterMode_Mask;

  /* Set the Counter Mode */
  tmpcr1 |= TIM1_CounterMode;

  TIM1->CR1 = tmpcr1;
}

/*******************************************************************************
* Function Name  : TIM1_ForcedOC1Config
* Description    : Forces the TIM1 Channel1 output waveform to active or inactive 
*                  level.
* Input          : - TIM1_ForcedAction: specifies the forced Action to be set to
*                    the output waveform.
*                    This parameter can be one of the following values:
*                       - TIM1_ForcedAction_Active: Force active level on OC1REF
*                       - TIM1_ForcedAction_InActive: Force inactive level on
*                         OC1REF.
* Output         : None
* Return         : None
*******************************************************************************/
void TIM1_ForcedOC1Config(u16 TIM1_ForcedAction)
{
  u32 tmpccmr1 = 0;

  tmpccmr1 = TIM1->CCMR1;

  /* Reset the OCM Bits */
  tmpccmr1 &= CCMR_OCM13_Mask;

  /* Configure The Forced output Mode */
  tmpccmr1 |= TIM1_ForcedAction;

  TIM1->CCMR1 = tmpccmr1;
}

/*******************************************************************************
* Function Name  : TIM1_ForcedOC2Config
* Description    : Forces the TIM1 Channel2 output waveform to active or inactive 
*                  level.
* Input          : - TIM1_ForcedAction: specifies the forced Action to be set to
*                    the output waveform.
*                    This parameter can be one of the following values:
*                       - TIM1_ForcedAction_Active: Force active level on OC2REF
*                       - TIM1_ForcedAction_InActive: Force inactive level on
*                         OC2REF.
* Output         : None
* Return         : None
*******************************************************************************/
void TIM1_ForcedOC2Config(u16 TIM1_ForcedAction)
{
  u32 tmpccmr1 = 0;

  tmpccmr1 = TIM1->CCMR1;

  /* Reset the OCM Bits */
  tmpccmr1 &= CCMR_OCM24_Mask;

  /* Configure The Forced output Mode */
  tmpccmr1 |= TIM1_ForcedAction << 8;

  TIM1->CCMR1 = tmpccmr1;
}

/*******************************************************************************
* Function Name  : TIM1_ForcedOC3Config
* Description    : Forces the TIM1 Channel3 output waveform to active or inactive 
*                  level.
* Input          : - TIM1_ForcedAction: specifies the forced Action to be set to
*                    the output waveform.
*                    This parameter can be one of the following values:
*                       - TIM1_ForcedAction_Active: Force active level on OC3REF
*                       - TIM1_ForcedAction_InActive: Force inactive level on
*                         OC3REF.
* Output         : None
* Return         : None
*******************************************************************************/
void TIM1_ForcedOC3Config(u16 TIM1_ForcedAction)
{
  u32 tmpccmr2 = 0;

  tmpccmr2 = TIM1->CCMR2;

  /* Reset the OCM Bits */
  tmpccmr2 &= CCMR_OCM13_Mask;

  /* Configure The Forced output Mode */
  tmpccmr2 |= TIM1_ForcedAction;

  TIM1->CCMR2 = tmpccmr2;
}

/*******************************************************************************
* Function Name  : TIM1_ForcedOC4Config
* Description    : Forces the TIM1 Channel4 output waveform to active or inactive 
*                  level.
* Input          : - TIM1_ForcedAction: specifies the forced Action to be set to
*                    the output waveform.
*                    This parameter can be one of the following values:
*                       - TIM1_ForcedAction_Active: Force active level on OC4REF
*                       - TIM1_ForcedAction_InActive: Force inactive level on
*                         OC4REF.
* Output         : None
* Return         : None
*******************************************************************************/
void TIM1_ForcedOC4Config(u16 TIM1_ForcedAction)
{
  u32 tmpccmr2 = 0;

  tmpccmr2 = TIM1->CCMR1;

  /* Reset the OCM Bits */
  tmpccmr2 &= CCMR_OCM24_Mask;

  /* Configure The Forced output Mode */
  tmpccmr2 |= TIM1_ForcedAction << 8;

  TIM1->CCMR2 = tmpccmr2;
}

/*******************************************************************************
* Function Name  : TIM1_ARRPreloadConfig
* Description    : Enables or disables TIM1 peripheral Preload register on ARR.
* Input          : - Newstate: new state of the TIM1 peripheral Preload register
*                    This parameter can be: ENABLE or DISABLE.
* Output         : None
* Return         : None
*******************************************************************************/
void TIM1_ARRPreloadConfig(FunctionalState Newstate)
{
  /* Set or Reset the ARPE Bit */
  *(vu32 *) CR1_ARPE_BB = Newstate;
}

/*******************************************************************************
* Function Name  : TIM1_SelectCOM
* Description    : Selects the TIM1 peripheral Commutation.
* Input          : - Newstate: new state of the Capture Compare Control Update bit
*                    This parameter can be: ENABLE or DISABLE.
* Output         : None
* Return         : None
*******************************************************************************/
void TIM1_SelectCOM(FunctionalState Newstate)
{
  /* Set or Reset the CCUS Bit */
  *(vu32 *) CR2_CCUS_BB = Newstate;
}

/*******************************************************************************
* Function Name  : TIM1_SelectCCDMA
* Description    : Selects the TIM1 peripheral Capture Compare DMA source.
* Input          : - Newstate: new state of the Capture Compare DMA source
*                    This parameter can be: ENABLE or DISABLE.
* Output         : None
* Return         : None
*******************************************************************************/
void TIM1_SelectCCDMA(FunctionalState Newstate)
{
  /* Set or Reset the CCDS Bit */
  *(vu32 *) CR2_CCDS_BB = Newstate;
}

/*******************************************************************************
* Function Name  : TIM1_CCPreloadControl
* Description    : Selects the TIM1 peripheral Capture Compare Preload Conrol bit.
* Input          : - Newstate: new state of the Capture Compare Preload Conrol bit
*                    This parameter can be: ENABLE or DISABLE.
* Output         : None
* Return         : None
*******************************************************************************/
void TIM1_CCPreloadControl(FunctionalState Newstate)
{
  /* Set or Reset the CCPC Bit */
  *(vu32 *) CR2_CCPC_BB = Newstate;
}

/*******************************************************************************
* Function Name  : TIM1_OC1PreloadConfig
* Description    : Enables or disables TIM1 peripheral Preload register on CCR1.
* Input          : - TIM1_OCPreload: new state of the Capture Compare Preload
*                    register.
*                    This parameter can be one of the following values:
*                       - TIM1_OCPreload_Enable
*                       - TIM1_OCPreload_Disable
* Output         : None
* Return         : None
*******************************************************************************/
void TIM1_OC1PreloadConfig(u16 TIM1_OCPreload)
{
  /* Set or Reset the OC1PE Bit */
  *(vu32 *) CCMR1_OC1PE_BB = TIM1_OCPreload;
}

/*******************************************************************************
* Function Name  : TIM1_OC2PreloadConfig
* Description    : Enables or disables TIM1 peripheral Preload register on CCR2.
* Input          : - TIM1_OCPreload: new state of the Capture Compare Preload
*                    register.
*                    This parameter can be one of the following values:
*                       - TIM1_OCPreload_Enable
*                       - TIM1_OCPreload_Disable
* Output         : None
* Return         : None
*******************************************************************************/
void TIM1_OC2PreloadConfig(u16 TIM1_OCPreload)
{
  /* Set or Reset the OC2PE Bit */
  *(vu32 *) CCMR1_OC2PE_BB = TIM1_OCPreload;
}

/*******************************************************************************
* Function Name  : TIM1_OC3PreloadConfig
* Description    : Enables or disables TIM1 peripheral Preload register on CCR3.
* Input          : - TIM1_OCPreload: new state of the Capture Compare Preload
*                    register.
*                    This parameter can be one of the following values:
*                       - TIM1_OCPreload_Enable
*                       - TIM1_OCPreload_Disable
* Output         : None
* Return         : None
*******************************************************************************/
void TIM1_OC3PreloadConfig(u16 TIM1_OCPreload)
{
  /* Set or Reset the OC3PE Bit */
  *(vu32 *) CCMR2_OC3PE_BB = TIM1_OCPreload;
}

/*******************************************************************************
* Function Name  : TIM1_OC4PreloadConfig
* Description    : Enables or disables TIM1 peripheral Preload register on CCR4.
* Input          : - TIM1_OCPreload: new state of the Capture Compare Preload
*                    register.
*                    This parameter can be one of the following values:
*                       - TIM1_OCPreload_Enable
*                       - TIM1_OCPreload_Disable
* Output         : None
* Return         : None
*******************************************************************************/
void TIM1_OC4PreloadConfig(u16 TIM1_OCPreload)
{
  /* Set or Reset the OC4PE Bit */
  *(vu32 *) CCMR2_OC4PE_BB = TIM1_OCPreload;
}

/*******************************************************************************
* Function Name  : TIM1_OC1FastConfig
* Description    : Configures the Capture Compare 1 Fast feature.
* Input          : - TIM1_OCFast: new state of the Output Compare Fast Enable bit.
*                    This parameter can be one of the following values:
*                       - TIM1_OCFast_Enable
*                       - TIM1_OCFast_Disable
* Output         : None
* Return         : None
*******************************************************************************/
void TIM1_OC1FastConfig(u16 TIM1_OCFast)
{
  /* Set or Reset the OC1FE Bit */
  *(vu32 *) CCMR1_OC1FE_BB = TIM1_OCFast;
}

/*******************************************************************************
* Function Name  : TIM1_OC2FastConfig
* Description    : Configures the Capture Compare Fast feature.
* Input          : - TIM1_OCFast: new state of the Output Compare Fast Enable bit.
*                    This parameter can be one of the following values:
*                       - TIM1_OCFast_Enable
*                       - TIM1_OCFast_Disable
* Output         : None
* Return         : None
*******************************************************************************/
void TIM1_OC2FastConfig(u16 TIM1_OCFast)
{
  /* Set or Reset the OC2FE Bit */
  *(vu32 *) CCMR1_OC2FE_BB = TIM1_OCFast;
}

/*******************************************************************************
* Function Name  : TIM1_OC3FastConfig
* Description    : Configures the Capture Compare Fast feature.
* Input          : - TIM1_OCFast: new state of the Output Compare Fast Enable bit.
*                    This parameter can be one of the following values:
*                       - TIM1_OCFast_Enable
*                       - TIM1_OCFast_Disable
* Output         : None
* Return         : None
*******************************************************************************/
void TIM1_OC3FastConfig(u16 TIM1_OCFast)
{
  /* Set or Reset the OC3FE Bit */
  *(vu32 *) CCMR2_OC3FE_BB = TIM1_OCFast;
}

/*******************************************************************************
* Function Name  : TIM1_OC4FastConfig
* Description    : Configures the Capture Compare Fast feature.
* Input          : - TIM1_OCFast: new state of the Output Compare Fast Enable bit.
*                    This parameter can be one of the following values:
*                       - TIM1_OCFast_Enable
*                       - TIM1_OCFast_Disable
* Output         : None
* Return         : None
*******************************************************************************/
void TIM1_OC4FastConfig(u16 TIM1_OCFast)
{
  /* Set or Reset the OC4FE Bit */
  *(vu32 *) CCMR2_OC4FE_BB = TIM1_OCFast;
}

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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -