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.
Dependencies: BufferedSerial USBDevice mbed
Fork of USB2UART by
main.cpp
- Committer:
- yihui
- Date:
- 2013-10-30
- Revision:
- 0:8c4eea221dcf
- Child:
- 1:efa9f62a12c4
File content as of revision 0:8c4eea221dcf:
/**
* USB to UART Bridge
*/
#include "mbed.h"
#include "USBSerial.h"
Serial uart(USBTX, USBRX);
USBSerial pc;
// Called by ISR
void settingsChanged(int baud, int bits, int parity, int stop)
{
const Serial::Parity parityTable[] = {Serial::None, Serial::Odd, Serial::Even, Serial::Forced0, Serial::Forced1};
if (stop != 2) {
stop = 1; // stop bit(s) = 1 or 1.5
}
uart.baud(baud);
uart.format(bits, parityTable[parity], stop);
}
int main()
{
pc.attach(settingsChanged);
while (1) {
while (uart.readable()) {
pc.putc(uart.getc());
}
while (pc.readable()) {
uart.putc(pc.getc());
}
}
}
