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.
Dependencies: mbed
COMM-RxTx.cpp
00001 #include "mbed.h" 00002 00003 DigitalOut led(LED1); 00004 DigitalOut Din(PB_9); 00005 Serial pc(USBTX, USBRX, 9600); // seriale di comunicazione con il PC. Associati a PA_11 e PA_12 00006 00007 // carattere in arrivo dal PC 00008 volatile unsigned char cReadChar; 00009 00010 00011 void RxInterrupt(void) 00012 { 00013 // ricevi caratteri su seriale, se disponibili 00014 while((pc.readable())) 00015 { 00016 // leggi carattere e riscrivi carattere su UART 00017 cReadChar = pc.getc(); 00018 pc.printf("\r\nRx [CHAR]: %c\n\r",cReadChar); 00019 pc.printf("Rx [HEX]: %#x\n\r", cReadChar); 00020 pc.printf("Rx [reverse BIN]: "); 00021 for(int i = 0; i< 8; i++) 00022 pc.printf("%d",((cReadChar>>i)&0x01)); 00023 pc.printf("\n\r"); 00024 00025 00026 } 00027 } 00028 00029 //+++++++++ 00030 // MAIN 00031 //+++++++++ 00032 int main() 00033 { 00034 pc.printf("\n\r*** Welcome TxRx ***\n\r"); 00035 00036 // definisci callback di IRQ 00037 pc.attach(&RxInterrupt,Serial::RxIrq); 00038 00039 // ciclo main 00040 while(true) 00041 { 00042 led = !led; // Toggle LED 00043 wait_ms(500); 00044 } 00045 }
Generated on Tue Jul 12 2022 13:49:54 by
1.7.2