[Taranis X9E] The radio starts if the PWR button is pressed between 2s
and 5s
This commit is contained in:
@@ -228,8 +228,6 @@ void lcd_bmp(coord_t x, coord_t y, const uint8_t * img, coord_t offset=0, coord_
|
||||
void lcdSetRefVolt(unsigned char val);
|
||||
void lcd_clear();
|
||||
void lcdSetContrast();
|
||||
void lcdInit();
|
||||
void lcdOff();
|
||||
|
||||
#if defined(REVPLUS) && !defined(SIMU)
|
||||
void lcdRefresh(bool wait=true);
|
||||
|
||||
@@ -119,6 +119,21 @@ void boardInit()
|
||||
RCC_APB2PeriphClockCmd(BACKLIGHT_RCC_APB2Periph | ADC_RCC_APB2Periph | HAPTIC_RCC_APB2Periph | INTMODULE_RCC_APB2Periph | EXTMODULE_RCC_APB2Periph | HEARTBEAT_RCC_APB2Periph, ENABLE);
|
||||
|
||||
pwrInit();
|
||||
|
||||
init5msTimer();
|
||||
__enable_irq();
|
||||
|
||||
#if defined(REV9E)
|
||||
if (!(RCC->CSR & (RCC_CSR_SFTRSTF | RCC_CSR_WDGRSTF))) {
|
||||
tmr10ms_t start = get_tmr10ms();
|
||||
while (pwrPressed());
|
||||
tmr10ms_t duration = get_tmr10ms() - start;
|
||||
if (duration < 200 || duration >= 500) {
|
||||
pwrOff();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
keysInit();
|
||||
adcInit();
|
||||
delaysInit();
|
||||
@@ -130,8 +145,6 @@ void boardInit()
|
||||
|
||||
audioInit();
|
||||
init2MhzTimer();
|
||||
init5msTimer();
|
||||
__enable_irq();
|
||||
i2cInit();
|
||||
usbInit();
|
||||
|
||||
@@ -146,6 +159,8 @@ void boardInit()
|
||||
#if defined(DEBUG)
|
||||
DBGMCU_APB1PeriphConfig(DBGMCU_IWDG_STOP|DBGMCU_TIM1_STOP|DBGMCU_TIM2_STOP|DBGMCU_TIM3_STOP|DBGMCU_TIM6_STOP|DBGMCU_TIM8_STOP|DBGMCU_TIM10_STOP|DBGMCU_TIM13_STOP|DBGMCU_TIM14_STOP, ENABLE);
|
||||
#endif
|
||||
|
||||
backlightInit();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -254,6 +254,7 @@ extern "C" {
|
||||
// Power driver
|
||||
void pwrInit(void);
|
||||
uint32_t pwrCheck(void);
|
||||
void pwrOn(void);
|
||||
void pwrOff(void);
|
||||
#if defined(REV9E)
|
||||
uint32_t pwrPressed(void);
|
||||
@@ -262,6 +263,7 @@ uint32_t pwrPressedDuration(void);
|
||||
#define UNEXPECTED_SHUTDOWN() (g_eeGeneral.unexpectedShutdown)
|
||||
|
||||
// Backlight driver
|
||||
void backlightInit(void);
|
||||
#if defined(REVPLUS)
|
||||
void turnBacklightOn(uint8_t level, uint8_t color);
|
||||
void turnBacklightOff(void);
|
||||
@@ -331,13 +333,17 @@ void uart3Stop(void);
|
||||
// BT driver
|
||||
#define BLUETOOTH_DEFAULT_BAUDRATE 115200
|
||||
#define BLUETOOTH_FACTORY_BAUDRATE 9600
|
||||
uint8_t bluetoothReady();
|
||||
uint8_t bluetoothReady(void);
|
||||
void bluetoothInit(uint32_t baudrate);
|
||||
void bluetoothWrite(const void * buffer, int len);
|
||||
void bluetoothWriteString(const char * str);
|
||||
int bluetoothRead(void * buffer, int len);
|
||||
void bluetoothWakeup(void);
|
||||
|
||||
// LCD driver
|
||||
void lcdInit(void);
|
||||
void lcdOff(void);
|
||||
|
||||
// Top LCD driver
|
||||
#if defined(REV9E)
|
||||
void topLcdInit(void);
|
||||
|
||||
@@ -413,6 +413,7 @@ int main()
|
||||
delaysInit(); //needed for lcdInit()
|
||||
#endif
|
||||
lcdInit();
|
||||
backlightInit();
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
extern uint8_t OptrexDisplay;
|
||||
|
||||
@@ -251,8 +251,7 @@ void lcdRefresh()
|
||||
}
|
||||
#endif
|
||||
|
||||
/**Init the Backlight GPIO */
|
||||
static void LCD_BL_Config()
|
||||
void backlightInit()
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
@@ -362,7 +361,6 @@ void lcdOff()
|
||||
*/
|
||||
void lcdInit()
|
||||
{
|
||||
LCD_BL_Config();
|
||||
LCD_Hardware_Init();
|
||||
|
||||
if (WAS_RESET_BY_WATCHDOG()|WAS_RESET_BY_SOFTWARE()) return; //no need to reset LCD module
|
||||
|
||||
@@ -72,17 +72,18 @@ void pwrInit()
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
||||
GPIO_Init(TRAINER_GPIO_DETECT, &GPIO_InitStructure);
|
||||
|
||||
// Soft power ON
|
||||
GPIO_SetBits(PWR_GPIO, PWR_GPIO_PIN_ON);
|
||||
pwrOn();
|
||||
}
|
||||
|
||||
#if defined(REV9E)
|
||||
while (pwrPressed()) ;
|
||||
#endif
|
||||
void pwrOn()
|
||||
{
|
||||
GPIO_SetBits(PWR_GPIO, PWR_GPIO_PIN_ON);
|
||||
}
|
||||
|
||||
void pwrOff()
|
||||
{
|
||||
GPIO_ResetBits(PWR_GPIO, PWR_GPIO_PIN_ON);
|
||||
|
||||
#if defined(REV9E)
|
||||
// 9E needs watchdog reset because CPU is still running while the power
|
||||
// key is held pressed by the user
|
||||
@@ -107,8 +108,11 @@ uint32_t pwrPressed()
|
||||
{
|
||||
return GPIO_ReadInputDataBit(PWR_GPIO, PWR_GPIO_PIN_SWITCH) == Bit_RESET;
|
||||
}
|
||||
#if !defined(BOOT)
|
||||
#endif
|
||||
|
||||
#if defined(REV9E) && !defined(BOOT)
|
||||
uint32_t pwrPressTime = 0;
|
||||
|
||||
uint32_t pwrPressedDuration()
|
||||
{
|
||||
if (pwrPressTime == 0) {
|
||||
@@ -118,6 +122,7 @@ uint32_t pwrPressedDuration()
|
||||
return get_tmr10ms() - pwrPressTime;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t pwrCheck()
|
||||
{
|
||||
if (pwrPressed()) {
|
||||
@@ -136,7 +141,8 @@ uint32_t pwrCheck()
|
||||
return e_power_on;
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
|
||||
#if !defined(REV9E)
|
||||
uint32_t pwrCheck()
|
||||
{
|
||||
#if defined(SIMU)
|
||||
|
||||
Reference in New Issue
Block a user