Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 2:21b2552c3724, committed 2014-11-27
- 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
diff -r 958d1da2df76 -r 21b2552c3724 BaudSerial/BaudSerial.cpp
--- /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
diff -r 958d1da2df76 -r 21b2552c3724 BaudSerial/BaudSerial.h
--- /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
diff -r 958d1da2df76 -r 21b2552c3724 main.cpp
--- 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) {