Preserve radio mode when updating iq_tx_phase_cal (#2008)

This commit is contained in:
Mark Thompson 2024-03-18 15:45:02 -05:00 committed by GitHub
parent 6e34343bde
commit 8383363e74
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 22 additions and 2 deletions

View file

@ -143,6 +143,8 @@ void MAX2839::init() {
}
void MAX2839::set_tx_LO_iq_phase_calibration(const size_t v) {
Mode saved_mode = get_mode();
/* IQ phase deg CAL adj (+4 ...-4) This IC in 64 steps (6 bits), 000000 = +4deg (Q lags I by 94degs, default), 011111 = +0deg, 111111 = -4deg (Q lags I by 86degs) */
// TX calibration , 2 x Logic pins , ENABLE, RXENABLE = 1,0, (2dec), and Reg address 16, D1 (CAL mode 1):DO (CHIP ENABLE 1)
@ -164,7 +166,7 @@ void MAX2839::set_tx_LO_iq_phase_calibration(const size_t v) {
_map.r.spi_en.EN_SPI = 1; // Register Settings reg address 16, DO (1 = Chip select enable )
flush_one(Register::SPI_EN);
set_mode(Mode::Standby); // Back 3 logic pins CALIBRATION mode -> Standby.
set_mode(saved_mode); // restore original mode
}
enum class Mask {
@ -196,11 +198,17 @@ Mask mode_mask(const Mode mode) {
}
void MAX2839::set_mode(const Mode mode) {
_mode = mode;
Mask mask = mode_mask(mode);
gpio_max283x_enable.write(toUType(mask) & toUType(Mask::Enable));
gpio_max2839_rxtx.write(toUType(mask) & toUType(Mask::RxTx));
}
Mode MAX2839::get_mode() {
return _mode;
}
void MAX2839::flush() {
if (_dirty) {
for (size_t n = 0; n < reg_count; n++) {