Commit d18ced9c authored by Daniel Campora's avatar Daniel Campora
Browse files

cc3200: Use alternative HAL_Delay also when interrupts are disabled.

parent 7463442e
......@@ -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));
}
}
}
......
......@@ -28,7 +28,6 @@
#include "py/mpconfig.h"
#include MICROPY_HAL_H
#include "py/obj.h"
#include "irq.h"
#include "mpsystick.h"
#include "systick.h"
#include "inc/hw_types.h"
......
......@@ -38,6 +38,7 @@
#include "mpexception.h"
#include "serverstask.h"
#include "genhdr/mpversion.h"
#include "irq.h"
/******************************************************************************
DEFINE PRIVATE CONSTANTS
......@@ -492,8 +493,8 @@ static void telnet_parse_input (uint8_t *str, int16_t *len) {
static bool telnet_send_with_retries (int16_t sd, const void *pBuf, int16_t len) {
int32_t retries = 0;
// abort sending if we happen to be 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) {
do {
_i16 result = sl_Send(sd, pBuf, len, 0);
if (result > 0) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment