Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
Baitboat
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
Baitboat
Commits
49d3035e
Commit
49d3035e
authored
10 years ago
by
Mikhail Avkhimenia
Committed by
Andrew Tridgell
10 years ago
Browse files
Options
Downloads
Patches
Plain Diff
HAL_Linux: fix types, remove printfs in GPIO_RPI
parent
6f993fe6
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
libraries/AP_HAL_Linux/GPIO_RPI.cpp
+21
-23
21 additions, 23 deletions
libraries/AP_HAL_Linux/GPIO_RPI.cpp
libraries/AP_HAL_Linux/GPIO_RPI.h
+2
-1
2 additions, 1 deletion
libraries/AP_HAL_Linux/GPIO_RPI.h
with
23 additions
and
24 deletions
libraries/AP_HAL_Linux/GPIO_RPI.cpp
+
21
−
23
View file @
49d3035e
...
...
@@ -22,29 +22,27 @@ LinuxGPIO_RPI::LinuxGPIO_RPI()
void
LinuxGPIO_RPI
::
init
()
{
// open /dev/mem
if
((
mem_fd
=
open
(
"/dev/mem"
,
O_RDWR
|
O_SYNC
)
)
<
0
)
{
printf
(
"can't open /dev/mem
\n
"
);
exit
(
-
1
);
}
// mmap GPIO
gpio_map
=
mmap
(
NULL
,
// Any adddress in our space will do
BLOCK_SIZE
,
// Map length
PROT_READ
|
PROT_WRITE
,
// Enable reading & writting to mapped memory
MAP_SHARED
,
// Shared with other processes
mem_fd
,
// File to map
GPIO_BASE
// Offset to GPIO peripheral
);
close
(
mem_fd
);
// No need to keep mem_fd open after mmap
if
(
gpio_map
==
MAP_FAILED
)
{
printf
(
"mmap error %d
\n
"
,
(
int
)
gpio_map
);
// errno also set!
exit
(
-
1
);
}
gpio
=
(
volatile
unsigned
*
)
gpio_map
;
// Always use volatile pointer!
if
((
mem_fd
=
open
(
"/dev/mem"
,
O_RDWR
|
O_SYNC
)
)
<
0
)
{
hal
.
scheduler
->
panic
(
"Can't open /dev/mem"
);
}
// mmap GPIO
gpio_map
=
mmap
(
NULL
,
// Any adddress in our space will do
BLOCK_SIZE
,
// Map length
PROT_READ
|
PROT_WRITE
,
// Enable reading & writting to mapped memory
MAP_SHARED
,
// Shared with other processes
mem_fd
,
// File to map
GPIO_BASE
// Offset to GPIO peripheral
);
close
(
mem_fd
);
// No need to keep mem_fd open after mmap
if
(
gpio_map
==
MAP_FAILED
)
{
hal
.
scheduler
->
panic
(
"Can't open /dev/mem"
);
}
gpio
=
(
volatile
uint32_t
*
)
gpio_map
;
// Always use volatile pointer!
}
void
LinuxGPIO_RPI
::
pinMode
(
uint8_t
pin
,
uint8_t
output
)
...
...
This diff is collapsed.
Click to expand it.
libraries/AP_HAL_Linux/GPIO_RPI.h
+
2
−
1
View file @
49d3035e
...
...
@@ -2,6 +2,7 @@
#ifndef __AP_HAL_LINUX_GPIO_RPI_H__
#define __AP_HAL_LINUX_GPIO_RPI_H__
#include
<stdint.h>
#include
<AP_HAL_Linux.h>
#define LOW 0
...
...
@@ -48,7 +49,7 @@ class Linux::LinuxGPIO_RPI : public AP_HAL::GPIO {
private:
int
mem_fd
;
void
*
gpio_map
;
volatile
u
nsigned
*
gpio
;
volatile
u
int32_t
*
gpio
;
public:
LinuxGPIO_RPI
();
...
...
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