embed-rs / stm32f7-discovery

Apache License 2.0
30 stars 23 forks source link

Ownership based SD-RAM #95

Open oli-obk opened 5 years ago

oli-obk commented 5 years ago

@phil-opp what do you think? is this sort of handling ok?

phil-opp commented 5 years ago

From a quick look, this seems like a good improvement to me!

The use of [volatile::Volatile<u8>] might be a bit problematic for use cases where multiple bytes should be accessed at once. But at least it allows the user to use the remaining SDRAM capacity, so it's definitely an improvement.

Instead of taking and returning ownership of the sdram, we could introduce a SdramMemory wrapper type and borrow it. But that's just a small cosmetic suggestion.

oli-obk commented 5 years ago

Instead of taking and returning ownership of the sdram, we could introduce a SdramMemory wrapper type and borrow it. But that's just a small cosmetic suggestion.

I was considering that, but that would give all the users an additional lifetime. Alternatively we can give the memory to an allocator and see how well liballoc supports custom allocators

phil-opp commented 5 years ago

Ah, didn't think of that. How about something like this?

see how well liballoc supports custom allocators

I think this is not ready yet. AFAIK only raw_vec supports custom allocators right now.

oli-obk commented 5 years ago

Updated to be less hacky.