Index: examples/Arduino/Arduino.ino
===================================================================
--- examples/Arduino/Arduino.ino	(revision 0)
+++ examples/Arduino/Arduino.ino	(working copy)
@@ -0,0 +1,142 @@
+#include <TimerOne.h>
+/* first include Arduino.h, the IDE includes it after irmp*.h ... */
+#include "Arduino.h"
+/* ... and then chokes on uintX_t ... */
+
+#include <irmp.h>
+#include <irsnd.h>
+
+/* undefine this if you don't want blinking LED for diagnosis */
+#define LED_PIN 13
+#define SER_BAUD 115200
+
+/* F_INTERRUPTS is the interrupt frequency defined in irmpconfig.h */
+#define US (1000000 / F_INTERRUPTS)
+void setup()
+{
+  Serial.begin(SER_BAUD);
+  delay(1000);
+  /* greeting string and debugging ouput */
+  Serial.println("IRMP test sketch");
+  Serial.print("US: ");
+  Serial.println(US);
+  Serial.println("Send example: P:02 A:916E C:000F (NEC Taste 1)");
+#ifdef LED_PIN
+  pinMode(LED_PIN, OUTPUT);
+#endif
+  irmp_init();
+  irsnd_init();
+  //sei();
+  led(HIGH);
+  delay(20); /* make sure the greeting string is out before starting */
+  led(LOW);
+  Timer1.initialize(US);
+  Timer1.attachInterrupt(timerinterrupt);
+}
+
+IRMP_DATA irmp_data[3];
+uint8_t act_data = 0;
+int incomingByte = 0;   // for incoming serial data
+void loop()
+{
+  IRMP_DATA* data = &irmp_data[act_data];
+  if (irmp_get_data(data)) {
+    led(HIGH);
+#if IRMP_PROTOCOL_NAMES == 1
+    Serial.print(irmp_protocol_names[data->protocol]);
+    Serial.print(" ");
+#endif
+    Serial.print("P:");
+    Serial.print(data->protocol, HEX);
+    Serial.print(" A:");
+    Serial.print(data->address, HEX);
+    Serial.print(" C:");
+    Serial.print(data->command, HEX);
+    Serial.print(" ");
+    Serial.print(data->flags, HEX);
+    Serial.println("");
+    /* Serial.print is asynchronous, so the LED is only flashing very lightly */
+    led(LOW);
+
+    data->flags = 0;    // reset flags!
+    int result = irsnd_send_data(data, TRUE);
+    if (result != 1) { Serial.println("loop : irsnd_send_data ERROR"); }
+    else {
+      if (++act_data >= 3) { act_data = 0; } 
+    }
+  }
+
+  if (Serial.available() == 18 && readAndCheck('P') && readAndCheck(':')) {
+    // read the protocol
+    data->protocol = readHex() * 16 + readHex();
+
+    if (readAndCheck(' ') && readAndCheck('A') && readAndCheck(':')) {
+      // read the address
+      data->address = ((readHex() * 16 + readHex()) * 16 + readHex()) * 16 + readHex();
+
+      if (readAndCheck(' ') && readAndCheck('C') && readAndCheck(':')) {
+        // read the address
+        data->command = ((readHex() * 16 + readHex()) * 16 + readHex()) * 16 + readHex();
+
+        // send ir data
+        data->flags = 0;
+        int result = irsnd_send_data(data, TRUE);
+        if (result) {
+          Serial.print("Send IR data: ");
+          Serial.print("P:");
+          Serial.print(data->protocol, HEX);
+          Serial.print(" A:");
+          Serial.print(data->address, HEX);
+          Serial.print(" C:");
+          Serial.print(data->command, HEX);
+          Serial.println("");
+          if (++act_data >= 3) { act_data = 0; } 
+        }
+      }
+    }
+  }
+}
+
+/* helper function: attachInterrupt wants void(), but irmp_ISR is uint8_t() */
+void timerinterrupt()
+{
+  // only when tsop dont see the ir_led flashing
+  irsnd_ISR();              // call irsnd ISR
+  irmp_ISR();               // call irmp ISR
+
+/*
+  // do not recive when sending (tsop see the ir_led)
+  if (! irsnd_ISR())          // call irsnd ISR
+  {                           // if not busy...
+    irmp_ISR();               // call irmp ISR
+  }
+*/
+}
+
+static inline void led(int state)
+{
+#ifdef LED_PIN
+  digitalWrite(LED_PIN, state);
+#endif
+}
+
+static inline int readAndCheck(int c)
+{
+  return c == Serial.read();
+}
+
+static inline int readHex()
+{
+  int c = Serial.read();
+  if (c >= '0' && c <= '9')
+  {
+    return c - '0';
+  }
+  c |= 0x20; // lowercase
+  if (c >= 'a' && c <= 'f')
+  {
+    return c + 10 - 'a';
+  }
+
+  return -1;
+}
Index: irmp.c
===================================================================
--- irmp.c	(revision 167)
+++ irmp.c	(working copy)
@@ -682,6 +682,13 @@
 #  include "stm32f4xx_usart.h"
 #elif defined(ARM_STM32F10X)
 #  define  STM32_UART_COM     USART3                                    // UART3 on PB10
