This is a monitor program for BLE NRF51822 chip. You can check memory, register and system information.

Dependencies:   BLE_API mbed nRF51822 nRF51_Vdd

Please refer follows.
/users/kenjiArai/code/debug_tools/
/users/kenjiArai/notebook/ble--tytaiyo-yuden-module-for-mbed/

Files at this revision

API Documentation at this revision

Comitter:
kenjiArai
Date:
Sun Jan 08 04:36:55 2017 +0000
Parent:
4:36ad7c7d0400
Commit message:
Abolish function:due to mbed library revision up "nrf radio test example" does NOT work anymore. Deleted unused files.

Changed in this revision

1st_readme.txt Show diff for this revision Revisions of this file
BLE_API.lib Show annotated file Show diff for this revision Revisions of this file
debug_tools/CheckRTC.lib Show diff for this revision Revisions of this file
debug_tools/debug_lpc1114.cpp Show diff for this revision Revisions of this file
debug_tools/debug_lpc1768.cpp Show diff for this revision Revisions of this file
debug_tools/debug_nRF51.cpp Show annotated file Show diff for this revision Revisions of this file
debug_tools/debug_nRF51_trx.cpp Show diff for this revision Revisions of this file
debug_tools/debug_nRF51_trx_tst.cpp Show diff for this revision Revisions of this file
debug_tools/debug_nRF51_trx_tst.h Show diff for this revision Revisions of this file
debug_tools/debug_nucleo_F4x1RE.cpp Show diff for this revision Revisions of this file
debug_tools/debugging_nRF51.h Show annotated file Show diff for this revision Revisions of this file
debug_tools/mon_hw_LPC1114.cpp Show diff for this revision Revisions of this file
debug_tools/mon_hw_LPC1768.cpp Show diff for this revision Revisions of this file
debug_tools/mon_hw_STM32.cpp Show diff for this revision Revisions of this file
debug_tools/mon_hw_STM32.h Show diff for this revision Revisions of this file
debug_tools/mon_hw_nRF51.cpp Show annotated file Show diff for this revision Revisions of this file
debug_tools/old_mon_hw_nRF51.cpp Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-dev.lib Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
modification/fstorage_config.h Show diff for this revision Revisions of this file
modification/port_api.c Show diff for this revision Revisions of this file
modification/system_nrf51.c Show diff for this revision Revisions of this file
nRF51822.lib Show annotated file Show diff for this revision Revisions of this file
nRF51_Vdd.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 36ad7c7d0400 -r 8c37a47ac34c 1st_readme.txt
--- a/1st_readme.txt	Sun Feb 14 21:55:30 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-
---- 32MHz Clock --- ONLY FOR TAIYO YUDEN MODULE (as of Feb.9th, 2016) ----
-
-/mbed-dev/targets/cmsis/TARGET_NORDIC/system_nrf51.c
-
-//--------- original ---------------------------------------
-#define __SYSTEM_CLOCK      (16000000UL)     /*!< nRF51 devices use a fixed System Clock Frequency of 16MHz */
-
------------ modified ---------------------------------------
-#define TARGET_NRF_32MHZ_XTAL
-//#if defined(TARGET_NRF_32MHZ_XTAL)
-//#define __SYSTEM_CLOCK      (32000000UL)     /*!< nRF51 devices use a fixed System Clock Frequency of 32MHz */
-//#else
-#define __SYSTEM_CLOCK      (16000000UL)     /*!< nRF51 devices use a fixed System Clock Frequency of 16MHz */
-//#endif
-
-
---- PortOut ----
-
-/mbed-dev/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/port_api.c
-
-//--------- original ---------------------------------------
-void port_write(port_t *obj, int value)
-{
-    *obj->reg_out = value;
-}
-
------------ modified ---------------------------------------
-void port_write(port_t *obj, int value)
-{
-#if 0
-    *obj->reg_out = value;
-#else
-    *obj->reg_out = (*obj->reg_out & ~obj->mask) | (value & obj->mask);
-#endif
-}
-
-
---- Error ---
-
-/nRF51822/source/nordic_sdk/components/libraries/fstorage/fstorage_config.h
-
-//--------- original ---------------------------------------
-static __INLINE uint32_t fs_flash_page_end_addr()
-{
-    uint32_t const bootloader_addr = NRF_UICR->NRFFW[0];
-    return  ((bootloader_addr != FS_EMPTY_MASK) ?
-             bootloader_addr : NRF_FICR->CODESIZE * FS_PAGE_SIZE);
-}
-
-//--------- modified ---------------------------------------
-static __INLINE uint32_t fs_flash_page_end_addr()
-{
-#if 0
-    uint32_t const bootloader_addr = NRF_UICR->NRFFW[0];
-#else
-    uint32_t const bootloader_addr = NRF_UICR->BOOTLOADERADDR;
-#endif
-    return  ((bootloader_addr != FS_EMPTY_MASK) ?
-             bootloader_addr : NRF_FICR->CODESIZE * FS_PAGE_SIZE);
-}
-
diff -r 36ad7c7d0400 -r 8c37a47ac34c BLE_API.lib
--- a/BLE_API.lib	Sun Feb 14 21:55:30 2016 +0000
+++ b/BLE_API.lib	Sun Jan 08 04:36:55 2017 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/teams/Bluetooth-Low-Energy/code/BLE_API/#ff83f0020480
+http://mbed.org/teams/Bluetooth-Low-Energy/code/BLE_API/#65474dc93927
diff -r 36ad7c7d0400 -r 8c37a47ac34c debug_tools/CheckRTC.lib
--- a/debug_tools/CheckRTC.lib	Sun Feb 14 21:55:30 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/kenjiArai/code/CheckRTC/#babcde30190d
diff -r 36ad7c7d0400 -r 8c37a47ac34c debug_tools/debug_lpc1114.cpp
--- a/debug_tools/debug_lpc1114.cpp	Sun Feb 14 21:55:30 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,146 +0,0 @@
-/*
- * mbed Application program
- *
- *  Copyright (c) 2010-2014 Kenji Arai / JH1PJL
- *  http://www.page.sannet.ne.jp/kenjia/index.html
- *  http://mbed.org/users/kenjiArai/
- *      Created:  May       15th, 2010
- *      Spareted: June      25th, 2014      mon() & mon_hw()
- *      Ported:   September 22nd, 2014      from L152RE, LP1114
- *      changed:  October   15th, 2014      mon.cpp to debug_xxx.cpp
- *      Revised:  Nobember   2nd, 2014
- *
- * 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.
- */
-
-#if defined(TARGET_LPC1114)
-
-//  Include ---------------------------------------------------------------------------------------
-#include "mbed.h"
-#include "debug_common.h"
-
-//  Object ----------------------------------------------------------------------------------------
-
-//  Definition ------------------------------------------------------------------------------------
-
-//  RAM -------------------------------------------------------------------------------------------
-
-//  ROM / Constant data ---------------------------------------------------------------------------
-
-//  Function prototypes ---------------------------------------------------------------------------
-extern void cpu_inf (void);
-
-//-------------------------------------------------------------------------------------------------
-//  Control Program
-//-------------------------------------------------------------------------------------------------
-//  Help Massage
-void msg_hlp (void)
-{
-    PRINTF(mon_msg);
-    put_rn();
-    PRINTF("1 - goto step1 -> no connection all pins");
-    put_rn();
-    PRINTF("2 - goto step2 -> connects pin_x and pin_y");
-    put_rn();
-    PRINTF("x - Goto HW monitor");
-    put_rn();
-    PRINTF("q - Return to main");
-    put_rn();
-}
-
-// ---------- Program starts here! ---------------------------------------------------------------
-void debug_interface(void)
-{
-    char *ptr;
-    uint8_t quitflag;
-
-    BAUD(BAUD_RATE);
-    put_rn();
-    put_rn();
-    PRINTF("%s [Help:'?' key]", mon_msg);
-    put_rn();
-    for (;;) {
-        put_r();
-        PUTC('>');
-        ptr = linebuf;
-        get_line(ptr, sizeof(linebuf));
-        switch (*ptr++) {
-                //---------------------------------------------------------------------------------
-                //  Debug Step1
-                //---------------------------------------------------------------------------------
-            case '1' :
-                put_r();
-                PRINTF("Enter Step1: no connection all pins");
-                put_rn();
-                quitflag = 0;
-                for (; quitflag != 0xff;) {
-                    PRINTF("1>");
-                    ptr = linebuf;
-                    get_line(ptr, buf_size);
-                    put_r();
-                    switch(*ptr++) {
-                        case 's' :
-                            PRINTF("----- CPU CLOCK Information -----");
-                            put_rn();
-                            get_freq(1);
-                            PRINTF("----- CPU TYPE Information ------");
-                            put_rn();
-                            cpu_inf();
-                            break;
-                        case '?' :
-                            PRINTF("s - CPU system info & clock");
-                            put_rn();
-                            PRINTF("q - Return to all mode");
-                            put_rn();
-                            PRINTF("? - You know this");
-                            put_rn();
-                            break;
-                        case 'q' :        // quit
-                            PRINTF("Back to all mode");
-                            quitflag = 0xff;
-                            break;
-                        default:
-                            PUTC('?');
-                            put_rn();
-                    }
-                }
-                put_rn();
-                break;
-                //---------------------------------------------------------------------------------
-                //  help
-                //---------------------------------------------------------------------------------
-            case '?' :
-                put_r();
-                msg_hlp();
-                break;
-                //---------------------------------------------------------------------------------
-                //  Go to special command
-                //---------------------------------------------------------------------------------
-            case 'x' :
-                mon_hw();
-                PRINTF("->Came back monitor\r\n");
-                break;
-                //---------------------------------------------------------------------------------
-                //  Go back to main()
-                //---------------------------------------------------------------------------------
-            case 'q' :        // Quit
-                PRINTF("\rReturn to main\r\n");
-                //PRINTF("cannot control anymore from here\r\n");
-                return;
-                //---------------------------------------------------------------------------------
-                //    no support
-                //---------------------------------------------------------------------------------
-            default:
-                put_r();
-                PUTC('?');
-                put_rn();
-                break;
-        }
-    }
-}
-
-#endif // defined(TARGET_LPC1114)
diff -r 36ad7c7d0400 -r 8c37a47ac34c debug_tools/debug_lpc1768.cpp
--- a/debug_tools/debug_lpc1768.cpp	Sun Feb 14 21:55:30 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,220 +0,0 @@
-/*
- * mbed Application program
- *
- *  Copyright (c) 2010-2014 Kenji Arai / JH1PJL
- *  http://www.page.sannet.ne.jp/kenjia/index.html
- *  http://mbed.org/users/kenjiArai/
- *      Created:  May       15th, 2010
- *      Spareted: June      25th, 2014      mon() & mon_hw()
- *      Ported:   September 22nd, 2014      from L152RE, LP1114
- *      changed:  October   15th, 2014      mon.cpp to debug_xxx.cpp
- *      Revised:  Nobember   2nd, 2014
- *
- * 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.
- */
-
-#if defined(TARGET_LPC1768)
-
-//  Include ---------------------------------------------------------------------------------------
-#include "mbed.h"
-#include "debug_common.h"
-
-//  Object ----------------------------------------------------------------------------------------
-DigitalOut myled1(LED1);
-DigitalOut myled2(LED2);
-DigitalOut myled3(LED3);
-DigitalOut myled4(LED4);
-
-//  Definition ------------------------------------------------------------------------------------
-
-//  RAM -------------------------------------------------------------------------------------------
-
-//  ROM / Constant data ---------------------------------------------------------------------------
-
-//  Function prototypes ---------------------------------------------------------------------------
-extern void cpu_inf (void);
-
-//-------------------------------------------------------------------------------------------------
-//  Control Program
-//-------------------------------------------------------------------------------------------------
-//  Help Massage
-void msg_hlp (void)
-{
-    PRINTF(mon_msg);
-    put_rn();
-    PRINTF("1 - goto step1 -> no connection all pins");
-    put_rn();
-    PRINTF("2 - goto step2 -> connects pin_x and pin_y");
-    put_rn();
-    PRINTF("t - Check and set RTC");
-    put_rn();
-    PRINTF("x - Goto HW monitor");
-    put_rn();
-    PRINTF("q - Return to main");
-    put_rn();
-}
-
-// ---------- Program starts here! ---------------------------------------------------------------
-void debug_interface(void)
-{
-    char c;
-    char *ptr;
-    uint8_t quitflag;
-
-    BAUD(BAUD_RATE);
-    put_rn();
-    put_rn();
-    PRINTF("%s [Help:'?' key]", mon_msg);
-    put_rn();
-    get_freq(0);
-    for (;;) {
-        put_r();
-        PUTC('>');
-        ptr = linebuf;
-        get_line(ptr, sizeof(linebuf));
-        switch (*ptr++) {
-                //---------------------------------------------------------------------------------
-                //  Debug Step1
-                //---------------------------------------------------------------------------------
-            case '1' :
-                put_r();
-                PRINTF("Enter Step1: no connection all pins");
-                put_rn();
-                quitflag = 0;
-                for (; quitflag != 0xff;) {
-                    PRINTF("1>");
-                    ptr = linebuf;
-                    get_line(ptr, buf_size);
-                    put_r();
-                    switch(*ptr++) {
-                        case 'l' :
-                            myled1 = 1;
-                            wait(0.1);
-                            myled1 = 0;
-                            myled2 = 1;
-                            wait(0.1);
-                            myled2 = 0;
-                            myled3 = 1;
-                            wait(0.1);
-                            myled3 = 0;
-                            myled4 = 1;
-                            wait(0.1);
-                            myled4 = 0;
-                            myled1 = 1;
-                            wait(0.2);
-                            myled2 = 1;
-                            wait(0.2);
-                            myled3 = 1;
-                            wait(0.2);
-                            myled4 = 1;
-                            PRINTF("Is LED on? -> enter y/n");
-                            put_rn();
-                            c = GETC();
-                            if (c == 'y') {
-                                PRINTF("Okay");
-                            } else {
-                                PRINTF("Are you sure? Check again!");
-                                for (c = 0; c < 10; c++) {
-                                    myled1 = !myled1;
-                                    wait(0.1);
-                                    myled2 = !myled2;
-                                    wait(0.1);
-                                    myled3 = !myled3;
-                                    wait(0.1);
-                                    myled4 = !myled4;
-                                    wait(0.1);
-                                }
-                                myled1 = 1;
-                                myled2 = 1;
-                                myled3 = 1;
-                                myled4 = 1;
-                                put_rn();
-                                PRINTF("Is LED on? -> enter y/n");
-                                put_rn();
-                                c = GETC();
-                                if (c == 'y') {
-                                    PRINTF("Looks okay");
-                                } else {
-                                    PRINTF("Please check LED line");
-                                }
-                            }
-                            put_rn();
-                            myled1 = 0;
-                            myled2 = 0;
-                            myled3 = 0;
-                            myled4 = 0;
-                            break;
-                        case 's' :
-                            PRINTF("----- CPU CLOCK Information -----");
-                            put_rn();
-                            get_freq(1);
-                            PRINTF("----- CPU TYPE Information ------");
-                            put_rn();
-                            cpu_inf();
-                            break;
-                        case '?' :
-                            PRINTF("l - Check LED");
-                            put_rn();
-                            PRINTF("s - CPU system info & clock");
-                            put_rn();
-                            PRINTF("q - Return to all mode");
-                            put_rn();
-                            PRINTF("? - You know this");
-                            put_rn();
-                            break;
-                        case 'q' :        // quit
-                            PRINTF("Back to all mode");
-                            quitflag = 0xff;
-                            break;
-                        default:
-                            PUTC('?');
-                            put_rn();
-                    }
-                }
-                put_rn();
-                break;
-                //---------------------------------------------------------------------------------
-                //  check and set RTC
-                //---------------------------------------------------------------------------------
-            case 't' :
-                put_r();
-                chk_and_set_time(ptr);
-                break;
-                //---------------------------------------------------------------------------------
-                //  help
-                //---------------------------------------------------------------------------------
-            case '?' :
-                put_r();
-                msg_hlp();
-                break;
-                //---------------------------------------------------------------------------------
-                //  Go to special command
-                //---------------------------------------------------------------------------------
-            case 'x' :
-                mon_hw();
-                PRINTF("->Came back monitor\r\n");
-                break;
-                //---------------------------------------------------------------------------------
-                //  Go back to main()
-                //---------------------------------------------------------------------------------
-            case 'q' :        // Quit
-                PRINTF("\rReturn to main\r\n");
-                //PRINTF("cannot control anymore from here\r\n");
-                return;
-                //---------------------------------------------------------------------------------
-                //    no support
-                //---------------------------------------------------------------------------------
-            default:
-                put_r();
-                PUTC('?');
-                put_rn();
-                break;
-        }
-    }
-}
-
-#endif // defined(TARGET_LPC1768)
diff -r 36ad7c7d0400 -r 8c37a47ac34c debug_tools/debug_nRF51.cpp
--- a/debug_tools/debug_nRF51.cpp	Sun Feb 14 21:55:30 2016 +0000
+++ b/debug_tools/debug_nRF51.cpp	Sun Jan 08 04:36:55 2017 +0000
@@ -1,11 +1,11 @@
 /*
  * mbed Application program
  *
- *  Copyright (c) 2016 Kenji Arai / JH1PJL
+ *  Copyright (c) 2016,'17 Kenji Arai / JH1PJL
  *  http://www.page.sannet.ne.jp/kenjia/index.html
  *  http://mbed.org/users/kenjiArai/
  *      Created:  Feburary   1st, 2016
- *      Revised:  Feburary  11th, 2016
+ *      Revised:  January    8th, 2017
  *
  * 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
@@ -21,6 +21,7 @@
 #include "debug_common.h"
 #include "nrf_soc.h"            // for internal Thermo sensoer
 #include "nRF51_Vdd.h"          // Read nRF51 Vdd voltage
+#include "nrf_delay.h"
 
 //  Object ----------------------------------------------------------------------------------------
 nRF51_Vdd vdd_mon(3.6f, 2.6f);
@@ -47,12 +48,16 @@
 {
     PRINTF(mon_msg);
     put_rn();
+    PRINTF("  RESET -> Press [Alt]+B");
+    put_rn();
     PRINTF("c - CPU VDD & Temp info");
     put_rn();
     PRINTF("l - Low current (Sleep Mode)");
     put_rn();
+#if 0
     PRINTF("t - Test Radio module");
     put_rn();
+#endif
     PRINTF("s - CPU system info");
     put_rn();
     PRINTF("r - Reset(by Software)");
@@ -129,12 +134,16 @@
                 PRINTF("Vdd: %4.3fV", vdd_mon.read_real_value());
                 put_rn();
                 break;
+#if 0   // Nobember   1st, 2016
+        // Timer1 IRQ handaler dupulicated error is occured dur to revision change.
+        // I cannot control Radio module.
                 //---------------------------------------------------------------------------------
                 //  Test Radio module
                 //---------------------------------------------------------------------------------
             case 't' :
                 trx_control();
                 break;
+#endif
                 //---------------------------------------------------------------------------------
                 //  Something new and try new functions
                 //---------------------------------------------------------------------------------
@@ -146,7 +155,8 @@
                 //  Go to Low current (Sleep mode)
                 //---------------------------------------------------------------------------------
             case 'l' :
-                PRINTF("Enter Sleep mode (Please push RESET button)");
+                PRINTF("Enter Sleep mode (Please push RESET button on the board");
+                PRINTF(" or Press [Alt]+B from PC)");
                 put_rn();
                 while(true){
                     sleep();
@@ -201,3 +211,5 @@
 }
 
 #endif  // defined(TARGET_NRF51822)
+
+
diff -r 36ad7c7d0400 -r 8c37a47ac34c debug_tools/debug_nRF51_trx.cpp
--- a/debug_tools/debug_nRF51_trx.cpp	Sun Feb 14 21:55:30 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,412 +0,0 @@
-/* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved.
- *
- * The information contained herein is property of Nordic Semiconductor ASA.
- * Terms and conditions of usage are described in detail in NORDIC
- * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
- *
- * Licensees are granted free, non-transferable use of the information. NO
- * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
- * the file.
- *
- */
-//  Original file name: nRF51_SDK_10.0.0_dc26b5e\examples\peripheral\radio_test\main.c
-#if defined(TARGET_NRF51822)
-
-/** @file
-*
-* @defgroup nrf_radio_test_example_main main.c
-* @{
-* @ingroup nrf_radio_test_example
-* @brief Radio Test Example Application main file.
-*
-* This file contains the source code for a sample application using the NRF_RADIO, 
-* and is controlled through the serial port.
-*
-*/
-
-#include "mbed.h"
-#include "nrf51_bitfields.h"
-#include "nrf.h"
-#include "debug_nRF51_trx_tst.h"
-#include "nordic_common.h"
-#include "softdevice_handler.h"
-
-#define BAUD(x)                 pcr.baud(x)
-#define GETC(x)                 pcr.getc(x)
-#define PUTC(x)                 pcr.putc(x)
-#define PRINTF(...)             pcr.printf(__VA_ARGS__)
-#define READABLE(x)             pcr.readable(x)
-
-Serial pcr(USBTX, USBRX);
-
-extern void put_rn ( void );
-extern void put_r  ( void );
-extern void get_line_no_param ( char *buff);
-extern int xatoi (char **str, int32_t *res);
-
-extern char linebuf[];
-extern int buf_size;
-
-static uint8_t mode_          = RADIO_MODE_MODE_Nrf_2Mbit;
-static uint8_t txpower_       = RADIO_TXPOWER_TXPOWER_0dBm;
-static int channel_start_     = 0;
-static int channel_end_       = 80;
-static int delayms_           = 10;
-
-static bool sweep = false;
-
-typedef enum
-{
-    RADIO_TEST_NOP,      /**< No test running.      */
-    RADIO_TEST_TXCC,     /**< TX constant carrier.  */
-    RADIO_TEST_TXMC,     /**< TX modulated carrier. */
-    RADIO_TEST_TXSWEEP,  /**< TX sweep.             */
-    RADIO_TEST_RXC,      /**< RX constant carrier.  */
-    RADIO_TEST_RXSWEEP,  /**< RX sweep.             */
-} radio_tests_t;
-
-
-#define BELL 7 // Bell
-
-/** @brief Function for configuring all peripherals used in this example.
-*/
-static void init(void)
-{
-    NRF_RNG->TASKS_START = 1;
-
-    // Start 16 MHz crystal oscillator
-    NRF_CLOCK->EVENTS_HFCLKSTARTED  = 0;
-    NRF_CLOCK->TASKS_HFCLKSTART     = 1;
-
-    // Wait for the external oscillator to start up
-    while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0)
-    {
-        // Do nothing.
-    }
-}
-
-
-/** @brief Function for outputting usage info to the serial port.
-*/
-static void help(void)
-{
-    PRINTF("Usage:\r\n");
-    PRINTF("---Check setting parameter\r\n");
-    PRINTF("s: Print current delay, channels and so on\r\n");
-    PRINTF("---Preparation\r\n");
-    PRINTF("m: Enter data rate\r\n");
-    PRINTF("p: Enter output power\r\n");
-    PRINTF("a: Enter start channel for sweep/channel for constant carrier\r\n");
-    PRINTF("b: Enter end channel for sweep\r\n");
-    PRINTF("d: Enter time on each channel (1ms-99ms)\r\n");
-    PRINTF("---Action\r\n");
-    PRINTF("x: Start RX carrier\r\n");
-    PRINTF("c: Start TX carrier\r\n");
-    PRINTF("r: Start RX sweep\r\n");
-    PRINTF("t: Start TX sweep\r\n");
-    PRINTF("o: Start modulated TX carrier\r\n");
-    PRINTF("e: Cancel sweep/carrier\r\n");
-    PRINTF("---Quit\r\n");
-    PRINTF("q: Return to monitor main\r\n");
-}
-
-
-/** @brief Function for reading the data rate.
-*/
-void get_datarate(void)
-{
-    char *ptr;
-
-    PRINTF("Enter data rate ('0'=250 Kbit/s, '1'=1 Mbit/s and '2'=2 Mbit/s):\r\n");
-    ptr = linebuf;
-    get_line_no_param(ptr);
-    put_r();
-    if (*ptr == '0'){
-        mode_ = RADIO_MODE_MODE_Nrf_250Kbit;
-        PRINTF("set 250Kbit");
-    } else if (*ptr == '1'){
-        mode_ = RADIO_MODE_MODE_Nrf_1Mbit;
-        PRINTF("set 1Mbit");
-    } else if (*ptr == '2'){
-        mode_ = RADIO_MODE_MODE_Nrf_2Mbit;
-        PRINTF("set 2Mbit");
-    } else {
-        mode_ = RADIO_MODE_MODE_Nrf_250Kbit;
-        PRINTF("? -> set 250Kbit");
-    }
-    PRINTF("\r\n");
-}
-
-/** @brief Function for reading the output power.
-*/
-void get_power(void)
-{
-    char *ptr;
-
-    PRINTF("Enter output power ('0'=+4 dBm, '1'=0 dBm,...,'7'=-30 dBm):\r\n");
-    ptr = linebuf;
-    get_line_no_param(ptr);
-    put_r();
-    switch(*ptr){
-        case '0':
-            txpower_ =  RADIO_TXPOWER_TXPOWER_Pos4dBm;
-            PRINTF("set +4dBm");
-            break;
-        case '1':
-            txpower_ =  RADIO_TXPOWER_TXPOWER_0dBm;
-            PRINTF("set 0dBm");
-            break;
-        case '2':
-            txpower_ = RADIO_TXPOWER_TXPOWER_Neg4dBm;
-            PRINTF("set -4dBm");
-            break;
-        case '3':
-            txpower_ = RADIO_TXPOWER_TXPOWER_Neg8dBm;
-            PRINTF("set -8dBm");
-            break;
-        case '4':
-            txpower_ = RADIO_TXPOWER_TXPOWER_Neg12dBm;
-            PRINTF("set -12dBm");
-            break;
-        case '5':
-            txpower_ = RADIO_TXPOWER_TXPOWER_Neg16dBm;
-            PRINTF("set -16dBm");
-            break;
-        case '6':
-            txpower_ = RADIO_TXPOWER_TXPOWER_Neg20dBm;
-            PRINTF("set -20dBm");
-            break;
-        case '7':
-            txpower_ = RADIO_TXPOWER_TXPOWER_Neg30dBm;
-            PRINTF("set -30dBm");
-            break;
-        default:
-            PRINTF("? -> set -30dBm");
-            txpower_ = RADIO_TXPOWER_TXPOWER_Neg30dBm;
-            break;
-    }
-    PRINTF("\r\n");
-}
-
-
-/** @brief Function for printing parameters to the serial port.
-*/
-void print_parameters(void)
-{
-    PRINTF("Parameters:\r\n");
-    switch(mode_){
-        case RADIO_MODE_MODE_Nrf_250Kbit:
-            PRINTF("Data rate...........: 250 Kbit/s\r\n");
-            break;
-        case RADIO_MODE_MODE_Nrf_1Mbit:
-            PRINTF("Data rate...........: 1 Mbit/s\r\n");
-            break;
-        case RADIO_MODE_MODE_Nrf_2Mbit:
-            PRINTF("Data rate...........: 2 Mbit/s\r\n");
-            break;
-    }
-    switch(txpower_){
-        case RADIO_TXPOWER_TXPOWER_Pos4dBm:
-            PRINTF("TX Power............: +4 dBm\r\n");
-            break;
-        case RADIO_TXPOWER_TXPOWER_0dBm:
-            PRINTF("TX Power............: 0 dBm\r\n");
-            break;
-        case RADIO_TXPOWER_TXPOWER_Neg4dBm:
-            PRINTF("TX Power............: -4 dBm\r\n");
-            break;
-
-        case RADIO_TXPOWER_TXPOWER_Neg8dBm:
-            PRINTF("TX Power............: -8 dBm\r\n");
-            break;
-        case RADIO_TXPOWER_TXPOWER_Neg12dBm:
-            PRINTF("TX Power............: -12 dBm\r\n");
-            break;
-        case RADIO_TXPOWER_TXPOWER_Neg16dBm:
-            PRINTF("TX Power............: -16 dBm\r\n");
-            break;
-        case RADIO_TXPOWER_TXPOWER_Neg20dBm:
-            PRINTF("TX Power............: -20 dBm\r\n");
-            break;
-        case RADIO_TXPOWER_TXPOWER_Neg30dBm:
-            PRINTF("TX Power............: -30 dBm\r\n");
-            break;
-        default:
-            // No implementation needed.
-            break;
-    }
-    PRINTF("(Start) Channel.....: %d\r\n",channel_start_);
-    PRINTF("End Channel.........: %d\r\n",channel_end_);
-    PRINTF("Time on each channel: %d ms\r\n",delayms_);
-}
-
-
-/** @brief Function for main application entry.
- */
-int trx_control(void)
-{
-    char *ptr;
-    radio_tests_t test     = RADIO_TEST_NOP;
-    radio_tests_t cur_test = RADIO_TEST_NOP;
-
-    init();
-    PRINTF("RF Test (original program from nRF51_SDK_10.0.0) ?= Help");
-    put_rn();
-    NVIC_SetPriority(TIMER1_IRQn, 1);
-    NVIC_EnableIRQ(TIMER1_IRQn);
-    //sd_nvic_EnableIRQ(TIMER1_IRQn);
-    //NVIC_EnableIRQ(TIMER1_IRQn);
-    __enable_irq();
-    while (true){
-        put_r();
-        PRINTF("trx>");
-        ptr = linebuf;
-        get_line_no_param(ptr);
-        put_r();
-        switch (*ptr++) {
-            case 'a':
-                PRINTF("Enter start channel (decimal digits, 0 to 80):\r\n");
-                ptr = linebuf;
-                get_line_no_param(ptr);
-                put_r();
-                xatoi(&ptr, &channel_start_);
-                if ((channel_start_ <= 80)&&(channel_start_ >= 0)){
-                    PRINTF("Start channel %d\r\n", channel_start_);
-                    break;
-                } else {
-                    PRINTF("Channel must be between 0 and 80 -> set 0\r\n");
-                    channel_start_ = 0;
-                }
-                test = cur_test;
-                break;
-            case 'b':
-                PRINTF("Enter end channel (decimal digits, 0 to 80):\r\n");
-                ptr = linebuf;
-                get_line_no_param(ptr);
-                put_r();
-                xatoi(&ptr, &channel_end_);
-                if ((channel_end_ <= 80)&&(channel_end_ >= 0)){
-                    PRINTF("End channel %d\r\n", channel_end_);
-                    break;
-                } else {
-                    PRINTF("Channel must be between 0 and 80 -> set 80\r\n");
-                    channel_end_ = 80;
-                }
-                test = cur_test;
-                break;
-            case 'c':
-                test = RADIO_TEST_TXCC;
-                break;
-            case 'd':
-                PRINTF("Enter delay in ms (decimal digits, 0 to 99):\r\n");
-                ptr = linebuf;
-                get_line_no_param(ptr);
-                put_r();
-                xatoi(&ptr, &delayms_);
-                if ((delayms_ > 0) && (delayms_ < 100)){
-                    PRINTF("Delay %dms\r\n", delayms_);
-                    break;
-                } else {
-                    PRINTF("Delay must be between 1 and 99 -> set 1\r\n");
-                    channel_end_ = 1;
-                }
-                test = cur_test;
-                break;
-            case 'e':
-                radio_sweep_end();
-                cur_test = RADIO_TEST_NOP;
-                break;
-            case 'm':
-                get_datarate();
-                test = cur_test;
-                break;
-            case 'o':
-                test = RADIO_TEST_TXMC;
-                PRINTF("TX modulated carrier\r\n");
-                break;
-            case 'p':
-                get_power();
-                test = cur_test;
-                break;
-            case 'r':
-                test = RADIO_TEST_RXSWEEP;
-                PRINTF("RX Sweep\r\n");
-                break;
-            case 's':
-                print_parameters();
-                break;
-            case 't':
-                test = RADIO_TEST_TXSWEEP;
-                PRINTF("TX Sweep\r\n");
-                break;
-            case 'q' :        // Quit
-                radio_sweep_end();
-                PRINTF("\rReturn to main\r\n");
-                return 0;
-            case 'x':
-                test = RADIO_TEST_RXC;
-                PRINTF("RX constant carrier\r\n");
-                break;
-            case 'h':
-                // Fall through.
-            default:
-                help();
-                break;
-        }
-        switch (test) {
-            case RADIO_TEST_TXCC:
-                if (sweep){
-                    radio_sweep_end();
-                    sweep = false;
-                }
-                radio_tx_carrier(txpower_, mode_, channel_start_);
-                PRINTF("RADIO_TEST_TXCC\r\n");
-                cur_test = test;
-                test     = RADIO_TEST_NOP;
-                break;
-            case RADIO_TEST_TXMC:
-                if (sweep){
-                    radio_sweep_end();
-                    sweep = false;
-                }
-                radio_modulated_tx_carrier(txpower_, mode_, channel_start_);
-                PRINTF("RADIO_TEST_TXMC\r\n");
-                cur_test = test;
-                test     = RADIO_TEST_NOP;
-                break;
-            case RADIO_TEST_TXSWEEP:
-                radio_tx_sweep_start(txpower_, mode_, channel_start_, channel_end_, delayms_);
-                PRINTF("RADIO_TEST_TXSWEEP\r\n");
-                sweep    = true;
-                cur_test = test;
-                test     = RADIO_TEST_NOP;
-                break;
-            case RADIO_TEST_RXC:
-                if (sweep){
-                    radio_sweep_end();
-                    sweep = false;
-                }
-                radio_rx_carrier(mode_, channel_start_);
-                PRINTF("RADIO_TEST_RXC\r\n");
-                cur_test = test;
-                test     = RADIO_TEST_NOP;
-                break;
-            case RADIO_TEST_RXSWEEP:
-                radio_rx_sweep_start(mode_, channel_start_, channel_end_, delayms_);
-                PRINTF("RADIO_TEST_RXSWEEP\r\n");
-                sweep    = true;
-                cur_test = test;
-                test     = RADIO_TEST_NOP;
-                break;
-            case RADIO_TEST_NOP:
-                // Fall through.
-            default:
-                // No implementation needed.
-                break;
-        }
-    }
-}
-
-/** @} */
-
-#endif  // defined(TARGET_NRF51822)
diff -r 36ad7c7d0400 -r 8c37a47ac34c debug_tools/debug_nRF51_trx_tst.cpp
--- a/debug_tools/debug_nRF51_trx_tst.cpp	Sun Feb 14 21:55:30 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,257 +0,0 @@
-/* Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved.
- *
- * The information contained herein is property of Nordic Semiconductor ASA.
- * Terms and conditions of usage are described in detail in NORDIC
- * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
- *
- * Licensees are granted free, non-transferable use of the information. NO
- * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
- * the file.
- *
- */
-
-//  Original file name: nRF51_SDK_10.0.0_dc26b5e\examples\peripheral\radio_test\radio_test.c
-#if defined(TARGET_NRF51822)
-
-/** @file
-* @addtogroup nrf_radio_test_example_main
-* @{
-*/
-
-#include "mbed.h"
-#include "nrf51_bitfields.h"
-#include "nrf51_deprecated.h"
-#include "debug_nRF51_trx_tst.h"
-#include <stdbool.h>
-#include "nrf.h"
-
-
-extern void timer_reg(uint8_t n);
-
-static uint8_t packet[256];
-
-static uint8_t mode_;
-static uint8_t txpower_;
-static uint8_t channel_start_;
-static uint8_t channel_end_;
-static uint8_t channel_;
-static bool    sweep_tx_;
-
-/**
- * @brief Function for initializing Timer in 24 bit timer mode with 1 us resolution.
-*/
-static void TIMER1_init(uint8_t delayms)
-{
-    NRF_TIMER1->TASKS_STOP = 1;
-
-    // Create an Event-Task shortcut to clear Timer on COMPARE[0] event.
-    NRF_TIMER1->SHORTS     = (TIMER_SHORTS_COMPARE0_CLEAR_Enabled << TIMER_SHORTS_COMPARE0_CLEAR_Pos);
-    NRF_TIMER1->MODE       = TIMER_MODE_MODE_Timer;
-    NRF_TIMER1->BITMODE    = (TIMER_BITMODE_BITMODE_24Bit << TIMER_BITMODE_BITMODE_Pos);
-    NRF_TIMER1->PRESCALER  = 4;  // 1us resolution
-
-    // Sample update needs to happen as soon as possible. The earliest possible moment is MAX_SAMPLE_LEVELS
-    // ticks before changing the output duty cycle.
-    NRF_TIMER1->CC[0]       = (uint32_t)delayms * 1000;
-    NRF_TIMER1->INTENSET   = (TIMER_INTENSET_COMPARE0_Set << TIMER_INTENSET_COMPARE0_Pos);
-    NRF_TIMER1->TASKS_START = 1;
-}
-
-
-/**
- * @brief Function for generating an 8 bit random number using the internal random generator.
-*/
-static uint32_t rnd8(void)
-{
-    NRF_RNG->EVENTS_VALRDY = 0;
-    while (NRF_RNG->EVENTS_VALRDY == 0) {
-        // Do nothing.
-    }
-    return NRF_RNG->VALUE;
-}
-
-
-/**
- * @brief Function for generating a 32 bit random number using the internal random generator.
-*/
-static uint32_t rnd32(void)
-{
-    uint8_t  i;
-    uint32_t val = 0;
-
-    for (i=0; i<4; i++) {
-        val <<= 8;
-        val  |= rnd8();
-    }
-    return val;
-}
-
-
-/**
- * @brief Function for configuring the radio to use a random address and a 254 byte random payload.
- * The S0 and S1 fields are not used.
-*/
-static void generate_modulated_rf_packet(void)
-{
-    uint8_t i;
-
-    NRF_RADIO->PREFIX0 = rnd8();
-    NRF_RADIO->BASE0   = rnd32();
-
-    // Packet configuration:
-    // S1 size = 0 bits, S0 size = 0 bytes, payload length size = 8 bits
-    NRF_RADIO->PCNF0  = (0UL << RADIO_PCNF0_S1LEN_Pos) |
-                        (0UL << RADIO_PCNF0_S0LEN_Pos) |
-                        (8UL << RADIO_PCNF0_LFLEN_Pos);
-    // Packet configuration:
-    // Bit 25: 1 Whitening enabled
-    // Bit 24: 1 Big endian,
-    // 4 byte base address length (5 byte full address length),
-    // 0 byte static length, max 255 byte payload .
-    NRF_RADIO->PCNF1  = (RADIO_PCNF1_WHITEEN_Enabled << RADIO_PCNF1_WHITEEN_Pos) |
-                        (RADIO_PCNF1_ENDIAN_Big << RADIO_PCNF1_ENDIAN_Pos) |
-                        (4UL << RADIO_PCNF1_BALEN_Pos) |
-                        (0UL << RADIO_PCNF1_STATLEN_Pos) |
-                        (255UL << RADIO_PCNF1_MAXLEN_Pos);
-    NRF_RADIO->CRCCNF = (RADIO_CRCCNF_LEN_Disabled << RADIO_CRCCNF_LEN_Pos);
-    packet[0]         = 254;    // 254 byte payload.
-
-    // Fill payload with random data.
-    for (i = 0; i < 254; i++){
-        packet[i+1] = rnd8();
-    }
-    NRF_RADIO->PACKETPTR = (uint32_t)packet;
-}
-
-
-static void radio_disable(void)
-{
-    NRF_RADIO->SHORTS          = 0;
-    NRF_RADIO->EVENTS_DISABLED = 0;
-#ifdef NRF51
-    NRF_RADIO->TEST            = 0;
-#endif
-    NRF_RADIO->TASKS_DISABLE   = 1;
-    while (NRF_RADIO->EVENTS_DISABLED == 0){
-        // Do nothing.
-    }
-    NRF_RADIO->EVENTS_DISABLED = 0;
-}
-
-
-/**
- * @brief Function for stopping Timer.
-*/
-void radio_sweep_end(void)
-{
-    NRF_TIMER1->TASKS_STOP = 1;
-    radio_disable();
-}
-
-
-/**
- * @brief Function for turning on the TX carrier test mode.
-*/
-void radio_tx_carrier(uint8_t txpower, uint8_t mode, uint8_t channel)
-{
-    radio_disable();
-    NRF_RADIO->SHORTS     = RADIO_SHORTS_READY_START_Msk;
-    NRF_RADIO->TXPOWER    = (txpower << RADIO_TXPOWER_TXPOWER_Pos);
-    NRF_RADIO->MODE       = (mode << RADIO_MODE_MODE_Pos);
-    NRF_RADIO->FREQUENCY  = channel;
-#ifdef NRF51
-    NRF_RADIO->TEST       = (RADIO_TEST_CONST_CARRIER_Enabled << RADIO_TEST_CONST_CARRIER_Pos) \
-                            | (RADIO_TEST_PLL_LOCK_Enabled << RADIO_TEST_PLL_LOCK_Pos);
-#endif
-    NRF_RADIO->TASKS_TXEN = 1;
-}
-
-
-/**
- * @brief Function for starting modulated TX carrier by repeatedly sending a packet with random address and
- * random payload.
-*/
-void radio_modulated_tx_carrier(uint8_t txpower, uint8_t mode, uint8_t channel)
-{
-    radio_disable();
-    generate_modulated_rf_packet();
-    NRF_RADIO->SHORTS     = RADIO_SHORTS_END_DISABLE_Msk | RADIO_SHORTS_READY_START_Msk | \
-                            RADIO_SHORTS_DISABLED_TXEN_Msk;;
-    NRF_RADIO->TXPOWER    = (txpower << RADIO_TXPOWER_TXPOWER_Pos);
-    NRF_RADIO->MODE       = (mode << RADIO_MODE_MODE_Pos);
-    NRF_RADIO->FREQUENCY  = channel;
-    NRF_RADIO->TASKS_TXEN = 1;
-}
-
-
-/**
- * @brief Function for turning on RX carrier.
-*/
-void radio_rx_carrier(uint8_t mode, uint8_t channel)
-{
-    radio_disable();
-    NRF_RADIO->SHORTS     = RADIO_SHORTS_READY_START_Msk;
-    NRF_RADIO->FREQUENCY  = channel;
-    NRF_RADIO->TASKS_RXEN = 1;
-}
-
-
-/**
- * @brief Function for turning on TX carrier sweep. This test uses Timer to restart the TX carrier at different channels.
-*/
-void radio_tx_sweep_start(uint8_t txpower, uint8_t mode, uint8_t channel_start, uint8_t channel_end, uint8_t delayms)
-{
-    txpower_       = txpower;
-    mode_          = mode;
-    channel_start_ = channel_start;
-    channel_       = channel_start;
-    channel_end_   = channel_end;
-    sweep_tx_      = true;
-    TIMER1_init(delayms);
-}
-
-
-/**
- * @brief Function for turning on RX carrier sweep. This test uses Timer to restart the RX carrier at different channels.
-*/
-void radio_rx_sweep_start(uint8_t mode, uint8_t channel_start, uint8_t channel_end, uint8_t delayms)
-{
-    mode_          = mode;
-    channel_start_ = channel_start;
-    channel_       = channel_start;
-    channel_end_   = channel_end;
-    sweep_tx_      = false;
-    TIMER1_init(delayms);
-}
-
-
-/**
- * @brief Function for handling the Timer interrupt used for TX/RX sweep. The carrier is started with the new channel,
- * and the channel is incremented for the next interrupt.
-*/
-#ifdef __cplusplus
-extern "C" {
-#endif
-void TIMER1_IRQHandler(void)
-{
-    if (sweep_tx_){
-        radio_tx_carrier(txpower_, mode_, channel_);
-    } else {
-        radio_rx_carrier(mode_, channel_);
-    }
-    channel_++;
-    if (channel_ > channel_end_){
-        channel_ = channel_start_;
-    }
-    NRF_TIMER1->EVENTS_COMPARE[0] = 0;
-    NRF_TIMER1->INTENSET   = (TIMER_INTENSET_COMPARE0_Set << TIMER_INTENSET_COMPARE0_Pos);
-    NRF_TIMER1->TASKS_START = 1;
-}
-#ifdef __cplusplus
-}
-#endif
-/**
- * @}
- */
-
-#endif  // defined(TARGET_NRF51822)
diff -r 36ad7c7d0400 -r 8c37a47ac34c debug_tools/debug_nRF51_trx_tst.h
--- a/debug_tools/debug_nRF51_trx_tst.h	Sun Feb 14 21:55:30 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
- *
- * The information contained herein is property of Nordic Semiconductor ASA.
- * Terms and conditions of usage are described in detail in NORDIC
- * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
- *
- * Licensees are granted free, non-transferable use of the information. NO
- * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
- * the file.
- *
- */
-
-//  Original file name: nRF51_SDK_10.0.0_dc26b5e\examples\peripheral\radio_test\radio_test.h
-#if defined(TARGET_NRF51822)
-
-#ifndef RADIO_TEST_H
-#define RADIO_TEST_H
-
-#include <stdint.h>
-
-
-void radio_tx_carrier(uint8_t txpower, uint8_t mode, uint8_t channel);
-void radio_modulated_tx_carrier(uint8_t txpower, uint8_t mode, uint8_t channel);
-void radio_rx_carrier(uint8_t mode, uint8_t channel);
-void radio_tx_sweep_start(uint8_t txpower, uint8_t mode, uint8_t channel_start, uint8_t channel_end, uint8_t delayms);
-void radio_rx_sweep_start(uint8_t mode, uint8_t channel_start, uint8_t channel_end, uint8_t delayms);
-void radio_sweep_end(void);
-
-#endif
-
-#endif  // defined(TARGET_NRF51822)
diff -r 36ad7c7d0400 -r 8c37a47ac34c debug_tools/debug_nucleo_F4x1RE.cpp
--- a/debug_tools/debug_nucleo_F4x1RE.cpp	Sun Feb 14 21:55:30 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,252 +0,0 @@
-/*
- * mbed Application program
- *
- *  Copyright (c) 2010-2015 Kenji Arai / JH1PJL
- *  http://www.page.sannet.ne.jp/kenjia/index.html
- *  http://mbed.org/users/kenjiArai/
- *      Created:  May  	    15th, 2010
- *		Spareted: June		25th, 2014		mon() & mon_hw()
- *		Ported:   September 22nd, 2014		from L152RE, LP1114
- *      changed:  October   15th, 2014		mon.cpp to debug_xxx.cpp
- *      Revised:  April     25th, 2015		Bug fix ('o' command) pointed out by Topi Makinen
- *
- * 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.
- */
-
-#if defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F411RE) || defined(TARGET_NUCLEO_L152RE)
-
-//  Include ---------------------------------------------------------------------------------------
-#include "mbed.h"
-#include "debug_common.h"
-#include "CheckRTC.h"
-
-//  Object ----------------------------------------------------------------------------------------
-DigitalOut myled(LED1);
-DigitalIn usr_sw(PC_13);
-
-//  Definition ------------------------------------------------------------------------------------
-
-//  RAM -------------------------------------------------------------------------------------------
-
-//  ROM / Constant data ---------------------------------------------------------------------------
-
-//  Function prototypes ---------------------------------------------------------------------------
-extern void cpu_inf( char *ptr );
-extern void port_mco1_mco2_set(uint8_t n);
-extern void port_mco1_mco2_recover(void);
-
-//-------------------------------------------------------------------------------------------------
-//  Control Program
-//-------------------------------------------------------------------------------------------------
-//  Help Massage
-void msg_hlp (void)
-{
-    PRINTF(mon_msg);
-    put_rn();
-    PRINTF("1 - goto step1 -> no connection all pins");
-    put_rn();
-    PRINTF("2 - goto step2 -> connects pin_x and pin_y");
-    put_rn();
-    PRINTF("t - Check and set RTC");
-    put_rn();
-    PRINTF("x - Goto HW monitor");
-    put_rn();
-    PRINTF("q - Return to main");
-    put_rn();
-}
-
-// ---------- Program starts here! ---------------------------------------------------------------
-void debug_interface(void)
-{
-    char c;
-    char *ptr;
-    uint8_t quitflag;
-
-    BAUD(BAUD_RATE);
-    put_rn();
-    put_rn();
-    PRINTF("%s [Help:'?' key]", mon_msg);
-    put_rn();
-    CheckRTC();
-    for (;;) {
-        put_r();
-        PUTC('>');
-        ptr = linebuf;
-        get_line(ptr, sizeof(linebuf));
-        switch (*ptr++) {
-                //---------------------------------------------------------------------------------
-                //  Debug Step1
-                //---------------------------------------------------------------------------------
-            case '1' :
-                put_r();
-                PRINTF("Enter Step1: no connection all pins");
-                put_rn();
-                quitflag = 0;
-                for (; quitflag != 0xff;) {
-                    PRINTF("1>");
-                    ptr = linebuf;
-                    get_line(ptr, buf_size);
-                    put_r();
-                    switch(*ptr++) {
-                        case 'l' :
-                            myled = 1;
-                            PRINTF("Is LED on? -> enter y/n");
-                            put_rn();
-                            c = GETC();
-                            if (c == 'y') {
-                                PRINTF("Okay");
-                            } else {
-                                PRINTF("Are you sure? Check again!");
-                                for (c = 0; c < 30; c++) {
-                                    myled = !myled;
-                                    wait(0.2);
-                                }
-                                myled = 1;
-                                put_rn();
-                                PRINTF("Is LED on? -> enter y/n");
-                                put_rn();
-                                c = GETC();
-                                if (c == 'y') {
-                                    PRINTF("Looks okay");
-                                } else {
-                                    PRINTF("Please check LED line");
-                                }
-                            }
-                            put_rn();
-                            myled = 0;
-                            break;
-                        case 'b' :
-                            PRINTF("Please push [USER] button -> You can see LED on if you push a button");
-                            put_rn();
-                            PRINTF("Hit any key to exit");
-                            while (true) {
-                                if (usr_sw == 0) {
-                                    myled = 1;
-                                } else {
-                                    myled = 0;
-                                }
-                                if (READABLE()) {
-                                    break;
-                                }
-                            }
-                            GETC();
-                            put_rn();
-                            break;
-                        case 's' :
-                            PRINTF("----- CPU CLOCK Information -----");
-                            put_rn();
-                            c = 'f';
-                            cpu_inf(&c);
-                            PRINTF("----- CPU TYPE Information ------");
-                            put_rn();
-                            c = 'c';
-                            cpu_inf(&c);
-                            break;
-#if defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F411RE)
-                        case 'o' : // Bug fix on April 25, 2015
-                            PRINTF("----- CPU CLOCK output from PA8 & PC9 -----");
-                            put_rn();
-                            PRINTF("Please check that both PA8 & PC9 ");
-                            PRINTF("are no connection with any peripheral I/O!!");
-                            put_rn();
-                            PRINTF("Are you okay? [y/n]");
-                            put_rn();
-                            c = GETC();
-                            if (c == 'y') {
-                                port_mco1_mco2_set(0);
-                                port_mco1_mco2_set(1);
-                                PRINTF("Please measure frequency at PA8 & PC9 pins");
-                                put_rn();
-                                PRINTF("PA8: HSE/4");
-                                put_rn();
-                                PRINTF("PC9: SYSCLK/4");
-                                put_rn();
-                                PRINTF("Change requency (Please hit any key)");
-                                put_rn();
-								c = GETC();
-								port_mco1_mco2_set(2);
-                                PRINTF("PA8: HSE/1");
-                                put_rn();
-                                PRINTF("PC9: SYSCLK/2");
-                                put_rn();
-                                PRINTF("If you would like to finish, hit anykey");
-                                put_rn();
-                                c = GETC();
-                                port_mco1_mco2_recover();
-                                PRINTF("End");
-                                put_rn();
-                            }
-                            break;
-#endif      // defined(TARGET_NUCLEO_F401RE) 
-                        case '?' :
-                            PRINTF("l - Check LED");
-                            put_rn();
-                            PRINTF("b - Check button");
-                            put_rn();
-                            PRINTF("s - CPU system info & clock");
-                            put_rn();
-#if defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F411RE)
-                            PRINTF("o - CPU clock output");
-                            put_rn();
-#endif      // defined(TARGET_NUCLEO_F401RE)                             
-                            PRINTF("q - Return to all mode");
-                            put_rn();
-                            PRINTF("? - You know this");
-                            put_rn();
-                            break;
-                        case 'q' :        // quit
-                            PRINTF("Back to all mode");
-                            quitflag = 0xff;
-                            break;
-                        default:
-                            PUTC('?');
-                            put_rn();
-                    }
-                }
-                put_rn();
-                break;
-                //---------------------------------------------------------------------------------
-                //  check and set RTC
-                //---------------------------------------------------------------------------------
-            case 't' :
-                put_r();
-                chk_and_set_time(ptr);
-                break;
-                //---------------------------------------------------------------------------------
-                //  help
-                //---------------------------------------------------------------------------------
-            case '?' :
-                put_r();
-                msg_hlp();
-                break;
-                //---------------------------------------------------------------------------------
-                //  Go to special command
-                //---------------------------------------------------------------------------------
-            case 'x' :
-                mon_hw();
-                PRINTF("->Came back monitor\r\n");
-                break;
-                //---------------------------------------------------------------------------------
-                //  Go back to main()
-                //---------------------------------------------------------------------------------
-            case 'q' :        // Quit
-                PRINTF("\rReturn to main\r\n");
-                //PRINTF("cannot control anymore from here\r\n");
-                return;
-                //---------------------------------------------------------------------------------
-                //    no support
-                //---------------------------------------------------------------------------------
-            default:
-                put_r();
-                PUTC('?');
-                put_rn();
-                break;
-        }
-    }
-}
-
-#endif // defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_L152RE)
diff -r 36ad7c7d0400 -r 8c37a47ac34c debug_tools/debugging_nRF51.h
--- a/debug_tools/debugging_nRF51.h	Sun Feb 14 21:55:30 2016 +0000
+++ b/debug_tools/debugging_nRF51.h	Sun Jan 08 04:36:55 2017 +0000
@@ -5,7 +5,7 @@
  *  http://www.page.sannet.ne.jp/kenjia/index.html
  *  http://mbed.org/users/kenjiArai/
  *      Created:  Feburary   1st, 2016
