Skip to content
Snippets Groups Projects
Commit 19502957 authored by danicampora's avatar danicampora
Browse files

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

parent e0d7740a
No related branches found
No related tags found
No related merge requests found
...@@ -290,16 +290,14 @@ STATIC void pin_obj_configure (const pin_obj_t *self) { ...@@ -290,16 +290,14 @@ STATIC void pin_obj_configure (const pin_obj_t *self) {
default: default:
break; break;
} }
// configure the direction
MAP_GPIODirModeSet(self->port, self->bit, direction);
// set the pin value // set the pin value
if (self->value) { if (self->value) {
MAP_GPIOPinWrite(self->port, self->bit, self->bit); MAP_GPIOPinWrite(self->port, self->bit, self->bit);
} else { } else {
MAP_GPIOPinWrite(self->port, self->bit, 0); MAP_GPIOPinWrite(self->port, self->bit, 0);
} }
// configure the direction
MAP_GPIODirModeSet(self->port, self->bit, direction);
} }
// now set the alternate function // now set the alternate function
MAP_PinModeSet (self->pin_num, self->af); MAP_PinModeSet (self->pin_num, self->af);
......
""" This test need a set of pins which can be set as inputs and have no external """
This test need a set of pins which can be set as inputs and have no external
pull up or pull down connected. pull up or pull down connected.
GP12 and GP17 must be connected together
""" """
from machine import Pin from machine import Pin
import os import os
...@@ -14,6 +16,13 @@ elif 'WiPy' in mch: ...@@ -14,6 +16,13 @@ elif 'WiPy' in mch:
else: else:
raise Exception('Board not supported!') 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(): def test_noinit():
for p in pin_map: for p in pin_map:
pin = Pin(p) pin = Pin(p)
......
True
True
1 1
1 1
1 1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment