与非网论坛
标题:
GD32固件库中对gd32f1x0_conf.h的修改优化
[打印本页]
作者:
sky-Hawk where
时间:
2015-7-21 10:26
标题:
GD32固件库中对gd32f1x0_conf.h的修改优化
gd32固件库里这个文件把所有的外围设备驱动全部包含进来,原代码如下:
#ifndef __GD32F10X_CONF_H
#define __GD32F10X_CONF_H
/* Includes ------------------------------------------------------------------*/
#include "gd32f10x_adc.h"
#include "gd32f10x_bkp.h"
#include "gd32f10x_can.h"
#include "gd32f10x_crc.h"
#include "gd32f10x_dac.h"
#include "gd32f10x_dma.h"
#include "gd32f10x_eth.h"
#include "gd32f10x_exmc.h"
#include "gd32f10x_exti.h"
#include "gd32f10x_fmc.h"
#include "gd32f10x_gpio.h"
#include "gd32f10x_i2c.h"
#include "gd32f10x_iwdg.h"
#include "gd32f10x_mcudbg.h"
#include "gd32f10x_misc.h"
#include "gd32f10x_pwr.h"
#include "gd32f10x_rcc.h"
#include "gd32f10x_rtc.h"
#include "gd32f10x_sdio.h"
#include "gd32f10x_spi.h"
#include "gd32f10x_timer.h"
#include "gd32f10x_usart.h"
#include "gd32f10x_wwdg.h"
#endif /* __GD32F10X_CONF_H */
复制代码
如果把这个文件include文件里,那么就会把所有的外设驱动引入到项目里,有的同学通过注释掉不用的模块来使用,这样每次都要修改这个文件很是不科学。我对这个文件进行修改如下:
/**
******************************************************************************
* @file gd32f1x0_conf.h
* @author MCU SD
* @version V1.0
* @date 6-Sep-2014
* @brief Library configuration file.
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __GD32F1X0_CONF_H
#define __GD32F1X0_CONF_H
/* Run Time Environment will set specific #define for each selected module below */
#include "RTE_Components.h"
#ifdef RTE_DEVICE_STDPERIPH_ADC
#include "gd32f1x0_adc.h"
#endif
#ifdef RTE_DEVICE_STDPERIPH_CMP
#include "gd32f1x0_cmp.h"
#endif
#ifdef RTE_DEVICE_STDPERIPH_SYSCFG
#include "gd32f1x0_syscfg.h"
#endif
#ifdef RTE_DEVICE_STDPERIPH_CEC
#include "gd32f1x0_cec.h"
#endif
#ifdef RTE_DEVICE_STDPERIPH_CRC
#include "gd32f1x0_crc.h"
#endif
#ifdef RTE_DEVICE_STDPERIPH_DAC
#include "gd32f1x0_dac.h"
#endif
#ifdef RTE_DEVICE_STDPERIPH_MCUDBG
#include "gd32f1x0_mcudbg.h"
#endif
#ifdef RTE_DEVICE_STDPERIPH_DMA
#include "gd32f1x0_dma.h"
#endif
#ifdef RTE_DEVICE_STDPERIPH_EXTI
#include "gd32f1x0_exti.h"
#endif
#ifdef RTE_DEVICE_STDPERIPH_TSI
#include "gd32f1x0_tsi.h"
#endif
#ifdef RTE_DEVICE_STDPERIPH_FMC
#include "gd32f1x0_fmc.h"
#endif
#ifdef RTE_DEVICE_STDPERIPH_GPIO
#include "gd32f1x0_gpio.h"
#endif
#ifdef RTE_DEVICE_STDPERIPH_I2C
#include "gd32f1x0_i2c.h"
#endif
#ifdef RTE_DEVICE_STDPERIPH_IWDG
#include "gd32f1x0_iwdg.h"
#endif
#ifdef RTE_DEVICE_STDPERIPH_PWR
#include "gd32f1x0_pwr.h"
#endif
#ifdef RTE_DEVICE_STDPERIPH_RCC
#include "gd32f1x0_rcc.h"
#endif
#ifdef RTE_DEVICE_STDPERIPH_RTC
#include "gd32f1x0_rtc.h"
#endif
#ifdef RTE_DEVICE_STDPERIPH_SDIO
#include "gd32f1x0_sdio.h"
#endif
#ifdef RTE_DEVICE_STDPERIPH_SPI
#include "gd32f1x0_spi.h"
#endif
#ifdef RTE_DEVICE_STDPERIPH_TIM
#include "gd32f1x0_timer.h"
#endif
#ifdef RTE_DEVICE_STDPERIPH_USART
#include "gd32f1x0_usart.h"
#endif
#ifdef RTE_DEVICE_STDPERIPH_WWDG
#include "gd32f1x0_wwdg.h"
#endif
#ifdef RTE_DEVICE_STDPERIPH_FRAMEWORK
#include "gd32f1x0_misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */
#endif
#endif /* __GD32F1X0_CONF_H */
/******************* (C) COPYRIGHT 2014 GIGADEVICE *****END OF FILE****/
复制代码
如果需要使用USART,那么就定义一个RTE_DEVICE_STDPERIPH_USART就可以了。
但是这样还是不太方便,那么就使用Keil.GD32F1xx_DFP.1.0.4 开发包,让软件来帮我们做这件事吧,只需要在Run-Time Environment选择相应的外设,其它的交给Keil去做吧。如图所示:
(, 下载次数: 16)
上传
点击文件名下载附件
不再需要去注释不用的include,不再需要定义宏。
欢迎光临 与非网论坛 (https://www.eefocus.com/forum/)
Powered by Discuz! X3.5