"Bit Bang" software SPI library for use with the TINIm400. This is a full featured SPI library for sending and receiving data. It supports 4 SPI_CLK polarity and phase modes, slave select with optional inversion and optional synching, 8 and 16 bit transfer modes, bit reordering and SPI_CLK delays.
Port pins used by this SPI library can be specified in spimacros.inc.
For detailed information on the DS80C400 please see the High-Speed Microcontroller User's Guide: DS80C400 Supplement.
Go to the source code of this file.
Defines | |
| #define | TINI400_SPI_VERSION 1 |
| #define | SPI_CKPOL_MASK 0x01 |
| CKPOL MASK. | |
| #define | SPI_CKPHA_MASK 0x02 |
| CKPHA MASK. | |
| #define | SPI_WORD_MASK 0x04 |
| Word mode MASK. | |
| #define | SPI_SKEW_MASK 0x08 |
| No Skew MASK. | |
| #define | SPI_USESS_MASK 0x10 |
| Use SS MASK. | |
| #define | SPI_SYNCHSS_MASK 0x20 |
| Synch SS MASK. | |
| #define | SPI_INVERTSS_MASK 0x40 |
| Invert SS MASK. | |
Functions | |
| void | spi_init (void) |
| Initalize the SPI library. | |
| int | spi_reverseBits (int length, int wordSize, unsigned char *dataptr) |
| Reverse bits in buffer. | |
| void | spi_xmit (unsigned char *dataptr, int length, unsigned char delay, unsigned char options) |
| Transmit SPI data. | |
| unsigned int | spi_version (void) |
| Returns the version number of this SPI library. | |
|
|
CKPHA MASK.
|
|
|
CKPOL MASK. The four SPI clock (SPI_CLK) modes supported by this library are defined by CKPHA and CKPOL. The CKPOL bit defines the idle state of the SPI clock, CKPOL = 0 forces SPI_CLK to idle low while CKPOL = 1 forces SPI_CLK to idle high. CKPHA changes the edge used to signal transfer of data. When CKPHA = 0 the first edge of SPI_CLK specifies when the slave and master should sample their input. With CKPHA = 1 the second edge of SPI_CLK specifies when to sample. When CKPHA = 1, the master and slave should present their data on their output during the first SPI_CLK edge, this allows the data sufficent hold time. When CKPHA = 0, data should become valid when the Slave Select (SS) line goes active. Note that most devices require the SS line to be used when CKPHA = 0 to allow proper timing while SS may be optional when CKPHA = 1.
|
|
|
Invert SS MASK. Most SPI devices expect the active state for SS to be low, but others require high as the active state.
|
|
|
No Skew MASK. To facilitate atomic transfers, interrupts may be disabled while transmiting.
|
|
|
Synch SS MASK. Some SPI devices expect the SS signal to go inactive after each word transfer in order to synchronize.
|
|
|
Use SS MASK. The SS signal is optional as it may not be required for all SPI setups.
|
|
|
Word mode MASK. Data is sent to the SPI library as a character array in data memory. When in 8 bit word mode these bytes will be transferred one at a time. In 16 bit word mode 2 bytes will be transferred but this operation will only consume 1 transfer of the number requested. Note that in this library, "word" may be 8 or 16 bits in length depending on the selected mode. Using this mask activates 16 bit word mode
|
|
|
Version number associated with this header file. Should be the same as the version number returned by the spi_version function.
|
|
|
Initalize the SPI library.
|
|
||||||||||||||||
|
Reverse bits in buffer. This function can be called to reverse the bits in the passed buffer. It reorders the based on the word mode 8 bit words or 16 bit words. This can be used to convert data for Least Significant Bit (LSB) transfers.
|
|
|
Returns the version number of this SPI library.
|
|
||||||||||||||||||||
|
Transmit SPI data. Transmits the data passed in over the SPI port, reads and returns any data read back.
|
| Copyright 2004 Dallas Semiconductor, Inc.. | Documentation generated by Doxygen. |