stm32 quadrature decoder general purpose timer functionality


Matias N.
 

Hi,
I need to access STM32's general purpose timer's quadrature decoding functionality. I'm trying to understand what exactly is needed to expose this, either write a custom driver accessing arch-dependant interface directly or if there's at least some support exposed via counter API for example. I see there's specific driver for STM32 PWM functionality so I would guess a similar driver is needed. There's also STM32 counter driver but this would be a different kind of counter (requires special setup of timer). I also see bindings for other platforms which have dedicated QDEC peripherals, so I'm guessing that a similar DTS binding should also be added.

What would be the proper way to do this?

Best,
Matias


Piotr Mienkowski
 

Hi Matias,

On 21.06.21 20:42, Matias N. wrote:
I need to access STM32's general purpose timer's quadrature decoding functionality. I'm trying to understand what exactly is needed to expose this, either write a custom driver accessing arch-dependant interface directly or if there's at least some support exposed via counter API for example.
So far support for quadrature decoding functionality of a general purpose timer/counter module has been implemented as a dedicated sensor driver. You can check

* drivers/sensor/qdec_nrfx
* drivers/sensor/qdec_sam

They use a different binding than a regular counter driver. It's the compatible property of the timer/counter DT node that decides which driver will 'own' it.

There is also a basic sample app to demo the driver: samples/sensor/qdec.

Regards,
Piotr


Matias N.
 

I thought I sent an answer but I don't see it here so I'll send again.

Thanks for the reply. What I was looking for is a way that could be acceptable for merging upstream, if possible.
So should I add a special binding for STM32 decoder functionality? Or what would be the preferred way?

Best,
Matias


Piotr Mienkowski
 

Hi Matias,

The best way to get stm32 quadrature decoder driver merged into Zephyr is to follow example of qdec_nrfx.c, qdec_sam.c drivers. Check PRs that introduced the respective drivers to see what files need to be added / modified. Yes, you'll need a new binding.

Regards,
Piotr

On 30.06.21 14:49, Matias N. wrote:
I thought I sent an answer but I don't see it here so I'll send again.

Thanks for the reply. What I was looking for is a way that could be acceptable for merging upstream, if possible.
So should I add a special binding for STM32 decoder functionality? Or what would be the preferred way?

Best,
Matias