What is the best way to implement this atomically? I have access to a macro that is atomic (ATOMIC_BLOCK).
My main concern is that the value of busy gets changed by an interrupt after I have jumped out of the while loop but before I have entered the atomic block. I guess I could test it again within the atomic block, but I'm not sure if I like that solution or not.Code:while (busy) ; ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { /* Do something. */ }