-
大小: 6.92KB文件类型: .rar金币: 1下载: 0 次发布日期: 2024-04-19
- 语言: C/C++
- 标签: Bootloader STM32 boot STM32
资源简介
stm32 BootLoader程序(main.c)
代码片段和文件信息
#include “Net_Config.h“
#include “flash_if.h“
#include “stm32f4xx_rcc.h“
#include “stm32f4xx_pwr.h“
#include “stm32f4xx_flash.h“
#include “stm32f4xx_iwdg.h“
#include “eth_stm32f4xx.h“
#include “stm32f4xx_rtc.h“
#include “StdFun.h“
#include “Matrix.h“
#include “uart_app.h“
#include “SysTick.h“
#include
#include “main.h“
static void timer_poll(void);
static void IWDG_Init(void);
typedef void (*pFunction)(void);
pFunction Jump_To_Application;
uint32_t JumpAddress;
Bool FirmwareUpdate = FALSE;
/* Net_Config.c */
extern struct http_cfg http_config;
extern U8 own_hw_adr[];
extern LOCALM localm[];
static const VERSION DeviceVersion __attribute__((at(0x08004000))) = {
SPONTAG
MATRIXBIRTHDAY
CFG_MAJOR
CFG_MINOR
CFG_YEAR
CFG_MONTH
CFG_DAY
};
void GPIOBiosControl_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_25MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOA &GPIO_InitStructure);
// RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB ENABLE);
// GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
// GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
// GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
// GPIO_InitStructure.GPIO_Speed = GPIO_Speed_25MHz;
// GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
// GPIO_Init(GPIOB &GPIO_InitStructure);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_25MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOD &GPIO_InitStructure);
GPIO_SetBits(GPIOD GPIO_Pin_8);
}
int main(void)
{
uint16_t timeout = 0;
uint32_t dwSponTag = 0;
uint8_t netsock = 0;
uint8_t GrpIpAddr[4];
BOOL bFlag = FALSE;
uint32_t ij;
GPIOBiosControl_Init();
bFlag = GPIOA->IDR & 0x0400;
for (i = 0; i < 3000; i++)//延时大约1S
for (j = 0; j < 10000; j++);
bFlag = GPIOA->IDR & 0x0400;
StdMemcpy(&dwSponTag (void *)((__IO uint32_t *)0x08040000) 4);
if ((dwSponTag == SPONTAG) && bFlag)
{
GPIO_SetBits(GPIOD GPIO_Pin_8);
//进应用程序段
/* Check if valid stack address (RAM address) then jump to user application */
if (((*(__IO uint32_t*)USER_FLASH_FIRST_PAGE_ADDRESS) & 0x2FFE0000 ) == 0x20000000)
{
/* Jump to user application */
JumpAddress = *(__IO uint32_t*) (USER_FLASH_FIRST_PAGE_ADDRESS + 4);
Jump_To_Application = (pFunction) JumpAddress;
/* Initialize user application‘s Stack Pointer */
__set_MSP(*(__IO uint32_t*) USER_FLASH_FIRST_PAGE_ADDRESS);
Jump_To_Application();
}
}
else
{
GPIO_ResetBits(GPIOD GPIO_Pin_8);//
相关资源
- cubeMX设计实现stm32f407上的CAN及485的通
- STM32修炼的最好书
- STM32 BLDC 无刷电机
- stm32 实现Fatfs对U盘文件操作(main.c)
- stm32f103 USB键盘
- OBD_CAN读取代码(stm32f103)
-
STM32-ba
se64加密源代码 - stm32 MQTT
- stm32f103 can驱动
- STM32三菱PLC源码原理图
- 基于STM32智能家居的无线网关设计与实
- 基于stm32的交通信号灯代码
- DHT11驱动程序基于STM32
- 基于STEM32的倒车记录仪智能报警系统
- STM32_GY25Z计步器
- USB 完整bootloader项目,包括底层驱动和
- C语言实现的红外发送STM32F10x单片机应
- stm32L系列F系列 加密库Cryptographic lib
- 心率传感器算法-stm32-实测可用
- 工程使用的STM32版FX2N源码和原理图
- 基于stm32f1的频率计
- stm32F103zet6开串口通信2 C语言
- LPC1768IAP+MFC上位机+bootloader+app
- LPC1768IAP+MFC上位机+bootloader+app有看不懂
- ADC电压采集程序
- STM32 电子密码锁设计,LCD12864显示C语
- 利用OV7725照相机与STM32F1识别车牌
- 基于STM32的小车红外黑线寻迹代码
- stm32图像采集+QT上位机源码
- STM32,5110液晶显示声纳探鱼器200KHz,
评论
共有 条评论