//*----------------------------------------------------------------------------
//* ATMEL Microcontroller Software Support - ROUSSET -
//*----------------------------------------------------------------------------
//* The software is delivered "AS IS" without warranty or condition of any
//* kind, either express, implied or statutory. This includes without
//* limitation any warranty or condition with respect to merchantability or
//* fitness for any particular purpose, or against the infringements of
//* intellectual property rights of others.
//*----------------------------------------------------------------------------
//* File Name : main.c
//* Object : main application written in C
//* 1.0 24/Jun/04 JPP : Creation
//* 1.1 21/Feb/05 JPP : Update AT91C_RSTC_URSTEN
//* 1.2 29/Aug/05 JPP : Update AIC definion
//*----------------------------------------------------------------------------
// Include Standard LIB files
#include "Board.h"
//* Waiting time between LED1 and LED2
#define WAIT_TIME MCK
#define PIO_INTERRUPT_LEVEL 6
#define IRQ0_INTERRUPT_LEVEL 2
#define SOFT_INTERRUPT_LEVEL 5
#define FIQ_INTERRUPT_LEVEL 0
//* Global variable
int count_timer0_interrupt;
int count_timer1_interrupt;
// Use the Library Handler defined in file periph/pio/pio_irq/irq_pio.s
extern void FIQ_init_handler(void);
extern void at91_IRQ0_handler(void);
// External Function Prototype
extern void timer_init (void );
extern void Usart_init (void);
//*----------------------------------------------------------------------------
//* Function Name : aic_software_interrupt
//* Object : Software interrupt function
//* Input Parameters : none
//* Output Parameters : none
//* Functions called : at91_pio_write
//*----------------------------------------------------------------------------
__ramfunc void aic_software_interrupt(void)
{
//* Read the output state
if ( (AT91F_PIO_GetInput(AT91C_BASE_PIOA) & LED2 ) == LED2 )
{
AT91F_PIO_ClearOutput( AT91C_BASE_PIOA, LED2 );
}
else
{
AT91F_PIO_SetOutput( AT91C_BASE_PIOA, LED2 );
}
}
//*----------------------------------------------------------------------------
//* Function Name : pio_c_irq_handler
//* Object : Irq Handler called by the irq_pio.s
//* Input Parameters : none
//* Output Parameters : none
//* Functions called : at91_pio_read, at91_pio_write
//*----------------------------------------------------------------------------
__ramfunc void pio_c_irq_handler ( void )
{
int dummy;
//* Read the output state
if ( (AT91F_PIO_GetInput(AT91C_BASE_PIOA) & LED2 ) == LED2 )
{
AT91F_PIO_ClearOutput( AT91C_BASE_PIOA, LED2);
}
else
{
AT91F_PIO_SetOutput( AT91C_BASE_PIOA, LED2);
}
//* enable the next PIO IRQ
dummy =AT91C_BASE_PIOA->PIO_ISR;
//* suppress the compilation warning
dummy =dummy;
//* while SW3 is push wait
while ( (AT91F_PIO_GetInput(AT91C_BASE_PIOA) & SW3_MASK ) != SW3_MASK );
}
//*----------------------------------------------------------------------------
//* Function Name : delay
//* Object : Wait
//* Input Parameters : none
//* Output Parameters : none
//* Functions called : none
//*----------------------------------------------------------------------------
void delay ( void )
{
//* Set in Volatile for Optimisation
volatile unsigned int i ;
//* loop delay
for ( i = 0 ;(i < WAIT_TIME/100 );i++ ) ;
}
//*----------------------------------------------------------------------------
//* Function Name : main
//* Object : Main interrupt function
//* level timer 0 => 1
//* SW2 level Irq0 => 2
//* level timer 1 => 4
//* SW4 level PIOA => 6
//* level USART => 7
//* LEVEL FIQ => MAX
//* Input Parameters : none
//* Output Parameters : TRUE
//*----------------------------------------------------------------------------
int main( void )
//* Begin
{
unsigned int loop_count ;
AT91PS_AIC pAic;
//* Load System pAic Base address
pAic = AT91C_BASE_AIC;
//* Enable User Reset and set its minimal assertion to 960 us
AT91C_BASE_RSTC->RSTC_RMR = AT91C_RSTC_URSTEN | (0x4<<8) | (unsigned int)(0xA5<<24);
//* Init
loop_count = 0 ;
// First, enable the clock of the PIOB
AT91F_PMC_EnablePeriphClock ( AT91C_BASE_PMC, 1 << AT91C_ID_PIOA ) ;
//* then, we configure the PIO Lines corresponding to LED1 to LED8
//* to be outputs. No need to set these pins to be driven by the PIO because it is GPIO pins only.
AT91F_PIO_CfgOutput( AT91C_BASE_PIOA, LED_MASK ) ;
//* Clear the LED's. On the EB55 we must apply a "1" to turn off LEDs
AT91F_PIO_SetOutput( AT91C_BASE_PIOA, LED_MASK ) ;
//* open external PIO interrupt
//* define switch SW3 at PIO input for interrupt IRQ loop
AT91F_PIO_CfgInput(AT91C_BASE_PIOA, SW3_MASK | SW4_MASK);
AT91F_AIC_ConfigureIt ( pAic, AT91C_ID_PIOA, PIO_INTERRUPT_LEVEL,AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL, pio_c_irq_handler);
AT91F_PIO_InterruptEnable(AT91C_BASE_PIOA,SW4_MASK);
//* set the interrupt by software
AT91F_AIC_EnableIt (pAic, AT91C_ID_PIOA);
//* open external IRQ interrupt
AT91F_PIO_CfgPeriph(AT91C_BASE_PIOA,SW2_MASK,0);
//* open external IRQ0 interrupt
AT91F_AIC_ConfigureIt ( pAic, AT91C_ID_IRQ0, IRQ0_INTERRUPT_LEVEL,AT91C_AIC_SRCTYPE_EXT_NEGATIVE_EDGE, at91_IRQ0_handler);
AT91F_AIC_EnableIt (pAic, AT91C_ID_IRQ0);
//* Open the software interrupt on the AIC
AT91F_AIC_ConfigureIt ( pAic, AT91C_ID_SYS, SOFT_INTERRUPT_LEVEL, AT91C_AIC_SRCTYPE_INT_POSITIVE_EDGE, aic_software_interrupt);
AT91F_AIC_EnableIt (pAic, AT91C_ID_SYS);
//* open FIQ interrupt
AT91F_PIO_CfgPeriph(AT91C_BASE_PIOA,SW1_MASK,0);
AT91F_AIC_ConfigureIt ( pAic, AT91C_ID_FIQ, FIQ_INTERRUPT_LEVEL,AT91C_AIC_SRCTYPE_EXT_NEGATIVE_EDGE, FIQ_init_handler);
AT91F_AIC_EnableIt (pAic, AT91C_ID_FIQ);
//* generate FIQ interrupt by software
AT91F_AIC_Trig (pAic,AT91C_ID_FIQ) ;
//* Init timer interrupt
timer_init();
//* Init Usart
Usart_init();
//* generate software interrupt
AT91F_AIC_Trig (pAic,AT91C_ID_SYS) ;
for (;;)
{
AT91F_PIO_ClearOutput( AT91C_BASE_PIOA, LED1 );
delay () ;
AT91F_PIO_SetOutput( AT91C_BASE_PIOA, LED1 );
delay () ;
loop_count ++ ;
//* Set LED by software interrupt
if (loop_count == 10)
{
loop_count=0;
//* Software interrupt
AT91F_AIC_Trig (pAic,AT91C_ID_SYS) ;
}
}
//* End
}
没有合适的资源?快使用搜索试试~ 我知道了~
AT91SAM7S-Interrupt.rar_AT91 INTERRUPT_at91sam7s interrupt_proje
共96个文件
entries:8个
c:8个
repository:8个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 182 浏览量
2022-09-20
20:06:50
上传
评论
收藏 367KB RAR 举报
温馨提示
AT91 SAM7S Interrupt Management This project demonstrates how to use the AT91 ARM-Based Software Package. It runs on the AT91SAM7S-EK shows how to manage interrupts on the SAM7S64. Reference Documents
资源推荐
资源详情
资源评论
收起资源包目录
AT91SAM7S-Interrupt.rar (96个子文件)
AT91SAM7S-Interrupt
Read Me.html 3KB
compil
Obj_KEIL
Interrupt.plg 292B
InterruptSAM7_ADS.Uv2 5KB
InterruptSAM7_KEIL_Uv2.Bak 4KB
InterruptSAM7_GCC_Uv2.Bak 5KB
InterruptSAM7_ADS_Interrupt_ADS_RAM.dep 2KB
InterruptSAM7_KEIL_Opt.Bak 3KB
InterruptSAM7_ADS_Opt.Bak 3KB
Clean.bat 124B
Obj_GCC
InterruptSAM7_GCC.plg 126B
InterruptSAM7_GCC.Opt 3KB
InterruptSAM7_GCC.Uv2 5KB
InterruptSAM7_GCC_Opt.Bak 3KB
SrcADS
Cstartup_SAM7.c 4KB
Cstartup.s 11KB
CVS
Root 58B
Entries 181B
Repository 45B
retarget.c 4KB
board.h 3KB
InterruptSAM7_ADS.Opt 3KB
CVS
Root 58B
Entries.Log 67B
Entries 465B
Repository 38B
InterruptSAM7_GCC_Interrupt_GCC_RAM.dep 3KB
Obj_ADS
interrupt_usart.d 222B
InterruptSAM7_ADS.tra 1KB
InterruptSAM7_ADS.axf 108KB
retarget.d 109B
cstartup_sam7.o 95KB
Cstartup.o 2KB
interrupt_usart.o 98KB
retarget.o 8KB
main.d 167B
ext_irq.d 182B
interrupt_timer.o 99KB
cstartup_sam7.d 210B
InterruptSAM7_ADS.htm 22KB
InterruptSAM7_ADS.map 32KB
main.o 100KB
interrupt_timer.d 222B
InterruptSAM7_ADS.plg 1KB
ext_irq.o 96KB
InterruptSAM7_ADS.lnp 473B
SrcKEIL
Cstartup_SAM7.c 4KB
Cstartup.s 11KB
CVS
Root 58B
Entries 137B
Repository 46B
Board.h 3KB
sam7.html 269B
InterruptSAM7_KEIL.Uv2 4KB
resource
SAM7_ADS_RAM.ini 6KB
SAM7_GCC_FLASH.ini 6KB
GCC_Flash.ld 4KB
ADS_Flash.lin 584B
SAM7_GCC_RAM.ini 6KB
SAM7_Flash_RAM.ini 5KB
JLinkRDI.dll 57KB
JLinkARM.dll 83KB
CVS
Root 58B
Entries 687B
Repository 47B
GCC_RAM.ld 4KB
SAM7_KEIL_FLASH.ini 6KB
SAM7_KEIL_RAM.ini 6KB
ADS_RAM.lin 567B
SAM7_ADS_Flash.ini 6KB
SAM7.setup 881B
tools.html 89KB
SrcGCC
Cstartup_SAM7.c 4KB
Cstartup.s 11KB
CVS
Root 58B
Entries 137B
Repository 45B
Board.h 5KB
InterruptSAM7_ADS_Uv2.Bak 5KB
InterruptSAM7_KEIL.Opt 3KB
Src
main.c 7KB
ext_irq.c 2KB
interrupt_timer.c 6KB
CVS
Root 58B
Entries 188B
Repository 25B
interrupt_Usart.c 4KB
CVS
Root 58B
Entries.Log 43B
Entries 46B
Repository 21B
HTML
CVS
Root 58B
Entries 163B
Repository 26B
Basic.html 49KB
orange_degrade_top.gif 1KB
AT91_title.html 396B
共 96 条
- 1
资源评论
御道御小黑
- 粉丝: 58
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功