The line that applies from the LMS7002M register map document on page 45 is “2 - Vptat_600 mV and vr_cal_ref=600 mV is passed to the ADC input MUX. The ratio between the two will be proportional to the absolute temp.”
That test is selected by this line of code: Modify_SPI_Reg_bits(LMS7_MUX_BIAS_OUT, 2);
So the setup sounds like it could be something very similar to this: https://en.wikipedia.org/wiki/Silicon_bandgap_temperature_sensor
There is a temperature-independent bandgap reference (vr_cal_ref=600 mV) where the the circuit maintains an internal voltage source that has a positive temperature coefficient and another internal voltage source that has a negative temperature coefficient. The two are summed together, and the temperature dependence is cancelled thus providing a fixed voltage reference that is independent of temperature (In this particular case 600 mV).
By comparing that constant reference voltage to the internal voltage source with a positive temperature coefficient (Vptat_600 mV) the temperature inside the device can be calculated.
- vr_cal_ref (AKA “RSSI_TREF_VAL” - bits 15 to 8 of register 0x0606 ) is a temperature-independent bandgap reference voltage of exactly 0.6 volts.
- Vptat_600 (AKA “RSSI_TVPTAT_VAL” - bits 7 to 0 of register 0x0606 ) is a temperature-dependent bandgap voltage of around ~0.6 volts.
If the above is the case then the current code could possibly be replaced by something much simpler like the below:
(if you assume that 300K (26.85°C) is room temperature (25°C) and that at exactly 300K the negative temperature coefficient is zero, which may be not be perfectly true, but it probably should be close enough):
const uint16_t reg606 = SPI_read(0x0606, true);
float Vref = (reg606 >> 8) & 0xFF;
float Vptat = reg606 & 0xFF;
temperature=(Vptat/Vref)*300 - 273.15 // temperature in degrees centigrade converted from kelvin
P.S. vptat stands for Voltage Proportional to Absolute Temperature, the second value the reference voltage “should” be a static number at all temperatures (unless the voltage sits between two levels of the ADC and random noise toggles it between two numbers).
And if this gives dire results, there is always the other test on the register map document on page 45(*). Using the External 10k referance resistor on the PCB (“R11” on both the LimeSDR-USB and LimeSDR-mini) that could be used. But it is a 1% tolerance resistor which has an extremely low TCR (Temperature Coefficient of Resistance) of ±100ppm℃. So over it’s entire operating temperature range (-55℃ to 155℃) its resistance changes by less than 3%, and over the operating temperature range of the LMS7002M (-40℃ to 85℃) less than 1.25%.
Maybe a higher temperature range could be possible with that external 10 kOhm reference resistor. Or maybe a much lower temperature range with a higher resolution, there is not really enough information to tell.
(*) “1 - vr_ext_bak and vr_cal_ref=600mV is passed to the ADC input MUX. Vr_ext_bak is the voltage read on the off-chip 10 kohm reference resistor. Ip60f is connected to r_ext=10 kohm and RP_CALIB_BIAS is changed until vr_ext becomes 600 mV.”
RP_CALIB_BIAS is only 5-bits and has a default value of 16, so it is in the middle of the range but only has a total of 32 discrete states or 32 possible temperatures steps. I’m not sure if the really low TCR of the external resistor is a good thing or bad thing, without knowing what Ip60f is in the circuitry inside the chip, it is difficult to know. There really needs to be more documentation available publicly.