Libraries and Example of mbed parallel bus using I2C port expanders

Dependencies:   HDSP253X mbed PCF8574_Bus

Files at this revision

API Documentation at this revision

Comitter:
wim
Date:
Sun Jan 25 17:30:47 2015 +0000
Parent:
5:38b853bb1afa
Child:
7:8680b8b718c8
Commit message:
Converted code for HDSP253X into Lib.

Changed in this revision

BusDefines.h Show annotated file Show diff for this revision Revisions of this file
ChangeLog.h Show diff for this revision Revisions of this file
HDSP253X.lib Show annotated file Show diff for this revision Revisions of this file
HDSP253X_Display.cpp Show diff for this revision Revisions of this file
HDSP253X_Display.h Show diff for this revision Revisions of this file
Host_Coms.cpp Show diff for this revision Revisions of this file
Host_Coms.h Show diff for this revision Revisions of this file
Keyboard.cpp Show diff for this revision Revisions of this file
Keyboard.h Show diff for this revision Revisions of this file
MBED_ControlBus.cpp Show annotated file Show diff for this revision Revisions of this file
MBED_ControlBus.h Show annotated file Show diff for this revision Revisions of this file
PinDetect.h Show diff for this revision Revisions of this file
STANAG_Codes.cpp Show diff for this revision Revisions of this file
STANAG_Codes.h Show diff for this revision Revisions of this file
Status_Display.cpp Show diff for this revision Revisions of this file
Status_Display.h Show diff for this revision Revisions of this file
Testloop.h Show diff for this revision Revisions of this file
Utils.h Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
mbed.lib Show diff for this revision Revisions of this file
--- a/BusDefines.h	Fri Aug 26 20:35:11 2011 +0000
+++ b/BusDefines.h	Sun Jan 25 17:30:47 2015 +0000
@@ -10,7 +10,6 @@
 
 
 //Pin Defines for MBED Control Bus (inputs)
-#define D_FIRE                 p19
 #define D_CDINT                p20
 //Pin Defines for MBED Control Bus (outputs)
 #define D_DTR                  p21
--- a/ChangeLog.h	Fri Aug 26 20:35:11 2011 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-/* LF28A Simulator - ChangeLog
- * Copyright (c) 2011 Wim Huiskamp
- *
- * Released under the MIT License: http://mbed.org/license/mit
- *
- * version 0.2 Initial Release
-*/
-/*  0.2        Jun 2011 - Testversion
-
-    0.1     23 Mar 2011 - Initial release.
-
-*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HDSP253X.lib	Sun Jan 25 17:30:47 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/wim/code/HDSP253X/#b3430a613781
--- a/HDSP253X_Display.cpp	Fri Aug 26 20:35:11 2011 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,741 +0,0 @@
-/* HDSP253X_Display - Intelligent 8 digit 5x7 LED matrix display
- *
- * Copyright (c) 2011 Wim Huiskamp
- * Modified software based on sourcecode by RAC 06/08/2008
- *
- * Released under the MIT License: http://mbed.org/license/mit
- *
- * version 0.2 Initial Release
-*/
-#include "mbed.h"
-//#include "Utils.h"
-#include "PCF8574_DataBus.h"
-#include "PCF8574_AddressBus.h"
-#include "PCF8574_EnableBus.h"
-#include "MBED_ControlBus.h"
-#include "HDSP253X_Display.h"
-
-/** Create an HDSP253X_Display object connected to the proper busses
- *
- * @param  PCF8574_DataBus data databus to connect to 
- * @param  PCF8574_AddressBus address addressbus to connect to 
- * @param  PCF8574_EnableBus enable enablebus to connect to 
- * @param  MBED_ControlBus control controlbus to connect to 
-*/
-HDSP253X_Display::HDSP253X_Display (PCF8574_DataBus &databus, PCF8574_AddressBus &addressbus, PCF8574_EnableBus &enablebus, MBED_ControlBus &controlbus) : 
-                                     _databus(databus), _addressbus(addressbus), _enablebus(enablebus), _controlbus(controlbus) {
-
-   _init();
-}    
-
-/** Init HDSP253X_Display
- * @param
- * @returns 
- */
-void HDSP253X_Display::_init(void)
-{
-    // Apply reset
-    reset();  // Note that this also resets the LED status display. 
- 
-    // Note: Brightness is 100% after reset
-    set_brightness(HDSP253X_DEF_DISPLAY_BRIGHT);
- 
-    // Reset cursor 
-    locate(0);
-}
-
-
-/*****************************************************************************/
-/*******************  LOW LEVEL HDSP253X SUPPORT FUNCTIONS  ******************/
-/*****************************************************************************/
-
-/*---------------------------------------------------------------------------*\
- |
- |  Function:       HDSP253X_reset
- |
- |  Description:    Reset routine for HDSP253X display, applying reset, 
- |                  removing reset, then waiting for preset delay.
- |                  With the internal clock, the delay should be around 1
- |                  millisecond, but slower clocks will require longer delays.
- |                  After reset the Char RAM and Flash RAM is cleared, the CTRL word is
- |                  cleared (Blink Off, Flash Off, Brightness 100%). UDC RAM and address
- |                  are unaffected.
- |
- |  Parameters:     None
- |
- |  Returns:        Nothing.
- |
-\*---------------------------------------------------------------------------*/
-void HDSP253X_Display::reset(void)
-{
-//NOTE: On LF28A the Reset* pin is connected to the display and to the latches.
-//      That implies they are all reset when the Reset* pin is used !
-// 
-// Alternative for the Display may be SW reset instruction
-
-    // Apply the reset condition and then remove after short delay
-    _enablebus.chipselect(CS_DISP, HIGH);  
-    wait_ms(HDSP253X_1TCY_WAIT_MS);
-    
-    _enablebus.reset(LOW);   
-    wait_ms(HDSP253X_1TCY_WAIT_MS);    
-    wait_ms(HDSP253X_1TCY_WAIT_MS);        
-    _enablebus.reset(HIGH);             
-    
-    // Wait for the preset delay to allow operation to complete
-    wait_ms(HDSP253X_RST_CLR_DELAY_MS);
-    
-    // Reset cursor 
-    locate(0);
-}
-
-
-/*---------------------------------------------------------------------------*\
- |
- |  Function:       HDSP253X_write
- |
- |  Description:    Low level data write routine for HDSP253X. Takes in data
- |                  and address (including Flash as top bit) and writes
- |                  it to the display. For simplicity, entire address byte
- |                  is written, even though top two bits are unused inputs.
- |                  After performing the operation, address lines are set
- |                  all high, in order to eliminate current drain through
- |                  pullup resistors (0.5mA per pin with 10K pullups)
- |
- |  Parameters:     address - full address in bits 0-5 (bit 5 is flash)
- |                  data - data byte to write out
- |
- |  Returns:        Nothing.
- |
-\*---------------------------------------------------------------------------*/
-
-void HDSP253X_Display::_write(uint8_t address, uint8_t data)
-{
-//    // Switch databus buffer to outputs
-//    _controlbus.busdir(WRITE);        
-//    // Switch databus to outputs
-//    _databus.busdir(WRITE);   
-
-    
-    // Write out the address on to the addressbus and wait
-    _addressbus.write(address);
-    wait_ms(HDSP253X_1TCY_WAIT_MS);
-
-    // Set CE low and wait
-    _enablebus.chipselect(CS_DISP, LOW);  
-    wait_ms(HDSP253X_1TCY_WAIT_MS);
-
-    // Write data to the databus
-    _databus.write(data);        
-    wait_ms(HDSP253X_1TCY_WAIT_MS);
-     
-    // Set WR low, wait, then set high and wait
-    _controlbus.WR(LOW);
-    wait_ms(HDSP253X_1TCY_WAIT_MS);
-    _controlbus.WR(HIGH);
-    wait_ms(HDSP253X_1TCY_WAIT_MS);
-
-    // Set CE high and wait
-    _enablebus.chipselect(CS_DISP, HIGH);  
-    wait_ms(HDSP253X_1TCY_WAIT_MS);
-    
-//    // Switch databus back to inputs
-//    _databus.busdir(READ);        
-//    // Switch databus buffer back to inputs
-//    _controlbus.busdir(READ);  
-
-//    // Set address lines all high to minimise power through pullups
-//    _addressbus.write(HDSP253X_ADDR_LOW_POWER);
-}
-
-/*---------------------------------------------------------------------------*\
- |
- |  Function:       HDSP253X_read
- |
- |  Description:    Low level data read routine for HDSP253X. Takes in 
- |                  address (including Flash as top bit) and reads data
- |                  from the display. For simplicity, entire address byte
- |                  is written, even though top two bits are unused inputs.
- |                  After performing the operation, address lines are set
- |                  all high, in order to eliminate current drain through
- |                  pullup resistors (0.5mA per pin with 10K pullups)
- |
- |  Parameters:     address - full address in bits 0-5 (bit 5 is flash)
- |
- |  Returns:        data - data byte read in (Note that D7 is masked out)
- |
-\*---------------------------------------------------------------------------*/
-
-uint8_t HDSP253X_Display::_read(uint8_t address)
-{
-    uint8_t data = 0;
-
-    // Switch databus to inputs
-    _databus.busdir(READ);        
-    // Switch databus buffer to inputs
-    _controlbus.busdir(READ);      
-       
-    // Write out the address on to the addressbus and wait
-    _addressbus.write(address);
-    wait_ms(HDSP253X_1TCY_WAIT_MS);
-
-    // Set CE low and wait
-    _enablebus.chipselect(CS_DISP, LOW);
-    wait_ms(HDSP253X_1TCY_WAIT_MS);
-
-    // Set RD low and wait
-    _controlbus.RD(LOW);
-    wait_ms(HDSP253X_1TCY_WAIT_MS);
-    
-    // Read the data byte from databus
-    // Mask out the not-readable D7 bit, this mask is needed for my specific targetboard !
-    // Reading the unconnected D7 bit results in 'H' level. A RMW cycle on the Ctrl register
-    // would then always result in a Clearscreen !
-    data = _databus.read() & HDSP253X_CTRL_MASK;
-
-    // set RD high and wait
-    _controlbus.RD(HIGH);
-    wait_ms(HDSP253X_1TCY_WAIT_MS);
-
-    // Set CE high and wait
-    _enablebus.chipselect(CS_DISP, HIGH);
-    wait_ms(HDSP253X_1TCY_WAIT_MS);
-
-//    // Set address lines all high to minimise power through pullups
-//    _addressbus.write(HDSP253X_ADDR_LOW_POWER);
-
-    // Switch databus buffer back to outputs
-    _controlbus.busdir(WRITE);        
-    // Switch databus to outputs
-    _databus.busdir(WRITE);   
-    
-    // Return read data to caller
-    return data;
-}
-
-
-/*****************************************************************************/
-/**************  HIGH LEVEL HDSP253X CHARACTER DISPLAY FUNCTIONS  ************/
-/*****************************************************************************/
-
-#if(0)
-/*---------------------------------------------------------------------------*\
- |
- |  Function:       HDSP253X_display_ascii_char
- |
- |  Description:    Displays specified character on the display at specified
- |                  position.
- |
- |  Parameters:     disp_char - single character display
- |                  char_pos - position on the display (0 to 7, Leftmost = 0)
- |
- |  Returns:        Nothing
- |
-\*---------------------------------------------------------------------------*/
-
-void HDSP253X_Display::_display_ascii_char(char ascii_char, char char_pos)
-{
-    // Write selected character to display at wrapped position
-    char_pos %= HDSP253X_NUM_CHARS;
-    ascii_char &= HDSP253X_CHAR_MASK;        // mask off unused bits
-    _write(HDSP253X_ADDR_CHAR_BASE + char_pos, ascii_char);
-}
-
-/*---------------------------------------------------------------------------*\
- |
- |  Function:       HDSP253X_display_udc_char
- |
- |  Description:    Displays specified UDC character on the display at specified
- |                  position. Used defined characters use codes from 128-142.
- |                  Note that the normal write routines can be used
- |                  to set UDCs, using ASCII values 128 to 143 inclusive.
- |
- |  Parameters:     udc_char - UDC character, 15 possible UDC values from 128-142
- |                  char_pos - position on the display (0 to 7, Leftmost = 0)
- |
- |  Returns:        Nothing
- |
-\*---------------------------------------------------------------------------*/
-
-void HDSP253X_Display::_display_udc_char(char udc_char, char char_pos)
-{
-    // Write selected UDC character to display at wrapped position
-    char_pos %= HDSP253X_NUM_CHARS;
-    udc_char &= HDSP253X_UDC_MASK;        // mask off unused bits
-    udc_char |= HDSP253X_UDC_SEL;         // add in top bit to specify UDC
-    _write(HDSP253X_ADDR_CHAR_BASE + char_pos, udc_char);
-}
-
-
-/*---------------------------------------------------------------------------*\
- |
- |  Function:       HDSP253X_display_part_string
- |
- |  Description:    Displays specified string on the display, starting
- |                  from specified position, up to end position or end of
- |                  string, whichever is less. NOTE this function must
- |                  NOT be used with read-only strings in program memory.
- |
- |  Parameters:     disp_string - character string to display
- |                  start_pos - starting position on the display (0 to 7)
- |                  end_pos - end position on the display (0 to 7)
- |
- |  Returns:        Nothing
- |
-\*---------------------------------------------------------------------------*/
-
-void HDSP253X_Display::_display_part_string(const char *disp_string, uint8_t start_pos, uint8_t end_pos)
-{
-    int i;
-    int string_len;
-
-    // loop round from start pos, writing characters until end reached
-    string_len = strlen(disp_string);   // obtain length of string
-    for (i = start_pos; (i < HDSP253X_NUM_CHARS) && ((i - start_pos) < string_len) && (i <= end_pos); i++)
-    {
-      // write selected character to display at selected position
-      _write(HDSP253X_ADDR_CHAR_BASE + i, disp_string[i - start_pos]);
-    }
-}
-
-/*---------------------------------------------------------------------------*\
- |
- |  Function:       HDSP253X_display_fixed_string
- |
- |  Description:    Displays specified fixed string on the display, starting
- |            from first character and filling in with spaces until specified
- |            starting position. If string is shorter than remaining display,
- |            extra characters will be filled with spaces. If string is longer,
- |            remaining characters will not be displayed. NOTE this function 
- |            must NOT be used with read-only strings in program memory.
- |
- |  Parameters:     disp_string - fixed character string to display
- |                  start_pos - starting position on the display (0 to 7)
- |
- |  Returns:        Nothing
- |
-\*---------------------------------------------------------------------------*/
-
-void HDSP253X_Display::_display_fixed_string(const char *disp_string, uint8_t start_pos)
-{
-    int i;
-    int string_len;
-    uint8_t char_value;
-
-    // loop round, writing characters or spaces to whole display from start
-    string_len = strlen(disp_string);   // obtain length of string
-    for (i = 0; i < HDSP253X_NUM_CHARS; i++) {
-      // work out whether to display a character or space
-      if ((i < start_pos) || ((i - start_pos) >= string_len)) {
-        // out of string range, so select space character
-        char_value = ' ';
-      }
-      else {
-        // within string, so select string character
-        char_value = disp_string[i - start_pos];
-      }
-
-      // write selected character to display at selected position
-      _write(HDSP253X_ADDR_CHAR_BASE + i, char_value);
-    }
-}
-#endif
-
-/*---------------------------------------------------------------------------*\
- |
- |  Function:       HDSP253X_printf
- |
- |  Description:    Displays specified string on the display at current
- |                  cursor position. Increments cursor.
- |
- |  Parameters:     format - format string
- |                  args   - data
- |
- |  Returns:        Nothing
- |
-\*---------------------------------------------------------------------------*/
-
-void HDSP253X_Display::printf (char * format, ...) {
-   char display_string[64];
-   int rv, string_len, i;   
-   va_list args;
-   va_start (args, format);
-
-   rv=vsprintf (display_string, format, args);
-   va_end (args);   
-// printf("printing:'%s'\n", display_string);
-//   writeString (buffer);
-
-   // loop round, writing characters
-   string_len = strlen(display_string);   // obtain length of string
-   for (i = 0; i < string_len; i++) {
-     putc(display_string[i]);
-   };
-
-   // return rv;
-}
-
-
-
-/*---------------------------------------------------------------------------*\
- |
- |  Function:       HDSP253X_putc
- |
- |  Description:    Displays specified character on the display at current
- |                  cursor position. Increments cursor.
- |                  Position on the display (0 to 7, Leftmost = 0)
- |
- |  Parameters:     disp_char - single character to display
- |                    - ASCII characters, 128 values between 0-127
- |                    - UDC character, 15 possible UDC values from 128-142
- |
- |  Returns:        Nothing
- |
-\*---------------------------------------------------------------------------*/
-void HDSP253X_Display::putc(char disp_char) {
-
-    // Write selected character to display at current position
-   
-    if ((disp_char & HDSP253X_UDC_SEL) == HDSP253X_UDC_SEL) {      
-        // Write UDC character to display, code between 128-143
-        disp_char &= HDSP253X_UDC_MASK;        // mask off unused bits
-        disp_char |= HDSP253X_UDC_SEL;         // add in top bit to specify UDC        
-        _write(HDSP253X_ADDR_CHAR_BASE + _column, disp_char);
-    }
-    else {
-        // Write ASCII character, code between 0-127
-        disp_char &= HDSP253X_CHAR_MASK;        // mask off unused bits
-        _write(HDSP253X_ADDR_CHAR_BASE + _column, disp_char);        
-    }
-    
-    // Incr and wrap around cursorposition
-    _column++; 
-    _column = _column % HDSP253X_NUM_CHARS;    
-}
-
-
-#if(0)
-//Testversion
-void HDSP253X_Display::putc(char disp_char) {
-
-    // Write ASCII character, code between 0-127
-    _write(HDSP253X_ADDR_CHAR_BASE + _column, disp_char);        
-   
-    // Incr and wrap around cursorposition
-    _column++;
-    if (_column==HDSP253X_NUM_CHARS) _column=0;        
-}
-#endif
-
-
-
-#if(0)
-char HDSP253X_Display::getc() {
-  return -1;
-}
-#endif
-
-/*---------------------------------------------------------------------------*\
- |
- |  Function:       HDSP253X_locate
- |
- |  Description:    Set the cursor address where the next character will be written. 
- |
- |  Parameters:     Cursor Column address
- |
- |  Returns:        Nothing
- |
-\*---------------------------------------------------------------------------*/
-
-void HDSP253X_Display::locate(uint8_t column) {
-
-//    _row = row % HDSP253X_NUM_ROWS;
-    _column = column % HDSP253X_NUM_CHARS;
-}
-
-
-/*---------------------------------------------------------------------------*\
- |
- |  Function:       HDSP253X_cls
- |
- |  Description:    Clears the displayed data and flash RAM, but not the user
- |                  defined characters. Waits for the preset delay to ensure the 
- |                  display is ready for operation; with an internal clock,
- |                  this delay needs to be around 1 millisecond. 
- |
- |  Parameters:     None
- |
- |  Returns:        Nothing
- |
-\*---------------------------------------------------------------------------*/
-
-void HDSP253X_Display::cls(void) {
-
-    uint8_t disp_data;
-
-    // Read in control word, modify and write back out
-    disp_data = _read(HDSP253X_ADDR_CTRL_WORD);
-    disp_data |= HDSP253X_CTRL_CLEAR_MASK;
-    _write(HDSP253X_ADDR_CTRL_WORD, disp_data);
-
-    // Wait for the preset delay to allow operation to complete
-    wait_ms(HDSP253X_RST_CLR_DELAY_MS);
-
-    // Reset cursor 
-    locate(0);
-}
-
-
-/*---------------------------------------------------------------------------*\
- |
- |  Function:       HDSP253X_set_brightness
- |
- |  Description:    Sets the brightness of the HDSP253X display, by performing
- |                  a read-modify-write on the control register.
- |
- |  Parameters:     brightness - 3 bit brightness value
- |
- |  Returns:        Nothing
- |
-\*---------------------------------------------------------------------------*/
-
-void HDSP253X_Display::set_brightness(uint8_t brightness) {
-
-    uint8_t ctrl_data;
-
-    // Read in control word, modify and write back out
-    ctrl_data = _read(HDSP253X_ADDR_CTRL_WORD);
-    ctrl_data &= ~HDSP253X_CTRL_BRIGHT_MASK;
-    ctrl_data |= (brightness & HDSP253X_CTRL_BRIGHT_MASK);
-    _write(HDSP253X_ADDR_CTRL_WORD, ctrl_data);
-}
-
-/*---------------------------------------------------------------------------*\
- |
- |  Function:       HDSP253X_start_self_test
- |
- |  Description:    Starts the HDSP253X self test, setting the relevant 
- |                  control word bit. The caller should then wait for 
- |                  the required number of seconds before checking the result.
- |                  With the internal display clock, the self test takes 
- |                  around 5 seconds, so waiting for 6 seconds should
- |                  be OK. Slower clocks will require longer delays.
- |
- |                  Note that some displays such as the Siemens HDSP2111
- |                  appear to take longer than the official 4.5 seconds
- |                  so it is advisable to wait for longer (say 6 seconds)
- |                  before checking the result. Attempting to access the
- |                  display before it is ready may result in the self test
- |                  status failing to clear down.
- |
- |                  Also note that some display datasheets suggest that
- |                  the display must be reset BEFORE running the self
- |                  test routine, so this routine does this.
- |
- |  Parameters:     None
- |
- |  Returns:        Nothing
- |
-\*---------------------------------------------------------------------------*/
-
-void HDSP253X_Display::start_self_test(void) {
-
-    // Reset the display to ensure it is ready for the self test
-    reset();
-
-    // Directly write the self test request, as control word is wiped at end
-    _write(HDSP253X_ADDR_CTRL_WORD, HDSP253X_CTRL_SELFTEST_MASK);
-}
-
-/*---------------------------------------------------------------------------*\
- |
- |  Function:       HDSP253X_finish_self_test
- |
- |  Description:    Reads the control register to determine the self test
- |                  result. Then issues a display reset to ensure 
- |                  that it is ready for operation afterwards. While such
- |                  a reset should not be necessary if an adequate delay
- |                  occurs between starting the self test and checking the 
- |                  result, issuing a reset guarantees that the display will 
- |                  be ready for operation. This also means that this function
- |                  can be called early to prematurely terminate a self test.
- |
- |  Parameters:     None
- |
- |  Returns:        True if passed, False if failed
- |
-\*---------------------------------------------------------------------------*/
-
-bool HDSP253X_Display::finish_self_test(void) {
-    uint8_t ctrl_data;
-    bool result;
-    
-    // Read back control word and obtain self test result
-    ctrl_data = _read(HDSP253X_ADDR_CTRL_WORD);
-    result = ((ctrl_data & HDSP253X_CTRL_STRESULT_MASK) != 0);
-
-    // Reset the display to ensure it is ready for normal operation
-    reset();
-
-    // Indicate the self test result
-    return result;
-}
-
-
-/*---------------------------------------------------------------------------*\
- |
- |  Function:       HDSP253X_set_blink_mode
- |
- |  Description:    Enables or disables the blinking function on the display.
- |                  When enabled, blinking will flash the whole display 
- |                  irrespective of the flash RAM. With the internal clock,
- |                  the blink rate is 2Hz. Note that blink mode overrides 
- |                  the normal flashing mode.
- |
- |  Parameters:     enable - true to enable, false to disable
- |
- |  Returns:        Nothing
- |
-\*---------------------------------------------------------------------------*/
-
-void HDSP253X_Display::set_blink_mode(bool enable) {
-    uint8_t ctrl_data;
-
-    // read in control word, modify and write back out
-    ctrl_data = _read(HDSP253X_ADDR_CTRL_WORD);
-    if (enable) {
-      ctrl_data |= HDSP253X_CTRL_BLINK_MASK;
-    }
-    else {
-      ctrl_data &= ~HDSP253X_CTRL_BLINK_MASK;
-    }
-    _write(HDSP253X_ADDR_CTRL_WORD, ctrl_data);
-}
-
-/*---------------------------------------------------------------------------*\
- |
- |  Function:       HDSP253X_set_flash_mode
- |
- |  Description:    Enables or disables the flashing function on the display.
- |                  When enabled, characters with the flashing bit set in the 
- |                  RAM will flash. With the internal clock, the flash rate is 2Hz.
- |
- |  Parameters:     enable - true to enable, false to disable
- |
- |  Returns:        Nothing
- |
-\*---------------------------------------------------------------------------*/
-
-void HDSP253X_Display::set_flash_mode(bool enable) {
-    uint8_t ctrl_data;
-
-    // read in control word, modify and write back out
-    ctrl_data = _read(HDSP253X_ADDR_CTRL_WORD);
-    if (enable) {
-      ctrl_data |= HDSP253X_CTRL_FLASH_MASK;
-    }
-    else {
-      ctrl_data &= ~HDSP253X_CTRL_FLASH_MASK;
-    }
-    _write(HDSP253X_ADDR_CTRL_WORD, ctrl_data);
-}
-
-/*---------------------------------------------------------------------------*\
- |
- |  Function:       HDSP253X_set_all_flash_states
- |
- |  Description:    Sets flashing states of all characters in flash RAM, using 
- |                  supplied bit mask. Each bit corresponds to a character
- |                  (bit 7 on left, bit 0 on right), and is set to flash and
- |                  clear for steady operation. NOTE: The overall flashing 
- |                  enable/disable state is set by the separate set flash 
- |                  mode function.
- |
- |  Parameters:     flash_bits - bitmask containing flash states
- |
- |  Returns:        Nothing
- |
-\*---------------------------------------------------------------------------*/
-
-void HDSP253X_Display::set_all_flash_states(uint8_t flash_bits)
-{
-    int i;
-    uint8_t char_pos;
-
-    // loop round all character positions, extracting each bit in turn
-    for (i = 1; i <= HDSP253X_NUM_CHARS; i++)
-    {
-      // Get state of bottom bit from mask and use to adjust flash state
-      // Note that character address is reversed as we start from right
-      char_pos = HDSP253X_NUM_CHARS - i;
-      _write(HDSP253X_ADDR_FLASH_BASE + char_pos, flash_bits & 0x01);
-
-      // Shift the mask to the right, ready for the next go
-      flash_bits >>= 1;
-    }
-}
-
-/*---------------------------------------------------------------------------*\
- |
- |  Function:       HDSP253X_set_char_flash_state
- |
- |  Description:    Sets flashing state of one character in flash RAM, using 
- |                  supplied character position and enable state. NOTE: The 
- |                  overall flashing enable/disable state is set by the 
- |                  separate set flash mode function.
- |
- |  Parameters:     flash_state - TRUE to flash, FALSE for steady operation
- |                  char_pos - position on the display (0 to 7)
- |
- |  Returns:        Nothing
- |
-\*---------------------------------------------------------------------------*/
-
-void HDSP253X_Display::set_char_flash_state(bool flash_state, uint8_t char_pos) {
-    // Write out the new flash state to the flash RAM
-    _write(HDSP253X_ADDR_FLASH_BASE + char_pos, flash_state);
-}
-
-/*---------------------------------------------------------------------------*\
- |
- |  Function:       HDSP253X_define_user_char
- |
- |  Description:    Full definition of UDC, firstly setting the UDC address
- |                  to specified character, and then loading all 7 data rows.
- |                  Note that for each row, only the bottom 5 bits are used.
- |  
- |  Parameters:     udc_char_num - number of UDC character, from 0 to 15
- |                  row_data_1 - top row data
- |                  row_data_2 - second row data
- |                  row_data_3 - third row data
- |                  row_data_4 - fourth row data
- |                  row_data_5 - fifth row data
- |                  row_data_6 - sixth row data
- |                  row_data_7 - bottomp row data
- |  
- |  Returns:        Nothing
- |
-\*---------------------------------------------------------------------------*/
-
-void HDSP253X_Display::define_user_char(uint8_t udc_char_num, uint8_t row_data_1, uint8_t row_data_2,
-                                        uint8_t row_data_3, uint8_t row_data_4, uint8_t row_data_5, 
-                                        uint8_t row_data_6, uint8_t row_data_7)
-{
-    // firstly set the UDC character address, by writing to the UDC addr reg
-    _write(HDSP253X_ADDR_UDC_ADDRESS, udc_char_num);
-
-    // now write out the 7 rows to the UDC RAM
-    _write(HDSP253X_ADDR_UDC_ROW_BASE+0, row_data_1);
-    _write(HDSP253X_ADDR_UDC_ROW_BASE+1, row_data_2);
-    _write(HDSP253X_ADDR_UDC_ROW_BASE+2, row_data_3);
-    _write(HDSP253X_ADDR_UDC_ROW_BASE+3, row_data_4);
-    _write(HDSP253X_ADDR_UDC_ROW_BASE+4, row_data_5);
-    _write(HDSP253X_ADDR_UDC_ROW_BASE+5, row_data_6);
-    _write(HDSP253X_ADDR_UDC_ROW_BASE+6, row_data_7);
-}
-
-
-/*****************************************************************************/
-/******************************  END OF FILE  ********************************/
-/*****************************************************************************/
-
--- a/HDSP253X_Display.h	Fri Aug 26 20:35:11 2011 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,225 +0,0 @@
-/* HDSP253X_Display - Intelligent 8 digit 5x7 LED matrix display
- *
- * Copyright (c) 2011 Wim Huiskamp
- * Modified software based on sourcecode by RAC 06/08/2008
- *
- * Released under the MIT License: http://mbed.org/license/mit
- *
- * version 0.2 Initial Release
-*/
-#ifndef _HDSP253X_DISPLAY_H
-#define _HDSP253X_DISPLAY_H
-/*---------------------------------------------------------------------------*\
- |  Original text by RAC 06/08/2008 has been modified to fix those parts of
- |  the description which explain hardware or software that has been removed or
- |  adapted in the new version. 
- |
- |  Description: Display driver and demonstrator for HDSP253X series intelligent
- |            8 character LED display modules. Options include adjusting 
- |            brightness and message blinking.
- |            This software drives a single display module using 8 bit databus,
- |            5 bit addressbus and controlsignals. Note that this software
- |            will drive all display devices in the series, including HDSP2530 Orange,
- |            HDSP2531 Yellow, HDSP2532 red and HDSP2533 green devices. It will also
- |            drive the smaller HDSP21XX series.
- |
- |            The peripheral is connected to the following pins:
- |            HDSP253X
- |                    - Reset (pin 1) to EnableBus.RESET
- |                    - Flash (pin 2) to AddressBus.A5
- |                    - Addr A0 (pin 3) to AddressBus.A0
- |                    - Addr A1 (pin 4) to AddressBus.A1
- |                    - Addr A2 (pin 5) to AddressBus.A2
- |                    - Addr A3 (pin 6) to AddressBus.A3
- |                    - Addr A4 (pin 10) to AddressBus.A4
- |                    - Clock select (pin 11) to VCC (Pull Up)
- |                    - Clock in/out (pin 12) to Not Connected
- |                    - Write (pin 13) to ControlBus.WR
- |                    - CE (Pin 14) to EnableBus.CSDISP
- |                    - VDD 5V (Pin 15)
- |                    - GND (supply) (Pin 16)
- |                    - TST (Pin 16) NC
- |                    - GND (logic) (Pin 18)   
- |                    - Read (pin 19) to ControlBus.RD
- |                    - Data D0 (pin 20) to Databus.D0
- |                    - Data D1 (pin 21) to Databus.D1
- |                    - Data D2 (pin 25) to Databus.D2
- |                    - Data D3 (pin 26) to Databus.D3
- |                    - Data D4 (pin 27) to Databus.D4
- |                    - Data D5 (pin 28) to Databus.D5
- |                    - Data D6 (pin 29) to Databus.D6
- |                    - Data D7 (pin 30) to Databus.D7
- |
- |            The peripheral is connected to the following pins:
- |            HDSP211X
- |                    - Reset (pin 1) to EnableBus.RESET
- |                    - Flash (pin 2) to AddressBus.A5
- |                    - Addr A0 (pin 3) to AddressBus.A0
- |                    - Addr A1 (pin 4) to AddressBus.A1
- |                    - Addr A2 (pin 5) to AddressBus.A2
- |                    - Addr A3 (pin 6) to AddressBus.A3
- |                    - Addr A4 (pin 10) to AddressBus.A4
- |                    - Clock select (pin 11) to VCC (Pull Up)
- |                    - Clock in/out (pin 12) to Not Connected
- |                    - Write (pin 13) to ControlBus.WR
- |                    - VDD 5V (Pin 14)
- |                    - GND (supply) (Pin 15)
- |                    - GND (logic) (Pin 16)   
- |                    - CE (Pin 17) to EnableBus.CSDISP
- |                    - Read (pin 18) to ControlBus.RD
- |                    - Data D0 (pin 19) to Databus.D0
- |                    - Data D1 (pin 20) to Databus.D1
- |                    - Data D2 (pin 23) to Databus.D2
- |                    - Data D3 (pin 24) to Databus.D3
- |                    - Data D4 (pin 25) to Databus.D4
- |                    - Data D5 (pin 26) to Databus.D5
- |                    - Data D6 (pin 27) to Databus.D6
- |                    - Data D7 (pin 28) to Databus.D7
- |
- |  Details:  All signals to the HDSP253X are pulled up by 10K resistors.
- |            The device must be reset by pulsing Reset low with Chip Enable
- |            set high. Other signals are don't cares during a reset. This
- |            firmware meets these conditions, as long as the pullups are 
- |            correctly installed.
- |
- |            Connecting the clock select and in/out lines to the CPU is optional,
- |            and may be used for experimentation.
- |            If using one display, the clock select should normally be pulled
- |            up high, which results in the clock signal being an output.
- |            This driver software does not currently control these signals.
- |
- |            If using more than one display, the driver software will 
- |            require modification and extension. Multiple displays should
- |            have reset, data, address, flash and read/write lines paralleled.
- |            Each display requires a unique Chip Enable input, and the 
- |            driver software will need to select which display to access.
- |            The first display should have clock select high, and its clock
- |            output connected to the clock inputs on all the other displays;
- |            these should have clock select low to input the clock signal.
- |
- |            Calls to wait_ms() are used to meet the display timing specs
- |            may need to be modified at higher CPU speeds.
- |
- |
- |  Legalese: This software is FREEWARE, and you can adapt it for any
- |            purpose whatsoever. I cannot be held responsible for any
- |            loss, injury, damage or death caused by the use of this 
- |            software.
- |
-\*---------------------------------------------------------------------------*/
-
-//Useful stuff to simplify porting of some third party software
- #include <stdarg.h>
- //#include "Utils.h"
-
-
-/*****************************************************************************/
-/*********************  DEFINITIONS FOR HDSP253X DISPLAY  ********************/
-/*****************************************************************************/
-
-// Specific delays for display operation, assuming internal clocking
-// This may need to be lengthened if a significantly slower external clock is used
-#define HDSP253X_1TCY_WAIT_MS       1
-//#define HDSP253X_1TCY_WAIT_MS       10
-#define HDSP253X_RST_CLR_DELAY_MS   2       // delay AFTER issuing reset or clear
-#define HDSP253X_SELFTEST_WAIT_MS   6000    // duration of self test operation
-
-// address values and masks for HDSP253X display access
-#define HDSP253X_ADDR_FLASH_BASE    0x00 
-#define HDSP253X_ADDR_UDC_ADDRESS   0x20 
-#define HDSP253X_ADDR_UDC_ROW_BASE  0x28 
-#define HDSP253X_ADDR_CTRL_WORD     0x30 
-#define HDSP253X_ADDR_CHAR_BASE     0x38 
-// minimises address line power consumption through pullups
-#define HDSP253X_ADDR_LOW_POWER     0x3F
-
-// control word masks for HDSP253X display
-#define HDSP253X_CTRL_BRIGHT_MASK   0x07 
-#define HDSP253X_CTRL_FLASH_MASK    0x08 
-#define HDSP253X_CTRL_BLINK_MASK    0x10 
-#define HDSP253X_CTRL_STRESULT_MASK 0x20 
-#define HDSP253X_CTRL_SELFTEST_MASK 0x40 
-#define HDSP253X_CTRL_CLEAR_MASK    0x80 
-
-// Masks for register read, Bit 7 not readable in the target hardware 
-#define HDSP253X_CTRL_MASK          0x7F 
-
-
-// display brightness definitions, indicating percentage brightness
-#define HDSP253X_BRIGHT_100         0x00
-#define HDSP253X_BRIGHT_80          0x01
-#define HDSP253X_BRIGHT_53          0x02
-#define HDSP253X_BRIGHT_40          0x03
-#define HDSP253X_BRIGHT_27          0x04
-#define HDSP253X_BRIGHT_20          0x05
-#define HDSP253X_BRIGHT_13          0x06
-#define HDSP253X_BRIGHT_0           0x07
-
-// miscellaneous definitions for HDSP253X display
-#define HDSP253X_NUM_CHARS          8
-#define HDSP253X_CHAR_MASK          0x7F  
-#define HDSP253X_UDC_SEL            0x80
-#define HDSP253X_UDC_MASK           0x0F
-//#define HDSP253X_ASCII_UDC_CHARS    144
-//#define HDSP253X_POUND_CHAR         0x1E
-
-
-// default display brightness
-#define HDSP253X_DEF_DISPLAY_BRIGHT HDSP253X_BRIGHT_100
-
-
-/** Create an HDSP253X_Display object connected to the proper busses
- *
- * @param  PCF8574_DataBus data databus to connect to 
- * @param  PCF8574_AddressBus address addressbus to connect to 
- * @param  PCF8574_EnableBus enable enablebus to connect to 
- * @param  MBED_ControlBus control controlbus to connect to 
-*/
-class HDSP253X_Display {
-public:
-    HDSP253X_Display(PCF8574_DataBus &databus, PCF8574_AddressBus &addressbus,
-                     PCF8574_EnableBus &enablebus, MBED_ControlBus &controlbus);
-    void cls();                              
-    void putc(char disp_char);
-//    char getc();    
-
-    void printf (char * format, ...);    
-    void locate(uint8_t column);
-    void define_user_char(uint8_t udc_char_num, uint8_t row_data_1, uint8_t row_data_2,
-                          uint8_t row_data_3, uint8_t row_data_4, uint8_t row_data_5, 
-                          uint8_t row_data_6, uint8_t row_data_7);    
-                          
-    void set_char_flash_state(bool flash_state, uint8_t char_pos);
-    void set_all_flash_states(uint8_t flash_bits);
-    void set_brightness(uint8_t brightness);  
-    void set_blink_mode(bool enable);  
-    void set_flash_mode(bool enable);        
-    void reset();
-//    void putudc(char byte);
-    void start_self_test();  
-    bool finish_self_test();  
-    
-protected:
-    PCF8574_DataBus &_databus;
-    PCF8574_AddressBus &_addressbus;
-    PCF8574_EnableBus &_enablebus;
-    MBED_ControlBus &_controlbus;
-
-//    int _row;
-    int _column;
-    void _write(uint8_t address, uint8_t data);
-    uint8_t _read(uint8_t address);
-    void _init(); 
-//    void _display_ascii_char(char ascii_char, uint8_t char_pos);  
-//    void _display_udc_char(char udc_char, uint8_t char_pos);  
-//    void _display_part_string(const char *disp_string, uint8_t start_pos, uint8_t end_pos);  
-//    void _display_fixed_string(const char *disp_string, uint8_t start_pos);
-          
-};
-
-
-#endif
-/*****************************************************************************/
-/******************************  END OF FILE  ********************************/
-/*****************************************************************************/
-
--- a/Host_Coms.cpp	Fri Aug 26 20:35:11 2011 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,526 +0,0 @@
-/* Host_Coms - Communications with Host PC
- *
- * Copyright (c) 2011 Wim Huiskamp
- *
- * Released under the MIT License: http://mbed.org/license/mit
- *
- * version 0.2 Initial Release
-*/
-#include "mbed.h"
-#include "Host_Coms.h"
-
-
-/** Create a Host Coms object connected to the proper channel
- *
- * @param  Serial serial channel to connect to 
- * @brief 
-*/
-Host_Coms::Host_Coms(Serial &hostChannel) : _hostChannel(hostChannel) {
-  
-  _init();  
-}   
-
-
-/** Send a formatted string to the Host PC
- * @param
- * @returns int message length
- */
-int Host_Coms::sendString(char * format, ...) {
-   va_list args;
-   va_start (args, format);
-   int rv;
-
-   rv = _hostChannel.printf(format, args);
-
-   va_end (args);
-
-   return rv;
-}
-
-
-
-/** Send a formatted message to the Host PC
- * @param
- * @returns int message length
- */
-int Host_Coms::sendMessage(char * format, ...) {
-   va_list args;
-   va_start (args, format);
-   int rv=vsprintf (_sendBuffer, format, args);
-
-//   _hostChannel.printf("%s:len=%d\r\n", _sendBuffer, strlen(_sendBuffer));
-   
-   _hostChannel.printf("%s*%02X\r\n", _sendBuffer, _calcChecksum());
-
-   va_end (args);
-
-   return (rv + 5);  // length + * + checksum + <CR> + <NL>
-}
-
-/** Compute the XOR checksum on the message
- * @param
- * @returns int checksum
- */
-int Host_Coms::_calcChecksum() {
-  int checksum = 0;
-  int i, last;
-
-  //_sendBuffer[0] should be '$' and is ignored in checksum  
-  last = strlen(_sendBuffer);
-  for (i=1; i<last; i++) {
-    checksum ^= (int) _sendBuffer[i];
-  }  
-  
-  return checksum;
-}
-
-
-/** Parse the LFRNG message and decode the fields
- * @param
- * @returns bool valid message 
- * @brief
- */
-bool Host_Coms::_parseLFRNG(char *data) {
-   char *token;
-   int tokenfield;
-   bool result=true;
-   
-//   char hostmessage[] = "1234,5678,0";
-//   strcpy(hostmessage, "1234,5678,0");
-      
-   token = strtok(data, ","); // get first token, separator is ','
-   tokenfield = 1;   
-
-   while ((token != NULL) && (tokenfield <= 3)) {     
-     switch (tokenfield) {
-        case 1:
-                // Range First
-                _hostChannel.printf("#%d: %s\r\n", tokenfield, token);
-                
-                // Convert and perform sanity check
-                rangeFirst = atoi(token);
-                if ((rangeFirst < 0) || (rangeFirst > 9999)) {
-                  rangeFirst = 0;
-                  result=false;
-                }
-                _hostChannel.printf("#%d: int=%04d\r\n", tokenfield, rangeFirst);                
-                break;
-
-        case 2:
-                // Range Last
-                _hostChannel.printf("#%d: %s\r\n", tokenfield, token);
-
-                // Convert and perform sanity check
-                rangeLast = atoi(token);
-                if ((rangeLast < 0) || (rangeLast > 9999)) {
-                  rangeLast = 0;
-                  result=false;
-                }
-
-                _hostChannel.printf("#%d: int=%04d\r\n", tokenfield, rangeLast);                                
-                break;
-
-        case 3:
-                // Multiple Returns
-                _hostChannel.printf("#%d: %s\r\n", tokenfield, token);
-
-                // Convert and perform sanity check
-                mult = atoi(token);
-                if ((mult < 0) || (mult > 1)) {
-                  mult = 0;
-                  result=false;
-                }
-
-                _hostChannel.printf("#%d: int=%1d\r\n", tokenfield, mult);                
-                break;
-
-        default:
-                break;
-     } // switch
-     
-     token = strtok(NULL, ","); // Get next token
-     tokenfield++;     
-   } // while
-
-   // Could do additional sanity check on correct number of fields
-      
-   return result;
-}
-
-/** Parse the LFRES message and decode the fields
- * @param
- * @returns bool valid message
- * @brief
- */
-bool Host_Coms::_parseLFRES(char *data) {
-   char *token;
-   int tokenfield;
-   int STANAG_Code;
-   bool result=true;
-      
-   token = strtok(data, ","); // get first token, separator is ','
-   tokenfield = 1;   
-   
-   while ((token != NULL) && (tokenfield <= D_HOST_STANAG_CODES)) {   
-     switch (tokenfield) {
-        case 1:
-        case 2:        
-        case 3:        
-        case 4:
-        case 5:                        
-        case 6:
-        case 7:        
-        case 8:        
-        case 9:
-        case 10:                        
-        case 11:
-        case 12:        
-        case 13:        
-        case 14:
-        case 15:                        
-        case 16:
-        case 17:        
-        case 18:        
-        case 19:
-        case 20:                        
-                _hostChannel.printf("#%d: %s\r\n", tokenfield, token);
-                
-                // STANAG_Code[i] and sanity check
-                STANAG_Code = atoi(token);
-                if ((STANAG_Code < 0) || (STANAG_Code > 9999)) {
-//                if (STANAG_Code < 0) || (STANAG_Code > 1999) {    // Check on limited code value            
-                  STANAG_Code = 0;
-                  result = false;
-                }
-                 
-                STANAG_Codes[tokenfield - 1] = STANAG_Code;                 
-
-                _hostChannel.printf("#%d: %s\r\n", tokenfield, STANAG_Codes[tokenfield - 1]);
-
-                break;
-
-        default:
-                break;
-     } // switch
-     
-     token = strtok(NULL, ","); // Get next token
-     tokenfield++;     
-   } // while
-   
-   // Could do additonal sanity check on correct number of fields
-   
-   return result;
-}
-
-
-/** Receive and Parse the Host message
- * @param
- * @returns Host_Mess message type that was received
- * @brief 
- *              Check LF28A Host channel and Parse received data for valid messages.
- *              Since the parser is a state machine, partial data may
- *              be supplied where the next time this method is called, the
- *              rest of the partial data will complete the message and 
- *              parsing will begin. A typical message is constructed as:
- *
- *                  $LFCMD,DDDD,DDDD,....DD*CS<CR><LF>
- *
- *              Where:
- *                        '$'            Hex 24 (Start of Message)
- *                        'LFCMD'        LF28A command or data
- *                        ',DDDD'        Zero or more data fields
- *                        '*CS'          Checksum field (optional)
- *                        <CR><LF>       Hex 0D 0A (End of Message)
- *
- *              When a complete message is received, this function sends the
- *              LF28A command and data to the parseCommand methods for
- *              individual field parsing. The received data will be stored
- *              in a datastructure. The return value informs the caller which
- *              command has been received to decide on proper action. 
- */
-Host_Mess Host_Coms::parseMessage() {
-  char data;
-  static int cmdIdx = 0;                    // index for received command
-  static int datIdx = 0;                    // index for received data
-  static int computedChecksum = 0;          // computed from the received data   
-  static int receivedChecksum = 0;          // checksum that was part of the received data
-  static bool checksumReceived = false;     // received data included the optional checksum
-  static bool messageComplete = false;      // message has been received that is ready for decoding
-  Host_Mess   messageType;                  // valid decoded message type   
-  static LFP_State parseState = LFP_STATE_SOM;
-     
-  // init while loop, no valid decoded message is available initially
-  messageType = HOST_CMD_NONE;
-  
-  // Continue reading from host as long as data is available or until a
-  // valid message has been received that needs to be processed first.
-  while ((_hostChannel.readable()) && (messageType == HOST_CMD_NONE)) {
-    data = _hostChannel.getc();
-
-    // The main state machine which processes individual characters
-    // until a complete message has been received that is ready for decoding.
-    switch(parseState) {
-      // Search for start of message '$'
-      case LFP_STATE_SOM :
-                            if(data == '$') {
-                              cmdIdx = 0;                   // reset index
-                              computedChecksum = 0;        // reset checksum
-                              receivedChecksum = 0; 
-                              messageComplete = false;     // restart                               
-                              checksumReceived = false;    // restart                                                             
-                              parseState = LFP_STATE_CMD;  // next state
-                              
-_hostChannel.printf("#start cmd\r\n");                              
-                            }
-  
-  
-                            break;
-
-      // Retrieve command field
-      case LFP_STATE_CMD :
-                            switch (data) {
-                              case ',':  
-                                        // terminate command
-                                        _command[cmdIdx] = '\0';
-
-                                        // update checksum
-                                        computedChecksum ^= (int) data;
-
-                                        // goto get data state
-                                        datIdx = 0;          // reset index                                                                                
-                                        parseState = LFP_STATE_DATA;
-_hostChannel.printf("#, end cmd\r\n");                                        
-                                        break;
-                              case '*':  
-                                        // terminate command
-                                        _command[cmdIdx] = '\0';
-
-                                        // goto get checksum state 
-                                        checksumReceived = true;                                                                               
-                                        parseState = LFP_STATE_CS1;   
-_hostChannel.printf("#* end cmd\r\n");
-                                        break;                                        
-
-                              case '\r':  
-                              case '\n':                                
-                                        // terminate command
-                                        _command[cmdIdx] = '\0';
-                                        
-                                        // done, decode data and restart
-                                        messageComplete = true;
-                                        parseState = LFP_STATE_SOM;
-_hostChannel.printf("#cr nl end cmd\r\n");
-                                        break;
-                                        
-                              case '$' : 
-                                        // unexpected restart 
-                                        cmdIdx = 0;                     // reset index
-                                        computedChecksum = 0;        // reset checksum 
-_hostChannel.printf("#$ restart cmd\r\n");                                        
-                                        break;
-
-                              default :  
-                                        // store command
-                                        _command[cmdIdx++] = data;                                        
-                                        
-                                        // update checksum
-                                        computedChecksum ^= (int) data;
-
-                                        // Check for command overflow
-                                        if (cmdIdx > D_HOST_MAX_CMD_LEN) {
-                                          parseState = LFP_STATE_SOM;  // something went wrong, restart
-                                        }
-                                        
-_hostChannel.printf("#in cmd\r\n");                                        
-                                        break;                                                                               
-                                        
-                           } // switch (data)
-                           break;
-
-        // Store data and check for end of sentence or checksum flag
-        case LFP_STATE_DATA :
-                           switch (data) {
-                              case '*':  
-                                        // terminate data
-                                        _data[datIdx] = '\0';
-
-                                        // goto get checksum state
-                                        checksumReceived = true;
-                                        parseState = LFP_STATE_CS1;
-_hostChannel.printf("#* end data\r\n");                                                                                                                                                                   
-                                        break;                                        
-
-                              case '\r':  
-                              case '\n':                                
-                                        // terminate data
-                                        _data[datIdx] = '\0';
-                                        
-                                        // done, decode data and restart
-                                        messageComplete = true;
-                                        parseState = LFP_STATE_SOM;
-_hostChannel.printf("#cr nl end data\r\n");                                                                                    
-                                        break;
-
-                              case '$' : 
-                                        // unexpected restart 
-                                        cmdIdx = 0;                     // reset index
-                                        computedChecksum = 0;        // reset checksum 
-
-                                        parseState = LFP_STATE_CMD;  // restart                                      
-_hostChannel.printf("#$ in data, restart cmd\r\n");                                        
-                                        break;
-                                        
-                              default :  
-                                        // store data
-                                        _data[datIdx++] = data;                                        
-
-                                        // update checksum
-                                        computedChecksum ^= (int) data;
-                                        
-                                        // Check for data overflow
-                                        if (datIdx > D_HOST_MAX_DATA_LEN) {
-                                          parseState = LFP_STATE_SOM;  // something went wrong, restart
-                                        }
-                                        
-_hostChannel.printf("#in data\r\n");                                                                                
-                                        break;                                                                               
-                                        
-                           } // switch (data)
-                           break;
-        
-        // Handle checksum (part1) from sentence
-        case LFP_STATE_CS1 :
-        
-                           if ((data >= '0') && (data <= '9')) {
-                             receivedChecksum = (data - '0') << 4;
-                             parseState = LFP_STATE_CS2;
-                           }
-                           else if ((data >= 'a') && (data <= 'f')) {
-                             receivedChecksum = ((data - 'a') + 10) << 4;
-                             parseState = LFP_STATE_CS2;                             
-                           }
-                           else if ((data >= 'A') && (data <= 'F')) {
-                             receivedChecksum = ((data - 'A') + 10) << 4;
-                             parseState = LFP_STATE_CS2;                             
-                           }
-                           else {
-                             // not a valid checksum
-                             parseState = LFP_STATE_SOM;  // something went wrong, restart
-                           }
-                      
-                           break;
-
-        // Handle checksum (part2) from sentence
-        case LFP_STATE_CS2 :
-        
-                           if ((data >= '0') && (data <= '9')) {
-                             receivedChecksum |= (data - '0');
-                             
-                             // done, decode data and restart
-                             messageComplete = true;
-                             parseState = LFP_STATE_SOM;                            
-                           }
-                           else if ((data >= 'a') && (data <= 'f')) {
-                             receivedChecksum |= (data - 'a') + 10;
-
-                             // done, decode data and restart
-                             messageComplete = true;
-                             parseState = LFP_STATE_SOM;                            
-                           }
-                           else if ((data >= 'A') && (data <= 'F')) {
-                             receivedChecksum |= (data - 'A') + 10;
-                             parseState = LFP_STATE_SOM;                             
-
-                             // done, decode data and restart
-                             messageComplete = true;
-                             parseState = LFP_STATE_SOM;                                                        
-                           }
-                           else {
-                             // not a valid checksum
-                             parseState = LFP_STATE_SOM;  // something went wrong, restart
-                           }
-                      
-                           break;
-        
-
-        // Something went wrong, restart
-        default :
-                           parseState = LFP_STATE_SOM;    
-    } // switch (_parseState)
-    
-    
-    // Check if done with this message
-    if (messageComplete) {
-_hostChannel.printf("#complete\r\n");                                                                                    
-      if (!checksumReceived) {      
-        // No checksum received, process message
-        messageType = _parseCommand(_command, _data);     
-      }
-      else if (computedChecksum == receivedChecksum) {        
-        // Correct checksum, process message              
-        messageType = _parseCommand(_command, _data);
-      }
-      else {
-       // Ignore messages with an invalid checksum
-        messageType = HOST_CMD_NONE;               
-      }
-      
-      // done processing this received message
-      messageComplete = false;
-    }
-
-                                
-  } // while readable and no valid message available
-
-  
-  // inform the caller when a valid message is available
-  return messageType;
-} // _parseMessage
-
-
-/** Receive and Parse the Host command from the message
- * @param
- * @returns Host_Mess valid command type
- * @brief 
- *          Process LFCMD message - Use the _command and _data strings to call the
- *          appropriate command sentence data processor.
- *          Return which command has been received to let caller decide on proper action !!
-*/
-Host_Mess Host_Coms::_parseCommand(char *command, char *data) {
-  Host_Mess result = HOST_CMD_NONE; 
-
-  //
-  // LFRES
-  //
-  if (strcmp(command, "LFRES") == NULL) {
-    if (_parseLFRES(data))
-      result = HOST_CMD_RES;
-  }
-  //
-  // LFRNG
-  //
-  else if (strcmp(command, "LFRNG") == NULL) {
-    if (_parseLFRNG(data))
-      result = HOST_CMD_RNG;
-  } 
-
-  return result;
-}
-
-
-
-/** Init Host_Coms
- * @param
- * @returns 
- */
-void Host_Coms::_init(void) {
-  int i;
-  
-  rangeFirst=0;
-  rangeLast=0;
-  mult=0;
-  
-  for (i=0; i<D_HOST_STANAG_CODES; i++) {
-    STANAG_Codes[i]=0;
-  }  
-}
--- a/Host_Coms.h	Fri Aug 26 20:35:11 2011 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-/* Host_Coms - Communications with Host PC
- *
- * Copyright (c) 2011 Wim Huiskamp
- *
- * Released under the MIT License: http://mbed.org/license/mit
- *
- * version 0.2 Initial Release
-*/
-#ifndef _HOST_COMS_H
-#define _HOST_COMS_H
-
-#include <stdarg.h>
-#include <string.h>
-
-/*****************************************************************************/
-/*********************  DEFINITIONS FOR HOST_COMS  ***************************/
-/*****************************************************************************/
-
-// Definitions for Host Comms
-#define D_HOST_MAX_MESS_LEN             255
-#define D_HOST_MAX_DATA_LEN             255
-#define D_HOST_MAX_TOKEN_LEN              4
-#define D_HOST_MAX_CMD_LEN                5
-#define D_HOST_STANAG_CODES              20
-
-// Masks
-
-// Enums
-enum LFP_State {LFP_STATE_SOM, LFP_STATE_CMD, LFP_STATE_DATA, LFP_STATE_CS1, LFP_STATE_CS2};   // Message Parser States
-enum Host_Mess {HOST_CMD_NONE, HOST_CMD_RES, HOST_CMD_RNG,                                     // Message Types Host to LF28A Mockup  
-                HOST_MESS_NONE, HOST_MESS_RDY1, HOST_MESS_RDY2, HOST_MESS_STATE};              // Message Types LF28A to Host
-
-
-/** Create a Host Coms object connected to the proper channel
- *
- * @param  Serial serial channel to connect to 
- * @brief 
-*/
-class Host_Coms {
-
-public:
-  Host_Coms(Serial &hostChannel);         
-  int sendString(char * format, ...);  
-  int sendMessage(char * format, ...);
-  Host_Mess parseMessage();
-    
-  int rangeFirst, rangeLast, mult;
-  int STANAG_Codes[D_HOST_STANAG_CODES];
-
-  char _data[D_HOST_MAX_DATA_LEN + 1];           // leave room for '\0'
-
-  bool _parseLFRNG(char *data);
-  bool _parseLFRES(char *data);
-  Host_Mess _parseCommand(char *command, char *data);  
-        
-protected:
-  Serial &_hostChannel;
-  char _sendBuffer[D_HOST_MAX_MESS_LEN + 1];     // leave room for '\0'
-//  char _receiveBuffer[D_HOST_MAX_MESS_LEN + 1];  // leave room for '\0'
-  char _command[D_HOST_MAX_CMD_LEN + 1];         // leave room for '\0'  
-  
-  void _init();          
-  int _calcChecksum();
-};
-
-
-#endif
-/*****************************************************************************/
-/******************************  END OF FILE  ********************************/
-/*****************************************************************************/
--- a/Keyboard.cpp	Fri Aug 26 20:35:11 2011 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,164 +0,0 @@
-/* Keyboard - Keyboard and Fire Switch control
- * Copyright (c) 2011 Wim Huiskamp
- *
- * Released under the MIT License: http://mbed.org/license/mit
- *
- * version 0.2 Initial Release
-*/
-#include "mbed.h"
-#include "PCF8574_DataBus.h"
-#include "PCF8574_EnableBus.h"
-#include "MBED_ControlBus.h"
-#include "Keyboard.h"
-
-
-/** Create a Keyboard object connected to the specified buses
- *
- * @param  PCF8574_DataBus databus to connect to 
- * @param  PCF8574_EnableBus enable enablebus to connect to 
- * @param  MBED_ControlBus control controlbus to connect to 
-*/
-Keyboard::Keyboard (PCF8574_DataBus &databus, PCF8574_EnableBus &enablebus, MBED_ControlBus &controlbus) : 
-                                     _databus(databus), _enablebus(enablebus), _controlbus(controlbus) {
-   _init();
-}    
-
-/** Init Keyboard
- * @param
- * @returns 
- */
-void Keyboard::_init(void)
-{
-   _KeyReady = false;  
-   _KeyCode = KEY_NONE;        
-}
-
-
-/** Check Keypressed or Fire switch pressed
- *
- * @param none
- * @returns bool keypressed 
-*/
-bool Keyboard::readable () {
-  uint8_t data = 0;
-
-  // Init to No keypressed
-  _KeyReady = false;
-  
-  if (_controlbus.CDINT() == HIGH) {
-    // CDA Key pressed  
-    _KeyReady = true;
-        
-    // Get the switchvalue and decode it
-    _KeyCode = getswitch();
-  }
-
-  if (_controlbus.FIRE() == HIGH) {
-    // Manual Fire Key pressed  
-    _KeyReady = true;
-        
-    _KeyCode = KEY_FIRE;
-  }
-
-  return _KeyReady;
-}
-
-
-/** Read keycode
- *
- * @param none
- * @returns keycode 
-*/
-Key_Code Keyboard::getkey() {
-  
-  if (_KeyReady) {
-    _KeyReady = false;  
-    return _KeyCode;  
-  }
-  else {
-    return KEY_NONE;
-  }
-}
-
-
-/** Get keycode for pressed switch
- *
- * @param none
- * @returns keycode 
-*/
-Key_Code Keyboard::getswitch() {
-  uint8_t data = 0;
-  Key_Code code;
-
-  // Get the switchvalue and decode it
-  data = _read() & D_KEYBOARD_MASK;       
-  switch (data) {
-    case D_KEYBOARD_MODE:      code = KEY_MODE;
-                               break;
-    case D_KEYBOARD_EDIT_PATH: code = KEY_EDIT_PATH;
-                               break;
-    case D_KEYBOARD_BRIGHT:    code = KEY_BRIGHT;
-                               break;                               
-    case D_KEYBOARD_GRAT_RT:   code = KEY_GRAT_RT;
-                               break;
-    case D_KEYBOARD_F_L_UP:    code = KEY_F_L_UP;
-                               break;
-    default:                   code = KEY_NONE;
-                               break;                               
-  }
-   
-  return code;
-}
-
-
-/** Read switch value
- *
- * @param none
- * @returns switch register value 
-*/
-uint8_t Keyboard::_read() {
-    uint8_t data = 0;
-
-    // Switch databus to inputs
-    _databus.busdir(READ);        
-    // Switch databus buffer to inputs
-    _controlbus.busdir(READ);      
-    
-    
-    // Set CE low and wait
-    _enablebus.chipselect(CS_SWITCH, LOW);
-    wait_ms(1.0);
-
-    // Set RD low and wait
-    _controlbus.RD(LOW);
-    wait_ms(1.0);
-    
-    // Read the data byte from databus
-    data = _databus.read();
-
-    // set RD high and wait
-    _controlbus.RD(HIGH);
-    wait_ms(1.0);
-
-    // Set CE high and wait
-    _enablebus.chipselect(CS_SWITCH, HIGH);
-    wait_ms(1.0);
-
-    // Switch databus buffer back to outputs
-    _controlbus.busdir(WRITE);        
-    // Switch databus to outputs
-    _databus.busdir(WRITE);   
-    
-    // Return read data to caller
-    return data;
-}
-
-
-
-
-
-
-
-
-
-
--- a/Keyboard.h	Fri Aug 26 20:35:11 2011 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/* Keyboard - Keyboard and Fire Switch control
- *
- * Copyright (c) 2011 Wim Huiskamp
- *
- * Released under the MIT License: http://mbed.org/license/mit
- *
- * version 0.2 Initial Release
-*/
-#ifndef _KEYBOARD_H
-#define _KEYBOARD_H
-
-/*****************************************************************************/
-/*********************  DEFINITIONS FOR KEYBOARD   ***************************/
-/*****************************************************************************/
-
-// Definitions for Keyboard Latch
-// NOTE: NEED TO CHECK THESE !!!!
-#define D_KEYBOARD_NONE             0x00
-#define D_KEYBOARD_MODE             0x01
-#define D_KEYBOARD_EDIT_PATH        0x02
-#define D_KEYBOARD_BRIGHT           0x03
-#define D_KEYBOARD_NOTUSED_4        0x04
-#define D_KEYBOARD_GRAT_RT          0x05
-#define D_KEYBOARD_F_L_UP           0x06
-#define D_KEYBOARD_NOTUSED_7        0x07
-
-// Masks for keyboard codes, bit 4-7 not used
-#define D_KEYBOARD_MASK             0x0F 
-
-//Enums for Keyboard codes
-enum Key_Code { KEY_NONE, KEY_MODE, KEY_EDIT_PATH, KEY_BRIGHT, KEY_GRAT_RT, KEY_F_L_UP, KEY_FIRE };
-
-
-/** Create a Keyboard object connected to the proper busses
- *
- * @param  PCF8574_DataBus data databus to connect to 
- * @param  PCF8574_EnableBus enable enablebus to connect to 
- * @param  MBED_ControlBus control controlbus to connect to 
-*/
-class Keyboard {
-public:
-    Keyboard(PCF8574_DataBus &databus,
-               PCF8574_EnableBus &enablebus, MBED_ControlBus &controlbus);
-    bool readable ();
-    Key_Code getkey();
-    Key_Code getswitch();    
-            
-protected:
-    PCF8574_DataBus &_databus;
-    PCF8574_EnableBus &_enablebus;
-    MBED_ControlBus &_controlbus;   
-    bool _KeyReady;      
-    Key_Code _KeyCode;
-
-    uint8_t _read();   
-    void _init();          
-};
-
-
-#endif
-/*****************************************************************************/
-/******************************  END OF FILE  ********************************/
-/*****************************************************************************/
-
--- a/MBED_ControlBus.cpp	Fri Aug 26 20:35:11 2011 +0000
+++ b/MBED_ControlBus.cpp	Sun Jan 25 17:30:47 2015 +0000
@@ -8,14 +8,6 @@
 #include "mbed.h"
 #include "MBED_ControlBus.h"
 
