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
MotorController.h
00001 #include "mbed.h" 00002 00003 #ifndef MOTOR_CONTROLLER_H 00004 #define MOTOR_CONTROLLER_H 00005 00006 #define BAUD_RATE 115200 00007 #define PIN_TX p9 00008 #define PIN_RX p10 00009 #define ENTER 0x0D 00010 00011 Serial mc(PIN_TX, PIN_RX); // tx, rx 00012 00013 void Rx_interruptMC(); 00014 char temp_rx[80]; 00015 00016 int initMotorController() 00017 { 00018 mc.baud(BAUD_RATE); 00019 00020 // Setup a serial interrupt function to receive data 00021 mc.attach(&Rx_interruptMC, Serial::RxIrq); 00022 00023 return 0; 00024 } 00025 00026 void Rx_interruptMC() 00027 { 00028 //led2 = 1; 00029 bool lineEnd = true; 00030 char raw_rx[80]; 00031 int i = 0; 00032 00033 while (lineEnd) 00034 { 00035 raw_rx[i] = mc.getc(); 00036 if ((int)raw_rx[i] == ENTER) 00037 { 00038 lineEnd = false; 00039 } 00040 i++; 00041 led3 = lineEnd; 00042 } 00043 00044 //Here now the Values of the MC in the current Value 00045 sprintf(temp_rx,raw_rx); 00046 //led2 = 0; 00047 } 00048 void writeLine(char *line) 00049 { 00050 mc.printf("%s\r\n",line); 00051 } 00052 00053 void writeWord(char *word) 00054 { 00055 mc.printf("%s",word); 00056 } 00057 00058 void startStatusWriting() 00059 { 00060 writeLine("status_start"); 00061 } 00062 00063 void endStatusWriting() 00064 { 00065 writeLine("status_end"); 00066 } 00067 00068 00069 #endif
Generated on Thu Jul 14 2022 00:29:41 by
1.7.2