Implementing async APIs for microcontroller peripherals