-//Debounce and Edge detecting stuff
-#include "PinDetect.h"
-//#define __DIGITAL_IN
-//#define __INTERRUPT_IN
-#define __PINDETECT_IN
-
-
-
 
 /** Create an MBED_ControlBus object connected to the specified Pins
  *
@@ -24,15 +16,13 @@
  * @param PinName DTR the databuffer Transmit/Receive direction pin 
  * @param PinName CDBUF the databuffer enable pin
  * @param PinName CDINT the Keyboard interrupt pin  
- * @param PinName FIRE the Manual Fire Unit pin   
 */
-MBED_ControlBus::MBED_ControlBus(PinName WR, PinName RD, PinName DTR, PinName CDBUF, PinName CDINT, PinName FIRE) :
+MBED_ControlBus::MBED_ControlBus(PinName WR, PinName RD, PinName DTR, PinName CDBUF, PinName CDINT) :
    _WR(WR),        // WR pin
    _RD(RD),        // RD pin
    _DTR(DTR),      // DTR pin
    _CDBUF(CDBUF),  // CDBUF pin   
-   _CDINT(CDINT),  // CDINT pin      
-   _FIRE(FIRE) {   // FIRE pin         
+   _CDINT(CDINT){  // CDINT pin      
    _init();
 }
 
@@ -117,7 +107,6 @@
 }
 
 
