mirror of
https://github.com/opentx/opentx.git
synced 2025-07-13 11:29:51 +03:00
parent
1efd3cbefa
commit
821865f70e
6 changed files with 32 additions and 36 deletions
|
@ -228,6 +228,7 @@ int main()
|
|||
#endif
|
||||
|
||||
pwrInit();
|
||||
pwrOn();
|
||||
delaysInit(); // needed for lcdInit()
|
||||
|
||||
#if defined(DEBUG)
|
||||
|
|
|
@ -279,9 +279,10 @@
|
|||
|
||||
// Power
|
||||
#define PWR_RCC_AHB1Periph RCC_AHB1Periph_GPIOJ
|
||||
#define PWR_GPIO GPIOJ
|
||||
#define PWR_SWITCH_GPIO_PIN GPIO_Pin_0 // PJ.00
|
||||
#define PWR_ON_GPIO GPIOJ
|
||||
#define PWR_ON_GPIO_PIN GPIO_Pin_1 // PJ.01
|
||||
#define PWR_SWITCH_GPIO GPIOJ
|
||||
#define PWR_SWITCH_GPIO_PIN GPIO_Pin_0 // PJ.00
|
||||
|
||||
// S.Port update connector
|
||||
#define SPORT_MAX_BAUDRATE 250000 // < 400000
|
||||
|
|
|
@ -28,37 +28,40 @@ uint32_t powerupReason __NOINIT; // Stores power up reason beyond initializati
|
|||
void pwrInit()
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
// Init Module PWR
|
||||
|
||||
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);
|
||||
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
||||
|
||||
// Init PWR SWITCH PIN
|
||||
// PWR SWITCH
|
||||
GPIO_InitStructure.GPIO_Pin = PWR_SWITCH_GPIO_PIN;
|
||||
GPIO_Init(PWR_GPIO, &GPIO_InitStructure);
|
||||
GPIO_Init(PWR_SWITCH_GPIO, &GPIO_InitStructure);
|
||||
|
||||
// Init PCBREV PIN
|
||||
// PCBREV
|
||||
// TODO to be removed on X10?
|
||||
GPIO_ResetBits(PCBREV_GPIO, PCBREV_GPIO_PIN);
|
||||
GPIO_InitStructure.GPIO_Pin = PCBREV_GPIO_PIN;
|
||||
GPIO_Init(PCBREV_GPIO, &GPIO_InitStructure);
|
||||
|
||||
// Init SD-DETECT PIN
|
||||
// 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);
|
||||
|
||||
// Init TRAINER DETECT PIN
|
||||
// TRAINER DETECT PIN
|
||||
GPIO_InitStructure.GPIO_Pin = TRAINER_DETECT_GPIO_PIN;
|
||||
GPIO_Init(TRAINER_DETECT_GPIO, &GPIO_InitStructure);
|
||||
|
||||
|
@ -73,9 +76,9 @@ void pwrOn()
|
|||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
|
||||
GPIO_Init(PWR_GPIO, &GPIO_InitStructure);
|
||||
GPIO_Init(PWR_ON_GPIO, &GPIO_InitStructure);
|
||||
|
||||
GPIO_SetBits(PWR_GPIO, PWR_ON_GPIO_PIN);
|
||||
GPIO_SetBits(PWR_ON_GPIO, PWR_ON_GPIO_PIN);
|
||||
|
||||
shutdownRequest = NO_SHUTDOWN_REQUEST;
|
||||
shutdownReason = DIRTY_SHUTDOWN;
|
||||
|
@ -100,12 +103,12 @@ void pwrOff()
|
|||
|
||||
shutdownRequest = SHUTDOWN_REQUEST;
|
||||
shutdownReason = NORMAL_POWER_OFF;
|
||||
GPIO_ResetBits(PWR_GPIO, PWR_ON_GPIO_PIN);
|
||||
GPIO_ResetBits(PWR_ON_GPIO, PWR_ON_GPIO_PIN);
|
||||
}
|
||||
|
||||
uint32_t pwrPressed()
|
||||
{
|
||||
return GPIO_ReadInputDataBit(PWR_GPIO, PWR_SWITCH_GPIO_PIN) == Bit_RESET;
|
||||
return GPIO_ReadInputDataBit(PWR_ON_GPIO, PWR_SWITCH_GPIO_PIN) == Bit_RESET;
|
||||
}
|
||||
|
||||
void pwrResetHandler()
|
||||
|
|
|
@ -192,10 +192,7 @@ void boardInit()
|
|||
bluetoothInit(BLUETOOTH_DEFAULT_BAUDRATE, true);
|
||||
#endif
|
||||
|
||||
#if !defined(PCBX9E)
|
||||
// some X9E boards need that the pwrInit() is moved a little bit later
|
||||
pwrInit();
|
||||
#endif
|
||||
|
||||
#if defined(STATUS_LEDS)
|
||||
ledInit();
|
||||
|
@ -247,7 +244,7 @@ void boardInit()
|
|||
#if defined(PWR_BUTTON_PRESS)
|
||||
if (!WAS_RESET_BY_WATCHDOG_OR_SOFTWARE()) {
|
||||
lcdClear();
|
||||
#if defined(PCBX9E)
|
||||
#if LCD_DEPTH > 1
|
||||
lcdDrawBitmap(76, 2, bmp_lock, 0, 60);
|
||||
#else
|
||||
lcdDrawFilledRect(LCD_W / 2 - 18, LCD_H / 2 - 3, 6, 6, SOLID, 0);
|
||||
|
@ -263,7 +260,7 @@ void boardInit()
|
|||
if (duration < PWR_PRESS_DURATION_MIN) {
|
||||
unsigned index = duration / (PWR_PRESS_DURATION_MIN / 4);
|
||||
lcdClear();
|
||||
#if defined(PCBX9E)
|
||||
#if LCD_DEPTH > 1
|
||||
lcdDrawBitmap(76, 2, bmp_startup, index*60, 60);
|
||||
#else
|
||||
for(uint8_t i= 0; i < 4; i++) {
|
||||
|
@ -280,7 +277,7 @@ void boardInit()
|
|||
else {
|
||||
if (pwr_on != 1) {
|
||||
pwr_on = 1;
|
||||
pwrInit();
|
||||
pwrOn();
|
||||
backlightInit();
|
||||
haptic.play(15, 3, PLAY_NOW);
|
||||
}
|
||||
|
@ -293,15 +290,17 @@ void boardInit()
|
|||
}
|
||||
}
|
||||
else {
|
||||
pwrInit();
|
||||
pwrOn();
|
||||
backlightInit();
|
||||
}
|
||||
#else // defined(PWR_BUTTON_PRESS)
|
||||
pwrOn();
|
||||
backlightInit();
|
||||
#endif
|
||||
|
||||
#if defined(TOPLCD_GPIO)
|
||||
toplcdInit();
|
||||
#endif
|
||||
#else // defined(PWR_BUTTON_PRESS)
|
||||
backlightInit();
|
||||
#endif
|
||||
|
||||
if (HAS_SPORT_UPDATE_CONNECTOR()) {
|
||||
sportUpdateInit();
|
||||
|
|
|
@ -22,14 +22,18 @@
|
|||
|
||||
void boardPreInit()
|
||||
{
|
||||
#if defined(INTMODULE_BOOTCMD_GPIO)
|
||||
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 kept OFF
|
||||
GPIO_ResetBits(PWR_ON_GPIO, PWR_ON_GPIO_PIN);
|
||||
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);
|
||||
GPIO_InitStructure.GPIO_Pin = INTMODULE_BOOTCMD_GPIO_PIN;
|
||||
GPIO_Init(INTMODULE_BOOTCMD_GPIO, &GPIO_InitStructure);
|
||||
|
|
|
@ -23,12 +23,11 @@
|
|||
void pwrInit()
|
||||
{
|
||||
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_ResetBits(INTMODULE_PWR_GPIO, INTMODULE_PWR_GPIO_PIN);
|
||||
GPIO_InitStructure.GPIO_Pin = INTMODULE_PWR_GPIO_PIN;
|
||||
GPIO_Init(INTMODULE_PWR_GPIO, &GPIO_InitStructure);
|
||||
|
@ -58,21 +57,10 @@ void pwrInit()
|
|||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
|
||||
GPIO_Init(PCBREV_GPIO, &GPIO_InitStructure);
|
||||
#endif
|
||||
|
||||
pwrOn();
|
||||
}
|
||||
|
||||
void pwrOn()
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue