Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Firmware
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alberto Ruiz Garcia
Firmware
Commits
7050657a
Commit
7050657a
authored
7 years ago
by
David Sidrane
Committed by
Beat Küng
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
board_identity:Add stm32 board_get_px4_guid and board_get_px4_guid_formated API
parent
1c2f8bd4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/drivers/boards/common/stm32/board_identity.c
+41
-0
41 additions, 0 deletions
src/drivers/boards/common/stm32/board_identity.c
with
41 additions
and
0 deletions
src/drivers/boards/common/stm32/board_identity.c
+
41
−
0
View file @
7050657a
...
...
@@ -44,6 +44,8 @@
#define CPU_UUID_BYTE_FORMAT_ORDER {3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8}
#define SWAP_UINT32(x) (((x) >> 24) | (((x) & 0x00ff0000) >> 8) | (((x) & 0x0000ff00) << 8) | ((x) << 24))
static
const
uint16_t
soc_arch_id
=
PX4_SOC_ARCH_ID
;
/* A type suitable for holding the reordering array for the byte format of the UUID
*/
...
...
@@ -124,3 +126,42 @@ int board_get_mfguid_formated(char *format_buffer, int size)
return
offset
;
}
int
board_get_px4_guid
(
px4_guid_t
px4_guid
)
{
uint8_t
*
pb
=
(
uint8_t
*
)
&
px4_guid
[
0
];
*
pb
++
=
(
soc_arch_id
>>
8
)
&
0xff
;
*
pb
++
=
(
soc_arch_id
&
0xff
);
for
(
unsigned
i
=
0
;
i
<
PX4_GUID_BYTE_LENGTH
-
(
sizeof
(
soc_arch_id
)
+
PX4_CPU_UUID_BYTE_LENGTH
);
i
++
)
{
*
pb
++
=
0
;
}
uint32_t
*
rv
=
(
uint32_t
*
)
pb
;
uint32_t
*
chip_uuid
=
(
uint32_t
*
)
STM32_SYSMEM_UID
;
for
(
unsigned
i
=
0
;
i
<
PX4_CPU_UUID_WORD32_LENGTH
;
i
++
)
{
*
rv
++
=
SWAP_UINT32
(
chip_uuid
[(
PX4_CPU_UUID_WORD32_LENGTH
-
1
)
-
i
]);
}
return
PX4_GUID_BYTE_LENGTH
;
}
int
board_get_px4_guid_formated
(
char
*
format_buffer
,
int
size
)
{
px4_guid_t
px4_guid
;
board_get_px4_guid
(
px4_guid
);
int
offset
=
0
;
/* size should be 2 per byte + 1 for termination
* So it needs to be odd
*/
size
=
size
&
1
?
size
:
size
-
1
;
/* Discard from MSD */
for
(
unsigned
i
=
PX4_GUID_BYTE_LENGTH
-
size
/
2
;
offset
<
size
&&
i
<
PX4_GUID_BYTE_LENGTH
;
i
++
)
{
offset
+=
snprintf
(
&
format_buffer
[
offset
],
size
-
offset
,
"%02x"
,
px4_guid
[
i
]);
}
return
offset
;
}
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