X@/''...
1> 概述
2> 下载链接
➕------------------------------------➕
🔗 StM32F407ZGT6 固件库
➕------------------------------------➕
帮助文档:
"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****/