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
692f7fa6
Commit
692f7fa6
authored
8 months ago
by
Samuel Tardieu
Browse files
Options
Downloads
Patches
Plain Diff
Add chip identification at boot time
parent
fd842936
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
controller/src/chip.rs
+42
-0
42 additions, 0 deletions
controller/src/chip.rs
controller/src/main.rs
+3
-0
3 additions, 0 deletions
controller/src/main.rs
with
45 additions
and
0 deletions
controller/src/chip.rs
0 → 100644
+
42
−
0
View file @
692f7fa6
use
embassy_stm32
::
pac
;
pub
fn
identify
()
{
let
dbgmcu
=
pac
::
DBGMCU
.idcode
()
.read
();
let
(
density
,
rev
)
=
match
(
dbgmcu
.dev_id
(),
dbgmcu
.rev_id
())
{
(
0x412
,
0x1000
)
=>
(
"low-density"
,
"A"
),
(
0x412
,
_
)
=>
(
"low-density"
,
"?"
),
(
0x410
,
0x0000
)
=>
(
"medium-density"
,
"A"
),
(
0x410
,
0x2000
)
=>
(
"medium-density"
,
"B"
),
(
0x410
,
0x2001
)
=>
(
"medium-density"
,
"Z"
),
(
0x410
,
0x2003
)
=>
(
"medium-density"
,
"1/2/3/X/Y"
),
(
0x414
,
0x1000
)
=>
(
"high-density"
,
"1/A"
),
(
0x414
,
0x1001
)
=>
(
"high-density"
,
"Z"
),
(
0x414
,
0x1003
)
=>
(
"high-density"
,
"1/2/3/X/Y"
),
(
0x414
,
_
)
=>
(
"high-density"
,
"?"
),
(
0x430
,
0x1000
)
=>
(
"XL-density"
,
"1/A"
),
(
0x430
,
_
)
=>
(
"XL-density"
,
"?"
),
(
0x418
,
0x1000
)
=>
(
"connectivity"
,
"A"
),
(
0x418
,
0x1001
)
=>
(
"connectivity"
,
"Z"
),
(
0x418
,
_
)
=>
(
"connectivity"
,
"?"
),
(
_
,
_
)
=>
(
"?"
,
"?"
),
};
let
flash_size
=
unsafe
{
*
(
0x1FFF_F7E0
as
*
const
u16
)
};
defmt
::
info!
(
"Device type: {}, revision: {} – flash size: {}kB"
,
density
,
rev
,
flash_size
);
let
pid
=
0xe00f_ffe0
as
*
const
[
u32
;
3
];
let
pid
=
unsafe
{
*
pid
};
let
used
=
pid
[
2
]
&
8
!=
0
;
let
identity_code
=
((
pid
[
1
]
&
0xf0
)
>>
4
)
|
((
pid
[
2
]
&
0x7
)
<<
4
);
let
continuation_code
=
unsafe
{
*
(
0xe00f_ffd0
as
*
const
u32
)
};
defmt
::
info!
(
"used = {}, identity_code = {:#04x}, continuation_code = {:#04x}"
,
used
,
identity_code
,
continuation_code
);
}
This diff is collapsed.
Click to expand it.
controller/src/main.rs
+
3
−
0
View file @
692f7fa6
...
@@ -15,6 +15,7 @@ use embassy_stm32::{
...
@@ -15,6 +15,7 @@ use embassy_stm32::{
use
panic_probe
as
_
;
use
panic_probe
as
_
;
pub
mod
blinker
;
pub
mod
blinker
;
mod
chip
;
mod
encoders
;
mod
encoders
;
mod
logic
;
mod
logic
;
mod
power
;
mod
power
;
...
@@ -87,6 +88,8 @@ async fn main(spawner: Spawner) {
...
@@ -87,6 +88,8 @@ async fn main(spawner: Spawner) {
defmt
::
Debug2Format
(
&
reset_cause
),
defmt
::
Debug2Format
(
&
reset_cause
),
);
);
chip
::
identify
();
spawner
spawner
.spawn
(
blinker
::
blink
(
p
.PB15
,
blink_pattern
(
reset_cause
)))
.spawn
(
blinker
::
blink
(
p
.PB15
,
blink_pattern
(
reset_cause
)))
.unwrap
();
.unwrap
();
...
...
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