Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
DC motor driver hat
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
Container 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
Software
DC motor driver hat
Commits
8f740492
Commit
8f740492
authored
8 months ago
by
Samuel Tardieu
Browse files
Options
Downloads
Patches
Plain Diff
Add RESET command
parent
b39f3f3a
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.org
+4
-0
4 additions, 0 deletions
README.org
controller/python/controller.py
+5
-0
5 additions, 0 deletions
controller/python/controller.py
controller/src/logic/mod.rs
+5
-0
5 additions, 0 deletions
controller/src/logic/mod.rs
with
14 additions
and
0 deletions
README.org
+
4
−
0
View file @
8f740492
...
...
@@ -125,6 +125,10 @@ Multibyte values are exchanged in little endian format.
duration in 10th of seconds on 1 byte. This cannot be used if the
motor is moving.
** [IMPLEMENTED] 0xE0 Reset (W)
- Reset the device. Used mainly for testing.
** 0xF0-0xF7 Unique device ID (R)
- Unique device ID as found in addresses 0x1FFFF7E8-0x1FFFF7EF
...
...
This diff is collapsed.
Click to expand it.
controller/python/controller.py
+
5
−
0
View file @
8f740492
...
...
@@ -22,6 +22,7 @@ class Controller:
MOTOR_SPEED
=
0x30
ENCODER_TICKS
=
0x32
STATUS
=
0x36
RESET
=
0xE0
def
__init__
(
self
,
i2cbus
=
8
):
import
smbus
...
...
@@ -161,3 +162,7 @@ class Controller:
"""
Return the PWM frequency in Hz.
"""
a
,
b
,
c
=
self
.
_read
(
self
.
PWM_FREQUENCY
,
3
,
"
BBB
"
)
return
a
|
(
b
<<
8
)
|
(
c
<<
16
)
def
reset
(
self
):
"""
Reset the device. Used mainly for testing.
"""
self
.
_write
(
self
.
RESET
,
[])
This diff is collapsed.
Click to expand it.
controller/src/logic/mod.rs
+
5
−
0
View file @
8f740492
...
...
@@ -60,6 +60,7 @@ const CMD_MOTOR_SHUTDOWN_TIMEOUT: u8 = 0x28;
const
CMD_MOTOR_SPEED
:
u8
=
0x30
;
const
CMD_ENCODER_TICKS
:
u8
=
0x32
;
const
CMD_STATUS
:
u8
=
0x36
;
const
CMD_RESET
:
u8
=
0xe0
;
include!
(
concat!
(
env!
(
"OUT_DIR"
),
"/version.rs"
));
...
...
@@ -153,6 +154,10 @@ fn process_command(
.push_back
(
u8
::
from
(
motor_control
::
is_moving
()))
.unwrap
();
}
[
CMD_RESET
]
=>
{
defmt
::
info!
(
"resetting device after receiving the RESET command"
);
cortex_m
::
peripheral
::
SCB
::
sys_reset
();
}
_
=>
{
defmt
::
warn!
(
"unknown command or args {:#04x}"
,
command
);
return
false
;
...
...
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