Code Monkey home page Code Monkey logo

nrf51-hal's People

Contributors

ctz avatar droogmic avatar guncha avatar jeremystucki avatar jonas-schievink avatar mattheww avatar miek avatar nemo157 avatar simonsso avatar stephanh avatar therealprof avatar wez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

nrf51-hal's Issues

GPIO.split() claims to produce PINnn<Input<Floating>> but doesn't enable the input buffer

GPIO.split() returns a Parts struct, whose members have types like PIN0<Input<Floating>>:
https://docs.rs/nrf51-hal/0.6.2/nrf51_hal/gpio/gpio/struct.Parts.html

This means its members claim to implement the embedded_hal::digital::InputPin trait, and so the compiler will let you call is_high() and is_low() on them.

But split() doesn't do anything to enable the input buffer for each pin (which is disabled by default), so these calls won't return meaningful information until you explicitly call one of the .into_xxx_input() methods.

In general the typestate system for these PIN types means the compiler prevents you making mistakes like this, so I think it would be better to either

  • have split() reconfigure all the pins as floating input; or
  • have a third mode for the PIN types which doesn't implement either input or output traits, and have Parts use those types.

The second change isn't fully backwards compatible, but if it makes a program stop compiling it's probably revealing a bug.

There's also a weakness that nothing stops you arbitrarily configuring the GPIO pins before calling split(), leading to another way for the typestates to get out of sync with the hardware. Either of the changes above would remove that weakness too.

serial::Write implementation is blocking

Opening this issue to avoid polluting rust-embedded/nb#13 with too much device specific discussion.


The current impl embedded_hal::serial::Write for Tx<UART0> is blocking, the easy implementation of

fn write(&mut self, byte: u8) -> nb::Result<(), !> {
    let uart = unsafe { &*UART0::ptr() };
    if uart.events_txdrdy.read().bits() == 1 {
         uart.events_txdrdy.reset();
         uart.txd.write(|w| unsafe { w.bits(u32::from(byte)) });
         Ok(())
    } else {
        Err(nb::Error::WouldBlock)
    }
}

doesn't work because events_txdrdy is only set after a byte is transmitted, not when the peripheral is first enabled. It doesn't appear to be possible to manually set event registers as well.

nRF91 support?

I have some changes which add support for the nRF9160 (UART and GPIO I think - not sure I did anything else). If I can get permission to publish them, would you like to add them here, or create an nrf91-hal? Or create an nrf-hal?

I also have github.com/thejpster/nrfxlib-sys, which generates bindings for the Nordic nrfxlib BSD library, which provides the socket API for the nRF9160. Would you like to host that in this org too, or shall I put it in rust-embedded-community?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.