当前位置: 首页>>代码示例>>C++>>正文


C++ Timeout::attach_us方法代码示例

本文整理汇总了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();
    }
}
开发者ID:DanKupiniak,项目名称:mbed,代码行数:10,代码来源:main.cpp

示例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);
}
开发者ID:0xc0170,项目名称:mbed-drivers,代码行数:12,代码来源:main.cpp

示例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
}
开发者ID:mnorman4,项目名称:ftf2016,代码行数:9,代码来源:main.cpp

示例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);
        }
    }
}
开发者ID:donatieng,项目名称:mbed,代码行数:31,代码来源:CordioBLE.cpp

示例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);
}
开发者ID:ElAbbassi,项目名称:mbed,代码行数:11,代码来源:main.cpp

示例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);
        }
    }
}
开发者ID:donatieng,项目名称:mbed,代码行数:16,代码来源:CordioBLE.cpp

示例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);
}
开发者ID:anangl,项目名称:mbed-os,代码行数:20,代码来源:equeue_mbed.cpp

示例8: autopilot_ISR

void autopilot_ISR()
{
	apDetect.attach_us(&autopilot_detect, 1500);
}
开发者ID:graymalkin,项目名称:shed_boat,代码行数:4,代码来源:main.cpp

示例9: toggleOff

void toggleOff(void) {
    out = 0;
    led = 0;
    timer.attach_us(toggleOn, 30000);
}
开发者ID:3eggert,项目名称:mbed,代码行数:5,代码来源:main.cpp

示例10: toggleOn

void toggleOn (void) {
    out = 1;
    led = 1;
    timer.attach_us(toggleOff, 10000);
}
开发者ID:3eggert,项目名称:mbed,代码行数:5,代码来源:main.cpp


注:本文中的Timeout::attach_us方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。