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
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
345e9864
Commit
345e9864
authored
5 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
stm32/modpyb: Add pyb.country() function to set the country.
To be used for peripherals (like radio) that must be location aware.
parent
cf1c131f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ports/stm32/factoryreset.c
+1
-0
1 addition, 0 deletions
ports/stm32/factoryreset.c
ports/stm32/modpyb.c
+19
-0
19 additions, 0 deletions
ports/stm32/modpyb.c
with
20 additions
and
0 deletions
ports/stm32/factoryreset.c
+
1
−
0
View file @
345e9864
...
...
@@ -35,6 +35,7 @@ static const char fresh_boot_py[] =
"
\r\n
"
"import machine
\r\n
"
"import pyb
\r\n
"
"pyb.country('US') # ISO 3166-1 Alpha-2 code, eg US, GB, DE, AU
\r\n
"
"#pyb.main('main.py') # main script to run after this one
\r\n
"
#if MICROPY_HW_ENABLE_USB
"#pyb.usb_mode('VCP+MSC') # act as a serial and a storage device
\r\n
"
...
...
This diff is collapsed.
Click to expand it.
ports/stm32/modpyb.c
+
19
−
0
View file @
345e9864
...
...
@@ -56,6 +56,8 @@
#include
"extmod/vfs.h"
#include
"extmod/utime_mphal.h"
char
pyb_country_code
[
2
];
STATIC
mp_obj_t
pyb_fault_debug
(
mp_obj_t
value
)
{
pyb_hard_fault_debug
=
mp_obj_is_true
(
value
);
return
mp_const_none
;
...
...
@@ -112,6 +114,22 @@ STATIC mp_obj_t pyb_repl_uart(size_t n_args, const mp_obj_t *args) {
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN
(
pyb_repl_uart_obj
,
0
,
1
,
pyb_repl_uart
);
STATIC
mp_obj_t
pyb_country
(
size_t
n_args
,
const
mp_obj_t
*
args
)
{
if
(
n_args
==
0
)
{
return
mp_obj_new_str
(
pyb_country_code
,
2
);
}
else
{
size_t
len
;
const
char
*
str
=
mp_obj_str_get_data
(
args
[
0
],
&
len
);
if
(
len
!=
2
)
{
mp_raise_ValueError
(
NULL
);
}
pyb_country_code
[
0
]
=
str
[
0
];
pyb_country_code
[
1
]
=
str
[
1
];
return
mp_const_none
;
}
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN
(
pyb_country_obj
,
0
,
1
,
pyb_country
);
STATIC
const
mp_rom_map_elem_t
pyb_module_globals_table
[]
=
{
{
MP_ROM_QSTR
(
MP_QSTR___name__
),
MP_ROM_QSTR
(
MP_QSTR_pyb
)
},
...
...
@@ -139,6 +157,7 @@ STATIC const mp_rom_map_elem_t pyb_module_globals_table[] = {
#endif
{
MP_ROM_QSTR
(
MP_QSTR_main
),
MP_ROM_PTR
(
&
pyb_main_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_repl_uart
),
MP_ROM_PTR
(
&
pyb_repl_uart_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_country
),
MP_ROM_PTR
(
&
pyb_country_obj
)
},
#if MICROPY_HW_ENABLE_USB
{
MP_ROM_QSTR
(
MP_QSTR_usb_mode
),
MP_ROM_PTR
(
&
pyb_usb_mode_obj
)
},
...
...
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