mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-12-28 08:49:45 -05:00
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:
parent
6784fe72dd
commit
68f960e4e7
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
};
|
||||
|
@ -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 */
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
class TemperatureLogger {
|
||||
public:
|
||||
using sample_t = uint8_t;
|
||||
using sample_t = int8_t;
|
||||
|
||||
void second_tick();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user