From ab35a1932efcd758d59eb13abbfa830ddec3b9db Mon Sep 17 00:00:00 2001 From: cfif Date: Sat, 20 Jun 2026 11:26:35 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Inc/BootJump.h | 1 + Src/BootJump.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/Inc/BootJump.h b/Inc/BootJump.h index 058361f..9f202f1 100644 --- a/Inc/BootJump.h +++ b/Inc/BootJump.h @@ -8,5 +8,6 @@ #include "stdint.h" void BootJumpToAddress(const uint32_t address); +void Reset(); #endif //HVAC_ON_CHIP_BOOTLOADER_JUMP_H diff --git a/Src/BootJump.c b/Src/BootJump.c index c069429..57b50c5 100644 --- a/Src/BootJump.c +++ b/Src/BootJump.c @@ -6,6 +6,10 @@ #include "fc7xxx_driver_fcuart.h" #include "fc7240_fcuart_regs.h" #include "fc7xxx_driver_pcc.h" +#include "fc7xxx_driver_adc.h" +#include "fc7xxx_driver_flexcan.h" +#include "fc7xxx_driver_tpu.h" + typedef void (*pFunction)(void); @@ -80,4 +84,68 @@ void BootJumpToAddress(const uint32_t address) { appEntry(); while (1); +} + +void Reset() { + // 1. ГЛОБАЛЬНО отключаем прерывания (первое, что делаем) + __disable_irq(); + + // 2. Отключаем ВСЕ прерывания в NVIC + for (int i = 0; i < 8; i++) { // Обычно достаточно 8 банков для всех прерываний + NVIC->ICER[i] = 0xFFFFFFFF; + NVIC->ICPR[i] = 0xFFFFFFFF; + } + + // 3. Останавливаем SysTick и сбрасываем + SysTick->CTRL = 0; + SysTick->LOAD = 0; + SysTick->VAL = 0; + + // 4. Сбрасываем все pending-флаги + SCB->ICSR |= SCB_ICSR_PENDSVCLR_Msk | SCB_ICSR_PENDSTCLR_Msk; + + // 5. Отключаем периферию, которая может генерировать прерывания + + // 5.1. DMA + DMA_DeInit(DMA_INSTANCE_0); + + // 5.2. UART + for (uint8_t i = 0; i < FCUART_INSTANCE_COUNT; ++i) { + FCUART_DeInit(i); + } + + // 5.3. CAN + for (uint8_t i = 0; i < FLEXCAN_INSTANCE_COUNT; ++i) { + FLEXCAN_DeInit(i); + } + + // 5.4. ADC + for (uint8_t i = 0; i < ADC_INSTANCE_COUNT; ++i) { + ADC_DeInit(i); + } + + // 5.5. TPU + TPU_DeInit(); + + + // 5.3 RESET CLK + PCC_GenPeripheralReset(PCC_CLK_DMA0); + PCC_GenPeripheralReset(PCC_CLK_DMAMUX0); + PCC_GenPeripheralReset(PCC_CLK_FLEXCAN0); + PCC_GenPeripheralReset(PCC_CLK_FLEXCAN1); + PCC_GenPeripheralReset(PCC_CLK_FLEXCAN2); + PCC_GenPeripheralReset(PCC_CLK_FLEXCAN3); + PCC_GenPeripheralReset(PCC_CLK_ADC0); + PCC_GenPeripheralReset(PCC_CLK_ADC1); + PCC_GenPeripheralReset(PCC_CLK_FCUART0); + PCC_GenPeripheralReset(PCC_CLK_FCUART1); + PCC_GenPeripheralReset(PCC_CLK_FCUART2); + PCC_GenPeripheralReset(PCC_CLK_FCUART3); + PCC_GenPeripheralReset(PCC_CLK_FCUART4); + PCC_GenPeripheralReset(PCC_CLK_FCUART5); + PCC_GenPeripheralReset(PCC_CLK_FCUART6); + PCC_GenPeripheralReset(PCC_CLK_FCUART7); + + NVIC_SystemReset(); + } \ No newline at end of file