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

📄 xirq0.c

📁 最新版IAR FOR ARM(EWARM)5.11中的代码例子
💻 C
字号:
#include <Analogdevices/ioADuC7032.H>
#include "ADuC_IRQ.H"
#include <intrinsics.h>
///////////////////////////////////////////////////////
// Filename:    main.c
// Author:      ADI
// Date:        13/12/2005
// Description: Blinks led(s) on ADuC7032 eval board
//
//              C Program that blinks the LED(s)
//              Can be configured to use
//               1) Interrupts
//               2) Delay Loops
//               3) Timer Delays
//
///////////////////////////////////////////////////////

// Define which delay mechanism is to be used
#define USE_T2_INT         0x0
#define USE_DELAY_LOOP     0x1

static const int iDelayMech        = 0x0;

// Constants
#define WAKEUP_TIMER_BIT         0x00000010
#define DIR_VAL                  0xFF000000

void  InterruptIRQHndlr   (void);

static unsigned long ulLoop   = 0x0;

// Function    : Delay
// Author      : ADI
// Description : main
// Revision    : 13.12.2005 - Initial
void Delay(void)
{
   volatile int iDelay = 0x1FFFF;

   while (iDelay--);
}

// Function    : LedToggle
// Author      : ADI
// Description : Advance leds based on timer interrupt
// Revision    : 13.12.2005 - Initial
#pragma location="block1"
void  LedToggle(void)
{
   // Apps EvalBoard with GP0 to blink
   if (ulLoop%2)
     GP0SET = 0x00010000;
   else
     GP0CLR = 0x00010000;

   ulLoop++;
}

// Function    : InterruptIRQHndlr
// Author      : ADI
// Description : Advance leds based on timer interrupt
// Revision    : 13.12.2005 - Initial
// Project compiled as Thumb but compile this func as
// arm to see the interwork support in operation
__arm void  InterruptIRQHndlr   (void)
{
   if ((IRQSTA & WAKEUP_TIMER_BIT) != 0)      // Timer2 IRQ?
      {
      LedToggle();
      T2CLRI = 0x0; // Clear the interrupt
      }
}

// Function    : ConfigureTimer2
// Description : ConfigureTimer2
// Revision    : 13.12.2005 - Initial
void ConfigureTimer2(void)
{
   // Initialise
   IRQCLR      = WAKEUP_TIMER_BIT;  // Timer2 IRQ
   IRQ         = InterruptIRQHndlr; // Specify Interrupt Service Rountine
   T2LD        = 0x1000;
   T2CON       = 0x2C0;
   IRQEN       = WAKEUP_TIMER_BIT;    // Timer2 IRQ
}

// Function    : main
// Author      : ADI
// Description : main
// Revision    : 13.12.2005 - Initial
int main(void)
{
   GP0CON = 0x0;

   GP0DAT = DIR_VAL;

   // Toggle the leds based on timer interrupt.
   switch(iDelayMech)
     {
     case USE_T2_INT:
       ConfigureTimer2();
       __enable_interrupt();       //      Enable interrupts
       while (1) ; // loop
       break;
     case USE_DELAY_LOOP:
     default:
       while (1)
         {
         LedToggle();
         Delay();
         }
       break;
     }
}


⌨️ 快捷键说明

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