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
0a6e9f56
Commit
0a6e9f56
authored
Apr 19, 2014
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
stmhal: Update ExtInt to allow keyword arguments in constructor.
parent
57e41585
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/extint.c
+19
-11
19 additions, 11 deletions
stmhal/extint.c
stmhal/qstrdefsport.h
+4
-0
4 additions, 0 deletions
stmhal/qstrdefsport.h
stmhal/spi.c
+0
-1
0 additions, 1 deletion
stmhal/spi.c
with
23 additions
and
12 deletions
stmhal/extint.c
+
19
−
11
View file @
0a6e9f56
...
...
@@ -28,7 +28,7 @@
// print("line =", line)
//
// # Note: ExtInt will automatically configure the gpio line as an input.
// extint = pyb.ExtInt(pin, pyb.ExtInt.
MODE_
IRQ_FALLING, pyb.GPIO.PULL_UP, callback)
// extint = pyb.ExtInt(pin, pyb.ExtInt.IRQ_FALLING, pyb.GPIO.PULL_UP, callback)
//
// Now every time a falling edge is seen on the X1 pin, the callback will be
// called. Caution: mechanical pushbuttons have "bounce" and pushing or
...
...
@@ -46,11 +46,11 @@
//
// extint = pyb.ExtInt(pin, mode, pull, callback)
//
// Valid modes are pyb.ExtInt.
MODE_
IRQ_RISING, pyb.ExtInt.
MODE_
IRQ_FALLING,
// pyb.ExtInt.
MODE_
IRQ_RISING_FALLING, pyb.ExtInt.
MODE_
EVT_RISING,
// pyb.ExtInt.
MODE_
EVT_FALLING, and pyb.ExtInt.
MODE_
EVT_RISING_FALLING.
// Valid modes are pyb.ExtInt.IRQ_RISING, pyb.ExtInt.IRQ_FALLING,
// pyb.ExtInt.IRQ_RISING_FALLING, pyb.ExtInt.EVT_RISING,
// pyb.ExtInt.EVT_FALLING, and pyb.ExtInt.EVT_RISING_FALLING.
//
// Only the
MODE_
IRQ_xxx modes have been tested. The
MODE_
EVT_xxx modes have
// Only the IRQ_xxx modes have been tested. The EVT_xxx modes have
// something to do with sleep mode and the WFE instruction.
//
// Valid pull values are pyb.GPIO.PULL_UP, pyb.GPIO.PULL_DOWN, pyb.GPIO.PULL_NONE.
...
...
@@ -241,18 +241,26 @@ STATIC mp_obj_t extint_regs(void) {
// line_obj = pyb.ExtInt(pin, mode, trigger, callback)
STATIC
const
mp_arg_parse_t
pyb_extint_make_new_accepted_args
[]
=
{
{
MP_QSTR_pin
,
MP_ARG_PARSE_REQUIRED
|
MP_ARG_PARSE_OBJ
,
{.
u_obj
=
MP_OBJ_NULL
}
},
{
MP_QSTR_mode
,
MP_ARG_PARSE_REQUIRED
|
MP_ARG_PARSE_OBJ
,
{.
u_obj
=
MP_OBJ_NULL
}
},
{
MP_QSTR_trigger
,
MP_ARG_PARSE_REQUIRED
|
MP_ARG_PARSE_OBJ
,
{.
u_obj
=
MP_OBJ_NULL
}
},
{
MP_QSTR_callback
,
MP_ARG_PARSE_REQUIRED
|
MP_ARG_PARSE_OBJ
,
{.
u_obj
=
MP_OBJ_NULL
}
},
};
#define PYB_EXTINT_MAKE_NEW_NUM_ARGS (sizeof(pyb_extint_make_new_accepted_args) / sizeof(pyb_extint_make_new_accepted_args[0]))
STATIC
mp_obj_t
extint_make_new
(
mp_obj_t
type_in
,
uint
n_args
,
uint
n_kw
,
const
mp_obj_t
*
args
)
{
// type_in == extint_obj_type
mp_arg_check_num
(
n_args
,
n_kw
,
4
,
4
,
false
);
// parse args
mp_map_t
kw_args
;
mp_map_init_fixed_table
(
&
kw_args
,
n_kw
,
args
+
n_args
);
mp_arg_parse_val_t
vals
[
PYB_EXTINT_MAKE_NEW_NUM_ARGS
];
mp_arg_parse_all
(
n_args
,
args
,
&
kw_args
,
PYB_EXTINT_MAKE_NEW_NUM_ARGS
,
pyb_extint_make_new_accepted_args
,
vals
);
extint_obj_t
*
self
=
m_new_obj
(
extint_obj_t
);
self
->
base
.
type
=
type_in
;
mp_obj_t
line_obj
=
args
[
0
];
mp_obj_t
mode_obj
=
args
[
1
];
mp_obj_t
trigger_obj
=
args
[
2
];
mp_obj_t
callback_obj
=
args
[
3
];
self
->
line
=
extint_register
(
line_obj
,
mode_obj
,
trigger_obj
,
callback_obj
,
false
,
NULL
);
self
->
line
=
extint_register
(
vals
[
0
].
u_obj
,
vals
[
1
].
u_obj
,
vals
[
2
].
u_obj
,
vals
[
3
].
u_obj
,
false
,
NULL
);
return
self
;
}
...
...
This diff is collapsed.
Click to expand it.
stmhal/qstrdefsport.h
+
4
−
0
View file @
0a6e9f56
...
...
@@ -88,6 +88,10 @@ Q(send)
// for ExtInt class
Q
(
ExtInt
)
Q
(
pin
)
Q
(
mode
)
Q
(
trigger
)
Q
(
callback
)
Q
(
line
)
Q
(
enable
)
Q
(
disable
)
...
...
This diff is collapsed.
Click to expand it.
stmhal/spi.c
+
0
−
1
View file @
0a6e9f56
...
...
@@ -160,7 +160,6 @@ STATIC const mp_arg_parse_t pyb_spi_init_accepted_args[] = {
{
MP_QSTR_ti
,
MP_ARG_PARSE_KW_ONLY
|
MP_ARG_PARSE_BOOL
,
{.
u_bool
=
false
}
},
{
MP_QSTR_crcpoly
,
MP_ARG_PARSE_KW_ONLY
|
MP_ARG_PARSE_OBJ
,
{.
u_obj
=
mp_const_none
}
},
};
#define PYB_SPI_INIT_NUM_ARGS (sizeof(pyb_spi_init_accepted_args) / sizeof(pyb_spi_init_accepted_args[0]))
STATIC
mp_obj_t
pyb_spi_init_helper
(
const
pyb_spi_obj_t
*
self
,
uint
n_args
,
const
mp_obj_t
*
args
,
mp_map_t
*
kw_args
)
{
...
...
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