News for hackers. Stuff that matters.
Re:Rust on Espressif chips – 2023 Roadmap by nextaccountic on Friday February 24, 2023 @12:56PM (#34927487)
I agree with a sibling comment point that Arduino's main strength is that it simplifies the installation of tooling, not that the code is particularly easy. But, on the code side, I think that embedded-hal is excellent

https://docs.rs/embedded-hal/latest/embedded_hal/

Here are the supported boards

https://github.com/rust-embedded/awesome-embedded-rust#hal-i...

There's a book on rust on esp https://esp-rs.github.io/book/

Here's how to blink a led using esp-idf-hal, targetting espressif

https://github.com/esp-rs/esp-idf-hal/blob/master/examples/b...

    /! Blinks an LED
    //!
    //! This assumes that a LED is connected to GPIO4.
    //! Depending on your target and the board you are using you should change the pin.
    //! If your board doesn't have on-board LEDs don't forget to add an appropriate resistor.
    //!

    use esp_idf_hal::delay::FreeRtos;
    use esp_idf_hal::gpio::*;
    use esp_idf_hal::peripherals::Peripherals;

    fn main() -> anyhow::Result<()> {
        esp_idf_sys::link_patches();

        let peripherals = Peripherals::take().unwrap();
        let mut led = PinDriver::output(peripherals.pins.gpio4)?;

        loop {
            led.set_high()?;
            // we are sleeping here to make sure the watchdog isn't triggered
            FreeRtos::delay_ms(1000);

            led.set_low()?;
            FreeRtos::delay_ms(1000);
        }
    }

There are no comments on this comment yet.