electro-smith / libDaisy

Hardware Library for the Daisy Audio Platform
https://www.electro-smith.com/daisy
MIT License
331 stars 143 forks source link

Timer: DeInitialization expectations #524

Open stephenhensley opened 2 years ago

stephenhensley commented 2 years ago

This is likely the case with a few other peripherals as well, but I encountered it with the TimerHandle

When testing reusing TIM2 (which is used by System internally):

I attempted to call Init without anything first, this (somewhat expectedly) failed since the timer was running already.

So the next logical step was to call DeInit, before calling Init. This does not work because Init is what assigns the internal Impl class. So any calls prior to Init will fail.

So not necessarily a bug, but a whole in the expected functionality that should be addressed at some point throughout the library.

Should all Init functions do a full DeInit before Init to avoid the necessity?