nrf-rs / microbit

A Rust crate for BBC micro:bit development
BSD Zero Clause License
276 stars 61 forks source link

Add microbit v2 support #41

Closed robyoung closed 3 years ago

robyoung commented 3 years ago

Relates to #27

Adds support for the v2 micro:bit within the same crate using feature flags. There are two things I really don't like about this.

1. There are two different APIs but only one can be documented

On the micro:bit v2 the LED column pins are split across the P0 and P1 ports. On the micro:bit v1 there is only one port, P0. This means the APIs to create an LED driver have to be different between the versions. However, because the features are mutually exclusive we can only fully document one. We can add module documentation that covers the others API but that feels a bit weak.

2. The non-blocking LED driver is working, but I don't know how

I do not have a lot of experience with bit twiddling and I found refactoring the display::control hard. I have managed to get it working but there is one little bit that makes absolutely no sense to me.

To do (if we want to continue with this route)

So far I only have the LED examples working.

therealprof commented 3 years ago

bors ping

bors[bot] commented 3 years ago

pong

therealprof commented 3 years ago

bors try

therealprof commented 3 years ago

There's another problem which needs addressing. nrf52 will need a different memory.x. It might be time to give up the examples directly and turn this crate into a proper workspace with each program being their own member, similarly to how https://github.com/nrf-rs/nrf-hal/ works.

robyoung commented 3 years ago

I agree, I think following the nrf-hal approach would be good. It would solve the documentation issue as well. ~I'm not sure why that would mean we need to give up the examples directory. There seem to be examples in nrf-hal. Are the more difficult to manage?~ I see why examples are more difficult in nrf-hal 😞

Also, I haven't found that I need a different memory.x for building examples for the nrf52, when would I expect to see issues?

therealprof commented 3 years ago

Also, I haven't found that I need a different memory.x for building examples for the nrf52, when would I expect to see issues?

The nRF52833 has twice the amount of flash and 8 times the amount of memory. It is also a more powerful Cortex-M architecture which means that the generated code will be larger and the space required for e.g. the interrupt vectors is bigger. TL;DR it's much more likely you'll run out of flash/RAM with complex examples.

bors[bot] commented 3 years ago

try

Timed out.

robyoung commented 3 years ago

Closing in favour of #44