RTIC. Is it able to use generic resources?

I use an RTIC for project on the STM32.
I need to store in the "local" struct some generic type. For example embedded_hal::blocking::i2c::Write + embedded_hal::blocking::i2c::WriteRead.
Is it able?


You will need to make your struct generic.

use embedded_hal::blocking::i2c::{Write, WriteRead};

struct MyDriver<I> {
    i2c: I,

impl<I> MyDriver<I>
    I: Write + WriteRead
    pub fn new(i2c: I) -> Self { MyDriver { i2c } }

    pub fn do_stuff(&mut self) -> Result<(), I::Error> {

In this case i need to store the MyDriver into the "local" as generic too.

    struct Local<I>
        driver: MyDriver<I>

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.