- *      Revised:  Feburary  15th, 2016
+ *      Revised:  Feburary  18th, 2016
  *
  * 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
@@ -19,7 +19,8 @@
     //---------------------------------------------------------------------------------
 #define NRF_RTC2_BASE                   0x40024000UL
 #define NRF_RTC2                        ((NRF_RTC_Type            *) NRF_RTC2_BASE)
-    
+#define MAX_RTC_TASKS_DELAY     47  /**< Maximum delay until an RTC task is executed. */
+ 
 case '1' :
     step_by_step('1');
     sd_power_system_off();
@@ -95,8 +96,6 @@
     NRF_TWI0->POWER =0;
     NRF_TWI1->POWER =0;
     step_by_step('4');
-    NRF_GPIO->DIR = 0xffff; // all ports set output mode
-    NRF_GPIO->OUTCLR = 0;   // all ports are low level
     //step_by_step('x');
     //NRF_UART0->ENABLE = 0;  // Disable UART
     step_by_step('2');
@@ -118,20 +117,142 @@
     }
     //break;
 case '2' :
+#if 1
+    step_by_step('a');              
+    // Stop Radio
+    NRF_RADIO->SHORTS          = 0;
+    NRF_RADIO->EVENTS_DISABLED = 0;
+    NRF_RADIO->TEST            = 0;
+    NRF_RADIO->TASKS_DISABLE   = 1;
+    while (NRF_RADIO->EVENTS_DISABLED == 0){
+        ;// Do nothing.
+    }
+    NRF_RADIO->EVENTS_DISABLED = 0;
+    // Set RTC1 for wake-up
+    NVIC_ClearPendingIRQ(RTC1_IRQn);
+    NVIC_DisableIRQ(RTC1_IRQn);
+    NRF_RTC1->TASKS_STOP = 1;
+    nrf_delay_us(MAX_RTC_TASKS_DELAY);
+    NRF_RTC1->TASKS_CLEAR = 1;
+    nrf_delay_us(MAX_RTC_TASKS_DELAY);
+    NRF_RTC1->INTENCLR = RTC_INTENSET_COMPARE0_Msk;
+    NRF_RTC1->EVTENCLR = RTC_EVTEN_COMPARE0_Msk;
+    NRF_RTC1->INTENCLR = RTC_INTENSET_OVRFLW_Msk;
+    NRF_RTC1->EVTENCLR = RTC_EVTEN_OVRFLW_Msk;
+    NRF_RTC1->EVENTS_COMPARE[0] = 0;
+    NRF_RTC1->EVTENCLR = 0x000f0003; // all clear
+    NRF_RTC1->EVTENSET = RTC_EVTEN_COMPARE0_Msk;
+#if 0
+    do {
+        NRF_RTC1->PRESCALER = 4095;
+    } while (NRF_RTC1->PRESCALER != 4095);
+#else
+    NRF_RTC1->PRESCALER = 4095;
+#endif
+    // Set wake-up time
+    NRF_RTC1->CC[0] = 50;
+    // GPIOE
+#if 0
+    NRF_GPIO->PIN_CNF[21] =   (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos)
+                            | (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos)
+                            | (GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos)
+                            | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos)
+                            | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos);
+#endif
+    NRF_GPIOTE->CONFIG[0] =   (GPIOTE_CONFIG_POLARITY_LoToHi << GPIOTE_CONFIG_POLARITY_Pos)
+                            | (21 << GPIOTE_CONFIG_PSEL_Pos) 
+                            | (GPIOTE_CONFIG_MODE_Task << GPIOTE_CONFIG_MODE_Pos);   
+    // Set PPI
+    NRF_PPI->CH[0].EEP = (uint32_t)&NRF_RTC1->EVENTS_COMPARE[0];
+    NRF_PPI->CH[0].TEP = (uint32_t)&NRF_GPIOTE->TASKS_OUT[0];
+    // Enable only PPI channels 0
+    NRF_PPI->CHEN = PPI_CHEN_CH0_Enabled << PPI_CHEN_CH0_Pos;
+    // Restart RTC1
+    NRF_RTC1->TASKS_START = 1;
+    nrf_delay_us(MAX_RTC_TASKS_DELAY);
+    // DEBUG
+    PRINTF("NRF_RTC1->PRESCALER=0x%x\r\n", NRF_RTC1->PRESCALER);
+    PRINTF("NRF_RTC1->EVTEN=0x%x\r\n", NRF_RTC1->EVTEN);
+    PRINTF("NRF_RTC1->COUNTER=0x%x\r\n", NRF_RTC1->COUNTER);
+    PRINTF("NRF_RTC1->EVENTS_COMPARE[0]=0x%x\r\n", NRF_RTC1->EVENTS_COMPARE[0]);
+    PRINTF("NRF_RTC1->CC[0]=0x%x\r\n", NRF_RTC1->CC[0]);
+    do {
+        PRINTF("NRF_RTC1->EVENTS_COMPARE[0]=");
+        PRINTF("%d", NRF_RTC1->EVENTS_COMPARE[0]);
+        PRINTF(" %d", NRF_RTC1->CC[0]);
+        PRINTF(" %d\r\n", NRF_RTC1->COUNTER);
+        nrf_delay_us(125000);
+    } while(NRF_RTC1->EVENTS_COMPARE[0] == 0);
+    PRINTF("NRF_RTC1->EVENTS_COMPARE[0]=");
+    PRINTF("%d", NRF_RTC1->EVENTS_COMPARE[0]);
+    PRINTF(" %d", NRF_RTC1->CC[0]);
+    PRINTF(" %d\r\n", NRF_RTC1->COUNTER);
+    step_by_step('b');
+    SCB->AIRCR = 0x05fa0004;    // System RESET!!
+    // Not come here (Just in case)
+    deepsleep();
+#else
     step_by_step('a');              
     // Internal 32kHz RC
-    NRF_CLOCK->LFCLKSRC = CLOCK_LFCLKSRC_SRC_RC << CLOCK_LFCLKSRC_SRC_Pos;           
+    //NRF_CLOCK->LFCLKSRC = CLOCK_LFCLKSRC_SRC_RC << CLOCK_LFCLKSRC_SRC_Pos;           
     // Start the 32 kHz clock, and wait for the start up to complete
-    NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
-    NRF_CLOCK->TASKS_LFCLKSTART = 1;
-    while(NRF_CLOCK->EVENTS_LFCLKSTARTED == 0);
+    //NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
+    //NRF_CLOCK->TASKS_LFCLKSTART = 1;
+    //while(NRF_CLOCK->EVENTS_LFCLKSTARTED == 0);
     // Configure the RTC to run at 2 second intervals, and make sure COMPARE0 generates an interrupt (this will be the wakeup source)
-    NRF_RTC1->PRESCALER = 3277;
+    NVIC_DisableIRQ(RTC0_IRQn);
+    NRF_RTC1->TASKS_STOP = 1;
+    // GPIOE
+#if 0
+    NRF_GPIO->PIN_CNF[21] =   (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos)
+                            | (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos)
+                            | (GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos)
+                            | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos)
+                            | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos);
+#endif    
+    NRF_GPIOTE->CONFIG[0] =   (GPIOTE_CONFIG_POLARITY_LoToHi << GPIOTE_CONFIG_POLARITY_Pos)
+                            | (21 << GPIOTE_CONFIG_PSEL_Pos) 
+                            | (GPIOTE_CONFIG_MODE_Task << GPIOTE_CONFIG_MODE_Pos);
+    // RTC1
+    NRF_RTC1->TASKS_STOP = 1;
+    NRF_RTC1->EVENTS_COMPARE[0] = 0;
+    NRF_RTC1->EVTENCLR = 0x000f0003; // all clear
     NRF_RTC1->EVTENSET = RTC_EVTEN_COMPARE0_Msk;
-    NRF_RTC1->INTENSET = RTC_INTENSET_COMPARE0_Msk;
-    NRF_RTC1->CC[0] = 2*10;
+    NRF_RTC1->TASKS_CLEAR = 1;    
+    NRF_RTC1->CC[0] = 100;
+    NRF_RTC1->PRESCALER = 4095;
+    do {
+        NRF_RTC1->TASKS_STOP = 1; 
+        NRF_RTC1->PRESCALER = 4095;
+        PRINTF("Retry PRESCALER setting\r\n");
+    } while (NRF_RTC1->PRESCALER != 4095);    
+    PRINTF("NRF_RTC1->PRESCALER=0x%x\r\n", NRF_RTC1->PRESCALER);
+    PRINTF("NRF_RTC1->EVTEN=0x%x\r\n", NRF_RTC1->EVTEN);
+    PRINTF("NRF_RTC1->COUNTER=0x%x\r\n", NRF_RTC1->COUNTER);
+    PRINTF("NRF_RTC1->EVENTS_COMPARE[0]=0x%x\r\n", NRF_RTC1->EVENTS_COMPARE[0]);
+    PRINTF("NRF_RTC1->CC[0]=0x%x\r\n", NRF_RTC1->CC[0]);
+    // PPI
+    NRF_PPI->CH[0].EEP = (uint32_t)&NRF_RTC1->EVENTS_COMPARE[0];
+    NRF_PPI->CH[0].TEP = (uint32_t)&NRF_GPIOTE->TASKS_OUT[0];
+    // Enable only PPI channels 0
+    NRF_PPI->CHEN = PPI_CHEN_CH0_Enabled << PPI_CHEN_CH0_Pos;
     NRF_RTC1->TASKS_START = 1;
-    //NVIC_EnableIRQ(RTC1_IRQn);
+    do {
+        PRINTF("NRF_RTC1->EVENTS_COMPARE[0]=");
+        PRINTF("%d", NRF_RTC1->EVENTS_COMPARE[0]);
+        PRINTF(" %d", NRF_RTC1->CC[0]);
+        PRINTF(" %d\r\n", NRF_RTC1->COUNTER);
+    } while(NRF_RTC1->EVENTS_COMPARE[0] == 0);
+    PRINTF("NRF_RTC1->EVENTS_COMPARE[0]=");
+    PRINTF("%d", NRF_RTC1->EVENTS_COMPARE[0]);
+    PRINTF(" %d", NRF_RTC1->CC[0]);
+    PRINTF(" %d\r\n", NRF_RTC1->COUNTER);
+    step_by_step('b');
+    SCB->AIRCR = 0x05fa0004;    // System RESET!!
+    // Not come here (Just in case)
+    deepsleep();
+#endif
+#if 0       
     // Configure the RAM retention parameters
     NRF_POWER->RAMON = POWER_RAMON_ONRAM0_RAM0On   << POWER_RAMON_ONRAM0_Pos
                      | POWER_RAMON_ONRAM1_RAM1Off  << POWER_RAMON_ONRAM1_Pos
@@ -141,8 +262,9 @@
         __WFI();
         //NRF_RTC1->TASKS_STOP = 1;
     }
-    //break;
-    #if 0
+    break;
+#endif
+#if 0
 case '3' :
     step_by_step('x');
     p_out = 1;
@@ -156,4 +278,4 @@
         wait(0.1);
     }
     break;
