tiacsys / bridle

Bridle and kite line for embedded systems based on Zephyr.
https://bridle.tiac-systems.net
Apache License 2.0
15 stars 3 forks source link

[RFC] PIO Based Counter for the RP2040 #269

Open jbehrensnx opened 2 weeks ago

jbehrensnx commented 2 weeks ago

Problem description

When testing the drv84xx stepper motor driver on the Cytron RP2040 board, it was discovered, that RP2040 does not include a counter (accessible via the Counter API) that has the required capabilities (setting of a custom comperator value and attaching an ISR to the comperator).

Proposed change

The development of a new counter using the RP2040s PIO that supports these features.

Detailed RFC

This requires he completion of the three following tasks:

  1. Evaluation of the PIO to determine that a counter with sufficient comparator max value can be implemented. A preliminary investigation suggests that this is possible.
  2. Evaluation of the Zephyr PIO integration to determine if it supports all necessary features. Currently the IRQs from the PIO are ignored.
  3. Implementation of the counter using the PIO.

Dependencies

The new counter driver would allow for the development and porting of software that require the setting of comparator values (TOP value) and attaching interrupts to it. The added interrupt support for the PIO would also allow for the development of software using its interrupts.

The PIO IRQ were already a topic in the following Zaphyr pull requests: rp2040: Added PIO support rpi_pico: Added Generic PIO support and a PIO based UART driver

Alternatives

Developing a counter using the PWM hardware of the RP2040 is currently also under consideration. This one is however limited to 16 bit and would not support alarm interrupts.

Points of origin

Our ongoing development of the stepper motor driver drv84xx is a consistent continuation of the results from the following Zephyr upstream RFCs and PRs:

The goal is a generalized STEP/DIR driver based on timers (Counter API and/or PWM API) that can be used on all usable SoCs from different manufacturers. The current focus is on: STMicro (STM32 series), NXP (i.MX RT series), Raspberry Pi Pico (RP2040, possibly also RP235x).