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: Bf_SoftSerial_IR
Revision 0:4350de08a6de, committed 2020-05-15
- Comitter:
- kenjiArai
- Date:
- Fri May 15 04:15:57 2020 +0000
- Commit message:
- Test program for Infrared SoftSerial using Infrared LED & IR Detector.
Changed in this revision
diff -r 000000000000 -r 4350de08a6de Bf_SoftSerial_IR.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Bf_SoftSerial_IR.lib Fri May 15 04:15:57 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/kenjiArai/code/Bf_SoftSerial_IR/#f3f6c1bc3bd6
diff -r 000000000000 -r 4350de08a6de check_revision.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/check_revision.cpp Fri May 15 04:15:57 2020 +0000 @@ -0,0 +1,31 @@ +/* + * Check Mbed revision + * + * Copyright (c) 2019,'20 Kenji Arai / JH1PJL + * http://www7b.biglobe.ne.jp/~kenjia/ + * https://os.mbed.com/users/kenjiArai/ + * Created: July 17th, 2019 + * Revised: May 2nd, 2020 + */ + +#include "mbed.h" + +// RUN ONLY ON mbed-os-5.15.3 +// https://github.com/ARMmbed/mbed-os/releases/tag/mbed-os-5.15.3 +#if (MBED_MAJOR_VERSION == 5) &&\ + (MBED_MINOR_VERSION == 15) &&\ + (MBED_PATCH_VERSION == 3) +#elif (MBED_MAJOR_VERSION == 2) &&\ + (MBED_MINOR_VERSION == 0) &&\ + (MBED_PATCH_VERSION == 165) +#else + //#warning "Please use mbed-os-5.15.3" + #error "Please use mbed-os-5.15.3" +#endif + +void print_revision(void) +{ + printf("MBED_MAJOR_VERSION = %d, ", MBED_MAJOR_VERSION); + printf("MINOR = %d, ", MBED_MINOR_VERSION); + printf("PATCH = %d\r\n", MBED_PATCH_VERSION); +}
diff -r 000000000000 -r 4350de08a6de main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri May 15 04:15:57 2020 +0000 @@ -0,0 +1,64 @@ +/* + * Mbed Application program + * IR TX & RX test program + * + * Copyright (c) 2020 Kenji Arai / JH1PJL + * http://www7b.biglobe.ne.jp/~kenjia/ + * https://os.mbed.com/users/kenjiArai/ + * Created: May 15th, 2020 + * Revised: May 15th, 2020 + */ + +// Include -------------------------------------------------------------------- +#include "mbed.h" +#include "Bf_SoftSerial_IR.h" + +// Object --------------------------------------------------------------------- +DigitalOut myled(LED1); +DigitalOut test_point(A5); +RawSerial pc(USBTX, USBRX); +Bf_SoftSerial_IR ir_trx(PB_2, PA_14); + +// RAM ------------------------------------------------------------------------ +CircularBuffer<char, 1024> pc_rxbuf; // PC receiving Buffer + +// ROM / Constant data -------------------------------------------------------- + +// Function prototypes -------------------------------------------------------- +static void pc_rx_handler(void); + +//------------------------------------------------------------------------------ +// Control Program +//------------------------------------------------------------------------------ +int main() +{ + char c; + + pc.attach(&pc_rx_handler, Serial::RxIrq); + pc.printf("\r\nStart UART test program\r\n"); + while(true){ + //pc.printf("line:%d\r\n", __LINE__); + if (!pc_rxbuf.empty()){ + pc_rxbuf.pop(c); + ir_trx.putc(c); + } + if (ir_trx.readable()){ + c = ir_trx.getc(); + if ((c == '\r') || (c == '\n')){ + pc.putc('\r'); + pc.putc('\n'); + } else if (c == 0xff){ + ; // no action -> Noise!! + } else { + pc.putc(c); + } + } + } +} + +static void pc_rx_handler(void) +{ + while(pc.readable()) { + pc_rxbuf.push(pc.getc()); + } +}
diff -r 000000000000 -r 4350de08a6de mbed-os.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Fri May 15 04:15:57 2020 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#b6370b4c37f3d4665ed1cdcb1afea85396bba1b3