mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-03 20:54:32 +02:00
newlib: implement usleep
This commit is contained in:
@@ -898,7 +898,7 @@ int linenoiseProbe() {
|
|||||||
int timeout_ms = 200;
|
int timeout_ms = 200;
|
||||||
size_t read_bytes = 0;
|
size_t read_bytes = 0;
|
||||||
while (timeout_ms > 0 && read_bytes < 4) { // response is ESC[0n or ESC[3n
|
while (timeout_ms > 0 && read_bytes < 4) { // response is ESC[0n or ESC[3n
|
||||||
usleep(1000);
|
usleep(10000);
|
||||||
char c;
|
char c;
|
||||||
int cb = fread(&c, 1, 1, stdin);
|
int cb = fread(&c, 1, 1, stdin);
|
||||||
read_bytes += cb;
|
read_bytes += cb;
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <reent.h>
|
#include <reent.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/reent.h>
|
#include <sys/reent.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
@@ -244,6 +245,20 @@ int settimeofday(const struct timeval *tv, const struct timezone *tz)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int usleep(useconds_t us)
|
||||||
|
{
|
||||||
|
const int us_per_tick = portTICK_PERIOD_MS * 1000;
|
||||||
|
if (us < us_per_tick) {
|
||||||
|
ets_delay_us((uint32_t) us);
|
||||||
|
} else {
|
||||||
|
/* since vTaskDelay(1) blocks for anywhere between 0 and portTICK_PERIOD_MS,
|
||||||
|
* round up to compensate.
|
||||||
|
*/
|
||||||
|
vTaskDelay((us + us_per_tick - 1) / us_per_tick);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t system_get_time(void)
|
uint32_t system_get_time(void)
|
||||||
{
|
{
|
||||||
#if defined( WITH_FRC1 ) || defined( WITH_RTC )
|
#if defined( WITH_FRC1 ) || defined( WITH_RTC )
|
||||||
|
Reference in New Issue
Block a user