|
1 | 1 | /* |
2 | | - * Copyright 2012-2022 Great Scott Gadgets <info@greatscottgadgets.com> |
| 2 | + * Copyright 2012-2026 Great Scott Gadgets <info@greatscottgadgets.com> |
3 | 3 | * Copyright 2012 Jared Boone <jared@sharebrained.com> |
4 | 4 | * Copyright 2013 Benjamin Vernoux <titanmkd@gmail.com> |
5 | 5 | * |
@@ -351,40 +351,7 @@ fpga_driver_t fpga = { |
351 | 351 | }; |
352 | 352 | #endif |
353 | 353 |
|
354 | | -radio_t radio = { |
355 | | - .channel[RADIO_CHANNEL0] = |
356 | | - { |
357 | | - .id = RADIO_CHANNEL0, |
358 | | - .config = |
359 | | - { |
360 | | - .sample_rate[RADIO_SAMPLE_RATE_CLOCKGEN] = |
361 | | - {.hz = 0}, |
362 | | - .filter[RADIO_FILTER_BASEBAND] = {.hz = 0}, |
363 | | - .frequency[RADIO_FREQUENCY_RF] = |
364 | | - { |
365 | | - .hz = 0, |
366 | | - .if_hz = 0, |
367 | | - .lo_hz = 0, |
368 | | - .path = 0, |
369 | | - }, |
370 | | - .gain[RADIO_GAIN_RF_AMP] = {.enable = 0}, |
371 | | - .gain[RADIO_GAIN_RX_LNA] = {.db = 0}, |
372 | | - .gain[RADIO_GAIN_RX_VGA] = {.db = 0}, |
373 | | - .gain[RADIO_GAIN_TX_VGA] = {.db = 0}, |
374 | | - .antenna[RADIO_ANTENNA_BIAS_TEE] = |
375 | | - {.enable = false}, |
376 | | - .mode = TRANSCEIVER_MODE_OFF, |
377 | | - .clock[RADIO_CLOCK_CLKIN] = {.enable = false}, |
378 | | - .clock[RADIO_CLOCK_CLKOUT] = {.enable = false}, |
379 | | - .trigger_enable = false, |
380 | | -#ifdef PRALINE |
381 | | - .resampling_n = 0, |
382 | | - .shift = FPGA_QUARTER_SHIFT_MODE_NONE, |
383 | | -#endif |
384 | | - }, |
385 | | - .clock_source = CLOCK_SOURCE_HACKRF, |
386 | | - }, |
387 | | -}; |
| 354 | +radio_t radio; |
388 | 355 |
|
389 | 356 | rf_path_t rf_path = { |
390 | 357 | .switchctrl = 0, |
@@ -486,7 +453,17 @@ bool sample_rate_frac_set(uint32_t rate_num, uint32_t rate_denom) |
486 | 453 | uint32_t a, b, c; |
487 | 454 | uint32_t rem; |
488 | 455 |
|
489 | | - hackrf_ui()->set_sample_rate(rate_num / 2); |
| 456 | + /* Round to the nearest Hz for display. */ |
| 457 | + uint32_t rate_hz = (rate_num + (rate_denom >> 1)) / rate_denom; |
| 458 | + hackrf_ui()->set_sample_rate(rate_hz); |
| 459 | + |
| 460 | + /* |
| 461 | + * First double the sample rate so that we can produce a clock at twice |
| 462 | + * the intended sample rate. The 2x clock is sometimes used directly, |
| 463 | + * and it is divided by two in an output divider to produce the actual |
| 464 | + * AFE clock. |
| 465 | + */ |
| 466 | + rate_num *= 2; |
490 | 467 |
|
491 | 468 | /* Find best config */ |
492 | 469 | a = (VCO_FREQ * rate_denom) / rate_num; |
@@ -999,7 +976,6 @@ clock_source_t activate_best_clock_source(void) |
999 | 976 | &clock_gen, |
1000 | 977 | (source == CLOCK_SOURCE_HACKRF) ? PLL_SOURCE_XTAL : PLL_SOURCE_CLKIN); |
1001 | 978 | hackrf_ui()->set_clock_source(source); |
1002 | | - radio.channel[RADIO_CHANNEL0].clock_source = source; |
1003 | 979 |
|
1004 | 980 | return source; |
1005 | 981 | } |
|
0 commit comments