本文整理汇总了C++中Timeout::attach_us方法的典型用法代码示例。如果您正苦于以下问题:C++ Timeout::attach_us方法的具体用法?C++ Timeout::attach_us怎么用?C++ Timeout::attach_us使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Timeout
的用法示例。
在下文中一共展示了Timeout::attach_us方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main() {
led1 = 0;
led2 = 0;
to1.attach_us(led1_on, 1000000);
to2.attach_us(led2_on, 2000000);
while (1) {
printf("Entering sleep.\n");
sleep();
}
}
示例2: app_start
void app_start(int, char*[]) {
MBED_HOSTTEST_TIMEOUT(10);
MBED_HOSTTEST_SELECT(default_auto);
MBED_HOSTTEST_DESCRIPTION(Sleep Timeout);
MBED_HOSTTEST_START("MBED_9");
led1 = 0;
led2 = 0;
led1_initial = led1;
led2_initial = led2;
to1.attach_us(led1_on, 1000000);
to2.attach_us(led2_on, 2000000);
}
示例3: play_tone
// this is our function that plays a tone.
// Takes in a tone frequency, and after duration (in ms.) we stop playing again
static void play_tone(int tone, int duration) {
buzzer.period_us(tone);
buzzer.write(0.10f); // 10% duty cycle, otherwise it's too loud
// we wait for duration ms. and then call the silence function
tone_timeout.attach_us(&silence, duration*1000); // setup tone_timeout to call silence after duration ms
}
示例4: callDispatcher
void BLE::callDispatcher()
{
// process the external event queue
_event_queue.process();
_last_update_us += (uint64_t)_timer.read_high_resolution_us();
_timer.reset();
uint64_t last_update_ms = (_last_update_us / 1000);
wsfTimerTicks_t wsf_ticks = (last_update_ms / WSF_MS_PER_TICK);
if (wsf_ticks > 0) {
WsfTimerUpdate(wsf_ticks);
_last_update_us -= (last_update_ms * 1000);
}
wsfOsDispatcher();
static Timeout nextTimeout;
CriticalSectionLock critical_section;
if (wsfOsReadyToSleep()) {
// setup an mbed timer for the next Cordio timeout
bool_t pTimerRunning;
timestamp_t nextTimestamp = (timestamp_t) (WsfTimerNextExpiration(&pTimerRunning) * WSF_MS_PER_TICK) * 1000;
if (pTimerRunning) {
nextTimeout.attach_us(timeoutCallback, nextTimestamp);
}
}
}
示例5: toggleOn
void toggleOn (void) {
static int toggle_counter = 0;
out = 1;
led = 1;
if (toggle_counter == MS_INTERVALS) {
print_char();
toggle_counter = 0;
}
toggle_counter++;
timer.attach_us(toggleOff, 500);
}
示例6: waitForEvent
void BLE::waitForEvent()
{
static Timeout nextTimeout;
timestamp_t nextTimestamp;
bool_t pTimerRunning;
callDispatcher();
if (wsfOsReadyToSleep()) {
// setup an mbed timer for the next cordio timeout
nextTimestamp = (timestamp_t)(WsfTimerNextExpiration(&pTimerRunning) * WSF_MS_PER_TICK) * 1000;
if (pTimerRunning) {
nextTimeout.attach_us(timeoutCallback, nextTimestamp);
}
}
}
示例7: equeue_sema_wait
bool equeue_sema_wait(equeue_sema_t *s, int ms) {
int signal = 0;
Timeout timeout;
if (ms > 0) {
timeout.attach_us(callback(equeue_sema_timeout, s), ms*1000);
}
core_util_critical_section_enter();
while (!*s) {
sleep();
core_util_critical_section_exit();
core_util_critical_section_enter();
}
signal = *s;
*s = false;
core_util_critical_section_exit();
return (signal > 0);
}
示例8: autopilot_ISR
void autopilot_ISR()
{
apDetect.attach_us(&autopilot_detect, 1500);
}
示例9: toggleOff
void toggleOff(void) {
out = 0;
led = 0;
timer.attach_us(toggleOn, 30000);
}
示例10: toggleOn
void toggleOn (void) {
out = 1;
led = 1;
timer.attach_us(toggleOff, 10000);
}