aboutsummaryrefslogtreecommitdiff
path: root/shared-bindings/analogio
diff options
context:
space:
mode:
Diffstat (limited to 'shared-bindings/analogio')
-rw-r--r--shared-bindings/analogio/AnalogIn.c164
-rw-r--r--shared-bindings/analogio/AnalogIn.h40
-rw-r--r--shared-bindings/analogio/AnalogOut.c147
-rw-r--r--shared-bindings/analogio/AnalogOut.h39
-rw-r--r--shared-bindings/analogio/__init__.c84
-rw-r--r--shared-bindings/analogio/__init__.h34
6 files changed, 508 insertions, 0 deletions
diff --git a/shared-bindings/analogio/AnalogIn.c b/shared-bindings/analogio/AnalogIn.c
new file mode 100644
index 000000000..f07302250
--- /dev/null
+++ b/shared-bindings/analogio/AnalogIn.c
@@ -0,0 +1,164 @@
+/*
+ * This file is part of the Micro Python project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2013, 2014 Damien P. George
+ *
+ * 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.
+ */
+
+#include <string.h>
+
+#include "lib/utils/context_manager_helpers.h"
+#include "py/binary.h"
+#include "py/mphal.h"
+#include "py/nlr.h"
+#include "py/objproperty.h"
+#include "py/runtime.h"
+#include "shared-bindings/microcontroller/Pin.h"
+#include "shared-bindings/analogio/AnalogIn.h"
+
+//| .. currentmodule:: analogio
+//|
+//| :class:`AnalogIn` -- read analog voltage
+//| ============================================
+//|
+//| Usage::
+//|
+//| import analogio
+//| from board import *
+//|
+//| with analogio.AnalogIn(A1) as adc:
+//| val = adc.value
+//|
+
+//| .. class:: AnalogIn(pin)
+//|
+//| Use the AnalogIn on the given pin. The reference voltage varies by
+//| platform so use ``reference_voltage`` to read the configured setting.
+//|
+//| :param ~microcontroller.Pin pin: the pin to read from
+//|
+STATIC mp_obj_t analogio_analogin_make_new(const mp_obj_type_t *type,
+ mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
+ // check number of arguments
+ mp_arg_check_num(n_args, n_kw, 1, 1, false);
+
+ // 1st argument is the pin
+ mp_obj_t pin_obj = args[0];
+ assert_pin(pin_obj, false);
+
+ analogio_analogin_obj_t *self = m_new_obj(analogio_analogin_obj_t);
+ self->base.type = &analogio_analogin_type;
+ const mcu_pin_obj_t *pin = MP_OBJ_TO_PTR(pin_obj);
+ assert_pin_free(pin);
+ common_hal_analogio_analogin_construct(self, pin);
+
+ return (mp_obj_t) self;
+}
+
+//| .. method:: deinit()
+//|
+//| Turn off the AnalogIn and release the pin for other use.
+//|
+STATIC mp_obj_t analogio_analogin_deinit(mp_obj_t self_in) {
+ analogio_analogin_obj_t *self = MP_OBJ_TO_PTR(self_in);
+ common_hal_analogio_analogin_deinit(self);
+ return mp_const_none;
+}
+MP_DEFINE_CONST_FUN_OBJ_1(analogio_analogin_deinit_obj, analogio_analogin_deinit);
+
+//| .. method:: __enter__()
+//|
+//| No-op used by Context Managers.
+//|
+// Provided by context manager helper.
+
+//| .. method:: __exit__()
+//|
+//| Automatically deinitializes the hardware when exiting a context.
+//|
+STATIC mp_obj_t analogio_analogin___exit__(size_t n_args, const mp_obj_t *args) {
+ (void)n_args;
+ common_hal_analogio_analogin_deinit(args[0]);
+ return mp_const_none;
+}
+STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(analogio_analogin___exit___obj, 4, 4, analogio_analogin___exit__);
+
+//| .. attribute:: value
+//|
+//| Read the value on the analog pin and return it. The returned value
+//| will be between 0 and 65535 inclusive (16-bit). Even if the underlying
+//| analog to digital converter (ADC) is lower resolution, the result will
+//| be scaled to be 16-bit.
+//|
+//| :return: the data read
+//| :rtype: int
+//|
+STATIC mp_obj_t analogio_analogin_obj_get_value(mp_obj_t self_in) {
+ analogio_analogin_obj_t *self = MP_OBJ_TO_PTR(self_in);
+ return MP_OBJ_NEW_SMALL_INT(common_hal_analogio_analogin_get_value(self));
+}
+MP_DEFINE_CONST_FUN_OBJ_1(analogio_analogin_get_value_obj, analogio_analogin_obj_get_value);
+
+const mp_obj_property_t analogio_analogin_value_obj = {
+ .base.type = &mp_type_property,
+ .proxy = {(mp_obj_t)&analogio_analogin_get_value_obj,
+ (mp_obj_t)&mp_const_none_obj,
+ (mp_obj_t)&mp_const_none_obj},
+};
+
+//| .. attribute:: reference_voltage
+//|
+//| The maximum voltage measurable. Also known as the reference voltage.
+//|
+//| :return: the reference voltage
+//| :rtype: float
+//|
+STATIC mp_obj_t analogio_analogin_obj_get_reference_voltage(mp_obj_t self_in) {
+ analogio_analogin_obj_t *self = MP_OBJ_TO_PTR(self_in);
+ return mp_obj_new_float(common_hal_analogio_analogin_get_reference_voltage(self));
+}
+MP_DEFINE_CONST_FUN_OBJ_1(analogio_analogin_get_reference_voltage_obj,
+ analogio_analogin_obj_get_reference_voltage);
+
+const mp_obj_property_t analogio_analogin_reference_voltage_obj = {
+ .base.type = &mp_type_property,
+ .proxy = {(mp_obj_t)&analogio_analogin_get_reference_voltage_obj,
+ (mp_obj_t)&mp_const_none_obj,
+ (mp_obj_t)&mp_const_none_obj},
+};
+
+STATIC const mp_rom_map_elem_t analogio_analogin_locals_dict_table[] = {
+ { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&analogio_analogin_deinit_obj) },
+ { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) },
+ { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&analogio_analogin___exit___obj) },
+ { MP_OBJ_NEW_QSTR(MP_QSTR_value), MP_ROM_PTR(&analogio_analogin_value_obj)},
+ { MP_OBJ_NEW_QSTR(MP_QSTR_reference_voltage), MP_ROM_PTR(&analogio_analogin_reference_voltage_obj)},
+};
+
+STATIC MP_DEFINE_CONST_DICT(analogio_analogin_locals_dict, analogio_analogin_locals_dict_table);
+
+const mp_obj_type_t analogio_analogin_type = {
+ { &mp_type_type },
+ .name = MP_QSTR_AnalogIn,
+ .make_new = analogio_analogin_make_new,
+ .locals_dict = (mp_obj_t)&analogio_analogin_locals_dict,
+};
diff --git a/shared-bindings/analogio/AnalogIn.h b/shared-bindings/analogio/AnalogIn.h
new file mode 100644
index 000000000..64ddaab0f
--- /dev/null
+++ b/shared-bindings/analogio/AnalogIn.h
@@ -0,0 +1,40 @@
+/*
+ * This file is part of the Micro Python project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2013, 2014 Damien P. George
+ *
+ * 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_SHARED_BINDINGS_ANALOGIO_ANALOGIN_H__
+#define __MICROPY_INCLUDED_SHARED_BINDINGS_ANALOGIO_ANALOGIN_H__
+
+#include "common-hal/microcontroller/types.h"
+#include "common-hal/analogio/AnalogIn.h"
+
+extern const mp_obj_type_t analogio_analogin_type;
+
+void common_hal_analogio_analogin_construct(analogio_analogin_obj_t* self, const mcu_pin_obj_t *pin);
+void common_hal_analogio_analogin_deinit(analogio_analogin_obj_t* self);
+uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self);
+float common_hal_analogio_analogin_get_reference_voltage(analogio_analogin_obj_t *self);
+
+#endif // __MICROPY_INCLUDED_SHARED_BINDINGS_ANALOGIO_ANALOGIN_H__
diff --git a/shared-bindings/analogio/AnalogOut.c b/shared-bindings/analogio/AnalogOut.c
new file mode 100644
index 000000000..6b02f8c0a
--- /dev/null
+++ b/shared-bindings/analogio/AnalogOut.c
@@ -0,0 +1,147 @@
+/*
+ * This file is part of the Micro Python project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2013, 2014 Damien P. George
+ *
+ * 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.
+ */
+
+#include <stdint.h>
+#include <string.h>
+
+#include "lib/utils/context_manager_helpers.h"
+#include "py/objproperty.h"
+#include "py/runtime.h"
+#include "shared-bindings/microcontroller/Pin.h"
+#include "shared-bindings/analogio/AnalogOut.h"
+
+//| .. currentmodule:: analogio
+//|
+//| :class:`AnalogOut` -- output analog voltage
+//| ============================================
+//|
+//| The AnalogOut is used to output analog values (a specific voltage).
+//|
+//| Example usage::
+//|
+//| import analogio
+//| from microcontroller import pin
+//|
+//| with analogio.AnalogOut(pin.PA02) as dac: # output on pin PA02
+//| dac.value = 32768 # makes PA02 1.65V
+//|
+
+//| .. class:: AnalogOut(pin)
+//|
+//| Use the AnalogOut on the given pin.
+//|
+//| :param ~microcontroller.Pin pin: the pin to output to
+//|
+STATIC mp_obj_t analogio_analogout_make_new(const mp_obj_type_t *type, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
+ // check arguments
+ mp_arg_check_num(n_args, n_kw, 1, MP_OBJ_FUN_ARGS_MAX, true);
+
+ assert_pin(args[0], false);
+ const mcu_pin_obj_t *pin = MP_OBJ_TO_PTR(args[0]);
+
+ analogio_analogout_obj_t *self = m_new_obj(analogio_analogout_obj_t);
+ self->base.type = &analogio_analogout_type;
+ assert_pin_free(pin);
+ common_hal_analogio_analogout_construct(self, pin);
+
+ return self;
+}
+
+//| .. method:: deinit()
+//|
+//| Turn off the AnalogOut and release the pin for other use.
+//|
+STATIC mp_obj_t analogio_analogout_deinit(mp_obj_t self_in) {
+ analogio_analogout_obj_t *self = self_in;
+
+ common_hal_analogio_analogout_deinit(self);
+
+ return mp_const_none;
+}
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(analogio_analogout_deinit_obj, analogio_analogout_deinit);
+
+//| .. method:: __enter__()
+//|
+//| No-op used by Context Managers.
+//|
+// Provided by context manager helper.
+
+//| .. method:: __exit__()
+//|
+//| Automatically deinitializes the hardware when exiting a context.
+//|
+STATIC mp_obj_t analogio_analogout___exit__(size_t n_args, const mp_obj_t *args) {
+ (void)n_args;
+ common_hal_analogio_analogout_deinit(args[0]);
+ return mp_const_none;
+}
+STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(analogio_analogout___exit___obj, 4, 4, analogio_analogout___exit__);
+
+//| .. attribute:: value
+//|
+//| The value on the analog pin. The value must be between 0 and 65535
+//| inclusive (16-bit). Even if the underlying digital to analog converter
+//| is lower resolution, the input must be scaled to be 16-bit.
+//|
+//| :return: the last value written
+//| :rtype: int
+//|
+STATIC mp_obj_t analogio_analogout_obj_set_value(mp_obj_t self_in, mp_obj_t value) {
+ analogio_analogout_obj_t *self = MP_OBJ_TO_PTR(self_in);
+ uint32_t v = mp_obj_get_int(value);
+ if (v >= (1 << 16)) {
+ mp_raise_ValueError("AnalogOut is only 16 bits. Value must be less than 65536.");
+ }
+ common_hal_analogio_analogout_set_value(self, v);
+ return mp_const_none;
+}
+MP_DEFINE_CONST_FUN_OBJ_2(analogio_analogout_set_value_obj, analogio_analogout_obj_set_value);
+
+const mp_obj_property_t analogio_analogout_value_obj = {
+ .base.type = &mp_type_property,
+ .proxy = {(mp_obj_t)&mp_const_none_obj,
+ (mp_obj_t)&analogio_analogout_set_value_obj,
+ (mp_obj_t)&mp_const_none_obj},
+};
+
+STATIC const mp_rom_map_elem_t analogio_analogout_locals_dict_table[] = {
+ // instance methods
+ { MP_OBJ_NEW_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&analogio_analogout_deinit_obj) },
+ { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) },
+ { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&analogio_analogout___exit___obj) },
+
+ // Properties
+ { MP_OBJ_NEW_QSTR(MP_QSTR_value), (mp_obj_t)&analogio_analogout_value_obj },
+};
+
+STATIC MP_DEFINE_CONST_DICT(analogio_analogout_locals_dict, analogio_analogout_locals_dict_table);
+
+const mp_obj_type_t analogio_analogout_type = {
+ { &mp_type_type },
+ .name = MP_QSTR_AnalogOut,
+ .make_new = analogio_analogout_make_new,
+ .locals_dict = (mp_obj_t)&analogio_analogout_locals_dict,
+};
diff --git a/shared-bindings/analogio/AnalogOut.h b/shared-bindings/analogio/AnalogOut.h
new file mode 100644
index 000000000..3aa19ac29
--- /dev/null
+++ b/shared-bindings/analogio/AnalogOut.h
@@ -0,0 +1,39 @@
+/*
+ * This file is part of the Micro Python project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2013, 2014 Damien P. George
+ *
+ * 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_SHARED_BINDINGS_ANALOGIO_ANALOGOUT_H__
+#define __MICROPY_INCLUDED_SHARED_BINDINGS_ANALOGIO_ANALOGOUT_H__
+
+#include "common-hal/microcontroller/types.h"
+#include "common-hal/analogio/AnalogOut.h"
+
+extern const mp_obj_type_t analogio_analogout_type;
+
+void common_hal_analogio_analogout_construct(analogio_analogout_obj_t* self, const mcu_pin_obj_t *pin);
+void common_hal_analogio_analogout_deinit(analogio_analogout_obj_t *self);
+void common_hal_analogio_analogout_set_value(analogio_analogout_obj_t *self, uint16_t value);
+
+#endif // __MICROPY_INCLUDED_SHARED_BINDINGS_ANALOGIO_ANALOGOUT_H__
diff --git a/shared-bindings/analogio/__init__.c b/shared-bindings/analogio/__init__.c
new file mode 100644
index 000000000..39d6bdcda
--- /dev/null
+++ b/shared-bindings/analogio/__init__.c
@@ -0,0 +1,84 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2016 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.
+ */
+
+#include <stdint.h>
+
+#include "py/obj.h"
+#include "py/runtime.h"
+
+#include "shared-bindings/microcontroller/Pin.h"
+#include "shared-bindings/analogio/__init__.h"
+#include "shared-bindings/analogio/AnalogIn.h"
+#include "shared-bindings/analogio/AnalogOut.h"
+
+//| :mod:`analogio` --- Analog hardware support
+//| =================================================
+//|
+//| .. module:: analogio
+//| :synopsis: Analog hardware support
+//| :platform: SAMD21, ESP8266
+//|
+//| The `analogio` module contains classes to provide access to analog IO
+//| typically implemented with digital-to-analog (DAC) and analog-to-digital
+//| (ADC) converters.
+//|
+//| Libraries
+//|
+//| .. toctree::
+//| :maxdepth: 3
+//|
+//| AnalogIn
+//| AnalogOut
+//|
+//| All libraries change hardware state and should be deinitialized when they
+//| are no longer needed. To do so, either call :py:meth:`!deinit` or use a
+//| context manager.
+//|
+//| For example::
+//|
+//| import analogio
+//| from board import *
+//|
+//| with analogio.AnalogIn(A0) as pin:
+//| print(pin.value)
+//|
+//| This example will initialize the the device, read
+//| :py:data:`~analogio.AnalogIn.value` and then
+//| :py:meth:`~analogio.AnalogIn.deinit` the hardware.
+//|
+
+STATIC const mp_rom_map_elem_t analogio_module_globals_table[] = {
+ { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_analogio) },
+ { MP_ROM_QSTR(MP_QSTR_AnalogIn), MP_ROM_PTR(&analogio_analogin_type) },
+ { MP_ROM_QSTR(MP_QSTR_AnalogOut), MP_ROM_PTR(&analogio_analogout_type) },
+};
+
+STATIC MP_DEFINE_CONST_DICT(analogio_module_globals, analogio_module_globals_table);
+
+const mp_obj_module_t analogio_module = {
+ .base = { &mp_type_module },
+ .globals = (mp_obj_dict_t*)&analogio_module_globals,
+};
diff --git a/shared-bindings/analogio/__init__.h b/shared-bindings/analogio/__init__.h
new file mode 100644
index 000000000..9a0c77cb8
--- /dev/null
+++ b/shared-bindings/analogio/__init__.h
@@ -0,0 +1,34 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2016 Scott Shawcroft
+ *
+ * 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_SHARED_BINDINGS_ANALOGIO___INIT___H__
+#define __MICROPY_INCLUDED_SHARED_BINDINGS_ANALOGIO___INIT___H__
+
+#include "py/obj.h"
+
+// Nothing now.
+
+#endif // __MICROPY_INCLUDED_SHARED_BINDINGS_ANALOGIO___INIT___H__