public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] Interrupt on ARM
@ 2002-04-06  0:18 Jacques Ehrlich
  2002-04-08  4:42 ` Bart Veer
  0 siblings, 1 reply; 2+ messages in thread
From: Jacques Ehrlich @ 2002-04-06  0:18 UTC (permalink / raw)
  To: Ecos-Discuss

Hi !
I'm trying to handle hardware interrupt from external IRQ lines on ARM E7T,
using ecos kernel API :
- void cyg_interrupt_create
- void cyg_interrupt_attach
- void cyg_interrupt_enable
- etc...
but without success.
Where can I find a simple example of source code ?
Below is an abstract of my code :
-----------------------------------------------------
/* ISR interrupt handler */
cyg_uint32 myISR(cyg_vector_t vector, cyg_addrword_t data)
{
	if(*INTPND & (1<<INT_SW3_NUM)){
		// clear interrupt pending IRQ0
		*INTPND |= INT_SW3_MASK;
		flag = 1;
	}
	else if(*INTPND){
		*INTPND = 0x1fffff;
		flag = 2;
	}
	cyg_interrupt_acknowledge(vector);
	return 0;
}

void myDSR(cyg_vector_t vector, cyg_ucount32 count, cyg_addrword_t data)
{

}
void thread(cyg_addrword_t data)
{
	int led1=0, led2=0;
	cyg_handle_t handle;
	cyg_interrupt intr;

	//printf("Entering simpleirq' thread() function\n");
	*IOPMOD |=0xF0;
	*IOPCON = (IO_ENABLE_INT0 | IO_ACTIVE_HIGH_INT0 | IO_RISING_EDGE_INT0);
	/* masquer toutes les it */
	*INTMSK = 0x3fffff;
	/* demasquer G et IRQ0 */
	*INTMSK &= ~((1<<INT_GLOBAL) | (1<<INT_SW3_NUM));


	cyg_interrupt_create((cyg_vector_t)CYGNUM_HAL_VECTOR_IRQ, 0, 0, myISR,
myDSR, &handle, &intr);
	cyg_interrupt_attach(handle);
	*INTPND= 0x1fffff;
	cyg_interrupt_enable();
	cyg_interrupt_unmask((cyg_vector_t)CYGNUM_HAL_VECTOR_IRQ);
	for(;;){
	  while(flag==0);
      if(flag==1){
		  if(led1)led1=0; else led1=1;
	  }
	  else if (flag==2){
		  if(led2)led2=0; else led2=1;
	  }
		SetLEDs((led2<<1) + led1)  ;
	  flag=0;
	}
	cyg_interrupt_mask((cyg_vector_t)CYGNUM_HAL_VECTOR_IRQ);
	cyg_interrupt_disable();
	cyg_interrupt_delete(handle);

	*IOPCON &= ~(IO_ENABLE_INT0 | IO_ACTIVE_HIGH_INT0 | IO_RISING_EDGE_INT0);
	/* masquer G et IRQ0 */
	*INTMSK |= ((1<<INT_GLOBAL) | (1<<INT_SW3_NUM));
}
--
Jacques Ehrlich | LIVIC (INRETS-LCPC) |
http://www.lcpc.fr
Laboratoire sur les Interactions Véhicules, Infrastructure, Conducteurs
tel:33(0)1 4043 2903 | fax:33(0)1 4043 2930 | mob:33(0)6 6336 9499
---



-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [ECOS] Interrupt on ARM
  2002-04-06  0:18 [ECOS] Interrupt on ARM Jacques Ehrlich
@ 2002-04-08  4:42 ` Bart Veer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Veer @ 2002-04-08  4:42 UTC (permalink / raw)
  To: ehrlich; +Cc: ecos-discuss

>>>>> "Jacques" == Jacques Ehrlich <ehrlich@lcpc.fr> writes:

    Jacques> Hi !
    Jacques> I'm trying to handle hardware interrupt from external IRQ lines on ARM E7T,
    Jacques> using ecos kernel API :
    Jacques> - void cyg_interrupt_create
    Jacques> - void cyg_interrupt_attach
    Jacques> - void cyg_interrupt_enable
    Jacques> - etc...
    Jacques> but without success.
    Jacques> Where can I find a simple example of source code ?
    Jacques> Below is an abstract of my code :

    Jacques> cyg_uint32 myISR(cyg_vector_t vector, cyg_addrword_t data)
    Jacques> {
                <snip>
    Jacques> 	return 0;
    Jacques> }

Minor point. That return code should usually be either CYG_ISR_HANDLED
or CYG_ISR_CALL_DSR, unless the hardware requires chained interrupts.

    Jacques> cyg_interrupt_create((cyg_vector_t)CYGNUM_HAL_VECTOR_IRQ, 0, 0, myISR,
    Jacques>                      myDSR, &handle, &intr);

I think the problem here is with the use of CYGNUM_HAL_VECTOR_IRQ. You
have misunderstood the meaning of eCos interrupt vectors.

A typical ARM target has an interrupt controller, either on-chip or
external. The various devices such as clock, serial, ethernet, ...
have their interrupt lines connected to the interrupt controller. The
interrupt controller is in turn connected to the main processor's IRQ
pin. When any device requests an interrupt, the interrupt controller
signals the IRQ pin. The interrupt controller allows various interrupt
sources to be masked, etc. A typical interrupt controller will support
something like 32 interrupt lines, numbered 0-31. Those numbers are
the interrupt vectors that get passed to cyg_interrupt_create(),
cyg_interrupt_mask(), etc.

When the processor receives an IRQ interrupt from the controller,
it switches to an eCos vector service routine or VSR for IRQ's. That
VSR sets up an environment suitable for calling C code. Then it looks
at the interrupt controller to find out which device actually
interrupted, and calls the associated interrupt handler. eCos does
allow applications to install a replacement VSR, and
CYGNUM_HAL_VECTOR_IRQ would be used for that purpose.

The exact details of which vectors are associated with which device
depend on the target, since different targets will have different
interrupt controllers and the various devices may be wired to
different pins on the interrupt controller. Looking at some existing
device drivers may help.

Bart

-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-04-08 11:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-06  0:18 [ECOS] Interrupt on ARM Jacques Ehrlich
2002-04-08  4:42 ` Bart Veer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).