# HG changeset patch # User Mychaela Falconia # Date 1516408668 0 # Node ID 5ca341a26dda2de082b50c039900f512f3c5ce6e # Parent b3d65ae5f02cef51a7f348381bbd370fe17e82eb tpudrv10.c: frequency programming function reconstructed diff -r b3d65ae5f02c -r 5ca341a26dda src/cs/layer1/tpu_drivers/source0/tpudrv10.c --- a/src/cs/layer1/tpu_drivers/source0/tpudrv10.c Sat Jan 20 00:03:02 2018 +0000 +++ b/src/cs/layer1/tpu_drivers/source0/tpudrv10.c Sat Jan 20 00:37:48 2018 +0000 @@ -306,23 +306,15 @@ synth_900, magic1_900, magic2_rx900}, }; -/* - * Leonardo tpudrv12.obj contains a function named calc_a_b(); there is - * no such function in the LoCosto version, but there is a similar-looking - * calc_rf_freq() function instead. Let's try making our calc_a_b() - * from LoCosto's calc_rf_freq(). - */ - -#if 0 -UWORD32 calc_a_b(UWORD16 arfcn, UWORD8 downlink) +static UWORD32 calc_freq_prog(UWORD16 arfcn, UWORD8 downlink) { UWORD32 farfcn; /* sp+0x1C, in 200 kHz units */ - struct synth_s *s; - struct magic1_s *m1; - struct magic2_s *m2; + const struct synth_s *s; + const struct magic1_s *m1; + const struct magic2_s *m2; UWORD32 magic1; /* sp+0x24 */ UWORD16 sp4; - UWORD32 sp0x14, sp0x18, sp0x20; + UWORD32 sp8, sp0xC, sp0x10, sp0x14, sp0x18, sp0x20; s = rf_path[rf_index].synth; while(s->limit < arfcn) @@ -353,16 +345,12 @@ m2++; magic2_byte = (m2->magic & 7) << 5; - rf_chip_band = s->rf_chip_band; + sp8 = (sp0x14 / 16) >> 21; + sp0xC = sp0x14 - (sp8 << 25); + sp0x10 = (((sp8 << 4) + sp0xC) * 0x1A00000 - 0x18) >> 21; - // Convert the ARFCN to the channel frequency (times 5 to avoid the decimal value) - farfcn = 5*s->tx_rx[downlink].farfcn0 + (arfcn - s->arfcn0); - n = farfcn * s->tx_rx[downlink].ou; - - /* magic A & B encoding for Rita */ - return((n - 4096) << 3); + return ((sp0xC & 0xF) << 12) | ((sp8 & 0x7F) << 16) | ((sp0x10 & 0xF) << 8); } -#endif /*------------------------------------------*/ /* Convert_l1_radio_freq */