Wim Huiskamp
/
SC16IS750_Test
Testsoftware for SC16IS750
Diff: main.cpp
- Revision:
- 3:3d4269319b51
- Parent:
- 2:8aba07490dce
- Child:
- 4:c75ddfd44ae3
--- a/main.cpp Thu Feb 13 17:12:12 2014 +0000 +++ b/main.cpp Thu Feb 20 19:45:33 2014 +0000 @@ -72,18 +72,18 @@ pc.printf("0: Exit\n\r"); pc.printf("1: Show Menu\n\r"); pc.printf("2: Init\n\r"); - pc.printf("3: IO Out\n\r"); - pc.printf("4: Echo Text\n\r"); + pc.printf("3: IO Port Out\n\r"); + pc.printf("4: Transparant mode\n\r"); pc.printf("5: Free bufferspace\n\r"); pc.printf("6: Enable RTS/CTS\n\r"); pc.printf("7: Disable RTS/CTS\n\r"); - pc.printf("8: Write block\n\r"); + pc.printf("8: Write block\n\r"); + pc.printf("9: Baudrate 9600\n\r"); + pc.printf("A: Baudrate 115200\n\r"); + pc.printf("B: Transparant mode with bufferdisplay\n\r"); + pc.printf("C: Test printf \n\r"); - #if(0) - pc.printf("9: \n\r"); - pc.printf("A: \n\r"); - pc.printf("B: \n\r"); - pc.printf("C: \n\r"); + #if(0) pc.printf("D: \n\r"); pc.printf("P: \n\r"); #endif @@ -170,7 +170,7 @@ break; case '3' : - pc.printf("IO Out\n\r"); + pc.printf("IO Port Out\n\r"); i=0; while (!pc.readable()) { @@ -182,11 +182,11 @@ } pc.getc(); - pc.printf("IO Out Done\n\r"); + pc.printf("IO Port Out Done\n\r"); break; case '4' : - pc.printf("Echo Text, Enter '$' to quit...\n\r"); + pc.printf("Transparant Mode, Enter '#' to quit...\n\r"); running_test=true; @@ -194,20 +194,20 @@ // From SPI/I2C to serial while (running_test && pc.readable()) { ch = pc.getc(); - running_test = (ch != '$'); + running_test = (ch != '#'); serial_bridge.putc(ch); } // From Serial to SPI/I2C while (running_test && serial_bridge.readable()) { ch = serial_bridge.getc(); - running_test = (ch != '$'); + running_test = (ch != '#'); pc.putc(ch); } } - pc.printf("\n\rEcho Text Done\n\r"); + pc.printf("\n\rTransparant Mode done\n\r"); break; case '5' : @@ -226,9 +226,58 @@ case '8' : pc.printf("Write block\n\r"); - serial_bridge.write("Hello World from mbed and SC16IS750 "); + serial_bridge.writeString("Hello World from mbed and SC16IS750 "); + break; + + case '9' : + pc.printf("Baudrate = 9600, Divisor = %d\n\r", SC16IS750_BAUDRATE_DIVISOR(9600)); + serial_bridge.baud(9600); + break; + + case 'A' : + pc.printf("Baudrate = 115200, Divisor = %d\n\r", SC16IS750_BAUDRATE_DIVISOR(115200)); + serial_bridge.baud(115200); break; + case 'B' : + pc.printf("Transparant Mode with buffer display, Enter '#' to quit...\n\r"); + + running_test=true; + + while (running_test) { + // From SPI/I2C to serial + while (running_test && pc.readable()) { + ch = pc.getc(); + running_test = (ch != '#'); + serial_bridge.putc(ch); + + // Show buffers when character was entered + pc.printf("\n\r"); + pc.printf("Available for Reading = %3d (Free Space = %3d)\n\r", serial_bridge.readableCount(), SC16IS750_FIFO_RX - serial_bridge.readableCount()); + pc.printf("Available for Writing = %3d (Used Space = %3d)\n\r", serial_bridge.writableCount(), SC16IS750_FIFO_TX - serial_bridge.writableCount()); + } + + + // From Serial to SPI/I2C + while (running_test && serial_bridge.readable()) { + ch = serial_bridge.getc(); + running_test = (ch != '#'); + pc.putc(ch); + } + + } + + pc.printf("\n\rTransparant Mode done\n\r"); + break; + + case 'C' : + pc.printf("Test printf() \n\r"); + + serial_bridge.printf("Available for Reading = %3d (Free Space = %3d)\n\r", serial_bridge.readableCount(), SC16IS750_FIFO_RX - serial_bridge.readableCount() ); + serial_bridge.printf("Available for Writing = %3d (Used Space = %3d)\n\r", serial_bridge.writableCount(), SC16IS750_FIFO_TX - serial_bridge.writableCount()); + + pc.printf("\n\rTest printf() done\n\r"); + break; default : break;