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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software
DC motor driver hat
Commits
3c8351ea
Commit
3c8351ea
authored
Jul 18, 2024
by
Samuel Tardieu
Browse files
Options
Downloads
Patches
Plain Diff
Use thread mode mutex now that I²C doesn't run in interrupt mode anymore
parent
98ef95c1
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
controller/src/blinker.rs
+2
-2
2 additions, 2 deletions
controller/src/blinker.rs
controller/src/logic/motor_control.rs
+2
-2
2 additions, 2 deletions
controller/src/logic/motor_control.rs
controller/src/logic/watchdog.rs
+2
-2
2 additions, 2 deletions
controller/src/logic/watchdog.rs
with
6 additions
and
6 deletions
controller/src/blinker.rs
+
2
−
2
View file @
3c8351ea
...
...
@@ -2,10 +2,10 @@ use embassy_stm32::{
gpio
::{
Level
,
Output
,
Speed
},
peripherals
::
PB15
,
};
use
embassy_sync
::{
blocking_mutex
::
raw
::
CriticalSection
RawMutex
,
signal
::
Signal
};
use
embassy_sync
::{
blocking_mutex
::
raw
::
ThreadMode
RawMutex
,
signal
::
Signal
};
use
embassy_time
::
Timer
;
static
BLINK_PATTERN
:
Signal
<
CriticalSection
RawMutex
,
&
'static
str
>
=
Signal
::
new
();
static
BLINK_PATTERN
:
Signal
<
ThreadMode
RawMutex
,
&
'static
str
>
=
Signal
::
new
();
pub
fn
set_blink_pattern
(
pattern
:
&
'static
str
)
{
BLINK_PATTERN
.signal
(
pattern
);
...
...
This diff is collapsed.
Click to expand it.
controller/src/logic/motor_control.rs
+
2
−
2
View file @
3c8351ea
use
crate
::
tb6612fng
::{
Movement
,
Tb6612fng
};
use
core
::
sync
::
atomic
::{
AtomicU16
,
AtomicU32
,
AtomicU8
,
Ordering
};
use
embassy_stm32
::
time
::{
hz
,
Hertz
};
use
embassy_sync
::{
blocking_mutex
::
raw
::
CriticalSection
RawMutex
,
channel
::
Channel
};
use
embassy_sync
::{
blocking_mutex
::
raw
::
ThreadMode
RawMutex
,
channel
::
Channel
};
const
STANDBY
:
u8
=
0x80
;
const
STANDBY_BOTH
:
u16
=
((
STANDBY
as
u16
)
<<
8
)
|
STANDBY
as
u16
;
...
...
@@ -56,7 +56,7 @@ pub fn get_pwm_frequency() -> Hertz {
// - two regular motor commands
// - one standby command sent by I²C
// - one standby command sent by the software watchdog
static
MOTOR_CONTROL
:
Channel
<
CriticalSection
RawMutex
,
MotorCommand
,
4
>
=
Channel
::
new
();
static
MOTOR_CONTROL
:
Channel
<
ThreadMode
RawMutex
,
MotorCommand
,
4
>
=
Channel
::
new
();
#[embassy_executor::task]
#[allow(clippy::cast_possible_wrap)]
...
...
This diff is collapsed.
Click to expand it.
controller/src/logic/watchdog.rs
+
2
−
2
View file @
3c8351ea
use
super
::
motor_control
;
use
core
::
sync
::
atomic
::{
AtomicU8
,
Ordering
};
use
embassy_stm32
::
pac
::{
self
,
wwdg
::
vals
::
Wdgtb
};
use
embassy_sync
::{
blocking_mutex
::
raw
::
CriticalSection
RawMutex
,
signal
::
Signal
};
use
embassy_sync
::{
blocking_mutex
::
raw
::
ThreadMode
RawMutex
,
signal
::
Signal
};
use
embassy_time
::{
Duration
,
Instant
,
Ticker
};
static
WATCHDOG_PING
:
Signal
<
CriticalSection
RawMutex
,
Instant
>
=
Signal
::
new
();
static
WATCHDOG_PING
:
Signal
<
ThreadMode
RawMutex
,
Instant
>
=
Signal
::
new
();
static
WATCHDOG_TICKS
:
AtomicU8
=
AtomicU8
::
new
(
5
);
pub
fn
ping
()
{
...
...
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