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
c459901f
Commit
c459901f
authored
11 years ago
by
px4dev
Browse files
Options
Downloads
Patches
Plain Diff
Let's have some direct-access I/O methods as well.
parent
95f59f52
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
src/drivers/device/cdev.cpp
+28
-7
28 additions, 7 deletions
src/drivers/device/cdev.cpp
src/drivers/device/device.h
+42
-5
42 additions, 5 deletions
src/drivers/device/device.h
with
70 additions
and
12 deletions
src/drivers/device/cdev.cpp
+
28
−
7
View file @
c459901f
...
...
@@ -111,21 +111,21 @@ CDev::~CDev()
int
CDev
::
init
()
{
int
ret
=
OK
;
// base class init first
ret
=
Device
::
init
();
int
ret
=
Device
::
init
();
if
(
ret
!=
OK
)
goto
out
;
// now register the driver
ret
=
register_driver
(
_devname
,
&
fops
,
0666
,
(
void
*
)
this
);
if
(
_devname
!=
nullptr
)
{
ret
=
register_driver
(
_devname
,
&
fops
,
0666
,
(
void
*
)
this
);
if
(
ret
!=
OK
)
goto
out
;
if
(
ret
!=
OK
)
goto
out
;
_registered
=
true
;
_registered
=
true
;
}
out
:
return
ret
;
...
...
@@ -395,4 +395,25 @@ cdev_poll(struct file *filp, struct pollfd *fds, bool setup)
return
cdev
->
poll
(
filp
,
fds
,
setup
);
}
int
CDev
::
read
(
unsigned
offset
,
void
*
data
,
unsigned
count
)
{
errno
=
ENODEV
;
return
-
1
;
}
int
CDev
::
write
(
unsigned
offset
,
void
*
data
,
unsigned
count
)
{
errno
=
ENODEV
;
return
-
1
;
}
int
CDev
::
ioctl
(
unsigned
operation
,
unsigned
&
arg
)
{
errno
=
ENODEV
;
return
-
1
;
}
}
// namespace device
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/drivers/device/device.h
+
42
−
5
View file @
c459901f
...
...
@@ -85,7 +85,7 @@ protected:
*/
Device
(
const
char
*
name
,
int
irq
=
0
);
~
Device
();
virtual
~
Device
();
/**
* Initialise the driver and make it ready for use.
...
...
@@ -189,7 +189,7 @@ public:
/**
* Destructor
*/
~
CDev
();
virtual
~
CDev
();
virtual
int
init
();
...
...
@@ -287,6 +287,43 @@ public:
*/
bool
is_open
()
{
return
_open_count
>
0
;
}
/*
* Direct access methods.
*/
/**
* Read directly from the device.
*
* The actual size of each unit quantity is device-specific.
*
* @param offset The device offset at which to start reading
* @param data The buffer into which the read values should be placed.
* @param count The number of items to read, defaults to 1.
* @return count on success, < 0 on error.
*/
virtual
int
read
(
unsigned
offset
,
void
*
data
,
unsigned
count
=
1
);
/**
* Write directly to the device.
*
* The actual size of each unit quantity is device-specific.
*
* @param address The device address at which to start writing.
* @param data The buffer from which values should be read.
* @param count The number of registers to write, defaults to 1.
* @return count on success, < 0 on error.
*/
virtual
int
write
(
unsigned
address
,
void
*
data
,
unsigned
count
=
1
);
/**
* Perform a device-specific operation.
*
* @param operation The operation to perform
* @param arg An argument to the operation.
* @return < 0 on error
*/
virtual
int
ioctl
(
unsigned
operation
,
unsigned
&
arg
);
protected
:
/**
* Pointer to the default cdev file operations table; useful for
...
...
@@ -396,9 +433,9 @@ public:
const
char
*
devname
,
uint32_t
base
,
int
irq
=
0
);
~
PIO
();
virtual
~
PIO
();
int
init
();
virtual
int
init
();
protected:
...
...
@@ -407,7 +444,7 @@ protected:
*
* @param offset Register offset in bytes from the base address.
*/
uint32_t
reg
(
uint32_t
offset
)
{
uint32_t
reg
(
uint32_t
offset
)
{
return
*
(
volatile
uint32_t
*
)(
_base
+
offset
);
}
...
...
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