+#elif defined(ARDUINO)
+   // we use the Arduino Serial Imlementation
+#if defined(USB_SERIAL)
+#  include "usb_serial.h"
+#  else
+# error USB_SERIAL not defined in ARDUINO Environment
+#  endif
 #else
 #  if IRMP_EXT_LOGGING == 1                                             // use external logging
 #    include "irmpextlog.h"
@@ -812,7 +819,11 @@
 
     // UART enable
     USART_Cmd(STM32_UART_COM, ENABLE);
-        
+
+#elif defined(ARDUINO)
+   // we use the Arduino Serial Imlementation
+   // you have to call Serial.begin(SER_BAUD); in Arduino setup() function
+
 #elif defined (__AVR_XMEGA__)
 
         PMIC.CTRL |= PMIC_HILVLEN_bm;
@@ -824,7 +835,7 @@
         USARTC1.CTRLC = USART_CHSIZE_8BIT_gc; //Größe der Zeichen: 8 Bit
         PORTC.DIR |= (1<<7);  //TXD als Ausgang setzen
         PORTC.DIR &= ~(1<<6);
-        
+
 #else
 
 #if (IRMP_EXT_LOGGING == 0)                                                                         // use UART
@@ -871,6 +882,9 @@
         USART_SendData(STM32_UART_COM, '\r');
     }
 
+#elif defined(ARDUINO)
+   // we use the Arduino Serial Imlementation
+  usb_serial_putchar(ch);
 #else
 #if (IRMP_EXT_LOGGING == 0)
         
@@ -1981,41 +1995,43 @@
 {
 #if defined(PIC_CCS) || defined(PIC_C18)                                // PIC: do nothing
 #elif defined (ARM_STM32)                                               // STM32
-   GPIO_InitTypeDef     GPIO_InitStructure;
+    GPIO_InitTypeDef     GPIO_InitStructure;
 
-   /* GPIOx clock enable */
+    /* GPIOx clock enable */
  #if defined (ARM_STM32L1XX)
-   RCC_AHBPeriphClockCmd(IRMP_PORT_RCC, ENABLE);
+    RCC_AHBPeriphClockCmd(IRMP_PORT_RCC, ENABLE);
  #elif defined (ARM_STM32F10X)
-   RCC_APB2PeriphClockCmd(IRMP_PORT_RCC, ENABLE);
+    RCC_APB2PeriphClockCmd(IRMP_PORT_RCC, ENABLE);
  #elif defined (ARM_STM32F4XX)
-   RCC_AHB1PeriphClockCmd(IRMP_PORT_RCC, ENABLE);
+    RCC_AHB1PeriphClockCmd(IRMP_PORT_RCC, ENABLE);
  #endif
 
    /* GPIO Configuration */
-   GPIO_InitStructure.GPIO_Pin = IRMP_BIT;
+    GPIO_InitStructure.GPIO_Pin = IRMP_BIT;
  #if defined (ARM_STM32L1XX) || defined (ARM_STM32F4XX)
-   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
-   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
-   GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
-   GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
+    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
+    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
+    GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
+    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  #elif defined (ARM_STM32F10X)
-   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
-   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
+    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
+    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
  #endif
-   GPIO_Init(IRMP_PORT, &GPIO_InitStructure);
+    GPIO_Init(IRMP_PORT, &GPIO_InitStructure);
 #elif defined(STELLARIS_ARM_CORTEX_M4)
-     // Enable the GPIO port
-     ROM_SysCtlPeripheralEnable(IRMP_PORT_PERIPH);
+    // Enable the GPIO port
+    ROM_SysCtlPeripheralEnable(IRMP_PORT_PERIPH);
 
-     // Set as an input
-     ROM_GPIODirModeSet(IRMP_PORT_BASE, IRMP_PORT_PIN, GPIO_DIR_MODE_IN);
-     ROM_GPIOPadConfigSet(IRMP_PORT_BASE, IRMP_PORT_PIN,
-                          GPIO_STRENGTH_2MA,
-                          GPIO_PIN_TYPE_STD_WPU);
+    // Set as an input
+    ROM_GPIODirModeSet(IRMP_PORT_BASE, IRMP_PORT_PIN, GPIO_DIR_MODE_IN);
+    ROM_GPIOPadConfigSet(IRMP_PORT_BASE, IRMP_PORT_PIN,
+                         GPIO_STRENGTH_2MA,
+                         GPIO_PIN_TYPE_STD_WPU);
 #elif defined(__SDCC_stm8)                                              // STM8
     IRMP_GPIO_STRUCT->CR1 |= (1<<IRMP_BIT);                             // activate pullup
     IRMP_GPIO_STRUCT->DDR &= ~(1<<IRMP_BIT);                            // pin is input
+#elif defined (TEENSY_ARM_CORTEX_M4)
+    pinMode(IRMP_PIN, INPUT);
 #else                                                                   // AVR
     IRMP_PORT &= ~(1<<IRMP_BIT);                                        // deactivate pullup
     IRMP_DDR &= ~(1<<IRMP_BIT);                                         // set pin to input
Index: irmp.h
===================================================================
--- irmp.h	(revision 167)
+++ irmp.h	(working copy)
@@ -80,6 +80,9 @@
 #  define IRMP_BIT                              IRMP_BIT_NUMBER
 #  define input(x)                              ((x) & (1 << IRMP_BIT))
 
+#elif defined (TEENSY_ARM_CORTEX_M4)
+#  define input(x)                              ((uint8_t)(digitalReadFast(x)))
+
 #endif
 
 #if IRMP_SUPPORT_TECHNICS_PROTOCOL == 1
@@ -217,6 +220,11 @@
 
 #define IRMP_FLAG_REPETITION            0x01
 
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
 extern void                             irmp_init (void);
 extern uint_fast8_t                     irmp_get_data (IRMP_DATA *);
 extern uint_fast8_t                     irmp_ISR (void);
@@ -229,4 +237,8 @@
 extern void                             irmp_set_callback_ptr (void (*cb)(uint_fast8_t));
 #endif // IRMP_USE_CALLBACK == 1
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _IRMP_H_ */
Index: irmpconfig.h
===================================================================
--- irmpconfig.h	(revision 167)
+++ irmpconfig.h	(working copy)
@@ -149,6 +149,13 @@
 #  define IRMP_BIT_NUMBER                       1
 
 /*---------------------------------------------------------------------------------------------------------------------------------------------------
+ * Change hardware pin here for Teensy 3.x with teensyduino gcc compiler
+ *---------------------------------------------------------------------------------------------------------------------------------------------------
+ */
+#elif defined (TEENSY_ARM_CORTEX_M4)
+#  define IRMP_PIN                              1                       // use Digital pin 1 as IR input on Teensy
+
+/*---------------------------------------------------------------------------------------------------------------------------------------------------
  * Handling of unknown target system: DON'T CHANGE
  *---------------------------------------------------------------------------------------------------------------------------------------------------
  */
Index: irmpextlog.h
===================================================================
--- irmpextlog.h	(revision 167)
+++ irmpextlog.h	(working copy)
@@ -1,7 +1,16 @@
 #ifndef _IRMPEXTLOG_H
 #define _IRMPEXTLOG_H
 
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
 void    initextlog (void);
 void    sendextlog (unsigned char);
 
+#ifdef __cplusplus
+}
 #endif
