mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-01 20:29:00 +00:00
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 <raiden00@railab.me>
This commit is contained in:
parent
5355adb9cf
commit
2ad3e4e17b
3 changed files with 14 additions and 72 deletions
|
|
@ -28,8 +28,7 @@ config EXAMPLES_PWM_DURATION
|
||||||
int "Default PWM duration"
|
int "Default PWM duration"
|
||||||
default 5
|
default 5
|
||||||
---help---
|
---help---
|
||||||
The default PWM pulse train duration in seconds. Used only if the current
|
The default PWM pulse train duration in seconds. Default: 5 seconds
|
||||||
pulse count is zero. Default: 5 seconds
|
|
||||||
|
|
||||||
config EXAMPLES_PWM_DUTYPCT1
|
config EXAMPLES_PWM_DUTYPCT1
|
||||||
int "First PWM duty percentage"
|
int "First PWM duty percentage"
|
||||||
|
|
@ -135,13 +134,4 @@ config EXAMPLES_PWM_CHANNEL6
|
||||||
|
|
||||||
endif
|
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
|
endif
|
||||||
|
|
|
||||||
|
|
@ -45,12 +45,8 @@
|
||||||
* CONFIG_EXAMPLES_PWM_CHANNELn - The PWM channel number for channel n.
|
* CONFIG_EXAMPLES_PWM_CHANNELn - The PWM channel number for channel n.
|
||||||
* Default: n
|
* Default: n
|
||||||
* CONFIG_EXAMPLES_PWM_DURATION - The initial PWM pulse train duration
|
* CONFIG_EXAMPLES_PWM_DURATION - The initial PWM pulse train duration
|
||||||
* in seconds. Used only if the current pulse count is zero
|
* in seconds.
|
||||||
* (pulse count is only supported if CONFIG_PWM_PULSECOUNT is defined).
|
|
||||||
* Default: 5 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
|
#ifndef CONFIG_PWM
|
||||||
|
|
@ -69,10 +65,6 @@
|
||||||
# define CONFIG_EXAMPLES_PWM_DURATION 5
|
# define CONFIG_EXAMPLES_PWM_DURATION 5
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_EXAMPLES_PWM_PULSECOUNT
|
|
||||||
# define CONFIG_EXAMPLES_PWM_PULSECOUNT 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Types
|
* Public Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
|
||||||
|
|
@ -98,9 +98,6 @@ struct pwm_state_s
|
||||||
int8_t channels[CONFIG_PWM_NCHANNELS];
|
int8_t channels[CONFIG_PWM_NCHANNELS];
|
||||||
uint8_t duties[CONFIG_PWM_NCHANNELS];
|
uint8_t duties[CONFIG_PWM_NCHANNELS];
|
||||||
uint32_t freq;
|
uint32_t freq;
|
||||||
#ifdef CONFIG_PWM_PULSECOUNT
|
|
||||||
uint32_t count;
|
|
||||||
#endif
|
|
||||||
int duration;
|
int duration;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -230,11 +227,6 @@ static void pwm_help(FAR struct pwm_state_s *pwm)
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\n");
|
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. "
|
printf(" [-t duration] is the duration of the pulse train in seconds. "
|
||||||
"Default: %d Current: %d\n",
|
"Default: %d Current: %d\n",
|
||||||
CONFIG_EXAMPLES_PWM_DURATION, pwm->duration);
|
CONFIG_EXAMPLES_PWM_DURATION, pwm->duration);
|
||||||
|
|
@ -361,20 +353,6 @@ static void parse_args(FAR struct pwm_state_s *pwm, int argc,
|
||||||
index += nargs;
|
index += nargs;
|
||||||
break;
|
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':
|
case 'p':
|
||||||
nargs = arg_string(&argv[index], &str);
|
nargs = arg_string(&argv[index], &str);
|
||||||
pwm_devpath(pwm, str);
|
pwm_devpath(pwm, str);
|
||||||
|
|
@ -449,9 +427,6 @@ int main(int argc, FAR char *argv[])
|
||||||
#endif
|
#endif
|
||||||
g_pwmstate.freq = CONFIG_EXAMPLES_PWM_FREQUENCY;
|
g_pwmstate.freq = CONFIG_EXAMPLES_PWM_FREQUENCY;
|
||||||
g_pwmstate.duration = CONFIG_EXAMPLES_PWM_DURATION;
|
g_pwmstate.duration = CONFIG_EXAMPLES_PWM_DURATION;
|
||||||
#ifdef CONFIG_PWM_PULSECOUNT
|
|
||||||
g_pwmstate.count = CONFIG_EXAMPLES_PWM_PULSECOUNT;
|
|
||||||
#endif
|
|
||||||
g_pwmstate.initialized = true;
|
g_pwmstate.initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -511,10 +486,6 @@ int main(int argc, FAR char *argv[])
|
||||||
info.channels[i].channel, info.channels[i].duty);
|
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");
|
printf("\n");
|
||||||
|
|
||||||
ret = ioctl(fd, PWMIOC_SETCHARACTERISTICS,
|
ret = ioctl(fd, PWMIOC_SETCHARACTERISTICS,
|
||||||
|
|
@ -526,9 +497,7 @@ int main(int argc, FAR char *argv[])
|
||||||
goto errout_with_dev;
|
goto errout_with_dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Then start the pulse train. Since the driver was opened in blocking
|
/* Then start the pulse train. */
|
||||||
* mode, this call will block if the count value is greater than zero.
|
|
||||||
*/
|
|
||||||
|
|
||||||
ret = ioctl(fd, PWMIOC_START, 0);
|
ret = ioctl(fd, PWMIOC_START, 0);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
|
@ -537,28 +506,19 @@ int main(int argc, FAR char *argv[])
|
||||||
goto errout_with_dev;
|
goto errout_with_dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* It a non-zero count was not specified, then wait for the selected
|
/* Wait for the specified duration, then stop the PWM output. */
|
||||||
* duration, then stop the PWM output.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef CONFIG_PWM_PULSECOUNT
|
sleep(g_pwmstate.duration);
|
||||||
if (info.channels[0].count == 0)
|
|
||||||
#endif
|
/* Then stop the pulse train */
|
||||||
|
|
||||||
|
printf("pwm_main: stopping output\n");
|
||||||
|
|
||||||
|
ret = ioctl(fd, PWMIOC_STOP, 0);
|
||||||
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
/* Wait for the specified duration */
|
printf("pwm_main: ioctl(PWMIOC_STOP) failed: %d\n", errno);
|
||||||
|
goto errout_with_dev;
|
||||||
sleep(g_pwmstate.duration);
|
|
||||||
|
|
||||||
/* Then stop the pulse train */
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue