Skip to content

Commit

Permalink
Rework GLOBAL_LOCK() and GLOBAL_UNLOCK (#1518)
Browse files Browse the repository at this point in the history
***NO_CI***
  • Loading branch information
MateuszKlatecki authored and josesimoes committed Nov 27, 2019
1 parent 642d56a commit 5c4d88c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions targets/FreeRTOS/common/include/targetHAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@
#ifndef _TARGET_HAL_H_
#define _TARGET_HAL_H_

#include "FreeRTOS.h"
#include <target_board.h>
#include "cmsis_gcc.h"

// global mutex protecting the internal state of the interpreter, including event flags
#define GLOBAL_LOCK() portENTER_CRITICAL();
#define GLOBAL_UNLOCK(); portEXIT_CRITICAL();
#define GLOBAL_LOCK(); UBaseType_t uxSavedInterruptStatus = 0; \
if (xPortIsInsideInterrupt() == pdTRUE) { \
uxSavedInterruptStatus = taskENTER_CRITICAL_FROM_ISR();\
} else { portENTER_CRITICAL(); }
#define GLOBAL_UNLOCK(); if (xPortIsInsideInterrupt() == pdTRUE) { \
taskEXIT_CRITICAL_FROM_ISR( uxSavedInterruptStatus ); \
} else { portEXIT_CRITICAL(); }

// platform dependent delay
#define PLATFORM_DELAY(milliSecs) vTaskDelay(milliSecs / portTICK_PERIOD_MS);
Expand Down

0 comments on commit 5c4d88c

Please sign in to comment.