Preliminary T18 support (#7581)

This commit is contained in:
3djc
2020-06-22 21:15:47 +02:00
committed by GitHub
parent 02b61fff24
commit 2d01916055
76 changed files with 952 additions and 426 deletions
+7
View File
@@ -71,6 +71,13 @@ if (PCB STREQUAL X10)
set(AUX2_SERIAL ON)
endif()
set(INTERNAL_GPS_BAUDRATE "9600" CACHE STRING "Baud rate for internal GPS")
elseif (PCBREV STREQUAL T18)
set(FLAVOUR t18)
set(LUA_EXPORT lua_export_t16)
add_definitions(-DRADIO_T18)
add_definitions(-DRADIO_FAMILY_T16)
option(INTERNAL_MODULE_MULTI "Support for MULTI internal module" ON)
option(BLUETOOTH "Support for bluetooth module" OFF)
else()
set(FLAVOUR x10)
option(INTERNAL_MODULE_PXX1 "Support for PXX1 internal module" ON)
@@ -32,6 +32,15 @@ void backlightInit()
GPIO_Init(BACKLIGHT_GPIO, &GPIO_InitStructure);
GPIO_PinAFConfig(BACKLIGHT_GPIO, BACKLIGHT_GPIO_PinSource, BACKLIGHT_GPIO_AF);
#if defined(KEYS_BACKLIGHT_GPIO)
GPIO_InitStructure.GPIO_Pin = KEYS_BACKLIGHT_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(KEYS_BACKLIGHT_GPIO, &GPIO_InitStructure);
#endif
// TIMER init
#if defined(PCBX12S) && PCBREV >= 13
BACKLIGHT_TIMER->ARR = 100;
@@ -72,6 +81,15 @@ void backlightEnable(uint8_t dutyCycle)
BACKLIGHT_TIMER->CCR3 = BACKLIGHT_LEVEL_MAX - dutyCycle;
#endif
#if defined(KEYS_BACKLIGHT_GPIO) && !defined(BOOT)
if (dutyCycle == 0 || g_eeGeneral.keysBacklight == 0) {
GPIO_ResetBits(KEYS_BACKLIGHT_GPIO, KEYS_BACKLIGHT_GPIO_PIN);
}
else {
GPIO_SetBits(KEYS_BACKLIGHT_GPIO, KEYS_BACKLIGHT_GPIO_PIN);
}
#endif
if (dutyCycle == 0) {
BACKLIGHT_TIMER->BDTR &= ~TIM_BDTR_MOE;
}
+1
View File
@@ -103,6 +103,7 @@ void boardInit()
LED_RCC_AHB1Periph |
LCD_RCC_AHB1Periph |
BACKLIGHT_RCC_AHB1Periph |
KEYS_BACKLIGHT_RCC_AHB1Periph |
SD_RCC_AHB1Periph |
AUDIO_RCC_AHB1Periph |
KEYS_RCC_AHB1Periph |
+9
View File
@@ -492,6 +492,11 @@ void pwrOn();
void pwrOff();
void pwrResetHandler();
bool pwrPressed();
#if defined(PWR_EXTRA_SWITCH_GPIO)
bool pwrForcePressed();
#else
#define pwrForcePressed() false
#endif
uint32_t pwrPressedDuration();
// USB Charger
@@ -555,6 +560,10 @@ void usbJoystickUpdate();
#define USB_NAME "Jumper T16"
#define USB_MANUFACTURER 'J', 'u', 'm', 'p', 'e', 'r', ' ', ' ' /* 8 bytes */
#define USB_PRODUCT 'T', '1', '6', ' ', ' ', ' ', ' ', ' ' /* 8 Bytes */
#elif defined(RADIO_T18)
#define USB_NAME "Jumper T18"
#define USB_MANUFACTURER 'J', 'u', 'm', 'p', 'e', 'r', ' ', ' ' /* 8 bytes */
#define USB_PRODUCT 'T', '1', '8', ' ', ' ', ' ', ' ', ' ' /* 8 Bytes */
#elif defined(RADIO_TX16S)
#define USB_NAME "RadioMas TX16S"
#define USB_MANUFACTURER 'R', 'a', 'd', 'i', 'o', 'M', 'a', 's' /* 8 bytes */
+22 -1
View File
@@ -322,7 +322,7 @@
#define ADC_TRANSFER_COMPLETE() (ADC_DMA->LISR & DMA_LISR_TCIF0)
#if defined(RADIO_TX16S)
#define ADC_VREF_PREC2 330
#elif defined(RADIO_T16)
#elif defined(RADIO_T16) || defined(RADIO_T18)
#define ADC_VREF_PREC2 300
#else
#define ADC_VREF_PREC2 250
@@ -330,11 +330,21 @@
#endif
// Power
#if defined(RADIO_T18)
#define PWR_RCC_AHB1Periph RCC_AHB1Periph_GPIOJ | RCC_AHB1Periph_GPIOB
#define PWR_ON_GPIO GPIOJ
#define PWR_ON_GPIO_PIN GPIO_Pin_1 // PJ.01
#define PWR_SWITCH_GPIO GPIOJ
#define PWR_SWITCH_GPIO_PIN GPIO_Pin_0 // PJ.00
#define PWR_EXTRA_SWITCH_GPIO GPIOB
#define PWR_EXTRA_SWITCH_GPIO_PIN GPIO_Pin_0 // PB.00
#else
#define PWR_RCC_AHB1Periph RCC_AHB1Periph_GPIOJ
#define PWR_ON_GPIO GPIOJ
#define PWR_ON_GPIO_PIN GPIO_Pin_1 // PJ.01
#define PWR_SWITCH_GPIO GPIOJ
#define PWR_SWITCH_GPIO_PIN GPIO_Pin_0 // PJ.00
#endif
// USB Charger
#if defined(USB_CHARGER)
@@ -514,6 +524,9 @@
#define LCD_GPIO_NRST GPIOI
#define LCD_GPIO_PIN_NRST GPIO_Pin_10 // PI.10
#endif
#if defined(PCBX10) && !defined(RADIO_T18) && !defined(SIMU)
#define LCD_VERTICAL_INVERT
#endif
#define LTDC_IRQ_PRIO 4
#define DMA_SCREEN_IRQ_PRIO 6
@@ -549,6 +562,14 @@
#define BACKLIGHT_GPIO_AF GPIO_AF_TIM8
#define BACKLIGHT_TIMER_FREQ (PERI2_FREQUENCY * TIMER_MULT_APB2)
#endif
#if defined(RADIO_T18)
#define KEYS_BACKLIGHT_RCC_AHB1Periph RCC_AHB1Periph_GPIOC
#define KEYS_BACKLIGHT_GPIO GPIOC
#define KEYS_BACKLIGHT_GPIO_PIN GPIO_Pin_4 // PC.04
#define KEYS_BACKLIGHT_GPIO_PinSource GPIO_PinSource4
#else
#define KEYS_BACKLIGHT_RCC_AHB1Periph 0
#endif
// SD
#define SD_RCC_AHB1Periph (RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_DMA2)
+24 -9
View File
@@ -20,14 +20,25 @@
#include "opentx.h"
#define HBP 42
#define VBP 12
#if defined(RADIO_T18)
#define HBP 43
#define VBP 12
#define HSW 2
#define VSW 10
#define HSW 2
#define VSW 4
#define HFP 3
#define VFP 2
#define HFP 8
#define VFP 8
#else
#define HBP 42
#define VBP 12
#define HSW 2
#define VSW 10
#define HFP 3
#define VFP 2
#endif
#define LCD_FIRST_LAYER 0
#define LCD_SECOND_LAYER 1
@@ -315,7 +326,11 @@ void LCD_Init(void)
{
/* Reset the LCD --------------------------------------------------------*/
LCD_NRSTConfig();
#if defined(RADIO_T18) // T18 seems to have eractic display issue if NRST is ever driven low
NRST_HIGH();
#else
lcd_reset();
#endif
/* Configure the LCD Control pins */
LCD_AF_GPIOConfig();
@@ -383,7 +398,7 @@ void lcdInit(void)
void DMAFillRect(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color)
{
#if defined(PCBX10)
#if defined(LCD_VERTICAL_INVERT)
x = destw - (x + w);
y = desth - (y + h);
#endif
@@ -415,7 +430,7 @@ void DMAFillRect(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, ui
void DMACopyBitmap(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, const uint16_t * src, uint16_t srcw, uint16_t srch, uint16_t srcx, uint16_t srcy, uint16_t w, uint16_t h)
{
#if defined(PCBX10)
#if defined(LCD_VERTICAL_INVERT)
x = destw - (x + w);
y = desth - (y + h);
srcx = srcw - (srcx + w);
@@ -458,7 +473,7 @@ void DMACopyBitmap(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x,
void DMACopyAlphaBitmap(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, const uint16_t * src, uint16_t srcw, uint16_t srch, uint16_t srcx, uint16_t srcy, uint16_t w, uint16_t h)
{
#if defined(PCBX10)
#if defined(LCD_VERTICAL_INVERT)
x = destw - (x + w);
y = desth - (y + h);
srcx = srcw - (srcx + w);