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 #pragma import __use_all_ctype 00002 00003 #include "mbed.h" 00004 #include <stdlib.h> 00005 00006 Serial pc(USBTX, USBRX); 00007 Serial pi(p9, p10); // tx, rx 00008 00009 bool f_rcev = 0; 00010 unsigned int c_rcev = 0; 00011 char uartBuff[1000]; 00012 char uartRcev[1000]; 00013 00014 void callback() { 00015 char buf = 0; 00016 00017 buf = pi.getc(); 00018 uartBuff[c_rcev] = buf; 00019 if(uartBuff[c_rcev] == '\r' ) 00020 { 00021 uartBuff[c_rcev+1] = 0; 00022 memcpy(uartRcev,uartBuff,sizeof(uartRcev) ); 00023 memset(uartBuff,0,sizeof(uartBuff)); 00024 c_rcev = 0; 00025 f_rcev = 1; 00026 } 00027 else 00028 { 00029 c_rcev++; 00030 } 00031 } 00032 00033 int main(void) { 00034 00035 pi.baud(115200); 00036 pc.baud(115200); 00037 pi.attach(&callback); 00038 00039 while (1) 00040 { 00041 if(f_rcev == 1) 00042 { 00043 // printf("\033[2J"); 00044 // printf("\033[1;1H"); 00045 // printf("%s\r\n",uartRcev); 00046 puts(uartRcev); 00047 f_rcev = 0; 00048 } 00049 } 00050 }
Generated on Mon Jul 18 2022 08:53:45 by
1.7.2