summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authordanicampora <daniel@wipy.io>2015-10-26 21:46:36 +0100
committerdanicampora <daniel@wipy.io>2015-10-26 23:26:43 +0100
commit19502957357aadf04015fd55272ae051d9fb0f23 (patch)
tree56f3a234fb4aa0f78a85965813d0e091a5f50ae9
parente0d7740a2294ed6bc7c6237f1a12413e0c5a9ce1 (diff)
downloadmicropython-19502957357aadf04015fd55272ae051d9fb0f23.tar.gz
micropython-19502957357aadf04015fd55272ae051d9fb0f23.zip
cc3200: Set pin direction first, then value. Fixes #1542.
-rw-r--r--cc3200/mods/pybpin.c6
-rw-r--r--tests/wipy/pin.py13
-rw-r--r--tests/wipy/pin.py.exp2
3 files changed, 15 insertions, 6 deletions
diff --git a/cc3200/mods/pybpin.c b/cc3200/mods/pybpin.c
index c1c0350548..4a2c313edb 100644
--- a/cc3200/mods/pybpin.c
+++ b/cc3200/mods/pybpin.c
@@ -290,16 +290,14 @@ STATIC void pin_obj_configure (const pin_obj_t *self) {
default:
break;
}
-
+ // configure the direction
+ MAP_GPIODirModeSet(self->port, self->bit, direction);
// set the pin value
if (self->value) {
MAP_GPIOPinWrite(self->port, self->bit, self->bit);
} else {
MAP_GPIOPinWrite(self->port, self->bit, 0);
}
-
- // configure the direction
- MAP_GPIODirModeSet(self->port, self->bit, direction);
}
// now set the alternate function
MAP_PinModeSet (self->pin_num, self->af);
diff --git a/tests/wipy/pin.py b/tests/wipy/pin.py
index 9f2eadb963..22c7c6176c 100644
--- a/tests/wipy/pin.py
+++ b/tests/wipy/pin.py
@@ -1,5 +1,7 @@
-""" This test need a set of pins which can be set as inputs and have no external
- pull up or pull down connected.
+"""
+This test need a set of pins which can be set as inputs and have no external
+pull up or pull down connected.
+GP12 and GP17 must be connected together
"""
from machine import Pin
import os
@@ -14,6 +16,13 @@ elif 'WiPy' in mch:
else:
raise Exception('Board not supported!')
+# test initial value
+p = Pin('GP12', Pin.IN)
+Pin('GP17', Pin.OUT, value=1)
+print(p() == 1)
+Pin('GP17', Pin.OUT, value=0)
+print(p() == 0)
+
def test_noinit():
for p in pin_map:
pin = Pin(p)
diff --git a/tests/wipy/pin.py.exp b/tests/wipy/pin.py.exp
index 7ca85ebdfc..0e3dddcf2b 100644
--- a/tests/wipy/pin.py.exp
+++ b/tests/wipy/pin.py.exp
@@ -1,3 +1,5 @@
+True
+True
1
1
1