aboutsummaryrefslogtreecommitdiff
path: root/extmod/virtpin.h
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2017-04-11 00:12:20 +0300
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2017-04-11 00:12:20 +0300
commit605ff91efdeb3cd7e4948c0398c839a9ae06044a (patch)
tree1772f83cc46dff962ad5d3be7e1777db2e5c8e0f /extmod/virtpin.h
parent79ce6649524b08732e15d86c4ff61266c3ec14ed (diff)
extmod/machine_signal: Support all Pin's arguments to the constructor.
This implements the orginal idea is that Signal is a subclass of Pin, and thus can accept all the same argument as Pin, and additionally, "inverted" param. On the practical side, it allows to avoid many enclosed parenses for a typical declararion, e.g. for Zephyr: Signal(Pin(("GPIO_0", 1))). Of course, passing a Pin to Signal constructor is still supported and is the most generic form (e.g. Unix port will only support such form, as it doesn't have "builtin" Pins), what's introduces here is just practical readability optimization. "value" kwarg is treated as applying to a Signal (i.e. accounts for possible inversion).
Diffstat (limited to 'extmod/virtpin.h')
-rw-r--r--extmod/virtpin.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/extmod/virtpin.h b/extmod/virtpin.h
index 3821f9dec..041010350 100644
--- a/extmod/virtpin.h
+++ b/extmod/virtpin.h
@@ -38,3 +38,6 @@ typedef struct _mp_pin_p_t {
int mp_virtual_pin_read(mp_obj_t pin);
void mp_virtual_pin_write(mp_obj_t pin, int value);
+
+// If a port exposes a Pin object, it's constructor should be like this
+mp_obj_t mp_pin_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args);