
F407_06_标准库开发
发布日期:2021-05-07 14:37:18
浏览次数:23
分类:原创文章
本文共 4826 字,大约阅读时间需要 16 分钟。
X@/''...
1> 概述
2> 下载链接
➕------------------------------------➕
➕------------------------------------➕
帮助文档:"stm32f4xx_dsp_stdperiph_lib_um.chm"编程时,可对库函数概览;
3> 文件简介
3.1> CPU文件
ARM公司为CPU编写的描述和操作代码: /* CMSIS Cortex-M4 Core Peripheral Access Layer Header File */"core_cm4.h" /* CMSIS Cortex-M Core Instruction Access Header File */ "core_cmInstr.h" /* CMSIS Cortex-M Core Function Access Header File */ "core_cmFunc.h" /* Compiler specific SIMD Intrinsics */ "core_cmSimd.h"/* standard types definitions */"stdint.h" //在安装目录下
3.2> MCU文件
/* MCU启动文件 */"startup_stm32f40xx.s"/* 时钟初始化 */"system_stm32f4xx.h""system_stm32f4xx.c"/* CMSIS Cortex-M4 Device Peripheral Access Layer Header File. This file contains:> all the peripheral register's definitions, > bits definitions,> memory mapping */"stm32f4xx.h"/* 外设驱动文件 */"stm32f4xx_gpio.h""stm32f4xx_gpio.c""stm32f4xx_rcc.h""stm32f4xx_rcc.C"..."stm32f4xx_ppp.h""stm32f4xx_ppp.C"/* 配置外设驱动文件 */"stm32f4xx_conf.h"
3.3> 头文件包含关系
4> 标准库修改
4.1> 修改外部晶振
Step 1> stm32f4xx.h
/*修改HSE_VALUE 指定频率 */#if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || \ defined(STM32F429_439xx) || defined(STM32F401xx) || \ defined(STM32F410xx) || defined(STM32F411xE) || \ defined(STM32F469_479xx) #if !defined (HSE_VALUE) #define HSE_VALUE ((uint32_t)8000000) /*!< Value of the External oscillator in Hz */ #endif /* HSE_VALUE */ #elif defined (STM32F412xG) || defined(STM32F413_423xx) || defined(STM32F446xx) #if !defined (HSE_VALUE) #define HSE_VALUE ((uint32_t)8000000) /*!< Value of the External oscillator in Hz */ #endif /* HSE_VALUE */ #endif
Step 2> system_stm32f4xx.c
/*修改PLL_M 为:指定频率/100000 */#if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || \ defined(STM32F429_439xx) || defined(STM32F401xx) || \ defined(STM32F469_479xx) /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N */ #define PLL_M 8 #elif defined(STM32F412xG) || defined(STM32F413_423xx) || defined (STM32F446xx) #define PLL_M 8 #elif defined (STM32F410xx) || defined (STM32F411xE) #if defined(USE_HSE_BYPASS) #define PLL_M 8 #else /* !USE_HSE_BYPASS */ #define PLL_M 16 #endif /* USE_HSE_BYPASS */#else #endif
Step 3> 调试仿真的时钟频率
4.2> 修改stm32f4xx_conf.h
"stm32f4xx_conf.h"/* 注释掉不需要的 *///#include "stm32f4xx_adc.h"//#include "stm32f4xx_crc.h"//#include "stm32f4xx_dbgmcu.h"//#include "stm32f4xx_dma.h"//#include "stm32f4xx_exti.h"//#include "stm32f4xx_flash.h"#include "stm32f4xx_gpio.h"
5> 标准库代码规范
5.1> 头文件
/** ****************************************************************************** * @file * @author * @version * @date * @brief * ****************************************************************************** * @attention * ****************************************************************************** *//* Define to prevent recursive inclusion -------------------------------------*/#ifndef __TEMPLATE_H#define __TEMPLATE_H/* Includes ------------------------------------------------------------------*/#include "stm32f4xx.h"/* Exported types ------------------------------------------------------------*/"数据类型声明"例如typedef struct{ uint32_t GPIO_Pin; GPIOMode_TypeDef GPIO_Mode; GPIOSpeed_TypeDef GPIO_Speed; GPIOOType_TypeDef GPIO_OType; GPIOPuPd_TypeDef GPIO_PuPd; }GPIO_InitTypeDef;/* Exported constants --------------------------------------------------------*/"常量定义"/* Exported macro ------------------------------------------------------------*/"宏函数"例如:#define MAX(a, b) ((a) > (b) ? (a) : (b))/* Exported functions --------------------------------------------------------*/ #endif /* __TEMPLATE_H *//************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
5.2> C文件
/** ****************************************************************************** * @file * @author * @version * @date * @brief * ****************************************************************************** * @attention * ****************************************************************************** *//* Includes ------------------------------------------------------------------*/#include "template.h"/* Private typedef -----------------------------------------------------------*//* Private define ------------------------------------------------------------*//* Private macro -------------------------------------------------------------*//* Private variables ---------------------------------------------------------*//* Private function prototypes -----------------------------------------------*//* Private functions ---------------------------------------------------------*//************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
发表评论
最新留言
表示我来过!
[***.240.166.169]2025年04月15日 22时42分16秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
远程触发Jenkins的Pipeline任务的并发问题处理
2021-05-09
entity framework core在独立类库下执行迁移操作
2021-05-09
Asp.Net Core 2.1+的视图缓存(响应缓存)
2021-05-09
【wp】HWS计划2021硬件安全冬令营线上选拔赛
2021-05-09
Ef+T4模板实现代码快速生成器
2021-05-09
JQuery选择器
2021-05-09
多线程之volatile关键字
2021-05-09
2.2.2原码补码移码的作用
2021-05-09
Java面试题:Servlet是线程安全的吗?
2021-05-09
Java集合总结系列2:Collection接口
2021-05-09
Linux学习总结(九)—— CentOS常用软件安装:中文输入法、Chrome
2021-05-09
比技术还重要的事
2021-05-09
linux线程调度策略
2021-05-09
软中断和实时性
2021-05-09
Linux探测工具BCC(可观测性)
2021-05-09
SNMP介绍及使用,超有用,建议收藏!
2021-05-09
HDU5589:Tree(莫队+01字典树)
2021-05-09
不停机替换线上代码? 你没听错,Arthas它能做到
2021-05-09
Python开发之序列化与反序列化:pickle、json模块使用详解
2021-05-09
采坑 - 字符串的 "" 与 pd.isnull()
2021-05-09