Merge pull request #2143 from betaflight/fix-transponder-hardfault
Prevent hard-fault when no IO available for transponder.
This commit is contained in:
commit
e539200e67
|
@ -39,7 +39,7 @@ uint8_t transponderIrDMABuffer[TRANSPONDER_DMA_BUFFER_SIZE];
|
|||
|
||||
volatile uint8_t transponderIrDataTransferInProgress = 0;
|
||||
|
||||
void transponderIrInit(void)
|
||||
bool transponderIrInit(void)
|
||||
{
|
||||
memset(&transponderIrDMABuffer, 0, TRANSPONDER_DMA_BUFFER_SIZE);
|
||||
|
||||
|
@ -51,7 +51,13 @@ void transponderIrInit(void)
|
|||
}
|
||||
}
|
||||
|
||||
if (!ioTag) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
transponderIrHardwareInit(ioTag);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool isTransponderIrReady(void)
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#define BIT_TOGGLE_1 78 // (156 / 2)
|
||||
#define BIT_TOGGLE_0 0
|
||||
|
||||
void transponderIrInit();
|
||||
bool transponderIrInit();
|
||||
void transponderIrDisable(void);
|
||||
|
||||
void transponderIrHardwareInit(ioTag_t ioTag);
|
||||
|
|
|
@ -45,10 +45,6 @@ static void TRANSPONDER_DMA_IRQHandler(dmaChannelDescriptor_t* descriptor)
|
|||
|
||||
void transponderIrHardwareInit(ioTag_t ioTag)
|
||||
{
|
||||
if (!ioTag) {
|
||||
return;
|
||||
}
|
||||
|
||||
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
|
||||
TIM_OCInitTypeDef TIM_OCInitStructure;
|
||||
DMA_InitTypeDef DMA_InitStructure;
|
||||
|
|
|
@ -490,7 +490,6 @@ void init(void)
|
|||
#ifdef TRANSPONDER
|
||||
if (feature(FEATURE_TRANSPONDER)) {
|
||||
transponderInit(masterConfig.transponderData);
|
||||
transponderEnable();
|
||||
transponderStartRepeating();
|
||||
systemState |= SYSTEM_STATE_TRANSPONDER_ENABLED;
|
||||
}
|
||||
|
|
|
@ -75,21 +75,14 @@ void transponderUpdate(timeUs_t currentTimeUs)
|
|||
|
||||
void transponderInit(uint8_t* transponderData)
|
||||
{
|
||||
transponderInitialised = false;
|
||||
transponderIrInit();
|
||||
transponderInitialised = transponderIrInit();
|
||||
if (!transponderInitialised) {
|
||||
return;
|
||||
}
|
||||
|
||||
transponderIrUpdateData(transponderData);
|
||||
}
|
||||
|
||||
void transponderEnable(void)
|
||||
{
|
||||
transponderInitialised = true;
|
||||
}
|
||||
|
||||
void transponderDisable(void)
|
||||
{
|
||||
transponderInitialised = false;
|
||||
}
|
||||
|
||||
void transponderStopRepeating(void)
|
||||
{
|
||||
transponderRepeat = false;
|
||||
|
@ -97,11 +90,19 @@ void transponderStopRepeating(void)
|
|||
|
||||
void transponderStartRepeating(void)
|
||||
{
|
||||
if (!transponderInitialised) {
|
||||
return;
|
||||
}
|
||||
|
||||
transponderRepeat = true;
|
||||
}
|
||||
|
||||
void transponderUpdateData(uint8_t* transponderData)
|
||||
{
|
||||
if (!transponderInitialised) {
|
||||
return;
|
||||
}
|
||||
|
||||
transponderIrUpdateData(transponderData);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,8 +21,6 @@
|
|||
|
||||
void transponderInit(uint8_t* transponderCode);
|
||||
|
||||
void transponderEnable(void);
|
||||
void transponderDisable(void);
|
||||
void transponderUpdate(timeUs_t currentTimeUs);
|
||||
void transponderUpdateData(uint8_t* transponderData);
|
||||
void transponderTransmitOnce(void);
|
||||
|
|
Loading…
Reference in New Issue