Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
e7020e_2021
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Deux Babiri Futari
e7020e_2021
Commits
74dfa9ee
Commit
74dfa9ee
authored
4 years ago
by
Per Lindgren
Browse files
Options
Downloads
Patches
Plain Diff
pmw3389 wip, id works
parent
a419d7ee
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/pmw3389.rs
+31
-5
31 additions, 5 deletions
examples/pmw3389.rs
with
31 additions
and
5 deletions
examples/pmw3389.rs
+
31
−
5
View file @
74dfa9ee
...
...
@@ -7,7 +7,7 @@ use cortex_m::{
iprintln
,
peripheral
::{
itm
::
Stim
,
DWT
},
};
use
embedded_hal
::
spi
::
MODE_0
;
use
embedded_hal
::
spi
::
{
MODE_0
,
MODE_1
,
MODE_2
,
MODE_3
}
;
// use cortex_m_semihosting::hprintln;
use
panic_halt
as
_
;
use
rtic
::
cyccnt
::{
Instant
,
U32Ext
as
_
};
...
...
@@ -83,8 +83,8 @@ const APP: () = {
// polarity: Polarity::IdleLow,
// phase: Phase::CaptureOnFirstTransition,
// },
MODE_
0
,
stm32f4xx_hal
::
time
::
KiloHertz
(
20
00
)
.into
(),
MODE_
3
,
stm32f4xx_hal
::
time
::
KiloHertz
(
1
00
)
.into
(),
clocks
,
);
...
...
@@ -94,6 +94,32 @@ const APP: () = {
let
id
=
pmw3389
.product_id
()
.unwrap
();
iprintln!
(
stim
,
"id {}"
,
id
);
let
id
=
pmw3389
.product_id
()
.unwrap
();
iprintln!
(
stim
,
"id {}"
,
id
);
let
id
=
pmw3389
.read_register
(
pmw3389
::
Register
::
RevisionId
)
.unwrap
();
iprintln!
(
stim
,
"rev {}"
,
id
);
let
id
=
pmw3389
.read_register
(
pmw3389
::
Register
::
ShutterLower
)
.unwrap
();
iprintln!
(
stim
,
"lower {}"
,
id
);
let
id
=
pmw3389
.read_register
(
pmw3389
::
Register
::
ShutterUpper
)
.unwrap
();
iprintln!
(
stim
,
"upper {}"
,
id
);
let
id
=
pmw3389
.read_register
(
pmw3389
::
Register
::
SROMId
)
.unwrap
();
iprintln!
(
stim
,
"sromid {}"
,
id
);
let
id
=
pmw3389
.read_register
(
pmw3389
::
Register
::
InverseProductID
)
.unwrap
();
iprintln!
(
stim
,
"-id {}"
,
id
);
// semantically, the monotonic timer is frozen at time "zero" during `init`
// NOTE do *not* call `Instant::now` in this context; it will return a nonsense value
// let now = cx.start; // the start time of the system
...
...
@@ -312,10 +338,10 @@ mod pmw3389 {
// self.change_config(Register::CTRL_REG4, scale)
// }
fn
read_register
(
&
mut
self
,
reg
:
Register
)
->
Result
<
u8
,
E
>
{
pub
fn
read_register
(
&
mut
self
,
reg
:
Register
)
->
Result
<
u8
,
E
>
{
let
_
=
self
.cs
.set_low
();
let
mut
buffer
=
[
reg
.addr
()
|
SINGLE
|
READ
,
0
];
let
mut
buffer
=
[
reg
.addr
()
&
0x7f
,
0
];
self
.spi
.transfer
(
&
mut
buffer
)
?
;
let
_
=
self
.cs
.set_high
();
...
...
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