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.
main.cpp
00001 #include "mbed.h" 00002 00003 #define BCSP 0 00004 00005 //I2C acp(p9, p10); 00006 Serial serBT(p28,p27); 00007 Serial serPC(USBTX,USBRX); 00008 00009 InterruptIn intCD(p22); 00010 00011 DigitalOut ledBT(LED1); 00012 DigitalOut ledDAT(LED2); 00013 DigitalOut ledCD0(LED3); 00014 DigitalOut ledCD(LED4); 00015 00016 DigitalOut outBTRES(p24); 00017 DigitalOut outDTR(p23); 00018 00019 Timeout toBTled; 00020 00021 void timeoutBt(void) 00022 { 00023 ledBT = 0; 00024 } 00025 00026 void goOffline( void ) 00027 { 00028 serPC.printf("CMD\n"); 00029 outDTR = 1; 00030 wait(0.10); 00031 outDTR = 0; 00032 //serPC.printf("DTR = %u\n",outDTR.read() ); 00033 } 00034 00035 void onCDUp(void) 00036 { 00037 ledCD = 1; 00038 serPC.printf("CD up\n"); 00039 } 00040 00041 void onCDDn(void) 00042 { 00043 ledCD = 0; 00044 serPC.printf("CD dn\n"); 00045 } 00046 00047 void ledBTOn(void) 00048 { 00049 ledBT = 1; 00050 toBTled.attach(timeoutBt,0.1); 00051 } 00052 00053 void resetBT(void) 00054 { 00055 outBTRES = 1; 00056 wait(0.010); 00057 outBTRES = 0; 00058 } 00059 00060 int main() { 00061 serPC.baud(115200); 00062 serBT.baud(115200); 00063 00064 //serBT.format( 8, Serial::Even, 1 ); 00065 // serBT.format( 8, Serial::None, 1 ); 00066 00067 serPC.format( 8, Serial::Even, 1 ); 00068 00069 intCD.rise(onCDUp); 00070 intCD.fall(onCDDn); 00071 ledBT = 0; 00072 00073 serPC.printf("Mbed starting\n"); 00074 resetBT(); 00075 00076 wait(0.5); 00077 serBT.printf("INFO\n"); 00078 00079 while(1) { 00080 char c; 00081 00082 if(serPC.readable()) { 00083 c = serPC.getc(); 00084 #if !BCSP 00085 if ( c == 0x1B ) 00086 goOffline(); 00087 else 00088 #endif 00089 { 00090 ledBTOn(); 00091 serBT.putc(c); 00092 } 00093 } 00094 00095 if(serBT.readable()) { 00096 ledBTOn(); 00097 c = serBT.getc(); 00098 serPC.putc(c); 00099 } 00100 } 00101 } 00102
Generated on Sat Jul 16 2022 17:58:02 by
1.7.2