See https://github.com/geoffreymbrown/STM32-Template/blob/master/Library/i2c.c#L39 and RM0090 p851-853.