-#ifdef __DIGITAL_IN
 /** Get the CDINT pin value from Control Bus
  *
  * @returns Bit_Level CDINT_level
@@ -131,249 +120,6 @@
       return HIGH;      
 }
 
-/** Get the FIRE pin value from Control Bus
- *
- * @returns Bit_Level FIRE_level
-*/
-Bit_Level MBED_ControlBus::FIRE() {
-    
-    // FIRE Pin value, used as regular Pin rather than as interrupt
-    if (_FIRE == 0)
-      return LOW;
-    else 
-      return HIGH;      
-}
-
-/** Setup debouncing and edge detection on the CDINT pin 
- *
- * @returns
-*/
-void MBED_ControlBus::_CDINT_init() {
-}
-
-/** Setup debouncing and edge detection on the FIRE pin 
- *
- * @returns
-*/
-void MBED_ControlBus::_FIRE_init() {
-}
-#endif   //__DIGITAL_IN
-
-
-
-#ifdef __INTERRUPT_IN
-/** Get the CDINT pin value from Control Bus
- *
- * @returns Bit_Level CDINT_detected
-*/
-Bit_Level MBED_ControlBus::CDINT () {
-       
-    // CDINT pin has been Debounced and Edge detected
-    // Respond only once for every keypress
-    if (_CDINT_detected) {
-      _CDINT_detected = false;
-      return HIGH;
-    }
-    else {
-      return LOW;      
-    }
-}
- 
-/** Get the FIRE pin value from Control Bus
- *
- * @returns Bit_Level FIRE_detected
-*/
-Bit_Level MBED_ControlBus::FIRE() {
-    
-    // FIRE pin has been Debounced and Edge detected
-    // Respond only once for every keypress
-    if (_FIRE_detected) {
-      _FIRE_detected = false;
-      return HIGH;
-    }
-    else {
-      return LOW;      
-    }
-}
-
-
-/** Called on detection of a rising edge at the CDINT pin 
- *
- * @returns
-*/
- void MBED_ControlBus::_CDINT_activated(void) {
-    _CDINT_detected = true;
-}
-
-
-/** Called on detection of a rising edge at the FIRE pin 
- *
- * @returns
-*/
- void MBED_ControlBus::_FIRE_activated(void) {
-    _FIRE_detected = true;
-}
-
-
-/** Setup simple edge detection on the CDINT pin 
- *
- * @returns
-*/
-void MBED_ControlBus::_CDINT_init() {
-    // Setup the callback function
-   _CDINT.mode(PullDown);
-   _CDINT.rise(this, &MBED_ControlBus::_CDINT_activated);
-
-   // Init the edge detection boolean
-   _CDINT_detected = false;
-}
-
-/** Setup simple edge detection on the FIRE pin 
- *
- * @returns
-*/
-void MBED_ControlBus::_FIRE_init() {
-    // Setup the callback function
-   _FIRE.mode(PullDown);
-   _FIRE.rise(this, &MBED_ControlBus::_FIRE_activated);
-
-   // Init the edge detection boolean
-   _FIRE_detected = false;
-}
-
-/** Setup debouncing and edge detection on the CDINT pin 
- *
- * @returns
-*/
-void MBED_ControlBus::_CDINT_init() {
-}
-
-/** Setup debouncing and edge detection on the FIRE pin 
- *
- * @returns
-*/
-void MBED_ControlBus::_FIRE_init() {
-}
-#endif //__INTERRUPT_IN
-
-
-
-#ifdef __PINDETECT_IN
-/** Get the CDINT pin value from Control Bus
- *
- * @returns Bit_Level CDINT_detected
-*/
-Bit_Level MBED_ControlBus::CDINT () {
-       
-    // CDINT pin has been Debounced and Edge detected
-    // Respond only once for every keypress
-    if (_CDINT_detected) {
-      _CDINT_detected = false;
-      return HIGH;
-    }
-    else {
-      return LOW;      
-    }
-}
- 
- /** Get the FIRE pin value from Control Bus
- *
- * @returns Bit_Level FIRE_detected
-*/
-Bit_Level MBED_ControlBus::FIRE() {
-    
-    // FIRE pin has been Debounced and Edge detected
-    // Respond only once for every keypress
-    if (_FIRE_detected) {
-      _FIRE_detected = false;
-      return HIGH;
-    }
-    else {
-      return LOW;      
-    }
-}
-
-/** Called on detection of a rising edge at the CDINT pin 
- *
- * @returns
-*/
- void MBED_ControlBus::_CDINT_activated(void) {
-    _CDINT_detected = true;
-}
-
-/** Called on detection of a falling edge at the CDINT pin 
- *
- * @returns
-*/
-void MBED_ControlBus::_CDINT_deactivated(void) {
-    _CDINT_detected = false;
-}
-
-/** Called on detection of a rising edge at the FIRE pin 
- *
- * @returns
-*/
- void MBED_ControlBus::_FIRE_activated(void) {
-    _FIRE_detected = true;
-}
-
-/** Called on detection of a falling edge at the FIRE pin 
- *
- * @returns
-*/
-void MBED_ControlBus::_FIRE_deactivated(void) {
-    _FIRE_detected = false;
-}
-
-/** Setup debouncing and edge detection on the CDINT pin 
- *
- * @returns
-*/
-void MBED_ControlBus::_CDINT_init() {
-
-    // Setup the callback functions
-   _CDINT.mode(PullDown);
-   _CDINT.attach_asserted(this, &MBED_ControlBus::_CDINT_activated);
-   _CDINT.attach_deasserted(this, &MBED_ControlBus::_CDINT_deactivated);
-//   _CDINT.attach_asserted_held( &keyPressedHeld );
-//   _CDINT.attach_deasserted_held( &keyReleasedHeld );
- 
-   // Init the edge detection boolean
-   _CDINT_detected = false;
-
-   // Sampling does not begin until you set a frequency.
-   // The default is 20ms. If you want a different frequency
-   // then pass the period in microseconds for example, for 10ms :-
-   //     _CDINT.setSampleFrequency(10000);
-   //
-   _CDINT.setSampleFrequency(); // Defaults to 20ms.
-}
-
-/** Setup debouncing and edge detection on the FIRE pin 
- *
- * @returns
-*/
-void MBED_ControlBus::_FIRE_init() {
-
-    // Setup the callback functions
-   _FIRE.mode(PullDown);
-   _FIRE.attach_asserted(this, &MBED_ControlBus::_FIRE_activated);
-   _FIRE.attach_deasserted(this, &MBED_ControlBus::_FIRE_deactivated);
-//   _FIRE.attach_asserted_held( &keyPressedHeld );
-//   _FIRE.attach_deasserted_held( &keyReleasedHeld );
- 
-   // Init the edge detection boolean
-   _FIRE_detected = false;
-
-   // Sampling does not begin until you set a frequency.
-   // The default is 20ms. If you want a different frequency
-   // then pass the period in microseconds for example, for 10ms :-
-   //     _FIRE.setSampleFrequency(10000);
-   //
-   _FIRE.setSampleFrequency(); // Defaults to 20ms.
-}
-#endif // __PINDETECT_IN
-
 
 /** Init MBED_ControlBus
  * @param
@@ -387,9 +133,4 @@
     // Make sure that databus buffer is enabled for Write
     busctrl(ENABLE, WRITE);
     
-    // Setup debouncing and edge detection for CDINT    
-    _CDINT_init();    
-    
-    // Setup debouncing and edge detection for FIRE    
-    _FIRE_init();        
 }
\ No newline at end of file
--- a/MBED_ControlBus.h	Fri Aug 26 20:35:11 2011 +0000
+++ b/MBED_ControlBus.h	Sun Jan 25 17:30:47 2015 +0000
@@ -11,9 +11,6 @@
 //Enums for Control Bus
 #include "BusEnums.h"
 
-//Debounce and Edge detecting stuff
-#include "PinDetect.h"
-
 /** Create an MBED_ControlBus object connected to the specified Pins
  *
  * @param PinName WR the Write pin 
@@ -21,17 +18,16 @@
  * @param PinName DTR the databuffer Transmit/Receive direction pin 
  * @param PinName CDBUF the databuffer enable pin
  * @param PinName CDINT the Keyboard interrupt pin 
- * @param PinName FIRE the Manual Fire Unit pin    
 */
 class MBED_ControlBus {
 public:
-    MBED_ControlBus(PinName WR, PinName RD, PinName DTR, PinName CDBUF, PinName CDINT, PinName FIRE);
+    MBED_ControlBus(PinName WR, PinName RD, PinName DTR, PinName CDBUF, PinName CDINT);
     void WR (Bit_Level wr_level);
     void RD (Bit_Level rd_level);
     void busdir (Bus_Dir buf_dir);    
     void busctrl (Bus_Ena buf_ena, Bus_Dir buf_dir);   
     Bit_Level CDINT ();
-    Bit_Level FIRE ();    
+
 protected:
     DigitalOut _WR;    // Write pin 
     DigitalOut _RD;    // Read pin 
@@ -39,27 +35,15 @@
     DigitalOut _CDBUF; // Databuffer enable pin
     
 //Plain digital input pin
-//    DigitalIn  _CDINT; // Keyboard interrupt pin
-//    DigitalIn  _FIRE;  // Fire interrupt pin
-    
+    DigitalIn  _CDINT; // Keyboard interrupt pin
+  
 //Plain digital interrupt pin
 //    InterruptIn  _CDINT; // Keyboard interrupt pin
-//    InterruptIn  _FIRE;  // Fire interrupt pin
 
 //Debounced and Edge detected input pin (Andy Kirkmans's Lib)
-    PinDetect  _CDINT; // Keyboard interrupt pin    
-    PinDetect  _FIRE;  // Fire interrupt pin
-        
+//    PinDetect  _CDINT; // Keyboard interrupt pin    
+       
     bool _CDINT_detected;
-    bool _FIRE_detected;
-
-    void _CDINT_activated();
-    void _CDINT_deactivated();
-    void _CDINT_init();        
-
-    void _FIRE_activated();
-    void _FIRE_deactivated();
-    void _FIRE_init();        
 
     void _init(); 
 };
