⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iar-

📁 IAR_example_EasyARM8962.zip
💻
字号:
/****************************************Copyright (c)****************************************************
**                            Guangzhou ZHIYUAN electronics Co.,LTD.
**                                      
**                                 http://www.embedtools.com
**
**--------------File Info---------------------------------------------------------------------------------
** File name:               InterrptDome.c
** Latest modified Date:    2007.12.21
** Latest Version:          V1.1
** Descriptions:            按键中断实验程序
**
**--------------------------------------------------------------------------------------------------------
** Created by:              Zhao shimin
** Created date:            2007.09.16
** Version:                 V1.0
** Descriptions:            The original version
**
**--------------------------------------------------------------------------------------------------------
** Modified by:             Kang qinhua
** Modified date:           2008.01.12
** Version:                 V1.1
** Descriptions:            
**
*********************************************************************************************************/

/*********************************************************************************************************
  调用库函数的头文件              
*********************************************************************************************************/
#include "hw_memmap.h"
#include "hw_ints.h"
#include "hw_nvic.h"
#include "hw_types.h"
#include "interrupt.h"
#include "sysctl.h"
#include "gpio.h"

#define LED3 GPIO_PIN_6                                                 /*  定义LED3的引脚PB6           */
#define KEY3 GPIO_PIN_4                                                 /*  定义KEY3的引脚PB4           */
/*********************************************************************************************************
** 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)
{
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);                        /*  使能GPIOB模块               */
    
    GPIOPadConfigSet(GPIO_PORTB_BASE, LED3, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
                                                                        /* 设置PB6为2MA,推挽输出      */
    GPIODirModeSet(GPIO_PORTB_BASE, LED3, GPIO_DIR_MODE_OUT);           /*  配置LED3为输出              */
    GPIOPadConfigSet(GPIO_PORTB_BASE, KEY3, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
                                                                        /* 设置PB4为2MA,上拉输入      */
    GPIODirModeSet(GPIO_PORTB_BASE, KEY3, GPIO_DIR_MODE_IN);            /*  配置KEY3为输入              */
  
    IntMasterEnable();                                                  /*  使能总中断                  */
    IntEnable(INT_GPIOB);                                               /*  使用GPIOB中断               */
    GPIOIntTypeSet(GPIO_PORTB_BASE,KEY3,GPIO_FALLING_EDGE);             /*  下降沿触发中断              */
    GPIOPinIntEnable(GPIO_PORTB_BASE, KEY3);                            /*  使能KEY3中断                */
 
    while (1) {
        ;                                                               /*  等待中断                    */
    }
}
/*********************************************************************************************************
** 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) 										
{
    long IntStatus;
  
    IntStatus = GPIOPinIntStatus(GPIO_PORTB_BASE, true);                /*  获取中断状态                */
    GPIOPinIntClear(GPIO_PORTB_BASE, IntStatus);                        /*  清GPIO中断                  */
    if ( IntStatus & KEY3 ) {                                           /*  判断按键是否按下            */
        GPIOPinWrite(GPIO_PORTB_BASE, LED3, LED3^GPIOPinRead(GPIO_PORTB_BASE,LED3));	
                                                                        /*  使LED状态改变               */
  }
}
/*********************************************************************************************************
  END FILE
*********************************************************************************************************/


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -