Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
b88bf6c7
Commit
b88bf6c7
authored
Sep 06, 2016
by
Damien George
Browse files
stmhal/wdt: Implement keyword args to WDT constructor.
parent
69768c97
Changes
1
Hide whitespace changes
Inline
Side-by-side
stmhal/wdt.c
View file @
b88bf6c7
...
...
@@ -37,17 +37,23 @@ typedef struct _pyb_wdt_obj_t {
STATIC
pyb_wdt_obj_t
pyb_wdt
=
{{
&
pyb_wdt_type
}};
STATIC
mp_obj_t
pyb_wdt_make_new
(
const
mp_obj_type_t
*
type
,
size_t
n_args
,
size_t
n_kw
,
const
mp_obj_t
*
args
)
{
// check arguments
mp_arg_check_num
(
n_args
,
n_kw
,
2
,
2
,
false
);
mp_int_t
id
=
mp_obj_get_int
(
args
[
0
]);
STATIC
mp_obj_t
pyb_wdt_make_new
(
const
mp_obj_type_t
*
type
,
size_t
n_args
,
size_t
n_kw
,
const
mp_obj_t
*
all_args
)
{
// parse arguments
enum
{
ARG_id
,
ARG_timeout
};
static
const
mp_arg_t
allowed_args
[]
=
{
{
MP_QSTR_id
,
MP_ARG_INT
,
{.
u_int
=
0
}
},
{
MP_QSTR_timeout
,
MP_ARG_INT
,
{.
u_int
=
5000
}
},
};
mp_arg_val_t
args
[
MP_ARRAY_SIZE
(
allowed_args
)];
mp_arg_parse_all_kw_array
(
n_args
,
n_kw
,
all_args
,
MP_ARRAY_SIZE
(
allowed_args
),
allowed_args
,
args
);
mp_int_t
id
=
args
[
ARG_id
].
u_int
;
if
(
id
!=
0
)
{
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_ValueError
,
"WDT(%d) does not exist"
,
id
));
}
// timeout is in milliseconds
mp_int_t
timeout
=
mp_obj_get_int
(
args
[
1
])
;
mp_int_t
timeout
=
args
[
ARG_timeout
].
u_int
;
// compute prescaler
uint32_t
prescaler
;
...
...
Write
Preview
Supports
Markdown
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