feat: Jumper T15 support (#5113)
Co-authored-by: 3djc <3djc@gh.com> Co-authored-by: philmoz <phil.a.mitchell@gmail.com>
This commit is contained in:
@@ -54,7 +54,7 @@ if (PCB STREQUAL X10)
|
||||
${FIRMWARE_SRC}
|
||||
targets/common/arm/stm32/audio_dac_driver.cpp
|
||||
)
|
||||
if (NOT PCBREV STREQUAL TX16S)
|
||||
if (NOT (PCBREV STREQUAL TX16S OR PCBREV STREQUAL T15))
|
||||
set(FIRMWARE_SRC
|
||||
${FIRMWARE_SRC}
|
||||
targets/common/arm/stm32/sticks_pwm_driver.cpp
|
||||
@@ -71,6 +71,18 @@ if (PCB STREQUAL X10)
|
||||
add_definitions(-DHARDWARE_POWER_MANAGEMENT_UNIT)
|
||||
add_definitions(-DRADIO_X10E)
|
||||
add_definitions(-DMANUFACTURER_FRSKY)
|
||||
elseif (PCBREV STREQUAL T15)
|
||||
set(FLAVOUR t15)
|
||||
add_definitions(-DRADIO_T15)
|
||||
add_definitions(-DRADIO_FAMILY_T16)
|
||||
set(FUNCTION_SWITCHES ON)
|
||||
set(DEFAULT_INTERNAL_MODULE CROSSFIRE CACHE STRING "Default internal module")
|
||||
option(BLUETOOTH "Support for bluetooth module" OFF)
|
||||
option(INTERNAL_GPS "Support for internal NMEA GPS" OFF)
|
||||
set(AUX_SERIAL ON)
|
||||
set(AUX2_SERIAL OFF)
|
||||
add_definitions(-DMANUFACTURER_JUMPER)
|
||||
set(LCD_DRIVER lcd_st7796s_driver.cpp)
|
||||
elseif (PCBREV STREQUAL T16)
|
||||
set(FLAVOUR t16)
|
||||
add_definitions(-DRADIO_T16)
|
||||
@@ -158,6 +170,10 @@ add_definitions(-DSTM32_SUPPORT_32BIT_TIMERS)
|
||||
|
||||
set(SDRAM ON)
|
||||
|
||||
if(FUNCTION_SWITCHES)
|
||||
add_definitions(-DFUNCTION_SWITCHES)
|
||||
endif()
|
||||
|
||||
if(NOT UNEXPECTED_SHUTDOWN)
|
||||
add_definitions(-DNO_UNEXPECTED_SHUTDOWN)
|
||||
endif()
|
||||
@@ -206,7 +222,12 @@ endif()
|
||||
set(GVAR_SCREEN model_gvars.cpp)
|
||||
|
||||
if(HARDWARE_TOUCH)
|
||||
set(TOUCH_DRIVER tp_gt911.cpp)
|
||||
if(FLAVOUR STREQUAL t15)
|
||||
set(TOUCH_DRIVER cst8xx_driver.cpp)
|
||||
else()
|
||||
set(TOUCH_DRIVER tp_gt911.cpp)
|
||||
add_definitions(-DTP_GT911)
|
||||
endif()
|
||||
add_definitions(-DHARDWARE_TOUCH)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -65,6 +65,52 @@ void boardInit()
|
||||
#endif
|
||||
|
||||
pwrInit();
|
||||
|
||||
#if defined(FUNCTION_SWITCHES) && !defined(DEBUG_SEGGER_RTT)
|
||||
#if defined(RADIO_T15)
|
||||
#define LEDCHARGEON(x) fsLedOff(x)
|
||||
#define LEDCHARGEOFF(x) fsLedOn(x)
|
||||
#else
|
||||
#define LEDCHARGEON(x) fsLedOn(x)
|
||||
#define LEDCHARGEOFF(x) fsLedOff(x)
|
||||
#endif
|
||||
// This is needed to prevent radio from starting when usb is plugged to charge
|
||||
usbInit();
|
||||
ledInit();
|
||||
// prime debounce state...
|
||||
usbPlugged();
|
||||
if (usbPlugged()) {
|
||||
delaysInit();
|
||||
adcInit(&_adc_driver);
|
||||
getADC();
|
||||
pwrOn(); // required to get bat adc reads
|
||||
INTERNAL_MODULE_OFF();
|
||||
EXTERNAL_MODULE_OFF();
|
||||
for (uint8_t i=0; i < NUM_FUNCTIONS_SWITCHES; i++)
|
||||
LEDCHARGEOFF(i);
|
||||
while (usbPlugged()) {
|
||||
// Let it charge ...
|
||||
getADC(); // Warning: the value read does not include VBAT calibration
|
||||
// Also, MCU is running which create a drop vs off
|
||||
if (getBatteryVoltage() >= 660)
|
||||
LEDCHARGEON(0);
|
||||
if (getBatteryVoltage() >= 700)
|
||||
LEDCHARGEON(1);
|
||||
if (getBatteryVoltage() >= 740)
|
||||
LEDCHARGEON(2);
|
||||
if (getBatteryVoltage() >= 780)
|
||||
LEDCHARGEON(3);
|
||||
if (getBatteryVoltage() >= 810)
|
||||
LEDCHARGEON(4);
|
||||
if (getBatteryVoltage() >= 820)
|
||||
LEDCHARGEON(5);
|
||||
delay_ms(1000);
|
||||
}
|
||||
while(1) // Wait power to drain
|
||||
pwrOff();
|
||||
}
|
||||
#endif
|
||||
|
||||
boardInitModulePorts();
|
||||
|
||||
#if defined(INTMODULE_HEARTBEAT) && \
|
||||
|
||||
@@ -74,6 +74,10 @@ enum {
|
||||
// X10
|
||||
PCBREV_X10_STD = 0,
|
||||
PCBREV_X10_EXPRESS = 3,
|
||||
|
||||
//T15
|
||||
PCBREV_T15_STD = 0,
|
||||
PCBREV_T15_IPS = 1,
|
||||
};
|
||||
|
||||
#if defined(SIMU)
|
||||
@@ -145,10 +149,6 @@ uint32_t isBootloaderStart(const uint8_t * buffer);
|
||||
#define IS_PXX1_INTERNAL_ENABLED() (true)
|
||||
#endif
|
||||
|
||||
#if !defined(NUM_FUNCTIONS_SWITCHES)
|
||||
#define NUM_FUNCTIONS_SWITCHES 0
|
||||
#endif
|
||||
|
||||
// POTS and SLIDERS default configuration
|
||||
#if defined(RADIO_TX16S)
|
||||
#define XPOS_CALIB_DEFAULT {0x3, 0xc, 0x15, 0x1e, 0x26}
|
||||
@@ -159,6 +159,10 @@ uint32_t isBootloaderStart(const uint8_t * buffer);
|
||||
#define NUM_TRIMS_KEYS (NUM_TRIMS * 2)
|
||||
|
||||
// Battery driver
|
||||
#if defined(RADIO_T15)
|
||||
#define VOLTAGE_DROP 65
|
||||
#endif
|
||||
|
||||
#if defined(PCBX10)
|
||||
// Lipo 2S
|
||||
#define BATTERY_WARN 66 // 6.6V
|
||||
@@ -320,6 +324,26 @@ void bluetoothDisable();
|
||||
#define BATTERY_DIVIDER 1495
|
||||
#else
|
||||
#define BATTERY_DIVIDER 1629
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(FUNCTION_SWITCHES)
|
||||
#define NUM_FUNCTIONS_SWITCHES 6
|
||||
#define DEFAULT_FS_CONFIG \
|
||||
(SWITCH_2POS << 10) + (SWITCH_2POS << 8) + (SWITCH_2POS << 6) + \
|
||||
(SWITCH_2POS << 4) + (SWITCH_2POS << 2) + (SWITCH_2POS << 0)
|
||||
|
||||
#define DEFAULT_FS_GROUPS \
|
||||
(1 << 10) + (1 << 8) + (1 << 6) + (1 << 4) + (1 << 2) + \
|
||||
(1 << 0) // Set all FS to group 1 to act like a 6pos
|
||||
|
||||
#define DEFAULT_FS_STARTUP_CONFIG \
|
||||
((FS_START_PREVIOUS << 10) + (FS_START_PREVIOUS << 8) + \
|
||||
(FS_START_PREVIOUS << 6) + (FS_START_PREVIOUS << 4) + \
|
||||
(FS_START_PREVIOUS << 2) + \
|
||||
(FS_START_PREVIOUS << 0)) // keep last state by default
|
||||
|
||||
#else
|
||||
#define NUM_FUNCTIONS_SWITCHES 0
|
||||
#endif
|
||||
|
||||
#endif // _BOARD_H_
|
||||
|
||||
@@ -61,7 +61,7 @@ static void bootloaderDrawTitle(unsigned int x, const char* text)
|
||||
|
||||
static void bootloaderDrawFooter()
|
||||
{
|
||||
lcd->drawSolidFilledRect(28, 234, 422, 2, BL_FOREGROUND);
|
||||
lcd->drawSolidFilledRect(28, LCD_H - 38, 422, 2, BL_FOREGROUND);
|
||||
}
|
||||
|
||||
static void bootloaderDrawBackground()
|
||||
@@ -94,17 +94,17 @@ void bootloaderDrawScreen(BootloaderState st, int opt, const char* str)
|
||||
pos -= 92;
|
||||
lcd->drawSolidRect(92, (opt == 0) ? 72 : 107, pos, 26, 2, BL_SELECTED);
|
||||
|
||||
lcd->drawBitmap(60, 166, (const BitmapBuffer*)&BMP_PLUG_USB);
|
||||
lcd->drawText(195, 175, TR_BL_USB_PLUGIN, BL_FOREGROUND);
|
||||
lcd->drawText(195, 200, TR_BL_USB_MASS_STORE, BL_FOREGROUND);
|
||||
lcd->drawBitmap(60, LCD_H - 106, (const BitmapBuffer*)&BMP_PLUG_USB);
|
||||
lcd->drawText(195, LCD_H - 97, TR_BL_USB_PLUGIN, BL_FOREGROUND);
|
||||
lcd->drawText(195, LCD_H - 72, TR_BL_USB_MASS_STORE, BL_FOREGROUND);
|
||||
|
||||
bootloaderDrawFooter();
|
||||
lcd->drawText(LCD_W / 2, 242, getFirmwareVersion(), CENTERED | BL_FOREGROUND);
|
||||
lcd->drawText(LCD_W / 2, LCD_H - 30, getFirmwareVersion(), CENTERED | BL_FOREGROUND);
|
||||
}
|
||||
else if (st == ST_USB) {
|
||||
|
||||
lcd->drawBitmap(136, 98, (const BitmapBuffer*)&BMP_USB_PLUGGED);
|
||||
lcd->drawText(195, 128, TR_BL_USB_CONNECTED, BL_FOREGROUND);
|
||||
coord_t y = (LCD_H - BMP_USB_PLUGGED.height()) / 2;
|
||||
lcd->drawBitmap(136, y, (const BitmapBuffer*)&BMP_USB_PLUGGED);
|
||||
lcd->drawText(195, y + 30, TR_BL_USB_CONNECTED, BL_FOREGROUND);
|
||||
}
|
||||
else if (st == ST_FILE_LIST || st == ST_DIR_CHECK || st == ST_FLASH_CHECK ||
|
||||
st == ST_FLASHING || st == ST_FLASH_DONE) {
|
||||
@@ -119,8 +119,8 @@ void bootloaderDrawScreen(BootloaderState st, int opt, const char* str)
|
||||
opt = 100; // Completed > 100%
|
||||
}
|
||||
|
||||
lcd->drawRect(70, 120, 340, 31, 2, SOLID, BL_SELECTED);
|
||||
lcd->drawSolidFilledRect(74, 124, (332 * opt) / 100, 23, color);
|
||||
lcd->drawRect(70, (LCD_H - 31) / 2, 340, 31, 2, SOLID, BL_SELECTED);
|
||||
lcd->drawSolidFilledRect(74, (LCD_H - 31) / 2 + 4, (332 * opt) / 100, 23, color);
|
||||
} else if (st == ST_DIR_CHECK) {
|
||||
if (opt == FR_NO_PATH) {
|
||||
lcd->drawText(90, 168, LV_SYMBOL_CLOSE TR_BL_DIR_MISSING,
|
||||
@@ -162,25 +162,25 @@ void bootloaderDrawScreen(BootloaderState st, int opt, const char* str)
|
||||
|
||||
if ( st != ST_DIR_CHECK && (st != ST_FLASH_CHECK || opt == FC_OK)) {
|
||||
|
||||
lcd->drawText(28, 242, LV_SYMBOL_CHARGE, BL_FOREGROUND);
|
||||
lcd->drawText(28, LCD_H - 30, LV_SYMBOL_CHARGE, BL_FOREGROUND);
|
||||
|
||||
if (st == ST_FILE_LIST) {
|
||||
lcd->drawText(56, 244, TR_BL_SELECT_KEY, BL_FOREGROUND);
|
||||
lcd->drawText(56, LCD_H - 28, TR_BL_SELECT_KEY, BL_FOREGROUND);
|
||||
}
|
||||
else if (st == ST_FLASH_CHECK && opt == FC_OK) {
|
||||
lcd->drawText(56, 244, TR_BL_FLASH_KEY, BL_FOREGROUND);
|
||||
lcd->drawText(56, LCD_H - 28, TR_BL_FLASH_KEY, BL_FOREGROUND);
|
||||
}
|
||||
else if (st == ST_FLASHING) {
|
||||
lcd->drawText(56, 244, TR_BL_WRITING_FW, BL_FOREGROUND);
|
||||
lcd->drawText(56, LCD_H - 28, TR_BL_WRITING_FW, BL_FOREGROUND);
|
||||
}
|
||||
else if (st == ST_FLASH_DONE) {
|
||||
lcd->drawText(56, 244, TR_BL_WRITING_COMPL, BL_FOREGROUND);
|
||||
lcd->drawText(56, LCD_H - 28, TR_BL_WRITING_COMPL, BL_FOREGROUND);
|
||||
}
|
||||
}
|
||||
|
||||
if (st != ST_FLASHING) {
|
||||
lcd->drawText(305, 244, LV_SYMBOL_NEW_LINE, BL_FOREGROUND);
|
||||
lcd->drawText(335, 244, TR_BL_EXIT_KEY, BL_FOREGROUND);
|
||||
lcd->drawText(305, LCD_H - 28, LV_SYMBOL_NEW_LINE, BL_FOREGROUND);
|
||||
lcd->drawText(335, LCD_H - 28, TR_BL_EXIT_KEY, BL_FOREGROUND);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,290 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "cst8xx_driver.h"
|
||||
|
||||
#include "debug.h"
|
||||
#include "delays_driver.h"
|
||||
#include "hal.h"
|
||||
#include "hal/gpio.h"
|
||||
#include "rtos.h"
|
||||
#include "stm32_exti_driver.h"
|
||||
#include "stm32_gpio.h"
|
||||
#include "stm32_gpio_driver.h"
|
||||
#include "stm32_hal.h"
|
||||
#include "stm32_hal_ll.h"
|
||||
#include "stm32_i2c_driver.h"
|
||||
#include "timers_driver.h"
|
||||
|
||||
volatile static bool touchEventOccured;
|
||||
|
||||
#define TOUCH_CST836U_I2C_ADDRESS (0x15)
|
||||
|
||||
static tc_handle_TypeDef tc_handle = {0, 0};
|
||||
|
||||
tmr10ms_t downTime = 0;
|
||||
tmr10ms_t tapTime = 0;
|
||||
short tapCount = 0;
|
||||
#define TAP_TIME 250 // ms
|
||||
|
||||
static TouchState internalTouchState = {};
|
||||
|
||||
static void _cst836u_exti_isr(void) { touchEventOccured = true; }
|
||||
|
||||
static void TouchAFExtiConfig(void)
|
||||
{
|
||||
__HAL_RCC_SYSCFG_CLK_ENABLE();
|
||||
LL_SYSCFG_SetEXTISource(TOUCH_INT_EXTI_Port, TOUCH_INT_EXTI_SysCfgLine);
|
||||
|
||||
stm32_exti_enable(TOUCH_INT_EXTI_Line, LL_EXTI_TRIGGER_FALLING,
|
||||
_cst836u_exti_isr);
|
||||
}
|
||||
|
||||
void initTouchI2C(void)
|
||||
{
|
||||
TRACE("CST836U I2C Init");
|
||||
|
||||
if (stm32_i2c_init(TOUCH_I2C_BUS, TOUCH_I2C_CLK_RATE) < 0) {
|
||||
TRACE("CST836U ERROR: stm32_i2c_init failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#define I2C_TIMEOUT_MAX 5 // 5 ms
|
||||
|
||||
bool touch_i2c_read(uint8_t addr, uint8_t reg, uint8_t* data, uint8_t len)
|
||||
{
|
||||
if (stm32_i2c_master_tx(TOUCH_I2C_BUS, addr, ®, 1, 3) < 0) return false;
|
||||
delay_us(5);
|
||||
if (stm32_i2c_master_rx(TOUCH_I2C_BUS, addr, data, len, I2C_TIMEOUT_MAX) < 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static uint8_t TS_IO_Read(uint8_t addr, uint8_t reg)
|
||||
{
|
||||
uint8_t result;
|
||||
uint8_t tryCount = 3;
|
||||
while (!touch_i2c_read(addr, reg, &result, 1)) {
|
||||
if (--tryCount == 0) break;
|
||||
initTouchI2C();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static uint16_t TS_IO_ReadMultiple(uint8_t addr, uint8_t reg, uint8_t* buffer,
|
||||
uint16_t length)
|
||||
{
|
||||
uint8_t tryCount = 3;
|
||||
while (!touch_i2c_read(addr, reg, buffer, length)) {
|
||||
if (--tryCount == 0) break;
|
||||
initTouchI2C();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void touch_cst836u_debug_info(void)
|
||||
{
|
||||
#if defined(DEBUG)
|
||||
TRACE("cst836u: fw ver 0x%02X %02X",
|
||||
TS_IO_Read(TOUCH_CST836U_I2C_ADDRESS, CST836U_FW_VERSION_H_REG),
|
||||
TS_IO_Read(TOUCH_CST836U_I2C_ADDRESS, CST836U_FW_VERSION_L_REG));
|
||||
TRACE("cst836u: module version 0x%02X",
|
||||
TS_IO_Read(TOUCH_CST836U_I2C_ADDRESS, CST836U_MODULE_VERSION_REG));
|
||||
TRACE("cst836u: project name 0x%02X",
|
||||
TS_IO_Read(TOUCH_CST836U_I2C_ADDRESS, CST836U_PROJECT_NAME_REG));
|
||||
TRACE("cst836u: chip type 0x%02X 0x%02X",
|
||||
TS_IO_Read(TOUCH_CST836U_I2C_ADDRESS, CST836U_CHIP_TYPE_H_REG),
|
||||
TS_IO_Read(TOUCH_CST836U_I2C_ADDRESS, CST836U_CHIP_TYPE_L_REG));
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the touch screen X and Y positions values
|
||||
* Manage multi touch thanks to touch Index global
|
||||
* variable 'tc_handle.currActiveTouchIdx'.
|
||||
* @param DeviceAddr: Device address on communication Bus.
|
||||
* @param X: Pointer to X position value
|
||||
* @param Y: Pointer to Y position value
|
||||
* @retval None.
|
||||
*/
|
||||
static void cst836u_TS_GetXY(uint16_t* X, uint16_t* Y, uint32_t* event)
|
||||
{
|
||||
uint8_t regAddress = 0;
|
||||
uint8_t dataxy[4];
|
||||
|
||||
if (tc_handle.currActiveTouchIdx < tc_handle.currActiveTouchNb) {
|
||||
switch (tc_handle.currActiveTouchIdx) {
|
||||
case 0:
|
||||
regAddress = CST836U_TOUCH1_XH_REG;
|
||||
break;
|
||||
case 1:
|
||||
regAddress = CST836U_TOUCH2_XH_REG;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* Read X and Y positions */
|
||||
TS_IO_ReadMultiple(TOUCH_CST836U_I2C_ADDRESS, regAddress, dataxy,
|
||||
sizeof(dataxy));
|
||||
/* Send back ready X position to caller */
|
||||
*X = ((dataxy[0] & CST836U_MSB_MASK) << 8) | dataxy[1];
|
||||
/* Send back ready Y position to caller */
|
||||
*Y = ((dataxy[2] & CST836U_MSB_MASK) << 8) | dataxy[3];
|
||||
|
||||
*event = (dataxy[0] & CST836U_TOUCH_EVT_FLAG_MASK) >>
|
||||
CST836U_TOUCH_EVT_FLAG_SHIFT;
|
||||
/*
|
||||
uint32_t weight;
|
||||
uint32_t area;
|
||||
*/
|
||||
tc_handle.currActiveTouchIdx++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return if there is touches detected or not.
|
||||
* Try to detect new touches and forget the old ones (reset internal
|
||||
* global variables).
|
||||
* @param DeviceAddr: Device address on communication Bus.
|
||||
* @retval : Number of active touches detected (can be 0, 1 or 2).
|
||||
*/
|
||||
static uint8_t cst836u_TS_DetectTouch()
|
||||
{
|
||||
volatile uint8_t nbTouch = 0;
|
||||
|
||||
/* Read register CST836U_TOUCH_NUM_REG to check number of touches detection */
|
||||
nbTouch = TS_IO_Read(TOUCH_CST836U_I2C_ADDRESS, CST836U_TOUCH_NUM_REG);
|
||||
if (nbTouch > CST836U_MAX_DETECTABLE_TOUCH) {
|
||||
/* If invalid number of touch detected, set it to zero */
|
||||
nbTouch = 0;
|
||||
}
|
||||
tc_handle.currActiveTouchNb = nbTouch;
|
||||
|
||||
tc_handle.currActiveTouchIdx = 0;
|
||||
return (nbTouch);
|
||||
}
|
||||
|
||||
void TouchReset()
|
||||
{
|
||||
gpio_clear(TOUCH_RST_GPIO);
|
||||
delay_ms(10);
|
||||
gpio_set(TOUCH_RST_GPIO);
|
||||
delay_ms(300);
|
||||
}
|
||||
|
||||
void touchPanelInit(void)
|
||||
{
|
||||
gpio_init(TOUCH_RST_GPIO, GPIO_OUT, GPIO_PIN_SPEED_LOW);
|
||||
initTouchI2C();
|
||||
TouchReset();
|
||||
TouchAFExtiConfig();
|
||||
touch_cst836u_debug_info();
|
||||
}
|
||||
|
||||
void handleTouch()
|
||||
{
|
||||
unsigned short touchX;
|
||||
unsigned short touchY;
|
||||
uint32_t tEvent = 0;
|
||||
cst836u_TS_GetXY(&touchX, &touchY, &tEvent);
|
||||
|
||||
if (tEvent == CST836U_TOUCH_EVT_FLAG_CONTACT) {
|
||||
int dx = touchX - internalTouchState.x;
|
||||
int dy = touchY - internalTouchState.y;
|
||||
|
||||
internalTouchState.x = touchX;
|
||||
internalTouchState.y = touchY;
|
||||
|
||||
if (internalTouchState.event == TE_NONE ||
|
||||
internalTouchState.event == TE_UP ||
|
||||
internalTouchState.event == TE_SLIDE_END) {
|
||||
internalTouchState.startX = internalTouchState.x;
|
||||
internalTouchState.startY = internalTouchState.y;
|
||||
internalTouchState.event = TE_DOWN;
|
||||
} else if (internalTouchState.event == TE_DOWN) {
|
||||
if (dx >= SLIDE_RANGE || dx <= -SLIDE_RANGE || dy >= SLIDE_RANGE ||
|
||||
dy <= -SLIDE_RANGE) {
|
||||
internalTouchState.event = TE_SLIDE;
|
||||
internalTouchState.deltaX = (short)dx;
|
||||
internalTouchState.deltaY = (short)dy;
|
||||
} else {
|
||||
internalTouchState.event = TE_DOWN;
|
||||
internalTouchState.deltaX = 0;
|
||||
internalTouchState.deltaY = 0;
|
||||
}
|
||||
} else if (internalTouchState.event == TE_SLIDE) {
|
||||
internalTouchState.event = TE_SLIDE; // no change
|
||||
internalTouchState.deltaX = (short)dx;
|
||||
internalTouchState.deltaY = (short)dy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool touchPanelEventOccured() { return touchEventOccured; }
|
||||
|
||||
TouchState touchPanelRead()
|
||||
{
|
||||
if (!touchEventOccured) return internalTouchState;
|
||||
|
||||
touchEventOccured = false;
|
||||
|
||||
tmr10ms_t now = RTOS_GET_MS();
|
||||
internalTouchState.tapCount = 0;
|
||||
|
||||
if (cst836u_TS_DetectTouch()) {
|
||||
handleTouch();
|
||||
if (internalTouchState.event == TE_DOWN && downTime == 0) {
|
||||
downTime = now;
|
||||
}
|
||||
} else {
|
||||
if (internalTouchState.event == TE_DOWN) {
|
||||
internalTouchState.event = TE_UP;
|
||||
if (now - downTime <= TAP_TIME) {
|
||||
if (now - tapTime > TAP_TIME) {
|
||||
tapCount = 1;
|
||||
} else {
|
||||
tapCount++;
|
||||
}
|
||||
internalTouchState.tapCount = tapCount;
|
||||
tapTime = now;
|
||||
} else {
|
||||
internalTouchState.tapCount = 0; // not a tap
|
||||
}
|
||||
downTime = 0;
|
||||
} else {
|
||||
tapCount = 0;
|
||||
internalTouchState.tapCount = 0;
|
||||
internalTouchState.event = TE_SLIDE_END;
|
||||
}
|
||||
}
|
||||
TouchState ret = internalTouchState;
|
||||
internalTouchState.deltaX = 0;
|
||||
internalTouchState.deltaY = 0;
|
||||
if (internalTouchState.event == TE_UP ||
|
||||
internalTouchState.event == TE_SLIDE_END)
|
||||
internalTouchState.event = TE_NONE;
|
||||
return ret;
|
||||
}
|
||||
|
||||
TouchState getInternalTouchState() { return internalTouchState; }
|
||||
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2016 fishpepper <AT> gmail.com
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
author: fishpepper <AT> gmail.com
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <touch.h>
|
||||
|
||||
/* Set Multi-touch as non supported */
|
||||
#ifndef TS_MULTI_TOUCH_SUPPORTED
|
||||
#define TS_MULTI_TOUCH_SUPPORTED 0
|
||||
#endif
|
||||
|
||||
/* Set Auto-calibration as non supported */
|
||||
#ifndef TS_AUTO_CALIBRATION_SUPPORTED
|
||||
#define TS_AUTO_CALIBRATION_SUPPORTED 0
|
||||
#endif
|
||||
|
||||
/* Macros --------------------------------------------------------------------*/
|
||||
|
||||
/** @typedef ft6x06_handle_TypeDef
|
||||
* ft6x06 Handle definition.
|
||||
*/
|
||||
typedef struct {
|
||||
/* field holding the current number of simultaneous active touches */
|
||||
uint8_t currActiveTouchNb;
|
||||
|
||||
/* field holding the touch index currently managed */
|
||||
uint8_t currActiveTouchIdx;
|
||||
|
||||
} tc_handle_TypeDef;
|
||||
/* clang-format off */
|
||||
#define CST836U_WORK_MODE_REG 0x00
|
||||
#define CST836U_PROXIMITY_ID_REG 0x01
|
||||
#define CST836U_TOUCH_NUM_REG 0x02
|
||||
#define CST836U_TOUCH1_XH_REG 0x03
|
||||
#define CST836U_TOUCH1_XL_REG 0x04
|
||||
#define CST836U_TOUCH1_YH_REG 0x05
|
||||
#define CST836U_TOUCH1_YL_REG 0x06
|
||||
|
||||
#define CST836U_TOUCH2_XH_REG 0x09
|
||||
#define CST836U_TOUCH2_XL_REG 0x0A
|
||||
#define CST836U_TOUCH2_YH_REG 0x0B
|
||||
#define CST836U_TOUCH2_YL_REG 0x0C
|
||||
|
||||
#define CST836U_FW_VERSION_L_REG 0xA6
|
||||
#define CST836U_FW_VERSION_H_REG 0xA7
|
||||
#define CST836U_MODULE_VERSION_REG 0xA8
|
||||
#define CST836U_PROJECT_NAME_REG 0xA9
|
||||
#define CST836U_CHIP_TYPE_L_REG 0xAA
|
||||
#define CST836U_CHIP_TYPE_H_REG 0xAB
|
||||
#define CST836U_CHECKSUM_L_REG 0xAC
|
||||
#define CST836U_CHECKSUM_H_REG 0xAD
|
||||
|
||||
#define CST836U_PROX_STATE_REG 0xB0
|
||||
#define CST836U_GES_STATE_REG 0xD0
|
||||
#define CST836U_GES_ID_REG_REG 0xD3
|
||||
|
||||
#define CST836U_MAX_DETECTABLE_TOUCH 2
|
||||
|
||||
#define CST836U_MSB_MASK 0x0F
|
||||
|
||||
#define CST836U_TOUCH_EVT_FLAG_SHIFT 6
|
||||
#define CST836U_TOUCH_EVT_FLAG_MASK (3 << CST836U_TOUCH_EVT_FLAG_SHIFT)
|
||||
#define CST836U_TOUCH_EVT_FLAG_CONTACT 0x02
|
||||
/* clang-format on */
|
||||
|
||||
extern void TouchInit(void);
|
||||
extern void TouchDriver(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
+276
-84
@@ -61,6 +61,19 @@
|
||||
#define KEYS_GPIO_PIN_SYS LL_GPIO_PIN_7 // PI.07
|
||||
#define KEYS_GPIO_REG_TELE GPIOI
|
||||
#define KEYS_GPIO_PIN_TELE LL_GPIO_PIN_5 // PI.05
|
||||
#elif defined(RADIO_T15)
|
||||
#define KEYS_GPIO_REG_ENTER GPIOI
|
||||
#define KEYS_GPIO_PIN_ENTER LL_GPIO_PIN_8 // PI.08
|
||||
#define KEYS_GPIO_REG_PAGEDN GPIOI
|
||||
#define KEYS_GPIO_PIN_PAGEDN LL_GPIO_PIN_11 // PI.11
|
||||
#define KEYS_GPIO_REG_MDL GPIOI
|
||||
#define KEYS_GPIO_PIN_MDL LL_GPIO_PIN_6 // PI.06
|
||||
#define KEYS_GPIO_REG_EXIT GPIOI
|
||||
#define KEYS_GPIO_PIN_EXIT LL_GPIO_PIN_5 // PI.05
|
||||
#define KEYS_GPIO_REG_SYS GPIOI
|
||||
#define KEYS_GPIO_PIN_SYS LL_GPIO_PIN_7 // PI.07
|
||||
#define KEYS_GPIO_REG_TELE GPIOI
|
||||
#define KEYS_GPIO_PIN_TELE LL_GPIO_PIN_4 // PI.04
|
||||
#elif defined(PCBX10)
|
||||
#define KEYS_GPIO_REG_ENTER GPIOI
|
||||
#define KEYS_GPIO_PIN_ENTER LL_GPIO_PIN_8 // PI.08
|
||||
@@ -94,90 +107,188 @@
|
||||
#define ROTARY_ENCODER_TIMER_IRQn TIM8_BRK_TIM12_IRQn
|
||||
#define ROTARY_ENCODER_TIMER_IRQHandler TIM8_BRK_TIM12_IRQHandler
|
||||
|
||||
#if defined(RADIO_FAMILY_T16) && !defined(RADIO_T18)
|
||||
#if defined(RADIO_T15)
|
||||
#define ROTARY_ENCODER_INVERTED
|
||||
#endif
|
||||
|
||||
#if defined(RADIO_FAMILY_T16) && !defined(RADIO_T18) && !defined(RADIO_T15)
|
||||
#define ROTARY_ENCODER_SUPPORT_BUGGY_WIRING
|
||||
#endif
|
||||
|
||||
// Switches
|
||||
#define STORAGE_SWITCH_A
|
||||
#define HARDWARE_SWITCH_A
|
||||
#define SWITCHES_GPIO_REG_A_H GPIOH
|
||||
#define SWITCHES_GPIO_PIN_A_H LL_GPIO_PIN_9 // PH.09
|
||||
#define SWITCHES_GPIO_REG_A_L GPIOI
|
||||
#define SWITCHES_GPIO_PIN_A_L LL_GPIO_PIN_15 // PI.15
|
||||
#define STORAGE_SWITCH_B
|
||||
#define HARDWARE_SWITCH_B
|
||||
#define SWITCHES_GPIO_REG_B_H GPIOH
|
||||
#define SWITCHES_GPIO_PIN_B_H LL_GPIO_PIN_12 // PH.12
|
||||
#define SWITCHES_GPIO_REG_B_L GPIOB
|
||||
#define SWITCHES_GPIO_PIN_B_L LL_GPIO_PIN_12 // PB.12
|
||||
#define STORAGE_SWITCH_C
|
||||
#define HARDWARE_SWITCH_C
|
||||
#define SWITCHES_GPIO_REG_C_H GPIOD
|
||||
#define SWITCHES_GPIO_PIN_C_H LL_GPIO_PIN_11 // PD.11
|
||||
#define SWITCHES_GPIO_REG_C_L GPIOB
|
||||
#define SWITCHES_GPIO_PIN_C_L LL_GPIO_PIN_15 // PB.15
|
||||
#define STORAGE_SWITCH_D
|
||||
#define HARDWARE_SWITCH_D
|
||||
#define SWITCHES_GPIO_REG_D_H GPIOJ
|
||||
#define SWITCHES_GPIO_PIN_D_H LL_GPIO_PIN_7 // PJ.07
|
||||
#define SWITCHES_GPIO_REG_D_L GPIOG
|
||||
#define SWITCHES_GPIO_PIN_D_L LL_GPIO_PIN_2 // PG.02
|
||||
#define STORAGE_SWITCH_E
|
||||
#define HARDWARE_SWITCH_E
|
||||
#define SWITCHES_GPIO_REG_E_H GPIOH
|
||||
#define SWITCHES_GPIO_PIN_E_H LL_GPIO_PIN_4 // PH.04
|
||||
#define SWITCHES_GPIO_REG_E_L GPIOE
|
||||
#define SWITCHES_GPIO_PIN_E_L LL_GPIO_PIN_3 // PE.03
|
||||
#define STORAGE_SWITCH_F
|
||||
#define HARDWARE_SWITCH_F
|
||||
#define SWITCHES_GPIO_REG_F GPIOH
|
||||
#define SWITCHES_GPIO_PIN_F LL_GPIO_PIN_3 // PH.03
|
||||
#define STORAGE_SWITCH_G
|
||||
#define HARDWARE_SWITCH_G
|
||||
#define SWITCHES_GPIO_REG_G_H GPIOG
|
||||
#define SWITCHES_GPIO_PIN_G_H LL_GPIO_PIN_6 // PG.06
|
||||
#define SWITCHES_GPIO_REG_G_L GPIOG
|
||||
#define SWITCHES_GPIO_PIN_G_L LL_GPIO_PIN_3 // PG.03
|
||||
#define STORAGE_SWITCH_H
|
||||
#define HARDWARE_SWITCH_H
|
||||
#define SWITCHES_GPIO_REG_H GPIOG
|
||||
#define SWITCHES_GPIO_PIN_H LL_GPIO_PIN_7 // PG.07
|
||||
#if defined(RADIO_T15)
|
||||
#define STORAGE_SWITCH_A
|
||||
#define HARDWARE_SWITCH_A
|
||||
#define SWITCHES_GPIO_REG_A_H GPIOG
|
||||
#define SWITCHES_GPIO_PIN_A_H LL_GPIO_PIN_3 // PG.03
|
||||
#define SWITCHES_GPIO_REG_A_L GPIOD
|
||||
#define SWITCHES_GPIO_PIN_A_L LL_GPIO_PIN_11 // PD.11
|
||||
#define SWITCHES_A_INVERTED
|
||||
|
||||
#if defined(PCBX12S)
|
||||
#define SWITCHES_F_INVERTED
|
||||
#elif defined(PCBX10)
|
||||
#define SWITCHES_B_INVERTED
|
||||
#define SWITCHES_D_INVERTED
|
||||
#define SWITCHES_E_INVERTED
|
||||
#endif
|
||||
#define STORAGE_SWITCH_B
|
||||
#define HARDWARE_SWITCH_B
|
||||
#define SWITCHES_GPIO_REG_B_H GPIOB
|
||||
#define SWITCHES_GPIO_PIN_B_H LL_GPIO_PIN_12 // PB.12
|
||||
#define SWITCHES_GPIO_REG_B_L GPIOH
|
||||
#define SWITCHES_GPIO_PIN_B_L LL_GPIO_PIN_9 // PH.09
|
||||
|
||||
#if defined(PCBX10)
|
||||
// Gimbal switch left
|
||||
#define STORAGE_SWITCH_C
|
||||
#define HARDWARE_SWITCH_C
|
||||
#define SWITCHES_GPIO_REG_C_H GPIOG
|
||||
#define SWITCHES_GPIO_PIN_C_H LL_GPIO_PIN_2 // PG.02
|
||||
#define SWITCHES_GPIO_REG_C_L GPIOH
|
||||
#define SWITCHES_GPIO_PIN_C_L LL_GPIO_PIN_14 // PH.14
|
||||
#define SWITCHES_C_INVERTED
|
||||
|
||||
#define STORAGE_SWITCH_D
|
||||
#define HARDWARE_SWITCH_D
|
||||
#define SWITCHES_GPIO_REG_D_H GPIOI
|
||||
#define SWITCHES_GPIO_PIN_D_H LL_GPIO_PIN_15 // PI.15
|
||||
#define SWITCHES_GPIO_REG_D_L GPIOH
|
||||
#define SWITCHES_GPIO_PIN_D_L LL_GPIO_PIN_15 // PH.15
|
||||
|
||||
#define STORAGE_SWITCH_E
|
||||
#define HARDWARE_SWITCH_E
|
||||
#define SWITCHES_GPIO_REG_E GPIOB
|
||||
#define SWITCHES_GPIO_PIN_E LL_GPIO_PIN_15 // PB.15
|
||||
#define STORAGE_SWITCH_F
|
||||
#define HARDWARE_SWITCH_F
|
||||
#define SWITCHES_GPIO_REG_F GPIOH
|
||||
#define SWITCHES_GPIO_PIN_F LL_GPIO_PIN_12 // PH.12
|
||||
//SW1
|
||||
#define FUNCTION_SWITCH_1 SG
|
||||
#define STORAGE_SWITCH_G
|
||||
#define HARDWARE_SWITCH_G
|
||||
#define SWITCHES_GPIO_REG_G GPIOB
|
||||
#define SWITCHES_GPIO_PIN_G LL_GPIO_PIN_14 // PB.14
|
||||
//SW2
|
||||
#define FUNCTION_SWITCH_2 SH
|
||||
#define STORAGE_SWITCH_H
|
||||
#define HARDWARE_SWITCH_H
|
||||
#define SWITCHES_GPIO_REG_H GPIOD
|
||||
#define SWITCHES_GPIO_PIN_H LL_GPIO_PIN_13 // PD.13
|
||||
//SW3
|
||||
#define FUNCTION_SWITCH_3 SI
|
||||
#define STORAGE_SWITCH_I
|
||||
#define HARDWARE_SWITCH_I
|
||||
#define SWITCHES_GPIO_REG_I GPIOH
|
||||
#define SWITCHES_GPIO_PIN_I LL_GPIO_PIN_14 // PH.14
|
||||
// Gimbal switch right
|
||||
#define SWITCHES_GPIO_REG_I GPIOJ
|
||||
#define SWITCHES_GPIO_PIN_I LL_GPIO_PIN_7 // PJ.07
|
||||
//SW4
|
||||
#define FUNCTION_SWITCH_4 SJ
|
||||
#define STORAGE_SWITCH_J
|
||||
#define HARDWARE_SWITCH_J
|
||||
#define SWITCHES_GPIO_REG_J GPIOH
|
||||
#define SWITCHES_GPIO_PIN_J LL_GPIO_PIN_15 // PH.15
|
||||
#elif defined(PCBX12S)
|
||||
#define SWITCHES_GPIO_REG_J GPIOG
|
||||
#define SWITCHES_GPIO_PIN_J LL_GPIO_PIN_13 // PG.13
|
||||
//SW5
|
||||
#define FUNCTION_SWITCH_5 SK
|
||||
#define STORAGE_SWITCH_K
|
||||
#define HARDWARE_SWITCH_K
|
||||
#define SWITCHES_GPIO_REG_K GPIOJ
|
||||
#define SWITCHES_GPIO_PIN_K LL_GPIO_PIN_8 // PJ.08
|
||||
//SW6
|
||||
#define FUNCTION_SWITCH_6 SL
|
||||
#define STORAGE_SWITCH_L
|
||||
#define HARDWARE_SWITCH_L
|
||||
#define SWITCHES_GPIO_REG_L GPIOB
|
||||
#define SWITCHES_GPIO_PIN_L LL_GPIO_PIN_13 // PB.13
|
||||
#else
|
||||
#define STORAGE_SWITCH_A
|
||||
#define HARDWARE_SWITCH_A
|
||||
#define SWITCHES_GPIO_REG_A_H GPIOH
|
||||
#define SWITCHES_GPIO_PIN_A_H LL_GPIO_PIN_9 // PH.09
|
||||
#define SWITCHES_GPIO_REG_A_L GPIOI
|
||||
#define SWITCHES_GPIO_PIN_A_L LL_GPIO_PIN_15 // PI.15
|
||||
#define STORAGE_SWITCH_B
|
||||
#define HARDWARE_SWITCH_B
|
||||
#define SWITCHES_GPIO_REG_B_H GPIOH
|
||||
#define SWITCHES_GPIO_PIN_B_H LL_GPIO_PIN_12 // PH.12
|
||||
#define SWITCHES_GPIO_REG_B_L GPIOB
|
||||
#define SWITCHES_GPIO_PIN_B_L LL_GPIO_PIN_12 // PB.12
|
||||
#define STORAGE_SWITCH_C
|
||||
#define HARDWARE_SWITCH_C
|
||||
#define SWITCHES_GPIO_REG_C_H GPIOD
|
||||
#define SWITCHES_GPIO_PIN_C_H LL_GPIO_PIN_11 // PD.11
|
||||
#define SWITCHES_GPIO_REG_C_L GPIOB
|
||||
#define SWITCHES_GPIO_PIN_C_L LL_GPIO_PIN_15 // PB.15
|
||||
#define STORAGE_SWITCH_D
|
||||
#define HARDWARE_SWITCH_D
|
||||
#define SWITCHES_GPIO_REG_D_H GPIOJ
|
||||
#define SWITCHES_GPIO_PIN_D_H LL_GPIO_PIN_7 // PJ.07
|
||||
#define SWITCHES_GPIO_REG_D_L GPIOG
|
||||
#define SWITCHES_GPIO_PIN_D_L LL_GPIO_PIN_2 // PG.02
|
||||
#define STORAGE_SWITCH_E
|
||||
#define HARDWARE_SWITCH_E
|
||||
#define SWITCHES_GPIO_REG_E_H GPIOH
|
||||
#define SWITCHES_GPIO_PIN_E_H LL_GPIO_PIN_4 // PH.04
|
||||
#define SWITCHES_GPIO_REG_E_L GPIOE
|
||||
#define SWITCHES_GPIO_PIN_E_L LL_GPIO_PIN_3 // PE.03
|
||||
#define STORAGE_SWITCH_F
|
||||
#define HARDWARE_SWITCH_F
|
||||
#define SWITCHES_GPIO_REG_F GPIOH
|
||||
#define SWITCHES_GPIO_PIN_F LL_GPIO_PIN_3 // PH.03
|
||||
#define STORAGE_SWITCH_G
|
||||
#define HARDWARE_SWITCH_G
|
||||
#define SWITCHES_GPIO_REG_G_H GPIOG
|
||||
#define SWITCHES_GPIO_PIN_G_H LL_GPIO_PIN_6 // PG.06
|
||||
#define SWITCHES_GPIO_REG_G_L GPIOG
|
||||
#define SWITCHES_GPIO_PIN_G_L LL_GPIO_PIN_3 // PG.03
|
||||
#define STORAGE_SWITCH_H
|
||||
#define HARDWARE_SWITCH_H
|
||||
#define SWITCHES_GPIO_REG_H GPIOG
|
||||
#define SWITCHES_GPIO_PIN_H LL_GPIO_PIN_7 // PG.07
|
||||
|
||||
#if defined(PCBX12S)
|
||||
#define SWITCHES_F_INVERTED
|
||||
#elif defined(PCBX10)
|
||||
#define SWITCHES_B_INVERTED
|
||||
#define SWITCHES_D_INVERTED
|
||||
#define SWITCHES_E_INVERTED
|
||||
#endif
|
||||
|
||||
#if defined(PCBX10)
|
||||
// Gimbal switch left
|
||||
#define STORAGE_SWITCH_I
|
||||
#define HARDWARE_SWITCH_I
|
||||
#define SWITCHES_GPIO_REG_I GPIOB
|
||||
#define SWITCHES_GPIO_PIN_I LL_GPIO_PIN_1 // PB.01
|
||||
// Gimbal switch right
|
||||
#define STORAGE_SWITCH_J
|
||||
#define HARDWARE_SWITCH_J
|
||||
#define SWITCHES_GPIO_REG_J GPIOB
|
||||
#define SWITCHES_GPIO_PIN_J LL_GPIO_PIN_0 // PB.00
|
||||
#define STORAGE_SWITCH_I
|
||||
#define HARDWARE_SWITCH_I
|
||||
#define SWITCHES_GPIO_REG_I GPIOH
|
||||
#define SWITCHES_GPIO_PIN_I LL_GPIO_PIN_14 // PH.14
|
||||
// Gimbal switch right
|
||||
#define STORAGE_SWITCH_J
|
||||
#define HARDWARE_SWITCH_J
|
||||
#define SWITCHES_GPIO_REG_J GPIOH
|
||||
#define SWITCHES_GPIO_PIN_J LL_GPIO_PIN_15 // PH.15
|
||||
#elif defined(PCBX12S)
|
||||
// Gimbal switch left
|
||||
#define STORAGE_SWITCH_I
|
||||
#define HARDWARE_SWITCH_I
|
||||
#define SWITCHES_GPIO_REG_I GPIOB
|
||||
#define SWITCHES_GPIO_PIN_I LL_GPIO_PIN_1 // PB.01
|
||||
// Gimbal switch right
|
||||
#define STORAGE_SWITCH_J
|
||||
#define HARDWARE_SWITCH_J
|
||||
#define SWITCHES_GPIO_REG_J GPIOB
|
||||
#define SWITCHES_GPIO_PIN_J LL_GPIO_PIN_0 // PB.00
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Trims
|
||||
#if defined(PCBX12S)
|
||||
#if defined(RADIO_T15)
|
||||
#define TRIMS_GPIO_REG_LHL GPIOD
|
||||
#define TRIMS_GPIO_PIN_LHL LL_GPIO_PIN_3 // PD.03
|
||||
#define TRIMS_GPIO_REG_LHR GPIOD
|
||||
#define TRIMS_GPIO_PIN_LHR LL_GPIO_PIN_7 // PD.07
|
||||
#define TRIMS_GPIO_REG_LVU GPIOJ
|
||||
#define TRIMS_GPIO_PIN_LVU LL_GPIO_PIN_12 // PJ.12
|
||||
#define TRIMS_GPIO_REG_LVD GPIOJ
|
||||
#define TRIMS_GPIO_PIN_LVD LL_GPIO_PIN_13 // PJ.13
|
||||
#define TRIMS_GPIO_REG_RVD GPIOG
|
||||
#define TRIMS_GPIO_PIN_RVD LL_GPIO_PIN_12 // PG.12
|
||||
#define TRIMS_GPIO_REG_RHL GPIOA
|
||||
#define TRIMS_GPIO_PIN_RHL LL_GPIO_PIN_6 // PA.06
|
||||
#define TRIMS_GPIO_REG_RVU GPIOJ
|
||||
#define TRIMS_GPIO_PIN_RVU LL_GPIO_PIN_14 // PJ.14
|
||||
#define TRIMS_GPIO_REG_RHR GPIOC
|
||||
#define TRIMS_GPIO_PIN_RHR LL_GPIO_PIN_4 // PC.04
|
||||
#elif defined(PCBX12S)
|
||||
#define TRIMS_GPIO_REG_RHL GPIOC
|
||||
#define TRIMS_GPIO_PIN_RHL LL_GPIO_PIN_0 // PC.00
|
||||
#define TRIMS_GPIO_REG_RHR GPIOI
|
||||
@@ -287,21 +398,36 @@
|
||||
#define ADC_SAMPTIME LL_ADC_SAMPLINGTIME_56CYCLES
|
||||
#define ADC_VREF_PREC2 600
|
||||
#elif defined(PCBX10)
|
||||
#if defined(RADIO_T15)
|
||||
#define ADC_GPIO_PIN_STICK_LH LL_GPIO_PIN_1 // PA.01
|
||||
#define ADC_GPIO_PIN_STICK_LV LL_GPIO_PIN_0 // PA.00
|
||||
#define ADC_GPIO_PIN_STICK_RV LL_GPIO_PIN_2 // PA.02
|
||||
#define ADC_GPIO_PIN_STICK_RH LL_GPIO_PIN_3 // PA.03
|
||||
#define ADC_GPIO_PIN_POT1 LL_GPIO_PIN_2 // PC.02
|
||||
#define ADC_GPIO_PIN_POT2 LL_GPIO_PIN_0 // PC.00
|
||||
#define ADC_CHANNEL_POT1 LL_ADC_CHANNEL_12 // ADC3_IN12
|
||||
#define ADC_CHANNEL_POT2 LL_ADC_CHANNEL_10 // ADC3_IN10
|
||||
#else
|
||||
#define ADC_GPIO_PIN_STICK_LH LL_GPIO_PIN_0 // PA.00
|
||||
#define ADC_GPIO_PIN_STICK_LV LL_GPIO_PIN_1 // PA.01
|
||||
#define ADC_GPIO_PIN_STICK_RV LL_GPIO_PIN_3 // PA.03
|
||||
#define ADC_GPIO_PIN_STICK_RH LL_GPIO_PIN_2 // PA.02
|
||||
#define ADC_GPIO_PIN_POT1 LL_GPIO_PIN_0 // PC.00
|
||||
#define ADC_GPIO_PIN_POT2 LL_GPIO_PIN_1 // PC.01
|
||||
#define ADC_CHANNEL_POT1 LL_ADC_CHANNEL_10 // ADC3_IN10
|
||||
#define ADC_CHANNEL_POT2 LL_ADC_CHANNEL_11 // ADC3_IN11
|
||||
#endif
|
||||
#define ADC_GPIO_PIN_BATT LL_GPIO_PIN_7 // PF.07
|
||||
#if !defined(RADIO_T15)
|
||||
#define ADC_GPIO_PIN_POT3 LL_GPIO_PIN_2 // PC.02 //
|
||||
#define ADC_GPIO_PIN_SLIDER1 LL_GPIO_PIN_6 // PF.06
|
||||
#define ADC_GPIO_PIN_SLIDER2 LL_GPIO_PIN_3 // PC.03 //
|
||||
#define ADC_GPIO_PIN_BATT LL_GPIO_PIN_7 // PF.07
|
||||
#define ADC_GPIO_PIN_EXT1 LL_GPIO_PIN_8 // PF.08
|
||||
#define ADC_GPIO_PIN_EXT2 LL_GPIO_PIN_9 // PF.09
|
||||
#define ADC_GPIO_PIN_EXT3 ADC_GPIO_PIN_STICK_RH
|
||||
#define ADC_GPIO_PIN_EXT4 ADC_GPIO_PIN_STICK_RV
|
||||
#if !defined(RADIO_TX16S)
|
||||
#endif
|
||||
#if !defined(RADIO_TX16S) && !defined(RADIO_T15)
|
||||
#define PWM_STICKS
|
||||
#define PWM_TIMER TIM5
|
||||
#define PWM_GPIO GPIOA
|
||||
@@ -314,24 +440,38 @@
|
||||
#define STICK_PWM_CHANNEL_RV 3
|
||||
#define STICK_PWM_CHANNEL_RH 2
|
||||
#endif
|
||||
#define ADC_GPIOA_PINS_FS (LL_GPIO_PIN_2 | LL_GPIO_PIN_3)
|
||||
#define ADC_GPIOA_PINS (ADC_GPIO_PIN_STICK_LH | ADC_GPIO_PIN_STICK_LV | ADC_GPIO_PIN_STICK_RH | ADC_GPIO_PIN_STICK_RV)
|
||||
#define ADC_GPIOC_PINS (ADC_GPIO_PIN_POT1 | ADC_GPIO_PIN_POT2 | ADC_GPIO_PIN_POT3 | ADC_GPIO_PIN_SLIDER2)
|
||||
#define ADC_GPIOF_PINS (ADC_GPIO_PIN_SLIDER1 | ADC_GPIO_PIN_BATT | ADC_GPIO_PIN_EXT1 | ADC_GPIO_PIN_EXT2)
|
||||
#if defined(RADIO_T15)
|
||||
#define ADC_CHANNEL_STICK_LH LL_ADC_CHANNEL_1 // ADC3_IN1
|
||||
#define ADC_CHANNEL_STICK_LV LL_ADC_CHANNEL_0 // ADC3_IN0
|
||||
#define ADC_CHANNEL_STICK_RH LL_ADC_CHANNEL_3 // ADC3_IN3
|
||||
#define ADC_CHANNEL_STICK_RV LL_ADC_CHANNEL_2 // ADC3_IN2
|
||||
#define ADC_CHANNEL_BATT LL_ADC_CHANNEL_5 // ADC3_IN5
|
||||
#else
|
||||
#define ADC_CHANNEL_STICK_LH LL_ADC_CHANNEL_0 // ADC3_IN0
|
||||
#define ADC_CHANNEL_STICK_LV LL_ADC_CHANNEL_1 // ADC3_IN1
|
||||
#define ADC_CHANNEL_STICK_RH LL_ADC_CHANNEL_2 // ADC3_IN2
|
||||
#define ADC_CHANNEL_STICK_RV LL_ADC_CHANNEL_3 // ADC3_IN3
|
||||
#define ADC_CHANNEL_POT1 LL_ADC_CHANNEL_10 // ADC3_IN10
|
||||
#define ADC_CHANNEL_POT2 LL_ADC_CHANNEL_11 // ADC3_IN11
|
||||
#define ADC_CHANNEL_BATT LL_ADC_CHANNEL_5 // ADC3_IN5
|
||||
#endif
|
||||
#if !defined(RADIO_T15)
|
||||
#define ADC_CHANNEL_POT3 LL_ADC_CHANNEL_12 // ADC3_IN12
|
||||
#define ADC_CHANNEL_SLIDER1 LL_ADC_CHANNEL_4 // ADC3_IN4
|
||||
#define ADC_CHANNEL_SLIDER2 LL_ADC_CHANNEL_13 // ADC3_IN13
|
||||
#define ADC_CHANNEL_BATT LL_ADC_CHANNEL_5 // ADC3_IN5
|
||||
#define ADC_CHANNEL_EXT1 LL_ADC_CHANNEL_6 // ADC3_IN6
|
||||
#define ADC_CHANNEL_EXT2 LL_ADC_CHANNEL_7 // ADC3_IN7
|
||||
#define ADC_CHANNEL_EXT3 LL_ADC_CHANNEL_2 // ADC3_IN2: same as RH
|
||||
#define ADC_CHANNEL_EXT4 LL_ADC_CHANNEL_3 // ADC3_IN3: same as RV
|
||||
#endif
|
||||
#if defined(RADIO_T15)
|
||||
#define ADC_GPIOA_PINS (ADC_GPIO_PIN_STICK_LH | ADC_GPIO_PIN_STICK_LV | ADC_GPIO_PIN_STICK_RH | ADC_GPIO_PIN_STICK_RV)
|
||||
#define ADC_GPIOC_PINS (ADC_GPIO_PIN_POT1 | ADC_GPIO_PIN_POT2)
|
||||
#define ADC_GPIOF_PINS (ADC_GPIO_PIN_BATT)
|
||||
#else
|
||||
#define ADC_GPIOA_PINS_FS (LL_GPIO_PIN_2 | LL_GPIO_PIN_3)
|
||||
#define ADC_GPIOA_PINS (ADC_GPIO_PIN_STICK_LH | ADC_GPIO_PIN_STICK_LV | ADC_GPIO_PIN_STICK_RH | ADC_GPIO_PIN_STICK_RV)
|
||||
#define ADC_GPIOC_PINS (ADC_GPIO_PIN_POT1 | ADC_GPIO_PIN_POT2 | ADC_GPIO_PIN_POT3 | ADC_GPIO_PIN_SLIDER2)
|
||||
#define ADC_GPIOF_PINS (ADC_GPIO_PIN_SLIDER1 | ADC_GPIO_PIN_BATT | ADC_GPIO_PIN_EXT1 | ADC_GPIO_PIN_EXT2)
|
||||
#endif
|
||||
#define ADC_CHANNEL_RTC_BAT LL_ADC_CHANNEL_VBAT // ADC1_IN18
|
||||
#define ADC_MAIN ADC3
|
||||
#define ADC_EXT ADC1
|
||||
@@ -345,7 +485,7 @@
|
||||
#define ADC_DMA_STREAM_IRQHandler DMA2_Stream0_IRQHandler
|
||||
|
||||
// VBat divider is /4 on F42x and F43x devices
|
||||
#if defined(RADIO_TX16S)
|
||||
#if defined(RADIO_TX16S) || defined(RADIO_T15)
|
||||
#define ADC_VREF_PREC2 660
|
||||
#elif defined(RADIO_T16) || defined(RADIO_T18)
|
||||
#define ADC_VREF_PREC2 600
|
||||
@@ -354,7 +494,9 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(RADIO_T16)
|
||||
#if defined(RADIO_T15)
|
||||
#define ADC_DIRECTION {1,-1,1,-1, 1,1}
|
||||
#elif defined(RADIO_T16)
|
||||
#define ADC_DIRECTION {1,-1,1,-1, 1,1,1, -1,1,1,1, -1,1 }
|
||||
#elif defined(RADIO_T18)
|
||||
#define ADC_DIRECTION {1,-1,1,-1, -1,1,-1, -1,1,1,1, -1,1 }
|
||||
@@ -392,12 +534,16 @@
|
||||
#define SPORT_MAX_BAUDRATE 250000 // < 400000
|
||||
#endif
|
||||
|
||||
#if defined(PCBX10) && !defined(RADIO_FAMILY_T16)
|
||||
#if defined(PCBX10) && !defined(RADIO_FAMILY_T16) && !defined(RADIO_T15)
|
||||
#define SPORT_UPDATE_PWR_GPIO GPIO_PIN(GPIOH, 13) // PH.13
|
||||
#endif
|
||||
|
||||
// PCBREV
|
||||
#if defined(PCBX10)
|
||||
#if defined(RADIO_T15)
|
||||
#define PCBREV_GPIO_1 GPIO_PIN(GPIOH, 7) // PH.07
|
||||
#define PCBREV_GPIO_2 GPIO_PIN(GPIOH, 8) // PH.08
|
||||
#define PCBREV_VALUE() ((gpio_read(PCBREV_GPIO_1) | gpio_read(PCBREV_GPIO_2)) >> 7)
|
||||
#elif defined(PCBX10)
|
||||
#define PCBREV_GPIO_1 GPIO_PIN(GPIOH, 7) // PH.07
|
||||
#define PCBREV_GPIO_2 GPIO_PIN(GPIOH, 8) // PH.08
|
||||
#define PCBREV_TOUCH_GPIO GPIO_PIN(GPIOA, 6) // PA.06
|
||||
@@ -412,12 +558,26 @@
|
||||
#define STATUS_LEDS
|
||||
#if defined(PCBX12S)
|
||||
#define LED_GPIO GPIO_PIN(GPIOI, 5) // PI.05
|
||||
#elif defined(RADIO_T15)
|
||||
#define LED_RED_GPIO GPIO_PIN(GPIOI, 14) //PI.14
|
||||
#define LED_GREEN_GPIO GPIO_PIN(GPIOC, 13) //PC.13
|
||||
#define LED_BLUE_GPIO GPIO_PIN(GPIOE, 3) //PE.03
|
||||
#elif defined(PCBX10)
|
||||
#define LED_RED_GPIO GPIO_PIN(GPIOE, 2) // PE.02
|
||||
#define LED_GREEN_GPIO GPIO_PIN(GPIOE, 4) // PE.04
|
||||
#define LED_BLUE_GPIO GPIO_PIN(GPIOE, 5) // PE.05
|
||||
#endif
|
||||
|
||||
// Customisable switches leds
|
||||
#if defined(RADIO_T15)
|
||||
#define FSLED_GPIO_1 GPIO_PIN(GPIOA, 15) //PA.15
|
||||
#define FSLED_GPIO_2 GPIO_PIN(GPIOC, 5) //PC.05
|
||||
#define FSLED_GPIO_3 GPIO_PIN(GPIOH, 13) //PH.13
|
||||
#define FSLED_GPIO_4 GPIO_PIN(GPIOG, 11) //PG.11
|
||||
#define FSLED_GPIO_5 GPIO_PIN(GPIOC, 3) //PC.03
|
||||
#define FSLED_GPIO_6 GPIO_PIN(GPIOC, 1) //PC.01
|
||||
#endif
|
||||
|
||||
// Serial Port (DEBUG)
|
||||
#if defined(AUX_SERIAL)
|
||||
#define AUX_SERIAL_TX_GPIO GPIO_PIN(GPIOB, 10) // PB.10
|
||||
@@ -507,6 +667,20 @@
|
||||
#define USB_GPIO_AF GPIO_AF10
|
||||
|
||||
// LCD
|
||||
#if defined(RADIO_T15)
|
||||
#define LCD_RCC_AHB1Periph (LL_AHB1_GRP1_PERIPH_GPIOE | LL_AHB1_GRP1_PERIPH_GPIOG | LL_AHB1_GRP1_PERIPH_GPIOI | LL_AHB1_GRP1_PERIPH_GPIOJ | LL_AHB1_GRP1_PERIPH_GPIOK | LL_AHB1_GRP1_PERIPH_DMA2D)
|
||||
#define LCD_RCC_APB1Periph 0
|
||||
#define LCD_RCC_APB2Periph LL_APB2_GRP1_PERIPH_LTDC
|
||||
#define LCD_NRST_GPIO GPIOG
|
||||
#define LCD_NRST_GPIO_PIN LL_GPIO_PIN_10 // PG.10
|
||||
#define LCD_SPI_GPIO GPIOE
|
||||
#define LCD_SPI_CS_GPIO_PIN LL_GPIO_PIN_4 // PE.04
|
||||
#define LCD_SPI_SCK_GPIO_PIN LL_GPIO_PIN_2 // PE.02
|
||||
#define LCD_SPI_MISO_GPIO_PIN LL_GPIO_PIN_5 // PE.05
|
||||
#define LCD_SPI_MOSI_GPIO_PIN LL_GPIO_PIN_6 // PE.06
|
||||
#define LTDC_IRQ_PRIO 4
|
||||
#define DMA_SCREEN_IRQ_PRIO 6
|
||||
#else
|
||||
#define LCD_RCC_AHB1Periph LL_AHB1_GRP1_PERIPH_DMA2D
|
||||
#define LCD_RCC_APB2Periph LL_APB2_GRP1_PERIPH_LTDC
|
||||
#if defined(PCBX12S)
|
||||
@@ -519,6 +693,7 @@
|
||||
#endif
|
||||
#define LTDC_IRQ_PRIO 4
|
||||
#define DMA_SCREEN_IRQ_PRIO 6
|
||||
#endif
|
||||
|
||||
// Backlight
|
||||
#if defined(PCBX12S)
|
||||
@@ -545,7 +720,9 @@
|
||||
#endif
|
||||
|
||||
// SD
|
||||
#if !defined(RADIO_T15)
|
||||
#define SD_PRESENT_GPIO GPIO_PIN(GPIOC, 5) // PC.05
|
||||
#endif
|
||||
#define SD_SDIO_DMA DMA2
|
||||
#define SD_SDIO_DMA_STREAM DMA2_Stream3 // or Stream6
|
||||
#define SD_SDIO_DMA_CHANNEL LL_DMA_CHANNEL_4
|
||||
@@ -675,7 +852,7 @@
|
||||
#endif // HARDWARE_TOUCH
|
||||
|
||||
// First I2C Bus
|
||||
#if defined(RADIO_TX16S) || defined(PCBX12S)
|
||||
#if defined(RADIO_TX16S) || defined(PCBX12S) || defined(RADIO_T15)
|
||||
#define I2C_B1 I2C1
|
||||
#define I2C_B1_GPIO GPIOB
|
||||
#define I2C_B1_SCL_GPIO_PIN LL_GPIO_PIN_8 // PB.08
|
||||
@@ -722,6 +899,13 @@
|
||||
#define HAPTIC_TIMER_OUTPUT_ENABLE TIM_CCER_CC1E
|
||||
#define HAPTIC_TIMER_MODE TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_2
|
||||
#define HAPTIC_TIMER_COMPARE_VALUE HAPTIC_GPIO_TIMER->CCR1
|
||||
#elif defined(RADIO_T15) // TIM2_CH1
|
||||
#define HAPTIC_GPIO GPIO_PIN(GPIOA, 5) // PA.05
|
||||
#define HAPTIC_GPIO_TIMER TIM2
|
||||
#define HAPTIC_GPIO_AF GPIO_AF1
|
||||
#define HAPTIC_TIMER_OUTPUT_ENABLE TIM_CCER_CC1E | TIM_CCER_CC1NE;
|
||||
#define HAPTIC_TIMER_MODE TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC1PE
|
||||
#define HAPTIC_TIMER_COMPARE_VALUE HAPTIC_GPIO_TIMER->CCR1
|
||||
#elif defined(PCBX10)
|
||||
#define HAPTIC_GPIO GPIO_PIN(GPIOE, 6) // PE.06
|
||||
#define HAPTIC_GPIO_TIMER TIM9
|
||||
@@ -904,10 +1088,18 @@
|
||||
|
||||
#define PORTRAIT_LCD false
|
||||
#define LANDSCAPE_LCD true
|
||||
#if defined(RADIO_T15)
|
||||
#define LCD_W 480
|
||||
#define LCD_H 320
|
||||
#define LCD_PHYS_H LCD_H
|
||||
#define LCD_PHYS_W LCD_W
|
||||
#define LCD_DEPTH 16
|
||||
#else
|
||||
#define LCD_W 480
|
||||
#define LCD_H 272
|
||||
#define LCD_PHYS_H LCD_H
|
||||
#define LCD_PHYS_W LCD_W
|
||||
#define LCD_DEPTH 16
|
||||
#endif
|
||||
|
||||
#endif // _HAL_H_
|
||||
|
||||
@@ -0,0 +1,460 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "lcd_st7796s_driver.h"
|
||||
|
||||
#include "board.h"
|
||||
#include "debug.h"
|
||||
#include "delays_driver.h"
|
||||
#include "dma2d.h"
|
||||
#include "hal.h"
|
||||
#include "lcd.h"
|
||||
#include "opentx_types.h"
|
||||
#include "stm32_hal.h"
|
||||
#include "stm32_hal_ll.h"
|
||||
|
||||
static LTDC_HandleTypeDef hltdc;
|
||||
static void* initialFrameBuffer = nullptr;
|
||||
|
||||
static volatile uint8_t _frame_addr_reloaded = 0;
|
||||
|
||||
static void startLcdRefresh(lv_disp_drv_t* disp_drv, uint16_t* buffer,
|
||||
const rect_t& copy_area)
|
||||
{
|
||||
(void)disp_drv;
|
||||
(void)copy_area;
|
||||
|
||||
LTDC_Layer1->CFBAR &= ~(LTDC_LxCFBAR_CFBADD);
|
||||
LTDC_Layer1->CFBAR = (uint32_t)buffer;
|
||||
// reload shadow registers on vertical blank
|
||||
_frame_addr_reloaded = 0;
|
||||
LTDC->SRCR = LTDC_SRCR_VBR;
|
||||
__HAL_LTDC_ENABLE_IT(&hltdc, LTDC_IT_LI);
|
||||
|
||||
// wait for reload
|
||||
// TODO: replace through some smarter mechanism without busy wait
|
||||
while (_frame_addr_reloaded == 0);
|
||||
}
|
||||
|
||||
uint32_t lcdPixelClock;
|
||||
|
||||
static void LCD_AF_GPIOConfig(void)
|
||||
{
|
||||
/*
|
||||
-----------------------------------------------------------------------------
|
||||
LCD_CLK <-> PG.07 | LCD_HSYNC <-> PI.12 | LCD_R3 <-> PJ.02 | LCD_G5 <-> PK.00
|
||||
| LCD VSYNC <-> PI.13 | LCD_R4 <-> PJ.03 | LCD_G6 <-> PK.01
|
||||
| | LCD_R5 <-> PJ.04 | LCD_G7 <-> PK.02
|
||||
| | LCD_R6 <-> PJ.05 | LCD_B4 <-> PK.03
|
||||
| | LCD_R7 <-> PJ.06 | LCD_B5 <-> PK.04
|
||||
| | LCD_G2 <-> PJ.09 | LCD_B6 <-> PK.05
|
||||
| | LCD_G3 <-> PJ.10 | LCD_B7 <-> PK.06
|
||||
| | LCD_G4 <-> PJ.11 | LCD_DE <-> PK.07
|
||||
| | LCD_B3 <-> PJ.15 |
|
||||
*/
|
||||
|
||||
LL_GPIO_InitTypeDef GPIO_InitStructure;
|
||||
LL_GPIO_StructInit(&GPIO_InitStructure);
|
||||
|
||||
// GPIOG configuration
|
||||
GPIO_InitStructure.Pin = LL_GPIO_PIN_7;
|
||||
GPIO_InitStructure.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
GPIO_InitStructure.Mode = LL_GPIO_MODE_ALTERNATE;
|
||||
GPIO_InitStructure.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
||||
GPIO_InitStructure.Pull = LL_GPIO_PULL_NO;
|
||||
GPIO_InitStructure.Alternate = LL_GPIO_AF_14; // AF LTDC
|
||||
LL_GPIO_Init(GPIOG, &GPIO_InitStructure);
|
||||
|
||||
// GPIOI configuration
|
||||
GPIO_InitStructure.Pin = LL_GPIO_PIN_12 | LL_GPIO_PIN_13;
|
||||
LL_GPIO_Init(GPIOI, &GPIO_InitStructure);
|
||||
|
||||
// GPIOJ configuration
|
||||
GPIO_InitStructure.Pin = LL_GPIO_PIN_2 | LL_GPIO_PIN_3 | LL_GPIO_PIN_4 |
|
||||
LL_GPIO_PIN_5 | LL_GPIO_PIN_6 | LL_GPIO_PIN_9 |
|
||||
LL_GPIO_PIN_10 | LL_GPIO_PIN_11 | LL_GPIO_PIN_15;
|
||||
LL_GPIO_Init(GPIOJ, &GPIO_InitStructure);
|
||||
|
||||
// GPIOK configuration
|
||||
GPIO_InitStructure.Pin = LL_GPIO_PIN_0 | LL_GPIO_PIN_1 | LL_GPIO_PIN_2 |
|
||||
LL_GPIO_PIN_3 | LL_GPIO_PIN_4 | LL_GPIO_PIN_5 |
|
||||
LL_GPIO_PIN_6 | LL_GPIO_PIN_7;
|
||||
LL_GPIO_Init(GPIOK, &GPIO_InitStructure);
|
||||
}
|
||||
|
||||
static void lcdSpiConfig(void)
|
||||
{
|
||||
LL_GPIO_InitTypeDef GPIO_InitStructure;
|
||||
LL_GPIO_StructInit(&GPIO_InitStructure);
|
||||
|
||||
GPIO_InitStructure.Pin = LCD_SPI_SCK_GPIO_PIN | LCD_SPI_MOSI_GPIO_PIN;
|
||||
GPIO_InitStructure.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
GPIO_InitStructure.Mode = LL_GPIO_MODE_OUTPUT;
|
||||
GPIO_InitStructure.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
||||
GPIO_InitStructure.Pull = LL_GPIO_PULL_NO;
|
||||
LL_GPIO_Init(LCD_SPI_GPIO, &GPIO_InitStructure);
|
||||
|
||||
GPIO_InitStructure.Pin = LCD_SPI_CS_GPIO_PIN;
|
||||
GPIO_InitStructure.Pull = LL_GPIO_PULL_UP;
|
||||
LL_GPIO_Init(LCD_SPI_GPIO, &GPIO_InitStructure);
|
||||
|
||||
GPIO_InitStructure.Pin = LCD_NRST_GPIO_PIN;
|
||||
LL_GPIO_Init(LCD_NRST_GPIO, &GPIO_InitStructure);
|
||||
|
||||
/* Set the chip select pin always low */
|
||||
LCD_CS_LOW();
|
||||
}
|
||||
|
||||
void lcdDelay() { delay_01us(1); }
|
||||
|
||||
static void lcdReset()
|
||||
{
|
||||
LCD_NRST_HIGH();
|
||||
delay_ms(1);
|
||||
|
||||
LCD_NRST_LOW(); // RESET();
|
||||
delay_ms(100);
|
||||
|
||||
LCD_NRST_HIGH();
|
||||
delay_ms(100);
|
||||
}
|
||||
|
||||
static void lcdWriteByte(uint8_t data_enable, uint8_t byte)
|
||||
{
|
||||
LCD_SCK_LOW();
|
||||
|
||||
if (data_enable) {
|
||||
LCD_MOSI_HIGH();
|
||||
} else {
|
||||
LCD_MOSI_LOW();
|
||||
}
|
||||
|
||||
lcdDelay();
|
||||
LCD_SCK_HIGH();
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
lcdDelay();
|
||||
LCD_SCK_LOW();
|
||||
|
||||
if (byte & 0x80) {
|
||||
LCD_MOSI_HIGH();
|
||||
} else {
|
||||
LCD_MOSI_LOW();
|
||||
}
|
||||
|
||||
lcdDelay();
|
||||
LCD_SCK_HIGH();
|
||||
byte <<= 1;
|
||||
}
|
||||
|
||||
lcdDelay();
|
||||
LCD_SCK_LOW();
|
||||
}
|
||||
|
||||
void lcdWriteCommand(uint8_t command)
|
||||
{
|
||||
LCD_CS_LOW();
|
||||
lcdWriteByte(0, command);
|
||||
LCD_CS_HIGH();
|
||||
lcdDelay();
|
||||
}
|
||||
|
||||
void lcdWriteData(uint8_t data)
|
||||
{
|
||||
LCD_CS_LOW();
|
||||
lcdWriteByte(1, data);
|
||||
LCD_CS_HIGH();
|
||||
lcdDelay();
|
||||
}
|
||||
|
||||
void LCD_ST7796S_On(void) { lcdWriteCommand(0x29); }
|
||||
|
||||
void LCD_ST7796S_Init(void)
|
||||
{
|
||||
delay_ms(120);
|
||||
|
||||
lcdWriteCommand(0x11);
|
||||
delay_ms(120);
|
||||
|
||||
lcdWriteCommand(0xF0);
|
||||
lcdWriteData(0xC3);
|
||||
|
||||
lcdWriteCommand(0xF0);
|
||||
lcdWriteData(0x96);
|
||||
|
||||
lcdWriteCommand(0x36);
|
||||
lcdWriteData(0x28);
|
||||
|
||||
lcdWriteCommand(0x2A);
|
||||
lcdWriteData(0x00);
|
||||
lcdWriteData(0x00);
|
||||
lcdWriteData(0x01);
|
||||
lcdWriteData(0xDF);
|
||||
lcdWriteCommand(0x2B);
|
||||
lcdWriteData(0x00);
|
||||
lcdWriteData(0x00);
|
||||
lcdWriteData(0x01);
|
||||
lcdWriteData(0x3F);
|
||||
|
||||
lcdWriteCommand(0x3A);
|
||||
#if defined(RADIO_T15)
|
||||
lcdWriteData(0x55);
|
||||
#else
|
||||
lcdWriteData(0x66);
|
||||
#endif
|
||||
|
||||
lcdWriteCommand(0x34);
|
||||
|
||||
// SET RGB STRAT
|
||||
lcdWriteCommand(0xB0); // SET HS VS DE CLK 上升还是下降有效
|
||||
lcdWriteData(0x80);
|
||||
|
||||
lcdWriteCommand(0xB4);
|
||||
lcdWriteData(0x01);
|
||||
|
||||
lcdWriteCommand(0xB6);
|
||||
// lcdWriteData( 0x20 );
|
||||
// lcdWriteData( 0x02 );
|
||||
// lcdWriteData( 0x3B );
|
||||
lcdWriteData(0x20);
|
||||
lcdWriteData(0x02);
|
||||
lcdWriteData(0x3B);
|
||||
// SET RGB END
|
||||
|
||||
lcdWriteCommand(0xB7);
|
||||
lcdWriteData(0xC6);
|
||||
|
||||
lcdWriteCommand(0xB9);
|
||||
lcdWriteData(0x02);
|
||||
lcdWriteData(0xE0);
|
||||
|
||||
lcdWriteCommand(0xC0);
|
||||
lcdWriteData(0x80);
|
||||
lcdWriteData(0x65);
|
||||
|
||||
lcdWriteCommand(0xC1);
|
||||
lcdWriteData(0x0D);
|
||||
|
||||
lcdWriteCommand(0xC2);
|
||||
lcdWriteData(0xA7);
|
||||
|
||||
lcdWriteCommand(0xC5);
|
||||
lcdWriteData(0x14);
|
||||
|
||||
lcdWriteCommand(0xE8);
|
||||
lcdWriteData(0x40);
|
||||
lcdWriteData(0x8A);
|
||||
lcdWriteData(0x00);
|
||||
lcdWriteData(0x00);
|
||||
lcdWriteData(0x29);
|
||||
lcdWriteData(0x19);
|
||||
lcdWriteData(0xA5);
|
||||
lcdWriteData(0x33);
|
||||
|
||||
lcdWriteCommand(0xE0);
|
||||
lcdWriteData(0xD0);
|
||||
lcdWriteData(0x00);
|
||||
lcdWriteData(0x04);
|
||||
lcdWriteData(0x05);
|
||||
lcdWriteData(0x04);
|
||||
lcdWriteData(0x21);
|
||||
lcdWriteData(0x25);
|
||||
lcdWriteData(0x43);
|
||||
lcdWriteData(0x3F);
|
||||
lcdWriteData(0x37);
|
||||
lcdWriteData(0x13);
|
||||
lcdWriteData(0x13);
|
||||
lcdWriteData(0x29);
|
||||
lcdWriteData(0x32);
|
||||
|
||||
lcdWriteCommand(0xE1);
|
||||
lcdWriteData(0xD0);
|
||||
lcdWriteData(0x04);
|
||||
lcdWriteData(0x06);
|
||||
lcdWriteData(0x09);
|
||||
lcdWriteData(0x06);
|
||||
lcdWriteData(0x03);
|
||||
lcdWriteData(0x25);
|
||||
lcdWriteData(0x32);
|
||||
lcdWriteData(0x3E);
|
||||
lcdWriteData(0x18);
|
||||
lcdWriteData(0x15);
|
||||
lcdWriteData(0x15);
|
||||
lcdWriteData(0x2B);
|
||||
lcdWriteData(0x30);
|
||||
|
||||
lcdWriteCommand(0xF0);
|
||||
lcdWriteData(0x3C);
|
||||
|
||||
lcdWriteCommand(0xF0);
|
||||
lcdWriteData(0x69);
|
||||
|
||||
delay_ms(120);
|
||||
|
||||
#if defined(RADIO_T15)
|
||||
if (hardwareOptions.pcbrev == PCBREV_T15_IPS) lcdWriteCommand(0x21);
|
||||
#endif
|
||||
|
||||
LCD_ST7796S_On();
|
||||
}
|
||||
|
||||
void LCD_ST7796S_Off(void) { lcdWriteCommand(0x28); }
|
||||
|
||||
void LCD_Init_LTDC()
|
||||
{
|
||||
hltdc.Instance = LTDC;
|
||||
|
||||
/* Configure PLLSAI prescalers for LCD */
|
||||
/* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */
|
||||
/* PLLSAI_VCO Output = PLLSAI_VCO Input * lcdPixelclock * 16 = XX Mhz */
|
||||
/* PLLLCDCLK = PLLSAI_VCO Output/PLL_LTDC = PLLSAI_VCO/4 = YY Mhz */
|
||||
/* LTDC clock frequency = PLLLCDCLK / RCC_PLLSAIDivR = YY/4 = lcdPixelClock
|
||||
* Mhz */
|
||||
uint32_t clock = (lcdPixelClock * 16) / 1000000; // clock*16 in MHz
|
||||
RCC_PeriphCLKInitTypeDef clkConfig;
|
||||
clkConfig.PeriphClockSelection = RCC_PERIPHCLK_LTDC;
|
||||
clkConfig.PLLSAI.PLLSAIN = clock;
|
||||
clkConfig.PLLSAI.PLLSAIR = 4;
|
||||
clkConfig.PLLSAIDivQ = 6;
|
||||
clkConfig.PLLSAIDivR = RCC_PLLSAIDIVR_4;
|
||||
HAL_RCCEx_PeriphCLKConfig(&clkConfig);
|
||||
|
||||
/* LTDC Configuration
|
||||
* *********************************************************/
|
||||
/* Polarity configuration */
|
||||
/* Initialize the horizontal synchronization polarity as active low */
|
||||
hltdc.Init.HSPolarity = LTDC_HSPOLARITY_AL;
|
||||
/* Initialize the vertical synchronization polarity as active low */
|
||||
hltdc.Init.VSPolarity = LTDC_VSPOLARITY_AL;
|
||||
/* Initialize the data enable polarity as active low */
|
||||
hltdc.Init.DEPolarity = LTDC_DEPOLARITY_AL;
|
||||
/* Initialize the pixel clock polarity as input pixel clock */
|
||||
hltdc.Init.PCPolarity = LTDC_PCPOLARITY_IIPC;
|
||||
|
||||
/* Configure R,G,B component values for LCD background color */
|
||||
hltdc.Init.Backcolor.Red = 0;
|
||||
hltdc.Init.Backcolor.Green = 0;
|
||||
hltdc.Init.Backcolor.Blue = 0;
|
||||
|
||||
/* Configure horizontal synchronization width */
|
||||
hltdc.Init.HorizontalSync = HSW;
|
||||
/* Configure vertical synchronization height */
|
||||
hltdc.Init.VerticalSync = VSH;
|
||||
/* Configure accumulated horizontal back porch */
|
||||
hltdc.Init.AccumulatedHBP = HBP;
|
||||
/* Configure accumulated vertical back porch */
|
||||
hltdc.Init.AccumulatedVBP = VBP;
|
||||
/* Configure accumulated active width */
|
||||
hltdc.Init.AccumulatedActiveW = LCD_H + HBP;
|
||||
/* Configure accumulated active height */
|
||||
hltdc.Init.AccumulatedActiveH = LCD_W + VBP;
|
||||
/* Configure total width */
|
||||
hltdc.Init.TotalWidth = LCD_H + HBP + HFP;
|
||||
/* Configure total height */
|
||||
hltdc.Init.TotalHeigh = LCD_W + VBP + VFP;
|
||||
|
||||
HAL_LTDC_Init(&hltdc);
|
||||
|
||||
// Configure IRQ (line)
|
||||
NVIC_SetPriority(LTDC_IRQn, LTDC_IRQ_PRIO);
|
||||
NVIC_EnableIRQ(LTDC_IRQn);
|
||||
|
||||
// Trigger on last line
|
||||
HAL_LTDC_ProgramLineEvent(&hltdc, LCD_W);
|
||||
__HAL_LTDC_ENABLE_IT(&hltdc, LTDC_IT_LI);
|
||||
}
|
||||
|
||||
void LCD_LayerInit()
|
||||
{
|
||||
auto& layer = hltdc.LayerCfg[0];
|
||||
|
||||
/* Windowing configuration */
|
||||
layer.WindowX0 = 0;
|
||||
layer.WindowX1 = LCD_H;
|
||||
layer.WindowY0 = 0;
|
||||
layer.WindowY1 = LCD_W;
|
||||
|
||||
/* Pixel Format configuration*/
|
||||
layer.PixelFormat = LTDC_PIXEL_FORMAT_RGB565;
|
||||
|
||||
/* Alpha constant (255 totally opaque) */
|
||||
layer.Alpha = 255;
|
||||
|
||||
/* Default Color configuration (configure A,R,G,B component values) */
|
||||
layer.Backcolor.Blue = 0;
|
||||
layer.Backcolor.Green = 0;
|
||||
layer.Backcolor.Red = 0;
|
||||
layer.Alpha0 = 0;
|
||||
|
||||
/* Configure blending factors */
|
||||
layer.BlendingFactor1 = LTDC_BLENDING_FACTOR1_CA;
|
||||
layer.BlendingFactor2 = LTDC_BLENDING_FACTOR2_CA;
|
||||
|
||||
layer.ImageWidth = LCD_H;
|
||||
layer.ImageHeight = LCD_W;
|
||||
|
||||
/* Start Address configuration : the LCD Frame buffer is defined on SDRAM w/
|
||||
* Offset */
|
||||
layer.FBStartAdress = (intptr_t)initialFrameBuffer;
|
||||
|
||||
/* Initialize LTDC layer 1 */
|
||||
HAL_LTDC_ConfigLayer(&hltdc, &hltdc.LayerCfg[0], 0);
|
||||
|
||||
/* dithering activation */
|
||||
HAL_LTDC_EnableDither(&hltdc);
|
||||
}
|
||||
|
||||
extern "C" void lcdSetInitalFrameBuffer(void* fbAddress)
|
||||
{
|
||||
initialFrameBuffer = fbAddress;
|
||||
}
|
||||
|
||||
extern "C" void lcdInit(void)
|
||||
{
|
||||
/* Configure the LCD SPI+RESET pins */
|
||||
lcdSpiConfig();
|
||||
|
||||
/* Reset the LCD --------------------------------------------------------*/
|
||||
lcdReset();
|
||||
|
||||
/* Configure the LCD Control pins */
|
||||
LCD_AF_GPIOConfig();
|
||||
|
||||
/* Send LCD initialization commands */
|
||||
lcdPixelClock = 12000000;
|
||||
|
||||
LCD_ST7796S_Init();
|
||||
|
||||
LCD_Init_LTDC();
|
||||
LCD_LayerInit();
|
||||
|
||||
// Enable LCD display
|
||||
__HAL_LTDC_ENABLE(&hltdc);
|
||||
|
||||
lcdSetFlushCb(startLcdRefresh);
|
||||
}
|
||||
|
||||
extern "C" void LTDC_IRQHandler(void)
|
||||
{
|
||||
__HAL_LTDC_CLEAR_FLAG(&hltdc, LTDC_FLAG_LI);
|
||||
__HAL_LTDC_DISABLE_IT(&hltdc, LTDC_IT_LI);
|
||||
_frame_addr_reloaded = 1;
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (C) EdgeTX
|
||||
*
|
||||
* Based on code named
|
||||
* opentx - https://github.com/opentx/opentx
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define HBP (24)
|
||||
#define VBP (10)
|
||||
|
||||
#define HSW (4)
|
||||
#define VSH (2)
|
||||
|
||||
#define HFP (140 - HBP)
|
||||
#define VFP (22 - VBP)
|
||||
|
||||
#define SET_IO_INPUT(PORT, PIN) \
|
||||
LL_GPIO_SetPinMode(PORT, PIN, LL_GPIO_MODE_INPUT)
|
||||
#define SET_IO_OUTPUT(PORT, PIN) \
|
||||
LL_GPIO_SetPinMode(PORT, PIN, LL_GPIO_MODE_OUTPUT)
|
||||
|
||||
#define LCD_NRST_HIGH() LL_GPIO_SetOutputPin(LCD_NRST_GPIO, LCD_NRST_GPIO_PIN)
|
||||
#define LCD_NRST_LOW() LL_GPIO_ResetOutputPin(LCD_NRST_GPIO, LCD_NRST_GPIO_PIN)
|
||||
|
||||
#define LCD_CS_HIGH() LL_GPIO_SetOutputPin(LCD_SPI_GPIO, LCD_SPI_CS_GPIO_PIN)
|
||||
#define LCD_CS_LOW() LL_GPIO_ResetOutputPin(LCD_SPI_GPIO, LCD_SPI_CS_GPIO_PIN)
|
||||
|
||||
#define LCD_SCK_HIGH() LL_GPIO_SetOutputPin(LCD_SPI_GPIO, LCD_SPI_SCK_GPIO_PIN)
|
||||
#define LCD_SCK_LOW() LL_GPIO_ResetOutputPin(LCD_SPI_GPIO, LCD_SPI_SCK_GPIO_PIN)
|
||||
|
||||
#define LCD_MOSI_HIGH() \
|
||||
LL_GPIO_SetOutputPin(LCD_SPI_GPIO, LCD_SPI_MOSI_GPIO_PIN)
|
||||
#define LCD_MOSI_LOW() \
|
||||
LL_GPIO_ResetOutputPin(LCD_SPI_GPIO, LCD_SPI_MOSI_GPIO_PIN)
|
||||
|
||||
#define LCD_MOSI_AS_INPUT() SET_IO_INPUT(LCD_SPI_GPIO, LCD_SPI_MOSI_GPIO_PIN)
|
||||
#define LCD_MOSI_AS_OUTPUT() SET_IO_OUTPUT(LCD_SPI_GPIO, LCD_SPI_MOSI_GPIO_PIN)
|
||||
|
||||
#define LCD_READ_DATA_PIN() \
|
||||
LL_GPIO_IsInputPinSet(LCD_SPI_GPIO, LCD_SPI_MOSI_GPIO_PIN)
|
||||
|
||||
#define HORIZONTAL_SYNC_WIDTH (4)
|
||||
#define HORIZONTAL_BACK_PORCH (24)
|
||||
#define HORIZONTAL_FRONT_PORCH (140 - HORIZONTAL_BACK_PORCH)
|
||||
#define VERTICAL_SYNC_HEIGHT (2)
|
||||
#define VERTICAL_BACK_PORCH (10)
|
||||
#define VERTICAL_FRONT_PORCH (22 - VERTICAL_BACK_PORCH)
|
||||
@@ -38,8 +38,39 @@ void ledInit()
|
||||
#if defined(LED_BLUE_GPIO)
|
||||
gpio_init(LED_BLUE_GPIO, GPIO_OUT, GPIO_PIN_SPEED_LOW);
|
||||
#endif
|
||||
|
||||
#if defined(FUNCTION_SWITCHES)
|
||||
gpio_init(FSLED_GPIO_1, GPIO_OUT, GPIO_PIN_SPEED_LOW);
|
||||
gpio_init(FSLED_GPIO_2, GPIO_OUT, GPIO_PIN_SPEED_LOW);
|
||||
gpio_init(FSLED_GPIO_3, GPIO_OUT, GPIO_PIN_SPEED_LOW);
|
||||
gpio_init(FSLED_GPIO_4, GPIO_OUT, GPIO_PIN_SPEED_LOW);
|
||||
gpio_init(FSLED_GPIO_5, GPIO_OUT, GPIO_PIN_SPEED_LOW);
|
||||
gpio_init(FSLED_GPIO_6, GPIO_OUT, GPIO_PIN_SPEED_LOW);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#if defined(FUNCTION_SWITCHES)
|
||||
gpio_t fsLeds[] = {FSLED_GPIO_1, FSLED_GPIO_2,
|
||||
FSLED_GPIO_3, FSLED_GPIO_4,
|
||||
FSLED_GPIO_5, FSLED_GPIO_6};
|
||||
|
||||
void fsLedOff(uint8_t index)
|
||||
{
|
||||
gpio_clear(fsLeds[index]);
|
||||
}
|
||||
|
||||
void fsLedOn(uint8_t index)
|
||||
{
|
||||
gpio_set(fsLeds[index]);
|
||||
}
|
||||
|
||||
bool getFSLedState(uint8_t index)
|
||||
{
|
||||
return (gpio_read(fsLeds[index]));
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(LED_GPIO)
|
||||
|
||||
// Single GPIO for dual color LED
|
||||
|
||||
@@ -26,6 +26,10 @@
|
||||
#define USB_NAME "FrSky Horus"
|
||||
#define USB_MANUFACTURER 'F', 'r', 'S', 'k', 'y', ' ', ' ', ' ' /* 8 bytes */
|
||||
#define USB_PRODUCT 'H', 'o', 'r', 'u', 's', ' ', ' ', ' ' /* 8 Bytes */
|
||||
#elif defined(RADIO_T15)
|
||||
#define USB_NAME "Jumper T15"
|
||||
#define USB_MANUFACTURER 'J', 'u', 'm', 'p', 'e', 'r', ' ', ' ' /* 8 bytes */
|
||||
#define USB_PRODUCT 'T', '1', '5', ' ', ' ', ' ', ' ', ' ' /* 8 Bytes */
|
||||
#elif defined(RADIO_T16)
|
||||
#define USB_NAME "Jumper T16"
|
||||
#define USB_MANUFACTURER 'J', 'u', 'm', 'p', 'e', 'r', ' ', ' ' /* 8 bytes */
|
||||
|
||||
@@ -131,17 +131,6 @@ uint32_t isBootloaderStart(const uint8_t * buffer);
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(FUNCTION_SWITCHES)
|
||||
extern uint8_t fsPreviousState;
|
||||
void evalFunctionSwitches();
|
||||
void setFSStartupPosition();
|
||||
void fsLedOff(uint8_t);
|
||||
void fsLedOn(uint8_t);
|
||||
uint8_t getFSLogicalState(uint8_t index);
|
||||
uint8_t getFSPhysicalState(uint8_t index);
|
||||
bool getFSLedState(uint8_t index);
|
||||
#endif
|
||||
|
||||
#if defined(ADC_GPIO_PIN_STICK_TH)
|
||||
#define SURFACE_RADIO true
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user