stm32l4xx-hal icon indicating copy to clipboard operation
stm32l4xx-hal copied to clipboard

API design parity/uniformity: enabling of a peripheral

Open datdenkikniet opened this issue 4 years ago • 1 comments

Hi all,

Currently, there are two types of API's being used for enabling peripherals: an Ext trait with something similar to an enable function, or a function like HalPeripheralWrapper::peripheralN(peripheralN: PACStruct).

I think it would be good if a single one of these could be picked, at least for expansions to the HAL, to ensure that the API is uniform.

Personally, I'm a bigger fan of the latter method: it's , in my opinion, clearer, and it's not necessary to import an extra trait to get the required functionality.

Perhaps changing the naming convention to HalPeripheralWrapper::from_peripheralN() would be nice, but I think that is a different discussion.

I'm interested to see what others' thoughts are on this, so please let me know below :)

datdenkikniet avatar May 21 '21 11:05 datdenkikniet

Hi, there is a similar issue open which motivates that we should not have extension traits (and I agree): https://github.com/stm32-rs/stm32l4xx-hal/issues/57

korken89 avatar May 30 '21 17:05 korken89