http://mbed.org/users/mbed_official/code/mbed-src/#a11c0372f0ba