This is the mail archive of the
ecos-discuss@sourceware.cygnus.com
mailing list for the eCos project.
Re: Example ISR,DSR for ARM AEB-1
- To: k e <ndgipper at yahoo dot com>
- Subject: Re: [ECOS] Example ISR,DSR for ARM AEB-1
- From: Jonathan Larmour <jlarmour at redhat dot co dot uk>
- Date: Tue, 08 Feb 2000 20:47:48 +0000
- CC: ecos-discuss at sourceware dot cygnus dot com
- Organization: Red Hat UK Ltd.
- References: <20000208194921.24528.qmail@web1105.mail.yahoo.com>
k e wrote:
>
> Can anyone recommend a source for a simple example
> program for the AEB that shows how to create
> an ISR and DSR? I'd like to have a thread respond
> to a low frequency external interrupt. I'd like to
> keep all of the other drivers on the board which
> are being used by other threads running. Is there
> a means by which I can identify a specific external
> interrupt to cause a specific DSR to be called
> without having to figure out all of the other DSR's
> that are being called by the default ISR?.
>
> Here's the simple application that I'd like to code
> up:
> external interrupt 0 (which is wired to a switch
> on the AEB-1) would cause a DSR that would toggle
> an LED.
I've attached something I quickly knocked up based on an old example of
mine. I haven't compiled it, so expect any sort of problems with it :-).
It should give you an idea of what's going on.
Jifl
--
Red Hat, 35 Cambridge Place, Cambridge, UK. CB2 1NS Tel: +44 (1223) 728762
"Plan to be spontaneous tomorrow." || These opinions are all my own fault
#include <cyg/kernel/kapi.h>
#include <stdio.h>
#include <cyg/hal/hal_intr.h>
volatile int i=0;
/* this is the ISR for ext 0 interrupts */
cyg_uint32 int_0_isr(cyg_vector_t vector, cyg_addrword_t data)
{
/* ISRs must acknowledge the interrupt, or they might be invoked
again */
cyg_interrupt_acknowledge(vector);
return CYG_ISR_CALL_DSR;
}
/* this is the DSR for ext 0 interrupts */
void int_0_dsr(cyg_vector_t vector, cyg_ucount32 count, cyg_addrword_t data)
{
i += count;
}
int main( int argc, char *argv[] )
{
cyg_handle_t int_0_ISR_H;
cyg_interrupt intr;
int oldi = 0;
/* create an interrupt handler with int_0_isr() as the ISR
and int_0_dsr() as the DSR. */
cyg_interrupt_create(CYGNUM_HAL_INTERRUPT_EXT0, 0, 0, &int_0_isr,
&int_0_dsr, &int_0_ISR_H, &intr);
cyg_interrupt_attach(int_0_ISR_H);
for (;;) {
if (i != oldi) {
printf("Now received %d interrupts\n", i);
oldi = i;
}
}
return 0;
}