mirror of
https://github.com/Rockbox/rockbox.git
synced 2026-10-10 08:03:04 -04:00
echoplayer: detect boot reason during system_init
Change-Id: I6fdc16e7476044b43e11d3f63d971bd8de860c58
This commit is contained in:
parent
86c975ee88
commit
025d641d1f
3 changed files with 43 additions and 0 deletions
|
|
@ -254,6 +254,20 @@ RCC @ 0x58024400 : block {
|
|||
0 LSION
|
||||
}
|
||||
|
||||
RSR @ 0xd0 : reg {
|
||||
30 LPWRRSTF
|
||||
28 WWDG1RSTF
|
||||
26 IWDGRSTF
|
||||
24 SFTRSTF
|
||||
23 PORRSTF
|
||||
22 PINRSTF
|
||||
21 BORRSTF
|
||||
20 D2RSTF
|
||||
19 D1RSTF
|
||||
17 CPURSTF
|
||||
16 RMVF
|
||||
}
|
||||
|
||||
AHB1ENR @ 0xd8 : reg {
|
||||
28 USB2OTGHSULPIEN
|
||||
27 USB2OTGHSEN
|
||||
|
|
|
|||
|
|
@ -54,6 +54,8 @@
|
|||
# define F_MCO1 GPIOF_ANALOG()
|
||||
#endif
|
||||
|
||||
enum echoplayer_boot_reason echoplayer_boot_reason = ECHOPLAYER_BOOT_REASON_NORMAL;
|
||||
|
||||
static const struct gpio_setting gpios[] = {
|
||||
STM_DEFGPIO(GPIO_BUTTON_A, F_INPUT_PU),
|
||||
STM_DEFGPIO(GPIO_BUTTON_B, F_INPUT_PU),
|
||||
|
|
@ -212,6 +214,24 @@ void system_init(void)
|
|||
pingroups, ARRAYLEN(pingroups));
|
||||
fmc_init();
|
||||
|
||||
/* Read & clear reset source */
|
||||
uint32_t rsr = reg_var(RCC_RSR);
|
||||
reg_assignf(RCC_RSR, RMVF(1));
|
||||
|
||||
/*
|
||||
* Determine boot reason -- SFTRST means a software reset
|
||||
* occurred, which may be a reboot or a power off
|
||||
*/
|
||||
if (reg_vreadf(rsr, RCC_RSR, SFTRSTF))
|
||||
{
|
||||
reg_writef(RCC_APB4ENR, RTCAPBEN(1));
|
||||
|
||||
if (reg_readf(RTC_CR, WUTE))
|
||||
echoplayer_boot_reason = ECHOPLAYER_BOOT_REASON_SW_REBOOT;
|
||||
else
|
||||
echoplayer_boot_reason = ECHOPLAYER_BOOT_REASON_SW_POWEROFF;
|
||||
}
|
||||
|
||||
/* Disable RTC_OUT pin */
|
||||
echoplayer_set_rtcout_mode(ECHOPLAYER_RTCOUT_DISABLED);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,15 @@ enum echoplayer_rtcout_mode
|
|||
ECHOPLAYER_RTCOUT_REBOOT,
|
||||
};
|
||||
|
||||
enum echoplayer_boot_reason
|
||||
{
|
||||
ECHOPLAYER_BOOT_REASON_NORMAL,
|
||||
ECHOPLAYER_BOOT_REASON_SW_POWEROFF,
|
||||
ECHOPLAYER_BOOT_REASON_SW_REBOOT,
|
||||
};
|
||||
|
||||
void echoplayer_set_rtcout_mode(enum echoplayer_rtcout_mode mode);
|
||||
|
||||
extern enum echoplayer_boot_reason echoplayer_boot_reason;
|
||||
|
||||
#endif /* __SYSTEM_ECHOPLAYER_H__ */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue