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

📄 target.c

📁 ZLG的EASYARM8962开发板Keil实验例程
💻 C
📖 第 1 页 / 共 2 页
字号:
/****************************************Copyright (c)****************************************************
**                               Guangzhou ZHIYUAN electronics Co.,LTD.
**                                     
**                                 http://www.embedtools.com
**
**--------------File Info---------------------------------------------------------------------------------
** File Name:               Target.c
** Last modified Date:      2007.01.18
** Last Version:            1.0
** Description:             Initialization of the target board 目标板初始化
** 
**--------------------------------------------------------------------------------------------------------
** Created By:              Steven Zhou 周绍刚
** Created date:            2007.01.18
** Version:                 1.0
** Descriptions:            The original version 初始版本
**
**--------------------------------------------------------------------------------------------------------
** Modified by: 	        Ni Likao 倪力考
** Modified date:	        2007.11.02
** Version:			        1.1
** Descriptions: 	        增加了LED,BUZZ,KEY端口类型配置以适用于LUMINARY新型号的芯片
**                        
*********************************************************************************************************/

#include <includes.h>
           
/*********************************************************************************************************
** Function name:			ledInit
** Descriptions:			Initialize the target board's leds,support up to 4 leds 
**                          初始化目标板的LED,最多支持4个
** Input parameters:		None 无
** Output parameters:		None 无
** Returned value:		    None 无
** Created by:				Steven Zhou 周绍刚
** Created Date:			2007.01.18
**--------------------------------------------------------------------------------------------------------
** Modified by:             Ni Likao 倪力考
** Modified date:           2007.11.02
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
#if (TARGET_LED1_EN > 0) || (TARGET_LED2_EN > 0) || (TARGET_LED3_EN > 0) || (TARGET_LED4_EN > 0)
    void  ledInit (void)
    {
        #if TARGET_LED1_EN > 0
 	        SysCtlPeripheralEnable(LED1_SYSCTL);
	        GPIODirModeSet(LED1_GPIO_PORT, LED1_PIN, GPIO_DIR_MODE_OUT);
            GPIOPadConfigSet(LED1_GPIO_PORT, LED1_PIN, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
        #endif

        #if TARGET_LED2_EN > 0
 	        SysCtlPeripheralEnable(LED2_SYSCTL);
	        GPIODirModeSet(LED2_GPIO_PORT, LED2_PIN, GPIO_DIR_MODE_OUT);
            GPIOPadConfigSet(LED2_GPIO_PORT, LED2_PIN, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
        #endif

        #if TARGET_LED3_EN > 0
 	        SysCtlPeripheralEnable(LED3_SYSCTL);
	        GPIODirModeSet(LED3_GPIO_PORT, LED3_PIN, GPIO_DIR_MODE_OUT);
            GPIOPadConfigSet(LED3_GPIO_PORT, LED3_PIN, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
        #endif

        #if TARGET_LED4_EN > 0
 	        SysCtlPeripheralEnable(LED4_SYSCTL);
	        GPIODirModeSet(LED4_GPIO_PORT, LED4_PIN, GPIO_DIR_MODE_OUT);
            GPIOPadConfigSet(LED4_GPIO_PORT, LED4_PIN, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
        #endif
    }
#endif


/*********************************************************************************************************
** Function name:			ledOn
** Descriptions:			Switch on one or all of the LEDs 点亮其中一个或全部的LED
** Input parameters:		led: The num.of led to be switched on, 1-4 for LED1-LED4, 
**                          0xFF for all leds, others no action
**                          led: 要点亮的LED的号码,1-4代表LED1-LED4,0xFF代表全部LED,其他值无意义。
** Output parameters:		None 无
** Returned value:		    None 无
** Created by:				Steven Zhou 周绍刚
** Created Date:			2007.01.18
**--------------------------------------------------------------------------------------------------------
** Modified by:             Ni Likao 倪力考
** Modified date:           2007.11.02
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
#if (TARGET_LED1_EN > 0) || (TARGET_LED2_EN > 0) || (TARGET_LED3_EN > 0) || (TARGET_LED4_EN > 0)
    void  ledOn (INT8U  ucLed)
    {
        switch (ucLed) {
   	    case 1: 
	        #if TARGET_LED1_EN > 0
      	        GPIOPinWrite(LED1_GPIO_PORT, LED1_PIN, ~LED1_PIN);
	        #endif
            break;
      
        case 2:
	        #if TARGET_LED2_EN > 0
      	        GPIOPinWrite(LED2_GPIO_PORT, LED2_PIN, ~LED2_PIN);
	        #endif
            break;
    
        case 3:
	        #if TARGET_LED3_EN > 0
      	        GPIOPinWrite(LED3_GPIO_PORT, LED3_PIN, ~LED3_PIN);
	        #endif
            break;
    
   	    case 4:
	        #if TARGET_LED4_EN > 0
      	        GPIOPinWrite(LED4_GPIO_PORT, LED4_PIN, ~LED4_PIN);
	        #endif
            break;

	    case 0xFF:
	        #if TARGET_LED1_EN > 0
      	        GPIOPinWrite(LED1_GPIO_PORT, LED1_PIN, ~LED1_PIN);
	        #endif

	        #if TARGET_LED2_EN > 0
      	        GPIOPinWrite(LED2_GPIO_PORT, LED2_PIN, ~LED2_PIN);
	        #endif

            #if TARGET_LED3_EN > 0
      	        GPIOPinWrite(LED3_GPIO_PORT, LED3_PIN, ~LED3_PIN);
	        #endif

	        #if TARGET_LED4_EN > 0
      	        GPIOPinWrite(LED4_GPIO_PORT, LED4_PIN, ~LED4_PIN);
	        #endif
	        break;
	   
        default:
            break;
        }
    }
#endif


/*********************************************************************************************************
** Function name:			ledOff
** Descriptions:			Switch off one or all of the LEDs 关闭其中一个或全部的LED
** Input parameters:		led: The num.of led to be switched off, 1-4 for LED1-LED4, 
**                          0xFF for all leds, others no action
**                          led: 要关闭的LED的号码,1-4代表LED1-LED4,0xFF代表全部LED,其他值无意义。
** Output parameters:		None 无
** Returned value:		    None 无
** Created by:				Steven Zhou 周绍刚
** Created Date:			2007.01.18
**--------------------------------------------------------------------------------------------------------
** Modified by:             Ni Likao 倪力考
** Modified date:           2007.11.02
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
#if (TARGET_LED1_EN > 0) || (TARGET_LED2_EN > 0) || (TARGET_LED3_EN > 0) || (TARGET_LED4_EN > 0)
    void  ledOff (INT8U  ucLed)
    {
        switch (ucLed) {
        case 1: 
	        #if TARGET_LED1_EN > 0
      	        GPIOPinWrite(LED1_GPIO_PORT, LED1_PIN, LED1_PIN);
	        #endif
            break;
      
        case 2:
	        #if TARGET_LED2_EN > 0
      	        GPIOPinWrite(LED2_GPIO_PORT, LED2_PIN, LED2_PIN);
	        #endif
            break;
    
	    case 3: 
	        #if TARGET_LED3_EN > 0
      	        GPIOPinWrite(LED3_GPIO_PORT, LED3_PIN, LED3_PIN);
	        #endif
            break;

	    case 4: 
	        #if TARGET_LED4_EN > 0
      	        GPIOPinWrite(LED4_GPIO_PORT, LED4_PIN, LED4_PIN);
	        #endif
            break;

	    case 0xFF:
	        #if TARGET_LED1_EN > 0
      	        GPIOPinWrite(LED1_GPIO_PORT, LED1_PIN, LED1_PIN);
	        #endif

	        #if TARGET_LED2_EN > 0
      	        GPIOPinWrite(LED2_GPIO_PORT, LED2_PIN, LED2_PIN);
	        #endif

            #if TARGET_LED3_EN > 0
      	        GPIOPinWrite(LED3_GPIO_PORT, LED3_PIN, LED3_PIN);
	        #endif

	        #if TARGET_LED4_EN > 0
      	        GPIOPinWrite(LED4_GPIO_PORT, LED4_PIN, LED4_PIN);
	        #endif
	        break;
	   
        default:
            break;
        }
    }
#endif


/*********************************************************************************************************
** Function name:			ledToggle
** Descriptions:			Toggle one or all of the LEDs 取反其中一个或全部的LED
** Input parameters:		led: The num.of led to be toggled, 1-4 for LED1-LED4, 
**                          0xFF for all leds, others no action
**                          led: 要取反的LED的号码,1-4代表LED1-LED4,0xFF代表全部LED,其他值无意义。
** Output parameters:		None 无
** Returned value:		    None 无         
** Created by:				Steven Zhou 周绍刚
** Created Date:			2007.01.18
**--------------------------------------------------------------------------------------------------------
** Modified by:             Ni Likao 倪力考
** Modified date:           2007.11.02
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
#if (TARGET_LED1_EN > 0) || (TARGET_LED2_EN > 0) || (TARGET_LED3_EN > 0) || (TARGET_LED4_EN > 0)
    void  ledToggle (INT8U  ucLed)
    {
        switch (ucLed) {
        case 1: 
	        #if TARGET_LED1_EN > 0
      	        GPIOPinWrite(LED1_GPIO_PORT, LED1_PIN, ~GPIOPinRead(LED1_GPIO_PORT, LED1_PIN));
	        #endif
            break;
      
        case 2:
            #if TARGET_LED2_EN > 0
    	        GPIOPinWrite(LED2_GPIO_PORT, LED2_PIN, ~GPIOPinRead(LED2_GPIO_PORT, LED2_PIN));
	        #endif
            break;
    
        case 3:
            #if TARGET_LED3_EN > 0
    	        GPIOPinWrite(LED3_GPIO_PORT, LED3_PIN, ~GPIOPinRead(LED3_GPIO_PORT, LED3_PIN));
	        #endif
            break;

	    case 4:
            #if TARGET_LED4_EN > 0
    	        GPIOPinWrite(LED4_GPIO_PORT, LED4_PIN, ~GPIOPinRead(LED4_GPIO_PORT, LED4_PIN));
	        #endif
            break;

	    case 0xFF:
	        #if TARGET_LED1_EN > 0
	  	        GPIOPinWrite(LED1_GPIO_PORT, LED1_PIN, ~GPIOPinRead(LED1_GPIO_PORT, LED1_PIN));
	        #endif

	        #if TARGET_LED2_EN > 0
	  	        GPIOPinWrite(LED2_GPIO_PORT, LED2_PIN, ~GPIOPinRead(LED2_GPIO_PORT, LED2_PIN));
	        #endif

            #if TARGET_LED3_EN > 0
    	        GPIOPinWrite(LED3_GPIO_PORT, LED3_PIN, ~GPIOPinRead(LED3_GPIO_PORT, LED3_PIN));
	        #endif

	        #if TARGET_LED4_EN > 0
    	        GPIOPinWrite(LED4_GPIO_PORT, LED4_PIN, ~GPIOPinRead(LED4_GPIO_PORT, LED4_PIN));
	        #endif
	        break;
	  	  
        default:
            break;
        }
    }
#endif


/*********************************************************************************************************
** Function name:			buzInit 
** Descriptions:			Initialize the target board's buzzer 初始化目标板的蜂鸣器
** Input parameters:		None 无
** Output parameters:		None 无
** Returned value:		    None 无         
** Created by:				Steven Zhou 周绍刚
** Created Date:			2007.01.18
**--------------------------------------------------------------------------------------------------------
** Modified by:             Ni Likao 倪力考
** Modified date:           2007.11.02
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
#if TARGET_BUZ_EN > 0
    void  buzInit (void)
    {
        SysCtlPeripheralEnable(BUZ_SYSCTL);
        GPIODirModeSet(BUZ_GPIO_PORT, BUZ_PIN, GPIO_DIR_MODE_OUT);
        GPIOPadConfigSet(BUZ_GPIO_PORT, BUZ_PIN,GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
        buzOff();
    }
#endif


/*********************************************************************************************************
** Function name:			buzOn
** Descriptions:			Switch on the buzzer 打开蜂鸣器
** Input parameters:		None 无
** Output parameters:		None 无
** Returned value:		    None 无
** Created by:				Steven Zhou 周绍刚
** Created Date:			2007.01.18
**--------------------------------------------------------------------------------------------------------
** Modified by:             Ni Likao 倪力考
** Modified date:           2007.11.02
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
#if TARGET_BUZ_EN > 0
    void  buzOn (void)

⌨️ 快捷键说明

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