/*
Function Name: Timer1Timeout.
Parameters: void *handle - This is void * because we are re-using the
armul_Event typedef for pointers to event functions
and this specified that a void* is used instead
of a specific type.
Return: unsigned - always return 0;
Description: This function is registered as the function to call when timer 1
times out.
Notes: Note that we check that the intcInterface has been installed correctly
by MemInit - if it hasn't then we do a late installation.
The check is prudent for pointers to functions/handles.
The late installation is an alternative to bombing out - this
is really a protection against user who don't read the documentation
and ignore the warnings that intc MUST be the first peripheral
in the peripheral list in armul.cnf. - or for users who have simply
left out the intc from their armul.cnf. These checks could be removed
to slightly improve performace for very timer intensive systems.
*/
static void Timer1Timeout(void *handle)
{
TimerState *ts = (TimerState*)handle;
timer_state *myTimer = &ts->timer1;
#ifdef VERBOSE_TIMEOUT
printf("Timer:1:Timeout.\n");
#endif
myTimer->timedCallback = NULL;
/* Check that we have the intc interface installed */
if (iCheckIntcIf(ts))
{
#ifdef VERBOSE_NOINTC
printf("Timer:1: no interrupt controller available.\n");
#endif
return;
}
{
GenericAccessCallback *cb1 = *ts->intcInterface;
ARMword data = 1;
cb1->func(cb1,myTimer->interruptNumber,&data,ACCESS_WRITE_WORD);
}
/* See if the timer should be restarted - and if so in what mode */
RunTimerAgain( ts, myTimer);
}
/* See TimerTimeout for function comment block */
static void Timer2Timeout(void *handle)
{
TimerState *ts = (TimerState*)handle;
timer_state *myTimer = &ts->timer2;
#ifdef VERBOSE_TIMEOUT
printf("Timer:2:Timeout.\n");
#endif
myTimer->timedCallback = NULL;
/* Check that we have the intc interface installed */
if (iCheckIntcIf(ts))
{
#ifdef VERBOSE_NOINTC
printf("Timer:2: no interrupt controller available.\n");
#endif
return;
}
{
GenericAccessCallback *cb1 = *ts->intcInterface;
ARMword data = 1;
cb1->func(cb1,myTimer->interruptNumber,&data,ACCESS_WRITE_WORD);
}
RunTimerAgain( ts, myTimer);
}
/****************************************************************************************/
/* NAME: test.c */
/* DESC: test doby through I/O Port with timer interrupt(1s). */
/* Date: 06.18.2008 */
/* version: 0.0 */
/* Program: Shen Hui (Shh) */
/****************************************************************************************/
/* 程序主要演示怎样使用armulator的定时器中断.输入也可以不在程序中赋值,直接在内存中改 */
/* 关键的地方在: */
/* 1>.要打开中断. */
/* 2>.要更改IRQ的服务程序. */
/* 3>.'服务程序'必须离'矢量'在32MB范围内.即25位地址. */
/* 4>.无中断矢量初始化程序(无.s文件),只设置了IRQ. */
/* 5>.目标CPU必须与调试器一致(例如,同是arm920T). */
/* 6>.MMU/PU initialization Pagetab必须设置为NO_PAGERABLES,否则映射不对 */
/****************************************************************************************/
/*Input: */
/* 0805ff01: D0-start h active */
/* 0805ff02: D0-stop l active */
/*Output: */
/* 0805ff0d: D0-doby1 l active 0805ff0e: D0-doby1 l active */
/* D1-doby1 l active D1-doby1 l active */
/* D2-doby1 l active D2-doby1 l active */
/* D3-doby1 l active D3-doby1 l active */
/* D4-doby1 l active D4-doby1 l active */
/* D5-doby1 l active D5-doby1 l active */
/* D6-doby1 l active D6-doby1 l active */
/* D7-doby1 l active D7-doby1 l active */
/****************************************************************************************/ #include "test.h" void itoa2(unsigned short n, unsigned char *str)
{//not find itoa in stdlib.h
int i=0;
int swap;
do
{
str=n%2+'0';
i++;