CC1310 Task_sleep() 跟usleep() 函数有什么区别吗?主要是功耗方面?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
您好,
1.sleep和usleep是posix中的API,而task_sleep是rtos中的API,二者的本质都是一样的,既最终都是通过tick实现sleep的
2.Task_sleep是让出对MCU的占用,可以让其他task得到执行或者执行idle task从而进入低功耗状态。它的计时单位是systick,默认为10us。
3..sleep的输入参数是seconds、usleep的输入参数是micro seconds
4.sleep和usleep是功耗是无差别的
5.关于Task_sleep()和usleep()功耗区别这个问题我会帮您询问一下资深工程师的。
希望对您有所帮助。
您好,以下来自工程师的回复:
Task_sleep() 将系统时钟节拍数作为计时参数。 您可以在此处阅读完整文档:https://dev.ti.com/tirex/explore/content/simplelink_cc13xx_cc26xx_sdk_7_10_01_24/docs/tirtos7/doxygen/m4/html/Task_8h.html#a1c5f0ae2e0960e2e7bdc4f1a8edb07fa
usleep() 以微秒为计时参数。 如果您查看 sleep.c 中的实现,您将看到它最终调用了 Task_sleep。
/* * ======== usleep ======== */ int usleep(useconds_t usec) { UInt32 timeout; /* usec must be less than 1000000 */ if (usec >= 1000000) { errno = EINVAL; return (-1); } /* Implementations may place limitations on the granularity of timer * values. For each interval timer, if the requested timer value requires * a finer granularity than the implementation supports, the actual timer * value shall be rounded up to the next supported value. */ /* Clock_tickPeriod is the Clock period in microseconds */ timeout = (UInt32)((usec + Clock_tickPeriod - 1) / Clock_tickPeriod); /* must add one tick to ensure a full duration of timeout ticks */ Task_sleep(timeout + 1); return (0); }