Преглед на файлове

Slighty improve the efficiency/precission of delayMicroseconds function by avoiding uneeded CPU cycles.

pull/143/head
jofemodo преди 2 години
родител
ревизия
b583d5d170
променени са 1 файла, в които са добавени 4 реда и са изтрити 5 реда
  1. +4
    -5
      wiringPi/wiringPi.c

+ 4
- 5
wiringPi/wiringPi.c Целия файл

@@ -2156,16 +2156,15 @@ void delayMicrosecondsHard (unsigned int howLong)

void delayMicroseconds (unsigned int howLong)
{
struct timespec sleeper ;
unsigned int uSecs = howLong % 1000000 ;
unsigned int wSecs = howLong / 1000000 ;

/**/ if (howLong == 0)
if (howLong == 0)
return ;
else if (howLong < 100)
delayMicrosecondsHard (howLong) ;
else
{
struct timespec sleeper ;
unsigned int uSecs = howLong % 1000000 ;
unsigned int wSecs = howLong / 1000000 ;
sleeper.tv_sec = wSecs ;
sleeper.tv_nsec = (long)(uSecs * 1000L) ;
nanosleep (&sleeper, NULL) ;


Зареждане…
Отказ
Запис