X10 / X12S fixes
This commit is contained in:
@@ -29,6 +29,8 @@ extern "C" {
|
||||
}
|
||||
#endif
|
||||
|
||||
HardwareOptions hardwareOptions;
|
||||
|
||||
void watchdogInit(unsigned int duration)
|
||||
{
|
||||
IWDG->KR = 0x5555; // Unlock registers
|
||||
|
||||
@@ -21,8 +21,7 @@
|
||||
#ifndef _BOARD_HORUS_H_
|
||||
#define _BOARD_HORUS_H_
|
||||
|
||||
#include "stddef.h"
|
||||
#include "stdbool.h"
|
||||
#include "definitions.h"
|
||||
|
||||
#if defined(__cplusplus) && !defined(SIMU)
|
||||
extern "C" {
|
||||
@@ -105,6 +104,14 @@ extern uint16_t sessionTimer;
|
||||
#define TRAINER_CONNECTED() (GPIO_ReadInputDataBit(TRAINER_DETECT_GPIO, TRAINER_DETECT_GPIO_PIN) == Bit_RESET)
|
||||
#endif
|
||||
|
||||
#if defined(PCBX10)
|
||||
#define NUM_SLIDERS 2
|
||||
#define NUM_PWMSTICKS 4
|
||||
#else
|
||||
#define NUM_SLIDERS 4
|
||||
#define NUM_PWMSTICKS 0
|
||||
#endif
|
||||
|
||||
// Board driver
|
||||
void boardInit(void);
|
||||
void boardOff(void);
|
||||
@@ -186,12 +193,31 @@ void SDRAM_Init(void);
|
||||
#define IS_INTERNAL_MODULE_ON() (GPIO_ReadInputDataBit(INTMODULE_PWR_GPIO, INTMODULE_PWR_GPIO_PIN) == Bit_SET)
|
||||
#define IS_EXTERNAL_MODULE_ON() (GPIO_ReadInputDataBit(EXTMODULE_PWR_GPIO, EXTMODULE_PWR_GPIO_PIN) == Bit_SET)
|
||||
|
||||
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_half_us);
|
||||
void disable_serial(uint32_t module_index);
|
||||
PACK(typedef struct {
|
||||
#if NUM_PWMSTICKS > 0
|
||||
uint8_t sticksPwmDisabled:1;
|
||||
#endif
|
||||
uint8_t pxx2Enabled:1;
|
||||
}) HardwareOptions;
|
||||
|
||||
extern HardwareOptions hardwareOptions;
|
||||
|
||||
#if defined(PCBX10)
|
||||
#define IS_PXX2_ENABLED() (true)
|
||||
#else
|
||||
#define IS_PXX2_ENABLED() (hardwareOptions.pxx2Enabled)
|
||||
#endif
|
||||
|
||||
void init_ppm(uint8_t module);
|
||||
void disable_ppm(uint8_t module);
|
||||
void init_pxx(uint8_t module);
|
||||
void disable_pxx(uint8_t module);
|
||||
void init_pxx2(uint8_t module);
|
||||
void disable_pxx2(uint8_t module);
|
||||
void init_serial(uint8_t module, uint32_t baudrate, uint32_t period_half_us);
|
||||
void disable_serial(uint8_t module);
|
||||
void intmoduleSendNextFrame();
|
||||
void extmoduleSendNextFrame();
|
||||
|
||||
// Trainer driver
|
||||
void init_trainer_ppm(void);
|
||||
@@ -330,13 +356,6 @@ void watchdogInit(unsigned int duration);
|
||||
// ADC driver
|
||||
#define NUM_POTS 3
|
||||
#define NUM_XPOTS NUM_POTS
|
||||
#if defined(PCBX10)
|
||||
#define NUM_SLIDERS 2
|
||||
#define NUM_PWMSTICKS 4
|
||||
#else
|
||||
#define NUM_SLIDERS 4
|
||||
#define NUM_PWMSTICKS 0
|
||||
#endif
|
||||
enum Analogs {
|
||||
STICK1,
|
||||
STICK2,
|
||||
@@ -402,8 +421,7 @@ uint16_t getAnalogValue(uint8_t index);
|
||||
#endif
|
||||
|
||||
#if NUM_PWMSTICKS > 0
|
||||
extern bool sticks_pwm_disabled;
|
||||
#define STICKS_PWM_ENABLED() (sticks_pwm_disabled == false)
|
||||
#define STICKS_PWM_ENABLED() (!hardwareOptions.sticksPwmDisabled)
|
||||
void sticksPwmInit(void);
|
||||
void sticksPwmRead(uint16_t * values);
|
||||
extern volatile uint32_t pwm_interrupt_count;
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
|
||||
#include "opentx.h"
|
||||
|
||||
void extmoduleSendNextFrame();
|
||||
|
||||
void extmoduleStop()
|
||||
{
|
||||
EXTERNAL_MODULE_OFF();
|
||||
@@ -34,37 +32,6 @@ void extmoduleStop()
|
||||
EXTMODULE_TIMER->CR1 &= ~TIM_CR1_CEN;
|
||||
}
|
||||
|
||||
void extmoduleTimerStart(uint32_t period, uint8_t state)
|
||||
{
|
||||
if (state)
|
||||
EXTERNAL_MODULE_ON();
|
||||
else
|
||||
EXTERNAL_MODULE_OFF();
|
||||
|
||||
GPIO_PinAFConfig(EXTMODULE_TX_GPIO, EXTMODULE_TX_GPIO_PinSource, 0);
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
GPIO_InitStructure.GPIO_Pin = EXTMODULE_TX_GPIO_PIN;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||
GPIO_Init(EXTMODULE_TX_GPIO, &GPIO_InitStructure);
|
||||
GPIO_SetBits(EXTMODULE_TX_GPIO, EXTMODULE_TX_GPIO_PIN); // Set high
|
||||
|
||||
EXTMODULE_TIMER->CR1 &= ~TIM_CR1_CEN;
|
||||
EXTMODULE_TIMER->PSC = EXTMODULE_TIMER_FREQ / 2000000 - 1; // 0.5uS (2Mhz)
|
||||
EXTMODULE_TIMER->ARR = (2000 * period);
|
||||
EXTMODULE_TIMER->CCR2 = (2000 * period) - 1000;
|
||||
EXTMODULE_TIMER->EGR = 1; // Restart
|
||||
EXTMODULE_TIMER->SR &= ~TIM_SR_CC2IF;
|
||||
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);
|
||||
}
|
||||
|
||||
void extmodulePpmStart()
|
||||
{
|
||||
EXTERNAL_MODULE_ON();
|
||||
@@ -238,6 +205,7 @@ void extmoduleSendNextFrame()
|
||||
EXTMODULE_DMA_STREAM->NDTR = extmodulePulsesData.ppm.ptr - extmodulePulsesData.ppm.pulses;
|
||||
EXTMODULE_DMA_STREAM->CR |= DMA_SxCR_EN | DMA_SxCR_TCIE; // Enable DMA
|
||||
}
|
||||
#if defined(PXX1)
|
||||
else if (moduleSettings[EXTERNAL_MODULE].protocol == PROTOCOL_CHANNELS_PXX1) {
|
||||
EXTMODULE_TIMER->CCR2 = extmodulePulsesData.pxx.getLast() - 4000; // 2mS in advance
|
||||
EXTMODULE_DMA_STREAM->CR &= ~DMA_SxCR_EN; // Disable DMA
|
||||
@@ -251,6 +219,7 @@ void extmoduleSendNextFrame()
|
||||
EXTMODULE_DMA_STREAM->NDTR = extmodulePulsesData.pxx.getSize();
|
||||
EXTMODULE_DMA_STREAM->CR |= DMA_SxCR_EN | DMA_SxCR_TCIE; // Enable DMA
|
||||
}
|
||||
#endif
|
||||
else if (IS_DSM2_PROTOCOL(moduleSettings[EXTERNAL_MODULE].protocol) || IS_MULTIMODULE_PROTOCOL(moduleSettings[EXTERNAL_MODULE].protocol) || IS_SBUS_PROTOCOL(moduleSettings[EXTERNAL_MODULE].protocol)) {
|
||||
EXTMODULE_TIMER->CCR2 = *(extmodulePulsesData.dsm2.ptr - 1) - 4000; // 2mS in advance
|
||||
EXTMODULE_DMA_STREAM->CR &= ~DMA_SxCR_EN; // Disable DMA
|
||||
|
||||
@@ -515,14 +515,13 @@
|
||||
#define INTMODULE_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_DMA2)
|
||||
#define INTMODULE_PWR_GPIO GPIOA
|
||||
#define INTMODULE_PWR_GPIO_PIN GPIO_Pin_8 // PA.08
|
||||
#define INTMODULE_TX_GPIO GPIOB
|
||||
#define INTMODULE_GPIO GPIOB
|
||||
#define INTMODULE_TX_GPIO_PIN GPIO_Pin_6 // PB.06
|
||||
#define INTMODULE_RX_GPIO GPIOB
|
||||
#define INTMODULE_RX_GPIO_PIN GPIO_Pin_7 // PB.07
|
||||
#define INTMODULE_TX_GPIO_PinSource GPIO_PinSource6
|
||||
#define INTMODULE_RX_GPIO_PinSource GPIO_PinSource7
|
||||
#define INTMODULE_GPIO_PinSource_TX GPIO_PinSource6
|
||||
#define INTMODULE_GPIO_PinSource_RX GPIO_PinSource7
|
||||
#define INTMODULE_USART USART1
|
||||
#define INTMODULE_TX_GPIO_AF GPIO_AF_USART1
|
||||
#define INTMODULE_GPIO_AF GPIO_AF_USART1
|
||||
#define INTMODULE_USART_IRQn USART1_IRQn
|
||||
#define INTMODULE_DMA_STREAM DMA2_Stream7
|
||||
#define INTMODULE_DMA_STREAM_IRQ DMA2_Stream7_IRQn
|
||||
|
||||
@@ -21,83 +21,75 @@
|
||||
#include "opentx.h"
|
||||
|
||||
void intmoduleStop();
|
||||
void intmoduleTimerStart(uint32_t period, uint8_t state);
|
||||
void intmodulePxxStart();
|
||||
void intmodulePxx2Start();
|
||||
|
||||
void extmoduleStop();
|
||||
void extmoduleTimerStart(uint32_t period, uint8_t state);
|
||||
void extmodulePpmStart();
|
||||
void extmodulePxxStart();
|
||||
void extmodulePxx2Start();
|
||||
void extmoduleSerialStart(uint32_t baudrate, uint32_t period_half_us);
|
||||
|
||||
void init_ppm(uint32_t port)
|
||||
|
||||
void init_ppm(uint8_t module)
|
||||
{
|
||||
if (port == EXTERNAL_MODULE) {
|
||||
if (module == EXTERNAL_MODULE) {
|
||||
extmodulePpmStart();
|
||||
}
|
||||
}
|
||||
|
||||
void disable_ppm(uint32_t port)
|
||||
void disable_ppm(uint8_t module)
|
||||
{
|
||||
if (port == EXTERNAL_MODULE) {
|
||||
if (module == EXTERNAL_MODULE) {
|
||||
extmoduleStop();
|
||||
}
|
||||
}
|
||||
|
||||
void init_pxx2(uint32_t port)
|
||||
void init_pxx2(uint8_t module)
|
||||
{
|
||||
if (port == INTERNAL_MODULE)
|
||||
if (module == INTERNAL_MODULE)
|
||||
intmodulePxx2Start();
|
||||
else
|
||||
extmodulePxx2Start();
|
||||
}
|
||||
|
||||
void init_pxx(uint32_t port)
|
||||
void disable_pxx2(uint8_t module)
|
||||
{
|
||||
if (port == INTERNAL_MODULE)
|
||||
if (module == INTERNAL_MODULE)
|
||||
intmoduleStop();
|
||||
else
|
||||
extmoduleStop();
|
||||
}
|
||||
|
||||
void init_pxx(uint8_t 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();
|
||||
}
|
||||
|
||||
#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_module_timer(uint32_t port, uint32_t period, uint8_t state)
|
||||
{
|
||||
if (port == INTERNAL_MODULE)
|
||||
intmoduleTimerStart(period, state);
|
||||
else
|
||||
extmoduleTimerStart(period, state);
|
||||
}
|
||||
|
||||
void disable_module_timer(uint32_t port)
|
||||
{
|
||||
if (port == INTERNAL_MODULE)
|
||||
intmoduleStop();
|
||||
else
|
||||
extmoduleStop();
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,6 @@ void intmoduleStop()
|
||||
void intmoduleSendNextFrame()
|
||||
{
|
||||
if (0) {
|
||||
|
||||
}
|
||||
#if defined(PXX1)
|
||||
else if (moduleSettings[INTERNAL_MODULE].protocol == PROTOCOL_CHANNELS_PXX1) {
|
||||
@@ -68,7 +67,7 @@ void intmoduleSendNextFrame()
|
||||
|
||||
void intmodulePxx2Start()
|
||||
{
|
||||
// TODO
|
||||
// nothing, the pulses will be sent through telemetry port
|
||||
}
|
||||
|
||||
void intmodulePxxStart()
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include "opentx.h"
|
||||
|
||||
void intmoduleStop();
|
||||
void intmoduleTimerStart(uint32_t period, uint8_t state);
|
||||
void intmodulePxxStart();
|
||||
void intmodulePxx2Start();
|
||||
#if defined(TARANIS_INTERNAL_PPM)
|
||||
|
||||
Reference in New Issue
Block a user