+
+#endif
Index: irmpsystem.h
===================================================================
--- irmpsystem.h	(revision 167)
+++ irmpsystem.h	(working copy)
@@ -48,6 +48,9 @@
 #elif defined(TARGET_IS_BLIZZARD_RA2)                                               // TI Stellaris (tested on Stellaris Launchpad with Code Composer Studio)
 #  define STELLARIS_ARM_CORTEX_M4
 #  define F_CPU (SysCtlClockGet())
+#elif defined(TEENSYDUINO) && (defined(__MK20DX256__) || defined(__MK20DX128__))    // Teensy 3.x (tested on Teensy 3.1 in Arduino 1.6.5 / Teensyduino 1.2.5)
+#  include <core_pins.h>
+#  define TEENSY_ARM_CORTEX_M4
 #elif defined(unix) || defined(WIN32) || defined(__APPLE__)                         // Unix/Linux or Windows or Apple
 #  define UNIX_OR_WINDOWS
 #else
@@ -130,7 +133,10 @@
 #else
 
 #  define PROGMEM
+
+#  ifndef memcpy_P
 #  define memcpy_P                      memcpy
+#  endif
 
 #endif
 
Index: irsnd.c
===================================================================
--- irsnd.c	(revision 167)
+++ irsnd.c	(working copy)
@@ -166,6 +166,10 @@
     //Nothing here to do here -> See irsndconfig.h
 #elif defined (ARM_STM32)  //STM32
     //Nothing here to do here -> See irsndconfig.h
+#elif defined (TEENSY_ARM_CORTEX_M4)  //Teensy3
+#  if !digitalPinHasPWM(IRSND_PIN)
+#    error need pin with pwm output.
+#  endif
 #else
 #  if !defined (unix) && !defined (WIN32)
 #    error mikrocontroller not defined, please fill in definitions here.
@@ -343,40 +347,6 @@
 #define RUWIDO_BIT_PAUSE_LEN                    (uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_BIT_PAUSE_TIME + 0.5)
 #define RUWIDO_FRAME_REPEAT_PAUSE_LEN           (uint16_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_FRAME_REPEAT_PAUSE_TIME + 0.5)      // use uint16_t!
 
