Skip to content

Commit af77d98

Browse files
committed
Store rotation in 32-bit format
1 parent 0a72d74 commit af77d98

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

firmware/common/radio.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,10 @@ static fp_40_24_t compute_offset(radio_t* const radio, uint64_t opmode, uint64_t
265265
if ((rotation != 0) && (rotation != RADIO_UNSET) && (mcu_rate != RADIO_UNSET) &&
266266
(n != RADIO_UNSET)) {
267267
const fp_40_24_t afe_rate = mcu_rate << n;
268-
if (rotation & 0x80) {
269-
rotation = 0x100 - rotation;
268+
if (rotation & 0x80000000) {
269+
rotation = 0x100000000 - rotation;
270270
}
271-
offset = (afe_rate * rotation) >> 8;
271+
offset = (afe_rate * (rotation >> 24)) >> 8;
272272
}
273273
return offset;
274274
}
@@ -285,13 +285,13 @@ static fp_40_24_t digital_from_analog_rf(
285285
{
286286
fp_40_24_t offset = compute_offset(radio, opmode, rotation);
287287
fp_40_24_t drf = arf;
288-
if (rotation > 0x80) {
288+
if (rotation > 0x80000000) {
289289
if (offset > arf) {
290290
drf = offset - arf;
291291
} else {
292292
drf = arf - offset;
293293
}
294-
} else if ((rotation & 0x7f) > 0x00) {
294+
} else if ((rotation & 0x7fffffff) > 0) {
295295
drf = arf + offset;
296296
}
297297
return drf;
@@ -310,9 +310,9 @@ static fp_40_24_t analog_from_digital_rf(
310310
{
311311
fp_40_24_t offset = compute_offset(radio, opmode, rotation);
312312
fp_40_24_t arf = drf;
313-
if (rotation > 0x80) {
313+
if (rotation > 0x80000000) {
314314
arf = drf + offset;
315-
} else if ((rotation & 0x7f) > 0x00) {
315+
} else if ((rotation & 0x7fffffff) > 0) {
316316
if (offset > drf) {
317317
arf = offset - drf;
318318
} else {
@@ -405,8 +405,8 @@ static bool radio_update_frequency(radio_t* const radio, uint64_t* bank)
405405
case TRANSCEIVER_MODE_RX:
406406
case TRANSCEIVER_MODE_RX_SWEEP:
407407
/* Round to nearest supported rotation. */
408-
rotation = (rotation + 0x20) & 0xc0;
409-
if (rotation == 0x80) {
408+
rotation = (rotation + 0x20000000) & 0xc0000000;
409+
if (rotation == 0x80000000) {
410410
rotation = 0;
411411
}
412412
break;
@@ -430,7 +430,7 @@ static bool radio_update_frequency(radio_t* const radio, uint64_t* bank)
430430
const tune_config_t* tune_config =
431431
select_tune_config(opmode, freq_rf);
432432
if (requested_rotation == RADIO_UNSET) {
433-
rotation = (uint8_t) (tune_config->shift) << 6;
433+
rotation = (uint64_t) (tune_config->shift) << 30;
434434
}
435435
analog_rf =
436436
analog_from_digital_rf(radio, freq_rf, opmode, rotation);
@@ -507,7 +507,7 @@ static bool radio_update_frequency(radio_t* const radio, uint64_t* bank)
507507
}
508508
if ((rotation != applied_rotation) && (rotation != RADIO_UNSET)) {
509509
#ifdef PRALINE
510-
fpga_set_rx_quarter_shift_mode(&fpga, rotation >> 6);
510+
fpga_set_rx_quarter_shift_mode(&fpga, rotation >> 30);
511511
#endif
512512
radio->config[RADIO_BANK_APPLIED][RADIO_ROTATION] = rotation;
513513
new_freq = true;

firmware/common/radio.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ typedef enum {
100100
*/
101101
RADIO_IMAGE_REJECT = 4,
102102
/**
103-
* Digital frequency conversion of type uint8_t in tau/256 steps with
103+
* Digital frequency conversion of type uint8_t in tau/(2**32) steps with
104104
* respect to AFE clock.
105105
*/
106106
RADIO_ROTATION = 5,

0 commit comments

Comments
 (0)