From 09947350353e7f6353e53920da06b0bb88d2a7f5 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Fri, 19 Aug 2016 12:20:17 +0200 Subject: [PATCH] [X12S] Backlight code splitted from LCD code [X12S] PCBREV introduction (PCBREV=10 or PCBREV=13) --- radio/src/targets/horus/CMakeLists.txt | 10 ++- radio/src/targets/horus/backlight_driver.cpp | 81 +++++++++++++++++++ radio/src/targets/horus/board.cpp | 6 ++ radio/src/targets/horus/board.h | 1 + radio/src/targets/horus/hal.h | 55 +++++++++---- radio/src/targets/horus/lcd_driver.cpp | 80 ++---------------- .../src/targets/taranis/bluetooth_driver.cpp | 28 +++---- radio/src/targets/taranis/hal.h | 32 ++++---- 8 files changed, 172 insertions(+), 121 deletions(-) create mode 100644 radio/src/targets/horus/backlight_driver.cpp diff --git a/radio/src/targets/horus/CMakeLists.txt b/radio/src/targets/horus/CMakeLists.txt index d16d7a912..991442e92 100644 --- a/radio/src/targets/horus/CMakeLists.txt +++ b/radio/src/targets/horus/CMakeLists.txt @@ -1,3 +1,6 @@ +set(PCBREV "13" CACHE STRING "PCB Revision") +option(DISK_CACHE "Enable SD card disk cache" YES) + set(CPU_TYPE STM32F4) set(HSE_VALUE 12000000) set(SDCARD YES) @@ -10,10 +13,12 @@ set(FIRMWARE_DEPENDENCIES ${FIRMWARE_DEPENDENCIES} horus_bitmaps) set(LUA_EXPORT lua_export_horus) set(FLAVOUR horus) set(RAMBACKUP YES) -option(DISK_CACHE "Enable SD card disk cache" YES) -add_definitions(-DPCBHORUS -DCOLORLCD -DSTM32F429_439xx -DSDRAM -DPPM_PIN_UART -DPPM_PIN_TIMER) + +add_definitions(-DPCBHORUS -DPCBREV=${PCBREV} -DCOLORLCD -DSTM32F429_439xx -DSDRAM -DPPM_PIN_UART -DPPM_PIN_TIMER) add_definitions(-DEEPROM_VARIANT=0 -DAUDIO -DVOICE -DRTCLOCK) + include_directories(${RADIO_SRC_DIRECTORY}/fonts/480x272 gui/${GUI_DIR} gui/${GUI_DIR}/layouts) + file(GLOB THEMES_SRC RELATIVE ${RADIO_SRC_DIRECTORY}/gui/480x272 ${RADIO_SRC_DIRECTORY}/gui/480x272/themes/*.cpp) file(GLOB LAYOUTS_SRC RELATIVE ${RADIO_SRC_DIRECTORY}/gui/480x272 ${RADIO_SRC_DIRECTORY}/gui/480x272/layouts/*.cpp) file(GLOB WIDGETS_SRC RELATIVE ${RADIO_SRC_DIRECTORY}/gui/480x272 ${RADIO_SRC_DIRECTORY}/gui/480x272/widgets/*.cpp) @@ -59,6 +64,7 @@ set(FIRMWARE_TARGET_SRC ${FIRMWARE_TARGET_SRC} sdio_sd.c lcd_driver.cpp + backlight_driver.cpp pwr_driver.cpp sdram_driver.c startup_stm32f40_41xxx.s diff --git a/radio/src/targets/horus/backlight_driver.cpp b/radio/src/targets/horus/backlight_driver.cpp new file mode 100644 index 000000000..5b9a5e80e --- /dev/null +++ b/radio/src/targets/horus/backlight_driver.cpp @@ -0,0 +1,81 @@ +/* + * Copyright (C) OpenTX + * + * Based on code named + * 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 "opentx.h" + +void backlightInit() +{ + GPIO_InitTypeDef GPIO_InitStructure; + GPIO_InitStructure.GPIO_Pin = BL_GPIO_PIN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; + GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; + GPIO_Init(BL_GPIO, &GPIO_InitStructure); + GPIO_PinAFConfig(BL_GPIO, BL_GPIO_PinSource, BL_GPIO_AF); +} + +void backlightEnable(uint8_t dutyCycle) +{ + static uint8_t existingDutyCycle; + + if (dutyCycle == existingDutyCycle || dutyCycle < 5) { + return; + } + else { + existingDutyCycle = dutyCycle; + } + + TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; + TIM_OCInitTypeDef TIM_OCInitStructure; + + TIM_TimeBaseStructure.TIM_Prescaler = SystemCoreClock / 10000 - 1; // 1KhZ + TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; + TIM_TimeBaseStructure.TIM_Period = 100; + TIM_TimeBaseStructure.TIM_ClockDivision = 0; + TIM_TimeBaseStructure.TIM_RepetitionCounter = 0; + TIM_TimeBaseInit(BL_TIMER, &TIM_TimeBaseStructure); + + TIM_Cmd(BL_TIMER, DISABLE); + + /* PWM mode */ + TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1; + TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; + TIM_OCInitStructure.TIM_OutputNState = TIM_OutputNState_Enable; +#if PCBREV >= 13 + TIM_OCInitStructure.TIM_Pulse = dutyCycle; +#else + TIM_OCInitStructure.TIM_Pulse = (100 - dutyCycle); +#endif + TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High; + TIM_OCInitStructure.TIM_OCNPolarity = TIM_OCNPolarity_High; + TIM_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Set; + TIM_OCInitStructure.TIM_OCNIdleState = TIM_OCNIdleState_Set; +#if PCBREV >= 13 + TIM_OC4Init(BL_TIMER, &TIM_OCInitStructure); +#else + TIM_OC1Init(BL_TIMER, &TIM_OCInitStructure); +#endif + + TIM_Cmd(BL_TIMER, ENABLE); + TIM_CtrlPWMOutputs(BL_TIMER, ENABLE); +} + + diff --git a/radio/src/targets/horus/board.cpp b/radio/src/targets/horus/board.cpp index d7942c08d..5b07f0687 100644 --- a/radio/src/targets/horus/board.cpp +++ b/radio/src/targets/horus/board.cpp @@ -114,6 +114,7 @@ void boardInit() RCC_AHB1PeriphClockCmd(PWR_RCC_AHB1Periph | LED_RCC_AHB1Periph | LCD_RCC_AHB1Periph | + BL_RCC_AHB1Periph | AUDIO_RCC_AHB1Periph | KEYS_RCC_AHB1Periph_GPIO | ADC_RCC_AHB1Periph | @@ -128,6 +129,7 @@ void boardInit() ENABLE); RCC_APB1PeriphClockCmd(INTERRUPT_5MS_RCC_APB1Periph | TIMER_2MHz_RCC_APB1Periph | + BL_RCC_APB1Periph | AUDIO_RCC_APB1Periph | SERIAL_RCC_APB1Periph | TELEMETRY_RCC_APB1Periph | @@ -137,6 +139,7 @@ void boardInit() GPS_RCC_APB1Periph, ENABLE); RCC_APB2PeriphClockCmd(LCD_RCC_APB2Periph | + BL_RCC_APB2Periph | ADC_RCC_APB2Periph | HAPTIC_RCC_APB2Periph | INTMODULE_RCC_APB2Periph, ENABLE); @@ -156,6 +159,9 @@ void boardInit() keysInit(); adcInit(); lcdInit(); + backlightInit(); + // TODO ? backlightEnable(100); + audioInit(); init2MhzTimer(); init1msTimer(); diff --git a/radio/src/targets/horus/board.h b/radio/src/targets/horus/board.h index 980e91ef6..8055ed699 100644 --- a/radio/src/targets/horus/board.h +++ b/radio/src/targets/horus/board.h @@ -344,6 +344,7 @@ void lcdSetContrast(); #define lcdRefreshWait(...) // Backlight driver +void backlightInit(void); #if defined(SIMU) #define backlightEnable(...) #else diff --git a/radio/src/targets/horus/hal.h b/radio/src/targets/horus/hal.h index 5b3fb1f89..979ed94bb 100644 --- a/radio/src/targets/horus/hal.h +++ b/radio/src/targets/horus/hal.h @@ -190,16 +190,31 @@ // LCD #define LCD_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOF | RCC_AHB1Periph_GPIOI | RCC_AHB1Periph_GPIOJ | RCC_AHB1Periph_GPIOK | RCC_AHB1Periph_DMA2D) -#define LCD_RCC_APB2Periph (RCC_APB2Periph_TIM8 | RCC_APB2Periph_LTDC) +#define LCD_RCC_APB2Periph RCC_APB2Periph_LTDC #define LCD_GPIO_NRST GPIOF #define LCD_GPIO_PIN_NRST GPIO_Pin_10 // PF.10 -#define LCD_GPIO_BL GPIOA -#define LCD_GPIO_PIN_BL GPIO_Pin_5 // PA.05 -#define LCD_GPIO_PinSource_BL GPIO_PinSource5 -#define LCD_GPIO_AF_BL GPIO_AF_TIM8 #define LTDC_IRQ_PRIO 4 #define DMA_SCREEN_IRQ_PRIO 6 +// Backlight +#define BL_RCC_AHB1Periph RCC_AHB1Periph_GPIOA +#define BL_GPIO GPIOA +#if PCBREV >= 13 +#define BL_TIMER TIM5 +#define BL_GPIO_PIN GPIO_Pin_3 // PA.03 +#define BL_GPIO_PinSource GPIO_PinSource3 +#define BL_RCC_APB1Periph RCC_APB1Periph_TIM5 +#define BL_RCC_APB2Periph 0 +#define BL_GPIO_AF GPIO_AF_TIM5 +#else +#define BL_TIMER TIM8 +#define BL_GPIO_PIN GPIO_Pin_5 // PA.05 +#define BL_GPIO_PinSource GPIO_PinSource5 +#define BL_RCC_APB1Periph 0 +#define BL_RCC_APB2Periph RCC_APB2Periph_TIM8 +#define BL_GPIO_AF GPIO_AF_TIM8 +#endif + // SD #define SD_RCC_AHB1Periph (RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_DMA2) #define SD_PRESENT_GPIO GPIOC @@ -341,22 +356,28 @@ #define TIMER_2MHz_TIMER TIM7 // Bluetooth -#define BT_RCC_AHB1Periph (RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOG) -#define BT_RCC_APB1Periph RCC_APB1Periph_UART6 +#define BT_RCC_APB2Periph RCC_APB2Periph_USART6 #define BT_USART USART6 #define BT_GPIO_AF GPIO_AF_USART6 #define BT_USART_IRQn USART6_IRQn #define BT_GPIO_TXRX GPIOG -#define BT_GPIO_PIN_TX GPIO_Pin_14 // PG.14 -#define BT_GPIO_PIN_RX GPIO_Pin_9 // PG.09 -#define BT_GPIO_EN GPIOB -#define BT_GPIO_PIN_EN GPIO_Pin_10 // PB.10 -#define BT_GPIO_BRTS GPIOG -#define BT_GPIO_PIN_BRTS GPIO_Pin_10 // PG.10 -#define BT_GPIO_BCTS GPIOG -#define BT_GPIO_PIN_BCTS GPIO_Pin_11 // PG.11 -#define BT_GPIO_PinSource_TX GPIO_PinSource14 -#define BT_GPIO_PinSource_RX GPIO_PinSource9 +#define BT_TX_GPIO_PIN GPIO_Pin_14 // PG.14 +#define BT_RX_GPIO_PIN GPIO_Pin_9 // PG.09 +#if PCBREV >= 13 +#define BT_RCC_AHB1Periph (RCC_AHB1Periph_GPIOI | RCC_AHB1Periph_GPIOG) +#define BT_EN_GPIO GPIOI +#define BT_EN_GPIO_PIN GPIO_Pin_10 // PI.10 +#else +#define BT_RCC_AHB1Periph (RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOG) +#define BT_EN_GPIO GPIOB +#define BT_EN_GPIO_PIN GPIO_Pin_10 // PB.10 +#endif +#define BT_BRTS_GPIO GPIOG +#define BT_BRTS_GPIO_PIN GPIO_Pin_10 // PG.10 +#define BT_BCTS_GPIO GPIOG +#define BT_BCTS_GPIO_PIN GPIO_Pin_11 // PG.11 +#define BT_TX_GPIO_PinSource GPIO_PinSource14 +#define BT_RX_GPIO_PinSource GPIO_PinSource9 // GPS #define GPS_RCC_AHB1Periph RCC_AHB1Periph_GPIOA diff --git a/radio/src/targets/horus/lcd_driver.cpp b/radio/src/targets/horus/lcd_driver.cpp index afc6f8bdd..5f81463b9 100644 --- a/radio/src/targets/horus/lcd_driver.cpp +++ b/radio/src/targets/horus/lcd_driver.cpp @@ -29,14 +29,9 @@ #define HFP 3 #define VFP 2 -#define LCD_DIR_HORIZONTAL 0x0000 -#define LCD_DIR_VERTICAL 0x0001 - #define LCD_FIRST_LAYER 0 #define LCD_SECOND_LAYER 1 -#define LCD_BKLIGHT_PWM_FREQ 300 - uint8_t LCD_FIRST_FRAME_BUFFER[DISPLAY_BUFFER_SIZE] __SDRAM; uint8_t LCD_SECOND_FRAME_BUFFER[DISPLAY_BUFFER_SIZE] __SDRAM; uint8_t LCD_BACKUP_FRAME_BUFFER[DISPLAY_BUFFER_SIZE] __SDRAM; @@ -65,28 +60,27 @@ static void LCD_AF_GPIOConfig(void) | LCD_TFT HSYNC <-> PI.12 | LCDTFT VSYNC <-> PI.13 | | LCD_TFT CLK <-> PI.14 | LCD_TFT DE <-> PK.07 /// ----------------------------------------------------- - |LCD_TFT backlight <-> PA.05| LCD_CS <-> PI.10 |LCD_SCK<->PI.11 + | LCD_CS <-> PI.10 |LCD_SCK<->PI.11 ----------------------------------------------------- */ - /*GPIOI configuration*/ - - GPIO_PinAFConfig(GPIOI,GPIO_PinSource12,GPIO_AF_LTDC); - GPIO_PinAFConfig(GPIOI,GPIO_PinSource13,GPIO_AF_LTDC); - GPIO_PinAFConfig(GPIOI,GPIO_PinSource14,GPIO_AF_LTDC); + // GPIOI configuration + GPIO_PinAFConfig(GPIOI, GPIO_PinSource12, GPIO_AF_LTDC); + GPIO_PinAFConfig(GPIOI, GPIO_PinSource13, GPIO_AF_LTDC); + GPIO_PinAFConfig(GPIOI, GPIO_PinSource14, GPIO_AF_LTDC); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14; GPIO_InitStructure.GPIO_Speed =GPIO_Speed_2MHz; GPIO_InitStructure.GPIO_Mode =GPIO_Mode_AF; GPIO_InitStructure.GPIO_OType =GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd =GPIO_PuPd_NOPULL; - GPIO_Init(GPIOI,&GPIO_InitStructure); + GPIO_Init(GPIOI, &GPIO_InitStructure); GPIO_PinAFConfig(GPIOK, GPIO_PinSource7, GPIO_AF_LTDC); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7; GPIO_Init(GPIOK, &GPIO_InitStructure); - /* GPIOJ configuration */ + // GPIOJ configuration GPIO_PinAFConfig(GPIOJ, GPIO_PinSource2, GPIO_AF_LTDC); GPIO_PinAFConfig(GPIOJ, GPIO_PinSource3, GPIO_AF_LTDC); GPIO_PinAFConfig(GPIOJ, GPIO_PinSource4, GPIO_AF_LTDC); @@ -102,7 +96,7 @@ static void LCD_AF_GPIOConfig(void) GPIO_Init(GPIOJ, &GPIO_InitStructure); - /* GPIOK configuration */ + // GPIOK configuration GPIO_PinAFConfig(GPIOK, GPIO_PinSource0, GPIO_AF_LTDC); GPIO_PinAFConfig(GPIOK, GPIO_PinSource1, GPIO_AF_LTDC); GPIO_PinAFConfig(GPIOK, GPIO_PinSource2, GPIO_AF_LTDC); @@ -120,18 +114,6 @@ static void LCD_AF_GPIOConfig(void) GPIO_Init(GPIOK, &GPIO_InitStructure); } -static void LCD_Backlight_Config(void) -{ - GPIO_InitTypeDef GPIO_InitStructure; - GPIO_InitStructure.GPIO_Pin = LCD_GPIO_PIN_BL; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; - GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; - GPIO_Init(LCD_GPIO_BL, &GPIO_InitStructure); - GPIO_PinAFConfig(LCD_GPIO_BL, LCD_GPIO_PinSource_BL, LCD_GPIO_AF_BL); -} - static void LCD_NRSTConfig(void) { GPIO_InitTypeDef GPIO_InitStructure; @@ -318,45 +300,6 @@ void LCD_LayerInit() LTDC_DitherCmd(ENABLE); } -void backlightEnable(uint8_t dutyCycle) -{ - static uint8_t existingDutyCycle; - - if (dutyCycle == existingDutyCycle || dutyCycle < 5) { - return; - } - else { - existingDutyCycle = dutyCycle; - } - - TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; - TIM_OCInitTypeDef TIM_OCInitStructure; - - TIM_TimeBaseStructure.TIM_Prescaler = SystemCoreClock / 10000 - 1 ;//1KhZ - TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; - TIM_TimeBaseStructure.TIM_Period = 100; - TIM_TimeBaseStructure.TIM_ClockDivision = 0; - TIM_TimeBaseStructure.TIM_RepetitionCounter = 0; - - TIM_TimeBaseInit(TIM8, &TIM_TimeBaseStructure); - - TIM_Cmd(TIM8, DISABLE); - - /* Channel 1 Configuration in PWM mode */ - TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1; - TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; - TIM_OCInitStructure.TIM_OutputNState = TIM_OutputNState_Enable; - TIM_OCInitStructure.TIM_Pulse = (100-dutyCycle); - TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High; - TIM_OCInitStructure.TIM_OCNPolarity = TIM_OCNPolarity_High; - TIM_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Set; - TIM_OCInitStructure.TIM_OCNIdleState = TIM_OCNIdleState_Set; - TIM_OC1Init(TIM8, &TIM_OCInitStructure); - - TIM_Cmd(TIM8, ENABLE); - TIM_CtrlPWMOutputs(TIM8, ENABLE); -} - /*********************************output****************************************/ /** * @brief Initializes the LCD. @@ -373,13 +316,6 @@ void LCD_Init(void) LCD_AF_GPIOConfig(); LCD_Init_LTDC(); - - // TODO split backlight from LCD - // Config backlight - LCD_Backlight_Config(); - - // Max Value - backlightEnable(100); } BitmapBuffer lcdBuffer1(BMP_RGB565, LCD_W, LCD_H, (uint16_t *)LCD_FIRST_FRAME_BUFFER); diff --git a/radio/src/targets/taranis/bluetooth_driver.cpp b/radio/src/targets/taranis/bluetooth_driver.cpp index 45be84373..446b1440d 100644 --- a/radio/src/targets/taranis/bluetooth_driver.cpp +++ b/radio/src/targets/taranis/bluetooth_driver.cpp @@ -52,28 +52,28 @@ void bluetoothInit(uint32_t baudrate) RCC_AHB1PeriphClockCmd(BT_RCC_AHB1Periph, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART6, ENABLE); - GPIO_InitStructure.GPIO_Pin = BT_GPIO_PIN_BRTS; + GPIO_InitStructure.GPIO_Pin = BT_BRTS_GPIO_PIN; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; - GPIO_Init(BT_GPIO_BRTS, &GPIO_InitStructure); - GPIO_SetBits(BT_GPIO_BRTS, BT_GPIO_PIN_BRTS); + GPIO_Init(BT_BRTS_GPIO, &GPIO_InitStructure); + GPIO_SetBits(BT_BRTS_GPIO, BT_BRTS_GPIO_PIN); - GPIO_InitStructure.GPIO_Pin = BT_GPIO_PIN_EN; - GPIO_Init(BT_GPIO_EN, &GPIO_InitStructure); + GPIO_InitStructure.GPIO_Pin = BT_EN_GPIO_PIN; + GPIO_Init(BT_EN_GPIO, &GPIO_InitStructure); - GPIO_InitStructure.GPIO_Pin = BT_GPIO_PIN_BCTS; + GPIO_InitStructure.GPIO_Pin = BT_BCTS_GPIO_PIN; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; - GPIO_Init(BT_GPIO_BCTS, &GPIO_InitStructure); + GPIO_Init(BT_BCTS_GPIO, &GPIO_InitStructure); - GPIO_InitStructure.GPIO_Pin = BT_GPIO_PIN_TX|BT_GPIO_PIN_RX; + GPIO_InitStructure.GPIO_Pin = BT_TX_GPIO_PIN|BT_RX_GPIO_PIN; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_Init(BT_GPIO_TXRX, &GPIO_InitStructure); - GPIO_PinAFConfig(BT_GPIO_TXRX, BT_GPIO_PinSource_TX, BT_GPIO_AF); - GPIO_PinAFConfig(BT_GPIO_TXRX, BT_GPIO_PinSource_RX, BT_GPIO_AF); + GPIO_PinAFConfig(BT_GPIO_TXRX, BT_TX_GPIO_PinSource, BT_GPIO_AF); + GPIO_PinAFConfig(BT_GPIO_TXRX, BT_RX_GPIO_PinSource, BT_GPIO_AF); USART_DeInit(BT_USART); USART_InitStructure.USART_BaudRate = baudrate; @@ -94,12 +94,12 @@ void bluetoothInit(uint32_t baudrate) NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); - GPIO_ResetBits(BT_GPIO_EN, BT_GPIO_PIN_EN); // open bluetooth + GPIO_ResetBits(BT_EN_GPIO, BT_EN_GPIO_PIN); // open bluetooth } void bluetoothDone() { - GPIO_SetBits(BT_GPIO_EN, BT_GPIO_PIN_EN); // close bluetooth + GPIO_SetBits(BT_EN_GPIO, BT_EN_GPIO_PIN); // close bluetooth } extern "C" void USART6_IRQHandler(void) @@ -144,7 +144,7 @@ void bluetoothWriteWakeup(void) if (bluetoothWriteState == BLUETOOTH_WRITE_IDLE) { if (!btTxFifo.isEmpty()) { bluetoothWriteState = BLUETOOTH_WRITE_INIT; - GPIO_ResetBits(BT_GPIO_BRTS, BT_GPIO_PIN_BRTS); + GPIO_ResetBits(BT_BRTS_GPIO, BT_BRTS_GPIO_PIN); } } else if (bluetoothWriteState == BLUETOOTH_WRITE_INIT) { @@ -153,7 +153,7 @@ void bluetoothWriteWakeup(void) } else if (bluetoothWriteState == BLUETOOTH_WRITE_DONE) { bluetoothWriteState = BLUETOOTH_WRITE_IDLE; - GPIO_SetBits(BT_GPIO_BRTS, BT_GPIO_PIN_BRTS); + GPIO_SetBits(BT_BRTS_GPIO, BT_BRTS_GPIO_PIN); } } diff --git a/radio/src/targets/taranis/hal.h b/radio/src/targets/taranis/hal.h index d849e8366..8180650cb 100644 --- a/radio/src/targets/taranis/hal.h +++ b/radio/src/targets/taranis/hal.h @@ -730,26 +730,26 @@ #define BT_USART_IRQn USART6_IRQn #define BT_RCC_AHB1Periph (RCC_AHB1Periph_GPIOG | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_GPIOB) #define BT_GPIO_TXRX GPIOG - #define BT_GPIO_PIN_TX GPIO_Pin_14 // PG.14 - #define BT_GPIO_PIN_RX GPIO_Pin_9 // PG.09 - #define BT_GPIO_EN GPIOD - #define BT_GPIO_PIN_EN GPIO_Pin_11 // PD.11 - #define BT_GPIO_BRTS GPIOE - #define BT_GPIO_PIN_BRTS GPIO_Pin_12 // PE.12 - #define BT_GPIO_BCTS GPIOG - #define BT_GPIO_PIN_BCTS GPIO_Pin_6 // PG.06 - #define BT_GPIO_PinSource_TX GPIO_PinSource14 - #define BT_GPIO_PinSource_RX GPIO_PinSource9 + #define BT_TX_GPIO_PIN GPIO_Pin_14 // PG.14 + #define BT_RX_GPIO_PIN GPIO_Pin_9 // PG.09 + #define BT_EN_GPIO GPIOD + #define BT_EN_GPIO_PIN GPIO_Pin_11 // PD.11 + #define BT_BRTS_GPIO GPIOE + #define BT_BRTS_GPIO_PIN GPIO_Pin_12 // PE.12 + #define BT_BCTS_GPIO GPIOG + #define BT_BCTS_GPIO_PIN GPIO_Pin_6 // PG.06 + #define BT_TX_GPIO_PinSource GPIO_PinSource14 + #define BT_RX_GPIO_PinSource GPIO_PinSource9 #elif defined(PCBX7D) #define BT_RCC_AHB1Periph (RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOE | RCC_AHB1Periph_DMA1) #define BT_RCC_APB1Periph RCC_APB1Periph_USART3 - #define BT_GPIO_EN GPIOE - #define BT_GPIO_PIN_EN GPIO_Pin_12 // PE.12 + #define BT_EN_GPIO GPIOE + #define BT_EN_GPIO_PIN GPIO_Pin_12 // PE.12 #define BT_GPIO GPIOB - #define BT_GPIO_PIN_TX GPIO_Pin_10 // PB.10 - #define BT_GPIO_PIN_RX GPIO_Pin_11 // PB.11 - #define BT_GPIO_PinSource_TX GPIO_PinSource10 - #define BT_GPIO_PinSource_RX GPIO_PinSource11 + #define BT_TX_GPIO_PIN GPIO_Pin_10 // PB.10 + #define BT_RX_GPIO_PIN GPIO_Pin_11 // PB.11 + #define BT_TX_GPIO_PinSource GPIO_PinSource10 + #define BT_RX_GPIO_PinSource GPIO_PinSource11 #define BT_GPIO_AF GPIO_AF_USART3 #define BT_USART USART3 #define BT_USART_IRQHandler USART3_IRQHandler