-#ifdef PIC_C18                                  // PIC C18
-#  define IRSND_FREQ_TYPE                       uint8_t
-#  define IRSND_FREQ_30_KHZ                     (IRSND_FREQ_TYPE) ((F_CPU / 30000  / 2 / Pre_Scaler / PIC_Scaler) - 1)
-#  define IRSND_FREQ_32_KHZ                     (IRSND_FREQ_TYPE) ((F_CPU / 32000  / 2 / Pre_Scaler / PIC_Scaler) - 1)
-#  define IRSND_FREQ_36_KHZ                     (IRSND_FREQ_TYPE) ((F_CPU / 36000  / 2 / Pre_Scaler / PIC_Scaler) - 1)
-#  define IRSND_FREQ_38_KHZ                     (IRSND_FREQ_TYPE) ((F_CPU / 38000  / 2 / Pre_Scaler / PIC_Scaler) - 1)
-#  define IRSND_FREQ_40_KHZ                     (IRSND_FREQ_TYPE) ((F_CPU / 40000  / 2 / Pre_Scaler / PIC_Scaler) - 1)
-#  define IRSND_FREQ_56_KHZ                     (IRSND_FREQ_TYPE) ((F_CPU / 56000  / 2 / Pre_Scaler / PIC_Scaler) - 1)
-#  define IRSND_FREQ_455_KHZ                    (IRSND_FREQ_TYPE) ((F_CPU / 455000 / 2 / Pre_Scaler / PIC_Scaler) - 1)
-#elif defined (ARM_STM32)                       // STM32
-#  define IRSND_FREQ_TYPE                       uint32_t
-#  define IRSND_FREQ_30_KHZ                     (IRSND_FREQ_TYPE) (30000)
-#  define IRSND_FREQ_32_KHZ                     (IRSND_FREQ_TYPE) (32000)
-#  define IRSND_FREQ_36_KHZ                     (IRSND_FREQ_TYPE) (36000)
-#  define IRSND_FREQ_38_KHZ                     (IRSND_FREQ_TYPE) (38000)
-#  define IRSND_FREQ_40_KHZ                     (IRSND_FREQ_TYPE) (40000)
-#  define IRSND_FREQ_56_KHZ                     (IRSND_FREQ_TYPE) (56000)
-#  define IRSND_FREQ_455_KHZ                    (IRSND_FREQ_TYPE) (455000)
-#else                                           // AVR
-#  if F_CPU >= 16000000L
-#    define AVR_PRESCALER                       8
-#  else
-#    define AVR_PRESCALER                       1
-#  endif
-#  define IRSND_FREQ_TYPE                       uint8_t
-#  define IRSND_FREQ_30_KHZ                     (IRSND_FREQ_TYPE) ((F_CPU / 30000 / AVR_PRESCALER / 2) - 1)
-#  define IRSND_FREQ_32_KHZ                     (IRSND_FREQ_TYPE) ((F_CPU / 32000 / AVR_PRESCALER / 2) - 1)
-#  define IRSND_FREQ_36_KHZ                     (IRSND_FREQ_TYPE) ((F_CPU / 36000 / AVR_PRESCALER / 2) - 1)
-#  define IRSND_FREQ_38_KHZ                     (IRSND_FREQ_TYPE) ((F_CPU / 38000 / AVR_PRESCALER / 2) - 1)
-#  define IRSND_FREQ_40_KHZ                     (IRSND_FREQ_TYPE) ((F_CPU / 40000 / AVR_PRESCALER / 2) - 1)
-#  define IRSND_FREQ_56_KHZ                     (IRSND_FREQ_TYPE) ((F_CPU / 56000 / AVR_PRESCALER / 2) - 1)
-#  define IRSND_FREQ_455_KHZ                    (IRSND_FREQ_TYPE) ((F_CPU / 455000 / AVR_PRESCALER / 2) - 1)
-#endif
-
 #define FDC_START_BIT_PULSE_LEN                 (uint8_t)(F_INTERRUPTS * FDC_START_BIT_PULSE_TIME + 0.5)
 #define FDC_START_BIT_PAUSE_LEN                 (uint8_t)(F_INTERRUPTS * FDC_START_BIT_PAUSE_TIME + 0.5)
 #define FDC_PULSE_LEN                           (uint8_t)(F_INTERRUPTS * FDC_PULSE_TIME + 0.5)
@@ -446,6 +416,50 @@
 #define ACP24_0_PAUSE_LEN                       (uint8_t)(F_INTERRUPTS * ACP24_0_PAUSE_TIME + 0.5)
 #define ACP24_FRAME_REPEAT_PAUSE_LEN            (uint16_t)(F_INTERRUPTS * ACP24_FRAME_REPEAT_PAUSE_TIME + 0.5)                // use uint16_t!
 
