summaryrefslogtreecommitdiff
path: root/esp8266
diff options
context:
space:
mode:
authorScott Shawcroft <scott.shawcroft@gmail.com>2017-03-25 12:04:49 +0000
committerScott Shawcroft <scott.shawcroft@gmail.com>2017-03-25 12:04:49 +0000
commitff208d767741104f7d2644a58269d7064d4c1b6a (patch)
tree1e8eaad503f41a31f59bd07753e781f4f74a7d6e /esp8266
parent7cb54864aa7c651fc65350708afcddfab2a15fcc (diff)
Add low-level OneWire support class.
This class focuses on the timing sensitive parts of the protocol. Everything else will be done by Python code. This also establishes that its OK to back a nativeio class with a bitbang implementation when no hardware acceleration exists. When it does, then bitbangio should be used to explicitly bitbang a protocol.
Diffstat (limited to 'esp8266')
-rw-r--r--esp8266/Makefile2
-rw-r--r--esp8266/common-hal/nativeio/DigitalInOut.h39
-rw-r--r--esp8266/common-hal/nativeio/types.h11
3 files changed, 45 insertions, 7 deletions
diff --git a/esp8266/Makefile b/esp8266/Makefile
index ec2475439..d7c8cef18 100644
--- a/esp8266/Makefile
+++ b/esp8266/Makefile
@@ -130,7 +130,9 @@ SRC_COMMON_HAL_EXPANDED = $(addprefix shared-bindings/, $(SRC_COMMON_HAL)) \
SRC_SHARED_MODULE = \
bitbangio/__init__.c \
bitbangio/I2C.c \
+ bitbangio/OneWire.c \
bitbangio/SPI.c \
+ nativeio/OneWire.c \
SRC_SHARED_MODULE_EXPANDED = $(addprefix shared-bindings/, $(SRC_SHARED_MODULE)) \
$(addprefix shared-module/, $(SRC_SHARED_MODULE))
diff --git a/esp8266/common-hal/nativeio/DigitalInOut.h b/esp8266/common-hal/nativeio/DigitalInOut.h
new file mode 100644
index 000000000..6325b978b
--- /dev/null
+++ b/esp8266/common-hal/nativeio/DigitalInOut.h
@@ -0,0 +1,39 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef __MICROPY_INCLUDED_ESP8266_COMMON_HAL_NATIVEIO_DIGITALINOUT_H__
+#define __MICROPY_INCLUDED_ESP8266_COMMON_HAL_NATIVEIO_DIGITALINOUT_H__
+
+#include "py/obj.h"
+
+typedef struct {
+ mp_obj_base_t base;
+ const mcu_pin_obj_t * pin;
+ bool output;
+ bool open_drain;
+} nativeio_digitalinout_obj_t;
+
+#endif // __MICROPY_INCLUDED_ESP8266_COMMON_HAL_NATIVEIO_DIGITALINOUT_H__
diff --git a/esp8266/common-hal/nativeio/types.h b/esp8266/common-hal/nativeio/types.h
index bc8a3bdc1..0a45712e4 100644
--- a/esp8266/common-hal/nativeio/types.h
+++ b/esp8266/common-hal/nativeio/types.h
@@ -34,6 +34,10 @@
#include "py/obj.h"
+// Use the bitbang wrapper for OneWire
+// TODO(tannewt): Wrap bitbangio for I2C too.
+#include "shared-module/nativeio/OneWire.h"
+
typedef struct {
mp_obj_base_t base;
const mcu_pin_obj_t * pin;
@@ -44,13 +48,6 @@ typedef struct {
mp_obj_base_t base;
} nativeio_analogout_obj_t;
-typedef struct {
- mp_obj_base_t base;
- const mcu_pin_obj_t * pin;
- bool output;
- bool open_drain;
-} nativeio_digitalinout_obj_t;
-
// Not supported, throws error on construction.
typedef struct {
mp_obj_base_t base;