Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython
Commits
83158e0e
Commit
83158e0e
authored
Oct 19, 2015
by
Damien George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stmhal: Implement os.dupterm (was pyb.repl_uart).
pyb.repl_uart still exists but points to os.dupterm.
parent
d8066e99
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
23 deletions
+29
-23
stmhal/modpyb.c
stmhal/modpyb.c
+1
-23
stmhal/moduos.c
stmhal/moduos.c
+26
-0
stmhal/portmodules.h
stmhal/portmodules.h
+1
-0
stmhal/qstrdefsport.h
stmhal/qstrdefsport.h
+1
-0
No files found.
stmhal/modpyb.c
View file @
83158e0e
...
...
@@ -124,28 +124,6 @@ STATIC mp_obj_t pyb_elapsed_micros(mp_obj_t start) {
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_1
(
pyb_elapsed_micros_obj
,
pyb_elapsed_micros
);
/// \function repl_uart(uart)
/// Get or set the UART object that the REPL is repeated on.
STATIC
mp_obj_t
pyb_repl_uart
(
mp_uint_t
n_args
,
const
mp_obj_t
*
args
)
{
if
(
n_args
==
0
)
{
if
(
MP_STATE_PORT
(
pyb_stdio_uart
)
==
NULL
)
{
return
mp_const_none
;
}
else
{
return
MP_STATE_PORT
(
pyb_stdio_uart
);
}
}
else
{
if
(
args
[
0
]
==
mp_const_none
)
{
MP_STATE_PORT
(
pyb_stdio_uart
)
=
NULL
;
}
else
if
(
mp_obj_get_type
(
args
[
0
])
==
&
pyb_uart_type
)
{
MP_STATE_PORT
(
pyb_stdio_uart
)
=
args
[
0
];
}
else
{
nlr_raise
(
mp_obj_new_exception_msg
(
&
mp_type_ValueError
,
"need a UART object"
));
}
return
mp_const_none
;
}
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN
(
pyb_repl_uart_obj
,
0
,
1
,
pyb_repl_uart
);
MP_DECLARE_CONST_FUN_OBJ
(
pyb_main_obj
);
// defined in main.c
STATIC
const
mp_map_elem_t
pyb_module_globals_table
[]
=
{
...
...
@@ -165,7 +143,7 @@ STATIC const mp_map_elem_t pyb_module_globals_table[] = {
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_stop
),
(
mp_obj_t
)
&
machine_sleep_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_standby
),
(
mp_obj_t
)
&
machine_deepsleep_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_main
),
(
mp_obj_t
)
&
pyb_main_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_repl_uart
),
(
mp_obj_t
)
&
pyb_repl_uart
_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_repl_uart
),
(
mp_obj_t
)
&
mod_os_dupterm
_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_usb_mode
),
(
mp_obj_t
)
&
pyb_usb_mode_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_hid_mouse
),
(
mp_obj_t
)
&
pyb_usb_hid_mouse_obj
},
...
...
stmhal/moduos.c
View file @
83158e0e
...
...
@@ -35,6 +35,7 @@
#include "lib/fatfs/diskio.h"
#include "timeutils.h"
#include "rng.h"
#include "uart.h"
#include "file.h"
#include "sdcard.h"
#include "fsusermount.h"
...
...
@@ -374,6 +375,28 @@ STATIC mp_obj_t os_urandom(mp_obj_t num) {
STATIC
MP_DEFINE_CONST_FUN_OBJ_1
(
os_urandom_obj
,
os_urandom
);
#endif
// Get or set the UART object that the REPL is repeated on.
// TODO should accept any object with read/write methods.
STATIC
mp_obj_t
os_dupterm
(
mp_uint_t
n_args
,
const
mp_obj_t
*
args
)
{
if
(
n_args
==
0
)
{
if
(
MP_STATE_PORT
(
pyb_stdio_uart
)
==
NULL
)
{
return
mp_const_none
;
}
else
{
return
MP_STATE_PORT
(
pyb_stdio_uart
);
}
}
else
{
if
(
args
[
0
]
==
mp_const_none
)
{
MP_STATE_PORT
(
pyb_stdio_uart
)
=
NULL
;
}
else
if
(
mp_obj_get_type
(
args
[
0
])
==
&
pyb_uart_type
)
{
MP_STATE_PORT
(
pyb_stdio_uart
)
=
args
[
0
];
}
else
{
nlr_raise
(
mp_obj_new_exception_msg
(
&
mp_type_ValueError
,
"need a UART object"
));
}
return
mp_const_none
;
}
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN
(
mod_os_dupterm_obj
,
0
,
1
,
os_dupterm
);
STATIC
const
mp_map_elem_t
os_module_globals_table
[]
=
{
{
MP_OBJ_NEW_QSTR
(
MP_QSTR___name__
),
MP_OBJ_NEW_QSTR
(
MP_QSTR_uos
)
},
...
...
@@ -397,6 +420,9 @@ STATIC const mp_map_elem_t os_module_globals_table[] = {
#if MICROPY_HW_ENABLE_RNG
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_urandom
),
(
mp_obj_t
)
&
os_urandom_obj
},
#endif
// these are MicroPython extensions
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_dupterm
),
(
mp_obj_t
)
&
mod_os_dupterm_obj
},
};
STATIC
MP_DEFINE_CONST_DICT
(
os_module_globals
,
os_module_globals_table
);
...
...
stmhal/portmodules.h
View file @
83158e0e
...
...
@@ -37,3 +37,4 @@ MP_DECLARE_CONST_FUN_OBJ(time_sleep_ms_obj);
MP_DECLARE_CONST_FUN_OBJ
(
time_sleep_us_obj
);
MP_DECLARE_CONST_FUN_OBJ
(
mod_os_sync_obj
);
MP_DECLARE_CONST_FUN_OBJ
(
mod_os_dupterm_obj
);
stmhal/qstrdefsport.h
View file @
83158e0e
...
...
@@ -400,6 +400,7 @@ Q(unlink)
Q
(
sep
)
Q
(
stat
)
Q
(
urandom
)
Q
(
dupterm
)
// for time module
Q
(
utime
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment