From ca72769bb8a7417900e60ca511ba4def12c00802 Mon Sep 17 00:00:00 2001 From: "Edward A. Lee" Date: Fri, 31 May 2024 18:00:24 +0200 Subject: [PATCH 1/2] Do not use macros in util.h, which is impossible to #include --- low_level_platform/impl/src/lf_rp2040_support.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/low_level_platform/impl/src/lf_rp2040_support.c b/low_level_platform/impl/src/lf_rp2040_support.c index fcbc71078..a21caa946 100644 --- a/low_level_platform/impl/src/lf_rp2040_support.c +++ b/low_level_platform/impl/src/lf_rp2040_support.c @@ -134,15 +134,17 @@ int _lf_interruptable_sleep_until_locked(environment_t* env, instant_t wakeup_ti sem_reset(&_lf_sem_irq_event, 0); // create us boot wakeup time target = from_us_since_boot((uint64_t)(wakeup_time / 1000)); - // allow interrupts - LF_CRITICAL_SECTION_EXIT(env); + // Enable interrupts. NOTE: It would be nice to use the macro LF_CRITICAL_SECTION_EXIT, + // but there seems to be no way to #include "util.h" that works in this file. + lf_critical_section_exit(env); // blocked sleep // return on timeout or on processor event if (sem_acquire_block_until(&_lf_sem_irq_event, target)) { ret_code = -1; } - // remove interrupts - LF_CRITICAL_SECTION_ENTER(env); + // Disable interrupts. NOTE: It would be nice to use the macro LF_CRITICAL_SECTION_ENTER, + // but there seems to be no way to #include "util.h" that works in this file. + lf_critical_section_enter(env); return ret_code; } From cf23e5c3e33a6d2b4d538161124d0456b810bd21 Mon Sep 17 00:00:00 2001 From: Marten Lohstroh Date: Sun, 2 Jun 2024 22:25:35 -0700 Subject: [PATCH 2/2] Apply suggestions from code review --- low_level_platform/impl/src/lf_rp2040_support.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/low_level_platform/impl/src/lf_rp2040_support.c b/low_level_platform/impl/src/lf_rp2040_support.c index a21caa946..a3f0237aa 100644 --- a/low_level_platform/impl/src/lf_rp2040_support.c +++ b/low_level_platform/impl/src/lf_rp2040_support.c @@ -134,16 +134,14 @@ int _lf_interruptable_sleep_until_locked(environment_t* env, instant_t wakeup_ti sem_reset(&_lf_sem_irq_event, 0); // create us boot wakeup time target = from_us_since_boot((uint64_t)(wakeup_time / 1000)); - // Enable interrupts. NOTE: It would be nice to use the macro LF_CRITICAL_SECTION_EXIT, - // but there seems to be no way to #include "util.h" that works in this file. + // Enable interrupts. lf_critical_section_exit(env); // blocked sleep // return on timeout or on processor event if (sem_acquire_block_until(&_lf_sem_irq_event, target)) { ret_code = -1; } - // Disable interrupts. NOTE: It would be nice to use the macro LF_CRITICAL_SECTION_ENTER, - // but there seems to be no way to #include "util.h" that works in this file. + // Disable interrupts. lf_critical_section_enter(env); return ret_code; }