From 82b13ebe3f4cc25227c0d99e8ab2fd0f45c0e03a Mon Sep 17 00:00:00 2001 From: 3djc Date: Wed, 27 May 2020 07:35:25 +0200 Subject: [PATCH] TX16S internal gps option (#7632) --- .../src/firmwares/opentx/opentxinterface.cpp | 4 +++- radio/src/options.h | 3 +++ radio/src/targets/horus/CMakeLists.txt | 6 +++-- radio/src/targets/horus/board.cpp | 1 + radio/src/targets/horus/gps_driver.cpp | 12 ++++++++-- radio/src/targets/horus/hal.h | 24 +++++++++++++++++-- radio/util/fwoptions.py | 1 + 7 files changed, 44 insertions(+), 7 deletions(-) diff --git a/companion/src/firmwares/opentx/opentxinterface.cpp b/companion/src/firmwares/opentx/opentxinterface.cpp index fa02be60a..150352da8 100644 --- a/companion/src/firmwares/opentx/opentxinterface.cpp +++ b/companion/src/firmwares/opentx/opentxinterface.cpp @@ -1357,8 +1357,10 @@ void registerOpenTxFirmwares() /* Radiomaster TX16S board */ firmware = new OpenTxFirmware("opentx-tx16s", Firmware::tr("Radiomaster TX16s / TX16s Hall / TX16s Masterfire"), BOARD_RADIOMASTER_TX16S); addOpenTxFrskyOptions(firmware); - firmware->addOption("bluetooth", Firmware::tr("Support for bluetooth module")); addOpenTxRfOptions(firmware, FLEX); + static const Firmware::Option opt_bt("bluetooth", Firmware::tr("Support for bluetooth module")); + static const Firmware::Option opt_internal_gps("internalgps", Firmware::tr("Support internal GPS")); + firmware->addOptionsGroup({opt_bt, opt_internal_gps}); registerOpenTxFirmware(firmware); /* 9XR-Pro */ diff --git a/radio/src/options.h b/radio/src/options.h index 2afb1596b..e8bf634c1 100644 --- a/radio/src/options.h +++ b/radio/src/options.h @@ -53,6 +53,9 @@ static const char * options[] = { #if defined(HORUS_STICKS) "horussticks", #endif +#if defined(INTERNAL_GPS) + "internalgps", +#endif #if defined(INTERNAL_MODULE_PPM) "internalppm", #endif diff --git a/radio/src/targets/horus/CMakeLists.txt b/radio/src/targets/horus/CMakeLists.txt index b1a01e2e1..dfa235baa 100644 --- a/radio/src/targets/horus/CMakeLists.txt +++ b/radio/src/targets/horus/CMakeLists.txt @@ -61,13 +61,15 @@ if (PCB STREQUAL X10) add_definitions(-DRADIO_FAMILY_T16) option(INTERNAL_MODULE_MULTI "Support for MULTI internal module" ON) option(BLUETOOTH "Support for bluetooth module" OFF) + option(INTERNAL_GPS "Support for internal ublox GPS" OFF) set(HARDWARE_TOUCH YES) set(USB_CHARGER YES) set(DEFAULT_THEME "DARKBLUE") set(AUX_SERIAL ON) - if (NOT BLUETOOTH) + if (NOT BLUETOOTH AND NOT INTERNAL_GPS) set(AUX2_SERIAL ON) endif() + set(INTERNAL_GPS_BAUDRATE "9600" CACHE STRING "Baud rate for internal GPS") else() set(FLAVOUR x10) option(INTERNAL_MODULE_PXX1 "Support for PXX1 internal module" ON) @@ -94,7 +96,6 @@ elseif (PCB STREQUAL X12S) ${TARGET_SRC} audio_spi_driver.cpp x12s_adc_driver.cpp - gps_driver.cpp ) set(BITMAPS_TARGET x12s_bitmaps) set(FONTS_TARGET x12s_fonts) @@ -199,6 +200,7 @@ endif() if(INTERNAL_GPS) set(SRC ${SRC} gps.cpp) + set(TARGET_SRC ${TARGET_SRC} gps_driver.cpp) add_definitions(-DINTERNAL_GPS) message("Horus: Internal GPS enabled") endif() diff --git a/radio/src/targets/horus/board.cpp b/radio/src/targets/horus/board.cpp index 25c0cbbdf..49a0f13f7 100644 --- a/radio/src/targets/horus/board.cpp +++ b/radio/src/targets/horus/board.cpp @@ -150,6 +150,7 @@ void boardInit() BT_RCC_APB2Periph | AUX_SERIAL_RCC_APB2Periph | AUX2_SERIAL_RCC_APB2Periph | + GPS_RCC_APB2Periph | BACKLIGHT_RCC_APB2Periph, ENABLE); diff --git a/radio/src/targets/horus/gps_driver.cpp b/radio/src/targets/horus/gps_driver.cpp index 7a5e464c4..0e165b978 100644 --- a/radio/src/targets/horus/gps_driver.cpp +++ b/radio/src/targets/horus/gps_driver.cpp @@ -33,8 +33,8 @@ void gpsInit(uint32_t baudrate) NVIC_InitTypeDef NVIC_InitStructure; // RX and TX pins - GPIO_PinAFConfig(GPIOA, GPS_TX_GPIO_PinSource, GPS_GPIO_AF); - GPIO_PinAFConfig(GPIOA, GPS_RX_GPIO_PinSource, GPS_GPIO_AF); + GPIO_PinAFConfig(GPS_UART_GPIO, GPS_TX_GPIO_PinSource, GPS_GPIO_AF); + GPIO_PinAFConfig(GPS_UART_GPIO, GPS_RX_GPIO_PinSource, GPS_GPIO_AF); GPIO_InitStructure.GPIO_Pin = (GPS_TX_GPIO_PIN | GPS_RX_GPIO_PIN); GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; @@ -58,6 +58,14 @@ void gpsInit(uint32_t baudrate) NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); + +#if defined(GPS_PWR_GPIO) + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; + GPIO_InitStructure.GPIO_Pin = GPS_PWR_GPIO_PIN; + GPIO_Init(GPS_PWR_GPIO, &GPIO_InitStructure); + GPIO_SetBits(GPS_PWR_GPIO, GPS_PWR_GPIO_PIN); +#endif } #if defined(DEBUG) diff --git a/radio/src/targets/horus/hal.h b/radio/src/targets/horus/hal.h index b0d2042ae..5e7cd04c2 100644 --- a/radio/src/targets/horus/hal.h +++ b/radio/src/targets/horus/hal.h @@ -418,7 +418,7 @@ #define AUX_SERIAL_RCC_APB2Periph 0 #endif -#if defined(RADIO_TX16S) && !defined(BLUETOOTH) +#if defined(AUX2_SERIAL) #define AUX2_SERIAL_RCC_AHB1Periph (RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOG | RCC_AHB1Periph_DMA2) #define AUX2_SERIAL_RCC_APB1Periph 0 #define AUX2_SERIAL_RCC_APB2Periph RCC_APB2Periph_USART6 @@ -435,6 +435,24 @@ #define AUX2_SERIAL_DMA_Channel_RX DMA_Channel_5 #define AUX2_SERIAL_PWR_GPIO GPIOB #define AUX2_SERIAL_PWR_GPIO_PIN GPIO_Pin_0 // PB.00 +#elif defined(RADIO_TX16S) && defined(INTERNAL_GPS) + #define GPS_RCC_AHB1Periph (RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOG) + #define GPS_RCC_APB1Periph 0 + #define GPS_RCC_APB2Periph RCC_APB2Periph_USART6 + #define GPS_USART USART6 + #define GPS_GPIO_AF GPIO_AF_USART6 + #define GPS_USART_IRQn USART6_IRQn + #define GPS_USART_IRQHandler USART6_IRQHandler + #define GPS_UART_GPIO GPIOG + #define GPS_TX_GPIO_PIN GPIO_Pin_14 // PG.14 + #define GPS_RX_GPIO_PIN GPIO_Pin_9 // PG.09 + #define GPS_TX_GPIO_PinSource GPIO_PinSource14 + #define GPS_RX_GPIO_PinSource GPIO_PinSource9 + #define GPS_PWR_GPIO GPIOB + #define GPS_PWR_GPIO_PIN GPIO_Pin_0 // PB.00 + #define AUX2_SERIAL_RCC_AHB1Periph 0 + #define AUX2_SERIAL_RCC_APB1Periph 0 + #define AUX2_SERIAL_RCC_APB2Periph 0 #else #define AUX2_SERIAL_RCC_AHB1Periph 0 #define AUX2_SERIAL_RCC_APB1Periph 0 @@ -900,6 +918,7 @@ #if defined(PCBX12S) #define GPS_RCC_AHB1Periph RCC_AHB1Periph_GPIOA #define GPS_RCC_APB1Periph RCC_APB1Periph_UART4 + #define GPS_RCC_APB2Periph 0 #define GPS_USART UART4 #define GPS_GPIO_AF GPIO_AF_UART4 #define GPS_USART_IRQn UART4_IRQn @@ -909,9 +928,10 @@ #define GPS_RX_GPIO_PIN GPIO_Pin_1 // PA.01 #define GPS_TX_GPIO_PinSource GPIO_PinSource0 #define GPS_RX_GPIO_PinSource GPIO_PinSource1 -#else +#elif !defined(INTERNAL_GPS) #define GPS_RCC_AHB1Periph 0 #define GPS_RCC_APB1Periph 0 + #define GPS_RCC_APB2Periph 0 #endif #endif // _HAL_H_ diff --git a/radio/util/fwoptions.py b/radio/util/fwoptions.py index 811ff17b7..8ee448f11 100755 --- a/radio/util/fwoptions.py +++ b/radio/util/fwoptions.py @@ -234,4 +234,5 @@ options_radiomaster_tx16s = { "nooverridech": ("OVERRIDE_CHANNEL_FUNCTION", "NO", "YES"), "flexr9m": ("MODULE_PROTOCOL_FLEX", "YES", None), "bluetooth": ("BLUETOOTH", "YES", "NO"), + "internalgps": ("INTERNAL_GPS", "YES", "NO"), } \ No newline at end of file