Preliminary T18 support (#7581)
This commit is contained in:
@@ -24,6 +24,8 @@
|
||||
// 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(RADIO_T18)
|
||||
const int8_t adcDirection[NUM_ANALOGS] = { 1,-1,1,-1, -1,1,-1, -1,1, -1,1 };
|
||||
#elif defined(RADIO_TX16S)
|
||||
const int8_t adcDirection[NUM_ANALOGS] = {1,-1,1,-1, 1,1,1, -1,1, -1,1};
|
||||
#elif defined(PCBX10)
|
||||
|
||||
@@ -197,7 +197,8 @@ int main()
|
||||
|
||||
RCC_AHB1PeriphClockCmd(PWR_RCC_AHB1Periph | KEYS_RCC_AHB1Periph |
|
||||
LCD_RCC_AHB1Periph | BACKLIGHT_RCC_AHB1Periph |
|
||||
AUX_SERIAL_RCC_AHB1Periph | AUX2_SERIAL_RCC_AHB1Periph | I2C_RCC_AHB1Periph |
|
||||
AUX_SERIAL_RCC_AHB1Periph | AUX2_SERIAL_RCC_AHB1Periph |
|
||||
I2C_RCC_AHB1Periph | KEYS_BACKLIGHT_RCC_AHB1Periph |
|
||||
SD_RCC_AHB1Periph, ENABLE);
|
||||
|
||||
RCC_APB1PeriphClockCmd(ROTARY_ENCODER_RCC_APB1Periph | LCD_RCC_APB1Periph | BACKLIGHT_RCC_APB1Periph |
|
||||
|
||||
@@ -51,6 +51,12 @@ void pwrInit()
|
||||
GPIO_InitStructure.GPIO_Pin = PWR_SWITCH_GPIO_PIN;
|
||||
GPIO_Init(PWR_SWITCH_GPIO, &GPIO_InitStructure);
|
||||
|
||||
#if defined(PWR_EXTRA_SWITCH_GPIO)
|
||||
// PWR Extra switch
|
||||
GPIO_InitStructure.GPIO_Pin = PWR_EXTRA_SWITCH_GPIO_PIN;
|
||||
GPIO_Init(PWR_EXTRA_SWITCH_GPIO, &GPIO_InitStructure);
|
||||
#endif
|
||||
|
||||
#if defined(PCBREV_HARDCODED)
|
||||
hardwareOptions.pcbrev = PCBREV_HARDCODED;
|
||||
#elif defined(PCBREV_GPIO_PIN)
|
||||
@@ -101,9 +107,20 @@ void pwrOff()
|
||||
GPIO_ResetBits(PWR_ON_GPIO, PWR_ON_GPIO_PIN);
|
||||
}
|
||||
|
||||
#if defined(PWR_EXTRA_SWITCH_GPIO)
|
||||
bool pwrForcePressed()
|
||||
{
|
||||
return (GPIO_ReadInputDataBit(PWR_SWITCH_GPIO, PWR_SWITCH_GPIO_PIN) == Bit_RESET && GPIO_ReadInputDataBit(PWR_EXTRA_SWITCH_GPIO, PWR_EXTRA_SWITCH_GPIO_PIN) == Bit_RESET);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool pwrPressed()
|
||||
{
|
||||
#if defined(PWR_EXTRA_SWITCH_GPIO)
|
||||
return (GPIO_ReadInputDataBit(PWR_SWITCH_GPIO, PWR_SWITCH_GPIO_PIN) == Bit_RESET || GPIO_ReadInputDataBit(PWR_EXTRA_SWITCH_GPIO, PWR_EXTRA_SWITCH_GPIO_PIN) == Bit_RESET);
|
||||
#else
|
||||
return GPIO_ReadInputDataBit(PWR_SWITCH_GPIO, PWR_SWITCH_GPIO_PIN) == Bit_RESET;
|
||||
#endif
|
||||
}
|
||||
|
||||
void pwrResetHandler()
|
||||
|
||||
@@ -71,7 +71,7 @@ void rotaryEncoderInit()
|
||||
|
||||
void rotaryEncoderCheck()
|
||||
{
|
||||
#if defined(RADIO_FAMILY_T16)
|
||||
#if defined(RADIO_FAMILY_T16) && !defined(RADIO_T18)
|
||||
static uint8_t state = 0;
|
||||
uint8_t pins = ROTARY_ENCODER_POSITION();
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 |
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -377,6 +377,7 @@ void pwrOn();
|
||||
uint32_t pwrCheck();
|
||||
bool pwrPressed();
|
||||
#define UNEXPECTED_SHUTDOWN() (g_eeGeneral.unexpectedShutdown)
|
||||
#define pwrForcePressed() (false)
|
||||
|
||||
// EEPROM driver
|
||||
#define EEPROM_SIZE (4*1024*1024/8)
|
||||
|
||||
@@ -648,6 +648,7 @@ bool pwrPressed();
|
||||
uint32_t pwrPressedDuration();
|
||||
#endif
|
||||
void pwrResetHandler();
|
||||
#define pwrForcePressed() false
|
||||
|
||||
#if defined(SIMU)
|
||||
#define UNEXPECTED_SHUTDOWN() false
|
||||
|
||||
@@ -1639,6 +1639,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)
|
||||
|
||||
Reference in New Issue
Block a user