您的位置 首页 应用

ARM常用函数的装备函数—要点堆集

Author:泪与汗的缠绵Data:2011-11月功能:积累编程的思想与套路本页所包含的配置函数有:voidSysTick_Configuration(void);voi

//Author:”泪与汗的纠缠”

//Data:2011-11月

//功用:堆集编程的思维与套路

本页所包括的装备函数有:
void SysTick_Configuration(void);
void GPIO_Configuration(void);//端口引脚功用的装备
void EXTI_Configuration(void);//装备外部中止线
void NVIC_Configuration(void);//装备中止的优先级、内部中止向量
void RCC_Configuration(void); //装备体系及其外设的时钟
void IWDG_Configuration(void);//看门狗的装备结构
voidTIM_Configuration(void)
voidADC_configuration();
void DMA_Configuration(void);
void DAC_Configuration(void);
//一起需求装备的结构体变量
GPIO_InitTypeDef GPIO_InitStructure;
EXTI_InitTypeDef EXTI_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;

*******//Cortex体系定时器(SysTick)*********************
*******************************************************
*******************************************************
void SysTick_Configuration(void)
{

//挑选体系定时器(SysTick)的时钟源
SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK_Div8);


SysTick_SetReload(250000);


SysTick_CounterCmd(SysTick_Counter_Enable);


SysTick_ITConfig(ENABLE);
}
*********///GPIO的装备程序***************************************
******************************************************************
*******************************************************************
void GPIO_Configuration(void) void RCC_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;


GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_8|GPIO_Pin_9;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOC, &GPIO_InitStructure);


GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOB, &GPIO_InitStructure);
}
//中止线路初始化
void EXTI_Configuration(void)
{

EXTI_InitStructure.EXTI_Line = EXTI_Line9;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);


EXTI_InitStructure.EXTI_Line = EXTI_Line13;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
}
///嵌套中止向量NVIC**********************************
/
GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource9);
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
NVIC_InitStructure.NVIC_IRQChannel=EXTI0_IRQChannel;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority=0;
NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE;
NVIC_Init(&NVIC_InitStructure);

//为EXTI_Line9使能并装备中止向量

//为EXTI_Line0使能并装备中止向量
GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource9);
NVIC_InitStructure.NVIC_IRQChannel=EXTI9_5_IRQChannel;
NVIC_Init(&NVIC_InitStructure);

//为EXTI_Line9使能并装备中止向量

//为EXTI_Line13使能并装备中止向量
GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource9);
NVIC_InitStructure.NVIC_IRQChannel=EXTI15_10_IRQChannel;
NVIC_Init(&NVIC_InitStructure);

}

********************************************************************
**************体系时钟的装备RCC_Configuration**********************
void RCC_Configuration(void)
{

RCC_DeInit();

RCC_HSEConfig(RCC_HSE_ON);

HSEStartUpStatus = RCC_WaitForHSEStartUp();
if(HSEStartUpStatus == SUCCESS)
{

RCC_HCLKConfig(RCC_SYSCLK_Div1);

RCC_PCLK2Config(RCC_HCLK_Div1);

RCC_PCLK1Config(RCC_HCLK_Div2);

FLASH_SetLatency(FLASH_Latency_2);

FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
*/
RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);

RCC_PLLCmd(ENABLE);

while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
{
}

RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);

while(RCC_GetSYSCLKSource() != 0x08)
{
}

RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOB |RCC_APB2Periph_AFIO, ENABLE);


RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);

}

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/yingyong/257888.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部