Handling interrupts within library passing peripheral HandleTypeDef
Hello,
I'm trying to develop a library for a device using I2C for multiple projects. To use the sequential transmit functions, I need to handle Interrupts for the correct I2Cx channel. When I initialize the device configuration struct from main.c, among other stuff, I pass the correct I2Cx handler, depending if the device is connected to channel 1, 2, 3 and so on.
In my library.c I have a function called myDevice_EV_IRQHandler(HAL_I2C_HandleTypeDef *hi2c) called by I2Cx_EV_IRQHandler() from main.c file where x is the channel I physically wired my device to.
I was wondering if I could do it in a more elegant way at run-time having the correct I2Cx handler passed during initialization. The goal is to substitute the function pointer of I2Cx_EV_IRQHandler with the one of myDevice_EV_IRQHandler at run-time based on which channel is the hi2c I passed initially.
I hope my question is clear, thank you in advance.
