Fixed bug in MD3x0 calibration loader, made the input parameters of 'interpCalParameter' const

This commit is contained in:
Silvano Seva 2020-12-05 14:23:27 +01:00
parent b1412dedb8
commit 6e144a7160
3 changed files with 11 additions and 6 deletions

View File

@ -39,7 +39,7 @@
* and frequencies.
* @return value for the calibration parameter at the given frequency point.
*/
uint8_t interpCalParameter(freq_t freq, freq_t *calPoints, uint8_t *param,
uint8_t elems);
uint8_t interpCalParameter(const freq_t freq, const freq_t *calPoints,
const uint8_t *param, const uint8_t elems);
#endif /* CALIB_UTILS_H */

View File

@ -19,8 +19,8 @@
#include <calibUtils.h>
uint8_t interpCalParameter(freq_t freq, freq_t *calPoints, uint8_t *param,
uint8_t elems)
uint8_t interpCalParameter(const freq_t freq, const freq_t *calPoints,
const uint8_t *param, const uint8_t elems)
{
if(freq <= calPoints[0]) return param[0];

View File

@ -179,10 +179,15 @@ void nvm_readCalibData(void *buf)
(void) extFlash_readSecurityRegister(0x20b0, ((uint8_t *) &freqs), 72);
extFlash_sleep();
/*
* Ugly quirk: frequency stored in calibration data is divided by ten, so,
* after bcd2bin conversion we have something like 40'135'000. To ajdust
* things, frequency has to be multiplied by ten.
*/
for(uint8_t i = 0; i < 9; i++)
{
calib->rxFreq[i] = ((freq_t) _bcd2bin(freqs[2*i]));
calib->txFreq[i] = ((freq_t) _bcd2bin(freqs[2*i+1]));
calib->rxFreq[i] = ((freq_t) _bcd2bin(freqs[2*i])) * 10;
calib->txFreq[i] = ((freq_t) _bcd2bin(freqs[2*i+1])) * 10;
}
}