本文整理汇总了C++中TIM_GetCapture1函数的典型用法代码示例。如果您正苦于以下问题:C++ TIM_GetCapture1函数的具体用法?C++ TIM_GetCapture1怎么用?C++ TIM_GetCapture1使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TIM_GetCapture1函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TIM14_IRQHandler
/**
* @brief This function handles TIM14 global interrupt request.
* @param None
* @retval None
*/
void TIM14_IRQHandler(void)
{
if (TIM_GetITStatus(TIM14, TIM_IT_CC1) != RESET)
{
/* Clear TIM14 Capture Compare 1 interrupt pending bit */
TIM_ClearITPendingBit(TIM14, TIM_IT_CC1);
if(CaptureNumber == 0)
{
/* Get the Input Capture value */
IC1ReadValue1 = TIM_GetCapture1(TIM14);
CaptureNumber = 1;
}
else if(CaptureNumber == 1)
{
/* Get the Input Capture value */
IC1ReadValue2 = TIM_GetCapture1(TIM14);
TIM_ITConfig(TIM14, TIM_IT_CC1, DISABLE);
/* Capture computation */
if (IC1ReadValue2 > IC1ReadValue1)
{
PeriodValue = (IC1ReadValue2 - IC1ReadValue1);
}
else
{
PeriodValue = ((0xFFFF - IC1ReadValue1) + IC1ReadValue2);
}
/* capture of two values is done */
CaptureNumber = 2;
}
}
}
示例2: TIM5_IRQHandler
/*TIM5_CH1*/
void TIM5_IRQHandler( void )
{
RCC_ClocksTypeDef RCC_Clocks;
RCC_GetClocksFreq( &RCC_Clocks );
TIM_ClearITPendingBit( TIM5, TIM_IT_CC2 );
/* Get the Input Capture value */
IC2Value = TIM_GetCapture2( TIM5 );
if( IC2Value != 0 )
{
/* Duty cycle computation */
//DutyCycle = ( TIM_GetCapture1( TIM5 ) * 100 ) / IC2Value;
/* Frequency computation TIM4 counter clock = (RCC_Clocks.HCLK_Frequency)/2 */
//Frequency = (RCC_Clocks.HCLK_Frequency)/2 / IC2Value;
/*是不是反向电路?*/
DutyCycle = ( IC2Value * 100 ) / TIM_GetCapture1( TIM5 );
Frequency = ( RCC_Clocks.HCLK_Frequency ) / 2 / TIM_GetCapture1( TIM5 );
}else
{
DutyCycle = 0;
Frequency = 0;
}
}
示例3: TIM14_IRQHandler
/**
* @brief This function handles TIM14 global interrupt request.
* @param None
* @retval None
*/
void TIM14_IRQHandler(void)
{
if (TIM_GetITStatus(TIM14, TIM_IT_CC1) != RESET)
{
if(CaptureNumber == 0)
{
/* Get the Input Capture value */
IC1ReadValue1 = TIM_GetCapture1(TIM14);
}
else if(CaptureNumber == 1)
{
/* Get the Input Capture value */
IC1ReadValue2 = TIM_GetCapture1(TIM14);
/* Capture computation */
if (IC1ReadValue2 > IC1ReadValue1)
{
Capture = (IC1ReadValue2 - IC1ReadValue1);
}
else
{
Capture = ((0xFFFF - IC1ReadValue1) + IC1ReadValue2);
}
/* Frequency computation */
LsiFreq = (uint32_t) SystemCoreClock / Capture;
LsiFreq *= 8;
}
CaptureNumber++;
/* Clear TIM14 Capture compare interrupt pending bit */
TIM_ClearITPendingBit(TIM14, TIM_IT_CC1);
}
}
示例4: TIM4_IRQHandler
void TIM4_IRQHandler(void)
{
static u16 Drop_Capture = 0;
static u16 Rise_Capture = 0;
static u16 Rise1 = 0;
static u16 Rise2 = 0;
static u16 Distance1 = 0;
static u16 Distance2 = 0;
static u16 Delta_Distance = 0;
static u8 i = 0;
static u8 j = 0;
if (TIM_GetITStatus(TIM4, TIM_IT_CC1) != RESET) //捕获1发生捕获事件
{
TIM_ClearITPendingBit(TIM4, TIM_IT_CC1); //清除中断标志位
if(GPIO_ReadInputDataBit(GPIOB,GPIO_Pin_6) == 1)
{
TIM_OC1PolarityConfig(TIM4,TIM_ICPolarity_Falling); //CC1P=1 设置为下降沿捕获
Rise_Capture=TIM_GetCapture1(TIM4);
if(i == 0)
{
Rise1 = Rise_Capture;
i = 1;
}
else
{
Rise2 = Rise_Capture;
i = 0;
}
pulse.period = (Rise1>Rise2)?(Rise1-Rise2):(Rise2-Rise1);//us
//Delta.dis =
//Speed = Delta.dis/pulse.period
Speed = Delta_Distance*1000/5069;// um*1000/us == m/s*1000 == mm/s
}
else
{
TIM_OC1PolarityConfig(TIM4,TIM_ICPolarity_Rising); //CC1P=0 设置为上升沿捕获
Drop_Capture=TIM_GetCapture1(TIM4);
if(Rise_Capture>Drop_Capture) pulse.width = 65535-Rise_Capture + Drop_Capture;
else pulse.width = Drop_Capture - Rise_Capture;
if(j == 0)
{
Distance1 = pulse.width;
j = 1;
}
else
{
Distance2 = pulse.width;
j = 0;
}
Delta_Distance = ((Distance1>Distance2)?(Distance1-Distance2):(Distance2-Distance1))*170;//um
}
}
}
示例5: TIM_GetCapture1
uint16_t Servo::readMicroseconds() const {
if (!this->attached()) {
return 0;
}
uint16_t SERVO_TIM_CCR = 0x0000;
if(PIN_MAP[this->pin].timer_ch == TIM_Channel_1)
{
SERVO_TIM_CCR = TIM_GetCapture1(PIN_MAP[this->pin].timer_peripheral);
}
else if(PIN_MAP[this->pin].timer_ch == TIM_Channel_2)
{
SERVO_TIM_CCR = TIM_GetCapture2(PIN_MAP[this->pin].timer_peripheral);
}
else if(PIN_MAP[this->pin].timer_ch == TIM_Channel_3)
{
SERVO_TIM_CCR = TIM_GetCapture3(PIN_MAP[this->pin].timer_peripheral);
}
else if(PIN_MAP[this->pin].timer_ch == TIM_Channel_4)
{
SERVO_TIM_CCR = TIM_GetCapture4(PIN_MAP[this->pin].timer_peripheral);
}
//pulseWidth = (SERVO_TIM_CCR * 1000000) / ((SERVO_TIM_ARR + 1) * SERVO_TIM_PWM_FREQ);
return SERVO_TIM_CCR;
}
示例6: __attribute__
void __attribute__((used)) TIM8_TRG_COM_TIM14_IRQHandler()
{
uint16_t capureVal;
uint16_t capureValDiff;
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
if (TIM_GetITStatus(CPPM_TIMER, TIM_IT_CC1) != RESET)
{
if (TIM_GetFlagStatus(CPPM_TIMER, TIM_FLAG_CC1OF) != RESET)
{
//TODO: Handle overflow error
}
capureVal = TIM_GetCapture1(CPPM_TIMER);
capureValDiff = capureVal - prevCapureVal;
prevCapureVal = capureVal;
xQueueSendFromISR(captureQueue, &capureValDiff, &xHigherPriorityTaskWoken);
captureFlag = true;
TIM_ClearITPendingBit(CPPM_TIMER, TIM_IT_CC1);
}
if (TIM_GetITStatus(CPPM_TIMER, TIM_IT_Update) != RESET)
{
// Update input status
isAvailible = (captureFlag == true);
captureFlag = false;
TIM_ClearITPendingBit(CPPM_TIMER, TIM_IT_Update);
}
}
示例7: TIM8_CC_IRQHandler
/**
* @brief This function handles timer 8 capture/compare interrupt request.
* @retval None
*/
void TIM8_CC_IRQHandler(void) {
if (TIM_GetITStatus(TIM8, TIM_IT_CC1) != RESET) {
TIM_ClearITPendingBit(TIM8, TIM_IT_CC1);
if(TIM_Handler[TIM8CH1] != NULL) {
TIM_Handler[TIM8CH1]();
}
TIM_SetCompare1(TIM8, TIM_GetCapture1(TIM8) + TIM_IRQ_period[TIM8CH1]);
}
else if (TIM_GetITStatus(TIM8, TIM_IT_CC2) != RESET) {
TIM_ClearITPendingBit(TIM8, TIM_IT_CC2);
if(TIM_Handler[TIM8CH2] != NULL) {
TIM_Handler[TIM8CH2]();
}
TIM_SetCompare2(TIM8, TIM_GetCapture2(TIM8) + TIM_IRQ_period[TIM8CH2]);
}
else if (TIM_GetITStatus(TIM8, TIM_IT_CC3) != RESET) {
TIM_ClearITPendingBit(TIM8, TIM_IT_CC3);
if(TIM_Handler[TIM8CH3] != NULL) {
TIM_Handler[TIM8CH3]();
}
TIM_SetCompare3(TIM8, TIM_GetCapture3(TIM8) + TIM_IRQ_period[TIM8CH3]);
}
else if (TIM_GetITStatus(TIM8, TIM_IT_CC4) != RESET) {
TIM_ClearITPendingBit(TIM8, TIM_IT_CC4);
if(TIM_Handler[TIM8CH4] != NULL) {
TIM_Handler[TIM8CH4]();
}
TIM_SetCompare4(TIM8, TIM_GetCapture4(TIM8) + TIM_IRQ_period[TIM8CH4]);
}
}
示例8: pwmTIMxHandler
static void pwmTIMxHandler(TIM_TypeDef *tim, uint8_t portBase)
{
int8_t port;
// Generic CC handler for TIM2,3,4
if (TIM_GetITStatus(tim, TIM_IT_CC1) == SET)
{
port = portBase + 0;
TIM_ClearITPendingBit(tim, TIM_IT_CC1);
pwmPorts[port].callback(port, TIM_GetCapture1(tim));
}
else if (TIM_GetITStatus(tim, TIM_IT_CC2) == SET)
{
port = portBase + 1;
TIM_ClearITPendingBit(tim, TIM_IT_CC2);
pwmPorts[port].callback(port, TIM_GetCapture2(tim));
}
else if (TIM_GetITStatus(tim, TIM_IT_CC3) == SET)
{
port = portBase + 2;
TIM_ClearITPendingBit(tim, TIM_IT_CC3);
pwmPorts[port].callback(port, TIM_GetCapture3(tim));
}
else if (TIM_GetITStatus(tim, TIM_IT_CC4) == SET)
{
port = portBase + 3;
TIM_ClearITPendingBit(tim, TIM_IT_CC4);
pwmPorts[port].callback(port, TIM_GetCapture4(tim));
}
}
示例9: TIM4_IRQHandler
void TIM4_IRQHandler(void) {
#ifdef PWM_IRQ_TIM4_CH1
if (TIM_GetITStatus(TIM4, TIM_IT_CC1) == SET) {
int8_t pwmPort = PWM_IRQ_TIM4_CH1;
TIM_ClearITPendingBit(TIM4, TIM_IT_CC1);
pwmData[pwmPort].callback(TIM_GetCapture1(TIM4), GPIO_ReadInputDataBit((GPIO_TypeDef *)pwmPorts[pwmPort], (uint16_t)pwmPins[pwmPort]));
}
#endif
#ifdef PWM_IRQ_TIM4_CH2
if (TIM_GetITStatus(TIM4, TIM_IT_CC2) == SET) {
int8_t pwmPort = PWM_IRQ_TIM4_CH2;
TIM_ClearITPendingBit(TIM4, TIM_IT_CC2);
pwmData[pwmPort].callback(TIM_GetCapture2(TIM4), GPIO_ReadInputDataBit((GPIO_TypeDef *)pwmPorts[pwmPort], (uint16_t)pwmPins[pwmPort]));
}
else
#endif
#ifdef PWM_IRQ_TIM4_CH3
if (TIM_GetITStatus(TIM4, TIM_IT_CC3) == SET) {
int8_t pwmPort = PWM_IRQ_TIM4_CH3;
TIM_ClearITPendingBit(TIM4, TIM_IT_CC3);
pwmData[pwmPort].callback(TIM_GetCapture3(TIM4), GPIO_ReadInputDataBit((GPIO_TypeDef *)pwmPorts[pwmPort], (uint16_t)pwmPins[pwmPort]));
}
#endif
#ifdef PWM_IRQ_TIM4_CH4
if (TIM_GetITStatus(TIM4, TIM_IT_CC4) == SET) {
int8_t pwmPort = PWM_IRQ_TIM4_CH4;
TIM_ClearITPendingBit(TIM4, TIM_IT_CC4);
pwmData[pwmPort].callback(TIM_GetCapture4(TIM4), GPIO_ReadInputDataBit((GPIO_TypeDef *)pwmPorts[pwmPort], (uint16_t)pwmPins[pwmPort]));
}
#endif
}
示例10: TIM2_IRQHandler
void TIM2_IRQHandler()
{
if (TIM_GetITStatus(TIM2, TIM_IT_CC1) == SET) {
/* Clear TIM2 Capture compare interrupt pending bit */
TIM_ClearITPendingBit(TIM2, TIM_IT_CC1);
/* Get the Input Capture value */
timebaseCapture_prev = timebaseCapture_current;
timebaseCapture_current = TIM_GetCapture1(TIM2);
if(TIM_ICInitStructure.TIM_ICPolarity == TIM_ICPolarity_Rising){
TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Falling;
TIM_ICInit(TIM2, &TIM_ICInitStructure);
}
else if(TIM_ICInitStructure.TIM_ICPolarity == TIM_ICPolarity_Falling){
TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising;
TIM_ICInit(TIM2, &TIM_ICInitStructure);
if(timebaseCapture_current > timebaseCapture_prev){
timebaseCapture_output = (timebaseCapture_current - timebaseCapture_prev);//*5/18;
}
else{
timebaseCapture_output = (20000 - timebaseCapture_prev + timebaseCapture_current);//*5/18;
}
}
}
}
示例11: timerISR
void timerISR(uint8_t timer) {
TIM_TypeDef *TIMx = TIMER_MAP[timer].TIMx;
TimerInfo *cfg = &TIMER_MAP[timer];
// Update for rollover
if (TIM_GetITStatus(TIMx, TIM_IT_Update) != RESET) {
TIM_ClearITPendingBit(TIMx, TIM_IT_Update);
cfg->numRollovers++;
}
// CCx for pwmIn
if (TIM_GetITStatus(TIMx, TIM_IT_CC1) != RESET) {
TIM_ClearITPendingBit(TIMx, TIM_IT_CC1);
timerCCxISR(TIMx, &cfg->channelData[0], TIM_GetCapture1(TIMx), cfg->numRollovers);
}
if (TIM_GetITStatus(TIMx, TIM_IT_CC2) != RESET) {
TIM_ClearITPendingBit(TIMx, TIM_IT_CC2);
timerCCxISR(TIMx, &cfg->channelData[1], TIM_GetCapture2(TIMx), cfg->numRollovers);
}
if (TIM_GetITStatus(TIMx, TIM_IT_CC3) != RESET) {
TIM_ClearITPendingBit(TIMx, TIM_IT_CC3);
timerCCxISR(TIMx, &cfg->channelData[2], TIM_GetCapture3(TIMx), cfg->numRollovers);
}
if (TIM_GetITStatus(TIMx, TIM_IT_CC4) != RESET) {
TIM_ClearITPendingBit(TIMx, TIM_IT_CC4);
timerCCxISR(TIMx, &cfg->channelData[3], TIM_GetCapture4(TIMx), cfg->numRollovers);
}
}
示例12: TIM2_IRQHandler
/**
* @brief This function handles TIM2 global interrupt request.
* @param None
* @retval None
*/
void TIM2_IRQHandler(void)
{
RCC_ClocksTypeDef RCC_Clocks;
RCC_GetClocksFreq(&RCC_Clocks);
/* Clear TIM2 Capture compare interrupt pending bit */
TIM_ClearITPendingBit(TIM2, TIM_IT_CC2);
/* Get the Input Capture value */
IC2Value = TIM_GetCapture2(TIM2);
if (IC2Value != 0)
{
/* Duty cycle computation */
DutyCycle = (TIM_GetCapture1(TIM2) * 100) / IC2Value;
/* Frequency computation
TIM2 counter clock = (RCC_Clocks.HCLK_Frequency)/2 */
Frequency = RCC_Clocks.HCLK_Frequency / IC2Value;
}
else
{
DutyCycle = 0;
Frequency = 0;
}
}
示例13: TIM3_IRQHandler
/**
* @brief This function handles TIM3 global interrupt request.
* @param None
* @retval None
*/
void TIM3_IRQHandler(void)
{
/* TIM3_CH1 toggling with frequency = 256.35 Hz */
if (TIM_GetITStatus(TIM3, TIM_IT_CC1) != RESET)
{
TIM_ClearITPendingBit(TIM3, TIM_IT_CC1 );
uhCapture = TIM_GetCapture1(TIM3);
TIM_SetCompare1(TIM3, uhCapture + uhCCR1_Val );
}
/* TIM3_CH2 toggling with frequency = 512.7 Hz */
if (TIM_GetITStatus(TIM3, TIM_IT_CC2) != RESET)
{
TIM_ClearITPendingBit(TIM3, TIM_IT_CC2);
uhCapture = TIM_GetCapture2(TIM3);
TIM_SetCompare2(TIM3, uhCapture + uhCCR2_Val);
}
/* TIM3_CH3 toggling with frequency = 1025.4 Hz */
if (TIM_GetITStatus(TIM3, TIM_IT_CC3) != RESET)
{
TIM_ClearITPendingBit(TIM3, TIM_IT_CC3);
uhCapture = TIM_GetCapture3(TIM3);
TIM_SetCompare3(TIM3, uhCapture + uhCCR3_Val);
}
/* TIM3_CH4 toggling with frequency = 2050.78 Hz */
if (TIM_GetITStatus(TIM3, TIM_IT_CC4) != RESET)
{
TIM_ClearITPendingBit(TIM3, TIM_IT_CC4);
uhCapture = TIM_GetCapture4(TIM3);
TIM_SetCompare4(TIM3, uhCapture + uhCCR4_Val);
}
}
示例14: TIM2_IRQHandler
void TIM2_IRQHandler(void)
{
vu16 vu16_IC2Value = 0;
/* Get the Input Capture value */
vu16_IC2Value = TIM_GetCapture2(TIM2);
if(vu16_IC2Value != 0)
{
/* Duty cycle computation */
vu16_DutyCycle = (TIM_GetCapture1(TIM2) * 100) / vu16_IC2Value;
/* Frequency computation */
f32_Frequency = ((float)u32_TimerFrequency) / ((float)vu16_IC2Value);
/* TIM counter disable */
TIM_Cmd(TIM2, DISABLE);
/* Disable the CC2 Interrupt Request */
TIM_ITConfig(TIM2, TIM_IT_CC2, DISABLE);
TIM_ClearITPendingBit(TIM2, TIM_IT_CC2);
}
else
{
vu16_DutyCycle = 0;
f32_Frequency = 0;
}
}
示例15: ppmIRQHandler
static void ppmIRQHandler(TIM_TypeDef *tim)
{
uint16_t diff;
static uint16_t now;
static uint16_t last = 0;
static uint8_t chan = 0;
if (TIM_GetITStatus(tim, TIM_IT_CC1) == SET) {
last = now;
now = TIM_GetCapture1(tim);
rcActive = true;
}
TIM_ClearITPendingBit(tim, TIM_IT_CC1);
if (now > last) {
diff = (now - last);
} else {
diff = ((0xFFFF - last) + now);
}
if (diff > 4000) {
chan = 0;
} else {
if (diff > 750 && diff < 2250 && chan < 8) { // 750 to 2250 ms is our 'valid' channel range
Inputs[chan].capture = diff;
}
chan++;
failsafeCnt = 0;
}
}