Browse Source

Add digitalPinToInterrupt

teensy4-core
PaulStoffregen 11 years ago
parent
commit
a3e31ee55d
2 changed files with 6 additions and 0 deletions
  1. +4
    -0
      teensy/pins_arduino.h
  2. +2
    -0
      teensy3/pins_arduino.h

+ 4
- 0
teensy/pins_arduino.h View File

// depend on these to be zero? // depend on these to be zero?
#define NOT_A_PORT 127 #define NOT_A_PORT 127
#define NOT_A_PIN 127 #define NOT_A_PIN 127
#define NOT_AN_INTERRUPT -1


#define digitalPinToPort(P) (P) #define digitalPinToPort(P) (P)
#define portInputRegister(P) ((volatile uint8_t *)((int)pgm_read_byte(digital_pin_table_PGM+(P)*2+1))) #define portInputRegister(P) ((volatile uint8_t *)((int)pgm_read_byte(digital_pin_table_PGM+(P)*2+1)))
#if defined(__AVR_AT90USB162__) #if defined(__AVR_AT90USB162__)
#define analogInputToDigitalPin(ch) (-1) #define analogInputToDigitalPin(ch) (-1)
#define digitalPinHasPWM(p) ((p) == 0 || (p) == 15 || (p) == 17 || (p) == 18) #define digitalPinHasPWM(p) ((p) == 0 || (p) == 15 || (p) == 17 || (p) == 18)
#define digitalPinToInterrupt(p) (((p) <= 3 || (p) == 6 || (p) == 8) ? (p) : ((p) == 4 ? 5 : ((p) == 16 ? 4 : -1)))
#elif defined(__AVR_ATmega32U4__) #elif defined(__AVR_ATmega32U4__)
#define analogInputToDigitalPin(ch) ((ch) <= 10 ? 21 - (ch) : ((ch) == 11 ? 22 : -1)) #define analogInputToDigitalPin(ch) ((ch) <= 10 ? 21 - (ch) : ((ch) == 11 ? 22 : -1))
#define digitalPinHasPWM(p) ((p) == 4 || (p) == 5 || (p) == 9 || (p) == 10 || (p) == 12 || (p) == 14 || (p) == 15) #define digitalPinHasPWM(p) ((p) == 4 || (p) == 5 || (p) == 9 || (p) == 10 || (p) == 12 || (p) == 14 || (p) == 15)
#define digitalPinToInterrupt(p) (((p) >= 5 && (p) <= 8) ? (p) - 5 : -1)
#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) #elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
#define analogInputToDigitalPin(ch) ((ch) <= 7 ? (ch) + 38 : -1) #define analogInputToDigitalPin(ch) ((ch) <= 7 ? (ch) + 38 : -1)
#define digitalPinHasPWM(p) (((p) >= 14 && (p) <= 16) || ((p) >= 24 && (p) <= 27) || (p) == 0 || (p) == 1) #define digitalPinHasPWM(p) (((p) >= 14 && (p) <= 16) || ((p) >= 24 && (p) <= 27) || (p) == 0 || (p) == 1)
#define digitalPinToInterrupt(p) ((p) <= 3 ? (p) : (((p) == 36 || (p) == 37) ? (p) - 32 : (((p) == 18 || (p) == 19) ? (p) - 12 : -1)))
#endif #endif


#if defined(__AVR_AT90USB162__) #if defined(__AVR_AT90USB162__)

+ 2
- 0
teensy3/pins_arduino.h View File

#define analogInputToDigitalPin(p) (((p) < 10) ? (p) + 14 : -1) #define analogInputToDigitalPin(p) (((p) < 10) ? (p) + 14 : -1)
#define digitalPinHasPWM(p) (((p) >= 3 && (p) <= 6) || (p) == 9 || (p) == 10 || ((p) >= 20 && (p) <= 23)) #define digitalPinHasPWM(p) (((p) >= 3 && (p) <= 6) || (p) == 9 || (p) == 10 || ((p) >= 20 && (p) <= 23))


#define NOT_AN_INTERRUPT -1
#define digitalPinToInterrupt(p) ((p) < NUM_DIGITAL_PINS ? (p) : -1)


struct digital_pin_bitband_and_config_table_struct { struct digital_pin_bitband_and_config_table_struct {
volatile uint32_t *reg; volatile uint32_t *reg;

Loading…
Cancel
Save