Test program for SoftSerial. TimerEvent function has bug for STM32 series Mbed. FRDM-64K works well without bug. This is a temporary solution avoid bug but not perfect.

Dependencies:   BufferedSoftSerial

Committer:
kenjiArai
Date:
Sun May 10 08:15:36 2020 +0000
Revision:
0:98865e300cd5
Tset program for SoftSerial library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kenjiArai 0:98865e300cd5 1 /*
kenjiArai 0:98865e300cd5 2 * Mbed Application program
kenjiArai 0:98865e300cd5 3 * SoftSerial(also BufferedSoftSerial) function test programs
kenjiArai 0:98865e300cd5 4 * UART 3 channels
kenjiArai 0:98865e300cd5 5 * (1) Mbed Serial communication line as "pc"
kenjiArai 0:98865e300cd5 6 * (2) CPU another UART channel as "ser"
kenjiArai 0:98865e300cd5 7 * (3) Software Serial channel as "dev"
kenjiArai 0:98865e300cd5 8 *
kenjiArai 0:98865e300cd5 9 * Copyright (c) 2020 Kenji Arai / JH1PJL
kenjiArai 0:98865e300cd5 10 * http://www7b.biglobe.ne.jp/~kenjia/
kenjiArai 0:98865e300cd5 11 * https://os.mbed.com/users/kenjiArai/
kenjiArai 0:98865e300cd5 12 * Created: May 9th, 2020
kenjiArai 0:98865e300cd5 13 * Revised: May 10th, 2020
kenjiArai 0:98865e300cd5 14 */
kenjiArai 0:98865e300cd5 15
kenjiArai 0:98865e300cd5 16 /*
kenjiArai 0:98865e300cd5 17 Tested board on OS5.15.3
kenjiArai 0:98865e300cd5 18 Nucleo-F446RE, Nucleo-L432KC
kenjiArai 0:98865e300cd5 19 */
kenjiArai 0:98865e300cd5 20
kenjiArai 0:98865e300cd5 21 // Pre-selection --------------------------------------------------------------
kenjiArai 0:98865e300cd5 22 #include "select_example.h"
kenjiArai 0:98865e300cd5 23 //#define EXAMPLE_0
kenjiArai 0:98865e300cd5 24 #ifdef EXAMPLE_0
kenjiArai 0:98865e300cd5 25 #warning "Select 0"
kenjiArai 0:98865e300cd5 26
kenjiArai 0:98865e300cd5 27 // Include --------------------------------------------------------------------
kenjiArai 0:98865e300cd5 28 #include "mbed.h"
kenjiArai 0:98865e300cd5 29 #include "BufferedSoftSerial.h"
kenjiArai 0:98865e300cd5 30
kenjiArai 0:98865e300cd5 31 // Definition -----------------------------------------------------------------
kenjiArai 0:98865e300cd5 32 #define BEFFERED 1
kenjiArai 0:98865e300cd5 33
kenjiArai 0:98865e300cd5 34 // Constructor ----------------------------------------------------------------
kenjiArai 0:98865e300cd5 35 #if defined(TARGET_NUCLEO_L432KC)
kenjiArai 0:98865e300cd5 36 DigitalOut test_point(D12);
kenjiArai 0:98865e300cd5 37 Serial ser(D5, D4, 9600);
kenjiArai 0:98865e300cd5 38 # if BEFFERED
kenjiArai 0:98865e300cd5 39 BufferedSoftSerial dev(D6,D3);
kenjiArai 0:98865e300cd5 40 # else
kenjiArai 0:98865e300cd5 41 SoftSerial dev(D6,D3);
kenjiArai 0:98865e300cd5 42 # endif
kenjiArai 0:98865e300cd5 43 #elif defined(TARGET_NUCLEO_F446RE)
kenjiArai 0:98865e300cd5 44 DigitalOut test_point(A0);
kenjiArai 0:98865e300cd5 45 Serial ser(D8, D2, 9600);
kenjiArai 0:98865e300cd5 46 # if BEFFERED
kenjiArai 0:98865e300cd5 47 BufferedSoftSerial dev(D4,D3);
kenjiArai 0:98865e300cd5 48 # else
kenjiArai 0:98865e300cd5 49 SoftSerial dev(D4,D3);
kenjiArai 0:98865e300cd5 50 # endif
kenjiArai 0:98865e300cd5 51 #endif
kenjiArai 0:98865e300cd5 52 Serial pc(USBTX,USBRX, 9600);
kenjiArai 0:98865e300cd5 53
kenjiArai 0:98865e300cd5 54 // RAM ------------------------------------------------------------------------
kenjiArai 0:98865e300cd5 55
kenjiArai 0:98865e300cd5 56 // ROM / Constant data --------------------------------------------------------
kenjiArai 0:98865e300cd5 57
kenjiArai 0:98865e300cd5 58 // Function prototypes --------------------------------------------------------
kenjiArai 0:98865e300cd5 59
kenjiArai 0:98865e300cd5 60 //------------------------------------------------------------------------------
kenjiArai 0:98865e300cd5 61 // Control Program
kenjiArai 0:98865e300cd5 62 //------------------------------------------------------------------------------
kenjiArai 0:98865e300cd5 63 /*
kenjiArai 0:98865e300cd5 64 UART 3 channels
kenjiArai 0:98865e300cd5 65 (1) Mbed Serial communication line as "pc"
kenjiArai 0:98865e300cd5 66 (2) CPU another UART channel as "ser"
kenjiArai 0:98865e300cd5 67 (3) Software Serial channel as "dev"
kenjiArai 0:98865e300cd5 68 */
kenjiArai 0:98865e300cd5 69 int main()
kenjiArai 0:98865e300cd5 70 {
kenjiArai 0:98865e300cd5 71 int count = 0;
kenjiArai 0:98865e300cd5 72 while(true) {
kenjiArai 0:98865e300cd5 73 for (uint32_t i = '!'; i < '~'; i++) {
kenjiArai 0:98865e300cd5 74 dev.putc(i); // output to softserial
kenjiArai 0:98865e300cd5 75 ser.putc(i); // output to another UART
kenjiArai 0:98865e300cd5 76 pc.putc(i); // output to PC
kenjiArai 0:98865e300cd5 77 }
kenjiArai 0:98865e300cd5 78 dev.puts("----> ABCDEFGHIJKLMOPQRSTUVWXYZ0123456789");
kenjiArai 0:98865e300cd5 79 ser.puts("----> ABCDEFGHIJKLMOPQRSTUVWXYZ0123456789");
kenjiArai 0:98865e300cd5 80 pc.puts( "----> ABCDEFGHIJKLMOPQRSTUVWXYZ0123456789");
kenjiArai 0:98865e300cd5 81 dev.printf("--------->%4d\r\n", count);
kenjiArai 0:98865e300cd5 82 ser.printf("--------->%4d\r\n", count);
kenjiArai 0:98865e300cd5 83 pc.printf( "--------->%4d\r\n", count++);
kenjiArai 0:98865e300cd5 84 }
kenjiArai 0:98865e300cd5 85 }
kenjiArai 0:98865e300cd5 86
kenjiArai 0:98865e300cd5 87 #endif //#ifdef EXAMPLE_0