test serial baud rate

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
joshchen
Date:
Thu Nov 27 07:23:10 2014 +0000
Parent:
1:958d1da2df76
Commit message:
create library - BaudSerial to make easy to set serial baudrate

Changed in this revision

BaudSerial/BaudSerial.cpp Show annotated file Show diff for this revision Revisions of this file
BaudSerial/BaudSerial.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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BaudSerial/BaudSerial.cpp	Thu Nov 27 07:23:10 2014 +0000
@@ -0,0 +1,7 @@
+#include "BaudSerial.h"
+
+BaudSerial::BaudSerial(int baudrate, PinName tx, PinName rx, const char* name)
+  : Serial(tx,rx,name)
+{
+    this->baud(baudrate);
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BaudSerial/BaudSerial.h	Thu Nov 27 07:23:10 2014 +0000
@@ -0,0 +1,11 @@
+#ifndef __BaudSerial_H
+#define __BaudSerial_H
+
+#include "mbed.h"
+
+class BaudSerial : public mbed::Serial {
+  public:
+    BaudSerial(int baudrate, PinName tx, PinName rx, const char* name=NULL);  
+};
+
+#endif //__BaudSerial_H
\ No newline at end of file
--- a/main.cpp	Mon Nov 24 07:07:58 2014 +0000
+++ b/main.cpp	Thu Nov 27 07:23:10 2014 +0000
@@ -1,10 +1,10 @@
-#include "mbed.h"
+#include "BaudSerial.h"
 
-Serial pc(SERIAL_TX, SERIAL_RX);
+BaudSerial pc(115200, SERIAL_TX, SERIAL_RX);
 DigitalOut myled(LED2);
 
 int main() {
-    pc.baud(921600);    
+    //pc.baud(921600);    
     pc.printf("Hello World !\n");
     int i=0;
     while(1) {