mirror of
https://github.com/Theaninova/Arduino-IRremote.git
synced 2025-12-23 06:46:17 +00:00
Merge pull request #22 from PaulStoffregen/master
Teensy 3.0 compatibility
This commit is contained in:
@@ -252,7 +252,7 @@ void IRsend::mark(int time) {
|
|||||||
// Sends an IR mark for the specified number of microseconds.
|
// Sends an IR mark for the specified number of microseconds.
|
||||||
// The mark output is modulated at the PWM frequency.
|
// The mark output is modulated at the PWM frequency.
|
||||||
TIMER_ENABLE_PWM; // Enable pin 3 PWM output
|
TIMER_ENABLE_PWM; // Enable pin 3 PWM output
|
||||||
delayMicroseconds(time);
|
if (time > 0) delayMicroseconds(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Leave pin off for time (given in microseconds) */
|
/* Leave pin off for time (given in microseconds) */
|
||||||
@@ -260,7 +260,7 @@ void IRsend::space(int time) {
|
|||||||
// Sends an IR space for the specified number of microseconds.
|
// Sends an IR space for the specified number of microseconds.
|
||||||
// A space is no output, so the PWM output is disabled.
|
// A space is no output, so the PWM output is disabled.
|
||||||
TIMER_DISABLE_PWM; // Disable pin 3 PWM output
|
TIMER_DISABLE_PWM; // Disable pin 3 PWM output
|
||||||
delayMicroseconds(time);
|
if (time > 0) delayMicroseconds(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRsend::enableIROut(int khz) {
|
void IRsend::enableIROut(int khz) {
|
||||||
|
|||||||
@@ -46,6 +46,10 @@
|
|||||||
//#define IR_USE_TIMER3 // tx = pin 9
|
//#define IR_USE_TIMER3 // tx = pin 9
|
||||||
#define IR_USE_TIMER4_HS // tx = pin 10
|
#define IR_USE_TIMER4_HS // tx = pin 10
|
||||||
|
|
||||||
|
// Teensy 3.0
|
||||||
|
#elif defined(__MK20DX128__)
|
||||||
|
#define IR_USE_TIMER_CMT // tx = pin 5
|
||||||
|
|
||||||
// Teensy++ 1.0 & 2.0
|
// Teensy++ 1.0 & 2.0
|
||||||
#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
|
#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
|
||||||
//#define IR_USE_TIMER1 // tx = pin 25
|
//#define IR_USE_TIMER1 // tx = pin 25
|
||||||
@@ -436,6 +440,54 @@ extern volatile irparams_t irparams;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// defines for special carrier modulator timer
|
||||||
|
#elif defined(IR_USE_TIMER_CMT)
|
||||||
|
#define TIMER_RESET ({ \
|
||||||
|
uint8_t tmp = CMT_MSC; \
|
||||||
|
CMT_CMD2 = 30; \
|
||||||
|
})
|
||||||
|
#define TIMER_ENABLE_PWM CORE_PIN5_CONFIG = PORT_PCR_MUX(2)|PORT_PCR_DSE|PORT_PCR_SRE
|
||||||
|
#define TIMER_DISABLE_PWM CORE_PIN5_CONFIG = PORT_PCR_MUX(1)|PORT_PCR_DSE|PORT_PCR_SRE
|
||||||
|
#define TIMER_ENABLE_INTR NVIC_ENABLE_IRQ(IRQ_CMT)
|
||||||
|
#define TIMER_DISABLE_INTR NVIC_DISABLE_IRQ(IRQ_CMT)
|
||||||
|
#define TIMER_INTR_NAME cmt_isr
|
||||||
|
#ifdef ISR
|
||||||
|
#undef ISR
|
||||||
|
#endif
|
||||||
|
#define ISR(f) void f(void)
|
||||||
|
#if F_BUS == 48000000
|
||||||
|
#define CMT_PPS_VAL 5
|
||||||
|
#else
|
||||||
|
#define CMT_PPS_VAL 2
|
||||||
|
#endif
|
||||||
|
#define TIMER_CONFIG_KHZ(val) ({ \
|
||||||
|
SIM_SCGC4 |= SIM_SCGC4_CMT; \
|
||||||
|
SIM_SOPT2 |= SIM_SOPT2_PTD7PAD; \
|
||||||
|
CMT_PPS = CMT_PPS_VAL; \
|
||||||
|
CMT_CGH1 = 2667 / val; \
|
||||||
|
CMT_CGL1 = 5333 / val; \
|
||||||
|
CMT_CMD1 = 0; \
|
||||||
|
CMT_CMD2 = 30; \
|
||||||
|
CMT_CMD3 = 0; \
|
||||||
|
CMT_CMD4 = 0; \
|
||||||
|
CMT_OC = 0x60; \
|
||||||
|
CMT_MSC = 0x01; \
|
||||||
|
})
|
||||||
|
#define TIMER_CONFIG_NORMAL() ({ \
|
||||||
|
SIM_SCGC4 |= SIM_SCGC4_CMT; \
|
||||||
|
CMT_PPS = CMT_PPS_VAL; \
|
||||||
|
CMT_CGH1 = 1; \
|
||||||
|
CMT_CGL1 = 1; \
|
||||||
|
CMT_CMD1 = 0; \
|
||||||
|
CMT_CMD2 = 30; \
|
||||||
|
CMT_CMD3 = 0; \
|
||||||
|
CMT_CMD4 = 19; \
|
||||||
|
CMT_OC = 0; \
|
||||||
|
CMT_MSC = 0x03; \
|
||||||
|
})
|
||||||
|
#define TIMER_PWM_PIN 5
|
||||||
|
|
||||||
|
|
||||||
#else // unknown timer
|
#else // unknown timer
|
||||||
#error "Internal code configuration error, no known IR_USE_TIMER# defined\n"
|
#error "Internal code configuration error, no known IR_USE_TIMER# defined\n"
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user