#2894 - Crossfire (inverted serial) sent on S.PORT pin in the module bay (ported from master f7044a20ec)
16 channels sent every 2.5ms now @ 200KBauds with CRC
This commit is contained in:
@@ -1277,6 +1277,10 @@ void lcdRefresh()
|
||||
simuLcdRefresh = true;
|
||||
}
|
||||
|
||||
void telemetryPortInit()
|
||||
{
|
||||
}
|
||||
|
||||
#if !defined(PCBFLAMENCO)
|
||||
display_t simuLcdBackupBuf[DISPLAY_BUFFER_SIZE];
|
||||
void lcdStoreBackupBuffer()
|
||||
|
||||
@@ -210,6 +210,8 @@ void init_pxx( uint32_t module_index );
|
||||
void disable_pxx( uint32_t module_index );
|
||||
void init_dsm2( uint32_t module_index );
|
||||
void disable_dsm2( uint32_t module_index );
|
||||
void init_crossfire( uint32_t module_index );
|
||||
void disable_crossfire( uint32_t module_index );
|
||||
|
||||
// Trainer driver
|
||||
void init_trainer_ppm(void);
|
||||
@@ -305,6 +307,7 @@ void debugPutc(const char c);
|
||||
|
||||
// Telemetry driver
|
||||
void telemetryPortInit(uint32_t baudrate);
|
||||
void telemetryPortSetDirectionOutput(void);
|
||||
void sportSendBuffer(uint8_t *buffer, uint32_t count);
|
||||
|
||||
// Audio driver
|
||||
|
||||
@@ -58,6 +58,8 @@ static void intmoduleNoneStart( void ) ;
|
||||
static void intmoduleNoneStop( void ) ;
|
||||
static void extmoduleNoneStart( void ) ;
|
||||
static void extmoduleNoneStop( void ) ;
|
||||
static void extmoduleCrossfireStart( void ) ;
|
||||
static void extmoduleCrossfireStop( void ) ;
|
||||
|
||||
void init_pxx(uint32_t port)
|
||||
{
|
||||
@@ -148,6 +150,19 @@ void disable_no_pulses(uint32_t port)
|
||||
extmoduleNoneStop();
|
||||
}
|
||||
|
||||
void init_crossfire(uint32_t port)
|
||||
{
|
||||
if (port == EXTERNAL_MODULE) {
|
||||
extmoduleCrossfireStart();
|
||||
}
|
||||
}
|
||||
|
||||
void disable_crossfire(uint32_t port)
|
||||
{
|
||||
if (port == EXTERNAL_MODULE)
|
||||
extmoduleCrossfireStop();
|
||||
}
|
||||
|
||||
static void intmoduleNoneStart()
|
||||
{
|
||||
INTERNAL_MODULE_OFF();
|
||||
@@ -226,6 +241,46 @@ static void extmoduleNoneStop()
|
||||
EXTMODULE_TIMER->CR1 &= ~TIM_CR1_CEN ;
|
||||
}
|
||||
|
||||
static void extmoduleCrossfireStart()
|
||||
{
|
||||
EXTERNAL_MODULE_ON();
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
GPIO_InitStructure.GPIO_Pin = EXTMODULE_GPIO_PIN;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT ;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||
GPIO_Init(EXTMODULE_GPIO, &GPIO_InitStructure);
|
||||
GPIO_SetBits(EXTMODULE_GPIO, EXTMODULE_GPIO_PIN); // Set high
|
||||
|
||||
EXTMODULE_TIMER->CR1 &= ~TIM_CR1_CEN ;
|
||||
EXTMODULE_TIMER->ARR = 5000 ; // 2.5mS
|
||||
EXTMODULE_TIMER->CCR2 = 32000 ; // Update time
|
||||
EXTMODULE_TIMER->PSC = (PERI2_FREQUENCY * TIMER_MULT_APB2) / 2000000 - 1 ; // 0.5uS from 30MHz
|
||||
|
||||
EXTMODULE_TIMER->CCMR2 = 0 ;
|
||||
EXTMODULE_TIMER->EGR = 1 ; // Restart
|
||||
|
||||
EXTMODULE_TIMER->CCMR2 = TIM_CCMR2_OC3M_1 | TIM_CCMR2_OC3M_0 ; // Toggle CC1 o/p
|
||||
EXTMODULE_TIMER->SR &= ~TIM_SR_CC2IF ; // Clear flag
|
||||
EXTMODULE_TIMER->DIER |= TIM_DIER_CC2IE ; // Enable this interrupt
|
||||
EXTMODULE_TIMER->CR1 |= TIM_CR1_CEN ;
|
||||
NVIC_EnableIRQ(EXTMODULE_TIMER_IRQn) ;
|
||||
NVIC_SetPriority(EXTMODULE_TIMER_IRQn, 7);
|
||||
}
|
||||
|
||||
static void extmoduleCrossfireStop()
|
||||
{
|
||||
NVIC_DisableIRQ(EXTMODULE_TIMER_IRQn) ;
|
||||
EXTMODULE_TIMER->DIER &= ~TIM_DIER_CC2IE ;
|
||||
EXTMODULE_TIMER->CR1 &= ~TIM_CR1_CEN ;
|
||||
|
||||
if (!IS_TRAINER_EXTERNAL_MODULE()) {
|
||||
EXTERNAL_MODULE_OFF();
|
||||
}
|
||||
}
|
||||
|
||||
static void intmodulePxxStart()
|
||||
{
|
||||
INTERNAL_MODULE_ON();
|
||||
|
||||
@@ -105,7 +105,7 @@ void serial2Putc(char c)
|
||||
|
||||
void serial2SbusInit()
|
||||
{
|
||||
uart3Setup(100000);
|
||||
uart3Setup(SBUS_BAUDRATE);
|
||||
SERIAL_USART->CR1 |= USART_CR1_M | USART_CR1_PCE ;
|
||||
}
|
||||
|
||||
|
||||
@@ -85,12 +85,17 @@ struct SportTxBuffer
|
||||
uint32_t count;
|
||||
} sportTxBuffer;
|
||||
|
||||
void telemetryPortSetDirectionOutput()
|
||||
{
|
||||
TELEMETRY_GPIO_DIR->BSRRL = TELEMETRY_GPIO_PIN_DIR; // output enable
|
||||
TELEMETRY_USART->CR1 &= ~USART_CR1_RE; // turn off receiver
|
||||
}
|
||||
|
||||
void sportSendBuffer(uint8_t *buffer, uint32_t count)
|
||||
{
|
||||
sportTxBuffer.ptr = buffer ;
|
||||
sportTxBuffer.count = count ;
|
||||
TELEMETRY_GPIO_DIR->BSRRL = TELEMETRY_GPIO_PIN_DIR ; // output enable
|
||||
TELEMETRY_USART->CR1 &= ~USART_CR1_RE ; // turn off receiver
|
||||
sportTxBuffer.ptr = buffer;
|
||||
sportTxBuffer.count = count;
|
||||
telemetryPortSetDirectionOutput();
|
||||
TELEMETRY_USART->CR1 |= USART_CR1_TXEIE ;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user