Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
debug_lpc1768.cpp
00001 /* 00002 * mbed Application program 00003 * 00004 * Copyright (c) 2010-2014 Kenji Arai / JH1PJL 00005 * http://www.page.sannet.ne.jp/kenjia/index.html 00006 * http://mbed.org/users/kenjiArai/ 00007 * Created: May 15th, 2010 00008 * Spareted: June 25th, 2014 mon() & mon_hw() 00009 * Ported: September 22nd, 2014 from L152RE, LP1114 00010 * changed: October 15th, 2014 mon.cpp to debug_xxx.cpp 00011 * Revised: Nobember 2nd, 2014 00012 * 00013 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 00014 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE 00015 * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 00016 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00017 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00018 */ 00019 00020 #if defined(TARGET_LPC1768) 00021 00022 // Include --------------------------------------------------------------------------------------- 00023 #include "mbed.h" 00024 #include "debug_common.h" 00025 00026 // Object ---------------------------------------------------------------------------------------- 00027 DigitalOut myled1(LED1); 00028 DigitalOut myled2(LED2); 00029 DigitalOut myled3(LED3); 00030 DigitalOut myled4(LED4); 00031 00032 // Definition ------------------------------------------------------------------------------------ 00033 00034 // RAM ------------------------------------------------------------------------------------------- 00035 00036 // ROM / Constant data --------------------------------------------------------------------------- 00037 00038 // Function prototypes --------------------------------------------------------------------------- 00039 extern void cpu_inf (void); 00040 00041 //------------------------------------------------------------------------------------------------- 00042 // Control Program 00043 //------------------------------------------------------------------------------------------------- 00044 // Help Massage 00045 void msg_hlp (void) 00046 { 00047 PRINTF(mon_msg); 00048 put_rn(); 00049 PRINTF("1 - goto step1 -> no connection all pins"); 00050 put_rn(); 00051 PRINTF("2 - goto step2 -> connects pin_x and pin_y"); 00052 put_rn(); 00053 PRINTF("t - Check and set RTC"); 00054 put_rn(); 00055 PRINTF("x - Goto HW monitor"); 00056 put_rn(); 00057 PRINTF("q - Return to main"); 00058 put_rn(); 00059 } 00060 00061 // ---------- Program starts here! --------------------------------------------------------------- 00062 void debug_interface(void) 00063 { 00064 char c; 00065 char *ptr; 00066 uint8_t quitflag; 00067 00068 BAUD(BAUD_RATE); 00069 put_rn(); 00070 put_rn(); 00071 PRINTF("%s [Help:'?' key]", mon_msg); 00072 put_rn(); 00073 get_freq(0); 00074 for (;;) { 00075 put_r(); 00076 PUTC('>'); 00077 ptr = linebuf; 00078 get_line(ptr, sizeof(linebuf)); 00079 switch (*ptr++) { 00080 //--------------------------------------------------------------------------------- 00081 // Debug Step1 00082 //--------------------------------------------------------------------------------- 00083 case '1' : 00084 put_r(); 00085 PRINTF("Enter Step1: no connection all pins"); 00086 put_rn(); 00087 quitflag = 0; 00088 for (; quitflag != 0xff;) { 00089 PRINTF("1>"); 00090 ptr = linebuf; 00091 get_line(ptr, buf_size); 00092 put_r(); 00093 switch(*ptr++) { 00094 case 'l' : 00095 myled1 = 1; 00096 wait(0.1); 00097 myled1 = 0; 00098 myled2 = 1; 00099 wait(0.1); 00100 myled2 = 0; 00101 myled3 = 1; 00102 wait(0.1); 00103 myled3 = 0; 00104 myled4 = 1; 00105 wait(0.1); 00106 myled4 = 0; 00107 myled1 = 1; 00108 wait(0.2); 00109 myled2 = 1; 00110 wait(0.2); 00111 myled3 = 1; 00112 wait(0.2); 00113 myled4 = 1; 00114 PRINTF("Is LED on? -> enter y/n"); 00115 put_rn(); 00116 c = GETC(); 00117 if (c == 'y') { 00118 PRINTF("Okay"); 00119 } else { 00120 PRINTF("Are you sure? Check again!"); 00121 for (c = 0; c < 10; c++) { 00122 myled1 = !myled1; 00123 wait(0.1); 00124 myled2 = !myled2; 00125 wait(0.1); 00126 myled3 = !myled3; 00127 wait(0.1); 00128 myled4 = !myled4; 00129 wait(0.1); 00130 } 00131 myled1 = 1; 00132 myled2 = 1; 00133 myled3 = 1; 00134 myled4 = 1; 00135 put_rn(); 00136 PRINTF("Is LED on? -> enter y/n"); 00137 put_rn(); 00138 c = GETC(); 00139 if (c == 'y') { 00140 PRINTF("Looks okay"); 00141 } else { 00142 PRINTF("Please check LED line"); 00143 } 00144 } 00145 put_rn(); 00146 myled1 = 0; 00147 myled2 = 0; 00148 myled3 = 0; 00149 myled4 = 0; 00150 break; 00151 case 's' : 00152 PRINTF("----- CPU CLOCK Information -----"); 00153 put_rn(); 00154 get_freq(1); 00155 PRINTF("----- CPU TYPE Information ------"); 00156 put_rn(); 00157 cpu_inf(); 00158 break; 00159 case '?' : 00160 PRINTF("l - Check LED"); 00161 put_rn(); 00162 PRINTF("s - CPU system info & clock"); 00163 put_rn(); 00164 PRINTF("q - Return to all mode"); 00165 put_rn(); 00166 PRINTF("? - You know this"); 00167 put_rn(); 00168 break; 00169 case 'q' : // quit 00170 PRINTF("Back to all mode"); 00171 quitflag = 0xff; 00172 break; 00173 default: 00174 PUTC('?'); 00175 put_rn(); 00176 } 00177 } 00178 put_rn(); 00179 break; 00180 //--------------------------------------------------------------------------------- 00181 // check and set RTC 00182 //--------------------------------------------------------------------------------- 00183 case 't' : 00184 put_r(); 00185 chk_and_set_time(ptr); 00186 break; 00187 //--------------------------------------------------------------------------------- 00188 // help 00189 //--------------------------------------------------------------------------------- 00190 case '?' : 00191 put_r(); 00192 msg_hlp(); 00193 break; 00194 //--------------------------------------------------------------------------------- 00195 // Go to special command 00196 //--------------------------------------------------------------------------------- 00197 case 'x' : 00198 mon_hw(); 00199 PRINTF("->Came back monitor\r\n"); 00200 break; 00201 //--------------------------------------------------------------------------------- 00202 // Go back to main() 00203 //--------------------------------------------------------------------------------- 00204 case 'q' : // Quit 00205 PRINTF("\rReturn to main\r\n"); 00206 //PRINTF("cannot control anymore from here\r\n"); 00207 return; 00208 //--------------------------------------------------------------------------------- 00209 // no support 00210 //--------------------------------------------------------------------------------- 00211 default: 00212 put_r(); 00213 PUTC('?'); 00214 put_rn(); 00215 break; 00216 } 00217 } 00218 } 00219 00220 #endif // defined(TARGET_LPC1768)
Generated on Thu Jul 14 2022 02:12:15 by
1.7.2