新聞中心

我的ARM編程技巧---積累

作者: 時(shí)間:2016-11-26 來源:網(wǎng)絡(luò) 收藏
隨著學(xué)習(xí)的深入,漸漸發(fā)現(xiàn),編程時(shí)更多的工作是不斷的配置寄存器,做著許多重復(fù)的工作。所以就感覺很有必要把經(jīng)常使用的寄存器、配置結(jié)構(gòu)羅列出來,以方便使用??!這是其中的一部分,其他的慢慢來

本文引用地址:http://butianyuan.cn/article/201611/321616.htm

本頁所包含的配置函數(shù)有:
void SysTick_Configuration(void);
void GPIO_Configuration(void);
void EXTI_Configuration(void);
void NVIC_Configuration(void);
void RCC_Configuration(void);
void IWDG_Configuration(void);

//同時(shí)需要配置的結(jié)構(gòu)體變量
GPIO_InitTypeDef GPIO_InitStructure;
EXTI_InitTypeDef EXTI_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;

*******//Cortex系統(tǒng)定時(shí)器(SysTick)*********************
*******************************************************
*******************************************************
void SysTick_Configuration(void)
{
/
//選擇系統(tǒng)定時(shí)器(SysTick)的時(shí)鐘源
SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK);


SysTick_SetReload(72000);


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);

}


上一頁 1 2 下一頁

關(guān)鍵詞: ARM編程技

評(píng)論


技術(shù)專區(qū)

關(guān)閉