mirror of https://github.com/ARMmbed/mbed-os.git
37 lines
667 B
C++
37 lines
667 B
C++
#include "mbed.h"
|
|
|
|
Serial pc(USBTX, USBRX);
|
|
|
|
Serial uart(p9, p10);
|
|
|
|
DigitalOut led1(LED1);
|
|
DigitalOut led2(LED2);
|
|
|
|
// This function is called when a character goes into the RX buffer.
|
|
void rxCallback(void) {
|
|
led1 = !led1;
|
|
pc.putc(uart.getc());
|
|
}
|
|
|
|
|
|
int main() {
|
|
// Use a deliberatly slow baud to fill up the TX buffer
|
|
uart.baud(1200);
|
|
uart.attach(&rxCallback, Serial::RxIrq);
|
|
|
|
printf("Starting test loop:\n");
|
|
wait(1);
|
|
|
|
int c = 'A';
|
|
for (int loop = 0; loop < 512; loop++) {
|
|
uart.printf("%c", c);
|
|
c++;
|
|
if (c > 'Z') c = 'A';
|
|
}
|
|
|
|
while (true) {
|
|
led2 = !led2;
|
|
wait(1);
|
|
}
|
|
}
|