Skip to content

Commit

Permalink
Added ability for the device to refuse a new clock hardware set.
Browse files Browse the repository at this point in the history
  • Loading branch information
filcarv committed Apr 13, 2022
1 parent e91dac4 commit fbf4b57
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions Firmware/Core/hwbp_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 */
Expand Down
4 changes: 2 additions & 2 deletions Firmware/Core/hwbp_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit fbf4b57

Please sign in to comment.