sbbif0.h File Reference


Detailed Description

Serial bit banged interface 0.

 *
 * $Log: sbbif0.h,v $
 * Revision 1.3  2008/08/28 16:11:31  haraldkipp
 * Fixed bitbanging SPI for ARM targets.
 *
 * Revision 1.2  2008/08/11 06:59:59  haraldkipp
 * BSD types replaced by stdint types (feature request #1282721).
 *
 * Revision 1.1  2007/04/12 09:07:54  haraldkipp
 * Configurable SPI added.
 *
 *
 * 

Definition in file sbbif0.h.

Go to the source code of this file.

Defines

#define SBBI0_MAX_DEVICES   4
 Maximum number of devices (chip selects).
#define SBBI0_CS0_ENA()
#define SBBI0_CS0_CLR()
#define SBBI0_CS0_SET()
#define SBBI0_CS1_ENA()
#define SBBI0_CS1_CLR()
#define SBBI0_CS1_SET()
#define SBBI0_CS2_ENA()
#define SBBI0_CS2_CLR()
#define SBBI0_CS2_SET()
#define SBBI0_CS3_ENA()
#define SBBI0_CS3_CLR()
#define SBBI0_CS3_SET()
#define SBBI0_RST0_ENA()
#define SBBI0_RST0_CLR()
#define SBBI0_RST0_SET()
#define SBBI0_RST1_ENA()
#define SBBI0_RST1_CLR()
#define SBBI0_RST1_SET()
#define SBBI0_RST2_ENA()
#define SBBI0_RST2_CLR()
#define SBBI0_RST2_SET()
#define SBBI0_RST3_ENA()
#define SBBI0_RST3_CLR()
#define SBBI0_RST3_SET()
#define SBBI0_SCK_ENA()
#define SBBI0_SCK_CLR()
#define SBBI0_SCK_SET()
#define SBBI0_MOSI_ENA()
#define SBBI0_MOSI_CLR()
#define SBBI0_MOSI_SET()
#define SBBI0_MISO_ENA()
#define SBBI0_MISO_TST()   0
#define SBBI0_INIT()

Functions

int Sbbi0SetMode (ureg_t ix, ureg_t mode)
 Set mode for a given device at SPI0.
void Sbbi0SetSpeed (ureg_t ix, uint32_t rate)
 Set transfer rate for a given device at SPI0.
void Sbbi0Enable (ureg_t ix)
 Enable the serial peripheral interface 0.
void Sbbi0ChipReset (ureg_t ix, ureg_t hi)
 Set or clear a configured reset line for a given device.
void Sbbi0ChipSelect (ureg_t ix, ureg_t hi)
 Set or clear a configured chip select for a given device.
void Sbbi0SelectDevice (ureg_t ix)
 Select the device at a given chip select.
void Sbbi0DeselectDevice (ureg_t ix)
 Deselect the device at a given chip select.
void Sbbi0NegSelectDevice (ureg_t ix)
 Select the device at a given negated chip select.
void Sbbi0NegDeselectDevice (ureg_t ix)
 Deselect the device at a given negated chip select.
uint8_t Sbbi0Byte (uint8_t data)
 Exchange a byte with the currently selected SPI device.
void Sbbi0Transact (CONST void *wdata, void *rdata, size_t len)
 Exchange a specified number of bytes with the currently selected SPI device.


Define Documentation

#define SBBI0_MAX_DEVICES   4

Maximum number of devices (chip selects).

Definition at line 62 of file sbbif0.h.

Referenced by Sbbi0SetMode().

 
#define SBBI0_CS0_ENA (  ) 

Definition at line 536 of file sbbif0.h.

Referenced by Sbbi0ChipSelect().

 
#define SBBI0_CS0_CLR (  ) 

Definition at line 537 of file sbbif0.h.

Referenced by Sbbi0ChipSelect().

 
#define SBBI0_CS0_SET (  ) 

Definition at line 538 of file sbbif0.h.

Referenced by Sbbi0ChipSelect().

 
#define SBBI0_CS1_ENA (  ) 

Definition at line 582 of file sbbif0.h.

Referenced by Sbbi0ChipSelect().

 
#define SBBI0_CS1_CLR (  ) 

Definition at line 583 of file sbbif0.h.

Referenced by Sbbi0ChipSelect().

 
#define SBBI0_CS1_SET (  ) 

Definition at line 584 of file sbbif0.h.

Referenced by Sbbi0ChipSelect().

 
#define SBBI0_CS2_ENA (  ) 

Definition at line 628 of file sbbif0.h.

Referenced by Sbbi0ChipSelect().

 
#define SBBI0_CS2_CLR (  ) 

Definition at line 629 of file sbbif0.h.

Referenced by Sbbi0ChipSelect().

 
#define SBBI0_CS2_SET (  ) 

Definition at line 630 of file sbbif0.h.

Referenced by Sbbi0ChipSelect().

 
#define SBBI0_CS3_ENA (  ) 

Definition at line 674 of file sbbif0.h.

Referenced by Sbbi0ChipSelect().

 
#define SBBI0_CS3_CLR (  ) 

Definition at line 675 of file sbbif0.h.

Referenced by Sbbi0ChipSelect().

 
#define SBBI0_CS3_SET (  ) 

Definition at line 676 of file sbbif0.h.

Referenced by Sbbi0ChipSelect().

 
#define SBBI0_RST0_ENA (  ) 

Definition at line 720 of file sbbif0.h.

Referenced by Sbbi0ChipReset().

 
#define SBBI0_RST0_CLR (  ) 

Definition at line 721 of file sbbif0.h.

Referenced by Sbbi0ChipReset().

 
#define SBBI0_RST0_SET (  ) 

Definition at line 722 of file sbbif0.h.

Referenced by Sbbi0ChipReset().

 
#define SBBI0_RST1_ENA (  ) 

Definition at line 766 of file sbbif0.h.

Referenced by Sbbi0ChipReset().

 
#define SBBI0_RST1_CLR (  ) 

Definition at line 767 of file sbbif0.h.

Referenced by Sbbi0ChipReset().

 
#define SBBI0_RST1_SET (  ) 

Definition at line 768 of file sbbif0.h.

Referenced by Sbbi0ChipReset().

 
#define SBBI0_RST2_ENA (  ) 

Definition at line 812 of file sbbif0.h.

Referenced by Sbbi0ChipReset().

 
#define SBBI0_RST2_CLR (  ) 

Definition at line 813 of file sbbif0.h.

Referenced by Sbbi0ChipReset().

 
#define SBBI0_RST2_SET (  ) 

Definition at line 814 of file sbbif0.h.

Referenced by Sbbi0ChipReset().

 
#define SBBI0_RST3_ENA (  ) 

Definition at line 858 of file sbbif0.h.

Referenced by Sbbi0ChipReset().

 
#define SBBI0_RST3_CLR (  ) 

Definition at line 859 of file sbbif0.h.

Referenced by Sbbi0ChipReset().

 
#define SBBI0_RST3_SET (  ) 

Definition at line 860 of file sbbif0.h.

Referenced by Sbbi0ChipReset().

 
#define SBBI0_SCK_ENA (  ) 

Definition at line 988 of file sbbif0.h.

Referenced by Sbbi0Enable().

 
#define SBBI0_SCK_CLR (  ) 

Definition at line 989 of file sbbif0.h.

Referenced by Sbbi0Byte(), and Sbbi0Enable().

 
#define SBBI0_SCK_SET (  ) 

Definition at line 990 of file sbbif0.h.

Referenced by Sbbi0Byte(), and Sbbi0Enable().

 
#define SBBI0_MOSI_ENA (  ) 

Definition at line 992 of file sbbif0.h.

Referenced by Sbbi0Enable().

 
#define SBBI0_MOSI_CLR (  ) 

Definition at line 993 of file sbbif0.h.

Referenced by Sbbi0Byte(), and Sbbi0Enable().

 
#define SBBI0_MOSI_SET (  ) 

Definition at line 994 of file sbbif0.h.

Referenced by Sbbi0Byte().

 
#define SBBI0_MISO_ENA (  ) 

Definition at line 996 of file sbbif0.h.

Referenced by Sbbi0Enable().

 
#define SBBI0_MISO_TST (  )     0

Definition at line 997 of file sbbif0.h.

Referenced by Sbbi0Byte().

 
#define SBBI0_INIT (  ) 

Value:

Definition at line 1003 of file sbbif0.h.


Function Documentation

int Sbbi0SetMode ( ureg_t  ix,
ureg_t  mode 
)

Set mode for a given device at SPI0.

This is typically the first call in order to use the device. It will not directly enable the SPI hardware. This is done when selecting the device.

Parameters:
ix The device index, starting at 0.
mode The mode to set.
  • 0: Leading edge is rising, data sampled on rising edge.
  • 1: Leading edge is rising, data sampled on falling edge.
  • 2: Leading edge is falling, data sampled on falling edge.
  • 3: Leading edge is falling, data sampled on rising edge.
Returns:
0, if the device index and the mode are both valid. Otherwise the return value will be -1.

Definition at line 77 of file sbbif0.c.

void Sbbi0SetSpeed ( ureg_t  ix,
uint32_t  rate 
)

Set transfer rate for a given device at SPI0.

This is currently a dummy and does nothing.

Parameters:
ix The device index, starting at 0.
rate Transfer rate in bits per second.

Definition at line 95 of file sbbif0.c.

void Sbbi0Enable ( ureg_t  ix  ) 

Enable the serial peripheral interface 0.

Enables SPI with the parameters previously set by Sbbi0SetMode().

Parameters:
ix The device index, starting at 0. The routine will not check if this is valid.

Definition at line 131 of file sbbif0.c.

Referenced by Sbbi0NegSelectDevice(), and Sbbi0SelectDevice().

void Sbbi0ChipReset ( ureg_t  ix,
ureg_t  hi 
)

Set or clear a configured reset line for a given device.

Reset lines must be configured when building the system libraries. This routine silently ignores them, if not configured.

Parameters:
ix The device index, starting at 0.
hi If 0, the reset line is driven low. Otherwise the line is driven high.

Definition at line 158 of file sbbif0.c.

void Sbbi0ChipSelect ( ureg_t  ix,
ureg_t  hi 
)

Set or clear a configured chip select for a given device.

Chip selects must be configured when building the system libraries. This routine silently ignores selects, if they are not configured.

Parameters:
ix The device index, starting at 0. Same as the chip select number.
hi If 0, the chip select is driven low. Otherwise the line is driven high.

Definition at line 213 of file sbbif0.c.

Referenced by Sbbi0DeselectDevice(), Sbbi0NegDeselectDevice(), Sbbi0NegSelectDevice(), and Sbbi0SelectDevice().

void Sbbi0SelectDevice ( ureg_t  ix  ) 

Select the device at a given chip select.

Enables the serial peripheral interface with the parameters previously set for the given device by Sbbi0SetMode() and Sbbi0SetSpeed(). Then the configured chip select line is driven high.

Parameters:
ix The device index, starting at 0. The routine will not check if this is a valid number.

Definition at line 268 of file sbbif0.c.

void Sbbi0DeselectDevice ( ureg_t  ix  ) 

Deselect the device at a given chip select.

The configured chip select line will be driven low.

Parameters:
ix The device index, starting at 0. The routine will not check if this is a valid number.

Definition at line 282 of file sbbif0.c.

void Sbbi0NegSelectDevice ( ureg_t  ix  ) 

Select the device at a given negated chip select.

Enables the serial peripheral interface with the parameters previously set for the given device by Sbbi0SetMode() and Sbbi0SetSpeed(). Then the configured chip select line is driven low.

Parameters:
ix The device index, starting at 0. The routine will not check if this is a valid number.

Definition at line 298 of file sbbif0.c.

void Sbbi0NegDeselectDevice ( ureg_t  ix  ) 

Deselect the device at a given negated chip select.

The configured chip select line will be driven high.

Parameters:
ix The device index, starting at 0. The routine will not check if this is a valid number.

Definition at line 312 of file sbbif0.c.

uint8_t Sbbi0Byte ( uint8_t  data  ) 

Exchange a byte with the currently selected SPI device.

Parameters:
data Byte to transmit.
Returns:
Received byte.

Definition at line 324 of file sbbif0.c.

Referenced by Sbbi0Transact().

void Sbbi0Transact ( CONST void *  wdata,
void *  rdata,
size_t  len 
)

Exchange a specified number of bytes with the currently selected SPI device.

It is assumed, that the serial peripheral interface has been properly initialized by calling Sbbi0SetMode() and optionally Sbbi0SetSpeed().

Further it is assumed, that the chip select (if there is one) had been enabled by a previous call to Sbbi0SelectDevice() or Sbbi0NegSelectDevice().

Parameters:
wdata Pointer to the data to transmit.
rdata Pointer to a buffer that receives the data from the device. Can be set to NULL for transmit only. May also point to the tranmit buffer, in which case the transmitted bytes are replaced by the bytes received.

Definition at line 429 of file sbbif0.c.


© 2000-2007 by egnite Software GmbH - visit http://www.ethernut.de/