example code IRBlaster

Dependencies:   mbed

Greenchips IR Blaster gives the easiest way to use various IR format and it is being tested and supported on mbed platform. It supports remote control format as followings.

  • NEC
  • NEC with Simple Repeat
  • Toshia
  • Toshiba with Simple Repeat,
  • Philips-RC5
  • Sony(12bits)
  • Sony(15bits)
  • Sony(20bits)
  • Misubish
  • JVC

Files at this revision

API Documentation at this revision

Comitter:
DavidJoo
Date:
Thu Sep 11 01:29:42 2014 +0000
Commit message:
IRBlaster Initial code

Changed in this revision

IR_Blaster.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 7896055e7ec5 IR_Blaster.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/IR_Blaster.h	Thu Sep 11 01:29:42 2014 +0000
@@ -0,0 +1,52 @@
+/**
+ * IR Blaster driver
+ * 
+ * please see Dream-IV User manual for more detail information.
+ *
+ ****/
+
+/*
+ * UART Packet Structure
+    
+    ------------------------------------------------
+    | SOP | Payload Size | Command | Payload | EOP |
+    | (1) |     (1)      |   (1)   | (0~128) | (1) |
+    ------------------------------------------------
+*/
+ 
+#define SOP 0xFE   //start of frame
+#define EOP 0xEF   //end of frame
+ 
+#define COMMAND_GET_VERSION     0x00
+#define COMMAND_START_IROUT     0x01
+#define COMMAND_STOP_IROUT      0x02
+
+// Response Command = 0x80 | Command
+/*  -----------------------------------------------------------
+    | SOP | Payload Size | 0x80 | Command | Payload   |   EOP |
+    | 0xFE|     1byte    |   (1)          | (reponse) |  0xEF |
+    -----------------------------------------------------------
+*/
+
+#define RSP_ACK     0x00
+#define RSP_INVALID_PACKET      0x10
+#define RSP_INVALID_COMMAND     0x10
+#define RSP_INVALID_FORMATID    0x10
+
+// Format Types
+#define NEC         0x01
+#define NEC_SR      0x02  //NEC simple repeate
+#define TOSHIBA     0x03
+#define TOSHIBA_SR  0x04 // Toshiba simple repeate
+#define PHILIPS_RC5 0x05
+#define SONY_12BITS 0x06
+#define SONY_15BITS 0x07
+#define SONY_20BITS 0x08
+#define MISUBISHI   0x09
+#define JVC         0x0A
+
+
+
+
+
+
diff -r 000000000000 -r 7896055e7ec5 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Sep 11 01:29:42 2014 +0000
@@ -0,0 +1,69 @@
+#include "mbed.h"
+#include "IR_Blaster.h"
+
+Serial pc(SERIAL_TX, SERIAL_RX);
+Serial IrBlaster(PA_9, PA_10);
+
+#define MAX_BUF_SIZE 12
+#define PAYLOAD_LEN  8
+
+char IrTxBuffer[MAX_BUF_SIZE] = {0,};
+
+/*
+ * UART Packet Structure
+    
+    ------------------------------------------------
+    | SOP | Payload Size | Command | Payload | EOP |
+    | (1) |     (1)      |   (1)   | (0~128) | (1) |
+    ------------------------------------------------
+ *
+ */
+
+// Sample UART data structure when user data is "0x6A"
+// NEC custom code : 0x04,0xFB
+char NEC_SR_Sample[12] =    {0xFE,0x8,0x1, 0x01,0x04,0xFB,0x00,0x00,0x6A,0x00,0x00, 0xEF};
+char NEC_Sample[12]    =    {0xFE,0x8,0x1, 0x02,0x04,0xFB,0x00,0x00,0x6A,0x00,0x00, 0xEF};
+// TOSHIBA custom code : 0x07, 0x07
+char TOSHIBA_Sample[12]=    {0xFE,0x8,0x1, 0x03,0x07,0x07,0x00,0x00,0x6A,0x00,0x00, 0xEF};
+char TOSHIBA_SR_Sample[12]= {0xFE,0x8,0x1, 0x04,0x07,0x07,0x00,0x00,0x6A,0x00,0x00, 0xEF};
+// PHILIPS System code : 0x15    
+char PHILIPS_RC5_Sample[12]={0xFE,0x8,0x1, 0x05,0x15,0x00,0x00,0x00,0x6A,0x00,0x00, 0xEF};     
+// SONY custom code : 0x12
+char SONY_12BITS_Sample[12]={0xFE,0x8,0x1, 0x06,0x12,0x00,0x00,0x00,0x6A,0x00,0x00, 0xEF};     
+char SONY_16BITS_Sample[12]={0xFE,0x8,0x1, 0x07,0x42,0x00,0x00,0x00,0x6A,0x00,0x00, 0xEF};     
+char SONY_20BITS_Sample[12]={0xFE,0x8,0x1, 0x08,0x34,0x00,0x00,0x00,0x6A,0x00,0x00, 0xEF};     
+char MISUBISHI_Sample[12]=  {0xFE,0x8,0x1, 0x09,0x12,0x00,0x00,0x00,0x6A,0x00,0x00, 0xEF};   
+char JVC_Sample[12]=        {0xFE,0x8,0x1, 0x0A,0x12,0x00,0x00,0x00,0x6A,0x00,0x00, 0xEF}; 
+
+
+DigitalOut myled(LED1);
+ 
+int main() {
+  int i = 1;
+  int j = 0;
+  
+  pc.baud(115200);
+  IrBlaster.baud(115200);
+  IrBlaster.format(8, Serial::None, 1);
+
+  IrBlaster.printf("Hello World !\n");
+  while(1)
+  {
+    wait(2);
+    //Send IR data through UART to IR Blaster 
+    IrTxBuffer[0]  = SOP;
+    IrTxBuffer[1]  = PAYLOAD_LEN;
+    IrTxBuffer[2]  = COMMAND_START_IROUT;
+    IrTxBuffer[3]  = NEC;
+    IrTxBuffer[4]  = 0x04;
+    IrTxBuffer[5]  = 0xFB;
+    IrTxBuffer[8]  = 0x6A;
+    IrTxBuffer[11] = EOP;
+    for(j=0; j<12; j++)
+        IrBlaster.putc(IrTxBuffer[j]);
+    pc.printf("This program runs since %d seconds.\n", i++);
+    myled = !myled;
+   }
+
+}
+ 
\ No newline at end of file
diff -r 000000000000 -r 7896055e7ec5 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Sep 11 01:29:42 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/ed8466a608b4
\ No newline at end of file