-    #endif              
+#endif              
diff -r 36ad7c7d0400 -r 8c37a47ac34c debug_tools/mon_hw_LPC1114.cpp
--- a/debug_tools/mon_hw_LPC1114.cpp	Sun Feb 14 21:55:30 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1493 +0,0 @@
-/*
- * mbed Application program for the mbed LPC1114FN28
- * Monitor program Ver.3 for only for LPC1114FN28
- *
- *  Copyright (c) 2010-2014 Kenji Arai / JH1PJL
- *  http://www.page.sannet.ne.jp/kenjia/index.html
- *  http://mbed.org/users/kenjiArai/
- *      Created:  May       15th, 2010
- *          release as "monitor_01" http://mbed.org/users/kenjiArai/code/monitor_01/
- *      Spareted: June      25th, 2014      mon() & mon_hw()
- *      Revised:  Nobember   2nd, 2014
- *
- * 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.
- */
-
-#if defined(TARGET_LPC1114)
-
-//  Include ---------------------------------------------------------------------------------------
-#include "mbed.h"
-#include "mon_hw_config.h"
-#include "mon_hw_common.h"
-
-//  Object ----------------------------------------------------------------------------------------
-
-//  Definition ------------------------------------------------------------------------------------
-// Define clocks
-#define __XTAL              (12000000UL)    // Oscillator frequency
-#define __SYS_OSC_CLK       (    __XTAL)    // Main oscillator frequency
-#define __IRC_OSC_CLK       (12000000UL)    // Internal RC oscillator frequency
-
-//  RAM -------------------------------------------------------------------------------------------
-uint32_t SystemFrequency;
-
-//  ROM / Constant data ---------------------------------------------------------------------------
-#if USE_MEM
-//  Memory range data
-const uint32_t mem_range[][2] = {          // Memory access range
-    { 0x00000000, 0x00007fff },            // On-chip non-volatile memory     //32KB Flash memory
-    { 0x10000000, 0x10000fff },            // On-chip SRAM                    //4KB local RAM
-    { 0x1fff0000, 0x1fff3fff },            // Boot ROM                        //16KB Boot ROM
-    { 0x40000000, 0x4007ffff },            // IO area
-    { 0x50000000, 0x501fffff }             // IO area
-};
-#endif  // USE_MEM
-
-char *const mon_msg = "HW monitor only for mbed LPC1114FN28 created on "__DATE__","__TIME__"";
-
-char *const xmsg0 = "Not implimented yet";
-
-char *const hmsg0 = "m  - Entry Memory Mode";
-char *const hmsg1 = "m>? -> Help ";
-char *const hmsg2 = "r  - Show PORT,I2C,SPI,UART & other Reg.";
-char *const hmsg3 = "r>? -> Help";
-char *const hmsg4 = "sf - System Clock";
-char *const hmsg5 = "sc - System / CPU information";
-char *const hmsg6 = "x  - Special command for Debug";
-char *const hmsg7 = "q  - Quit (back to called routine)";
-
-#if (USE_PORT==0)||(USE_UART==0)||(USE_SPI==0)||(USE_I2C==0)
-char *const io_port_name0 = "PIO0_";
-char *const io_port_name1 = "PIO1_";
-char *const iomsg0 = "Func->select ";
-char *const iomsg1 = "IO";
-char *const iomsg2 = "Reserved";
-char *const iomsg30 = "B0_MAT";
-char *const iomsg31 = "B1_MAT";
-char *const iomsg4 = "Std/F-md I2C";
-char *const iomsg5 = "func. R";
-char *const iomsg6 = "D-Mode";
-char *const iomsg7 = "A-Mode";
-#endif
-
-//  Calculate CPU System Clock Frequency /refrence: system_LPCxx.c
-char *const fmsg0 = "Internal RC Oscillator";
-char *const fmsg1 = "Xtal Osc Clock";
-char *const fmsg2 = "Watch dog Osc Clock";
-char *const fmsg3 = "with PLL";
-char *const fmsg4 = "System Clock =";
-char *const fmsg5 = "PLL Post divider ratio =";
-char *const fmsg6 = "feedback devider =";
-char *const fmsg7 = "NO Clock ?!";
-
-#if (USE_UART==1) || (USE_SPI==1) || (USE_I2C == 1)
-char *const imsg2 = "-->Control Reg.";
-char *const imsg3 = "-->Status Reg.";
-char *const imsg4 = "-->Data Reg.";
-char *const imsg5 = "-->Clock control Reg.";
-#endif
-
-//  Function prototypes ---------------------------------------------------------------------------
-
-//-------------------------------------------------------------------------------------------------
-//  Control Program
-//-------------------------------------------------------------------------------------------------
-// No function
-void not_yet_impliment( void )
-{
-    PRINTF(xmsg0);
-    put_rn();
-}
-
-// No function
-#if (USE_MEM==0)||(USE_PORT==0)||(USE_UART==0)||(USE_SPI==0)||(USE_I2C==0)||(USE_SYS==0)
-void not_select( void )
-{
-    PRINTF("Not select the function (refer mon_hw_config.h)");
-    put_rn();
-}
-#endif
-
-//  Help Massage
-void msg_hlp_hw (void)
-{
-    PRINTF(mon_msg);
-    put_rn();
-    PRINTF(hmsg0);
-    put_rn();
-    PRINTF(hmsg1);
-    put_rn();
-    PRINTF(hmsg2);
-    put_rn();
-    PRINTF(hmsg3);
-    put_rn();
-    PRINTF(hmsg4);
-    put_rn();
-    PRINTF(hmsg5);
-    put_rn();
-    PRINTF(hmsg6);
-    put_rn();
-    PRINTF(hmsg7);
-    put_rn();
-}
-
-#if USE_MEM
-char *const rmsg0 = "FLASH     ";
-char *const rmsg1 = "SRAM      ";
-char *const rmsg2 = "Boot ROM  ";
-char *const rmsg3 = "IO Area0  ";
-char *const rmsg4 = "IO Area1  ";
-
-#include "mon_hw_mem.h"
-#endif   // USE_MEM
-
-//  Show 16bit register contents
-void reg_print(uint16_t size, uint16_t reg)
-{
-    uint16_t i, j, k, n;
-
-    if (size == 8) {
-        PRINTF(" 7, 6, 5, 4, 3, 2, 1, 0");
-        put_rn();
-        i = 8;
-        n = 0x80;
-    } else if (size == 16) {
-        PRINTF( "15,14,13,12,11,10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0" );
-        put_rn();
-        i = 16;
-        n = 0x8000;
-    } else {
-        PRINTF("0x%08x", reg);
-        return;
-    }
-    PUTC(' ');
-    for (; i>0; i--) {
-        k = n >> (size-i);
-        j = reg & k;
-        if (j) {
-            PUTC('1');
-        } else {
-            PUTC('0');
-        }
-        PUTC(' ');
-        PUTC(' ');
-    }
-    PRINTF("  (0x%04x)", reg);
-}
-
-#if USE_PORT
-void io_mode(uint32_t reg)
-{
-    PRINTF("MODE->");
-    switch (reg) {
-        case 0:
-            PRINTF("Inactive");
-            break;
-        case 1:
-            PRINTF("P-DWN");
-            break;
-        case 2:
-            PRINTF("P-UP");
-            break;
-        case 3:
-            PRINTF("Repeater");
-            break;
-    }
-}
-
-void io_hys(uint32_t reg)
-{
-    PRINTF("HIS->");
-    switch (reg) {
-        case 0:
-            PRINTF("Dis");
-            break;
-        case 1:
-            PRINTF("Ena");
-            break;
-    }
-}
-
-void io_od(uint32_t reg)
-{
-    PRINTF("OD->");
-    switch (reg) {
-        case 0:
-            PRINTF("no OD");
-            break;
-        case 1:
-            PRINTF("OD");
-            break;
-    }
-}
-
-void io_mode_hys_od(uint32_t reg)
-{
-    io_mode ((reg >>  3) & 0x3);
-    put_lin();
-    io_hys (( reg >>  5) & 0x1);
-    put_lin();
-    io_od (( reg >> 10) & 0x1);
-}
-
-// I/O Config IO0_x
-void io_config0(void)
-{
-    uint32_t r0;
-
-    // P0_0
-    r0 = LPC_IOCON->RESET_PIO0_0;
-    PRINTF("RESET_%s0(dp23)", io_port_name0);
-    put_spc(1);
-    reg_print( SIZE_X, r0 );
-    put_spc(2);
-    PRINTF( iomsg0 );
-    if ((r0 & 0x7) == 0) {
-        PRINTF("RESET");
-    } else {
-        PRINTF( iomsg1 );
-    }
-    put_lin();
-    io_mode_hys_od( r0 );
-    put_rn();
-    // P0_1
-    r0 = LPC_IOCON->PIO0_1;
-    PRINTF("%s1(dp24)", io_port_name0);
-    put_spc(3);
-    reg_print( SIZE_X, r0 );
-    put_spc(2);
-    PRINTF( iomsg0 );
-    switch (r0 & 0x7) {
-        case 0:
-            PRINTF(iomsg1);
-            break;
-        case 1:
-            PRINTF("CLKOUT");
-            break;
-        case 2:
-            PRINTF("32%s2", iomsg30);
-            break;
-    }
-    put_lin();
-    io_mode_hys_od(r0);
-    put_rn();
-    // P0_2
-    r0 = LPC_IOCON->PIO0_2;
-    PRINTF("%s2(dp25)",io_port_name0);
-    put_spc(3);
-    reg_print(SIZE_X, r0);
-    put_spc(2);
-    PRINTF(iomsg0);
-    switch (r0 & 0x7) {
-        case 0:
-            PRINTF(iomsg1);
-            break;
-        case 1:
-            PRINTF("SSEL0");
-            break;
-        case 2:
-            PRINTF("16B0_CAP0");
-            break;
-    }
-    put_lin();
-    io_mode_hys_od(r0);
-    put_rn();
-    // P0_3
-    r0 = LPC_IOCON->PIO0_3;
-    PRINTF("%s3(dp26)",io_port_name0);
-    put_spc(3);
-    reg_print(SIZE_X, r0);
-    put_spc(2);
-    PRINTF(iomsg0);
-    switch (r0 & 0x7) {
-        case 0:
-            PRINTF(iomsg1);
-            break;
-    }
-    put_lin();
-    io_mode_hys_od(r0);
-    put_rn();
-    // P0_4
-    r0 = LPC_IOCON->PIO0_4;
-    PRINTF("%s4(dp27)",io_port_name0);
-    put_spc(3);
-    reg_print(SIZE_X, r0);
-    put_spc(2);
-    PRINTF(iomsg0);
-    switch (r0 & 0x7) {
-        case 0:
-            PRINTF(iomsg1);
-            break;
-        case 1:
-            PRINTF("SCL");
-            break;
-    }
-    put_lin();
-    switch (( r0 >> 8 ) & 0x3) {
-        case 0:
-            PRINTF(iomsg4);
-            break;
-        case 1:
-            PRINTF(iomsg1);
-            break;
-        case 2:
-            PRINTF("Fast md");
-            break;
-        case 3:
-            PRINTF(iomsg2);
-            break;
-    }
-    put_rn();
-    // P0_5
-    r0 = LPC_IOCON->PIO0_5;
-    PRINTF("%s5(dp5)",io_port_name0);
-    put_spc(4);
-    reg_print(SIZE_X, r0);
-    put_spc(2);
-    PRINTF(iomsg0);
-    switch (r0 & 0x7) {
-        case 0:
-            PRINTF(iomsg1);
-            break;
-        case 1:
-            PRINTF("SDA");
-            break;
-    }
-    put_lin();
-    switch ( ( r0 >> 8 ) & 0x3 ) {
-        case 0:
-            PRINTF(iomsg4);
-            break;
-        case 1:
-            PRINTF(iomsg1);
-            break;
-        case 2:
-            PRINTF("Fast md");
-            break;
-        case 3:
-            PRINTF(iomsg2);
-            break;
-    }
-    put_rn();
-    // P0_6
-    r0 = LPC_IOCON->PIO0_6;
-    PRINTF("%s6(dp6)", io_port_name0);
-    put_spc(4);
-    reg_print(SIZE_X, r0);
-    put_spc(2);
-    PRINTF(iomsg0);
-    switch (r0 & 0x7) {
-        case 0:
-            PRINTF(iomsg1);
-            break;
-        case 1:
-            PRINTF(iomsg2);
-            break;
-        case 2:
-            PRINTF("SCK0");
-            break;
-    }
-    put_lin();
-    io_mode_hys_od(r0);
-    put_rn();
-    // P0_7
-    r0 = LPC_IOCON->PIO0_7;
-    PRINTF("%s7(dp28)", io_port_name0);
-    put_spc(3);
-    reg_print(SIZE_X, r0);
-    put_spc(2);
-    PRINTF(iomsg0);
-    switch (r0 & 0x7) {
-        case 0:
-            PRINTF(iomsg1);
-            break;
-        case 1:
-            PRINTF("CTS");
-            break;
-    }
-    put_lin();
-    io_mode_hys_od(r0);
-    put_rn();
-    // P0_8
-    r0 = LPC_IOCON->PIO0_8;
-    PRINTF("%s8(dp1)", io_port_name0);
-    put_spc(4);
-    reg_print(SIZE_X, r0);
-    put_spc(2);
-    PRINTF(iomsg0);
-    switch (r0 & 0x7) {
-        case 0:
-            PRINTF(iomsg1);
-            break;
-        case 1:
-            PRINTF("MISO0");
-            break;
-        case 2:
-            PRINTF("16%s0", iomsg30);
-            break;
-    }
-    put_lin();
-    io_mode_hys_od(r0);
-    put_rn();
-    // P0_9
-    r0 = LPC_IOCON->PIO0_9;
-    PRINTF("%s9(dp2)", io_port_name0);
-    put_spc(4);
-    reg_print(SIZE_X, r0);
-    put_spc(2);
-    PRINTF(iomsg0);
-    switch (r0 & 0x7) {
-        case 0:
-            PRINTF(iomsg1);
-            break;
-        case 1:
-            PRINTF("MOSI0");
-            break;
-        case 2:
-            PRINTF("16%s1", iomsg30);
-            break;
-    }
-    put_lin();
-    io_mode_hys_od(r0);
-    put_rn();
-    // P0_10
-    r0 = LPC_IOCON->SWCLK_PIO0_10;
-    PRINTF("SWCLK_%s10(dp3)", io_port_name0);
-    put_spc(1);
-    reg_print(SIZE_X, r0);
-    put_spc(2);
-    PRINTF(iomsg0);
-    switch (r0 & 0x7) {
-        case 0:
-            PRINTF("SWCLK");
-            break;
-        case 1:
-            PRINTF(iomsg1);
-            break;
-        case 2:
-            PRINTF("SCK0");
-            break;
-        case 3:
-            PRINTF("16%s2", iomsg30);
-            break;
-    }
-    put_lin();
-    io_mode_hys_od(r0);
-    put_rn();
-    // P0_11
-    r0 = LPC_IOCON->R_PIO0_11;
-    PRINTF("R_%s11(dp4)", io_port_name0);
-    put_spc(1);
-    reg_print(SIZE_X, r0);
-    put_spc(2);
-    PRINTF( iomsg0 );
-    switch ( r0 & 0x7 ) {
-        case 0:
-            PRINTF(iomsg5);
-            break;
-        case 1:
-            PRINTF(iomsg1);
-            break;
-        case 2:
-            PRINTF("AD0");
-            break;
-        case 3:
-            PRINTF("32%s3", iomsg30);
-            break;
-    }
-    put_lin();
-    io_mode_hys_od(r0);
-    if ( r0 & 0x80 ) {
-        PRINTF(", %s", iomsg6);
-    } else {
-        PRINTF(", %s", iomsg7);
-    }
-    put_rn();
-}
-
-// I/O Config IO1_x
-void io_config1(void)
-{
-    uint32_t r0;
-
-    // P1_0
-    r0 = LPC_IOCON->R_PIO1_0;
-    PRINTF("R_%s0(dp9)", io_port_name1);
-    put_spc(2);
-    reg_print(SIZE_X, r0);
-    put_spc(2);
-    PRINTF( iomsg0 );
-    switch ( r0 & 0x7 ) {
-        case 0:
-            PRINTF(iomsg5);
-            break;
-        case 1:
-            PRINTF(iomsg1);
-            break;
-        case 2:
-            PRINTF("AD1");
-            break;
-        case 3:
-            PRINTF("32B1_CAP0");
-            break;
-    }
-    io_mode_hys_od(r0);
-    if (r0 & 0x80) {
-        PRINTF(", %s", iomsg6);
-    } else {
-        PRINTF(", %s", iomsg7);
-    }
-    put_rn();
-    // P1_1
-    r0 = LPC_IOCON->R_PIO1_1;
-    PRINTF("R_%s1(dp10)", io_port_name1);
-    put_spc(1);
-    reg_print(SIZE_X, r0);
-    put_spc(2);
-    PRINTF(iomsg0);
-    switch (r0 & 0x7) {
-        case 0:
-            PRINTF(iomsg5);
-            break;
-        case 1:
-            PRINTF(iomsg1);
-            break;
-        case 2:
-            PRINTF("AD2");
-            break;
-        case 3:
-            PRINTF("32%s0", iomsg31);
-            break;
-    }
-    io_mode_hys_od(r0);
-    if (r0 & 0x80) {
-        PRINTF(", %s", iomsg6);
-    } else {
-        PRINTF(", %s", iomsg7);
-    }
-    put_rn();
-    // P1_2
-    r0 = LPC_IOCON->R_PIO1_2;
-    PRINTF("R_%s2(dp11)", io_port_name1);
-    put_spc(1);
-    reg_print(SIZE_X, r0);
-    put_spc(2);
-    PRINTF(iomsg0);
-    switch (r0 & 0x7) {
-        case 0:
-            PRINTF(iomsg5);
-            break;
-        case 1:
-            PRINTF(iomsg1);
-            break;
-        case 2:
-            PRINTF("AD3");
-            break;
-        case 3:
-            PRINTF("32%s1", iomsg31);
-            break;
-    }
-    io_mode_hys_od( r0 );
-    if (r0 & 0x80) {
-        PRINTF(", %s", iomsg6);
-    } else {
-        PRINTF(", %s", iomsg7);
-    }
-    put_rn();
-    // P1_3
-    r0 = LPC_IOCON->SWDIO_PIO1_3;
-    PRINTF("SWDIO_%s3(dp12)",io_port_name1);
-    put_spc(1);
-    reg_print(SIZE_X, r0);
-    put_spc(3);
-    PRINTF(iomsg0);
-    switch (r0 & 0x7) {
-        case 0:
-            PRINTF("SWDIO");
-            break;
-        case 1:
-            PRINTF(iomsg1);
-            break;
-        case 2:
-            PRINTF("AD4");
-            break;
-        case 3:
-            PRINTF("32%s2", iomsg31);
-            break;
-    }
-    io_mode_hys_od(r0);
-    if (r0 & 0x80) {
-        PRINTF(", %s", iomsg6);
-    } else {
-        PRINTF(", %s", iomsg7);
-    }
-    put_rn();
-    // P1_4
-    r0 = LPC_IOCON->PIO1_4;
-    PRINTF("%s4(dp13)",io_port_name1);
-    put_spc(3);
-    reg_print(SIZE_X, r0);
-    put_spc(2);
-    PRINTF( iomsg0 );
-    switch (r0 & 0x7) {
-        case 0:
-            PRINTF(iomsg1);
-            break;
-        case 1:
-            PRINTF("AD5");
-            break;
-        case 2:
-            PRINTF("32%s3", iomsg31);
-            break;
-    }
-    put_lin();
-    io_mode_hys_od(r0);
-    put_rn();
-    // P1_5
-    r0 = LPC_IOCON->PIO1_5;
-    PRINTF("%s5(dp14)",io_port_name1);
-    put_spc(3);
-    reg_print(SIZE_X, r0);
-    put_spc(2);
-    PRINTF(iomsg0);
-    switch (r0 & 0x7) {
-        case 0:
-            PRINTF(iomsg1);
-            break;
-        case 1:
-            PRINTF("RTS");
-            break;
-        case 2:
-            PRINTF("32B0_CAP0");
-            break;
-    }
-    put_lin();
-    io_mode_hys_od(r0);
-    put_rn();
-    // P1_6
-    r0 = LPC_IOCON->PIO1_6;
-    PRINTF("%s6(dp15)", io_port_name1);
-    put_spc(3);
-    reg_print(SIZE_X, r0);
-    put_spc(2);
-    PRINTF(iomsg0);
-    switch (r0 & 0x7) {
-        case 0:
-            PRINTF(iomsg1);
-            break;
-        case 1:
-            PRINTF("RXD");
-            break;
-        case 2:
-            PRINTF( "32%s0", iomsg30 );
-            break;
-    }
-    put_lin();
-    io_mode_hys_od( r0 );
-    put_rn();
-    // P1_7
-    r0 = LPC_IOCON->PIO1_7;
-    PRINTF("%s7(dp16)", io_port_name1);
-    put_spc(3);
-    reg_print(SIZE_X, r0);
-    put_spc(2);
-    PRINTF(iomsg0);
-    switch (r0 & 0x7) {
-        case 0:
-            PRINTF(iomsg1);
-            break;
-        case 1:
-            PRINTF("TXD");
-            break;
-        case 2:
-            PRINTF("32%s1", iomsg30);
-            break;
-    }
-    put_lin();
-    io_mode_hys_od(r0);
-    put_rn();
-    // P1_8
-    r0 = LPC_IOCON->PIO1_8;
-    PRINTF("%s8(dp17)", io_port_name1);
-    put_spc(3);
-    reg_print(SIZE_X, r0);
-    put_spc(2);
-    PRINTF(iomsg0);
-    switch (r0 & 0x7) {
-        case 0:
-            PRINTF(iomsg1);
-            break;
-        case 1:
-            PRINTF("32%s1", iomsg30);
-            break;
-    }
-    put_lin();
-    io_mode_hys_od(r0);
-    put_rn();
-    // P1_9
-    r0 = LPC_IOCON->PIO1_9;
-    PRINTF("%s9(dp18)", io_port_name1);
-    put_spc(3);
-    reg_print(SIZE_X, r0);
-    put_spc(2);
-    PRINTF(iomsg0);
-    switch (r0 & 0x7) {
-        case 0:
-            PRINTF(iomsg1);
-            break;
-        case 1:
-            PRINTF("16%s0", iomsg31);
-            break;
-        case 2:
-            PRINTF("MOSI1");
-            break;
-    }
-    put_lin();
-    io_mode_hys_od(r0);
-    put_rn();
-}
-#endif  // USE_PORT
-
-#if USE_SPI
-void spi_reg(int no)
-{
-    uint32_t n, r0, r1 ,r2, r3, r4, r5, r6, r7, r8;
-
-    if (no == SPI_0) {
-        n = 0;
-        r0 = LPC_SSP0->CR1;
-        r1 = LPC_SSP0->DR;
-        r2 = LPC_SSP0->SR;
-        r3 = LPC_SSP0->CPSR;
-        r4 = LPC_SSP0->IMSC;
-        r5 = LPC_SSP0->RIS;
-        r6 = LPC_SSP0->MIS;
-        r7 = LPC_SSP0->ICR;
-        r8 = LPC_SSP0->CR0;
-    } else if (no == SPI_1) {
-        n = 1;
-        r0 = LPC_SSP1->CR1;
-        r1 = LPC_SSP1->DR;
-        r2 = LPC_SSP1->SR;
-        r3 = LPC_SSP1->CPSR;
-        r4 = LPC_SSP1->IMSC;
-        r5 = LPC_SSP1->RIS;
-        r6 = LPC_SSP1->MIS;
-        r7 = LPC_SSP1->ICR;
-        r8 = LPC_SSP1->CR0;
-    } else {
-        return;
-    }
-    PRINTF("Show SSP%1d(SPI%1d) Registers", n, n);
-    put_rn();
-    PRINTF("CR0");
-    PRINTF(imsg2);
-    reg_print(SIZE8, r8);
-    put_rn();
-    PRINTF("CR1");
-    PRINTF(imsg2);
-    reg_print(SIZE8, r0);
-    put_rn();
-    PRINTF("DR");
-    PRINTF(imsg4);
-    reg_print(SIZE8, r1);
-    put_rn();
-    PRINTF("SR");
-    PRINTF(imsg3);
-    reg_print(SIZE8, r2);
-    put_rn();
-    PRINTF("CPSR");
-    PRINTF(imsg5);
-    reg_print(SIZE8, r3);
-    put_rn();
-    PRINTF("IMSC");
-    PRINTF(imsg2);
-    reg_print(SIZE8, r4);
-    put_rn();
-    PRINTF("RIS");
-    PRINTF(imsg3);
-    reg_print(SIZE8, r5);
-    put_rn();
-    PRINTF("MIS");
-    PRINTF(imsg3);
-    reg_print(SIZE8, r6);
-    put_rn();
-    PRINTF("ICR");
-    PRINTF(imsg2);
-    reg_print(SIZE8, r7);
-    put_rn();
-}
-#endif  //USE_SPI
-
-#if USE_UART
-void uart_reg(void)
-{
-    uint32_t r0,r1,r2,r3,r4,r5,r6;
-
-    // clear LCR[DLAB] to read registers
-    LPC_UART->LCR &= ~(1 << 7);
-    r0 = LPC_UART->RBR;
-    r1 = LPC_UART->IER;
-    r2 = LPC_UART->IIR;
-    r3 = LPC_UART->TER;
-    // set LCR[DLAB] to enable writing to divider registers
-    LPC_UART->LCR |= (1 << 7);
-    r4 = LPC_UART->DLL;
-    r5 = LPC_UART->DLM;
-    r6 = LPC_UART->FDR;
-    // clear LCR[DLAB]
-    LPC_UART->LCR &= ~(1 << 7);
-    // Print each register
-    PRINTF("Show UART Registers");
-    put_rn();
-    PRINTF("RBR");
-    PRINTF(imsg4);
-    reg_print(SIZE8, r0);
-    put_rn();
-    PRINTF("THR--Write only");
-    PRINTF(imsg4);
-    put_rn();
-    PRINTF("DLL");
-    PRINTF(imsg2);
-    reg_print(SIZE8, r4);
-    put_rn();
-    PRINTF("DLM");
-    PRINTF(imsg2);
-    reg_print(SIZE8, r5);
-    put_rn();
-    PRINTF("IER");
-    PRINTF(imsg2);
-    reg_print(SIZE8, r1);
-    put_rn();
-    PRINTF("IIR");
-    PRINTF(imsg2);
-    reg_print(SIZE8, r2);
-    put_rn();
-    PRINTF("FCR--Write only");
-    PRINTF(imsg2);
-    put_rn();
-    PRINTF("LCR,MCR,MSR,SCR,ACR--Not support");
-    put_rn();
-    PRINTF("FDR");
-    PRINTF(imsg2);
-    reg_print(SIZE8, r6);
-    put_rn();
-    PRINTF("TER");
-    PRINTF(imsg3);
-    reg_print(SIZE8, r3);
-    put_rn();
-    PRINTF("RS485CTRL,485ADRMATCH,485DLY--Not support");
-    put_rn();
-}
-#endif  //USE_UART
-
-//#if USE_SYS
-void cpu_inf (void)
-{
-    unsigned long m1, m2;
-
-    m1 = SCB->CPUID;
-    m2 = (m1 >> 24);
-    if (m2 == 0x41) {
-        put_r();
-        PRINTF("CPU = ARM ");
-    } else {
-        put_r();
-        PRINTF("CPU = NOT ARM ");
-    }
-    m2 = (m1 >> 4) & 0xfff;
-    if (m2 == 0xc23) {
-        PRINTF("Cortex-M3");
-        put_rn();
-    } else if (m2 == 0xc20) {
-        PRINTF("Cortex-M0");
-        put_rn();
-    } else {
-        PRINTF("NOT Cortex-M3,M0");
-        put_rn();
-    }
-    m2 = (m1 >> 20) & 0x0f;
-    PRINTF("Variant:%x", m2);
-    put_rn();
-    m2 = m1 & 0x7;
-    PRINTF("Revision:%x", m2);
-    put_rn();
-#if 0
-    // unique ID
-    // http://nemuisan.blog.bai.ne.jp/?eid=192845
-    m1 = *(__IO uint32_t *)((uint32_t)0x1FFF7A22);
-    PRINTF("Unique device ID(94bits):(1) 0x%08x ", m1);
-    m1 = *(__IO uint32_t *)((uint32_t)0x1FFF7A26);
-    PRINTF("(2) 0x%08x ", m1);
-    m1 = *(__IO uint32_t *)((uint32_t)0x1FFF7A2A);
-    PRINTF( "(3) 0x%08x", m1 );
-    put_rn();
-//    m1 = DBGMCU->IDCODE;
-//    PRINTF( "DBG ID: 0x%08x", m1 );
-#endif
-}
-
-//  Calculate CPU System Clock Frequency
-void get_freq(int pr)
-{
-    uint32_t wdt_osc = 0, pll_fct0 = 0, pll_fct1 = 0;
-
-    // Determine clock frequency according to clock register values
-    switch ((LPC_SYSCON->WDTOSCCTRL >> 5) & 0x0F) {
-        case 0:
-            wdt_osc =  400000;
-            break;
-        case 1:
-            wdt_osc =  500000;
-            break;
-        case 2:
-            wdt_osc =  800000;
-            break;
-        case 3:
-            wdt_osc = 1100000;
-            break;
-        case 4:
-            wdt_osc = 1400000;
-            break;
-        case 5:
-            wdt_osc = 1600000;
-            break;
-        case 6:
-            wdt_osc = 1800000;
-            break;
-        case 7:
-            wdt_osc = 2000000;
-            break;
-        case 8:
-            wdt_osc = 2200000;
-            break;
-        case 9:
-            wdt_osc = 2400000;
-            break;
-        case 10:
-            wdt_osc = 2600000;
-            break;
-        case 11:
-            wdt_osc = 2700000;
-            break;
-        case 12:
-            wdt_osc = 2900000;
-            break;
-        case 13:
-            wdt_osc = 3100000;
-            break;
-        case 14:
-            wdt_osc = 3200000;
-            break;
-        case 15:
-            wdt_osc = 3400000;
-            break;
-    }
-    wdt_osc /= ((LPC_SYSCON->WDTOSCCTRL & 0x1F) << 1) + 2;
-    put_r();
-    switch (LPC_SYSCON->MAINCLKSEL & 0x03) {
-        case 0:                             // Internal RC oscillator
-            SystemCoreClock = __IRC_OSC_CLK;
-            if(pr) {
-                PRINTF("%s = %dHz", fmsg0, SystemCoreClock);
-            }
-            break;
-        case 1:                             // Input Clock to System PLL
-            switch (LPC_SYSCON->SYSPLLCLKSEL & 0x03) {
-                case 0:                         // Internal RC oscillator
-                    SystemCoreClock = __IRC_OSC_CLK;
-                    if(pr) {
-                        PRINTF("%s = %dHz", fmsg0, SystemCoreClock);
-                    }
-                    break;
-                case 1:                         // System oscillator
-                    SystemCoreClock = __SYS_OSC_CLK;
-                    if(pr) {
-                        PRINTF("%s = %dHz", fmsg1, SystemCoreClock );
-                    }
-                    break;
-                case 2:                         // WDT Oscillator
-                    SystemCoreClock = wdt_osc;
-                    if(pr) {
-                        PRINTF("%s = %dHz", fmsg2, wdt_osc );
-                    }
-                    break;
-                case 3:                         // Reserved
-                    SystemCoreClock = 0;
-                    if(pr) {
-                        PRINTF(fmsg7);
-                    }
-                    break;
-            }
-            break;
-        case 2:                             // WDT Oscillator
-            SystemCoreClock = wdt_osc;
-            if(pr) {
-                PRINTF("%s = %dHz", fmsg2, wdt_osc );
-            }
-            break;
-        case 3:                             // System PLL Clock Out
-            switch (LPC_SYSCON->SYSPLLCLKSEL & 0x03) {
-                case 0:                         // Internal RC oscillator
-                    if (LPC_SYSCON->SYSPLLCTRL & 0x180) {
-                        SystemCoreClock = __IRC_OSC_CLK;
-                        if(pr) {
-                            PRINTF("%s = %dHz", fmsg0, SystemCoreClock);
-                        }
-                    } else {
-                        pll_fct0 = (LPC_SYSCON->SYSPLLCTRL & 0x01F) + 1;
-                        pll_fct1 = (LPC_SYSCON->SYSPLLCTRL & 0x060) >> 5UL;
-                        SystemCoreClock = __IRC_OSC_CLK *  pll_fct0;
-                        if(pr) {
-                            PRINTF("Use Internal RC = %dHz", __IRC_OSC_CLK);
-                            put_rn();
-                            PRINTF("%s %s = %dHz", fmsg0, fmsg3, SystemCoreClock);
-                            put_rn();
-                            PRINTF("%s %d, %s %d", fmsg5, pll_fct1, fmsg6, pll_fct0);
-                        }
-                    }
-                    break;
-                case 1:                         // System oscillator
-                    if (LPC_SYSCON->SYSPLLCTRL & 0x180) {
-                        SystemCoreClock = __SYS_OSC_CLK;
-                        if(pr) {
-                            PRINTF("%s = %dHz", fmsg1, SystemCoreClock );
-                        }
-                    } else {
-                        pll_fct0 = (LPC_SYSCON->SYSPLLCTRL & 0x01F) + 1;
-                        pll_fct1 = (LPC_SYSCON->SYSPLLCTRL & 0x060) >> 5UL;
-                        SystemCoreClock = __SYS_OSC_CLK * pll_fct0;
-                        if(pr) {
-                            PRINTF("Use XTAL = %dHz", __XTAL);
-                            put_rn();
-                            PRINTF("%s %s = %dHz", fmsg1, fmsg3, SystemCoreClock);
-                            put_rn();
-                            PRINTF("%s %d, %s %d", fmsg5, pll_fct1, fmsg6, pll_fct0);
-                        }
-                    }
-                    break;
-                case 2:                         // WDT Oscillator
-                    if (LPC_SYSCON->SYSPLLCTRL & 0x180) {
-                        SystemCoreClock = wdt_osc;
-                        if(pr) {
-                            PRINTF("%s = %dHz", fmsg2, wdt_osc );
-                        }
-                    } else {
-                        pll_fct0 = (LPC_SYSCON->SYSPLLCTRL & 0x01F) + 1;
-                        pll_fct1 = (LPC_SYSCON->SYSPLLCTRL & 0x060) >> 5UL;
-                        SystemCoreClock = wdt_osc *  pll_fct0;
-                        if(pr) {
-                            PRINTF("Use WDT OSC = %dHz", wdt_osc);
-                            put_rn();
-                            PRINTF("%s %s = %dHz", fmsg2, fmsg3, SystemCoreClock);
-                            put_rn();
-                            PRINTF("%s %d, %s %d", fmsg5, pll_fct1, fmsg6, pll_fct0);
-                        }
-                    }
-                    break;
-                case 3:                         // Reserved
-                    SystemCoreClock = 0;
-                    if(pr) {
-                        PRINTF("fmsg7");
-                    }
-                    break;
-            }
-            break;
-    }
-    SystemCoreClock /= LPC_SYSCON->SYSAHBCLKDIV;
-    if(pr) {
-        put_rn();
-        PRINTF("%s %dHz", fmsg4, SystemCoreClock);
-        put_rn();
-    }
-}
-//#endif  //USE_SYS
-
-#if USE_I2C
-void i2c_io_reg (void)
-{
-    uint32_t r0;
-
-    PRINTF("<Show IO Pin>");
-    put_rn();
-    // P0_4
-    r0 = LPC_IOCON->PIO0_4;
-    reg_print(SIZE_X, r0);
-    put_spc(2);
-    PRINTF("%s4(dp27)",io_port_name0);
-    put_spc(2);
-    PRINTF(iomsg0);
-    switch (r0 & 0x7) {
-        case 0:
-            PRINTF(iomsg1);
-            break;
-        case 1:
-            PRINTF("SCL");
-            break;
-    }
-    put_lin();
-    switch (( r0 >> 8 ) & 0x3) {
-        case 0:
-            PRINTF(iomsg4);
-            break;
-        case 1:
-            PRINTF(iomsg1);
-            break;
-        case 2:
-            PRINTF("Fast md");
-            break;
-        case 3:
-            PRINTF(iomsg2);
-            break;
-    }
-    put_rn();
-    // P0_5
-    r0 = LPC_IOCON->PIO0_5;
-    reg_print( SIZE_X, r0 );
-    put_spc(2);
-    PRINTF("%s5(dp5)",io_port_name0);
-    put_spc(3);
-    PRINTF(iomsg0);
-    switch (r0 & 0x7) {
-        case 0:
-            PRINTF(iomsg1);
-            break;
-        case 1:
-            PRINTF("SDA");
-            break;
-    }
-    put_lin();
-    switch ((r0 >> 8 ) & 0x3) {
-        case 0:
-            PRINTF(iomsg4);
-            break;
-        case 1:
-            PRINTF(iomsg1);
-            break;
-        case 2:
-            PRINTF("Fast md");
-            break;
-        case 3:
-            PRINTF(iomsg2);
-            break;
-    }
-    put_rn();
-}
-
-void i2c_reg (void)
-{
-    uint32_t r0,r1,r2,r3,r4,r5,r6,r7;
-
-    r0 = LPC_I2C->CONSET;
-    r1 = LPC_I2C->STAT;
-    r2 = LPC_I2C->DAT;
-    r3 = LPC_I2C->SCLH;
-    r4 = LPC_I2C->SCLL;
-    r5 = LPC_I2C->CONCLR;
-    r6 = LPC_I2C->MMCTRL;
-    r7 = LPC_I2C->DATA_BUFFER;
-
-    PRINTF("<Show I2C Registers>");
-    put_rn();
-    reg_print(SIZE8, r0);
-    put_spc(2);
-    PRINTF("CONSET");
-    PRINTF(imsg2);
-    put_rn();
-    reg_print(SIZE8, r1);
-    put_spc(2);
-    PRINTF("STAT");
-    PRINTF(imsg3);
-    put_rn();
-    reg_print(SIZE8, r2);
-    put_spc(2);
-    PRINTF("DAT");
-    PRINTF(imsg4);
-    put_rn();
-    put_spc(2);
-    PRINTF("ADR0--Not support");
-    put_rn();
-    reg_print(SIZE8, r3);
-    put_spc(2);
-    PRINTF("SCLH");
-    PRINTF(imsg2);
-    put_rn();
-    reg_print(SIZE8, r4);
-    put_spc(2);
-    PRINTF("SCLL");
-    PRINTF(imsg2);
-    put_rn();
-    reg_print(SIZE8, r5);
-    put_spc(2);
-    PRINTF("CONCLR");
-    PRINTF(imsg2);
-    put_rn();
-    reg_print(SIZE8, r6);
-    put_spc(2);
-    PRINTF("MMCTRL");
-    PRINTF(imsg2);
-    put_rn();
-    put_spc(2);
-    PRINTF("ADR1,2,3--Not support");
-    put_rn();
-    reg_print(SIZE8, r7);
-    put_spc(2);
-    PRINTF("DATA_BUFFER");
-    PRINTF(imsg5);
-    put_rn();
-    put_spc(2);
-    PRINTF("MASK0,1,2,3--Not support");
-    put_rn();
-}
-
-void i2c_freq (void)
-{
-    uint32_t r0,r1;
-
-    r0 = LPC_I2C->SCLH;
-    r1 = LPC_I2C->SCLL;
-    get_freq(0);
-    PRINTF("<I2C Status>");
-    put_rn();
-    PRINTF("Freq. = I2CPCLK/(SCLH+SCLL) = %d/(%d+%d) = %d Hz",
-           SystemCoreClock, r0, r1, SystemCoreClock/(r0+r1));
-    put_rn();
-    r0 = LPC_I2C->CONSET;
-    PRINTF("I2C I/F ");
-    if ( r0 & 0x40 ) {
-        PRINTF("Enabled");
-    } else {
-        PRINTF("disabled");
-    }
-    put_rn();
-}
-#endif
-
-//-------------------------------------------------------------------------------------------------
-//  Monitor Main Program
-//-------------------------------------------------------------------------------------------------
-int mon_hw (void)
-{
-    char *ptr;
-
-    put_r();
-    PRINTF("%s [Help:'?' key]", mon_msg);
-    put_rn();
-#if USE_SYS
-    get_freq(0);
-#endif      //USE_SYS
-    for (;;) {
-        put_r();
-        PUTC('>');
-        ptr = linebuf;
-        get_line(ptr, buf_size);
-        switch (*ptr++) {
-                //---------------------------------------------------------------------------------
-                //    Memory
-                //---------------------------------------------------------------------------------
-            case 'm' :
-#if USE_MEM
-                mem_inf(ptr);
-                put_rn();
-                break;
-#else
-                not_select();
-#endif   // USE_MEM
-                //---------------------------------------------------------------------------------
-                //    Register
-                //---------------------------------------------------------------------------------
-            case 'r' :
-                uint8_t  r_flg;
-                put_r();
-                PRINTF("Reg. Mode p,u,i,s,t,a,d,l,w,c & ?");
-                put_rn();
-                r_flg = 0;
-                for (; r_flg != 0xff;) {
-                    PRINTF("r>");
-                    ptr = linebuf;
-                    get_line(ptr, buf_size);
-                    put_r();
-                    switch(*ptr++) {
-                        case 'p' :
-#if USE_PORT
-                            put_r();
-                            switch(*ptr++) {
-                                case '0' :
-                                    io_config0();
-                                    break;
-                                case '1' :
-                                    io_config1();
-                                    break;
-                                case '*' :
-                                    io_config0();
-                                    put_rn();
-                                    io_config1();
-                                    break;
-                                case '?' :
-                                default:
-                                    PRINTF("Enter p0,p1 and p* for all");
-                                    put_rn();
-                            }
-#else
-                            not_select();
-#endif // USE_PORT
-                            break;
-                        case 'u' :
-#if USE_UART
-                            uart_reg();
-#else
-                            not_select();
-#endif // USE_UART
-                            break;
-                        case 'i' :
-#if USE_I2C
-                            put_r();
-                            i2c_io_reg();
-                            i2c_reg();
-                            i2c_freq();
-#else
-                            not_select();
-#endif // USE_I2C
-                            break;
-                        case 's' :
-#if USE_SPI
-                            switch(*ptr++) {
-                                case '0' :
-                                    spi_reg(SPI_0);
-                                    break;
-                                case '1' :
-                                    spi_reg(SPI_1);
-                                    break;
-                                case '*' :
-                                    spi_reg(SPI_0);
-                                    put_rn();
-                                    spi_reg( SPI_1 );
-                                    break;
-                                case '?' :
-                                default:
-                                    PRINTF("Enter s0,s1 and s* for all");
-                                    put_rn();
-                            }
-#else
-                            not_select();
-#endif // USE_SPI
-                            break;
-                        case 't' :      //
-                            not_yet_impliment();
-                            break;
-                        case 'a' :      //
-                            not_yet_impliment();
-                            break;
-                        case 'd' :      //
-                            not_yet_impliment();
-                            break;
-                        case 'w' :      //
-                            not_yet_impliment();
-                            break;
-                        case 'l' :        //
-                            not_yet_impliment();
-                            break;
-                        case 'c' :      //
-                            not_yet_impliment();
-                            break;
-                        case 'x' :      //
-                            not_yet_impliment();
-                            break;
-                        case 'y' :      //
-                            not_yet_impliment();
-                            break;
-                        case 'q' :        // quit
-                            r_flg = 0xff;
-                            break;
-                        case '?' :
-                            PRINTF("p - I/O Pin Config");
-                            put_rn();
-                            PRINTF("u - UART");
-                            put_rn();
-                            PRINTF("i - I2C");
-                            put_rn();
-                            PRINTF("s - SPI");
-                            put_rn();
-                            PRINTF("t - TIMER");
-                            put_rn();
-                            PRINTF("a - ADC");
-                            put_rn();
-                            PRINTF("d - DAC");
-                            put_rn();
-                            PRINTF("l - LDC");
-                            put_rn();
-                            PRINTF("w - WWDG");
-                            put_rn();
-                            PRINTF("c - COMP");
-                            put_rn();
-                            PRINTF("q - Exit mode");
-                            put_rn();
-                            break;
-                        default:
-                            PUTC('?');
-                            put_rn();
-                    }
-                }
-                PRINTF("Return to All Mode");
-                put_rn();
-                break;
-                //---------------------------------------------------------------------------------
-                //    System
-                //---------------------------------------------------------------------------------
-            case 's' :    // System related information
-#if USE_SYS
-                switch (*ptr++) {
-                    case 'f' :    // sc - show system clock frequency
-                        get_freq(1);
-                        break;
-                    case 'c' :    // sc - show system CPU information
-                        cpu_inf();
-                        break;
-                    case '?' :
-                    default:
-                        put_r();
-                        PRINTF("sc - System CPU information");
-                        put_rn();
-                        PRINTF("sf - System Clock");
-                        put_rn();
-                        break;
-                }
-#else
-                not_select();
-#endif   // USE_SYS
-                break;
-                //---------------------------------------------------------------------------------
-                //    Help
-                //---------------------------------------------------------------------------------
-            case '?' :
-                put_r();
-                msg_hlp_hw();
-                break;
-                //---------------------------------------------------------------------------------
-                //    Return to main routine
-                //---------------------------------------------------------------------------------
-            case 'q' :        // Quit
-                PRINTF("\rReturn to monitor ");
-                return 0;
-                //---------------------------------------------------------------------------------
-                //    Special command for DEBUG
-                //---------------------------------------------------------------------------------
-            case 'x' :
-                not_yet_impliment();
-                break;
-                //---------------------------------------------------------------------------------
-                //    no support
-                //---------------------------------------------------------------------------------
-            default:
-                PUTC('?');
-                put_rn();
-                break;
-        }
-    }
-}
-
-#endif  // defined(TARGET_LPC1114)
diff -r 36ad7c7d0400 -r 8c37a47ac34c debug_tools/mon_hw_LPC1768.cpp
--- a/debug_tools/mon_hw_LPC1768.cpp	Sun Feb 14 21:55:30 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1839 +0,0 @@
-/*
- * mbed Application program for the mbed LPC1768 Board
- * Monitor program Ver.3 for only for LPC1768
- *
- *	Copyright (c) 2010-2014 Kenji Arai / JH1PJL
- *	http://www.page.sannet.ne.jp/kenjia/index.html
- *	http://mbed.org/users/kenjiArai/
- *      Started: May 		9th, 2010
- *      Created: May       15th, 2010
- *			release as "monitor_01"	http://mbed.org/users/kenjiArai/code/monitor_01/
- *      restart: September 22nd, 2014
- *      Revised: Nobember   2nd, 2014
- *
- * 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.
- */
-
-#if defined(TARGET_LPC1768)
-
-//  Include ---------------------------------------------------------------------------------------
-#include "mbed.h"
-#include "mon_hw_config.h"
-#include "mon_hw_common.h"
-
-//  Object ----------------------------------------------------------------------------------------
-
-//  Definition ------------------------------------------------------------------------------------
-// Define clocks
-#define XTAL        		(12000000UL)        // Oscillator frequency
-#define OSC_CLK     		(      XTAL)        // Main oscillator frequency
-#define RTC_CLK     		(   32000UL)        // RTC oscillator frequency
-#define IRC_OSC     		( 4000000UL)        // Internal RC oscillator frequency
-
-//  RAM -------------------------------------------------------------------------------------------
-uint32_t SystemFrequency;
-
-//  ROM / Constant data ---------------------------------------------------------------------------
-#if USE_MEM
-//  Memory range data
-const uint32_t mem_range[][2] = {	// Memory access range
-    { 0x00000000, 0x0007ffff },     // On-chip non-volatile memory     // 512KB Flash memory
-    { 0x10000000, 0x10007fff },     // On-chip SRAM                    // 32KB local RAM
-    { 0x1fff0000, 0x1fff1fff },     // Boot ROM                        // 8KB Boot ROM
-    { 0x2007c000, 0x2007ffff },     // On-chip SRAM                    // 16KB AHB SRAM
-    { 0x20080000, 0x20083fff }      // On-chip SRAM                    // 16KB AHB SRAM
-};
-#endif // USE_MEM
-
-char *const mon_msg = "HW monitor only for mbed LPC1768 created on "__DATE__","__TIME__"";
-char *const xmsg0 = "Not implimented yet";
-
-char *const hmsg0 = "m  - Entry Memory Mode";
-char *const hmsg1 = "m>? -> Help ";
-char *const hmsg2 = "r  - Show PORT,I2C,SPI,UART & other Reg.";
-char *const hmsg3 = "r>? -> Help";
-char *const hmsg4 = "sf - System Clock";
-char *const hmsg5 = "sc - System / CPU information";
-char *const hmsg6 = "x  - Special command for Debug";
-char *const hmsg7 = "q  - Quit (back to called routine)";
-
-//  Function prototypes ---------------------------------------------------------------------------
-
-//-------------------------------------------------------------------------------------------------
-//  Control Program
-//-------------------------------------------------------------------------------------------------
-// No function
-static void not_yet_impliment( void )
-{
-    PRINTF(xmsg0);
-    put_rn();
-}
-
-// No function
-#if (USE_MEM==0)||(USE_PORT==0)||(USE_UART==0)||(USE_SPI==0)||(USE_I2C==0)||(USE_SYS==0)
-static void not_select( void )
-{
-    PRINTF("Not select the function (refer mon_hw_config.h)");
-    put_rn();
-}
-#endif
-
-//  Help Massage
-void msg_hlp_hw (void)
-{
-    PRINTF(mon_msg);
-    put_rn();
-    PRINTF(hmsg0);
-    put_rn();
-    PRINTF(hmsg1);
-    put_rn();
-    PRINTF(hmsg2);
-    put_rn();
-    PRINTF(hmsg3);
-    put_rn();
-    PRINTF(hmsg4);
-    put_rn();
-    PRINTF(hmsg5);
-    put_rn();
-    PRINTF(hmsg6);
-    put_rn();
-    PRINTF(hmsg7);
-    put_rn();
-}
-
-#if USE_MEM
-char *const rmsg0 = "FLASH     ";
-char *const rmsg1 = "SRAM      ";
-char *const rmsg2 = "Boot ROM  ";
-char *const rmsg3 = "AHB SRAM0 ";
-char *const rmsg4 = "AHB SRAM1 ";
-
-#include "mon_hw_mem.h"
-#endif   // USE_MEM
-
-#if USE_PORT
-void io_condition(uint32_t reg0, uint32_t reg1, uint8_t shift)
-{
-    PRINTF("IO->");
-    if (reg0 & (1UL << shift)) {
-        PRINTF("Output=");
-    } else {
-        PRINTF("Input =");
-    }
-    if (reg1 & (1UL << shift)) {
-        PUTC('1');
-    } else {
-        PUTC('0');
-    }
-}
-
-void port_config_left(void)
-{
-    uint32_t r0,r1;
-
-    // p5(P0.9)
-    PRINTF("p 5(P0. 9):");
-    r0 = LPC_PINCON->PINSEL0;
-    r0 = (r0 >> 18) & 0x03;
-    switch (r0) {
-        case 0:
-            r0 = LPC_GPIO0->FIODIR;
-            r1 = LPC_GPIO0->FIOPIN;
-            io_condition(r0, r1, 9);
-            break;
-        case 1:
-            PRINTF("I2STX_SDA");
-            break;
-        case 2:
-            PRINTF("MOSI1");
-            break;
-        case 3:
-            PRINTF("MAT2.3");
-            break;
-    }
-    put_rn();
-    // p6(P0.8)
-    PRINTF("p 6(P0. 8):");
-    r0 = LPC_PINCON->PINSEL0;
-    r0 = (r0 >> 16) & 0x03;
-    switch (r0) {
-        case 0:
-            r0 = LPC_GPIO0->FIODIR;
-            r1 = LPC_GPIO0->FIOPIN;
-            io_condition(r0, r1, 8);
-            break;
-        case 1:
-            PRINTF("I2STX_WS");
-            break;
-        case 2:
-            PRINTF("MISO1");
-            break;
-        case 3:
-            PRINTF("MAT2.2");
-            break;
-    }
-    put_rn();
-    // p7(P0.7)
-    PRINTF("p 7(P0. 7):");
-    r0 = LPC_PINCON->PINSEL0;
-    r0 = (r0 >> 14) & 0x03;
-    switch (r0) {
-        case 0:
-            r0 = LPC_GPIO0->FIODIR;
-            r1 = LPC_GPIO0->FIOPIN;
-            io_condition(r0, r1, 7);
-            break;
-        case 1:
-            PRINTF("I2STX_CLK");
-            break;
-        case 2:
-            PRINTF("SCK1");
-            break;
-        case 3:
-            PRINTF("MAT2.1");
-            break;
-    }
-    put_rn();
-    // p8(P0.6)
-    PRINTF("p 8(P0. 6):");
-    r0 = LPC_PINCON->PINSEL0;
-    r0 = (r0 >> 12) & 0x03;
-    switch (r0) {
-        case 0:
-            r0 = LPC_GPIO0->FIODIR;
-            r1 = LPC_GPIO0->FIOPIN;
-            io_condition(r0, r1, 6);
-            break;
-        case 1:
-            PRINTF("I2SRX_SDA");
-            break;
-        case 2:
-            PRINTF("SSEL1");
-            break;
-        case 3:
-            PRINTF("MAT2.0");
-            break;
-    }
-    put_rn();
-    // p9(P0.0)
-    PRINTF("p 9(P0. 0):");
-    r0 = LPC_PINCON->PINSEL0;
-    r0 = (r0 >> 0) & 0x03;
-    switch (r0) {
-        case 0:
-            r0 = LPC_GPIO0->FIODIR;
-            r1 = LPC_GPIO0->FIOPIN;
-            io_condition(r0, r1, 0);
-            break;
-        case 1:
-            PRINTF("RD1");
-            break;
-        case 2:
-            PRINTF("TXD3");
-            break;
-        case 3:
-            PRINTF("SDA1");
-            break;
-    }
-    put_rn();
-    // p10(P0.1)
-    PRINTF("p10(P0. 1):");
-    r0 = LPC_PINCON->PINSEL0;
-    r0 = (r0 >> 2) & 0x03;
-    switch (r0) {
-        case 0:
-            r0 = LPC_GPIO0->FIODIR;
-            r1 = LPC_GPIO0->FIOPIN;
-            io_condition(r0, r1, 1);
-            break;
-        case 1:
-            PRINTF("TD1");
-            break;
-        case 2:
-            PRINTF("RXD3");
-            break;
-        case 3:
-            PRINTF("SCL1");
-            break;
-    }
-    put_rn();
-    // p11(P0.18)
-    PRINTF("p11(P0.18):");
-    r0 = LPC_PINCON->PINSEL1;
-    r0 = (r0 >> 4) & 0x03;
-    switch (r0) {
-        case 0:
-            r0 = LPC_GPIO0->FIODIR;
-            r1 = LPC_GPIO0->FIOPIN;
-            io_condition(r0, r1, 18);
-            break;
-        case 1:
-            PRINTF("DCD1");
-            break;
-        case 2:
-            PRINTF("MOSI0");
-            break;
-        case 3:
-            PRINTF("MOSI");
-            break;
-    }
-    put_rn();
-    // p12(P0.17)
-    PRINTF("p12(P0.17):");
-    r0 = LPC_PINCON->PINSEL1;
-    r0 = (r0 >> 2) & 0x03;
-    switch (r0) {
-        case 0:
-            r0 = LPC_GPIO0->FIODIR;
-            r1 = LPC_GPIO0->FIOPIN;
-            io_condition(r0, r1, 17);
-            break;
-        case 1:
-            PRINTF("CTS1");
-            break;
-        case 2:
-            PRINTF("MISO0");
-            break;
-        case 3:
-            PRINTF("MISO");
-            break;
-    }
-    put_rn();
-    // p13(P0.15)
-    PRINTF("p13(P0.15):");
-    r0 = LPC_PINCON->PINSEL0;
-    r0 = (r0 >> 30) & 0x03;
-    switch (r0) {
-        case 0:
-            r0 = LPC_GPIO0->FIODIR;
-            r1 = LPC_GPIO0->FIOPIN;
-            io_condition(r0, r1, 15);
-            break;
-        case 1:
-            PRINTF("TXD1");
-            break;
-        case 2:
-            PRINTF("SCK0");
-            break;
-        case 3:
-            PRINTF("SCK");
-            break;
-    }
-    put_rn();
-    // p14(P0.16)
-    PRINTF("p14(P0.16):");
-    r0 = LPC_PINCON->PINSEL1;
-    r0 = (r0 >> 0) & 0x03;
-    switch (r0) {
-        case 0:
-            r0 = LPC_GPIO0->FIODIR;
-            r1 = LPC_GPIO0->FIOPIN;
-            io_condition(r0, r1, 16);
-            break;
-        case 1:
-            PRINTF("RXD1");
-            break;
-        case 2:
-            PRINTF("SSEL0");
-            break;
-        case 3:
-            PRINTF("SSEL");
-            break;
-    }
-    put_rn();
-    // p15(P0.23)
-    PRINTF("p15(P0.23):");
-    r0 = LPC_PINCON->PINSEL1;
-    r0 = (r0 >> 14) & 0x03;
-    switch (r0) {
-        case 0:
-            r0 = LPC_GPIO0->FIODIR;
-            r1 = LPC_GPIO0->FIOPIN;
-            io_condition(r0, r1, 23);
-            break;
-        case 1:
-            PRINTF("AD0.0");
-            break;
-        case 2:
-            PRINTF("I2SRX_CLK");
-            break;
-        case 3:
-            PRINTF("CAP3.0");
-            break;
-    }
-    put_rn();
-    // p16(P0.24)
-    PRINTF("p16(P0.24):");
-    r0 = LPC_PINCON->PINSEL1;
-    r0 = (r0 >> 16) & 0x03;
-    switch (r0) {
-        case 0:
-            r0 = LPC_GPIO0->FIODIR;
-            r1 = LPC_GPIO0->FIOPIN;
-            io_condition(r0, r1, 24);
-            break;
-        case 1:
-            PRINTF("AD0.1");
-            break;
-        case 2:
-            PRINTF("I2SRX_WS");
-            break;
-        case 3:
-            PRINTF("CAP3.1");
-            break;
-    }
-    put_rn();
-    // p17(P0.25)
-    PRINTF("p17(P0.25):");
-    r0 = LPC_PINCON->PINSEL1;
-    r0 = (r0 >> 18) & 0x03;
-    switch (r0) {
-        case 0:
-            r0 = LPC_GPIO0->FIODIR;
-            r1 = LPC_GPIO0->FIOPIN;
-            io_condition(r0, r1, 25);
-            break;
-        case 1:
-            PRINTF("AD0.2");
-            break;
-        case 2:
-            PRINTF("I2SRX_SDA");
-            break;
-        case 3:
-            PRINTF("TXD3");
-            break;
-    }
-    put_rn();
-    // p18(P0.26)
-    PRINTF("p18(P0.26):");
-    r0 = LPC_PINCON->PINSEL1;
-    r0 = (r0 >> 20) & 0x03;
-    switch (r0) {
-        case 0:
-            r0 = LPC_GPIO0->FIODIR;
-            r1 = LPC_GPIO0->FIOPIN;
-            io_condition(r0, r1, 26);
-            break;
-        case 1:
-            PRINTF("AD0.3");
-            break;
-        case 2:
-            PRINTF("AOUT");
-            break;
-        case 3:
-            PRINTF("RXD3");
-            break;
-    }
-    put_rn();
-    // p19(P1.30)
-    PRINTF("p19(P1.30):");
-    r0 = LPC_PINCON->PINSEL3;
-    r0 = (r0 >> 28) & 0x03;
-    switch (r0) {
-        case 0:
-            r0 = LPC_GPIO1->FIODIR;
-            r1 = LPC_GPIO1->FIOPIN;
-            io_condition(r0, r1, 30);
-            break;
-        case 1:
-            PRINTF("Reserved");
-            break;
-        case 2:
-            PRINTF("VBUS");
-            break;
-        case 3:
-            PRINTF("AD0.4");
-            break;
-    }
-    put_rn();
-    // p20(P1.31)
-    PRINTF("p20(P1.31):");
-    r0 = LPC_PINCON->PINSEL3;
-    r0 = (r0 >> 30) & 0x03;
-    switch (r0) {
-        case 0:
-            r0 = LPC_GPIO1->FIODIR;
-            r1 = LPC_GPIO1->FIOPIN;
-            io_condition(r0, r1, 31);
-            break;
-        case 1:
-            PRINTF("Reserved");
-            break;
-        case 2:
-            PRINTF("SCK1");
-            break;
-        case 3:
-            PRINTF("AD0.5");
-            break;
-    }
-    put_rn();
-}
-
-void port_config_right(void)
-{
-    uint32_t r0, r1;
-
-    // p30(P0.4)
-    PRINTF("p30(P0. 4):");
-    r0 = LPC_PINCON->PINSEL0;
-    r0 = (r0 >> 8) & 0x03;
-    switch (r0) {
-        case 0:
-            r0 = LPC_GPIO0->FIODIR;
-            r1 = LPC_GPIO0->FIOPIN;
-            io_condition(r0, r1, 4);
-            break;
-        case 1:
-            PRINTF("I2SRX_CLK");
-            break;
-        case 2:
-            PRINTF("RD2");
-            break;
-        case 3:
-            PRINTF("CAP2.0");
-            break;
-    }
-    put_rn();
-    // p29(P0.5)
-    PRINTF("p29(P0. 5):");
-    r0 = LPC_PINCON->PINSEL0;
-    r0 = (r0 >> 10) & 0x03;
-    switch (r0) {
-        case 0:
-            r0 = LPC_GPIO0->FIODIR;
-            r1 = LPC_GPIO0->FIOPIN;
-            io_condition(r0, r1, 5);
-            break;
-        case 1:
-            PRINTF("I2SRX_WS");
-            break;
-        case 2:
-            PRINTF("TD2");
-            break;
-        case 3:
-            PRINTF("CAP2.1");
-            break;
-    }
-    put_rn();
-    // p28(P0.10)
-    PRINTF("p28(P0.10):");
-    r0 = LPC_PINCON->PINSEL0;
-    r0 = (r0 >> 20) & 0x03;
-    switch (r0) {
-        case 0:
-            r0 = LPC_GPIO0->FIODIR;
-            r1 = LPC_GPIO0->FIOPIN;
-            io_condition(r0, r1, 10);
-            break;
-        case 1:
-            PRINTF("TXD2");
-            break;
-        case 2:
-            PRINTF("SDA2");
-            break;
-        case 3:
-            PRINTF("MAT3.0");
-            break;
-    }
-    put_rn();
-    // p27(P0.11)
-    PRINTF("p27(P0.11):");
-    r0 = LPC_PINCON->PINSEL0;
-    r0 = (r0 >> 22) & 0x03;
-    switch (r0) {
-        case 0:
-            r0 = LPC_GPIO0->FIODIR;
-            r1 = LPC_GPIO0->FIOPIN;
-            io_condition(r0, r1, 11);
-            break;
-        case 1:
-            PRINTF("RXD2");
-            break;
-        case 2:
-            PRINTF("SCL2");
-            break;
-        case 3:
-            PRINTF("MAT3.1");
-            break;
-    }
-    put_rn();
-    // p26(P2.0)
-    PRINTF("p26(P2. 0):");
-    r0 = LPC_PINCON->PINSEL4;
-    r0 = (r0 >> 0) & 0x03;
-    switch (r0) {
-        case 0:
-            r0 = LPC_GPIO2->FIODIR;
-            r1 = LPC_GPIO2->FIOPIN;
-            io_condition(r0, r1, 0);
-            break;
-        case 1:
-            PRINTF("PWM1.1");
-            break;
-        case 2:
-            PRINTF("TXD1");
-            break;
-        case 3:
-            PRINTF("Reserved");
-            break;
-    }
-    put_rn();
-    // p25(P2.1)
-    PRINTF("p25(P2. 1):");
-    r0 = LPC_PINCON->PINSEL4;
-    r0 = (r0 >> 2) & 0x03;
-    switch (r0) {
-        case 0:
-            r0 = LPC_GPIO2->FIODIR;
-            r1 = LPC_GPIO2->FIOPIN;
-            io_condition(r0, r1, 1);
-            break;
-        case 1:
-            PRINTF("PWM1.2");
-            break;
-        case 2:
-            PRINTF("RXD1");
-            break;
-        case 3:
-            PRINTF("Reserved");
-            break;
-    }
-    put_rn();
-    // p24(P2.2)
-    PRINTF("p24(P2. 2):");
-    r0 = LPC_PINCON->PINSEL4;
-    r0 = (r0 >> 4) & 0x03;
-    switch (r0) {
-        case 0:
-            r0 = LPC_GPIO2->FIODIR;
-            r1 = LPC_GPIO2->FIOPIN;
-            io_condition(r0, r1, 2);
-            break;
-        case 1:
-            PRINTF("PWM1.3");
-            break;
-        case 2:
-            PRINTF("CTS1");
-            break;
-        case 3:
-            PRINTF("Reserved");
-            break;
-    }
-    put_rn();
-    // p23(P2.3)
-    PRINTF("p23(P2. 3):");
-    r0 = LPC_PINCON->PINSEL4;
-    r0 = (r0 >> 6) & 0x03;
-    switch (r0) {
-        case 0:
-            r0 = LPC_GPIO2->FIODIR;
-            r1 = LPC_GPIO2->FIOPIN;
-            io_condition(r0, r1, 3);
-            break;
-        case 1:
-            PRINTF("PWM1.4");
-            break;
-        case 2:
-            PRINTF("DCD1");
-            break;
-        case 3:
-            PRINTF("Reserved");
-            break;
-    }
-    put_rn();
-    // p22(P2.4)
-    PRINTF("p22(P2. 4):");
-    r0 = LPC_PINCON->PINSEL4;
-    r0 = (r0 >> 8) & 0x03;
-    switch (r0) {
-        case 0:
-            r0 = LPC_GPIO2->FIODIR;
-            r1 = LPC_GPIO2->FIOPIN;
-            io_condition(r0, r1, 4);
-            break;
-        case 1:
-            PRINTF("PWM1.5");
-            break;
-        case 2:
-            PRINTF("DSR1");
-            break;
-        case 3:
-            PRINTF("Reserved");
-            break;
-    }
-    put_rn();
-    // p21(P2.5)
-    PRINTF("p21(P2. 5):");
-    r0 = LPC_PINCON->PINSEL4;
-    r0 = (r0 >> 10) & 0x03;
-    switch (r0) {
-        case 0:
-            r0 = LPC_GPIO2->FIODIR;
-            r1 = LPC_GPIO2->FIOPIN;
-            io_condition(r0, r1, 5);
-            break;
-        case 1:
-            PRINTF("PWM1.6");
-            break;
-        case 2:
-            PRINTF("DTR1");
-            break;
-        case 3:
-            PRINTF("Reserved");
-            break;
-    }
-    put_rn();
-}
-#endif	// USE_PORT
-
-//#if USE_SYS
-void cpu_inf ( void )
-{
-    unsigned long m1, m2;
-
-    m1 = SCB->CPUID;
-    m2 = ( m1 >> 24 );
-    if ( m2 == 0x41 ) {
-        put_r();
-        PRINTF("CPU = ARM ");
-    } else {
-        put_r();
-        PRINTF("CPU = NOT ARM ");
-    }
-    m2 = ( m1 >> 4 ) & 0xfff;
-    if ( m2 == 0xc23 ) {
-        PRINTF("Cortex-M3");
-        put_rn();
-    } else {
-        PRINTF("NOT Cortex-M3");
-        put_rn();
-    }
-    m2 = ( m1 >> 20 ) & 0x0f;
-    PRINTF("Variant:%x", m2);
-    put_rn();
-    m2 = m1 & 0x7;
-    PRINTF("Revision:%x", m2);
-    put_rn();
-}
-//#endif	// USE_SYS
-
-//  Calculate CPU System Clock Frequency
-void get_freq ( int pr )
-{
-    if(pr) {
-        put_r();
-        PRINTF("System Clock = %dHz",SystemFrequency );
-        put_rn();
-    }
-    if (((LPC_SC->PLL0STAT >> 24) & 3) == 3) {/* If PLL0 enabled and connected      */
-        if(pr) {
-            PRINTF("PLL0 enabled");
-            put_rn();
-        }
-        switch (LPC_SC->CLKSRCSEL & 0x03) {
-            case 0:                /* Internal RC oscillator => PLL0     */
-            case 3:                /* Reserved, default to Internal RC   */
-                if(pr) {
-                    PRINTF("Internal RC Oscillator");
-                    put_rn();
-                }
-                SystemFrequency = (IRC_OSC *
-                                   (((2 * ((LPC_SC->PLL0STAT & 0x7FFF) + 1))) /
-                                    (((LPC_SC->PLL0STAT >> 16) & 0xFF) + 1))   /
-                                   ((LPC_SC->CCLKCFG & 0xFF)+ 1));
-                break;
-            case 1:                /* Main oscillator => PLL0            */
-                if(pr) {
-                    PRINTF("Xtal Osc Clock = %dHz",XTAL );
-                    put_rn();
-                }
-                SystemFrequency = (OSC_CLK *
-                                   (((2 * ((LPC_SC->PLL0STAT & 0x7FFF) + 1))) /
-                                    (((LPC_SC->PLL0STAT >> 16) & 0xFF) + 1))   /
-                                   ((LPC_SC->CCLKCFG & 0xFF)+ 1));
-                break;
-            case 2:                /* RTC oscillator => PLL0             */
-                if(pr) {
-                    PRINTF("RTC Xtal Oscillator f = %dHz", RTC_CLK );
-                    put_rn();
-                }
-                SystemFrequency = (RTC_CLK *
-                                   (((2 * ((LPC_SC->PLL0STAT & 0x7FFF) + 1))) /
-                                    (((LPC_SC->PLL0STAT >> 16) & 0xFF) + 1))   /
-                                   ((LPC_SC->CCLKCFG & 0xFF)+ 1));
-                break;
-        }
-    } else {
-        if(pr) {
-            PRINTF("PLL0 disabled");
-        }
-        switch (LPC_SC->CLKSRCSEL & 0x03) {
-            case 0:                /* Internal RC oscillator => PLL0     */
-            case 3:                /* Reserved, default to Internal RC   */
-                if(pr) {
-                    PRINTF("Internal RC Oscillator");
-                    put_rn();
-                }
-                SystemFrequency = IRC_OSC / ((LPC_SC->CCLKCFG & 0xFF)+ 1);
-                break;
-            case 1:                /* Main oscillator => PLL0            */
-                if(pr) {
-                    PRINTF("Xtal Osc Clock = %dHz",XTAL );
-                    put_rn();
-                }
-                SystemFrequency = OSC_CLK / ((LPC_SC->CCLKCFG & 0xFF)+ 1);
-                break;
-            case 2:                /* RTC oscillator => PLL0             */
-                if(pr) {
-                    PRINTF("RTC Xtal Oscillator f = %dHz", RTC_CLK );
-                    put_rn();
-                }
-                SystemFrequency = RTC_CLK / ((LPC_SC->CCLKCFG & 0xFF)+ 1);
-                break;
-        }
-    }
-}
-
-#if (USE_UART==1)||(USE_SPI==1)||(USE_I2C==1)
-char *const uismsg0 = "is enable";
-char *const uismsg1 = "is disable";
-char *const uismsg2 = "(mbed pins are not avairable)";
-char *const uismsg3 = "Other";
-#endif
-
-#if USE_UART
-//  Show 16bit register contents
-void reg_print(uint16_t size, uint16_t reg)
-{
-    uint16_t i, j, k, n;
-
-    if (size == 8) {
-        PRINTF(" 7, 6, 5, 4, 3, 2, 1, 0");
-        put_rn();
-        i = 8;
-        n = 0x80;
-    } else if (size == 16) {
-        PRINTF( "15,14,13,12,11,10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0" );
-        put_rn();
-        i = 16;
-        n = 0x8000;
-    } else {
-        PRINTF("0x%08x", reg);
-        return;
-    }
-    PUTC(' ');
-    for (; i>0; i--) {
-        k = n >> (size-i);
-        j = reg & k;
-        if (j) {
-            PUTC('1');
-        } else {
-            PUTC('0');
-        }
-        PUTC(' ');
-        PUTC(' ');
-    }
-    PRINTF("  (0x%04x)", reg);
-}
-
-void uart_reg(uint8_t uart)
-{
-    uint32_t c_lcr,c_fdr,c_dll,c_dlm;
-    uint32_t divaddval,mulval,div,baud;
-
-    PRINTF("<Show UART%d status>", uart);
-    put_rn();
-    c_lcr = c_fdr = c_dll = c_dlm = 0;
-    divaddval = mulval = div = baud = 0;
-    get_freq(0);
-    switch (uart) {
-        case 0:
-            if (LPC_SC->PCONP & (1UL<<3)) {
-                c_fdr = LPC_UART0->FDR;
-                c_lcr = LPC_UART0->LCR;
-                // set LCR[DLAB] to enable writing to divider registers
-                LPC_UART0->LCR |= (1 << 7);
-                c_dll = LPC_UART0->DLL;
-                c_dlm = LPC_UART0->DLM;
-                // clear LCR[DLAB]
-                LPC_UART0->LCR &= ~(1 << 7);
-                div = (LPC_SC->PCLKSEL0 >> 6) & 0x3;
-            }
-            break;
-        case 1:
-            if (LPC_SC->PCONP & (1UL<<4)) {
-                c_fdr = LPC_UART1->FDR;
-                c_lcr = LPC_UART1->LCR;
-                // set LCR[DLAB] to enable writing to divider registers
-                LPC_UART1->LCR |= (1 << 7);
-                c_dll = LPC_UART1->DLL;
-                c_dlm = LPC_UART1->DLM;
-                // clear LCR[DLAB]
-                LPC_UART1->LCR &= ~(1 << 7);
-                div = (LPC_SC->PCLKSEL0 >> 8) & 0x3;
-            }
-            break;
-        case 2:
-            if (LPC_SC->PCONP & (1UL<<24)) {
-                c_fdr = LPC_UART2->FDR;
-                c_lcr = LPC_UART2->LCR;
-                // set LCR[DLAB] to enable writing to divider registers
-                LPC_UART2->LCR |= (1 << 7);
-                c_dll = LPC_UART2->DLL;
-                c_dlm = LPC_UART2->DLM;
-                // clear LCR[DLAB]
-                LPC_UART2->LCR &= ~(1 << 7);
-                div = (LPC_SC->PCLKSEL1 >> 16) & 0x3;
-            }
-            break;
-        case 3:
-            if (LPC_SC->PCONP & (1UL<<25)) {
-                c_fdr = LPC_UART3->FDR;
-                c_lcr = LPC_UART3->LCR;
-                // set LCR[DLAB] to enable writing to divider registers
-                LPC_UART3->LCR |= (1 << 7);
-                c_dll = LPC_UART3->DLL;
-                c_dlm = LPC_UART3->DLM;
-                // clear LCR[DLAB]
-                LPC_UART3->LCR &= ~(1 << 7);
-                div = (LPC_SC->PCLKSEL1 >> 18) & 0x3;
-            }
-            break;
-        default:
-            break;
-    }
-    if ((c_fdr == 0)&&(c_lcr == 0)&&(c_dll == 0)) {
-        PRINTF("NOT Avairable (power off the UART module)");
-    } else {
-        // condition
-        PRINTF("Word Length: ");
-        switch ((c_lcr >> 0) & 0x03) {
-            case 0:
-                PUTC('5');
-                break;
-            case 1:
-                PUTC('6');
-                break;
-            case 2:
-                PUTC('7');
-                break;
-            case 3:
-                PUTC('8');
-                break;
-        }
-        PRINTF("-bit");
-        put_rn();
-        PRINTF("Stop bit: ");
-        if (c_lcr & 0x04) {
-            PUTC('1');
-        } else {
-            PUTC('2');
-        }
-        PRINTF("-bit");
-        put_rn();
-        PRINTF("Parity: ");
-        if (c_lcr & 0x08) {
-            switch ((c_lcr >> 4) & 0x03) {
-                case 0:
-                    PRINTF("Odd");
-                    break;
-                case 1:
-                    PRINTF("Even");
-                    break;
-                case 2:
-                    PRINTF("Forced '1'");
-                    break;
-                case 3:
-                    PRINTF("Forced '0'");
-                    break;
-            }
-            PRINTF(" parity");
-        } else {
-            PRINTF("None-Parity");
-        }
-        put_rn();
-        switch (div) {
-            case 0:
-                div = 4;
-                break;
-            case 1:
-                div = 1;
-                break;
-            case 2:
-                div = 2;
-                break;
-            case 3:
-                div = 8;
-                break;
-        }
-        divaddval = (c_fdr >> 0) & 0x0f;
-        mulval = (c_fdr >> 4) & 0x0f;
-        baud =  (SystemCoreClock/div)/(16 * (256 * c_dlm + c_dll) * (1 + divaddval/mulval));
-        PRINTF("Baud rate: %d bps", baud);
-        put_rn();
-        PRINTF(" = PCLK(=Sys/div)/(16 x (256 x DLM + DLL) x (1 + DivAddVal/MulVal)");
-        put_rn();
-        PRINTF(" = (%d/%d)/(16 x (256 x %d + %d) x (1 + %d/%d)",
-               SystemCoreClock,div,c_dlm,c_dll,divaddval,mulval);
-    }
-    put_rn();
-}
-
-void uart_io_print (void)
-{
-    PRINTF("<Show IO Pin>");
-    put_rn();
-}
-
-void uart_io_reg0 (void)
-{
-    uint32_t r0;
-
-    PRINTF("UART0/USBTX(P0.2),USBRX(P0.3):");
-    // P0.2
-    r0 = LPC_PINCON->PINSEL0;
-    r0 = (r0 >> 4) & 0x03;
-    if (r0 == 1) {
-        PRINTF("TXD0 ");
-    } else {
-        PRINTF(uismsg3);
-    }
-    // P0.3
-    r0 = LPC_PINCON->PINSEL0;
-    r0 = (r0 >> 6) & 0x03;
-    if (r0 == 1) {
-        PRINTF(",RXD0");
-    } else {
-        PRINTF(",%s", uismsg3);
-    }
-    PRINTF("(connected to PC via USB)");
-    put_rn();
-}
-
-void uart_io_reg1 (void)
-{
-    uint32_t r0;
-
-    PRINTF("UART1/ p13(P0.15), p14(P0.16):");
-    // P0.15
-    r0 = LPC_PINCON->PINSEL0;
-    r0 = (r0 >> 30) & 0x03;
-    if (r0 == 1) {
-        PRINTF("TXD1 ");
-    } else {
-        PRINTF(uismsg3);
-    }
-    // P0.16
-    r0 = LPC_PINCON->PINSEL1;
-    r0 = (r0 >> 2) & 0x03;
-    if (r0 == 1) {
-        PRINTF(",RXD1");
-    } else {
-        PRINTF(",%s", uismsg3);
-    }
-    put_rn();
-}
-
-void uart_io_reg2 (void)
-{
-    uint32_t r0;
-
-    PRINTF("UART2/ p28(P0.10), p27(P0.11):");
-    // P0.10
-    r0 = LPC_PINCON->PINSEL0;
-    r0 = (r0 >> 20) & 0x03;
-    if (r0 == 1) {
-        PRINTF("TXD2 ");
-    } else {
-        PRINTF(uismsg3);
-    }
-    // P0.11
-    r0 = LPC_PINCON->PINSEL0;
-    r0 = (r0 >> 22) & 0x03;
-    if (r0 == 1) {
-        PRINTF(",RXD2");
-    } else {
-        PRINTF(",%s", uismsg3);
-    }
-    put_rn();
-}
-
-void uart_io_reg3 (void)
-{
-    uint32_t r0;
-
-    PRINTF("UART3/ p 9(P0. 0), p10(P0. 1):");
-    // P0.0
-    r0 = LPC_PINCON->PINSEL0;
-    r0 = (r0 >> 0) & 0x03;
-    if (r0 == 2) {
-        PRINTF("TXD3 ");
-    } else {
-        PRINTF(uismsg3);
-    }
-    // P0.1
-    r0 = LPC_PINCON->PINSEL0;
-    r0 = (r0 >> 2) & 0x03;
-    if (r0 == 2) {
-        PRINTF(",RXD3");
-    } else {
-        PRINTF(",%s", uismsg3);
-    }
-    put_rn();
-}
-#endif  //USE_UART
-
-#if USE_SPI
-void spi_io_reg (void)
-{
-    uint32_t r0;
-
-    PRINTF("<Show IO Pin>");
-    put_rn();
-    //-----------------------------------------------------
-    PRINTF("SPI /p11(P0.18),p12(P0.17),p13(P0.15):");
-    // p11(P0.18)
-    r0 = LPC_PINCON->PINSEL1;
-    r0 = (r0 >> 4) & 0x03;
-    if (r0 == 3) {
-        PRINTF(",MOSI ");
-    } else {
-        PRINTF("%s", uismsg3);
-    }
-    // p12(P0.17)
-    r0 = LPC_PINCON->PINSEL1;
-    r0 = (r0 >> 2) & 0x03;
-    if (r0 == 3) {
-        PRINTF(",MISO ");
-    } else {
-        PRINTF(",%s", uismsg3);
-    }
-    // p13(P0.15)
-    r0 = LPC_PINCON->PINSEL0;
-    r0 = (r0 >> 30) & 0x03;
-    if (r0 == 3) {
-        PRINTF(",SCK ");
-    } else {
-        PRINTF(",%s", uismsg3);
-    }
-    put_rn();
-    //-----------------------------------------------------
-    PRINTF("SSP0/p11(P0.18),p12(P0.17),p13(P0.15):");
-    // p11(P0.18)
-    r0 = LPC_PINCON->PINSEL1;
-    r0 = (r0 >> 4) & 0x03;
-    if (r0 == 2) {
-        PRINTF(",MOSI0");
-    } else {
-        PRINTF("%s", uismsg3);
-    }
-    // p12(P0.17)
-    r0 = LPC_PINCON->PINSEL1;
-    r0 = (r0 >> 2) & 0x03;
-    if (r0 == 2) {
-        PRINTF(",MISO0");
-    } else {
-        PRINTF(",%s", uismsg3);
-    }
-    // p13(P0.15)
-    r0 = LPC_PINCON->PINSEL0;
-    r0 = (r0 >> 30) & 0x03;
-    if (r0 == 2) {
-        PRINTF(",SCK0 ");
-    } else {
-        PRINTF(",%s", uismsg3);
-    }
-    put_rn();
-    //-----------------------------------------------------
-    PRINTF("SSP1/p 5(P0. 9),p 6(P0. 8),p 7(P0. 7):");
-    // p5(P0.9)
-    r0 = LPC_PINCON->PINSEL0;
-    r0 = (r0 >> 18) & 0x03;
-    if (r0 == 2) {
-        PRINTF("MOSI1");
-    } else {
-        PRINTF(uismsg3);
-    }
-    // p6(P0.8)
-    r0 = LPC_PINCON->PINSEL0;
-    r0 = (r0 >> 16) & 0x03;
-    if (r0 == 2) {
-        PRINTF(",MISO1");
-    } else {
-        PRINTF(",%s", uismsg3);
-    }
-    // p7(P0.7)
-    r0 = LPC_PINCON->PINSEL0;
-    r0 = (r0 >> 14) & 0x03;
-    if (r0 == 2) {
-        PRINTF(",SCK1");
-    } else {
-        PRINTF(",%s", uismsg3);
-    }
-    put_rn();
-}
-
-void spi_freq (void)
-{
-    uint32_t div, r0, r1;
-
-    get_freq(0);
-    //-----------------------------------------------------
-    // SPI
-    PRINTF("<Show SPI status>");
-    put_rn();
-    if (LPC_SC->PCONP & (1UL<<8)) {
-        div = (LPC_SC->PCLKSEL0 >> 16) & 0x3;
-        switch (div) {
-            case 0:
-                div = 4;
-                break;
-            case 1:
-                div = 1;
-                break;
-            case 2:
-                div = 2;
-                break;
-            case 3:
-                div = 8;
-                break;
-        }
-        r0 = LPC_SPI->SPCR;
-        PRINTF("Data length: ");
-        if (r0 & 0x04) {
-            r1 = (r0 >> 8) & 0x0f;
-            if (r1 == 0) {
-                r1 = 16;
-            }
-            PRINTF("%d", r1);
-        } else {
-            PUTC('8');
-        }
-        PRINTF("bit,  ");
-        PRINTF("CPHA: ");
-        PRINTF("%d", (r0 >> 3) & 0x01);
-        PRINTF(",  CPOL: ");
-        PRINTF("%d", (r0 >> 4) & 0x01);
-        put_rn();
-        if ((r0 >> 5) & 0x01) {
-            PRINTF("Master");
-        } else {
-            PRINTF("Slave");
-        }
-        PRINTF(" Mode");
-        put_rn();
-        if ((r0 >> 6) & 0x01) {
-            PRINTF("MSB(bit7)");
-        } else {
-            PRINTF("LSB(Bit0)");
-        }
-        PRINTF(" first");
-        put_rn();
-        r1 = LPC_SPI->SPCCR;
-        PRINTF("CLK = %d Hz", SystemCoreClock/div/r1);
-        put_rn();
-        PRINTF("    = PCLK_SPI(=Sys/div)/SPCCR0");
-        put_rn();
-        PRINTF("    = (%d/%d)/%d", SystemCoreClock, div, r1, SystemCoreClock/div/r1);
-    } else {
-        PRINTF("NOT Avairable (power off the module)");
-    }
-    put_rn();
-    //-----------------------------------------------------
-    // SSP0
-    PRINTF("<Show SSP0 status>");
-    put_rn();
-    if (LPC_SC->PCONP & (1UL<<21)) {
-        r0 = LPC_SSP0->CR1;
-        if (r0 & 0x02) {
-            div = (LPC_SC->PCLKSEL1 >> 10) & 0x3;
-            switch (div) {
-                case 0:
-                    div = 4;
-                    break;
-                case 1:
-                    div = 1;
-                    break;
-                case 2:
-                    div = 2;
-                    break;
-                case 3:
-                    div = 8;
-                    break;
-            }
-            r1 = LPC_SSP0->CR0;
-            PRINTF("SSP Mode: ");
-            r1 = (r1 >> 4) & 0x03;
-            switch (r1) {
-                case 0:
-                    PRINTF("SPI");
-                    break;
-                case 1:
-                    PRINTF("TI");
-                    break;
-                case 2:
-                    PRINTF("Microwire");
-                    break;
-                case 3:
-                    PRINTF("Not support");
-                    break;
-            }
-            put_rn();
-            r1 = LPC_SSP0->CR0;
-            PRINTF("Data length: ");
-            PRINTF("%d", r1 & 0x0f);
-            PRINTF("bit,  ");
-            PRINTF("CPHA: ");
-            PRINTF("%d", (r1 >> 7) & 0x01);
-            PRINTF(",  CPOL: ");
-            PRINTF("%d", (r1 >> 6) & 0x01);
-            put_rn();
-            if ((r0 >> 2) & 0x01) {
-                PRINTF("Slave");
-            } else {
-                PRINTF("Master");
-            }
-            PRINTF(" Mode");
-            put_rn();
-            r1 = LPC_SSP0->CR0;
-            r1 = (r1 >> 8) & 0xff;
-            r0 = LPC_SSP0->CPSR;
-            r0 = (r0 >> 0) & 0x0f;
-            PRINTF("CLK = %d Hz", SystemCoreClock/div/(r0 * (r1+1)));
-            put_rn();
-            PRINTF("    = PCLK_SSP0(=Sys/div)/(CPSDVSR x [SCR+1])");
-            put_rn();
-            PRINTF("    = (%d/%d)/(%d x [%d + 1])", SystemCoreClock, div, r0, r1);
-        } else {
-            PRINTF("SSP0 is disabled");
-        }
-    } else {
-        PRINTF("NOT Avairable (power off the module)");
-    }
-    put_rn();
-    //-----------------------------------------------------
-    // SSP1
-    PRINTF("<Show SSP1 status>");
-    put_rn();
-    if (LPC_SC->PCONP & (1UL<<10)) {
-        r0 = LPC_SSP1->CR1;
-        if (r0 & 0x02) {
-            div = (LPC_SC->PCLKSEL0 >> 20) & 0x3;
-            switch (div) {
-                case 0:
-                    div = 4;
-                    break;
-                case 1:
-                    div = 1;
-                    break;
-                case 2:
-                    div = 2;
-                    break;
-                case 3:
-                    div = 8;
-                    break;
-            }
-            r1 = LPC_SSP1->CR0;
-            PRINTF("SSP Mode: ");
-            r1 = (r1 >> 4) & 0x03;
-            switch (r1) {
-                case 0:
-                    PRINTF("SPI");
-                    break;
-                case 1:
-                    PRINTF("TI");
-                    break;
-                case 2:
-                    PRINTF("Microwire");
-                    break;
-                case 3:
-                    PRINTF("Not support");
-                    break;
-            }
-            put_rn();
-            r1 = LPC_SSP1->CR0;
-            PRINTF("Data length: ");
-            PRINTF("%d", r1 & 0x0f);
-            PRINTF("bit,  ");
-            PRINTF("CPHA: ");
-            PRINTF("%d", (r1 >> 7) & 0x01);
-            PRINTF(",  CPOL: ");
-            PRINTF("%d", (r1 >> 6) & 0x01);
-            put_rn();
-            if ((r0 >> 2) & 0x01) {
-                PRINTF("Slave");
-            } else {
-                PRINTF("Master");
-            }
-            PRINTF(" Mode");
-            put_rn();
-            r1 = LPC_SSP1->CR0;
-            r1 = (r1 >> 8) & 0xff;
-            r0 = LPC_SSP1->CPSR;
-            r0 = (r0 >> 0) & 0x0f;
-            PRINTF("CLK = %d Hz", SystemCoreClock/div/(r0 * (r1+1)));
-            put_rn();
-            PRINTF("    = PCLK_SSP1(=Sys/div)/(CPSDVSR x [SCR+1])");
-            put_rn();
-            PRINTF("    = (%d/%d)/(%d x [%d + 1])", SystemCoreClock, div, r0, r1);
-        } else {
-            PRINTF("SSP1 is disabled");
-        }
-    } else {
-        PRINTF("NOT Avairable (power off the module)");
-    }
-    put_rn();
-}
-#endif
-
-#if USE_I2C
-void i2c_io_reg (void)
-{
-    uint32_t r0;
-
-    PRINTF("<Show IO Pin>");
-    put_rn();
-    //-----------------------------------------------------
-    PRINTF("I2C0/pxx(P0.27),pxx(P0.28):");
-    // P0.27
-    r0 = LPC_PINCON->PINSEL1;
-    r0 = (r0 >> 22) & 0x03;
-    if (r0 == 3) {
-        PRINTF("SDA0");
-    } else {
-        PRINTF(uismsg3);
-    }
-    // P0.28
-    r0 = LPC_PINCON->PINSEL1;
-    r0 = (r0 >> 24) & 0x03;
-    if (r0 == 3) {
-        PRINTF(",SCL0");
-    } else {
-        PRINTF(",%s", uismsg3);
-    }
-    PRINTF(uismsg2);
-    put_rn();
-    //-----------------------------------------------------
-    PRINTF("I2C1/p 9(P0. 0),p10(P0. 1):");
-    // P0.0
-    r0 = LPC_PINCON->PINSEL0;
-    r0 = (r0 >> 0) & 0x03;
-    if (r0 == 3) {
-        PRINTF("SDA1");
-    } else {
-        PRINTF(uismsg3);
-    }
-    // P0.1
-    r0 = LPC_PINCON->PINSEL0;
-    r0 = (r0 >> 2) & 0x03;
-    if (r0 == 3) {
-        PRINTF(",SCL1");
-    } else {
-        PRINTF(",%s", uismsg3);
-    }
-    put_rn();
-    //-----------------------------------------------------
-    PRINTF("I2C1/pxx(P0.19),pxx(P0.20):");
-    // P0.19
-    r0 = LPC_PINCON->PINSEL1;
-    r0 = (r0 >> 6) & 0x03;
-    if (r0 == 3) {
-        PRINTF("SDA1");
-    } else {
-        PRINTF(uismsg3);
-    }
-    // P0.20
-    r0 = LPC_PINCON->PINSEL1;
-    r0 = (r0 >> 8) & 0x03;
-    if (r0 == 3) {
-        PRINTF(",SCL1");
-    } else {
-        PRINTF(",%s", uismsg3);
-    }
-    PRINTF(uismsg2);
-    put_rn();
-    //-----------------------------------------------------
-    PRINTF("I2C2/p28(P0.10),p27(P0.11):");
-    // P0.10
-    r0 = LPC_PINCON->PINSEL0;
-    r0 = (r0 >> 20) & 0x03;
-    if (r0 == 3) {
-        PRINTF("SDA2");
-    } else {
-        PRINTF(uismsg3);
-    }
-    // P0.11
-    r0 = LPC_PINCON->PINSEL0;
-    r0 = (r0 >> 22) & 0x03;
-    if (r0 == 3) {
-        PRINTF(",SCL2");
-    } else {
-        PRINTF(",%s", uismsg3);
-    }
-    put_rn();
-}
-
-char *const msg_cal = "    = I2CPCLK(=Sys/div)/(SCLH+SCLL)";
-
-void i2c_freq (void)
-{
-    uint32_t r0, r1, r2, r3;
-
-    get_freq(0);
-    // I2C0
-    r0 = LPC_I2C0->I2SCLL;
-    r1 = LPC_I2C0->I2SCLH;
-    r2 = LPC_I2C0->I2CONSET;
-    r3 = (LPC_SC->PCLKSEL0 >> 14) & 0x3;
-    switch (r3) {
-        case 0:
-            r3 = 4;
-            break;
-        case 1:
-            r3 = 1;
-            break;
-        case 2:
-            r3 = 2;
-            break;
-        case 3:
-            r3 = 8;
-            break;
-    }
-    PRINTF("<I2C Status>");
-    put_rn();
-    //-----------------------------------------------------
-    PRINTF("I2C0 ");
-    if (r2 & 0x40) {
-        PRINTF(uismsg0);
-        put_rn();
-        PRINTF("CLK = %d Hz", SystemCoreClock/r3/(r0+r1));
-        put_rn();
-        PRINTF(msg_cal);
-        put_rn();
-        PRINTF("    = (%d/%d)/(%d+%d)", SystemCoreClock,r3, r0, r1);
-    } else {
-        PRINTF(uismsg1);
-    }
-    put_rn();
-    //-----------------------------------------------------
-    // I2C1
-    r0 = LPC_I2C1->I2SCLL;
-    r1 = LPC_I2C1->I2SCLH;
-    r2 = LPC_I2C1->I2CONSET;
-    r3 = (LPC_SC->PCLKSEL1 >> 6) & 0x3;
-    switch (r3) {
-        case 0:
-            r3 = 4;
-            break;
-        case 1:
-            r3 = 1;
-            break;
-        case 2:
-            r3 = 2;
-            break;
-        case 3:
-            r3 = 8;
-            break;
-    }
-    PRINTF("I2C1 ");
-    if (r2 & 0x40) {
-        PRINTF(uismsg0);
-        put_rn();
-        PRINTF("CLK = %d Hz", SystemCoreClock/r3/(r0+r1));
-        put_rn();
-        PRINTF(msg_cal);
-        put_rn();
-        PRINTF("    = (%d/%d)/(%d+%d)", SystemCoreClock,r3, r0, r1);
-    } else {
-        PRINTF(uismsg1);
-    }
-    put_rn();
-    //-----------------------------------------------------
-    // I2C2
-    r0 = LPC_I2C2->I2SCLL;
-    r1 = LPC_I2C2->I2SCLH;
-    r2 = LPC_I2C2->I2CONSET;
-    r3 = (LPC_SC->PCLKSEL1 >> 20) & 0x3;
-    switch (r3) {
-        case 0:
-            r3 = 4;
-            break;
-        case 1:
-            r3 = 1;
-            break;
-        case 2:
-            r3 = 2;
-            break;
-        case 3:
-            r3 = 8;
-            break;
-    }
-    PRINTF("I2C2 ");
-    if (r2 & 0x40) {
-        PRINTF(uismsg0);
-        put_rn();
-        PRINTF("CLK = %d Hz", SystemCoreClock/r3/(r0+r1));
-        put_rn();
-        PRINTF(msg_cal);
-        put_rn();
-        PRINTF("    = (%d/%d)/(%d+%d)", SystemCoreClock,r3, r0, r1);
-    } else {
-        PRINTF(uismsg1);
-    }
-    put_rn();
-}
-#endif
-
-//-----------------------------------------------------------------------------
-//  Monitor Main Program
-//-----------------------------------------------------------------------------
-int mon_hw(void)
-{
-    char *ptr;
-
-    put_r();
-    PRINTF("%s [Help:'?' key]", mon_msg);
-    put_rn();
-    get_freq(0);
-    for (;;) {
-        put_r();
-        PUTC('>');
-        ptr = linebuf;
-        get_line(ptr, buf_size);
-        put_r();
-        switch (*ptr++) {
-                //---------------------------------------------------------------------------------
-                //    Memory
-                //---------------------------------------------------------------------------------
-            case 'm' :
-#if USE_MEM
-                mem_inf(ptr);
-                put_rn();
-#else
-                not_select();
-#endif   // USE_MEM
-                break;
-                //--------------------------------------------------------------------------------------
-                //    Register
-                //--------------------------------------------------------------------------------------
-            case 'r' :
-                uint8_t  r_flg;
-                put_r();
-                PRINTF("Reg. Mode p,u,i,s,t,a,d,l,w,c & ?");
-                put_rn();
-                r_flg = 0;
-                for (; r_flg != 0xff;) {
-                    PRINTF("r>");
-                    ptr = linebuf;
-                    get_line(ptr, buf_size);
-                    put_r();
-                    switch(*ptr++) {
-                        case 'p' :
-#if USE_PORT
-                            put_r();
-                            switch(*ptr++) {
-                                case 'l' :
-                                    port_config_left();
-                                    break;
-                                case 'r' :
-                                    port_config_right();
-                                    break;
-                                case '*' :
-                                    port_config_left();
-                                    port_config_right();
-                                    break;
-                                case '?' :
-                                    PRINTF("Enter pl,pr and p* for all");
-                                    put_rn();
-                                    break;;
-                                default:
-                                    PUTC('?');
-                                    put_rn();
-                                    break;
-                            }
-#else
-                            not_select();
-#endif // USE_PORT
-                            break;
-                        case 'u' :
-#if USE_UART
-                            put_r();
-                            switch(*ptr++) {
-                                case '0' :
-                                    uart_io_print();
-                                    uart_io_reg0();
-                                    uart_reg(0);
-                                    break;
-                                case '1' :
-                                    uart_io_print();
-                                    uart_io_reg1();
-                                    uart_reg(1);
-                                    break;
-                                case '2' :
-                                    uart_io_print();
-                                    uart_io_reg2();
-                                    uart_reg(2);
-                                    break;
-                                case '3' :
-                                    uart_io_print();
-                                    uart_io_reg3();
-                                    uart_reg(3);
-                                    break;
-                                case '*' :
-                                    uart_io_print();
-                                    uart_io_reg0();
-                                    uart_io_reg1();
-                                    uart_io_reg2();
-                                    uart_io_reg3();
-                                    break;
-                                case '?' :
-                                    PRINTF("Enter u0,u1,u2,u3 for each UART ");
-                                    PRINTF("or u* for UART port assignment");
-                                    put_rn();
-                                    break;
-                                default:
-                                    PUTC('?');
-                                    put_rn();
-                                    break;
-                            }
-#else
-                            not_select();
-#endif // USE_UART
-                            break;
-                        case 'i' :
-#if USE_I2C
-                            put_r();
-                            i2c_io_reg();
-                            i2c_freq();
-#else
-                            not_select();
-#endif // USE_I2C
-                            break;
-                        case 's' :
-#if USE_SPI
-                            put_r();
-                            spi_io_reg();
-                            spi_freq();
-#else
-                            not_select();
-#endif // USE_SPI
-                            break;
-                        case 't' :		//
-                            not_yet_impliment();
-                            break;
-                        case 'a' :		//
-                            not_yet_impliment();
-                            break;
-                        case 'd' :		//
-                            not_yet_impliment();
-                            break;
-                        case 'w' :		//
-                            not_yet_impliment();
-                            break;
-                        case 'l' :        //
-                            not_yet_impliment();
-                            break;
-                        case 'c' :		//
-                            not_yet_impliment();
-                            break;
-                        case 'x' :		//
-                            not_yet_impliment();
-                            break;
-                        case 'y' :		//
-                            not_yet_impliment();
-                            break;
-                        case 'q' :        // quit
-                            r_flg = 0xff;
-                            break;
-                        case '?' :
-                            PRINTF("p - I/O Pin Config. pl(p5 to p20) & pr(p21 to p30)");
-                            put_rn();
-                            PRINTF("u - UART u0,1,2,3 or u* (port assignment)");
-                            put_rn();
-                            PRINTF("i - I2C");
-                            put_rn();
-                            PRINTF("s - SPI/SSP");
-                            put_rn();
-                            PRINTF("t - TIMER");
-                            put_rn();
-                            PRINTF("a - ADC");
-                            put_rn();
-                            PRINTF("d - DAC");
-                            put_rn();
-                            PRINTF("l - LDC");
-                            put_rn();
-                            PRINTF("w - WWDG");
-                            put_rn();
-                            PRINTF("c - COMP");
-                            put_rn();
-                            PRINTF("q - Exit mode");
-                            put_rn();
-                            break;
-                        default:
-                            PUTC('?');
-                            put_rn();
-                    }
-                }
-                PRINTF("Return to All Mode");
-                put_rn();
-                break;
-                //---------------------------------------------------------------------------------
-                //    System
-                //---------------------------------------------------------------------------------
-            case 's' :    // System related information
-#if USE_SYS
-                switch (*ptr++) {
-                    case 'f' :    // sc - show system clock frequency
-                        get_freq(1);
-                        break;
-                    case 'c' :    // sc - show system CPU information
-                        cpu_inf();
-                        break;
-                    case '?' :
-                    default:
-                        put_r();
-                        PRINTF("sc - System CPU information");
-                        put_rn();
-                        PRINTF("sf - System Clock");
-                        put_rn();
-                        break;
-                }
-#else
-                not_select();
-#endif   // USE_SYS
-                break;
-                //-----------------------------------------------------------------------------------------
-                //    Help
-                //-----------------------------------------------------------------------------------------
-            case '?' :
-                msg_hlp_hw();
-                break;
-                //-----------------------------------------------------------------------------------------
-                //    Return to main routine
-                //-----------------------------------------------------------------------------------------
-            case 'q' :        // Quit
-                put_r();
-                PRINTF("Return to monitor");
-                put_rn();
-                return 0;
-                //-----------------------------------------------------------------------------------------
-                //    Special command for DEBUG
-                //-----------------------------------------------------------------------------------------
-            case 'x' :
-                not_yet_impliment();
-                break;
-                //-----------------------------------------------------------------------------------------
-                //    no support
-                //-----------------------------------------------------------------------------------------
-            default:
-                PUTC('?');
-                put_rn();
-                break;
-        }
-    }
-}
-#endif	// defined(TARGET_LPC1768)
diff -r 36ad7c7d0400 -r 8c37a47ac34c debug_tools/mon_hw_STM32.cpp
--- a/debug_tools/mon_hw_STM32.cpp	Sun Feb 14 21:55:30 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1292 +0,0 @@
-/*
- * mbed Application program for the ST NUCLEO Board
- * Monitor program Ver.3 for only for STM32F401RE,F411RE & STM32L152RE
- *
- *  Copyright (c) 2010-2015 Kenji Arai / JH1PJL
- *  http://www.page.sannet.ne.jp/kenjia/index.html
- *  http://mbed.org/users/kenjiArai/
- *      Started:  May        9th, 2010
- *      Created:  May       15th, 2010
- *          release as "monitor_01" http://mbed.org/users/kenjiArai/code/monitor_01/
- *      Spareted: June      25th, 2014      mon() & mon_hw()
- *      restart:  July      12th, 2014
- *      Revised:  April     25th, 2015      Bug fix ('o' command) pointed out by Topi Makinen
- *      Revised:  April     26th, 2015      Change Port output speed (set High speed)
- *
- * 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.
- */
-
-#if defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F411RE) || defined(TARGET_NUCLEO_L152RE)
-
-//  Include ---------------------------------------------------------------------------------------
-#include "mbed.h"
-#include "mon_hw_config.h"
-#include "mon_hw_common.h"
-#include "mon_hw_STM32.h"
-
-//  Object ----------------------------------------------------------------------------------------
-
-//  Definition ------------------------------------------------------------------------------------
-// USB Frequency
-#define USB_FREQ_H          48100000
-#define USB_FREQ_L          47900000
-
-//  RAM -------------------------------------------------------------------------------------------
-uint32_t SystemFrequency;
-uint8_t quitflag;
-
-uint32_t reg_save0, reg_save1, reg_save2, reg_save3, reg_save4, reg_save5, reg_save6;
-
-//  ROM / Constant data ---------------------------------------------------------------------------
-#if defined(TARGET_NUCLEO_F401RE)
-char *const mon_msg =
-    "HW monitor only for mbed Nucleo F401RE created on UTC:"__DATE__"("__TIME__")";
-
-#if USE_MEM
-const uint32_t mem_range[][2] = {   // Memory access range
-    { 0x08000000, 0x0807ffff },     // On-chip Flash memory, 512KB Flash
-    { 0x1fff0000, 0x1fff7a0f },     // System memory
-    { 0x1fffc000, 0x1fffc007 },     // Option bytes
-    { 0x20000000, 0x20017fff },     // Main Embedded SRAM, 96KB SRAM
-    { 0x40000000, 0x5003ffff }      // IO area
-};
-#endif // USE_MEM
-#elif defined(TARGET_NUCLEO_F411RE)
-char *const mon_msg =
-    "HW monitor only for mbed Nucleo F411RE created on UTC:"__DATE__"("__TIME__")";
-
-#if USE_MEM
-const uint32_t mem_range[][2] = {   // Memory access range
-    { 0x08000000, 0x0807ffff },     // On-chip Flash memory, 512KB Flash
-    { 0x1fff0000, 0x1fff7a0f },     // System memory
-    { 0x1fffc000, 0x1fffc007 },     // Option bytes
-    { 0x20000000, 0x2001ffff },     // Main Embedded SRAM, 128KB SRAM
-    { 0x40000000, 0x5003ffff }      // IO area
-};
-#endif // USE_MEM
-#elif defined(TARGET_NUCLEO_L152RE)
-char *const mon_msg =
-    "HW monitor only for mbed Nucleo L152RE created on UTC:"__DATE__"("__TIME__")";
-
-#if USE_MEM
-const uint32_t mem_range[][2] = {   // Memory access range
-    { 0x08000000, 0x0807ffff },     // On-chip Flash memory, 512KB Flash
-    { 0x08080000, 0x08083fff },     // EEPROM, 16KB
-    { 0x1ff00000, 0x1ff01fff },     // System memory
-    { 0x1ff80000, 0x1ff8009f },     // Option bytes
-    { 0x20000000, 0x20013fff },     // Main Embedded SRAM, 32KB SRAM
-    { 0x40000000, 0x400267ff }      // IO area
-};
-#endif // USE_MEM
-#endif
-
-char *const hmsg0 = "m  - Entry Memory Mode";
-char *const hmsg1 = "m>? -> Aditinal functions can see by ?";
-char *const hmsg2 = "r  - Entry Register Mode";
-char *const hmsg3 = "r>? -> Aditinal functions can see by ?";
-char *const hmsg4 = "s  - System Clock -> sf, System / CPU information -> sc";
-char *const hmsg5 = "q  - Quit (back to called routine)";
-char *const hmsg6 = "p  - Entry Port Mode";
-char *const hmsg7 = "p>? -> Aditinal functions can see by ?";
-
-char *const mrmsg0 = "Enter Register Mode u,i,s,t,a,d,l,w,c & ? for help";
-#if (USE_UART==1) || (USE_SPI==1) || (USE_I2C == 1)
-char *const mrmsg1 = "------";
-char *const mrmsg2 = "USART";
-//
-char *const mrmsg4 = "I2C";
-//
-char *const mrmsg6 = "SPI";
-//
-#if defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F411RE)
-char *const mrmsg3 = "Enter u1,u2,u6 and u* for all";
-char *const mrmsg5 = "Enter i1,i2,i3 and i* for all";
-char *const mrmsg7 = "Enter s1,s2,s3,s4 and s* for all";
-#elif defined(TARGET_NUCLEO_L152RE)
-char *const mrmsg3 = "Enter u1,u2,u3,u5 and u* for all";
-char *const mrmsg5 = "Enter i1,i2 and i* for all";
-char *const mrmsg7 = "Enter s1,s2,s3 and s* for all";
-#endif
-#endif  // (USE_UART==1) || (USE_SPI==1) || (USE_I2C == 1)
-char *const mrmsg8 = "Return to All Mode";
-
-//-------------------------------------------------------------------------------------------------
-//  Control Program
-//-------------------------------------------------------------------------------------------------
-// No function
-static void not_yet_impliment( void )
-{
-    PRINTF("Not implimented yet");
-    put_rn();
-}
-
-// No function
-#if (USE_MEM==0)||(USE_PORT==0)||(USE_UART==0)||(USE_SPI==0)||(USE_I2C==0)||(USE_SYS==0)
-static void not_select( void )
-{
-    PRINTF("Not select the function (refer mon_hw_config.h)");
-    put_rn();
-}
-#endif
-
-//  Help Massage
-void hw_msg_hlp ( void )
-{
-    PRINTF(mon_msg);
-    put_rn();
-    PRINTF(hmsg0);
-    put_rn();
-    PRINTF(hmsg1);
-    put_rn();
-    PRINTF(hmsg6);
-    put_rn();
-    PRINTF(hmsg7);
-    put_rn();
-    PRINTF(hmsg2);
-    put_rn();
-    PRINTF(hmsg3);
-    put_rn();
-    PRINTF(hmsg4);
-    put_rn();
-    PRINTF(hmsg5);
-    put_rn();
-}
-
-#if USE_MEM
-#if defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F411RE)
-char *const rmsg0 = "FLASH    ";
-char *const rmsg1 = "SYS-Mem  ";
-char *const rmsg2 = "OPTION   ";
-char *const rmsg3 = "SRAM     ";
-char *const rmsg4 = "IO       ";
-#elif defined(TARGET_NUCLEO_L152RE)
-char *const rmsg0 = "FLASH    ";
-char *const rmsg1 = "EEPROM   ";
-char *const rmsg2 = "SYS-Mem  ";
-char *const rmsg3 = "OPTION   ";
-char *const rmsg4 = "SRAM     ";
-char *const rmsg5 = "IO       ";
-#endif
-
-#include "mon_hw_mem.h"
-#endif   // USE_MEM
-
-
-//  Show 16bit register contents
-void reg_print(uint16_t size, uint16_t reg)
-{
-    uint16_t i, j, k, n;
-
-    i = j = k = n = 0;
-    switch (size) {
-        case SIZE8:
-            PRINTF(rgmsg0);
-            put_rn();
-            i = 8;
-            n = 0x80;
-            break;
-        case SIZE16:
-            PRINTF("%s%s", rgmsg1, rgmsg0);
-            put_rn();
-            i = 16;
-            n = 0x8000;
-            break;
-        case SIZE32:
-            PRINTF("0x%08x", reg);
-            return;
-        default :
-            ;
-    }
-    PUTC(' ');
-    for (; i>0; i--) {
-        k = n >> (size-i);
-        j = reg & k;
-        if (j) {
-            PUTC('1');
-        } else {
-            PUTC('0');
-        }
-        PUTC(' ');
-        PUTC(' ');
-    }
-    PRINTF("  (0x%04x)", reg);
-}
-
-#if USE_I2C
-void i2c_reg( I2C_TypeDef* I2Cx )
-{
-    uint16_t reg;
-
-    put_rn();
-    reg = I2Cx->CR1;
-    reg_print( SIZE32, reg );
-    PRINTF( rnmsg0 );
-    PRINTF( imsg2 );
-    put_rn();
-    reg = I2Cx->CR2;
-    reg_print( SIZE32, reg );
-    PRINTF( rnmsg1 );
-    PRINTF( imsg2 );
-    put_rn();
-    reg = I2Cx->SR1;
-    reg_print( SIZE32, reg );
-    PRINTF( rnmsg5 );
-    PRINTF( imsg3 );
-    put_rn();
-    reg = I2Cx->SR2;
-    reg_print( SIZE32, reg );
-    PRINTF( rnmsg6 );
-    PRINTF( imsg3 );
-    put_rn();
-    reg = I2Cx->DR;
-    reg_print( SIZE32, reg );
-    PRINTF( rnmsg2 );
-    PRINTF( imsg4 );
-    put_rn();
-    reg = I2Cx->OAR1;
-    reg_print( SIZE32, reg );
-    PRINTF( rnmsg7 );
-    PRINTF( imsg6 );
-    put_rn();
-    reg = I2Cx->OAR2;
-    reg_print( SIZE32, reg );
-    PRINTF( rnmsg8 );
-    PRINTF( imsg6 );
-    put_rn();
-    reg = I2Cx->CCR;
-    reg_print( SIZE32, reg );
-    PRINTF( rnmsg9 );
-    PRINTF( imsg7 );
-    put_rn();
-    reg = I2Cx->TRISE;
-    reg_print( SIZE32, reg );
-    PRINTF( rnmsg10 );
-    PRINTF( imsg8 );
-    put_rn();
-}
-#endif  // USE_I2C
-
-#if USE_SPI
-void spi_reg( SPI_TypeDef* SPIx )
-{
-    uint16_t reg;
-
-    put_rn();
-    reg = SPIx->CR1;
-    reg_print( SIZE32, reg );
-    PRINTF( rnmsg0 );
-    PRINTF( imsg2 );
-    put_rn();
-    reg = SPIx->CR2;
-    reg_print( SIZE32, reg );
-    PRINTF( rnmsg1 );
-    PRINTF( imsg2 );
-    put_rn();
-    reg = SPIx->SR;
-    reg_print( SIZE32, reg );
-    PRINTF( rnmsg3 );
-    PRINTF( imsg3 );
-    put_rn();
-    reg = SPIx->DR;
-    reg_print( SIZE32, reg );
-    PRINTF( rnmsg2 );
-    PRINTF( imsg4 );
-    put_rn();
-}
-#endif  // USE_SPI
-
-#if USE_UART
-void usart_reg( USART_TypeDef* USARTx )
-{
-    uint16_t reg;
-
-    put_rn();
-    reg = USARTx->SR;
-    reg_print( SIZE32, reg );
-    PRINTF( rnmsg3 );
-    PRINTF( imsg3 );
-    put_rn();
-    reg = USARTx->DR;
-    reg_print( SIZE32, reg );
-    PRINTF( rnmsg2 );
-    PRINTF( imsg4 );
-    put_rn();
-    reg = USARTx->BRR;
-    reg_print( SIZE32, reg );
-    PRINTF( rnmsg4 );
-    PRINTF( imsg5 );
-    put_rn();
-    reg = USARTx->CR1;
-    reg_print( SIZE32, reg );
-    PRINTF( rnmsg0 );
-    PRINTF( imsg2 );
-    put_rn();
-    reg = USARTx->CR2;
-    reg_print( SIZE32, reg );
-    PRINTF( rnmsg1 );
-    PRINTF( imsg2 );
-    put_rn();
-}
-#endif  // USE_UART
-
-#if USE_PORT
-void rpt_port_one( GPIO_TypeDef* GPIOx )
-{
-    uint32_t i;
-
-    PRINTF( " " );
-    i = GPIOx->MODER;
-    PRINTF( "0x%08x",i );
-    i = GPIOx->OTYPER;
-    PRINTF( " 0x%04x",i );
-    i = GPIOx->OSPEEDR;
-    PRINTF( "  0x%08x",i );
-    i = GPIOx->PUPDR;
-    PRINTF( " 0x%08x",i );
-    i = GPIOx->IDR;
-    PRINTF( " 0x%04x",i );
-    i = GPIOx->ODR;
-    PRINTF( " 0x%04x",i );
-    put_rn();
-}
-
-void rpt_port( void )
-{
-    PRINTF( pnmsg0 );
-    PRINTF( pnmsg1 );
-    put_rn();
-    PRINTF( pnmsga );
-    rpt_port_one( GPIOA );
-    PRINTF( pnmsgb );
-    rpt_port_one( GPIOB );
-    PRINTF( pnmsgc );
-    rpt_port_one( GPIOC );
-    PRINTF( pnmsgd );
-    rpt_port_one( GPIOD );
-    PRINTF( pnmsge );
-    rpt_port_one( GPIOE );
-    PRINTF( pnmsgh );
-    rpt_port_one( GPIOH );
-}
-
-void port_inf_one( char *ptr )
-{
-    GPIO_TypeDef* GPIOx;
-    uint32_t i,j;
-    uint32_t pinpos;
-
-    GPIOx = 0;
-    PRINTF( pnmsg2 );
-    switch ( *ptr ) {
-        case 'a':
-            GPIOx = GPIOA;
-            PUTC( 'A' );
-            break;
-        case 'b':
-            GPIOx = GPIOB;
-            PUTC( 'B' );
-            break;
-        case 'c':
-            GPIOx = GPIOC;
-            PUTC( 'C' );
-            break;
-        case 'd':
-            GPIOx = GPIOD;
-            PUTC( 'D' );
-            break;
-        case 'e':
-            GPIOx = GPIOE;
-            PUTC( 'E' );
-            break;
-        case 'h':
-            GPIOx = GPIOH;
-            PUTC( 'H' );
-            break;
-    }
-    i = GPIOx->MODER;
-    put_rn();
-    PRINTF( "-->Mode Reg.  (0x%08x)",i );
-    put_rn();
-    for ( pinpos = 0x00; pinpos < 16; pinpos++ ) {
-        j = GPIO_MODER_MODER0 & (i >> (pinpos * 2));
-        switch (j) {
-            case GPIO_Mode_IN:
-                PRINTF( "%2d= in", pinpos );
-                break;
-            case GPIO_Mode_OUT:
-                PRINTF( "%2d=out", pinpos );
-                break;
-            case GPIO_Mode_AF:
-                PRINTF( "%2d=alt", pinpos );
-                break;
-            case GPIO_Mode_AN:
-                PRINTF( "%2d=ana", pinpos );
-                break;
-            default:
-                break;
-        }
-        if ( (pinpos == 3) && (*ptr == 'h') ) {
-            break;
-        } else {
-            if ( pinpos == 7 ) {
-                put_rn();
-            } else if ( pinpos == 15 ) {
-                ;
-            } else {
-                PRINTF(", ");
-            }
-        }
-    }
-    i = GPIOx->OTYPER;
-    put_rn();
-    PRINTF( "%s type 1=push-pull, 0= open-drain", pnmsg4 );
-    put_rn();
-    reg_print( SIZE32,i);
-    i = GPIOx->OSPEEDR;
-    PRINTF( "%s speed [MHz] (0x%08x)", pnmsg4, i );
-    put_rn();
-    for ( pinpos = 0x00; pinpos < 16; pinpos++ ) {
-        j = GPIO_OSPEEDER_OSPEEDR0 & (i >> (pinpos * 2));
-        switch (j) {
-            case GPIO_Speed_400KHz:
-                PRINTF( "%2d=0.4", pinpos );
-                break;
-            case GPIO_Speed_2MHz:
-                PRINTF( "%2d=  2", pinpos );
-                break;
-            case GPIO_Speed_10MHz:
-                PRINTF( "%2d= 10", pinpos );
-                break;
-            case GPIO_Speed_40MHz:
-                PRINTF( "%2d= 40", pinpos );
-                break;
-            default:
-                break;
-        }
-        if ( (pinpos == 3) && (*ptr == 'h') ) {
-            break;
-        } else {
-            if ( pinpos == 7 ) {
-                put_rn();
-            } else if ( pinpos == 15) {
-                ;
-            } else {
-                PRINTF(", ");
-            }
-        }
-    }
-    i = GPIOx->PUPDR;
-    put_rn();
-    PRINTF( "-->Pullup(pup)/down(pdn) none(no)(0x%08x)",i );
-    put_rn();
-    for ( pinpos = 0x00; pinpos < 16; pinpos++ ) {
-        j = GPIO_PUPDR_PUPDR0 & (i >> (pinpos * 2));
-        switch (j) {
-            case GPIO_PuPd_NOPULL:
-                PRINTF( "%2d= no", pinpos );
-                break;
-            case GPIO_PuPd_UP:
-                PRINTF( "%2d=pup", pinpos );
-                break;
-            case GPIO_PuPd_DOWN:
-                PRINTF( "%2d=pdn", pinpos );
-                break;
-            default:
-                break;
-        }
-        if ( (pinpos == 3) && (*ptr == 'h') ) {
-            break;
-        } else {
-            if ( pinpos == 7 ) {
-                put_rn();
-            } else if ( pinpos == 15 ) {
-                ;
-            } else {
-                PRINTF(", ");
-            }
-        }
-    }
-    put_rn();
-    PRINTF( "%s %s", pnmsg5, pnmsg6);
-    i = GPIOx->IDR;
-    reg_print( SIZE32,i);
-    put_rn();
-    PRINTF( "%s %s", pnmsg4, pnmsg6);
-    i = GPIOx->ODR;
-    reg_print( SIZE32,i);
-    put_rn();
-}
-#endif  // USE_PORT
-
-#if defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F411RE)
-void port_mco1_mco2_set(uint8_t n)
-{
-    GPIO_TypeDef* GPIOx = 0;
-    uint32_t temp = 0x00;
-
-    if (n == 0){    // Just save the original setting
-        // PA8 -> MCO_1
-        GPIOx = GPIOA;
-        reg_save0 = GPIOx->AFR[8 >> 3];
-        reg_save1 = GPIOx->MODER;
-        reg_save2 = GPIOx->OSPEEDR;
-        GPIOx = GPIOC;
-        reg_save3 = GPIOx->AFR[9 >> 3];
-        reg_save4 = GPIOx->MODER;
-        reg_save5 = GPIOx->OSPEEDR;
-        reg_save6 = RCC->CFGR;
-    } else {
-        // PA8 -> MCO_1
-        GPIOx = GPIOA;
-        temp = ((uint32_t)(GPIO_AF0_MCO) << (((uint32_t)8 & (uint32_t)0x07) * 4)) ;
-        GPIOx->AFR[8 >> 3] &= ~((uint32_t)0xf << ((uint32_t)(8 & (uint32_t)0x07) * 4)) ;
-        GPIOx->AFR[8 >> 3] |= temp;
-        GPIOx->MODER &= ~(GPIO_MODER_MODER0 << (8 * 2));
-        GPIOx->MODER |= (0x2 << (8 * 2));
-        GPIOx->OSPEEDR |= (0x03 << (8 * 2)); // High speed
-        // PC9 -> MCO_2
-        GPIOx = GPIOC;
-        temp = ((uint32_t)(GPIO_AF0_MCO) << (((uint32_t)9 & (uint32_t)0x07) * 4)) ;
-        GPIOx->AFR[9 >> 3] &= ~((uint32_t)0xf << ((uint32_t)(9 & (uint32_t)0x07) * 4)) ;
-        GPIOx->AFR[9 >> 3] |= temp;
-        GPIOx->MODER &= ~(GPIO_MODER_MODER0 << (9 * 2));
-        GPIOx->MODER |= (0x2 << (9 * 2));
-        GPIOx->OSPEEDR |= (0x03 << (9 * 2)); // High speed
-        // Select output clock source
-        RCC->CFGR &= 0x009fffff;
-        if (n == 1){
-            // MC0_1 output HSE 1/4, MCO_2 output SYSCLK 1/4
-            //             MCO2          MCO2PRE       MCO1PRE       MCO1
-            RCC->CFGR |= (0x0 << 30) + (0x6 << 27) + (0x6 << 24) + (0x3 << 22);
-        } else {
-            // MC0_1 output HSE 1/1, MCO_2 output SYSCLK 1/2
-            //             MCO2          MCO2PRE       MCO1PRE       MCO1
-            RCC->CFGR |= (0x0 << 30) + (0x4 << 27) + (0x0 << 24) + (0x3 << 22);
-        }
-    }
-}
-
-void port_mco1_mco2_recover(void)
-{
-    GPIO_TypeDef* GPIOx = 0;
-
-    // PA8 -> MCO_1
-    GPIOx = GPIOA;
-    GPIOx->AFR[8 >> 3] = reg_save0;
-    GPIOx->MODER = reg_save1;
-    GPIOx->OSPEEDR = reg_save2;
-    // PC9 -> MCO_2
-    GPIOx = GPIOC;
-    GPIOx->AFR[9 >> 3] = reg_save3;
-    GPIOx->MODER = reg_save4;
-    GPIOx->OSPEEDR = reg_save5;
-    // MC0_1 & MCO_2
-    RCC->CFGR = reg_save6;
-}
-#endif      // defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F411RE)
-
-#if defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F411RE)
-void cpu_inf( char *ptr )
-{
-    uint32_t m1 = 0, m2 = 0, m3 = 0, m4 = 0, m5 = 0;
-
-    switch (*ptr++) {
-        case 'f' :  // sc - show system clock frequency
-            m1 = RCC->CR;
-            PRINTF( "CR       = 0x%08x", m1 );
-            put_rn();
-            m1 = RCC->PLLCFGR;
-            PRINTF( "PLLCFGR  = 0x%08x", m1 );
-            put_rn();
-            m1 = RCC->CFGR;
-            PRINTF( "CFGR     = 0x%08x", m1 );
-            put_rn();
-            m1 = RCC->CIR;
-            PRINTF( "CIR      = 0x%08x", m1 );
-            put_rn();
-            m1 = RCC->AHB1RSTR;
-            PRINTF( "AHB1RSTR = 0x%08x", m1 );
-            put_rn();
-            m1 = RCC->APB2RSTR;
-            PRINTF( "APB2RSTR = 0x%08x", m1 );
-            put_rn();
-            m1 = RCC->APB1RSTR;
-            PRINTF( "APB1RSTR = 0x%08x", m1 );
-            put_rn();
-            m1 = RCC->AHB1ENR;
-            PRINTF( "AHB1ENR  = 0x%08x", m1 );
-            put_rn();
-            m1 = RCC->APB2ENR;
-            PRINTF( "APB2ENR  = 0x%08x", m1 );
-            put_rn();
-            m1 = RCC->APB2LPENR;
-            PRINTF( "APB2LPENR= 0x%08x", m1 );
-            put_rn();
-            m1 = RCC->APB1LPENR;
-            PRINTF( "APB1LPENR= 0x%08x", m1 );
-            put_rn();
-            m1 = RCC->CSR;
-            PRINTF( "CSR      = 0x%08x", m1 );
-            put_rn();
-            PRINTF(cmsg11);
-            put_rn();
-            m1 = PWR->CR;
-            PRINTF( "CR       = 0x%08x", m1 );
-            put_rn();
-            m1 = PWR->CSR;
-            PRINTF( "CSR      = 0x%08x", m1 );
-            put_rn();
-            put_rn();
-        case 'F' :  // sF - show system clock frequency
-            m1 = RCC->CFGR & RCC_CFGR_SWS;  /* Get SYSCLK source */
-            switch (m1) {
-                case 0x00:  // HSI used as system clock
-                    PRINTF( "%s, %s%dHz", cmsg2, cmsg1,HSI_VALUE );
-                    m2 = HSI_VALUE;
-                    break;
-                case 0x04:  // HSE used as system clock
-                    PRINTF( "%s, %s%dHz", cmsg3, cmsg1, HSE_VALUE );
-                    m2 = HSE_VALUE;
-                    break;
-                case 0x08:  // PLL used as system clock
-                    PRINTF("fVCO = fPLL-in x (PLLN/PLLM), fPLL-out = fVCO/PLLP, fUSB-out = fVCO/PLLQ");
-                    put_rn();
-                    m5 = (RCC->PLLCFGR >> 6) & 0x1ff;   // PLLN
-                    m1 = RCC->PLLCFGR & 0x3f;           // PLLM
-                    PRINTF( "%s PLLN=%d, PLLM=%d", cmsg4, m5, m1 );
-                    put_rn();
-                    m3 = (RCC->PLLCFGR >> 22) & 0x1;    // Clock source
-                    if (m3 == 0) {
-                        // HSI oscillator clock selected as PLL clock source
-                        m2 = (HSI_VALUE * (m5 / m1));
-                        PRINTF( "%s, RC=%dHz", cmsg2, HSI_VALUE );
-                    } else {
-                        // HSE selected
-                        m2 = (((HSE_VALUE) * m5) / m1);
-                        if ((RCC->CR >> 18) & 0x01) {  // check HSEBYP bit
-                            // HSE(not Xtal) selected as PLL clock source
-                            PRINTF( "Use HSE(not Xtal but External Clock)=%dHz", HSE_VALUE );
-                        } else {
-                            // HSE(Xtal) selected as PLL clock source
-                            PRINTF( "%s, Xtal=%dHz", cmsg3, HSE_VALUE );
-                        }
-                    }
-                    put_rn();
-                    PRINTF("PLL/Base   %s%dHz", cmsg1, m2);
-                    put_rn();
-                    m3 = (RCC->PLLCFGR >> 16) & 0x03;  // PLLP
-                    switch (m3) {
-                        case 0:
-                            m3 = 2;
-                            break;
-                        case 1:
-                            m3 = 4;
-                            break;
-                        case 2:
-                            m3 = 6;
-                            break;
-                        case 3:
-                            m3 = 8;
-                            break;
-                    }
-                    m4 = (RCC->PLLCFGR >> 24) & 0x0f;  // PLLQ
-                    PRINTF("%s PLLP=%d, PLLQ=%d", cmsg4, m3, m4);
-                    put_rn();
-                    PRINTF("PLL/System %s%dHz", cmsg1, m2/m3);
-                    put_rn();
-                    PRINTF("PLL/USB    %s%dHz", cmsg1, m2/m4);
-                    m2 = m2/m4;
-                    if ((m2 > USB_FREQ_H) || (m2 <USB_FREQ_L)) {
-                        PRINTF(" -> USB Freq. is out of range!");
-                    }
-                    put_rn();
-                    break;
-                default:    // Not come here
-                    PRINTF( cmsg5 );
-                    break;
-            }
-            put_rn();
-            PRINTF( "SYSCLK %s%dHz", cmsg6, HAL_RCC_GetSysClockFreq());
-            put_rn();
-            PRINTF( "HCLK   %s%dHz", cmsg6, HAL_RCC_GetHCLKFreq());
-            put_rn();
-            PRINTF( "PCLK1  %s%dHz", cmsg6, HAL_RCC_GetPCLK1Freq());
-            put_rn();
-            PRINTF( "PCLK2  %s%dHz", cmsg6, HAL_RCC_GetPCLK2Freq());
-            put_rn();
-            put_rn();
-            // Check RTC Clock
-            PRINTF("RTC Clock");
-            put_rn();
-            m1 = (RCC->BDCR >> 8) & 0x03;
-            switch (m1) {
-                case 0: // no clock
-                    PRINTF(cmsg7);
-                    break;
-                case 1: // LSE
-                    PRINTF(cmsg8);
-                    break;
-                case 2: // LSI
-                    PRINTF("%s 17 to 47, typ.32KHz", cmsg9);
-                    break;
-                case 3: // HSE
-                    PRINTF( cmsg10 );
-                    m2 = (RCC->PLLCFGR >> 16) & 0x1f;   // RTCPRE
-                    m3 = HSE_VALUE / m2;
-                    PRINTF("%s%dHz", cmsg6, m3);
-                    put_rn();
-                    break;
-                default:    // Not come here
-                    PRINTF(cmsg5);
-                    break;
-            }
-            put_rn();
-            put_rn();
-            break;
-        case 'c' :      // sc - show system CPU information
-            m1 = SCB->CPUID;
-            m2 = ( m1 >> 24 );
-            if ( m2 == 0x41 ) {
-                PRINTF( "CPU = ARM " );
-            } else {
-                PRINTF( "CPU = NOT ARM " );
-            }
-            m2 = ( m1 >> 4 ) & 0xfff;
-            if ( m2 == 0xc24 ) {
-                PRINTF( "Cortex-M4" );
-            } else {
-                PRINTF( "NOT Cortex-M4" );
-            }
-            put_rn();
-            m2 = ( m1 >> 20 ) & 0x0f;
-            PRINTF( "Variant:%x", m2 );
-            put_rn();
-            m2 = m1 & 0x7;
-            PRINTF( "Revision:%x", m2 );
-            put_rn();
-            PRINTF( "CPU ID: 0x%08x", m1 );
-            put_rn();
-            m1 = DBGMCU->IDCODE;
-            PRINTF( "DBG ID: 0x%08x", m1 );
-            put_rn();
-            // unique ID
-            // http://waijung.aimagin.com/index.htm?stm32f4_uidread.htm
-            m1 = *(__IO uint32_t *)((uint32_t)0x1FFF7A10);
-            PRINTF("Unique device ID(94bits):(1) 0x%08x ", m1);
-            m1 = *(__IO uint32_t *)((uint32_t)0x1FFF7A14);
-            PRINTF("(2) 0x%08x ", m1);
-            m1 = *(__IO uint32_t *)((uint32_t)0x1FFF7A18);
-            PRINTF( "(3) 0x%08x", m1 );
-            put_rn();
-            break;
-        case '?' :
-        default:
-            PRINTF( "sc - System CPU information" );
-            put_rn();
-            PRINTF( "sf - System Clock" );
-            put_rn();
-    }
-}
-#elif defined(TARGET_NUCLEO_L152RE)
-
-static __I uint8_t PLLMulTable[9] = {3, 4, 6, 8, 12, 16, 24, 32, 48};
-
-void cpu_inf( char *ptr )
-{
-    uint32_t m1, m2, m3, m4, m5;
-
-    switch (*ptr++) {
-        case 'f' :  // sc - show system clock frequency
-            m1 = RCC->CR;
-            PRINTF( "CR       = 0x%08x", m1 );
-            put_rn();
-            m1 = RCC->ICSCR;
-            PRINTF( "ICSCR    = 0x%08x", m1 );
-            put_rn();
-            m1 = RCC->CFGR;
-            PRINTF( "CFGR     = 0x%08x", m1 );
-            put_rn();
-            m1 = RCC->CIR;
-            PRINTF( "CIR      = 0x%08x", m1 );
-            put_rn();
-            m1 = RCC->AHBRSTR;
-            PRINTF( "AHBRSTR  = 0x%08x", m1 );
-            put_rn();
-            m1 = RCC->APB2RSTR;
-            PRINTF( "APB2RSTR = 0x%08x", m1 );
-            put_rn();
-            m1 = RCC->APB1RSTR;
-            PRINTF( "APB1RSTR = 0x%08x", m1 );
-            put_rn();
-            m1 = RCC->AHBENR;
-            PRINTF( "AHBENR   = 0x%08x", m1 );
-            put_rn();
-            m1 = RCC->APB2ENR;
-            PRINTF( "APB2ENR  = 0x%08x", m1 );
-            put_rn();
-            m1 = RCC->APB2LPENR;
-            PRINTF( "APB2LPENR= 0x%08x", m1 );
-            put_rn();
-            m1 = RCC->APB1LPENR;
-            PRINTF( "APB1LPENR= 0x%08x", m1 );
-            put_rn();
-            m1 = RCC->CSR;
-            PRINTF( "CSR      = 0x%08x", m1 );
-            put_rn();
-            PRINTF( cmsg11 );
-            put_rn();
-            m1 = PWR->CR;
-            PRINTF( "CR       = 0x%08x", m1 );
-            put_rn();
-            m1 = PWR->CSR;
-            PRINTF( "CSR      = 0x%08x", m1 );
-            put_rn();
-            put_rn();
-        case 'F' :  // sF - show system clock frequency
-            m1 = RCC->CFGR & RCC_CFGR_SWS;  /* Get SYSCLK source */
-            switch (m1) {
-                case 0x00:  // MSI used as system clock
-                    m4 = ( RCC->ICSCR & RCC_ICSCR_MSIRANGE ) >> 13;
-                    m2 = (32768 * (1 << (m4 + 1)));
-                    PRINTF( "%s, %s%dHz", cmsg0, cmsg1, m2);
-                    break;
-                case 0x04:  // HSI used as system clock
-                    PRINTF( "%s, %s%dHz", cmsg2, cmsg1,HSI_VALUE );
-                    m2 = HSI_VALUE;
-                    break;
-                case 0x08:  // HSE used as system clock
-                    PRINTF( "%s, %s%dHz", cmsg3, cmsg1, HSE_VALUE );
-                    m2 = HSE_VALUE;
-                    break;
-                case 0x0C:  // PLL used as system clock
-                    // Get PLL clock source and multiplication factor
-                    m5 = RCC->CFGR & RCC_CFGR_PLLMUL;
-                    m1 = RCC->CFGR & RCC_CFGR_PLLDIV;
-                    m5 = PLLMulTable[(m5 >> 18)];
-                    m1 = (m1 >> 22) + 1;
-                    PRINTF( "%s Mul=%d, Div=%d", cmsg4, m5, m1 );
-                    put_rn();
-                    m3 = RCC->CFGR & RCC_CFGR_PLLSRC;
-                    if ( m3 == 0x00 ) {
-                        // HSI oscillator clock selected as PLL clock source
-                        m2 = (((HSI_VALUE) * m5) / m1);
-                        PRINTF( "%s, RC=%dHz", cmsg2, HSI_VALUE );
-                    } else {
-                        // HSE selected
-                        m2 = (((HSE_VALUE) * m5) / m1);
-                        if ((RCC->CR >> 18) & 0x01) {  // check HSEBYP bit
-                            // HSE(not Xtal) selected as PLL clock source
-                            PRINTF( "Use HSE(not Xtal but External Clock)=%dHz", HSE_VALUE );
-                        } else {
-                            // HSE(Xtal) selected as PLL clock source
-                            PRINTF( "%s, Xtal=%dHz", cmsg3, HSE_VALUE );
-                        }
-                    }
-                    put_rn();
-                    PRINTF( "PLL %s%dHz", cmsg1, m2 );
-                    put_rn();
-                    break;
-                default:    // Not come here
-                    PRINTF( cmsg5 );
-                    break;
-            }
-            put_rn();
-            PRINTF( "SYSCLK %s%dHz", cmsg6, HAL_RCC_GetSysClockFreq() );
-            put_rn();
-            PRINTF( "HCLK   %s%dHz", cmsg6, HAL_RCC_GetHCLKFreq() );
-            put_rn();
-            PRINTF( "PCLK1  %s%dHz", cmsg6, HAL_RCC_GetPCLK1Freq() );
-            put_rn();
-            PRINTF( "PCLK2  %s%dHz", cmsg6, HAL_RCC_GetPCLK2Freq() );
-            put_rn();
-            put_rn();
-            m1 = RCC->CSR & RCC_CSR_RTCSEL;
-            // Check RTC & LCD Clock
-            PRINTF("RTC/LCD Clock");
-            put_rn();
-            switch (m1) {
-                case RCC_CSR_RTCSEL_NOCLOCK:
-                    PRINTF( cmsg7 );
-                    break;
-                case RCC_CSR_RTCSEL_LSE:
-                    PRINTF( cmsg8 );
-                    break;
-                case RCC_CSR_RTCSEL_LSI:
-                    PRINTF("%s 26 to 56, typ.38KHz", cmsg9);
-                    break;
-                case RCC_CSR_RTCSEL_HSE:
-                    PRINTF( cmsg10 );
-                    break;
-                default:    // Not come here
-                    PRINTF( cmsg5 );
-                    break;
-            }
-            put_rn();
-            put_rn();
-            break;
-        case 'c' :      // sc - show system CPU information
-            m1 = SCB->CPUID;
-            m2 = ( m1 >> 24 );
-            if ( m2 == 0x41 ) {
-                PRINTF( "CPU = ARM " );
-            } else {
-                PRINTF( "CPU = NOT ARM " );
-            }
-            m2 = ( m1 >> 4 ) & 0xfff;
-            if ( m2 == 0xc23 ) {
-                PRINTF( "Cortex-M3" );
-            } else {
-                PRINTF( "NOT Cortex-M3" );
-            }
-            put_rn();
-            m2 = ( m1 >> 20 ) & 0x0f;
-            PRINTF( "Variant:%x", m2 );
-            put_rn();
-            m2 = m1 & 0x7;
-            PRINTF( "Revision:%x", m2 );
-            put_rn();
-            PRINTF( "CPU ID: 0x%08x", m1 );
-            put_rn();
-            m1 = DBGMCU->IDCODE;
-            PRINTF( "DBG ID: 0x%08x", m1 );
-            put_rn();
-            // unique ID
-            // http://false.ekta.is/2013/09/stm32-unique-id-register-not-so-unique/
-            m1 = *(__IO uint32_t *)((uint32_t)0x1FF80050);
-            PRINTF("Unique device ID(94bits):(1) 0x%08x ", m1);
-            m1 = *(__IO uint32_t *)((uint32_t)0x1FF80054);
-            PRINTF("(2) 0x%08x ", m1);
-            m1 = *(__IO uint32_t *)((uint32_t)0x1FF80058);
-            PRINTF( "(3) 0x%08x", m1 );
-            put_rn();
-            break;
-        case '?' :
-        default:
-            PRINTF( "sc - System CPU information" );
-            put_rn();
-            PRINTF( "sf - System Clock" );
-            put_rn();
-    }
-}
-#endif  // Select CPU
-
-//-------------------------------------------------------------------------------------------------
-//  Monitor Main Program
-//-------------------------------------------------------------------------------------------------
-int mon_hw(void)
-{
-    char *ptr;
-
-    put_r();
-    PRINTF("%s [Help:'?' key]", mon_msg);
-    put_rn();
-    for (;;) {
-        put_r();
-        PUTC('>');
-        ptr = linebuf;
-        get_line(ptr, buf_size);
-        put_r();
-        switch (*ptr++) {
-                //-----------------------------------------------------------------------------------------
-                //    Memory
-                //-----------------------------------------------------------------------------------------
-            case 'm' :
-#if USE_MEM
-                mem_inf(ptr);
-                put_rn();
-#else
-                not_select();
-#endif   // USE_MEM
-                break;
-                //-----------------------------------------------------------------------------------------
-                //    Register
-                //-----------------------------------------------------------------------------------------
-            case 'r' :
-                put_r();
-                PRINTF(mrmsg0);
-                put_rn();
-                quitflag = 0;
-                for (; quitflag != 0xff;) {
-                    PRINTF("r>");
-                    ptr = linebuf;
-                    get_line(ptr, buf_size);
-                    put_r();
-                    switch(*ptr++) {
-                        case 'u' :
-#if USE_UART
-                            switch(*ptr++) {
-                                case '1' :
-                                    PRINTF("%s%s1%s", mrmsg1,mrmsg2,mrmsg1);
-                                    usart_reg(USART1);
-                                    break;
-                                case '2' :
-                                    PRINTF("%s%s2%s", mrmsg1,mrmsg2,mrmsg1);
-                                    usart_reg(USART2);
-                                    break;
-#if defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F411RE)
-                                case '6' :
-                                    PRINTF("%s%s6%s", mrmsg1,mrmsg2,mrmsg1);
-                                    usart_reg(USART6);
-                                    break;
-#elif defined(TARGET_NUCLEO_L152RE)
-                                case '3' :
-                                    PRINTF("%s%s3%s", mrmsg1,mrmsg2,mrmsg1);
-                                    usart_reg(USART3);
-                                    break;
-                                case '5' :
-                                    PRINTF("%s%s5%s", mrmsg1,mrmsg2,mrmsg1);
-                                    usart_reg(UART5);
-                                    break;
-#endif
-                                case '*' :
-                                    PRINTF( "%s & UART", mrmsg2 );
-                                    put_rn();
-                                    PRINTF("%s%s1%s", mrmsg1,mrmsg2,mrmsg1);
-                                    usart_reg(USART1);
-                                    PRINTF("%s%s2%s", mrmsg1,mrmsg2,mrmsg1);
-                                    usart_reg(USART2);
-#if defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F411RE)
-                                    PRINTF("%s%s6%s", mrmsg1,mrmsg2,mrmsg1);
-                                    usart_reg(USART6);
-#elif defined(TARGET_NUCLEO_L152RE)
-                                    PRINTF("%s%s3%s", mrmsg1,mrmsg2,mrmsg1);
-                                    usart_reg(USART3);
-                                    PRINTF("%s%s5%s", mrmsg1,mrmsg2,mrmsg1);
-                                    usart_reg(UART5);
-#endif
-                                    break;
-                                case '?' :
-                                default:
-                                    PRINTF( mrmsg3 );
-                                    put_rn();
-                            }
-#else
-                            not_select();
-#endif // USE_UART
-                            break;
-                        case 'i' :
-#if USE_I2C
-                            switch(*ptr++) {
-                                case '1' :
-                                    PRINTF("%s%s1%s", mrmsg1,mrmsg4,mrmsg1);
-                                    i2c_reg( I2C1 );
-                                    break;
-                                case '2' :
-                                    PRINTF("%s%s2%s", mrmsg1,mrmsg4,mrmsg1);;
-                                    i2c_reg( I2C2 );
-                                    break;
-#if defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F411RE)
-                                case '3' :
-                                    PRINTF("%s%s3%s", mrmsg1,mrmsg4,mrmsg1);;
-                                    i2c_reg( I2C3 );
-                                    break;
-#endif
-                                case '*' :
-                                    PRINTF(mrmsg4);
-                                    put_rn();
-                                    PRINTF("%s%s1%s", mrmsg1,mrmsg4,mrmsg1);
-                                    i2c_reg( I2C1 );
-                                    PRINTF("%s%s2%s", mrmsg1,mrmsg4,mrmsg1);
-                                    i2c_reg( I2C2 );
-#if defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F411RE)
-                                    PRINTF("%s%s3%s", mrmsg1,mrmsg4,mrmsg1);;
-                                    i2c_reg( I2C3 );
-#endif
-                                    break;
-                                case '?' :
-                                default:
-                                    PRINTF(mrmsg5);
-                                    put_rn();
-                            }
-#else
-                            not_select();
-#endif // USE_I2C
-                            break;
-                        case 's' :
-#if USE_SPI
-                            switch(*ptr++) {
-                                case '1' :
-                                    PRINTF("%s%s1%s", mrmsg1,mrmsg6,mrmsg1);
-                                    spi_reg( SPI1 );
-                                    break;
-                                case '2' :
-                                    PRINTF("%s%s2%s", mrmsg1,mrmsg6,mrmsg1);
-                                    spi_reg( SPI2 );
-                                    break;
-                                case '3' :
-                                    PRINTF("%s%s3%s", mrmsg1,mrmsg6,mrmsg1);
-                                    spi_reg( SPI3 );
-                                    break;
-#if defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F411RE)
-                                case '4' :
-                                    PRINTF("%s%s4%s", mrmsg1,mrmsg6,mrmsg1);
-                                    spi_reg( SPI4 );
-                                    break;
-#endif
-                                case '*' :
-                                    PRINTF(mrmsg6);
-                                    put_rn();
-                                    PRINTF("%s%s1%s", mrmsg1,mrmsg6,mrmsg1);
-                                    spi_reg( SPI1 );
-                                    PRINTF("%s%s2%s", mrmsg1,mrmsg6,mrmsg1);
-                                    spi_reg( SPI2 );
-                                    PRINTF("%s%s3%s", mrmsg1,mrmsg6,mrmsg1);
-                                    spi_reg( SPI3 );
-#if defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F411RE)
-                                    PRINTF("%s%s4%s", mrmsg1,mrmsg6,mrmsg1);
-                                    spi_reg( SPI4 );
-#endif
-                                    break;
-                                case '?' :
-                                default:
-                                    PRINTF(mrmsg7);
-                                    put_rn();
-                            }
-#else
-                            not_select();
-#endif // USE_SPI
-                            break;
-                        case 't' :      //
-                            not_yet_impliment();
-                            break;
-                        case 'a' :      //
-                            not_yet_impliment();
-                            break;
-                        case 'd' :      //
-                            not_yet_impliment();
-                            break;
-                        case 'w' :      //
-                            not_yet_impliment();
-                            break;
-                        case 'l' :        //
-                            not_yet_impliment();
-                            break;
-                        case 'c' :      //
-                            not_yet_impliment();
-                            break;
-                        case 'x' :      //
-                            not_yet_impliment();
-                            break;
-                        case 'y' :      //
-                            not_yet_impliment();
-                            break;
-                        case '?' :
-                            PRINTF("u - USART");
-                            put_rn();
-                            PRINTF("i - I2C");
-                            put_rn();
-                            PRINTF("s - SPI");
-                            put_rn();
-                            PRINTF("t - TIMER");
-                            put_rn();
-                            PRINTF("a - ADC");
-                            put_rn();
-                            PRINTF("d - DAC");
-                            put_rn();
-                            PRINTF("l - LDC");
-                            put_rn();
-                            PRINTF("w - WWDG");
-                            put_rn();
-                            PRINTF("c - COMP");
-                            put_rn();
-                            break;
-                        case 'q' :        // quit
-                            quitflag = 0xff;
-                            break;
-                        default:
-                            PUTC('?');
-                            put_rn();
-                    }
-                }
-                PRINTF(mrmsg8);
-                put_rn();
-                break;
-                //-----------------------------------------------------------------------------------------
-                //    Port
-                //-----------------------------------------------------------------------------------------
-            case 'p' :
-#if USE_PORT
-                put_r();
-                PRINTF("Enter port a,b,c,d,e,h & * ? for help");
-                put_rn();
-                quitflag = 0;
-                for (; quitflag != 0xff;) {
-                    PRINTF("p>");
-                    ptr = linebuf;
-                    get_line(ptr, buf_size);
-                    put_r();
-                    switch(*ptr) {
-                        case 'a' :
-                        case 'b' :
-                        case 'c' :
-                        case 'd' :
-                        case 'e' :
-                        case 'h' :
-                            port_inf_one(ptr);
-                            break;
-                        case '*' :
-                            rpt_port();
-                            break;
-                        case '?' :
-                            PRINTF("port a,b,c,d,e,h & *");
-                            put_rn();
-                            break;
-                        case 'q' :        // quit
-                            quitflag = 0xff;
-                            break;
-                        default:
-                            PUTC('?');
-                            put_rn();
-                    }
-                }
-                PRINTF(mrmsg8);
-                put_rn();
-#else
-                not_select();
-#endif // USE_PORT
-                break;
-                //-----------------------------------------------------------------------------------------
-                //    System
-                //-----------------------------------------------------------------------------------------
-            case 's' :    // System related information
-#if USE_SYS
-                cpu_inf(ptr);
-#else
-                not_select();
-#endif   // USE_SYS
-                break;
-                //-----------------------------------------------------------------------------------------
-                //    Help
-                //-----------------------------------------------------------------------------------------
-            case '?' :
-                hw_msg_hlp();
-                break;
-                //-----------------------------------------------------------------------------------------
-                //    Return to main routine
-                //-----------------------------------------------------------------------------------------
-            case 'q' :        // Quit
-                put_r();
-                PRINTF("Return to monitor");
-                put_rn();
-                return 0;
-                //-----------------------------------------------------------------------------------------
-                //    Special command for DEBUG
-                //-----------------------------------------------------------------------------------------
-            case 'x' :
-                not_yet_impliment();
-                break;
-                //-----------------------------------------------------------------------------------------
-                //    no support
-                //-----------------------------------------------------------------------------------------
-            default:
-                PUTC('?');
-                put_rn();
-                break;
-        }
-    }
-}
-#endif  // defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F411RE) || defined(TARGET_NUCLEO_L152RE)
diff -r 36ad7c7d0400 -r 8c37a47ac34c debug_tools/mon_hw_STM32.h
--- a/debug_tools/mon_hw_STM32.h	Sun Feb 14 21:55:30 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,88 +0,0 @@
-/*
- * mbed Application program for the ST NUCLEO Board
- *
- *  Copyright (c) 2010-2014 Kenji Arai / JH1PJL
- *  http://www.page.sannet.ne.jp/kenjia/index.html
- *  http://mbed.org/users/kenjiArai/
- *      Created: July       7th, 2014
- *      Revised: Nobember   2nd, 2014
- *
- * 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.
- */
-
-//  ROM / Constant data ---------------------------------------------------------------------------
-char *const rgmsg0 = " 7, 6, 5, 4, 3, 2, 1, 0";
-char *const rgmsg1 = "15,14,13,12,11,10, 9, 8,";
-
-char *const cmsg0 = "Use MSI(internal RC)";
-char *const cmsg1 = "freq=";
-char *const cmsg2 = "Use HSI(internal RC/High speed)";
-char *const cmsg3 = "Use HSE(External Xtal)";
-char *const cmsg4 = "Use PLL with";
-char *const cmsg5 = "??? following infromation is not valid !";
-char *const cmsg6 = "clock freq. =";
-char *const cmsg7 = "No clock";
-char *const cmsg8 = "Use LSE(external Xtal)=32768Hz";
-char *const cmsg9 = "Use LSI(internal RC/Low speed), RC=";
-char *const cmsg10= "Use HSE(external Xtal & prescaler)";
-char *const cmsg11= "Power Control";
-
-char *const imsg2 = "-->Control Reg.";
-char *const imsg3 = "-->Status Reg.";
-char *const imsg4 = "-->Data Reg.";
-char *const imsg5 = "-->Baud rate Reg.";
-char *const imsg6 = "-->Own address Reg.";
-char *const imsg7 = "-->Clock control Reg.";
-char *const imsg8 = "-->TRISE Reg.";
-
-char *const rnmsg0 = " CR1--";
-char *const rnmsg1 = " CR2--";
-char *const rnmsg2 = " DR---";
-char *const rnmsg3 = " SR---";
-char *const rnmsg4 = " BRR--";
-char *const rnmsg5 = " SR1--";
-char *const rnmsg6 = " SR2--";
-char *const rnmsg7 = " OAR1-";
-char *const rnmsg8 = " OAR2-";
-char *const rnmsg9 = " CCR--";
-char *const rnmsg10 = " TRISE";
-
-char *const pnmsg0 = "Port  ";
-//                    0x00000000 0x0000  0x00000000 0x00000000 0x0000 0x0000
-char *const pnmsg1 = "Mode      Out-type Out-speed  Pup/dwn    Input  Output";
-char *const pnmsga = "GPIOA";
-char *const pnmsgb = "GPIOB";
-char *const pnmsgc = "GPIOC";
-char *const pnmsgd = "GPIOD";
-char *const pnmsge = "GPIOE";
-char *const pnmsgh = "GPIOH";
-char *const pnmsg2 = "Select GPIO";
-char *const pnmsg3 = " All";
-char *const pnmsg4 = "-->Output";
-char *const pnmsg5 = "-->Input";
-char *const pnmsg6 = "data";
-
-// Here is redefine part (ST Nucleo F401RE needs here definition)
-#ifndef GPIO_Mode_IN
-#define GPIO_Mode_IN    0
-#define GPIO_Mode_OUT   1
-#define GPIO_Mode_AF    2
-#define GPIO_Mode_AN    3
-#endif
-
-#ifndef GPIO_Speed_400KHz
-#define GPIO_Speed_400KHz   0
-#define GPIO_Speed_2MHz     1
-#define GPIO_Speed_10MHz    2
-#define GPIO_Speed_40MHz    3
-#endif
-
-#ifndef GPIO_PuPd_NOPULL
-#define GPIO_PuPd_NOPULL    0
-#define GPIO_PuPd_UP        1
-#define GPIO_PuPd_DOWN      2
-#endif
diff -r 36ad7c7d0400 -r 8c37a47ac34c debug_tools/mon_hw_nRF51.cpp
--- a/debug_tools/mon_hw_nRF51.cpp	Sun Feb 14 21:55:30 2016 +0000
+++ b/debug_tools/mon_hw_nRF51.cpp	Sun Jan 08 04:36:55 2017 +0000
@@ -6,7 +6,7 @@
  *  http://www.page.sannet.ne.jp/kenjia/index.html
  *  http://mbed.org/users/kenjiArai/
  *      Created:  Feburary   1st, 2016