+
+#ifdef PIC_C18                                  // PIC C18
+#  define IRSND_FREQ_TYPE                       uint8_t
+#  define IRSND_FREQ_30_KHZ                     (IRSND_FREQ_TYPE) ((F_CPU / 30000  / 2 / Pre_Scaler / PIC_Scaler) - 1)
+#  define IRSND_FREQ_32_KHZ                     (IRSND_FREQ_TYPE) ((F_CPU / 32000  / 2 / Pre_Scaler / PIC_Scaler) - 1)
+#  define IRSND_FREQ_36_KHZ                     (IRSND_FREQ_TYPE) ((F_CPU / 36000  / 2 / Pre_Scaler / PIC_Scaler) - 1)
+#  define IRSND_FREQ_38_KHZ                     (IRSND_FREQ_TYPE) ((F_CPU / 38000  / 2 / Pre_Scaler / PIC_Scaler) - 1)
+#  define IRSND_FREQ_40_KHZ                     (IRSND_FREQ_TYPE) ((F_CPU / 40000  / 2 / Pre_Scaler / PIC_Scaler) - 1)
+#  define IRSND_FREQ_56_KHZ                     (IRSND_FREQ_TYPE) ((F_CPU / 56000  / 2 / Pre_Scaler / PIC_Scaler) - 1)
+#  define IRSND_FREQ_455_KHZ                    (IRSND_FREQ_TYPE) ((F_CPU / 455000 / 2 / Pre_Scaler / PIC_Scaler) - 1)
+#elif defined (ARM_STM32)                       // STM32
+#  define IRSND_FREQ_TYPE                       uint32_t
+#  define IRSND_FREQ_30_KHZ                     (IRSND_FREQ_TYPE) (30000)
+#  define IRSND_FREQ_32_KHZ                     (IRSND_FREQ_TYPE) (32000)
+#  define IRSND_FREQ_36_KHZ                     (IRSND_FREQ_TYPE) (36000)
+#  define IRSND_FREQ_38_KHZ                     (IRSND_FREQ_TYPE) (38000)
+#  define IRSND_FREQ_40_KHZ                     (IRSND_FREQ_TYPE) (40000)
+#  define IRSND_FREQ_56_KHZ                     (IRSND_FREQ_TYPE) (56000)
+#  define IRSND_FREQ_455_KHZ                    (IRSND_FREQ_TYPE) (455000)
+#elif defined (TEENSY_ARM_CORTEX_M4)
+#  define IRSND_FREQ_TYPE                       float
+#  define IRSND_FREQ_30_KHZ                     (IRSND_FREQ_TYPE) (30000)
+#  define IRSND_FREQ_32_KHZ                     (IRSND_FREQ_TYPE) (32000)
+#  define IRSND_FREQ_36_KHZ                     (IRSND_FREQ_TYPE) (36000)
+#  define IRSND_FREQ_38_KHZ                     (IRSND_FREQ_TYPE) (38000)
+#  define IRSND_FREQ_40_KHZ                     (IRSND_FREQ_TYPE) (40000)
+#  define IRSND_FREQ_56_KHZ                     (IRSND_FREQ_TYPE) (56000)
+#  define IRSND_FREQ_455_KHZ                    (IRSND_FREQ_TYPE) (455000)
+#else                                           // AVR
+#  if F_CPU >= 16000000L
+#    define AVR_PRESCALER                       8
+#  else
+#    define AVR_PRESCALER                       1
+#  endif
+#  define IRSND_FREQ_TYPE                       uint8_t
+#  define IRSND_FREQ_30_KHZ                     (IRSND_FREQ_TYPE) ((F_CPU / 30000 / AVR_PRESCALER / 2) - 1)
+#  define IRSND_FREQ_32_KHZ                     (IRSND_FREQ_TYPE) ((F_CPU / 32000 / AVR_PRESCALER / 2) - 1)
+#  define IRSND_FREQ_36_KHZ                     (IRSND_FREQ_TYPE) ((F_CPU / 36000 / AVR_PRESCALER / 2) - 1)
+#  define IRSND_FREQ_38_KHZ                     (IRSND_FREQ_TYPE) ((F_CPU / 38000 / AVR_PRESCALER / 2) - 1)
+#  define IRSND_FREQ_40_KHZ                     (IRSND_FREQ_TYPE) ((F_CPU / 40000 / AVR_PRESCALER / 2) - 1)
+#  define IRSND_FREQ_56_KHZ                     (IRSND_FREQ_TYPE) ((F_CPU / 56000 / AVR_PRESCALER / 2) - 1)
+#  define IRSND_FREQ_455_KHZ                    (IRSND_FREQ_TYPE) ((F_CPU / 455000 / AVR_PRESCALER / 2) - 1)
+#endif
+
 static volatile uint8_t                         irsnd_busy = 0;
 static volatile uint8_t                         irsnd_protocol = 0;
 static volatile uint8_t                         irsnd_buffer[9] = {0};
