esp-rs / esp32-hal

A hardware abstraction layer for the esp32 written in Rust.
Apache License 2.0
192 stars 28 forks source link

GPIO Output #4

Closed MabezDev closed 4 years ago

MabezDev commented 4 years ago

PoC gpio driver for all output enabled pins using the embedded-hal traits

Example usage:

let dp = unsafe { esp32::Peripherals::steal() };
let pins = dp.GPIO.split();

let mut blinky = pins.gpio2.into_push_pull_output();

blinky.set_high().unwrap();
fmckeogh commented 4 years ago

😭 I should've checked the branches before I started working on this haha

Your implementation is much cleaner than mine anyway :D

MabezDev commented 4 years ago

Feel free to PR it still, I'm not sure this is the best way but from my limited testing it seems to work. Lots still to do though!

fmckeogh commented 4 years ago

Sure thing! I just pulled it and its working for me too, I was thinking of starting on I2C next?

MabezDev commented 4 years ago

I'm tackling GPIO first as its required for most of the other peripherals (UART, I2C, SPI, etc).

So for I2C may still need some more GPIO stuff for that, probably the ability to get the pin into open drain mode (easy), and also putting it into its alternate function mode so the I2C peripheral can use it (harder).

Unfortunately I can't merge this yet as I need to cut a new release of esp32 but I can't do that because of https://github.com/esp-rs/esp32/issues/17

fmckeogh commented 4 years ago

Ah I see, I can rebase my work on top of this branch and hopefully I won't have any major conflicts rebasing back onto master when this merges. In the meantime I can just use a local master build of the esp32 PAC.

Is there anything I could do to help out with esp-rs/esp32#17?

MabezDev commented 4 years ago

Ah I see, I can rebase my work on top of this branch and hopefully I won't have any major conflicts rebasing back onto master when this merges.

Sounds good.

In the meantime I can just use a local master build of the esp32 PAC

Yep, thats what I'm doing.

Is there anything I could do to help out with esp-rs/esp32#17?

I have a theory on what the problem is, just haven't had time to test it. I've left a comment in the issue if you would like to take a look.

fmckeogh commented 4 years ago

Initial implementation for input pins is now on my fork, working on alternate function mode and I2C now :)

MabezDev commented 4 years ago

Awesome! I'll try it out at the weekend.