mtthw-meyer / libdaisy-rust

Hardware Abstraction Layer implementation for Daisy boards
MIT License
51 stars 18 forks source link

reorg #11

Closed x37v closed 3 years ago

x37v commented 3 years ago

I moved some things around and broke out the System::init functionality into separate methods that could be used without the big "batteries include" init.

For instance, if if you don't care about sdram or audio or gpio for some reason, or you want to run at a lower clock rate to save power, you could skip System::init and just initialize the things you want to use.

There is still plenty that could be cleaned up, but I figured I'd see if you're even interested in this before going much further.

FYI, I've only run some of the basic examples as I don't have a reasonable setup to test this on my current desk.

x37v commented 3 years ago

BTW, here's an example of MIDI branched off this DR.

https://github.com/x37v/libdaisy-rust/blob/xnor/reorg-midi/examples/midi.rs

I added a method to libdaisy to create a midi serial device because it is simple and probably useful for a bunch of folks, but with this new refactor, we wouldn't have to modify system in order to do this.

mtthw-meyer commented 3 years ago

Overall I like the idea of making it more modular and letting users pick which components to initialize. I'm not sure why they'd ever need to not use the clock setup . Making the plls have an Option<> for setting custom values on the free ones makes sense though.

x37v commented 3 years ago

I'm not sure why they'd ever need to not use the clock setup . Making the plls have an Option<> for setting custom values on the free ones makes sense though.

someone on the rust-embedded channel indicated that they thought libraries shouldn't setup clocks at all, maybe because they're rather complex and users could want to tune for power consumption or various peripherals.. which is why I made it an optional thing here. Though, maybe for this project that doesn't make sense and there should just be some additional arguments to set custom values like you've said.

mtthw-meyer commented 3 years ago

That makes sense. The daisy is a rather more specific board than most, but there could be a case where someone wanted to run it for power efficiency instead of audio quality. Having both options is good. A preset with good default clocks and a do it yourself if you want to mode.

x37v commented 3 years ago

started from scratch, in a PR now