Startup / shutdown refactoring
This commit is contained in:
@@ -429,7 +429,7 @@ extern uint16_t adcValues[NUM_ANALOGS];
|
||||
|
||||
#if NUM_PWMSTICKS > 0
|
||||
#define STICKS_PWM_ENABLED() (!hardwareOptions.sticksPwmDisabled)
|
||||
void sticksPwmInit(void);
|
||||
void sticksPwmInit();
|
||||
void sticksPwmRead(uint16_t * values);
|
||||
extern volatile uint32_t pwm_interrupt_count;
|
||||
#else
|
||||
@@ -457,13 +457,13 @@ extern "C" {
|
||||
#define SOFT_PWR_CTRL
|
||||
extern uint32_t shutdownRequest; // Stores intentional shutdown to avoid reboot loop
|
||||
extern uint32_t shutdownReason; // Used for detecting unexpected reboots regardless of reason
|
||||
void pwrInit(void);
|
||||
uint32_t pwrCheck(void);
|
||||
void pwrOn(void);
|
||||
void pwrOff(void);
|
||||
void pwrResetHandler(void);
|
||||
uint32_t pwrPressed(void);
|
||||
uint32_t pwrPressedDuration(void);
|
||||
void pwrInit();
|
||||
uint32_t pwrCheck();
|
||||
void pwrOn();
|
||||
void pwrOff();
|
||||
void pwrResetHandler();
|
||||
bool pwrPressed();
|
||||
uint32_t pwrPressedDuration();
|
||||
#if defined(SIMU) || defined(NO_UNEXPECTED_SHUTDOWN)
|
||||
#define UNEXPECTED_SHUTDOWN() (false)
|
||||
#else
|
||||
@@ -471,10 +471,10 @@ uint32_t pwrPressedDuration(void);
|
||||
#endif
|
||||
|
||||
// Led driver
|
||||
void ledInit(void);
|
||||
void ledOff(void);
|
||||
void ledRed(void);
|
||||
void ledBlue(void);
|
||||
void ledInit();
|
||||
void ledOff();
|
||||
void ledRed();
|
||||
void ledBlue();
|
||||
#if defined(PCBX10)
|
||||
void ledGreen();
|
||||
#endif
|
||||
@@ -483,15 +483,15 @@ void ledBlue(void);
|
||||
#define LCD_W 480
|
||||
#define LCD_H 272
|
||||
#define LCD_DEPTH 16
|
||||
void lcdInit(void);
|
||||
void lcdRefresh(void);
|
||||
void lcdInit();
|
||||
void lcdRefresh();
|
||||
void lcdCopy(void * dest, void * src);
|
||||
void DMAFillRect(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color);
|
||||
void DMACopyBitmap(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, const uint16_t * src, uint16_t srcw, uint16_t srch, uint16_t srcx, uint16_t srcy, uint16_t w, uint16_t h);
|
||||
void DMACopyAlphaBitmap(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, const uint16_t * src, uint16_t srcw, uint16_t srch, uint16_t srcx, uint16_t srcy, uint16_t w, uint16_t h);
|
||||
void DMABitmapConvert(uint16_t * dest, const uint8_t * src, uint16_t w, uint16_t h, uint32_t format);
|
||||
void lcdStoreBackupBuffer(void);
|
||||
int lcdRestoreBackupBuffer(void);
|
||||
void lcdStoreBackupBuffer();
|
||||
int lcdRestoreBackupBuffer();
|
||||
void lcdSetContrast();
|
||||
#define lcdOff() backlightEnable(0) /* just disable the backlight */
|
||||
#define lcdSetRefVolt(...)
|
||||
|
||||
@@ -96,14 +96,14 @@ void pwrOff()
|
||||
GPIO_ResetBits(PWR_ON_GPIO, PWR_ON_GPIO_PIN);
|
||||
}
|
||||
|
||||
uint32_t pwrPressed()
|
||||
bool pwrPressed()
|
||||
{
|
||||
return GPIO_ReadInputDataBit(PWR_ON_GPIO, PWR_SWITCH_GPIO_PIN) == Bit_RESET;
|
||||
}
|
||||
|
||||
void pwrResetHandler()
|
||||
{
|
||||
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOJEN;
|
||||
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
|
||||
@@ -137,9 +137,11 @@ void pwrResetHandler()
|
||||
if (shutdownReason == DIRTY_SHUTDOWN) {
|
||||
powerupReason = DIRTY_SHUTDOWN;
|
||||
}
|
||||
#else
|
||||
if (WAS_RESET_BY_WATCHDOG_OR_SOFTWARE()) {
|
||||
#endif
|
||||
pwrOn();
|
||||
}
|
||||
#else
|
||||
if (WAS_RESET_BY_WATCHDOG_OR_SOFTWARE()) {
|
||||
pwrOn();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -458,11 +458,7 @@ uint32_t pwrCheck()
|
||||
return simu_shutdown ? e_power_off : e_power_on;
|
||||
}
|
||||
|
||||
void pwrOff()
|
||||
{
|
||||
}
|
||||
|
||||
uint32_t pwrPressed()
|
||||
bool pwrPressed()
|
||||
{
|
||||
// TODO: simulate power button
|
||||
#if defined(PWR_SWITCH_GPIO) // STM32
|
||||
@@ -478,6 +474,14 @@ void pwrInit()
|
||||
{
|
||||
}
|
||||
|
||||
void pwrOn()
|
||||
{
|
||||
}
|
||||
|
||||
void pwrOff()
|
||||
{
|
||||
}
|
||||
|
||||
void readKeysAndTrims()
|
||||
{
|
||||
uint8_t index = 0;
|
||||
|
||||
@@ -76,7 +76,7 @@ void backlightInit()
|
||||
BACKLIGHT_TIMER->CCMR2 = TIM_CCMR2_OC4M_1 | TIM_CCMR2_OC4M_2; // PWM
|
||||
BACKLIGHT_TIMER->CCER = TIM_CCER_CC4E | TIM_CCER_CC2E;
|
||||
BACKLIGHT_TIMER->CCR2 = 0;
|
||||
BACKLIGHT_TIMER->CCR4 = 100;
|
||||
BACKLIGHT_TIMER->CCR4 = 0;
|
||||
BACKLIGHT_TIMER->EGR = 0;
|
||||
BACKLIGHT_TIMER->CR1 = TIM_CR1_CEN; // Counter enable
|
||||
}
|
||||
|
||||
@@ -41,21 +41,6 @@ void watchdogInit(unsigned int duration)
|
||||
IWDG->KR = 0xCCCC; // start
|
||||
}
|
||||
|
||||
#if defined(PWR_BUTTON_PRESS)
|
||||
#define PWR_PRESS_DURATION_MIN 100 // 1s
|
||||
#define PWR_PRESS_DURATION_MAX 500 // 5s
|
||||
|
||||
#if LCD_DEPTH > 1
|
||||
const unsigned char bmp_startup[] = {
|
||||
#include "startup.lbm"
|
||||
};
|
||||
|
||||
const unsigned char bmp_lock[] = {
|
||||
#include "lock.lbm"
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(SPORT_UPDATE_PWR_GPIO)
|
||||
void sportUpdateInit()
|
||||
{
|
||||
@@ -189,63 +174,6 @@ void boardInit()
|
||||
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
|
||||
|
||||
#if defined(PWR_BUTTON_PRESS)
|
||||
if (!WAS_RESET_BY_WATCHDOG_OR_SOFTWARE()) {
|
||||
lcdClear();
|
||||
#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);
|
||||
#endif
|
||||
lcdRefresh();
|
||||
lcdRefreshWait();
|
||||
|
||||
tmr10ms_t start = get_tmr10ms();
|
||||
tmr10ms_t duration = 0;
|
||||
uint8_t pwr_on = 0;
|
||||
while (pwrPressed()) {
|
||||
duration = get_tmr10ms() - start;
|
||||
if (duration < PWR_PRESS_DURATION_MIN) {
|
||||
unsigned index = duration / (PWR_PRESS_DURATION_MIN / 4);
|
||||
lcdClear();
|
||||
#if LCD_DEPTH > 1
|
||||
lcdDrawBitmap(76, 2, bmp_startup, index*60, 60);
|
||||
#else
|
||||
for(uint8_t i = 0; i < 4; i++) {
|
||||
if (index >= i) {
|
||||
lcdDrawFilledRect(LCD_W / 2 - 18 + 10 * i, LCD_H / 2 - 3, 6, 6, SOLID, 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (duration >= PWR_PRESS_DURATION_MAX) {
|
||||
drawSleepBitmap();
|
||||
backlightDisable();
|
||||
}
|
||||
else {
|
||||
if (pwr_on != 1) {
|
||||
pwr_on = 1;
|
||||
pwrOn();
|
||||
backlightInit();
|
||||
haptic.play(15, 3, PLAY_NOW);
|
||||
}
|
||||
}
|
||||
lcdRefresh();
|
||||
lcdRefreshWait();
|
||||
}
|
||||
if (duration < PWR_PRESS_DURATION_MIN || duration >= PWR_PRESS_DURATION_MAX) {
|
||||
boardOff();
|
||||
}
|
||||
}
|
||||
else {
|
||||
pwrOn();
|
||||
backlightInit();
|
||||
}
|
||||
#else // defined(PWR_BUTTON_PRESS)
|
||||
pwrOn();
|
||||
backlightInit();
|
||||
#endif
|
||||
|
||||
#if defined(TOPLCD_GPIO)
|
||||
toplcdInit();
|
||||
#endif
|
||||
@@ -266,6 +194,12 @@ void boardInit()
|
||||
#if defined(GYRO)
|
||||
gyroInit();
|
||||
#endif
|
||||
|
||||
#if defined(RTCLOCK) && !defined(COPROCESSOR)
|
||||
rtcInit(); // RTC must be initialized before rambackupRestore() is called
|
||||
#endif
|
||||
|
||||
backlightInit();
|
||||
}
|
||||
|
||||
void boardOff()
|
||||
|
||||
@@ -30,8 +30,8 @@
|
||||
|
||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||
// Rotary Encoder driver
|
||||
void rotaryEncoderInit(void);
|
||||
void rotaryEncoderCheck(void);
|
||||
void rotaryEncoderInit();
|
||||
void rotaryEncoderCheck();
|
||||
#endif
|
||||
|
||||
#define FLASHSIZE 0x80000
|
||||
@@ -54,8 +54,8 @@ void rotaryEncoderCheck(void);
|
||||
extern uint16_t sessionTimer;
|
||||
|
||||
// Board driver
|
||||
void boardInit(void);
|
||||
void boardOff(void);
|
||||
void boardInit();
|
||||
void boardOff();
|
||||
|
||||
// Timers driver
|
||||
void init2MhzTimer();
|
||||
@@ -64,8 +64,8 @@ void init5msTimer();
|
||||
// SD driver
|
||||
#define BLOCK_SIZE 512 /* Block Size in Bytes */
|
||||
#if !defined(SIMU) || defined(SIMU_DISKIO)
|
||||
uint32_t sdIsHC(void);
|
||||
uint32_t sdGetSpeed(void);
|
||||
uint32_t sdIsHC();
|
||||
uint32_t sdGetSpeed();
|
||||
#define SD_IS_HC() (sdIsHC())
|
||||
#define SD_GET_SPEED() (sdGetSpeed())
|
||||
#define SD_GET_FREE_BLOCKNR() (sdGetFreeSectors())
|
||||
@@ -83,18 +83,18 @@ uint32_t sdGetSpeed(void);
|
||||
#define sdMount()
|
||||
#define SD_CARD_PRESENT() true
|
||||
#else
|
||||
void sdInit(void);
|
||||
void sdMount(void);
|
||||
void sdDone(void);
|
||||
void sdPoll10ms(void);
|
||||
uint32_t sdMounted(void);
|
||||
void sdInit();
|
||||
void sdMount();
|
||||
void sdDone();
|
||||
void sdPoll10ms();
|
||||
uint32_t sdMounted();
|
||||
#define SD_CARD_PRESENT() ((SD_GPIO_PRESENT_GPIO->IDR & SD_GPIO_PRESENT_GPIO_PIN) == 0)
|
||||
#endif
|
||||
|
||||
// Flash Write driver
|
||||
#define FLASH_PAGESIZE 256
|
||||
void unlockFlash(void);
|
||||
void lockFlash(void);
|
||||
void unlockFlash();
|
||||
void lockFlash();
|
||||
void flashWrite(uint32_t * address, uint32_t * buffer);
|
||||
uint32_t isFirmwareStart(const uint8_t * buffer);
|
||||
uint32_t isBootloaderStart(const uint8_t * buffer);
|
||||
@@ -603,15 +603,16 @@ extern "C" {
|
||||
|
||||
// Power driver
|
||||
#define SOFT_PWR_CTRL
|
||||
void pwrInit(void);
|
||||
uint32_t pwrCheck(void);
|
||||
void pwrOn(void);
|
||||
void pwrOff(void);
|
||||
uint32_t pwrPressed(void);
|
||||
void pwrInit();
|
||||
uint32_t pwrCheck();
|
||||
void pwrOn();
|
||||
void pwrOff();
|
||||
bool pwrPressed();
|
||||
#if defined(PWR_BUTTON_PRESS)
|
||||
uint32_t pwrPressedDuration(void);
|
||||
#define STARTUP_ANIMATION
|
||||
uint32_t pwrPressedDuration();
|
||||
#endif
|
||||
void pwrResetHandler(void);
|
||||
void pwrResetHandler();
|
||||
|
||||
#if defined(SIMU)
|
||||
#define UNEXPECTED_SHUTDOWN() false
|
||||
@@ -620,10 +621,10 @@ void pwrResetHandler(void);
|
||||
#endif
|
||||
|
||||
// Backlight driver
|
||||
void backlightInit(void);
|
||||
void backlightDisable(void);
|
||||
void backlightInit();
|
||||
void backlightDisable();
|
||||
#define BACKLIGHT_DISABLE() backlightDisable()
|
||||
uint8_t isBacklightEnabled(void);
|
||||
uint8_t isBacklightEnabled();
|
||||
#if defined(PCBX9E) || defined(PCBX9DP)
|
||||
void backlightEnable(uint8_t level, uint8_t color);
|
||||
#define BACKLIGHT_ENABLE() backlightEnable(g_eeGeneral.backlightBright, g_eeGeneral.backlightColor)
|
||||
@@ -646,7 +647,7 @@ uint8_t isBacklightEnabled(void);
|
||||
// I2C driver: EEPROM + Audio Volume
|
||||
#define EEPROM_SIZE (32*1024)
|
||||
|
||||
void i2cInit(void);
|
||||
void i2cInit();
|
||||
void eepromReadBlock(uint8_t * buffer, size_t address, size_t size);
|
||||
void eepromStartWrite(uint8_t * buffer, size_t address, size_t size);
|
||||
uint8_t eepromIsTransferComplete();
|
||||
@@ -656,8 +657,8 @@ void debugPutc(const char c);
|
||||
|
||||
// Telemetry driver
|
||||
void telemetryPortInit(uint32_t baudrate, uint8_t mode);
|
||||
void telemetryPortSetDirectionInput(void);
|
||||
void telemetryPortSetDirectionOutput(void);
|
||||
void telemetryPortSetDirectionInput();
|
||||
void telemetryPortSetDirectionOutput();
|
||||
void sportSendByte(uint8_t byte);
|
||||
void sportSendByteLoop(uint8_t byte);
|
||||
void sportStopSendByteLoop();
|
||||
@@ -678,9 +679,9 @@ extern uint32_t telemetryErrors;
|
||||
|
||||
// Sport update driver
|
||||
#if defined(SPORT_UPDATE_PWR_GPIO)
|
||||
void sportUpdateInit(void);
|
||||
void sportUpdatePowerOn(void);
|
||||
void sportUpdatePowerOff(void);
|
||||
void sportUpdateInit();
|
||||
void sportUpdatePowerOn();
|
||||
void sportUpdatePowerOff();
|
||||
#define SPORT_UPDATE_POWER_ON() sportUpdatePowerOn()
|
||||
#define SPORT_UPDATE_POWER_OFF() sportUpdatePowerOff()
|
||||
#else
|
||||
@@ -690,38 +691,38 @@ void sportUpdatePowerOff(void);
|
||||
#endif
|
||||
|
||||
// Audio driver
|
||||
void audioInit(void) ;
|
||||
void audioEnd(void) ;
|
||||
void dacStart(void);
|
||||
void dacStop(void);
|
||||
void audioInit() ;
|
||||
void audioEnd() ;
|
||||
void dacStart();
|
||||
void dacStop();
|
||||
void setSampleRate(uint32_t frequency);
|
||||
#define VOLUME_LEVEL_MAX 23
|
||||
#define VOLUME_LEVEL_DEF 12
|
||||
#if !defined(SOFTWARE_VOLUME)
|
||||
void setScaledVolume(uint8_t volume);
|
||||
void setVolume(uint8_t volume);
|
||||
int32_t getVolume(void);
|
||||
int32_t getVolume();
|
||||
#endif
|
||||
#if defined(AUDIO_SPEAKER_ENABLE_GPIO)
|
||||
void initSpeakerEnable(void);
|
||||
void initSpeakerEnable();
|
||||
void enableSpeaker();
|
||||
void disableSpeaker();
|
||||
#else
|
||||
static inline void initSpeakerEnable(void) { }
|
||||
static inline void enableSpeaker(void) { }
|
||||
static inline void disableSpeaker(void) { }
|
||||
static inline void initSpeakerEnable() { }
|
||||
static inline void enableSpeaker() { }
|
||||
static inline void disableSpeaker() { }
|
||||
#endif
|
||||
#if defined(HEADPHONE_TRAINER_SWITCH_GPIO)
|
||||
void initHeadphoneTrainerSwitch(void);
|
||||
void enableHeadphone(void);
|
||||
void enableTrainer(void);
|
||||
void initHeadphoneTrainerSwitch();
|
||||
void enableHeadphone();
|
||||
void enableTrainer();
|
||||
#else
|
||||
static inline void initHeadphoneTrainerSwitch(void) { }
|
||||
static inline void enableHeadphone(void) { }
|
||||
static inline void enableTrainer(void) { }
|
||||
static inline void initHeadphoneTrainerSwitch() { }
|
||||
static inline void enableHeadphone() { }
|
||||
static inline void enableTrainer() { }
|
||||
#endif
|
||||
#if defined(JACK_DETECT_GPIO)
|
||||
void initJackDetect(void);
|
||||
void initJackDetect();
|
||||
bool isJackPlugged();
|
||||
#endif
|
||||
void audioConsumeCurrentBuffer();
|
||||
@@ -729,12 +730,12 @@ void audioConsumeCurrentBuffer();
|
||||
#define audioEnableIrq() __enable_irq()
|
||||
|
||||
// Haptic driver
|
||||
void hapticInit(void);
|
||||
void hapticOff(void);
|
||||
void hapticInit();
|
||||
void hapticOff();
|
||||
#if defined(HAPTIC_PWM)
|
||||
void hapticOn(uint32_t pwmPercent);
|
||||
#else
|
||||
void hapticOn(void);
|
||||
void hapticOn();
|
||||
#endif
|
||||
|
||||
// Second serial port driver
|
||||
@@ -745,8 +746,8 @@ extern uint8_t auxSerialMode;
|
||||
void auxSerialInit(unsigned int mode, unsigned int protocol);
|
||||
void auxSerialPutc(char c);
|
||||
#define auxSerialTelemetryInit(protocol) auxSerialInit(UART_MODE_TELEMETRY, protocol)
|
||||
void auxSerialSbusInit(void);
|
||||
void auxSerialStop(void);
|
||||
void auxSerialSbusInit();
|
||||
void auxSerialStop();
|
||||
#endif
|
||||
|
||||
// BT driver
|
||||
@@ -760,9 +761,9 @@ void auxSerialStop(void);
|
||||
#define BT_TX_FIFO_SIZE 64
|
||||
#define BT_RX_FIFO_SIZE 128
|
||||
void bluetoothInit(uint32_t baudrate, bool enable);
|
||||
void bluetoothWriteWakeup(void);
|
||||
uint8_t bluetoothIsWriting(void);
|
||||
void bluetoothDisable(void);
|
||||
void bluetoothWriteWakeup();
|
||||
uint8_t bluetoothIsWriting();
|
||||
void bluetoothDisable();
|
||||
#if defined(PCBX9LITE)
|
||||
#define IS_BLUETOOTH_CHIP_PRESENT() (false)
|
||||
#elif (defined(PCBX7) || defined(PCBXLITE)) && !defined(SIMU)
|
||||
@@ -773,11 +774,11 @@ void bluetoothDisable(void);
|
||||
#endif
|
||||
|
||||
// LED driver
|
||||
void ledInit(void);
|
||||
void ledOff(void);
|
||||
void ledRed(void);
|
||||
void ledGreen(void);
|
||||
void ledBlue(void);
|
||||
void ledInit();
|
||||
void ledOff();
|
||||
void ledRed();
|
||||
void ledGreen();
|
||||
void ledBlue();
|
||||
|
||||
// LCD driver
|
||||
#if defined(PCBX9D) || defined(PCBX9DP) || defined(PCBX9E)
|
||||
@@ -803,9 +804,9 @@ void ledBlue(void);
|
||||
#define IS_LCD_RESET_NEEDED() true
|
||||
#endif
|
||||
|
||||
void lcdInit(void);
|
||||
void lcdInitFinish(void);
|
||||
void lcdOff(void);
|
||||
void lcdInit();
|
||||
void lcdInitFinish();
|
||||
void lcdOff();
|
||||
|
||||
// TODO lcdRefreshWait() stub in simpgmspace and remove LCD_DUAL_BUFFER
|
||||
#if defined(LCD_DMA) && !defined(LCD_DUAL_BUFFER) && !defined(SIMU)
|
||||
@@ -814,19 +815,19 @@ void lcdRefreshWait();
|
||||
#define lcdRefreshWait()
|
||||
#endif
|
||||
#if defined(PCBX9D) || defined(SIMU) || !defined(__cplusplus)
|
||||
void lcdRefresh(void);
|
||||
void lcdRefresh();
|
||||
#else
|
||||
void lcdRefresh(bool wait=true); // TODO uint8_t wait to simplify this
|
||||
#endif
|
||||
void lcdSetRefVolt(unsigned char val);
|
||||
void lcdSetContrast(void);
|
||||
void lcdSetContrast();
|
||||
|
||||
// Top LCD driver
|
||||
#if defined(TOPLCD_GPIO)
|
||||
void toplcdInit(void);
|
||||
void toplcdOff(void);
|
||||
void toplcdRefreshStart(void);
|
||||
void toplcdRefreshEnd(void);
|
||||
void toplcdInit();
|
||||
void toplcdOff();
|
||||
void toplcdRefreshStart();
|
||||
void toplcdRefreshEnd();
|
||||
void setTopFirstTimer(int32_t value);
|
||||
void setTopSecondTimer(uint32_t value);
|
||||
void setTopRssi(uint32_t rssi);
|
||||
|
||||
@@ -83,14 +83,14 @@ void pwrOff()
|
||||
GPIO_ResetBits(PWR_ON_GPIO, PWR_ON_GPIO_PIN);
|
||||
}
|
||||
|
||||
uint32_t pwrPressed()
|
||||
bool pwrPressed()
|
||||
{
|
||||
return GPIO_ReadInputDataBit(PWR_SWITCH_GPIO, PWR_SWITCH_GPIO_PIN) == Bit_RESET;
|
||||
}
|
||||
|
||||
void pwrResetHandler()
|
||||
{
|
||||
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOEEN;
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user