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: SDFileSystem mbed
Fork of PES4_Programme by
Diff: source/main.cpp
- Revision:
- 71:3d0a4dbff536
- Parent:
- 70:cc7ed2325202
- Child:
- 76:53a25f1dc2b6
--- a/source/main.cpp Fri Apr 06 06:47:53 2018 +0000 +++ b/source/main.cpp Fri Apr 06 06:55:36 2018 +0000 @@ -14,32 +14,6 @@ DigitalIn glasDetection(PA_10); PwmOut summer(PC_8); -// Circular buffers for serial TX and RX data - used by interrupt routines -const int buffer_size = 255; -// might need to increase buffer size for high baud rates -char tx_buffer[buffer_size+1]; -char rx_buffer[buffer_size+1]; -// Circular buffer pointers -// volatile makes read-modify-write atomic -volatile int tx_in=0; -volatile int tx_out=0; -volatile int rx_in=0; -volatile int rx_out=0; -// Line buffers for sprintf and sscanf -char tx_line[80]; -char rx_line[80]; - -int i=0; -int rx_i=0; - -// Setup a serial interrupt function to receive data -pc.attach(&Rx_interrupt, Serial::RxIrq); -// Setup a serial interrupt function to transmit data -pc.attach(&Tx_interrupt, Serial::TxIrq); - - - - /* PWM Test Tool */ int channel; int dutyCycle; @@ -85,38 +59,6 @@ break; case 10: - // Formatted IO test using send and receive serial interrupts - // with sprintf and sscanf - while (1) { - // Loop to generate different test values - send value in hex, decimal, and octal and then read back - for (i=0; i<0xFFFF; i++) { - // Print ASCII number to tx line buffer in hex - sprintf(tx_line,"%x\r\n",i); - // Copy tx line buffer to large tx buffer for tx interrupt routine - send_line(); - // Print ASCII number to tx line buffer in decimal - sprintf(tx_line,"%d\r\n",i); - // Copy tx line buffer to large tx buffer for tx interrupt routine - send_line(); - // Print ASCII number to tx line buffer in octal - sprintf(tx_line,"%o\r\n",i); - // Copy tx line buffer to large tx buffer for tx interrupt routine - send_line(); - - // Read a line from the large rx buffer from rx interrupt routine - read_line(); - // Read ASCII number from rx line buffer - sscanf(rx_line,"%x",&rx_i); - // Read a line from the large rx buffer from rx interrupt routine - read_line(); - // Read ASCII number from rx line buffer - sscanf(rx_line,"%d",&rx_i); - // Read a line from the large rx buffer from rx interrupt routine - read_line(); - // Read ASCII number from rx line buffer - sscanf(rx_line,"%o",&rx_i); - } - } break;