change-baud-rate

xod/uart/change-baud-rate

Changes baud rate of passed UART object. If UART already has started communication it will end it up and begin again with new baud rate.
change-baud-rate
@/change-baud-rate
Changes baud rate of passed UART object. If UART already has started communication it will end it up and begin again with new baud rate.
UART@/uart
An UART object
BAUDnumber
A new baud rate to set
UPDpulse
Trigger update baud rate
change-baud-rate
UART
BAUD
UPD
DONE
DONEpulse
Pulses when baud rate changed

C++ implementation

#pragma XOD evaluate_on_pin disable
#pragma XOD evaluate_on_pin enable input_UPD

node {
    void evaluate(Context ctx) {
        if (!isInputDirty<input_UPD>(ctx))
            return;

        auto uart = getValue<input_UART>(ctx);
        long baud = (long)getValue<input_BAUD>(ctx);
        uart->changeBaudRate(baud);
        emitValue<output_DONE>(ctx, 1);
    }
}