> I have a collection of sensors that I need to poll fairly quickly (~1kHz). Traditionally, I'd just dedicate a timer and poll from the timer interrupt handler, or set the scheduling quantum to 1ms and use a high-priority thread to poll at every tick.
>
> I'm curious as to whether some of the other NuttX primitives could be used to do this in a more canonical fashion. For example, the work_queue() interface looks interesting, but designed for longer-running workers that can be blocked, pre-empted, etc, and competition for the worker thread could easily lead to sensor data being lost.
The work queue is really intended to be a driver back-end. It is intended to support short processing and shouldn't really block (but, of course, may have to if necesssary.).
While the work queue was not planned to support periodic processing, it could. Work can be scheduled with a delay. If you reschedule the work each time with the same delay it will be periodic (but not exact).
> Right now, since I'm running on STM32 it looks like the best approach is to extend the stm32_tim driver to support output compare interrupts on a timer, which I'm sure will work but is of course quite a platform-dependent solution.
You don't say what kind of sensors you are polling. Analog signals? If so, the STM32 ADC supports collections of several samples periodically. If you drive the ADC with a timer, it can sample multiple sensors on each timer trigger.
That capability is already built into the NuttX STM32 ADC driver -- but it doesn't work yet for more than one signal. You have to have use DMA if you want obtain more than one sample per clock trigger. Otherwise, you will always get data overrun (if you set up to sample 3 signals, you will see the same value 3 times because the overrun).
Greg