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.

Dependencies:   mbed

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.

SerialCommunication.h

Committer:
waspSalander
Date:
2017-09-05
Revision:
0:78c623c147d2

File content as of revision 0:78c623c147d2:


#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