Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: SPI usage

2005-01-13 by Bruce Paterson

Hi,

I've written an interrupt based SPI driver to fit into the newlib 
structure (ioctl, read, write).

It only handles SPI0 at present, but probably could be easily extended
to handle SPI1 as a subdevice. (btw, Why are UART0 and UART1 handled as 
seperate devices rather than sub-devices in  newlib ? Is it because 
UART1 has full handshaking potential and UART0 doesn't ?).

Since SPI is inherently bi-directional, you use read before write to 
setup where you want the received data to go (if you wish). You must do 
a write for anything to happen (read or write), so if you only want to 
read (unusual in an SPI master) just write some crap. Both read and 
write return immediately (this is an interrupt based driver!). You can 
poll for transaction completion, however, by observing return status of 
write with 0 length requested.
Open resets the buffer pointers to nowhere, and ensures only one thread 
can open an SPI device at a time.
Ioctl can be used to setup the speed, clocking polarities and bit order.

It will be quite a while before I'm in a position to test it. Anyone 
willing to give it a bash ? (probable bugs apologised for in advance).

-- 
Cheers,
Bruce
-------------------------------------------------------------------
     /\\\/\\\/\\\    /   /      Bruce Paterson
    /  \\\ \\\ \\\  /   /    Senior Design Engineer
   /   /\\\/\\\/\\\/   /   8 Anzed Court, Mulgrave, Vic, 3170
  /   /  \\\ \\\ \\\  /  PO Box 4112, Mulgrave, Vic, 3170, Australia
/   /    \\\/\\\ \\\/   Ph: +61 3 8561 4232   Fax: +61 3 9560 9055
       Tele-IP Ltd.      Email: bruce@...    Icq: #32015991
                         WWW:   http://www.tele-ip.com       VK3TJN
-------------------------------------------------------------------

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.