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

📄 main.c

📁 s3c44b0实现中断控制。已通过调试。
💻 C
字号:
#include "inc\44b.h"
#include "common.h"
#include "armisr.h"

void __irq IrqEint3Service()
{
  //
  // Clear interrupt status bit
  //
  rI_ISPC    |= (BIT_EINT3);
  OutPut(0,"External INT3 occured!\n");
}

void __irq IrqEint4567Service()
{
  int irq;

  //
  // Get interruption source
  //
  if   (rEXTINTPND & BIT_EINT6)    irq = 6;
  else if (rEXTINTPND & BIT_EINT7) irq = 7;
  else irq = 0;

  //
  // For IRQ4567, clear extended pending register 
  //
  rEXTINTPND |= (BIT_EINT4|BIT_EINT5|BIT_EINT6|BIT_EINT7);

  //
  // Clear interrupt status bit
  //
  rI_ISPC    |= (BIT_EINT4567);

  if (irq)  OutPut(0,"External Key0%c interruption occured!\n",'0'+ irq-6);
  else      OutPut(0,"External EINT4 or EINT5 occured!\n");

}

void RegisterIrqHandler(NON_VECTOR_HANDLER IrqSrc, void * IRQService)
{
  //
  // Register relanvant handler
  //
  *(uint *)(IRQVECTOR(IrqSrc)) = (uint)IRQService;
}




void SetIrqAttribute()
{
  //
  // Set INT3
  //
  rPCONG  |= 0x00C0;       //Enable EINT3 Func
  rPUPG   &= 0xFFF7;       //DISABLE Pull-up for EXTINT3
  rEXTINT &= 0xFFFF8FFF;   //Set Falling edge
  rEXTINT |= 0x00002000;   //Set Falling edge

  /*
  //
  // Set EINT4
  //
  rPCONG  |= 0x0300;       //Enable EINT4 Func
  rPUPG   &= 0xFFEF;       //Enable Pull-up for EXTINT4
  rEXTINT &= 0xFFF8FFFF;   //Set Falling edge
  rEXTINT |= 0x00040000;   //Set Falling edge  
  */

  //
  // Set EINT6,7
  //
  rPCONG  |= 0xF000;      //Enable EINT4 Func
  rPUPG   &= 0xFF3F;       //Enable Pull-up for EXTINT6,7
  rEXTINT &= 0x0000FFFF;   //Set Falling edge
  rEXTINT |= 0x33330000;   //Set Falling edge  

}


int Main(void)
{

  BoardInit();


  rINTMSK |= ((BIT_EINT3|BIT_EINT4567));  //mask IRQ


  rEXTINTPND |= (BIT_EINT4|BIT_EINT5|BIT_EINT6|BIT_EINT7);

  //
  // Clear interrupt status bit
  //
  rI_ISPC    |= (BIT_EINT4567);

  SetIrqAttribute();

  RegisterIrqHandler(HandlerEINT3,     (void*)IrqEint3Service);

  RegisterIrqHandler(HandlerEINT4567,  (void*)IrqEint4567Service);

  OutPut(0,"Ready to accept IRQ!\n");

  rINTMSK &= (~(BIT_EINT3|BIT_EINT4567));  //Unmask IRQ

  while(1);

  return 0;
}


⌨️ 快捷键说明

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