本文整理汇总了C++中HardwareTimer::setChannelMode方法的典型用法代码示例。如果您正苦于以下问题:C++ HardwareTimer::setChannelMode方法的具体用法?C++ HardwareTimer::setChannelMode怎么用?C++ HardwareTimer::setChannelMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HardwareTimer
的用法示例。
在下文中一共展示了HardwareTimer::setChannelMode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
void FLYMAPLEScheduler::init(void* machtnichts)
{
delay_us(2000000); // Wait for startup so we have time to connect a new USB console
// 1kHz interrupts from systick for normal timers
systick_attach_callback(_timer_procs_timer_event);
// Set up Maple hardware timer for 1khz failsafe timer
// ref: http://leaflabs.com/docs/lang/api/hardwaretimer.html#lang-hardwaretimer
_failsafe_timer.pause();
_failsafe_timer.setPeriod(1000); // 1000us = 1kHz
_failsafe_timer.setChannelMode(TIMER_CH1, TIMER_OUTPUT_COMPARE);// Set up an interrupt on channel 1
_failsafe_timer.setCompare(TIMER_CH1, 1); // Interrupt 1 count after each update
_failsafe_timer.attachInterrupt(TIMER_CH1, _failsafe_timer_event);
_failsafe_timer.refresh();// Refresh the timer's count, prescale, and overflow
_failsafe_timer.resume(); // Start the timer counting
// We run this timer at a higher priority, so that a broken timer handler (ie one that hangs)
// will not prevent the failsafe timer interrupt.
// Caution: the timer number must agree with the HardwareTimer number
nvic_irq_set_priority(NVIC_TIMER2, 0x14);
}