- *      Revised:  Feburary  13th, 2016
+ *      Revised:  Feburary  18th, 2016
  *
  * 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
diff -r 36ad7c7d0400 -r 8c37a47ac34c debug_tools/old_mon_hw_nRF51.cpp
--- a/debug_tools/old_mon_hw_nRF51.cpp	Sun Feb 14 21:55:30 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,814 +0,0 @@
-#if 0
-
-/*
- * mbed Application program for the mbed nRF51 series
- * Monitor program Ver.3 for only for nRF51 series
- *
- *  Copyright (c) 2016 Kenji Arai / JH1PJL
- *  http://www.page.sannet.ne.jp/kenjia/index.html
- *  http://mbed.org/users/kenjiArai/
- *      Created:  Feburary   1st, 2016
- *      Revised:  Feburary   4th, 2016
- *
- * 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.
- */
-
-#if defined(TARGET_NRF51822)
-
-//  Include ---------------------------------------------------------------------------------------
-#include "mbed.h"
-#include "mon_hw_config.h"
-#include "mon_hw_common.h"
-
-//  Object ----------------------------------------------------------------------------------------
-
-//  Definition ------------------------------------------------------------------------------------
-
-//  RAM -------------------------------------------------------------------------------------------
-uint32_t SystemFrequency;
-#if USE_MEM
-//  Memory range data (This is special case: save in RAM area! (others mbed's are in FLASH))
-uint32_t mem_range[][2] = {                // Memory access range
-    { 0x00000000, 0x0003ffff },            // On-chip non-volatile memory     //128 or 256KB Flash
-    { 0x20000000, 0x20007fff },            // On-chip SRAM                    //16 or 32KB RAM
-    { 0x10000000, 0x1000007f },            // FICR
-    { 0x10001000, 0x100010ff },            // UICR
-    { 0x40000000, 0x4001f58c },            // Peripheral
-    { 0x50000500, 0x500007ff }             // GPIO
-};
-#endif  // USE_MEM
-
-//  ROM / Constant data ---------------------------------------------------------------------------
-char *const mon_msg = "HW monitor only for mbed nRF51 series created on "__DATE__","__TIME__"";
-
-char *const xmsg0 = "Not implimented yet";
-char *const hmsg0 = "m  - Entry Memory Mode";
-char *const hmsg1 = "m>? -> Help ";
-char *const hmsg2 = "r  - Show I2C,SPI,UART,Timer,ADC Reg.";
-char *const hmsg3 = "r>? -> Help";
-char *const hmsg4 = "c  - CPU information";
-char *const hmsg5 = "p  - GPIO information";
-char *const hmsg6 = "x  - Special command for Debug";
-char *const hmsg7 = "q  - Quit (back to called routine)";
-
-//  Function prototypes ---------------------------------------------------------------------------
-
-//-------------------------------------------------------------------------------------------------
-//  Control Program
-//-------------------------------------------------------------------------------------------------
-// No function
-void not_yet_impliment( void )
-{
-    put_r();
-    PRINTF(xmsg0);
-    put_rn();
-}
-
-// No function
-#if (USE_MEM==0)||(USE_PORT==0)||(USE_UART==0)||(USE_SPI==0)||(USE_I2C==0)||(USE_SYS==0)
-void not_select( void )
-{
-    PRINTF("Not select the function (refer mon_hw_config.h)");
-    put_rn();
-}
-#endif
-
-//  Help Massage
-void msg_hlp_hw (void)
-{
-    PRINTF(mon_msg);
-    put_rn();
-    PRINTF(hmsg0);
-    put_rn();
-    PRINTF(hmsg1);
-    put_rn();
-    PRINTF(hmsg2);
-    put_rn();
-    PRINTF(hmsg3);
-    put_rn();
-    PRINTF(hmsg4);
-    put_rn();
-    PRINTF(hmsg5);
-    put_rn();
-    PRINTF(hmsg6);
-    put_rn();
-    PRINTF(hmsg7);
-    put_rn();
-}
-
-#if USE_MEM
-char *const rmsg0 = "FLASH      ";
-char *const rmsg1 = "SRAM       ";
-char *const rmsg2 = "FIR        ";
-char *const rmsg3 = "UIR        ";
-char *const rmsg4 = "Peripheral ";
-char *const rmsg5 = "GPIO       ";
-
-#include "mon_hw_mem.h"
-#endif   // USE_MEM
-
-//  Show Xbit register contents
-void reg_print(uint16_t size, uint16_t reg)
-{
-    uint16_t i, j, k, n;
-
-    if (size == 8) {
-        PRINTF(" 7, 6, 5, 4, 3, 2, 1, 0");
-        put_rn();
-        i = 8;
-        n = 0x80;
-    } else if (size == 16) {
-        PRINTF( "15,14,13,12,11,10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0" );
-        put_rn();
-        i = 16;
-        n = 0x8000;
-    } else {
-        PRINTF("0x%08x", reg);
-        return;
-    }
-    PUTC(' ');
-    for (; i>0; i--) {
-        k = n >> (size-i);
-        j = reg & k;
-        if (j) {
-            PUTC('1');
-        } else {
-            PUTC('0');
-        }
-        PUTC(' ');
-        PUTC(' ');
-    }
-    PRINTF("  (0x%04x)", reg);
-}
-
-uint8_t bit_position(uint32_t x)
-{
-    uint8_t n;
-    
-    for (n = 0; n < 32; n++){
-        x = x >> 1UL;
-        if (x & 0x1){
-            break;
-        }
-    }
-    return n;
-}
-
-void cpu_sys(void)
-{
-    uint32_t m1 = 0, m2 = 0;
-
-    m1 = SCB->CPUID;
-    m2 = ( m1 >> 24 );
-    if ( m2 == 0x41 ) {
-        PRINTF( "CPU = ARM " );
-    } else {
-        PRINTF( "CPU = NOT ARM " );
-    }
-    m2 = ( m1 >> 4 ) & 0xfff;
-    if ( m2 == 0xc20 ) {
-        PRINTF( "Cortex-M0" );
-    } else {
-        PRINTF( "NOT Cortex-M0" );
-    }
-    //put_rn();
-    m2 = ( m1 >> 20 ) & 0x0f;
-    PRINTF( "  Variant:%x  ", m2 );
-    //put_rn();
-    m2 = m1 & 0x7;
-    PRINTF( "Revision:%x", m2 );
-    put_rn();
-    PRINTF( "CPU ID: 0x%08x", m1 );
-    put_rn();
-    // nRF Chip revision
-    m1 = (((*((uint32_t volatile *)0xF0000FE8)) & 0x000000F0) >> 4);
-    switch (m1) {
-        case 1:     // revision 1
-            m2 = 1;
-            break;
-        case 4:     // revision 2
-            m2 = 2;
-            break;
-        case 7:
-        case 8:
-        case 9:     // revision 3
-            m2 = 3;
-            break;
-        default:
-            m2 = 0;
-            break;
-    }
-    if (m2){
-        PRINTF( "nRF Revision: %d", m2 );
-    } else {
-        PRINTF( "nRF Revision: Unknown" );
-    }
-    put_rn();
-    // Firmware
-    m1 = NRF_UICR->FWID & 0xffff;
-    PRINTF( "Firmware ID: 0x%04x", m1 );
-    put_rn();
-    // System Clock
-    m1 = NRF_UICR->XTALFREQ & 0xff;
-    PRINTF( "System clock by " );
-    if (m1){
-        PRINTF( "XTAL:16MHz" );
-    } else {
-        PRINTF( "XTAL:32MHz" );
-    }
-    put_rn();
-    m1 = NRF_CLOCK->LFCLKSRCCOPY & 0x3;
-    PRINTF( "LFCLK Source=32.768 kHz " );
-    switch (m1) {
-        case 0:     // revision 1
-            PRINTF( "RC oscillator" );
-            break;
-        case 1:     // revision 1
-            PRINTF( "crystal oscillator" );
-            break;
-        case 2:      // revision 1
-            PRINTF( "synthesized from HFCLK" );
-            break;
-        default:
-            PRINTF( "unknown" );
-            break;
-    }
-    put_rn();  
-    // FLASH & RAM
-    mem_cnfg_init(1);    
-}
-
-#if USE_PORT
-void port_all(void)
-{
-    uint32_t p0, p1;
-    uint8_t n;
-   
-    put_r();
-    PRINTF( "GPIO registers" );
-    put_rn();
-    p0 = NRF_GPIO->OUTSET;
-    PRINTF( "OUT: " );
-    reg_print(SIZE32, p0);
-    PRINTF( " ;0=L, 1=H" );
-    put_rn();
-    p0 = NRF_GPIO->IN;
-    PRINTF( "IN:  " );
-    reg_print(SIZE32, p0);
-    PRINTF(" ;0=L, 1=H");
-    put_rn();
-    p0 = NRF_GPIO->DIRSET;
-    PRINTF("DIR: ");
-    reg_print(SIZE32, p0);
-    PRINTF(" ;0=in,1=out");
-    put_rn();
-    PRINTF("Dc=Disconnect,Cn=Connect,Ot=Out,Dis=Disabled,PU=Pullup,PD=Pulldown,Hi=High,Lo=Low");
-    for (n=0; n < 32; n++){
-        put_rn();
-        p0 = NRF_GPIO->PIN_CNF[n];
-        PRINTF("P0_%02d: DIR=", n);
-        if (p0 & 0x1){
-            PRINTF("Ot");
-        } else {
-            PRINTF("In");
-        }
-        PRINTF(", IN=");
-        if (p0 & 0x2){
-            PRINTF("Dc");
-        } else {
-            PRINTF("Cn");
-        }
-        PRINTF(", PULL=");
-        p1 = (p0 >> 2) & 0x3;
-        switch (p1){
-            case 0:
-                PRINTF("Dis");
-                break;
-            case 1:
-                PRINTF("PD ");
-                break;
-            case 3:
-                PRINTF("PU ");
-                break;
-            default:
-                PRINTF("?  ");
-                break;
-        }
-        PRINTF(", Drive=");
-        p1 = (p0 >> 8) & 0x7;
-        switch (p1){
-            case 0:
-                PRINTF("S0S1");
-                break;
-            case 1:
-                PRINTF("H0S1");
-                break;
-            case 2:
-                PRINTF("S0H1");
-                break;
-            case 3:
-                PRINTF("H0H1");
-                break;
-            case 4:
-                PRINTF("D0S1");
-                break;
-            case 5:
-                PRINTF("D0H1");
-                break;
-            case 6:
-                PRINTF("S0D1");
-                break;
-            case 7:
-                PRINTF("H0D1");
-                break;
-            default:
-                PRINTF("?   ");
-                break;
-        }
-        PRINTF(", SENSE=");
-        p1 = (p0 >> 16) & 0x3;
-        switch (p1){
-            case 0:
-                PRINTF("Dis");
-                break;
-            case 2:
-                PRINTF("Hi ");
-                break;
-            case 3:
-                PRINTF("Lo ");
-                break;
-            default:
-                PRINTF("?  ");
-                break;
-        }
-    }
-}
-#endif  // USE_PORT
-
-#if USE_UART
-void uart_reg(void)
-{
-    uint32_t p0, p1;
-
-    put_r();
-    PRINTF("UART registers");
-    put_rn();
-    p0 = NRF_UART0->ENABLE;
-    p1 = p0 & 0x7;
-    PRINTF("UART is ");
-    if (p1 == 4){
-        PRINTF("enabled");
-        put_rn();      
-        p0 = NRF_UART0->BAUDRATE;
-        switch(p0){
-            case UART_BAUDRATE_BAUDRATE_Baud1200:
-                p1 = 1200;
-                break;
-            case UART_BAUDRATE_BAUDRATE_Baud2400:
-                p1 = 2400;
-                break;
-            case UART_BAUDRATE_BAUDRATE_Baud4800:
-                p1 = 4800;
-                break;
-            case UART_BAUDRATE_BAUDRATE_Baud9600:
-                p1 = 9600;
-                break;
-            case UART_BAUDRATE_BAUDRATE_Baud14400:
-                p1 = 14400;
-                break;
-            case UART_BAUDRATE_BAUDRATE_Baud19200:
-                p1 = 19200;
-                break;
-            case UART_BAUDRATE_BAUDRATE_Baud28800:
-                p1 = 28800;
-                break;
-            case UART_BAUDRATE_BAUDRATE_Baud38400:
-                p1 = 38400;
-                break;
-            case UART_BAUDRATE_BAUDRATE_Baud57600:
-                p1 = 576000;
-                break;
-            case UART_BAUDRATE_BAUDRATE_Baud76800:
-                p1 = 76800;
-                break;
-            case UART_BAUDRATE_BAUDRATE_Baud115200:
-                p1 = 115200;
-                break;
-            case UART_BAUDRATE_BAUDRATE_Baud230400:
-                p1 = 230400;
-                break; 
-            case UART_BAUDRATE_BAUDRATE_Baud250000:
-                p1 = 250000;
-                break;
-            case UART_BAUDRATE_BAUDRATE_Baud460800:
-                p1 = 460800;
-                break;
-            case UART_BAUDRATE_BAUDRATE_Baud921600:
-                p1 = 921600;
-                break;
-            case UART_BAUDRATE_BAUDRATE_Baud1M:
-                PRINTF("Baud rate: 1M");
-                p1 = 1;
-                break;
-            default:
-                PRINTF("Baud rate: Unknown");
-                p1 = 0;
-        }
-        if (p1 > 10){
-            PRINTF("Baud rate: %dbps", p1);
-        }
-        put_rn();
-        p0 = NRF_UART0->PSELTXD;
-        //PRINTF("0x%08x\r\n",p0);
-        PRINTF("TXD Pin: ");
-        if (p0 == 0xffffffff){
-            PRINTF("Unknown");
-        } else {
-            PRINTF("P0_%02d", p0);
-        }
-        put_rn();
-        p0 = NRF_UART0->PSELRXD;
-        //PRINTF("0x%08x\r\n",p0);
-        PRINTF("RXD Pin: ");
-        if (p0 == 0xffffffff){
-            PRINTF("Unknown");
-        } else {
-            PRINTF("P0_%02d", p0);
-        }
-        put_rn();
-        p0 = NRF_UART0->PSELRTS;
-        //PRINTF("0x%08x\r\n",p0);
-        PRINTF("RTS Pin: ");
-        if (p0 == 0xffffffff){
-            PRINTF("Unknown");
-        } else {
-            PRINTF("P0_%02d", p0);
-        }
-        put_rn();
-        p0 = NRF_UART0->PSELCTS;
-        //PRINTF("0x%08x\r\n",p0);
-        PRINTF("CTS Pin: ");
-        if (p0 == 0xffffffff){
-            PRINTF("Unknown");
-        } else {
-            PRINTF("P0_%02d", p0);
-        }
-        put_rn();
-        p0 = NRF_UART0->SHORTS;
-        PRINTF("SHORTS:  ");
-        reg_print(SIZE32, p0);
-        put_rn();
-        p0 = NRF_UART0->ERRORSRC;
-        PRINTF("ERRORSRC:");
-        reg_print(SIZE32, p0);
-        put_rn();
-    } else {
-        PRINTF("disabled");
-   }
-}
-#endif  //USE_UART
-
-#if USE_SPI
-void spi_reg(uint8_t n)
-{
-    uint32_t r0, r1, r2, r3;
-
-    put_r();
-    PRINTF("SPI registers");
-    put_rn();
-    if (n == 0){
-        r0 = NRF_SPI0->ENABLE;
-        PRINTF("SPI0 is ");
-    } else {
-        r0 = NRF_SPI1->ENABLE;
-        PRINTF("SPI1 is ");
-    }
-    r1 = p0 & 0x7;
-    if (r1 == 1){
-        PRINTF("enabled");
-//    } else {
-//        PRINTF("disabled");
-//    }
-        put_rn();
-        if (n == 0){
-            r0 = NRF_SPI0->FREQUENCY;
-            r1 = NRF_SPI0->PSELMOSI;
-            r2 = NRF_SPI0->PSELMISO;
-            r3 = NRF_SPI0->PSELSCK;
-        } else {
-            r0 = NRF_SPI1->FREQUENCY;
-            r1 = NRF_SPI1->PSELMOSI;
-            r2 = NRF_SPI1->PSELMISO;
-            r3 = NRF_SPI1->PSELSCK;
-        }
-        //r0 = NRF_SPI1->FREQUENCY;
-        PRINTF("Clock:");
-        switch(r0){
-            case SPI_FREQUENCY_FREQUENCY_K125:
-                PRINTF("125k");
-                break;
-            case SPI_FREQUENCY_FREQUENCY_K250:
-                PRINTF("250k");
-                break;
-            case SPI_FREQUENCY_FREQUENCY_K500:
-                PRINTF("500k");
-                break;
-            case SPI_FREQUENCY_FREQUENCY_M1:
-                PRINTF("1M");
-                break;
-            case SPI_FREQUENCY_FREQUENCY_M2:
-                PRINTF("2M");
-                break;
-            case SPI_FREQUENCY_FREQUENCY_M4:
-                PRINTF("4M");
-                break;
-            case SPI_FREQUENCY_FREQUENCY_M8:
-                PRINTF("8M");
-                break;
-            default:
-                PRINTF("Unknown");
-        }
-        PRINTF("bps");
-        put_rn();
-        //p0 = NRF_SPI1->PSELMOSI;
-        PRINTF("MOSI Pin: ");
-        if (r1 == 0xffffffff){
-            PRINTF("Unknown");
-        } else {
-            PRINTF("P0_%02d", r1);
-        }
-        put_rn();
-        //p0 = NRF_SPI1->PSELMISO;
-        PRINTF("MISO Pin: ");
-        if (r2 == 0xffffffff){
-            PRINTF("Unknown");
-        } else {
-            PRINTF("P0_%02d", r2);
-        }
-        put_rn();
-        //p0 = NRF_SPI1->PSELSCK;
-        PRINTF("SCK  Pin: ");
-        if (r3 == 0xffffffff){
-            PRINTF("Unknown");
-        } else {
-            PRINTF("P0_%02d", r3);
-        }
-        put_rn();
-    } else {
-        PRINTF("disabled");
-    }
-}
-#endif  //USE_SPI
-
-#if USE_I2C
-void i2c_reg(uint8_t n)
-{
-    uint32_t r0, r1, r2, r3, r4;
-
-    put_r();
-    PRINTF("TWI(I2C) registers");
-    put_rn();
-    if (n == 0){
-        r0 = NRF_SPI0->ENABLE;
-        PRINTF("TWI0 is ");
-    } else {
-        r0 = NRF_SPI1->ENABLE;
-        PRINTF("TWI1 is ");
-    }
-    r1 = p0 & 0x7;    
-    if (r1 == 5){
-        PRINTF("enabled");
-//    } else {
-//        PRINTF("disabled");
-//    }
-        put_rn();
-        if (n == 0){
-            r0 = NRF_TWI0->FREQUENCY;
-            r1 = NRF_TWI0->PSELSCL;
-            r2 = NRF_TWI0->PSELSDA;
-            r3 = NRF_TWI0->SHORTS;
-            r4 = NRF_TWI0->ERRORSRC;
-        } else {
-            r0 = NRF_TWI1->FREQUENCY;
-            r1 = NRF_TWI1->PSELSCL;
-            r2 = NRF_TWI1->PSELSDA;
-            r3 = NRF_TWI1->SHORTS;
-            r4 = NRF_TWI1->ERRORSRC;
-        }
-        //p0 = NRF_TWI0->FREQUENCY;
-        PRINTF("Clock: ");
-        if (r0 == TWI_FREQUENCY_FREQUENCY_K100){
-            PRINTF("100KHz");
-        } else if (p0 == TWI_FREQUENCY_FREQUENCY_K250){
-            PRINTF("250KHz");
-        } else if (p0 == TWI_FREQUENCY_FREQUENCY_K400){
-            PRINTF("400KHz");
-        } else {
-            PRINTF("Unknown");
-        }
-        put_rn();
-        //p0 = NRF_TWI0->PSELSCL;
-        PRINTF("SCL Pin: ");
-        if (r1 == 0xffffffff){
-            PRINTF("Unknown");
-        } else {
-            PRINTF("P0_%02d", p0);
-        }
-        put_rn();
-        //p0 = NRF_TWI0->PSELSDA;
-        PRINTF("SDA Pin: ");
-        if (r2 == 0xffffffff){
-            PRINTF("Unknown");
-        } else {
-            PRINTF("P0_%02d", p0);
-        }
-        put_rn();
-        //p0 = NRF_TWI0->SHORTS;
-        PRINTF("SHORTS:  ");
-        reg_print(SIZE32, r3);
-        put_rn();
-        //p0 = NRF_TWI0->ERRORSRC;
-        PRINTF("ERRORSRC:");
-        reg_print(SIZE32, r4);
-        put_rn();
-    } else {
-        PRINTF("disabled");
-    }
-}
-#endif  //USE_I2C
-
-//-------------------------------------------------------------------------------------------------
-//  Monitor Main Program
-//-------------------------------------------------------------------------------------------------
-int mon_hw (void)
-{
-    char *ptr;
-
-    put_r();
-    PRINTF("%s [Help:'?' key]", mon_msg);
-    put_rn();
-    for (;;) {
-        put_r();
-        PUTC('>');
-        ptr = linebuf;
-        get_line(ptr, buf_size);
-        switch (*ptr++) {
-                //---------------------------------------------------------------------------------
-                //    Memory
-                //---------------------------------------------------------------------------------
-            case 'm' :
-#if USE_MEM
-                mem_inf(ptr);
-                put_rn();
-                break;
-#else
-                not_select();
-#endif   // USE_MEM
-                //---------------------------------------------------------------------------------
-                //    GPIO
-                //---------------------------------------------------------------------------------
-            case 'p' :
-#if USE_PORT
-                port_all();
-                put_rn();
-                break;
-#else
-                not_select();
-#endif   // USE_PORT
-                //---------------------------------------------------------------------------------
-                //    Register
-                //---------------------------------------------------------------------------------
-            case 'r' :
-                uint8_t  r_flg;
-                put_r();
-                PRINTF("Reg. Mode u,i,s,t,a & ?");
-                put_rn();
-                r_flg = 0;
-                for (; r_flg != 0xff;) {
-                    PRINTF("r>");
-                    ptr = linebuf;
-                    get_line(ptr, buf_size);
-                    put_r();
-                    switch(*ptr++) {
-                        case 'u' :
-#if USE_UART
-                            uart_reg();
-#else
-                            not_select();
-#endif // USE_UART
-                            break;
-                        case 'i' :
-#if USE_I2C
-                            put_r();
-                            i2c_reg(0);
-                            i2c_reg(1);
-#else
-                            not_select();
-#endif // USE_I2C
-                            break;
-                        case 's' :
-#if USE_SPI
-                            spi_reg(0);
-                            spi_reg(1);
-#else
-                            not_select();
-#endif // USE_SPI
-                            break;
-                        case 't' :      //
-                            not_yet_impliment();
-                            break;
-                        case 'a' :      //
-                            not_yet_impliment();
-                            break;
-                        case 'd' :      //
-                            not_yet_impliment();
-                            break;
-                        case 'w' :      //
-                            not_yet_impliment();
-                            break;
-                        case 'l' :        //
-                            not_yet_impliment();
-                            break;
-                        case 'c' :      //
-                            not_yet_impliment();
-                            break;
-                        case 'x' :      //
-                            not_yet_impliment();
-                            break;
-                        case 'y' :      //
-                            not_yet_impliment();
-                            break;
-                        case 'q' :        // quit
-                            r_flg = 0xff;
-                            break;
-                        case '?' :
-                            PRINTF("u - UART");
-                            put_rn();
-                            PRINTF("i - I2C");
-                            put_rn();
-                            PRINTF("s - SPI");
-                            put_rn();
-                            PRINTF("t - TIMER");
-                            put_rn();
-                            PRINTF("a - ADC");
-                            put_rn();
-                            PRINTF("q - Exit mode");
-                            put_rn();
-                            break;
-                        default:
-                            PUTC('?');
-                            put_rn();
-                    }
-                }
-                PRINTF("Return to All Mode");
-                put_rn();
-                break;
-                //---------------------------------------------------------------------------------
-                //    CPU
-                //---------------------------------------------------------------------------------
-            case 'c' :    // CPU related information
-#if USE_SYS
-                put_r();
-                cpu_sys();
-#else
-                not_select();
-#endif   // USE_SYS
-                break;
-                //---------------------------------------------------------------------------------
-                //    Help
-                //---------------------------------------------------------------------------------
-            case '?' :
-                put_r();
-                msg_hlp_hw();
-                break;
-                //---------------------------------------------------------------------------------
-                //    Return to main routine
-                //---------------------------------------------------------------------------------
-            case 'q' :        // Quit
-                PRINTF("\rReturn to monitor ");
-                return 0;
-                //---------------------------------------------------------------------------------
-                //    Special command for DEBUG
-                //---------------------------------------------------------------------------------
-            case 'x' :
-                not_yet_impliment();
-                break;
-                //---------------------------------------------------------------------------------
-                //    no support
-                //---------------------------------------------------------------------------------
-            default:
-                PUTC('?');
-                put_rn();
-                break;
-        }
-    }
-}
-
-#endif  // defined(TARGET_NRF51822)
-
-
-#endif
diff -r 36ad7c7d0400 -r 8c37a47ac34c main.cpp
--- a/main.cpp	Sun Feb 14 21:55:30 2016 +0000
+++ b/main.cpp	Sun Jan 08 04:36:55 2017 +0000
@@ -19,8 +19,8 @@
  *      http://www.page.sannet.ne.jp/kenjia/index.html
  *      http://mbed.org/users/kenjiArai/
  *
