📄 iar-
字号:
/****************************************Copyright (c)****************************************************
** Guangzhou ZHIYUAN electronics Co.,LTD.
**
** http://www.embedtools.com
**
**--------------File Info---------------------------------------------------------------------------------
** File name: IntDome2.c
** Latest modified Date: 2007.12.21
** Latest Version: V1.1
** Descriptions: 按键中断实验程序
**
**--------------------------------------------------------------------------------------------------------
** Created by: Zhao shimin
** Created date: 2007.09.18
** Version: V1.0
** Descriptions: The original version
**
**--------------------------------------------------------------------------------------------------------
** Modified by: Kang qinhua
** Modified date: 2008.01.12
** Version: V1.1
** Descriptions:
**
*********************************************************************************************************/
/*********************************************************************************************************
调用库函数的头文件
*********************************************************************************************************/
#include "hw_ints.h"
#include "hw_nvic.h"
#include "hw_types.h"
#include "interrupt.h"
#include "sysctl.h"
/*********************************************************************************************************
全局变量定义
*********************************************************************************************************/
volatile unsigned long GulIndex; /* 中断次数计数 */
volatile unsigned long GulGPIOA; /* GPIOA中断次数 */
volatile unsigned long GulGPIOB; /* GPIOB中断次数 */
volatile unsigned long GulGPIOC; /* GPIOC中断次数 */
/*********************************************************************************************************
** Function name: GPIO_Port_A_ISR
** Descriptions: 中断服务程序
** input parameters: NONE
** output parameters: NONE
** Returned value: NONE
** Created by: Zhao shimin
** Created Date: 2007.09.18
**--------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
void GPIO_Port_A_ISR (void)
{
GulGPIOA = GulIndex++;
}
/*********************************************************************************************************
** Function name: GPIO_Port_B_ISR
** Descriptions: 中断服务程序
** input parameters: NONE
** output parameters: NONE
** Returned value: NONE
** Created by: Zhao shimin
** Created Date: 2007.09.18
**--------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
void GPIO_Port_B_ISR (void)
{
HWREG(NVIC_SW_TRIG) = INT_GPIOA - 16;
GulGPIOB = GulIndex++;
}
/*********************************************************************************************************
** Function name: GPIO_Port_C_ISR
** Descriptions: 中断服务程序
** input parameters: NONE
** output parameters: NONE
** Returned value: NONE
** Created by: Zhao shimin
** Created Date: 2007.09.18
**--------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
void GPIO_Port_C_ISR (void)
{
HWREG(NVIC_SW_TRIG) = INT_GPIOB - 16;
GulGPIOC = GulIndex++;
}
/*********************************************************************************************************
** Function name: main
** Descriptions: 中断初始化
** input parameters: NONE
** output parameters: NONE
** Returned value: NONE
** Created by: Zhao shimin
** Created Date: 2007.09.18
**--------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
int main(void)
{
IntMasterEnable(); /* 使能总中断 */
IntEnable(INT_GPIOA); /* 使能GPIOA中断 */
IntEnable(INT_GPIOB); /* 使能GPIOB中断 */
IntEnable(INT_GPIOC); /* 使能GPIOC中断 */
/*
* GPIOA,GPIOB,GPIOC的中断优先级都设为0
*/
IntPrioritySet(INT_GPIOA, 0 << 5);
IntPrioritySet(INT_GPIOB, 0 << 5);
IntPrioritySet(INT_GPIOC, 0 << 5);
GulGPIOA = 0;
GulGPIOB = 0;
GulGPIOC = 0;
GulIndex = 1;
HWREG(NVIC_SW_TRIG) = INT_GPIOC - 16; /* 软件触发中断GPIOC */
if ((GulGPIOA != 3) || (GulGPIOB != 2) || (GulGPIOC != 1)) {
while (1);
}
/*
* GPIOA,GPIOB,GPIOC的中断优先级依次由低到高
*/
IntPrioritySet(INT_GPIOA, 2 << 5);
IntPrioritySet(INT_GPIOB, 1 << 5);
IntPrioritySet(INT_GPIOC, 0 << 5);
GulGPIOA = 0;
GulGPIOB = 0;
GulGPIOC = 0;
GulIndex = 1;
HWREG(NVIC_SW_TRIG) = INT_GPIOC - 16;
if ((GulGPIOA != 3) || (GulGPIOB != 2) || (GulGPIOC != 1)) {
while(1);
}
/*
* GPIOA,GPIOB,GPIOC的中断优先级依次由高到低
*/
IntPrioritySet(INT_GPIOA, 0 << 5);
IntPrioritySet(INT_GPIOB, 1 << 5);
IntPrioritySet(INT_GPIOC, 2 << 5);
GulGPIOA = 0;
GulGPIOB = 0;
GulGPIOC = 0;
GulIndex = 1;
HWREG(NVIC_SW_TRIG) = INT_GPIOC - 16;
if ((GulGPIOA != 1) || (GulGPIOB != 2) || (GulGPIOC != 3)) {
while(1) {
;
}
}
IntDisable(INT_GPIOA); /* 禁止GPIOA中断 */
IntDisable(INT_GPIOB); /* 禁止GPIOB中断 */
IntDisable(INT_GPIOC); /* 禁止GPIOC中断 */
IntMasterDisable(); /* 禁止总中断 */
while (1) {
;
}
}
/*********************************************************************************************************
END FILE
*********************************************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -