drivers/timers:Arch_alarm and arch_timer add up_ndelay interface
Signed-off-by: liwenxiang1 <liwenxiang1@xiaomi.com>
This commit is contained in:
parent
47fc3a67f7
commit
fa48d9e972
3 changed files with 35 additions and 4 deletions
|
|
@ -50,14 +50,14 @@ static clock_t g_current_tick;
|
|||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
static void udelay_accurate(useconds_t microseconds)
|
||||
static void ndelay_accurate(unsigned long nanoseconds)
|
||||
{
|
||||
struct timespec now;
|
||||
struct timespec end;
|
||||
struct timespec delta;
|
||||
|
||||
ONESHOT_CURRENT(g_oneshot_lower, &now);
|
||||
clock_nsec2time(&delta, (uint64_t)microseconds * NSEC_PER_USEC);
|
||||
clock_nsec2time(&delta, nanoseconds);
|
||||
clock_timespec_add(&now, &delta, &end);
|
||||
|
||||
while (clock_timespec_compare(&now, &end) < 0)
|
||||
|
|
@ -426,13 +426,28 @@ void weak_function up_mdelay(unsigned int milliseconds)
|
|||
****************************************************************************/
|
||||
|
||||
void weak_function up_udelay(useconds_t microseconds)
|
||||
{
|
||||
up_ndelay(NSEC_PER_USEC * microseconds);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_ndelay
|
||||
*
|
||||
* Description:
|
||||
* Delay inline for the requested number of nanoseconds.
|
||||
*
|
||||
* *** NOT multi-tasking friendly ***
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void weak_function up_ndelay(unsigned long nanoseconds)
|
||||
{
|
||||
if (g_oneshot_lower != NULL)
|
||||
{
|
||||
udelay_accurate(microseconds);
|
||||
ndelay_accurate(nanoseconds);
|
||||
}
|
||||
else /* Oneshot timer hasn't been initialized yet */
|
||||
{
|
||||
udelay_coarse(microseconds);
|
||||
udelay_coarse((nanoseconds + NSEC_PER_USEC - 1) / NSEC_PER_USEC);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -466,3 +466,18 @@ void weak_function up_udelay(useconds_t microseconds)
|
|||
udelay_coarse(microseconds);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_ndelay
|
||||
*
|
||||
* Description:
|
||||
* Delay inline for the requested number of nanoseconds.
|
||||
*
|
||||
* *** NOT multi-tasking friendly ***
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void weak_function up_ndelay(unsigned long nanoseconds)
|
||||
{
|
||||
up_udelay((nanoseconds + NSEC_PER_USEC - 1) / NSEC_PER_USEC);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2363,6 +2363,7 @@ char up_romgetc(FAR const char *ptr);
|
|||
|
||||
void up_mdelay(unsigned int milliseconds);
|
||||
void up_udelay(useconds_t microseconds);
|
||||
void up_ndelay(unsigned long nanoseconds);
|
||||
|
||||
/****************************************************************************
|
||||
* These are standard interfaces that are exported by the OS for use by the
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue