-
Notifications
You must be signed in to change notification settings - Fork 29
zephyrCommon: Implement analogWrite() #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
b32d822
to
f3b7ebe
Compare
samples/fade/prj.conf
Outdated
@@ -0,0 +1,4 @@ | |||
CONFIG_CPLUSPLUS=y | |||
CONFIG_ARDUINO_API=y | |||
CONFIG_GPIO=y |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, gpio and CPP seem redundant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed it.
samples/fade/src/app.cpp
Outdated
*/ | ||
|
||
#include <Arduino.h> | ||
#include "zephyrSerial.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
including zephyrSerial shouldn't really be necessary as it is included in Arduino.h itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed it.
pinctrl-0 = <&pwm1_default>; | ||
pinctrl-1 = <&pwm1_sleep>; | ||
pinctrl-names = "default", "sleep"; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having documentation as to what all needs to be added in overlays might help here as well.
The 'pwms' node under the 'zephyr,user' defines available PWM channels. The 'pwm-pins' defines the mapping of PWM channels to pin numbers. API looks up the 'pwm-pins' when querying the PWM channel by digital pin number. So it should be in the same order as 'pwms' node. PWM channels should configure and tied to the output pins. The period property of the PWM channel is used as resolution as PWM. For original Arduino API compatibility, it should be 255. The period property and API argument determines the duty ratio. Signed-off-by: TOKITA Hiroshi <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Built locally, and it does build.
Also flashed it on my nano 33 ble sense, and changed the sample a bit to rather use LED_BUILTIN.
LGTM.
Minor nitpicks, but otherwise can merge.
I thought I would have rebase access, but seems like I can't squash commits, please can you squash my last commit in previous one? |
Added a fade sample to demonstrate how to use analogWrite API Signed-off-by: TOKITA Hiroshi <[email protected]>
squash and update done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
The 'pwms' node under the 'zephyr,user' defines available PWM channels.
The 'pwm-pins' defines the mapping of PWM channels to pin numbers.
API looks up the 'pwm-pins' when querying the PWM channel by digital pin number.
So it should be in the same order as 'pwms' node.
PWM channels should configure and tied to the output pins.
The period property of the PWM channel is used as resolution as PWM.
For original Arduino API compatibility, it should be 255.
The period property and API argument determines the duty ratio.
I verified this PR with mkrzero and nano_33_ble.
Some pins of the mkrzero seem not to work correctly.
Only verified configuration only enableed.