Enable telemetry through the nice little cable on 9XR-PRRRO ;)
This commit is contained in:
+1
-2
@@ -596,7 +596,7 @@ ifeq ($(PCB), $(filter $(PCB), SKY9X 9XRPRO))
|
|||||||
EEPROMSRC = eeprom_common.cpp eeprom_raw.cpp eeprom_conversions.cpp
|
EEPROMSRC = eeprom_common.cpp eeprom_raw.cpp eeprom_conversions.cpp
|
||||||
PULSESSRC = pulses/pulses_arm.cpp pulses/ppm_arm.cpp pulses/pxx_arm.cpp pulses/dsm2_arm.cpp
|
PULSESSRC = pulses/pulses_arm.cpp pulses/ppm_arm.cpp pulses/pxx_arm.cpp pulses/dsm2_arm.cpp
|
||||||
CPPSRC += audio_arm.cpp haptic.cpp gui/view_about.cpp gui/view_text.cpp
|
CPPSRC += audio_arm.cpp haptic.cpp gui/view_about.cpp gui/view_text.cpp
|
||||||
CPPSRC += targets/sky9x/telemetry_driver.cpp targets/sky9x/pwr_driver.cpp targets/sky9x/adc_driver.cpp targets/sky9x/eeprom_driver.cpp targets/sky9x/pulses_driver.cpp targets/sky9x/keys_driver.cpp targets/sky9x/audio_driver.cpp targets/sky9x/buzzer_driver.cpp targets/sky9x/haptic_driver.cpp targets/sky9x/sdcard_driver.cpp targets/sky9x/massstorage.cpp
|
CPPSRC += targets/sky9x/telemetry_driver.cpp targets/sky9x/second_serial_driver.cpp targets/sky9x/pwr_driver.cpp targets/sky9x/adc_driver.cpp targets/sky9x/eeprom_driver.cpp targets/sky9x/pulses_driver.cpp targets/sky9x/keys_driver.cpp targets/sky9x/audio_driver.cpp targets/sky9x/buzzer_driver.cpp targets/sky9x/haptic_driver.cpp targets/sky9x/sdcard_driver.cpp targets/sky9x/massstorage.cpp
|
||||||
CPPSRC += loadboot.cpp
|
CPPSRC += loadboot.cpp
|
||||||
|
|
||||||
ifeq ($(SDCARD), YES)
|
ifeq ($(SDCARD), YES)
|
||||||
@@ -622,7 +622,6 @@ ifeq ($(PCB), $(filter $(PCB), SKY9X 9XRPRO))
|
|||||||
|
|
||||||
ifeq ($(DEBUG), YES)
|
ifeq ($(DEBUG), YES)
|
||||||
CPPSRC += debug.cpp
|
CPPSRC += debug.cpp
|
||||||
CPPSRC += targets/sky9x/debug_driver.cpp
|
|
||||||
SRC += targets/sky9x/syscalls.c
|
SRC += targets/sky9x/syscalls.c
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -36,29 +36,12 @@
|
|||||||
|
|
||||||
#include "../../opentx.h"
|
#include "../../opentx.h"
|
||||||
|
|
||||||
#if defined(DEBUG) && !defined(SIMU)
|
|
||||||
void DEBUG_UART_Configure( uint32_t baudrate, uint32_t masterClock);
|
|
||||||
void DEBUG_UART_Stop();
|
|
||||||
#else
|
|
||||||
#define DEBUG_UART_Stop()
|
|
||||||
#define DEBUG_UART_Configure(...)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
uint16_t ResetReason;
|
uint16_t ResetReason;
|
||||||
uint32_t Master_frequency ;
|
uint32_t Master_frequency ;
|
||||||
volatile uint32_t Tenms ;
|
volatile uint32_t Tenms ;
|
||||||
volatile uint8_t lcdLock;
|
volatile uint8_t lcdLock;
|
||||||
volatile uint32_t lcdInputs;
|
volatile uint32_t lcdInputs;
|
||||||
|
|
||||||
/** Console baudrate 9600. */
|
|
||||||
#define CONSOLE_BAUDRATE 9600
|
|
||||||
/** Usart Hw interface used by the console (UART0). */
|
|
||||||
#define CONSOLE_USART UART0
|
|
||||||
/** Usart Hw ID used by the console (UART0). */
|
|
||||||
#define CONSOLE_ID ID_UART0
|
|
||||||
/** Pins description corresponding to Rxd,Txd, (UART pins) */
|
|
||||||
#define CONSOLE_PINS {PINS_UART}
|
|
||||||
|
|
||||||
extern "C" void sam_boot( void ) ;
|
extern "C" void sam_boot( void ) ;
|
||||||
|
|
||||||
// Prototype
|
// Prototype
|
||||||
@@ -124,7 +107,6 @@ inline void setup_switches()
|
|||||||
|
|
||||||
inline void UART3_Configure(uint32_t baudrate, uint32_t masterClock)
|
inline void UART3_Configure(uint32_t baudrate, uint32_t masterClock)
|
||||||
{
|
{
|
||||||
// const Pin pPins[] = CONSOLE_PINS;
|
|
||||||
register Uart *pUart = BT_USART;
|
register Uart *pUart = BT_USART;
|
||||||
|
|
||||||
/* Configure PIO */
|
/* Configure PIO */
|
||||||
@@ -589,9 +571,6 @@ void boardInit()
|
|||||||
PMC->PMC_SCER |= 0x0400 ; // PCK2 enabled
|
PMC->PMC_SCER |= 0x0400 ; // PCK2 enabled
|
||||||
PMC->PMC_PCK[2] = 2 ; // PCK2 is PLLA
|
PMC->PMC_PCK[2] = 2 ; // PCK2 is PLLA
|
||||||
|
|
||||||
DEBUG_UART_Configure( 9600, Master_frequency ) ;
|
|
||||||
UART3_Configure( 9600, Master_frequency ) ; // TODO not needed, done after ...
|
|
||||||
|
|
||||||
start_timer2() ;
|
start_timer2() ;
|
||||||
start_timer0() ;
|
start_timer0() ;
|
||||||
adcInit() ;
|
adcInit() ;
|
||||||
|
|||||||
@@ -291,4 +291,8 @@ void telemetryPortInit(uint32_t baudrate);
|
|||||||
uint32_t telemetryTransmitPending();
|
uint32_t telemetryTransmitPending();
|
||||||
void telemetryTransmitBuffer(uint8_t * buffer, uint32_t size);
|
void telemetryTransmitBuffer(uint8_t * buffer, uint32_t size);
|
||||||
|
|
||||||
|
// Second UART driver
|
||||||
|
void telemetrySecondPortInit(unsigned int protocol);
|
||||||
|
uint16_t telemetrySecondPortReceive();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+41
-11
@@ -37,6 +37,13 @@
|
|||||||
#include "../opentx.h"
|
#include "../opentx.h"
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
/** Usart Hw interface used by the console (UART0). */
|
||||||
|
#define SECOND_SERIAL_UART UART0
|
||||||
|
/** Usart Hw ID used by the console (UART0). */
|
||||||
|
#define SECOND_SERIAL_ID ID_UART0
|
||||||
|
/** Pins description corresponding to Rxd,Txd, (UART pins) */
|
||||||
|
#define SECOND_SERIAL_PINS {PINS_UART}
|
||||||
|
|
||||||
#if !defined(SIMU)
|
#if !defined(SIMU)
|
||||||
|
|
||||||
extern Fifo<512> debugRxFifo;
|
extern Fifo<512> debugRxFifo;
|
||||||
@@ -49,7 +56,7 @@ extern Fifo<512> debugRxFifo;
|
|||||||
*/
|
*/
|
||||||
void debugPutc(const char c)
|
void debugPutc(const char c)
|
||||||
{
|
{
|
||||||
Uart *pUart = CONSOLE_USART;
|
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_TXEMPTY) == 0 ) ;
|
||||||
@@ -65,22 +72,22 @@ void debugPutc(const char c)
|
|||||||
* masterClock Frequency of the system master clock (in Hz).
|
* masterClock Frequency of the system master clock (in Hz).
|
||||||
* uses PA9 and PA10, RXD2 and TXD2
|
* uses PA9 and PA10, RXD2 and TXD2
|
||||||
*/
|
*/
|
||||||
void DEBUG_UART_Configure( uint32_t baudrate, uint32_t masterClock)
|
void SECOND_UART_Configure(uint32_t baudrate, uint32_t masterClock)
|
||||||
{
|
{
|
||||||
register Uart *pUart = CONSOLE_USART;
|
register Uart *pUart = SECOND_SERIAL_UART;
|
||||||
|
|
||||||
/* Configure PIO */
|
/* Configure PIO */
|
||||||
configure_pins( (PIO_PA9 | PIO_PA10), PIN_PERIPHERAL | PIN_INPUT | PIN_PER_A | PIN_PORTA | PIN_NO_PULLUP ) ;
|
configure_pins( (PIO_PA9 | PIO_PA10), PIN_PERIPHERAL | PIN_INPUT | PIN_PER_A | PIN_PORTA | PIN_NO_PULLUP ) ;
|
||||||
|
|
||||||
/* Configure PMC */
|
/* Configure PMC */
|
||||||
PMC->PMC_PCER0 = 1 << CONSOLE_ID;
|
PMC->PMC_PCER0 = 1 << SECOND_SERIAL_ID;
|
||||||
|
|
||||||
/* Reset and disable receiver & transmitter */
|
/* Reset and disable receiver & transmitter */
|
||||||
pUart->UART_CR = UART_CR_RSTRX | UART_CR_RSTTX
|
pUart->UART_CR = UART_CR_RSTRX | UART_CR_RSTTX
|
||||||
| UART_CR_RXDIS | UART_CR_TXDIS;
|
| UART_CR_RXDIS | UART_CR_TXDIS;
|
||||||
|
|
||||||
/* Configure mode */
|
/* Configure mode */
|
||||||
pUart->UART_MR = 0x800 ; // NORMAL, No Parity
|
pUart->UART_MR = 0x800 ; // NORMAL, No Parity
|
||||||
|
|
||||||
/* Configure baudrate */
|
/* Configure baudrate */
|
||||||
/* Asynchronous, no oversampling */
|
/* Asynchronous, no oversampling */
|
||||||
@@ -91,19 +98,42 @@ void DEBUG_UART_Configure( uint32_t baudrate, uint32_t masterClock)
|
|||||||
|
|
||||||
/* Enable receiver and transmitter */
|
/* Enable receiver and transmitter */
|
||||||
pUart->UART_CR = UART_CR_RXEN | UART_CR_TXEN;
|
pUart->UART_CR = UART_CR_RXEN | UART_CR_TXEN;
|
||||||
pUart->UART_IER = UART_IER_RXRDY ;
|
|
||||||
NVIC_EnableIRQ(UART0_IRQn) ;
|
#if defined(DEBUG)
|
||||||
|
pUart->UART_IER = UART_IER_RXRDY;
|
||||||
|
NVIC_EnableIRQ(UART0_IRQn);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void DEBUG_UART_Stop()
|
void SECOND_UART_Stop()
|
||||||
{
|
{
|
||||||
CONSOLE_USART->UART_IDR = UART_IDR_RXRDY ;
|
SECOND_SERIAL_UART->UART_IDR = UART_IDR_RXRDY ;
|
||||||
NVIC_DisableIRQ(UART0_IRQn) ;
|
NVIC_DisableIRQ(UART0_IRQn) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void UART0_IRQHandler()
|
extern "C" void UART0_IRQHandler()
|
||||||
{
|
{
|
||||||
debugRxFifo.push(CONSOLE_USART->UART_RHR);
|
#if defined(DEBUG)
|
||||||
|
debugRxFifo.push(SECOND_SERIAL_UART->UART_RHR);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#define SECOND_UART_Configure(...)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void telemetrySecondPortInit(unsigned int /*protocol*/)
|
||||||
|
{
|
||||||
|
SECOND_UART_Configure(FRSKY_D_BAUDRATE, Master_frequency);
|
||||||
|
startPdcUsartReceive();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
uint16_t telemetrySecondPortReceive()
|
||||||
|
{
|
||||||
|
Uart *pUart = SECOND_SERIAL_UART;
|
||||||
|
|
||||||
|
if (pUart->UART_SR & UART_SR_RXRDY) {
|
||||||
|
return pUart->UART_RHR ;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0xFFFF ;
|
||||||
|
}
|
||||||
@@ -113,11 +113,6 @@ extern uint16_t sessionTimer;
|
|||||||
|
|
||||||
void delaysInit(void);
|
void delaysInit(void);
|
||||||
|
|
||||||
#define DEBUG_BAUDRATE 115200
|
|
||||||
|
|
||||||
void uart3Init(unsigned int mode, unsigned int protocol);
|
|
||||||
void uart3Putc(const char c);
|
|
||||||
|
|
||||||
void delaysInit(void);
|
void delaysInit(void);
|
||||||
void delay_01us(uint16_t nb);
|
void delay_01us(uint16_t nb);
|
||||||
|
|
||||||
@@ -259,6 +254,12 @@ void hapticOff(void);
|
|||||||
#define HAPTIC_ON() hapticOn()
|
#define HAPTIC_ON() hapticOn()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// UART3 driver
|
||||||
|
#define DEBUG_BAUDRATE 115200
|
||||||
|
void uart3Init(unsigned int mode, unsigned int protocol);
|
||||||
|
void uart3Putc(const char c);
|
||||||
|
#define telemetrySecondPortInit(protocol) uart3Init(UART_MODE_TELEMETRY, protocol)
|
||||||
|
|
||||||
extern uint8_t currentTrainerMode;
|
extern uint8_t currentTrainerMode;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -303,7 +303,16 @@ void telemetryWakeup()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#elif defined(PCBSKY9X)
|
#elif defined(PCBSKY9X)
|
||||||
rxPdcUsart(processSerialData); // Receive serial data here
|
if (telemetryProtocol == PROTOCOL_FRSKY_D_SECONDARY) {
|
||||||
|
uint16_t data ;
|
||||||
|
while ((data=telemetrySecondPortReceive()) != 0xFFFF) {
|
||||||
|
processSerialData(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Receive serial data here
|
||||||
|
rxPdcUsart(processSerialData);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(PCBTARANIS)
|
#if !defined(PCBTARANIS)
|
||||||
@@ -577,7 +586,7 @@ void telemetryInit(void)
|
|||||||
}
|
}
|
||||||
else if (telemetryProtocol==PROTOCOL_FRSKY_D_SECONDARY) {
|
else if (telemetryProtocol==PROTOCOL_FRSKY_D_SECONDARY) {
|
||||||
telemetryPortInit(0);
|
telemetryPortInit(0);
|
||||||
uart3Init(UART_MODE_TELEMETRY, PROTOCOL_FRSKY_D_SECONDARY);
|
telemetrySecondPortInit(PROTOCOL_FRSKY_D_SECONDARY);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
telemetryPortInit(FRSKY_SPORT_BAUDRATE);
|
telemetryPortInit(FRSKY_SPORT_BAUDRATE);
|
||||||
|
|||||||
Reference in New Issue
Block a user