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.
ros_lib_kinetic/MbedHardware.h
- Committer:
- _seminahn
- Date:
- 2021-11-30
- Revision:
- 3:a4677501ae87
- Parent:
- 0:4ff8aeb3e4d1
File content as of revision 3:a4677501ae87:
/*
* MbedHardware
*
* Created on: Aug 17, 2011
* Author: nucho
*/
#ifndef ROS_MBED_HARDWARE_H_
#define ROS_MBED_HARDWARE_H_
#include "mbed.h"
#include "BufferedSerial.h"
class MbedHardware {
public:
MbedHardware(PinName tx, PinName rx, long baud = 57600)
:iostream(tx, rx){
baud_ = baud;
t.start();
}
MbedHardware()
:iostream(USBTX, USBRX) {
baud_ = 57600;
t.start();
}
void setBaud(long baud){
this->baud_= baud;
}
int getBaud(){return baud_;}
void init(){
iostream.baud(baud_);
}
int read(){
if (iostream.readable()) {
return iostream.getc();
} else {
return -1;
}
};
void write(uint8_t* data, int length) {
for (int i=0; i<length; i++)
iostream.putc(data[i]);
}
unsigned long time(){return t.read_ms();}
protected:
BufferedSerial iostream;
long baud_;
Timer t;
};
#endif /* ROS_MBED_HARDWARE_H_ */