craig Flanagan
/
Nucleo_blink_SERIAL_1_FOR_QUESTION
Serial Question
Diff: main.cpp
- Revision:
- 0:7229d855a74e
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Aug 23 22:00:28 2017 +0000 @@ -0,0 +1,65 @@ +#include "mbed.h" + +Serial dialog(PB_6, PB_7); +Serial pcc(USBTX, USBRX); +DigitalOut myled(LED1); + +char ch; +const int PACKET_SIZE = 3; +char dialog_RxBuf[PACKET_SIZE]; +volatile int dialog_RxLen = 0; +int index = 0; + +void dialog_Rx(void) +{ + wait(.4); + + if(dialog.readable()) + { + char c = dialog.getc(); + + switch(c) + { + case '*': + do + { + pcc.printf("\r\n stuck in this do loop..."); + if (dialog.readable()) // NOTE: NOT MAKING IT INTO THIS "IF" STATMENT + { + ch = dialog.getc(); // read it + if (index < PACKET_SIZE) // to avoid buffer overflow + dialog_RxBuf[index++]=ch; // put it into the value array and increment the index + pcc.printf("\r\n Did it make it in here?"); + } + } while (ch!='\n'); + break; + default: + pcc.putc(c); + break; + } + } + +} + + + +int main() +{ + dialog.baud(9600); + pcc.baud(9600); + dialog.attach(&dialog_Rx); // Attach UART receive interrupt + + + __disable_irq(); + + dialog.puts("*12\n"); // Put in a string in the UART buffer + wait(1); + + __enable_irq(); + + myled = 0; + wait(0.5); + myled = 1; + wait(0.5); +} +