diff --git a/irmp-main-chibios.c b/irmp-main-chibios.c
new file mode 100644
index 0000000..06d0800
--- /dev/null
+++ b/irmp-main-chibios.c
@@ -0,0 +1,140 @@
+/*---------------------------------------------------------------------------------------------------------------------------------------------------
+ * irmp-main-chibios.c - demo main module to test IRMP decoder on ChibiOS
+ *
+ * This demo module needs to be compiled with the Makefiles and board config
+ * as provided and generated by ChibiOS
+ * 
+ * Add IRMP to your ChibiOS-Makefile like this:
+ * 
+ * IRMP_PATH = ../irmp
+ * ALLCSRC += $(IRMP_PATH)/irmp.c
+ * UDEFS += -DIRMP_CHIBIOS_HAL
+ * UINCDIR += $(IRMP_PATH)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *---------------------------------------------------------------------------------------------------------------------------------------------------
+ */
+
+#include "hal.h"
+#include "ch.h"
+#include "chprintf.h"
+
+#include "irmp.h"
+
+/*
+ * Timer definition for IRMP, using the GPT driver from ChibiOS HAL
+ */
+
+// the callback function
+static void irmp_timer_callback(GPTDriver *gptp) 
+{
+    (void)gptp;
+    (void)irmp_ISR();
+}
+
+// GPT timer configuration.
+static const GPTConfig irmp_gpt_cfg =
+{
+    F_INTERRUPTS*10,         /* timer tick frequency, a bit faster than the IRMP interrupts to improve accuracy .*/
+    irmp_timer_callback,     /* Timer callback function.*/
+    0,
+    0
+};
+
+/*
+ * IR receive thread, sends decoded IR data to a serial data stream
+ */
+
+thread_t *ir_receive_thread_p = NULL;
+
+static THD_WORKING_AREA(waIRThread, 256);
+static THD_FUNCTION(IRThread, arg)
+{
+    (void)arg;
+
+    ir_receive_thread_p = chThdGetSelfX();
+
+    // initialize the serial stream according to halconf.h
+    sdStart(&SD1, NULL);
+
+    // Welcome message
+    chprintf((BaseSequentialStream *)&SD1,"IRMP Receiver\r\nReady\r\n");
+
+    while (true)
+    {
+        IRMP_DATA   irmp_data;
+
+#if IRMP_USE_EVENT == 1
+        // the more elegant way: wait till event from irmp arrives
+
+        // wait for event sent from irmp_ISR
+        chEvtWaitAnyTimeout(ALL_EVENTS,TIME_INFINITE);
+#else
+        // the dumb way
+        chThdSleepMilliseconds(100);
+#endif
+
+        if (irmp_get_data (&irmp_data))
+        {
+            chprintf((BaseSequentialStream *)&SD1,">>IR: 0x%02x 0x%04x 0x%04x 0x%02x\r\n",
+                       irmp_data.protocol, irmp_data.address, irmp_data.command, irmp_data.flags);
+        }
+    }
+}
+
+#if defined(_CHIBIOS_NIL_)
+/*
+ * for ChibiOS/NIL:
+ * Threads static table, one entry per thread. The number of entries must
+ * match NIL_CFG_NUM_THREADS.
+ */
+THD_TABLE_BEGIN
+  THD_TABLE_ENTRY(waIRThread, "IRThread", IRThread, NULL)
+THD_TABLE_END
+#endif
+
+/*
+ * Application entry point.
+ */
+int main(void)
+{
+    /*
+    * System initializations.
+    * - HAL initialization, this also initializes the configured device drivers
+    *   and performs the board-specific initializations.
+    * - Kernel initialization, the main() function becomes a thread and the
+    *   RTOS is active.
+    */
+    halInit();
+
+    irmp_init();
+
+    chSysInit();
+
+#if defined(_CHIBIOS_RT_)
+    /*
+     * for ChibiOS/RT:
+     * Create & start the IR receive thread
+     */
+    chThdCreateStatic(waIRThread, sizeof(waIRThread), NORMALPRIO, IRThread, NULL);
+#endif
+
+    // now the system is ready: init and start the timer for IRMP
+
+    // Here we use timer 14, but you could use any other.
+    // The actual timer used must be available on the chosen hardware
+    // and activated in mcuconf.h (e.g. use #define STM32_GPT_USE_TIM14 TRUE)
+
+    gptStart(&GPTD14, &irmp_gpt_cfg);
+    gptStartContinuous(&GPTD14, 10);
+
+    /* This is now the idle thread loop, you may perform here a low priority
+        task but you must never try to sleep or wait in this loop. Note that
+        this tasks runs at the lowest priority level so any instruction added
+        here will be executed after all other tasks have been started.*/
+    while (true)
+    {    }
+}
diff --git a/irmp.c b/irmp.c
index df7d3ec..466eab4 100644
--- a/irmp.c
+++ b/irmp.c
@@ -759,6 +759,10 @@ irmp_protocol_names[IRMP_N_PROTOCOLS + 1] PROGMEM =
 #  else
 #    error USB_SERIAL not defined in ARDUINO Environment
 #  endif
+#elif defined(_CHIBIOS_HAL_)                                            // ChibiOS HAL
+#  if IRMP_EXT_LOGGING == 1
+#    error IRMP_EXT_LOGGING not implemented for ChibiOS HAL, use regular logging instead
+#  endif
 #else
 #  if IRMP_EXT_LOGGING == 1                                             // use external logging
 #    include "irmpextlog.h"
@@ -906,6 +910,9 @@ irmp_uart_init (void)
     PORTC.DIR |= (1<<7);                                                                            // TXD is output
     PORTC.DIR &= ~(1<<6);
 