--- a/PinDetect.h	Fri Aug 26 20:35:11 2011 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,501 +0,0 @@
-/*
-    Copyright (c) 2010 Andy Kirkham
- 
-    Permission is hereby granted, free of charge, to any person obtaining a copy
-    of this software and associated documentation files (the "Software"), to deal
-    in the Software without restriction, including without limitation the rights
-    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-    copies of the Software, and to permit persons to whom the Software is
-    furnished to do so, subject to the following conditions:
- 
-    The above copyright notice and this permission notice shall be included in
-    all copies or substantial portions of the Software.
- 
-    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 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.
-*/
-
-#ifndef AJK_PIN_DETECT_H
-#define AJK_PIN_DETECT_H
-
-#ifndef MBED_H
-#include "mbed.h"
-#endif
-
-#ifndef PINDETECT_PIN_ASSTERED
-#define PINDETECT_PIN_ASSTERED   1
-#endif
-
-#ifndef PINDETECT_SAMPLE_PERIOD
-#define PINDETECT_SAMPLE_PERIOD 20000
-#endif
-
-#ifndef PINDETECT_ASSERT_COUNT  
-#define PINDETECT_ASSERT_COUNT  1
-#endif
-
-#ifndef PINDETECT_HOLD_COUNT
-#define PINDETECT_HOLD_COUNT    50
-#endif
-
-namespace AjK {
-
-/** PinDetect adds mechanical switch debouncing to DigitialIn and interrupt callbacks.
- *
- * This is done by sampling the specified pin at regular intervals and detecting any
- * change of state ( 0 -> 1 or 1 -> 0 ). When a state change is detected the attached
- * callback handler is called. Additionally, if the pin stays in the same state after
- * a state change for a defined period of time, an extra callback is made allowing a
- * program to detect when a "key is pressed and held down" rather than a momentary
- * key/switch press.
- *
- * All parameters are customisable which include:-
- *  <ul>
- *  <li> The sampling frequency. </li>
- *  <li> The number of continuous samples until a state change is detected. </li> 
- *  <li> The number of continuous samples until a key is assumed held after a state change. </li>
- *  <li> The logic level which is assumed to be asserted (0volts or +volts). </li>
- *  </ul>
- *
- * Only callbacks that have been attached will be called by the library.
- *
- * Example:
- * @code
- * #include "mbed.h"
- * #include "PinDetect.h"
- *
- * PinDetect  pin( p30 );
- * DigitialOut led1( LED1 );
- * DigitialOut led2( LED2 );
- * DigitialOut led3( LED3 );
- * DigitialOut led4( LED4 );
- *
- * void keyPressed( void ) {
- *     led2 = 1;
- *     led3 = 0;
- *     led4 = 0;
- * }
- *
- * void keyReleased( void ) {
- *     led2 = 0;
- *     led3 = 0;
- *     led4 = 0;
- * }
- *
- * void keyPressedHeld( void ) {
- *     led3 = 1;
- * }
- *
- * void keyReleasedHeld( void ) {
- *     led4 = 1;
- * }
- *
- * int main() {
- *
- *     pin.mode( PullDown );
- *     pin.attach_asserted( &keyPressed );
- *     pin.attach_deasserted( &keyReleased );
- *     pin.attach_asserted_held( &keyPressedHeld );
- *     pin.attach_deasserted_held( &keyReleasedHeld );
- *
- *     // Sampling does not begin until you set a frequency.
- *     // The default is 20ms. If you want a different frequency
- *     // then pass the period in microseconds for example, for 10ms :-
- *     //     pin.setSampleFrequency( 10000 );
- *     //
- *     pin.setSampleFrequency(); // Defaults to 20ms.
- *
- *     while( 1 ) {
- *         led1 = !led1;
- *         wait( 0.2 );
- *     }
- * }
- * @endcode
- *
- * This example will flash led1 in a similar to a standard starting program.
- *
- * Applying a "1" (switch on) to pin 30 will switch on led2, removing the "1" to "0"
- * (switch off) led2 goes out. Holding the "switch" at one for one second will switch
- * on led3. An unasserted P30 (switched off) will, after one second illuminate led4
- * when the deasserted calledback is called.
- *
- * The above is a very basic introduction. For more details:-
- * @see example.h
- */
-class PinDetect {
-
-protected:
-    DigitalIn   *_in;
-    Ticker      *_ticker;
-    int         _prevState;
-    int         _currentStateCounter;
-    int         _sampleTime;
-    int         _assertValue;
-    int         _samplesTillAssertReload;
-    int         _samplesTillAssert;
-    int         _samplesTillHeldReload;
-    int         _samplesTillHeld;
-    FunctionPointer _callbackAsserted;
-    FunctionPointer _callbackDeasserted;
-    FunctionPointer _callbackAssertedHeld;
-    FunctionPointer _callbackDeassertedHeld;
-    
-    /** initialise class
-     *
-     * @param PinName p is a valid pin that supports DigitalIn
-     * @param PinMode m The mode the DigitalIn should use.
-     */
-    void init(PinName p, PinMode m) {
-        _sampleTime              = PINDETECT_SAMPLE_PERIOD;
-        _samplesTillAssert       = PINDETECT_ASSERT_COUNT;
-        _samplesTillHeld         = 0;
-        _samplesTillAssertReload = PINDETECT_ASSERT_COUNT;
-        _samplesTillHeldReload   = PINDETECT_HOLD_COUNT;
-        _assertValue             = PINDETECT_PIN_ASSTERED;
-        
-        _in = new DigitalIn( p );
-        _in->mode( m );        
-        _prevState = _in->read();        
-        _ticker = new Ticker;
-    }
-    
-public:
-
-    friend class Ticker;
-    
-    PinDetect() { error("You must supply a PinName"); }
-
-    /** PinDetect constructor
-     *
-     * By default the PinMode is set to PullDown.
-     *
-     * @see http://mbed.org/handbook/DigitalIn
-     * @param p PinName is a valid pin that supports DigitalIn
-     */    
-    PinDetect(PinName p) {
-        init( p, PullDown );
-    }
-
-    /** PinDetect constructor
-     *
-     * @see http://mbed.org/handbook/DigitalIn
-     * @param PinName p is a valid pin that supports DigitalIn
-     * @param PinMode m The mode the DigitalIn should use.
-     */    
-    PinDetect(PinName p, PinMode m) {
-        init( p, m );
-    }
-    
-    /** PinDetect destructor
-     */    
-    ~PinDetect() {
-        if ( _ticker )  delete( _ticker );
-        if ( _in )      delete( _in );
-    }
-    
-    /** Set the sampling time in microseconds.
-     *
-     * @param int The time between pin samples in microseconds.
-     */
-    void setSampleFrequency(int i = PINDETECT_SAMPLE_PERIOD) { 
-        _sampleTime = i; 
-        _prevState  = _in->read();        
-        _ticker->attach_us( this, &PinDetect::isr, _sampleTime );
-    }
-    
-    /** Set the value used as assert.
-     *
-     * Defaults to 1 (ie if pin == 1 then pin asserted).
-     *
-     * @param int New assert value (1 or 0)
-     */
-    void setAssertValue (int i = PINDETECT_PIN_ASSTERED) { _assertValue = i & 1; }
-    
-    /** Set the number of continuous samples until assert assumed.
-     *
-     * Defaults to 1 (1 * sample frequency).
-     *
-     * @param int The number of continuous samples until assert assumed.
-     */    
-    void setSamplesTillAssert(int i) { _samplesTillAssertReload = i; }
-    
-    /** Set the number of continuous samples until held assumed.
-     *
-     * Defaults to 50 * sample frequency.
-     *
-     * @param int The number of continuous samples until held assumed.
-     */    
-    void setSamplesTillHeld(int i) { _samplesTillHeldReload = i; }
-    
-    /** Set the pin mode.
-     *
-     * @see http://mbed.org/projects/libraries/api/mbed/trunk/DigitalInOut#DigitalInOut.mode
-     * @param PinMode m The mode to pass on to the DigitalIn
-     */
-    void mode(PinMode m) { _in->mode( m ); }
-    
-    /** Attach a callback function 
-     *
-     * @code
-     *
-     * DigitalOut led1( LED1 );
-     * PinDetect pin( p30 );
-     *
-     * void myCallback( void ) {
-     *   led1 = 1;
-     * };
-     * 
-     * main() {
-     *     pin.attach_asserted( &myCallback );
-     * }
-     *
-     * @endcode
-     *
-     * Call this function when a pin is asserted.
-     * @param function A C function pointer
-     */
-    void attach_asserted(void (*function)(void)) {
-        _callbackAsserted.attach( function );
-    }
-    
-    /** Attach a callback object/method 
-     *
-     * @code
-     *
-     * class Bar {
-     *   public:
-     *     void myCallback( void ) { led1 = 1; }
-     * };
-     *
-     * DigitalOut led1( LED1 );
-     * PinDetect pin( p30 );
-     * Bar bar;
-     *
-     * main() {
-     *     pin.attach_asserted( &bar, &Bar::myCallback );
-     * }
-     *
-     * @endcode
-     *
-     * Call this function when a pin is asserted.
-     * @param object An object that conatins the callback method.
-     * @param method The method within the object to call.
-     */
-    template<typename T>
-    void attach_asserted(T *object, void (T::*member)(void)) {
-        _callbackAsserted.attach( object, member );        
-    }
-    
-    /** Attach a callback function 
-     *
-     * @code
-     *
-     * DigitalOut led1( LED1 );
-     * PinDetect pin( p30 );
-     *
-     * void myCallback( void ) {
-     *   led1 = 0;
-     * };
-     *
-     * main() {
-     *     pin.attach_deasserted( &myCallback );
-     * }
-     *
-     * @endcode
-     *
-     * Call this function when a pin is deasserted.
-     * @param function A C function pointer
-     */
-    void attach_deasserted(void (*function)(void)) {
-        _callbackDeasserted.attach( function );
-    }
-    
-    /** Attach a callback object/method
-     *
-     * @code
-     *
-     * class Bar {
-     *   public:
-     *     void myCallback( void ) { led1 = 0; }
-     * };
-     *
-     * DigitalOut led1( LED1 );
-     * PinDetect pin( p30 );
-     * Bar bar;
-     * 
-     * main() {
-     *     pin.attach_deasserted( &bar, &Bar::myCallback );
-     * }
-     *
-     * @endcode
-     *
-     * Call this function when a pin is deasserted.
-     * @param object An object that conatins the callback method.
-     * @param method The method within the object to call.
-     */
-    template<typename T>
-    void attach_deasserted(T *object, void (T::*member)(void)) {
-        _callbackDeasserted.attach( object, member );        
-    }
-    
-    /** Attach a callback function 
-     *
-     * @code
-     *
-     * DigitalOut led2( LED2 );
-     * PinDetect pin( p30 );
-     *
-     * void myCallback( void ) {
-     *   led2 = 1;
-     * };
-     *
-     * main() {
-     *     pin.attach_asserted_held( &myCallback );
-     * }
-     *
-     * @endcode
-     *
-     * Call this function when a pin is asserted and held.
-     * @param function A C function pointer
-     */
-    void attach_asserted_held(void (*function)(void)) {
-        _callbackAssertedHeld.attach( function );
-    }
-    
-    /** Attach a callback object/method
-     *
-     * @code
-     *
-     * class Bar {
-     *   public:
-     *     void myCallback( void ) { led2 = 0; }
-     * };
-     *
-     * DigitalOut led2( LED2 );
-     * PinDetect pin( p30 );
-     * Bar bar;
-     * 
-     * main() {
-     *     pin.attach_asserted_held( &bar, &Bar::myCallback );
-     * }
-     *
-     * @endcode
-     *
-     * Call this function when a pin is asserted and held.
-     * @param object An object that conatins the callback method.
-     * @param method The method within the object to call.
-     */
-    template<typename T>
-    void attach_asserted_held(T *object, void (T::*member)(void)) {
-        _callbackAssertedHeld.attach( object, member );        
-    }
-    
-    /** Attach a callback function 
-     *
-     * @code
-     *
-     * DigitalOut led3( LED3 );
-     * PinDetect pin( p30 );
-     *
-     * void myCallback( void ) {
-     *   led3 = 1;
-     * };
-     *
-     * main() {
-     *     pin.attach_deasserted_held( &myCallback );
-     * }
-     *
-     * @endcode
-     *
-     * Call this function when a pin is deasserted and held.
-     * @param function A C function pointer
-     */
-    void attach_deasserted_held(void (*function)(void)) {
-        _callbackDeassertedHeld.attach( function );
-    }
-    
-    /** Attach a callback object/method
-     *
-     * @code
-     *
-     * class Bar {
-     *   public:
-     *     void myCallback( void ) { led3 = 0; }
-     * };
-     *
-     * DigitalOut led3( LED3 );
-     * PinDetect pin( p30 );
-     * Bar bar;
-     * 
-     * main() {
-     *     pin.attach_deasserted_held( &bar, &Bar::myCallback );
-     * }
-     *
-     * @endcode
-     *
-     * Call this function when a pin is deasserted and held.
-     * @param object An object that conatins the callback method.
-     * @param method The method within the object to call.
-     */
-    template<typename T>
-    void attach_deasserted_held(T *object, void (T::*member)(void)) {
-        _callbackDeassertedHeld.attach( object, member );        
-    }
-    
-    /** operator int()
-     *
-     * Read the value of the pin being sampled.
-     */
-    operator int() { return _in->read(); }
-
-protected:    
-    /** The Ticker periodic callback function
-     */
-    void isr(void) {
-        int currentState = _in->read();
-    
-        if ( currentState != _prevState ) {
-            if ( _samplesTillAssert == 0 ) {
-                _prevState = currentState;
-                _samplesTillHeld = _samplesTillHeldReload;
-                if ( currentState == _assertValue ) 
-                    _callbackAsserted.call();
-                else                              
-                    _callbackDeasserted.call();
-            }
-            else {
-                _samplesTillAssert--;
-            }
-        }
-        else {
-            _samplesTillAssert = _samplesTillAssertReload;
-        }
-        
-        if ( _samplesTillHeld ) {
-            if ( _prevState == currentState ) {
-                _samplesTillHeld--;
-                if ( _samplesTillHeld == 0 ) {
-                    if ( currentState == _assertValue ) 
-                        _callbackAssertedHeld.call();
-                    else                              
-                        _callbackDeassertedHeld.call();
-                }
-            }
-            else {
-                _samplesTillHeld = 0;
-            }
-        }
-    }
-    
-};
-
-}; // namespace AjK ends.
-
-using namespace AjK;
-
-#endif
--- a/STANAG_Codes.cpp	Fri Aug 26 20:35:11 2011 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,249 +0,0 @@
-/* STANAG Codes - LTD STANAG Codes
- * Copyright (c) 2011 Wim Huiskamp
- *
- * Released under the MIT License: http://mbed.org/license/mit
- *
- * version 0.2 Initial Release
-*/
-#include "mbed.h"
-#include "STANAG_Codes.h"
-
-
-/** Create a STANAG Codes object
- *
- * @param  none
- * @brief
-*/
-STANAG_Codes::STANAG_Codes() {
-
-  _init(); 
-}
-
-/** Init STANAG_Codes()
- * @param
- * @returns 
- */
-void STANAG_Codes::_init(void) {
-
-  for (_codeIdx=0; _codeIdx < D_STANAG_CODES; _codeIdx++) {
- 
-    for (_digitIdx=0; _digitIdx < D_STANAG_DIGITS; _digitIdx++) {
-      _codes[_codeIdx][_digitIdx] = STANAG_DEFAULTS[_codeIdx][_digitIdx];
-    }
-  }
-
-#if(0)
-  for (_codeIdx=0; _codeIdx < D_STANAG_CODES; _codeIdx++) {
-     _codes[_codeIdx] = STANAG_DEFAULTS[_codeIdx];
-  }
-#endif
-
-  _codeIdx = 0;
-  _digitIdx = 0;
-}
-
-
-/** Set the code Index of the selected STANAG Code
- * @param uint8_t codeIdx
- * @returns value of STANAG code Index
- */
-uint8_t STANAG_Codes::setCodeIdx(uint8_t codeIdx) {
-  
-  //Check upper boundary
-  if (codeIdx > D_STANAG_CODES-1) {
-    _codeIdx = D_STANAG_CODES-1;  
-  }
-  else {
-    _codeIdx = codeIdx;
-  };
- 
-  return _codeIdx;
-}
-    
-    
-/** Get code Index of the selected STANAG Code
- * @param 
- * @returns value of STANAG code Index
- */
-uint8_t STANAG_Codes::getCodeIdx() {
- 
-  return _codeIdx;
-}
-    
-
-/** Increment code Index of the selected STANAG Code
- * @param 
- * @returns value of STANAG code Index
- */
-uint8_t STANAG_Codes::incCodeIdx() {
-
-  _codeIdx++;
-  
-  //Check upper boundary and wrap around
-  if (_codeIdx > D_STANAG_CODES-1) {
-      _codeIdx = 0;  
-  };
- 
-  return _codeIdx;
-}
-
-
-/** Set the digit index of the selected STANAG Code
- * @param uint8_t digitIdx
- * @returns value of the digit index
- */
-uint8_t STANAG_Codes::setDigitIdx(uint8_t digitIdx) {
-  
-  //Check upper boundary
-  if (digitIdx > D_STANAG_DIGITS-1) {
-    _digitIdx = D_STANAG_DIGITS-1;  
-  }
-  else {
-    _digitIdx = digitIdx;
-  };
- 
-  return _digitIdx;
-}
-    
-    
-/** Get digit Index of the selected STANAG Code
- * @param 
- * @returns value of digit Index
- */
-uint8_t STANAG_Codes::getDigitIdx() {
- 
-  return _digitIdx;
-}
-    
-
-/** Increment digit Index of the selected STANAG Code
- * @param 
- * @returns value of digit Index
- */
-uint8_t STANAG_Codes::incDigitIdx() {
-
-  _digitIdx++;
-  
-  //Check upper boundary and wrap around
-  if (_digitIdx > D_STANAG_DIGITS-1) {
-      _digitIdx = 0;  
-  };
- 
-  return _digitIdx;
-}
-
-
-/** Increment Digit of the selected STANAG Code
- * @param 
- * @returns value of Digit
- */
-uint8_t STANAG_Codes::incDigit() {
-  uint8_t digit;
-  
-  //Get digit value and increment
-  digit = _codes[_codeIdx][_digitIdx];
-  digit++;
-  
-//NOTE: maybe additional checks required. Valid codes seem to start with a "1" ???
- 
-  //Check upper boundary and wrap around
-  if (digit > 9) {
-    digit=0;   
-  };
- 
-  // Save updated digit
-  _codes[_codeIdx][_digitIdx]=digit;
-  
-  return digit;
-}
-
-   
-
-/** Compute the integer value of the selected STANAG Code
- * @param uint8_t codeIdx
- * @returns integer value of STANAG code
- */
-int STANAG_Codes::getCode(uint8_t codeIdx) {
-  uint8_t digitIdx;
-  int code;
-  
-  code=0;
-  for (digitIdx=0; digitIdx < D_STANAG_DIGITS; digitIdx++) {
-
-    // ..., thousands, hundreds, tens, units    
-    code = code + _codes[codeIdx][digitIdx] * DECIMALS[D_STANAG_DIGITS - 1 - digitIdx];    
-  };  
-    
-  return code;
-}     
-
-
-/** Compute the integer value of the currently selected STANAG Code
- * @param 
- * @returns integer value of STANAG code
- */
-int STANAG_Codes::getCode() {
-    
-  return getCode(_codeIdx);
-}     
-
-
-/** Compute and Set the digits of the selected STANAG Code
- * @param uint8_t codeIdx
- * @param int code 
- * @returns valid integer value of STANAG code
- */
-int STANAG_Codes::setCode(uint8_t codeIdx, int code) {
-  uint8_t digitIdx;
-  int temp;
-
-  //Check lower boundary
-  if (code<0) {
-    code=0;
-  }
-  else {
-    //Check upper boundary
-    if (code > DECIMALS[D_STANAG_DIGITS]) {
-      code = DECIMALS[D_STANAG_DIGITS] - 1;
-    }
-  };
-
-  // Extract decimal digits
-  temp=code;
-  for (digitIdx=0; digitIdx < D_STANAG_DIGITS; digitIdx++) {
-    
-    // ..., thousands, hundreds, tens, units
-    _codes[codeIdx][digitIdx] = temp / DECIMALS[D_STANAG_DIGITS - 1 - digitIdx];  // Extract most significant decimal digit
-    temp = temp % DECIMALS[D_STANAG_DIGITS - 1 - digitIdx];                       // Remainder for next digit  
-  };  
-    
-  return code;
-}     
-
-
-/** Compute and Set the digits of the currently selected STANAG Code
- * @param int code 
- * @returns valid integer value of STANAG code
- */
-int STANAG_Codes::setCode(int code) {
-    
-  return setCode(_codeIdx, code);
-}     
-
-
-
-#if(0)
-int STANAG_Codes::setCodeDigits(uint8_t codeIdx, STANAG_Code_t STANAG_code) {
-}    
-
-STANAG_Code_t STANAG_Codes::getCodeDigits(uint8_t codeIdx) {
-} 
-#endif
- 
-
-
-/*****************************************************************************/
-/******************************  END OF FILE  ********************************/
-/*****************************************************************************/
-
-
--- a/STANAG_Codes.h	Fri Aug 26 20:35:11 2011 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-/* STANAG Codes - LTD STANAG Codes
- * Copyright (c) 2011 Wim Huiskamp
- *
- * Released under the MIT License: http://mbed.org/license/mit
- *
- * version 0.2 Initial Release
-*/
-#ifndef _STANAG_H
-#define _STANAG_H
-
-/*****************************************************************************/
-/*********************  DEFINITIONS FOR STANAG   *****************************/
-/*****************************************************************************/
-
-// Definitions
-#define D_STANAG_CODES              20
-#define D_STANAG_DIGITS              4
-
-// Typedefs
-typedef uint8_t STANAG_Code_t[D_STANAG_DIGITS];
-
-const int DECIMALS[D_STANAG_DIGITS+1] = {1, 10, 100, 1000, 10000};
-
-const STANAG_Code_t STANAG_DEFAULTS[D_STANAG_CODES] = {{1,0,0,0},{1,0,0,1},{1,0,0,2},{1,0,0,3},{1,0,0,4},
-                                                       {1,0,1,0},{1,0,1,1},{1,0,1,2},{1,0,1,3},{1,0,1,4},
-                                                       {1,0,2,0},{1,0,2,1},{1,0,2,2},{1,0,2,3},{1,0,2,4},
-                                                       {1,0,3,0},{1,0,3,1},{1,0,3,2},{1,0,3,3},{1,0,3,4}};
-
-// Masks
-
-// Enums
-
-/** Create a STANAG Codes object
- *
- * @param  none
- * @brief
-*/
-class STANAG_Codes {
-public:
-    STANAG_Codes();
-    uint8_t setCodeIdx(uint8_t codeIdx);
-    uint8_t getCodeIdx();
-    uint8_t incCodeIdx();
-            
-    uint8_t setDigitIdx(uint8_t digitIdx);    
-    uint8_t getDigitIdx();                    
-    uint8_t incDigitIdx();                        
-    uint8_t incDigit();                            
-    
-    int setCode(uint8_t codeIdx, int code);    
-    int getCode(uint8_t codeIdx);        
-    int setCode(int code);    
-    int getCode();        
-    
-//  int setCodeDigits(uint8_t codeIdx, STANAG_Code_t STANAG_code);    
-//  STANAG_Code_t getCodeDigits(uint8_t codeIdx); 
-   
-protected:
-    uint8_t _codeIdx;
-    uint8_t _digitIdx;
-//    int     _codes[D_STANAG_CODES][D_STANAG_DIGITS];
-    STANAG_Code_t _codes[D_STANAG_CODES];
-    
-    void _init();          
-};
-
-
-#endif
-/*****************************************************************************/
-/******************************  END OF FILE  ********************************/
-/*****************************************************************************/
-
--- a/Status_Display.cpp	Fri Aug 26 20:35:11 2011 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,355 +0,0 @@
-/* Status_Display - LED Status Display control
- * Copyright (c) 2011 Wim Huiskamp
- *
- * Released under the MIT License: http://mbed.org/license/mit
- *
- * version 0.2 Initial Release
-*/
-#include "mbed.h"
-#include "PCF8574_DataBus.h"
-#include "PCF8574_EnableBus.h"
-#include "MBED_ControlBus.h"
-#include "Status_Display.h"
-
-
-/** Create a Status_Display object connected to the specified buses
- *
- * @param  PCF8574_DataBus data databus to connect to 
- * @param  PCF8574_EnableBus enable enablebus to connect to 
- * @param  MBED_ControlBus control controlbus to connect to 
-*/
-Status_Display::Status_Display (PCF8574_DataBus &databus, PCF8574_EnableBus &enablebus, MBED_ControlBus &controlbus) : 
-                                     _databus(databus), _enablebus(enablebus), _controlbus(controlbus) {
-   _init();
-}    
-
-/** Init Status_Display
- * @param
- * @returns 
- *
- * @brief
- */
-void Status_Display::_init(void)
-{
-    // Apply reset
-//    reset();  // Note that this would also reset the Alphanumeric display. 
-
-    _latch1     = 0x00;                    // Make sure that all LEDs are disabled
-    _latch2     = 0x00;                    // Make sure that all LEDs are disabled 
-    _brightness = D_STATUS_LED_BRIGHT_DEF; // Default Brightness  
-
-    _write_latch1();                       // Write Status LED 
-    _write_latch2();                       // Write Status LED 
-    _write_latchbrightness();              // Write Brightness 
-
-    NoGo (LED_OFF);                        // NoGo Off (separate control)          
-}
-
-
-/** Set or Reset LED lamptest, note that current LED state is lost
- *
- * @param LED_State led_state
- *
- * @brief 
-*/
-void Status_Display::lamptest (LED_State led_state) {
-    int result = 1;
-    
-    if (led_state == LED_ON) {
-      // Status LEDs controlled by Latch1     
-      _latch1 = D_STATUS_LED_MULT | D_STATUS_LED_LASER | D_STATUS_LED_BATT | D_STATUS_LED_TEMP | D_STATUS_LED_ENRGY;
-      // Backlight On      
-      _latch1 |= D_STATUS_BACKLIGHT;
-
-      // Status LEDs controlled by Latch2 
-      _latch2 = D_STATUS_LED_CODE | D_STATUS_LED_RANGE | D_STATUS_LED_DESIG | D_STATUS_LED_ADDR | D_STATUS_LED_FREQ | D_STATUS_LED_PATH;
-
-      // NoGo On (separate control)     
-      NoGo (LED_ON);
-    }
-    else {
-      _latch1     = 0x00;                    // Make sure that all LEDs are disabled
-      _latch2     = 0x00;                    // Make sure that all LEDs are disabled 
-      
-      // NoGo Off (separate control)          
-      NoGo (LED_OFF);    
-    }  
-
-    // Write LED status
-    _write_latch1();
-    _write_latch2();           
-}
-
-
-
-/** Set or Reset Status LEDs
- *
- * @param LED_Pin led_pin 
- * @param LED_State led_state
- *
- * @brief 
-*/
-void Status_Display::LED (LED_Pin led_pin, LED_State led_state) {
-    int result = 1;
-      
-    switch (led_pin) {
-// Status LEDs controlled by Latch1 
-     case LED_MULT : if (led_state == LED_ON)
-                         _latch1 |= D_STATUS_LED_MULT;      // LED Pin High
-                      else
-                         _latch1 &= ~D_STATUS_LED_MULT;     // LED Pin Low
-                      break;
-     case LED_LASER : if (led_state == LED_ON)
-                         _latch1 |= D_STATUS_LED_LASER;     // LED Pin High
-                      else
-                         _latch1 &= ~D_STATUS_LED_LASER;    // LED Pin Low
-                      break;
-     case LED_BATT : if (led_state == LED_ON)
-                         _latch1 |= D_STATUS_LED_BATT;      // LED Pin High
-                      else
-                         _latch1 &= ~D_STATUS_LED_BATT;     // LED Pin Low
-                      break;
-     case LED_TEMP : if (led_state == LED_ON)
-                         _latch1 |= D_STATUS_LED_TEMP;      // LED Pin High
-                      else
-                         _latch1 &= ~D_STATUS_LED_TEMP;     // LED Pin Low
-                      break;
-     case LED_ENRGY : if (led_state == LED_ON)
-                         _latch1 |= D_STATUS_LED_ENRGY;     // LED Pin High
-                      else
-                         _latch1 &= ~D_STATUS_LED_ENRGY;    // LED Pin Low
-                      break;
-
-// Status LEDs controlled by Latch2 
-     case LED_CODE : if (led_state == LED_ON)
-                         _latch2 |= D_STATUS_LED_CODE;      // LED Pin High
-                      else
-                         _latch2 &= ~D_STATUS_LED_CODE;     // LED Pin Low
-                      break;
-     case LED_RANGE : if (led_state == LED_ON)
-                         _latch2 |= D_STATUS_LED_RANGE;     // LED Pin High
-                      else
-                         _latch2 &= ~D_STATUS_LED_RANGE;    // LED Pin Low
-                      break;
-     case LED_DESIG : if (led_state == LED_ON)
-                         _latch2 |= D_STATUS_LED_DESIG;     // LED Pin High
-                      else
-                         _latch2 &= ~D_STATUS_LED_DESIG;    // LED Pin Low
-                      break;
-     case LED_ADDR : if (led_state == LED_ON)
-                         _latch2 |= D_STATUS_LED_ADDR;      // LED Pin High
-                      else
-                         _latch2 &= ~D_STATUS_LED_ADDR;     // LED Pin Low
-                      break;
-     case LED_FREQ : if (led_state == LED_ON)
-                         _latch2 |= D_STATUS_LED_FREQ;      // LED Pin High
-                      else
-                         _latch2 &= ~D_STATUS_LED_FREQ;     // LED Pin Low
-                      break;
-     case LED_PATH : if (led_state == LED_ON)
-                         _latch2 |= D_STATUS_LED_PATH;      // LED Pin High
-                      else
-                         _latch2 &= ~D_STATUS_LED_PATH;     // LED Pin Low
-                      break;
-     
-     default:          // Oops, we should never end up here....
-                      result = -1;
-    }
-
-    _write_latch1();                                 // Write LED status
-    _write_latch2();           
-}
-
-
-/** Set or Clear the NoGo LED
- *
- * @param LED_State nogo_state
- *
- * @brief 
-*/
-void Status_Display::NoGo(LED_State NoGo_state) {
-  // Note that the NoGo LED has a separate pin and is directly connected to the Enable bus
-  // The LED is controlled from this class because it is more convenient and logical
-  
-  if (NoGo_state == LED_ON) {
-    _enablebus.nogo(LOW);     // NoGo LED On
-  }              
-  else {
-    _enablebus.nogo(HIGH);    // NoGo LED Off
-  }     
-  
-}
-               
-/** Set or Clear the Backlight
- *
- * @param LED_State led_state
- *
- * @brief 
-*/
-void Status_Display::backlight (LED_State backlight_state) {
-
-    if (backlight_state == LED_ON) {
-        _latch1 |= D_STATUS_BACKLIGHT;     // Backlight On
-      }               
-    else {
-        _latch1 &= ~D_STATUS_BACKLIGHT;    // Backlight Off
-    }     
-    
-    _write_latch1();                       // Write Backlight state
-}
- 
-
-/** Set Backlight and Status LEDs Brightness
- *
- * @param uint8_t brightness
- *
- * @brief 
-*/
-void Status_Display::set_brightness (uint8_t brightness) {
-
-    _brightness = brightness & STATUS_LED_BRIGHT_MASK;   
-
-    _write_latchbrightness();               // Write Brightness value
-}
- 
-
-/** Set Backlight and Status LEDs Brightness
- *
- * @param Brightness brightness
- *
- * @brief 
-*/
-void Status_Display::set_brightness (Brightness brightness) {
-
-    switch (brightness) {
-     case BRT_OFF : set_brightness(D_STATUS_LED_BRIGHT_OFF);
-                    break;
-     case BRT_LOW : set_brightness(D_STATUS_LED_BRIGHT_LOW);
-                    break;
-     case BRT_MED : set_brightness(D_STATUS_LED_BRIGHT_MED);
-                    break;
-     case BRT_HIGH : set_brightness(D_STATUS_LED_BRIGHT_HGH);
-                    break;
-     default:       // Oops, we should never end up here....
-                    set_brightness(D_STATUS_LED_BRIGHT_DEF);
-    }
-                      
-}
- 
-
-/** Write Latch1 value
- *
- * @param  none
- *
- * @brief 
-*/
-void Status_Display::_write_latch1()
-{
-//    // Switch databus buffer to outputs
-//    _controlbus.busdir(WRITE);        
-//    // Switch databus to outputs
-//    _databus.busdir(WRITE);        
-    
-    // Set CE low and wait
-    _enablebus.chipselect(LATCHEN_1, LOW);  
-    wait_ms(STATUS_1TCY_WAIT_MS);
-
-    // Write data to the databus
-    _databus.write(_latch1);        
- 
-    // Set WR low, wait, then set high and wait
-    _controlbus.WR(LOW);
-    wait_ms(STATUS_1TCY_WAIT_MS);
-    _controlbus.WR(HIGH);
-    wait_ms(STATUS_1TCY_WAIT_MS);
-
-
-    // Set CE high and wait
-    _enablebus.chipselect(LATCHEN_1, HIGH);  
-    wait_ms(STATUS_1TCY_WAIT_MS);
-
-    
-//    // Switch databus back to inputs
-//    _databus.busdir(READ);        
-//    // Switch databus buffer back to inputs
-//    _controlbus.busdir(READ);        
-
-}
-
-
-/** Write Latch2 value
- *
- * @param none
- *
- * @brief 
-*/
-void Status_Display::_write_latch2()
-{
-//    // Switch databus buffer to outputs
-//    _controlbus.busdir(WRITE);        
-//    // Switch databus to outputs
-//    _databus.busdir(WRITE);        
-    
-    // Set CE low and wait
-    _enablebus.chipselect(LATCHEN_2, LOW);  
-    wait_ms(STATUS_1TCY_WAIT_MS);
-
-    // Write data to the databus
-    _databus.write(_latch2);        
- 
-    // Set WR low, wait, then set high and wait
-    _controlbus.WR(LOW);
-    wait_ms(STATUS_1TCY_WAIT_MS);
-    _controlbus.WR(HIGH);
-    wait_ms(STATUS_1TCY_WAIT_MS);
-
-    // Set CE high and wait
-    _enablebus.chipselect(LATCHEN_2, HIGH);  
-    wait_ms(STATUS_1TCY_WAIT_MS);
-
-    
-//    // Switch databus back to inputs
-//    _databus.busdir(READ);        
-//    // Switch databus buffer back to inputs
-//    _controlbus.busdir(READ);        
-
-}
-
-/** Write Brightness value
- *
- * @param none
- *
- * @brief 
-*/
-void Status_Display::_write_latchbrightness()
-{
-//    // Switch databus buffer to outputs
-//    _controlbus.busdir(WRITE);        
-//    // Switch databus to outputs
-//    _databus.busdir(WRITE);        
-    
-    // Set CE low and wait
-    _enablebus.chipselect(CS_BRIGHT, LOW);  
-    wait_ms(STATUS_1TCY_WAIT_MS);
-
-    // Write data to the databus
-    _databus.write(_brightness);        
- 
-    // Set WR low, wait, then set high and wait
-    _controlbus.WR(LOW);
-    wait_ms(STATUS_1TCY_WAIT_MS);
-    _controlbus.WR(HIGH);
-    wait_ms(STATUS_1TCY_WAIT_MS);
-
-    // Set CE high and wait
-    _enablebus.chipselect(CS_BRIGHT, HIGH);  
-    wait_ms(STATUS_1TCY_WAIT_MS);
-
-    
-//    // Switch databus back to inputs
-//    _databus.busdir(READ);        
-//    // Switch databus buffer back to inputs
-//    _controlbus.busdir(READ);        
-
-}
-
--- a/Status_Display.h	Fri Aug 26 20:35:11 2011 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,116 +0,0 @@
-/* Status_Display - LED status indicators
- * Copyright (c) 2011 Wim Huiskamp
- *
- * Released under the MIT License: http://mbed.org/license/mit
- *
- * version 0.2 Initial Release
-*/
-#ifndef _STATUS_DISPLAY_H
-#define _STATUS_DISPLAY_H
-
-//Useful stuff to simplify porting of some third party software
-#include "Utils.h"
-
-/*****************************************************************************/
-/*********************  DEFINITIONS FOR STATUS DISPLAY ** ********************/
-/*****************************************************************************/
-
-// Specific delays for display operation
-#define STATUS_1TCY_WAIT_MS         1
-
-// Definitions for Latch1 of Status LEDs
-#define D_STATUS_LED_MULT           0x01
-#define D_STATUS_LED_LASER          0x02
-#define D_STATUS_LED_BATT           0x04
-#define D_STATUS_LED_TEMP           0x08
-#define D_STATUS_LED_ENRGY          0x10
-#define D_STATUS_LED_NOTUSED_15     0x20
-#define D_STATUS_LED_NOTUSED_16     0x40
-#define D_STATUS_BACKLIGHT          0x80
-
-// Definitions for Latch2 of Status LEDs
-#define D_STATUS_LED_NOTUSED_20     0x01
-#define D_STATUS_LED_CODE           0x02
-#define D_STATUS_LED_RANGE          0x04
-#define D_STATUS_LED_DESIG          0x08
-#define D_STATUS_LED_ADDR           0x10
-#define D_STATUS_LED_FREQ           0x20
-#define D_STATUS_LED_PATH           0x40
-#define D_STATUS_LED_NOTUSED_27     0x80
-
-
-// Definitions for LatchBrightness of Status LEDs
-// Value indicates cd/m2
-#define D_STATUS_LED_BRIGHT_000     0x00
-#define D_STATUS_LED_BRIGHT_022     0x01
-#define D_STATUS_LED_BRIGHT_053     0x02
-#define D_STATUS_LED_BRIGHT_112     0x03
-#define D_STATUS_LED_BRIGHT_253     0x04
-#define D_STATUS_LED_BRIGHT_570     0x05
-#define D_STATUS_LED_BRIGHT_129     0x06
-#define D_STATUS_LED_BRIGHT_360     0x07
-
-// control word masks for Status LEDs
-#define STATUS_LED_BRIGHT_MASK      0x07 
-
-// Display brightness modes
-//#define D_STATUS_LED_BRIGHT_OFF     D_STATUS_LED_BRIGHT_000
-//#define D_STATUS_LED_BRIGHT_LOW     D_STATUS_LED_BRIGHT_053
-//#define D_STATUS_LED_BRIGHT_MED     D_STATUS_LED_BRIGHT_570
-//#define D_STATUS_LED_BRIGHT_HGH     D_STATUS_LED_BRIGHT_360
-//Test values
-#define D_STATUS_LED_BRIGHT_OFF     D_STATUS_LED_BRIGHT_053
-#define D_STATUS_LED_BRIGHT_LOW     D_STATUS_LED_BRIGHT_112
-#define D_STATUS_LED_BRIGHT_MED     D_STATUS_LED_BRIGHT_570
-#define D_STATUS_LED_BRIGHT_HGH     D_STATUS_LED_BRIGHT_129
-
-// default display brightness
-#define D_STATUS_LED_BRIGHT_DEF     D_STATUS_LED_BRIGHT_LOW
-
-//Enums for Status LEDs
-enum LED_Pin { LED_MULT, LED_LASER, LED_BATT, LED_TEMP, LED_ENRGY, LED_CODE, LED_RANGE, LED_DESIG, LED_ADDR, LED_FREQ, LED_PATH };
-enum LED_State { LED_ON, LED_OFF};
-
-//Enums for Brightness
-enum Brightness { BRT_OFF, BRT_LOW, BRT_MED, BRT_HIGH };
-
-/** Create a Status_Display object connected to the proper busses
- *
- * @param  PCF8574_DataBus data databus to connect to 
- * @param  PCF8574_EnableBus enable enablebus to connect to 
- * @param  MBED_ControlBus control controlbus to connect to 
-*/
-class Status_Display {
-public:
-    Status_Display(PCF8574_DataBus &databus,
-                   PCF8574_EnableBus &enablebus, MBED_ControlBus &controlbus);
-    void lamptest (LED_State led_state);
-    void LED (LED_Pin led_pin, LED_State led_state);
-    void NoGo(LED_State NoGo_state);
-    void backlight (LED_State backlight_state);
-    void set_brightness(uint8_t brightness);  
-    void set_brightness(Brightness brightness);  
-            
-protected:
-    PCF8574_DataBus &_databus;
-    PCF8574_EnableBus &_enablebus;
-    MBED_ControlBus &_controlbus;
-
-    uint8_t _latch1;
-    uint8_t _latch2;
-    uint8_t _brightness;
-//    void _write_latch1(char data);
-//    void _write_latch2(char data);
-    void _write_latch1();
-    void _write_latch2();
-    void _write_latchbrightness();                
-    void _init(); 
-          
-};
-
-
-#endif
-/*****************************************************************************/
-/******************************  END OF FILE  ********************************/
-/*****************************************************************************/
-
--- a/Testloop.h	Fri Aug 26 20:35:11 2011 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,521 +0,0 @@
-//------------------------------------------------------------//
-// Testing Stuff                                              //   
-//------------------------------------------------------------//
-void show_LEDS () {
-  static int state = 0;
- 
-  switch (state) {
-   case 0: 
-        myled1 = 1;
-        myled2 = 0;
-        myled3 = 0;
-        state = 1;
-        break;
-   case 1: 
-        myled1 = 0;
-        myled2 = 1;
-        myled3 = 0;
-        state = 2;
-        break;
-   case 2:     
-        myled1 = 0;
-        myled2 = 0;
-        myled3 = 1;
-        state = 0;
-        break;
-   }
-}
-
-
-void show_menu() {
-    pc.printf("0: Exit\r");
-    pc.printf("1: Show Menu\r");    
-    pc.printf("2: Send Message\r"); 
-    pc.printf("3: Toggle Heartbeat\r");    
-    pc.printf("4: Show STANAGs\r");        
-    pc.printf("5: Set all STANAGs\r");
-    pc.printf("6: Inc STANAG Code Idx\r"); 
-    pc.printf("7: Inc STANAG Digit Idx\r");                                
-    pc.printf("8: Inc STANAG Digit\r");                                    
-    pc.printf("9: Test I2C Databus\r");                                        
-    pc.printf("A: Test I2C Addressbus\r");                                        
-    pc.printf("E: Test I2C Enablebus\r");        
-    pc.printf("S: Test Status LEDs\r");            
-    pc.printf("B: Test Brightness LEDs\r");                
-    pc.printf("D: Test Display\r");                    
-    pc.printf("K: Test Keyboard\r");                        
-    pc.printf("N: Test STANAG\r");                            
-    pc.printf("\r");                
-}
-
-
-void testloop() {
-  bool running=true;
-  bool run_test=true;  
-  char command;
-  int count;
-  
-    pc.printf("Start Test!\r");
-    show_LEDS();
-    show_menu();
-
-//make sure we see something    
-    LF28A_status.set_brightness(BRT_MED);           
-
-    while(running) {
-    
-       if(pc.readable()) {
-         command = pc.getc();       
-         pc.printf("\r");         
-         show_LEDS();         
-
-         switch (command) {
-          case '0' :
-                     pc.printf("Done\r");                    
-                     running = false;  
-                     break;
-          
-          case '1' :
-                     show_menu();
-                     break;
-                    
-          case '2' :
-                     pc.printf("Hello World!\r");          
-                     break;
-          
-          case '3' :
-                     if (heartbeatflag){
-                       heartbeat_stop();
-                     }
-                     else {
-                       heartbeat_start();
-                     };            
-                     break;
-
-          case '4' :
-                     pc.printf("Show STANAGs\r");  
-                     for (int codeIdx=0; codeIdx < D_STANAG_CODES; codeIdx++) {
-                       pc.printf("Code[%d] = %d\r", codeIdx, STANAG_codes.getCode(codeIdx) );
-                     }  
-                     break;
-
-          case '5' :
-                     pc.printf("Set STANAGs\r");
-                     for (int codeIdx=0; codeIdx < D_STANAG_CODES; codeIdx++) {
-                       STANAG_codes.setCode(codeIdx, 2000 + codeIdx );
-                     }  
-        
-                     break;
- 
-          case '6' :
-                      pc.printf("Inc STANAG Code Idx\r"); 
-                      pc.printf("New Idx = %d\r", STANAG_codes.incCodeIdx() );
-                        
-                      break;
-          case '7' :
-                      pc.printf("Inc STANAG Digit Idx\r"); 
-                      pc.printf("New Idx = %d\r", STANAG_codes.incDigitIdx() );
-                        
-                      break;
- 
-          case '8' :
-                      pc.printf("Inc STANAG Digit\r"); 
-                      pc.printf("New Digit = %d\r", STANAG_codes.incDigit() );
-                        
-                      pc.printf("New Code = %4d\r", STANAG_codes.getCode() );                      
-                      break;
-          case '9' :
-                      pc.printf("Test I2C Databus\r"); 
-                      pc.printf("Press any key to quit...");
-                      count=0;                       
-                      while(! pc.readable()) {
-                        myled2 = 1;      
-                        wait(0.1);
-                        myled2 = 0;
-                        wait(0.1);
-
-                        databus.write(count); 
-                        //addressbus.write(count);
-                        //enablebus.chipselect(CS_DISP, HIGH);
-                        count = (count + 1) & 0xFF;
-                      }                      
-                      
-                      command = pc.getc(); 
-                      pc.printf("..Done\r");                      
-                      
-                      break;
-          case 'A' :
-                      pc.printf("Test I2C Addressbus\r"); 
-                      pc.printf("Press any key to quit...");
-                      count=0;                       
-                      while(! pc.readable()) {
-                        myled2 = 1;      
-                        wait(0.1);
-                        myled2 = 0;
-                        wait(0.1);
-
-                        //databus.write(count); 
-                        addressbus.write(count);
-                        //enablebus.chipselect(CS_DISP, HIGH);
-                        count = (count + 1) & 0xFF;
-                      }                      
-                      
-                      command = pc.getc(); 
-                      pc.printf("..Done\r");                      
-                      
-                      break;
- 
-          case 'E' :
-                      pc.printf("Test I2C Enablebus\r"); 
-                      pc.printf("Press any key to quit...");
-                      count=0;                       
-                      while(! pc.readable()) {
-
-                        myled2 = 1;      
-                        enablebus.chipselect(CS_SWITCH, LOW);                        
-                        wait(0.1);
-                        myled2 = 0;
-//                        enablebus.chipselect(CS_SWITCH, HIGH);                        
-                        wait(0.1);
-
-                        myled2 = 1;      
-                        enablebus.chipselect(LATCHEN_1, LOW);                        
-                        wait(0.1);
-                        myled2 = 0;
-//                        enablebus.chipselect(LATCHEN_1, HIGH);                        
-                        wait(0.1);
-
-                        myled2 = 1;      
-                        enablebus.chipselect(LATCHEN_2, LOW);                        
-                        wait(0.1);
-                        myled2 = 0;
-//                        enablebus.chipselect(LATCHEN_2, HIGH);                        
-                        wait(0.1);
-
-                        myled2 = 1;      
-                        enablebus.chipselect(CS_BRIGHT, LOW);                        
-                        wait(0.1);
-                        myled2 = 0;
-//                        enablebus.chipselect(CS_BRIGHT, HIGH);                        
-                        wait(0.1);
-
-                        myled2 = 1;      
-                        enablebus.chipselect(CS_DISP, LOW);                        
-                        wait(0.1);
-                        myled2 = 0;
-                        enablebus.chipselect(CS_DISP, HIGH);                        
-                        wait(0.1);
-
-                        myled2 = 1;      
-                        enablebus.reset(LOW);                        
-                        wait(0.1);
-                        myled2 = 0;
-                        enablebus.reset(HIGH);                        
-                        wait(0.1);
-
-                        myled2 = 1;      
-                        enablebus.nogo(LOW);                        
-                        wait(0.1);
-                        myled2 = 0;
-                        enablebus.nogo(HIGH);                        
-                        wait(0.1);
-
-                        //databus.write(count); 
-                        //addressbus.write(count);
-                        //count = (count + 1) & 0xFF;
-                      }                      
-                      
-                      command = pc.getc(); 
-                      pc.printf("..Done\r");                      
-                      
-                      break;
-                      
-          case 'S' :
-                      pc.printf("Test Status LEDs\r"); 
-                      pc.printf("Press any key to quit...");
-                      count=0;                       
-                      while(! pc.readable()) {
-                      // LEDs On
-                        LF28A_status.NoGo(LED_ON);
-                        wait(0.1);                        
-                        LF28A_status.LED(LED_LASER, LED_ON);
-                        wait(0.1);                                                
-                        LF28A_status.LED(LED_TEMP, LED_ON);
-                        wait(0.1);
-                                                
-                        LF28A_status.LED(LED_MULT, LED_ON);
-                        wait(0.1);                        
-                        LF28A_status.LED(LED_ENRGY, LED_ON);
-                        wait(0.1);                        
-                        LF28A_status.LED(LED_BATT, LED_ON);
-                        wait(0.1);                        
-                        
-                        LF28A_status.LED(LED_DESIG, LED_ON);
-                        wait(0.1);                        
-                        LF28A_status.LED(LED_RANGE, LED_ON);
-                        wait(0.1);                        
-                        LF28A_status.LED(LED_CODE, LED_ON);
-                        wait(0.1);                        
-                        
-                        LF28A_status.LED(LED_ADDR, LED_ON);
-                        wait(0.1);                        
-                        LF28A_status.LED(LED_FREQ, LED_ON);
-                        wait(0.1);                        
-                        LF28A_status.LED(LED_PATH, LED_ON);
-                        wait(0.1);                        
-                                                                                                                        
-                        LF28A_status.backlight(LED_ON);
-                        wait(0.1);                        
-
-                      // LEDs Off
-                        LF28A_status.NoGo(LED_OFF);
-                        wait(0.1);                        
-                        LF28A_status.LED(LED_LASER, LED_OFF);
-                        wait(0.1);                                                
-                        LF28A_status.LED(LED_TEMP, LED_OFF);
-                        wait(0.1);
-                                                
-                        LF28A_status.LED(LED_MULT, LED_OFF);
-                        wait(0.1);                        
-                        LF28A_status.LED(LED_ENRGY, LED_OFF);
-                        wait(0.1);                        
-                        LF28A_status.LED(LED_BATT, LED_OFF);
-                        wait(0.1);                        
-                        
-                        LF28A_status.LED(LED_DESIG, LED_OFF);
-                        wait(0.1);                        
-                        LF28A_status.LED(LED_RANGE, LED_OFF);
-                        wait(0.1);                        
-                        LF28A_status.LED(LED_CODE, LED_OFF);
-                        wait(0.1);                        
-                        
-                        LF28A_status.LED(LED_ADDR, LED_OFF);
-                        wait(0.1);                        
-                        LF28A_status.LED(LED_FREQ, LED_OFF);
-                        wait(0.1);                        
-                        LF28A_status.LED(LED_PATH, LED_OFF);
-                        wait(0.1);                        
-                                                                                                                        
-                        LF28A_status.backlight(LED_OFF);
-                        wait(0.1);                        
-                      }                      
-                      
-                      command = pc.getc(); 
-                      pc.printf("..Done\r");                      
-                      
-                      break;                      
-
-          case 'B' :
-                      pc.printf("Test Brightness LEDs\r"); 
-                      pc.printf("Press any key to quit...");
-
-                      // LEDs On
-                      LF28A_status.NoGo(LED_ON);
-                      LF28A_status.LED(LED_LASER, LED_ON);
-                      LF28A_status.LED(LED_TEMP, LED_ON);
-
-                      while(! pc.readable()) {
-                        LF28A_status.set_brightness(BRT_LOW); 
-                        wait(0.5);
-                        LF28A_status.set_brightness(BRT_MED);
-                        wait(0.5);                                                 
-//                        LF28A_status.set_brightness(BRT_HIGH);                         
-//                        wait(0.5);                        
-                        LF28A_status.set_brightness(BRT_OFF);                                                 
-                        wait(0.5);                        
-                      }                      
-                      // LEDs Off
-                      LF28A_status.NoGo(LED_OFF);
-                      LF28A_status.LED(LED_LASER, LED_OFF);
-                      LF28A_status.LED(LED_TEMP, LED_OFF);
-
-                      LF28A_status.set_brightness(BRT_LOW); 
-                                                
-                      command = pc.getc(); 
-                      pc.printf("..Done\r");                      
-                      
-                      break;  
-                      
-          case 'D' :
-                      pc.printf("Test Display\r"); 
-                      pc.printf("Press any key to continue...");
-
-                      LF28A_display.cls();                      
-                      LF28A_display.putc('H');
-                      LF28A_display.putc('i');
-                      LF28A_display.putc('-');
-                      LF28A_display.putc('W');
-                      LF28A_display.putc('i');
-                      LF28A_display.putc('m');                      
-                      LF28A_display.putc('-');                      
-
-                      while(! pc.readable()) {
-                      }                      
-                      command = pc.getc(); 
-                      
-                      pc.printf("Test printf\r\n");                      
-                      
-                      LF28A_display.locate (0);                      
-                      LF28A_display.printf ("%s=%d", "Rng", 2);                      
-                      
-                      while(! pc.readable()) {
-                      }                      
-                      command = pc.getc(); 
-
-                      LF28A_display.locate (4);                      
-                      LF28A_display.printf ("    ");                      
-
-                      LF28A_display.locate (4);                      
-                      LF28A_display.printf ("%d", 123);                      
-                      
-                      while(! pc.readable()) {
-                      }                      
-                      command = pc.getc(); 
-                      
-                      LF28A_display.cls();                      
-                      LF28A_display.printf ("%s", "Hello...");                      
-
-                      while(! pc.readable()) {
-                      }                      
-                      command = pc.getc(); 
-                                            
-                      pc.printf("Test Flash\r\n");     
-                      LF28A_display.set_flash_mode(true);                                      
-                      for (int i=0; i<8; i++) {
-                        LF28A_display.set_char_flash_state(true, i);                      
-                        while(! pc.readable()) {
-                        }                      
-                        command = pc.getc(); 
-                        LF28A_display.set_char_flash_state(false, i);                                              
-                      }
-
-                      LF28A_display.set_flash_mode(false);
-                                            
-                      pc.printf("..Done\r");                      
-                      
-                      break; 
-                      
-           case 'K' :
-                      pc.printf("Test Keyboard\r"); 
-                      pc.printf("Press any key to continue...");
-
-
-                      while(! pc.readable()) {
-                         if (LF28A_keyboard.readable()) {
-                           pc.printf(".");
-                           
-                           keycode = LF28A_keyboard.getkey();
-                           switch (keycode) {
-                             case KEY_MODE :
-                                                    pc.printf("Mode\r");                             
-                                                    break;
-                             case KEY_EDIT_PATH :
-                                                    pc.printf("Edit\r");                                                          
-                                                    break;
-                             case KEY_BRIGHT :
-                                                    pc.printf("Bright\r");                             
-                                                    break;                               
-                             case KEY_GRAT_RT :
-                                                    pc.printf("Grat\r");                             
-                                                    break;
-                             case KEY_F_L_UP :
-                                                    pc.printf("F-L\r");                             
-                                                    break;
-                             case KEY_FIRE:
-                                                    pc.printf("Fire\r");                             
-                                                    break;                               
-                             case KEY_NONE:
-                                                    pc.printf("None\r");                             
-                                                    break;              
-                                                    
-                             default:  
-                                                    pc.printf("Oops\r");                             
-                                                    break;                               
-                           }; //switch
-                           
-                         } //if
-                      } //while                      
-                      command = pc.getc();                     
-                       
-                      pc.printf("..Done\r");                      
-                      
-                      break;                      
-                              
-
-          case 'N' :
-                      pc.printf("Test STANAG\r");
-                                               
-                      STANAG_codes.setDigitIdx(0);
-                      pc.printf("Code = %04d; CodeIdx=%d; DigitIdx=%d;\r", STANAG_codes.getCode(), STANAG_codes.getCodeIdx(), STANAG_codes.getDigitIdx() );                      
-
-                      LF28A_display.locate (0);                      
-                      LF28A_display.printf ("    %04d",STANAG_codes.getCode() );                      
-                      LF28A_display.set_flash_mode(true);                      
-                                         
-                      run_test=true;  
-                      while(run_test) {
-                        while(! pc.readable()) {
-                        }
-                        command = pc.getc();
-                        switch(command) {                                                                     
-                          case '0': run_test=false;
-                                    break;
-                          case '1':
-                                    pc.printf("0: Exit\r");
-                                    pc.printf("1: Show Menu\r");    
-                                    pc.printf("f: Next Code\r");                                     
-                                    pc.printf("g: Next Digit\r");                                                                         
-                                    pc.printf("u: Inc Digit\r");                                                                                                             
-                                    break;
-    
-                          case 'f': 
-                                    pc.printf("New Code Idx = %d\r", STANAG_codes.incCodeIdx() );                          
-                                    pc.printf("New Code = %04d\r", STANAG_codes.getCode() );                                                          
-                                    
-                                    LF28A_display.locate (0);                      
-                                    LF28A_display.printf ("    %04d",STANAG_codes.getCode() );                      
-                                                                                                                                  
-                                    break;
-                          case 'g': 
-                                    // Disable previous flashing digit
-                                    LF28A_display.set_char_flash_state(false, 4 + STANAG_codes.getDigitIdx());                          
-                                    
-                                    // Incr selected digit
-                                    pc.printf("New Digit Idx = %d\r", STANAG_codes.incDigitIdx() );
-
-                                    // Enable current flashing digit
-                                    LF28A_display.set_char_flash_state(true, 4 + STANAG_codes.getDigitIdx());                          
-
-                                    break;
-                          case 'u': 
-                                    pc.printf("New Digit = %d\r", STANAG_codes.incDigit() );
-                                    pc.printf("New Code = %04d\r", STANAG_codes.getCode() );                                                         
-                                    
-                                    LF28A_display.locate (0);                      
-                                    LF28A_display.printf ("    %04d",STANAG_codes.getCode() );                      
-                                    
-                                    break;
-                          default:  
-                                    pc.printf("Oops\r");                             
-                                    break;                               
-                        }; //switch
-                      } //while run_test                      
-
-
-                      LF28A_display.set_flash_mode(false);
-                                            
-                      pc.printf("..Done\r");                                                                
-                        
-                      break;
-
-        } //switch
-      }//if
-    }//while
-
-    pc.printf("End Test!\r\r");
-}
-
-//------------------------------------------------------------//
-// End Testing Stuff                                          //   
-//------------------------------------------------------------//
-
--- a/Utils.h	Fri Aug 26 20:35:11 2011 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-/* Utils - Useful stuff to simplify porting of some third party software
- * Copyright (c) 2011 Wim Huiskamp
- *
- * Released under the MIT License: http://mbed.org/license/mit
- *
- * version 0.2 Initial Release
-*/
-#ifndef _UTILS_H
-#define _UTILS_H
-
-//Typedefs
-
-#ifndef min
-#define min(_a,_b) ((_a) < (_b) ? (_a) : (_b))
-#endif
-
-
-#endif
\ No newline at end of file
--- a/main.cpp	Fri Aug 26 20:35:11 2011 +0000
+++ b/main.cpp	Sun Jan 25 17:30:47 2015 +0000
@@ -1,4 +1,4 @@
-/* LF28A Simulator - Main
+/* mbed bus - Main
  * Copyright (c) 2011 Wim Huiskamp
  *
  * Released under the MIT License: http://mbed.org/license/mit
@@ -11,32 +11,12 @@
 #include "PCF8574_AddressBus.h"
 #include "PCF8574_EnableBus.h"
 #include "MBED_ControlBus.h"
-#include "HDSP253X_Display.h"
-#include "Status_Display.h"
-#include "Keyboard.h"
-#include "STANAG_Codes.h"
-#include "Host_Coms.h"
+#include "HDSP253X.h"
   
 // Debug stuff
 #define __DEBUG  
 #include "Dbg.h"
 
-//#define __TESTCODE  
-
-
-// Software version
-#define LF28A_SOFTWARE_DESCRIPTOR    "LF28A Testsoftware"
-#define LF28A_SW_VERSION_MAJOR       0
-#define LF28A_SW_VERSION_MINOR       2
-#define LF28A_COPYRIGHT_DESCRIPTOR   "(C)TNO 2011"
-
-// Laser Time-out in Seconds
-//#define LF28A_RANGE_TIME_OUT_S           1      
-//#define LF28A_DESIG_TIME_OUT_S  (3*60 + 20)      
-//Test only:
-#define LF28A_RANGE_TIME_OUT_S           5      
-#define LF28A_DESIG_TIME_OUT_S          10      
- 
 // mbed Interface Hardware definitions
 DigitalOut myled1(LED1);
 DigitalOut myled2(LED2);
@@ -45,67 +25,31 @@
 
 // Host PC Communication channels
 Serial pc(USBTX, USBRX);
-Host_Coms host_coms(pc);
 
 //I2C Bus
 I2C i2c(D_SDA, D_SCL);
 
-// CDA Interface Hardware definitions
+// Bus Interface Hardware definitions
 PCF8574_DataBus    databus = PCF8574_DataBus(i2c, D_I2C_DATA_BUS);  //Copy constructors..
 PCF8574_AddressBus addressbus = PCF8574_AddressBus(i2c, D_I2C_ADDR_BUS);
 PCF8574_EnableBus  enablebus = PCF8574_EnableBus(i2c, D_I2C_ENA_BUS);
-MBED_ControlBus  controlbus = MBED_ControlBus(D_WR, D_RD, D_DTR, D_CDBUF, D_CDINT, D_FIRE);
-
-// CDA Hardware definitions
-HDSP253X_Display LF28A_display = HDSP253X_Display(databus, addressbus, enablebus, controlbus);
-Status_Display LF28A_status = Status_Display(databus, enablebus, controlbus);
-Keyboard LF28A_keyboard = Keyboard(databus, enablebus, controlbus);
-
-
-//Enums for LF28A Statemachines
-enum Mode { IDLE,
-            INIT_ENTRY, INIT, INIT_EXIT,  
-            DESIG_ENTRY, DESIG_DISP, DESIG_LASER, DESIG_EXIT,
-            RANGE_ENTRY, RANGE_DISP, RANGE_FIRE, RANGE_EXIT,
-            CODE_ENTRY, CODE_DISP, CODE_EDIT, CODE_EXIT,
-            ADDR_ENTRY, ADDR, ADDR_EXIT,
-            FREQ_ENTRY, FREQ, FREQ_EXIT,
-            PATH_ENTRY, PATH, PATH_EXIT };                                    
-
-enum RangeSelect { RNG_F, RNG_L };
+MBED_ControlBus  controlbus = MBED_ControlBus(D_WR, D_RD, D_DTR, D_CDBUF, D_CDINT);
 
-enum MessageToHost { LFPON, LFRDY_0, LFRDY_1, LFSTA_D, LFSTA_R, LFSTA_C, LFSTA_A, LFSTA_F, LFSTA_P, LFIDL };
-//enum MessageToHost { LFPON, LFRDY_0, LFRDY_1, LFSTA, LFIDL };
-enum MessageFromHost { LFRES, LFRNG };
+// Display Hardware definitions
+HDSP253X_Display LED_display = HDSP253X_Display(databus, addressbus, enablebus, controlbus);
 
-//Typedef for Laser Range finder data
-typedef struct {
- uint16_t first;
- uint16_t last;
- RangeSelect select; 
-} Range_t;
- 
-// Variables for Statemachine
-Mode mode; 
-Brightness brightness, graticule; 
-Key_Code keycode;
-Range_t range;
-bool laser;                           // Laser On/Off
-bool hostResetCmd;
-MessageToHost messageToHost;
-STANAG_Codes STANAG_codes;
+// Dummy delay
+#define DEVICE_WAIT_MS   0
+
 
 // Variables for Heartbeat and Status monitoring
 Ticker heartbeat;
 bool heartbeatflag=false;
 
-// Laser Time-out
-Timer timer;
-
 // Cycle Timer
 Timer cycletimer;
 int cyclecount = 0;
-const int maxcount = 1000000;
+const int maxcount = 10;
 
 // Local functions
 void clear_screen() {
@@ -114,186 +58,19 @@
     pc.printf("\x1B[H");
 }
 
-void version_string() {
-    pc.printf("\r\r");            
-    pc.printf("%s\r", LF28A_SOFTWARE_DESCRIPTOR);
-    pc.printf("Version v%1d.%1d\r", LF28A_SW_VERSION_MAJOR, LF28A_SW_VERSION_MINOR);
-    pc.printf("Build on %s at %s\r", __DATE__, __TIME__);    
-    pc.printf("%s\r", LF28A_COPYRIGHT_DESCRIPTOR);
-    pc.printf("\r\n");            
-}
 
 void init_interfaces() {
 // Init Host PC communication, default is 9600
     pc.baud(D_BAUDRATE);
       
-// Init LF28A CDA I/F hardware
+// Init I/F hardware
     i2c.frequency(100000);  
-//    pc.printf("SCL0 H, L = 0x%x, 0x%x\r", LPC_I2C0->I2SCLH, LPC_I2C0->I2SCLL);
-//    pc.printf("SCL1 H, L = 0x%x, 0x%x\r", LPC_I2C1->I2SCLH, LPC_I2C1->I2SCLL);
-//    pc.printf("SCL2 H, L = 0x%x, 0x%x\r", LPC_I2C2->I2SCLH, LPC_I2C2->I2SCLL);
-
-// Reset LF28A CDA
-// NOTE: On LF28A CDA the Reset* pin is connected to the Display and to the Latches.
-//       That implies they are all reset when the Reset* pin is used !
-    enablebus.reset(LOW);   
-    wait_ms(50);    
-    enablebus.reset(HIGH);             
   
     //Done, Tell me about it
     myled1 = 1;
-    DBG("Init Interfaces Done, Main, Step = %d\r", 10);    
+//    DBG("Init Interfaces Done\r");    
 }
       
-void BITE() {
-  int count;
-  
-    LF28A_status.set_brightness(BRT_MED);           
-    LF28A_status.NoGo(LED_ON);
-    
-    for (count=0; count<5; count++) {
-      LF28A_display.locate(0);
-      LF28A_display.printf("BITE  - ");    
-      LF28A_display.locate(0);    
-      LF28A_display.printf("BITE  \ ");    
-      LF28A_display.locate(0);        
-      LF28A_display.printf("BITE  | ");        
-      LF28A_display.locate(0);    
-      LF28A_display.printf("BITE  / ");    
-      LF28A_display.locate(0);    
-      LF28A_display.printf("BITE  - ");                
-    };
-
-    LF28A_display.locate(0);    
-    LF28A_display.printf("BITE  OK");    
-    LF28A_status.NoGo(LED_OFF);  
-    
-    wait(2.0);          
-    
-    LF28A_display.cls();  
-//    LF28A_status.set_brightness(D_STATUS_LED_BRIGHT_OFF); 
-
-    //Done, Tell me about it                        
-    DBG("BITE Done, Main, Step = %d\r", 30);    
-}
-
-void lamp_test() {
-    LF28A_status.set_brightness(BRT_LOW);       
-    LF28A_status.lamptest(LED_ON);  // All LEDs On, including Backlight and NoGo
-
-    LF28A_display.locate(0);
-    LF28A_display.printf("XXXXXXXX");
-
-    wait(2.0);      
-
-    LF28A_status.lamptest(LED_OFF);  // All LEDs Off, including Backlight and NoGo
-    
-    LF28A_display.cls();  
-//    LF28A_status.set_brightness(D_STATUS_LED_BRIGHT_OFF); 
-
-    //Done, Tell me about it          
-    //DBG("Lamp Test Done, Main, Step = %d\r", 20);    
-}
-
-
-void init_state() {
-    // Default modes and settings after Power On or Host Reset
-    brightness = BRT_LOW;   // Should be BRT_OFF, but then you dont see anything.. 
-    graticule  = BRT_LOW;   // Should be BRT_OFF, but then you dont see anything.. 
-
-    range.last = 0;
-    range.first = 0;
-    range.select = RNG_F;
-
-    laser = false;
-    timer.stop();
-    timer.reset();
-
-// Read Config File if needed..
-// Reload STANAG Codes ?
-    STANAG_codes.setCodeIdx(0);
-    STANAG_codes.setDigitIdx(0);
-                
-    // Init Status LEDs 
-    LF28A_status.lamptest(LED_OFF); // All LEDs off   
-    LF28A_status.backlight(LED_ON);
-    LF28A_status.set_brightness(brightness);          
-   
-    // Init Alphanumeric Display
-    LF28A_display.cls();                    // Clear display and Cursor home
-    LF28A_display.set_flash_mode(false);    // Disable flashing digits                                     
-    
-    //Done, Tell me about it 
-    //DBG("Init Done, Originator = %d\r", hostResetCmd);               
-}
-
-
-void grat_bright_selector() {
-  int result;
-  
-  switch (graticule) {
-    case BRT_OFF : graticule = BRT_LOW;
-                   break;
-    case BRT_LOW : graticule = BRT_MED;
-                   break;
-    case BRT_MED : graticule = BRT_HIGH;
-                   break;
-    case BRT_HIGH : graticule = BRT_OFF;
-                   break;
-    default:       // Oops, we should never end up here....
-                   graticule = BRT_LOW;
-                   result = -1;
-                   break;                   
-  } //end switch              
-     
-  //Done, Tell me about it 
-  //DBG("Grat Bright Chnge, val = %d\r", graticule);
-}
-
-void disp_bright_selector() {
-  int result;
-  
-  switch (brightness) {
-    case BRT_OFF : brightness = BRT_LOW;
-                   LF28A_status.set_brightness(BRT_LOW);    
-                   break;
-    case BRT_LOW : brightness = BRT_MED;
-                   LF28A_status.set_brightness(BRT_MED);        
-                   break;
-    case BRT_MED : brightness = BRT_HIGH;
-                   LF28A_status.set_brightness(BRT_HIGH);    
-                   break;
-    case BRT_HIGH : brightness = BRT_OFF;
-                   LF28A_status.set_brightness(BRT_OFF);        
-                   break;
-    default:       // Oops, we should never end up here....
-                   brightness = BRT_LOW;
-                   LF28A_status.set_brightness(BRT_LOW);                       
-                   result = -1;
-                   break;                   
-  } //end switch              
-        
-  //Done, Tell me about it 
-  //DBG("Disp Bright Chng, val = %d\r", brightness);
-}
-
-void range_selector() {
-  int result;
-  
-  switch (range.select) {
-    case RNG_F : range.select = RNG_L;
-                 break;
-    case RNG_L : range.select = RNG_F;
-                 break;
-    default:     // Oops, we should never end up here....
-                 range.select = RNG_F;
-                 result = -1;
-                 break;                 
-  } //end switch              
-     
-  //Done, Tell me about it   
-  //DBG("Rng Chng, val = %d\r", range.select);
-}
 
 // Heartbeat monitor
 void pulse() {
@@ -310,536 +87,277 @@
   heartbeatflag = false;
 }
 
-// Construct and Send messages to Host PC. Need to complete this !!
-void SendHostMessage(MessageToHost messageToHost) {
-  int result;
-
-  switch (messageToHost) {
-    case LFPON:    host_coms.sendMessage("$LFPON");
-                   break;
-                   
-    case LFRDY_0:  // No hostResetCmd
-                   host_coms.sendMessage("$LFRDY,0");
-                   //pc.printf("$LFRDY,0*00\r\n");
-                   break;
-                   
-    case LFRDY_1:  // hostResetCmd
-                   host_coms.sendMessage("$LFRDY,1");
-//                   pc.printf("$LFRDY,1*00\r\n");
-                   break;
-
-    case LFSTA_D:  // Designate
-                   host_coms.sendMessage("$LFSTA,D,%1d,%04d,%1d", laser, STANAG_codes.getCode(), graticule);    
-//                   pc.printf("$LFSTA,D,0,1234,1*00\r\n");
-                   break;
-
-    case LFSTA_R:  // Range
-                   host_coms.sendMessage("$LFSTA,R,%1d,%04d,%1d", laser, STANAG_codes.getCode(), graticule);        
-//                   pc.printf("$LFSTA,D,0,1234,1*00\r\n");
-                   break;
-
-    case LFSTA_C:  // Code
-                   host_coms.sendMessage("$LFSTA,C,%1d,%04d,%1d", laser, STANAG_codes.getCode(), graticule);    
-//                   pc.printf("$LFSTA,D,0,1234,1*00\r\n");
-                   break;
-
-    case LFSTA_A:
-    case LFSTA_F:
-    case LFSTA_P:        
-    case LFIDL:    // No Message
-                   break;
-
-    default:     // Oops, we should never end up here....
-
-                   result = -1;
-                   break;                 
-  } //end switch              
-     
-  //Done, Tell me about it  
-  //DBG("To Host Msg, type = %d\r", messageToHost);
+void show_LEDS () {
+  static int state = 0;
+ 
+  switch (state) {
+   case 0: 
+        myled1 = 1;
+        myled2 = 0;
+        myled3 = 0;
+        state = 1;
+        break;
+   case 1: 
+        myled1 = 0;
+        myled2 = 1;
+        myled3 = 0;
+        state = 2;
+        break;
+   case 2:     
+        myled1 = 0;
+        myled2 = 0;
+        myled3 = 1;
+        state = 0;
+        break;
+   }
 }
 
 
-//------------------------------------------------------------//
-// Testing Stuff                                              //   
-//------------------------------------------------------------//
-#ifdef __TESTCODE
-#include "Testloop.h"
-#endif
-//------------------------------------------------------------//
-// End Testing Stuff                                          //   
-//------------------------------------------------------------//
+// The next two functions are examples of low-level reading and writing to a device that is connected on the mbed bus.
+// In your own application you can develop a Class for each specific slave device and include modified versions of the 
+// functions below as 'private' functions. This allows you to hardcode the device CS_pin signals, define specific delays
+// when needed, change the sequence of CS, WR etc or mask out certain address or databits when they are not used in a certain case.
+//
+
+/*---------------------------------------------------------------------------*\
+ |
+ |  Function:       write
+ |
+ |  Description:    Low level data write routine for device. Takes in data
+ |                  and address and CS pin to identify the device and writes
+ |                  data to the display. For simplicity, entire address byte
+ |                  is written, even though top two bits are unused inputs.
+ |                  After performing the operation, address lines are set
+ |                  all high, in order to eliminate current drain through
+ |                  pullup resistors (0.5mA per pin with 10K pullups)
+ |
+ |  Parameters:     address - full address in bits 0-5
+ |                  device  - enum CS_Pin for Chip Select pin
+ |                  data - data byte to write out
+ |
+ |  Returns:        Nothing.
+ |
+\*---------------------------------------------------------------------------*/
+
+void write(uint8_t address, CS_Pin device, uint8_t data)
+{
+//    // Switch databus buffer to outputs (note: this is the default state)
+//    controlbus.busdir(WRITE);        
+//    // Switch databus to outputs
+//    databus.busdir(WRITE);   
+
+    
+    // Write out the address on to the addressbus and wait
+    addressbus.write(address);
+    wait_ms(DEVICE_WAIT_MS);
+
+    // Set CE low and wait
+    enablebus.chipselect(device, LOW);  
+    wait_ms(DEVICE_WAIT_MS);
+
+    // Write data to the databus
+    databus.write(data);        
+    wait_ms(DEVICE_WAIT_MS);
+     
+    // Set WR low, wait, then set high and wait
+    controlbus.WR(LOW);
+    wait_ms(DEVICE_WAIT_MS);
+    controlbus.WR(HIGH);
+    wait_ms(DEVICE_WAIT_MS);
+
+    // Set CE high and wait
+    enablebus.chipselect(device, HIGH);  
+    wait_ms(DEVICE_WAIT_MS);
+    
+//    // Switch databus back to inputs
+//    databus.busdir(READ);        
+//    // Switch databus buffer back to inputs
+//    controlbus.busdir(READ);  
+
+//    // Set address lines all high to minimise power through pullups
+//    addressbus.write(0xFF);
+}
+
+/*---------------------------------------------------------------------------*\
+ |
+ |  Function:       read
+ |
+ |  Description:    Low level data read routine for a Device. Takes in 
+ |                  address and CS pin to identify the device and then 
+ |                  reads data from the device.
+ |                  After performing the operation, address lines are set
+ |                  all high, in order to eliminate current drain through
+ |                  pullup resistors (0.5mA per pin with 10K pullups)
+ |
+ |  Parameters:     address - 8 bit address
+ |                  device  - enum CS_Pin for Chip Select pin
+ |  Returns:        data - data byte read
+ |
+\*---------------------------------------------------------------------------*/
+
+uint8_t read(uint8_t address, CS_Pin device)
+{
+    uint8_t data = 0;
+
+    // Switch databus to inputs (default state is output)
+    databus.busdir(READ);        
+    // Switch databus buffer to inputs
+    controlbus.busdir(READ);      
+       
+    // Write out the address on to the addressbus and wait
+    addressbus.write(address);
+    wait_ms(DEVICE_WAIT_MS);
+
+    // Set CE low and wait
+    enablebus.chipselect(device, LOW);
+    wait_ms(DEVICE_WAIT_MS);
+
+    // Set RD low and wait
+    controlbus.RD(LOW);
+    wait_ms(DEVICE_WAIT_MS);
+    
+    // Read the data byte from databus
+    data = databus.read();
+
+    // set RD high and wait
+    controlbus.RD(HIGH);
+    wait_ms(DEVICE_WAIT_MS);
+
+    // Set CE high and wait
+    enablebus.chipselect(device, HIGH);
+    wait_ms(DEVICE_WAIT_MS);
+
+//    // Set address lines all high to minimise power through pullups
+//    addressbus.write(0xFF);
+
+    // Switch databus buffer back to outputs
+    controlbus.busdir(WRITE);        
+    // Switch databus to outputs
+    databus.busdir(WRITE);   
+    
+    // Return read data to caller
+    return data;
+}
 
 
+void HDSP_BITE() {
+  int count;
+    
+    for (count=0; count<5; count++) {
+      LED_display.locate(0);
+      LED_display.printf("BITE  - ");
+      wait(0.05);                    
+      LED_display.locate(0);         
+      LED_display.printf("BITE  \\ ");
+      wait(0.05);                              
+      LED_display.locate(0);        
+      LED_display.printf("BITE  | ");
+      wait(0.05);              
+      LED_display.locate(0);    
+      LED_display.printf("BITE  / ");    
+      wait(0.05);      
+      LED_display.locate(0);    
+      LED_display.printf("BITE  - ");                
+      wait(0.05);      
+    };
+
+    LED_display.locate(0);    
+    LED_display.printf("BITE  OK"); 
+
+    LED_display.set_blink_mode(true);            
+    wait(2.0);          
+    LED_display.set_blink_mode(false);
+                    
+    LED_display.cls();  
+
+    //Done, Tell me about it                        
+//    DBG("BITE Done, Main, Step = %d\r", 30);    
+}
+
+void HDSP_Init_UDC() {
+
+// batt empty
+  LED_display.define_user_char(0, 0x0E, 0x11, 0x11, 0x11, 0x11, 0x11, 0x1F);
+// batt full  
+  LED_display.define_user_char(1, 0x0E, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F);  
+}  
+  
+
+void HDSP_Show_UDC() {
+ 
+  LED_display.locate(0);    
+  LED_display.printf("Batt "); 
+//  LED_display.putc(HDSP253X_ASCII_UDC_CHARS + 0); 
+//  LED_display.putc(HDSP253X_ASCII_UDC_CHARS + 1); 
+  LED_display.putudc(0); 
+  LED_display.putudc(1); 
+    
+  wait(2.0);          
+}
+
 int main() {
-    int address, result;
-   
+    int address;
+    uint8_t dummy;
+
     init_interfaces();
     
     heartbeat_start();
           
     clear_screen(); 
-    version_string();    
-        
-#ifndef __TESTCODE
-    lamp_test();
     
-    BITE();
+    HDSP_Init_UDC();
+            
+//    DBG("Start Main Loop\r");    
 
-    DBG("Start Main Loop, Step = %d\r", 50);    
-
-    // Prepare main State Machine 
-    mode = INIT_ENTRY;    // Start with Init
-    hostResetCmd = false; // Start with regular PowerOn reset   
-
-//Test cycletime
+//Testing stuff
+        
+    //Test cycletime
     cycletimer.start();      
     cycletimer.reset();
-          
-    // Main Controlloop:
-    //   Check keyboard input and respond as required in the current device mode
-    //   Check Host commands and respond as required
-    while(1) {
-        
-        // Handle mode statemachine
-        switch (mode) {
-        
-          // INIT MODEs - Init LF28A after Power On or Host Reset
-          case INIT_ENTRY:  // Transitional state
-                            mode = INIT;
-                            break;
-
-          case INIT:        // Init LF28A after Power On or Host Reset
-                            init_state(); 
-
-                           // Inform Host that Init has completed
-                            if (hostResetCmd) {
-                              // Host initiated a Reset
-                              SendHostMessage(LFRDY_1);
-                              hostResetCmd = false;                            
-                            }
-                            else {
-                              // Regular PowerOn Reset                                                        
-                              SendHostMessage(LFRDY_0);                            
-                            }
-                                                          
-                            mode = INIT_EXIT;                            
-                            break;                            
-        
-          case INIT_EXIT:  // Transitional state
-                            mode = DESIG_ENTRY;
-                            break;
-        
-          // DESIG MODEs - Laser Designator
-          case DESIG_ENTRY:  // Transitional state
-
-                            // Status LEDs
-                            LF28A_status.LED(LED_DESIG, LED_ON);
-
-                            //Display current STANAG Code
-                            LF28A_display.locate (0);                      
-                            LF28A_display.printf ("    %04d",STANAG_codes.getCode() );                      
-                          
-                            // Inform Host of change
-                            SendHostMessage(LFSTA_D);  
-                          
-                            mode = DESIG_DISP;
-                            break;
-
-          case DESIG_DISP:
-                            // Check and handle Keyboard
-                            if (LF28A_keyboard.readable()) {
-                              keycode = LF28A_keyboard.getkey();
-
-                              switch (keycode) {
-                                case KEY_GRAT_RT: grat_bright_selector();
-                                                  // Inform Host of change
-                                                  SendHostMessage(LFSTA_D);  
-                                                  break;
-
-                                case KEY_BRIGHT:  disp_bright_selector();
-                                                  break;                              
-
-                                case KEY_MODE:    mode = DESIG_EXIT;
-                                                  break;
-                                                  
-                                case KEY_FIRE:    // Check and handle Fire key
-                                                  
-                                                  // Toggle Laser On/Off
-                                                  if (laser) {
-                                                    // Laser is On, Switch Off
-                                                    laser=false;
-                                                    timer.stop();  // Stop time-out timer
-                                                    timer.reset();
-                                
-                                                    // Status LEDs
-                                                    LF28A_status.LED(LED_LASER, LED_OFF);                                                    
-                                                  }
-                                                  else {
-                                                    // Laser is Off, Switch On
-                                                    laser=true;
-                                                    timer.start(); // Start time-out timer
-
-                                                    // Status LEDs
-                                                    LF28A_status.LED(LED_LASER, LED_ON);                                                                                                         
-                                                  };
-                                                  
-                                                  // Inform Host of change (laser on/off)
-                                                  SendHostMessage(LFSTA_D);  
-                                
-                                                  break;                              
-                                                                                
-
-                                default:          // Ignore other keys
-                                                  break;                                                            
-                              }; //End Keyswitch            
-                            }; // End Keyread
-                              
-                            // Check Automatic Time-out for Laser
-                            if (laser) {
-                              // Laser is On, Test Time-out to Switch Off
-                              if (timer.read() > LF28A_DESIG_TIME_OUT_S) {
-                                laser=false;   // Laser Off
-                                timer.stop();  // Stop time-out timer
-                                timer.reset();
-
-                                // Status LEDs
-                                LF28A_status.LED(LED_LASER, LED_OFF); 
-
-                                // Inform Host of change (laser off)
-                                SendHostMessage(LFSTA_D);
-                              }                                                                                     
-                            };
-                                                       
-                            break;                              
-
-          case DESIG_EXIT:  // Transitional state
-
-                            // Check Laser
-                            if (laser) {
-                              // Laser is On, Switch Off
-                              laser=false;   // Laser Off
-                              timer.stop();  // Stop time-out timer
-                              timer.reset();
-                                
-                              // Status LEDs
-                              LF28A_status.LED(LED_LASER, LED_OFF); 
-                            };
-          
-                            // Status LEDs
-                            LF28A_status.LED(LED_DESIG, LED_OFF);        
-          
-                            mode = RANGE_ENTRY;
-                            break;                              
-
-          // RANGE MODEs
-          case RANGE_ENTRY: // Transitional state
-          
-                            // Status LEDs
-                            LF28A_status.LED(LED_RANGE, LED_ON);
-                  
-                            //Display current STANAG Code ...Is this correct on entry ??
-                            LF28A_display.locate (0);                      
-                            LF28A_display.printf ("    %04d",STANAG_codes.getCode() );                      
-                            
-                            // Inform Host of change
-                            SendHostMessage(LFSTA_R);  
-                           
-                            mode = RANGE_DISP;
-                            break;
-
-          case RANGE_DISP:
-                            // Check and handle Keyboard
-                            if (LF28A_keyboard.readable()) {
-                              keycode = LF28A_keyboard.getkey();
-
-                              switch (keycode) {
-                                case KEY_GRAT_RT: grat_bright_selector();
-
-                                                  // Inform Host of change
-                                                  SendHostMessage(LFSTA_R);  
-
-                                                  break;
-
-                                case KEY_BRIGHT:  disp_bright_selector();
-                                                  break;                              
-
-                                case KEY_MODE:    mode = RANGE_EXIT;
-                                                  break;                              
-
-                                case KEY_F_L_UP : //Toggle First/Last
-                                                  range_selector();                                
-
-                                                  //Display current Range
-                                                  if (range.select == RNG_F) {
-                                                    LF28A_display.locate (0);                      
-                                                    LF28A_display.printf ("F   %04d", range.first );
-                                                  }
-                                                  else {
-                                                    LF28A_display.locate (0);                      
-                                                    LF28A_display.printf ("L   %04d", range.last);                                                     
-                                                  };
-                                                                                                 
-                                                  // Inform Host of change ??
-                                                  //SendHostMessage(LFSTA);  
-                                                  
-                                                  break;
-
-                                case KEY_FIRE:    // Check and handle Fire key
-                                                  
-                                                  // Toggle Laser On/Off
-                                                  if (laser) {
-                                                    // Laser is On, Switch Off
-                                                    laser=false;
-                                                    timer.stop();  // Stop time-out timer
-                                                    timer.reset();                                                    
-
-                                                    // Status LEDs
-                                                    LF28A_status.LED(LED_LASER, LED_OFF);                                                    
-                                                  }
-                                                  else {
-                                                    // Laser is Off, Switch On
-                                                    laser=true;
-                                                    timer.start(); // Start time-out timer
-
-                                                    // Status LEDs
-                                                    LF28A_status.LED(LED_LASER, LED_ON);                                                                                                         
-                                                  };
-                                                  
-                                                  // Inform Host of change (laser on/off)
-                                                  SendHostMessage(LFSTA_R);  
-                                
-                                                  break;                              
-  
-                                default:          // Ignore other keys
-                                                  break;                                                              
-                              }; //End Keyswitch            
-                            }; // End Keyread          
-
-                            // Check Automatic Time-out for Laser
-                            if (laser) {
-                              // Laser is On, Test Time-out to Switch Off
-                              if (timer.read() > LF28A_RANGE_TIME_OUT_S) {
-                                laser=false;   // Laser Off
-                                timer.stop();  // Stop time-out timer
-                                timer.reset();                                
-
-                                // Status LEDs
-                                LF28A_status.LED(LED_LASER, LED_OFF); 
-
-                                // Inform Host of change (laser off)
-                                SendHostMessage(LFSTA_R);
-                              }                                                                                     
-                            };
-
-                            break;                              
-
-          case RANGE_EXIT:  // Transitional state
-
-                            // Check Laser
-                            if (laser) {
-                              // Laser is On, Switch Off
-                              laser=false;   // Laser Off
-                              timer.stop();  // Stop time-out timer
-                              timer.reset();                              
-
-                              // Status LEDs
-                              LF28A_status.LED(LED_LASER, LED_OFF); 
-                            };
-        
-                            // Status LEDs
-                            LF28A_status.LED(LED_RANGE, LED_OFF);
-
-                            mode = CODE_ENTRY;
-                            break;                              
 
 
-          // CODE MODEs
-          case CODE_ENTRY:  // Transitional state
-
-                            // Status LEDs
-                            LF28A_status.LED(LED_CODE, LED_ON);          
-          
-                            //Enable flashing Code                                
-                            LF28A_display.set_flash_mode(true);
- 
-                            //Display current STANAG Code
-                            LF28A_display.locate (0);                      
-                            LF28A_display.printf ("    %04d",STANAG_codes.getCode() );                      
- 
-                            // Inform Host of change
-                            SendHostMessage(LFSTA_C);  
-                            
-                            mode = CODE_DISP;
-                            break;
-
-          case CODE_DISP:
-                            // Check and handle Keyboard
-                            if (LF28A_keyboard.readable()) {
-                              keycode = LF28A_keyboard.getkey();
-
-                              switch (keycode) {
-                                case KEY_GRAT_RT: grat_bright_selector();
-
-                                                  // Inform Host of change
-                                                  SendHostMessage(LFSTA_C);  
-                                
-                                                  break;
-
-                                case KEY_BRIGHT:  disp_bright_selector();
-                                                  break;                              
-
-                                case KEY_MODE:    mode = CODE_EXIT;
-                                                  break;                              
-
-                                case KEY_EDIT_PATH:
-                                                  mode = CODE_EDIT;
-                                                  
-                                                  // Enable current flashing digit
-                                                  LF28A_display.set_char_flash_state(true, 4 + STANAG_codes.getDigitIdx());                          
-                                                                                                                                                         
-                                                  break;                              
-
-                                case KEY_F_L_UP : //Incr STANAG code idx
-                                                  STANAG_codes.incCodeIdx();
-                                                  
-                                                  //Display current STANAG Code
-                                                  LF28A_display.locate (0);                      
-                                                  LF28A_display.printf ("    %04d",STANAG_codes.getCode() );                      
-                                                                                                   
-
-                                                  // Inform Host of change ??
-                                                  //SendHostMessage(LFSTA);  
-                                                  
-                                                  break;
-                                                    
-                                default:          // Ignore other keys
-                                                  break;                                
-                              }; //End Keyswitch            
-                            }; //End Keyread            
-
-                            break;                              
-
-          case CODE_EDIT:
-                            // Check and handle Keyboard
-                            if (LF28A_keyboard.readable()) {
-                              keycode = LF28A_keyboard.getkey();
-
-                              switch (keycode) {
-                                case KEY_GRAT_RT: //Cursor Right;
-                                                  // Disable current flashing digit
-                                                  LF28A_display.set_char_flash_state(false, 4 + STANAG_codes.getDigitIdx());                          
-
-                                                  // Incr selected digit
-                                                  STANAG_codes.incDigitIdx();
-
-                                                  // Enable current flashing digit
-                                                  LF28A_display.set_char_flash_state(true, 4 + STANAG_codes.getDigitIdx());                          
-                                
-                                                  break;
-
-                                case KEY_BRIGHT:  disp_bright_selector();
-                                                  break;                              
+#if (1)
+// Bus test
+    while (1) {
+      for (address=0; address<256; address++) {
+        //data = read(address, CS_SWITCH);
+        
+        dummy = ~address;
+        write(address, LATCHEN_1, dummy); 
+//        wait(0.05);       
+      }    
+    
+      // Just for Info, lets see how fast this cycle is...
+      cyclecount++;
+      if (cyclecount == maxcount) {
+        pc.printf("Freq = %d Hz\r", (cyclecount * 256 * 1000) / cycletimer.read_ms());
+        cyclecount = 0;          
+        cycletimer.reset();      
+      }
+      
+      show_LEDS ();      
+    }
+#else
+// LED Display test
+    while (1) {
+      HDSP_BITE();   
 
-                                case KEY_MODE:    // Done, exit Code mode
-                                                                                    
-                                                  // Disable current flashing digit
-                                                  LF28A_display.set_char_flash_state(false, 4 + STANAG_codes.getDigitIdx());                          
-                                
-                                                  // Inform Host of change
-                                                  SendHostMessage(LFSTA_C);  
-                                                  
-                                                  mode = CODE_EXIT;                                                                                  
-                                                  
-                                                  break;                              
-
-                                case KEY_EDIT_PATH: // Done, return to Code display mode
-                                
-                                                  // Disable current flashing digit
-                                                  LF28A_display.set_char_flash_state(false, 4 + STANAG_codes.getDigitIdx());                          
-                                 
-                                                  // Inform Host of change
-                                                  SendHostMessage(LFSTA_C);  
-                                
-                                                  mode = CODE_DISP;
-                                                  
-                                                  break;                              
-
-                                case KEY_F_L_UP : //Incr current digit
-                                                  STANAG_codes.incDigit();
-
-                                                  // Display Current STANAG Code
-                                                  LF28A_display.locate (0);                      
-                                                  LF28A_display.printf ("    %04d",STANAG_codes.getCode() );                                                                       
-                                
-                                                  // Inform Host of change or wait until done editing ??
-                                                  //SendHostMessage(LFSTA);  
-                                                                                  
-                                                  break;                              
-                                                                                                
-                                default:          // Ignore other keys
-                                                  break;                                                              
-                              }; //End Keyswitch            
-                            }; //End Keyread                      
-
-                            break;                              
+      cyclecount++;
+      if (cyclecount == 10) {
+        cyclecount = 0;
+//        LED_display.printf ("Restart ");
+        HDSP_Show_UDC();         
+      }       
+      else {
+        LED_display.printf ("Cnt=  %2d", cyclecount);      
+      }
+      wait(2.0);
+      pc.printf ("."); 
+                     
+      show_LEDS ();      
+    }
 
-          case CODE_EXIT:  // Transitional state
-          
-                            // Status LEDs
-                            LF28A_status.LED(LED_CODE, LED_OFF); 
-
-                            //Disable flashing Code                                
-                            LF28A_display.set_flash_mode(false);
-                                            
-                            mode = DESIG_ENTRY;
-                            break;                              
-
-          // ADDR MODEs 
-          case ADDR_ENTRY: // Transitional state                    
-          case ADDR:       // Transitional state                              
-          case ADDR_EXIT:  // Transitional state          
-          // FREQ MODEs 
-          case FREQ_ENTRY: // Transitional state                    
-          case FREQ:       // Transitional state                              
-          case FREQ_EXIT:  // Transitional state          
-          // PATH MODEs
-          case PATH_ENTRY: // Transitional state                    
-          case PATH:       // Transitional state                              
-          case PATH_EXIT:  // Transitional state          
-                        
-          default:          // Oops, we should never end up here....try to recover
-                            mode = INIT_ENTRY;
-                            hostResetCmd = false;
-                            
-                            result = -1;
-                            DBG("Error - Result = %d\r", result);                            
-                            break;                                                          
-        }; //End mode statemachine switch              
-
-
-        // Handle Host commands
-        //  Reset command 
-        //  Range data         
-
-#if(0)
-        // Just for Info, lets see how fast this cycle is...
-        cyclecount++;
-        if (cyclecount == maxcount) {
-          pc.printf("Freq = %d Hz\r", (cyclecount * 1000) / cycletimer.read_ms());
-          cyclecount = 0;          
-          cycletimer.reset();      
-        }
 #endif
       
-    } // end while(1)
-
-
-#else
-//testing stuff
-    testloop();
-    
-#endif
-
-    DBG("I'll be back...\r\r");
+    //DBG("I'll be back...\r\r");
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Jan 25 17:30:47 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/63bcd7ba4912
\ No newline at end of file
--- a/mbed.lib	Fri Aug 26 20:35:11 2011 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/projects/libraries/svn/mbed/trunk@28
\ No newline at end of file