?? interrupt_timer.c
字號:
//*----------------------------------------------------------------------------
//* 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 : interrupt_timer.c
//* Object : Timer interrupt management
//* : Use LED7 & LED8 for status interrupt
//*
//* 1.0 24/Jun/04 JPP : Creation
//* 1.1 29/Aug/05 JPP : Update AIC definion
//*----------------------------------------------------------------------------
// Include Standard LIB files
#include "Board.h"
#define TIMERPIT_INTERRUPT_LEVEL 1
//*------------------------- Interrupt Function -------------------------------
//*----------------------------------------------------------------------------
//* Function Name : timer0_c_irq_handler
//* Object : C handler interrupt function called by the interrupts
//* assembling routine
//* Output Parameters : increment count_timer0_interrupt
//*----------------------------------------------------------------------------
__ramfunc void timer_c_irq_handler(void)
{
unsigned int status;
//* Interrupt Acknowledge
status = AT91C_BASE_PITC->PITC_PIVR; //讀PIT_PIVR清除中斷
status =status;
// AT91C_BASE_DBGU->DBGU_THR = '*';
//* Read the output state
if ((AT91F_PIO_GetInput(AT91C_BASE_PIOA) & LED1 ) == LED1 )
{
AT91F_PIO_ClearOutput(AT91C_BASE_PIOA, LED1 );
}
else
{
AT91F_PIO_SetOutput( AT91C_BASE_PIOA, LED1 );
}
}
//*-------------------------- External Function -------------------------------
//*----------------------------------------------------------------------------
//* Function Name : timer_init
//* Object : Init timer counter
//* Input Parameters : none
//* Output Parameters : TRUE
//*----------------------------------------------------------------------------
void timer_init ( void )
//* Begin
{
//* Open Timer PIT interrupt
AT91F_AIC_ConfigureIt ( AT91C_BASE_AIC,
AT91C_ID_SYS,
TIMERPIT_INTERRUPT_LEVEL,
AT91C_AIC_SRCTYPE_INT_POSITIVE_EDGE,
timer_c_irq_handler);
AT91F_PITInit(AT91C_BASE_PITC,PIV,MCK);
//AT91C_BASE_PITC->PITC_PIMR = AT91C_PITC_PITEN | AT91C_PITC_PITIEN | (((MCK/16)*PIV)/1000-1) ;
AT91C_BASE_PITC->PITC_PIMR |= AT91C_PITC_PITIEN;
AT91F_AIC_EnableIt (AT91C_BASE_AIC, AT91C_ID_SYS);
//* End
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -