fj2020 Geschrieben May 16, 2022 at 15:26 Geschrieben May 16, 2022 at 15:26 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. Zitieren
rtrbt Geschrieben May 17, 2022 at 07:47 Geschrieben May 17, 2022 at 07:47 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. Zitieren
fj2020 Geschrieben May 18, 2022 at 07:48 Autor Geschrieben May 18, 2022 at 07:48 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? Zitieren
borg Geschrieben May 18, 2022 at 08:19 Geschrieben May 18, 2022 at 08:19 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 Zitieren
rtrbt Geschrieben May 18, 2022 at 08:21 Geschrieben May 18, 2022 at 08:21 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). Zitieren
fj2020 Geschrieben May 18, 2022 at 11:30 Autor Geschrieben May 18, 2022 at 11:30 Ok, That sets it. Thanks a lot... Zitieren
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.