@@ -475,19 +489,22 @@
         TIM_CCxCmd(IRSND_TIMER, IRSND_TIMER_CHANNEL, TIM_CCx_Enable);      // enable OC-output (is being disabled in TIM_SelectOCxM())
         TIM_Cmd(IRSND_TIMER, ENABLE);                   // enable counter
 
+#  elif defined (TEENSY_ARM_CORTEX_M4)
+        analogWrite(IRSND_PIN, 33*255/100); // pwm 33%
+
 #  elif defined (__AVR_XMEGA__) 
-#    if (IRSND_OCx == IRSND_XMEGA_OC0A)                                 // use OC0A
-                XMEGA_Timer.CTRLB |= (1<<TC0_CCAEN_bp);                 // Compare A 
-#    elif (IRSND_OCx == IRSND_XMEGA_OC0B)                               // use OC0B
-                XMEGA_Timer.CTRLB |= (1<<TC0_CCBEN_bp);                 // Compare B 
-#    elif IRSND_OCx == IRSND_XMEGA_OC0C                                 // use OC0C
-                XMEGA_Timer.CTRLB |= (1<<TC0_CCCEN_bp);                 // Compare C
-#    elif IRSND_OCx == IRSND_XMEGA_OC0D                                 // use OC0D
-                XMEGA_Timer.CTRLB |= (1<<TC0_CCDEN_bp);                 // Compare D
-#    elif IRSND_OCx == IRSND_XMEGA_OC1A                                 // use OC1A
-                XMEGA_Timer.CTRLB |= (1<<TC1_CCAEN_bp);                 // Compare A
-#    elif IRSND_OCx == IRSND_XMEGA_OC1B                                 // use OC1B
-                XMEGA_Timer.CTRLB |= (1<<TC1_CCBEN_bp);                 // Compare B
+#    if (IRSND_OCx == IRSND_XMEGA_OC0A)                 // use OC0A
+        XMEGA_Timer.CTRLB |= (1<<TC0_CCAEN_bp);         // Compare A 
+#    elif (IRSND_OCx == IRSND_XMEGA_OC0B)               // use OC0B
+        XMEGA_Timer.CTRLB |= (1<<TC0_CCBEN_bp);         // Compare B 
+#    elif IRSND_OCx == IRSND_XMEGA_OC0C                 // use OC0C
+        XMEGA_Timer.CTRLB |= (1<<TC0_CCCEN_bp);         // Compare C
+#    elif IRSND_OCx == IRSND_XMEGA_OC0D                 // use OC0D
+        XMEGA_Timer.CTRLB |= (1<<TC0_CCDEN_bp);         // Compare D
+#    elif IRSND_OCx == IRSND_XMEGA_OC1A                 // use OC1A
+        XMEGA_Timer.CTRLB |= (1<<TC1_CCAEN_bp);         // Compare A
+#    elif IRSND_OCx == IRSND_XMEGA_OC1B                 // use OC1B
+        XMEGA_Timer.CTRLB |= (1<<TC1_CCBEN_bp);         // Compare B
 #    else
 #       error wrong value of IRSND_OCx
 #    endif // IRSND_OCx
