DipCortex USB CDC + EEprom

Dependencies:   DipCortex-EEprom USBDevice mbed

Fork of DipCortex-USB-EEProm by Carl - SolderSplash Labs

main.cpp

Committer:
SolderSplashLabs
Date:
2013-11-01
Revision:
1:b9eededaba19
Parent:
0:8c4eea221dcf
Child:
2:ec470dd97c6e

File content as of revision 1:b9eededaba19:

/**
 * USB to UART Bridge
 */
 
#include "mbed.h"
#include "USBSerial.h"

//Serial uart(USBTX, USBRX);
Serial uart(p19, p20);
USBSerial pc;

// Called by ISR
void settingsChanged(int baud, int bits, int parity, int stop)
{
    const Serial::Parity parityTable[] = {Serial::None, Serial::Odd, Serial::Even, Serial::Forced0, Serial::Forced1};
    
    if (stop != 2) {
        stop = 1;   // stop bit(s) = 1 or 1.5
    }
    
    uart.baud(baud);
    uart.format(bits, parityTable[parity], stop);
}

int main()
{
    pc.attach(settingsChanged);
    
    while (1) {
        while (uart.readable()) {
           pc.putc(uart.getc());
        }
        
        while (pc.readable()) {
            uart.putc(pc.getc());
        }
    }
}