Module17: implemented configurable logic levels for PTT in/out

See #248
pull/256/head
Silvano Seva 2024-03-09 11:20:31 +01:00
rodzic 87314db133
commit ed92d81543
6 zmienionych plików z 54 dodań i 13 usunięć

Wyświetl plik

@ -30,12 +30,14 @@
*/
typedef struct
{
uint16_t tx_wiper;
uint16_t rx_wiper;
uint8_t mic_gain;
uint8_t tx_invert : 1,
rx_invert : 1,
_padding : 6;
uint16_t tx_wiper; ///< Baseband TX potentiometer
uint16_t rx_wiper; ///< Baseband RX potentiometer
uint8_t mic_gain; ///< Microphone gain
uint8_t tx_invert : 1, ///< Invert TX baseband
rx_invert : 1, ///< Invert RX baseband
ptt_in_level : 1, ///< PTT in acive level
ptt_out_level : 1, ///< PTT out active level
_padding : 4;
}
mod17Calib_t;

Wyświetl plik

@ -133,7 +133,9 @@ enum module17Items
D_RXWIPER,
D_TXINVERT,
D_RXINVERT,
D_MICGAIN
D_MICGAIN,
D_PTTINLEVEL,
D_PTTOUTLEVEL
};
/**

Wyświetl plik

@ -104,7 +104,9 @@ const char *module17_items[] =
"RX Softpot",
"TX Phase",
"RX Phase",
"Mic Gain"
"Mic Gain",
"PTT In",
"PTT Out"
};
#ifdef CONFIG_GPS
@ -1000,6 +1002,12 @@ void ui_updateFSM(bool *sync_rtx)
case D_MICGAIN:
_ui_changeMicGain(-1);
break;
case D_PTTINLEVEL:
mod17CalData.ptt_in_level -= 1;
break;
case D_PTTOUTLEVEL:
mod17CalData.ptt_out_level -= 1;
break;
default:
state.ui_screen = SETTINGS_MODULE17;
}
@ -1023,6 +1031,12 @@ void ui_updateFSM(bool *sync_rtx)
case D_MICGAIN:
_ui_changeMicGain(+1);
break;
case D_PTTINLEVEL:
mod17CalData.ptt_in_level += 1;
break;
case D_PTTOUTLEVEL:
mod17CalData.ptt_out_level += 1;
break;
default:
state.ui_screen = SETTINGS_MODULE17;
}

Wyświetl plik

@ -240,6 +240,12 @@ int _ui_getModule17ValueName(char *buf, uint8_t max_len, uint8_t index)
case D_MICGAIN:
snprintf(buf, max_len, "%s", mic_gain_values[mod17CalData.mic_gain]);
break;
case D_PTTINLEVEL:
snprintf(buf, max_len, "%s", mod17CalData.ptt_in_level ? "Act high" : "Act low");
break;
case D_PTTOUTLEVEL:
snprintf(buf, max_len, "%s", mod17CalData.ptt_out_level ? "Act high" : "Act low");
break;
}
return 0;

Wyświetl plik

@ -73,25 +73,38 @@ void radio_disableAfOutput()
void radio_enableRx()
{
radioStatus = RX;
gpio_clearPin(PTT_OUT);
mcp4551_setWiper(SOFTPOT_TX, mod17CalData.tx_wiper);
mcp4551_setWiper(SOFTPOT_RX, mod17CalData.rx_wiper);
// Module17 PTT output is open drain. This means that, on MCU side, we have
// to assert the gpio to bring it to low state.
if(mod17CalData.ptt_out_level)
gpio_setPin(PTT_OUT);
else
gpio_clearPin(PTT_OUT);
}
void radio_enableTx()
{
radioStatus = TX;
gpio_setPin(PTT_OUT);
mcp4551_setWiper(SOFTPOT_TX, mod17CalData.tx_wiper);
mcp4551_setWiper(SOFTPOT_RX, mod17CalData.rx_wiper);
max9814_setGain(mod17CalData.mic_gain);
if(mod17CalData.ptt_out_level)
gpio_clearPin(PTT_OUT);
else
gpio_setPin(PTT_OUT);
}
void radio_disableRtx()
{
if(mod17CalData.ptt_out_level)
gpio_setPin(PTT_OUT);
else
gpio_clearPin(PTT_OUT);
}
void radio_updateConfiguration()

Wyświetl plik

@ -135,8 +135,12 @@ int8_t platform_getChSelector()
bool platform_getPttStatus()
{
/* PTT line has a pullup resistor with PTT switch closing to ground */
return (gpio_readPin(PTT_SW) == 0) ? true : false;
// Return true if gpio status matches the PTT in active level
uint8_t ptt_status = gpio_readPin(PTT_SW);
if(ptt_status == mod17CalData.ptt_in_level)
return true;
return false;
}
bool platform_pwrButtonStatus()