From: Wolfram Kattanek <wolfram.kattanek@imms.de>
To: Carlos Eduardo dos Reis Rodrigues Sobrinho <epilog@netc.pt>
Cc: eCos Discuss <ecos-discuss@sourceware.cygnus.com>
Subject: Re: [ECOS] Build eCos and Handle/Interrupts problems
Date: Thu, 01 Mar 2001 02:38:00 -0000 [thread overview]
Message-ID: <983443086.3a9e268e1013c@imp.imms.de> (raw)
In-Reply-To: <003a01c0a234$f53898a0$24bd12d4@netc.pt>
Carlos Eduardo dos Reis Rodrigues Sobrinho <epilog@netc.pt>:
> > > I also have some questions about interrupts and handles like how can I
> make
> > > a program with two threads, one that printf the cosine of a number and
> the
> > > other one (don't know if i need another one or if one thread is enough)
> that
> > > is only active when the push button of the AEB is pressed for
> example.The
> > > one near the reset button.
> >
> > You mean the interrupt button? That only delivers an interrupt. Even if
> you
> > configure it to be level triggered (rather than edge triggered) it would
> > mean getting far too many interrupts while the button is depressed.
> >
> > If my understanding is wrong, then find out what interrupt the button is
> > associated with, and write an application using the kernel C API that
> > attaches an ISR and DSR to that interrupt. In the DSR, suspend the thread
> > whatever way you like depending on what its doing (and whether it needs to
> > finish it whenever the button is released).
>
> Sorry to being so anoying but could you or anyone give me and example of
> using and interrupt to call a thread
> Thanks
Here's code snippet which probably will help you:
#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)
{
/* put your code here; for details of ISRs and DSRs see eCos documentation */
/* the following serves only as an example: */
i += count;
}
int main( int argc, char *argv[] )
{
cyg_handle_t int_0_ISR_H;
cyg_interrupt intr;
int oldi = 0;
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;
}
Wolfram
--
Wolfram 'L.A.' Kattanek Institut fuer Mikroelektronik- und
Email: LA@imms.de Mechatronik-Systeme (IMMS) gGmbH
Tel: +49 3677 / 6783-55 Langewiesener Str. 22
Fax: +49 3677 / 6783-38 98693 Ilmenau / Germany
-------------------------------------------------
This mail sent through IMP: imp.imms.de
next prev parent reply other threads:[~2001-03-01 2:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-02-27 23:34 Carlos Eduardo dos Reis Rodrigues Sobrinho
2001-02-28 0:00 ` Jonathan Larmour
2001-03-01 1:56 ` Carlos Eduardo dos Reis Rodrigues Sobrinho
2001-03-01 2:38 ` Wolfram Kattanek [this message]
-- strict thread matches above, loose matches on Subject: below --
2001-02-27 23:29 [ECOS] Build eCos and Handle/Interrupts problems #2 Carlos Eduardo dos Reis Rodrigues Sobrinho
2001-02-27 23:38 ` Jonathan Larmour
2001-02-27 23:54 ` [ECOS] Build eCos and Handle/Interrupts problems Carlos Eduardo dos Reis Rodrigues Sobrinho
2001-02-28 0:05 ` Jonathan Larmour
2001-02-28 12:19 ` Carlos Eduardo dos Reis Rodrigues Sobrinho
2001-02-28 2:45 ` Hugo Tyson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=983443086.3a9e268e1013c@imp.imms.de \
--to=wolfram.kattanek@imms.de \
--cc=ecos-discuss@sourceware.cygnus.com \
--cc=epilog@netc.pt \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).