- *      Started:  January   3rd, 2016
- *      Revised:  Feburary 13th, 2016
+ *      Started:  January    3rd, 2016
+ *      Revised:  January    8th, 2017
  */
 
 //  Include ---------------------------------------------------------------------------------------
@@ -42,7 +42,8 @@
 //  Object ----------------------------------------------------------------------------------------
 BLE         ble;
 DigitalOut  led1(LED1, 1);
-Serial      pc(USBTX, USBRX);
+//Serial      pc(USBTX, USBRX);
+Serial      pc(P0_3, P0_1);     // TX, RX
 I2C         i2c(P0_29,P0_28);
 SPI         spi(P0_20,P0_22,P0_25);
 nRF51_Vdd   vdd(3.6f, 2.6f);
diff -r 36ad7c7d0400 -r 8c37a47ac34c mbed-dev.lib
--- a/mbed-dev.lib	Sun Feb 14 21:55:30 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/mbed-dev/#d8964d7491c1
diff -r 36ad7c7d0400 -r 8c37a47ac34c mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Jan 08 04:36:55 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/99b5ccf27215
\ No newline at end of file
diff -r 36ad7c7d0400 -r 8c37a47ac34c modification/fstorage_config.h
--- a/modification/fstorage_config.h	Sun Feb 14 21:55:30 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,121 +0,0 @@
-#if 0
-/*
- * Copyright (c) Nordic Semiconductor ASA
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- *   1. Redistributions of source code must retain the above copyright notice, this
- *   list of conditions and the following disclaimer.
- *
- *   2. Redistributions in binary form must reproduce the above copyright notice, this
- *   list of conditions and the following disclaimer in the documentation and/or
- *   other materials provided with the distribution.
- *
- *   3. Neither the name of Nordic Semiconductor ASA nor the names of other
- *   contributors to this software may be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#ifndef FS_CONFIG_H__
-#define FS_CONFIG_H__
-
-#include <stdint.h>
-#include "nrf.h"
-
-/**
- * @defgroup fstorage_config FStorage configuration
- * @ingroup fstorage
- * @{
- * @brief FStorage configuration.
- */
-
-
-/**@brief Macro for max number of operations in the fs cmd queue.
- */
-#define FS_CMD_QUEUE_SIZE   (8)
-
-
-/**@brief Macro for max number of retries for a flash command before it notifies as failed.
- */
-#define FS_CMD_MAX_RETRIES  (3)
-
-
-/**@brief Macro for the content of a flash address that has not been written to.
- */
-#define FS_EMPTY_MASK       (0xFFFFFFFF)
-
-
-/**@brief Macro for flash page size according to chip family
- */
-#if defined (NRF51)
-    #define FS_PAGE_SIZE    (1024)
-#elif defined (NRF52)
-    #define FS_PAGE_SIZE    (4096)
-#else
-    #error "Device family must be defined. See nrf.h."
-#endif
-
-
-/*@brief Macro for flash page size according to chip family
-*/
-#define FS_PAGE_SIZE_WORDS  (FS_PAGE_SIZE/4)
-
-
-/**@brief Static inline function that provides last page address
- *
- * @note    If there is a bootloader present the bootloader address read from UICR
- *          will act as the page beyond the end of the available flash storage
- */
-static __INLINE uint32_t fs_flash_page_end_addr()
-{
-// January 30th, 2016 modified by JH1PJL    --- from here ---
-#if 0
-    uint32_t const bootloader_addr = NRF_UICR->NRFFW[0];
-#else
-    uint32_t const bootloader_addr = NRF_UICR->BOOTLOADERADDR;
-#endif
-//                                          ---- to here ---
-    return  ((bootloader_addr != FS_EMPTY_MASK) ?
-             bootloader_addr : NRF_FICR->CODESIZE * FS_PAGE_SIZE);
-}
-
-
-/**@brief Macro for last page address
- *
- * @note    If there is a bootloader present the bootloader address read from UICR
- *          will act as the page beyond the end of the available flash storage
- */
-#define FS_PAGE_END_ADDR  fs_flash_page_end_addr()
-
-
-/**@brief Macro to describe the write
- *
- */
-#if defined (NRF51)
-    #define FS_MAX_WRITE_SIZE_WORDS	    (256)
-#elif defined (NRF52)
-    #define FS_MAX_WRITE_SIZE_WORDS     (1024)
-#else
-    #error "Device family must be defined. see nrf.h"
-#endif
-
-/** @} */
-
-#endif // FS_CONFIG_H__
-#endif
-
diff -r 36ad7c7d0400 -r 8c37a47ac34c modification/port_api.c
--- a/modification/port_api.c	Sun Feb 14 21:55:30 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,94 +0,0 @@
-#if 0
-/* mbed Microcontroller Library
- * Copyright (c) 2013 Nordic Semiconductor
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "port_api.h"
-#include "pinmap.h"
-#include "gpio_api.h"
-
-PinName port_pin(PortName port, int pin_n)
-{
-    return (PinName)(pin_n);
-}
-
-void port_init(port_t *obj, PortName port, int mask, PinDirection dir)
-{
-    obj->port = port;
-    obj->mask = mask;
-
-    obj->reg_out = &NRF_GPIO->OUT;
-    obj->reg_in  = &NRF_GPIO->IN;
-    obj->reg_cnf = NRF_GPIO->PIN_CNF;
-
-    port_dir(obj, dir);
-}
-
-void port_mode(port_t *obj, PinMode mode)
-{
-    uint32_t i;
-    // The mode is set per pin: reuse pinmap logic
-    for (i = 0; i<31; i++) {
-        if (obj->mask & (1 << i)) {
-            pin_mode(port_pin(obj->port, i), mode);
-        }
-    }
-}
-
-void port_dir(port_t *obj, PinDirection dir)
-{
-    int i;
-    switch (dir) {
-    case PIN_INPUT:
-        for (i = 0; i<31; i++) {
-            if (obj->mask & (1 << i)) {
-                obj->reg_cnf[i] = (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos)
-                                    | (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos)
-                                    | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos)
-                                    | (GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos);
-            }
-        }
-        break;
-    case PIN_OUTPUT:
-        for (i = 0; i<31; i++) {
-            if (obj->mask & (1 << i)) {
-                obj->reg_cnf[i] = (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos)
-                                    | (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos)
-                                    | (GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos)
-                                    | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos)
-                                    | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos);
-            }
-        }
-        break;
-    }
-}
-
-// January 30th, 2016 modified by JH1PJL    --- from here ---
-void port_write(port_t *obj, int value)
-{
-#if 0
-    *obj->reg_out = value;
-#else
-    *obj->reg_out = (*obj->reg_out & ~obj->mask) | (value & obj->mask);
-#endif
-}
-//                                          ---- to here ---
-
-int port_read(port_t *obj)
-{
-    return (*obj->reg_in);
-}
-
-#endif
-
diff -r 36ad7c7d0400 -r 8c37a47ac34c modification/system_nrf51.c
--- a/modification/system_nrf51.c	Sun Feb 14 21:55:30 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,197 +0,0 @@
-#if 0
-/* Copyright (c) 2013, Nordic Semiconductor ASA
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   * Redistributions of source code must retain the above copyright notice, this
- *     list of conditions and the following disclaimer.
- *
- *   * Redistributions in binary form must reproduce the above copyright notice,
- *     this list of conditions and the following disclaimer in the documentation
- *     and/or other materials provided with the distribution.
- *
- *   * Neither the name of Nordic Semiconductor ASA nor the names of its
- *     contributors may be used to endorse or promote products derived from
- *     this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-/* NOTE: Template files (including this one) are application specific and therefore expected to
-   be copied into the application project folder prior to its use! */
-
-#include <stdint.h>
-#include <stdbool.h>
-#include "nrf.h"
-#include "nrf_delay.h"
-#include "system_nrf51.h"
-
-/*lint ++flb "Enter library region" */
-
-// January 30th, 2016 modified by JH1PJL    --- from here ---
-#define TARGET_NRF_32MHZ_XTAL
-//#if defined(TARGET_NRF_32MHZ_XTAL)
-//#define __SYSTEM_CLOCK      (32000000UL)     /*!< nRF51 devices use a fixed System Clock Frequency of 32MHz */
-//#else
-#define __SYSTEM_CLOCK      (16000000UL)     /*!< nRF51 devices use a fixed System Clock Frequency of 16MHz */
-//#endif
-//                                          ---- to here ---
-
-static bool is_manual_peripheral_setup_needed(void);
-static bool is_disabled_in_debug_needed(void);
-static void init_clock(void);
-
-
-#if defined ( __CC_ARM )
-    uint32_t SystemCoreClock __attribute__((used)) = __SYSTEM_CLOCK;
-#elif defined ( __ICCARM__ )
-    __root uint32_t SystemCoreClock = __SYSTEM_CLOCK;
-#elif defined   ( __GNUC__ )
-    uint32_t SystemCoreClock __attribute__((used)) = __SYSTEM_CLOCK;
-#endif
-
-void SystemCoreClockUpdate(void)
-{
-    SystemCoreClock = __SYSTEM_CLOCK;
-}
-
-void SystemInit(void)
-{
-#if defined(TARGET_NRF_32MHZ_XTAL)
-    /* For 32MHz HFCLK XTAL such as Taiyo Yuden
-       Physically, tiny footprint XTAL oscillate higher freq. To make BLE modules smaller, some modules
-       are using 32MHz XTAL.
-       This code wriging the value 0xFFFFFF00 to the UICR (User Information Configuration Register)
-       at address 0x10001008, to make nRF51 works with 32MHz system clock. This register will be overwritten
-       by SoftDevice to 0xFFFFFFFF, the default value. Each hex files built with mbed classic online compiler
-       contain SoftDevice, so that, this code run once just after the hex file will be flashed onto nRF51.
-       After changing the value, nRF51 need to reboot. */
-    if (*(uint32_t *)0x10001008 == 0xFFFFFFFF)
-    {
-        NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
-        while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
-        *(uint32_t *)0x10001008 = 0xFFFFFF00;
-        NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
-        while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
-        NVIC_SystemReset();
-        while (true){}
-    }
-#endif
-
-    /* If desired, switch off the unused RAM to lower consumption by the use of RAMON register.
-       It can also be done in the application main() function. */
-
-    /* Prepare the peripherals for use as indicated by the PAN 26 "System: Manual setup is required
-       to enable the use of peripherals" found at Product Anomaly document for your device found at
-       https://www.nordicsemi.com/. The side effect of executing these instructions in the devices
-       that do not need it is that the new peripherals in the second generation devices (LPCOMP for
-       example) will not be available. */
-    if (is_manual_peripheral_setup_needed())
-    {
-        *(uint32_t volatile *)0x40000504 = 0xC007FFDF;
-        *(uint32_t volatile *)0x40006C18 = 0x00008000;
-    }
-
-    /* Disable PROTENSET registers under debug, as indicated by PAN 59 "MPU: Reset value of DISABLEINDEBUG
-       register is incorrect" found at Product Anomaly document four your device found at
-       https://www.nordicsemi.com/. There is no side effect of using these instruction if not needed. */
-    if (is_disabled_in_debug_needed())
-    {
-        NRF_MPU->DISABLEINDEBUG = MPU_DISABLEINDEBUG_DISABLEINDEBUG_Disabled << MPU_DISABLEINDEBUG_DISABLEINDEBUG_Pos;
-    }
-
-    // Start the external 32khz crystal oscillator.
-    init_clock();
-}
-
-void init_clock(void)
-{
-    /* For compatibility purpose, the default behaviour is to first attempt to initialise an
-       external clock, and after a timeout, use the internal RC one. To avoid this wait, boards that
-       don't have an external oscillator can set TARGET_NRF_LFCLK_RC directly. */
-    uint32_t i = 0;
-    const uint32_t polling_period = 200;
-    const uint32_t timeout = 1000000;
-
-#if defined(TARGET_NRF_LFCLK_RC)
-    NRF_CLOCK->LFCLKSRC             = (CLOCK_LFCLKSRC_SRC_RC << CLOCK_LFCLKSRC_SRC_Pos);
-#else
-    NRF_CLOCK->LFCLKSRC             = (CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos);
-#endif
-    NRF_CLOCK->EVENTS_LFCLKSTARTED  = 0;
-    NRF_CLOCK->TASKS_LFCLKSTART     = 1;
-
-    /* Wait for the external oscillator to start up.
-       nRF51822 product specification (8.1.5) gives a typical value of 300ms for external clock
-       startup duration, and a maximum value of 1s. When using the internal RC source, typical delay
-       will be 390µs, so we use a polling period of 200µs.
-
-       We can't use us_ticker at this point, so we have to rely on a less precise method for
-       measuring our timeout. Because of this, the actual timeout will be slightly longer than 1
-       second, which isn't an issue at all, since this fallback should only be used as a safety net.
-       */
-    for (i = 0; i < (timeout / polling_period); i++) {
-        if (NRF_CLOCK->EVENTS_LFCLKSTARTED != 0)
-            return;
-        nrf_delay_us(polling_period);
-    }
-
-    /* Fallback to internal clock. Belt and braces, since the internal clock is used by default
-       whilst no external source is running. This is not only a sanity check, but it also allows
-       code down the road (e.g. ble initialisation) to directly know which clock is used. */
-    NRF_CLOCK->LFCLKSRC         = (CLOCK_LFCLKSRC_SRC_RC << CLOCK_LFCLKSRC_SRC_Pos);
-    NRF_CLOCK->TASKS_LFCLKSTART = 1;
-    while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0) {
-        // Do nothing.
-    }
-}
-
-static bool is_manual_peripheral_setup_needed(void)
-{
-    if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x1) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0))
-    {
-        if ((((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x00) && (((*(uint32_t *)0xF0000FEC) & 0x000000F0) == 0x0))
-        {
-            return true;
-        }
-        if ((((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x10) && (((*(uint32_t *)0xF0000FEC) & 0x000000F0) == 0x0))
-        {
-            return true;
-        }
-        if ((((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x30) && (((*(uint32_t *)0xF0000FEC) & 0x000000F0) == 0x0))
-        {
-            return true;
-        }
-    }
-
-    return false;
-}
-
-static bool is_disabled_in_debug_needed(void)
-{
-    if ((((*(uint32_t *)0xF0000FE0) & 0x000000FF) == 0x1) && (((*(uint32_t *)0xF0000FE4) & 0x0000000F) == 0x0))
-    {
-        if ((((*(uint32_t *)0xF0000FE8) & 0x000000F0) == 0x40) && (((*(uint32_t *)0xF0000FEC) & 0x000000F0) == 0x0))
-        {
-            return true;
-        }
-    }
-
-    return false;
-}
-
-/*lint --flb "Leave library region" */
-#endif
-
diff -r 36ad7c7d0400 -r 8c37a47ac34c nRF51822.lib
--- a/nRF51822.lib	Sun Feb 14 21:55:30 2016 +0000
+++ b/nRF51822.lib	Sun Jan 08 04:36:55 2017 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/teams/Nordic-Semiconductor/code/nRF51822/#1751e2e2637a
+http://mbed.org/teams/Nordic-Semiconductor/code/nRF51822/#c90ae1400bf2
diff -r 36ad7c7d0400 -r 8c37a47ac34c nRF51_Vdd.lib
--- a/nRF51_Vdd.lib	Sun Feb 14 21:55:30 2016 +0000
+++ b/nRF51_Vdd.lib	Sun Jan 08 04:36:55 2017 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/users/kenjiArai/code/nRF51_Vdd/#11c9f031975d
+http://developer.mbed.org/users/kenjiArai/code/nRF51_Vdd/#9b1e219a7695