DALI TX BACKWARDS

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
wikarapg
Date:
Sat Jan 16 16:15:49 2021 +0000
Commit message:
Design

Changed in this revision

dalidemo.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
manchester_packets.h 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dalidemo.h	Sat Jan 16 16:15:49 2021 +0000
@@ -0,0 +1,10 @@
+// DALI DEMO LIBRARY
+// WIKARA GUNAWAN 
+
+
+#ifndef DALI_DRIVER_H
+#define DALI_DRIVER_H
+
+#include "manchester/encoder.h"
+#include "mbed.h"
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Jan 16 16:15:49 2021 +0000
@@ -0,0 +1,69 @@
+// Backward FRAME Code to debug
+
+#include "mbed.h"
+
+#define BROADCAST   0x00
+#define OFF         0x01
+#define ON          0x02
+
+#define TE 834/2 //Halftime of The Transmitted BIT
+
+DigitalOut myled(LED1);
+DigitalOut dali(D7);
+DigitalOut dali_tx(D8);
+
+
+int man_packets[20];
+int address;
+int command;
+int packet_fin;
+
+//How To initialise the interrupt
+
+void dali_packet(int address, int command){
+    int i;
+    int ones;
+    //Start Bits 1
+    man_packets[0] = 1;
+    man_packets[1] = 0;
+    man_packets[2] = 1;
+    //Stop Bits
+    
+    for(i=0; i<8; i++){
+        //For Address Conversion
+        ones = address >> 7 - i;   //Shift the bit to the left   
+        ones &= 0x01;
+        if(ones == 1){
+            man_packets[(i*2)+3] = 0;
+            man_packets[(i*2)+4] = 1;
+        } else {
+            man_packets[(i*2)+3] = 1;
+            man_packets[(i*2)+4] = 0;
+        }
+        
+    man_packets[19] = 1;           //This is only a workaround solution
+    }
+}
+
+
+int main() {
+    while(1) {
+        int i;
+        dali = 1; 
+        
+        int value;
+        printf("Enter an integer: ");
+        scanf("%d", &value); 
+
+        dali_packet(value, value+20);   //Process packets
+        
+        for(i=0; i<20; i++){
+            dali =  man_packets[i];
+            dali_tx = man_packets[i];
+            wait_us(416);
+            }
+        dali = 1;
+        dali_tx = 1;
+        packet_fin = 1;   
+        }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/manchester_packets.h	Sat Jan 16 16:15:49 2021 +0000
@@ -0,0 +1,5 @@
+#ifndef MANPACKETS
+#define MANPACKETS
+
+#include "mbed.h"
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Jan 16 16:15:49 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file