When debugging code it can be handy to examine/alter variables and to check the state of input lines. So your main program can run and you have access to alter variables and run functions from a terminal. In this sample the main program is just a loop that flashes an LED. In that loop a periodic call is made to ShellTC which handles any commands from the serial terminal. The code is a bit quirky(it was originally written for a very resource limited device) but it works well enough to be useful, hence its published. More details in the main.cpp

Dependencies:   mbed

.

Files at this revision

API Documentation at this revision

Comitter:
jont
Date:
Fri Feb 06 09:46:44 2015 +0000
Parent:
3:6a35fb789679
Commit message:
Tweaked for GU Projects

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
sio.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Feb 04 21:07:52 2015 +0000
+++ b/main.cpp	Fri Feb 06 09:46:44 2015 +0000
@@ -15,6 +15,8 @@
  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
+ 
+ 
 #include "mbed.h"
 #include "shell.h"
 #include "mon.h"
--- a/sio.cpp	Wed Feb 04 21:07:52 2015 +0000
+++ b/sio.cpp	Fri Feb 06 09:46:44 2015 +0000
@@ -18,7 +18,7 @@
 /*
 sio handler august 96
 */
-//(c)jont@ninelocks.com 1992-2012
+//(c)jont@ninelocks.com 1992-2015
 #include "string.h"
 #include <stdio.h>
 #include <ctype.h>
@@ -63,16 +63,8 @@
 char theChar = 0x00; //used to be a char...
 //h8    theChar = SIO_RDR;        /* get received character */
 theChar = pc.getc();
-//theChar = LPC_UART0->RBR; //oct2012 expereiment
-//
-//see this for reg names http://mbed.org/users/4180_1/notebook/cc-io-register-names/
- //do {
- //           } while ((LPC_UART0->LSR & 0x20)==0) ;
-//write character to UART
-   //         LPC_UART0->THR = theChar ;
-
-    //theChar = RCREG;    //PIC
-   // theChar = 0x42;    //TODO2k12 this needs to be whats read from sio RXREG
+pc.putc(theChar);
+ 
     /* if an Xoff was received from
     remote term telling us to stop...
     in which case if anything other than an xon is receievd
@@ -127,15 +119,15 @@
 {
 
 //see http://mbed.org/forum/mbed/topic/3414/?page=1#comment-17231
-   while (pc.readable() == 1){
-  // jtdebug();
+   while (pc.readable()){
+ 
      sioGetSingle();
-     uint32_t UART_0_RBR = LPC_UART0->RBR;  
+    
     
   }
   //http://mbed.org/forum/mbed/topic/408/?page=1#comment-2221
  // pc.putc(0x00);
  
- uint32_t UART_0_RBR = LPC_UART0->RBR;  
+// uint32_t UART_0_RBR = LPC_UART0->RBR;  
     
 }