https://developer.mbed.org/teams/ST/code/X_NUCLEO_COMMON/#12be3dfc15fd