Browse Source

switch to real time

Meichel Cyrille 10 years ago
parent
commit
b44bba4c27
3 changed files with 26 additions and 12 deletions
  1. 1 1
      emit/emit.c
  2. 17 5
      emit/home_easy.c
  3. 8 6
      emit/home_easy.h

+ 1 - 1
emit/emit.c

@@ -123,7 +123,7 @@ int main(int argc, char** argv)
 
     initIO();
     sendHomeEasyCommand(idString, section, number, onOff, repeat);
-
+    closeIO();
 
     destroyByteBuffer(command);
     destroyByteBuffer(encoded);

+ 17 - 5
emit/home_easy.c

@@ -8,9 +8,11 @@
 #include "utils.h"
 
 unsigned int timings[5][2] = {
-    {275, 275},  //  bit 0
-    {275, 1300}, //  bit 1
-    {275, 9900},  //  end of data
+    {310, 310},  // bit 0
+    {310, 1340}, // bit 1
+    //{275, 275},  //  bit 0
+    //{275, 1300}, //  bit 1
+    {275, 9900},  //  start of data
     {275, 2675}, //  start of frame
     {275, 2675},  //  end of data
 };
@@ -198,12 +200,21 @@ int initIO()
         printf("Setting up GPIO\n");
         pinMode(homeEasyPinIn, INPUT);
         pinMode(homeEasyPinOut, OUTPUT);
+        scheduler_realtime();
     } else {
         printf("GPIO setup failed %d\n", status);
     }
     return status;
 }
 
+/**
+ * Return to normal mode
+ */
+void closeIO()
+{
+    scheduler_standard();
+}
+
 /**
  * Send a bit to the RF transmitter
  * 
@@ -211,10 +222,11 @@ int initIO()
  */
 void sendHomeEasyBit(unsigned char bit)
 {
-    digitalWrite(homeEasyPinOut, HIGH_RF);
+    digitalWrite(homeEasyPinOut, HIGH);
     delayMicroseconds(timings[bit][0]);
-    digitalWrite(homeEasyPinOut, LOW_RF);
+    digitalWrite(homeEasyPinOut, LOW);
     delayMicroseconds(timings[bit][1]);
+    digitalWrite(homeEasyPinOut, HIGH);
 }
 
 /**

+ 8 - 6
emit/home_easy.h

@@ -6,16 +6,13 @@
 
 #define BIT0 0
 #define BIT1 1
-#define TRIGGER0 2
-#define TRIGGER1 3
-#define END_OF_FRAME 3
+#define START_OF_DATA 2
+#define START_OF_FRAME 3
+#define END_OF_FRAME 4
 
 #define ON 1
 #define OFF 0
 
-#define HIGH_RF 1
-#define LOW_RF 0
-
 /**
  * Encode bits with HomeEasy encoding (1 => 10, 0 => 01)
  * 
@@ -87,6 +84,11 @@ void setHomeEasyTransmittorPin(unsigned char pinNumber);
  */
 int initIO();
 
+/**
+ * Return to normal mode
+ */
+void closeIO();
+
 /**
  * read the GPIO output pin
  *