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
Roger Le Fort Ndayambaje
e7020e_2021
Commits
a7c31800
Commit
a7c31800
authored
4 years ago
by
Per Lindgren
Browse files
Options
Downloads
Patches
Plain Diff
pmw3389 wip, firmare uplode not yet tested
parent
12c41d5a
Branches
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
+60
-8
60 additions, 8 deletions
examples/pmw3389.rs
with
60 additions
and
8 deletions
examples/pmw3389.rs
+
60
−
8
View file @
a7c31800
...
...
@@ -120,12 +120,14 @@ const APP: () = {
.unwrap
();
iprintln!
(
stim
,
"ripple_control {:x}"
,
id
);
pmw3389
.write_register
(
pmw3389
::
Register
::
RippleControl
,
10
);
// pmw3389
// .write_register(pmw3389::Register::RippleControl, 10)
// .unwrap();
let
id
=
pmw3389
.read_register
(
pmw3389
::
Register
::
RippleControl
)
.unwrap
();
iprintln!
(
stim
,
"ripple_control {:x}"
,
id
);
//
let id = pmw3389
//
.read_register(pmw3389::Register::RippleControl)
//
.unwrap();
//
iprintln!(stim, "ripple_control {:x}", 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
...
...
@@ -286,12 +288,62 @@ mod pmw3389 {
SPI
:
Transfer
<
u8
,
Error
=
E
>
+
Write
<
u8
,
Error
=
E
>
,
CS
:
OutputPin
,
{
fn
com_start
(
&
mut
self
)
{
self
.cs
.set_low
();
}
fn
com_end
(
&
mut
self
)
{
self
.cs
.set_low
();
}
/// Creates a new driver from a SPI peripheral and a NCS pin
pub
fn
new
(
spi
:
SPI
,
cs
:
CS
,
delay
:
DwtDelay
)
->
Result
<
Self
,
E
>
{
pub
fn
new
(
spi
:
SPI
,
cs
:
CS
,
delay
:
DwtDelay
,
mut
itm
:
stm32f4
::
stm32f411
::
ITM
,
)
->
Result
<
Self
,
E
>
{
let
mut
pmw3389
=
Pmw3389
{
spi
,
cs
,
delay
};
// power up code here?
// download firmware etc.
// ensure SPI is reset
pmw3389
.com_end
();
pmw3389
.com_start
();
pmw3389
.com_end
();
// force reset
pmw3389
.write_register
(
Register
::
PowerUpReset
,
0x5a
);
// wait for reboot
pmw3389
.delay
.delay_ms
(
50
);
// read registers 0x02 to 0x06 (and discard the data)
pmw3389
.read_register
(
Register
::
Motion
)
?
;
pmw3389
.read_register
(
Register
::
DeltaXL
)
?
;
pmw3389
.read_register
(
Register
::
DeltaXH
)
?
;
pmw3389
.read_register
(
Register
::
DeltaYL
)
?
;
pmw3389
.read_register
(
Register
::
DeltaYH
)
?
;
pmw3389
.upload_firmware
(
itm
)
?
;
pmw3389
.delay
.delay_ms
(
10
);
iprintln!
(
&
mut
itm
.stim
[
0
],
"Optical Chip Initialized"
);
// adns_com_end(); // ensure that the serial port is reset
// adns_com_begin(); // ensure that the serial port is reset
// adns_com_end(); // ensure that the serial port is reset
// adns_write_reg(Power_Up_Reset, 0x5a); // force reset
// delay(50); // wait for it to reboot
// // read registers 0x02 to 0x06 (and discard the data)
// adns_read_reg(Motion);
// adns_read_reg(Delta_X_L);
// adns_read_reg(Delta_X_H);
// adns_read_reg(Delta_Y_L);
// adns_read_reg(Delta_Y_H);
// // upload the firmware
// adns_upload_firmware();
// delay(10);
// Serial.println("Optical Chip Initialized");
// }
Ok
(
pmw3389
)
}
...
...
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