uart-0

xod/uart/uart-0

Constructor of HardwareUart, provides serial communication through Serial.
uart-0
@/uart-0
Constructor of HardwareUart, provides serial communication through Serial.
BAUDnumber
Speed of data transmission in bits per second (baud rate).
INITpulse
Begin UART communication
uart-0
BAUD
INIT
UART
DONE
DONEpulse
Pulses when UART communication began
UART@/uart
An UART object

C++ implementation

struct State {
    uint8_t mem[sizeof(HardwareUart)];
    HardwareUart* uart;
};

// clang-format off
{{ GENERATED_CODE }}
// clang-format on

void evaluate(Context ctx) {
    auto state = getState(ctx);

    if (isSettingUp()) {
        state->uart = new (state->mem) HardwareUart(Serial, (uint32_t)getValue<input_BAUD>(ctx));
        emitValue<output_UART>(ctx, state->uart);
    }

    if (isInputDirty<input_INIT>(ctx)) {
        state->uart->begin();
        emitValue<output_DONE>(ctx, 1);
    }
}