SPI Control Module


Defines

#define CPHA   0x04
#define CPOL   0x08
#define MHZ4   0x20
#define MHZ2   0x21
#define MHZ1   0x22

Typedefs

typedef void(* spi_callback )(u8 data, void *privatedata)

Functions

int SPI0_setup (int bitrate, int flags)
int SPI0_IRQ_Control (spi_callback callback, KFifo *fifo, void *privatedata)
int SP0_Tranceive_Blocking (u8 *buffer, int size)

Detailed Description

This module contains functions for controlling the IPACs internal SPI in a blocking or interrupt based system. Currently only the blocking mode is used because the SPI is fast enough that it only blocks for a couple micro-seconds. And background tasks are still running during this time.

Define Documentation

#define CPHA   0x04
 

Motorola CPHA clock phase flag

Definition at line 16 of file ssi.h.

#define CPOL   0x08
 

Motorola CPOL clock polarity flag

Definition at line 18 of file ssi.h.

#define MHZ4   0x20
 

SPI Init bitrates

Definition at line 22 of file ssi.h.


Typedef Documentation

typedef void(* spi_callback)(u8 data, void *privatedata)
 

Callback used for spi in interrupt mode

Parameters:
data byte read from the SPI
privatedata generic user pointer

Definition at line 30 of file ssi.h.


Function Documentation

int SP0_Tranceive_Blocking u8 *  buffer,
int  size
 

Trancieve of buffer of size size Calling this function will transmit the contents of the buffer out of the SPI in the foreground. Data is received simultanously overwrites the contents of buffer.

Parameters:
buffer the array to transmit from and store data in
size the number of characters to transmit from the buffer
Returns:
the number of characters transmitted

int SPI0_IRQ_Control spi_callback  callback,
KFifo fifo,
void *  privatedata
 

Install a callback and transmit fifo in the interrupt handler Once this function has been called the interrupt hander will call callback with every data byte received. Data will be transmitted through fifo as soon as the SPI becomes ready.

Parameters:
callback the receive data callback
fifo the fifo to transmit data from
privatedata generic user pointer
Returns:
SUCCESS

int SPI0_setup int  bitrate,
int  flags
 

Configure the SPI This function is called to set the SPI's bitrate and mode

Parameters:
bitrate MHZ4,MHZ2 or MHZ1 sets the bitrate
flags bitmask of CPHA, CPOL or nothing. See the motorala SPI pdf for descriptions of the various modes
Returns:
SUCCESS


Generated on Fri Mar 3 17:25:46 2006 for EMAC-HCS12-SDK by  doxygen 1.4.6