Prevent hard-fault when no IO available for transponder.

This cleans up the transponder api too.
This commit is contained in:
Hydra 2017-01-16 19:27:20 +00:00
parent b7caf6f85e
commit 3c29725672
6 changed files with 21 additions and 21 deletions

View File

@ -39,7 +39,7 @@ uint8_t transponderIrDMABuffer[TRANSPONDER_DMA_BUFFER_SIZE];
volatile uint8_t transponderIrDataTransferInProgress = 0; volatile uint8_t transponderIrDataTransferInProgress = 0;
void transponderIrInit(void) bool transponderIrInit(void)
{ {
memset(&transponderIrDMABuffer, 0, TRANSPONDER_DMA_BUFFER_SIZE); memset(&transponderIrDMABuffer, 0, TRANSPONDER_DMA_BUFFER_SIZE);
@ -51,7 +51,13 @@ void transponderIrInit(void)
} }
} }
if (!ioTag) {
return false;
}
transponderIrHardwareInit(ioTag); transponderIrHardwareInit(ioTag);
return true;
} }
bool isTransponderIrReady(void) bool isTransponderIrReady(void)

View File

@ -30,7 +30,7 @@
#define BIT_TOGGLE_1 78 // (156 / 2) #define BIT_TOGGLE_1 78 // (156 / 2)
#define BIT_TOGGLE_0 0 #define BIT_TOGGLE_0 0
void transponderIrInit(); bool transponderIrInit();
void transponderIrDisable(void); void transponderIrDisable(void);
void transponderIrHardwareInit(ioTag_t ioTag); void transponderIrHardwareInit(ioTag_t ioTag);

View File

@ -45,10 +45,6 @@ static void TRANSPONDER_DMA_IRQHandler(dmaChannelDescriptor_t* descriptor)
void transponderIrHardwareInit(ioTag_t ioTag) void transponderIrHardwareInit(ioTag_t ioTag)
{ {
if (!ioTag) {
return;
}
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
TIM_OCInitTypeDef TIM_OCInitStructure; TIM_OCInitTypeDef TIM_OCInitStructure;
DMA_InitTypeDef DMA_InitStructure; DMA_InitTypeDef DMA_InitStructure;

View File

@ -490,7 +490,6 @@ void init(void)
#ifdef TRANSPONDER #ifdef TRANSPONDER
if (feature(FEATURE_TRANSPONDER)) { if (feature(FEATURE_TRANSPONDER)) {
transponderInit(masterConfig.transponderData); transponderInit(masterConfig.transponderData);
transponderEnable();
transponderStartRepeating(); transponderStartRepeating();
systemState |= SYSTEM_STATE_TRANSPONDER_ENABLED; systemState |= SYSTEM_STATE_TRANSPONDER_ENABLED;
} }

View File

@ -75,21 +75,14 @@ void transponderUpdate(timeUs_t currentTimeUs)
void transponderInit(uint8_t* transponderData) void transponderInit(uint8_t* transponderData)
{ {
transponderInitialised = false; transponderInitialised = transponderIrInit();
transponderIrInit(); if (!transponderInitialised) {
return;
}
transponderIrUpdateData(transponderData); transponderIrUpdateData(transponderData);
} }
void transponderEnable(void)
{
transponderInitialised = true;
}
void transponderDisable(void)
{
transponderInitialised = false;
}
void transponderStopRepeating(void) void transponderStopRepeating(void)
{ {
transponderRepeat = false; transponderRepeat = false;
@ -97,11 +90,19 @@ void transponderStopRepeating(void)
void transponderStartRepeating(void) void transponderStartRepeating(void)
{ {
if (!transponderInitialised) {
return;
}
transponderRepeat = true; transponderRepeat = true;
} }
void transponderUpdateData(uint8_t* transponderData) void transponderUpdateData(uint8_t* transponderData)
{ {
if (!transponderInitialised) {
return;
}
transponderIrUpdateData(transponderData); transponderIrUpdateData(transponderData);
} }

View File

@ -21,8 +21,6 @@
void transponderInit(uint8_t* transponderCode); void transponderInit(uint8_t* transponderCode);
void transponderEnable(void);
void transponderDisable(void);
void transponderUpdate(timeUs_t currentTimeUs); void transponderUpdate(timeUs_t currentTimeUs);
void transponderUpdateData(uint8_t* transponderData); void transponderUpdateData(uint8_t* transponderData);
void transponderTransmitOnce(void); void transponderTransmitOnce(void);