From efce71d8f4c38c7bf5846fe8677e2c5455eb8ba2 Mon Sep 17 00:00:00 2001
From: Nuno Barcellos <nuno.barcellos@skywarder.eu>
Date: Sat, 4 Nov 2017 14:15:25 +0100
Subject: [PATCH] Started working with dsgamma driver

---
 sbs.conf                                      | 13 +++++
 src/entrypoints/test-dsgamma-serial.cpp       | 57 +++++++++++++++++++
 .../drivers/dsgamma-serial/dsgamma-serial.cpp |  0
 .../drivers/dsgamma-serial/dsgamma-serial.h   |  0
 4 files changed, 70 insertions(+)
 create mode 100644 src/entrypoints/test-dsgamma-serial.cpp
 create mode 100644 src/shared/drivers/dsgamma-serial/dsgamma-serial.cpp
 create mode 100644 src/shared/drivers/dsgamma-serial/dsgamma-serial.h

diff --git a/sbs.conf b/sbs.conf
index 13f75518d..c82700d1f 100644
--- a/sbs.conf
+++ b/sbs.conf
@@ -97,6 +97,11 @@ Type:       srcfiles
 Files:      src/shared/boards/AnakinBoard.cpp
             src/shared/drivers/Leds.cpp
 
+[dsgamma-serial]
+Type:       srcfiles
+Files:      src/shared/drivers/dsgamma-serial/dsgamma-serial.cpp
+
+
 # Boards 
 [discovery-canbus-test]
 Type:       board
@@ -193,3 +198,11 @@ BinName:    test-piksi
 Include:    %piksi
 Defines:   
 Main:       test-piksi
+
+[test-dsgamma-serial]
+Type:       board
+BoardId:    stm32f407vg_stm32f4discovery
+BinName:    test-dsgamma
+Include:    %dsgamma-serial
+Defines:   
+Main:       test-dsgamma-serial
\ No newline at end of file
diff --git a/src/entrypoints/test-dsgamma-serial.cpp b/src/entrypoints/test-dsgamma-serial.cpp
new file mode 100644
index 000000000..05585f766
--- /dev/null
+++ b/src/entrypoints/test-dsgamma-serial.cpp
@@ -0,0 +1,57 @@
+
+#include <cstdio>
+#include "miosix.h"
+//#include <pthread.h> 
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+
+using namespace std;
+using namespace miosix;
+
+typedef Gpio<GPIOD_BASE,12> greenLed;
+typedef Gpio<GPIOD_BASE,14> redLed;
+
+void thread1(void *arg);
+
+int main(){
+     
+    {
+        FastInterruptDisableLock dLock;
+        greenLed::mode(Mode::OUTPUT);
+        redLed::mode(Mode::OUTPUT);
+    }
+    
+    int fd = open("/dev/auxtty",O_RDWR);
+    if(fd<0) printf("Error opening serial test port\n");
+    
+    Thread *t;
+    t=Thread::create(thread1,STACK_MIN);
+    if(t==NULL) printf("Error: thread not created\n");
+    
+    for(;;){
+        greenLed::high();
+        Thread::sleep(200);
+        greenLed::low();
+        Thread::sleep(2000);
+        printf("Hey!\n");
+        
+        write(fd,"24",2);
+    }
+}
+
+void thread1(void *arg){
+    int i = 0;
+    for(;;){
+        redLed::high();
+        Thread::sleep(50);
+        redLed::low();
+        Thread::sleep(50);
+        i++;
+        if(i==4){
+            Thread::sleep(2000);
+            i = 0;
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/shared/drivers/dsgamma-serial/dsgamma-serial.cpp b/src/shared/drivers/dsgamma-serial/dsgamma-serial.cpp
new file mode 100644
index 000000000..e69de29bb
diff --git a/src/shared/drivers/dsgamma-serial/dsgamma-serial.h b/src/shared/drivers/dsgamma-serial/dsgamma-serial.h
new file mode 100644
index 000000000..e69de29bb
-- 
GitLab