📄 73x_eic.c
字号:
/******************** (C) COPYRIGHT 2005 STMicroelectronics ********************
* File Name : 73x_eic.c
* Author : MCD Application Team
* Date First Issued : 09/27/2005 : V1.0
* Description : This file provides all the EIC software functions.
**********************************************************************************
* History:
* 09/27/2005 : V1.0
**********************************************************************************
* THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH
* CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT
* OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
* OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
* CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*********************************************************************************/
/* Standard include -----------------------------------------------------------*/
#include "73x_eic.h"
#include "73x_cfg.h"
/* Include of other module interface headers ----------------------------------*/
/* Local includes -------------------------------------------------------------*/
/* Private typedef ------------------------------------------------------------*/
/* Private define -------------------------------------------------------------*/
/* Private macro --------------------------------------------------------------*/
/* Private variables ----------------------------------------------------------*/
/* Private function prototypes ------------------------------------------------*/
/* Interface functions --------------------------------------------------------*/
extern void ARMIRQ_Enable (void); /* Imported from 73x_init.s Assembler file */
extern void ARMFIQ_Enable (void); /* Imported from 73x_init.s Assembler file */
extern void ARMIRQ_Disable (void); /* Imported from 73x_init.s Assembler file */
extern void ARMFIQ_Disable (void); /* Imported from 73x_init.s Assembler file */
/* Private functions ---------------------------------------------------------*/
/******************************************************************************
* Function Name : EIC_Init
* Description : Initializes the EIC peripheral according to the specified
* parameters in the EIC_InitTypeDef structure.
* Input : EIC_InitStruct: pointer to a EIC_InitTypeDef structure that
* contains the configuration information for the EIC peripheral.
* Output : None
* Return : None
******************************************************************************/
void EIC_Init(EIC_InitTypeDef* EIC_InitStruct)
{
extern u32 PRCCUCMU_Addr;
u8 Counter=0;
u32 Offset = (u32)&PRCCUCMU_Addr;
u32 Tmp=0;
/* Initialize the EIC IVR and SIRn registers to be able */
/* to recognize Interrupts ------------------------------------------*/
/* IVR = high half of load PC instruction (LDR PC,) */
EIC->IVR = 0xE59F0000;
/* Read the offset of the interrupt vectors table address */
Offset = (Offset+0x3E0)<<16;
/* Initialize SIRn registers with the equivalent low half of load PC instruction */
for(Counter=64; Counter!=0; Counter--)
{
EIC->SIRn[64-Counter] = Offset|0xF0000000;
Offset += 0x00000004 << 16;
}
/* Enable or disable the select IRQ channel -------------------------*/
if(EIC_InitStruct->EIC_IRQCmd == ENABLE)
{
/* Enable the selected IRQ channel*/
if(EIC_InitStruct->EIC_IRQChannel<32)
{
EIC->IER0 |= 0x0001 << EIC_InitStruct->EIC_IRQChannel;
}
else
{
EIC->IER1 |= 0x0001 << (EIC_InitStruct->EIC_IRQChannel-32);
}
}
else
{
/* Disable the select IRQ channel */
if(EIC_InitStruct->EIC_IRQChannel<32)
{
EIC->IER0 &= ~(0x0001 << EIC_InitStruct->EIC_IRQChannel);
}
else
{
EIC->IER1 &= ~(0x0001 << (EIC_InitStruct->EIC_IRQChannel-32));
}
}
/* Enable or disable the selected FIQ channel -------------------------*/
if(EIC_InitStruct->EIC_FIQCmd == ENABLE)
{
/* Enable the selected FIQ channel*/
EIC->FIR |= EIC_InitStruct->EIC_FIQChannel ;
}
else
{
/* Disable the selected FIQ channel */
EIC->FIR &= ~EIC_InitStruct->EIC_FIQChannel;
}
/* Configure the selected IRQ channel priority */
Tmp = (EIC->SIRn[EIC_InitStruct->EIC_IRQChannel]&0xFFFF0000) | ((u16)EIC_InitStruct->EIC_IRQChannelPriority & 0x000F);
EIC->SIRn[EIC_InitStruct->EIC_IRQChannel] = Tmp;
}
/******************************************************************************
* Function Name : EIC_DeInit
* Description : Initializes the Interrupt Controller to be able with
* the str73x library architecture to handle th interrupt request.
* Input : None
* Output : None
* Return : None
******************************************************************************/
void EIC_DeInit(void)
{
/*Reset EIC peripheral */
CFG_PeripheralClockConfig(CFG_CLK_EIC,DISABLE);
CFG_PeripheralClockConfig(CFG_CLK_EIC,ENABLE);
}
/******************************************************************************
* Function Name : EIC_StructInit
* Description : Fills in a EIC_InitTypeDef structure with the reset value of
* each parameter.
* Input : EIC_InitStruct : pointer to a EIC_InitTypeDef structure
which will be initialized.
* Output : None
* Return : None
******************************************************************************/
void EIC_StructInit(EIC_InitTypeDef* EIC_InitStruct)
{
/* Initialize all the EIC_InitStruct members to 0*/
EIC_InitStruct->EIC_IRQChannel = 0;
EIC_InitStruct->EIC_FIQChannel = 0;
EIC_InitStruct->EIC_IRQCmd = DISABLE;
EIC_InitStruct->EIC_FIQCmd = DISABLE;
EIC_InitStruct->EIC_IRQChannelPriority = 0;
}
/*******************************************************************************
* Function Name : EIC_CurrentPriorityLevelConfig
* Description : Change the current priority level of the served IRQ routine
* Input : NewPriorityLevel: New current priority.
* Output : None
* Return : None
*******************************************************************************/
void EIC_CurrentPriorityLevelConfig(u8 NewPriorityLevel)
{
u32 Val = EIC->ICR; /* Save ICR content */
/* Disable IRQ interrupts */
ARMIRQ_Disable();
EIC->ICR &= ~0x0001;
ARMIRQ_Enable();
/* Change the current priority */
EIC->CIPR = NewPriorityLevel;
/* Restore ICR content */
EIC->ICR = Val;
}
/*******************************************************************************
* Function Name : EIC_IRQChannelConfig
* Description : Enable or Disable the selected IRQ Channel
* Input : - IRQChannel: the selected IRQ channel.
* - NewState: New state of the selected IRQ channel.
* This parameter can be: ENABLE or DISABLE.
* Output : None
* Return : None
*******************************************************************************/
void EIC_IRQChannelConfig(u8 IRQChannel, FunctionalState NewStatus)
{
/* Enable or disable the select IRQ channel */
if (NewStatus == ENABLE)
{
/* Enable the selected IRQ channel*/
if(IRQChannel<32)
{
EIC->IER0 |= 0x0001 << IRQChannel;
}
else
{
EIC->IER1 |= 0x0001 << (IRQChannel-32);
}
}
else
{
/* Disable the selected IRQ channel */
if(IRQChannel<32)
{
EIC->IER0 &= ~(0x0001 << IRQChannel);
}
else
{
EIC->IER1 &= ~(0x0001 << (IRQChannel-32));
}
}
}
/*******************************************************************************
* Function Name : EIC_ExternalITTriggerConfig
* Description : Select the edge or the level in which the external interrupt
* is issued
* Input : - EXTERNAL_IT: The selected External IRQ channel.
* - EXTIT_Trigger : the selected triggering edge or level
* of the external interrupt it can be one of the following value:
* - EXTIT_TRIGGER_Rising_Falling
* - EXTIT_TRIGGER_Rising
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -