/**
* @brief Configures the TIMx channel 1 polarity.
* @param TIMx: where x can be 1 to 17 except 6 and 7 to select the TIM peripheral.
* @param TIM_OCPolarity: specifies the OC1 Polarity
* This parameter can be one of the following values:
* @arg TIM_OCPolarity_High: Output Compare active high
* @arg TIM_OCPolarity_Low: Output Compare active low
* @retval None
*/
void TIM_OC1PolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPolarity)
{
uint16_t tmpccer = 0;
/* Check the parameters */
assert_param(IS_TIM_LIST8_PERIPH(TIMx));
assert_param(IS_TIM_OC_POLARITY(TIM_OCPolarity));
tmpccer = TIMx->CCER;
/* Set or Reset the CC1P Bit */
tmpccer &= (uint16_t)~((uint16_t)TIM_CCER_CC1P);
tmpccer |= TIM_OCPolarity;
/* Write to TIMx CCER register */
TIMx->CCER = tmpccer;
}
CC1P:输入/捕获1输出极性 (Capture/Compare 1 output polarity) 位1
CC1 通道配置为输出:
0:OC1高电平有效;
1:OC1低电平有效。
CC1 通道配置为输入:
该位选择是IC1还是IC1的反相信号作为触发或捕获信号。
0:不反相:捕获发生在IC1的上升沿;当用作外部触发器时,IC1不反相。
1:反相:捕获发生在IC1的下降沿;当用作外部触发器时,IC1反相。
注:一旦LOCK级别(TIMx_BDTR寄存器中的LOCK位)设为3或2,则该位不能被修改。
由此可知输入输出共用一位,共用一个函数