+#elif defined (_CHIBIOS_HAL_)
+    // we use the SD interface for logging, no need to init that here
+
 #else
 
 #if (IRMP_EXT_LOGGING == 0)                                                                         // use UART
@@ -956,6 +963,10 @@ irmp_uart_putc (unsigned char ch)
     // we use the Arduino Serial Imlementation
     usb_serial_putchar(ch);
 
+#elif defined(_CHIBIOS_HAL_)
+    // use the SD interface from HAL, log to IRMP_LOGGING_SD which is defined in irmpconfig.h
+    sdWriteI(&IRMP_LOGGING_SD,&ch,1);      // we are called from interrupt context, so use the ...I version of the function
+
 #else
 #if (IRMP_EXT_LOGGING == 0)
 
@@ -2258,6 +2269,9 @@ irmp_init (void)
 #elif defined(__MBED__)
     gpio_init_in_ex(&gpioIRin, IRMP_PIN, IRMP_PINMODE);                 // initialize input for IR diode
 
+#elif defined(_CHIBIOS_HAL_)
+    // ChibiOS HAL automatically initializes all pins according to the board config file, no need to repeat here
+
 #else                                                                   // AVR
     IRMP_PORT &= ~(1<<IRMP_BIT);                                        // deactivate pullup
     IRMP_DDR &= ~(1<<IRMP_BIT);                                         // set pin to input
@@ -5193,6 +5207,11 @@ irmp_ISR (void)
     TimerIntClear(TIMER1_BASE, TIMER_TIMA_TIMEOUT);
 #endif
 
+#if (defined(_CHIBIOS_RT_) || defined(_CHIBIOS_NIL_)) && IRMP_USE_EVENT == 1
+    if (IRMP_EVENT_THREAD_PTR != NULL && irmp_ir_detected)
+        chEvtSignalI(IRMP_EVENT_THREAD_PTR,IRMP_EVENT_BIT);
+#endif
+
     return (irmp_ir_detected);
 }
 
diff --git a/irmp.h b/irmp.h
index ded7e80..2c3a4c1 100644
--- a/irmp.h
+++ b/irmp.h
@@ -86,6 +86,10 @@
 #elif defined(__xtensa__)
 #  define IRMP_BIT                              IRMP_BIT_NUMBER
 #  define input(x)                              GPIO_INPUT_GET(IRMP_BIT_NUMBER)
+
+#elif defined(_CHIBIOS_HAL_)
+#  define input(x)                              palReadLine(x)
+
 #endif
 
 #if IRMP_SUPPORT_TECHNICS_PROTOCOL == 1
diff --git a/irmpconfig.h b/irmpconfig.h
index aa157eb..94f8f2b 100644
--- a/irmpconfig.h
+++ b/irmpconfig.h
@@ -176,6 +176,16 @@
 #  define IRMP_PIN                              P0_22                   // use P1_27 on LPC1347
 #  define IRMP_PINMODE                          PullUp                  // hardware dependent
 
+/*---------------------------------------------------------------------------------------------------------------------------------------------------
+ * Change hardware pin here for ChibiOS HAL
+ *---------------------------------------------------------------------------------------------------------------------------------------------------
+ */
+#elif defined(_CHIBIOS_HAL_)
+#  define IRMP_PIN                              LINE_IR_IN              // use pin names as defined in the board config file, prefixed with "LINE_"
+#  define IRMP_LOGGING_SD                       SD1                     // the ChibiOS HAL Serial Driver instance to log to
+                                                                        // (when IRMP_LOGGING is enabled below). 
+                                                                        // Make sure SERIAL_BUFFERS_SIZE is large enough when enabling logging
+
 /*---------------------------------------------------------------------------------------------------------------------------------------------------
  * Handling of unknown target system: DON'T CHANGE
  *---------------------------------------------------------------------------------------------------------------------------------------------------
@@ -217,4 +227,24 @@
 #  define IRMP_USE_CALLBACK                     0       // 1: use callbacks. 0: do not. default is 0
 #endif
 
+/*---------------------------------------------------------------------------------------------------------------------------------------------------
+ * Use ChibiOS Events to signal that valid IR data was received
+ *---------------------------------------------------------------------------------------------------------------------------------------------------
+ */
+#if defined(_CHIBIOS_RT_) || defined(_CHIBIOS_NIL_)
+
+#  ifndef IRMP_USE_EVENT
+#    define IRMP_USE_EVENT                      0       // 1: use event. 0: do not. default is 0
+#  endif
+
+#  if IRMP_USE_EVENT == 1 && !defined(IRMP_EVENT_BIT)
+#    define IRMP_EVENT_BIT                      1                     // event flag or bit to send
+#  endif
+#  if IRMP_USE_EVENT == 1 && !defined(IRMP_EVENT_THREAD_PTR)
+#    define IRMP_EVENT_THREAD_PTR               ir_receive_thread_p   // pointer to the thread to send the event to
+extern thread_t *IRMP_EVENT_THREAD_PTR;                               // the pointer must be defined and initialized elsewhere
+#  endif
+
+#endif // _CHIBIOS_RT_ || _CHIBIOS_NIL_
+
 #endif // _IRMPCONFIG_H_
diff --git a/irmpsystem.h b/irmpsystem.h
index 0321538..c301019 100644
--- a/irmpsystem.h
+++ b/irmpsystem.h
@@ -65,6 +65,8 @@
 #elif defined(__MBED__)                                                             // mbed platform
 // #include "mbed.h"                                                                // if mbed.h is used, source must be compiled as cpp
 #include "gpio_api.h"
+#elif defined(IRMP_CHIBIOS_HAL)                                                     // ChibiOS HAL
+#  include "hal.h"
 #else
 #  define ATMEL_AVR                                                                 // ATMEL AVR
 #endif
