cc3200: Set pin direction first, then value. Fixes #1542.

This commit is contained in:
danicampora 2015-10-26 21:46:36 +01:00
parent e0d7740a22
commit 1950295735
3 changed files with 15 additions and 6 deletions

View File

@ -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);

View File

@ -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)

View File

@ -1,3 +1,5 @@
True
True
1
1
1