Add iFlight Commando8
Add iFlight Commando8 ELRS radio
This commit is contained in:
@@ -44,6 +44,34 @@ void dacTimerInit()
|
||||
AUDIO_TIMER->CR1 = TIM_CR1_CEN ;
|
||||
}
|
||||
|
||||
#if defined(AUDIO_MUTE_GPIO_PIN)
|
||||
static inline void setMutePin(bool enabled)
|
||||
{
|
||||
if (enabled) {
|
||||
#if defined(INVERTED_MUTE_PIN)
|
||||
GPIO_ResetBits(AUDIO_MUTE_GPIO, AUDIO_MUTE_GPIO_PIN);
|
||||
#else
|
||||
GPIO_SetBits(AUDIO_MUTE_GPIO, AUDIO_MUTE_GPIO_PIN);
|
||||
#endif
|
||||
} else {
|
||||
#if defined(INVERTED_MUTE_PIN)
|
||||
GPIO_SetBits(AUDIO_MUTE_GPIO, AUDIO_MUTE_GPIO_PIN);
|
||||
#else
|
||||
GPIO_ResetBits(AUDIO_MUTE_GPIO, AUDIO_MUTE_GPIO_PIN);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool getMutePin(void)
|
||||
{
|
||||
#if defined(INVERTED_MUTE_PIN)
|
||||
return !GPIO_ReadOutputDataBit(AUDIO_MUTE_GPIO, AUDIO_MUTE_GPIO_PIN);
|
||||
#else
|
||||
return GPIO_ReadOutputDataBit(AUDIO_MUTE_GPIO, AUDIO_MUTE_GPIO_PIN);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
// Configure DAC0
|
||||
// Not sure why PB14 has not be allocated to the DAC, although it is an EXTRA function
|
||||
// So maybe it is automatically done
|
||||
@@ -60,7 +88,7 @@ void dacInit()
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
|
||||
GPIO_Init(AUDIO_MUTE_GPIO, &GPIO_InitStructure);
|
||||
GPIO_SetBits(AUDIO_MUTE_GPIO, AUDIO_MUTE_GPIO_PIN);
|
||||
setMutePin(true);
|
||||
#endif
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = AUDIO_OUTPUT_GPIO_PIN;
|
||||
@@ -100,11 +128,11 @@ void audioMute()
|
||||
}
|
||||
else if (now - audioQueue.lastAudioPlayTime > AUDIO_MUTE_DELAY / 10) {
|
||||
// delay expired, we may mute
|
||||
GPIO_SetBits(AUDIO_MUTE_GPIO, AUDIO_MUTE_GPIO_PIN);
|
||||
setMutePin(true);
|
||||
}
|
||||
#else
|
||||
// mute
|
||||
GPIO_SetBits(AUDIO_MUTE_GPIO, AUDIO_MUTE_GPIO_PIN);
|
||||
setMutePin(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -112,15 +140,15 @@ void audioUnmute()
|
||||
{
|
||||
#if defined(AUDIO_UNMUTE_DELAY)
|
||||
// if muted
|
||||
if (GPIO_ReadOutputDataBit(AUDIO_MUTE_GPIO, AUDIO_MUTE_GPIO_PIN)) {
|
||||
if (getMutePin()) {
|
||||
// ..un-mute
|
||||
GPIO_ResetBits(AUDIO_MUTE_GPIO, AUDIO_MUTE_GPIO_PIN);
|
||||
setMutePin(false);
|
||||
RTOS_WAIT_MS(AUDIO_UNMUTE_DELAY);
|
||||
}
|
||||
// reset the mute delay
|
||||
audioQueue.lastAudioPlayTime = 0;
|
||||
#else
|
||||
GPIO_ResetBits(AUDIO_MUTE_GPIO, AUDIO_MUTE_GPIO_PIN);
|
||||
setMutePin(false);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user