Llosa de Viango Tollos – lpcSPI9IO.c



Getting started



  Tollos libraries

  Device libraries





  Sample application


lpcSPI9IO.c – write-only 9 bit SPI glue

This module wraps the interface to the LPC SPI routines using some fixed assumptions:

– write only, Master mode

– 12 MHz (SPI peripheral clock = 96 MHz), or otherwise as fast as permitted (1/8 system clock)

– MSB first

– 9-bit data

– clock polarity high, sample on rising edge

– three-wire interface; SSEL is the chip select line/port

This might be generalized later but currently this is intended to be used by other glue routines, not directly from Tollos.

Polling output is used here because the overhead of using interrupts would not give a useful power or speed saving (at 12 MHz each word being written is only 9 clocks, or 750ns).
 spi9CommandIO   send a one-byte Command
 spi9Command2IO   send a two-byte Command
 spi9DataIO   send byte(s) as Data
 spi9InitIO   initialize SPI and third wire
 spi9StopIO   stop the SPI device

spi9CommandIO – send a one-byte Command

int spi9CommandIO(byte b);

b – byte to send

returns 0 if OK, negative if error

spi9Command2IO – send a two-byte Command

int spi9Command2IO(byte b1, byte b2);

b1 – first byte to send

b2 – second byte to send

returns 0 if OK, negative if error

spi9DataIO – send byte(s) as Data

int spi9DataIO(byte *data, uint length);

data – address of data to send

length – count of bytes to send

returns 0 if OK, negative if error

spi9InitIO – initialize SPI and third wire

void spi9InitIO(void);

SSEL is the GPIO line that will be used for the chip select third wire of the 3-wire 9 bit interface; this could be parameterized later to allow multiple devices to be driven on the SPI bus, providing they all use the same protocol.

See the module header for other assumptions.

spi9StopIO – stop the SPI device

void spi9StopIO(void);

This just disables the SPI clock.

Tollos and these web pages were written by Mike Cowlishaw; Please send me any corrections, suggestions, etc.
All content © Mike Cowlishaw, 2010–2012, except where marked otherwise. All rights reserved. The pages here are for non-commercial use only (see the separate licence for Tollos source code). Privacy policy: the Speleotrove website records no personal information and sets no ‘cookies’. However, statistics, etc. might be recorded by the web hosting service.

This page was last updated on 2011-01-04 by c2wiki.