Skip to content

Commit 1950295

Browse files
author
danicampora
committed
cc3200: Set pin direction first, then value. Fixes adafruit#1542.
1 parent e0d7740 commit 1950295

3 files changed

Lines changed: 15 additions & 6 deletions

File tree

cc3200/mods/pybpin.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,16 +290,14 @@ STATIC void pin_obj_configure (const pin_obj_t *self) {
290290
default:
291291
break;
292292
}
293-
293+
// configure the direction
294+
MAP_GPIODirModeSet(self->port, self->bit, direction);
294295
// set the pin value
295296
if (self->value) {
296297
MAP_GPIOPinWrite(self->port, self->bit, self->bit);
297298
} else {
298299
MAP_GPIOPinWrite(self->port, self->bit, 0);
299300
}
300-
301-
// configure the direction
302-
MAP_GPIODirModeSet(self->port, self->bit, direction);
303301
}
304302
// now set the alternate function
305303
MAP_PinModeSet (self->pin_num, self->af);

tests/wipy/pin.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
""" This test need a set of pins which can be set as inputs and have no external
2-
pull up or pull down connected.
1+
"""
2+
This test need a set of pins which can be set as inputs and have no external
3+
pull up or pull down connected.
4+
GP12 and GP17 must be connected together
35
"""
46
from machine import Pin
57
import os
@@ -14,6 +16,13 @@
1416
else:
1517
raise Exception('Board not supported!')
1618

19+
# test initial value
20+
p = Pin('GP12', Pin.IN)
21+
Pin('GP17', Pin.OUT, value=1)
22+
print(p() == 1)
23+
Pin('GP17', Pin.OUT, value=0)
24+
print(p() == 0)
25+
1726
def test_noinit():
1827
for p in pin_map:
1928
pin = Pin(p)

tests/wipy/pin.py.exp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
True
2+
True
13
1
24
1
35
1

0 commit comments

Comments
 (0)