Newlib-lpc 5a example for SPI?

Started by lpcarmed October 30, 2006
I made a quick test of SPI support of newlib_lpc5b contributed by
Robert/Aeolusdevelopment. I could not get example11.c to use the plain
SPI device without the fram subdevice. This line:

fputs(helwrld, spif)

reported error, but all open/ioctl calls before that line that worked
just fine. I could not see any activity on SPI clock, neither on IO
pin designated by DEVICE_SELECT. Does anyone have a working code
example using the SPI device without subdevices? Does newlib-lpc
support slave or just master? What would it take to add slave support?

An Engineer's Guide to the LPC2100 Series

At 01:26 AM 10/31/2006 +0000, lpcarmed wrote:
>I made a quick test of SPI support of newlib_lpc5b contributed by
>Robert/Aeolusdevelopment. I could not get example11.c to use the plain
>SPI device without the fram subdevice. This line:
>
> fputs(helwrld, spif)
>
>reported error, but all open/ioctl calls before that line that worked
>just fine. I could not see any activity on SPI clock, neither on IO
>pin designated by DEVICE_SELECT. Does anyone have a working code
>example using the SPI device without subdevices?

That's how I originally tested it. I'll see if I can't put something
together as an example. I'm a little puzzled by your symptoms at the
moment though. The likely error returns are due to the device not being
open or busy. Try printing out errno.

You do have do have to do a DEVICE_SELECT to set or clear the chip select
line though.

>Does newlib-lpc
>support slave or just master? What would it take to add slave support?

Just master, no ones attempted a slave as far as I know. I expect a slave
SPI device would look a bit like a UART device.

Robert

http://www.aeolusdevelopment.com/

From the Divided by a Common Language File (Edited to protect the guilty)
ME - "I'd like to get Price and delivery for connector Part # XXXXX"
Dist./Rep - "$X.XX Lead time 37 days"
ME - "Anything we can do about lead time? 37 days seems a bit high."
Dist./Rep - "that is the lead time given because our stock is live.... we
currently have stock."
Incidentally Robert,
The newlib_lpc IIC module has now been tested, slightly modified, and is
now working with an Fram and multiple IO explanders similtaneously.
I will send you an updated copy shortly.
________________________________

From: l... [mailto:l...]
On Behalf Of Robert Adsett
Sent: Tuesday, 31 October 2006 2:10 PM
To: l...; l...
Subject: Re: [lpc2000] Newlib-lpc 5a example for SPI?

.

msgId 280/stime62264313/nc1848622/nc2@25369/nc3848542>
Cheers,
Bruce
At 02:17 PM 10/31/2006 +1100, Bruce Paterson wrote:
>Incidentally Robert,
>The newlib_lpc IIC module has now been tested, slightly modified, and is
>now working with an Fram and multiple IO explanders similtaneously.
>I will send you an updated copy shortly.

Good news.

Robert

http://www.aeolusdevelopment.com/

From the Divided by a Common Language File (Edited to protect the guilty)
ME - "I'd like to get Price and delivery for connector Part # XXXXX"
Dist./Rep - "$X.XX Lead time 37 days"
ME - "Anything we can do about lead time? 37 days seems a bit high."
Dist./Rep - "that is the lead time given because our stock is live.... we
currently have stock."
At 10:09 PM 10/30/2006 -0500, Robert Adsett wrote:
>At 01:26 AM 10/31/2006 +0000, lpcarmed wrote:
> >I made a quick test of SPI support of newlib_lpc5b contributed by
> >Robert/Aeolusdevelopment. I could not get example11.c to use the plain
> >SPI device without the fram subdevice. This line:
> >
> > fputs(helwrld, spif)
> >
> >reported error, but all open/ioctl calls before that line that worked
> >just fine. I could not see any activity on SPI clock, neither on IO
> >pin designated by DEVICE_SELECT. Does anyone have a working code
> >example using the SPI device without subdevices?
>
>That's how I originally tested it. I'll see if I can't put something
>together as an example. I'm a little puzzled by your symptoms at the
>moment though. The likely error returns are due to the device not being
>open or busy. Try printing out errno.

