Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
non-destructive text 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
Show more breadcrumbs
badge fixer
non-destructive text micropython
Commits
cc63e193
Commit
cc63e193
authored
Feb 22, 2019
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
stm32/mphalport: Add mp_hal_get_mac() helper function.
parent
75a35448
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
ports/stm32/mphalport.c
+11
-0
11 additions, 0 deletions
ports/stm32/mphalport.c
ports/stm32/mphalport.h
+9
-0
9 additions, 0 deletions
ports/stm32/mphalport.h
with
20 additions
and
0 deletions
ports/stm32/mphalport.c
+
11
−
0
View file @
cc63e193
...
@@ -162,3 +162,14 @@ void mp_hal_pin_config_speed(mp_hal_pin_obj_t pin_obj, uint32_t speed) {
...
@@ -162,3 +162,14 @@ void mp_hal_pin_config_speed(mp_hal_pin_obj_t pin_obj, uint32_t speed) {
uint32_t
pin
=
pin_obj
->
pin
;
uint32_t
pin
=
pin_obj
->
pin
;
gpio
->
OSPEEDR
=
(
gpio
->
OSPEEDR
&
~
(
3
<<
(
2
*
pin
)))
|
(
speed
<<
(
2
*
pin
));
gpio
->
OSPEEDR
=
(
gpio
->
OSPEEDR
&
~
(
3
<<
(
2
*
pin
)))
|
(
speed
<<
(
2
*
pin
));
}
}
MP_WEAK
void
mp_hal_get_mac
(
int
idx
,
uint8_t
buf
[
6
])
{
// Generate a random locally administered MAC address (LAA)
uint8_t
*
id
=
(
uint8_t
*
)
MP_HAL_UNIQUE_ID_ADDRESS
;
buf
[
0
]
=
0x02
;
// LAA range
buf
[
1
]
=
(
id
[
11
]
<<
4
)
|
(
id
[
10
]
&
0xf
);
buf
[
2
]
=
(
id
[
9
]
<<
4
)
|
(
id
[
8
]
&
0xf
);
buf
[
3
]
=
(
id
[
7
]
<<
4
)
|
(
id
[
6
]
&
0xf
);
buf
[
4
]
=
id
[
2
];
buf
[
5
]
=
(
id
[
0
]
<<
2
)
|
idx
;
}
This diff is collapsed.
Click to expand it.
ports/stm32/mphalport.h
+
9
−
0
View file @
cc63e193
...
@@ -79,3 +79,12 @@ void mp_hal_gpio_clock_enable(GPIO_TypeDef *gpio);
...
@@ -79,3 +79,12 @@ void mp_hal_gpio_clock_enable(GPIO_TypeDef *gpio);
void
mp_hal_pin_config
(
mp_hal_pin_obj_t
pin
,
uint32_t
mode
,
uint32_t
pull
,
uint32_t
alt
);
void
mp_hal_pin_config
(
mp_hal_pin_obj_t
pin
,
uint32_t
mode
,
uint32_t
pull
,
uint32_t
alt
);
bool
mp_hal_pin_config_alt
(
mp_hal_pin_obj_t
pin
,
uint32_t
mode
,
uint32_t
pull
,
uint8_t
fn
,
uint8_t
unit
);
bool
mp_hal_pin_config_alt
(
mp_hal_pin_obj_t
pin
,
uint32_t
mode
,
uint32_t
pull
,
uint8_t
fn
,
uint8_t
unit
);
void
mp_hal_pin_config_speed
(
mp_hal_pin_obj_t
pin_obj
,
uint32_t
speed
);
void
mp_hal_pin_config_speed
(
mp_hal_pin_obj_t
pin_obj
,
uint32_t
speed
);
enum
{
MP_HAL_MAC_WLAN0
=
0
,
MP_HAL_MAC_WLAN1
,
MP_HAL_MAC_BDADDR
,
MP_HAL_MAC_ETH0
,
};
void
mp_hal_get_mac
(
int
idx
,
uint8_t
buf
[
6
]);
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