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

📄 73x_eic.c

📁 国外LPC2000系列的一些源程序,请大家快快下载
💻 C
📖 第 1 页 / 共 2 页
字号:
*                         - EXTIT_TRIGGER_Falling
*                         - EXTIT_TRIGGER_HIGH_Level
*                         - EXTIT_TRIGGER_LOW_Level
* Output         : None
* Return         : None
*******************************************************************************/
void EIC_ExternalITTriggerConfig(u16 EXTERNAL_IT, EXTIT_TRIGGER_TypeDef EXTIT_Trigger)
{
  /*  Depending on the selected Edge or level and according to the External
   *  Interrupt Configuration Table Configure the External Interrupt Trigger
   *  Event Registers */
  switch (EXTIT_Trigger)
  {
    case EXTIT_TRIGGER_Rising_Falling:
      CFG->EITE0 &= ~ EXTERNAL_IT;
      CFG->EITE1 |=   EXTERNAL_IT;
      CFG->EITE2 |=   EXTERNAL_IT;
      break;

    case EXTIT_TRIGGER_Rising:
      CFG->EITE0 |=  EXTERNAL_IT;
      CFG->EITE1 &=~ EXTERNAL_IT;
      CFG->EITE2 |=  EXTERNAL_IT;
      break;

    case EXTIT_TRIGGER_Falling:
      CFG->EITE0 &=~ EXTERNAL_IT;
      CFG->EITE1 &=~ EXTERNAL_IT;
      CFG->EITE2 |=  EXTERNAL_IT;
      break;

    case EXTIT_TRIGGER_HIGH_Level:
      CFG->EITE0 |=  EXTERNAL_IT;
      CFG->EITE1 |=  EXTERNAL_IT;
      CFG->EITE2 &=~ EXTERNAL_IT;
      break;

    case EXTIT_TRIGGER_LOW_Level:
      CFG->EITE0 &=~ EXTERNAL_IT;
      CFG->EITE1 |=  EXTERNAL_IT;
      CFG->EITE2 &=~ EXTERNAL_IT;
      break;
  }
}


/*******************************************************************************
* Function Name  : EIC_IRQCmd
* Description    : Enables or disables EIC IRQ output request to CPU.
* Input          : NewState: new state of the EIC IRQ output request to CPU.
*                  This parameter can be: ENABLE or DISABLE.
* Output         : None
* Return         : None
*******************************************************************************/
void EIC_IRQCmd( FunctionalState NewState)
{
  
   ARMIRQ_Disable ();


  if (NewState == ENABLE)
  {
    /* Enable EIC IRQ output request to CPU*/
    EIC->ICR  |= EIC_IRQEnable_Mask;
  }
  else
  {
    /* Disable EIC IRQ output request to CPU*/
    EIC->ICR  &= EIC_IRQDisable_Mask;
  }

   ARMIRQ_Enable();

}

/*******************************************************************************
* Function Name  : EIC_FIQCmd
* Description    : Enables or disables EIC FIQ output request to CPU.
* Input          : NewState: new state of the EIC FIQ output request to CPU.
*                  This parameter can be: ENABLE or DISABLE.
* Output         : None
* Return         : None
*******************************************************************************/
void EIC_FIQCmd( FunctionalState NewState)
{
   ARMFIQ_Disable();
  

  if (NewState == ENABLE)
  {
    /* Enable EIC FIQ output request to CPU*/
    EIC->ICR  |= EIC_FIQEnable_Mask;
  }
  else
  {
    /* Disable EIC FIQ output request to CPU*/
    EIC->ICR  &= EIC_FIQDisable_Mask;
  }

  ARMFIQ_Enable();
}

/*******************************************************************************
* Function Name  : EIC_CurrentPriorityLevelValue
* Description    : Returns the current priority level of the current served IRQ
*                  routine
* Input          : None
* Output         : None
* Return         : The current priority level
*******************************************************************************/
u8 EIC_CurrentPriorityLevelValue(void)
{
  return EIC->CIPR;
}

/*******************************************************************************
* Function Name  : EIC_CurrentIRQChannelValue
* Description    : Returns the current served IRQ channel number
* Input          : None
* Output         : None
* Return         : The current served IRQ channel number
*******************************************************************************/
u8 EIC_CurrentIRQChannelValue(void)
{
  /* Reads and return the 6 LSB of the CICR register*/
  return (u8) (EIC->CICR);
}

/*******************************************************************************
* Function Name  : EIC_CurrentFIQChannelValue
* Description    : Returns the current served FIQ channel number.
* Input          : None
* Output         : None
* Return         : The current served FIQ channel number
*******************************************************************************/
u8 EIC_CurrentFIQChannelValue(void)
{
   /* Reads and return the FIP[1:0] bits */
   return (u8) (EIC->FIPR);
}

/*******************************************************************************
* Function Name  : EIC_FIQPendingBitClear
* Description    : Clears the FIQ pending bit of the selected FIQ Channel.
* Input          : FIQ channel : the selected FIQ channel to clear its
                   Correspondent pending bit
* Output         : None
* Return         : None
*******************************************************************************/
void EIC_FIQPendingBitClear(u8 FIQChannel)
{
  /* Clear the correspondent FIP[1:0] bit of the FIQChannel */
  EIC->FIPR   = FIQChannel ;
}

/*******************************************************************************
* Function Name  : EIC_FIQChannelConfig
* Description    : Configures the FIQ Channel.
* Input          : - FIQChannel: the selected channel to change its status
                   - NewStatus : the new status of FIQ channel it can be
                     ENABLE or DISABLE
* Output         : None
* Return         : None
*******************************************************************************/
void EIC_FIQChannelConfig(u8 FIQChannel,FunctionalState NewStatus)
{
  /* Enable or disable the selected FIQ channel */
  if (NewStatus == ENABLE)
  {
    /* Enable the selected FIQ channel*/
    EIC->FIR |= FIQChannel ;
  }
  else
  {
    /* Disable the selected FIQ channel */
    EIC->FIR &= ~FIQChannel;
  }
}

/*******************************************************************************
* Function Name  : EIC_IRQChannelPriorityConfig
* Description    : Configures the selected IRQ channel priority.
* Input          : - IRQChannel: the selected IRQ channel.
*                  - Priority:  the priority to be configured for the IRQchannel
* Output         : None
* Return         : None
*******************************************************************************/
void EIC_IRQChannelPriorityConfig(u8 IRQChannel, u8 Priority)
{
  /* Configure the priority by setting the SIPL[3:0] of the correspondent SIRn register*/
  EIC->SIRn[IRQChannel] = (EIC->SIRn[IRQChannel]&0xFFFF0000) | (u16)Priority & 0x000F;
}

/*******************************************************************************
* Function Name  : EIC_ExternalITFilterConfig
* Description    : Enables or disables a digital filter on external interrupt.
*                 channels INT[15:0]
* Input          : - NewStatus : the new status of the digital filter  it can be
                     ENABLE or DISABLE
* Output         : None
* Return         : None
*******************************************************************************/
void EIC_ExternalITFilterConfig(FunctionalState NewStatus)
{  
  if (NewStatus == ENABLE)
  {
    /* Enable the digital filter */
    CFG->R1 |= EIC_EXTIT_FILTER_Mask;
  }
  else
  {
    /* Disable the digital filter */
    CFG->R1 &= ~EIC_EXTIT_FILTER_Mask;
  }
}


/******************* (C) COPYRIGHT 2005 STMicroelectronics *****END OF FILE****/


⌨️ 快捷键说明

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