Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alberto Ruiz Garcia
Firmware
Commits
0ce854ad
Commit
0ce854ad
authored
8 years ago
by
David Sidrane
Committed by
Lorenz Meier
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Support onshot command
parent
6bc04201
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/systemcmds/pwm/pwm.c
+26
-11
26 additions, 11 deletions
src/systemcmds/pwm/pwm.c
with
26 additions
and
11 deletions
src/systemcmds/pwm/pwm.c
+
26
−
11
View file @
0ce854ad
...
@@ -83,6 +83,12 @@ usage(const char *reason)
...
@@ -83,6 +83,12 @@ usage(const char *reason)
"arm
\t\t\t\t
Arm output
\n
"
"arm
\t\t\t\t
Arm output
\n
"
"disarm
\t\t\t\t
Disarm output
\n
"
"disarm
\t\t\t\t
Disarm output
\n
"
"
\n
"
"
\n
"
"oneshot ...
\t\t\t
Configure Onshot
\n
"
"
\t
[-g <channel group>]
\t
(e.g. 0,1,2)
\n
"
"
\t
[-m <channel mask> ]
\t
(e.g. 0xF)
\n
"
"
\t
[-a]
\t\t\t
Configure all outputs
\n
"
"
\t
-t <pulse>
\t\t
Oneshot duration (1 to 65535 125nS)
\n
"
"
\n
"
"rate ...
\t\t\t
Configure PWM rates
\n
"
"rate ...
\t\t\t
Configure PWM rates
\n
"
"
\t
[-g <channel group>]
\t
(e.g. 0,1,2)
\n
"
"
\t
[-g <channel group>]
\t
(e.g. 0,1,2)
\n
"
"
\t
[-m <channel mask> ]
\t
(e.g. 0xF)
\n
"
"
\t
[-m <channel mask> ]
\t
(e.g. 0xF)
\n
"
...
@@ -169,6 +175,7 @@ pwm_main(int argc, char *argv[])
...
@@ -169,6 +175,7 @@ pwm_main(int argc, char *argv[])
bool
alt_channels_set
=
false
;
bool
alt_channels_set
=
false
;
bool
print_verbose
=
false
;
bool
print_verbose
=
false
;
bool
error_on_warn
=
false
;
bool
error_on_warn
=
false
;
bool
oneshot
=
false
;
int
ch
;
int
ch
;
int
ret
;
int
ret
;
char
*
ep
;
char
*
ep
;
...
@@ -302,6 +309,8 @@ pwm_main(int argc, char *argv[])
...
@@ -302,6 +309,8 @@ pwm_main(int argc, char *argv[])
return
error_on_warn
;
return
error_on_warn
;
}
}
oneshot
=
!
strcmp
(
command
,
"oneshot"
);
if
(
!
strcmp
(
command
,
"arm"
))
{
if
(
!
strcmp
(
command
,
"arm"
))
{
/* tell safety that its ok to disable it with the switch */
/* tell safety that its ok to disable it with the switch */
ret
=
px4_ioctl
(
fd
,
PWM_SERVO_SET_ARM_OK
,
0
);
ret
=
px4_ioctl
(
fd
,
PWM_SERVO_SET_ARM_OK
,
0
);
...
@@ -337,19 +346,18 @@ pwm_main(int argc, char *argv[])
...
@@ -337,19 +346,18 @@ pwm_main(int argc, char *argv[])
return
0
;
return
0
;
}
else
if
(
!
strcmp
(
command
,
"rate"
))
{
}
else
if
(
oneshot
||
!
strcmp
(
command
,
"rate"
))
{
/* change alternate PWM rate */
/* change alternate PWM rate
or set oneshot
*/
//
if (alt_rate > 0) {
if
(
oneshot
||
alt_rate
>
0
)
{
ret
=
px4_ioctl
(
fd
,
PWM_SERVO_SET_UPDATE_RATE
,
alt_rate
);
ret
=
px4_ioctl
(
fd
,
PWM_SERVO_SET_UPDATE_RATE
,
alt_rate
);
if
(
ret
!=
OK
)
{
if
(
ret
!=
OK
)
{
PX4_ERR
(
"PWM_SERVO_SET_UPDATE_RATE (check rate for sanity)"
);
PX4_ERR
(
"PWM_SERVO_SET_UPDATE_RATE (check rate for sanity)"
);
return
error_on_warn
;
return
error_on_warn
;
}
}
}
// }
/* directly supplied channel mask */
/* directly supplied channel mask */
if
(
set_mask
>
0
)
{
if
(
set_mask
>
0
)
{
ret
=
px4_ioctl
(
fd
,
PWM_SERVO_SET_SELECT_UPDATE_RATE
,
set_mask
);
ret
=
px4_ioctl
(
fd
,
PWM_SERVO_SET_SELECT_UPDATE_RATE
,
set_mask
);
...
@@ -632,7 +640,6 @@ pwm_main(int argc, char *argv[])
...
@@ -632,7 +640,6 @@ pwm_main(int argc, char *argv[])
PX4_INFO
(
"Press CTRL-C or 'c' to abort."
);
PX4_INFO
(
"Press CTRL-C or 'c' to abort."
);
while
(
1
)
{
while
(
1
)
{
for
(
unsigned
i
=
0
;
i
<
servo_count
;
i
++
)
{
for
(
unsigned
i
=
0
;
i
<
servo_count
;
i
++
)
{
if
(
set_mask
&
1
<<
i
)
{
if
(
set_mask
&
1
<<
i
)
{
ret
=
px4_ioctl
(
fd
,
PWM_SERVO_SET
(
i
),
pwm_value
);
ret
=
px4_ioctl
(
fd
,
PWM_SERVO_SET
(
i
),
pwm_value
);
...
@@ -670,7 +677,15 @@ pwm_main(int argc, char *argv[])
...
@@ -670,7 +677,15 @@ pwm_main(int argc, char *argv[])
}
}
}
}
usleep
(
2500
);
/* Delay longer than the max Oneshot duration */
usleep
(
2542
);
/* Trigger all timer's channels in Oneshot mode to fire
* the oneshots with updated values.
*/
up_pwm_update
();
}
}
return
0
;
return
0
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment