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.
Dependents: projecte_v4_rtos ProjecteRobotFinal
Revision 0:ab6e0939a63f, committed 2015-12-19
- Comitter:
- jcabello7
- Date:
- Sat Dec 19 01:09:28 2015 +0000
- Commit message:
- Programa final, fent servir les llibreries RTOS, amb les llibreries RawSerialPc i Hc05 separades per facilitar la modificaci? del programa. Comprovat que funciona.
Changed in this revision
| RawSerialPc.cpp | Show annotated file Show diff for this revision Revisions of this file |
| RawSerialPc.h | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/RawSerialPc.cpp Sat Dec 19 01:09:28 2015 +0000
@@ -0,0 +1,31 @@
+#include "RawSerialPc.h"
+#include "mbed.h"
+
+
+ RawSerialPc::RawSerialPc(PinName tx, PinName rx) : RawSerial(tx, rx){
+ baud(115200);
+ };
+
+ void RawSerialPc::enviaString(char* str){
+ int i = 0;
+ while((i < longString) && (str[i] != '\0')) {
+ putc(str[i]);
+ i++;
+ }
+ putc(10);
+ };
+
+ bool RawSerialPc::llegirString(char* str){
+ if(readable()){
+ int i= 0;
+ str[i] = getc();
+ while((i < longString) && (str[i] != 13)) {
+ if (str[i] != '@')
+ i++;
+ str[i] = getc();
+ }
+ str[i] = '\0';
+ return true;
+ }
+ return false;
+ };
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/RawSerialPc.h Sat Dec 19 01:09:28 2015 +0000
@@ -0,0 +1,16 @@
+#ifndef MBED_RAWSERIALPC_H
+#define MBED_RAWSERIALPC_H
+
+#include "mbed.h"
+
+#define longString 128 //Longitud màxima del string a enviar
+
+class RawSerialPc : public RawSerial {
+ public:
+ RawSerialPc(PinName tx, PinName rx);
+ void enviaString(char* str);
+ bool llegirString(char* str);
+ };
+
+
+#endif
\ No newline at end of file