Merge with latest 2.3
This commit is contained in:
@@ -147,7 +147,7 @@ endif()
|
||||
|
||||
if(MULTIMODULE)
|
||||
add_definitions(-DMULTIMODULE)
|
||||
set(SRC ${SRC} pulses/multi.cpp telemetry/spektrum.cpp telemetry/flysky_ibus.cpp telemetry/multi.cpp)
|
||||
set(SRC ${SRC} pulses/multi.cpp telemetry/spektrum.cpp telemetry/flysky_ibus.cpp telemetry/hitec.cpp telemetry/multi.cpp io/multi_firmware_update.cpp)
|
||||
endif()
|
||||
|
||||
if(CROSSFIRE)
|
||||
|
||||
@@ -22,8 +22,10 @@
|
||||
|
||||
#if defined(SIMU)
|
||||
// not needed
|
||||
#elif defined(RADIO_T16)
|
||||
const int8_t adcDirection[NUM_ANALOGS] = {1,-1,1,-1, 1,1,1, -1,1, -1,1};
|
||||
#elif defined(PCBX10)
|
||||
const int8_t adcDirection[NUM_ANALOGS] = {1,-1,1,-1, -1,1,-1, 1,1, 1, -1};
|
||||
const int8_t adcDirection[NUM_ANALOGS] = {1,-1,1,-1, -1,1,-1, 1,1, 1, -1};
|
||||
#elif defined(PCBX9E)
|
||||
#if defined(HORUS_STICKS)
|
||||
const int8_t adcDirection[NUM_ANALOGS] = {1,-1,1,-1, -1,-1,-1,1, -1,1,-1, -1,-1,-1};
|
||||
@@ -36,14 +38,14 @@
|
||||
9 /*TX_VOLTAGE*/, 10 /*TX_VBAT*/ };
|
||||
#elif defined(PCBX9DP)
|
||||
const int8_t adcDirection[NUM_ANALOGS] = {1,-1,1,-1, 1,1,-1, 1,1, 1, 1};
|
||||
#elif defined(PCBX9D)
|
||||
const int8_t adcDirection[NUM_ANALOGS] = {1,-1,1,-1, 1,1,0, 1,1, 1, 1};
|
||||
#elif defined(PCBX7)
|
||||
const int8_t adcDirection[NUM_ANALOGS] = {-1,1,-1,1, 1,1, 1, 1};
|
||||
#elif defined(PCBX9LITE)
|
||||
const int8_t adcDirection[NUM_ANALOGS] = {-1,1,-1,1, 1,1, 1};
|
||||
#elif defined(PCBXLITE)
|
||||
const int8_t adcDirection[NUM_ANALOGS] = {1,-1,-1,1, -1,1, 1, 1};
|
||||
#else
|
||||
const int8_t adcDirection[NUM_ANALOGS] = {1,-1,1,-1, 1,1,0, 1,1, 1, 1};
|
||||
#endif
|
||||
|
||||
#if NUM_PWMSTICKS > 0
|
||||
|
||||
@@ -90,13 +90,18 @@ void dacInit()
|
||||
|
||||
void audioConsumeCurrentBuffer()
|
||||
{
|
||||
if (nextBuffer == 0) {
|
||||
|
||||
if (!nextBuffer) {
|
||||
nextBuffer = audioQueue.buffersFifo.getNextFilledBuffer();
|
||||
if (nextBuffer) {
|
||||
#if defined(AUDIO_MUTE_GPIO_PIN)
|
||||
// un-mute
|
||||
GPIO_ResetBits(AUDIO_MUTE_GPIO, AUDIO_MUTE_GPIO_PIN);
|
||||
// if muted
|
||||
if (GPIO_ReadOutputDataBit(AUDIO_MUTE_GPIO, AUDIO_MUTE_GPIO_PIN)) {
|
||||
// ..un-mute
|
||||
GPIO_ResetBits(AUDIO_MUTE_GPIO, AUDIO_MUTE_GPIO_PIN);
|
||||
#if defined(AUDIO_UNMUTE_DELAY)
|
||||
RTOS_WAIT_MS(AUDIO_UNMUTE_DELAY);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
AUDIO_DMA_Stream->CR &= ~DMA_SxCR_EN ; // Disable DMA channel
|
||||
AUDIO_DMA->HIFCR = DMA_HIFCR_CTCIF5 | DMA_HIFCR_CHTIF5 | DMA_HIFCR_CTEIF5 | DMA_HIFCR_CDMEIF5 | DMA_HIFCR_CFEIF5 ; // Write ones to clear bits
|
||||
|
||||
@@ -206,4 +206,4 @@ extern "C" void AUX_SERIAL_USART_IRQHandler(void)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "opentx.h"
|
||||
|
||||
#if !defined(BOOT)
|
||||
Fifo<uint8_t, BT_TX_FIFO_SIZE> btTxFifo;
|
||||
Fifo<uint8_t, BT_RX_FIFO_SIZE> btRxFifo;
|
||||
|
||||
@@ -42,6 +43,7 @@ enum BluetoothWriteState
|
||||
};
|
||||
|
||||
volatile uint8_t bluetoothWriteState = BLUETOOTH_WRITE_IDLE;
|
||||
#endif
|
||||
|
||||
void bluetoothInit(uint32_t baudrate, bool enable)
|
||||
{
|
||||
@@ -65,6 +67,7 @@ void bluetoothInit(uint32_t baudrate, bool enable)
|
||||
GPIO_Init(BT_BCTS_GPIO, &GPIO_InitStructure);
|
||||
#endif
|
||||
|
||||
#if !defined(BOOT)
|
||||
GPIO_PinAFConfig(BT_USART_GPIO, BT_TX_GPIO_PinSource, BT_GPIO_AF);
|
||||
GPIO_PinAFConfig(BT_USART_GPIO, BT_RX_GPIO_PinSource, BT_GPIO_AF);
|
||||
|
||||
@@ -90,17 +93,17 @@ void bluetoothInit(uint32_t baudrate, bool enable)
|
||||
|
||||
bluetoothWriteState = BLUETOOTH_WRITE_IDLE;
|
||||
|
||||
if (enable) {
|
||||
GPIO_ResetBits(BT_EN_GPIO, BT_EN_GPIO_PIN);
|
||||
}
|
||||
else {
|
||||
GPIO_SetBits(BT_EN_GPIO, BT_EN_GPIO_PIN);
|
||||
}
|
||||
|
||||
btRxFifo.clear();
|
||||
btTxFifo.clear();
|
||||
#endif
|
||||
|
||||
if (enable)
|
||||
GPIO_ResetBits(BT_EN_GPIO, BT_EN_GPIO_PIN);
|
||||
else
|
||||
GPIO_SetBits(BT_EN_GPIO, BT_EN_GPIO_PIN);
|
||||
}
|
||||
|
||||
#if !defined(BOOT)
|
||||
void bluetoothDisable()
|
||||
{
|
||||
GPIO_SetBits(BT_EN_GPIO, BT_EN_GPIO_PIN); // close bluetooth (recent modules will go to bootloader mode)
|
||||
@@ -165,3 +168,4 @@ uint8_t bluetoothIsWriting(void)
|
||||
{
|
||||
return bluetoothWriteState != BLUETOOTH_WRITE_IDLE;
|
||||
}
|
||||
#endif // !BOOT
|
||||
|
||||
@@ -85,13 +85,20 @@ set(BOOTLOADER_SRC
|
||||
bin_files.cpp
|
||||
)
|
||||
|
||||
if(PCB STREQUAL X12S OR PCB STREQUAL X10 OR PCB STREQUAL X9E OR (PCB STREQUAL X9D+ AND PCBREV STREQUAL 2019) OR (PCB STREQUAL X7 AND NOT (PCBREV STREQUAL T12)) OR PCB STREQUAL X9LITE)
|
||||
if(PCB STREQUAL X12S OR PCB STREQUAL X10 OR PCB STREQUAL X9E OR (PCB STREQUAL X9D+ AND PCBREV STREQUAL 2019) OR (PCB STREQUAL X7 AND NOT (PCBREV STREQUAL T12)) OR PCB STREQUAL X9LITE OR PCB STREQUAL X9LITES)
|
||||
set(BOOTLOADER_SRC
|
||||
${BOOTLOADER_SRC}
|
||||
../../../../../targets/common/arm/stm32/rotary_encoder_driver.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
if(PCB STREQUAL X7 OR PCB STREQUAL XLITE OR PCB STREQUAL XLITES)
|
||||
set(BOOTLOADER_SRC
|
||||
${BOOTLOADER_SRC}
|
||||
../../../../../targets/common/arm/stm32/bluetooth_driver.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
if(NOT (PCB STREQUAL X10 OR PCB STREQUAL X12S))
|
||||
set(BOOTLOADER_SRC
|
||||
${BOOTLOADER_SRC}
|
||||
@@ -116,7 +123,6 @@ if(PCB STREQUAL X10 OR PCB STREQUAL X12S OR PCB STREQUAL NV14)
|
||||
${BOOTLOADER_SRC}
|
||||
../../../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_usart.c
|
||||
../../../../../serial.cpp
|
||||
../aux_serial_driver.cpp
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
@@ -133,7 +139,7 @@ set(CMAKE_EXE_LINKER_FLAGS "-mcpu=${MCU} -mthumb -nostartfiles -lm -T${RADIO_SRC
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --specs=nano.specs")
|
||||
|
||||
add_executable(bootloader ${BOOTLOADER_SRC})
|
||||
add_dependencies(bootloader ${BITMAPS_TARGET} translations)
|
||||
add_dependencies(bootloader ${BITMAPS_TARGET})
|
||||
|
||||
add_custom_command(
|
||||
TARGET bootloader POST_BUILD
|
||||
|
||||
@@ -245,6 +245,11 @@ int main()
|
||||
backlightInit();
|
||||
backlightEnable();
|
||||
|
||||
#if defined(PCBX7) || defined(PCBXLITE)
|
||||
// we shutdown the bluetooth module now to be sure it will be detected on firmware start
|
||||
bluetoothInit(BLUETOOTH_DEFAULT_BAUDRATE, false);
|
||||
#endif
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
i2cInit();
|
||||
#endif
|
||||
|
||||
@@ -83,5 +83,8 @@ void check_intmodule_heartbeat()
|
||||
extern "C" void INTMODULE_HEARTBEAT_EXTI_IRQHandler()
|
||||
{
|
||||
check_intmodule_heartbeat();
|
||||
#if defined(TELEMETRY_EXTI_REUSE_INTERRUPT_INTMODULE_HEARTBEAT)
|
||||
check_telemetry_exti();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -39,14 +39,20 @@ void intmoduleStop()
|
||||
USART_DeInit(INTMODULE_USART);
|
||||
|
||||
GPIO_ResetBits(INTMODULE_GPIO, INTMODULE_TX_GPIO_PIN | INTMODULE_RX_GPIO_PIN);
|
||||
|
||||
#if defined(INTERNAL_MODULE_MULTI)
|
||||
// stop pulses timer
|
||||
INTMODULE_TIMER->DIER &= ~TIM_DIER_CC2IE;
|
||||
INTMODULE_TIMER->CR1 &= ~TIM_CR1_CEN;
|
||||
#endif
|
||||
}
|
||||
|
||||
void intmodulePxx1SerialStart()
|
||||
{
|
||||
intmoduleSerialStart(INTMODULE_PXX1_SERIAL_BAUDRATE, false);
|
||||
intmoduleSerialStart(INTMODULE_PXX1_SERIAL_BAUDRATE, false, USART_Parity_No, USART_StopBits_1, USART_WordLength_8b);
|
||||
}
|
||||
|
||||
void intmoduleSerialStart(uint32_t baudrate, uint8_t rxEnable)
|
||||
void intmoduleSerialStart(uint32_t baudrate, uint8_t rxEnable, uint16_t parity, uint16_t stopBits, uint16_t wordLength)
|
||||
{
|
||||
INTERNAL_MODULE_ON();
|
||||
|
||||
@@ -71,9 +77,9 @@ void intmoduleSerialStart(uint32_t baudrate, uint8_t rxEnable)
|
||||
USART_DeInit(INTMODULE_USART);
|
||||
USART_InitTypeDef USART_InitStructure;
|
||||
USART_InitStructure.USART_BaudRate = baudrate;
|
||||
USART_InitStructure.USART_Parity = USART_Parity_No;
|
||||
USART_InitStructure.USART_StopBits = USART_StopBits_1;
|
||||
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
|
||||
USART_InitStructure.USART_Parity = parity;
|
||||
USART_InitStructure.USART_StopBits = stopBits;
|
||||
USART_InitStructure.USART_WordLength = wordLength;
|
||||
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
|
||||
USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
|
||||
USART_Init(INTMODULE_USART, &USART_InitStructure);
|
||||
@@ -87,6 +93,28 @@ void intmoduleSerialStart(uint32_t baudrate, uint8_t rxEnable)
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(INTERNAL_MODULE_MULTI)
|
||||
void intmoduleTimerStart(uint32_t periodMs)
|
||||
{
|
||||
// Timer
|
||||
INTMODULE_TIMER->CR1 &= ~TIM_CR1_CEN;
|
||||
INTMODULE_TIMER->PSC = INTMODULE_TIMER_FREQ / 2000000 - 1; // 0.5uS (2Mhz)
|
||||
INTMODULE_TIMER->ARR = periodMs * 2000;
|
||||
INTMODULE_TIMER->CCR2 = (periodMs - 1) * 2000;
|
||||
INTMODULE_TIMER->CCER = TIM_CCER_CC3E;
|
||||
INTMODULE_TIMER->CCMR2 = 0;
|
||||
INTMODULE_TIMER->EGR = 1; // Restart
|
||||
|
||||
INTMODULE_TIMER->CCMR2 = TIM_CCMR2_OC3M_1 | TIM_CCMR2_OC3M_0; // Toggle CC1 o/p
|
||||
INTMODULE_TIMER->SR &= ~TIM_SR_CC2IF; // Clear flag
|
||||
INTMODULE_TIMER->DIER |= TIM_DIER_CC2IE; // Enable this interrupt
|
||||
INTMODULE_TIMER->CR1 |= TIM_CR1_CEN;
|
||||
|
||||
NVIC_EnableIRQ(INTMODULE_TIMER_IRQn);
|
||||
NVIC_SetPriority(INTMODULE_TIMER_IRQn, 7);
|
||||
}
|
||||
#endif
|
||||
|
||||
#define USART_FLAG_ERRORS (USART_FLAG_ORE | USART_FLAG_NE | USART_FLAG_FE | USART_FLAG_PE)
|
||||
extern "C" void INTMODULE_USART_IRQHandler(void)
|
||||
{
|
||||
@@ -98,7 +126,6 @@ extern "C" void INTMODULE_USART_IRQHandler(void)
|
||||
intmoduleFifo.errors++;
|
||||
}
|
||||
else {
|
||||
hardwareOptions.pxx2Enabled = true;
|
||||
intmoduleFifo.push(data);
|
||||
}
|
||||
status = INTMODULE_USART->SR;
|
||||
@@ -152,5 +179,20 @@ void intmoduleSendNextFrame()
|
||||
intmoduleSendBuffer(intmodulePulsesData.pxx_uart.getData(), intmodulePulsesData.pxx_uart.getSize());
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if defined(INTERNAL_MODULE_MULTI)
|
||||
case PROTOCOL_CHANNELS_MULTIMODULE:
|
||||
intmoduleSendBuffer(intmodulePulsesData.multi.getData(), intmodulePulsesData.multi.getSize());
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(INTERNAL_MODULE_MULTI)
|
||||
extern "C" void INTMODULE_TIMER_IRQHandler()
|
||||
{
|
||||
INTMODULE_TIMER->SR &= ~TIM_SR_CC2IF; // clear flag
|
||||
setupPulsesInternalModule();
|
||||
intmoduleSendNextFrame();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -71,6 +71,27 @@ void rotaryEncoderInit()
|
||||
|
||||
void rotaryEncoderCheck()
|
||||
{
|
||||
#if defined(RADIO_T16)
|
||||
static uint8_t state = 0;
|
||||
uint8_t pins = ROTARY_ENCODER_POSITION();
|
||||
|
||||
if (pins != (state & 0x03) && !(readKeys() & (1 << KEY_ENTER))) {
|
||||
if ((pins & 0x01) ^ ((pins & 0x02) >> 1)) {
|
||||
if ((state & 0x03) == 3)
|
||||
++rotencValue;
|
||||
else
|
||||
--rotencValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((state & 0x03) == 3)
|
||||
--rotencValue;
|
||||
else if ((state & 0x03) == 0)
|
||||
++rotencValue;
|
||||
}
|
||||
state &= ~0x03 ;
|
||||
state |= pins ;
|
||||
#else
|
||||
uint8_t newPosition = ROTARY_ENCODER_POSITION();
|
||||
if (newPosition != rotencPosition && !(readKeys() & (1 << KEY_ENTER))) {
|
||||
if ((rotencPosition & 0x01) ^ ((newPosition & 0x02) >> 1)) {
|
||||
@@ -80,10 +101,12 @@ void rotaryEncoderCheck()
|
||||
++rotencValue;
|
||||
}
|
||||
rotencPosition = newPosition;
|
||||
#endif
|
||||
#if !defined(BOOT)
|
||||
if (g_eeGeneral.backlightMode & e_backlight_mode_keys) {
|
||||
backlightOn();
|
||||
}
|
||||
inactivity.counter = 0;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -110,6 +133,10 @@ extern "C" void ROTARY_ENCODER_EXTI_IRQHandler1(void)
|
||||
#if !defined(BOOT) && defined(INTMODULE_HEARTBEAT_REUSE_INTERRUPT_ROTARY_ENCODER)
|
||||
check_intmodule_heartbeat();
|
||||
#endif
|
||||
|
||||
#if !defined(BOOT) && defined(TELEMETRY_EXTI_REUSE_INTERRUPT_ROTARY_ENCODER)
|
||||
check_telemetry_exti();
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(ROTARY_ENCODER_EXTI_IRQn2)
|
||||
@@ -127,4 +154,4 @@ extern "C" void ROTARY_ENCODER_TIMER_IRQHandler(void)
|
||||
ROTARY_ENCODER_TIMER->SR &= ~TIM_SR_UIF;
|
||||
ROTARY_ENCODER_TIMER->CR1 = 0;
|
||||
rotaryEncoderCheck();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user