Sun SPOT API
Green Release  


com.sun.spot.peripheral
Interface ISpiMaster


public interface ISpiMaster

Interface to the SPI master controller. The SPI transfers are done by C code (in spi.c). The transfer is done using DMA in most cases (some small transfers don't bother with it). Each call to the transfer operations defined in this interface require a SpiPcs parameter which defines the peripheral chip select that is to be used (ie which of the 4 channels) plus the configuration required. The configuration is as per the SPI_CSRx register definition. Constants for the fields in the CSR are defined in this interface. Details can be found in the Atmel AT91RM9200 datasheet.


Field Summary
static int CSR_BITS_10
           
static int CSR_BITS_11
           
static int CSR_BITS_12
           
static int CSR_BITS_13
           
static int CSR_BITS_14
           
static int CSR_BITS_15
           
static int CSR_BITS_16
           
static int CSR_BITS_8
           
static int CSR_BITS_9
           
static int CSR_CPOL
           
static int CSR_DLYBCT
           
static int CSR_DLYBCT_1
           
static int CSR_DLYBCT_10
           
static int CSR_DLYBCT_100
           
static int CSR_DLYBCT_2
           
static int CSR_DLYBCT_200
           
static int CSR_DLYBCT_50
           
static int CSR_DLYBS
           
static int CSR_MODE0
           
static int CSR_MODE1
           
static int CSR_MODE2
           
static int CSR_MODE3
           
static int CSR_NCPHA
           
static int CSR_SCBR
           
static int CSR_SCBR_1MHZ
           
static int CSR_SCBR_250K
           
static int CSR_SCBR_2MHZ
           
static int CSR_SCBR_3MHZ
           
static int CSR_SCBR_6MHZ
           
 
Method Summary
 void sendAndReceive(SpiPcs pcs, int txSize, byte[] tx, int rxOffset, int rxSize, byte[] rx)
          General SPI send and receive
 void sendAndReceive(SpiPcs pcs, int deviceAddress, int txSize, byte[] tx, int rxOffset, int rxSize, byte[] rx)
          General SPI send and receive
 int sendReceive8(SpiPcs pcs, int data)
          SPI send of 8 bits, plus simultaneous receive of 8 bits
 int sendReceive8PlusReceive16(SpiPcs pcs, int first)
          SPI send of 8 bits, plus simultaneous receive of 8 bits, then receive 16 bits
 int sendReceive8PlusSend16(SpiPcs pcs, int first, int subsequent)
          SPI send of 8 bits, plus simultaneous receive of 8 bits, then send 16 bits
 int sendReceive8PlusSendN(SpiPcs pcs, int first, int size, byte[] subsequent)
          SPI send of 8 bits, simultaneous receive of 8 bits, then send of multiple 8 bits
 int sendReceive8PlusVariableReceiveN(SpiPcs pcs, int first, byte[] subsequent, PIOPin fifo_pin)
          Specialised SPI send of 8 bits, simultaneous receive of 8 bits, then receive of multiple 8 bits

This routine is highly specialised for the CC2420

the number of bytes received is determined by the 7 bit value read as the first byte after the initial 8 bits

 void setLoopback(boolean b)
          Allows the loopback feature to be turned on and off.
 

Field Detail

CSR_CPOL

static final int CSR_CPOL
See Also:
Constant Field Values

CSR_NCPHA

static final int CSR_NCPHA
See Also:
Constant Field Values

CSR_MODE0

static final int CSR_MODE0
See Also:
Constant Field Values

CSR_MODE1

static final int CSR_MODE1
See Also:
Constant Field Values

CSR_MODE2

static final int CSR_MODE2
See Also:
Constant Field Values

CSR_MODE3

static final int CSR_MODE3
See Also:
Constant Field Values

CSR_BITS_8

static final int CSR_BITS_8
See Also:
Constant Field Values

CSR_BITS_9

static final int CSR_BITS_9
See Also:
Constant Field Values

CSR_BITS_10

static final int CSR_BITS_10
See Also:
Constant Field Values

CSR_BITS_11

static final int CSR_BITS_11
See Also:
Constant Field Values

CSR_BITS_12

static final int CSR_BITS_12
See Also:
Constant Field Values

CSR_BITS_13

static final int CSR_BITS_13
See Also:
Constant Field Values

CSR_BITS_14

static final int CSR_BITS_14
See Also:
Constant Field Values

CSR_BITS_15

static final int CSR_BITS_15
See Also:
Constant Field Values

CSR_BITS_16

static final int CSR_BITS_16
See Also:
Constant Field Values

CSR_SCBR

static final int CSR_SCBR
See Also:
Constant Field Values

CSR_SCBR_1MHZ

static final int CSR_SCBR_1MHZ
See Also:
Constant Field Values

CSR_SCBR_2MHZ

static final int CSR_SCBR_2MHZ
See Also:
Constant Field Values

CSR_SCBR_3MHZ

static final int CSR_SCBR_3MHZ
See Also:
Constant Field Values

CSR_SCBR_6MHZ

static final int CSR_SCBR_6MHZ
See Also:
Constant Field Values

CSR_SCBR_250K

static final int CSR_SCBR_250K
See Also:
Constant Field Values

CSR_DLYBS

static final int CSR_DLYBS
See Also:
Constant Field Values

CSR_DLYBCT

static final int CSR_DLYBCT
See Also:
Constant Field Values

CSR_DLYBCT_1

static final int CSR_DLYBCT_1
See Also:
Constant Field Values

CSR_DLYBCT_2

static final int CSR_DLYBCT_2
See Also:
Constant Field Values

CSR_DLYBCT_10

static final int CSR_DLYBCT_10
See Also:
Constant Field Values

CSR_DLYBCT_50

static final int CSR_DLYBCT_50
See Also:
Constant Field Values

CSR_DLYBCT_100

static final int CSR_DLYBCT_100
See Also:
Constant Field Values

CSR_DLYBCT_200

static final int CSR_DLYBCT_200
See Also:
Constant Field Values
Method Detail

sendReceive8

int sendReceive8(SpiPcs pcs,
                 int data)
SPI send of 8 bits, plus simultaneous receive of 8 bits

Parameters:
pcs - SPI Peripheral Chip Select to use
data - the data to send in bits 7:0
Returns:
byte received in bits 7:0 of int

sendReceive8PlusSend16

int sendReceive8PlusSend16(SpiPcs pcs,
                           int first,
                           int subsequent)
SPI send of 8 bits, plus simultaneous receive of 8 bits, then send 16 bits

Parameters:
pcs - SPI Peripheral Chip Select to use
first - the data to send in bits 0:7
subsequent - the subsequent bytes to send, bits 15:8 then bits 7:0
Returns:
byte received in bits 7:0 of int

sendReceive8PlusSendN

int sendReceive8PlusSendN(SpiPcs pcs,
                          int first,
                          int size,
                          byte[] subsequent)
SPI send of 8 bits, simultaneous receive of 8 bits, then send of multiple 8 bits

Parameters:
pcs - SPI Peripheral Chip Select to use
first - the first 8 bits to send in bits 7:0
size - number of bytes to send
subsequent - the bytes to send
Returns:
byte received in bits 0:7 of int

sendAndReceive

void sendAndReceive(SpiPcs pcs,
                    int txSize,
                    byte[] tx,
                    int rxOffset,
                    int rxSize,
                    byte[] rx)
General SPI send and receive

Parameters:
pcs - SPI Peripheral Chip Select to use
txSize - the number of bytes to send
tx - the bytes to send
rxOffset - positive integer indicating the number of bytes transmitted before rx begins
rxSize - the number of bytes to receive
rx - buffer for the received bytes

sendAndReceive

void sendAndReceive(SpiPcs pcs,
                    int deviceAddress,
                    int txSize,
                    byte[] tx,
                    int rxOffset,
                    int rxSize,
                    byte[] rx)
General SPI send and receive

Parameters:
pcs - SPI Peripheral Chip Select to use
deviceAddress - Board device address to use
txSize - the number of bytes to send
tx - the bytes to send
rxOffset - positive integer indicating the number of bytes transmitted before rx begins
rxSize - the number of bytes to receive
rx - buffer for the received bytes

sendReceive8PlusReceive16

int sendReceive8PlusReceive16(SpiPcs pcs,
                              int first)
SPI send of 8 bits, plus simultaneous receive of 8 bits, then receive 16 bits

Parameters:
pcs - SPI Peripheral Chip Select to use
first - the data to send in bits 0:7
Returns:
bytes received, first in bits 7:0, second in bits 23:16, third in bits 15:8

sendReceive8PlusVariableReceiveN

int sendReceive8PlusVariableReceiveN(SpiPcs pcs,
                                     int first,
                                     byte[] subsequent,
                                     PIOPin fifo_pin)
Specialised SPI send of 8 bits, simultaneous receive of 8 bits, then receive of multiple 8 bits

This routine is highly specialised for the CC2420

the number of bytes received is determined by the 7 bit value read as the first byte after the initial 8 bits

Parameters:
pcs - SPI Peripheral Chip Select to use
first - the first 8 bits to send in bits 7:0
subsequent - byte array to receive data; length (max 127 not including length byte) will be written into first byte
fifo_pin - pin to test for overflow. The INVERSE state of this bit is written into the top bit of the length byte.
Returns:
bits 7:0 --> first 8 bits read

setLoopback

void setLoopback(boolean b)
Allows the loopback feature to be turned on and off. Loopback is useful for testing.

Parameters:
b - true to turn loopback on, false to turn it off

Sun SPOT API
Green Release  


Copyright © 2006 Sun Microsystems, Inc. All Rights Reserved.