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.
Dependencies: Break Motor Communication Steering mbed Controller
Diff: SerialCommunication/MbedToPC.h
- Revision:
- 1:2538cbbea1f8
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/SerialCommunication/MbedToPC.h Thu Jul 13 13:45:55 2017 +0000
@@ -0,0 +1,69 @@
+#include "mbed.h"
+
+#ifndef MOTOR_CONTROLLER_H
+#define MOTOR_CONTROLLER_H
+
+#define BAUD_RATE 115200
+#define PIN_TX p9
+#define PIN_RX p10
+#define ENTER 0x0D
+
+Serial mPC(PIN_TX, PIN_RX); // tx, rx
+
+void Rx_interrupt();
+char temp_rx[80];
+
+int initMotorController()
+{
+ mPC.baud(BAUD_RATE);
+
+ // Setup a serial interrupt function to receive data
+ mPC.attach(&Rx_interrupt, Serial::RxIrq);
+
+ return 0;
+}
+
+void Rx_interruptMPC()
+{
+ // led2 = 1;
+ bool lineEnd = true;
+ char raw_rx[80];
+ int i = 0;
+
+ while (lineEnd)
+ {
+ raw_rx[i] = mc.getc();
+ if ((int)raw_rx[i] == 13)
+ {
+ lineEnd = false;
+ }
+ i++;
+ led3 = lineEnd;
+ }
+
+ //Here now the Values of the MC in the current Value
+ //sprintf(temp_rx,raw_rx);
+ //led2 = 0;
+}
+void writeLine(char *line)
+{
+ mc.printf("%s\r\n",line);
+}
+
+void writeWord(char *word)
+{
+ mc.printf("%s",word);
+}
+
+void startStatusWriting()
+{
+ writeLine("status_start");
+}
+
+void endStatusWriting()
+{
+ writeLine("status_end");
+}
+
+
+#endif
\ No newline at end of file