Browse Source

Add pinMode INPUT_DISABLE

main
PaulStoffregen 8 years ago
parent
commit
56f36603ad
3 changed files with 9 additions and 10 deletions
  1. +1
    -0
      keywords.txt
  2. +1
    -0
      teensy3/core_pins.h
  3. +7
    -10
      teensy3/pins_teensy.c

+ 1
- 0
keywords.txt View File

@@ -81,6 +81,7 @@ digitalPinToInterrupt KEYWORD2
OUTPUT_OPENDRAIN LITERAL1
INPUT_PULLUP LITERAL1
INPUT_PULLDOWN LITERAL1
INPUT_DISABLE LITERAL1

# String functions
copy KEYWORD2

+ 1
- 0
teensy3/core_pins.h View File

@@ -41,6 +41,7 @@
#define INPUT_PULLUP 2
#define INPUT_PULLDOWN 3
#define OUTPUT_OPENDRAIN 4
#define INPUT_DISABLE 5
#define LSBFIRST 0
#define MSBFIRST 1
#define _BV(n) (1<<(n))

+ 7
- 10
teensy3/pins_teensy.c View File

@@ -1066,19 +1066,16 @@ void pinMode(uint8_t pin, uint8_t mode)
#else
*portModeRegister(pin) &= ~digitalPinToBitMask(pin);
#endif
if (mode == INPUT || mode == INPUT_PULLUP || mode == INPUT_PULLDOWN) {
if (mode == INPUT) {
*config = PORT_PCR_MUX(1);
if (mode == INPUT_PULLUP) {
*config |= (PORT_PCR_PE | PORT_PCR_PS); // pullup
} else if (mode == INPUT_PULLDOWN) {
*config |= (PORT_PCR_PE); // pulldown
*config &= ~(PORT_PCR_PS);
}
} else {
*config = PORT_PCR_MUX(1) | PORT_PCR_PE | PORT_PCR_PS; // pullup
} else if (mode == INPUT_PULLUP) {
*config = PORT_PCR_MUX(1) | PORT_PCR_PE | PORT_PCR_PS;
} else if (mode == INPUT_PULLDOWN) {
*config = PORT_PCR_MUX(1) | PORT_PCR_PE;
} else { // INPUT_DISABLE
*config = 0;
}
}

}



Loading…
Cancel
Save