Merge tag 'dey-3.2-r1.2'
Digi Embedded Yocto 3.2-r1.2 Signed-off-by: Mike Engel <Mike.Engel@digi.com>
This commit is contained in:
commit
f7a41d073c
|
|
@ -139,8 +139,11 @@ static int parse_argument(char *argv, int arg_type)
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int ret, duty_cycle = 10, ascending = 1, pwm_chip, pwm_channel, pwm_freq = 0;
|
int ret, ascending = 1, pwm_chip, pwm_channel, pwm_freq = 0;
|
||||||
char *name = basename(argv[0]);
|
char *name = basename(argv[0]);
|
||||||
|
int duty_cycle[] = {0, 1, 3, 5, 10, 15, 20, 30, 50, 100};
|
||||||
|
int d = 0;
|
||||||
|
int levels = sizeof(duty_cycle) / sizeof(duty_cycle[0]);
|
||||||
|
|
||||||
/* Check if the PWM values are passed in the command line. */
|
/* Check if the PWM values are passed in the command line. */
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
|
|
@ -211,25 +214,19 @@ int main(int argc, char **argv)
|
||||||
/* Main application loop.*/
|
/* Main application loop.*/
|
||||||
while (running) {
|
while (running) {
|
||||||
/* Set the duty cycle. */
|
/* Set the duty cycle. */
|
||||||
ret = ldx_pwm_set_duty_cycle_percentage(pwm_line, duty_cycle);
|
ret = ldx_pwm_set_duty_cycle_percentage(pwm_line, duty_cycle[d]);
|
||||||
if (ret != PWM_CONFIG_ERROR_NONE) {
|
if (ret != PWM_CONFIG_ERROR_NONE) {
|
||||||
printf("Failed to set the duty cycle\n");
|
printf("Failed to set the duty cycle\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
if (ascending) {
|
if (ascending) {
|
||||||
duty_cycle += 10;
|
if (++d == levels - 1)
|
||||||
if (duty_cycle == 100) {
|
|
||||||
duty_cycle = 80;
|
|
||||||
ascending = 0;
|
ascending = 0;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
duty_cycle -= 10;
|
if (--d == 0)
|
||||||
if (duty_cycle == 0) {
|
|
||||||
duty_cycle = 20;
|
|
||||||
ascending = 1;
|
ascending = 1;
|
||||||
}
|
}
|
||||||
}
|
usleep(150000);
|
||||||
sleep(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue