Enable telemetry through the nice little cable on 9XR-PRRRO ;)

This commit is contained in:
bsongis
2014-06-23 17:24:38 +02:00
parent e96578c857
commit 9d4fbfc3ea
6 changed files with 63 additions and 41 deletions
+1 -2
View File
@@ -596,7 +596,7 @@ ifeq ($(PCB), $(filter $(PCB), SKY9X 9XRPRO))
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
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
ifeq ($(SDCARD), YES)
@@ -622,7 +622,6 @@ ifeq ($(PCB), $(filter $(PCB), SKY9X 9XRPRO))
ifeq ($(DEBUG), YES)
CPPSRC += debug.cpp
CPPSRC += targets/sky9x/debug_driver.cpp
SRC += targets/sky9x/syscalls.c
endif
endif
-21
View File
@@ -36,29 +36,12 @@
#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;
uint32_t Master_frequency ;
volatile uint32_t Tenms ;
volatile uint8_t lcdLock;
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 ) ;
// Prototype
@@ -124,7 +107,6 @@ inline void setup_switches()
inline void UART3_Configure(uint32_t baudrate, uint32_t masterClock)
{
// const Pin pPins[] = CONSOLE_PINS;
register Uart *pUart = BT_USART;
/* Configure PIO */
@@ -589,9 +571,6 @@ void boardInit()
PMC->PMC_SCER |= 0x0400 ; // PCK2 enabled
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_timer0() ;
adcInit() ;
+4
View File
@@ -291,4 +291,8 @@ void telemetryPortInit(uint32_t baudrate);
uint32_t telemetryTransmitPending();
void telemetryTransmitBuffer(uint8_t * buffer, uint32_t size);
// Second UART driver
void telemetrySecondPortInit(unsigned int protocol);
uint16_t telemetrySecondPortReceive();
#endif
@@ -37,6 +37,13 @@
#include "../opentx.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)
extern Fifo<512> debugRxFifo;
@@ -49,7 +56,7 @@ extern Fifo<512> debugRxFifo;
*/
void debugPutc(const char c)
{
Uart *pUart = CONSOLE_USART;
Uart *pUart = SECOND_SERIAL_UART;
/* Wait for the transmitter to be ready */
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).
* 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_pins( (PIO_PA9 | PIO_PA10), PIN_PERIPHERAL | PIN_INPUT | PIN_PER_A | PIN_PORTA | PIN_NO_PULLUP ) ;
/* Configure PMC */
PMC->PMC_PCER0 = 1 << CONSOLE_ID;
PMC->PMC_PCER0 = 1 << SECOND_SERIAL_ID;
/* Reset and disable receiver & transmitter */
pUart->UART_CR = UART_CR_RSTRX | UART_CR_RSTTX
| UART_CR_RXDIS | UART_CR_TXDIS;
/* Configure mode */
pUart->UART_MR = 0x800 ; // NORMAL, No Parity
pUart->UART_MR = 0x800 ; // NORMAL, No Parity
/* Configure baudrate */
/* Asynchronous, no oversampling */
@@ -91,19 +98,42 @@ void DEBUG_UART_Configure( uint32_t baudrate, uint32_t masterClock)
/* Enable receiver and transmitter */
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) ;
}
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 ;
}
+6 -5
View File
@@ -113,11 +113,6 @@ extern uint16_t sessionTimer;
void delaysInit(void);
#define DEBUG_BAUDRATE 115200
void uart3Init(unsigned int mode, unsigned int protocol);
void uart3Putc(const char c);
void delaysInit(void);
void delay_01us(uint16_t nb);
@@ -259,6 +254,12 @@ void hapticOff(void);
#define HAPTIC_ON() hapticOn()
#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;
#endif
+11 -2
View File
@@ -303,7 +303,16 @@ void telemetryWakeup()
#endif
}
#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
#if !defined(PCBTARANIS)
@@ -577,7 +586,7 @@ void telemetryInit(void)
}
else if (telemetryProtocol==PROTOCOL_FRSKY_D_SECONDARY) {
telemetryPortInit(0);
uart3Init(UART_MODE_TELEMETRY, PROTOCOL_FRSKY_D_SECONDARY);
telemetrySecondPortInit(PROTOCOL_FRSKY_D_SECONDARY);
}
else {
telemetryPortInit(FRSKY_SPORT_BAUDRATE);