Closed puzrin closed 6 months ago
Can you provide more context how the modified signature of readRegister()
helps and where it helps?
Sure. See this draft (not working, done for demo only):
The protothreaded function can't return value. All data is changed via param's object/pointers. I just unified the signature to be compatible with any possible use.
Also, this is better mapped to a generic i2c connector interface (it does not exist now, but should be added). Something of this kind:
typedef struct {
void (*write)(uint8_t addr, uint8_t reg, uint8_t *out, int len);
void (*read)(uint8_t addr, uint8_t reg, uint8_t *in, int len);
// required for `pt_wait_cond()` polling
bool (*done)();
// "get_last error()"
int (*get_status)();
// MUST be called by every async i2c function, when done.
// Used to invoke pt scheduler and continue processing
void (*on_complete)();
} fusb302_i2c_drv_t
Anyway, I planned to create a separate folder for protothreaded version of fusb302 driver. If you hesitate about this PR - I will continue there.
Minor polish to reduce number of i2c connector methods.