📄 stm32f10x_tim.c
字号:
/* Reset the ARR Preload Bit */
tmpcr1 &= CR1_ARPE_Reset;
}
TIMx->CR1 = (u16)tmpcr1;
}
/*******************************************************************************
* Function Name : TIM_SelectCCDMA
* Description : Selects the TIMx peripheral Capture Compare DMA source.
* Input : - TIMx: where x can be 2, 3 or 4 to select the TIM peripheral.
* - Newstate: new state of the Capture Compare DMA source
* This parameter can be: ENABLE or DISABLE.
* Output : None
* Return : None
*******************************************************************************/
void TIM_SelectCCDMA(TIM_TypeDef* TIMx, FunctionalState Newstate)
{
u32 tmpcr2 = 0;
/* Check the parameters */
assert_param(IS_FUNCTIONAL_STATE(Newstate));
tmpcr2 = TIMx->CR2;
if (Newstate != DISABLE)
{
/* Set the CCDS Bit */
tmpcr2 |= CR2_CCDS_Set;
}
else
{
/* Reset the CCDS Bit */
tmpcr2 &= CR2_CCDS_Reset;
}
TIMx->CR2 = (u16)tmpcr2;
}
/*******************************************************************************
* Function Name : TIM_OC1PreloadConfig
* Description : Enables or disables the TIMx peripheral Preload register on CCR1.
* Input : - TIMx: where x can be 2, 3 or 4 to select the TIM peripheral.
* - TIM_OCPreload: new state of the TIMx peripheral Preload
* register
* This parameter can be one of the following values:
* - TIM_OCPreload_Enable
* - TIM_OCPreload_Disable
* Output : None
* Return : None
*******************************************************************************/
void TIM_OC1PreloadConfig(TIM_TypeDef* TIMx, u16 TIM_OCPreload)
{
u32 tmpccmr1 = 0;
/* Check the parameters */
assert_param(IS_TIM_OCPRELOAD_STATE(TIM_OCPreload));
tmpccmr1 = TIMx->CCMR1;
/* Reset the OCPE Bit */
tmpccmr1 &= CCMR_OC13PE_Mask;
/* Enable or Disable the Output Compare Preload feature */
tmpccmr1 |= TIM_OCPreload;
TIMx->CCMR1 = (u16)tmpccmr1;
}
/*******************************************************************************
* Function Name : TIM_OC2PreloadConfig
* Description : Enables or disables the TIMx peripheral Preload register on CCR2.
* Input : - TIMx: where x can be 2, 3 or 4 to select the TIM peripheral.
* - TIM_OCPreload: new state of the TIMx peripheral Preload
* register
* This parameter can be one of the following values:
* - TIM_OCPreload_Enable
* - TIM_OCPreload_Disable
* Output : None
* Return : None
*******************************************************************************/
void TIM_OC2PreloadConfig(TIM_TypeDef* TIMx, u16 TIM_OCPreload)
{
u32 tmpccmr1 = 0;
/* Check the parameters */
assert_param(IS_TIM_OCPRELOAD_STATE(TIM_OCPreload));
tmpccmr1 = TIMx->CCMR1;
/* Reset the OCPE Bit */
tmpccmr1 &= CCMR_OC24PE_Mask;
/* Enable or Disable the Output Compare Preload feature */
tmpccmr1 |= (u16)(TIM_OCPreload << 8);
TIMx->CCMR1 = (u16)tmpccmr1;
}
/*******************************************************************************
* Function Name : TIM_OC3PreloadConfig
* Description : Enables or disables the TIMx peripheral Preload register on CCR3.
* Input : - TIMx: where x can be 2, 3 or 4 to select the TIM peripheral.
* - TIM_OCPreload: new state of the TIMx peripheral Preload
* register
* This parameter can be one of the following values:
* - TIM_OCPreload_Enable
* - TIM_OCPreload_Disable
* Output : None
* Return : None
*******************************************************************************/
void TIM_OC3PreloadConfig(TIM_TypeDef* TIMx, u16 TIM_OCPreload)
{
u32 tmpccmr2 = 0;
/* Check the parameters */
assert_param(IS_TIM_OCPRELOAD_STATE(TIM_OCPreload));
tmpccmr2 = TIMx->CCMR2;
/* Reset the OCPE Bit */
tmpccmr2 &= CCMR_OC13PE_Mask;
/* Enable or Disable the Output Compare Preload feature */
tmpccmr2 |= TIM_OCPreload;
TIMx->CCMR2 = (u16)tmpccmr2;
}
/*******************************************************************************
* Function Name : TIM_OC4PreloadConfig
* Description : Enables or disables the TIMx peripheral Preload register on CCR4.
* Input : - TIMx: where x can be 2, 3 or 4 to select the TIM peripheral.
* - TIM_OCPreload: new state of the TIMx peripheral Preload
* register
* This parameter can be one of the following values:
* - TIM_OCPreload_Enable
* - TIM_OCPreload_Disable
* Output : None
* Return : None
*******************************************************************************/
void TIM_OC4PreloadConfig(TIM_TypeDef* TIMx, u16 TIM_OCPreload)
{
u32 tmpccmr2 = 0;
/* Check the parameters */
assert_param(IS_TIM_OCPRELOAD_STATE(TIM_OCPreload));
tmpccmr2 = TIMx->CCMR2;
/* Reset the OCPE Bit */
tmpccmr2 &= CCMR_OC24PE_Mask;
/* Enable or Disable the Output Compare Preload feature */
tmpccmr2 |= (u16)(TIM_OCPreload << 8);
TIMx->CCMR2 = (u16)tmpccmr2;
}
/*******************************************************************************
* Function Name : TIM_OC1FastConfig
* Description : Configures the TIMx Output Compare 1 Fast feature.
* Input : - TIMx: where x can be 2, 3 or 4 to select the TIM peripheral.
* - TIM_OCFast: new state of the Output Compare Fast Enable Bit.
* This parameter can be one of the following values:
* - TIM_OCFast_Enable
* - TIM_OCFast_Disable
* Output : None
* Return : None
*******************************************************************************/
void TIM_OC1FastConfig(TIM_TypeDef* TIMx, u16 TIM_OCFast)
{
u32 tmpccmr1 = 0;
/* Check the parameters */
assert_param(IS_TIM_OCFAST_STATE(TIM_OCFast));
tmpccmr1 = TIMx->CCMR1;
/* Reset the OCFE Bit */
tmpccmr1 &= CCMR_OC13FE_Mask;
/* Enable or Disable the Output Compare Fast Bit */
tmpccmr1 |= TIM_OCFast;
TIMx->CCMR1 = (u16)tmpccmr1;
}
/*******************************************************************************
* Function Name : TIM_OC2FastConfig
* Description : Configures the TIMx Output Compare 2 Fast feature.
* Input : - TIMx: where x can be 2, 3 or 4 to select the TIM peripheral.
* - TIM_OCFast: new state of the Output Compare Fast Enable Bit.
* This parameter can be one of the following values:
* - TIM_OCFast_Enable
* - TIM_OCFast_Disable
* Output : None
* Return : None
*******************************************************************************/
void TIM_OC2FastConfig(TIM_TypeDef* TIMx, u16 TIM_OCFast)
{
u32 tmpccmr1 = 0;
/* Check the parameters */
assert_param(IS_TIM_OCFAST_STATE(TIM_OCFast));
tmpccmr1 = TIMx->CCMR1;
/* Reset the OCFE Bit */
tmpccmr1 &= CCMR_OC24FE_Mask;
/* Enable or Disable the Output Compare Fast Bit */
tmpccmr1 |= (u16)(TIM_OCFast << 8);
TIMx->CCMR1 = (u16)tmpccmr1;
}
/*******************************************************************************
* Function Name : TIM_OC3FastConfig
* Description : Configures the TIMx Output Compare 3 Fast feature.
* Input : - TIMx: where x can be 2, 3 or 4 to select the TIM peripheral.
* - TIM_OCFast: new state of the Output Compare Fast Enable Bit.
* This parameter can be one of the following values:
* - TIM_OCFast_Enable
* - TIM_OCFast_Disable
* Output : None
* Return : None
*******************************************************************************/
void TIM_OC3FastConfig(TIM_TypeDef* TIMx, u16 TIM_OCFast)
{
u32 tmpccmr2 = 0;
/* Check the parameters */
assert_param(IS_TIM_OCFAST_STATE(TIM_OCFast));
tmpccmr2 = TIMx->CCMR2;
/* Reset the OCFE Bit */
tmpccmr2 &= CCMR_OC13FE_Mask;
/* Enable or Disable the Output Compare Fast Bit */
tmpccmr2 |= TIM_OCFast;
TIMx->CCMR2 = (u16)tmpccmr2;
}
/*******************************************************************************
* Function Name : TIM_OC4FastConfig
* Description : Configures the TIMx Output Compare 4 Fast feature.
* Input : - TIMx: where x can be 2, 3 or 4 to select the TIM peripheral.
* - TIM_OCFast: new state of the Output Compare Fast Enable Bit.
* This parameter can be one of the following values:
* - TIM_OCFast_Enable
* - TIM_OCFast_Disable
* Output : None
* Return : None
*******************************************************************************/
void TIM_OC4FastConfig(TIM_TypeDef* TIMx, u16 TIM_OCFast)
{
u32 tmpccmr2 = 0;
/* Check the parameters */
assert_param(IS_TIM_OCFAST_STATE(TIM_OCFast));
tmpccmr2 = TIMx->CCMR2;
/* Reset the OCFE Bit */
tmpccmr2 &= CCMR_OC24FE_Mask;
/* Enable or Disable the Output Compare Fast Bit */
tmpccmr2 |= (u16)(TIM_OCFast << 8);
TIMx->CCMR2 = (u16)tmpccmr2;
}
/*******************************************************************************
* Function Name : TIM_ClearOC1Ref
* Description : Clears or safeguards the OCREF1 signal on an external event
* Input : - TIMx: where x can be 2, 3 or 4 to select the TIM peripheral.
* - TIM_OCClear: new state of the Output Compare Clear Enable Bit.
* This parameter can be one of the following values:
* - TIM_OCClear_Enable
* - TIM_OCClear_Disable
* Output : None
* Return : None
*******************************************************************************/
void TIM_ClearOC1Ref(TIM_TypeDef* TIMx, u16 TIM_OCClear)
{
u32 tmpccmr1 = 0;
/* Check the parameters */
assert_param(IS_TIM_OCCLEAR_STATE(TIM_OCClear));
tmpccmr1 = TIMx->CCMR1;
/* Reset the OCFE Bit */
tmpccmr1 &= CCMR_OC13CE_Mask;
/* Enable or Disable the Output Compare Clear Bit */
tmpccmr1 |= (u16)(TIM_OCClear);
TIMx->CCMR1 = (u16)tmpccmr1;
}
/*******************************************************************************
* Function Name : TIM_ClearOC2Ref
* Description : Clears or safeguards the OCREF2 signal on an external event
* Input : - TIMx: where x can be 2, 3 or 4 to select the TIM peripheral.
* - TIM_OCClear: new state of the Output Compare Clear Enable Bit.
* This parameter can be one of the following values:
* - TIM_OCClear_Enable
* - TIM_OCClear_Disable
* Output : None
* Return : None
*******************************************************************************/
void TIM_ClearOC2Ref(TIM_TypeDef* TIMx, u16 TIM_OCClear)
{
u32 tmpccmr1 = 0;
/* Check the parameters */
assert_param(IS_TIM_OCCLEAR_STATE(TIM_OCClear));
tmpccmr1 = TIMx->CCMR1;
/* Reset the OCFE Bit */
tmpccmr1 &= CCMR_OC24CE_Mask;
/* Enable or Disable the Output Compare Clear Bit */
tmpccmr1 |= (u16)(TIM_OCClear << 8);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -