Sean Stanko / Mbed 2 deprecated PPM_Out

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
ststanko
Date:
Sat Oct 18 03:57:42 2014 +0000
Commit message:
PPM output v1

Changed in this revision

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
transmitter.c Show annotated file Show diff for this revision Revisions of this file
transmitter.h Show annotated file Show diff for this revision Revisions of this file
usb.cpp Show annotated file Show diff for this revision Revisions of this file
usb.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Oct 18 03:57:42 2014 +0000
@@ -0,0 +1,55 @@
+#include "mbed.h"
+#include "usb.h"
+
+//------------------------------------
+// Hyperterminal configuration
+// 9600 bauds, 8-bit data, no parity
+//------------------------------------
+
+
+#define PULSE_WIDTH 1000
+#define ONE_DELAY   10000
+#define ZERO_DELAY  40000
+
+DigitalOut myled(LED1);
+DigitalOut outpin(D15);
+void transmit_bit(char c) {
+    int i;
+    for (i = 0; i < 8; i++) {
+        myled = 1;
+        outpin = 1;
+        wait_us(PULSE_WIDTH);
+        myled = 0;
+        outpin = 0;
+        if (c & 0x1) {
+            wait_us(ONE_DELAY);
+        } else {
+            wait_us(ZERO_DELAY);
+        }
+        c >>= 1;
+    }
+}
+
+void transmit(char * data, unsigned int size) {
+    int i;
+    for (i = 0; i < size; i++) {
+        transmit_bit(data[i]);
+    }
+}
+
+int main() {
+  myled = 1;
+  outpin = 1;
+  int i = 0;
+  usb_write("Hello World !\n");
+  while(1) {
+      myled = 1;
+      outpin = 1;
+      i = 0;
+      wait(1);
+      char * str = "This program is alive \n";
+      usb_write(str);
+      transmit("Hello", 5);
+  }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Oct 18 03:57:42 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/552587b429a1
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/transmitter.c	Sat Oct 18 03:57:42 2014 +0000
@@ -0,0 +1,29 @@
+#include "transmitter.h"
+
+#define PULSE_WIDTH 1000
+#define ONE_DELAY   10000
+#define ZERO_DELAY  40000
+
+
+/*
+void transmit_bit(char c) {
+    int i;
+    for (i = 0; i < 8; i++) {
+        myled = 1;
+        wait_us(PULSE_WIDTH);
+        myled = 0;
+        if (c & 0x1) {
+            wait_us(ONE_DELAY);
+        } else {
+            wait_us(ZERO_DELAY);
+        }
+        c >>= 1;
+    }
+}
+
+void transmit(char * data, unsigned int size) {
+    int i;
+    for (i = 0; i < size; i++) {
+        transmit_bit(data[i]);
+    }
+}*/
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/transmitter.h	Sat Oct 18 03:57:42 2014 +0000
@@ -0,0 +1,7 @@
+#ifndef transmitter_h
+#define transmitter_h
+
+void transmit_bit(char c);
+void transmit(char * data, unsigned int size);
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usb.cpp	Sat Oct 18 03:57:42 2014 +0000
@@ -0,0 +1,8 @@
+#include "mbed.h"
+#include "usb.h"
+
+Serial pc(SERIAL_TX, SERIAL_RX);
+
+void usb_write(char * text) {
+    pc.printf(text);
+    }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usb.h	Sat Oct 18 03:57:42 2014 +0000
@@ -0,0 +1,7 @@
+#ifndef usb_h
+#define usb_h
+
+char * usb_read();
+void usb_write(char * text);
+
+#endif
\ No newline at end of file