Preliminary main mbed library for nexpaq development

Committer:
nexpaq
Date:
Fri Nov 04 20:27:58 2016 +0000
Revision:
0:6c56fb4bc5f0
Moving to library for sharing updates

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nexpaq 0:6c56fb4bc5f0 1 #include "mbed.h"
nexpaq 0:6c56fb4bc5f0 2
nexpaq 0:6c56fb4bc5f0 3 DigitalOut led1(LED1);
nexpaq 0:6c56fb4bc5f0 4 DigitalOut led2(LED2);
nexpaq 0:6c56fb4bc5f0 5
nexpaq 0:6c56fb4bc5f0 6 Serial computer(USBTX, USBRX);
nexpaq 0:6c56fb4bc5f0 7
nexpaq 0:6c56fb4bc5f0 8 // This function is called when a character goes into the TX buffer.
nexpaq 0:6c56fb4bc5f0 9 void txCallback() {
nexpaq 0:6c56fb4bc5f0 10 led1 = !led1;
nexpaq 0:6c56fb4bc5f0 11 }
nexpaq 0:6c56fb4bc5f0 12
nexpaq 0:6c56fb4bc5f0 13 // This function is called when a character goes into the RX buffer.
nexpaq 0:6c56fb4bc5f0 14 void rxCallback() {
nexpaq 0:6c56fb4bc5f0 15 led2 = !led2;
nexpaq 0:6c56fb4bc5f0 16 computer.putc(computer.getc());
nexpaq 0:6c56fb4bc5f0 17 }
nexpaq 0:6c56fb4bc5f0 18
nexpaq 0:6c56fb4bc5f0 19 int main() {
nexpaq 0:6c56fb4bc5f0 20 printf("start test\n");
nexpaq 0:6c56fb4bc5f0 21 computer.attach(&txCallback, Serial::TxIrq);
nexpaq 0:6c56fb4bc5f0 22 computer.attach(&rxCallback, Serial::RxIrq);
nexpaq 0:6c56fb4bc5f0 23 while (true) {
nexpaq 0:6c56fb4bc5f0 24 wait(1);
nexpaq 0:6c56fb4bc5f0 25 }
nexpaq 0:6c56fb4bc5f0 26 }