HAL_ChibiOS: added support for RTC sig for fast boot
This commit is contained in:
parent
a3e44b3249
commit
2b7b499c63
@ -32,6 +32,7 @@
|
||||
#include <DataFlash/DataFlash.h>
|
||||
#include <AP_Scheduler/AP_Scheduler.h>
|
||||
#include <AP_BoardConfig/AP_BoardConfig.h>
|
||||
#include "hwdef/common/stm32_util.h"
|
||||
#include "shared_dma.h"
|
||||
#include "sdcard.h"
|
||||
|
||||
@ -232,7 +233,6 @@ void Scheduler::register_timer_failsafe(AP_HAL::Proc failsafe, uint32_t period_u
|
||||
_failsafe = failsafe;
|
||||
}
|
||||
|
||||
extern void Reset_Handler();
|
||||
void Scheduler::reboot(bool hold_in_bootloader)
|
||||
{
|
||||
// disarm motors to ensure they are off during a bootloader upload
|
||||
@ -245,6 +245,9 @@ void Scheduler::reboot(bool hold_in_bootloader)
|
||||
// stop sdcard driver, if active
|
||||
sdcard_stop();
|
||||
|
||||
// setup RTC for fast reboot
|
||||
set_fast_reboot(hold_in_bootloader?RTC_BOOT_HOLD:RTC_BOOT_FAST);
|
||||
|
||||
// disable all interrupt sources
|
||||
port_disable();
|
||||
|
||||
|
@ -218,3 +218,36 @@ uint32_t get_fattime()
|
||||
|
||||
return fattime;
|
||||
}
|
||||
|
||||
// get RTC backup register 0
|
||||
static uint32_t get_rtc_backup0(void)
|
||||
{
|
||||
return RTC->BKP0R;
|
||||
}
|
||||
|
||||
// set RTC backup register 0
|
||||
static void set_rtc_backup0(uint32_t v)
|
||||
{
|
||||
if ((RCC->BDCR & RCC_BDCR_RTCEN) == 0) {
|
||||
RCC->BDCR |= STM32_RTCSEL;
|
||||
RCC->BDCR |= RCC_BDCR_RTCEN;
|
||||
}
|
||||
#ifdef PWR_CR_DBP
|
||||
PWR->CR |= PWR_CR_DBP;
|
||||
#else
|
||||
PWR->CR1 |= PWR_CR1_DBP;
|
||||
#endif
|
||||
RTC->BKP0R = v;
|
||||
}
|
||||
|
||||
// see if RTC registers is setup for a fast reboot
|
||||
enum rtc_boot_magic check_fast_reboot(void)
|
||||
{
|
||||
return (enum rtc_boot_magic)get_rtc_backup0();
|
||||
}
|
||||
|
||||
// set RTC register for a fast reboot
|
||||
void set_fast_reboot(enum rtc_boot_magic v)
|
||||
{
|
||||
set_rtc_backup0(v);
|
||||
}
|
||||
|
@ -52,6 +52,18 @@ uint32_t get_fattime(void);
|
||||
#define OTP_BASE 0x1ff0f000
|
||||
#define OTP_SIZE 1024
|
||||
#endif
|
||||
|
||||
enum rtc_boot_magic {
|
||||
RTC_BOOT_OFF = 0,
|
||||
RTC_BOOT_HOLD = 0xb0070001,
|
||||
RTC_BOOT_FAST = 0xb0070002
|
||||
};
|
||||
|
||||
// see if RTC registers is setup for a fast reboot
|
||||
enum rtc_boot_magic check_fast_reboot(void);
|
||||
|
||||
// set RTC register for a fast reboot
|
||||
void set_fast_reboot(enum rtc_boot_magic v);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user