public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] How to make a Interrupt driven serial port driver?
@ 2000-10-27 17:53 Ling Su
  2000-10-29 13:43 ` Jonathan Larmour
  0 siblings, 1 reply; 4+ messages in thread
From: Ling Su @ 2000-10-27 17:53 UTC (permalink / raw)
  To: ecos-discuss

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1064 bytes --]

Dear All,
 
I am using a NEC VRC4373 board, as you may know, it has two serial ports. I 
use serial port 1 for GDB, and leave serial port 2 for communication with PC. 
Now I have tested all the io tests on serial port 2, so it works well. My 
question is how I can make a Interrupt driven driver from serial port 2. The 
current serial port driver in eCos supports general Read/Write/ioctl funtions. I 
don't want to waste time on constantly query serial port for input. The ideal 
method will be interrupt trigged when input byte coming. On this platform, only 
one interrupt allocated to UART, serial port 1 for GDB purpose, I think it will 
use Interrupt, too. Is there any general method to implement a interrupt driver 
for serial port B? Or I have to write it from scratch? Is there kernal API 
for me can register such kind of Interrupt for serial port B without producing 
conflict for serial port A? 
 
I looked the kernel source and driver, didn't figure out a simple way, is 
that possible, please help me. Thanks a bounch!
 
Regards,
-Ling

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

* Re: [ECOS] How to make a Interrupt driven serial port driver?
  2000-10-27 17:53 [ECOS] How to make a Interrupt driven serial port driver? Ling Su
@ 2000-10-29 13:43 ` Jonathan Larmour
  2000-10-29 18:28   ` Ling Su
  0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Larmour @ 2000-10-29 13:43 UTC (permalink / raw)
  To: Ling Su; +Cc: ecos-discuss

> Ling Su wrote:
> 
> Dear All,
> 
> I am using a NEC VRC4373 board, as you may know, it has two serial ports.
> I use serial port 1 for GDB, and leave serial port 2 for communication
> with PC. Now I have tested all the io tests on serial port 2, so it works
> well.

Out of interest, what was the problem before?

> My question is how I can make a Interrupt driven driver from serial
> port 2. The current serial port driver in eCos supports general
> Read/Write/ioctl funtions. I don't want to waste time on constantly query
> serial port for input. The ideal method will be interrupt trigged when
> input byte coming. On this platform, only one interrupt allocated to
> UART, serial port 1 for GDB purpose, I think it will use Interrupt, too.
> Is there any general method to implement a interrupt driver for serial
> port B? Or I have to write it from scratch? Is there kernal API for me
> can register such kind of Interrupt for serial port B without producing
> conflict for serial port A?

Look at the end of the serial driver, above the DSR. Here's what it says:

// Note: This device presents a single interrupt for both channels.  Thus
the
// interrupt handler has to query the device and decide which channel needs
service.

and indeed in the code:


       stat = scc_read_ctl(port, R3);
        if (stat & (RR3_AExt | RR3_ATxIP | RR3_ARxIP)) {
            chan = vrc4373_chans[0];  // Hardware channel A
            vrc4373_int(chan, stat>>3);  // Handle interrupt
        } else if (stat & (RR3_BExt | RR3_BTxIP | RR3_BRxIP)) {
            chan = vrc4373_chans[1];  // Hardware channel A
            vrc4373_int(chan, stat);  // Handle interrupt
        } else {

Although the second comment is wrong (it should be channel A then channel
B, not two channel A's obviously) - I'll fix that now.

So in fact it should already be interrupt driven.

Or instead are you asking for some sort of automatic notification to your
application when data arrives?

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

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

* Re: [ECOS] How to make a Interrupt driven serial port driver?
  2000-10-29 13:43 ` Jonathan Larmour
@ 2000-10-29 18:28   ` Ling Su
  2000-10-29 19:02     ` Jonathan Larmour
  0 siblings, 1 reply; 4+ messages in thread
From: Ling Su @ 2000-10-29 18:28 UTC (permalink / raw)
  To: Jonathan Larmour; +Cc: ecos-discuss

> Look at the end of the serial driver, above the DSR. Here's what it says:
>
> // Note: This device presents a single interrupt for both channels.  Thus
> the
> // interrupt handler has to query the device and decide which channel
needs
> service.
>
> and indeed in the code:
>
>
>        stat = scc_read_ctl(port, R3);
>         if (stat & (RR3_AExt | RR3_ATxIP | RR3_ARxIP)) {
>             chan = vrc4373_chans[0];  // Hardware channel A
>             vrc4373_int(chan, stat>>3);  // Handle interrupt
>         } else if (stat & (RR3_BExt | RR3_BTxIP | RR3_BRxIP)) {
>             chan = vrc4373_chans[1];  // Hardware channel A
>             vrc4373_int(chan, stat);  // Handle interrupt
>         } else {
>
> Although the second comment is wrong (it should be channel A then channel
> B, not two channel A's obviously) - I'll fix that now.
>
> So in fact it should already be interrupt driven.
>
> Or instead are you asking for some sort of automatic notification to your
> application when data arrives?
>

Yeah, exactly, what I am asking is how to make a kind of automatic
notification to my application, so that my own serial port handler can
continue process that data when data arrives. Any clue? Thanks!

Rgds,
-Ling

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

* Re: [ECOS] How to make a Interrupt driven serial port driver?
  2000-10-29 18:28   ` Ling Su
@ 2000-10-29 19:02     ` Jonathan Larmour
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Larmour @ 2000-10-29 19:02 UTC (permalink / raw)
  To: Ling Su; +Cc: ecos-discuss

Ling Su wrote:
> 
> > Or instead are you asking for some sort of automatic notification to your
> > application when data arrives?
> >
> 
> Yeah, exactly, what I am asking is how to make a kind of automatic
> notification to my application, so that my own serial port handler can
> continue process that data when data arrives. Any clue? Thanks!

Well, in that case as per another thread on ecos-discuss, you can either:

- use select(), but this has a number of overheads
- use a separate thread to read data, and then signal other threads in your
application
- or just go ahead and modify the source in the driver itself! e.g. by
waking up a thread in the serial DSR. This is one of the advantages of open
source after all.

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

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

end of thread, other threads:[~2000-10-29 19:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-10-27 17:53 [ECOS] How to make a Interrupt driven serial port driver? Ling Su
2000-10-29 13:43 ` Jonathan Larmour
2000-10-29 18:28   ` Ling Su
2000-10-29 19:02     ` Jonathan Larmour

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).