This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

What is a good practice to "block" for async event.

HI, I wan't to read sensor data from ADC. So i use nrf_drv_saadc_sample(). On Arduinos i usually call value = analogRead() and after that i process the data. But here the data comes asynchronously. So i can't make a simple clean function that would give me the data i need.

I had an idea of making a bool data_is_ready,set it to false, call nrf_drv_saadc_sample() and make while(!data_is_ready).

Now inside a callback function on the end of the function set the bool back to true. But as i understand this is not a way to do with nordic.

What is a good practice to make such event. Is there a sleep function which does not block the CPU? Maybe some combination using RTC?

My idea of a clean concept would be something like value = getMySensorData(), and to continue from there on.

Parents Reply Children
Related