@@ -75,7 +75,7 @@ set(BOOTLOADER_SRC
|
||||
../../../../../targets/${TARGET_DIR}/keys_driver.cpp
|
||||
../../../../../targets/${TARGET_DIR}/diskio.cpp
|
||||
../../../../../targets/${TARGET_DIR}/board.cpp
|
||||
../../../../../targets/${TARGET_DIR}/pwr_driver.cpp
|
||||
../pwr_driver.cpp
|
||||
../../../../../targets/${TARGET_DIR}/bootloader/boot_menu.cpp
|
||||
../usbd_usr.cpp
|
||||
../usbd_storage_msd.cpp
|
||||
|
||||
+18
-12
@@ -23,17 +23,14 @@
|
||||
void pwrInit()
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
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_UP;
|
||||
|
||||
// Board PWR
|
||||
GPIO_InitStructure.GPIO_Pin = PWR_ON_GPIO_PIN;
|
||||
GPIO_Init(PWR_ON_GPIO, &GPIO_InitStructure);
|
||||
|
||||
#if defined(INTMODULE_BOOTCMD_GPIO)
|
||||
GPIO_SetBits(INTMODULE_BOOTCMD_GPIO, INTMODULE_BOOTCMD_GPIO_PIN);
|
||||
INIT_INTMODULE_BOOTCMD_PIN();
|
||||
GPIO_InitStructure.GPIO_Pin = INTMODULE_BOOTCMD_GPIO_PIN;
|
||||
GPIO_Init(INTMODULE_BOOTCMD_GPIO, &GPIO_InitStructure);
|
||||
#endif
|
||||
@@ -54,23 +51,32 @@ void pwrInit()
|
||||
GPIO_InitStructure.GPIO_Pin = PWR_SWITCH_GPIO_PIN;
|
||||
GPIO_Init(PWR_SWITCH_GPIO, &GPIO_InitStructure);
|
||||
|
||||
#if defined(PCBREV_HARDCODED)
|
||||
hardwareOptions.pcbrev = PCBREV_HARDCODED;
|
||||
#elif defined(PCBREV_GPIO_PIN)
|
||||
GPIO_ResetBits(PCBREV_GPIO, PCBREV_GPIO_PIN);
|
||||
GPIO_InitStructure.GPIO_Pin = PCBREV_GPIO_PIN;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
|
||||
GPIO_Init(PCBREV_GPIO, &GPIO_InitStructure);
|
||||
hardwareOptions.pcbrev = PCBREV_VALUE();
|
||||
#endif
|
||||
|
||||
#if defined(TRAINER_DETECT_GPIO_PIN)
|
||||
GPIO_InitStructure.GPIO_Pin = TRAINER_DETECT_GPIO_PIN;
|
||||
GPIO_Init(TRAINER_DETECT_GPIO, &GPIO_InitStructure);
|
||||
#endif
|
||||
|
||||
#if defined(SD_PRESENT_GPIO_PIN)
|
||||
GPIO_ResetBits(SD_PRESENT_GPIO, SD_PRESENT_GPIO_PIN);
|
||||
GPIO_InitStructure.GPIO_Pin = SD_PRESENT_GPIO_PIN;
|
||||
GPIO_Init(SD_PRESENT_GPIO, &GPIO_InitStructure);
|
||||
#endif
|
||||
|
||||
#if defined(INTMODULE_USART) && defined(TRAINER_MODULE_CPPM_GPIO_PIN)
|
||||
GPIO_SetBits(TRAINER_MODULE_CPPM_GPIO, TRAINER_MODULE_CPPM_GPIO_PIN);
|
||||
GPIO_InitStructure.GPIO_Pin = TRAINER_MODULE_CPPM_GPIO_PIN;
|
||||
GPIO_Init(TRAINER_MODULE_CPPM_GPIO, &GPIO_InitStructure);
|
||||
#endif
|
||||
|
||||
#if defined(PCBREV_GPIO_PIN)
|
||||
GPIO_ResetBits(PCBREV_GPIO, PCBREV_GPIO_PIN);
|
||||
GPIO_InitStructure.GPIO_Pin = PCBREV_GPIO_PIN;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
|
||||
GPIO_Init(PCBREV_GPIO, &GPIO_InitStructure);
|
||||
#endif
|
||||
}
|
||||
|
||||
void pwrOn()
|
||||
@@ -207,7 +207,7 @@ set(FIRMWARE_TARGET_SRC
|
||||
${LCD_DRIVER}
|
||||
board.cpp
|
||||
backlight_driver.cpp
|
||||
pwr_driver.cpp
|
||||
../common/arm/stm32/pwr_driver.cpp
|
||||
sdram_driver.c
|
||||
startup_stm32f42_43xxx.s
|
||||
../common/arm/stm32/sdio_sd.c
|
||||
|
||||
@@ -616,6 +616,7 @@
|
||||
#define INTMODULE_BOOTCMD_GPIO GPIOI
|
||||
#define INTMODULE_BOOTCMD_GPIO_PIN GPIO_Pin_9 // PI.09
|
||||
#endif
|
||||
#define INIT_INTMODULE_BOOTCMD_PIN() GPIO_ResetBits(INTMODULE_BOOTCMD_GPIO, INTMODULE_BOOTCMD_GPIO_PIN);
|
||||
#if defined(PCBX10) || PCBREV >= 13
|
||||
#define INTMODULE_RCC_APB1Periph RCC_APB1Periph_TIM2
|
||||
#define INTMODULE_RCC_APB2Periph RCC_APB2Periph_USART1
|
||||
@@ -635,6 +636,7 @@
|
||||
// External Module
|
||||
#define EXTMODULE_PWR_GPIO GPIOB
|
||||
#define EXTMODULE_PWR_GPIO_PIN GPIO_Pin_3 // PB.03
|
||||
#define EXTERNAL_MODULE_PWR_OFF() GPIO_ResetBits(EXTMODULE_PWR_GPIO, EXTMODULE_PWR_GPIO_PIN)
|
||||
#if defined(PCBX10) && defined(PCBREV_EXPRESS)
|
||||
#define EXTMODULE_RCC_AHB1Periph (RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_DMA1)
|
||||
#define EXTMODULE_RCC_APB1Periph (RCC_APB1Periph_TIM2 | RCC_APB1Periph_USART3)
|
||||
|
||||
@@ -1,109 +0,0 @@
|
||||
/*
|
||||
* 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 "board.h"
|
||||
#include "storage/rtc_backup.h"
|
||||
|
||||
void pwrInit()
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
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_UP;
|
||||
|
||||
// Internal module PWR
|
||||
GPIO_ResetBits(INTMODULE_PWR_GPIO, INTMODULE_PWR_GPIO_PIN);
|
||||
GPIO_InitStructure.GPIO_Pin = INTMODULE_PWR_GPIO_PIN;
|
||||
GPIO_Init(INTMODULE_PWR_GPIO, &GPIO_InitStructure);
|
||||
|
||||
// External module PWR
|
||||
GPIO_ResetBits(EXTMODULE_PWR_GPIO, EXTMODULE_PWR_GPIO_PIN);
|
||||
GPIO_InitStructure.GPIO_Pin = EXTMODULE_PWR_GPIO_PIN;
|
||||
GPIO_Init(EXTMODULE_PWR_GPIO, &GPIO_InitStructure);
|
||||
|
||||
#if defined(INTMODULE_BOOTCMD_GPIO)
|
||||
GPIO_ResetBits(INTMODULE_BOOTCMD_GPIO, INTMODULE_BOOTCMD_GPIO_PIN);
|
||||
GPIO_InitStructure.GPIO_Pin = INTMODULE_BOOTCMD_GPIO_PIN;
|
||||
GPIO_Init(INTMODULE_BOOTCMD_GPIO, &GPIO_InitStructure);
|
||||
#endif
|
||||
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
||||
|
||||
// PWR SWITCH
|
||||
GPIO_InitStructure.GPIO_Pin = PWR_SWITCH_GPIO_PIN;
|
||||
GPIO_Init(PWR_SWITCH_GPIO, &GPIO_InitStructure);
|
||||
|
||||
#if defined(PCBREV_GPIO_PIN)
|
||||
// PCBREV
|
||||
GPIO_InitStructure.GPIO_Pin = PCBREV_GPIO_PIN;
|
||||
GPIO_Init(PCBREV_GPIO, &GPIO_InitStructure);
|
||||
hardwareOptions.pcbrev = PCBREV_VALUE();
|
||||
#endif
|
||||
|
||||
// SD-DETECT PIN
|
||||
GPIO_ResetBits(SD_PRESENT_GPIO, SD_PRESENT_GPIO_PIN);
|
||||
GPIO_InitStructure.GPIO_Pin = SD_PRESENT_GPIO_PIN;
|
||||
GPIO_Init(SD_PRESENT_GPIO, &GPIO_InitStructure);
|
||||
|
||||
// TRAINER DETECT PIN
|
||||
GPIO_InitStructure.GPIO_Pin = TRAINER_DETECT_GPIO_PIN;
|
||||
GPIO_Init(TRAINER_DETECT_GPIO, &GPIO_InitStructure);
|
||||
}
|
||||
|
||||
void pwrOn()
|
||||
{
|
||||
// we keep the init of the PIN to have pwrOn as quick as possible
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
GPIO_InitStructure.GPIO_Pin = PWR_ON_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_UP;
|
||||
GPIO_Init(PWR_ON_GPIO, &GPIO_InitStructure);
|
||||
|
||||
GPIO_SetBits(PWR_ON_GPIO, PWR_ON_GPIO_PIN);
|
||||
}
|
||||
|
||||
void pwrOff()
|
||||
{
|
||||
GPIO_ResetBits(PWR_ON_GPIO, PWR_ON_GPIO_PIN);
|
||||
}
|
||||
|
||||
bool pwrPressed()
|
||||
{
|
||||
return GPIO_ReadInputDataBit(PWR_ON_GPIO, PWR_SWITCH_GPIO_PIN) == Bit_RESET;
|
||||
}
|
||||
|
||||
void pwrResetHandler()
|
||||
{
|
||||
RCC->AHB1ENR |= PWR_RCC_AHB1Periph;
|
||||
|
||||
// these two NOPs are needed (see STM32F errata sheet) before the peripheral
|
||||
// register can be written after the peripheral clock was enabled
|
||||
__ASM volatile ("nop");
|
||||
__ASM volatile ("nop");
|
||||
|
||||
if (WAS_RESET_BY_WATCHDOG_OR_SOFTWARE()) {
|
||||
pwrOn();
|
||||
}
|
||||
}
|
||||
@@ -160,6 +160,14 @@ elseif(PCB STREQUAL X7)
|
||||
set(BLUETOOTH YES)
|
||||
add_definitions(-DBLUETOOTH_PROBE)
|
||||
set(ROTARY_ENCODER YES)
|
||||
if(DEFINED PCBREV_HARDCODED)
|
||||
# This *can* be used to prevent messing with PA14 (SWCLK), so stlink can be used
|
||||
# without interruptions.
|
||||
if(NOT ${PCBREV_HARDCODED} MATCHES "^[0-1]$")
|
||||
message(FATAL_ERROR "PCBREV_HARDCODED must be 0 or 1, not '${PCBREV_HARDCODED}'")
|
||||
endif()
|
||||
add_definitions(-DPCBREV_HARDCODED=${PCBREV_HARDCODED})
|
||||
endif()
|
||||
endif()
|
||||
elseif(PCB STREQUAL X9LITE)
|
||||
option(INTERNAL_MODULE_PXX1 "Support for PXX1 internal module" OFF)
|
||||
@@ -379,7 +387,7 @@ set(FIRMWARE_TARGET_SRC
|
||||
${LCD_DRIVER}
|
||||
board.cpp
|
||||
i2c_driver.cpp
|
||||
pwr_driver.cpp
|
||||
../common/arm/stm32/pwr_driver.cpp
|
||||
../common/arm/loadboot.cpp
|
||||
)
|
||||
|
||||
|
||||
@@ -61,6 +61,13 @@ void boardOff();
|
||||
void init2MhzTimer();
|
||||
void init5msTimer();
|
||||
|
||||
// PCBREV driver
|
||||
enum {
|
||||
// X7
|
||||
PCBREV_X7_STD = 0,
|
||||
PCBREV_X7_40 = 1,
|
||||
};
|
||||
|
||||
// SD driver
|
||||
#define BLOCK_SIZE 512 /* Block Size in Bytes */
|
||||
#if !defined(SIMU) || defined(SIMU_DISKIO)
|
||||
@@ -545,16 +552,11 @@ enum Analogs {
|
||||
#define STICKS_PWM_ENABLED() false
|
||||
#endif
|
||||
|
||||
#if NUM_PWMSTICKS > 0
|
||||
PACK(typedef struct {
|
||||
uint8_t pcbrev:2;
|
||||
uint8_t sticksPwmDisabled:1;
|
||||
uint8_t pxx2Enabled:1;
|
||||
}) HardwareOptions;
|
||||
#else
|
||||
PACK(typedef struct {
|
||||
uint8_t pxx2Enabled:1;
|
||||
}) HardwareOptions;
|
||||
#endif
|
||||
|
||||
extern HardwareOptions hardwareOptions;
|
||||
|
||||
@@ -705,7 +707,7 @@ void telemetryPortInvertedInit(uint32_t baudrate);
|
||||
#if defined(PCBX7ACCESS)
|
||||
#define HAS_SPORT_UPDATE_CONNECTOR() true
|
||||
#elif defined(PCBX7)
|
||||
#define IS_PCBREV_40() (GPIO_ReadInputDataBit(PCBREV_GPIO, PCBREV_GPIO_PIN) == Bit_SET)
|
||||
#define IS_PCBREV_40() (hardwareOptions.pcbrev == PCBREV_X7_40)
|
||||
#define HAS_SPORT_UPDATE_CONNECTOR() IS_PCBREV_40()
|
||||
#elif defined(SPORT_UPDATE_PWR_GPIO)
|
||||
#define HAS_SPORT_UPDATE_CONNECTOR() true
|
||||
|
||||
@@ -986,23 +986,24 @@
|
||||
#define INTMODULE_PWR_GPIO GPIOD
|
||||
#define INTMODULE_PWR_GPIO_PIN GPIO_Pin_9 // PD.09
|
||||
#endif
|
||||
#define INTMODULE_GPIO GPIOB
|
||||
#define INTMODULE_TX_GPIO_PIN GPIO_Pin_6 // PB.06
|
||||
#define INTMODULE_RX_GPIO_PIN GPIO_Pin_7 // PB.07
|
||||
#define INTMODULE_GPIO_PinSource_TX GPIO_PinSource6
|
||||
#define INTMODULE_GPIO_PinSource_RX GPIO_PinSource7
|
||||
#define INTMODULE_USART USART1
|
||||
#define INTMODULE_GPIO_AF GPIO_AF_USART1
|
||||
#define INTMODULE_USART_IRQHandler USART1_IRQHandler
|
||||
#define INTMODULE_USART_IRQn USART1_IRQn
|
||||
#define INTMODULE_DMA_STREAM DMA2_Stream7
|
||||
#define INTMODULE_GPIO GPIOB
|
||||
#define INTMODULE_TX_GPIO_PIN GPIO_Pin_6 // PB.06
|
||||
#define INTMODULE_RX_GPIO_PIN GPIO_Pin_7 // PB.07
|
||||
#define INTMODULE_GPIO_PinSource_TX GPIO_PinSource6
|
||||
#define INTMODULE_GPIO_PinSource_RX GPIO_PinSource7
|
||||
#define INTMODULE_USART USART1
|
||||
#define INTMODULE_GPIO_AF GPIO_AF_USART1
|
||||
#define INTMODULE_USART_IRQHandler USART1_IRQHandler
|
||||
#define INTMODULE_USART_IRQn USART1_IRQn
|
||||
#define INTMODULE_DMA_STREAM DMA2_Stream7
|
||||
#define INTMODULE_DMA_STREAM_IRQ DMA2_Stream7_IRQn
|
||||
#define INTMODULE_DMA_STREAM_IRQHandler DMA2_Stream7_IRQHandler
|
||||
#define INTMODULE_DMA_FLAG_TC DMA_IT_TCIF7
|
||||
#define INTMODULE_DMA_CHANNEL DMA_Channel_4
|
||||
#define INTMODULE_DMA_FLAG_TC DMA_IT_TCIF7
|
||||
#define INTMODULE_DMA_CHANNEL DMA_Channel_4
|
||||
#if defined(PCBXLITES)
|
||||
#define INTMODULE_BOOTCMD_GPIO GPIOC
|
||||
#define INTMODULE_BOOTCMD_GPIO_PIN GPIO_Pin_8 // PC.08
|
||||
#define INTMODULE_BOOTCMD_GPIO GPIOC
|
||||
#define INTMODULE_BOOTCMD_GPIO_PIN GPIO_Pin_8 // PC.08
|
||||
#define INIT_INTMODULE_BOOTCMD_PIN() GPIO_SetBits(INTMODULE_BOOTCMD_GPIO, INTMODULE_BOOTCMD_GPIO_PIN);
|
||||
#endif
|
||||
#elif defined(RADIO_X9DP2019)
|
||||
#define INTMODULE_RCC_APB1Periph 0
|
||||
@@ -1374,6 +1375,7 @@
|
||||
#define PCBREV_RCC_AHB1Periph RCC_AHB1Periph_GPIOA
|
||||
#define PCBREV_GPIO GPIOA
|
||||
#define PCBREV_GPIO_PIN GPIO_Pin_14 // PA.14
|
||||
#define PCBREV_VALUE() GPIO_ReadInputDataBit(PCBREV_GPIO, PCBREV_GPIO_PIN)
|
||||
#else
|
||||
#define PCBREV_RCC_AHB1Periph 0
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user