-
Notifications
You must be signed in to change notification settings - Fork 247
Closed
Description
From i2c.c:
void xs_i2c(xsMachine *the)
{
modI2CConfiguration i2c;
int sda, scl, address, hz = 0;
xsmcVars(1);
xsmcGet(xsVar(0), xsArg(0), xsID_sda);
sda = (xsUndefinedType == xsmcTypeOf(xsVar(0))) ? -1 : xsmcToInteger(xsVar(0));
xsmcGet(xsVar(0), xsArg(0), xsID_clock);
scl = (xsUndefinedType == xsmcTypeOf(xsVar(0))) ? -1 : xsmcToInteger(xsVar(0));
xsmcGet(xsVar(0), xsArg(0), xsID_address);
address = xsmcToInteger(xsVar(0));
if ((address < 0) || (address > 127))
xsUnknownError("invalid address");
if (xsmcHas(xsArg(0), xsID_hz)) {
xsmcGet(xsVar(0), xsArg(0), xsID_hz);
hz = xsmcToInteger(xsVar(0));
}
i2c = xsmcSetHostChunk(xsThis, NULL, sizeof(modI2CConfigurationRecord));
i2c->hz = hz;
i2c->sda = sda;
i2c->scl = scl;
i2c->address = address;
modI2CInit(i2c);
}If I was implementing an I2C driver, following the recommended examples given here: #12 (comment), and using the i2c.c as another reference of sorts, my intuition would be that the 4 known properties are: address, hz, sda & scl. The last two are especially intuitive, considering sda & scl are the standard names for the two wires in the i2c bus. So, if I was testing eg:
new Foo({
address: 0x20,
hz: 0,
sda: 4,
scl: 5,
})(or similar)
... I might expect that to work correctly, but I'd be completely wrong: there is no scl property because it's called clock.
I propose changing this to scl as soon as possible. If this is a desirable change, I'm willing to do the work
Metadata
Metadata
Assignees
Labels
No labels