From 08f5b23a6138045408fd81556359218e802cb1da Mon Sep 17 00:00:00 2001 From: rusefi Date: Wed, 7 Jun 2017 21:04:04 -0400 Subject: [PATCH] #441 --- firmware/config/stm32f4ems/chconf.h | 5 +++++ firmware/console/console_io.cpp | 4 ++++ simulator/chconf.h | 2 ++ 3 files changed, 11 insertions(+) diff --git a/firmware/config/stm32f4ems/chconf.h b/firmware/config/stm32f4ems/chconf.h index 33ec9f25f1..f6b9f72335 100644 --- a/firmware/config/stm32f4ems/chconf.h +++ b/firmware/config/stm32f4ems/chconf.h @@ -365,6 +365,11 @@ extern "C" */ #define CH_DBG_SYSTEM_STATE_CHECK TRUE +/** + * micro-optimization: use same (lower-level) api for lock/unlock regardless on context + * this saves us one branching + */ +#define USE_PORT_LOCK FALSE /** * @brief Debug option, parameters checks. diff --git a/firmware/console/console_io.cpp b/firmware/console/console_io.cpp index 467e7e33c1..7053a22493 100644 --- a/firmware/console/console_io.cpp +++ b/firmware/console/console_io.cpp @@ -285,6 +285,9 @@ bool lockAnyContext(void) { int alreadyLocked = isLocked(); if (alreadyLocked) return true; +#if USE_PORT_LOCK + port_lock(); +#else if (isIsrContext()) { chSysLockFromISR() ; @@ -292,6 +295,7 @@ bool lockAnyContext(void) { chSysLock() ; } +#endif return false; } diff --git a/simulator/chconf.h b/simulator/chconf.h index 76ab9217a0..e5adee835b 100644 --- a/simulator/chconf.h +++ b/simulator/chconf.h @@ -338,6 +338,8 @@ */ #define CH_DBG_SYSTEM_STATE_CHECK FALSE +#define USE_PORT_LOCK TRUE + /** * @brief Debug option, parameters checks. * @details If enabled then the checks on the API functions input