summaryrefslogtreecommitdiff
path: root/zephyr/modmachine.h
diff options
context:
space:
mode:
authorDaniel Thompson <daniel.thompson@linaro.org>2016-09-28 14:22:42 -0700
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2016-10-27 00:47:26 +0300
commit67b6d9d499bee6283ae1005d0c829b8f552ac5af (patch)
treef8d64563e1f26b6ad4279fc7fce860a57af20802 /zephyr/modmachine.h
parenta3519332b65837987d33cdae1a8fa8a509b9ad4e (diff)
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/modmachine.h')
-rw-r--r--zephyr/modmachine.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/zephyr/modmachine.h b/zephyr/modmachine.h
new file mode 100644
index 000000000..596c59b17
--- /dev/null
+++ b/zephyr/modmachine.h
@@ -0,0 +1,16 @@
+#ifndef __MICROPY_INCLUDED_ZEPHYR_MODMACHINE_H__
+#define __MICROPY_INCLUDED_ZEPHYR_MODMACHINE_H__
+
+#include "py/obj.h"
+
+extern const mp_obj_type_t machine_pin_type;
+
+MP_DECLARE_CONST_FUN_OBJ_0(machine_info_obj);
+
+typedef struct _machine_pin_obj_t {
+ mp_obj_base_t base;
+ struct device *port;
+ uint32_t pin;
+} machine_pin_obj_t;
+
+#endif // __MICROPY_INCLUDED_ZEPHYR_MODMACHINE_H__