RTOS Thread::wait in microseconds

24 Nov 2012

I need to wait for an external ADC to complete a conversion after triggering. The required time is 128us (microseconds). The ADC is triggered in an RTOS call. Thread::wait only uses milliseconds. What's the best way to trigger the ADC and wait for the conversion to complete? The ADC sends a falling edge upon conversion completion, but that requires an interrupt.

28 Dec 2012

You can wait on an interrupt. Just use a semaphore.

Semaphore sem_adc(0);

// in the thread that waits...
sem_adc.wait();

// in the interrupt
sem_adc.release();