More work on pulses ...
This commit is contained in:
@@ -119,6 +119,7 @@ elseif(PCB STREQUAL XLITES)
|
||||
endif()
|
||||
|
||||
if(PCB STREQUAL XLITE OR PCB STREQUAL XLITES)
|
||||
add_definitions(-DINTERNAL_MODULE_SERIAL)
|
||||
if(PXX_FREQUENCY STREQUAL HIGH)
|
||||
add_definitions(-DPXX_FREQUENCY_HIGH)
|
||||
endif()
|
||||
|
||||
@@ -180,16 +180,19 @@ uint32_t isBootloaderStart(const uint8_t * buffer);
|
||||
#else
|
||||
#define IS_UART_MODULE(port) (false)
|
||||
#endif
|
||||
void init_no_pulses(uint32_t port);
|
||||
void disable_no_pulses(uint32_t port);
|
||||
void init_ppm( uint32_t module_index);
|
||||
void disable_ppm( uint32_t module_index);
|
||||
void init_pxx( uint32_t module_index);
|
||||
void disable_pxx( uint32_t module_index);
|
||||
void init_serial( uint32_t module_index, uint32_t baudrate, uint32_t period);
|
||||
void disable_serial( uint32_t module_index);
|
||||
void init_module_timer( uint32_t module_index, uint32_t period, uint8_t state);
|
||||
void disable_module_timer( uint32_t module_index);
|
||||
void init_no_pulses(uint8_t module);
|
||||
void disable_no_pulses(uint8_t module);
|
||||
void init_ppm(uint8_t module);
|
||||
void disable_ppm(uint8_t module);
|
||||
void intmoduleSendNextFrame();
|
||||
void init_pxx2(uint8_t module);
|
||||
void disable_pxx2(uint8_t module);
|
||||
void init_pxx(uint8_t module);
|
||||
void disable_pxx(uint8_t module);
|
||||
void init_serial(uint8_t module, uint32_t baudrate, uint32_t period);
|
||||
void disable_serial(uint8_t module);
|
||||
void init_module_timer(uint8_t module, uint32_t period, uint8_t state);
|
||||
void disable_module_timer(uint8_t module);
|
||||
|
||||
// Trainer driver
|
||||
#define SLAVE_MODE() (g_model.trainerData.mode == TRAINER_MODE_SLAVE)
|
||||
|
||||
@@ -200,6 +200,11 @@ void extmodulePxxStart()
|
||||
{
|
||||
extmoduleInvertedSerialStart(EXTMODULE_USART_PXX_BAUDRATE, PXX_PERIOD_HALF_US);
|
||||
}
|
||||
|
||||
void extmodulePxx2Start()
|
||||
{
|
||||
extmoduleInvertedSerialStart(EXTMODULE_USART_PXX_BAUDRATE, PXX_PERIOD_HALF_US);
|
||||
}
|
||||
#else
|
||||
void extmodulePxxStart()
|
||||
{
|
||||
@@ -234,6 +239,11 @@ void extmodulePxxStart()
|
||||
NVIC_EnableIRQ(EXTMODULE_TIMER_CC_IRQn);
|
||||
NVIC_SetPriority(EXTMODULE_TIMER_CC_IRQn, 7);
|
||||
}
|
||||
|
||||
void extmodulePxx2Start()
|
||||
{
|
||||
// TODO just enable the S.PORT line (or let telemetry init do it)
|
||||
}
|
||||
#endif
|
||||
|
||||
void extmoduleSendNextFrame()
|
||||
|
||||
@@ -32,9 +32,14 @@ void intmoduleStop()
|
||||
INTMODULE_TIMER->CR1 &= ~TIM_CR1_CEN;
|
||||
}
|
||||
|
||||
void intmoduleNoneStart()
|
||||
void intmoduleTimerStart(uint32_t period, uint8_t state)
|
||||
{
|
||||
INTERNAL_MODULE_OFF();
|
||||
if (state)
|
||||
INTERNAL_MODULE_ON();
|
||||
else
|
||||
INTERNAL_MODULE_OFF();
|
||||
|
||||
GPIO_PinAFConfig(EXTMODULE_TX_GPIO, EXTMODULE_TX_GPIO_PinSource, 0);
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
GPIO_InitStructure.GPIO_Pin = INTMODULE_TX_GPIO_PIN;
|
||||
@@ -46,9 +51,9 @@ void intmoduleNoneStart()
|
||||
GPIO_SetBits(INTMODULE_TX_GPIO, INTMODULE_TX_GPIO_PIN); // Set high
|
||||
|
||||
INTMODULE_TIMER->CR1 &= ~TIM_CR1_CEN;
|
||||
INTMODULE_TIMER->PSC = INTMODULE_TIMER_FREQ / 2000000 - 1; // 0.5uS from 30MHz
|
||||
INTMODULE_TIMER->ARR = 36000; // 18mS
|
||||
INTMODULE_TIMER->CCR2 = 32000; // Update time
|
||||
INTMODULE_TIMER->PSC = EXTMODULE_TIMER_FREQ / 2000000 - 1; // 0.5uS from 30MHz
|
||||
INTMODULE_TIMER->ARR = (2000 * period);
|
||||
INTMODULE_TIMER->CCR2 = (2000 * period) - 1000;
|
||||
INTMODULE_TIMER->EGR = 1; // Restart
|
||||
INTMODULE_TIMER->SR &= ~TIM_SR_CC2IF; // Clear flag
|
||||
INTMODULE_TIMER->DIER |= TIM_DIER_CC2IE; // Enable this interrupt
|
||||
|
||||
@@ -20,103 +20,118 @@
|
||||
|
||||
#include "opentx.h"
|
||||
|
||||
void intmoduleStop(void);
|
||||
void extmoduleStop(void);
|
||||
|
||||
void intmoduleNoneStart(void);
|
||||
void intmodulePxxStart(void);
|
||||
void intmoduleStop();
|
||||
void intmoduleTimerStart(uint32_t period, uint8_t state);
|
||||
void intmodulePxxStart();
|
||||
void intmodulePxx2Start();
|
||||
#if defined(TARANIS_INTERNAL_PPM)
|
||||
void intmodulePpmStart(void);
|
||||
#endif
|
||||
|
||||
void extmoduleStop();
|
||||
void extmoduleTimerStart(uint32_t period, uint8_t state);
|
||||
void extmodulePpmStart(void);
|
||||
void extmodulePxxStart(void);
|
||||
void extmodulePpmStart();
|
||||
void extmodulePxxStart();
|
||||
void extmodulePxx2Start();
|
||||
void extmoduleSerialStart(uint32_t baudrate, uint32_t period_half_us);
|
||||
|
||||
|
||||
void init_pxx(uint32_t port)
|
||||
void init_pxx(uint8_t module)
|
||||
{
|
||||
if (port == INTERNAL_MODULE)
|
||||
if (module == INTERNAL_MODULE)
|
||||
intmodulePxxStart();
|
||||
else
|
||||
extmodulePxxStart();
|
||||
}
|
||||
|
||||
void disable_pxx(uint32_t port)
|
||||
void disable_pxx(uint8_t module)
|
||||
{
|
||||
if (port == INTERNAL_MODULE)
|
||||
if (module == INTERNAL_MODULE)
|
||||
intmoduleStop();
|
||||
else
|
||||
extmoduleStop();
|
||||
}
|
||||
|
||||
void init_pxx2(uint8_t module)
|
||||
{
|
||||
if (module == INTERNAL_MODULE)
|
||||
intmodulePxx2Start();
|
||||
else
|
||||
extmodulePxx2Start();
|
||||
}
|
||||
|
||||
void disable_pxx2(uint8_t module)
|
||||
{
|
||||
if (module == INTERNAL_MODULE)
|
||||
intmoduleStop();
|
||||
else
|
||||
extmoduleStop();
|
||||
}
|
||||
|
||||
#if defined(DSM2)
|
||||
void init_serial(uint32_t port, uint32_t baudrate, uint32_t period_half_us)
|
||||
void init_serial(uint8_t module, uint32_t baudrate, uint32_t period_half_us)
|
||||
{
|
||||
if (port == EXTERNAL_MODULE) {
|
||||
if (module == EXTERNAL_MODULE) {
|
||||
extmoduleSerialStart(baudrate, period_half_us);
|
||||
}
|
||||
}
|
||||
|
||||
void disable_serial(uint32_t port)
|
||||
void disable_serial(uint8_t module)
|
||||
{
|
||||
if (port == EXTERNAL_MODULE) {
|
||||
if (module == EXTERNAL_MODULE) {
|
||||
extmoduleStop();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void init_ppm(uint32_t port)
|
||||
void init_ppm(uint8_t module)
|
||||
{
|
||||
if (port == EXTERNAL_MODULE) {
|
||||
if (module == EXTERNAL_MODULE) {
|
||||
extmodulePpmStart();
|
||||
}
|
||||
#if defined(TARANIS_INTERNAL_PPM)
|
||||
else if (port == INTERNAL_MODULE) {
|
||||
else {
|
||||
intmodulePpmStart();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void disable_ppm(uint32_t port)
|
||||
void disable_ppm(uint8_t module)
|
||||
{
|
||||
if (port == EXTERNAL_MODULE) {
|
||||
if (module == EXTERNAL_MODULE) {
|
||||
extmoduleStop();
|
||||
}
|
||||
#if defined(TARANIS_INTERNAL_PPM)
|
||||
else if (port == INTERNAL_MODULE) {
|
||||
else {
|
||||
intmoduleStop();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void init_no_pulses(uint32_t port)
|
||||
void init_no_pulses(uint8_t module)
|
||||
{
|
||||
if (port == INTERNAL_MODULE)
|
||||
intmoduleNoneStart();
|
||||
else
|
||||
extmoduleTimerStart(18, false);
|
||||
init_module_timer(module, 18, false);
|
||||
}
|
||||
|
||||
void disable_no_pulses(uint32_t port)
|
||||
void disable_no_pulses(uint8_t module)
|
||||
{
|
||||
if (port == INTERNAL_MODULE)
|
||||
if (module == INTERNAL_MODULE)
|
||||
intmoduleStop();
|
||||
else
|
||||
extmoduleStop();
|
||||
}
|
||||
|
||||
void init_module_timer(uint32_t port, uint32_t period, uint8_t state)
|
||||
void init_module_timer(uint8_t module, uint32_t period, uint8_t state)
|
||||
{
|
||||
if (port == EXTERNAL_MODULE) {
|
||||
if (module == INTERNAL_MODULE)
|
||||
intmoduleTimerStart(period, state);
|
||||
else
|
||||
extmoduleTimerStart(period, state);
|
||||
}
|
||||
}
|
||||
|
||||
void disable_module_timer(uint32_t port)
|
||||
void disable_module_timer(uint8_t module)
|
||||
{
|
||||
if (port == EXTERNAL_MODULE) {
|
||||
if (module == INTERNAL_MODULE)
|
||||
intmoduleStop();
|
||||
else
|
||||
extmoduleStop();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user