Skip to content

Add Arduino Zephyr core support - #567

Open
gbr1 wants to merge 2 commits into
simplefoc:devfrom
gbr1:zephyr
Open

gbr1 wants to merge 2 commits into
simplefoc:devfrom
gbr1:zephyr

Conversation

@gbr1

@gbr1 gbr1 commented Sep 29, 2026

Copy link
Copy Markdown

Description

Adds hardware-specific implementations for the Arduino Zephyr core (ArduinoCore-zephyr), selected via ARDUINO_ARCH_ZEPHYR.

Driver PWM (1/2/3/4-PWM) drives the Zephyr PWM timers directly through pwm_set_pulse_dt(): the requested frequency is stored once into a per-pin copy of the channel's pwm_dt_spec, and each update pushes only the pulse width. Pins are resolved from the pwms/pwm-pin-gpios properties of the board's zephyr,user devicetree node, and the timer channel is muxed to the GPIO via init_dev_apply_channel_pinctrl() (as the core's analogWrite does). Pins not mapped to a PWM channel fall back to analogWrite(). 6-PWM is reported as unsupported (no portable hardware dead-time).

Verified on Arduino UNO Q (STM32U585): compiles, uploads, runs the open-loop velocity example, and generates PWM on the timer-mapped pins.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Test Configuration/Setup:

  • Hardware: Arduino UNO Q
  • IDE: Arduino IDE
  • MCU package version (ArduinoCore-zephyr 1.0.0)

Adds hardware-specific implementations for the Arduino Zephyr core
(ArduinoCore-zephyr), selected via ARDUINO_ARCH_ZEPHYR.

Driver PWM (1/2/3/4-PWM) drives the Zephyr PWM timers directly through
pwm_set_pulse_dt(): the requested frequency is stored once into a per-pin
copy of the channel's pwm_dt_spec, and each update pushes only the pulse
width. Pins are resolved from the `pwms`/`pwm-pin-gpios` properties of the
board's `zephyr,user` devicetree node, and the timer channel is muxed to
the GPIO via init_dev_apply_channel_pinctrl() (as the core's analogWrite
does). Pins not mapped to a PWM channel fall back to analogWrite().
6-PWM is reported as unsupported (no portable hardware dead-time).

Inline current sensing uses analogRead()/analogReadResolution().
Low-side sensing is reported as unsupported (needs ADC/PWM sync).

Verified on Arduino UNO Q (STM32U585): compiles, uploads, runs the
open-loop velocity example, and generates PWM on the timer-mapped pins.
@gbr1
gbr1 marked this pull request as ready for review October 1, 2026 09:45
@askuric

askuric commented Oct 4, 2026

Copy link
Copy Markdown
Member

Hey @gbr1,

Thanks for this.
I've added a CI for zephyr to test. I'd be ok to merge this at this stage, wve thoug it's early, but it is ok. the comunity wil ask for more if they want it. :D

Could you please just add an example code in th examples folder?
examples/hardware_specific_examples\UNO_Q\open_loop_control

Just in case someone searches for something similar.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants