Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
7 years, 10 months ago.
MODSERIAL - print buffer
Hello,
I am trying simple code for my GPS and I would like to use MODSERIAL interrupt but I do not know how to print uart buffer to USBSerial. Could You help me ?
#include "mbed.h" #include "USBSerial.h" #include "MODSERIAL.h" #include "at25sf041.h" DigitalOut LedStatus(P0_13); DigitalOut LedRX(P0_14); DigitalOut USB_connect(P0_6); AnalogIn ain(P0_11); USBSerial usb(0x1f00, 0x2012, 0x0001, false); DigitalIn Vbus(P0_3); AT25SF041 memory(P0_9, P0_8, P0_10, P0_15); MODSERIAL uart(P0_19, P0_18); InterruptIn GPS_fix(P0_17); volatile bool newline_detected = false; void Rx_interrupt(MODSERIAL_IRQ_INFO *q) { MODSERIAL *serial = q->serial; if ( serial->rxGetLastChar() == '\n') { newline_detected = true; } LedRX= !LedRX; } void toogle() { LedStatus = !LedStatus; } int main(){ USB_connect = 0; GPS_fix.rise(&toogle); uart.baud(9600); uart.attach(&Rx_interrupt, MODSERIAL::RxIrq); while (! newline_detected) { usb.putc(uart.getc()); } }