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
68e222af
Commit
68e222af
authored
9 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
esp8266: Add mp_hal_pin_input() and mp_hal_pin_output() functions.
parent
20aa9c85
Branches
gohu
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
esp8266/esp_mphal.h
+2
-0
2 additions, 0 deletions
esp8266/esp_mphal.h
esp8266/modpybpin.c
+29
-0
29 additions, 0 deletions
esp8266/modpybpin.c
with
31 additions
and
0 deletions
esp8266/esp_mphal.h
+
2
−
0
View file @
68e222af
...
@@ -68,6 +68,8 @@ void ets_event_poll(void);
...
@@ -68,6 +68,8 @@ void ets_event_poll(void);
#include
"esp8266/modpyb.h"
#include
"esp8266/modpyb.h"
#define mp_hal_pin_obj_t uint32_t
#define mp_hal_pin_obj_t uint32_t
#define mp_hal_get_pin_obj(o) mp_obj_get_pin(o)
#define mp_hal_get_pin_obj(o) mp_obj_get_pin(o)
void
mp_hal_pin_input
(
mp_hal_pin_obj_t
pin
);
void
mp_hal_pin_output
(
mp_hal_pin_obj_t
pin
);
void
mp_hal_pin_config_od
(
mp_hal_pin_obj_t
pin
);
void
mp_hal_pin_config_od
(
mp_hal_pin_obj_t
pin
);
#define mp_hal_pin_low(p) do { \
#define mp_hal_pin_low(p) do { \
if ((p) == 16) { WRITE_PERI_REG(RTC_GPIO_ENABLE, (READ_PERI_REG(RTC_GPIO_ENABLE) & ~1) | 1); } \
if ((p) == 16) { WRITE_PERI_REG(RTC_GPIO_ENABLE, (READ_PERI_REG(RTC_GPIO_ENABLE) & ~1) | 1); } \
...
...
This diff is collapsed.
Click to expand it.
esp8266/modpybpin.c
+
29
−
0
View file @
68e222af
...
@@ -36,6 +36,7 @@
...
@@ -36,6 +36,7 @@
#include
"py/nlr.h"
#include
"py/nlr.h"
#include
"py/runtime.h"
#include
"py/runtime.h"
#include
"py/gc.h"
#include
"py/gc.h"
#include
"py/mphal.h"
#include
"modpyb.h"
#include
"modpyb.h"
#define GET_TRIGGER(phys_port) \
#define GET_TRIGGER(phys_port) \
...
@@ -123,6 +124,34 @@ uint mp_obj_get_pin(mp_obj_t pin_in) {
...
@@ -123,6 +124,34 @@ uint mp_obj_get_pin(mp_obj_t pin_in) {
return
mp_obj_get_pin_obj
(
pin_in
)
->
phys_port
;
return
mp_obj_get_pin_obj
(
pin_in
)
->
phys_port
;
}
}
void
mp_hal_pin_input
(
mp_hal_pin_obj_t
pin_id
)
{
pin_mode
[
pin_id
]
=
GPIO_MODE_INPUT
;
if
(
pin_id
==
16
)
{
WRITE_PERI_REG
(
PAD_XPD_DCDC_CONF
,
(
READ_PERI_REG
(
PAD_XPD_DCDC_CONF
)
&
0xffffffbc
)
|
1
);
WRITE_PERI_REG
(
RTC_GPIO_CONF
,
READ_PERI_REG
(
RTC_GPIO_CONF
)
&
~
1
);
WRITE_PERI_REG
(
RTC_GPIO_ENABLE
,
(
READ_PERI_REG
(
RTC_GPIO_ENABLE
)
&
~
1
));
// input
}
else
{
const
pyb_pin_obj_t
*
self
=
&
pyb_pin_obj
[
pin_id
];
PIN_FUNC_SELECT
(
self
->
periph
,
self
->
func
);
PIN_PULLUP_DIS
(
self
->
periph
);
gpio_output_set
(
0
,
0
,
0
,
1
<<
self
->
phys_port
);
}
}
void
mp_hal_pin_output
(
mp_hal_pin_obj_t
pin_id
)
{
pin_mode
[
pin_id
]
=
GPIO_MODE_OUTPUT
;
if
(
pin_id
==
16
)
{
WRITE_PERI_REG
(
PAD_XPD_DCDC_CONF
,
(
READ_PERI_REG
(
PAD_XPD_DCDC_CONF
)
&
0xffffffbc
)
|
1
);
WRITE_PERI_REG
(
RTC_GPIO_CONF
,
READ_PERI_REG
(
RTC_GPIO_CONF
)
&
~
1
);
WRITE_PERI_REG
(
RTC_GPIO_ENABLE
,
(
READ_PERI_REG
(
RTC_GPIO_ENABLE
)
&
~
1
)
|
1
);
// output
}
else
{
const
pyb_pin_obj_t
*
self
=
&
pyb_pin_obj
[
pin_id
];
PIN_FUNC_SELECT
(
self
->
periph
,
self
->
func
);
PIN_PULLUP_DIS
(
self
->
periph
);
gpio_output_set
(
0
,
0
,
1
<<
self
->
phys_port
,
0
);
}
}
int
pin_get
(
uint
pin
)
{
int
pin_get
(
uint
pin
)
{
if
(
pin
==
16
)
{
if
(
pin
==
16
)
{
return
READ_PERI_REG
(
RTC_GPIO_IN_DATA
)
&
1
;
return
READ_PERI_REG
(
RTC_GPIO_IN_DATA
)
&
1
;
...
...
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