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
GitLab 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
18b6835a
Commit
18b6835a
authored
8 years ago
by
Paul Sokolovsky
Browse files
Options
Downloads
Patches
Plain Diff
esp8266/machine_pin: Implement pin ioctl protocol.
For polymorphic interfacing on C level.
parent
0ddeedfc
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
esp8266/machine_pin.c
+23
-0
23 additions, 0 deletions
esp8266/machine_pin.c
with
23 additions
and
0 deletions
esp8266/machine_pin.c
+
23
−
0
View file @
18b6835a
...
...
@@ -37,6 +37,7 @@
#include
"py/runtime.h"
#include
"py/gc.h"
#include
"py/mphal.h"
#include
"extmod/virtpin.h"
#include
"modmachine.h"
#define GET_TRIGGER(phys_port) \
...
...
@@ -374,6 +375,23 @@ STATIC mp_obj_t pyb_pin_irq(size_t n_args, const mp_obj_t *pos_args, mp_map_t *k
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_KW
(
pyb_pin_irq_obj
,
1
,
pyb_pin_irq
);
STATIC
mp_uint_t
pin_ioctl
(
mp_obj_t
self_in
,
mp_uint_t
request
,
uintptr_t
arg
,
int
*
errcode
);
STATIC
mp_uint_t
pin_ioctl
(
mp_obj_t
self_in
,
mp_uint_t
request
,
uintptr_t
arg
,
int
*
errcode
)
{
(
void
)
errcode
;
pyb_pin_obj_t
*
self
=
self_in
;
switch
(
request
)
{
case
MP_PIN_READ
:
{
return
pin_get
(
self
->
phys_port
);
}
case
MP_PIN_WRITE
:
{
pin_set
(
self
->
phys_port
,
arg
);
return
0
;
}
}
return
-
1
;
}
STATIC
const
mp_map_elem_t
pyb_pin_locals_dict_table
[]
=
{
// instance methods
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_init
),
(
mp_obj_t
)
&
pyb_pin_init_obj
},
...
...
@@ -396,12 +414,17 @@ STATIC const mp_map_elem_t pyb_pin_locals_dict_table[] = {
STATIC
MP_DEFINE_CONST_DICT
(
pyb_pin_locals_dict
,
pyb_pin_locals_dict_table
);
STATIC
const
mp_pin_p_t
pin_pin_p
=
{
.
ioctl
=
pin_ioctl
,
};
const
mp_obj_type_t
pyb_pin_type
=
{
{
&
mp_type_type
},
.
name
=
MP_QSTR_Pin
,
.
print
=
pyb_pin_print
,
.
make_new
=
pyb_pin_make_new
,
.
call
=
pyb_pin_call
,
.
protocol
=
&
pin_pin_p
,
.
locals_dict
=
(
mp_obj_t
)
&
pyb_pin_locals_dict
,
};
...
...
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