Skip to content

Add Arduino Zephyr core support - #567

Draft
gbr1 wants to merge 1 commit into
simplefoc:devfrom
gbr1:zephyr
Draft

gbr1 wants to merge 1 commit 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.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant