Ai
2 Star 11 Fork 8

MaYuchen/BMCBootLoader

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
bootLoader.c 1.73 KB
一键复制 编辑 原始数据 按行查看 历史
MaYuchen 提交于 2023-03-28 19:47 +08:00 . 重构应用启动功能为一个模块
/*
* @Author: jimma0312 jimma0312@outlook.com
* @Date: 2023-03-28 19:09:24
* @LastEditors: jimma0312 jimma0312@outlook.com
* @LastEditTime: 2023-03-28 19:12:52
* @FilePath: .\bootLoader.c
* @Description: 应用程序启动模块 实现
*/
#include "gd32f4xx.h" // Device header
#include <stdio.h>
#include <stdint.h>
#include "bootLoader.h"
#ifndef BOARD_EVAL
#include "bsp_gpio.h"
#endif
#include "bsp_uart.h"
#include "bsp_ocflash.h"
#include "systick.h"
static pFunction Jump_To_Application;
static uint32_t JumpAddress;
int GetIAPIntper(void)
{
int delayCnt=1000; //设置等待中断字符时间 约1s
uint8_t key=0;
do
{
if((1==SerialKeyPressed(&key)) && (0x1B == key))
{
Serial_PutString("Get ESC Now turn In IAP Progame\r\n");
return 1;
}
delay_1ms(1);
} while ((--delayCnt) >0);
return 0;
}
/**
* @brief 运行应用程序
*
*/
void RunApp(void)
{
if(ExistApplication() != 0)
{
LoadRunApplication();
}
else
{
Serial_PutString("Warning Not Application On BMC!!!\r\n");
}
}
int ExistApplication(void)
{
if(((*(__IO uint32_t *)APPLICATION_ADDRESS) & 0x2FFE0000) == 0x20000000)
{
return 1;
}
return 0;
}
void LoadRunApplication(void)
{
ResetSerial();
#ifndef BOARD_EVAL
PowerOffBmcPeriph();
ResetGpio();
#endif
delay_1ms(500);
nvic_irq_disable(EXTI0_IRQn);
//__set_FAULTMASK(1);
JumpAddress = *(__IO uint32_t *)(APPLICATION_ADDRESS + 4); // application main address
Jump_To_Application = (pFunction)JumpAddress;
// 初始化Application的栈指针
__set_MSP(*(__IO uint32_t *)APPLICATION_ADDRESS);
Jump_To_Application();
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/VoldemortCat/bmcboot-loader.git
git@gitee.com:VoldemortCat/bmcboot-loader.git
VoldemortCat
bmcboot-loader
BMCBootLoader
master

搜索帮助