2 * This code was written by Mychaela Falconia <falcon@freecalypso.org>
3 * who refuses to claim copyright on it and has released it as public domain
4 * instead. NO rights reserved, all rights relinquished.
6 * Tweaked (coding style changes) by Vadim Yanitskiy <axilirator@gmail.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
24 #include <rf/readcal.h>
26 #include <rf/vcxocal.h>
28 static int16_t afcdac_shifted
;
30 static void afcdac_postproc(void)
32 afc_initial_dac_value
= afcdac_shifted
>> 3;
35 static int verify_checksum(const uint8_t *start
, size_t len
)
37 const uint8_t *p
, *endp
;
52 static const struct calmap
{
57 void (*postproc
)(void);
59 { "afcdac", 0x528, 2, &afcdac_shifted
, afcdac_postproc
},
60 { "Tx ramps 900", 0x72B, 512, rf_tx_ramps_900
, NULL
},
61 { "Tx levels 900", 0x92C, 128, rf_tx_levels_900
, NULL
},
62 { "Tx calchan 900", 0x9AD, 128, rf_tx_chan_cal_900
, NULL
},
63 { "Tx ramps 1800", 0xA2E, 512, rf_tx_ramps_1800
, NULL
},
64 { "Tx levels 1800", 0xC2F, 128, rf_tx_levels_1800
, NULL
},
65 { "Tx calchan 1800", 0xCB0, 128, rf_tx_chan_cal_1800
, NULL
},
66 { "Tx ramps 1900", 0xD31, 512, rf_tx_ramps_1900
, NULL
},
67 { "Tx levels 1900", 0xF32, 128, rf_tx_levels_1900
, NULL
},
68 { "Tx calchan 1900", 0xFB3, 128, rf_tx_chan_cal_1900
, NULL
},
69 { NULL
, 0, 0, NULL
, NULL
}
72 void read_factory_rf_calibration(void)
74 const struct calmap
*tp
;
75 const uint8_t *record
;
77 puts("Checking factory data block for the RF calibration records\n");
78 for (tp
= rf_cal_list
; tp
->desc
; tp
++) {
79 record
= (const uint8_t *)0x027F0000 + tp
->offset
;
80 if (verify_checksum(record
, tp
->record_len
) < 0)
82 printf("Found '%s' record, applying\n", tp
->desc
);
83 memcpy(tp
->buffer
, record
, tp
->record_len
);