1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-25 17:25:13 +03:00

Fix FrSky D cable telementry for 9XR PRO and DJT module. (#5220)

* Fix FrSky D cable telementry for 9XR PRO and DJT module.

* Revert a breaking change.
This commit is contained in:
Roderick Taylor 2017-09-18 03:10:45 +10:00 committed by Bertrand Songis
parent 6f3577c9a5
commit 9cb4b782e1
3 changed files with 13 additions and 5 deletions

View file

@ -405,6 +405,7 @@ void rxPdcUsart( void (*pChProcess)(uint8_t x) );
// Second UART driver // Second UART driver
void serial2TelemetryInit(unsigned int protocol); void serial2TelemetryInit(unsigned int protocol);
void serial2Putc(const unsigned char c);
#if defined(__cplusplus) #if defined(__cplusplus)
bool telemetrySecondPortReceive(uint8_t & data); bool telemetrySecondPortReceive(uint8_t & data);
#endif #endif

View file

@ -37,12 +37,12 @@ Fifo<uint8_t, 512> serial2RxFifo;
* This function is synchronous (i.e. uses polling). * This function is synchronous (i.e. uses polling).
* c Character to send. * c Character to send.
*/ */
void serial2Putc(const char c) void serial2Putc(const unsigned char c)
{ {
Uart *pUart = SECOND_SERIAL_UART; Uart *pUart = SECOND_SERIAL_UART;
/* Wait for the transmitter to be ready */ /* Wait for the transmitter to be ready */
while ( (pUart->UART_SR & UART_SR_TXEMPTY) == 0 ) ; while ( (pUart->UART_SR & UART_SR_TXRDY) == 0 ) ;
/* Send character */ /* Send character */
pUart->UART_THR = c; pUart->UART_THR = c;
@ -99,8 +99,12 @@ void SECOND_UART_Stop()
extern "C" void UART0_IRQHandler() extern "C" void UART0_IRQHandler()
{ {
serial2RxFifo.push(SECOND_SERIAL_UART->UART_RHR); if ( SECOND_SERIAL_UART->UART_SR & UART_SR_RXRDY )
{
serial2RxFifo.push(SECOND_SERIAL_UART->UART_RHR);
}
} }
#else #else
#define SECOND_UART_Configure(...) #define SECOND_UART_Configure(...)
#endif #endif
@ -109,7 +113,6 @@ extern "C" void UART0_IRQHandler()
void serial2TelemetryInit(unsigned int /*protocol*/) void serial2TelemetryInit(unsigned int /*protocol*/)
{ {
SECOND_UART_Configure(FRSKY_D_BAUDRATE, Master_frequency); SECOND_UART_Configure(FRSKY_D_BAUDRATE, Master_frequency);
// startPdcUsartReceive();
} }
bool telemetrySecondPortReceive(uint8_t & data) bool telemetrySecondPortReceive(uint8_t & data)
@ -117,3 +120,7 @@ bool telemetrySecondPortReceive(uint8_t & data)
return serial2RxFifo.pop(data); return serial2RxFifo.pop(data);
} }
#endif #endif
#if defined(DEBUG)
void serialPrintf(const char*, ... ) {}
#endif

View file

@ -404,7 +404,7 @@ void telemetryInit(uint8_t protocol)
} }
#endif #endif
#if defined(SERIAL2) #if defined(SERIAL2) || defined(PCBSKY9X)
else if (protocol == PROTOCOL_FRSKY_D_SECONDARY) { else if (protocol == PROTOCOL_FRSKY_D_SECONDARY) {
telemetryPortInit(0, TELEMETRY_SERIAL_DEFAULT); telemetryPortInit(0, TELEMETRY_SERIAL_DEFAULT);
serial2TelemetryInit(PROTOCOL_FRSKY_D_SECONDARY); serial2TelemetryInit(PROTOCOL_FRSKY_D_SECONDARY);