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.
Fork of rosserial_mbed_lib by
MbedHardware.h
- Committer:
- nucho
- Date:
- 2011-10-16
- Revision:
- 1:ff0ec969dad1
- Parent:
- 0:77afd7560544
- Child:
- 3:1cf99502f396
File content as of revision 1:ff0ec969dad1:
/* * MbedHardware * * Created on: Aug 17, 2011 * Author: nucho */ #ifndef MBEDHARDWARE_H_ #define MBEDHARDWARE_H_ #include"mbed.h" #include"MODSERIAL.h" class MbedHardware { public: MbedHardware(MODSERIAL* io , int baud= 57600) :iostream(*io){ baud_ = baud; t.start(); } MbedHardware() :iostream(USBTX, USBRX) { baud_ = 57600; t.start(); } MbedHardware(MbedHardware& h) :iostream(h.iostream) { this->baud_ = h.baud_; t.start(); } void setBaud(int 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: int baud_; MODSERIAL iostream; Timer t; }; #endif /* MBEDHARDWARE_H_ */