MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / regulator_delay

Function regulator_delay

components/drivers/regulator/regulator.c:187–225  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

185}
186
187static void regulator_delay(rt_uint32_t delay)
188{
189 rt_uint32_t ms = delay / 1000;
190 rt_uint32_t us = delay % 1000;
191
192 if (ms > 0)
193 {
194 /*
195 * For small enough values, handle super-millisecond
196 * delays in the usleep_range() call below.
197 */
198 if (ms < 20)
199 {
200 us += ms * 1000;
201 }
202 else if (rt_thread_self())
203 {
204 rt_thread_mdelay(ms);
205 }
206 else
207 {
208 rt_hw_us_delay(ms * 1000);
209 }
210 }
211
212 /*
213 * Give the scheduler some room to coalesce with any other
214 * wakeup sources. For delays shorter than 10 us, don't even
215 * bother setting up high-resolution timers and just busy-loop.
216 */
217 if (us >= 10)
218 {
219 rt_hw_us_delay((us + 100) >> 1);
220 }
221 else
222 {
223 rt_hw_us_delay(us);
224 }
225}
226
227static rt_err_t regulator_enable(struct rt_regulator_node *reg_np)
228{

Callers 2

regulator_enableFunction · 0.85
regulator_disableFunction · 0.85

Calls 3

rt_thread_selfFunction · 0.85
rt_thread_mdelayFunction · 0.85
rt_hw_us_delayFunction · 0.50

Tested by

no test coverage detected