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
2507c83b
Commit
2507c83b
authored
8 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
esp8266/machine_pin: Add "hard" parameter to pin.irq, soft by default.
parent
31ea1585
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
esp8266/machine_pin.c
+12
-2
12 additions, 2 deletions
esp8266/machine_pin.c
with
12 additions
and
2 deletions
esp8266/machine_pin.c
+
12
−
2
View file @
2507c83b
...
@@ -87,11 +87,15 @@ STATIC uint8_t pin_mode[16 + 1];
...
@@ -87,11 +87,15 @@ STATIC uint8_t pin_mode[16 + 1];
// forward declaration
// forward declaration
STATIC
const
pin_irq_obj_t
pin_irq_obj
[
16
];
STATIC
const
pin_irq_obj_t
pin_irq_obj
[
16
];
// whether the irq is hard or soft
STATIC
bool
pin_irq_is_hard
[
16
];
void
pin_init0
(
void
)
{
void
pin_init0
(
void
)
{
ETS_GPIO_INTR_DISABLE
();
ETS_GPIO_INTR_DISABLE
();
ETS_GPIO_INTR_ATTACH
(
pin_intr_handler_iram
,
NULL
);
ETS_GPIO_INTR_ATTACH
(
pin_intr_handler_iram
,
NULL
);
// disable all interrupts
// disable all interrupts
memset
(
&
MP_STATE_PORT
(
pin_irq_handler
)[
0
],
0
,
16
*
sizeof
(
mp_obj_t
));
memset
(
&
MP_STATE_PORT
(
pin_irq_handler
)[
0
],
0
,
16
*
sizeof
(
mp_obj_t
));
memset
(
pin_irq_is_hard
,
0
,
sizeof
(
pin_irq_obj
));
for
(
int
p
=
0
;
p
<
16
;
++
p
)
{
for
(
int
p
=
0
;
p
<
16
;
++
p
)
{
GPIO_REG_WRITE
(
GPIO_STATUS_W1TC_ADDRESS
,
1
<<
p
);
GPIO_REG_WRITE
(
GPIO_STATUS_W1TC_ADDRESS
,
1
<<
p
);
SET_TRIGGER
(
p
,
0
);
SET_TRIGGER
(
p
,
0
);
...
@@ -107,7 +111,11 @@ void pin_intr_handler(uint32_t status) {
...
@@ -107,7 +111,11 @@ void pin_intr_handler(uint32_t status) {
if
(
status
&
1
)
{
if
(
status
&
1
)
{
mp_obj_t
handler
=
MP_STATE_PORT
(
pin_irq_handler
)[
p
];
mp_obj_t
handler
=
MP_STATE_PORT
(
pin_irq_handler
)[
p
];
if
(
handler
!=
MP_OBJ_NULL
)
{
if
(
handler
!=
MP_OBJ_NULL
)
{
if
(
pin_irq_is_hard
[
p
])
{
mp_call_function_1_protected
(
handler
,
MP_OBJ_FROM_PTR
(
&
pyb_pin_obj
[
p
]));
mp_call_function_1_protected
(
handler
,
MP_OBJ_FROM_PTR
(
&
pyb_pin_obj
[
p
]));
}
else
{
mp_sched_schedule
(
handler
,
MP_OBJ_FROM_PTR
(
&
pyb_pin_obj
[
p
]));
}
}
}
}
}
}
}
...
@@ -346,10 +354,11 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_pin_high_obj, pyb_pin_high);
...
@@ -346,10 +354,11 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_pin_high_obj, pyb_pin_high);
// pin.irq(*, trigger, handler=None)
// pin.irq(*, trigger, handler=None)
STATIC
mp_obj_t
pyb_pin_irq
(
size_t
n_args
,
const
mp_obj_t
*
pos_args
,
mp_map_t
*
kw_args
)
{
STATIC
mp_obj_t
pyb_pin_irq
(
size_t
n_args
,
const
mp_obj_t
*
pos_args
,
mp_map_t
*
kw_args
)
{
enum
{
ARG_trigger
,
ARG_handler
};
enum
{
ARG_trigger
,
ARG_handler
,
ARG_hard
};
static
const
mp_arg_t
allowed_args
[]
=
{
static
const
mp_arg_t
allowed_args
[]
=
{
{
MP_QSTR_trigger
,
MP_ARG_KW_ONLY
|
MP_ARG_INT
,
{.
u_int
=
0
}
},
{
MP_QSTR_trigger
,
MP_ARG_KW_ONLY
|
MP_ARG_INT
,
{.
u_int
=
0
}
},
{
MP_QSTR_handler
,
MP_ARG_KW_ONLY
|
MP_ARG_OBJ
,
{.
u_obj
=
mp_const_none
}
},
{
MP_QSTR_handler
,
MP_ARG_KW_ONLY
|
MP_ARG_OBJ
,
{.
u_obj
=
mp_const_none
}
},
{
MP_QSTR_hard
,
MP_ARG_KW_ONLY
|
MP_ARG_BOOL
,
{.
u_bool
=
false
}
},
};
};
pyb_pin_obj_t
*
self
=
MP_OBJ_TO_PTR
(
pos_args
[
0
]);
pyb_pin_obj_t
*
self
=
MP_OBJ_TO_PTR
(
pos_args
[
0
]);
mp_arg_val_t
args
[
MP_ARRAY_SIZE
(
allowed_args
)];
mp_arg_val_t
args
[
MP_ARRAY_SIZE
(
allowed_args
)];
...
@@ -367,6 +376,7 @@ STATIC mp_obj_t pyb_pin_irq(size_t n_args, const mp_obj_t *pos_args, mp_map_t *k
...
@@ -367,6 +376,7 @@ STATIC mp_obj_t pyb_pin_irq(size_t n_args, const mp_obj_t *pos_args, mp_map_t *k
}
}
ETS_GPIO_INTR_DISABLE
();
ETS_GPIO_INTR_DISABLE
();
MP_STATE_PORT
(
pin_irq_handler
)[
self
->
phys_port
]
=
handler
;
MP_STATE_PORT
(
pin_irq_handler
)[
self
->
phys_port
]
=
handler
;
pin_irq_is_hard
[
self
->
phys_port
]
=
args
[
ARG_hard
].
u_bool
;
SET_TRIGGER
(
self
->
phys_port
,
args
[
ARG_trigger
].
u_int
);
SET_TRIGGER
(
self
->
phys_port
,
args
[
ARG_trigger
].
u_int
);
GPIO_REG_WRITE
(
GPIO_STATUS_W1TC_ADDRESS
,
1
<<
self
->
phys_port
);
GPIO_REG_WRITE
(
GPIO_STATUS_W1TC_ADDRESS
,
1
<<
self
->
phys_port
);
ETS_GPIO_INTR_ENABLE
();
ETS_GPIO_INTR_ENABLE
();
...
...
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