@@ -148,7 +148,7 @@ endif()
|
||||
|
||||
if(MULTIMODULE)
|
||||
add_definitions(-DMULTIMODULE)
|
||||
set(SRC ${SRC} pulses/multi.cpp telemetry/spektrum.cpp telemetry/flysky_ibus.cpp telemetry/hitec.cpp telemetry/hott.cpp telemetry/multi.cpp io/multi_firmware_update.cpp)
|
||||
set(SRC ${SRC} pulses/multi.cpp telemetry/spektrum.cpp telemetry/hitec.cpp telemetry/hott.cpp telemetry/multi.cpp io/multi_firmware_update.cpp)
|
||||
endif()
|
||||
|
||||
if(CROSSFIRE)
|
||||
@@ -163,6 +163,18 @@ if(CROSSFIRE)
|
||||
)
|
||||
endif()
|
||||
|
||||
if(AFHDS3)
|
||||
add_definitions(-DAFHDS3)
|
||||
set(PULSES_SRC
|
||||
${PULSES_SRC}
|
||||
afhds3.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
if(MULTIMODULE OR AFHDS3)
|
||||
set(SRC ${SRC} telemetry/flysky_ibus.cpp )
|
||||
endif()
|
||||
|
||||
add_definitions(-DCPUARM)
|
||||
add_definitions(-DGPS)
|
||||
add_definitions(-DBOLD_FONT -DBATTGRAPH -DTHRTRACE)
|
||||
|
||||
@@ -2,6 +2,7 @@ option(DISK_CACHE "Enable SD card disk cache" ON)
|
||||
option(UNEXPECTED_SHUTDOWN "Enable the Unexpected Shutdown screen" ON)
|
||||
option(PXX1 "PXX1 protocol support" ON)
|
||||
option(PXX2 "PXX2 protocol support" OFF)
|
||||
option(AFHDS3 "AFHDS3 TX Module" ON)
|
||||
option(MULTIMODULE "DIY Multiprotocol TX Module (https://github.com/pascallanger/DIY-Multiprotocol-TX-Module)" ON)
|
||||
|
||||
set(PWR_BUTTON "PRESS" CACHE STRING "Pwr button type (PRESS/SWITCH)")
|
||||
|
||||
@@ -316,6 +316,30 @@ void extmoduleSendNextFrame()
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if defined(AFHDS3)
|
||||
case PROTOCOL_CHANNELS_AFHDS3:
|
||||
{
|
||||
#if defined(EXTMODULE_USART) && defined(EXTMODULE_TX_INVERT_GPIO)
|
||||
extmoduleSendBuffer(extmodulePulsesData.afhds3.getData(), extmodulePulsesData.afhds3.getSize());
|
||||
#else
|
||||
const uint16_t* dataPtr = extmodulePulsesData.afhds3.getData();
|
||||
uint32_t dataSize = extmodulePulsesData.afhds3.getSize();
|
||||
//Peripheral data size
|
||||
//we know that afdhds3 uses 2 byte values!
|
||||
uint32_t dmaSize = (EXTMODULE_TIMER_DMA_SIZE & (DMA_SxCR_PSIZE_0 | DMA_SxCR_PSIZE_1)) | DMA_SxCR_MSIZE_0;
|
||||
|
||||
EXTMODULE_TIMER->CCR2 = dataPtr[dataSize -1] - 4000; // 2mS in advance
|
||||
EXTMODULE_TIMER_DMA_STREAM->CR &= ~DMA_SxCR_EN; // Disable DMA
|
||||
EXTMODULE_TIMER_DMA_STREAM->CR |= EXTMODULE_TIMER_DMA_CHANNEL | DMA_SxCR_DIR_0 | DMA_SxCR_MINC | dmaSize | DMA_SxCR_PL_0 | DMA_SxCR_PL_1;
|
||||
EXTMODULE_TIMER_DMA_STREAM->PAR = CONVERT_PTR_UINT(&EXTMODULE_TIMER->ARR);
|
||||
EXTMODULE_TIMER_DMA_STREAM->M0AR = CONVERT_PTR_UINT(dataPtr);
|
||||
EXTMODULE_TIMER_DMA_STREAM->NDTR = (uint32_t)dataSize;
|
||||
EXTMODULE_TIMER_DMA_STREAM->CR |= DMA_SxCR_EN | DMA_SxCR_TCIE; // Enable DMA
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if defined(DSM2)
|
||||
case PROTOCOL_CHANNELS_SBUS:
|
||||
#if defined(PCBX10) || PCBREV >= 13
|
||||
|
||||
@@ -45,7 +45,8 @@ void telemetryPortInit(uint32_t baudrate, uint8_t mode)
|
||||
USART_DeInit(TELEMETRY_USART);
|
||||
return;
|
||||
}
|
||||
|
||||
//deinit inverted mode
|
||||
telemetryPortInvertedInit(0);
|
||||
NVIC_InitTypeDef NVIC_InitStructure;
|
||||
NVIC_InitStructure.NVIC_IRQChannel = TELEMETRY_DMA_TX_Stream_IRQ;
|
||||
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
|
||||
@@ -136,6 +137,9 @@ void telemetryPortInit(uint32_t baudrate, uint8_t mode)
|
||||
// soft serial vars
|
||||
static uint8_t rxBitCount;
|
||||
static uint8_t rxByte;
|
||||
// single bit length expresses in half us
|
||||
static uint16_t bitLength;
|
||||
static uint16_t probeTimeFromStartBit;
|
||||
|
||||
void telemetryPortInvertedInit(uint32_t baudrate)
|
||||
{
|
||||
@@ -155,6 +159,20 @@ void telemetryPortInvertedInit(uint32_t baudrate)
|
||||
|
||||
rxBitCount = 0;
|
||||
|
||||
switch(baudrate) {
|
||||
case 115200:
|
||||
bitLength = 17;
|
||||
probeTimeFromStartBit = 23; //because pin is not probed immediately
|
||||
break;
|
||||
case 57600:
|
||||
bitLength = 35; //34 was used before - I prefer to use use 35 because of lower error
|
||||
probeTimeFromStartBit = 48; // 48 used in original implementation
|
||||
break;
|
||||
default:
|
||||
bitLength = 2000000/baudrate; //because of 0,5 us tick
|
||||
probeTimeFromStartBit = 3000000/baudrate;
|
||||
}
|
||||
|
||||
// configure bit sample timer
|
||||
TELEMETRY_TIMER->PSC = (PERI2_FREQUENCY * TIMER_MULT_APB2) / 2000000 - 1; // 0.5uS
|
||||
TELEMETRY_TIMER->CCER = 0;
|
||||
@@ -196,7 +214,7 @@ void telemetryPortInvertedRxBit()
|
||||
{
|
||||
if (rxBitCount < 8) {
|
||||
if (rxBitCount == 0) {
|
||||
TELEMETRY_TIMER->ARR = 34;
|
||||
TELEMETRY_TIMER->ARR = bitLength;
|
||||
rxByte = 0;
|
||||
}
|
||||
else {
|
||||
@@ -209,7 +227,6 @@ void telemetryPortInvertedRxBit()
|
||||
++rxBitCount;
|
||||
}
|
||||
else if (rxBitCount == 8) {
|
||||
|
||||
telemetryNoDMAFifo.push(rxByte);
|
||||
rxBitCount = 0;
|
||||
|
||||
@@ -360,7 +377,7 @@ extern "C" void TELEMETRY_EXTI_IRQHandler(void)
|
||||
|
||||
if (rxBitCount == 0) {
|
||||
|
||||
TELEMETRY_TIMER->ARR = 48; // 1,5 cycle from start at 57600bps
|
||||
TELEMETRY_TIMER->ARR = probeTimeFromStartBit; // 1,5 cycle from start at 57600bps
|
||||
TELEMETRY_TIMER->CR1 |= TIM_CR1_CEN;
|
||||
|
||||
// disable start bit interrupt
|
||||
|
||||
@@ -10,6 +10,7 @@ set(TARGET_DIR sky9x)
|
||||
set(RADIO_DEPENDENCIES ${RADIO_DEPENDENCIES} 9x_bitmaps)
|
||||
set(PPM_LIMITS_SYMETRICAL YES)
|
||||
set(PXX1 YES)
|
||||
set(AFHDS3 NO)
|
||||
add_definitions(-DDISABLE_MULTI_UPDATE)
|
||||
|
||||
if(PCB STREQUAL 9XRPRO)
|
||||
|
||||
@@ -2,6 +2,7 @@ option(SHUTDOWN_CONFIRMATION "Shutdown confirmation" OFF)
|
||||
option(LCD_DUAL_BUFFER "Dual LCD Buffer" OFF)
|
||||
option(PXX1 "PXX1 protocol support" ON)
|
||||
option(PXX2 "PXX2 protocol support" OFF)
|
||||
option(AFHDS3 "AFHDS3 TX Module" OFF)
|
||||
option(INTERNAL_MODULE_PPM "Support for PPM internal module" OFF)
|
||||
option(AUTOUPDATE "Auto update internal chips from SD" OFF)
|
||||
|
||||
|
||||
@@ -278,7 +278,25 @@ void extmoduleSendNextFrame()
|
||||
extmoduleSendBuffer(extmodulePulsesData.pxx2.getData(), extmodulePulsesData.pxx2.getSize());
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if defined(AFHDS3)
|
||||
case PROTOCOL_CHANNELS_AFHDS3:
|
||||
{
|
||||
#if defined(EXTMODULE_USART) && defined(EXTMODULE_TX_INVERT_GPIO)
|
||||
extmoduleSendBuffer(extmodulePulsesData.afhds3.getData(), extmodulePulsesData.afhds3.getSize());
|
||||
#else
|
||||
const uint16_t* dataPtr = extmodulePulsesData.afhds3.getData();
|
||||
uint32_t dataSize = extmodulePulsesData.afhds3.getSize();
|
||||
EXTMODULE_TIMER->CCR2 = dataPtr[dataSize -1] - 4000; // 2mS in advance
|
||||
EXTMODULE_TIMER_DMA_STREAM->CR &= ~DMA_SxCR_EN; // Disable DMA
|
||||
EXTMODULE_TIMER_DMA_STREAM->CR |= EXTMODULE_TIMER_DMA_CHANNEL | DMA_SxCR_DIR_0 | DMA_SxCR_MINC | DMA_SxCR_PSIZE_0 | DMA_SxCR_MSIZE_0 | DMA_SxCR_PL_0 | DMA_SxCR_PL_1;
|
||||
EXTMODULE_TIMER_DMA_STREAM->PAR = CONVERT_PTR_UINT(&EXTMODULE_TIMER->ARR);
|
||||
EXTMODULE_TIMER_DMA_STREAM->M0AR = CONVERT_PTR_UINT(dataPtr);
|
||||
EXTMODULE_TIMER_DMA_STREAM->NDTR = dataSize;
|
||||
EXTMODULE_TIMER_DMA_STREAM->CR |= DMA_SxCR_EN | DMA_SxCR_TCIE; // Enable DMA
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#if defined(SBUS) || defined(DSM2) || defined(MULTIMODULE)
|
||||
case PROTOCOL_CHANNELS_SBUS:
|
||||
EXTMODULE_TIMER->CCER = EXTMODULE_TIMER_OUTPUT_ENABLE | (GET_SBUS_POLARITY(EXTERNAL_MODULE) ? 0 : EXTMODULE_TIMER_OUTPUT_POLARITY); // reverse polarity for Sbus if needed
|
||||
|
||||
@@ -40,7 +40,8 @@ void telemetryPortInit(uint32_t baudrate, uint8_t mode)
|
||||
USART_DeInit(TELEMETRY_USART);
|
||||
return;
|
||||
}
|
||||
|
||||
//deinit inverted mode
|
||||
telemetryPortInvertedInit(0);
|
||||
NVIC_InitTypeDef NVIC_InitStructure;
|
||||
NVIC_InitStructure.NVIC_IRQChannel = TELEMETRY_DMA_TX_Stream_IRQ;
|
||||
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
|
||||
@@ -87,11 +88,10 @@ void telemetryPortInit(uint32_t baudrate, uint8_t mode)
|
||||
// soft serial vars
|
||||
static uint8_t rxBitCount;
|
||||
static uint8_t rxByte;
|
||||
// single bit length expresses in half us
|
||||
static uint16_t bitLength;
|
||||
static uint16_t probeTimeFromStartBit;
|
||||
|
||||
//TODO:
|
||||
// - only 57600 supported for now
|
||||
// - handle other bitrates as well?
|
||||
//
|
||||
void telemetryPortInvertedInit(uint32_t baudrate)
|
||||
{
|
||||
if (baudrate == 0) {
|
||||
@@ -116,6 +116,20 @@ void telemetryPortInvertedInit(uint32_t baudrate)
|
||||
|
||||
rxBitCount = 0;
|
||||
|
||||
switch(baudrate) {
|
||||
case 115200:
|
||||
bitLength = 17;
|
||||
probeTimeFromStartBit = 25;
|
||||
break;
|
||||
case 57600:
|
||||
bitLength = 35; //34 was used before - I prefer to use use 35 because of lower error
|
||||
probeTimeFromStartBit = 52; //round down - 48 used in original implementation
|
||||
break;
|
||||
default:
|
||||
bitLength = 2000000/baudrate; //because of 0,5 us tick
|
||||
probeTimeFromStartBit = 3000000/baudrate;
|
||||
}
|
||||
|
||||
// configure bit sample timer
|
||||
TELEMETRY_TIMER->PSC = (PERI2_FREQUENCY * TIMER_MULT_APB2) / 2000000 - 1; // 0.5uS
|
||||
TELEMETRY_TIMER->CCER = 0;
|
||||
@@ -162,7 +176,7 @@ void telemetryPortInvertedRxBit()
|
||||
{
|
||||
if (rxBitCount < 8) {
|
||||
if (rxBitCount == 0) {
|
||||
TELEMETRY_TIMER->ARR = 34;
|
||||
TELEMETRY_TIMER->ARR = bitLength;
|
||||
rxByte = 0;
|
||||
}
|
||||
else {
|
||||
@@ -333,7 +347,7 @@ void check_telemetry_exti()
|
||||
|
||||
if (rxBitCount == 0) {
|
||||
|
||||
TELEMETRY_TIMER->ARR = 48; // 1,5 cycle from start at 57600bps
|
||||
TELEMETRY_TIMER->ARR = probeTimeFromStartBit; // 1,5 cycle from start at 57600bps
|
||||
TELEMETRY_TIMER->CR1 |= TIM_CR1_CEN;
|
||||
|
||||
// disable start bit interrupt
|
||||
|
||||
Reference in New Issue
Block a user