STM32 HAL used incorrectly in mbed?

19 Jun 2015

I've noticed that in every driver implementation (i2c_api.c, serial_api.c, ...) there is always just one PPP_HandleTypeDef (I2C_HandleTypeDef, …) and the PPP_HandleTypeDef.Instance pointer gets changed according to the hardware instance that is meant to be worked with (I2C1, I2C2 ..).

IMHO this is completely wrong and goes against the very design of STM32 HAL. http://www.st.com/st-web-ui/static/active/en/resource/technical/document/user_manual/DM00105879.pdf section 2.2.1 (p.59) states that each peripheral instance should have its own handle and it's only logical since it contains components like lock, buffer pointers, state,.. that should be specific for every peripheral instance.

So is it really wrong or have I just completely misunderstood it?