diff options
| author | Daniel Campora | 2015-07-08 12:46:47 +0200 |
|---|---|---|
| committer | Daniel Campora | 2015-07-08 12:48:35 +0200 |
| commit | d18ced9cddb4123ba793824bf7370a6593c9a3ae (patch) | |
| tree | bdc87f35defee6ef0ae191a185d65c5215843880 /cc3200/hal/cc3200_hal.c | |
| parent | 7463442e5867cc40d59e84760606c52d2198b913 (diff) | |
cc3200: Use alternative HAL_Delay also when interrupts are disabled.
Diffstat (limited to 'cc3200/hal/cc3200_hal.c')
| -rw-r--r-- | cc3200/hal/cc3200_hal.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/cc3200/hal/cc3200_hal.c b/cc3200/hal/cc3200_hal.c index 671af3cf9..afc5fb724 100644 --- a/cc3200/hal/cc3200_hal.c +++ b/cc3200/hal/cc3200_hal.c @@ -46,6 +46,7 @@ #include "telnet.h" #include "pybuart.h" #include "utils.h" +#include "irq.h" #ifdef USE_FREERTOS #include "FreeRTOS.h" @@ -108,8 +109,8 @@ uint32_t HAL_GetTick(void) { } void HAL_Delay(uint32_t delay) { - // only if we are not within interrupt context - if ((HAL_NVIC_INT_CTRL_REG & HAL_VECTACTIVE_MASK) == 0) { + // only if we are not within interrupt context and interrupts are enabled + if ((HAL_NVIC_INT_CTRL_REG & HAL_VECTACTIVE_MASK) == 0 && query_irq() == IRQ_STATE_ENABLED) { #ifdef USE_FREERTOS vTaskDelay (delay / portTICK_PERIOD_MS); #else @@ -121,8 +122,10 @@ void HAL_Delay(uint32_t delay) { } #endif } else { - for (int ms = 1; ms <= delay; ms++) { - UtilsDelay(UTILS_DELAY_US_TO_COUNT(ms * 1000)); + for (int ms = 0; ms < delay; ms++) { + // 500 instead of 1000 us to compensate the overhead of the for loop + // and the function call + UtilsDelay(UTILS_DELAY_US_TO_COUNT(500)); } } } |
