diff options
author | Cristian Maglie <c.maglie@bug.st> | 2012-05-21 01:56:06 +0200 |
---|---|---|
committer | Cristian Maglie <c.maglie@bug.st> | 2012-05-22 11:23:47 +0200 |
commit | 3786e337e0211ca1ef94b37b03e891adfb3b5f9a (patch) | |
tree | dd7f8f6fd396243460ec22da89bfbd71d552f484 /cores/arduino/wiring_digital.c | |
parent | 324023a67afd1691f12ead4388d7cdf1a9d1a6ef (diff) | |
parent | 9a8976ce56bcdb70815dd58c1764d9e5c3b6fe95 (diff) |
Pre-merge upstream Arduino
Diffstat (limited to 'cores/arduino/wiring_digital.c')
-rwxr-xr-x | cores/arduino/wiring_digital.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/cores/arduino/wiring_digital.c b/cores/arduino/wiring_digital.c index 97ef134..584a28a 100755 --- a/cores/arduino/wiring_digital.c +++ b/cores/arduino/wiring_digital.c @@ -32,17 +32,25 @@ void pinMode(uint8_t pin, uint8_t mode) { uint8_t bit = digitalPinToBitMask(pin); uint8_t port = digitalPinToPort(pin); - volatile uint8_t *reg; + volatile uint8_t *reg, *out; if (port == NOT_A_PIN) return; // JWS: can I let the optimizer do this? reg = portModeRegister(port); + out = portOutputRegister(port); if (mode == INPUT) { uint8_t oldSREG = SREG; cli(); *reg &= ~bit; + *out &= ~bit; + SREG = oldSREG; + } else if (mode == INPUT_PULLUP) { + uint8_t oldSREG = SREG; + cli(); + *reg &= ~bit; + *out |= bit; SREG = oldSREG; } else { uint8_t oldSREG = SREG; |