capstone_finish
Dependencies: BufferedSerial motor_sn7544
MbedHardware.h
- Committer:
- Jeonghoon
- Date:
- 2019-11-21
- Revision:
- 9:ccd662244071
- Parent:
- 3:2a3664dc6634
- Child:
- 10:ca4e4062701a
File content as of revision 9:ccd662244071:
/* * 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 = 1843200) :iostream(tx, rx){ baud_ = baud; t.start(); } MbedHardware() :iostream(USBTX, USBRX) { baud_ = 1843200; 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_ */