ivory-bsp-stm32f4: refactor platform code, use across all examples