NRF52832学习笔记(21)——系统延时使用

188 阅读1分钟

持续创作,加速成长!这是我参与「掘金日新计划 · 10 月更文挑战」的第21天,点击查看活动详情

一、头文件

需要包含头文件 #include "nrf_delay.h"

二、原函数

/**
 * @brief Function for delaying execution for a number of microseconds.
 *
 * @param us_time Number of microseconds to wait.
 */
#define nrf_delay_us(us_time) NRFX_DELAY_US(us_time)


/**
 * @brief Function for delaying execution for a number of milliseconds.
 *
 * @param ms_time Number of milliseconds to wait.
 */

__STATIC_INLINE void nrf_delay_ms(uint32_t ms_time)
{
    if (ms_time == 0)
    {
        return;
    }

    do {
        nrf_delay_us(1000);
    } while (--ms_time);
}

三、调用函数

nrf_delay_ms(50);    // 延时50ms
nrf_delay_us(50);    // 延时50us

• 由 Leung 写于 2020 年 7 月 15 日