Обновление 23.06.2026

This commit is contained in:
Дарья Бараева 2026-06-23 20:48:36 +03:00
parent b62f196e90
commit 2a80d89c7d
2 changed files with 35 additions and 0 deletions

View File

@ -7,6 +7,7 @@
#include "stdint.h"
void BootFastJumpToAddress(const uint32_t address);
void BootJumpToAddress(const uint32_t address);
void Reset();

View File

@ -150,6 +150,40 @@ void BootJumpToAddress(const uint32_t address) {
while (1);
}
void BootFastJumpToAddress(const uint32_t address) {
// 1. Подготовка процессора
if (CONTROL_nPRIV_Msk & __get_CONTROL()) {
EnablePrivilegedMode();
}
if (CONTROL_SPSEL_Msk & __get_CONTROL()) {
__set_MSP(__get_PSP());
__set_CONTROL(__get_CONTROL() & ~CONTROL_SPSEL_Msk);
}
// 2. Получаем стек и точку входа приложения
uint32_t appStack = *((__IO uint32_t *) address);
pFunction appEntry = (pFunction) *((__IO uint32_t *) (address + 4));
// 3. Устанавливаем VTOR и стек
SCB->VTOR = address;
__set_MSP(appStack);
// 4. Очищаем регистры, которые могут содержать данные загрузчика
__ISB(); // Instruction Synchronization Barrier
__DSB(); // Data Synchronization Barrier
// 5. Переход БЕЗ включения прерываний!
// Приложение само должно включить прерывания после инициализации
appEntry();
while (1);
}
void Reset() {
// DeInitAll();