any other techniques you recommend to achieve a balance in my library design for I2C, SPI, and GPIO

Hi Everyone @Middleware & OS I'm developing a device library for various I2C, SPI, and GPIO sensors and actuators. My goal is to achieve hardware independence, allowing the library to work seamlessly across different MCUs like the Arduino family or STM32 with minimal code changes. I'm considering two approaches: 1. A Callback System: Close to the u8x8 library, users define functions to handle specific hardware interactions like reading sensor data. Offers flexibility but might be complex. 2. With i2C Sharing: Allows sharing the I2C communication bus with other libraries, potentially simplifying integration. I don't know if it might limit functionality for some specialized sensors or actuators. Considering the trade-offs between ease of use and versatility, are there any other techniques you recommend to achieve a balance in my library design for I2C, SPI, and GPIO communication? Greetings Devs,Please help me out with your opinion (s)🙏
2 Replies
barafael
barafael7mo ago
@UC GEE you ask for opinion 😄 it is a solved problem: https://crates.io/crates/embedded-hal-async
UC GEE
UC GEE7mo ago
Thanks @barafael 😊😊😊...I really appreciate 💯
Want results from more Discord servers?
Add your server