瀏覽代碼

Add pinMode INPUT_DISABLE

main
PaulStoffregen 8 年之前
父節點
當前提交
56f36603ad
共有 3 個文件被更改,包括 9 次插入10 次删除
  1. +1
    -0
      keywords.txt
  2. +1
    -0
      teensy3/core_pins.h
  3. +7
    -10
      teensy3/pins_teensy.c

+ 1
- 0
keywords.txt 查看文件

@@ -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 查看文件

@@ -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 查看文件

@@ -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…
取消
儲存