Clock reference: Return enum for selected clock source.
This commit is contained in:
@ -716,7 +716,7 @@ void cpu_clock_init(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void activate_best_clock_source(void)
|
clock_source_t activate_best_clock_source(void)
|
||||||
{
|
{
|
||||||
#ifdef HACKRF_ONE
|
#ifdef HACKRF_ONE
|
||||||
/* Ensure PortaPack reference oscillator is off while checking for external clock input. */
|
/* Ensure PortaPack reference oscillator is off while checking for external clock input. */
|
||||||
@ -728,6 +728,7 @@ void activate_best_clock_source(void)
|
|||||||
/* Check for external clock input. */
|
/* Check for external clock input. */
|
||||||
if (si5351c_clkin_signal_valid(&clock_gen)) {
|
if (si5351c_clkin_signal_valid(&clock_gen)) {
|
||||||
si5351c_set_clock_source(&clock_gen, PLL_SOURCE_CLKIN);
|
si5351c_set_clock_source(&clock_gen, PLL_SOURCE_CLKIN);
|
||||||
|
return CLOCK_SOURCE_EXTERNAL;
|
||||||
} else {
|
} else {
|
||||||
#ifdef HACKRF_ONE
|
#ifdef HACKRF_ONE
|
||||||
/* Enable PortaPack reference oscillator (if present), and check for valid clock. */
|
/* Enable PortaPack reference oscillator (if present), and check for valid clock. */
|
||||||
@ -736,7 +737,7 @@ void activate_best_clock_source(void)
|
|||||||
delay(510000); /* loop iterations @ 204MHz for >10ms for oscillator to enable. */
|
delay(510000); /* loop iterations @ 204MHz for >10ms for oscillator to enable. */
|
||||||
if (si5351c_clkin_signal_valid(&clock_gen)) {
|
if (si5351c_clkin_signal_valid(&clock_gen)) {
|
||||||
si5351c_set_clock_source(&clock_gen, PLL_SOURCE_CLKIN);
|
si5351c_set_clock_source(&clock_gen, PLL_SOURCE_CLKIN);
|
||||||
return;
|
return CLOCK_SOURCE_PORTAPACK;
|
||||||
} else {
|
} else {
|
||||||
portapack_reference_oscillator(false);
|
portapack_reference_oscillator(false);
|
||||||
}
|
}
|
||||||
@ -744,6 +745,7 @@ void activate_best_clock_source(void)
|
|||||||
#endif
|
#endif
|
||||||
/* No external or PortaPack clock was found. Use HackRF Si5351C crystal. */
|
/* No external or PortaPack clock was found. Use HackRF Si5351C crystal. */
|
||||||
si5351c_set_clock_source(&clock_gen, PLL_SOURCE_XTAL);
|
si5351c_set_clock_source(&clock_gen, PLL_SOURCE_XTAL);
|
||||||
|
return CLOCK_SOURCE_HACKRF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,6 +264,12 @@ typedef enum {
|
|||||||
HW_SYNC_MODE_ON = 1,
|
HW_SYNC_MODE_ON = 1,
|
||||||
} hw_sync_mode_t;
|
} hw_sync_mode_t;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
CLOCK_SOURCE_HACKRF = 0,
|
||||||
|
CLOCK_SOURCE_EXTERNAL = 1,
|
||||||
|
CLOCK_SOURCE_PORTAPACK = 2,
|
||||||
|
} clock_source_t;
|
||||||
|
|
||||||
void delay(uint32_t duration);
|
void delay(uint32_t duration);
|
||||||
|
|
||||||
/* TODO: Hide these configurations */
|
/* TODO: Hide these configurations */
|
||||||
@ -294,7 +300,7 @@ bool sample_rate_frac_set(uint32_t rate_num, uint32_t rate_denom);
|
|||||||
bool sample_rate_set(const uint32_t sampling_rate_hz);
|
bool sample_rate_set(const uint32_t sampling_rate_hz);
|
||||||
bool baseband_filter_bandwidth_set(const uint32_t bandwidth_hz);
|
bool baseband_filter_bandwidth_set(const uint32_t bandwidth_hz);
|
||||||
|
|
||||||
void activate_best_clock_source(void);
|
clock_source_t activate_best_clock_source(void);
|
||||||
|
|
||||||
#if (defined HACKRF_ONE || defined RAD1O)
|
#if (defined HACKRF_ONE || defined RAD1O)
|
||||||
void enable_rf_power(void);
|
void enable_rf_power(void);
|
||||||
|
Reference in New Issue
Block a user