-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
Pickup some loose ends from PR #7122 #7218
Conversation
…ckCycles (like in rest of core API for this type of use). Fix/clarify comments. Fix redundancies in Tone, end Tone waveform on exact period limit for proper sound. Fix redundancies in wiring_pwmExtend Servo to map in-use pins, Tone already has this.
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.
Thanks for the cleanup and fixing the comments to match the code.
For the Servo changes, I'm not seeing it used anywhere but keeping a mask like in the other 2 users of waveforms seems like a nice thing to do.
@@ -49,7 +52,7 @@ void tone(uint8_t _pin, unsigned int frequency, unsigned long duration) { | |||
if (frequency == 0) { | |||
noTone(_pin); | |||
} else { | |||
uint32_t period = (1000000L * system_get_cpu_freq()) / frequency; | |||
uint32_t period = microsecondsToClockCycles(1000000UL) / frequency; |
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.
I'm not sure whether this change is ok. The microsecondsToClockCycles() define uses the F_CPU macro, while system_get_cpu_freq() is the SDK api call.
I think it is ok because these functions aren't supposed to be called from an ISR. Also, if built for 160MHz, execution will be done at that speed something like 95% of the time.
Future-proofing #7122, newly introduced public
startWaveformCycles()
is more aptly namedstartWaveformClockCycles()
(like in rest of core API for this type of use).Fix/clarify comments.
Fix redundancies in Tone, end Tone waveform on exact period limit for proper sound.
Fix redundancies in wiring_pwm.
Extend Servo to map in-use pins, Tone already has this.