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]

Interrupts ? oops !


Oooups Sorry !
I forgot to include my code source in the previous e-mail.

____________________________________

Hello world !

A question from a newbie on the eCos interrupts system :

You can see just under a very little source code in order to test eCos
interrupts on my Linux (Synthetic Target).
1) Is it correct ? I believe and it compiled without any problem.
2) Can I launch next an interrupt to the eCos process under Linux with a
"kill -s 1 ecos_pid" whee ecos_pid is the pid of this process eCos ?
3) Can I use any signal Linux for this application ? What are the eCos
vectors ?

Thanks a lot by advance.
It's my first try on interrupts, so please explain me and sorry if it's to
simple for you ;-) !
Thanks !

Matthieu

____________________________________

My source :

#include <cyg/kernel/kapi.h>
#include <stdio.h>

#define NTHREADS 2
#define STACKSIZE 4096

static cyg_uint32 intr_flag;
static cyg_handle_t thread[NTHREADS];
static cyg_thread thread_obj[NTHREADS];
static char stack[NTHREADS][STACKSIZE];
cyg_thread_entry_t reception;
static cyg_interrupt intr;

cyg_uint32 isr(cyg_vector_t vector, cyg_addrword_t data)
{
  cyg_bool_t dsr_required = 0;
  intr_flag = 1;
  return dsr_required ? CYG_ISR_CALL_DSR : CYG_ISR_HANDLED;
}

void cyg_user_start(void)
{
  cyg_handle_t handle;
  intr_flag = 0;

  cyg_interrupt_create(1, 0, 124, isr, NULL, &handle, &intr);
  cyg_interrupt_attach(handle);

  cyg_thread_create(4, reception, (cyg_addrword_t) 0, "thread 0", (void *)
stack[0], STACKSIZE, &thread[0], &thread_obj[0]);
  
  cyg_thread_resume(thread[1]);
}

void reception(cyg_addrword_t data)
{	
  cyg_scheduler_lock();
  printf("\nT2 is waiting ...\n");
  cyg_scheduler_unlock(); 

  while(intr_flag != 1){cyg_thread_delay(100);}

  cyg_scheduler_lock();
  printf("\nT2 OK !!!\n");
  cyg_scheduler_unlock(); 
}


-- 
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]