jamesmunns / nrf52dk-sys

A Rust Crate to develop on the Nordic nRF52-DK
MIT License
85 stars 19 forks source link

`nrf52` and `nrf52-hal` vs `nrf52dk-sys` #14

Closed xieyuheng closed 5 years ago

xieyuheng commented 5 years ago

Hi James :)

I am new to embedded rust world.

Just watched your video :: Bootstrapping Embedded Development in Rust @ Rust DC, June 15, 2017 I saw you used nrf52dk-sys (this repo) there, while in your repos I saw nrf52 and nrf52-hal.

Are the later two preferred crates for new developers now ?

jamesmunns commented 5 years ago

Hey @xieyuheng, welcome to the embedded rust world :)

In general, this crate (nrf52dk-sys) is based on the C code provided by Nordic. This is nice, because you don't have to rewrite those drivers from scratch, and it is possible to use the SoftDevice to control the bluetooth components of the nrf52. The down side is that because these drivers were written for C, you will either need to use unsafe {} to interact with them, or you will need to make your own safe abstraction over them.

The other crates you mentioned are an attempt to start from the beginning in a pure-rust approach. This makes it easier to write only rust code with less unsafe, but we haven't implemented very many features yet. These crates also do not have any way to interact with the bluetooth hardware yet. In the near future, the nrf52 and nrf52-hal crates will be moving here: https://github.com/nrf-rs .

I hope that helps, let me know if you have any more questions!

xieyuheng commented 5 years ago

Thank you James, for explaining :)

Closing this issue for now ~

I might have much more questions about embedded rust. I plan to build a device to store private key in a safe way -- maybe can be used as bitcoin cold wallet ~