Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
Ardupilot
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OpenSource
Ardupilot
Commits
6f993fe6
Commit
6f993fe6
authored
10 years ago
by
Mikhail Avkhimenia
Committed by
Andrew Tridgell
10 years ago
Browse files
Options
Downloads
Patches
Plain Diff
HAL_Linux: add prototype RCInput code for Navio
parent
ef420a25
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
libraries/AP_HAL_Linux/RCInput_Navio.cpp
+49
-3
49 additions, 3 deletions
libraries/AP_HAL_Linux/RCInput_Navio.cpp
libraries/AP_HAL_Linux/RCInput_Navio.h
+13
-0
13 additions, 0 deletions
libraries/AP_HAL_Linux/RCInput_Navio.h
with
62 additions
and
3 deletions
libraries/AP_HAL_Linux/RCInput_Navio.cpp
+
49
−
3
View file @
6f993fe6
...
...
@@ -15,16 +15,62 @@ extern const AP_HAL::HAL& hal;
using
namespace
Linux
;
// This is a prototype code for RC input decoding on Raspberry Pi.
// It uses pigpio daemon to sample GPIOs over DMA with 1 microsecond resolution.
// This code should be rewritten to configure DMA GPIO sampling without pigpio.
void
LinuxRCInput_Navio
::
init
(
void
*
)
{
// To be added
curtick
=
0
;
prevtick
=
0
;
width_s0
=
0
;
width_s1
=
0
;
// Kills pigpio daemon in case it was run with wrong parameters
system
(
"killall pigpiod -q"
);
hal
.
scheduler
->
delay
(
1000
);
// Starts pigpio daemon with 1 microsecond sampling resolution
system
(
"pigpiod -s 1"
);
hal
.
scheduler
->
delay
(
1000
);
// Configures pigpiod to send GPIO change notifications to /dev/pigpio0
system
(
"pigs NO NB 0 0x10"
);
hal
.
scheduler
->
delay
(
1000
);
// Configures /dev/pigpio0 for non-blocking read
pigpio
=
open
(
"/dev/pigpio0"
,
O_RDONLY
);
if
(
pigpio
==
-
1
)
hal
.
scheduler
->
panic
(
"No pigpio interface for RCInput"
);
}
void
LinuxRCInput_Navio
::
_timer_tick
()
{
// To be added
while
(
true
)
{
int
bytesAvailable
;
ioctl
(
pigpio
,
FIONREAD
,
&
bytesAvailable
);
if
(
bytesAvailable
>=
12
)
::
read
(
pigpio
,
reinterpret_cast
<
uint8_t
*>
(
&
gpioReport
),
12
);
else
break
;
prevtick
=
curtick
;
curtick
=
gpioReport
.
tick
;
if
(((
gpioReport
.
level
>>
4
)
&
0x01
)
==
0
)
{
width_s0
=
curtick
-
prevtick
;
}
else
{
width_s1
=
curtick
-
prevtick
;
_process_rc_pulse
(
width_s0
,
width_s1
);
}
}
}
#endif // CONFIG_HAL_BOARD_SUBTYPE
This diff is collapsed.
Click to expand it.
libraries/AP_HAL_Linux/RCInput_Navio.h
+
13
−
0
View file @
6f993fe6
...
...
@@ -12,7 +12,20 @@ public:
void
_timer_tick
(
void
);
private:
int
pigpio
;
struct
gpioReport_t
{
uint16_t
seqno
;
uint16_t
flags
;
uint32_t
tick
;
uint32_t
level
;
}
gpioReport
;
int
curtick
;
int
prevtick
;
uint16_t
width_s0
;
uint16_t
width_s1
;
};
#endif // __AP_HAL_LINUX_RCINPUT_NAVIO_H__
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