fj2020 Posted May 16, 2022 at 03:26 PM Share Posted May 16, 2022 at 03:26 PM Hello, I am working on a personal project using the Load Cell Bricklet V2 and I would like to know if the SPI protocol is described somewhere, so I can use an Arduino (with level converters) to talk to it. I could not find any description of the SPI protocol. Quote Link to comment Share on other sites More sharing options...
rtrbt Posted May 17, 2022 at 07:47 AM Share Posted May 17, 2022 at 07:47 AM Hi, You don't have to implement the SPI protocol yourself if you don't want to. Instead you can use the C/C++ bindings for microcontrollers. Those bindings implement the SPI-TFP protocol for you, so that you can use more or less the same API as with the normal C bindings. See for example here for the Load Cell Bricklet API. To use the bindings you have to use a Hardware Abstraction Layer (HAL) for your Arduino, but currently there is no generic one available. (We've released the bindings just some weeks ago). You basically have two options here: Patch the Arduino ESP32 Brick HAL or try to use the prototype Arduino HAL, however I'm not sure if this one works right now. If you really want to implement the SPI protocol yourself, you have to take a look at our implementations, as there currently is no documentation of the SPI protocol. The implementation used in the microcontroller bindings is here: https://github.com/Tinkerforge/generators/tree/master/uc (have a look at spitfp.h/.c) As a very short overview (so you know what to grep for ;) ): The SPI protocol (called SPITFP) wraps the TFP protocol that is also used over TCP. See here for the TFP protocol: https://www.tinkerforge.com/en/doc/Low_Level_Protocols/TCPIP.html and for example the Load Cell 2.0 packets: https://www.tinkerforge.com/en/doc/Software/Bricklets/LoadCellV2_Bricklet_TCPIP.html SPITFP consists of two header bytes, a wrapped TFP packet (if it is not only an ACK) and one footer byte: The packet length: 3 bytes for an acknowledgement or 11 to 83 bytes for a payload packet The sequence number of this packet (4 bit) and the sequence number that is acknowledged with this packet (also 4 bit) (Footer) A checksum over all packet bytes except this one. This is a Pearson hash . See here for an implementation Only one packet in flight is allowed in each direction. A bricklet will resend the last packet if you don't acknowledge it. Bricklets expect that you send a CoMCU-enumerate as first packet. If you don't, the bricklet will send a response for the enumerate by itself. Quote Link to comment Share on other sites More sharing options...
fj2020 Posted May 18, 2022 at 07:48 AM Author Share Posted May 18, 2022 at 07:48 AM Thanks for your answer. I think I can find my way through it. :-) Just 2 more questions: -how do I find the bricklet UID? -where do I find information about CoMCU-enumerate? Quote Link to comment Share on other sites More sharing options...
borg Posted May 18, 2022 at 08:19 AM Share Posted May 18, 2022 at 08:19 AM There is actually a small SPITFP protocol definition in the SPITFP implementation of the XMC Bootloader firmware source as a comment. Take a look here: https://github.com/Tinkerforge/brickletboot_xmc/blob/master/software/src/bootloader_spitfp.c Quote Link to comment Share on other sites More sharing options...
rtrbt Posted May 18, 2022 at 08:21 AM Share Posted May 18, 2022 at 08:21 AM 31 minutes ago, fj2020 said: -how do I find the bricklet UID? The bricklet returns its UID in the enumerate response. For the enumerate request you don't have to set a UID, but use 0 (or "1" if base58-encoded) 31 minutes ago, fj2020 said: -where do I find information about CoMCU-enumerate? This is basically the "normal" enumerate: https://www.tinkerforge.com/de/doc/Low_Level_Protocols/TCPIP.html#broadcast-functions but with another function ID (252). Quote Link to comment Share on other sites More sharing options...
fj2020 Posted May 18, 2022 at 11:30 AM Author Share Posted May 18, 2022 at 11:30 AM Ok, That sets it. Thanks a lot... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.