Ralim / usb-pd

USB-PD driver stack for the FUSB302
Apache License 2.0
124 stars 15 forks source link

Consider pass user extensions via constructor params instead of global functions. #8

Closed puzrin closed 3 years ago

puzrin commented 3 years ago

Currently user has to create global functions to make library work:

That works, but a bit dirty. IMO it would be nice to pass such things as constructor params. The same about driver - it can be passed as policy engine param. That will be more clean & flexible than hardcoding/globals.

For example, anyone will be able to experiment with alternate drivers without intruding into library code.

PS. If you feel uncomfortable from multiple open issues i can close all those. I just post notes after code review, according to my experience, no mean to push you do something. Or i can suggest PRs and so on. Let me know about preferable way.

Ralim commented 3 years ago

These are currently passed in as constructor params?

puzrin commented 3 years ago

Ah, sorry for buss.

The only note: https://github.com/Ralim/usb-pd/blob/main/lib/Inc/policy_engine.h#L43 first param seem to be generic driver (base driver class), not fusb.

Ralim commented 3 years ago

Not sure what you mean by your note. At the moment it is the FUSB class (not a generic) as have not refactored for generic yet