From fbf4b5784cb2119d6aa4d259d6012055a8b0282e Mon Sep 17 00:00:00 2001 From: Filipe Carvalho <34546039+filcarv@users.noreply.github.com> Date: Wed, 13 Apr 2022 23:42:18 +0100 Subject: [PATCH] Added ability for the device to refuse a new clock hardware set. --- Firmware/Core/hwbp_core.c | 10 +++++++--- Firmware/Core/hwbp_core.h | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Firmware/Core/hwbp_core.c b/Firmware/Core/hwbp_core.c index 5b1423c..a4ff3f2 100644 --- a/Firmware/Core/hwbp_core.c +++ b/Firmware/Core/hwbp_core.c @@ -1367,9 +1367,11 @@ bool hwbp_write_common_reg_CONFIG(void *a) /* Configure device to repeater if the device wasn't a repeater */ if ((reg & B_CLK_REP) && ((commonbank.R_CLOCK_CONFIG & B_CLK_REP) == false)) { + if (!core_callback_clock_to_repeater()) + return false; + commonbank.R_CLOCK_CONFIG &= ~B_CLK_GEN; // Clear CLK_GEN bit commonbank.R_CLOCK_CONFIG |= B_CLK_REP; // Set CLK_REP bit - core_callback_clock_to_repeater(); /* Removes the timestamp lock if the device is locked */ if (commonbank.R_CLOCK_CONFIG & B_CLK_LOCK) @@ -1383,9 +1385,11 @@ bool hwbp_write_common_reg_CONFIG(void *a) /* Configure device to generator if the device wasn't a generator */ if ((reg & B_CLK_GEN) && ((commonbank.R_CLOCK_CONFIG & B_CLK_GEN) == false)) { + if (!core_callback_clock_to_generator()) + return false; + commonbank.R_CLOCK_CONFIG |= B_CLK_GEN; // Set CLK_GEN bit - commonbank.R_CLOCK_CONFIG &= ~B_CLK_REP; // Clear CLK_REP bit - core_callback_clock_to_generator(); + commonbank.R_CLOCK_CONFIG &= ~B_CLK_REP; // Clear CLK_REP bit } /* Unlock timestamp if was locked */ diff --git a/Firmware/Core/hwbp_core.h b/Firmware/Core/hwbp_core.h index aabd3cc..eb5862b 100644 --- a/Firmware/Core/hwbp_core.h +++ b/Firmware/Core/hwbp_core.h @@ -88,9 +88,9 @@ bool hwbp_write_common_reg_CONFIG(void *a); void hwbp_read_common_reg_CONFIG(void); // Called when the application should configure the hardware to repeat the harp timestamp clock input. -void core_callback_clock_to_repeater(void); +bool core_callback_clock_to_repeater(void); // Called when the application should configure the hardware to generate the harp timestamp clock. -void core_callback_clock_to_generator(void); +bool core_callback_clock_to_generator(void); // Called when the timestamp lock is changed to unlocked. void core_callback_clock_to_unlock(void); // Called when the timestamp lock is changed to locked.