Dog Ears
Dog Ears

Reputation: 10025

Sleep while bit NOT set

How do I do the opposite of this:

while((*i2s) & (1<<19))
    usleep(10);

I want to keep sleeping while the 19th bit is 0.

Upvotes: 0

Views: 231

Answers (4)

alf
alf

Reputation: 18550

Using the ! operator will negate your expression:

while(!((*i2s) & (1<<19)))
    usleep(10);

Upvotes: 0

Bort
Bort

Reputation: 7638

! not operator reverses a condition:

while(!((*i2s) & (1 << 19))) {
    usleep(10);
}

Upvotes: 1

Rocky Pulley
Rocky Pulley

Reputation: 23321

To do the opposite of something, use !

while(!((*i2s) & (1<<19)))
   usleep(10);

Upvotes: 0

Daniel Fischer
Daniel Fischer

Reputation: 183968

while(((*i2s) & (1<<19)) == 0)
    usleep(10);

of course.

Upvotes: 3

Related Questions