Hey everyone. I am trying to interface between a Teensy 3.2 and a stepper motor we use at my work with what I believe has a non-standard I2C protocol and I can't figure out how to construct the I2C functions. In the protocol we use, I have to send the following in a series of bytes:
- Byte 1: Device address
- Byte 2: Message length in bytes (6 bytes in this example)
- Byte 3: more config info
- Byte 4: Message code
- Byte 5 and 6: CRC-16 for the above 4 bytes.
The device will then respond with:
- Byte 1: Device Address
- Byte 2: return message length
- Byte 3: config info
- Byte 4: message code
- Byte 5 and 6: Return message CRC
I'm hung up because this all needs to happen as part of a single call, but the build-in Wire functions only allow for the address + number of bits to read, and no options to put in the other 5 fields mentioned above after the device address. The write function would let me write all this data and I could use endTransaction(), but when I go to use requestFrom(), it is going to rebroadcast the device address which doesn't follow the protocol, I'm supposed to start reading immediately after the 6th bytes in the first block of bytes. Is there a way to do this using the built-in functions, or would I need to write my own Wire functions which can send the bytes before starting the read portion?
- Byte 1: Device address
- Byte 2: Message length in bytes (6 bytes in this example)
- Byte 3: more config info
- Byte 4: Message code
- Byte 5 and 6: CRC-16 for the above 4 bytes.
The device will then respond with:
- Byte 1: Device Address
- Byte 2: return message length
- Byte 3: config info
- Byte 4: message code
- Byte 5 and 6: Return message CRC
I'm hung up because this all needs to happen as part of a single call, but the build-in Wire functions only allow for the address + number of bits to read, and no options to put in the other 5 fields mentioned above after the device address. The write function would let me write all this data and I could use endTransaction(), but when I go to use requestFrom(), it is going to rebroadcast the device address which doesn't follow the protocol, I'm supposed to start reading immediately after the 6th bytes in the first block of bytes. Is there a way to do this using the built-in functions, or would I need to write my own Wire functions which can send the bytes before starting the read portion?