analogdevicesinc / no-OS

Software drivers in C for systems without an operating system
http://analogdevicesinc.github.io/no-OS/
Other
971 stars 1.67k forks source link

peripheral drivers should have a config() API #2339

Open buha opened 1 month ago

buha commented 1 month ago

There is an issue with UART being needlessly reinitialized by calling remove() and init() API's only to change the baudrate. This kind of problem could be solved by adding a mandatory config() API to the peripheral drivers so that the minimal API set would look like this:

init(**dev, *init_param) - allocate memory, calls config() internally
config(*dev, *init_param) - configure the peripheral
remove(*dev) - deallocate memory (and put the hardware in a good state, if needed)

The user could then reconfigure the peripheral with a new set of init_param structure without deallocating/reallocating memory.