This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
commit 2ad3e4e17be61f6f98acfc6bba2c19fe3f753f11 Author: raiden00pl <[email protected]> AuthorDate: Wed May 20 09:25:25 2026 +0200 examples/pwm: remove refenrences to PULSECOUNT Remove refenrences to PULSECOUNT from PWM example. Pulse count driver will be handled by separate application. Signed-off-by: raiden00pl <[email protected]> --- examples/pwm/Kconfig | 12 +--------- examples/pwm/pwm.h | 10 +-------- examples/pwm/pwm_main.c | 60 +++++++++---------------------------------------- 3 files changed, 12 insertions(+), 70 deletions(-) diff --git a/examples/pwm/Kconfig b/examples/pwm/Kconfig index b6e0a3d82..facd1b6dd 100644 --- a/examples/pwm/Kconfig +++ b/examples/pwm/Kconfig @@ -28,8 +28,7 @@ config EXAMPLES_PWM_DURATION int "Default PWM duration" default 5 ---help--- - The default PWM pulse train duration in seconds. Used only if the current - pulse count is zero. Default: 5 seconds + The default PWM pulse train duration in seconds. Default: 5 seconds config EXAMPLES_PWM_DUTYPCT1 int "First PWM duty percentage" @@ -135,13 +134,4 @@ config EXAMPLES_PWM_CHANNEL6 endif -config EXAMPLES_PWM_PULSECOUNT - int "Default pulse count" - default 0 - depends on PWM_PULSECOUNT - ---help--- - The initial PWM pulse count. This option is only available if - PWM_PULSECOUNT is defined. Default: 0 (i.e., use the duration, not - the count). - endif diff --git a/examples/pwm/pwm.h b/examples/pwm/pwm.h index d5c15aed9..389241626 100644 --- a/examples/pwm/pwm.h +++ b/examples/pwm/pwm.h @@ -45,12 +45,8 @@ * CONFIG_EXAMPLES_PWM_CHANNELn - The PWM channel number for channel n. * Default: n * CONFIG_EXAMPLES_PWM_DURATION - The initial PWM pulse train duration - * in seconds. Used only if the current pulse count is zero - * (pulse count is only supported if CONFIG_PWM_PULSECOUNT is defined). + * in seconds. * Default: 5 seconds - * CONFIG_EXAMPLES_PWM_PULSECOUNT - The initial PWM pulse count. - * This option is only available if CONFIG_PWM_PULSECOUNT is defined. - * Default: 0 (i.e., use the duration, not the count). */ #ifndef CONFIG_PWM @@ -69,10 +65,6 @@ # define CONFIG_EXAMPLES_PWM_DURATION 5 #endif -#ifndef CONFIG_EXAMPLES_PWM_PULSECOUNT -# define CONFIG_EXAMPLES_PWM_PULSECOUNT 0 -#endif - /**************************************************************************** * Public Types ****************************************************************************/ diff --git a/examples/pwm/pwm_main.c b/examples/pwm/pwm_main.c index 085a36b9e..e373a5bb0 100644 --- a/examples/pwm/pwm_main.c +++ b/examples/pwm/pwm_main.c @@ -98,9 +98,6 @@ struct pwm_state_s int8_t channels[CONFIG_PWM_NCHANNELS]; uint8_t duties[CONFIG_PWM_NCHANNELS]; uint32_t freq; -#ifdef CONFIG_PWM_PULSECOUNT - uint32_t count; -#endif int duration; }; @@ -230,11 +227,6 @@ static void pwm_help(FAR struct pwm_state_s *pwm) } printf("\n"); -#ifdef CONFIG_PWM_PULSECOUNT - printf(" [-n count] selects the pulse count. " - "Default: %d Current: %" PRIx32 "\n", - CONFIG_EXAMPLES_PWM_PULSECOUNT, pwm->count); -#endif printf(" [-t duration] is the duration of the pulse train in seconds. " "Default: %d Current: %d\n", CONFIG_EXAMPLES_PWM_DURATION, pwm->duration); @@ -361,20 +353,6 @@ static void parse_args(FAR struct pwm_state_s *pwm, int argc, index += nargs; break; -#ifdef CONFIG_PWM_PULSECOUNT - case 'n': - nargs = arg_decimal(&argv[index], &value); - if (value < 0) - { - printf("Count must be non-negative: %ld\n", value); - exit(1); - } - - pwm->count = (uint32_t)value; - index += nargs; - break; -#endif - case 'p': nargs = arg_string(&argv[index], &str); pwm_devpath(pwm, str); @@ -449,9 +427,6 @@ int main(int argc, FAR char *argv[]) #endif g_pwmstate.freq = CONFIG_EXAMPLES_PWM_FREQUENCY; g_pwmstate.duration = CONFIG_EXAMPLES_PWM_DURATION; -#ifdef CONFIG_PWM_PULSECOUNT - g_pwmstate.count = CONFIG_EXAMPLES_PWM_PULSECOUNT; -#endif g_pwmstate.initialized = true; } @@ -511,10 +486,6 @@ int main(int argc, FAR char *argv[]) info.channels[i].channel, info.channels[i].duty); } -#ifdef CONFIG_PWM_PULSECOUNT - info.channels[0].count = g_pwmstate.count; - printf(" count: %" PRIx32, info.channels[0].count); -#endif printf("\n"); ret = ioctl(fd, PWMIOC_SETCHARACTERISTICS, @@ -526,9 +497,7 @@ int main(int argc, FAR char *argv[]) goto errout_with_dev; } - /* Then start the pulse train. Since the driver was opened in blocking - * mode, this call will block if the count value is greater than zero. - */ + /* Then start the pulse train. */ ret = ioctl(fd, PWMIOC_START, 0); if (ret < 0) @@ -537,28 +506,19 @@ int main(int argc, FAR char *argv[]) goto errout_with_dev; } - /* It a non-zero count was not specified, then wait for the selected - * duration, then stop the PWM output. - */ - -#ifdef CONFIG_PWM_PULSECOUNT - if (info.channels[0].count == 0) -#endif - { - /* Wait for the specified duration */ + /* Wait for the specified duration, then stop the PWM output. */ - sleep(g_pwmstate.duration); + sleep(g_pwmstate.duration); - /* Then stop the pulse train */ + /* Then stop the pulse train */ - printf("pwm_main: stopping output\n"); + printf("pwm_main: stopping output\n"); - ret = ioctl(fd, PWMIOC_STOP, 0); - if (ret < 0) - { - printf("pwm_main: ioctl(PWMIOC_STOP) failed: %d\n", errno); - goto errout_with_dev; - } + ret = ioctl(fd, PWMIOC_STOP, 0); + if (ret < 0) + { + printf("pwm_main: ioctl(PWMIOC_STOP) failed: %d\n", errno); + goto errout_with_dev; } close(fd);
