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.
test_mode.cpp
00001 #include "mbed.h" 00002 00003 extern Serial pc; 00004 00005 00006 char test_char = 0; 00007 int test = 1; 00008 00009 void get_char() { 00010 test_char = pc.getc(); 00011 if(test_char == 's') test=0; 00012 pc.printf("\n\r"); 00013 } 00014 00015 void testmode() { 00016 DigitalOut sda(p9,1); 00017 DigitalOut scl(p10,1); 00018 LPC_PINCON->PINMODE_OD0 = (LPC_PINCON->PINMODE_OD0 | 0x0003); // To make p9 & P10 open_drain 00019 Timer timer1; 00020 test = 1; 00021 test_char = 0; 00022 pc.printf("\n\n\r\tStarting test-mode pattern generation ...\n\r"); 00023 pc.printf("\n\n\r\tEnter 's' to stop test-mode: "); 00024 pc.attach(&get_char); //interupt looking for character entry 00025 timer1.start(); 00026 while(test) { 00027 while(timer1.read_us()<300) { 00028 } 00029 sda=0; 00030 while(timer1.read_us()<600) { 00031 } 00032 scl=0; 00033 while(timer1.read_us()<900) { 00034 } 00035 sda=1; 00036 while(timer1.read_us()<950) { 00037 } 00038 scl=1; 00039 while(timer1.read_us()<1200) { 00040 } 00041 timer1.reset(); 00042 } 00043 timer1.stop(); 00044 scl=1; 00045 sda=1; 00046 pc.printf("\n\n\r\t....test-mode pattern generation stopped\n\n\r"); 00047 sda.~DigitalOut(); 00048 scl.~DigitalOut(); 00049 pc.attach(NULL); 00050 return; 00051 }
Generated on Wed Jul 13 2022 07:54:48 by
