diff options
| author | Daniel Campora <daniel@wipy.io> | 2015-07-05 22:26:12 +0200 |
|---|---|---|
| committer | Daniel Campora <daniel@wipy.io> | 2015-07-07 16:11:05 +0200 |
| commit | fa655ce196ad82e3b8664dcd0ba78328ecaa9a58 (patch) | |
| tree | 9ff312814008236e29f8d141f8416b324c4707b5 /cc3200/mods | |
| parent | 194c8c761e853cb200d5aab885b6d62ec87cf4b2 (diff) | |
cc3200: Improve interrupt handling and fix bug in HAL_Delay().
Diffstat (limited to 'cc3200/mods')
| -rw-r--r-- | cc3200/mods/modutime.c | 5 | ||||
| -rw-r--r-- | cc3200/mods/pybuart.c | 8 |
2 files changed, 8 insertions, 5 deletions
diff --git a/cc3200/mods/modutime.c b/cc3200/mods/modutime.c index f828fca9a..d69e5c4e2 100644 --- a/cc3200/mods/modutime.c +++ b/cc3200/mods/modutime.c @@ -125,7 +125,10 @@ MP_DEFINE_CONST_FUN_OBJ_1(time_mktime_obj, time_mktime); /// \function sleep(seconds) /// Sleep for the given number of seconds. STATIC mp_obj_t time_sleep(mp_obj_t seconds_o) { - HAL_Delay(mp_obj_get_int(seconds_o) * 1000); + int32_t sleep_s = mp_obj_get_int(seconds_o); + if (sleep_s > 0) { + HAL_Delay(sleep_s * 1000); + } return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_1(time_sleep_obj, time_sleep); diff --git a/cc3200/mods/pybuart.c b/cc3200/mods/pybuart.c index 41a0a2ec3..f4ac2881a 100644 --- a/cc3200/mods/pybuart.c +++ b/cc3200/mods/pybuart.c @@ -89,8 +89,8 @@ /****************************************************************************** DEFINE CONSTANTS ******************************************************************************/ -#define PYBUART_TX_WAIT_MS 1 -#define PYBUART_TX_MAX_TIMEOUT_MS 5 +#define PYBUART_TX_WAIT_US (50) +#define PYBUART_TX_MAX_TIMEOUT_MS (5) /****************************************************************************** DECLARE PRIVATE FUNCTIONS @@ -156,10 +156,10 @@ bool uart_tx_char(pyb_uart_obj_t *self, int c) { uint32_t timeout = 0; while (!MAP_UARTCharPutNonBlocking(self->reg, c)) { - if (timeout++ > (PYBUART_TX_MAX_TIMEOUT_MS / PYBUART_TX_WAIT_MS)) { + if (timeout++ > ((PYBUART_TX_MAX_TIMEOUT_MS * 1000) / PYBUART_TX_WAIT_US)) { return false; } - HAL_Delay (PYBUART_TX_WAIT_MS); + UtilsDelay(UTILS_DELAY_US_TO_COUNT(PYBUART_TX_WAIT_US)); } return true; } |
