aboutsummaryrefslogtreecommitdiff
path: root/py/mphal.h
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2016-05-27 00:57:18 +0300
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2016-05-27 01:08:43 +0300
commit751e3b7a820c13561cca47717d47d7784f776232 (patch)
treeef29b10707011f48906fa7fed4c480ccc81108ff /py/mphal.h
parent74e6c0337de9570f85da88a2443e7c20a6d2e7ff (diff)
extmod/virtpin: Initial implementation of open-ended C-level Pin interface.
Using usual method of virtual method tables. Single virtual method, ioctl, is defined currently for all operations. This universal and extensible vtable-based method is also defined as a default MPHAL GPIO implementation, but a specific port may override it with its own implementation (e.g. close-ended, but very efficient, e.g. avoiding virtual method dispatch).
Diffstat (limited to 'py/mphal.h')
-rw-r--r--py/mphal.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/py/mphal.h b/py/mphal.h
index 6215ab065..aacd02ebd 100644
--- a/py/mphal.h
+++ b/py/mphal.h
@@ -66,4 +66,13 @@ mp_uint_t mp_hal_ticks_ms(void);
mp_uint_t mp_hal_ticks_us(void);
#endif
+// If port HAL didn't define its own pin API, use generic
+// "virtual pin" API from the core.
+#ifndef mp_hal_pin_obj_t
+#define mp_hal_pin_obj_t mp_obj_t
+#define mp_hal_get_pin_obj(pin) (pin)
+#define mp_hal_pin_read(pin) mp_virtual_pin_read(pin)
+#define mp_hal_pin_write(pin, v) mp_virtual_pin_write(pin, v)
+#endif
+
#endif // __MICROPY_INCLUDED_PY_MPHAL_H__