Temperature scaling changes for HackRF r9 (MAX2839) (#1561)

* Add files via upload

* Add files via upload

* Add files via upload
This commit is contained in:
Mark Thompson 2023-11-06 13:56:09 -06:00 committed by GitHub
parent 6784fe72dd
commit 68f960e4e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 19 additions and 17 deletions

View File

@ -124,8 +124,8 @@ void TemperatureWidget::paint(Painter& painter) {
}
TemperatureWidget::temperature_t TemperatureWidget::temperature(const sample_t sensor_value) const {
/*It seems to be a temperature difference of 25C*/
return -40 + (sensor_value * 4.31) + 25; // max2837 datasheet temp 25ºC has sensor value: 15
// Scaling is different for MAX2837 vs MAX2839 so it's now done in the respective chip-specific module
return sensor_value;
}
std::string TemperatureWidget::temperature_str(const temperature_t temperature) const {

View File

@ -321,7 +321,7 @@ void MAX2837::set_rx_buff_vcm(const size_t v) {
flush();
}
reg_t MAX2837::temp_sense() {
int8_t MAX2837::temp_sense() {
if (!_map.r.rx_top.ts_en) {
_map.r.rx_top.ts_en = 1;
flush_one(Register::RX_TOP);
@ -334,12 +334,15 @@ reg_t MAX2837::temp_sense() {
halPolledDelay(ticks_for_temperature_sense_adc_conversion);
const auto value = read(Register::TEMP_SENSE);
/*
* Conversion to degrees C determined by testing - does not match data sheet.
*/
reg_t value = read(Register::TEMP_SENSE) & 0x1F;
_map.r.rx_top.ts_adc_trigger = 0;
flush_one(Register::RX_TOP);
return value;
return value * 4.31 - 6; // reg value is 0 to 31; possible return range is -6 C to 127 C
}
} // namespace max2837

View File

@ -833,7 +833,7 @@ class MAX2837 : public MAX283x {
void set_vco_bias(const size_t v);
void set_rx_buff_vcm(const size_t v) override;
reg_t temp_sense() override;
int8_t temp_sense() override;
reg_t read(const address_t reg_num) override;

View File

@ -351,7 +351,7 @@ void MAX2839::set_rx_buff_vcm(const size_t v) {
flush();
}
reg_t MAX2839::temp_sense() {
int8_t MAX2839::temp_sense() {
if (!_map.r.rx_top_2.ts_en) {
_map.r.rx_top_2.ts_en = 1;
flush_one(Register::RX_TOP_2);
@ -365,15 +365,14 @@ reg_t MAX2839::temp_sense() {
halPolledDelay(ticks_for_temperature_sense_adc_conversion);
/*
* Things look very similar to MAX2837, so this probably works, but the
* MAX2839 data sheet does not describe the TEMP_SENSE register contents.
* Conversion to degrees C determined by testing - does not match data sheet.
*/
const auto value = read(Register::TEMP_SENSE);
reg_t value = read(Register::TEMP_SENSE) & 0x1F;
_map.r.rx_top_2.ts_adc_trigger = 0;
flush_one(Register::RX_TOP_2);
return value;
return value * 4.31 - 75; // reg value is 0 to 31; possible return range is -75 C to 58 C
}
} // namespace max2839

View File

@ -692,7 +692,7 @@ class MAX2839 : public MAX283x {
void set_rx_lo_iq_calibration(const size_t v) override;
void set_rx_buff_vcm(const size_t v) override;
reg_t temp_sense() override;
int8_t temp_sense() override;
reg_t read(const address_t reg_num) override;

View File

@ -131,7 +131,7 @@ class MAX283x {
virtual void set_rx_lo_iq_calibration(const size_t v);
virtual void set_rx_buff_vcm(const size_t v);
virtual reg_t temp_sense();
virtual int8_t temp_sense();
virtual reg_t read(const address_t reg_num);
};

View File

@ -295,8 +295,8 @@ uint32_t register_read(const size_t register_number) {
return radio::second_if->read(register_number);
}
uint8_t temp_sense() {
return radio::second_if->temp_sense() & 0x1f;
int8_t temp_sense() {
return radio::second_if->temp_sense();
}
} /* namespace second_if */

View File

@ -73,7 +73,7 @@ namespace second_if {
uint32_t register_read(const size_t register_number);
// TODO: This belongs somewhere else.
uint8_t temp_sense();
int8_t temp_sense();
} /* namespace second_if */

View File

@ -29,7 +29,7 @@
class TemperatureLogger {
public:
using sample_t = uint8_t;
using sample_t = int8_t;
void second_tick();