extmod/utime_mphal: sleep_us/ms(): Don't wait on negative argument.

This commit is contained in:
Paul Sokolovsky 2016-10-14 22:19:45 +03:00
parent f059563507
commit 36f97f19b4
1 changed files with 8 additions and 2 deletions

View File

@ -46,13 +46,19 @@ STATIC mp_obj_t time_sleep(mp_obj_t seconds_o) {
MP_DEFINE_CONST_FUN_OBJ_1(mp_utime_sleep_obj, time_sleep);
STATIC mp_obj_t time_sleep_ms(mp_obj_t arg) {
mp_hal_delay_ms(mp_obj_get_int(arg));
mp_int_t ms = mp_obj_get_int(arg);
if (ms > 0) {
mp_hal_delay_ms(ms);
}
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_1(mp_utime_sleep_ms_obj, time_sleep_ms);
STATIC mp_obj_t time_sleep_us(mp_obj_t arg) {
mp_hal_delay_us(mp_obj_get_int(arg));
mp_int_t us = mp_obj_get_int(arg);
if (us > 0) {
mp_hal_delay_us(us);
}
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_1(mp_utime_sleep_us_obj, time_sleep_us);