begin-transmission

xod/i2c/begin-transmission

Begins a transmission to the I²C slave device. Possible errors: — Invalid I2C address
begin-transmission
@/begin-transmission
Begins a transmission to the I²C slave device. Possible errors: — Invalid I2C address
I2C@/i2c
I²C interface object
ADDRbyte
I²C address of the target slave device
SENDpulse
Triggers the transmission start
begin-transmission
I2C
ADDR
SEND
DONE
DONEpulse
Pulses when the transmission successfully starts. Chain it to a `write-byte` node.

C++ implementation

#pragma XOD evaluate_on_pin disable
#pragma XOD evaluate_on_pin enable input_SEND
#pragma XOD error_raise enable

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

        uint8_t addr = getValue<input_ADDR>(ctx);

        if (addr > 127) {
            raiseError(ctx); // Invalid I2C address
            return;
        }

        auto wire = getValue<input_I2C>(ctx);
        wire->beginTransmission(addr);
        emitValue<output_DONE>(ctx, 1);
    }
}