From 89eced25e01b1424a0c36b6e2c31423935456b5b Mon Sep 17 00:00:00 2001 From: fastium Date: Sat, 6 Jun 2026 17:33:54 +0200 Subject: [PATCH] fix(MP/kernel): period is only over 0 --- src/06-mini-project/kernel/regulator/regulator.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/06-mini-project/kernel/regulator/regulator.c b/src/06-mini-project/kernel/regulator/regulator.c index 64b0f1b..a0838cd 100644 --- a/src/06-mini-project/kernel/regulator/regulator.c +++ b/src/06-mini-project/kernel/regulator/regulator.c @@ -37,12 +37,17 @@ static uint32_t cb_get_period(void) { return current_period; } -static void cb_set_period(uint32_t freq) { +static void cb_set_period(uint32_t period_ms) { /* Allow period changes only in Manual mode */ if (current_mode == 0) { - current_period = freq; - regulator_cbs.adjust_period(current_period); - pr_info("regulator: Manual period set to %u ms\n", current_period); + if (period_ms > 0) { + current_period = period_ms; + regulator_cbs.adjust_period(current_period); + pr_info("regulator: Manual period set to %u ms\n", current_period); + } else { + pr_warn("regulator: Period must be greater than 0\n"); + } + } else { pr_warn("regulator: Cannot set period manually in auto mode\n"); }