Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
volatile-register
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
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
Per Lindgren
volatile-register
Commits
dd032be5
Commit
dd032be5
authored
6 years ago
by
Per
Browse files
Options
Downloads
Patches
Plain Diff
examples and documentation
parent
23972ce1
No related branches found
No related tags found
No related merge requests found
Pipeline
#90
failed
6 years ago
Stage: build
Stage: test
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
README.md
+5
-0
5 additions, 0 deletions
README.md
examples/example.rs
+18
-13
18 additions, 13 deletions
examples/example.rs
examples/example2.rs
+5
-0
5 additions, 0 deletions
examples/example2.rs
src/lib.rs
+2
-3
2 additions, 3 deletions
src/lib.rs
with
30 additions
and
16 deletions
README.md
+
5
−
0
View file @
dd032be5
...
...
@@ -7,6 +7,11 @@
Adds debug to volatile register when compiled with
`--features debug-fmt`
.
## Caveats
Notice, the current implementation requres a nightly toolchain (
`feature(specilization`
)).
This can be
```
rust
extern
crate
volatile_register
;
use
std
::
mem
;
...
...
This diff is collapsed.
Click to expand it.
examples/example.rs
+
18
−
13
View file @
dd032be5
//! Example to show the use of debug output for small register arrays
//!
//! > cargo run --example example2 --features debug-fmt
//!
extern
crate
volatile_register
;
use
std
::
mem
;
use
volatile_register
::
{
RW
}
;
use
volatile_register
::
RW
;
#[repr(C)]
#[derive(Debug)]
pub
struct
Nvic
{
/// Interrupt Set-Enable
pub
iser
:
[
RW
<
u32
>
;
8
],
reserved0
:
[
u32
;
24
],
/// Interrupt Clear-Enable
pub
icer
:
[
RW
<
u32
>
;
8
],
reserved1
:
[
u32
;
24
],
// .. more registers ..
#[repr(C)]
#[derive(Debug)]
pub
struct
Nvic
{
/// Interrupt Set-Enable
pub
iser
:
[
RW
<
u32
>
;
8
],
reserved0
:
[
u32
;
24
],
/// Interrupt Clear-Enable
pub
icer
:
[
RW
<
u32
>
;
8
],
reserved1
:
[
u32
;
24
],
// .. more registers ..
}
fn
main
()
{
let
r
:
Nvic
=
unsafe
{
mem
::
uninitialized
()
};
let
r
:
Nvic
=
unsafe
{
mem
::
uninitialized
()
};
println!
(
"{:?}"
,
r
);
}
\ No newline at end of file
}
This diff is collapsed.
Click to expand it.
examples/example2.rs
+
5
−
0
View file @
dd032be5
//! Example to show the use of debug output for big register arrays
//!
//! > cargo run --example example2 --features debug-fmt
//!
extern
crate
array_debug
;
extern
crate
volatile_register
;
...
...
This diff is collapsed.
Click to expand it.
src/lib.rs
+
2
−
3
View file @
dd032be5
...
...
@@ -27,14 +27,13 @@
#![deny(missing_docs)]
#![no_std]
#![feature(specialization)]
#![
cfg_attr(feature
=
"debug-fmt"
,
feature(specialization)
)
]
extern
crate
vcell
;
#[cfg(feature
=
"debug-fmt"
)]
use
core
::
fmt
;
use
core
::
fmt
::{
self
,
Debug
,
UpperHex
}
;
#[cfg(feature
=
"debug-fmt"
)]
use
core
::
fmt
::{
Debug
,
UpperHex
};
use
vcell
::
VolatileCell
;
/// Read-Only register
...
...
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