File tree Expand file tree Collapse file tree 3 files changed +34
-1
lines changed Expand file tree Collapse file tree 3 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,6 @@ uint32_t Wait_SPI_Idle();
1717
1818void uart_div_modify (uint32_t uart_no , uint32_t baud_div );
1919
20- void ets_delay_us (uint32_t us );
2120int ets_io_vprintf (int (* putc )(int ), const char * fmt , va_list ap );
2221
2322void system_soft_wdt_feed ();
Original file line number Diff line number Diff line change @@ -97,6 +97,16 @@ extern uint32_t WDEV_INTEREST_EVENT;
9797 */
9898void os_delay_us (uint16_t us );
9999
100+ /**
101+ * @brief CPU do while loop for some time.
102+ * In FreeRTOS task, please call FreeRTOS apis.
103+ *
104+ * @param uint32_t us : Delay time in us.
105+ *
106+ * @return None
107+ */
108+ void ets_delay_us (uint32_t us );
109+
100110/**
101111 * @brief Register the print output function.
102112 *
Original file line number Diff line number Diff line change 1919
2020#include "esp_system.h"
2121#include "esp_timer.h"
22+ #include "rom/ets_sys.h"
2223
2324#include "FreeRTOS.h"
2425#include "task.h"
@@ -141,3 +142,26 @@ clock_t _times_r(struct _reent *r, struct tms *tms)
141142
142143 return 0 ;
143144}
145+
146+ int usleep (useconds_t us )
147+ {
148+ const int us_per_tick = portTICK_PERIOD_MS * 1000 ;
149+
150+ if (us < us_per_tick ) {
151+ ets_delay_us ((uint32_t ) us );
152+ } else {
153+ /* since vTaskDelay(1) blocks for anywhere between 0 and portTICK_PERIOD_MS,
154+ * round up to compensate.
155+ */
156+ vTaskDelay ((us + us_per_tick - 1 ) / us_per_tick );
157+ }
158+
159+ return 0 ;
160+ }
161+
162+ unsigned int sleep (unsigned int seconds )
163+ {
164+ vTaskDelay (seconds * (1000 / portTICK_PERIOD_MS ));
165+
166+ return 0 ;
167+ }
You can’t perform that action at this time.
0 commit comments