http://www.aeolusdevelopment.com/Additions/AdditionalNewlibSupport.html

A short demo. Sits in an infinite loop send out the SPI toggling the chip
select.

Robert

http://www.aeolusdevelopment.com/

From the Divided by a Common Language File (Edited to protect the guilty)
ME - "I'd like to get Price and delivery for connector Part # XXXXX"
Dist./Rep - "$X.XX Lead time 37 days"
ME - "Anything we can do about lead time? 37 days seems a bit high."
Dist./Rep - "that is the lead time given because our stock is live.... we
currently have stock."
SPI works now. I'm using it in a run to completion style code like this:

if ( ! spi_transferring) {
sel.select_action = SELECT_ACTION_SEL;
ret = ioctl( fileno(spif), DEVICE_SELECT, &sel);
if( fputs(helwrld, spif) == EOF) {
iprintf("could not write spi - errno:%d \r\n", errno);
}
fflush( spif);
spi_transferring = 1;
} else {
if ( chars_waiting( fileno(spif)) < strlen( helwrld)) {
// not there yet - do nothing
} else {
sel.select_action = SELECT_ACTION_DESEL;
ret = ioctl( fileno(spif), DEVICE_SELECT, &sel);
fread( buffer, 1, strlen( helwrld), spif);
spi_transferring = 0;
}
}

Then I wanted to add a non-blocking UART the same way using
uart0_inb.c from the additional newlib support.

ioctl( fileno(stdout), BLOCKING_SETUP, &block_mode)

was successful, however getch() and getchar() always returns with -1,
fread did not bring in any. The chars_waiting returns an error on
stdin. I assumed I do not need to open stdin/stdout. Is there an
example on the non-blocking UART with newlib?
--- In l..., Robert Adsett wrote:
>
> At 10:09 PM 10/30/2006 -0500, Robert Adsett wrote:
> >At 01:26 AM 10/31/2006 +0000, lpcarmed wrote:
> > >I made a quick test of SPI support of newlib_lpc5b contributed by
> > >Robert/Aeolusdevelopment. I could not get example11.c to use the
plain
> > >SPI device without the fram subdevice. This line:
> > >
> > > fputs(helwrld, spif)
> > >
> > >reported error, but all open/ioctl calls before that line that worked
> > >just fine. I could not see any activity on SPI clock, neither on IO
> > >pin designated by DEVICE_SELECT. Does anyone have a working code
> > >example using the SPI device without subdevices?
> >
> >That's how I originally tested it. I'll see if I can't put something
> >together as an example. I'm a little puzzled by your symptoms at the
> >moment though. The likely error returns are due to the device not
being
> >open or busy. Try printing out errno.
>
> http://www.aeolusdevelopment.com/Additions/AdditionalNewlibSupport.html
>
> A short demo. Sits in an infinite loop send out the SPI toggling
the chip
> select.
>
> Robert
>
> http://www.aeolusdevelopment.com/
Catching up, hopefully I haven't missed anything important, my ISP keeps
bouncing an occasional group message as spam and Yahoo several days later
after delivering multiple messages successfully decides the e-mail address
is no longer valid. Sigh.

At 04:54 AM 11/2/2006 +0000, lpcarmed wrote:
>SPI works now. I'm using it in a run to completion style code like this:


>Then I wanted to add a non-blocking UART the same way using
>uart0_inb.c from the additional newlib support.
>
> ioctl( fileno(stdout), BLOCKING_SETUP, &block_mode)
>
>was successful, however getch() and getchar() always returns with -1,
>fread did not bring in any. The chars_waiting returns an error on
>stdin. I assumed I do not need to open stdin/stdout. Is there an
>example on the non-blocking UART with newlib?

I haven't used the non-blocking driver myself. If Jacob is listening he
may be able to help. In the meantime just a quick check, have you set up
the interrupt for the driver? It's derived from the interrupt based version.

Robert

Another sign of the end of civilization, our technical magazines are
getting chatty
From an EETimes product descriptions 2006/08/09
".... systems that can sample gobs of inputs simultaneously"
Now just what is the technical definition for gobs again?
http://www.aeolusdevelopment.com/