Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
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
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
b83d0b35
Commit
b83d0b35
authored
9 years ago
by
Dave Hylands
Committed by
Damien George
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
stmhal: Add define for UNIQUE_ID address (differs per MCU)
parent
823a961e
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
stmhal/modmachine.c
+2
-1
2 additions, 1 deletion
stmhal/modmachine.c
stmhal/mphal.h
+10
-0
10 additions, 0 deletions
stmhal/mphal.h
stmhal/usbd_desc.c
+5
-1
5 additions, 1 deletion
stmhal/usbd_desc.c
with
17 additions
and
2 deletions
stmhal/modmachine.c
+
2
−
1
View file @
b83d0b35
...
@@ -38,13 +38,14 @@
...
@@ -38,13 +38,14 @@
#include
"pin.h"
#include
"pin.h"
#include
"timer.h"
#include
"timer.h"
#include
"usb.h"
#include
"usb.h"
#include MICROPY_HAL_H
// machine.info([dump_alloc_table])
// machine.info([dump_alloc_table])
// Print out lots of information about the board.
// Print out lots of information about the board.
STATIC
mp_obj_t
machine_info
(
mp_uint_t
n_args
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
machine_info
(
mp_uint_t
n_args
,
const
mp_obj_t
*
args
)
{
// get and print unique id; 96 bits
// get and print unique id; 96 bits
{
{
byte
*
id
=
(
byte
*
)
0x1fff7a10
;
byte
*
id
=
(
byte
*
)
MP_HAL_UNIQUE_ID_ADDRESS
;
printf
(
"ID=%02x%02x%02x%02x:%02x%02x%02x%02x:%02x%02x%02x%02x
\n
"
,
id
[
0
],
id
[
1
],
id
[
2
],
id
[
3
],
id
[
4
],
id
[
5
],
id
[
6
],
id
[
7
],
id
[
8
],
id
[
9
],
id
[
10
],
id
[
11
]);
printf
(
"ID=%02x%02x%02x%02x:%02x%02x%02x%02x:%02x%02x%02x%02x
\n
"
,
id
[
0
],
id
[
1
],
id
[
2
],
id
[
3
],
id
[
4
],
id
[
5
],
id
[
6
],
id
[
7
],
id
[
8
],
id
[
9
],
id
[
10
],
id
[
11
]);
}
}
...
...
This diff is collapsed.
Click to expand it.
stmhal/mphal.h
+
10
−
0
View file @
b83d0b35
// We use the ST Cube HAL library for most hardware peripherals
// We use the ST Cube HAL library for most hardware peripherals
#include STM32_HAL_H
#include STM32_HAL_H
// The unique id address differs per MCU. Ideally this define should
// go in some MCU-specific header, but for now it lives here.
#if defined(MCU_SERIES_F4)
#define MP_HAL_UNIQUE_ID_ADDRESS (0x1fff7a10)
#elif defined(MCU_SERIES_F7)
#define MP_HAL_UNIQUE_ID_ADDRESS (0x1ff0f420)
#else
#error mphal.h: Unrecognized MCU_SERIES
#endif
// Basic GPIO functions
// Basic GPIO functions
#define GPIO_read_pin(gpio, pin) (((gpio)->IDR >> (pin)) & 1)
#define GPIO_read_pin(gpio, pin) (((gpio)->IDR >> (pin)) & 1)
#if defined(MCU_SERIES_F7)
#if defined(MCU_SERIES_F7)
...
...
This diff is collapsed.
Click to expand it.
stmhal/usbd_desc.c
+
5
−
1
View file @
b83d0b35
...
@@ -33,6 +33,10 @@
...
@@ -33,6 +33,10 @@
#include
"usbd_desc.h"
#include
"usbd_desc.h"
#include
"usbd_conf.h"
#include
"usbd_conf.h"
// need these headers just for MP_HAL_UNIQUE_ID_ADDRESS
#include
"py/misc.h"
#include MICROPY_HAL_H
// So we don't clash with existing ST boards, we use the unofficial FOSS VID.
// So we don't clash with existing ST boards, we use the unofficial FOSS VID.
// This needs a proper solution.
// This needs a proper solution.
#define USBD_VID 0xf055
#define USBD_VID 0xf055
...
@@ -169,7 +173,7 @@ STATIC uint8_t *USBD_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *leng
...
@@ -169,7 +173,7 @@ STATIC uint8_t *USBD_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *leng
//
//
// See: https://my.st.com/52d187b7 for the algorithim used.
// See: https://my.st.com/52d187b7 for the algorithim used.
uint8_t
*
id
=
(
uint8_t
*
)
0x1fff7a10
;
uint8_t
*
id
=
(
uint8_t
*
)
MP_HAL_UNIQUE_ID_ADDRESS
;
char
serial_buf
[
16
];
char
serial_buf
[
16
];
snprintf
(
serial_buf
,
sizeof
(
serial_buf
),
snprintf
(
serial_buf
,
sizeof
(
serial_buf
),
"%02X%02X%02X%02X%02X%02X"
,
"%02X%02X%02X%02X%02X%02X"
,
...
...
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