@@ -544,6 +561,9 @@
         TIM_CCxCmd(IRSND_TIMER, IRSND_TIMER_CHANNEL, TIM_CCx_Enable);      // enable OC-output (is being disabled in TIM_SelectOCxM())
         TIM_SetCounter(IRSND_TIMER, 0);                 // reset counter value
 
+#  elif defined (TEENSY_ARM_CORTEX_M4)
+        analogWrite(IRSND_PIN, 0); // pwm off, LOW level
+
 #  elif defined (__AVR_XMEGA__)
 #    if (IRSND_OCx == IRSND_XMEGA_OC0A)                                                                                                 // use OC0A 
         XMEGA_Timer.CTRLB &= ~(1<<TC0_CCAEN_bp);                                        // Compare A disconnected
@@ -662,9 +682,13 @@
          /* Set duty cycle */
          TIM_SetCompare1(IRSND_TIMER, (freq + 1) / 2);
 
+#  elif defined (TEENSY_ARM_CORTEX_M4)
+        analogWriteResolution(8);  // 8 bit
+        analogWriteFrequency(IRSND_PIN, freq);
+        analogWrite(IRSND_PIN, 0); // pwm off, LOW level
+
 #  elif defined (__AVR_XMEGA__)
         XMEGA_Timer.CCA = freq;
-
 #  else                                                                                     // AVR
 
 #    if IRSND_OCx == IRSND_OC2
@@ -760,6 +784,10 @@
 
         irsnd_set_freq (IRSND_FREQ_36_KHZ);                                         // set default frequency
 
+#  elif defined (TEENSY_ARM_CORTEX_M4)
+        if (!digitalPinHasPWM(IRSND_PIN)) {
+          return;
+        }
 # elif defined (__AVR_XMEGA__)
         IRSND_PORT &= ~(1<<IRSND_BIT);                                              // set IRSND_BIT to low
         IRSND_DDR |= (1<<IRSND_BIT);                                                // set IRSND_BIT to output
Index: irsnd.h
===================================================================
--- irsnd.h	(revision 167)
+++ irsnd.h	(working copy)
@@ -126,6 +126,11 @@
 #define IRSND_ENDLESS_REPETITION                15      // endless repetions
 #define IRSND_REPETITION_MASK                   0x0F    // lower nibble of flags
 
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
 extern void                                     irsnd_init (void);
 extern uint8_t                                  irsnd_is_busy (void);
 extern uint8_t                                  irsnd_send_data (IRMP_DATA *, uint8_t);
@@ -136,4 +141,8 @@
 extern void                                     irsnd_set_callback_ptr (void (*cb)(uint8_t));
 #endif // IRSND_USE_CALLBACK == 1
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _IRSND_H_ */
Index: irsndconfig.h
===================================================================
--- irsndconfig.h	(revision 167)
+++ irsndconfig.h	(working copy)
@@ -149,6 +149,13 @@
 #  define IRSND_TIMER_CHANNEL_NUMBER            1                       // only channel 1 can be used at the moment, others won't work
 
 /*---------------------------------------------------------------------------------------------------------------------------------------------------
+ * Teensy 3.x with teensyduino gcc compiler
+ *---------------------------------------------------------------------------------------------------------------------------------------------------
+ */
+#elif defined (TEENSY_ARM_CORTEX_M4)
+#  define IRSND_PIN                             5                       // choose an arduino pin with pwm function!
+
+/*---------------------------------------------------------------------------------------------------------------------------------------------------
  * Other target systems
  *---------------------------------------------------------------------------------------------------------------------------------------------------
  */
