Skip to content

Commit

Permalink
Update for Teensy 4.0 PWM pins
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulStoffregen committed Dec 27, 2019
1 parent ba7c37f commit ce0fa0b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion TimerOne.cpp
Expand Up @@ -45,7 +45,7 @@ void ftm1_isr(void)
#endif
Timer1.isrCallback();
}
#elif defined(__arm__) && defined(TEENSYDUINO) && (defined(__IMXRT1052__) || defined(__IMXRT1062__))
#elif defined(__arm__) && defined(TEENSYDUINO) && defined(__IMXRT1062__)
void TimerOne::isr(void)
{
FLEXPWM1_SM3STS = FLEXPWM_SMSTS_RF;
Expand Down
10 changes: 5 additions & 5 deletions TimerOne.h
Expand Up @@ -491,7 +491,7 @@ class TimerOne

#undef F_TIMER

#elif defined(__arm__) && defined(TEENSYDUINO) && (defined(__IMXRT1052__) || defined(__IMXRT1062__))
#elif defined(__arm__) && defined(TEENSYDUINO) && defined(__IMXRT1062__)

public:
//****************************
Expand Down Expand Up @@ -568,10 +568,10 @@ class TimerOne
setPwmDuty(pin, duty);
if (pin == TIMER1_A_PIN) {
FLEXPWM1_OUTEN |= FLEXPWM_OUTEN_PWMB_EN(8);
IOMUXC_SW_MUX_CTL_PAD_GPIO_B1_01 = 6; // pin 6 FLEXPWM1_PWM3_B
IOMUXC_SW_MUX_CTL_PAD_GPIO_B1_01 = 6; // pin 7 FLEXPWM1_PWM3_B
} else if (pin == TIMER1_B_PIN) {
FLEXPWM1_OUTEN |= FLEXPWM_OUTEN_PWMA_EN(8);
IOMUXC_SW_MUX_CTL_PAD_GPIO_B1_00 = 6; // pin 7 FLEXPWM1_PWM3_A
IOMUXC_SW_MUX_CTL_PAD_GPIO_B1_00 = 6; // pin 8 FLEXPWM1_PWM3_A
}
}
void pwm(char pin, unsigned int duty, unsigned long microseconds) __attribute__((always_inline)) {
Expand All @@ -580,10 +580,10 @@ class TimerOne
}
void disablePwm(char pin) __attribute__((always_inline)) {
if (pin == TIMER1_A_PIN) {
IOMUXC_SW_MUX_CTL_PAD_GPIO_B1_01 = 5; // pin 6 FLEXPWM1_PWM3_B
IOMUXC_SW_MUX_CTL_PAD_GPIO_B1_01 = 5; // pin 7 FLEXPWM1_PWM3_B
FLEXPWM1_OUTEN &= ~FLEXPWM_OUTEN_PWMB_EN(8);
} else if (pin == TIMER1_B_PIN) {
IOMUXC_SW_MUX_CTL_PAD_GPIO_B1_00 = 5; // pin 7 FLEXPWM1_PWM3_A
IOMUXC_SW_MUX_CTL_PAD_GPIO_B1_00 = 5; // pin 8 FLEXPWM1_PWM3_A
FLEXPWM1_OUTEN &= ~FLEXPWM_OUTEN_PWMA_EN(8);
}
}
Expand Down
12 changes: 6 additions & 6 deletions config/known_16bit_timers.h
Expand Up @@ -69,13 +69,13 @@
#define TIMER3_B_PIN 4
#define TIMER3_ICP_PIN 4

// Teensy 4
// Teensy 4.0
//
#elif defined(__IMXRT1052__) || defined(__IMXRT1062__)
#define TIMER1_A_PIN 6
#define TIMER1_B_PIN 7
#define TIMER3_A_PIN 8
#define TIMER3_B_PIN 9
#elif defined(__IMXRT1062__)
#define TIMER1_A_PIN 7
#define TIMER1_B_PIN 8
#define TIMER3_A_PIN 9
#define TIMER3_B_PIN 6

// Arduino Mega
//
Expand Down

0 comments on commit ce0fa0b

Please sign in to comment.