
In the mbed documentation LPC1768 there are many examples of serial communication implemented in a structured and disorganized way. So, I decided to make it very practical and reusable for other users who need to use this feature. For this, I created my own library based on the OO paradigm.
In the mbed documentation LPC1768 there are many examples of serial communication implemented in a structured and disorganized way. So, I decided to make it very practical and reusable for other users who need to use this feature. For this, I created my own library based on the OO paradigm.
Diff: SerialCommunication.h
- Revision:
- 0:78c623c147d2
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SerialCommunication.h Tue Sep 05 22:36:20 2017 +0000 @@ -0,0 +1,41 @@ + +#ifndef SERIAL_COMMUNICATION_H +#define SERIAL_COMMUNICATION_H + +#include "mbed.h" +#include <string.h> +#include <string> +#include <iostream> + + +#define DELAY_COMMAND 0.5 +#define DEBUG_SERIAL_COMUNNICATION 1 + +using namespace std; + + +class SerialCommunication{ + + public: + SerialCommunication(PinName tx, PinName rx, int baudRate); + + int ReceiveCommand(); + void SendCommand(string commandSended); + + + private: + Serial *serial; + + DigitalOut tx; + DigitalOut rx; + DigitalOut *debug; + + int baudRate; + int messageLength; + +}; + +#endif + + +