mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-08-07 06:02:20 -04:00
Correctly map TX gain from dB to register value.
This commit is contained in:
parent
69173f5292
commit
45a1ccbc53
2 changed files with 23 additions and 3 deletions
|
@ -55,6 +55,18 @@ static uint_fast8_t gain_ordinal(const int8_t db) {
|
||||||
|
|
||||||
} /* namespace vga */
|
} /* namespace vga */
|
||||||
|
|
||||||
|
namespace tx {
|
||||||
|
|
||||||
|
static uint_fast8_t gain_ordinal(const int8_t db) {
|
||||||
|
const auto db_sat = gain_db_range.clip(db);
|
||||||
|
uint8_t value = db_sat & 0x0f;
|
||||||
|
value = (db_sat >= 16) ? (value | 0x20) : value;
|
||||||
|
value = (db_sat >= 32) ? (value | 0x10) : value;
|
||||||
|
return (value & 0b111111) ^ 0b111111;
|
||||||
|
}
|
||||||
|
|
||||||
|
} /* namespace tx */
|
||||||
|
|
||||||
namespace filter {
|
namespace filter {
|
||||||
|
|
||||||
static uint_fast8_t bandwidth_ordinal(const uint32_t bandwidth) {
|
static uint_fast8_t bandwidth_ordinal(const uint32_t bandwidth) {
|
||||||
|
@ -170,8 +182,8 @@ reg_t MAX2837::read(const Register reg) {
|
||||||
return read(toUType(reg));
|
return read(toUType(reg));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MAX2837::set_tx_vga_gain(const int_fast8_t value) {
|
void MAX2837::set_tx_vga_gain(const int_fast8_t db) {
|
||||||
_map.r.tx_gain.TXVGA_GAIN_SPI = value;
|
_map.r.tx_gain.TXVGA_GAIN_SPI = tx::gain_ordinal(db);
|
||||||
_dirty[Register::TX_GAIN] = 1;
|
_dirty[Register::TX_GAIN] = 1;
|
||||||
flush();
|
flush();
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,6 +83,14 @@ constexpr int8_t gain_db_step = 2;
|
||||||
|
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
|
namespace tx {
|
||||||
|
|
||||||
|
constexpr range_t<int8_t> gain_db_range { 0, 47 };
|
||||||
|
constexpr int8_t gain_db_step = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************/
|
||||||
|
|
||||||
namespace filter {
|
namespace filter {
|
||||||
|
|
||||||
constexpr std::array<uint32_t, 16> bandwidths {
|
constexpr std::array<uint32_t, 16> bandwidths {
|
||||||
|
@ -829,7 +837,7 @@ public:
|
||||||
void init();
|
void init();
|
||||||
void set_mode(const Mode mode);
|
void set_mode(const Mode mode);
|
||||||
|
|
||||||
void set_tx_vga_gain(const int_fast8_t value);
|
void set_tx_vga_gain(const int_fast8_t db);
|
||||||
void set_lna_gain(const int_fast8_t db);
|
void set_lna_gain(const int_fast8_t db);
|
||||||
void set_vga_gain(const int_fast8_t db);
|
void set_vga_gain(const int_fast8_t db);
|
||||||
void set_lpf_rf_bandwidth(const uint32_t bandwidth_minimum);
|
void set_lpf_rf_bandwidth(const uint32_t bandwidth_minimum);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue