![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
USART RX Interrupt
main.cpp
- Committer:
- thinkfire
- Date:
- 2017-01-20
- Revision:
- 0:39c8feff805f
File content as of revision 0:39c8feff805f:
#include "mbed.h" #include "string.h" #include "stdio.h" DigitalOut led2(LED2); DigitalOut led3(LED3); Serial device(p9, p10); // tx, rx char msgPC[20],msgDEV[20]; void serialRXmon(){ char msg1[] = "Your msg-> ",msg[30]; msg[0] = '\0'; int i=0; while(msgDEV[i-1]!=0x0D){ msgDEV[i] = device.getc(); i++; led3 = 1; } msgDEV[i] = '\0'; strcat(msg,msg1); strcat(msg,msgDEV); device.puts(msg); led3 = 0; device.getc(); } int main() { int adcVal; device.attach(&serialRXmon); while(1) { adcVal = rand()%255+1; sprintf(msgPC,"adcVal -> %d\n",adcVal); if(device.writeable()) { device.puts(msgPC); } led2 = 1; wait(1); led2 = 0; wait(1); } }