This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new 76a5693cb examples/pwm: support CONFIG_PWM_FREQUENCY_FIXED
76a5693cb is described below
commit 76a5693cbbc8f03702d08afda562a5fa2c188e1f
Author: yangsong8 <[email protected]>
AuthorDate: Mon Nov 16 22:24:37 2026 +0800
examples/pwm: support CONFIG_PWM_FREQUENCY_FIXED
With CONFIG_PWM_FREQUENCY_FIXED pwm_info_s.frequency is ub32_t (Hz
in 32.32 fixed point). The example assigned the raw Hz value
without converting it, which also breaks the build because the
printf format no longer matches the wider type:
examples/pwm/pwm_main.c:477:10: error: format '%u' expects
argument of type 'unsigned int', but argument 2 has type
'pwm_freq_t' {aka 'long unsigned int'} [-Werror=format=]
Convert the frequency with uitoub32() and print the Hz value.
Assisted-by: opencode:zhipuai/glm-5.3
Signed-off-by: yangsong8 <[email protected]>
---
examples/pwm/pwm_main.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/examples/pwm/pwm_main.c b/examples/pwm/pwm_main.c
index e373a5bb0..40f533070 100644
--- a/examples/pwm/pwm_main.c
+++ b/examples/pwm/pwm_main.c
@@ -473,9 +473,13 @@ int main(int argc, FAR char *argv[])
/* Configure the characteristics of the pulse train */
memset(&info, 0, sizeof(info));
+#ifdef CONFIG_PWM_FREQUENCY_FIXED
+ info.frequency = uitoub32(g_pwmstate.freq);
+#else
info.frequency = g_pwmstate.freq;
+#endif
printf("pwm_main: starting output with frequency: %" PRIu32,
- info.frequency);
+ g_pwmstate.freq);
for (i = 0; i < CONFIG_PWM_NCHANNELS; i++)
{