This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

help needed: interrupt + semaphore


Hi,

I need your help! I've attached a simplified copy of my System. Only running
an Interrupthandler with a Semaphore.

But it is not running. The Problem: If I receive an external Interupt
(created by a FPGA) the ISR Routine is called, but nothing else. WHY???

What am I doing wrong???

Thanks for your Help!

bye,
Thomas


--- System.c ---

#include <stdio.h>                      /* printf */
#include <stdlib.h>
#include <pkgconf/system.h>
#include <pkgconf/net.h>
#include <pkgconf/posix.h>
#include <pkgconf/kernel.h>
#include <fcntl.h>
#include <mqueue.h>
#include <cyg/kernel/kapi.h>            /* All the kernel specific stuff */
#include <cyg/io/io.h>                  /* I/O functions */
#include <cyg/hal/hal_arch.h>           /* CYGNUM_HAL_STACK_SIZE_TYPICAL */
#include <cyg/hal/hal_intr.h>
#include <cyg/hal/hal_edb7xxx.h>
#include <network.h>

/* ============ */
/* === ecos === */

/* DEFINES */

#define NTHREADS 2
#define STACKSIZE ( CYGNUM_HAL_STACK_SIZE_TYPICAL)

/* STATICS */

static cyg_handle_t		thread[NTHREADS];
static cyg_thread			thread_obj[NTHREADS];
static char				stack[NTHREADS][STACKSIZE];

static cyg_handle_t		hEInt1;
static cyg_interrupt		iEInt1;
static cyg_sem_t			semEINT1;

static void intDSR(cyg_vector_t vector, cyg_ucount32 count, cyg_addrword_t
data)
{
	cyg_semaphore_post(&semEINT1);
}

static cyg_uint32 intE1ISR(cyg_vector_t vector, cyg_addrword_t data)
{
	cyg_interrupt_mask(CYGNUM_HAL_INTERRUPT_EINT1);

	return (CYG_ISR_HANDLED|CYG_ISR_CALL_DSR);  // Run the DSR
}

void INTThread (CYG_ADDRESS data)
{
	while (1)
	{
		cyg_semaphore_wait(&semEINT1);

		diag_printf("INTThread: IRT IRQ1: %.8lX NRT IRQ1:
%.8lX\n\n", IO_SP_IRQ1_IRT, IO_SP_IRQ1_NRT);

		cyg_interrupt_acknowledge(CYGNUM_HAL_INTERRUPT_EINT1);
		cyg_interrupt_unmask(CYGNUM_HAL_INTERRUPT_EINT1);
	}
}

externC void
cyg_user_start( void )
{
	cyg_semaphore_init(&semEINT1, 0);

	cyg_interrupt_create(CYGNUM_HAL_INTERRUPT_EINT1,
		6,                     // Priority - unused
		1,   //  Data item passed to interrupt handler
		intE1ISR,
		intDSR,
		&hEInt1,
		&iEInt1);
	
	cyg_interrupt_attach(hEInt1);
	cyg_interrupt_acknowledge(CYGNUM_HAL_INTERRUPT_EINT1);

	// Interrupt Freigabe
	cyg_interrupt_unmask(CYGNUM_HAL_INTERRUPT_EINT1);
	
	// Interrupts aktivieren
	// external 1
	*(volatile unsigned char *)INTMR1 |= 0x20;

	cyg_interrupt_enable();

	cyg_thread_create (5, INTThread, (cyg_addrword_t) 0, "INTThread",
		(void *)stack[5], STACKSIZE, &thread[5], &thread_obj[5]);
	cyg_thread_resume (thread[5]);

//	cyg_scheduler_start();
}

--- \System.c ---

Mit freundlichen Grüßen
Thomas Edelmann



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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]