* ECHO communication between Bluetooth and RS232 * Using mBED Landtiger Card
Fork of HC05_Transparent_mode by
Revision 4:c68d2d96da42, committed 2016-03-12
- Comitter:
- alex_G_blanco
- Date:
- Sat Mar 12 01:12:36 2016 +0000
- Parent:
- 3:8783bfb5d8fa
- Commit message:
- * ECHO communication between Bluetooth and RS232; * Using mBED Landtiger Card
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Aug 15 12:18:04 2014 +0000 +++ b/main.cpp Sat Mar 12 01:12:36 2016 +0000 @@ -1,47 +1,55 @@ /* + * ECHO communication between Bluetooth and RS232 + * Using mBED Landtiger Card + * Based on HC05 work by: * Author: Edoardo De Marchi * Date: 11-08-14 * Notes: HC05 Trasparent Mode */ +//mBED Complete libraries #include "mbed.h" - -Serial pc(USBTX, USBRX); +//Serial Pin port configurations +//pc - RS232 serial port, blue - bluetootk serial port + Serial pc(P0_10, P0_11); //tx, rx pins for the Landtiger, use COM2 UART2 connector direct from the card + Serial blue(P0_2, P0_3); // UART0_TX, UART0_RX for the LandTiger. Connect a BT module to these pins -#if defined(TARGET_LPC1768) -Serial blue(p9, p10); // TX, RX -//Serial blue(p13, p14); // TX, RX -#elif defined(TARGET_LPC4330_M4) -Serial blue(P6_4, P6_5); // UART0_TX, UART0_RX -//Serial blue(P2_3, P2_4); // UART3_TX, UART3_RX -#endif +//Define activity leds for RS232 and BT + DigitalOut myled4(P2_7);//landtiger LEDS LD4, LD5 + DigitalOut myled5(P2_6); + BusOut LEDS(P2_5, P2_4, P2_3, P2_2, P2_1, P2_0); //landtiger all leds +int temp; -DigitalOut myled(LED1); -DigitalOut myled4(LED4); - - +//Main routine int main() { - - blue.baud(115200); - pc.baud(115200); + //Serial ports initialization + blue.baud(9600); + pc.baud(9600); pc.printf("Bluetooth Start\r\n"); + blue.printf("Communication Start \r\n\0"); + LEDS = 0; //turn off other leds // echo back characters and toggle the LED while (1) { if (blue.readable()) { - pc.putc(blue.getc()); - myled = !myled; + temp = blue.getc(); //reads BT one character + pc.putc(temp); // puts character in serial + blue.putc(temp); //echo BT + myled4 = !myled4; //Led BT activity } if (pc.readable()) { - blue.putc(pc.getc()); - myled4 = !myled4; + temp = pc.getc(); //reads RS232 one character + blue.putc(temp); //puts character thru BT + pc.putc(temp); // echo serial + blue.printf("\0"); //null character to empty BT buffer + myled5 = !myled5; // RS232 activity led } } -} \ No newline at end of file +}