Merge with latest 2.3

This commit is contained in:
Bertrand Songis
2020-10-07 21:01:45 +02:00
376 changed files with 10566 additions and 8633 deletions
+3
View File
@@ -2,6 +2,8 @@ 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(GHOST "Ghost TX Module" ON)
option(INTERNAL_MODULE_PPM "Support for PPM internal module" OFF)
option(AUTOUPDATE "Auto update internal chips from SD" OFF)
@@ -353,6 +355,7 @@ endif()
add_definitions(-DPCBTARANIS)
add_definitions(-DAUDIO -DVOICE -DRTCLOCK)
add_definitions(-DSBUS_TRAINER)
set(SRC
${SRC}
+4 -3
View File
@@ -647,6 +647,7 @@ bool pwrPressed();
uint32_t pwrPressedDuration();
#endif
void pwrResetHandler();
#define pwrForcePressed() false
#if defined(SIMU)
#define UNEXPECTED_SHUTDOWN() false
@@ -663,10 +664,10 @@ uint8_t isBacklightEnabled();
#define backlightEnable(...)
#elif defined(PCBX9E) || defined(PCBX9DP)
void backlightEnable(uint8_t level = 0, uint8_t color = 0);
#define BACKLIGHT_ENABLE() backlightEnable(g_eeGeneral.backlightBright, g_eeGeneral.backlightColor)
#define BACKLIGHT_ENABLE() backlightEnable(currentBacklightBright, g_eeGeneral.backlightColor)
#else
void backlightEnable(uint8_t level = 0);
#define BACKLIGHT_ENABLE() backlightEnable(g_eeGeneral.backlightBright)
#define BACKLIGHT_ENABLE() backlightEnable(currentBacklightBright)
#endif
#if !defined(SIMU)
@@ -846,7 +847,7 @@ void ledBlue();
#define IS_LCD_RESET_NEEDED() true
#define LCD_CONTRAST_MIN 10
#define LCD_CONTRAST_MAX 30
#define LCD_CONTRAST_DEFAULT 20
#define LCD_CONTRAST_DEFAULT 15
#endif
#if defined(PCBX9D) || defined(PCBX9E) || (defined(PCBX9DP) && PCBREV < 2019)
+25 -1
View File
@@ -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
@@ -303,6 +321,12 @@ void extmoduleSendNextFrame()
break;
#endif
#if defined(GHOST)
case PROTOCOL_CHANNELS_GHOST:
sportSendBuffer(extmodulePulsesData.ghost.pulses, extmodulePulsesData.ghost.length);
break;
#endif
default:
EXTMODULE_TIMER->DIER |= TIM_DIER_CC2IE;
break;
+9
View File
@@ -928,6 +928,14 @@
#define GPIO_LED_GPIO_OFF GPIO_SetBits
#define LED_RED_GPIO GPIOA
#define LED_RED_GPIO_PIN GPIO_Pin_13 // PA.13
#elif defined(PCBXLITES)
#define STATUS_LEDS
#define GPIO_LED_GPIO_ON GPIO_ResetBits
#define GPIO_LED_GPIO_OFF GPIO_SetBits
#define LED_BLUE_GPIO GPIOE
#define LED_BLUE_GPIO_PIN GPIO_Pin_6 // PE.06
#define LED_RED_GPIO GPIOE
#define LED_RED_GPIO_PIN GPIO_Pin_4 // PE.04
#elif defined(PCBXLITE)
#define STATUS_LEDS
#define GPIO_LED_GPIO_ON GPIO_ResetBits
@@ -1646,6 +1654,7 @@
#define BACKLIGHT_GPIO_PinSource GPIO_PinSource8
#define BACKLIGHT_GPIO_AF GPIO_AF_TIM10
#endif
#define KEYS_BACKLIGHT_RCC_AHB1Periph 0
// LCD driver
#if defined(PCBX9E)
+6 -6
View File
@@ -144,9 +144,9 @@ void lcdStart()
lcdWriteCommand(0xE9); // Set bias=1/10
lcdWriteCommand(0x81); // Set Vop
#if defined(BOOT)
lcdWriteCommand(LCD_CONTRAST_OFFSET+LCD_CONTRAST_DEFAULT);
lcdWriteCommand(LCD_CONTRAST_OFFSET + LCD_CONTRAST_DEFAULT);
#else
lcdWriteCommand(LCD_CONTRAST_OFFSET+g_eeGeneral.contrast);
lcdWriteCommand(LCD_CONTRAST_OFFSET + g_eeGeneral.contrast);
#endif
lcdWriteCommand(0xA2); // Set line rate: 28KLPS
lcdWriteCommand(0x28); // Set panel loading
@@ -173,11 +173,11 @@ void lcdStart()
void lcdWriteAddress(uint8_t x, uint8_t y)
{
lcdWriteCommand(x & 0x0F); // Set Column Address LSB CA[3:0]
lcdWriteCommand((x>>4) | 0x10); // Set Column Address MSB CA[7:4]
lcdWriteCommand(x & 0x0Fu); // Set Column Address LSB CA[3:0]
lcdWriteCommand((x >> 4u) | 0x10u); // Set Column Address MSB CA[7:4]
lcdWriteCommand((y&0x0F) | 0x60); // Set Row Address LSB RA [3:0]
lcdWriteCommand(((y>>4) & 0x0F) | 0x70); // Set Row Address MSB RA [7:4]
lcdWriteCommand((y & 0x0Fu) | 0x60u); // Set Row Address LSB RA [3:0]
lcdWriteCommand(((y >> 4u) & 0x0Fu) | 0x70u); // Set Row Address MSB RA [7:4]
}
#endif
+31 -7
View File
@@ -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 {
@@ -189,6 +203,11 @@ void telemetryPortInvertedRxBit()
void telemetryPortSetDirectionOutput()
{
#if defined(GHOST) && SPORT_MAX_BAUDRATE < 400000
if (isModuleGhost(EXTERNAL_MODULE)) {
TELEMETRY_USART->BRR = BRR_400K;
}
#endif
TELEMETRY_DIR_OUTPUT();
TELEMETRY_USART->CR1 &= ~USART_CR1_RE; // turn off receiver
}
@@ -201,6 +220,11 @@ void sportWaitTransmissionComplete()
void telemetryPortSetDirectionInput()
{
sportWaitTransmissionComplete();
#if defined(GHOST) && SPORT_MAX_BAUDRATE < 400000
if (isModuleGhost(EXTERNAL_MODULE) && g_eeGeneral.telemetryBaudrate == GHST_TELEMETRY_RATE_115K) {
TELEMETRY_USART->BRR = BRR_115K;
}
#endif
TELEMETRY_DIR_INPUT();
TELEMETRY_USART->CR1 |= USART_CR1_RE; // turn on receiver
}
@@ -333,7 +357,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
+1 -1
View File
@@ -329,7 +329,7 @@ void stop_trainer_module_sbus()
}
#endif
#if defined(SBUS)
#if defined(SBUS_TRAINER)
int sbusGetByte(uint8_t * byte)
{
switch (currentTrainerMode) {