diff options
author | Daniel Thompson <daniel.thompson@linaro.org> | 2016-09-28 14:22:42 -0700 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2016-10-27 00:47:26 +0300 |
commit | 67b6d9d499bee6283ae1005d0c829b8f552ac5af (patch) | |
tree | f8d64563e1f26b6ad4279fc7fce860a57af20802 /zephyr/mpconfigport.h | |
parent | a3519332b65837987d33cdae1a8fa8a509b9ad4e (diff) | |
download | micropython-67b6d9d499bee6283ae1005d0c829b8f552ac5af.tar.gz micropython-67b6d9d499bee6283ae1005d0c829b8f552ac5af.zip |
zephyr: Initial implementation of machine.Pin.
The integration with Zephyr is fairly clean but as MicroPython Hardware API
requires pin ID to be a single value, but Zephyr operates GPIO in terms of
ports and pins, not just pins, a "hierarchical" ID is required, using tuple
of (port, pin). Port is a string, effectively a device name of a GPIO port,
per Zephyr conventions these are "GPIO_0", "GPIO_1", etc.; pin is integer
number of pin with the port (supposed to be in range 0-31).
Example of pin initialization:
pin = Pin(("GPIO_1", 21), Pin.OUT)
(an LED on FRDM-K64F's Port B, Pin 21).
There is support for in/out pins and pull up/pull down but currently
there is no interrupt support.
Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
Diffstat (limited to 'zephyr/mpconfigport.h')
-rw-r--r-- | zephyr/mpconfigport.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/zephyr/mpconfigport.h b/zephyr/mpconfigport.h index 2f12cf7112..0a3905c3c5 100644 --- a/zephyr/mpconfigport.h +++ b/zephyr/mpconfigport.h @@ -53,6 +53,7 @@ #define MICROPY_PY_CMATH (0) #define MICROPY_PY_IO (0) #define MICROPY_PY_MICROPYTHON_MEM_INFO (1) +#define MICROPY_PY_MACHINE (1) #define MICROPY_PY_STRUCT (0) #define MICROPY_PY_UTIME (1) #define MICROPY_PY_UTIME_MP_HAL (1) @@ -90,6 +91,7 @@ typedef long mp_off_t; mp_obj_t mp_kbd_exception; \ const char *readline_hist[8]; +extern const struct _mp_obj_module_t mp_module_machine; extern const struct _mp_obj_module_t mp_module_time; #if MICROPY_PY_UTIME @@ -99,6 +101,7 @@ extern const struct _mp_obj_module_t mp_module_time; #endif #define MICROPY_PORT_BUILTIN_MODULES \ + { MP_OBJ_NEW_QSTR(MP_QSTR_machine), (mp_obj_t)&mp_module_machine }, \ MICROPY_PY_UTIME_DEF \ // extra built in names to add to the global namespace |