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
fd842936
Commit
fd842936
authored
8 months ago
by
Samuel Tardieu
Browse files
Options
Downloads
Patches
Plain Diff
Add low power detector
parent
a412a7d3
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.org
+5
-4
5 additions, 4 deletions
README.org
controller/src/main.rs
+3
-0
3 additions, 0 deletions
controller/src/main.rs
controller/src/power.rs
+24
-0
24 additions, 0 deletions
controller/src/power.rs
with
32 additions
and
4 deletions
README.org
+
5
−
4
View file @
fd842936
...
...
@@ -48,10 +48,11 @@ the TB6612FNG motor driver.
The led pattern is in Morse code.
| Code | Meaning | Pattern |
|------+------------------------------+---------|
| I | Regular reset | .. |
| WW | Reset due to window watchdog | .-- .-- |
| Code | Meaning | Pattern |
|------+------------------------------------------------------+-----------|
| I | Regular mode | .. |
| LP | Low power (Vdd is below 2.9V) | .-.. .--. |
| WW | Last reset was due to the window watchdog trigerring | .-- .-- |
* Command set
...
...
This diff is collapsed.
Click to expand it.
controller/src/main.rs
+
3
−
0
View file @
fd842936
...
...
@@ -17,6 +17,7 @@ use panic_probe as _;
pub
mod
blinker
;
mod
encoders
;
mod
logic
;
mod
power
;
mod
tb6612fng
;
#[derive(Clone,
Copy,
Debug)]
...
...
@@ -90,6 +91,8 @@ async fn main(spawner: Spawner) {
.spawn
(
blinker
::
blink
(
p
.PB15
,
blink_pattern
(
reset_cause
)))
.unwrap
();
spawner
.spawn
(
power
::
watch_power_level
())
.unwrap
();
let
motors
=
Tb6612fng
::
new
(
p
.PA4
,
p
.PA5
,
...
...
This diff is collapsed.
Click to expand it.
controller/src/power.rs
0 → 100644
+
24
−
0
View file @
fd842936
use
crate
::
blinker
;
use
embassy_stm32
::
pac
;
use
embassy_time
::
Timer
;
#[embassy_executor::task]
pub
async
fn
watch_power_level
()
{
// Activate PWR clock
pac
::
RCC
.apb1enr
()
.modify
(|
w
|
w
.set_pwren
(
true
));
// Configure PVD for 2.9V
pac
::
PWR
.cr
()
.modify
(|
w
|
{
w
.set_pls
(
0b111
);
// 2.9V
w
.set_pvde
(
true
);
});
// Check power level every second, switch blinker to
// LP (low power) if power goes beyond this value.
loop
{
Timer
::
after_secs
(
1
)
.await
;
if
pac
::
PWR
.csr
()
.read
()
.pvdo
()
{
defmt
::
warn!
(
"low power (< 2.9V) detected"
);
blinker
::
set_blink_pattern
(
".-.. .--."
);
break
;
}
}
}
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