From 8aa48c4fb6a691a321bd167892c79a844ec52cf1 Mon Sep 17 00:00:00 2001 From: hujun5 Date: Tue, 27 Jan 2026 14:14:26 +0800 Subject: [PATCH] examples: foc: Add critical section protection to FOC control loop Introduce CONFIG_EXAMPLES_FOC_CONTROL_CRITSEC configuration option to enable critical section protection in the FOC (Field-Oriented Control) motor control examples. This adds irq-safe critical sections around the main control loop processing to prevent race conditions and ensure atomic updates of motor control state and parameters during interrupt handling. Signed-off-by: hujun5 --- examples/foc/foc_fixed16_thr.c | 2 ++ examples/foc/foc_float_thr.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/examples/foc/foc_fixed16_thr.c b/examples/foc/foc_fixed16_thr.c index 2ba2998e6..3c9a8c77b 100644 --- a/examples/foc/foc_fixed16_thr.c +++ b/examples/foc/foc_fixed16_thr.c @@ -26,6 +26,8 @@ #include +#include + #include #include #include diff --git a/examples/foc/foc_float_thr.c b/examples/foc/foc_float_thr.c index af967f255..4c52b86bf 100644 --- a/examples/foc/foc_float_thr.c +++ b/examples/foc/foc_float_thr.c @@ -26,6 +26,8 @@ #include +#include + #include #include #include