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

📄 iar-

📁 IAR_example_EasyARM8962.zip
💻
📖 第 1 页 / 共 2 页
字号:
    }
#endif


/*********************************************************************************************************
** Function name:       buzOff
** Descriptions:	Switch off the buzzer 关闭蜂鸣器
** Input parameters:	None 无
** Output parameters:	None 无
** Returned value:	None 无
** Created by:		Steven Zhou 周绍刚
** Created Date:	2007.12.12
**--------------------------------------------------------------------------------------------------------
** Modified by:            
** Modified date:          
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
#if TARGET_BUZ_EN > 0
    void  buzOff (void)
    {
        GPIOPinWrite(BUZ_GPIO_PORT, BUZ_PIN, BUZ_PIN);
    }
#endif


/*********************************************************************************************************
** Function name:       buzToggle
** Descriptions:        Toggle the buzzer 取反蜂鸣器
** Input parameters:    None 无
** Output parameters:   None 无
** Returned value:      None 无
** Created by:	        Steven Zhou 周绍刚
** Created Date:        2007.12.12
**--------------------------------------------------------------------------------------------------------
** Modified by:            
** Modified date:          
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
#if TARGET_BUZ_EN > 0
    void buzToggle (void)    
    {
        GPIOPinWrite(BUZ_GPIO_PORT, BUZ_PIN, ~GPIOPinRead(BUZ_GPIO_PORT, BUZ_PIN));
    }
#endif


/*********************************************************************************************************
** Function name:       keyInit
** Descriptions:	Initialize the target board's keys,support up to 4 keys 
**                      初始化目标板的按键,最多支持4个
** Input parameters:    None 无
** Output parameters:	None 无
** Returned value:	None 无
** Created by:		Steven Zhou 周绍刚
** Created Date:	2007.12.12
**--------------------------------------------------------------------------------------------------------
** Modified by:             
** Modified date:           
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
#if (TARGET_KEY1_EN > 0) ||  (TARGET_KEY2_EN > 0) || (TARGET_KEY3_EN > 0) || (TARGET_KEY4_EN > 0)
    void keyInit (void)    
    {
        #if TARGET_KEY1_EN > 0
            SysCtlPeripheralEnable(KEY1_SYSCTL);
	    GPIODirModeSet(KEY1_GPIO_PORT, KEY1_PIN, GPIO_DIR_MODE_IN);
            GPIOPadConfigSet(KEY1_GPIO_PORT, KEY1_PIN, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
        #endif	
 
        #if TARGET_KEY2_EN > 0
 	    SysCtlPeripheralEnable(KEY2_SYSCTL);
	    GPIODirModeSet(KEY2_GPIO_PORT, KEY2_PIN, GPIO_DIR_MODE_IN);
            GPIOPadConfigSet(KEY2_GPIO_PORT, KEY2_PIN, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
        #endif	    

        #if TARGET_KEY3_EN > 0
 	    SysCtlPeripheralEnable(KEY3_SYSCTL);
	    GPIODirModeSet(KEY3_GPIO_PORT, KEY3_PIN, GPIO_DIR_MODE_IN);
            GPIOPadConfigSet(KEY3_GPIO_PORT, KEY3_PIN, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
        #endif	  

        #if TARGET_KEY4_EN > 0
 	    SysCtlPeripheralEnable(KEY4_SYSCTL);
	    GPIODirModeSet(KEY4_GPIO_PORT, KEY4_PIN, GPIO_DIR_MODE_IN);
            GPIOPadConfigSet(KEY4_GPIO_PORT, KEY4_PIN, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
        #endif	  
    }
#endif


/*********************************************************************************************************
** Function name:       keyRead
** Descriptions:	Read the status of the keys. 读取按键的状态
** Input parameters:	None 无
** Output parameters:	None 无
** Returned value:	8-bit unsigned char data. Bit0-bit3 stand for the status of Key1-Key4,
**                                                Bit4-Bit7 no meaning
**                      8位无符号数,位0-位3表示Key1-Key4的状态,位4-位7无意义         
** Created by:	        Steven Zhou 周绍刚
** Created Date:        2007.12.12
**--------------------------------------------------------------------------------------------------------
** Modified by:           
** Modified date:          
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
#if (TARGET_KEY1_EN > 0) ||  (TARGET_KEY2_EN > 0) || (TARGET_KEY3_EN > 0) || (TARGET_KEY4_EN > 0)
    INT8U keyRead (void)
    {
        INT8U ucTemp;

        ucTemp = 0xFF;

        #if TARGET_KEY1_EN > 0
	    if (!GPIOPinRead(KEY1_GPIO_PORT, KEY1_PIN)) {
                ucTemp &= 0xFE;  
            }
        #endif

        #if TARGET_KEY2_EN > 0
	    if (!GPIOPinRead(KEY2_GPIO_PORT, KEY2_PIN)) { 
                ucTemp &= 0xFD; 
            }
        #endif

        #if TARGET_KEY3_EN > 0
            if (!GPIOPinRead(KEY3_GPIO_PORT, KEY3_PIN)) {
                ucTemp &= 0xFB; 
            }
        #endif

        #if TARGET_KEY4_EN > 0
            if (!GPIOPinRead(KEY4_GPIO_PORT, KEY4_PIN)) {
                ucTemp &= 0xF7; 
            }
        #endif     

        return(ucTemp);
    }
#endif


/*********************************************************************************************************
** Function name:       timer0AInit
** Descriptions:	Initialize Timer0A to 32bit timeout 初始化定时器0A为32位超时
** Input parameters:	Tick: Number of timeout tick 超时脉冲数
                        Prio: Interrupt priority 中断优先级
** Output parameters:	None 无
** Returned value:	None 无
** Created by:		Steven Zhou 周绍刚
** Created Date:        2007.12.12
**--------------------------------------------------------------------------------------------------------
** Modified by:         
** Modified date:       
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
#if TARGET_TMR0A_EN > 0
    void timer0AInit (INT32U  ulTick, INT8U  ucPrio)
    {
        SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
  	TimerConfigure(TIMER0_BASE, TIMER_CFG_32_BIT_PER);
  	TimerLoadSet(TIMER0_BASE, TIMER_A, ulTick);
  	TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
  	IntEnable(INT_TIMER0A);
  	IntPrioritySet(INT_TIMER0A, ucPrio);
	TimerEnable(TIMER0_BASE, TIMER_A);  	
            
    }
#endif


/*********************************************************************************************************
** Function name:       timer0AISR
** Descriptions:	Timeout interrupt handler of Timer0A 定时器0A超时中断
** Input parameters:	None 无
** Output parameters:	None 无
** Returned value:	None 无        
** Created by:		Steven Zhou 周绍刚
** Created Date:	2007.12.12
**--------------------------------------------------------------------------------------------------------
** Modified by:             
** Modified date:           
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
#if TARGET_TMR0A_EN > 0
    void timer0AISR (void)
    {
        /*
         *  Optional Code. If you don't call any uC/OS-II's functions & variables, 
         *  this code can be cancelled
         *  选择代码,如果你没有调用任何的uC/OS-II的函数和变量,可选择不编译这段代码.
         */ 
        #if 1
            #if OS_CRITICAL_METHOD == 3
                OS_CPU_SR cpu_sr;
            #endif 

            OS_ENTER_CRITICAL();                       
            OSIntNesting++;
            OS_EXIT_CRITICAL();
        #endif 
  
        TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);	                /*  Clear the interrupt flag.   */
                                                                        /*  清空中断标志                */
        /*
         *  Add you initialization code here.
         *  在这里加入你的初始化代码。
         */
        buzToggle();
        
        /*
         *  Optional Code. If you don't call any uC/OS-II's functions & variables,  
         *  this code can be cancelled.
         *  选择代码,如果你没有调用任何的uC/OS-II的函数和变量,可选择不编译这段代码.
         */ 
        
        #if 1 
            OSIntExit();
        #endif      					        
    }
#endif


/*********************************************************************************************************
** Function name:       tickInit
** Descriptions:	Initialize uC/OS-II's tick source(system timer),
                        初始化uC/OS-II的时钟源(系统定时器)
** Input parameters:	None 无
** Output parameters:	None 无
** Returned value:	None 无        
** Created by:		Steven Zhou 周绍刚
** Created Date:	2007.12.12
**--------------------------------------------------------------------------------------------------------
** Modified by:             
** Modified date:           
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
static  void  tickInit (void)
{
    SysTickPeriodSet((INT32U)(SysCtlClockGet() / OS_TICKS_PER_SEC) -1 );
    SysTickEnable();
    SysTickIntEnable();
}


/*********************************************************************************************************
** Function name:       tickISRHandler
** Descriptions:	Timeout interrupt handler of system timer 系统定时器超时中断
** Input parameters:	None 无
** Output parameters:	None 无
** Returned value:	None 无        
** Created by:		Steven Zhou 周绍刚
** Created Date:	2007.12.12
**--------------------------------------------------------------------------------------------------------
** Modified by:            
** Modified date:          
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
void  tickISRHandler (void)
{
    #if OS_CRITICAL_METHOD == 3
        OS_CPU_SR cpu_sr;
    #endif 

    OS_ENTER_CRITICAL();                         
    OSIntNesting++;
    OS_EXIT_CRITICAL();

    OSTimeTick();                                                       /*  Call uC/OS-II's OSTimeTick()*/

    OSIntExit();                                 
}


/*********************************************************************************************************
** Function name:       targetInit
** Descriptions:        Initialize the target board 初始化目标板
** Input parameters:    None 无
** Output parameters:   None 无
** Returned value:      None 无        
** Created by:	        Steven Zhou 周绍刚
** Created Date:        2007.12.12
**--------------------------------------------------------------------------------------------------------
** Modified by:             
** Modified date:           
**--------------------------------------------------------------------------------------------------------
*********************************************************************************************************/
void  targetInit (void)
{
    #if PLL_EN == 0                                                     /*  Not use PLL  不使用PLL      */ 
        SysCtlClockSet(CCLK_DIV | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | EXT_CLK); 
                                                                        /*  System clock=               */
                                                                        /*  EXT_CLK/CCLK_DIV            */
                                                                        /*  系统时钟=EXT_CLK/CCLK_DIV   */ 

    #else                                                               /*  Use PLL  使用PLL            */  
        SysCtlClockSet(CCLK_DIV | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | EXT_CLK); 
                                                                        /*  System clock=200MHz/CCLK_DIV*/
                                                                        /*  系统时钟=200MHz/CCLK_DIV    */ 
    #endif
  
    tickInit();                                                         /*  Initialize the uC/OS-II tick*/ 
                                                                        /*  interrupt,using the Kernal's*/
                                                                        /*  timer                       */    
    /*
     *  Add you initialization code here.
     *  在这里加入你的初始化代码。
     */
    
}


/*********************************************************************************************************
  END FILE 
*********************************************************************************************************/

⌨️ 快捷键说明

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