The Oracle
The Oracle

Reputation: 81

How would I port Arduino C++ libraries to Rust Embedded (i.e. rp-hal)

Does anyone have any way I could port an Arduino C++ library like the Adafruit LIS3DH or Adafruit SSD1306 libraries to Rust Embedded especially for the RP2040?

I've got lots of external devices that I see aren't supported (yet!) by a library on the Rust Driver Crates. I suppose for smaller sensors like my LIS3DH, I'm confident enough in Rust embedded to write a library (though I'm not sure how, any pointers would be appreciated) but I'm completely gone at rewriting something resembling Adafruits SSD1306. Thanks!

Upvotes: 0

Views: 182

Answers (1)

Clifford
Clifford

Reputation: 93556

Rather than needlessly translating all that working code from C++ to Rust (and then needing to extensively test and debug it), it would be more productive, and less error prone Probably easier, safer, more productive to wrap it in a Rust interop layer. C/Rust interop is well defined, and can be adapted for use with C++ (by utilising C/C++ interop) as an intermediate. Described in the Embedded Rust documentation: https://docs.rust-embedded.org/book/interoperability/c-with-rust.html.

Upvotes: 0

Related Questions