-
Notifications
You must be signed in to change notification settings - Fork 200
Code Snippets
Ian edited this page Aug 22, 2024
·
1 revision
use atsamd_hal::pac::SCB;
/// RAM size (32 kB for ATSAMD21E18A)
const HMCRAMC0_SIZE: u32 = 0x00008000;
/// RAM base address
const HMCRAMC0_ADDR: u32 = 0x20000000;
/// Writing this value into `BOOTLOADER_DBL_TAP_PTR` and resetting will
/// cause the bootloader to 'stick'
const BOOTLOADER_DBL_TAP_MAGIC: u32 = 0xF01669EF;
/// Writing this value into `BOOTLOADER_DBL_TAP_PTR` and resetting will
/// cause the bootloader pass right through to the app
const BOOTLOADER_DBL_TAP_MAGIC_QUICK_BOOT: u32 = 0xF02669EF;
/// Bootloader magic values need to be written here
const BOOTLOADER_DBL_TAP_PTR: *mut u32 = (HMCRAMC0_ADDR + HMCRAMC0_SIZE - 4) as *mut _;
/// Reset into the bootloader, and stay there in order to flash a new
/// firmware image.
#[inline]
pub fn reset() -> ! {
unsafe {
core::ptr::write_volatile(BOOTLOADER_DBL_TAP_PTR, BOOTLOADER_DBL_TAP_MAGIC);
}
SCB::sys_reset();
}