jdskier1 / arduino-tiny

Automatically exported from code.google.com/p/arduino-tiny
Other
0 stars 0 forks source link

Support INPUT_PULLUP on pinMode command. #69

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. use pinMode(1, INPUT_PULLUP)

What is the expected output? What do you see instead?
This will switch on the internal Pullup resistor. But i get a INPUT_PULLUP was 
not declared in this scope.

What version of the product are you using? On what operating system?
0010_0015

Please provide any additional information below.
I have changed the following line of the files:

wiring.h
45: #define INPUT 0x0
46: #define OUTPUT 0x1
47: #define INPUT_PULLUP 0x2
48: 
49: #define true 0x1
50: #define false 0x0

wiring_digital.c
 void pinMode(uint8_t pin, uint8_t mode)
 {
    uint8_t bit = digitalPinToBitMask(pin);
    uint8_t port = digitalPinToPort(pin);
>   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;
    cli();
        *reg |= bit;
        SREG = oldSREG;
    }
}

Original issue reported on code.google.com by Wilfried...@googlemail.com on 5 Oct 2012 at 11:16

Attachments:

GoogleCodeExporter commented 8 years ago
yes, 
pinMode(AnalogInPin, INPUT_PULLUP);

and equivalent:
pinMode(AnalogInPin, INPUT);
digitalWrite(AnalogInPin, HIGH);
do not appear to activate the internal pullup on attiny85
(winxp, arduino1.0.1)

Original comment by LoftyAn...@gmail.com on 17 Nov 2012 at 11:23

GoogleCodeExporter commented 8 years ago
I can confirm that the problem exists, and the code above works.

Original comment by andre....@gmail.com on 18 Apr 2013 at 8:06

GoogleCodeExporter commented 8 years ago

Original comment by arduino....@gmail.com on 24 May 2013 at 8:03