[Taranis] SPORT Rx must be OFF when Tx is ON (otherwise it receives what

it sends...)
This commit is contained in:
bsongis
2015-03-14 11:48:54 +01:00
parent fdb48528f9
commit d885807c11
+12 -7
View File
@@ -97,6 +97,7 @@ void sportSendBuffer(uint8_t *buffer, uint32_t count)
sportTxBuffer.ptr = buffer ; sportTxBuffer.ptr = buffer ;
sportTxBuffer.count = count ; sportTxBuffer.count = count ;
GPIO_PIN_SPORT_ON->BSRRL = PIN_SPORT_ON ; // output enable GPIO_PIN_SPORT_ON->BSRRL = PIN_SPORT_ON ; // output enable
SPORT_USART->CR1 &= ~USART_CR1_RE ; // turn off receiver
SPORT_USART->CR1 |= USART_CR1_TXEIE ; SPORT_USART->CR1 |= USART_CR1_TXEIE ;
} }
@@ -114,23 +115,27 @@ extern "C" void SPORT_IRQHandler()
if (sportTxBuffer.count) { if (sportTxBuffer.count) {
SPORT_USART->DR = *sportTxBuffer.ptr++; SPORT_USART->DR = *sportTxBuffer.ptr++;
if (--sportTxBuffer.count == 0) { if (--sportTxBuffer.count == 0) {
SPORT_USART->CR1 &= ~USART_CR1_TXEIE; // Stop Tx interrupt SPORT_USART->CR1 &= ~USART_CR1_TXEIE; // stop Tx interrupt
SPORT_USART->CR1 |= USART_CR1_TCIE; // Enable complete interrupt SPORT_USART->CR1 |= USART_CR1_TCIE; // enable complete interrupt
} }
} }
} }
if (SPORT_USART->SR & USART_SR_TC) { if ((status & USART_SR_TC) && (SPORT_USART->CR1 & USART_CR1_TCIE))
SPORT_USART->CR1 &= ~USART_CR1_TCIE ; // Stop Complete interrupt SPORT_USART->CR1 &= ~USART_CR1_TCIE ; // stop Complete interrupt
GPIO_PIN_SPORT_ON->BSRRH = PIN_SPORT_ON ; // output disable GPIO_PIN_SPORT_ON->BSRRH = PIN_SPORT_ON ; // output disable
SPORT_USART->CR1 |= USART_CR1_RE ;
while (status & (USART_FLAG_RXNE)) {
status = SPORT_USART->DR;
status = SPORT_USART->SR ;
}
} }
while (status & (USART_FLAG_RXNE | USART_FLAG_ERRORS)) { while (status & (USART_FLAG_RXNE | USART_FLAG_ERRORS)) {
data = SPORT_USART->DR; data = SPORT_USART->DR;
if (!(status & USART_FLAG_ERRORS)) {
if (!(status & USART_FLAG_ERRORS))
telemetryFifo.push(data); telemetryFifo.push(data);
}
status = SPORT_USART->SR; status = SPORT_USART->SR;
} }
} }